feat(ai): add xai-oauth SuperGrok device-code login - #1639
Closed
GratefulDave wants to merge 1 commit into
Closed
Conversation
Add a separate xai-oauth provider for SuperGrok / X Premium+ device-code auth against api.x.ai, clone the xAI catalog onto that provider, and flatten exclusive-required MCP object-root unions so xAI does not 400 the whole turn.
|
Hi @GratefulDave, thanks for your interest in contributing! This project requires that pull request authors are vouched, and you are not in the list of vouched users. This PR will be closed automatically. See https://github.com/PrimeIntellect-ai/prime-agent/blob/main/CONTRIBUTING.md for more details. |
Author
|
Opened a Feature Request so this can go through the documented intake: #1640 Branch remains at |
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.
Summary
xai-oauthas a built-in provider for SuperGrok / X Premium+ device-code login (auth.x.ai).xaiunchanged. OAuth inference uses the OpenAI-compatiblehttps://api.x.ai/v1endpoint withX-XAI-Token-Auth: xai-grok-cli.xai-oauth(default modelgrok-4.6).anyOffragments before send; leftover object-root unions quarantine that one tool instead of 400ing the turn./loginshows "xAI Grok OAuth". Optional env:XAI_OAUTH_TOKEN(auth.jsonkey:xai-oauth).Validation
packages/ai:test/xai-oauth.test.ts,test/openai-completions-xai-root-union.test.ts(25 passed)npm run checkpassed on the v0.8.0 overlay branch before this cherry-pickNotes
xai, so API-key and subscription auth stay independent.main(e319a66d7) with catalog clone + the MCP schema flatten that xAI currently requires.Note
Add
xai-oauthSuperGrok device-code login and fix xAI tool schema handlingxai-oauthOAuth provider in xai.ts implementing RFC 8628 device-code login againstauth.x.ai, token refresh, endpoint validation restricted tohttps://*.x.ai, andmodifyModelsthat pins SuperGrok models toXAI_API_BASE_URLwithXAI_OAUTH_API_HEADERSxaiOAuthProviderin index.ts viaBUILT_IN_OAUTH_PROVIDERS, adds'xai-oauth'toKnownProviderin types.ts, maps it toXAI_OAUTH_TOKENin env-api-keys.ts, and sets default modelgrok-4.6in model-resolver.tsxai-oauthnamespace in models.generated.ts via generate-models.ts, addinggrok-4.6and header{"X-XAI-Token-Auth":"xai-grok-cli"}convertTools, dropping tools whose object-rootanyOf/oneOfschemas xAI rejects (via xai-tool-schema.ts), and removingtool_choicewhen it references a dropped or nonexistent toolshouldDropToolChoicenow deletesparams.tool_choicewhen tools are empty withtool_choiceset to'none'/'required'/object, or when atool_choiceobject references a function absent fromparams.tools;convertToolsnow omits individual tools with unfixable root unions forxaiandxai-oauthproviders instead of sending the full set and failing the requestMacroscope summarized 5778cad.