/** * Retry logic with exponential backoff. */ import { type ErrorContext } from './types.js'; /** * Retry options. */ export interface RetryOptions { /** Maximum number of retry attempts (default: 3) */ maxAttempts?: number; /** Initial delay in milliseconds (default: 1000) */ initialDelayMs?: number; /** Maximum delay in milliseconds (default: 30000) */ maxDelayMs?: number; /** Backoff multiplier (default: 2) */ backoffMultiplier?: number; /** Add jitter to delays (default: true) */ jitter?: boolean; /** Custom retry condition (default: isRetryable) */ shouldRetry?: (error: unknown, attempt: number) => boolean; /** Callback on retry (for logging) */ onRetry?: (error: unknown, attempt: number, delayMs: number) => void; /** Operation name for logging */ operation?: string; /** Additional context for errors */ context?: ErrorContext; } /** * Execute a function with retry logic. * * @example * ```typescript * const result = await withRetry( * async () => await llmClient.complete(prompt), * { maxAttempts: 3, operation: 'LLM completion' } * ); * ``` */ export declare function withRetry(fn: () => Promise, options?: RetryOptions): Promise; /** * Create a retry wrapper for a specific operation. * * @example * ```typescript * const retryableFetch = createRetryWrapper({ * maxAttempts: 5, * operation: 'API fetch' * }); * * const data = await retryableFetch(() => fetchData()); * ``` */ export declare function createRetryWrapper(defaultOptions: RetryOptions): (fn: () => Promise, overrides?: RetryOptions) => Promise; /** * Retry options specifically tuned for LLM calls. */ export declare const LLM_RETRY_OPTIONS: RetryOptions; /** * Retry options for MCP transport operations. */ export declare const TRANSPORT_RETRY_OPTIONS: RetryOptions; /** * Retry options for tool calls during interviews. */ export declare const TOOL_CALL_RETRY_OPTIONS: RetryOptions; /** * Circuit breaker options. */ export interface CircuitBreakerOptions { /** Number of failures before opening circuit (default: 5) */ failureThreshold?: number; /** Time in ms before attempting to close circuit (default: 30000) */ resetTimeMs?: number; /** Time window for counting failures in ms (default: 60000) */ failureWindowMs?: number; } /** * Create a circuit breaker for an operation. * * @example * ```typescript * const protectedCall = createCircuitBreaker('llm-api'); * * try { * const result = await protectedCall(() => llmClient.complete(prompt)); * } catch (error) { * // Either operation error or circuit open error * } * ``` */ export declare function createCircuitBreaker(name: string, options?: CircuitBreakerOptions): (fn: () => Promise) => Promise; //# sourceMappingURL=retry.d.ts.map