/** * Vibe MCP Relay Server * * Daemon that multiplexes multiple MCP agents to a single browser extension. * - Listens on port 19889 for extension connection (one client) * - Listens on port 19888 for MCP agent connections (multiple clients) * - Routes tool calls from agents to extension, responses back to agents * * Note: Using 19888/19889 to avoid conflict with Playwriter MCP (uses 19988/19989) */ import { EventEmitter } from 'events'; export declare const EXTENSION_PORT: number; export declare const AGENT_PORT: number; /** * Absolute path of the relay pidfile (single source of truth for tests/tooling). */ export declare function getRelayPidFile(): string; /** * Vibe MCP Relay Server * * Owns exactly one shared chrome-devtools fallback backend process per relay * daemon instance. All connected MCP clients (vibebrowser-mcp and * vibebrowser-cli) route through this relay, so fallback lifecycle and tool * routing stay deterministic across concurrent agents. */ export declare class RelayServer extends EventEmitter { private extensionWss; private agentWss; private extensionSessions; private socketToSessionId; private agents; private pendingRequests; private requestIdCounter; private anonymousSessionCounter; private debug; private readonly devtoolsFallback; private pidFileOwned; private cleanupRegistered; constructor(debug?: boolean); /** * Start the relay server */ start(): Promise; /** * Register process-exit and signal handlers that release the pidfile lock. * `exit` cleanup is synchronous so it runs on unexpected termination; SIGINT * and SIGTERM trigger a graceful shutdown. */ private registerCleanupHandlers; /** * Release the pidfile lock if (and only if) this process still owns it. */ private releasePidFile; /** * Start WebSocket server for extension connection */ private startExtensionServer; /** * Start WebSocket server for agent connections */ private startAgentServer; /** * Handle extension connection */ private handleExtensionConnection; /** * Handle agent connection */ private handleAgentConnection; /** * Handle message from extension */ private handleExtensionMessage; /** * Handle message from an agent */ private handleAgentMessage; /** * Request tools list from extension */ private requestToolsFromExtension; /** * Replay pending requests on a replacement extension connection. * * The browser-side client deduplicates repeated request IDs, so keeping the * same relay request ID lets us survive a transient socket swap without * dropping the original MCP call or double-running it under normal reconnects. */ private replayPendingRequests; /** * Keep requesting tools until extension responds with tools_list. */ private startToolsSyncLoop; private stopToolsSyncLoop; /** * Broadcast message to all connected agents */ private broadcastToAgents; /** * Shutdown the relay server */ private shutdown; /** * Log message */ private log; private ensureSessionForSocket; private extractAnnouncedSessionId; private buildSessionsList; private getDefaultSession; private resolveTargetSession; private parseToolDefinitions; private getToolsForSession; private findExtensionTool; private findFallbackTool; private broadcastDefaultToolsToAgents; private hasConnectedExtensionSession; private sendSessionStateToAgent; private broadcastSessionState; private rejectPendingRequestsForSession; } /** * Check if relay is already running */ export declare function isRelayRunning(): boolean; /** * Get relay PID if running */ export declare function getRelayPid(): number | null; /** * Start relay as a detached daemon */ export declare function spawnRelayDaemon(debug?: boolean): void; /** * Main entry point for relay daemon */ export declare function startRelayDaemon(debug?: boolean): Promise; //# sourceMappingURL=relay.d.ts.map