/** * Error Taxonomy Types and Classification (CX-004) * * Provides structured error responses with: * - Error categories for high-level classification * - Error codes for programmatic handling * - Recommended actions for LLM recovery strategies * - Retryability indicators */ /** * High-level error categories for classification */ export type ErrorCategory = 'network' | 'http' | 'auth' | 'rate_limit' | 'content' | 'validation' | 'security' | 'browser' | 'config' | 'site_change' | 'blocked' | 'internal'; /** * Machine-readable error codes for programmatic handling */ export type ErrorCode = 'NETWORK_TIMEOUT' | 'NETWORK_CONNECTION_REFUSED' | 'NETWORK_DNS_FAILURE' | 'NETWORK_SOCKET_ERROR' | 'NETWORK_UNREACHABLE' | 'HTTP_BAD_REQUEST' | 'HTTP_UNAUTHORIZED' | 'HTTP_FORBIDDEN' | 'HTTP_NOT_FOUND' | 'HTTP_METHOD_NOT_ALLOWED' | 'HTTP_GONE' | 'HTTP_TOO_MANY_REQUESTS' | 'HTTP_SERVER_ERROR' | 'HTTP_BAD_GATEWAY' | 'HTTP_SERVICE_UNAVAILABLE' | 'HTTP_GATEWAY_TIMEOUT' | 'AUTH_SESSION_EXPIRED' | 'AUTH_CREDENTIALS_MISSING' | 'AUTH_CREDENTIALS_INVALID' | 'AUTH_TOKEN_EXPIRED' | 'RATE_LIMIT_EXCEEDED' | 'RATE_LIMIT_BACKOFF_REQUIRED' | 'CONTENT_EMPTY' | 'CONTENT_REQUIRES_JS' | 'CONTENT_EXTRACTION_FAILED' | 'CONTENT_FORMAT_UNEXPECTED' | 'VALIDATION_CONTENT_TOO_SHORT' | 'VALIDATION_PATTERN_MISMATCH' | 'VALIDATION_MISSING_ELEMENTS' | 'VALIDATION_INCOMPLETE_RENDER' | 'SECURITY_PRIVATE_IP' | 'SECURITY_LOCALHOST' | 'SECURITY_METADATA_ENDPOINT' | 'SECURITY_BLOCKED_PROTOCOL' | 'SECURITY_BLOCKED_HOSTNAME' | 'BROWSER_NOT_INSTALLED' | 'BROWSER_CRASHED' | 'BROWSER_ELEMENT_NOT_FOUND' | 'BROWSER_NAVIGATION_FAILED' | 'BROWSER_TIMEOUT' | 'CONFIG_MISSING_ARGUMENT' | 'CONFIG_INVALID_OPTION' | 'CONFIG_UNKNOWN_TOOL' | 'CONFIG_INVALID_URL' | 'SITE_STRUCTURE_CHANGED' | 'SITE_SELECTORS_OUTDATED' | 'SITE_API_CHANGED' | 'BLOCKED_CAPTCHA' | 'BLOCKED_CHALLENGE_PAGE' | 'BLOCKED_BOT_DETECTION' | 'BLOCKED_GEO_RESTRICTED' | 'INTERNAL_ERROR' | 'INTERNAL_SKILL_ERROR'; /** * Actionable recommendation for LLM clients */ export interface RecommendedAction { /** Action identifier (e.g., "retry", "wait", "refresh_session") */ action: string; /** Human-readable description of what to do */ description: string; /** Suggested wait time in milliseconds before action */ suggestedDelayMs?: number; /** MCP tool that might help resolve the issue */ toolToUse?: string; /** Suggested parameters for the tool */ parameters?: Record; /** Priority of this action (lower = try first) */ priority: number; } /** * Context about the error */ export interface ErrorContext { url?: string; domain?: string; tier?: string; strategy?: string; attemptNumber?: number; elapsed?: number; } /** * Structured error response with taxonomy and recommendations */ export interface StructuredError { /** Human-readable error message (backward compatible) */ error: string; /** High-level error category */ category: ErrorCategory; /** Specific error code for programmatic handling */ code: ErrorCode; /** HTTP status code if applicable */ httpStatus?: number; /** Whether this error is retryable */ retryable: boolean; /** Recommended actions for recovery */ recommendedActions: RecommendedAction[]; /** Additional context about the error */ context?: ErrorContext; } /** * Result of error classification */ export interface ErrorClassification { category: ErrorCategory; code: ErrorCode; httpStatus?: number; } /** * Context for error classification */ export interface ClassificationContext { httpStatus?: number; securityCategory?: string; } /** * Classify an error into category and code based on message patterns */ export declare function classifyError(error: Error | string, context?: ClassificationContext): ErrorClassification; /** * Determine if an error is retryable based on category and code */ export declare function isRetryable(category: ErrorCategory, code: ErrorCode): boolean; /** * Get recommended actions based on error category and code */ export declare function getRecommendedActions(category: ErrorCategory, code: ErrorCode, context?: ErrorContext): RecommendedAction[]; /** * Build a structured error response from an error */ export declare function buildStructuredError(error: Error | string, classificationContext?: ClassificationContext, errorContext?: ErrorContext): StructuredError; //# sourceMappingURL=errors.d.ts.map