Repository navigation
feat(ai): provider quota functions and opencode quota subcommand - #1722
Merged
Merged
Conversation
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.
This was referenced Nov 5, 2026
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements developing-today/code#6125: all quota info from one source — the
opencode quotasubcommand. 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.credentialExpiresAt+credentialSourceon success and error results alike.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.packages/clitest/auth.test.tshas 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. Namedquota meta command-code groqbypasses the disabled filter; meta reports via the key endpoint (portal session expired), groq reportsno-quota-surface.