import { ExpertType } from '../types/workflow'; /** * Advanced error handling interfaces and types */ export declare enum ErrorCategory { TRANSIENT = "transient", PERMANENT = "permanent", TIMEOUT = "timeout", RATE_LIMIT = "rate_limit", AUTHENTICATION = "authentication", VALIDATION = "validation", RESOURCE_EXHAUSTION = "resource_exhaustion", NETWORK = "network", API_ERROR = "api_error", SYSTEM = "system", BUSINESS_LOGIC = "business_logic" } export declare enum ErrorSeverity { LOW = 1, MEDIUM = 2, HIGH = 3, CRITICAL = 4 } export interface ErrorClassification { category: ErrorCategory; severity: ErrorSeverity; recoverable: boolean; retryable: boolean; expectedRecoveryTime?: number; userImpact: UserImpactLevel; businessImpact: BusinessImpactLevel; } export declare enum UserImpactLevel { NONE = "none", LOW = "low", MEDIUM = "medium", HIGH = "high", CRITICAL = "critical" } export declare enum BusinessImpactLevel { NONE = "none", LOW = "low", MEDIUM = "medium", HIGH = "high", CRITICAL = "critical" } export interface ErrorContext { operation: string; expertType?: ExpertType; workflowId?: string; userId?: string; correlationId?: string; timestamp: number; stackTrace?: string; metadata?: Record; } export interface ErrorRecoveryStrategy { name: string; description: string; applicableCategories: ErrorCategory[]; execute: (error: ClassifiedError, context: ErrorContext) => Promise; priority: number; successRate?: number; } export interface RecoveryResult { success: boolean; action: RecoveryAction; message: string; metadata?: Record; nextRetryDelay?: number; } export declare enum RecoveryAction { RETRY = "retry", FALLBACK = "fallback", SKIP = "skip", ABORT = "abort", ESCALATE = "escalate", PARTIAL_SUCCESS = "partial_success" } export interface ClassifiedError extends Error { classification: ErrorClassification; context: ErrorContext; originalError?: Error; recoveryAttempts: number; lastRecoveryAttempt?: Date; } export interface ErrorPattern { pattern: string | RegExp; classification: ErrorClassification; customHandler?: (error: Error, context: ErrorContext) => Promise; } export interface ErrorBoundaryConfig { isolationLevel: IsolationLevel; fallbackStrategies: ErrorRecoveryStrategy[]; circuitBreakerConfig?: { failureThreshold: number; recoveryTimeout: number; monitoringWindow: number; }; partialFailurePolicy: PartialFailurePolicy; } export declare enum IsolationLevel { NONE = "none", EXPERT = "expert", WORKFLOW = "workflow", SYSTEM = "system" } export interface PartialFailurePolicy { allowPartialSuccess: boolean; minimumSuccessThreshold: number; failFastOnCriticalErrors: boolean; continueOnNonCriticalErrors: boolean; } /** * Advanced error classifier with machine learning-inspired pattern recognition */ export declare class ErrorClassifier { private errorPatterns; private historicalPatterns; private logger; constructor(); /** * Classify an error using pattern matching and historical data */ classifyError(error: Error, context: ErrorContext): ErrorClassification; /** * Learn from error outcomes to improve classification */ updateClassificationFromOutcome(error: ClassifiedError, outcome: RecoveryResult): void; private initializeDefaultPatterns; private generateErrorSignature; private matchesPattern; private createDefaultClassification; private simpleHash; } /** * Advanced error recovery system with multiple strategies */ export declare class ErrorRecoverySystem { private recoveryStrategies; private classifier; private logger; private recoveryMetrics; constructor(); /** * Handle error with intelligent recovery */ handleError(error: Error, context: ErrorContext, options?: { maxRecoveryAttempts?: number; allowPartialSuccess?: boolean; }): Promise; /** * Attempt recovery using available strategies */ private attemptRecovery; private getApplicableStrategies; private sortStrategiesByEffectiveness; private updateRecoveryMetrics; private delay; private initializeRecoveryStrategies; private extractRateLimitDelay; /** * Get recovery metrics for analysis */ getRecoveryMetrics(): Map; /** * Get recovery strategy recommendations based on historical performance */ getStrategyRecommendations(category: ErrorCategory): ErrorRecoveryStrategy[]; } /** * Error boundary for isolating failures within workflows */ export declare class ErrorBoundary { private config; private recoverySystem; private logger; constructor(config: ErrorBoundaryConfig); /** * Execute operation within error boundary */ execute(operation: () => Promise, context: ErrorContext, options?: { allowPartialFailure?: boolean; }): Promise>; private generateIsolationId; private shouldEscalateError; } interface RecoveryMetrics { attempts: number; successes: number; failures: number; successRate: number; averageRecoveryTime: number; } interface BoundaryResult { success: boolean; result?: T; isolationId: string; errors: Error[]; recoveryAction?: RecoveryAction; recoveryMessage?: string; } export declare const errorClassifier: ErrorClassifier; export declare const errorRecoverySystem: ErrorRecoverySystem; export {}; //# sourceMappingURL=advancedErrorHandling.d.ts.map