Repository navigation
feat(console): add go usage endpoint - #16513
Conversation
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Hey, any news on merging this? |
|
no clue |
|
+++ |
|
I would like to see this implemented |
|
+1 for implementing this. In the meantime I'm using this hacky solution https://pi.dev/packages/pi-go-bars |
|
I would like to see this implemented |
|
Official support would be nice. If you need usage and quota tracking in opencode, https://github.com/slkiser/opencode-quota |
|
up |
|
I'd employ this feature. |
|
+1 |
|
+1 |
|
Did they truly forget about this? |
|
Would really love this for OpenUsage. A lot of users keep asking, and the local SQL is unreliable. |
|
+1 |
|
+1 pls merge this |
|
Upstream v1.18.16 (a3647eb) -> v1.18.17 (02546df), 32 commits. Functional changes: - fix(compaction): clearer instructions for smaller models like dsv4 flash (anomalyco#42045) - fix(provider): add Merge Gateway reasoning variants (anomalyco#41867) - fix(opencode): cap session retries with jitter (anomalyco#41939) - retry policy gains RETRY_MAX_RETRIES=5 global cap and 25% jitter - fix(opencode): detect Copilot PDF input support (anomalyco#41522) - fix(provider): scope DeepSeek V4 Flash sampling defaults (anomalyco#41620) - fix(session): route all Muse family models to the Meta system prompt (anomalyco#41581) - fix(app): use current default model (anomalyco#38603) - feat(console): add go usage endpoint (anomalyco#16513) and r2 data catalog stats - fix(ui): correct OC-2 weak icon color (anomalyco#41504) - fix(i18n): use widely recognized developer terminology (anomalyco#41532) Conflicts resolved: 30 package.json version bumps (rebranded 1.18.17-sscity), bun.lock (took upstream, rebranded workspace entries via bun install), and session/retry.ts (kept fork per-reason maxAttempts cap alongside upstream RETRY_MAX_RETRIES global cap and jitter).
Co-authored-by: vimtor <[email protected]>
Co-authored-by: vimtor <[email protected]>
Co-authored-by: vimtor <[email protected]>
Co-authored-by: vimtor <[email protected]>
GET /zen/go/v1/usage merged in anomalyco/opencode#16513 and now answers in production, so the parser no longer has to guess. The route returns `{ usage: { rolling, weekly, monthly } }`, each window holding a status, a floored percent and an ISO reset, and nothing else; the aliases and dollar fallbacks written against the proposal are gone. A window marked `rate-limited` reads as spent, since its floored percent can say 99. A valid key on a workspace without Go answers 403 with an EntitlementError, which now reads as no subscription instead of a rejected key, and a 404 is drift rather than an outage. The cookie still ranks above the key because only the console publishes dollars.
Co-authored-by: vimtor <[email protected]>
opencode exposes no plan limits, but opencode.ai has an undocumented usage route (GET /zen/go/v1/usage, anomalyco/opencode#16513) that answers the 5-hour, week and month windows with a status, a percent and a reset time. The Agents panel, the status bar and its hover now show them like Claude's and Codex's, a rate-limited window in red, on the same refresh interval. The key comes only from `opencode auth export` run in the temporary folder: the active opencode-go API key, every other entry ignored. It lives for that one request, goes to opencode.ai over https in the Authorization header and nowhere else: never written, logged, shown or passed to a child; zinc.json asks for net:opencode.ai only. A Settings toggle, on by default, turns it off. Off, no key, a revoked or expired key, a 403 or an answer the app does not know show « unknown », the reason and the console link. agents_go.sh drives a fake export and made-up route answers (nothing goes to the network) and checks the fake key appears in no file of the run: data, settings, output, scenes, child arguments and environment. One read-only check against the real route returned three windows ok. New-task: owner ZN-770 OpenCode Go usage read with the Go key

Issue for this PR
Closes #16017
Type of change
What does this PR do?
this PR adds an API endpoint at
/zen/go/v1/usagethat will provide the same opencode go usage data as in the zen workspace dashboard.If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!
How did you verify your code works?
unfortunately i don't think this is a change i can verify as an outside contributor. i did try running
bun dev:remotebut met with cloudflare api key error.I did copy the pattern in
/zen/v1/modelsand copied the logic from/workspace/[id]/billing/lite-section.tsxScreenshots / recordings
not a ui change
Checklist
i guess running dev server and building counts as testing? but yea i don't think i can test this feature locally
If you do not follow this template your PR will be automatically rejected.