import type { RelayInbound, RelayOutbound } from "./terminal-session.ts"; /** The minimal socket surface the client drives (a browser `WebSocket` adapts to this). */ export interface RawSocket { /** Send one binary frame. */ send(bytes: Uint8Array): void; /** Close the socket. */ close(): void; /** Register the inbound-binary-frame listener. */ onMessage(listener: (bytes: Uint8Array) => void): void; /** Register the open listener (fired once per successful connect). */ onOpen(listener: () => void): void; /** Register the close listener (fired once when the socket drops). */ onClose(listener: () => void): void; } /** Opens a fresh socket. Called once per (re)connect. */ export type SocketFactory = () => RawSocket; /** Schedules a reconnect attempt. Injected so tests can run it synchronously. */ export type Scheduler = (run: () => void) => void; export interface RelayChannelClientOptions { /** Opens a fresh socket for each (re)connect. */ readonly connect: SocketFactory; /** Receives every inbound `relay`-family payload (data chunk or resume ack). */ readonly onRelay: (message: RelayInbound) => void; /** Fired on every (re)connect — the caller re-attaches the session here. */ readonly onOpen?: () => void; /** Fired when the socket drops (before a reconnect is scheduled). */ readonly onClose?: () => void; /** Notified of a decode/dispatch error on an inbound frame. */ readonly onError?: (err: unknown) => void; /** Reconnect scheduler. Default `setTimeout(run, 0)`. */ readonly schedule?: Scheduler; /** Reconnect automatically on close. Default true. */ readonly autoReconnect?: boolean; } /** * Manages one relay socket with automatic resume-on-reconnect. Construct once * per drill-in and pair with a {@link TerminalSession}: wire the session's * `send` to {@link sendRelay}, feed {@link RelayChannelClientOptions.onRelay} to * `session.handle`, and call `session.attach()` from `onOpen`. */ export declare class RelayChannelClient { #private; constructor(options: RelayChannelClientOptions); /** True once {@link close} has been called (no further reconnects). */ get isClosed(): boolean; /** Open the first socket and wire its lifecycle. Idempotent while connected. */ open(): void; /** Encode and send one outbound relay message on the control lane. */ sendRelay(message: RelayOutbound): void; /** Close for good — no reconnect will follow. */ close(): void; }