hermes-agent/website/docs/guides
Jaaneek b62c997973 feat(xai-oauth): add xAI Grok OAuth (SuperGrok Subscription) provider
Adds a new authentication provider that lets SuperGrok subscribers sign
in to Hermes with their xAI account via the standard OAuth 2.0 PKCE
loopback flow, instead of pasting a raw API key from console.x.ai.

Highlights
----------
* OAuth 2.0 PKCE loopback login against accounts.x.ai with discovery,
  state/nonce, and a strict CORS-origin allowlist on the callback.
* Authorize URL carries `plan=generic` (required for non-allowlisted
  loopback clients) and `referrer=hermes-agent` for best-effort
  attribution in xAI's OAuth server logs.
* Token storage in `auth.json` with file-locked atomic writes; JWT
  `exp`-based expiry detection with skew; refresh-token rotation
  synced both ways between the singleton store and the credential
  pool so multi-process / multi-profile setups don't tear each other's
  refresh tokens.
* Reactive 401 retry: on a 401 from the xAI Responses API, the agent
  refreshes the token, swaps it back into `self.api_key`, and retries
  the call once. Guarded against silent account swaps when the active
  key was sourced from a different (manual) pool entry.
* Auxiliary tasks (curator, vision, embeddings, etc.) route through a
  dedicated xAI Responses-mode auxiliary client instead of falling back
  to OpenRouter billing.
* Direct HTTP tools (`tools/xai_http.py`, transcription, TTS, image-gen
  plugin) resolve credentials through a unified runtime → singleton →
  env-var fallback chain so xai-oauth users get them for free.
* `hermes auth add xai-oauth` and `hermes auth remove xai-oauth N` are
  wired through the standard auth-commands surface; remove cleans up
  the singleton loopback_pkce entry so it doesn't silently reinstate.
* `hermes model` provider picker shows
  "xAI Grok OAuth (SuperGrok Subscription)" and the model-flow falls
  back to pool credentials when the singleton is missing.

Hardening
---------
* Discovery and refresh responses validate the returned
  `token_endpoint` host against the same `*.x.ai` allowlist as the
  authorization endpoint, blocking MITM persistence of a hostile
  endpoint.
* Discovery / refresh / token-exchange `response.json()` calls are
  wrapped to raise typed `AuthError` on malformed bodies (captive
  portals, proxy error pages) instead of leaking JSONDecodeError
  tracebacks.
* `prompt_cache_key` is routed through `extra_body` on the codex
  transport (sending it as a top-level kwarg trips xAI's SDK with a
  TypeError).
* Credential-pool sync-back preserves `active_provider` so refreshing
  an OAuth entry doesn't silently flip the active provider out from
  under the running agent.

Testing
-------
* New `tests/hermes_cli/test_auth_xai_oauth_provider.py` (~63 tests)
  covers JWT expiry, OAuth URL params (plan + referrer), CORS origins,
  redirect URI validation, singleton↔pool sync, concurrency races,
  refresh error paths, runtime resolution, and malformed-JSON guards.
* Extended `test_credential_pool.py`, `test_codex_transport.py`, and
  `test_run_agent_codex_responses.py` cover the pool sync-back,
  `extra_body` routing, and 401 reactive refresh paths.
* 165 tests passing on this branch via `scripts/run_tests.sh`.
2026-05-15 12:11:32 -07:00
..
_category_.json docs: add Guides & Tutorials section, restructure sidebar 2026-03-08 19:37:34 -07:00
automate-with-cron.md docs(cron): lead with agent-driven setup for no-agent mode (#19871) 2026-05-04 12:39:19 -07:00
automation-templates.md docs: round 2 audit — messaging, developer-guide, guides, integrations (#22858) 2026-05-09 15:00:24 -07:00
aws-bedrock.md docs(bedrock): fix IAM permissions, add quickstart entry, add fallback provider, fix deployment section 2026-05-05 13:41:14 -07:00
azure-foundry.md fix(providers): honor key_env/api_key_env on Azure Anthropic + accept alias in normalizer (#16935) 2026-04-28 02:12:08 -07:00
build-a-hermes-plugin.md feat(video_gen): unified video_generate tool with pluggable provider backends (#25126) 2026-05-13 16:39:41 -07:00
cron-script-only.md fix(docs): correct broken internal links to webhooks and mlops skill pages 2026-05-12 15:03:33 -07:00
cron-troubleshooting.md docs: round 2 audit — messaging, developer-guide, guides, integrations (#22858) 2026-05-09 15:00:24 -07:00
daily-briefing-bot.md docs(cron): clarify default model/provider setup for scheduled jobs 2026-04-23 02:04:45 -07:00
delegation-patterns.md docs(delegate_task): clarify that it is synchronous and not durable (#17022) 2026-04-28 06:45:15 -07:00
github-pr-review-agent.md fix(docs): unbreak docs-site-checks — ascii-guard diagram + MDX <1% (#12984) 2026-04-20 04:29:02 -07:00
google-gemini.md docs(gemini): add Google Gemini guide 2026-05-05 13:43:04 -07:00
local-llm-on-mac.md docs: document streaming timeout auto-detection for local LLMs (#6990) 2026-04-09 23:28:25 -07:00
local-ollama-setup.md docs: round 2 audit — messaging, developer-guide, guides, integrations (#22858) 2026-05-09 15:00:24 -07:00
microsoft-graph-app-registration.md docs(msgraph): add Azure app registration walkthrough + env var reference 2026-05-08 09:27:26 -07:00
migrate-from-openclaw.md feat(claw-migrate): harden OpenClaw import with plan-first apply, redaction, and pre-migration backup (#16911) 2026-04-28 01:50:23 -07:00
minimax-oauth.md docs: round 2 audit — messaging, developer-guide, guides, integrations (#22858) 2026-05-09 15:00:24 -07:00
operate-teams-meeting-pipeline.md docs: round 2 audit — messaging, developer-guide, guides, integrations (#22858) 2026-05-09 15:00:24 -07:00
python-library.md docs: round 2 audit — messaging, developer-guide, guides, integrations (#22858) 2026-05-09 15:00:24 -07:00
team-telegram-assistant.md docs: guides section overhaul — fix existing + add 3 new tutorials (#5735) 2026-04-06 22:02:47 -07:00
tips.md feat(cli): recognise Shift+Enter as a newline key 2026-05-08 16:26:51 -07:00
use-mcp-with-hermes.md docs: round 2 audit — messaging, developer-guide, guides, integrations (#22858) 2026-05-09 15:00:24 -07:00
use-soul-with-hermes.md docs: guides section overhaul — fix existing + add 3 new tutorials (#5735) 2026-04-06 22:02:47 -07:00
use-voice-mode-with-hermes.md feat(voice): add cli beep toggle 2026-04-21 00:29:29 -07:00
webhook-github-pr-review.md docs: add PR review guides, rework quickstart, slim down installation 2026-04-19 05:30:50 -07:00
work-with-skills.md docs(skills): document URL install across features, reference, guide, and hermes-agent skill (#16355) 2026-04-26 21:27:59 -07:00
xai-grok-oauth.md feat(xai-oauth): add xAI Grok OAuth (SuperGrok Subscription) provider 2026-05-15 12:11:32 -07:00