/** * How soon an account's saved rate-limit resets expire, and whether anything * will spend them first. Shared by `omp usage` and the TUI status line so both * warn about the accounts the salvage planners would act on. */ import type { UsageLimit, UsageReport } from "@oh-my-pi/pi-ai"; import type { Settings } from "../config/settings.js"; import { type ResetAutoRedeemMode } from "./settings.js"; /** Saved resets close to expiry on an account whose fullest chat window is worth restoring. */ export interface ResetExpiryWarning { provider: "openai-codex" | "anthropic"; /** `soon`: the soonest reset expires within 7 days; `imminent`: within 24 hours. */ tier: "soon" | "imminent"; /** Banked resets that expire within the tier's horizon, usable now or not. */ count: number; /** Soonest expiry among them (epoch ms). */ expiresAtMs: number; /** Whether the provider lets the soonest one be spent now. */ usableNow: boolean; /** The chat window the salvage planner measures for this account. */ limit: UsageLimit; usedFraction: number; } /** * Classify an account's banked saved resets by expiry, including ones the * provider will not let it spend yet. An account whose fullest chat window is * below {@link SALVAGE_MIN_USED_FRACTION} gets no warning: the salvage * planners skip it as well. */ export declare function classifyResetExpiry(report: UsageReport, nowMs: number): ResetExpiryWarning | undefined; /** * What an open interactive omp session does with an account's soonest expiring saved * reset. `kind` comes from the provider's `autoRedeem` setting alone: `auto` * spends it by its last five minutes if the provider still allows it then, * `ask` prompts first, `off` leaves it. `eligibleNow` is the salvage planner's * answer for this report today; usage can change it before the reset expires. */ export interface ResetSpendVerdict { kind: "auto" | "ask" | "off"; setting: "codexResets.autoRedeem" | "claudeResets.autoRedeem"; mode: ResetAutoRedeemMode; eligibleNow: boolean; } export declare function resetSpendVerdict(report: UsageReport, warning: ResetExpiryWarning, settings: Settings, nowMs: number): ResetSpendVerdict; /** * One-line TUI warning for saved resets across the pool within {@link NOTICE_LEAD_MS} * of expiry, naming only those `claim` accepts. Each account's soonest due reset is * offered under a key of provider, account, and expiry minute, so a `claim` that * accepts each key once warns about every saved reset once. */ export declare function claimResetExpiryNotice(reports: readonly UsageReport[], nowMs: number, claim: (key: string, expiresAtMs: number) => boolean): string | undefined;