sync wire fix (bare array + string delivery_id), WS delivery acks, dedup, terminal closes — 1.0.21 - #1
Merged
Merged
Conversation
…dup, terminal closes — 1.0.21
The /v1/messages/sync path never matched production: the server returns a
bare JSON array with opaque string delivery_id cursors, but the SDK typed
{envelopes: [{delivery_id: number}]} — so the realtime client's offline
drain read .envelopes off an array, threw, and the rejection was swallowed
by a void call. Every reconnect drain silently delivered zero rows and
never acked. Fixed against the real wire (reference: agentchat-coding-agents
core/src/lib/wire.ts), with a dedicated wire-contract test suite so CI can
never be green on the wrong shape again.
- sync() -> SyncEnvelope[] (breaking type change; runtime was already
broken, migration notes in CHANGELOG); syncAck(string) -> {acked}
- drain: cursor pagination, positional ack of the settled prefix only,
clean-prefix stop on invalid rows, handler-throw => no ack, gap-buffer
rows never acked before dispatch, errors surface via onError
- WS delivery acks (capability-negotiated per docs/realtime-delivery-ack.md):
HELLO advertises ['ack']; ack after handlers settle; dormant against
servers that don't echo the capability
- bounded message-id dedup LRU (default 2048) across live+drain
- close codes 1008/4401/4403 are terminal: no infinite reconnect on
revoked keys; final ConnectionError via onError
- paginator audit vs live routes: contacts/agents keys match, no drift
107 tests (was 86), type-check + build clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes the broken
/v1/messages/syncwire contract — production returns a bare JSON array with opaque stringdelivery_idcursors, but the SDK typed{envelopes: [{delivery_id: number}]}, making the realtime client's post-reconnect offline drain a silent zero-row no-op (TypeError swallowed by avoidfire-and-forget). This has been broken in every published version; the hand-rolled workaround inagentchat-coding-agents/core/src/lib/wire.tsis the reference this now matches.Also ships the client half of the WS delivery-ack protocol (server repo
docs/realtime-delivery-ack.md), closing the delivered-on-socket-write at-most-once gap once the server side deploys.Changes
sync()→SyncEnvelope[](breaking type change — runtime was already broken; migration notes in CHANGELOG);syncAck(string)→{acked}onError['ack']; fully dormant against today's server (no capability echo ⇒ zero new frames)contacts/agentskeys match — no driftVerification
tsc --noEmitclean, tsup build clean (ESM+CJS+DTS), version 1.0.21 build-injection confirmedRelease
Not published — tag + OIDC pipeline per RELEASING.md when ready.