import { type BridgeResult } from './protocol.js'; /** Minimal structural WebSocket — satisfied by both the browser global and `ws`. */ export interface WebSocketLike { readyState: number; send(data: string): void; close(): void; onopen: ((ev?: unknown) => void) | null; onmessage: ((ev: { data: unknown; }) => void) | null; onclose: ((ev?: unknown) => void) | null; onerror: ((ev?: unknown) => void) | null; } export interface WebSocketCtor { new (url: string): WebSocketLike; } /** The app-supplied registry the tab executes commands against. */ export interface BridgeRegistry { manifest: unknown; execute: (command: string, params: unknown) => Promise; } export interface BridgeConfirmRequest { id: string; command: string; params: unknown; summary: string; /** Executes the command and reports the result upstream. */ accept: () => Promise; /** Reports the refusal without executing. */ decline: () => void; } export interface BridgeClientOptions { url: string; thread: string; apiKey: string; registry: BridgeRegistry; /** Recomputed on every sendContext, never cached. */ describeView?: () => unknown; /** * Render the confirm chip. Without this hook, confirm requests are * auto-declined — export can never silently execute. */ onConfirmRequest?: (req: BridgeConfirmRequest) => void; onStateChange?: (state: 'connecting' | 'open' | 'closed') => void; maxBackoffMs?: number; WebSocket?: WebSocketCtor; } export declare class BridgeClient { private readonly opts; private readonly WebSocketImpl; private readonly maxBackoffMs; private backoffMs; private ws; private closed; registered: boolean; constructor(opts: BridgeClientOptions); connect(): this; /** Piggyback fresh view context on a user chat turn. */ sendContext(selection?: unknown): void; close(): void; private onMessage; private execute; private send; } //# sourceMappingURL=client.d.ts.map