/** Configuration for retry behaviour with exponential backoff. */ export interface RetryConfig { maxRetries: number; initialDelayMs: number; maxDelayMs: number; /** * Cancellation for the backoff between attempts. * * Without it the backoff is unreachable once armed: a caller that has been * cancelled, an agent killed, a turn abandoned, still sits out the full * wait, up to `maxDelayMs` per attempt, before it can even discover it was * cancelled. The wait is where nearly all of a failing retry's wall time * goes, so leaving it uncancellable made cancellation approximate. * * When it fires the sleep ends immediately and the last error is thrown, * which is what the surrounding code already does with a spent retry budget. */ signal?: AbortSignal | undefined; } /** Type guard: checks if an unknown value has a numeric `statusCode` property. */ export declare function hasStatusCode(err: unknown): err is { statusCode: number; }; /** Type guard: checks if an unknown value has a numeric `status` property. */ export declare function hasStatus(err: unknown): err is { status: number; }; /** * Determines whether an error should trigger a retry. * Checks AppError.recoverable first, then falls back to HTTP status code inspection. * Handles both Error subclasses and plain objects with statusCode/status properties. */ export declare function isRetryableError(error: unknown): boolean; /** * Wraps an async function with retry logic using exponential backoff. * Retries when `isRetryableError` returns true for the thrown error. * * @param fn - Async function to execute. * @param config - Optional overrides for retry behaviour. * @param onRetry - Optional callback invoked before each retry. Argument order * (attempt, maxAttempts, delayMs, error) matches `ChatRequest.onRetry` so * providers can pass it straight through without an adapter. */ export declare function withRetry(fn: () => Promise, config?: Partial, onRetry?: (attempt: number, maxAttempts: number, delayMs: number, error: Error) => void): Promise; //# sourceMappingURL=retry.d.ts.map