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
137 lines • 4.05 kB
TypeScript
/**
* Circuit Breaker Manager for AI-Debug Tools
*
* Implements circuit breaker pattern to handle failures gracefully and provide
* reset capabilities for AI-Debug tools that get stuck in failure states.
*
* Features:
* - Per-tool circuit breakers with configurable thresholds
* - Automatic failure detection and circuit opening
* - Manual and automatic reset capabilities
* - Health monitoring and recovery strategies
* - Graceful degradation and fallback mechanisms
*/
import { CircuitBreakerConfig as PhoenixConfig } from './phoenix-circuit-breaker-config.js';
export interface CircuitBreakerConfig extends PhoenixConfig {
}
export interface CircuitBreakerState {
status: 'closed' | 'open' | 'half-open';
failureCount: number;
successCount: number;
lastFailureTime: number;
lastSuccessTime: number;
openedAt: number;
nextAttemptTime: number;
totalAttempts: number;
recentFailures: Array<{
timestamp: number;
error: string;
context: string;
}>;
}
export interface ToolHealthMetrics {
toolName: string;
state: CircuitBreakerState;
healthScore: number;
availabilityRate: number;
averageResponseTime: number;
lastHealthCheck: number;
recommendations: string[];
}
export interface CircuitBreakerEvent {
timestamp: number;
toolName: string;
event: 'failure' | 'success' | 'open' | 'close' | 'half-open' | 'reset';
context: string;
metadata?: any;
}
export declare class CircuitBreakerManager {
private logger;
private circuitBreakers;
private configs;
private events;
private healthMetrics;
private monitoringInterval;
constructor();
/**
* Initialize default circuit breaker configurations for AI-Debug tools
*/
private initializeDefaultConfigs;
/**
* Initialize circuit breaker state for a tool
*/
private initializeCircuitBreaker;
/**
* Record a successful execution
*/
recordSuccess(toolName: string, responseTime?: number, context?: string): void;
/**
* Record a failed execution
*/
recordFailure(toolName: string, error: string, context?: string): void;
/**
* Check if a tool can be executed (circuit is not open)
*/
canExecute(toolName: string): {
allowed: boolean;
reason?: string;
};
/**
* Manually reset a circuit breaker
*/
resetCircuit(toolName: string, reason?: string): boolean;
/**
* Reset all circuit breakers (emergency recovery)
*/
resetAllCircuits(reason?: string): number;
/**
* Get health status for a specific tool
*/
getToolHealth(toolName: string): ToolHealthMetrics | null;
/**
* Get health status for all tools
*/
getAllToolHealth(): Map<string, ToolHealthMetrics>;
/**
* Get tools that are currently failing or degraded
*/
getUnhealthyTools(): ToolHealthMetrics[];
/**
* Get circuit breaker statistics
*/
getStatistics(): {
totalTools: number;
healthyTools: number;
degradedTools: number;
failedTools: number;
totalEvents: number;
recentEvents: CircuitBreakerEvent[];
};
/**
* Update configuration for a specific tool
*/
updateConfig(toolName: string, config: Partial<CircuitBreakerConfig>): void;
/**
* Update circuit breaker configuration for a specific tool
*/
private updateCircuitBreakerConfig;
private getOrCreateCircuitBreaker;
/**
* Apply Phoenix-specific circuit breaker configuration if appropriate
*/
applyPhoenixConfiguration(context: any): void;
private openCircuit;
private closeCircuit;
private setHalfOpen;
private getRecentFailureCount;
private recordEvent;
private updateHealthMetrics;
private generateRecommendations;
private startHealthMonitoring;
private performHealthCheck;
/**
* Cleanup resources
*/
destroy(): void;
}
//# sourceMappingURL=circuit-breaker-manager.d.ts.map