import type { CuttlefishConfig } from "./types.js"; export { nextKiroCreditResetAt, readKiroCreditLedger, recordKiroCreditUsage, type KiroCreditLedger, } from "./kiro-usage.js"; export type UsageState = "ok" | "low" | "exhausted" | "unknown"; export interface UsageStatus { engine: string; state: UsageState; /** Worst remaining percentage across the engine's windows, if known. */ remainingPercent?: number; /** Epoch seconds when the binding window resets, if known. */ resetsAt?: number; source: "live" | "recorded" | "estimate" | "none"; /** True when the provider exposes no authoritative quota endpoint and Cuttlefish is using local accounting. */ estimated?: boolean; } export interface UsageConfig { lowPercent: number; fallbackWindowMins: number; maxWaitMins: number; } export declare function usageConfig(config: CuttlefishConfig): UsageConfig; /** Record that `engine` hit a usage/rate limit, with its reset time if the provider gave one. */ export declare function recordEngineRateLimit(engine: string, resetsAtSeconds?: number): void; export declare function getKiroCreditUsageStatus(config: CuttlefishConfig, opts?: { now?: number; }): UsageStatus; /** * The engine's recorded reset time (epoch seconds) if it is still in the future. * Uses the provider-given reset, else `lastRateLimitAt + fallbackWindow` (default 3h). * Returns undefined once the reset has passed (the limit is considered cleared). */ export declare function getRecordedReset(engine: string, fallbackWindowMins: number, now?: number): number | undefined; export interface SnapshotLike { available?: boolean; status?: string; windows?: Array<{ usedPercent?: number; resetsAt?: number; }>; } /** Decide a usage state from a (fresher) live snapshot and/or a recorded reset. Pure. */ export declare function statusFromInputs(engine: string, opts: { recordedReset?: number; snapshot?: SnapshotLike; lowPercent: number; }): UsageStatus; /** Live usage status for one engine (recorded clock + actual snapshot). */ export declare function getEngineUsageStatus(engine: string, config: CuttlefishConfig, opts?: { now?: number; }): Promise; export interface UsagePlan { action: "proceed" | "switch" | "wait"; toEngine?: string; /** Epoch seconds to resume at (action === "wait"). */ waitUntil?: number; waitMs?: number; reason: string; } /** * Deterministic recovery decision: proceed on the current engine, switch to the * healthiest available alternate, or wait until the earliest known reset (bounded * by maxWait; falls back to the 3h window when no reset is known). Pure. */ export declare function planUsageRecovery(opts: { fromEngine: string; statuses: Record; isAvailable: (engine: string) => boolean; config: CuttlefishConfig; now?: number; }): UsagePlan; /** Convenience: gather usage status for several engines, then plan recovery. */ export declare function planUsageRecoveryLive(opts: { fromEngine: string; engines: string[]; config: CuttlefishConfig; isAvailable: (engine: string) => boolean; now?: number; }): Promise<{ plan: UsagePlan; statuses: Record; }>; //# sourceMappingURL=usage-status.d.ts.map