Skip to main content

Module provider_limits

Module provider_limits 

Source
Expand description

Provider usage limits as the provider itself shows them, read ONLY from PTY screens: the node’s limit heartbeat (crate::limit_heartbeat: one light service PTY per signed-in provider account) and any node PTY session that happens to show the screen.

  • claude: /usage (and /status) — “Current session” = 5h window, “Current week” = 7d window, the plan from “Claude Max/Pro/Team/Enterprise”.
  • codex: /status — its “5h limit” and “Weekly limit” lines.

Nothing is estimated, and no other source is read: no session logs or rollouts, no provider error text (that only notifies the operator), never tokens, OAuth or auth.json. Every entry keeps its source and observed_at_ms.

Structs§

ProviderLimits
RawReading
A provider’s own limit line, kept as it was shown (providers say % used or % left).
Window

Functions§

changed
codex_reset_ms
A codex reset as shown on its screen: resets HH:MM (the next such time) or resets HH:MM on D Mon (that day; next year when already past). The screen gives no zone, so it is the node’s local time (now’s offset).
collect
Everything seen on screens now.
fresh_5h_used
The 5h window usage of provider if a reading at most max_age_ms old is known (any source).
now_ms
observe_screen
Called from the frame publisher with every scanned session screen.
observe_screen_as
Remember a limit screen under source (screen or heartbeat). True when it was one.
parse_claude_screen
Parse a claude /usage (or /status) screen. None when it shows neither.
parse_codex_status
Parse a codex /status screen: the 5h limit / Weekly limit lines (N% used, or N% left), and the reset in parentheses. Nothing else on the screen is kept (it also shows the account’s email). None when it shows no limit line.
parse_screen
Parse screen as provider’s limit screen.
reading
The percent on line and what it means. left also covers remaining.
window_from
A window from a raw reading: used and remaining both derived from it; unknown keeps both unset (routing never guesses which way a bare percent goes).