Skip to content

grok accounts - #29

Open
pedroapfilho wants to merge 1 commit into
RubricLab:mainfrom
pedroapfilho:grok-accounts
Open

grok accounts#29
pedroapfilho wants to merge 1 commit into
RubricLab:mainfrom
pedroapfilho:grok-accounts

Conversation

@pedroapfilho

Copy link
Copy Markdown
Contributor

Adds xAI as a third provider: Grok accounts sign in, switch, auto-rotate and meter alongside Codex and Claude Code.

What

  • tokenmaxx login grok runs the official grok CLI against an isolated GROK_HOME, imports auth.json (OIDC session against https://auth.x.ai), stores it in the keychain and refreshes it in-process. --api-key accounts go to api.x.ai.
  • Routing: [endpoints] cli_chat_proxy_base_url in ~/.grok/config.toml, written inside an existing [endpoints] table when there is one, reclaimed if grok re-serialises the file. install, uninstall, doctor, heal-on-update and the dashboard settings toggle all cover it.
  • Pressure: xAI reports no rate-limit headers, so a 429 fills one synthetic limit window (reset from retry-after) and the probe clears it once the reset passes. That is what makes Grok accounts eligible for rotation and the proxy's retry-on-next-account.
  • PROVIDERS table in domain.ts replaces the scattered vendor/app/cli name lookups; installStatus() returns routed: Record<ProviderId, boolean>; tokenmaxx auto all replaces both.
  • Shared extractions instead of a third copy: src/login.ts (isolated-login dependencies, codex uses it too) and readApiKey in vault.ts.
  • Pricing for grok-4.6 / 4.5 / build / 4, fixtures with two Grok accounts, pi gets a tokenmaxx-xai provider, README updated.

Verified live

  • tokenmaxx login grok → device-code flow → signed in, config routed.
  • grok -p "say hi" --no-auto-update → answered through the proxy; token_events has grok-4.6-build rows (4063 in / 35 out).
  • bun run check: typecheck, biome, 111 tests (16 new: grok.test.ts, xai cases in ratelimit.test.ts and config-install.test.ts).

Known limits

  • Grok meters are empty until a 429; auto-rotation for Grok is hard-limit driven, not threshold driven.
  • Plan tier is null — nothing in auth.json or userinfo names the subscription.
  • The live model id is grok-4.6-build, priced at the grok-4.6 rate; adjust in pricing.ts if xAI lists it differently.
  • The refresh-token grant and userinfo are exercised by the 60 s probe; the first refresh happens ~6 h after login.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant