Add typed websocket push envelopes with ordered sequence numbers,
structured decode diagnostics, and a client transport state machine.
On the server, route pushes through a shared push bus, gate welcome
delivery on explicit readiness barriers, and make keybindings startup
an explicit runtime with start/ready lifecycle.
Fix the flaky keybindings watcher test on Linux CI:
- Subscribe eagerly via PubSub.subscribe instead of lazy
Stream.fromPubSub to avoid missing events before the fiber
is scheduled.
- Replace the hand-rolled Effect.sleep polling loop with
fs.watchFile (Node's built-in stat-based poller on libuv
timers) so file change detection is reliable regardless of
Effect fiber scheduling pressure.
Add orchestration runtime receipts for checkpoint baseline capture,
checkpoint diff finalization, and turn quiescence, then update the
integration harness/tests to wait on those receipts instead of
timing-sensitive polling.
Use DrainableWorker for queue-based reactors so unit tests can
deterministically drain() instead of sleeping.
Adopt idiomatic Effect patterns: Effect.ignoreCause({ log: true })
for log-and-ignore error handling, Effect.tapCause for side-effecting
on errors before ignoring.
1.8 KiB
Provider architecture
The web app communicates with the server via WebSocket using a simple JSON-RPC-style protocol:
- Request/Response:
{ id, method, params }→{ id, result }or{ id, error } - Push events: typed envelopes with
channel,sequence(monotonic per connection), and channel-specificdata
Push channels: server.welcome, server.configUpdated, terminal.event, orchestration.domainEvent. Payloads are schema-validated at the transport boundary (wsTransport.ts). Decode failures produce structured WsDecodeDiagnostic with code, reason, and path info.
Methods mirror the NativeApi interface defined in @t3tools/contracts:
providers.startSession,providers.sendTurn,providers.interruptTurnproviders.respondToRequest,providers.stopSessionshell.openInEditor,server.getConfig
Codex is the only implemented provider. claudeCode is reserved in contracts/UI.
Client transport
wsTransport.ts manages connection state: connecting → open → reconnecting → closed → disposed. Outbound requests are queued while disconnected and flushed on reconnect. Inbound pushes are decoded and validated at the boundary, then cached per channel. Subscribers can opt into replayLatest to receive the last push on subscribe.
Server-side orchestration layers
Provider runtime events flow through queue-based workers:
- ProviderRuntimeIngestion — consumes provider runtime streams, emits orchestration commands
- ProviderCommandReactor — reacts to orchestration intent events, dispatches provider calls
- CheckpointReactor — captures git checkpoints on turn start/complete, publishes runtime receipts
All three use DrainableWorker internally and expose drain() for deterministic test synchronization.