/**
 * Session Stability Manager
 * Addresses critical feedback: "Had to restart sessions multiple times, losing context and workflow momentum"
 * Provides robust session recovery, state persistence, and connection resilience
 */
import { EventEmitter } from 'events';
export interface SessionState {
    sessionId: string;
    url: string;
    framework?: string;
    lastActivity: number;
    browserConnected: boolean;
    accessibility: {
        enabled: boolean;
        lastAttempt?: number;
        failureReason?: string;
    };
    quantumDebug: {
        initialized: boolean;
        lastAttempt?: number;
        failureReason?: string;
    };
    tools: {
        [toolName: string]: {
            lastUsed: number;
            status: 'success' | 'failed' | 'timeout';
            errorDetails?: string;
        };
    };
    context: {
        workflowPhase?: string;
        debuggingGoal?: string;
        reproducedIssue?: boolean;
    };
}
export interface SessionRecoveryPlan {
    canRecover: boolean;
    steps: Array<{
        action: string;
        tool: string;
        reason: string;
        estimatedTime: number;
    }>;
    preservedState: Partial<SessionState>;
    riskFactors: string[];
}
export declare class SessionStabilityManager extends EventEmitter {
    private sessions;
    private recoveryAttempts;
    private maxRecoveryAttempts;
    private sessionTimeout;
    private heartbeatInterval;
    private heartbeatTimers;
    constructor();
    /**
     * Create a new session with stability tracking
     * Addresses: "Easy session management but session instability issues"
     */
    createStableSession(url: string, options?: {
        framework?: string;
        workflowPhase?: string;
        debuggingGoal?: string;
    }): Promise<{
        sessionId: string;
        state: SessionState;
    }>;
    /**
     * Update session state with tool usage tracking
     * Addresses: "Context loss during debugging"
     */
    updateSessionState(sessionId: string, updates: Partial<SessionState>): SessionState | null;
    /**
     * Track tool usage with success/failure monitoring
     * Addresses: "Tools failing due to unmet requirements"
     */
    trackToolUsage(sessionId: string, toolName: string, result: {
        status: 'success' | 'failed' | 'timeout';
        errorDetails?: string;
        duration?: number;
    }): void;
    /**
     * Detect session failures and create recovery plan
     * Addresses: "Failed to enable Flutter accessibility: Target page, context or browser has been closed"
     */
    detectSessionFailure(sessionId: string, error: Error): Promise<SessionRecoveryPlan>;
    /**
     * Execute automatic session recovery
     * Addresses: "Auto-restart with previous context if browser closes"
     */
    executeSessionRecovery(sessionId: string, recoveryPlan: SessionRecoveryPlan): Promise<{
        success: boolean;
        newSessionId?: string;
        restoredFeatures: string[];
        failedFeatures: string[];
    }>;
    /**
     * Get comprehensive session diagnostics
     * Addresses: "Show session state clearly"
     */
    getSessionDiagnostics(sessionId: string): {
        status: 'healthy' | 'degraded' | 'failed' | 'not_found';
        details: {
            browser: {
                status: string;
                lastCheck: number;
            };
            framework: {
                detected: boolean;
                type?: string;
            };
            accessibility: {
                enabled: boolean;
                lastAttempt?: number;
                error?: string;
            };
            quantumDebug: {
                initialized: boolean;
                lastAttempt?: number;
                error?: string;
            };
            tools: {
                working: string[];
                failed: string[];
            };
            activity: {
                lastActivity: number;
                ageMinutes: number;
            };
        };
        recommendations: string[];
    } | null;
    /**
     * Get recommended tool workflow based on session state
     * Addresses: "Suggest logical tool sequences"
     */
    getRecommendedWorkflow(sessionId: string): {
        nextSteps: Array<{
            tool: string;
            reason: string;
            prerequisites: string[];
            estimatedTime: number;
        }>;
        currentPhase: string;
        blockers: string[];
    };
    /**
     * Private helper methods
     */
    private generateSessionId;
    private startSessionHeartbeat;
    private stopSessionHeartbeat;
    private startGlobalMonitoring;
    /**
     * Cleanup resources
     */
    destroy(): void;
}
//# sourceMappingURL=session-stability-manager.d.ts.map