import type { ResetCreditAccountStatus, ResetCreditRedeemOutcome } from "./auth-storage.js"; /** An account's last recorded attempt: `pending` (sent, unconfirmed) or `reset`, and when it started. */ export interface ResetMarker { state: string; atMs: number; } /** Records `pending` around one consume, then `reset`, or clears the marker when nothing was spent. */ export type MarkedRedeem = (redeem: () => Promise) => Promise<{ outcome: ResetCreditRedeemOutcome; attemptedAt: number; }>; /** Lock file for one `resetAccountLockKey`, beside the agent database unless `root` replaces it. */ export declare function resetLockPath(lockKey: string, root?: string): string; export declare function readResetMarker(lockPath: string): Promise; /** * Hold the account's lock, then run `onRecent` when another attempt started * within `ATTEMPT_COOLDOWN_MS`, or `spend` otherwise. Both run under the lock. */ export declare function withResetFence(lockPath: string, onRecent: (marker: ResetMarker) => Promise, spend: (redeem: MarkedRedeem) => Promise): Promise; /** * Codex's live balance for one credential, re-read under the fence. `spent` * means it fell below the `expected` count the spend was decided on. */ export declare function checkCodexBalance(statuses: readonly ResetCreditAccountStatus[], credentialId: number, expected: number | undefined): "spent" | "credit_list_failed" | "no_credit" | undefined;