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 xAI authentication handling to support SuperGrok subscriptions by redirecting credentials from ANTHROPIC_API_KEY to XAI_API_KEY and adding token expiry validation. Existing behavior affected: xAI users, MCP token env guards, and setup-auth login flow. What could break: repos naming XAI_API_KEY or XAI_OAUTH_ACCESS_TOKEN for non-xai purposes are now refused; oauth runs fail fast on expired or near-expiry tokens; setup-auth depends on bundled OpenCode CLI method labels. Rollback is direct. 🔎 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.
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. A live access token is reused. If the env var is already set, the login is skipped.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, the run warns and continues.XAI_API_KEY. setup-auth prints https://console.x.ai. It does not run "Manually enter API Key".xai. An MCP server token env cannot use either.mode: "oauth"still caps concurrency at 3.buildOpencodeConfigdoes not add aprovider.xaiblock.Test Plan
bun testonauth,setup-auth,opencode,mcp-servers, andreview-internals: 182 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-authdevice login, thenecr doctor, then one short local review onxai/…. If that review returns 402 or 403, stop and report the host. Do not send the oauth token toapi.x.ai.