/**
 * Quota Manager for Hybrid Auto+Manual Account Selection
 *
 * Provides pre-flight quota checking with caching, tier-based failover,
 * and cooldown tracking for exhausted accounts.
 *
 * Key features:
 * - 30-second in-memory cache for quota results
 * - Tier-priority failover (ultra > pro by default)
 * - Cooldown tracking for exhausted accounts
 * - Respects paused accounts from manual config
 * - Graceful degradation on API failures
 */
import { CLIProxyProvider } from '../types';
import { QuotaResult } from './quota-fetcher';
import type { ClaudeQuotaResult, CodexQuotaResult, GeminiCliQuotaResult, GhcpQuotaResult } from './quota-types';
import { type AccountInfo } from '../accounts/account-manager';
export type ManagedQuotaProvider = 'agy' | 'claude' | 'codex' | 'gemini' | 'ghcp';
type ManagedQuotaResult = QuotaResult | ClaudeQuotaResult | CodexQuotaResult | GeminiCliQuotaResult | GhcpQuotaResult;
export declare const MANAGED_QUOTA_PROVIDERS: readonly ManagedQuotaProvider[];
export declare function isManagedQuotaProvider(provider: CLIProxyProvider): provider is ManagedQuotaProvider;
/**
 * Get cached quota result if still valid
 */
export declare function getCachedQuota(provider: CLIProxyProvider, accountId: string): ManagedQuotaResult | null;
/**
 * Cache quota result
 */
export declare function setCachedQuota(provider: CLIProxyProvider, accountId: string, result: ManagedQuotaResult): void;
/**
 * Clear all cached quota results
 */
export declare function clearQuotaCache(): void;
/**
 * Check if account is on cooldown
 */
export declare function isOnCooldown(provider: CLIProxyProvider, accountId: string): boolean;
/**
 * Apply cooldown to an exhausted account
 */
export declare function applyCooldown(provider: CLIProxyProvider, accountId: string, minutes: number): void;
/**
 * Clear cooldown for an account
 */
export declare function clearCooldown(provider: CLIProxyProvider, accountId: string): void;
/**
 * Result of pre-flight quota check
 */
export interface PreflightResult {
    /** Whether to proceed with session */
    proceed: boolean;
    /** Account to use (may differ from original default) */
    accountId: string;
    /** If switched, the original account ID */
    switchedFrom?: string;
    /** Reason for switch or failure */
    reason?: string;
    /** Average quota percentage of selected account */
    quotaPercent?: number | null;
}
/**
 * Find healthy account with remaining quota
 * Respects tier priority and skips paused/cooldown accounts
 */
export declare function findHealthyAccount(provider: CLIProxyProvider, exclude: string[]): Promise<{
    id: string;
    tier: string;
    lastQuota: number | null;
} | null>;
export declare function reconcileExhaustedRotationAccounts(provider: CLIProxyProvider): Promise<string[]>;
/**
 * Perform pre-flight quota check before session start
 *
 * Checks if default account has sufficient quota, auto-switches if needed.
 * Respects paused accounts, tier priority, and cooldown settings.
 *
 * @param provider - CLIProxy provider
 * @returns PreflightResult with account to use and any switch info
 */
export declare function preflightCheck(provider: CLIProxyProvider): Promise<PreflightResult>;
/**
 * Get quota status for all accounts of a provider
 * Used by CLI status command
 */
export declare function getQuotaStatus(provider: CLIProxyProvider): Promise<{
    accounts: Array<{
        account: AccountInfo;
        quota: number | null;
        paused: boolean;
        onCooldown: boolean;
        isDefault: boolean;
    }>;
}>;
/**
 * Start adaptive quota monitor for an active session.
 * Polls at normal_interval (300s) when healthy, switches to
 * critical_interval (60s) when quota hits warn_threshold (20%).
 * Auto-stops on exhaustion or when stopQuotaMonitor() is called.
 *
 * Only monitors providers with quota-based account rotation.
 * No-op for other providers, manual mode, or if disabled in config.
 */
export declare function startQuotaMonitor(provider: CLIProxyProvider, accountId: string): void;
/**
 * Stop the runtime quota monitor. Safe to call multiple times.
 */
export declare function stopQuotaMonitor(): void;
export {};
//# sourceMappingURL=quota-manager.d.ts.map