File size: 3,748 Bytes
d5f068b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/**
 * Unified Error Handling System for CLI Providers
 *
 * Provides consistent error classification, user-friendly messages, and debugging support
 * across all AI providers (Claude, Codex, Cursor)
 */
export declare enum ErrorType {
    AUTHENTICATION = "authentication",
    BILLING = "billing",
    RATE_LIMIT = "rate_limit",
    NETWORK = "network",
    TIMEOUT = "timeout",
    VALIDATION = "validation",
    PERMISSION = "permission",
    CLI_NOT_FOUND = "cli_not_found",
    CLI_NOT_INSTALLED = "cli_not_installed",
    MODEL_NOT_SUPPORTED = "model_not_supported",
    INVALID_REQUEST = "invalid_request",
    SERVER_ERROR = "server_error",
    UNKNOWN = "unknown"
}
export declare enum ErrorSeverity {
    LOW = "low",
    MEDIUM = "medium",
    HIGH = "high",
    CRITICAL = "critical"
}
export interface ErrorClassification {
    type: ErrorType;
    severity: ErrorSeverity;
    userMessage: string;
    technicalMessage: string;
    suggestedAction?: string;
    retryable: boolean;
    provider?: string;
    context?: Record<string, unknown>;
}
export interface ErrorPattern {
    type: ErrorType;
    severity: ErrorSeverity;
    patterns: RegExp[];
    userMessage: string;
    suggestedAction?: string;
    retryable: boolean;
}
/**
 * Classify an error into a specific type with user-friendly message
 */
export declare function classifyError(error: unknown, provider?: string, context?: Record<string, unknown>): ErrorClassification;
/**
 * Get a user-friendly error message
 */
export declare function getUserFriendlyErrorMessage(error: unknown, provider?: string): string;
/**
 * Check if an error is retryable
 */
export declare function isRetryableError(error: unknown): boolean;
/**
 * Check if an error is authentication-related
 */
export declare function isAuthenticationError(error: unknown): boolean;
/**
 * Check if an error is billing-related
 */
export declare function isBillingError(error: unknown): boolean;
/**
 * Check if an error is rate limit related
 */
export declare function isRateLimitError(error: unknown): boolean;
/**
 * Create a standardized error response
 */
export declare function createErrorResponse(error: unknown, provider?: string, context?: Record<string, unknown>): {
    success: false;
    error: string;
    errorType: ErrorType;
    severity: ErrorSeverity;
    retryable: boolean;
    suggestedAction?: string;
};
/**
 * Log error with full context
 */
export declare function logError(error: unknown, provider?: string, operation?: string, additionalContext?: Record<string, unknown>): void;
/**
 * Provider-specific error handlers
 */
export declare const ProviderErrorHandler: {
    claude: {
        classify: (error: unknown) => ErrorClassification;
        getUserMessage: (error: unknown) => string;
        isAuth: (error: unknown) => boolean;
        isBilling: (error: unknown) => boolean;
        isRateLimit: (error: unknown) => boolean;
    };
    codex: {
        classify: (error: unknown) => ErrorClassification;
        getUserMessage: (error: unknown) => string;
        isAuth: (error: unknown) => boolean;
        isBilling: (error: unknown) => boolean;
        isRateLimit: (error: unknown) => boolean;
    };
    cursor: {
        classify: (error: unknown) => ErrorClassification;
        getUserMessage: (error: unknown) => string;
        isAuth: (error: unknown) => boolean;
        isBilling: (error: unknown) => boolean;
        isRateLimit: (error: unknown) => boolean;
    };
};
/**
 * Create a retry handler for retryable errors
 */
export declare function createRetryHandler(maxRetries?: number, baseDelay?: number): <T>(operation: () => Promise<T>, shouldRetry?: (error: unknown) => boolean) => Promise<T>;
//# sourceMappingURL=error-handler.d.ts.map