/** * Retry module with exponential backoff and jitter * * Features: * - Configurable backoff strategies (constant, linear, exponential) * - Jitter to prevent thundering herd * - Retryable error detection * - Per-attempt hooks for logging/metrics */ import type { RetryConfig } from '@cogitator-ai/types'; /** * Retry result with metadata */ export interface RetryResult { success: boolean; result?: T; error?: Error; attempts: number; totalDuration: number; delays: number[]; } /** * Attempt metadata passed to hooks */ export interface AttemptInfo { attempt: number; maxAttempts: number; delay: number; error?: Error; startTime: number; duration: number; } /** * Extended retry config with hooks */ export interface RetryOptions extends Partial { onAttempt?: (info: AttemptInfo) => void; onRetry?: (info: AttemptInfo) => void; onSuccess?: (result: T, info: AttemptInfo) => void; onFailure?: (error: Error, info: AttemptInfo) => void; abortSignal?: AbortSignal; } /** * Execute function with retry logic */ export declare function executeWithRetry(fn: (attempt: number) => Promise, options?: RetryOptions): Promise>; /** * Create a retryable version of a function */ export declare function withRetry(fn: (...args: A) => Promise, options?: RetryOptions): (...args: A) => Promise; /** * Decorator for retryable class methods */ export declare function Retryable(options?: RetryOptions): (_target: unknown, _propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor; /** * Calculate total expected retry time (for timeout estimation) */ export declare function estimateRetryDuration(config?: Partial): number; //# sourceMappingURL=retry.d.ts.map