/** * Read an account's real subscription usage, and verify whether it is actually * rate-limited, from Anthropic's dedicated OAuth usage endpoint. This is a plain * GET that costs no tokens and returns the same numbers the Claude usage page * shows: the 5-hour session window, the weekly "all models" window, and a * per-model breakdown (e.g. Fable's weekly window), each with a utilization * percent and a reset time. * * Rendered cap text on screen is never trusted directly (a resumed conversation and the * resume picker replay old cap messages, and code can mention rate limits); this * endpoint is the ground truth used to confirm or refute a cap before switching. */ export type LimitVerdict = 'limited' | 'allowed' | 'unknown'; /** A per-model (or per-scope) weekly window from the usage response. */ export interface ModelWindow { /** Display name, e.g. "Fable". */ name: string; /** 0..1 utilization. */ utilization: number; /** Epoch ms reset time, when present. */ resetsAt?: number; /** Raw severity string from the API (e.g. "normal", "warning"). */ severity?: string; } export interface LimitProbeResult { verdict: LimitVerdict; /** When only one model is out, its name (for example "Fable"). */ limitedModel?: string; /** Set when the endpoint asked us to back off (429), in ms. */ retryAfterMs?: number; /** 0..1 utilization for the 5-hour session window. */ fiveHour?: number; /** 0..1 utilization for the weekly "all models" window. */ sevenDay?: number; /** Reset times (epoch ms). */ fiveHourReset?: number; sevenDayReset?: number; /** Per-model weekly windows (Fable, Opus, ...). */ models?: ModelWindow[]; /** * True when usage credits will carry this account PAST its plan limit. * * A spent plan window then says nothing about whether work will be served, so * it must not be read as the account being out of room. */ creditsCarryPastLimit?: boolean; detail?: string; } /** Read the OAuth access token from a credentials file, or null. */ export declare function readOauthToken(credentialsFile: string): string | null; /** * Fetch usage + decide a limit verdict from ONE GET. Fail-safe: no token, a * network error, or an unexpected status all yield verdict 'unknown' (never a * false 'limited'). `renderedText` narrows the verdict to a named model's window * when a per-model cap is on screen (e.g. "Fable 5 limit"). */ export declare function probeLimit(credentialsFile: string, renderedText?: string, fetchImpl?: typeof fetch): Promise; /** Read the account-wide usage picture (no cap decision needed). */ export declare function probeUsage(credentialsFile: string, fetchImpl?: typeof fetch): Promise;