ai-debug-local-mcp
Version:
🎯 ENHANCED AI GUIDANCE v4.1.2: Dramatically improved tool descriptions help AI users choose the right tools instead of 'close enough' options. Ultra-fast keyboard automation (10x speed), universal recording, multi-ecosystem debugging support, and compreh
155 lines • 4.55 kB
TypeScript
export interface SessionHandler {
name: string;
onSessionCreate?: (sessionId: string) => Promise<void> | void;
onSessionDestroy?: (sessionId: string) => Promise<void> | void;
onSessionError?: (sessionId: string, error: Error) => Promise<void> | void;
}
export interface DistributedSessionInfo {
id: string;
createdAt: Date;
lastUsed: Date;
handlerCount: number;
handlerNames: string[];
resources: any[];
}
export interface SessionUsageStats {
totalHandlers: number;
handlerNames: string[];
lastUsed: Date;
createdAt: Date;
}
export interface SessionHealthReport {
totalSessions: number;
activeSessions: number;
totalHandlers: number;
averageHandlersPerSession: number;
orphanedSessions: number;
healthScore: number;
}
export interface PerformanceMetrics {
totalSessions: number;
averageSessionAge: number;
memoryUsage: number;
handlerEfficiency: number;
cleanupLatency: number;
}
export interface CleanupRecommendation {
totalSessions: number;
recommendedActions: Array<{
action: string;
priority: 'low' | 'medium' | 'high';
description: string;
}>;
priority: string;
}
/**
* DistributedSessionManager - Solves the audit finding:
* "Session cleanup relies entirely on main server - fragile pattern"
*
* Provides distributed session management where handlers can participate
* in session lifecycle events and cleanup is not centralized
*/
export declare class DistributedSessionManager {
sessions: Map<string, DistributedSessionInfo>;
private handlers;
private externalSessionsMap?;
private performanceData;
/**
* Create a new session with distributed handler notification
*/
createSession(sessionId: string): Promise<DistributedSessionInfo>;
/**
* Destroy a session with distributed cleanup
*/
destroySession(sessionId: string): Promise<void>;
/**
* Attach a handler to receive session events
*/
attachHandler(handler: SessionHandler): void;
/**
* Detach a handler from session events
*/
detachHandler(handlerName: string): boolean;
/**
* Notify all handlers about a session event
*/
notifyHandlers(sessionId: string, eventType: keyof SessionHandler, error?: Error): Promise<void>;
/**
* Get session by ID
*/
getSession(sessionId: string): DistributedSessionInfo | undefined;
/**
* Check if session exists
*/
hasSession(sessionId: string): boolean;
/**
* Track session usage by a handler
*/
trackSessionUsage(sessionId: string, handlerName: string): void;
/**
* Get session usage statistics
*/
getSessionUsageStats(sessionId: string): SessionUsageStats | undefined;
/**
* Get count of registered handlers
*/
getHandlerCount(): number;
/**
* Get health report
*/
getHealthReport(): SessionHealthReport;
/**
* Detect orphaned sessions (sessions not used recently)
*/
detectOrphanedSessions(ageThresholdMinutes?: number): DistributedSessionInfo[];
/**
* Clean up orphaned sessions
*/
cleanupOrphanedSessions(ageThresholdMinutes?: number): Promise<number>;
/**
* Set external sessions map for integration
*/
setExternalSessionsMap(sessionsMap: Map<string, any>): void;
/**
* Import existing sessions from external map
*/
importExistingSessions(): DistributedSessionInfo[];
/**
* Get performance metrics
*/
getPerformanceMetrics(): PerformanceMetrics;
/**
* Get cleanup recommendations
*/
getCleanupRecommendations(): CleanupRecommendation;
/**
* Destroy all sessions
*/
destroyAllSessions(): Promise<void>;
/**
* Integration with main server
*/
integrateWithServer(): void;
/**
* Enhance existing server cleanup
*/
enhanceServerCleanup(originalCleanup: (sessionId: string) => Promise<void>): (sessionId: string) => Promise<void>;
/**
* Get server integration status
*/
getServerIntegrationStatus(): {
integrated: boolean;
handlersRegistered: number;
sessionsManaged: number;
healthScore: number;
};
/**
* Clear all sessions and handlers (for testing)
*/
clear(): void;
}
/**
* Global distributed session manager instance
*/
export declare const globalDistributedSessionManager: DistributedSessionManager;
//# sourceMappingURL=distributed-session-manager.d.ts.map