/** * Fetch with automatic retry on 429 / 5xx. Returns the final * `Response` — the caller checks `.ok` and parses the body as usual. * * Does NOT retry network-level errors (connection reset, DNS * failure) — those throw synchronously and the caller's existing * try/catch handles them. */ export declare function fetchWithRetry(input: RequestInfo | URL, init?: RequestInit, config?: RetryConfig): Promise; /** * Retry helper for AI driver HTTP calls (stacksjs/stacks#1878 A-5). * * Background: OpenAI / Anthropic / etc. routinely return 429 (rate * limit) and 5xx (capacity / overloaded) responses with a * `Retry-After` header indicating when the caller should try again. * The pre-fix AI drivers threw immediately on any non-2xx, surfacing * transient capacity issues as hard user-facing failures. * * This helper wraps `fetch()` with: * - Honor `Retry-After` (seconds or HTTP-date) for 429 + 503 * - Exponential backoff + jitter for other 5xx * - Cap at `maxRetries` attempts (default 3) * - Surface the final non-recoverable response to the caller * * No retry on 4xx other than 429 — those are caller bugs (bad API * key, malformed request) that won't clear with more retries. */ /** * Configurable retry policy. Defaults are tuned for the typical * "Anthropic returned 429, try again in 3s" case without being so * aggressive that a permanent outage hangs the request loop for * minutes. */ export declare interface RetryConfig { maxRetries?: number baseDelayMs?: number maxDelayMs?: number }