Repository navigation
Conversation
xAI models already run on OpenCode, and the pinned CLI can sign in with SuperGrok. setup-auth treated that oauth entry as unsupported, so a review never received the access token.
🤖 AI code reviewDecision: Ready for human review Overall PR risk: Medium. This change modifies auth validation, the setup-auth command, and xai provider handling. Existing configurations with oauth entries that name another provider's token through an upstream alias are now rejected, and auth tokenEnv entries containing non-identifier characters now fail at load. The blast radius is limited to credential handling, and rollback requires only a plain revert. 🔎 Reviewer summaries (3)
No findings. This review is advisory — it never blocks a merge and never auto-approves. |
An xAI oauth entry with no tokenEnv cannot run. setup-auth was filling in XAI_OAUTH_ACCESS_TOKEN and printing an export, then the review rejected the same config.
An alias with upstream "xai" could carry an xAI credential under another provider id. A ChatGPT access token also passed the xAI check, because the Codex env names had no owner. An api-key entry that named XAI_OAUTH_ACCESS_TOKEN copied the token into XAI_API_KEY with no expiry check. The docs said a run warns about a token that lapses soon, but only doctor printed the warning. prepareAuth now returns the warnings of the tokens it staged, and the review prints them. An xai api-key entry with no tokenEnv relies on OpenCode's own login again, as it did before XAI_API_KEY had an owner.
The review names `ecr setup-auth` as the fix for an expired token. setup-auth skipped the login while the env var was set, so the fix did nothing. It also reused a stored token with seconds left and called it "1 more hour(s)". It now reuses a token only when a review takes it with no error and no expiry warning. The access token lasts hours, so the README says this mode suits local runs. An auth tokenEnv must be an env var name, because setup-auth prints it into an export line. The OpenCode logins turn project config off. OpenCode reads config from every parent of its cwd, and the login cwd is the shared /tmp on Linux.
A device login through the pinned OpenCode gave a 6-hour access token. Staged the way a review stages it, that token completed one direct request and one local review on xai/grok-4.7.
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
xai/…models already run on OpenCode. The pinned CLI can sign in with SuperGrok (opencode auth login -p xailistsSuperGrok Subscription), butecr setup-authfiled anxaioauth entry as unsupported. A review also had no owner forXAI_API_KEYorXAI_OAUTH_ACCESS_TOKEN, so an xAI API key was copied intoANTHROPIC_API_KEY.Claude reviews still do not write
auth.json. The token goes on the Claude child. Codex reviews write an isolatedauth.json, and a SuperGrok review does the same with the access token.How
ecr setup-authruns the bundledopencode auth login -p xai -m "SuperGrok Subscription"from a temp directory. It readsxai.accessfrom OpenCode's store and printsexport XAI_OAUTH_ACCESS_TOKEN='…'. The refresh token stays in that store.ecr setup-authas the fix.prepareAuthwrites that JWT into the isolated$XDG_DATA_HOME/opencode/auth.jsonas{ type: "oauth", access, refresh: "", expires }. It does not setXAI_API_KEYfrom the access token.ecr setup-auth. So does a JWT that is expired or has 120 seconds or less left. Under about two hours left,ecr doctorand the run both warn and continue.XAI_API_KEY. setup-auth prints https://console.x.ai. It does not run "Manually enter API Key". Anxaiapi-key entry with notokenEnvstill relies on OpenCode's own login.xai, and an alias withupstream: "xai"cannot borrow them. The twoCODEX_OAUTH_*names now belong toopenai. An api-key entry that namesXAI_OAUTH_ACCESS_TOKENis refused. An MCP server token env cannot use either xAI name.mode: "oauth"still caps concurrency at 3.authtokenEnvmust be an env var name, because setup-auth prints it into an export line. There is no OpenCode bump, andbuildOpencodeConfigdoes not add aprovider.xaiblock.OPENCODE_DISABLE_PROJECT_CONFIG=1. OpenCode reads config from every parent of its cwd, and the login cwd is the shared/tmpon Linux.Test Plan
bun test: 1184 pass.bun run typecheck,bun run lint,bun run fmt:check, andbun run llp:check.opencode-ai@1.19.5:opencode auth login -p xai -m '__no-such-method__'listsSuperGrok SubscriptionandManually enter API Key.ecr setup-authdid the device login,ecr doctorpassed, and one short local review onxai/grok-4.7completed. It found the off-by-one bug in the test diff. The access token was a JWT with a 6-hour lifetime.https://api.x.ai/v1/responses. A run with a placeholder token showed that host and got a 400. With the real token staged the same way, a direct request and the review both completed.ecr setup-authon Node with an expired, a live, and a 90-minute token in the env. It signs in again for the first and the third, and it skips the login for the second.