import { type ProviderRequestDiagnostic } from '../provider-error.js';
export interface AdaptiveConcurrencySnapshot {
    key: string;
    cap: number;
    effectiveLimit: number;
    consecutiveSuccesses: number;
    cooldownUntil: number;
}
export interface AdaptiveControllerOptions {
    increaseAfterSuccess?: number;
    cooldownMs?: number;
    now?: () => number;
}
export declare class AdaptiveConcurrencyController {
    private readonly states;
    private readonly increaseAfterSuccess;
    private readonly cooldownMs;
    private readonly now;
    constructor(opts?: AdaptiveControllerOptions);
    currentLimit(key: string, cap: number): number;
    recordSuccess(key: string, cap: number): AdaptiveConcurrencySnapshot;
    recordRateLimit(key: string, cap: number): AdaptiveConcurrencySnapshot;
    reset(): void;
    snapshotForTesting(key: string, cap: number): AdaptiveConcurrencySnapshot;
    private stateFor;
    private snapshot;
}
export declare function isAdaptiveAgentConcurrencyEnabled(): boolean;
export declare function resolveAgentConcurrencyCap(): number;
export declare function resolveAdaptiveAgentLimit(key: string, cap?: number): number;
export declare function recordAdaptiveSuccess(key: string, cap?: number): void;
export declare function recordAdaptiveRateLimit(key: string, cap?: number): void;
export declare function adaptiveConcurrencyKeyFromApiBaseUrl(apiBaseUrl: string): string;
export declare function diagnosticLooksLikeRateLimit(diagnostic: ProviderRequestDiagnostic | null | undefined): boolean;
export declare function parseRetryAfterMs(value: string | null | undefined, now?: number): number | null;
export declare function computeRequestRetryDelayMs(opts: {
    attempt: number;
    status?: number;
    detail?: string;
    retryAfterHeader?: string | null;
    adaptive?: boolean;
    now?: number;
    random?: () => number;
}): number;
export declare function requestAutoRetryLimit(retryable: boolean, kind: string | undefined): number;
export declare function tryConsumeAdaptiveRetryBudget(key: string): boolean;
export declare function __resetAdaptiveConcurrencyForTesting(): void;
export declare function __getAdaptiveConcurrencySnapshotForTesting(key: string, cap?: number): AdaptiveConcurrencySnapshot;
