/** * Comprehensive error types for Bellwether. * * Error hierarchy: * - BellwetherError (base) * - TransportError (MCP communication) * - LLMError (LLM provider issues) * - InterviewError (interview execution) * - WorkflowError (workflow execution) * - ConfigError (configuration issues) */ /** * Error severity levels. */ export type ErrorSeverity = 'low' | 'medium' | 'high' | 'critical'; /** * Whether an error is retryable. */ export type RetryableStatus = 'retryable' | 'terminal' | 'unknown'; /** * Error context for debugging and recovery. */ export interface ErrorContext { /** Operation that failed */ operation?: string; /** Component where error occurred */ component?: string; /** Tool name if applicable */ tool?: string; /** Workflow ID if applicable */ workflow?: string; /** Step index if applicable */ stepIndex?: number; /** Request ID for tracing */ requestId?: string; /** Timing information */ timing?: { startedAt: Date; failedAt: Date; durationMs: number; }; /** Retry information */ retry?: { attempt: number; maxAttempts: number; nextDelayMs?: number; }; /** Additional metadata */ metadata?: Record; } /** * Base error class for all Bellwether errors. */ export declare class BellwetherError extends Error { /** Error code for programmatic handling */ readonly code: string; /** Error severity */ readonly severity: ErrorSeverity; /** Whether this error is retryable */ readonly retryable: RetryableStatus; /** Error context for debugging */ readonly context: ErrorContext; /** Original error if this wraps another */ readonly cause?: Error; constructor(message: string, options: { code: string; severity?: ErrorSeverity; retryable?: RetryableStatus; context?: ErrorContext; cause?: Error; }); /** * Create a new error with additional context. */ withContext(additionalContext: Partial): BellwetherError; /** * Convert to JSON for logging. */ toJSON(): Record; } /** * Base class for transport-related errors. */ export declare class TransportError extends BellwetherError { constructor(message: string, options: { code: string; severity?: ErrorSeverity; retryable?: RetryableStatus; context?: ErrorContext; cause?: Error; }); } /** * Connection failed or was lost. */ export declare class ConnectionError extends TransportError { constructor(message: string, context?: ErrorContext, cause?: Error); } /** * Request timed out. */ export declare class TimeoutError extends TransportError { /** Timeout value in milliseconds */ readonly timeoutMs: number; constructor(message: string, timeoutMs: number, context?: ErrorContext, cause?: Error); } /** * Server process exited unexpectedly. */ export declare class ServerExitError extends TransportError { /** Exit code if available */ readonly exitCode?: number; /** Exit signal if available */ readonly signal?: string; constructor(message: string, exitCode?: number, signal?: string, context?: ErrorContext); } /** * Protocol error (invalid message format, etc). */ export declare class ProtocolError extends TransportError { constructor(message: string, context?: ErrorContext, cause?: Error); } /** * Remote server authentication/authorization failed. */ export declare class ServerAuthError extends TransportError { /** HTTP status code if available */ readonly statusCode?: number; /** Suggested remediation hint */ readonly hint?: string; constructor(message: string, statusCode?: number, hint?: string, context?: ErrorContext, cause?: Error); } /** * Buffer overflow during message processing. */ export declare class BufferOverflowError extends TransportError { /** Current buffer size */ readonly bufferSize: number; /** Maximum allowed size */ readonly maxSize: number; constructor(bufferSize: number, maxSize: number, context?: ErrorContext); } /** * Base class for LLM-related errors. */ export declare class LLMError extends BellwetherError { /** LLM provider name */ readonly provider: string; /** Model name if available */ readonly model?: string; constructor(message: string, provider: string, options: { code: string; model?: string; severity?: ErrorSeverity; retryable?: RetryableStatus; context?: ErrorContext; cause?: Error; }); } /** * Authentication/API key error. */ export declare class LLMAuthError extends LLMError { constructor(provider: string, model?: string, context?: ErrorContext, cause?: Error); } /** * Rate limit exceeded. */ export declare class LLMRateLimitError extends LLMError { /** Retry after in milliseconds if known */ readonly retryAfterMs?: number; constructor(provider: string, retryAfterMs?: number, model?: string, context?: ErrorContext, cause?: Error); } /** * Quota/credits exhausted. */ export declare class LLMQuotaError extends LLMError { constructor(provider: string, model?: string, context?: ErrorContext, cause?: Error); } /** * Model refused to complete request (content policy, etc). */ export declare class LLMRefusalError extends LLMError { /** Refusal reason if available */ readonly reason?: string; constructor(provider: string, reason?: string, model?: string, context?: ErrorContext, cause?: Error); } /** * LLM response parsing failed. */ export declare class LLMParseError extends LLMError { /** Raw response that couldn't be parsed */ readonly rawResponse?: string; constructor(provider: string, rawResponse?: string, model?: string, context?: ErrorContext, cause?: Error); } /** * LLM connection failed. */ export declare class LLMConnectionError extends LLMError { constructor(provider: string, model?: string, context?: ErrorContext, cause?: Error); } /** * Base class for interview-related errors. */ export declare class InterviewError extends BellwetherError { constructor(message: string, options: { code: string; severity?: ErrorSeverity; retryable?: RetryableStatus; context?: ErrorContext; cause?: Error; }); } /** * Tool call failed. */ export declare class ToolCallError extends InterviewError { /** Tool name */ readonly toolName: string; /** Arguments passed to tool */ readonly args: Record; constructor(toolName: string, args: Record, message: string, context?: ErrorContext, cause?: Error); } /** * Discovery failed. */ export declare class DiscoveryError extends InterviewError { constructor(message: string, context?: ErrorContext, cause?: Error); } /** * Question generation failed. */ export declare class QuestionGenerationError extends InterviewError { constructor(toolName: string, context?: ErrorContext, cause?: Error); } /** * Analysis/synthesis failed. */ export declare class AnalysisError extends InterviewError { constructor(phase: 'response' | 'profile' | 'summary', context?: ErrorContext, cause?: Error); } /** * Base class for workflow-related errors. */ export declare class WorkflowError extends BellwetherError { /** Workflow ID */ readonly workflowId: string; /** Workflow name */ readonly workflowName?: string; constructor(message: string, workflowId: string, options: { code: string; workflowName?: string; severity?: ErrorSeverity; retryable?: RetryableStatus; context?: ErrorContext; cause?: Error; }); } /** * Workflow step failed. */ export declare class WorkflowStepError extends WorkflowError { /** Step index (0-based) */ readonly stepIndex: number; /** Tool name for this step */ readonly toolName: string; constructor(workflowId: string, stepIndex: number, toolName: string, message: string, workflowName?: string, context?: ErrorContext, cause?: Error); } /** * Argument resolution failed (JSON path evaluation). */ export declare class ArgResolutionError extends WorkflowError { /** The path expression that failed */ readonly pathExpression: string; /** Step index where resolution failed */ readonly stepIndex: number; constructor(workflowId: string, stepIndex: number, pathExpression: string, message: string, workflowName?: string, context?: ErrorContext); } /** * Assertion failed during workflow execution. */ export declare class AssertionError extends WorkflowError { /** The assertion that failed */ readonly assertion: string; /** Actual value received */ readonly actualValue?: unknown; constructor(workflowId: string, stepIndex: number, assertion: string, actualValue?: unknown, workflowName?: string, context?: ErrorContext); } /** * Configuration-related error. */ export declare class ConfigError extends BellwetherError { constructor(message: string, context?: ErrorContext, cause?: Error); } /** * Configuration file not found. */ export declare class ConfigNotFoundError extends ConfigError { /** Path that was searched */ readonly path: string; constructor(path: string, context?: ErrorContext); } /** * Configuration validation failed. */ export declare class ConfigValidationError extends ConfigError { /** Validation errors */ readonly validationErrors: string[]; constructor(errors: string[], context?: ErrorContext); } /** * Check if an error is a BellwetherError. */ export declare function isBellwetherError(error: unknown): error is BellwetherError; /** * Check if an error is retryable. */ export declare function isRetryable(error: unknown): boolean; /** * Wrap an unknown error in a BellwetherError. */ export declare function wrapError(error: unknown, context?: ErrorContext): BellwetherError; /** * Extract error message from any error type. */ export declare function getErrorMessage(error: unknown): string; /** * Create timing context for error tracking. */ export declare function createTimingContext(startedAt: Date): ErrorContext['timing']; //# sourceMappingURL=types.d.ts.map