Skip to content

feat(ai): provider quota functions and opencode quota subcommand - #1722

Merged
dezren39 merged 1 commit into
mainfrom
quota-subcommand
Nov 5, 2026
Merged

dezren39 merged 1 commit into
mainfrom
quota-subcommand

Conversation

@dezren39

@dezren39 dezren39 commented Nov 5, 2026

Copy link
Copy Markdown

Implements developing-today/code#6125: all quota info from one source — the opencode quota subcommand. Quota is a provider function implemented in the provider (@opencode/ai/quota), porting the OpenChamber quota module's wire behavior without redesigning endpoints.

What

  • packages/ai/src/quota/ — per-provider quota functions returning the module result shape, one result per credential instance: antigravity, claude, cline-pass, codex (with instance folding), command-code (plan read only), deepseek, groq, meta (portal read + key-endpoint cross-check), mistral (including the admin console budget read: API $15/mo + Vibe $150/mo dollar windows via CDP in-page fetch or stored console cookie), opencode-go (API key + Console OAuth), opendesign (reads OpenChamber's managed credential store read-only — the AMR key is refused by the billing API), openrouter, plus a built-in turso fetcher (org usage API, token resolved from BWS by name).
  • opencode quota [--json] [PROVIDER...] [--all] in packages/cli — no args = every configured provider (disabled_providers skipped unless --all or explicitly named; turso always included, error entry if its token cannot resolve), JSON array one result per credential instance, exit non-zero iff a requested provider produced no successful result.
  • Claude results carry credentialExpiresAt + credentialSource on success and error results alike.
  • Groq has no first-party quota surface (evidence comment on code#6125): the provider probes response rate-limit headers and otherwise returns failureClass: no-quota-surface — never fabricated numbers.

Tests

  • packages/ai/test/quota.test.ts — mistral budget fixture mapping ($ windows from usage_percentage), meta portal mapping, turso mapping, groq reset parsing: 7/7.
  • packages/cli/test/quota.test.ts — exit-code grouping + human rendering: 4/4.
  • tsgo clean in packages/ai and packages/cli.
  • Note: packages/cli test/auth.test.ts has pre-existing load-sensitive 5s-timeout failures on this machine, present with and without this change (verified via stash).

Live proof (built binary, real credentials)

Built dist/cli-linux-x64/bin/opencode (v2.0.30+quota, channel prod) from this branch and ran it against the laptop's real credential store: default run emits 14 rows — every pool ok except claude (Anthropic 429 rate limit on the usage endpoint, reported honestly). Mistral shows API $0.84/$15 (5.61%) and Vibe $0.06/$150 (0.043%), reset 2026-12-01, matching console truth. Named quota meta command-code groq bypasses the disabled filter; meta reports via the key endpoint (portal session expired), groq reports no-quota-surface.

Port the OpenChamber quota module wire behavior into @opencode/ai as per-provider quota functions (antigravity, claude, cline-pass, codex, command-code, deepseek, groq, meta, mistral incl. the admin console budget read, opencode-go, opendesign via the OpenChamber managed credential store, openrouter) plus a built-in turso fetcher (token via BWS), and register the quota subcommand in the CLI: opencode quota [--json] [PROVIDER...] [--all], one result per credential instance, named asks bypass disabled_providers, exit non-zero iff a requested provider produced no successful result. Groq has no first-party quota surface (evidence on developing-today/code#6125) and reports failureClass no-quota-surface.
@dezren39
dezren39 merged commit 13ab3dc into main Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant