import type { FetchImpl } from "../types.js"; /** A single redeemable (or already-spent) saved reset. */ export interface CodexResetCredit { /** Opaque credit id, e.g. `RateLimitResetCredit_…`. Pass to {@link consumeCodexResetCredit}. */ id: string; /** Backend reset family, e.g. `codex_rate_limits`. */ resetType?: string; /** `available`, `redeemed`, … */ status?: string; grantedAt?: string; expiresAt?: string; redeemStartedAt?: string | null; redeemedAt?: string | null; /** Human-facing card title, e.g. "One free rate limit reset". */ title?: string; description?: string; } /** Result of listing an account's saved resets. */ export interface CodexResetCreditList { credits: CodexResetCredit[]; /** Backend-reported count of credits redeemable right now. */ availableCount: number; } /** * Consume outcome `code`. `reset` means a window was actually reset; the others * are no-op business outcomes the caller should surface verbatim-ish to the user. */ export type CodexResetConsumeCode = "reset" | "already_redeemed" | "no_credit" | "nothing_to_reset" | (string & {}); export interface CodexResetConsumeResult { /** `true` only when `code === "reset"` (a reset was applied). */ ok: boolean; code: CodexResetConsumeCode; /** HTTP status of the consume call (for diagnostics). */ status: number; raw?: unknown; } interface CodexResetAuth { accessToken: string; accountId?: string; /** Provider base URL override; defaults to the Codex backend. */ baseUrl?: string; fetch: FetchImpl; signal?: AbortSignal; } /** * List the account's saved rate-limit resets. Returns `null` on transport/auth * failure (non-2xx or thrown), letting callers treat it the same as "no data". */ export declare function listCodexResetCredits(auth: CodexResetAuth): Promise; /** * Pick the credit to spend: the available one that expires soonest. * * Credits are perishable, so spending in expiry order maximizes the bank's * lifetime value. Available credits without a parseable `expiresAt` rank after * dated ones; when nothing is available the first credit is returned unchanged * (the consume then surfaces the backend's business outcome verbatim). */ export declare function pickSoonestExpiringCredit(credits: readonly CodexResetCredit[]): CodexResetCredit | undefined; /** * Spend one saved reset. `redeemRequestId` is the idempotency key; one is * generated when omitted, so retrying with the SAME id is safe and won't * double-spend. The returned `code` is `"reset"` on success. */ export declare function consumeCodexResetCredit(auth: CodexResetAuth & { creditId: string; redeemRequestId?: string; }): Promise; export {};