## Agents Added - Alateya: R&D, biotech, innovations - Clan (Spirit): Community spirit agent - Eonarch: Consciousness evolution agent ## Changes - docker-compose.node1.yml: Added tokens for all 3 new agents - gateway-bot/http_api.py: Added configs and webhook endpoints - gateway-bot/clan_prompt.txt: New prompt file - gateway-bot/eonarch_prompt.txt: New prompt file ## Fixes - Fixed ROUTER_URL from :9102 to :8000 (internal container port) - All 9 Telegram agents now working ## Documentation - Created PROJECT-MASTER-INDEX.md - single entry point - Added various status documents and scripts Tokens configured: - Helion, NUTRA, Agromatrix (existing) - Alateya, Clan, Eonarch (new) - Druid, GreenFood, DAARWIZZ (configured)
97 lines
2.6 KiB
Python
97 lines
2.6 KiB
Python
"""
|
|
"""Bot Gateway Service
|
|
Entry point for Telegram/Discord webhook handling
|
|
"""
|
|
import logging
|
|
import argparse
|
|
import asyncio
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
import uvicorn
|
|
|
|
from .http_api import router as gateway_router
|
|
from .telegram_history_recovery import auto_recover_on_startup_all_agents
|
|
|
|
# Configure logging
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s"
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
"""Create FastAPI application"""
|
|
app = FastAPI(
|
|
title="Bot Gateway",
|
|
version="1.0.0",
|
|
description="Gateway service for Telegram/Discord bots → DAGI Router"
|
|
)
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Startup event: auto-recover Telegram history
|
|
@app.on_event("startup")
|
|
async def startup_event():
|
|
"""Run on application startup"""
|
|
logger.info("🚀 Bot Gateway startup initiated")
|
|
|
|
# Auto-recover Telegram history for all agents
|
|
try:
|
|
logger.info("📊 Starting automatic Telegram history check...")
|
|
result = await auto_recover_on_startup_all_agents()
|
|
logger.info(f"✅ Telegram history check completed: {result.get('status')}")
|
|
except Exception as e:
|
|
logger.error(f"❌ Failed to run history recovery on startup: {e}")
|
|
# Don't block startup if recovery fails
|
|
|
|
# Include gateway routes
|
|
app.include_router(gateway_router, prefix="", tags=["gateway"])
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"service": "bot-gateway",
|
|
"version": "1.0.0",
|
|
"endpoints": [
|
|
"POST /telegram/webhook",
|
|
"POST /discord/webhook",
|
|
"GET /health"
|
|
]
|
|
}
|
|
|
|
return app
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Bot Gateway Service")
|
|
parser.add_argument("--host", default="127.0.0.1", help="Host to bind to")
|
|
parser.add_argument("--port", type=int, default=9300, help="Port to bind to")
|
|
parser.add_argument("--reload", action="store_true", help="Enable auto-reload")
|
|
|
|
args = parser.parse_args()
|
|
|
|
logger.info(f"Starting Bot Gateway on {args.host}:{args.port}")
|
|
|
|
app = create_app()
|
|
|
|
uvicorn.run(
|
|
app,
|
|
host=args.host,
|
|
port=args.port,
|
|
reload=args.reload,
|
|
log_level="info"
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|