New router intelligence modules (26 files): alert_ingest/store, audit_store, architecture_pressure, backlog_generator/store, cost_analyzer, data_governance, dependency_scanner, drift_analyzer, incident_* (5 files), llm_enrichment, platform_priority_digest, provider_budget, release_check_runner, risk_* (6 files), signature_state_store, sofiia_auto_router, tool_governance New services: - sofiia-console: Dockerfile, adapters/, monitor/nodes/ops/voice modules, launchd, react static - memory-service: integration_endpoints, integrations, voice_endpoints, static UI - aurora-service: full app suite (analysis, job_store, orchestrator, reporting, schemas, subagents) - sofiia-supervisor: new supervisor service - aistalk-bridge-lite: Telegram bridge lite - calendar-service: CalDAV calendar service with reminders - mlx-stt-service / mlx-tts-service: Apple Silicon speech services - binance-bot-monitor: market monitor service - node-worker: STT/TTS memory providers New tools (9): agent_email, browser_tool, contract_tool, observability_tool, oncall_tool, pr_reviewer_tool, repo_tool, safe_code_executor, secure_vault New crews: agromatrix_crew (10 modules: depth_classifier, doc_facts, doc_focus, farm_state, light_reply, llm_factory, memory_manager, proactivity, reflection_engine, session_context, style_adapter, telemetry) Tests: 85+ test files for all new modules Made-with: Cursor
75 lines
1.8 KiB
Python
75 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
import time
|
|
from typing import Any, Dict, List
|
|
|
|
from fastapi import FastAPI, File, Form, UploadFile
|
|
|
|
app = FastAPI(title="aistalk-bridge-lite", version="0.1.0")
|
|
|
|
_MAX_EVENTS = 200
|
|
_events: List[Dict[str, Any]] = []
|
|
|
|
|
|
def _push(item: Dict[str, Any]) -> None:
|
|
_events.append(item)
|
|
if len(_events) > _MAX_EVENTS:
|
|
del _events[: len(_events) - _MAX_EVENTS]
|
|
|
|
|
|
@app.get("/healthz")
|
|
async def healthz() -> Dict[str, Any]:
|
|
return {"status": "ok", "service": "aistalk-bridge-lite", "events": len(_events)}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health() -> Dict[str, Any]:
|
|
return await healthz()
|
|
|
|
|
|
@app.get("/api/health")
|
|
async def api_health() -> Dict[str, Any]:
|
|
return await healthz()
|
|
|
|
|
|
@app.post("/api/events")
|
|
@app.post("/events")
|
|
@app.post("/v1/events")
|
|
async def accept_events(payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
_push({"ts": time.time(), "kind": "event", "payload": payload})
|
|
return {"ok": True, "accepted": "event"}
|
|
|
|
|
|
@app.post("/api/text")
|
|
@app.post("/text")
|
|
@app.post("/v1/text")
|
|
async def accept_text(payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
_push({"ts": time.time(), "kind": "text", "payload": payload})
|
|
return {"ok": True, "accepted": "text"}
|
|
|
|
|
|
@app.post("/api/audio")
|
|
@app.post("/audio")
|
|
@app.post("/v1/audio")
|
|
async def accept_audio(
|
|
audio: UploadFile = File(...),
|
|
meta: str = Form(""),
|
|
) -> Dict[str, Any]:
|
|
raw = await audio.read()
|
|
_push(
|
|
{
|
|
"ts": time.time(),
|
|
"kind": "audio",
|
|
"bytes": len(raw),
|
|
"mime": audio.content_type or "application/octet-stream",
|
|
"meta": meta[:2000],
|
|
}
|
|
)
|
|
return {"ok": True, "accepted": "audio", "bytes": len(raw)}
|
|
|
|
|
|
@app.get("/api/recent")
|
|
async def recent(limit: int = 20) -> Dict[str, Any]:
|
|
n = max(1, min(int(limit), 100))
|
|
return {"ok": True, "items": _events[-n:]}
|