Files
microdao-daarion/gateway-bot/main.py
Apple ef3473db21 snapshot: NODE1 production state 2026-02-09
Complete snapshot of /opt/microdao-daarion/ from NODE1 (144.76.224.179).
This represents the actual running production code that has diverged
significantly from the previous main branch.

Key changes from old main:
- Gateway (http_api.py): expanded from ~40KB to 164KB with full agent support
- Router: new /v1/agents/{id}/infer endpoint with vision + DeepSeek routing
- Behavior Policy: SOWA v2.2 (3-level: FULL/ACK/SILENT)
- Agent Registry: config/agent_registry.yml as single source of truth
- 13 agents configured (was 3)
- Memory service integration
- CrewAI teams and roles

Excluded from snapshot: venv/, .env, data/, backups, .tgz archives

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-09 08:46:46 -08:00

80 lines
1.9 KiB
Python

"""
Bot Gateway Service
Entry point for Telegram/Discord webhook handling
"""
import logging
import argparse
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from .http_api import router as gateway_router
# 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=["*"],
)
# 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()