Files
api/services/chat
Roberto Musso 90018af311 feat: add WS Gateway and Chat Service (Step 2)
WS Gateway:
- WebSocket lifecycle handler with RS256 JWT auth
- Redis bridge: device registry, frame publishing, tool_result routing
- Inbound routing: tool_result→LPUSH, home/floating→chat pub/sub
- Outbound: subscribes to ws:out:{user_id}, forwards to Electron
- Single-worker Dockerfile (long-lived WS connections)

Chat Service:
- Redis consumer: subscribes to chat:request:* pattern
- Redis-based ws_context: tool_call→publish, BRPOP tool_result (30s timeout)
- deep_agent: single-agent runner with home/floating/stream variants
- memory_middleware: core/associative/episodic/proactive memory with Fernet
- Domain agents: task (8 tools), note (5), project (6), timeline (4)
- LLM factory via LiteLLM (100+ providers)
- Output formatter (StreamFormatter)
- POST /chat REST fallback with Traefik header auth
- Multi-worker Dockerfile with 120s timeout for LLM calls
2026-03-22 01:20:11 +01:00
..

Chat Service

Owns: deep_agent (home + floating chat), memory middleware, domain agents (task, note, project, timeline), LLM orchestration.

Tables owned

  • memory_core
  • memory_associative
  • memory_episodic
  • memory_proactive

Tables read (cross-service)

  • users (for encryption_key — memory decryption)

Endpoints

  • POST /chat (REST fallback)

Redis channels

  • Subscribe: chat:request:{user_id}
  • Publish: ws:out:{user_id} (stream frames + tool calls)
  • BRPOP: tool:result:{call_id} (30s timeout)