Repository navigation
Conversation
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.
Problems
code 1000 身份验证失败:ZHIPU_QUOTA_QUERY_URLpoints tohttps://bigmodel.cn— that is the web-console origin (cookie auth). The API origin for the same path ishttps://open.bigmodel.cn(matches Z.ai's official usage-query plugin, zai-org/zai-coding-plugins, and community tools tokn / cc-switch / CodexBar).TOKENS_LIMIT. Since the 2026-07-30 credit revision plans reportCREDIT_LIMITand return two windows — 5-hour rolling (unit==3) + weekly (unit==6) — so weekly usage was invisible and credit plans showed nothing.accesstoken the tool errors out even thoughauth.jsonholds a validrefreshtoken.Changes
zhipu.ts: correct host;Accept-Languageheader; render all windows (5h tokens/credits + weekly + MCPTIME_LIMIT), plan level in the title, precise percentage fromcurrentValue/usagewhen available (serverpercentageis floor'ed); on auth failure, one retry against the other host (keys are host-specific — a zhipuai key only works on open.bigmodel.cn, a z.ai key only on api.z.ai).openai.ts: refresh viaPOST https://auth.openai.com/oauth/token(grant_type=refresh_token, client_idapp_EMoamEEZ73f0CkXaXp7hrann— the same public client OpenCode and codex-rs use), on expiry or HTTP 401; the rotated refresh token is persisted atomically toauth.json(temp+rename, mode 0600, other providers preserved); refresh failures return an actionable re-login hint.Evidence
Authorization: <raw token>primary (Bearer also accepted).packages/opencode/src/plugin/openai/codex.ts(same client_id, form-encoded body, rotated rt persisted back).level+ both windows; expired lineage returns cleaninvalid_refresh_token+ re-login message.Testing
npm run typecheck,npm run build,npm run lintall pass.level) fixtures correctly.