/**
 * Gemini capacity policy.
 *
 * Gemini CLI quota failures expose reset windows in stderr (for example,
 * "quota will reset after 7h32m28s"). Without a provider-specific policy the
 * next call just spawns Gemini again, hits the same 429/QUOTA_EXHAUSTED, and
 * appears stalled. This module keeps the policy small and explicit:
 *
 * - short capacity blips can retry once after a bounded backoff;
 * - quota windows with a reset hint are deferred until that window has passed;
 * - later calls are refused locally while deferred, avoiding doomed subprocesses;
 * - fallback models must be in the verified Gemini model set.
 */
export interface GeminiCapacityPolicyConfig {
    enabled?: boolean;
    /** Number of immediate retries for short capacity windows. Default 1. */
    maxImmediateRetries?: number;
    /** Retry immediately only when the parsed reset is at/below this. Default 30s. */
    immediateRetryMaxMs?: number;
    /** Backoff used when retrying and no shorter reset hint exists. Default 5s. */
    backoffMs?: number;
    /** Optional operator-selected fallback. Ignored unless it is a known Gemini model. */
    fallbackModel?: string;
    /**
     * Optional quota-state output path. When set, long Gemini capacity deferrals
     * are written as stop-state snapshots so the existing quota gate blocks
     * doomed scheduler spawns until the CLI-reported reset window passes.
     */
    quotaStateFile?: string;
}
export type GeminiCapacityAction = 'none' | 'retry' | 'defer';
export interface GeminiCapacityDecision {
    action: GeminiCapacityAction;
    retryAfterMs?: number;
    model: string;
    reason: string | null;
}
export interface GeminiCapacityGate {
    allow: boolean;
    retryAfterMs: number;
    deferredUntil: number | null;
    reason: string | null;
}
export declare function isGeminiCapacityError(message: string | null | undefined): boolean;
export declare function parseGeminiRetryAfterMs(message: string | null | undefined): number | undefined;
export declare function resolveKnownGeminiFallback(requestedModel: string, config: GeminiCapacityPolicyConfig | undefined): string;
/**
 * Pick a known Gemini model to switch to when `exhaustedModel` hit its capacity
 * limit. A candidate qualifies when it is (a) a known Gemini model, (b) not the
 * just-exhausted model, and (c) not itself inside a recorded exhaustion window
 * at `now`. Prefers an operator-configured fallback when it qualifies, otherwise
 * the first known model with headroom. Returns undefined when every known model
 * is exhausted — the genuine account-wide block case.
 */
export declare function pickGeminiFallbackModel(exhaustedModel: string, config: GeminiCapacityPolicyConfig | undefined, now: number): string | undefined;
export declare function decideGeminiCapacityPolicy(params: {
    errorMessage: string;
    attempt: number;
    model: string;
    config?: GeminiCapacityPolicyConfig;
    now?: number;
}): GeminiCapacityDecision;
export declare function getGeminiCapacityGate(now?: number): GeminiCapacityGate;
export declare function recordGeminiCapacityDeferral(params: {
    retryAfterMs: number;
    reason: string;
    model?: string;
    quotaStateFile?: string;
    now?: number;
}): GeminiCapacityGate;
export declare function resetGeminiCapacityPolicyForTests(): void;
//# sourceMappingURL=geminiCapacityPolicy.d.ts.map