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
143 lines • 4.38 kB
TypeScript
/**
* Session Persistence Handler - Automatic Session Recovery
*
* Addresses Cycle 3 feedback: "Sessions unexpectedly close (Target page, context or browser has been closed)"
* Provides automatic session recovery with context preservation for uninterrupted debugging workflows
*/
import { ToolHandler } from './base-handler.js';
import { Tool } from '@modelcontextprotocol/sdk/types.js';
interface SessionSnapshot {
sessionId: string;
url: string;
framework: string;
timestamp: number;
debuggingContext: {
variables: Record<string, any>;
breakpoints: string[];
networkFilters: string[];
lastAction: string;
pageState: any;
};
browserState: {
cookies: any[];
localStorage: Record<string, string>;
sessionStorage: Record<string, string>;
userAgent: string;
};
recoveryAttempts: number;
}
interface SessionRecoveryResult {
success: boolean;
newSessionId?: string;
recoveredState: boolean;
message: string;
preservedContext?: SessionSnapshot;
}
interface AutoRecoveryStatus {
enabled: boolean;
maxRetries: number;
backoffDelay: number;
monitoringActive: boolean;
recoveriesPerformed: number;
}
/**
* Session Persistence Handler - Implements automatic session recovery and context preservation
* Based on real-world user feedback from Cycle 3 (genetic analysis platform debugging)
*/
export declare class SessionPersistenceHandler implements ToolHandler {
tools: Tool[];
private snapshots;
private recoveryConfig;
private snapshotDirectory;
constructor();
/**
* Get available session persistence tools
*/
getTools(): Tool[];
/**
* Handle tool requests by routing to appropriate methods
*/
handle(toolName: string, args: any, sessions: Map<string, any>): Promise<any>;
/**
* Create a backup snapshot of current session state
* Addresses user feedback: "context preservation for uninterrupted debugging workflows"
*/
createSessionSnapshot(args: {
sessionId: string;
includePageState?: boolean;
includeBrowserState?: boolean;
}, sessions: Map<string, any>): Promise<{
snapshotId: string;
size: number;
timestamp: number;
success: boolean;
}>;
/**
* Recover failed session with preserved context
* Addresses user feedback: "Automatic session recovery with context preservation"
*/
recoverFailedSession(args: {
failedSessionId: string;
lastError: string;
preserveContext?: boolean;
}, sessions: Map<string, any>): Promise<SessionRecoveryResult>;
/**
* Enable automatic session recovery monitoring
* Addresses user feedback: "Uninterrupted debugging workflows, especially for long test generation cycles"
*/
enableAutoRecovery(args: {
sessionId: string;
maxRetries?: number;
backoffDelay?: number;
snapshotInterval?: number;
}, sessions: Map<string, any>): Promise<{
enabled: boolean;
configuration: AutoRecoveryStatus;
message: string;
}>;
/**
* Get current recovery status and statistics
*/
getRecoveryStatus(args: {
sessionId?: string;
}, sessions: Map<string, any>): Promise<{
globalStatus: AutoRecoveryStatus;
sessionSnapshots: number;
availableSnapshots: string[];
sessionSpecific?: {
hasSnapshot: boolean;
lastSnapshot?: number;
recoveryAttempts?: number;
};
}>;
/**
* Capture current page state for snapshot
*/
private capturePageState;
/**
* Capture browser context (cookies, storage, etc.)
*/
private captureBrowserState;
/**
* Recreate session from snapshot (placeholder for integration with core handler)
*/
private recreateSession;
/**
* Restore debugging context to recovered session
*/
private restoreDebuggingContext;
/**
* Persist snapshot to disk for cross-process recovery
*/
private persistSnapshot;
/**
* Load snapshot from disk
*/
private loadSnapshot;
/**
* Ensure snapshot directory exists
*/
private ensureSnapshotDirectory;
}
export {};
//# sourceMappingURL=session-persistence-handler.d.ts.map