/** * Connection Manager * Manages multiple debugger connections (Chrome, Node.js, etc.) */ import { CDPManager } from './cdp-manager.js'; import { PuppeteerManager } from './puppeteer-manager.js'; import { ConsoleMonitor } from './console-monitor.js'; import { NetworkMonitor } from './network-monitor.js'; import type { RuntimeType } from './types.js'; import type { ChromeLauncher } from './chrome-launcher.js'; export interface Connection { id: string; type: RuntimeType; cdpManager: CDPManager; puppeteerManager?: PuppeteerManager; consoleMonitor?: ConsoleMonitor; networkMonitor?: NetworkMonitor; host: string; port: number; createdAt: number; lastActivityAt: number; reference?: string; pageIndex?: number; breakpointPauseAcknowledged?: boolean; } export declare class ConnectionManager { private connections; private browsers; private activeConnectionId; private connectionCounter; private chromeLauncher?; /** * Set the Chrome launcher instance for automatic cleanup */ setChromeLauncher(launcher: ChromeLauncher): void; /** * Create a new connection (tab) */ createConnection(cdpManager: CDPManager, puppeteerManager?: PuppeteerManager, consoleMonitor?: ConsoleMonitor, networkMonitor?: NetworkMonitor, host?: string, port?: number, reference?: string, pageIndex?: number): string; /** * Check if a browser instance exists at this host:port */ hasBrowser(host: string, port: number): boolean; /** * Get all connections for a specific browser */ getConnectionsForBrowser(host: string, port: number): Connection[]; /** * Get all connections */ getAllConnections(): Connection[]; /** * Update tab reference for a connection */ updateReference(connectionId: string, reference: string): boolean; /** * Get a connection by ID (or active if not specified) */ getConnection(id?: string): Connection | null; /** * Find a connection by reference name * Sanitizes input to match stored references (lowercase, trimmed, spaces to hyphens) */ findConnectionByReference(reference: string): Connection | null; /** * Check if a connection is still alive by attempting a lightweight CDP call * Returns false if the connection is dead or the CDP client is not responding * Uses a short timeout to avoid hanging when Chrome is killed or page is stuck * * This checks at the TARGET level (specific tab), not browser level. * When a tab is closed, the CDP connection to that target becomes invalid * even if the browser is still running. */ isConnectionAlive(connection: Connection): Promise; /** * Remove a stale/dead connection from the registry without attempting cleanup operations * Use this when the connection is known to be dead (e.g., Chrome was killed externally) */ removeStaleConnection(connectionId: string): Promise; /** * Find a connection by reference and validate it's still alive * If the connection is dead, automatically removes it and returns null * Use this instead of findConnectionByReference when you need to verify the connection is usable */ findConnectionByReferenceValidated(reference: string): Promise; /** * Get all connections */ listConnections(): Connection[]; /** * Set the active connection */ setActiveConnection(id: string): boolean; /** * Get the active connection ID */ getActiveConnectionId(): string | null; /** * Close a connection (tab) */ closeConnection(id: string): Promise; /** * Close all connections */ closeAll(): Promise; /** * Check if there are any connections */ hasConnections(): boolean; /** * Get connection count */ getConnectionCount(): number; /** * Update the lastActivityAt timestamp for a connection */ updateActivity(id: string): void; /** * Close connections that have been inactive for longer than the specified duration * @param inactivityMs - Inactivity duration in milliseconds (default: 5 minutes) * @returns Number of connections closed */ closeInactiveConnections(inactivityMs?: number): Promise; /** * Get list of inactive connections * @param inactivityMs - Inactivity duration in milliseconds (default: 5 minutes) * @returns Array of inactive connections with their info */ getInactiveConnections(inactivityMs?: number): Array<{ id: string; reference?: string; inactiveForMs: number; createdAt: number; }>; /** * Get console log stats from all connections * Returns an array of stats per connection that has new messages */ getConsoleLogStats(): Array<{ reference: string; newMessages: number; newErrors: number; newWarnings: number; }>; } //# sourceMappingURL=connection-manager.d.ts.map