/** Exponential delay settings for retries. */ export type RetryBackoff = { initialMs: number; multiplier?: number; maxMs?: number; jitter?: boolean; }; /** Bounds for attempts and total execution time. */ export type RetryPolicy = { maxAttempts: number; attemptTimeoutMs?: number; totalTimeoutMs?: number; backoff?: RetryBackoff; }; /** Whether to retry, with an optional minimum delay. */ export type RetryDecision = boolean | { afterMs: number; }; /** Dependencies and callbacks for a retry run. */ export type RetryParams = { policy: RetryPolicy; signal?: AbortSignal; retryable?: (error: unknown) => RetryDecision; onRetry?: (event: { attempt: number; delayMs: number; error: unknown; }) => void; random?: () => number; now?: () => number; }; /** Largest delay accepted by JavaScript timers. */ export declare const MAX_DELAY_MS = 2147483647; /** Limit that stopped a retry run. */ export type RetryExhaustedReason = 'attempts' | 'total_timeout'; /** Details of the exhausted retry run. */ export type RetryExhaustedErrorParams = { attempts: number; reason: RetryExhaustedReason; cause?: unknown; }; /** Error raised when a retry limit is reached. */ export declare class RetryExhaustedError extends Error { #private; constructor(params: RetryExhaustedErrorParams); get attempts(): number; get reason(): RetryExhaustedReason; } /** Assert that retry policy bounds are usable by timers. */ export declare function assertRetryPolicy(policy: RetryPolicy): void; /** Calculate the delay before the next attempt. */ export declare function getRetryDelay(policy: RetryPolicy, attempt: number, params?: { afterMs?: number; random?: () => number; }): number; /** Dependencies and time bounds for one attempt. */ export type RaceAttemptParams = { fn: (signal: AbortSignal) => Promise; signal?: AbortSignal; timeoutMs?: number; deadline?: number; now?: () => number; }; /** Race one attempt against abort and timeout signals. */ export declare function raceAttempt(params: RaceAttemptParams): Promise; /** Retry an asynchronous operation within the supplied policy bounds. */ export declare function retry(fn: (ctx: { attempt: number; signal: AbortSignal; }) => Promise, params: RetryParams): Promise;