feat: add OpenCode Zen Go official usage quota provider - #1
Open
abduznik wants to merge 2 commits into
Open
Conversation
Fetches the official OpenCode Zen Go usage API (GET opencode.ai/zen/go/v1/usage)
and shows rolling (5-hour), weekly and monthly utilisation with reset times in
a quota panel on the usage tab.
- New providers::opencode_go module: URL const, browser UA (the API 403s the
default ureq UA), 60s result cache, key resolution (OPENCODE_GO_API_KEY env
var, falling back to ${HERMES_HOME}/.env for Hermes portable), pure JSON
parser.
- app.rs: StateInner and UsageView carry the ZenGoUsage; refresh() fetches it
in the background alongside the Claude limits, lock-free.
- +page.svelte: ZenGoLimits types + quota panel mirroring the Claude limits
card (utilization bars and reset times).
- README: document the quota panel and key sources.
- Version bump 0.4.1 -> 0.4.2 (package.json, package-lock, Cargo.toml,
tauri.conf.json, Cargo.lock).
351 tests pass, including a live fetch against the real endpoint (skips when
no key is configured).
The only audit finding is cookie <0.7.0 (3 low), pulled transitively by @sveltejs/kit@2.70.2. npm audit fix --force would downgrade to a breaking pre-release (@sveltejs/kit@0.0.30), so pin via overrides instead: cookie 0.6.0 -> 0.7.2. npm audit now reports 0 vulnerabilities. Verified: npm run check (0 errors), npm run build, cargo test (351 passed).
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.
What
Adds an OpenCode Zen Go quota panel to the usage tab — the official cloud usage feed (
GET https://opencode.ai/zen/go/v1/usage, same data as the web panel) showing rolling (5-hour), weekly and monthly utilisation percentages with their reset times, alongside the existing Claude/Codex limits cards.This covers OpenCode usage that isn't visible in local logs — the OpenCode provider already tracks the local
opencode.db, but token burns through Zen Go API providers (e.g. Hermes Agent pointed atopencode.ai/zen/go/v1) are only visible on the cloud-side quota feed.How it works
providers::opencode_gomodule:fetch_zen_go_usage(key)— oneureqGET,Authorization: Bearer, browserUser-Agent(the endpoint 403s the defaultureqUA), 5 s timeout, 60 s result cache (same cadence asclaude_limits).resolve_api_key()—OPENCODE_GO_API_KEYenv var first, falling back to${HERMES_HOME}/.env(the Hermes portable convention) so the quota lights up automatically under that setup without any extra config.parse_zen_go_usage(Value)parser with unit tests against the real response shape (usage.rolling/weekly/monthlywithstatus/percent/resetsAt).app.rs—StateInnerandUsageViewcarryZenGoUsage;refresh()fetches it lock-free alongside the Claude limits; missing key →None→ panel hidden.+page.svelte—ZenGoLimitstypes and a quota card mirroring the Claude limits card (labels, percent, track fill). Rendered only when at least one bucket is present.0.4.1 → 0.4.2.Testing
providers::opencode_go::tests::test_live_fetch_zen_go_usage— verified green against the live API.npm run check(svelte-check / tsc): 0 errors.Notes
/usageexists on the Zen Go API — no raw token counts or other endpoints, so the quota is percent + reset time, matching the web panel.