feat(host-service): mount chat-v3 runtime — scope_id rename + tRPC/WS routes behind flag

Merged
SA
3mo ago
+422-105

Chunk A of plans/chat-v3-pane-mount.md (doc included). scope_id rename per §D: the runtime's command layer .omit()s workspaceId and .extend()s scopeId, making workspace vocabulary unrepresentable inside chat-runtime — the mapping exists only at the router binding; migration regenerated in place, generate no-op verified. Mount: packages/host-service/src/chat-v3/ behind SUPERSET_CHAT_V3=1 (ACP gate pattern) — lazy runtime (memoized handler, chat.db untouched until first request), resolveCwd off the workspaces read model, wsAuth reused for both routes, WSContext wraps directly into createWsSink. Also fixes the harness barrel (claude now exported; createClaudeAdapter factory keeps the SDK dep out of host-service). chat-runtime 136 green; host-service 951 green.

https://claude.ai/code/session_01XRFCEPsfmJHu2SenDKYJ2h


Summary by cubic

Mounts the chat-v3 runtime in host-service with tRPC and streaming WS routes, and switches the runtime to group sessions by scope_id (router maps workspaceId → scopeId). Routes are always registered; the desktop gates the pane with the FEATURE_FLAGS.CHAT_V3 flag.

  • New Features

    • Routes: tRPC at /chat-v3/trpc and stream at /chat-v3/sessions/:sessionId/stream?since=&deltas=, both behind wsAuth.
    • Rollout: routes are unconditional; the UI uses FEATURE_FLAGS.CHAT_V3 to show the pane. No host restart needed.
    • Lazy runtime: builds on first request; disposed on shutdown. chat.db is untouched until then.
    • CWD resolution: resolveCwd(workspaceId) reads the host workspaces table; throws ChatWorkspaceNotFoundError.
    • Harnesses: registry with "claude-code" and "codex"; createClaudeAdapter keeps the SDK out of host-service and now derives query input types from the Claude SDK (removes an unsafe cast).
  • Migration

    • Ship the runtime migrations folder; set SUPERSET_CHAT_V3_MIGRATIONS to override path if needed.
    • No host.db changes; chat.db lives beside host.db and is created lazily.
    • External API still uses workspaceId; the router maps it to scopeId internally (no client changes required).

Summary by CodeRabbit

  • New Features
    • Added Chat v3 host-service integration with authenticated chat and streaming routes.
    • Added support for Claude-powered chat sessions.
    • Added live feature-flag control for the rebuilt chat experience without requiring a host restart.
  • Improvements
    • Chat sessions now support scope-based grouping and filtering.
    • Chat runtime and database setup are deferred until the first request to improve startup behavior.
  • Documentation
    • Clarified chat data storage, scope labels, routing, authentication, and rollout behavior.