Repository navigation
Conversation
The console status endpoint accepts the OAuth access token that the opencode-console CLI already stores, so OpenCode Go usage can be polled without asking for a browser session cookie. Read the login from ~/.local/share/opencode-console/credential.json (also $XDG_DATA_HOME/... or OPENCODE_CONSOLE_CREDENTIAL_FILE), take its orgID and access fields, and send them as x-org-id and Authorization: Bearer. Explicit environment variables and the saved dashboard configuration keep precedence, and the legacy cookie path behaves exactly as before. Credential-change tracking now hashes the auth kind and watches the console login file, so a refreshed token triggers a new poll.
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.
Why
OpenCode Go is the only provider that requires a manual credential: the README asks for a workspace ID plus the
__Host-console_sessioncookie from an authenticated browser session, and that cookie has to be refreshed by hand whenever the session expires.Anyone who uses OpenCode Go through the OpenCode Console CLI already has a working login on disk, and the console status endpoint accepts it. Polling it removes the manual step entirely.
What
~/.local/share/opencode-console/credential.json($XDG_DATA_HOME/opencode-console/credential.json, or the file named byOPENCODE_CONSOLE_CREDENTIAL_FILE), take itsorgIDandaccessfields, and send them asx-org-idandAuthorization: Bearer <access>instead of a cookie.OPENCODE_GO_WORKSPACE_ID+OPENCODE_GO_AUTH_COOKIE, then the saved dashboard configuration (%APPDATA%\opencode-go\config.jsonand the other paths), then the console login. Existing setups behave exactly as before.Verification
cargo test --locked --release --bin claude-code-usage-monitor poller::opencode: 14 passed, 0 failed. Five are new: parsing the login file (includingorgID/orgId/org_idspellings and trimming), rejecting missing fields, header injection and short workspace slugs, the bearer request being sent without aCookieheader, and a 401 mapped toAuthRequired.cargo fmt --checkandcargo clippy --locked --release --bin claude-code-usage-monitor -- -D warningsare clean.GET https://opencode.ai/console/api/go/statuswithAuthorization: Bearertaken from the console login returns200withaccess.meters.fiveHour/week/month; the same token sent asCookie: auth=…orCookie: __Host-console_session=…returns401, which is why the header path is needed rather than reusing the cookie code.usage-cache.json(session 9.7 %, weekly 3.9 %, monthly 1.9 %), so the tray widget and themes render real values instead of the error placeholder.Notes
opencode-consolecommand refreshes the login, and afteropencode-console logoutthe poll reports the existing "sign in again" state.