/** * Provider retry metadata shared by transport retries and durable memory jobs. * Only structural status/header fields establish a deadline; prose never does. * * The installed AI SDK wraps a provider failure in a `RetryError` envelope once * its own retries exhaust; the envelope's top node carries no status and no * headers — the 429 and its Retry-After live on the wrapped `APICallError`. * These classifiers therefore read the same bounded cause/lastError/errors * graph as the model-error classifiers, and never a message substring. */ /** * Read the provider's retry delay once for both retry admission and cooldowns. * The millisecond header takes precedence over Retry-After seconds/date, matching * the SDK transport contract. Invalid values fall through to the other header; * missing or invalid hints leave the bounded exponential policy in control. */ export declare function providerRetryAfterMs(error: unknown, now?: number): number | undefined; /** * Explicit credit exhaustion is not a temporary rate-limit window. Any node in * the wrapped provider-error graph may carry the provider's quota codes. */ export declare function isPermanentQuotaError(error: unknown): boolean; /** * Absolute deadline survives evaluator processing before task persistence. * The 429 and its retry hint may sit on any node of the wrapped provider-error * graph; permanent quota exhaustion anywhere in the graph rejects the wait. */ export declare function providerRateLimitRetryAt(error: unknown, now?: number): number | undefined; /** * Provider limits a typed 429 may name: the plan's burst and sustained * request buckets, or the plan's period allowance. */ export declare const PROVIDER_RATE_LIMIT_SCOPES: readonly ["burst", "sustained", "period"]; export type ProviderRateLimitScope = (typeof PROVIDER_RATE_LIMIT_SCOPES)[number]; /** * Typed, client-safe view of a provider 429. It holds only bounded fields: * never the provider message, the raw body or any credential. */ export interface ProviderRateLimit { kind: "rate_limited"; /** Wait before the next attempt, whole milliseconds, capped. */ retryAfterMs: number; /** Provider plan id that owns the refused bucket. */ planId?: string; /** Provider bucket or allowance that refused the request. */ scope?: ProviderRateLimitScope; /** * When the provider sent one: the absolute time (ISO 8601) at which the * refused bucket or period allowance resets. Not capped, so a period * allowance can reset days after the refusal. */ resetAt?: string; /** Seconds from the refusal until `resetAt`. Present only with `resetAt`. */ resetAfterSeconds?: number; } /** Upper bound for a reported wait; longer provider hints are clamped. */ export declare const MAX_PROVIDER_RATE_LIMIT_RETRY_AFTER_MS: number; /** Clamp a provider wait to whole milliseconds; reject non-finite or negative. */ export declare function boundProviderRetryAfterMs(value: unknown): number | undefined; /** * Validate a rate-limit record at a trust boundary. Unknown keys are dropped, * a malformed plan id or scope is omitted, and the wait is capped. */ export declare function parseProviderRateLimit(value: unknown): ProviderRateLimit | undefined; /** Normalize an ISO 8601 reset time with a time zone; anything else is dropped. */ export declare function parseProviderResetAt(value: unknown): string | undefined; /** * Read the typed rate limit a provider attached to its 429 (`rateLimit` on the * error node), through SDK and failover wrappers. Prose is never parsed. It is * a report for the client, not a retry signal: no caller waits on it. * * A used-up period allowance (`scope: "period"`) is reported from any status, * including a permanent-quota 402, so the client can show when the allowance * resets. `providerRateLimitRetryAt` still rejects it, so nothing retries. */ export declare function readProviderRateLimit(error: unknown): ProviderRateLimit | undefined;