@kenkaiiii/gg-ai 5.35.1 → 5.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3642,6 +3642,8 @@ function sanitizeMessagesForWire(messages) {
3642
3642
  // src/stream.ts
3643
3643
  var GLM_CODING_BASE_URL = "https://api.z.ai/api/coding/paas/v4";
3644
3644
  var KIMI_CODE_USER_AGENT = `kimi-code-cli/${process.env.KIMI_CODE_VERSION ?? "1.0.11"}`;
3645
+ var GROK_CLI_PROXY_HOST = "cli-chat-proxy.grok.com";
3646
+ var GROK_CLI_VERSION = process.env.GROK_CLI_VERSION ?? "0.2.101";
3645
3647
  providerRegistry.register("anthropic", {
3646
3648
  stream: (options) => streamAnthropic(options)
3647
3649
  });
@@ -3702,13 +3704,25 @@ providerRegistry.register("xai", {
3702
3704
  // xAI's public API (console.x.ai key) is OpenAI-compatible — ride the Chat
3703
3705
  // Completions transport like Moonshot/DeepSeek. Grok reasoning models take
3704
3706
  // top-level `reasoning_effort` (low/medium/high), which the shared thinking
3705
- // path already sends. xAI's OAuth path exists but only via the Grok CLI's
3706
- // private Responses proxy (cli-chat-proxy.grok.com) with reverse-engineered
3707
- // attribution headers and account-tier gating intentionally not wired.
3708
- stream: (options) => streamOpenAI({
3709
- ...options,
3710
- baseUrl: options.baseUrl ?? "https://api.x.ai/v1"
3711
- })
3707
+ // path already sends.
3708
+ //
3709
+ // Subscription OAuth (SuperGrok / X Premium) routes to the Grok CLI chat proxy
3710
+ // instead, which speaks the same Chat Completions wire but gates on Grok-CLI
3711
+ // client identity. Inject those headers centrally here — exactly as the Kimi
3712
+ // endpoint above — so EVERY stream (agent loop, compaction, title-gen,
3713
+ // sub-agents) is accepted rather than depending on each call site to thread
3714
+ // headers. Caller-provided headers still win on collision.
3715
+ stream: (options) => {
3716
+ const baseUrl = options.baseUrl ?? "https://api.x.ai/v1";
3717
+ const defaultHeaders = baseUrl.includes(GROK_CLI_PROXY_HOST) ? {
3718
+ "X-XAI-Token-Auth": "xai-grok-cli",
3719
+ "x-grok-client-version": GROK_CLI_VERSION,
3720
+ "x-grok-client-identifier": "ggcoder",
3721
+ "x-grok-model-override": options.model,
3722
+ ...options.defaultHeaders
3723
+ } : options.defaultHeaders;
3724
+ return streamOpenAI({ ...options, baseUrl, defaultHeaders });
3725
+ }
3712
3726
  });
3713
3727
  providerRegistry.register("minimax", {
3714
3728
  stream: (options) => streamAnthropic({