/** * Provider limit classification shared by every runner and `agent exec` * (doc/agent-exec-protocol.md §3.4, rev 20): a transient rate limit (HTTP * 429, "too many requests", a per-minute cap) is worth a retry after a short * backoff; exhausted quota, credits, billing or a daily allowance is not. * * Wordings seen in this repo's fixtures and runners: * - OpenRouter through pi (fixture json-openrouter-429-retries.jsonl): * `429: {"message":"Provider returned error","code":429,…"… is * temporarily rate-limited upstream. Please retry shortly…"}` * - OpenRouter's own caps: "Rate limit exceeded: free-models-per-min." * (transient) vs "…: free-models-per-day. Add 10 credits…" (daily cap) * - litellm (aider, dsh's pi-ai adapter): "litellm.RateLimitError: …" * - Anthropic: `rate_limit_error`; OpenAI: "Rate limit reached for … Please * try again in 1.5s" vs `insufficient_quota` / "exceeded your current * quota"; Gemini: `RESOURCE_EXHAUSTED` with a `…PerMinute…` quota id and * `"retryDelay": "17s"`; codex: "exceeded retry limit, last status: 429 * Too Many Requests" vs "You've hit your usage limit". */ export type ProviderLimit = 'rate-limited' | 'quota'; /** `rate-limited` for a transient limit, `quota` for exhausted quota or * billing, undefined when the text is neither. */ export declare function classifyProviderLimit(text: string): ProviderLimit | undefined; /** Longest wait a provider's Retry-After hint may impose on one retry. */ export declare const MAX_RETRY_AFTER_MS = 30000; /** * The wait a provider asked for ("Retry-After: 20", "retry after 20 * seconds", "Please try again in 1.5s", "retryDelay":"17s", "retry in * 500ms"), capped at MAX_RETRY_AFTER_MS; undefined when the text has none. */ export declare function parseRetryAfterMs(text: string): number | undefined; /** Error property a runner sets when its CLI already retried the failure * itself (pi's auto_retry, aider's litellm backoff): the number of retries, * or 0 when the CLI retried an unknown number of times. */ export interface VendorRetried { vendorRetries?: number; } /** Tag `err` with the retries the runtime's CLI already made (a count, or * 'unknown'); a count of 0 leaves it untagged. */ export declare function withVendorRetries(err: E, retries: number | 'unknown'): E; /** * The retries a runtime's CLI already made on this failure: the error's * `vendorRetries` tag, else wording such as codex's "exceeded retry limit" * (0 = count unknown). undefined when nothing says the CLI retried. */ export declare function vendorRetriesOf(err: unknown, text: string): number | undefined; //# sourceMappingURL=provider-limit.d.ts.map