99 lines
3.6 KiB
Python
99 lines
3.6 KiB
Python
"""Entrypoint for running HomeAgent."""
|
|
|
|
import argparse
|
|
import asyncio
|
|
import logging
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add src to python path
|
|
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
|
|
|
from homeagent.bot.telegram_app import TelegramAgentApp
|
|
from homeagent.config import get_settings
|
|
|
|
|
|
def setup_logging(level: str = "INFO") -> None:
|
|
logging.basicConfig(
|
|
level=getattr(logging, level.upper(), logging.INFO),
|
|
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
datefmt="%Y-%m-%d %H:%M:%S",
|
|
)
|
|
|
|
|
|
def check_configuration() -> None:
|
|
"""Validate settings, extensions, and skills without running the Telegram loop."""
|
|
settings = get_settings()
|
|
print("=" * 60)
|
|
print(" 🛠️ HomeAgent Configuration Check")
|
|
print("=" * 60)
|
|
print(f"Telegram Bot Token: {'[SET]' if settings.TELEGRAM_BOT_TOKEN.get_secret_value() else '[MISSING ❌]'}")
|
|
print(f"Allowed User IDs (Whitelist): {settings.ALLOWED_TELEGRAM_USER_IDS or '[EMPTY ⚠️ - bot will drop all messages]'}")
|
|
print(f"Active LLM Provider: {settings.get_active_provider_name()} ({settings.LLM_PROVIDER})")
|
|
|
|
if settings.LLM_PROVIDER == "deepseek":
|
|
ds_key = settings.DEEPSEEK_API_KEY or settings.OPENAI_API_KEY
|
|
print(f"DeepSeek API Key: {'[SET]' if ds_key and ds_key.get_secret_value() else '[MISSING ❌]'}")
|
|
print(f"DeepSeek Base URL: {settings.DEEPSEEK_BASE_URL}")
|
|
elif settings.LLM_PROVIDER == "openai":
|
|
oa_key = settings.OPENAI_API_KEY
|
|
print(f"OpenAI API Key: {'[SET]' if oa_key and oa_key.get_secret_value() else '[MISSING ❌]'}")
|
|
print(f"OpenAI Base URL: {settings.OPENAI_BASE_URL}")
|
|
else:
|
|
print(f"Gemini API Key: {'[SET]' if settings.GEMINI_API_KEY.get_secret_value() else '[MISSING ❌]'}")
|
|
|
|
print(f"Orchestrator Model: {settings.get_active_model()}")
|
|
print(f"Subagent Model (Fast): {settings.get_active_subagent_model()}")
|
|
print(f"Gitea Enabled: {settings.GITEA_ENABLED} (URL: {settings.GITEA_URL})")
|
|
print(f"Jira Enabled: {settings.JIRA_ENABLED} (URL: {settings.JIRA_URL or 'not set'})")
|
|
print(f"Google Calendar Enabled: {settings.GOOGLE_CALENDAR_ENABLED} (Auth type: {settings.GOOGLE_AUTH_TYPE})")
|
|
|
|
app = TelegramAgentApp(settings=settings)
|
|
tools = app.registry.list_tools()
|
|
skills = app.skill_manager.list_skills()
|
|
|
|
print(f"\n📦 Registered Tools ({len(tools)}):")
|
|
for t in tools:
|
|
print(f" - {t.name}: {t.description}")
|
|
|
|
print(f"\n🎯 Loaded Skills ({len(skills)}):")
|
|
for s in skills:
|
|
print(f" - {s.name} ({s.title}): triggers={s.triggers}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("✅ Configuration and component check complete!")
|
|
print("=" * 60)
|
|
|
|
|
|
async def main() -> None:
|
|
parser = argparse.ArgumentParser(description="HomeAgent - Telegram AI Agent with Jira and Calendar")
|
|
parser.add_argument(
|
|
"--check-config",
|
|
action="store_true",
|
|
help="Check configuration and print registered tools and skills without starting the bot",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
settings = get_settings()
|
|
setup_logging(settings.LOG_LEVEL)
|
|
|
|
if args.check_config:
|
|
check_configuration()
|
|
return
|
|
|
|
token = settings.TELEGRAM_BOT_TOKEN.get_secret_value()
|
|
if not token:
|
|
print("\n❌ Error: TELEGRAM_BOT_TOKEN is not set in .env file!")
|
|
print("Please create .env (use .env.example as a template) and add your bot token.")
|
|
sys.exit(1)
|
|
|
|
app = TelegramAgentApp(settings=settings)
|
|
await app.start()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
asyncio.run(main())
|
|
except (KeyboardInterrupt, SystemExit):
|
|
logging.info("HomeAgent stopped gracefully.")
|