Skip to content

Speak session stream protocol v2#64

Merged
hbrooks merged 1 commit into
mainfrom
stream-protocol-v2
Jul 21, 2026
Merged

Speak session stream protocol v2#64
hbrooks merged 1 commit into
mainfrom
stream-protocol-v2

Conversation

@hbrooks

@hbrooks hbrooks commented Jul 21, 2026

Copy link
Copy Markdown
Member

Ports the CLI to v2 of the Ellipsis session stream — the server now sends raw session records over the WebSocket and the client owns all rendering.

  • ws.ts: sends the required ?protocol=2 handshake and parses the v2 frames (snapshot / records_append / messages / session / delta / heartbeat / done / error). The resume cursor advances ONLY on records_append feed_seq; done outcomes derive their status word from the last session frame; close 1002 joins 1003 as REST-polling fallbacks, 1013 (over capacity) retries with backoff. Unknown frame types/kinds are ignored, so additive server changes never break this client.
  • connect: status + live cost come from session frames; the open inbox slice (messages frames) drives the queued region, and local chips now retire by the created message's id (POST /v1/sessions/{id}/messages returns the created SessionMessage) plus the transcript user-echo back-reference — no more postSeq bookkeeping. The resume cursor seeds from the already-rendered transcript so reattach never replays what's on screen.
  • --watch: renders the pushed raw records client-side with the same shaping connect uses; --json emits the v2 frames as NDJSON.
  • sendSessionMessage returns the created SessionMessage and supports an idempotency key for retry-safe sends.

Previously released binaries keep working against a v2 backend via their existing close-1003 → REST-polling fallback; this should release alongside the backend cutover.

Verified: 246 tests green (ws suite updated to v2 semantics), tsc --noEmit clean, bun --compile binary builds and prints its version.

Minimal v2 port (documents/eng/SESSION_STREAM_PROTOCOL.md PR 1, CLI half): ws.ts sends the required ?protocol=2 handshake and the v2 frame vocabulary (snapshot/records_append/messages/session/delta/heartbeat/done/error); the resume cursor advances only on records_append feed_seq; done outcomes derive status from the last session frame. connect keys queued chips on the created SessionMessage id (POST /messages returns it now) and reads status/cost from session frames; watch renders pushed raw records client-side; sendSessionMessage supports an idempotency key. Old binaries keep working via their 1003 REST-polling fallback.
@hbrooks
hbrooks merged commit ae5f798 into main Jul 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant