import type { RetryOptions } from "../index.js"; import { FilesError } from "./errors.js"; /** * Combine zero or more abort signals with an optional per-attempt timeout into * a single signal. Returns the original signal untouched when there's exactly * one and no timeout; otherwise mints a controller that aborts when any input * aborts or the timer fires, plus a `cleanup` to detach listeners and clear the * timer. Callers must invoke `cleanup` in a `finally`. */ export declare const mergeSignals: (signals: AbortSignal[], timeout?: number) => { signal?: AbortSignal; cleanup?: () => void; }; /** * Normalize an abort `reason` into a {@link FilesError} flagged `aborted`. A * reason that's already a `FilesError` (e.g. a timeout) passes through; an * `Error` is wrapped with its message; anything else is stringified. */ export declare const abortError: (reason?: unknown) => FilesError; /** * Run `fn`, rejecting early if `signal` aborts before it settles. When no * signal is given, just runs `fn`. The abort listener is detached once `fn` * settles so a long-lived signal doesn't accumulate listeners. */ export declare const runWithSignal: (signal: AbortSignal | undefined, fn: () => Promise) => Promise; /** * Sleep `ms`, rejecting early (and clearing the timer) if `signal` aborts. A * non-positive `ms` resolves immediately. */ export declare const sleep: (ms: number, signal?: AbortSignal) => Promise; /** * Maximum number of retry attempts for an operation. `0` when not retryable or * unset. A bare number is treated as `{ max }`. */ export declare const maxRetries: (retries: RetryOptions | undefined, retryable: boolean) => number; /** * Backoff delay in ms before the given (1-based) retry attempt. Uses the * caller's `backoff` curve when supplied, otherwise an exponential curve from * 100ms, capped at 30s. */ export declare const retryBackoff: (retries: RetryOptions | undefined, attempt: number, error: FilesError) => number; /** * Whether a failed attempt should be retried: under the attempt cap, a * transient `Provider` error, not an abort (aborts and timeouts are * deliberate and never retried), and not flagged `permanent` (a * deterministic failure re-issuing the request can't fix). */ export declare const canRetry: (error: FilesError, attempt: number, maxAttempts: number) => boolean; //# sourceMappingURL=retry.d.ts.map