- Router Core with rule-based routing (1530 lines) - DevTools Backend (file ops, test execution) (393 lines) - CrewAI Orchestrator (4 workflows, 12 agents) (358 lines) - Bot Gateway (Telegram/Discord) (321 lines) - RBAC Service (role resolution) (272 lines) - Structured logging (utils/logger.py) - Docker deployment (docker-compose.yml) - Comprehensive documentation (57KB) - Test suites (41 tests, 95% coverage) - Phase 4 roadmap & ecosystem integration plans Production-ready infrastructure for DAARION microDAOs.
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
"""
|
|
DAGI Router Client
|
|
Sends requests to DAGI Router from Bot Gateway
|
|
"""
|
|
import logging
|
|
import httpx
|
|
from typing import Dict, Any
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Router configuration
|
|
ROUTER_URL = "http://127.0.0.1:9102/route"
|
|
ROUTER_TIMEOUT = 30.0
|
|
|
|
|
|
async def send_to_router(body: Dict[str, Any]) -> Dict[str, Any]:
|
|
"""
|
|
Send request to DAGI Router.
|
|
|
|
Args:
|
|
body: Request payload with mode, message, dao_id, etc.
|
|
|
|
Returns:
|
|
Router response as dict
|
|
|
|
Raises:
|
|
httpx.HTTPError: if router request fails
|
|
"""
|
|
logger.info(f"Sending to Router: mode={body.get('mode')}, dao_id={body.get('dao_id')}")
|
|
|
|
try:
|
|
async with httpx.AsyncClient(timeout=ROUTER_TIMEOUT) as client:
|
|
response = await client.post(ROUTER_URL, json=body)
|
|
response.raise_for_status()
|
|
|
|
result = response.json()
|
|
logger.info(f"Router response: ok={result.get('ok')}")
|
|
return result
|
|
|
|
except httpx.HTTPError as e:
|
|
logger.error(f"Router request failed: {e}")
|
|
raise
|