UNPKG

@ai-capabilities-suite/mcp-debugger-core

Version:

Core debugging engine for Node.js and TypeScript applications. Provides Inspector Protocol integration, breakpoint management, variable inspection, execution control, profiling, hang detection, and source map support.

119 lines (118 loc) 3.42 kB
/** * Session timeout configuration */ export interface SessionTimeoutConfig { enabled: boolean; timeoutMs: number; warningMs?: number; } /** * Session timeout event handler */ export type SessionTimeoutHandler = (sessionId: string) => void; /** * Session warning event handler */ export type SessionWarningHandler = (sessionId: string, remainingMs: number) => void; /** * Manages session timeouts for debug sessions * Automatically cleans up expired sessions and sends warnings */ export declare class SessionTimeoutManager { private config; private sessions; private timeoutHandlers; private warningHandlers; constructor(config?: SessionTimeoutConfig); /** * Register a session for timeout tracking * @param sessionId The session identifier */ registerSession(sessionId: string): void; /** * Update the last activity time for a session * Resets the timeout timer * @param sessionId The session identifier */ updateActivity(sessionId: string): void; /** * Unregister a session from timeout tracking * @param sessionId The session identifier */ unregisterSession(sessionId: string): void; /** * Check if a session is registered * @param sessionId The session identifier * @returns True if the session is registered */ hasSession(sessionId: string): boolean; /** * Get the remaining time until timeout for a session * @param sessionId The session identifier * @returns Remaining time in milliseconds, or null if session not found */ getRemainingTime(sessionId: string): number | null; /** * Get session timeout information * @param sessionId The session identifier * @returns Session timeout information or null if not found */ getSessionInfo(sessionId: string): { createdAt: Date; lastActivityAt: Date; timeoutAt: Date; remainingMs: number; } | null; /** * Get all registered session IDs * @returns Array of session IDs */ getAllSessionIds(): string[]; /** * Get the number of registered sessions * @returns Number of sessions */ getSessionCount(): number; /** * Register a timeout handler * Called when a session times out * @param handler The timeout handler function */ onTimeout(handler: SessionTimeoutHandler): void; /** * Register a warning handler * Called when a session is about to timeout * @param handler The warning handler function */ onWarning(handler: SessionWarningHandler): void; /** * Handle session timeout * @param sessionId The session identifier */ private handleTimeout; /** * Handle session warning * @param sessionId The session identifier */ private handleWarning; /** * Clear all sessions and timers */ clear(): void; /** * Check if timeout enforcement is enabled * @returns True if enabled */ isEnabled(): boolean; /** * Get the current configuration * @returns The current configuration */ getConfig(): SessionTimeoutConfig; /** * Update the configuration * Note: This does not affect already registered sessions * @param config The new configuration */ updateConfig(config: Partial<SessionTimeoutConfig>): void; }