/** * Internal transport interface used by `MessagingClient`. Abstracts the * WebSocket, SSE-fallback, and WebTransport lanes behind a single * lifecycle surface so the client can pick a lane at init time without * the rest of the SDK caring which one is in use. * * Public consumers of the SDK continue to use the standalone primitives * (`SseTransport`, `WebTransportTransport`); this interface is an internal * adapter target only. */ export interface MessagingTransportClose { code: number; reason: string; } export interface MessagingTransportEvents { onOpen(handler: () => void): void; onFrame(handler: (bytes: Uint8Array) => void): void; onClose(handler: (info: MessagingTransportClose) => void): void; onError(handler: (err: Error) => void): void; } export interface MessagingTransport extends MessagingTransportEvents { /** Human-readable transport name, mirrors the `/api/info.transports` token. */ readonly name: 'ws' | 'sse' | 'wt'; /** Open the underlying stream. Resolves once frames can be sent and received. */ connect(): Promise; /** Send a raw protobuf frame (no framing of its own). */ send(bytes: Uint8Array): void; /** True if the transport can accept `send()` right now. */ isOpen(): boolean; /** Close the stream. Idempotent. `code`/`reason` are best-effort hints. */ close(code?: number, reason?: string): void; } export type MessagingTransportSelection = 'ws' | 'sse' | 'wt' | 'auto';