UNPKG

thoughtmcp

Version:

AI that thinks more like humans do - MCP server with human-like cognitive architecture for enhanced reasoning, memory, and self-monitoring

98 lines 2.88 kB
/** * Comprehensive error handling utilities for the cognitive MCP server * Provides graceful degradation and component failure recovery */ export declare enum ErrorSeverity { LOW = "low", MEDIUM = "medium", HIGH = "high", CRITICAL = "critical" } export interface ComponentError { component: string; error: Error; severity: ErrorSeverity; timestamp: number; context?: Record<string, unknown>; } export interface GracefulDegradationOptions { enableFallbacks: boolean; maxRetries: number; retryDelayMs: number; timeoutMs: number; criticalComponents: string[]; } export declare class ErrorHandler { private static logger; private static componentErrors; private static readonly MAX_ERROR_HISTORY; /** * Handle errors with appropriate logging and recovery strategies */ static handleError(error: Error | string, component: string, context?: Record<string, unknown>, options?: Partial<GracefulDegradationOptions>): Promise<{ canContinue: boolean; fallbackData?: unknown; }>; /** * Wrap async operations with error handling and retries */ static withErrorHandling<T>(operation: () => Promise<T>, component: string, options?: Partial<GracefulDegradationOptions>): Promise<{ success: boolean; data?: T; error?: Error; }>; /** * Check if a component can gracefully degrade */ private static canGracefullyDegrade; /** * Attempt to provide fallback functionality */ private static attemptFallback; /** * Fallback implementations for various components */ private static sensoryProcessorFallback; private static emotionalProcessorFallback; private static metacognitionFallback; private static predictiveProcessorFallback; private static stochasticProcessorFallback; private static dualProcessFallback; /** * Assess error severity based on error type and component */ private static assessErrorSeverity; /** * Log errors with appropriate detail level */ private static logError; /** * Record component error for tracking and analysis */ private static recordComponentError; /** * Get recent errors for a component */ private static getRecentErrors; /** * Get error statistics for monitoring */ static getErrorStatistics(): Record<string, { total: number; recent: number; by_severity: Record<ErrorSeverity, number>; }>; /** * Clear error history for a component */ static clearErrorHistory(component?: string): void; /** * Create a timeout promise */ private static createTimeoutPromise; /** * Delay utility for retries */ private static delay; } //# sourceMappingURL=ErrorHandler.d.ts.map