/** * WebSocket client with reconnection and request/response correlation. * Connects to claw-messenger server with API key auth. * * Uses the `ws` npm package instead of the native WebSocket to avoid * Node 22+ HTTP/2 compatibility issues (native WebSocket silently fails * against HTTP/2 servers like Render.com). */ type MessageHandler = (message: Record) => void; export interface WsClientOptions { serverUrl: string; apiKey: string; onMessage: MessageHandler; onConnect?: () => void; onDisconnect?: () => void; log?: (msg: string) => void; } interface DiagnosticEntry { ts: string; type: "connect" | "disconnect" | "error" | "evicted" | "pong_timeout" | "send_fail"; code?: number; reason?: string; detail?: string; } export declare class WsClient { private ws; private opts; private reconnectAttempt; private reconnectTimer; private pingTimer; private pongTimeoutTimer; private pendingRequests; private stopped; private correlationCounter; private lastPongAt; private diagnosticLog; private errorLog; constructor(opts: WsClientOptions); connect(): void; stop(): void; /** * Send a message and wait for a correlated response (e.g., send -> send.result). */ request(message: Record): Promise>; /** * Send a message without waiting for a response. */ send(message: Record): void; get connected(): boolean; /** * Get diagnostic data for error reporting. */ getDiagnostics(): { errors: DiagnosticEntry[]; connectionLog: DiagnosticEntry[]; }; private _logDiagnostic; private _nextId; private _connect; private _handleMessage; private _send; private _startPing; private _schedulePongTimeout; private _clearPongTimeout; private _rejectPendingRequests; private _scheduleReconnect; private _clearTimers; } export {};