Transport abstraction implemented by concrete client transports such as WebSocket or SSE adapters.
In the thread-centric protocol, transports are bound to a specific thread at construction time — the thread ID is part of the connection URL.
interface TransportAdapterThread ID this transport is bound to.
Shuts down the transport and releases any underlying resources.
Streams incoming protocol messages from the remote peer. Used by WebSocket transports where all events share one connection.
Opens the underlying connection (e.g. WebSocket handshake). For HTTP/SSE transports this is a no-op.
Opens an independent filtered SSE event stream.
Each call creates a new server connection with the given filter.
Returns undefined when the transport does not support per-subscription
streams (e.g. WebSocket), in which case the caller should fall back to
command-based subscriptions over events.
Replay contract. Implementations MUST buffer events emitted for
the thread/run and replay them through every newly-opened stream
whose filter matches. The SDK's shared-stream rotation relies on
this: when a subscription's filter widens the union, the SDK opens
a fresh stream and expects to receive the run's full history from
seq=0 (deduplication is handled client-side via event_id). The
SDK also defers the open until after run.start has committed the
thread server-side to avoid a 404: Thread not found, which means
events emitted during that window MUST be delivered to the late
opener. The protocol v2 server implements this via a bounded
per-run replay buffer; custom adapters should mirror that.
Sends a command and optionally returns an immediate response.