import type { HubClientMessage, HubRequest, HubResponse, InitMessage } from './protocol.ts';
export type ConnectionState = 'connected' | 'disconnected' | 'reconnecting' | 'closed';
export declare class HubClient {
    private ws;
    private reconnectAttempts;
    private reconnectTimer;
    private intentionallyClosed;
    private lastConnectUrl;
    private queue;
    private connectionStateListeners;
    private pending;
    connectionState: ConnectionState;
    onConnectionStateChange?: (state: ConnectionState) => void;
    onBeforeReconnect?: () => Promise<void>;
    onInitMessage?: (initMessage: InitMessage) => void;
    /** Called when an unsolicited server message arrives (broadcast, presence, hydration). */
    onServerMessage?: (message: Record<string, unknown>) => void;
    /** Hub auth token from the CLI environment. */
    apiKey: string | null;
    private setConnectionState;
    private buildWebSocketUrl;
    private enqueue;
    private sendRequestNow;
    private sendFireAndForgetNow;
    private flushQueue;
    private handleUnexpectedClose;
    private clearReconnectTimer;
    private rejectQueuedRequests;
    private startReconnectLoop;
    private connectInternal;
    connect(url: string, opts?: {
        sessionId?: string;
        role?: string;
        origin?: string;
    }): Promise<InitMessage>;
    private waitForConnection;
    nextId(): string;
    send(request: HubRequest): Promise<HubResponse>;
    sendNoWait(message: HubClientMessage | Record<string, unknown>): void;
    waitUntilConnected(timeoutMs?: number): Promise<void>;
    close(): void;
    get connected(): boolean;
}
//# sourceMappingURL=client.d.ts.map