fix(xai): track the official Grok CLI version for cli-chat-proxy

cli-chat-proxy.grok.com started rejecting every request on 2026-10-01
with HTTP 426 "Your Grok CLI version (0.2.120) is outdated. Please
update to version 1.0.13 or later", because x-grok-client-version and
the xai-grok-workspace user agent were pinned to 0.2.120.

Replace the pin with a runtime-published version (built-in fallback
1.0.46) and add a gateway worker, modelled on the Codex profile worker,
that prewarms at startup and refreshes every 3h:

- read the official stable channel https://x.ai/cli/stable, falling
  back to npm @xai-official/grok/latest (deployments that cannot reach
  x.ai directly), requiring all six platform binaries at one version;
- never roll back, persist the verified version in runtime KV and
  restore it on restart;
- AETHER_XAI_CLIENT_VERSION pins a version, and
  AETHER_XAI_CLIENT_PROFILE_REFRESH=off disables the network check.

Endpoint header rules still win over the injected identity headers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
stabey
2026-10-01 14:53:26 +08:00
co-authored by Claude Opus 5.5
parent 54fbcc25a1
commit 2257c3959f
7 changed files with 693 additions and 6 deletions
+4 -3
View File
@@ -199,7 +199,8 @@ pub use windsurf::{
pub use xai::{
extract_xai_user_id_from_auth_config, extract_xai_user_id_from_value,
insert_cli_identity_headers, insert_cli_identity_headers_if_needed, is_xai_provider_transport,
resolved_xai_request_base_url, resolved_xai_upstream_base_url,
should_attach_cli_identity_headers, xai_auth_uses_api, xai_uses_official_api, XAI_API_BASE_URL,
XAI_CHAT_PROXY_BASE_URL, XAI_PROVIDER_TYPE,
resolved_xai_request_base_url, resolved_xai_upstream_base_url, set_xai_client_version,
should_attach_cli_identity_headers, xai_auth_uses_api, xai_client_version,
xai_uses_official_api, XAI_API_BASE_URL, XAI_CHAT_PROXY_BASE_URL, XAI_DEFAULT_CLIENT_VERSION,
XAI_PROVIDER_TYPE,
};