/** * Retry and resilience layer for recursive-llm-ts. * * Provides configurable retry with exponential backoff, jitter, * and provider fallback chains. */ export interface RetryConfig { /** Maximum number of retries (default: 3) */ maxRetries?: number; /** Backoff strategy (default: 'exponential') */ backoff?: 'exponential' | 'linear' | 'fixed'; /** Base delay in milliseconds (default: 1000) */ baseDelay?: number; /** Maximum delay in milliseconds (default: 30000) */ maxDelay?: number; /** Add jitter to delays (default: true) */ jitter?: boolean; /** Error types that should be retried */ retryableErrors?: string[]; /** Called before each retry with retry info */ onRetry?: (attempt: number, error: Error, delay: number) => void; } /** Fallback model configuration */ export interface FallbackConfig { /** Ordered list of fallback models to try */ models?: string[]; /** Strategy for fallback selection */ strategy?: 'sequential' | 'round-robin'; } /** * Execute a function with retry logic. * * @example * ```typescript * const result = await withRetry( * () => rlm.completion(query, context), * { maxRetries: 3, backoff: 'exponential' } * ); * ``` */ export declare function withRetry(fn: () => Promise, config?: RetryConfig, signal?: AbortSignal): Promise; /** * Execute a function with fallback models. * Tries each model in order until one succeeds. * * @example * ```typescript * const result = await withFallback( * (model) => rlm.completion(query, context, model), * { models: ['gpt-4o', 'claude-sonnet-4-20250514', 'gemini-2.0-flash'] } * ); * ``` */ export declare function withFallback(fn: (model: string) => Promise, fallbackConfig: FallbackConfig, retryConfig?: RetryConfig, signal?: AbortSignal): Promise;