You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 178ae20
Browse filesBrowse the repository at this point in the historyBrowse files
feat(opencode-zen): pay-as-you-go balance via billing-page scrape
OpenCode Zen's PAYG account has no JSON usage endpoint yet
(anomalyco/opencode#10448), so this vendor scrapes the workspace
billing page with the session `auth` cookie and parses the embedded
SolidStart data. It complements the existing `opencode-go` vendor:
Go-plan percentage windows stay there; Zen here reports the prepaid
balance in USD.
- Parser: anchored field scan after the `billing.get[` anchor plus a
rendered `data-slot` fallback. Unit handling learned from a live
capture (2026-08): balance/usage/payments are billing units where
1 USD = 1e8 units, but reloadAmount/reloadTrigger are plain dollars.
Missing fields are legal (monthlyLimit is null on most accounts); a
missing balance is schema drift -> AppError::Schema, never $0.00.
No new dependencies — hand-rolled byte scanners, fully unit-tested.
- Fetch: lock -> fresh cache (300s TTL; the HTML console must not be
hit on every Waybar tick) -> live scrape -> stale fallback (7d).
Error paths are terse by construction: fixed status messages and a
hashed workspace id keep the cookie out of every rendered surface.
- Render: bar shows `$balance` (DeepSeek-style balance vendor). With
a dashboard monthly limit set, severity follows consumed %; without
one, absolute bands driven by configurable low_balance_warn_usd.
Tooltip adds spend, auto-reload state and last top-up.
- Config `[opencode-zen]`: enabled/workspace_id/auth_cookie/
low_balance_warn_usd. No env var on purpose — OPENCODE_* collides
with the opencode client's own variables. A non-empty cookie
auto-tightens the config file to 0600.
Verified against a live workspace capture and via the new
#[ignore]d `opencode_zen_live` smoke test (make smoke).
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,6 +144,7 @@ come from environment variables or `config.toml`.
144
144
| Kiro CLI | Existing kiro-cli login | Opt in and run `kiro-cli login` once. ai-usagebar refreshes the session when needed. |
145
145
| Nous Research | OAuth device flow | Enable `[nous]`, click **Log in with Nous Research** in the Omarchy settings panel, or run `ai-usagebar auth nous login`. Credentials are kept in ai-usagebar's separate platform config directory (`~/.config/ai-usagebar/credentials.json` on Linux). |
146
146
| OpenCode Go | API key (`OPENCODE_GO_API_KEY` env or `[opencode-go] api_key` in config) | Enable `[opencode-go]`, then enter the key in the Omarchy settings panel or set the environment variable. |
147
+
| OpenCode Zen | Session cookie (`[opencode-zen] auth_cookie` in config) | Opt in. Copy the workspace id from your billing URL and the `auth` session cookie from your browser (DevTools → Cookies); both live under `[opencode-zen]`. Reports the pay-as-you-go balance, not Go-plan quotas. |
Copy file name to clipboardExpand all lines: docs/vendor-endpoints.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ defensive and includes opt-in live tests for catching response changes.
24
24
|**Kiro CLI**|`codewhisperer.<region>.amazonaws.com``GetUsageLimits` (undocumented; the same call kiro-cli's own `/usage` slash command makes) | Single credit pool this cycle — used/limit/%, plan, reset | No — widget/TUI only |
|**OpenCode Go**|`opencode.ai/zen/go/v1/usage`| Rolling, weekly, and monthly `percent` windows with absolute reset timestamps | Yes |
27
+
|**OpenCode Zen**|`opencode.ai/workspace/{id}/billing` HTML (undocumented; the web console's own page, scraped with the session `auth` cookie — no JSON endpoint exists yet, anomalyco/opencode#10448) | Pay-as-you-go balance ($), monthly usage vs optional limit, auto-reload config, last top-up | No — widget/TUI only |
0 commit comments