/**
 * Rate Limit Tracker Service
 *
 * A service that tracks which executables are rate-limited and when their
 * limits reset. Used by the dispatch system to avoid spawning sessions
 * against rate-limited executables and to select fallback executables
 * when the primary is throttled.
 *
 * Key features:
 * - Track rate-limited executables with reset timestamps
 * - Auto-expire stale entries (past reset times)
 * - Walk fallback chains to find available executables
 * - Query soonest reset time for scheduling retries
 * - Optional persistence to SQLite via SettingsService (survives restarts)
 *
 * @module
 */
import type { SettingsService } from './settings-service.js';
/**
 * A single rate limit entry for a tracked executable.
 */
export interface RateLimitEntry {
    executable: string;
    resetsAt: Date;
    recordedAt: Date;
}
/**
 * Rate Limit Tracker interface for managing executable rate limit state.
 *
 * The tracker provides methods for:
 * - Recording rate-limited executables
 * - Checking whether an executable is currently limited
 * - Walking fallback chains to find available executables
 * - Querying when rate limits will reset
 */
export interface RateLimitTracker {
    /**
     * Mark an executable as rate-limited until the given reset time.
     * If the executable is already tracked, only update if the new
     * resetsAt is later than the existing one (never downgrade).
     */
    markLimited(executable: string, resetsAt: Date): void;
    /**
     * Check whether an executable is currently rate-limited.
     * Auto-expires stale entries whose resetsAt is in the past.
     */
    isLimited(executable: string): boolean;
    /**
     * Walk the fallback chain and return the first executable that
     * is not currently rate-limited. Returns undefined if all are limited.
     */
    getAvailableExecutable(fallbackChain: string[]): string | undefined;
    /**
     * Return the earliest resetsAt among all currently-limited executables
     * (after auto-expiring stale entries). Returns undefined if nothing is limited.
     */
    getSoonestResetTime(): Date | undefined;
    /**
     * Return all currently-limited entries (after auto-expiring stale ones).
     */
    getAllLimits(): RateLimitEntry[];
    /**
     * Return true if every executable in the fallback chain is currently
     * rate-limited (after auto-expiring stale entries).
     */
    isAllLimited(fallbackChain: string[]): boolean;
    /**
     * Reset all tracked state.
     */
    clear(): void;
}
/**
 * Settings key used to persist rate limit state.
 */
export declare const RATE_LIMITS_SETTING_KEY = "rateLimits";
/**
 * Creates a RateLimitTracker instance.
 *
 * When a SettingsService is provided, the tracker persists its state to SQLite
 * (key: `rateLimits`) and hydrates from it on creation — surviving server restarts.
 * Without a SettingsService, the tracker is purely in-memory.
 */
export declare function createRateLimitTracker(settingsService?: SettingsService): RateLimitTracker;
//# sourceMappingURL=rate-limit-tracker.d.ts.map