/** * ERROR HANDLING FRAMEWORK * Typed error hierarchy, recovery strategies, debugging context */ export declare enum ErrorCode { AUTHENTICATION_FAILED = 1001, INVALID_API_KEY = 1002, TOKEN_EXPIRED = 1003, INSUFFICIENT_PERMISSIONS = 1004, RATE_LIMIT_EXCEEDED = 1101, QUOTA_EXCEEDED = 1102, BUDGET_EXCEEDED = 1103, MODEL_NOT_FOUND = 1201, MODEL_UNAVAILABLE = 1202, MODEL_TIMEOUT = 1203, MODEL_OVERLOADED = 1204, INVALID_MODEL_CONFIG = 1205, INVALID_REQUEST = 1301, INVALID_PARAMETERS = 1302, MISSING_REQUIRED_FIELD = 1303, INVALID_FORMAT = 1304, REQUEST_TOO_LARGE = 1305, CONTENT_FILTERED = 1401, UNSAFE_CONTENT = 1402, PII_DETECTED = 1403, PROMPT_INJECTION = 1404, INTERNAL_ERROR = 1501, SERVICE_UNAVAILABLE = 1502, TIMEOUT = 1503, NETWORK_ERROR = 1504, DATABASE_ERROR = 1505, VENDOR_ERROR = 1601, VENDOR_RATE_LIMIT = 1602, VENDOR_AUTHENTICATION = 1603, VENDOR_INVALID_REQUEST = 1604 } export declare enum ErrorSeverity { LOW = "low", MEDIUM = "medium", HIGH = "high", CRITICAL = "critical" } export declare class ModelOrchError extends Error { readonly code: ErrorCode; readonly severity: ErrorSeverity; readonly recoverable: boolean; readonly context?: Record; readonly timestamp: Date; readonly request_id?: string; constructor(params: { message: string; code: ErrorCode; severity?: ErrorSeverity; recoverable?: boolean; context?: Record; request_id?: string; cause?: Error; }); /** * Get user-friendly error message */ getUserMessage(): string; /** * Get debugging context */ getDebugContext(): Record; /** * Convert to JSON */ toJSON(): Record; } export declare class AuthenticationError extends ModelOrchError { constructor(message: string, context?: Record); } export declare class RateLimitError extends ModelOrchError { readonly retry_after?: number; constructor(message: string, retry_after?: number, context?: Record); getUserMessage(): string; } export declare class ModelError extends ModelOrchError { readonly model: string; constructor(message: string, model: string, code?: ErrorCode, context?: Record); } export declare class ValidationError extends ModelOrchError { readonly field?: string; constructor(message: string, field?: string, context?: Record); } export declare class ContentSafetyError extends ModelOrchError { readonly violation_type: string; constructor(message: string, violation_type: string, context?: Record); } export declare class VendorError extends ModelOrchError { readonly vendor: string; readonly vendor_code?: string; constructor(message: string, vendor: string, vendor_code?: string, context?: Record); } export declare class ErrorHandler { private listeners; /** * Handle error */ handle(error: Error | ModelOrchError, request_id?: string): ModelOrchError; /** * Add error listener */ onError(listener: (error: ModelOrchError) => void): void; /** * Remove error listener */ offError(listener: (error: ModelOrchError) => void): void; /** * Check if error is recoverable */ isRecoverable(error: Error): boolean; /** * Get retry strategy */ getRetryStrategy(error: ModelOrchError): { should_retry: boolean; delay_ms: number; max_attempts: number; }; } export declare class ErrorRecovery { /** * Retry with exponential backoff */ withRetry(fn: () => Promise, options?: { max_attempts?: number; initial_delay_ms?: number; max_delay_ms?: number; backoff_multiplier?: number; }): Promise; /** * Fallback to alternative */ withFallback(primary: () => Promise, fallback: () => Promise): Promise; /** * Timeout wrapper */ withTimeout(fn: () => Promise, timeout_ms: number): Promise; private sleep; } export interface ErrorReport { total_errors: number; errors_by_code: Record; errors_by_severity: Record; recoverable_errors: number; recent_errors: Array<{ code: number; message: string; timestamp: string; }>; } export declare class ErrorReporter { private errors; private max_errors; /** * Record error */ record(error: ModelOrchError): void; /** * Generate report */ generateReport(): ErrorReport; /** * Clear errors */ clear(): void; } //# sourceMappingURL=error-handler.d.ts.map