/** * SSEListener - Real-time event stream listener for the MCP server. * * Connects to the backend's SSE endpoint (`GET /v1/events/stream`) * and dispatches transfer and broadcast events as they arrive. * Auto-reconnects with exponential backoff on disconnect. * Falls back to polling after 3 consecutive connection failures. */ export interface SSEListenerOptions { apiBase: string; apiKey: string; agentId?: string; /** Called when a transfer event fires (created, downloaded, deleted). */ onTransferEvent: (type: string, data: unknown) => void; /** Called when a broadcast event fires. */ onBroadcast?: (data: unknown) => void; /** Called when a real-time message event fires (Phase A v0.1 — message.created). */ onMessageEvent?: (type: string, data: unknown) => void; /** Called when SSE gives up after consecutive failures. */ onFallbackToPolling?: () => void; /** Max consecutive failures before fallback. Default: 3 */ maxConsecutiveFailures?: number; /** Initial backoff delay in ms. Default: 3000 */ initialBackoffMs?: number; /** Max backoff delay in ms. Default: 60000 */ maxBackoffMs?: number; } export declare class SSEListener { private apiBase; private apiKey; private agentId?; private onTransferEvent; private onBroadcast?; private onMessageEvent?; private onFallbackToPolling?; private maxConsecutiveFailures; private initialBackoffMs; private maxBackoffMs; private consecutiveFailures; private running; private abortController; private reconnectTimer; constructor(opts: SSEListenerOptions); /** * Build the SSE endpoint URL. */ private buildUrl; /** * Calculate backoff delay for the current failure count. */ private getBackoffMs; /** * Connect to the SSE endpoint and start reading events. */ private connect; /** * Parse a raw SSE event block into type + data and dispatch. */ private processRawEvent; /** * Schedule a reconnection attempt after backoff delay. */ private scheduleReconnect; /** * Start listening to the SSE stream. */ start(): void; /** * Stop listening and clean up. */ stop(): void; }