feat: realtime WebSocket layer for live events and streaming logs

- Backend: ConnectionManager, Redis-backed bus with in-process fallback,
  channel authorization, and typed emit helpers wired into workers
  (ai_runtime, sandbox_gateway), workforce/sandbox/billing/audit/error services.
- Frontend: single shared WS client with backoff + heartbeat, RealtimeProvider,
  useLiveChannel/useLiveEvent hooks, live indicators on task detail, manager
  chat, dashboard, traces, sandbox terminal, admin errors, and billing.
- Contracts: WsEvent/WsServerFrame/WsClientFrame types mirroring the port.

All 255 backend tests pass; web typecheck and build pass.
This commit is contained in:
mjalmoudy94
2026-10-13 12:56:36 +03:30
parent afdef4b444
commit f1e5df29ce
31 changed files with 2981 additions and 28 deletions
@@ -42,5 +42,22 @@ async def readiness(session: AsyncSession = Depends(get_session)) -> dict:
"sandbox": settings.sandbox_provider,
"payment": settings.payment_provider,
}
# Live-feed visibility: how many browser sockets this process is serving,
# and whether the cross-process relay (Redis) is connected. An operator
# wondering "is realtime working?" should not have to read the logs.
try:
from app.interfaces.realtime.bus import get_bus
from app.interfaces.realtime.router import realtime_manager
manager = realtime_manager()
checks["realtime"] = {
"connections": manager.connection_count,
"channels": manager.channel_count,
"redis_relay": "connected" if get_bus().redis_healthy else "in_process_only",
}
except Exception: # noqa: BLE001 - health must answer regardless
checks["realtime"] = "unavailable"
healthy = checks.get("database") == "ok"
return {"status": "ok" if healthy else "degraded", "checks": checks}