"""Entry point: python -m cheddahbot""" import logging import sys from .config import load_config from .db import Database from .llm import LLMAdapter from .agent import Agent from .ui import create_ui logging.basicConfig( level=logging.INFO, format="%(asctime)s [%(name)s] %(levelname)s: %(message)s", datefmt="%H:%M:%S", ) log = logging.getLogger("cheddahbot") def main(): log.info("Loading configuration...") config = load_config() log.info("Initializing database...") db = Database(config.db_path) log.info("Chat brain model: %s", config.chat_model) log.info("Execution brain model: %s (Claude Code CLI)", config.default_model) llm = LLMAdapter( default_model=config.chat_model, openrouter_key=config.openrouter_api_key, ollama_url=config.ollama_url, lmstudio_url=config.lmstudio_url, ) if llm.is_execution_brain_available(): log.info("Execution brain: Claude Code CLI found in PATH") else: log.warning("Execution brain: Claude Code CLI NOT found — heartbeat/scheduler tasks will fail") log.info("Creating agent...") agent = Agent(config, db, llm) # Phase 2+: Memory system try: from .memory import MemorySystem log.info("Initializing memory system...") memory = MemorySystem(config, db) agent.set_memory(memory) except Exception as e: log.warning("Memory system not available: %s", e) # Phase 3+: Tool system try: from .tools import ToolRegistry log.info("Initializing tool system...") tools = ToolRegistry(config, db, agent) agent.set_tools(tools) except Exception as e: log.warning("Tool system not available: %s", e) # Phase 3+: Scheduler try: from .scheduler import Scheduler log.info("Starting scheduler...") scheduler = Scheduler(config, db, agent) scheduler.start() except Exception as e: log.warning("Scheduler not available: %s", e) log.info("Launching Gradio UI on %s:%s...", config.host, config.port) app, css = create_ui(agent, config, llm) app.launch( server_name=config.host, server_port=config.port, pwa=True, show_error=True, css=css, ) if __name__ == "__main__": main()