/** * Error classes for @compilr-dev/agents * * Error hierarchy: * - AgentError (base) * - ProviderError (LLM API errors) * - ToolError (tool execution errors) * - ValidationError (input validation errors) */ /** * Base error class for all agent-related errors. */ export declare class AgentError extends Error { readonly cause?: Error | undefined; constructor(message: string, cause?: Error | undefined); } /** * Error thrown when an LLM provider API call fails. * * @example * ```typescript * throw new ProviderError( * 'Rate limit exceeded. Retry after 60s', * 'claude', * 429 * ); * ``` */ export declare class ProviderError extends AgentError { readonly provider: string; readonly statusCode?: number | undefined; constructor(message: string, provider: string, statusCode?: number | undefined, cause?: Error); /** * Check if this is a rate limit error (HTTP 429) */ isRateLimitError(): boolean; /** * Check if this is an authentication error (HTTP 401/403) */ isAuthError(): boolean; /** * Check if this is a server error (HTTP 5xx) */ isServerError(): boolean; /** * Check if this is a connection/network error. * These errors typically have no status code but are retryable. */ isConnectionError(): boolean; /** * Check if this is an Anthropic overloaded error (529) */ isOverloadedError(): boolean; /** * Check if this error is retryable. * Retryable errors include: * - Rate limit (429) * - Server errors (5xx) * - Connection/network errors * - Anthropic overloaded (529) * * Non-retryable errors include: * - Authentication errors (401, 403) * - Bad request (400) * - Not found (404) */ isRetryable(): boolean; } /** * Error thrown when a tool execution fails. * * @example * ```typescript * throw new ToolError( * 'File not found: /path/to/file.txt', * 'read_file', * originalError * ); * ``` */ export declare class ToolError extends AgentError { readonly toolName: string; constructor(message: string, toolName: string, cause?: Error); } /** * Error thrown when a tool execution times out. * * @example * ```typescript * throw new ToolTimeoutError('read_file', 30000); * ``` */ export declare class ToolTimeoutError extends ToolError { readonly toolName: string; readonly timeoutMs: number; constructor(toolName: string, timeoutMs: number); } /** * Error thrown when input validation fails. * * @example * ```typescript * throw new ValidationError( * 'maxTokens must be a positive number', * 'maxTokens' * ); * ``` */ export declare class ValidationError extends AgentError { readonly field: string; constructor(message: string, field: string); } /** * Error thrown when the agentic loop exceeds max iterations. * * @example * ```typescript * throw new MaxIterationsError(10); * ``` */ export declare class MaxIterationsError extends AgentError { readonly maxIterations: number; constructor(maxIterations: number); } /** * Error thrown when the agent is stuck in a tool call loop. * * This occurs when the same tool is called with identical input * multiple times consecutively, indicating the agent is not * processing the tool results properly. * * @example * ```typescript * throw new ToolLoopError('read_file', 3); * ``` */ export declare class ToolLoopError extends AgentError { readonly toolName: string; readonly consecutiveCalls: number; readonly input?: Record | undefined; constructor(toolName: string, consecutiveCalls: number, input?: Record | undefined); } /** * Error thrown when a request is aborted via AbortSignal. */ export declare class AbortError extends AgentError { constructor(message?: string); } /** * Error thrown when context window cannot be reduced sufficiently. * * This occurs when: * - Multiple summarization rounds fail to reduce context below target * - Content is too large even after aggressive filtering * * @example * ```typescript * throw new ContextOverflowError( * 'Unable to reduce context below 90% after 3 summarization rounds', * 0.95, // current utilization * 3 // rounds attempted * ); * ``` */ export declare class ContextOverflowError extends AgentError { readonly utilization: number; readonly roundsAttempted?: number | undefined; constructor(message: string, utilization: number, roundsAttempted?: number | undefined); } /** * Type guard to check if an error is a ContextOverflowError */ export declare function isContextOverflowError(error: unknown): error is ContextOverflowError; /** * Type guard to check if an error is an AgentError */ export declare function isAgentError(error: unknown): error is AgentError; /** * Type guard to check if an error is a ProviderError */ export declare function isProviderError(error: unknown): error is ProviderError; /** * Type guard to check if an error is a ToolError */ export declare function isToolError(error: unknown): error is ToolError; /** * Type guard to check if an error is a ToolLoopError */ export declare function isToolLoopError(error: unknown): error is ToolLoopError; /** * Type guard to check if an error is a ToolTimeoutError */ export declare function isToolTimeoutError(error: unknown): error is ToolTimeoutError; /** * Wrap an unknown error into an AgentError */ export declare function wrapError(error: unknown, message?: string): AgentError;