Provider & subscription

panto-codex

rock 0.3.0-1Source

Codex subscription defaults for panto. Mark named tables; the extension fills the boilerplate.

Setup

Requires panto's configure(config) extension hook (before auth/provider validation).

TOML
[extensions]
rocks = ["panto-codex"]

[auth.codex]
panto_codex_extension = true

[providers.codex]
auth = "codex"
panto_codex_extension = true
SH
panto auth login codex
panto models sync
panto models list codex:

Defaults

SettingValue
AuthCodex device OAuth; credentials and refresh stay in panto
ProviderResponses API with the Codex dialect; openai model catalog
Endpointhttps://chatgpt.com/backend-api/codex
HeadersOpenAI-Beta: responses=experimental, originator: codex_cli_rs, session-id: ${session:id}

Rules

  • Only panto_codex_extension = true opts in; auth/provider names are arbitrary.
  • Keep providers.<name>.auth explicit; the extension never guesses linkage.
  • Explicit values win, including nested endpoints and case-insensitive headers.
  • Defaults are independent per table and per load; no config files are rewritten.
  • Credentials stay native; env and session placeholders stay raw for panto, which expands ${session:id} to the conversation's stable session ID.
  • Rigs inherit user connection settings after this hook runs, so they need not include this extension unless their own config uses its markers. --no-extensions skips the hook.

Flat and endpoint-table provider configurations are supported. Overrides must remain valid panto configuration.

Quota polling requires panto's http_request API and the render_footer event. It runs only when this extension is permitted and at least one marked auth or provider subscription is configured.

  • It queries every distinct named auth, not only the current model.
  • Polls start at session_ready, repeat about every 60 seconds when luv is available, and are throttled after turns.
  • Failed snapshots are retained and marked stale, with bounded retry backoff.
  • Session end cancels the timer and any in-flight request.
  • One shared logical usage row wraps to the terminal width.

The monitor uses Codex's internal https://chatgpt.com/backend-api/wham/usage endpoint, which is undocumented and subject to change. It calls through panto's named-auth HTTP API with the configured OAuth access token; panto derives ChatGPT-Account-Id from the auth account claim. It never logs in interactively and never reads token files.

The footer uses lowercase provider and window labels, highlighted headings, and green/yellow/red percentages at 33% and 66%:

TEXT
codex 5h 42%  reset in 2h 14m    7d 18%  reset in 3d 4h

A shared, unreferenced minute timer keeps countdowns current while idle; it does not fetch usage. Claude stays absent until its model is first used.

Packaging / checks

SH
panto lua _selfcheck.lua
panto lua _footer-selfcheck.lua
luarocks lint panto-codex-0.2.0-1.rockspec

The rockspec maps require("panto-codex") to init.lua, the quota poller and shared footer helper to their modules; no dependencies beyond Lua.

References