feat(chat-runtime): tRPC router over commands + WebSocket sink adapter
Merged
SA
3mo ago+547+547+012345678901234567890123456789-0-0-0123456789
Stacked on #6167. The package now owns its transport surface: createChatRouter(runtime) (own initTRPC, procedures close over the runtime, inputs are exactly the protocol schemas, ChatRouter type exported for end-to-end inference) + createWsSink turning any structural WebSocket into a runtime Sink. Host-service's future mount = createChatRouter(runtime) at a path + wsSink per socket. 7 new tests (57 total green).
https://claude.ai/code/session_01XRFCEPsfmJHu2SenDKYJ2h
Summary by cubic
Adds a tRPC router over chat commands and a WebSocket sink adapter for streaming envelopes. The router resolves cwd on the host and returns typed tRPC errors for common failures.
-
New Features
- Router:
createChatRouter(runtime, { resolveCwd })exposes 8 protocol commands as tRPC procedures withzodinputs from@superset/chat/protocol; exportsChatRouter,ChatRouterOptions, andcreateChatCallerFactory. - Host-resolved cwd:
createSessioncallsresolveCwd(workspaceId); clients never sendcwd. - Typed errors: unknown harness →
BAD_REQUEST; not-running sessions →NOT_FOUND/CONFLICT; invalid inputs rejected byzod. createWsSink(socket)adapts any structural WebSocket to the runtimeSink, JSON-serializes envelopes, chains/restoresonclose, closes on send error, and is idempotent on peer/host close; exportsWsSinkSocket.
- Router:
-
Dependencies
- Added
@trpc/server@11.16.0topackages/chat-runtime.
- Added