/** * Session-scoped quota state for external providers (Tavily, DeepSeek, * future model brains). When an upstream API responds with a quota / * insufficient-balance signal — i.e. one that retrying within this * session won't fix — we mark the provider DISABLED and short-circuit * future calls with a user-friendly message instead of hammering the * provider further or surfacing a raw HTTP error. * * Rate-limit errors (429 Retry-After style) do NOT disable here; the * resilientProvider retry+backoff handles those. This module is for * "monthly limit hit, won't recover this billing cycle" cases. * * State is in-memory and resets when the CLI restarts; no disk * persistence so a top-up + relaunch immediately works. */ export type ProviderQuotaName = 'tavily' | 'deepseek' | (string & {}); export interface ProviderQuotaInfo { reason: string; detectedAt: number; detail?: string; /** * Optional HTTP status that triggered the disable. Lets callers * decide whether to expose it to the user. */ httpStatus?: number; } export declare function markProviderQuotaExhausted(provider: ProviderQuotaName, reason: string, extras?: { detail?: string; httpStatus?: number; }): void; export declare function isProviderQuotaExhausted(provider: ProviderQuotaName): boolean; export declare function getProviderQuotaInfo(provider: ProviderQuotaName): ProviderQuotaInfo | null; export declare function clearProviderQuota(provider: ProviderQuotaName): void; export declare function buildQuotaExhaustedMessage(provider: ProviderQuotaName): string; /** * Heuristic: given an HTTP status + response body fragment, decide * whether the failure is "out of quota / out of balance" (persistent) * vs. transient rate-limit. Returns null for "neither / inconclusive". * * This is shared by the Tavily handlers and the model provider wrapper * so we stay consistent about which signals burn the quota flag. */ export declare function classifyUpstreamError(status: number | undefined, body: string | undefined): 'quota-exhausted' | 'rate-limit' | null; //# sourceMappingURL=providerQuotaState.d.ts.map