@cartanova/qgrid-cli 2.10.10 → 2.11.1
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/bundle/dist/_virtual/_rolldown/runtime.js +1 -10
- package/bundle/dist/application/monit/log-buffer.js +12 -6
- package/bundle/dist/application/monit/monit.frame.js +11 -3
- package/bundle/dist/application/monit/monit.types.js +1 -1
- package/bundle/dist/application/qgrid/conv-routing.js +9 -6
- package/bundle/dist/application/qgrid/expired-token-reminder.js +2 -2
- package/bundle/dist/application/qgrid/oauth.js +31 -4
- package/bundle/dist/application/qgrid/qgrid-image-generation.js +1 -1
- package/bundle/dist/application/qgrid/qgrid-response-format.js +21 -19
- package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +40 -33
- package/bundle/dist/application/qgrid/qgrid.dispatcher.js +128 -93
- package/bundle/dist/application/qgrid/qgrid.frame.js +930 -49
- package/bundle/dist/application/qgrid/qgrid.types.js +212 -5
- package/bundle/dist/application/qgrid/schema-prompt.js +75 -48
- package/bundle/dist/application/qgrid/slack-user-map.js +1 -1
- package/bundle/dist/application/qgrid/token-death.js +1 -1
- package/bundle/dist/application/qgrid/token-subscriber.js +83 -30
- package/bundle/dist/application/qgrid/token-trigger-setup.js +1 -1
- package/bundle/dist/application/qgrid/token-window-keepalive.js +8 -6
- package/bundle/dist/application/qgrid/tool-emulation-schema.js +13 -13
- package/bundle/dist/application/qgrid/tool-emulation.js +19 -15
- package/bundle/dist/application/request-log/json-schema-type-text.js +29 -12
- package/bundle/dist/application/request-log/request-log.model.js +83 -70
- package/bundle/dist/application/request-log/request-log.types.js +1 -1
- package/bundle/dist/application/request-log/zod-code-format.js +1 -1
- package/bundle/dist/application/request-log-step/request-log-step.model.js +1 -1
- package/bundle/dist/application/request-log-step/request-log-step.types.js +1 -1
- package/bundle/dist/application/setting/setting.constant.js +1 -1
- package/bundle/dist/application/setting/setting.model.js +2 -2
- package/bundle/dist/application/setting/setting.store.js +2 -2
- package/bundle/dist/application/setting/setting.types.js +1 -1
- package/bundle/dist/application/sonamu.generated.js +32 -16
- package/bundle/dist/application/sonamu.generated.sso.js +1 -1
- package/bundle/dist/application/token/token.model.js +26 -9
- package/bundle/dist/application/token/token.types.js +20 -3
- package/bundle/dist/i18n/en.js +15 -1
- package/bundle/dist/i18n/ko.js +15 -1
- package/bundle/dist/i18n/sd.generated.js +1 -1
- package/bundle/dist/migrations/20260807133553_manual__backfill_request_log_cost.js +8 -6
- package/bundle/dist/server-bootstrap.js +4 -2
- package/bundle/dist/server-error-handler.js +1 -1
- package/bundle/dist/sonamu.config.js +37 -8
- package/bundle/dist/startup-migrations.js +17 -7
- package/bundle/dist/testing/global.js +1 -1
- package/bundle/dist/testing/schema-bench.js +0 -0
- package/bundle/dist/testing/test-database-name.js +1 -1
- package/bundle/dist/utils/providers/anthropic/anthropic-constants.js +1 -1
- package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +11 -5
- package/bundle/dist/utils/providers/anthropic/anthropic-quota.js +4 -4
- package/bundle/dist/utils/providers/anthropic/anthropic-thinking.js +1 -1
- package/bundle/dist/utils/providers/anthropic/claude-session.js +20 -19
- package/bundle/dist/utils/providers/anthropic/fence-strip.js +1 -1
- package/bundle/dist/utils/providers/anthropic/stream-json-adapter.js +49 -23
- package/bundle/dist/utils/providers/common/credentials.js +5 -1
- package/bundle/dist/utils/providers/common/effort.js +3 -3
- package/bundle/dist/utils/providers/common/model-cost.js +69 -14
- package/bundle/dist/utils/providers/common/provider-types.js +29 -1
- package/bundle/dist/utils/providers/common/schema-validation.js +78 -40
- package/bundle/dist/utils/providers/common/smooth-weighted-round-robin.js +1 -1
- package/bundle/dist/utils/providers/common/strictifier.js +62 -43
- package/bundle/dist/utils/providers/common/thinking.js +3 -2
- package/bundle/dist/utils/providers/common/ttft.js +1 -1
- package/bundle/dist/utils/providers/grok/grok-backend-protocol.js +427 -0
- package/bundle/dist/utils/providers/grok/grok-constants.js +55 -0
- package/bundle/dist/utils/providers/grok/grok-direct-client.js +196 -0
- package/bundle/dist/utils/providers/grok/grok-dispatcher.js +1313 -0
- package/bundle/dist/utils/providers/grok/grok-headers.js +118 -0
- package/bundle/dist/utils/providers/grok/grok-media-client.js +420 -0
- package/bundle/dist/utils/providers/grok/grok-models.js +114 -0
- package/bundle/dist/utils/providers/grok/grok-oauth.js +455 -0
- package/bundle/dist/utils/providers/grok/grok-quota.js +119 -0
- package/bundle/dist/utils/providers/grok/grok-refresh.js +192 -0
- package/bundle/dist/utils/providers/grok/grok-types.js +186 -0
- package/bundle/dist/utils/providers/grok/grok-voice-client.js +199 -0
- package/bundle/dist/utils/providers/grok/index.js +11 -0
- package/bundle/dist/utils/providers/openai/openai-backend-protocol.js +111 -83
- package/bundle/dist/utils/providers/openai/openai-callback-relay.js +3 -2
- package/bundle/dist/utils/providers/openai/openai-constants.js +1 -1
- package/bundle/dist/utils/providers/openai/openai-direct-client.js +23 -7
- package/bundle/dist/utils/providers/openai/openai-dispatcher.js +143 -106
- package/bundle/dist/utils/providers/openai/openai-image-generation.js +48 -33
- package/bundle/dist/utils/providers/openai/openai-oauth.js +28 -13
- package/bundle/dist/utils/providers/openai/openai-quota.js +38 -27
- package/bundle/dist/utils/providers/openai/openai-refresh.js +17 -9
- package/bundle/dist/utils/providers/openai/openai-sse.js +1 -1
- package/bundle/dist/utils/providers/openai/openai-transport-config.js +1 -1
- package/bundle/dist/utils/quiet-hours.js +1 -1
- package/bundle/dist/utils/slack-notify.js +14 -8
- package/bundle/dist/utils/subset-loaders.js +4 -5
- package/bundle/src/application/monit/log-buffer.ts +23 -9
- package/bundle/src/application/monit/monit.frame.ts +22 -5
- package/bundle/src/application/monit/monit.types.ts +6 -0
- package/bundle/src/application/qgrid/conv-routing.test.ts +76 -4
- package/bundle/src/application/qgrid/conv-routing.ts +35 -9
- package/bundle/src/application/qgrid/expired-token-reminder.ts +9 -1
- package/bundle/src/application/qgrid/oauth.ts +51 -15
- package/bundle/src/application/qgrid/qgrid-image-generation.ts +9 -0
- package/bundle/src/application/qgrid/qgrid-response-format.ts +50 -25
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +19 -0
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +84 -40
- package/bundle/src/application/qgrid/qgrid.dispatcher.test.ts +97 -0
- package/bundle/src/application/qgrid/qgrid.dispatcher.ts +274 -126
- package/bundle/src/application/qgrid/qgrid.frame.test.ts +1013 -3
- package/bundle/src/application/qgrid/qgrid.frame.ts +1415 -60
- package/bundle/src/application/qgrid/qgrid.types.ts +335 -0
- package/bundle/src/application/qgrid/schema-prompt.ts +105 -41
- package/bundle/src/application/qgrid/slack-user-map.ts +5 -0
- package/bundle/src/application/qgrid/token-death.ts +4 -0
- package/bundle/src/application/qgrid/token-subscriber.test.ts +21 -19
- package/bundle/src/application/qgrid/token-subscriber.ts +186 -53
- package/bundle/src/application/qgrid/token-trigger-setup.ts +2 -0
- package/bundle/src/application/qgrid/token-window-keepalive.ts +49 -6
- package/bundle/src/application/qgrid/tool-emulation-schema.ts +33 -29
- package/bundle/src/application/qgrid/tool-emulation.ts +52 -27
- package/bundle/src/application/request-log/json-schema-type-text.test.ts +5 -5
- package/bundle/src/application/request-log/json-schema-type-text.ts +81 -26
- package/bundle/src/application/request-log/request-log.model.test.ts +111 -4
- package/bundle/src/application/request-log/request-log.model.ts +277 -146
- package/bundle/src/application/request-log/request-log.types.ts +6 -0
- package/bundle/src/application/request-log/zod-code-format.ts +11 -0
- package/bundle/src/application/request-log-step/request-log-step.model.ts +1 -0
- package/bundle/src/application/request-log-step/request-log-step.types.ts +2 -0
- package/bundle/src/application/setting/setting.constant.ts +9 -0
- package/bundle/src/application/setting/setting.model.ts +12 -2
- package/bundle/src/application/setting/setting.store.ts +5 -1
- package/bundle/src/application/setting/setting.types.ts +8 -0
- package/bundle/src/application/sonamu.generated.http +133 -0
- package/bundle/src/application/sonamu.generated.sso.ts +2 -0
- package/bundle/src/application/sonamu.generated.ts +15 -0
- package/bundle/src/application/token/token.identity.test.ts +20 -0
- package/bundle/src/application/token/token.model.ts +66 -7
- package/bundle/src/application/token/token.types.ts +24 -1
- package/bundle/src/i18n/en.ts +19 -0
- package/bundle/src/i18n/ko.ts +21 -0
- package/bundle/src/i18n/sd.generated.ts +23 -2
- package/bundle/src/migrations/20260807133553_manual__backfill_request_log_cost.ts +16 -8
- package/bundle/src/server-bootstrap.ts +4 -2
- package/bundle/src/server-error-handler.ts +1 -0
- package/bundle/src/sonamu.config.ts +69 -7
- package/bundle/src/startup-migrations.ts +27 -9
- package/bundle/src/testing/global.ts +20 -0
- package/bundle/src/testing/schema-bench.ts +105 -30
- package/bundle/src/testing/test-database-name.ts +2 -0
- package/bundle/src/utils/providers/anthropic/anthropic-constants.ts +8 -0
- package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +41 -6
- package/bundle/src/utils/providers/anthropic/anthropic-quota.ts +7 -3
- package/bundle/src/utils/providers/anthropic/anthropic-thinking.ts +6 -0
- package/bundle/src/utils/providers/anthropic/claude-session.ts +58 -24
- package/bundle/src/utils/providers/anthropic/fence-strip.ts +11 -0
- package/bundle/src/utils/providers/anthropic/stream-json-adapter.ts +110 -45
- package/bundle/src/utils/providers/common/credentials.ts +8 -0
- package/bundle/src/utils/providers/common/effort.ts +9 -2
- package/bundle/src/utils/providers/common/model-cost.test.ts +48 -1
- package/bundle/src/utils/providers/common/model-cost.ts +259 -158
- package/bundle/src/utils/providers/common/provider-dispatcher.ts +98 -2
- package/bundle/src/utils/providers/common/provider-types.ts +46 -3
- package/bundle/src/utils/providers/common/schema-validation.test.ts +5 -1
- package/bundle/src/utils/providers/common/schema-validation.ts +124 -56
- package/bundle/src/utils/providers/common/smooth-weighted-round-robin.ts +4 -0
- package/bundle/src/utils/providers/common/strictifier.ts +185 -59
- package/bundle/src/utils/providers/common/thinking.ts +2 -2
- package/bundle/src/utils/providers/common/ttft.ts +4 -2
- package/bundle/src/utils/providers/grok/__fixtures__/golden-responses-1.0.60.json +164 -0
- package/bundle/src/utils/providers/grok/grok-backend-protocol.test.ts +325 -0
- package/bundle/src/utils/providers/grok/grok-backend-protocol.ts +721 -0
- package/bundle/src/utils/providers/grok/grok-constants.ts +105 -0
- package/bundle/src/utils/providers/grok/grok-direct-client.test.ts +179 -0
- package/bundle/src/utils/providers/grok/grok-direct-client.ts +313 -0
- package/bundle/src/utils/providers/grok/grok-dispatcher.test.ts +1395 -0
- package/bundle/src/utils/providers/grok/grok-dispatcher.ts +2105 -0
- package/bundle/src/utils/providers/grok/grok-headers.test.ts +149 -0
- package/bundle/src/utils/providers/grok/grok-headers.ts +199 -0
- package/bundle/src/utils/providers/grok/grok-media-client.test.ts +446 -0
- package/bundle/src/utils/providers/grok/grok-media-client.ts +703 -0
- package/bundle/src/utils/providers/grok/grok-models.test.ts +96 -0
- package/bundle/src/utils/providers/grok/grok-models.ts +161 -0
- package/bundle/src/utils/providers/grok/grok-oauth.test.ts +406 -0
- package/bundle/src/utils/providers/grok/grok-oauth.ts +771 -0
- package/bundle/src/utils/providers/grok/grok-quota.test.ts +142 -0
- package/bundle/src/utils/providers/grok/grok-quota.ts +198 -0
- package/bundle/src/utils/providers/grok/grok-refresh.test.ts +239 -0
- package/bundle/src/utils/providers/grok/grok-refresh.ts +325 -0
- package/bundle/src/utils/providers/grok/grok-types.test.ts +252 -0
- package/bundle/src/utils/providers/grok/grok-types.ts +374 -0
- package/bundle/src/utils/providers/grok/grok-voice-client.test.ts +321 -0
- package/bundle/src/utils/providers/grok/grok-voice-client.ts +284 -0
- package/bundle/src/utils/providers/grok/index.ts +20 -0
- package/bundle/src/utils/providers/openai/openai-backend-protocol.ts +221 -137
- package/bundle/src/utils/providers/openai/openai-callback-relay.ts +12 -1
- package/bundle/src/utils/providers/openai/openai-constants.ts +2 -0
- package/bundle/src/utils/providers/openai/openai-direct-client.ts +111 -21
- package/bundle/src/utils/providers/openai/openai-dispatcher.ts +322 -169
- package/bundle/src/utils/providers/openai/openai-image-generation.ts +116 -36
- package/bundle/src/utils/providers/openai/openai-oauth.ts +48 -20
- package/bundle/src/utils/providers/openai/openai-quota.ts +77 -46
- package/bundle/src/utils/providers/openai/openai-refresh.ts +42 -18
- package/bundle/src/utils/providers/openai/openai-sse.ts +27 -3
- package/bundle/src/utils/providers/openai/openai-transport-config.ts +2 -0
- package/bundle/src/utils/quiet-hours.ts +12 -1
- package/bundle/src/utils/slack-notify.ts +44 -13
- package/bundle/src/utils/subset-loaders.ts +7 -7
- package/bundle/web-dist/client/assets/clsx-5XM_pHvN.js +1 -0
- package/bundle/web-dist/client/assets/index-Be2qCZmI.css +1 -0
- package/bundle/web-dist/client/assets/index-C96h3feE.js +32 -0
- package/bundle/web-dist/client/assets/logs-DBM6U0QD.js +1 -0
- package/bundle/web-dist/client/assets/monit-BBjXa7vB.js +1 -0
- package/bundle/web-dist/client/assets/routes-Crz_PQzi.js +5 -0
- package/bundle/web-dist/client/assets/{services.generated-NP-ValHd.js → services.generated-B5lc3aIC.js} +5 -5
- package/bundle/web-dist/client/assets/settings-Cdwm3OBB.js +1 -0
- package/bundle/web-dist/client/assets/show-DBUhALT1.js +2 -0
- package/bundle/web-dist/client/assets/tokens-CVQAVJTo.js +1 -0
- package/bundle/web-dist/client/assets/total-cost-MnfKU8IN.js +1 -0
- package/bundle/web-dist/client/assets/use-oauth-login-flow-BfxYI4Oh.js +1 -0
- package/bundle/web-dist/client/assets/use-update-token-mutation-qKBC2sn7.js +1 -0
- package/bundle/web-dist/client/assets/{vendor-tanstack-DJRQAbrY.js → vendor-tanstack-DRPs09ai.js} +1 -1
- package/bundle/web-dist/client/index.html +5 -5
- package/bundle/web-dist/server/assets/clsx-D_N5PN_2.js +16 -0
- package/bundle/web-dist/server/assets/{lazyRouteComponent-CgBdabgd.js → lazyRouteComponent-AKiHfZWp.js} +129 -2
- package/bundle/web-dist/server/assets/{logs-BMyR98rU.js → logs-B7QmGJq3.js} +18 -14
- package/bundle/web-dist/server/assets/{monit-ZPt66W5M.js → monit-DFt7x3bh.js} +13 -12
- package/bundle/web-dist/server/assets/{plus-BZ9I0VgC.js → plus-DaYQRpBt.js} +1 -1
- package/bundle/web-dist/server/assets/{react-dom-Ds75e4Jl.js → react-dom-Cv23mm1K.js} +2 -129
- package/bundle/web-dist/server/assets/{refresh-cw-CztCFis-.js → refresh-cw-BpXNsAy-.js} +1 -1
- package/bundle/web-dist/server/assets/{request-model-DjGldb-h.js → request-model-eHE6YbaF.js} +1 -1
- package/bundle/web-dist/server/assets/{routes-Ct-k7nBA.js → routes-_Y-PJfgO.js} +110 -39
- package/bundle/web-dist/server/assets/{services.generated-BA4AcAf5.js → services.generated-CMJ8AHbO.js} +582 -172
- package/bundle/web-dist/server/assets/{settings-CBUZ47Xx.js → settings-JwJKxn2e.js} +14 -14
- package/bundle/web-dist/server/assets/{show-LSFIzvO2.js → show-BEv6z1v_.js} +90 -60
- package/bundle/web-dist/server/assets/{tokens-DxrBW512.js → tokens-CNT4mI-f.js} +162 -50
- package/bundle/web-dist/server/assets/total-cost-fTE9Xy82.js +18 -0
- package/bundle/web-dist/server/assets/use-oauth-login-flow-jkAkT3X6.js +2345 -0
- package/bundle/web-dist/server/assets/{use-update-token-mutation-pkArIzCP.js → use-update-token-mutation-Sm6kh02m.js} +1 -1
- package/bundle/web-dist/server/entry-server.generated.js +1644 -21655
- package/dist/cli.js +9 -9
- package/package.json +4 -11
- package/postinstall.mjs +12 -0
- package/skills/qgrid/SKILL.md +1 -0
- package/skills/qgrid/references/cli-env-and-server-boot.md +4 -1
- package/skills/qgrid/references/decision-rationale.md +23 -0
- package/skills/qgrid/references/grok-runtime.md +89 -0
- package/skills/qgrid/references/provider-runtime-differences.md +30 -29
- package/skills/qgrid/references/repo-map.md +10 -0
- package/skills/qgrid/references/token-auth-quota-lifecycle.md +56 -3
- package/bundle/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +0 -406
- package/bundle/dist/node_modules/.pnpm/@vitest_expect@4.1.10/node_modules/@vitest/expect/dist/index.js +0 -1507
- package/bundle/dist/node_modules/.pnpm/@vitest_pretty-format@4.1.10/node_modules/@vitest/pretty-format/dist/index.js +0 -887
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/chunk-artifact.js +0 -2756
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/index.js +0 -8
- package/bundle/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/utils.js +0 -8
- package/bundle/dist/node_modules/.pnpm/@vitest_snapshot@4.1.10/node_modules/@vitest/snapshot/dist/index.js +0 -922
- package/bundle/dist/node_modules/.pnpm/@vitest_spy@4.1.10/node_modules/@vitest/spy/dist/index.js +0 -386
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js +0 -121
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/constants.js +0 -51
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/diff.js +0 -1317
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/display.js +0 -561
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/error.js +0 -40
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/helpers.js +0 -272
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/offset.js +0 -27
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/serialize.js +0 -77
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/source-map.js +0 -381
- package/bundle/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/timers.js +0 -51
- package/bundle/dist/node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js +0 -2986
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js +0 -10
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js +0 -109
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js +0 -10
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js +0 -10
- package/bundle/dist/node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js +0 -10
- package/bundle/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +0 -1126
- package/bundle/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.js +0 -21
- package/bundle/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.js +0 -432
- package/bundle/dist/node_modules/.pnpm/tinybench@2.9.0/node_modules/tinybench/dist/index.js +0 -517
- package/bundle/dist/node_modules/.pnpm/tinyrainbow@3.1.0/node_modules/tinyrainbow/dist/index.js +0 -101
- package/bundle/dist/node_modules/.pnpm/vite@8.0.3_@emnapi_core@1.11.2_@emnapi_runtime@1.11.2_@types_node@25.0.7_esbuild@0.27.4_5b35fc1fb85d2af4d105e0d74f940f50/node_modules/vite/dist/node/module-runner.js +0 -1265
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -9
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js +0 -41
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js +0 -19
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/index.Chj8NDwU.js +0 -202
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/index.DdgEv5B1.js +0 -46
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +0 -119
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js +0 -3044
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +0 -59
- package/bundle/dist/node_modules/.pnpm/vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618/node_modules/vitest/dist/index.js +0 -28
- package/bundle/dist/testing/setup-mocks.js +0 -16
- package/bundle/src/testing/setup-mocks.ts +0 -44
- package/bundle/web-dist/client/assets/index-Bw2s88Ot.css +0 -1
- package/bundle/web-dist/client/assets/index-DZwzUfI-.js +0 -106
- package/bundle/web-dist/client/assets/logs-Cog79DU5.js +0 -1
- package/bundle/web-dist/client/assets/monit-2auznBys.js +0 -1
- package/bundle/web-dist/client/assets/routes-B0lTeLK-.js +0 -5
- package/bundle/web-dist/client/assets/settings-D8ZxZGSJ.js +0 -1
- package/bundle/web-dist/client/assets/show-CFSERlnM.js +0 -2
- package/bundle/web-dist/client/assets/tokens-CZXUyI7O.js +0 -1
- package/bundle/web-dist/client/assets/use-oauth-login-flow-hboOs3wG.js +0 -1
- package/bundle/web-dist/client/assets/use-update-token-mutation-BQHS0byG.js +0 -1
- package/bundle/web-dist/server/assets/use-oauth-login-flow-Gn8flMK5.js +0 -178
- package/dist/cli.d.ts +0 -10
- /package/bundle/web-dist/client/assets/{cost-DH2jZbrw.js → cost-DB3HbU7T.js} +0 -0
- /package/bundle/web-dist/client/assets/{plus-B62CuqT8.js → plus-BsQdY7PS.js} +0 -0
- /package/bundle/web-dist/client/assets/{preload-helper-ca-nBW7U.js → preload-helper-DWTEM3RW.js} +0 -0
- /package/bundle/web-dist/client/assets/{refresh-cw-NNcU0Cmq.js → refresh-cw-D9IUmT23.js} +0 -0
- /package/bundle/web-dist/client/assets/{request-model-CojtinqK.js → request-model-Bpp_rkK8.js} +0 -0
- /package/bundle/web-dist/server/assets/{cost-eEHeTRT5.js → cost-BC9yzyA9.js} +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import golden from "./__fixtures__/golden-responses-1.0.60.json";
|
|
4
|
+
import { GROK_BUILD_VERSION } from "./grok-constants";
|
|
5
|
+
import {
|
|
6
|
+
buildGrokChatHeaders,
|
|
7
|
+
buildGrokMediaHeaders,
|
|
8
|
+
buildGrokProxyGetHeaders,
|
|
9
|
+
buildGrokVoiceHeaders,
|
|
10
|
+
generateTraceparent,
|
|
11
|
+
grokPlatform,
|
|
12
|
+
} from "./grok-headers";
|
|
13
|
+
|
|
14
|
+
const TRANSPORT_HEADERS = new Set(["host", "content-length", "accept-encoding"]);
|
|
15
|
+
const TRACEPARENT = "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01";
|
|
16
|
+
|
|
17
|
+
const placeholders: Record<string, string> = {
|
|
18
|
+
"<user-id>": "11111111-1111-1111-1111-111111111111",
|
|
19
|
+
"<conv-group-id>": "conv-group",
|
|
20
|
+
"<redacted>": "jwt-token",
|
|
21
|
+
"<traceparent>": TRACEPARENT,
|
|
22
|
+
"<conv-id>": "conv-1",
|
|
23
|
+
"<req-id>": "req-1",
|
|
24
|
+
"<session-id>": "22222222-2222-2222-2222-222222222222",
|
|
25
|
+
"<agent-id>": "33333333-3333-3333-3333-333333333333",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function substitute(value: string): string {
|
|
29
|
+
return value.replace(/<[a-z-]+>/g, (token) => placeholders[token] ?? token);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const macArm = { os: "macos", arch: "aarch64" } as const;
|
|
33
|
+
|
|
34
|
+
function chatHeaders(overrides: Partial<Parameters<typeof buildGrokChatHeaders>[0]> = {}) {
|
|
35
|
+
return buildGrokChatHeaders({
|
|
36
|
+
bearer: "jwt-token",
|
|
37
|
+
model: "grok-4.7",
|
|
38
|
+
convId: "conv-1",
|
|
39
|
+
reqId: "req-1",
|
|
40
|
+
sessionId: "22222222-2222-2222-2222-222222222222",
|
|
41
|
+
agentId: "33333333-3333-3333-3333-333333333333",
|
|
42
|
+
userId: "11111111-1111-1111-1111-111111111111",
|
|
43
|
+
convGroupId: "conv-group",
|
|
44
|
+
turnIdx: 1,
|
|
45
|
+
traceparent: TRACEPARENT,
|
|
46
|
+
zstd: true,
|
|
47
|
+
platform: macArm,
|
|
48
|
+
...overrides,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe("Grok chat headers (acceptance A3)", () => {
|
|
53
|
+
it("match the 1.0.60 golden capture in key order and value", () => {
|
|
54
|
+
const expectedOrder = golden.request.headerOrder.filter((name) => !TRANSPORT_HEADERS.has(name));
|
|
55
|
+
const goldenHeaders: Record<string, string> = golden.request.headers;
|
|
56
|
+
const expected = Object.fromEntries(
|
|
57
|
+
expectedOrder.map((name) => [name, substitute(goldenHeaders[name] ?? "")]),
|
|
58
|
+
);
|
|
59
|
+
const headers = chatHeaders();
|
|
60
|
+
expect(Object.keys(headers)).toEqual(expectedOrder);
|
|
61
|
+
expect(headers).toEqual(expected);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("pins the fixture to the build version constant", () => {
|
|
65
|
+
expect(golden.request.headers["x-grok-client-version"]).toBe(GROK_BUILD_VERSION);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("omits content-encoding for a plain body and adds transient-retry only when given", () => {
|
|
69
|
+
const plain = chatHeaders({ zstd: false });
|
|
70
|
+
expect(plain).not.toHaveProperty("content-encoding");
|
|
71
|
+
expect(plain).not.toHaveProperty("x-grok-transient-retry");
|
|
72
|
+
const retry = chatHeaders({ transientRetry: 2 });
|
|
73
|
+
const keys = Object.keys(retry);
|
|
74
|
+
expect(retry["x-grok-transient-retry"]).toBe("2");
|
|
75
|
+
expect(keys.indexOf("x-grok-transient-retry")).toBe(keys.indexOf("x-grok-turn-idx") + 1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("generates a valid W3C traceparent when absent", () => {
|
|
79
|
+
const headers = chatHeaders({ traceparent: undefined });
|
|
80
|
+
expect(headers.traceparent).toMatch(/^00-[0-9a-f]{32}-[0-9a-f]{16}-01$/);
|
|
81
|
+
expect(generateTraceparent()).not.toBe(generateTraceparent());
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("rejects malformed inputs instead of sending them", () => {
|
|
85
|
+
expect(() => chatHeaders({ traceparent: "00-bad-01" })).toThrow(TypeError);
|
|
86
|
+
expect(() =>
|
|
87
|
+
chatHeaders({ traceparent: "00-00000000000000000000000000000000-0123456789abcdef-01" }),
|
|
88
|
+
).toThrow(TypeError);
|
|
89
|
+
expect(() => chatHeaders({ bearer: "" })).toThrow(TypeError);
|
|
90
|
+
expect(() => chatHeaders({ bearer: "a b" })).toThrow(TypeError);
|
|
91
|
+
expect(() => chatHeaders({ turnIdx: -1 })).toThrow(TypeError);
|
|
92
|
+
expect(() => chatHeaders({ userId: "" })).toThrow(TypeError);
|
|
93
|
+
expect(() => chatHeaders({ convId: "a\r\nx-evil: 1" })).toThrow(TypeError);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("overrides compactions remaining", () => {
|
|
97
|
+
expect(chatHeaders({ compactionsRemaining: 0 })["x-compactions-remaining"]).toBe("0");
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe("Grok proxy GET, media and voice headers", () => {
|
|
102
|
+
it("builds proxy GET headers in the captured /settings order", () => {
|
|
103
|
+
const headers = buildGrokProxyGetHeaders({
|
|
104
|
+
bearer: "jwt",
|
|
105
|
+
userId: "u",
|
|
106
|
+
email: "a@example.com",
|
|
107
|
+
platform: macArm,
|
|
108
|
+
});
|
|
109
|
+
expect(Object.entries(headers)).toEqual([
|
|
110
|
+
["authorization", "Bearer jwt"],
|
|
111
|
+
["x-xai-token-auth", "xai-grok-cli"],
|
|
112
|
+
["x-userid", "u"],
|
|
113
|
+
["x-grok-client-version", "1.0.60"],
|
|
114
|
+
["x-email", "a@example.com"],
|
|
115
|
+
["x-grok-client-identifier", "grok-shell"],
|
|
116
|
+
["x-grok-client-mode", "headless"],
|
|
117
|
+
["accept", "*/*"],
|
|
118
|
+
["user-agent", "grok-shell/1.0.60 (macos; aarch64)"],
|
|
119
|
+
]);
|
|
120
|
+
expect(buildGrokProxyGetHeaders({ bearer: "jwt", userId: "u" })).not.toHaveProperty("x-email");
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it("never attaches the proxy auth trio to api.x.ai", () => {
|
|
124
|
+
expect(Object.entries(buildGrokMediaHeaders({ bearer: "jwt", sessionId: "s-1" }))).toEqual([
|
|
125
|
+
["user-agent", "xai-grok-build/1.0.60"],
|
|
126
|
+
["authorization", "Bearer jwt"],
|
|
127
|
+
["x-grok-session-id", "s-1"],
|
|
128
|
+
["x-grok-client-version", "1.0.60"],
|
|
129
|
+
["x-grok-client-identifier", "grok-shell"],
|
|
130
|
+
]);
|
|
131
|
+
expect(() => buildGrokMediaHeaders({ bearer: "jwt", sessionId: "" })).toThrow(TypeError);
|
|
132
|
+
expect(Object.entries(buildGrokVoiceHeaders({ bearer: "jwt", platform: macArm }))).toEqual([
|
|
133
|
+
["user-agent", "grok-shell/1.0.60 (macos; aarch64)"],
|
|
134
|
+
["authorization", "Bearer jwt"],
|
|
135
|
+
["x-grok-client-version", "1.0.60"],
|
|
136
|
+
["x-grok-client-identifier", "grok-shell"],
|
|
137
|
+
]);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it.each([
|
|
141
|
+
["darwin", "arm64", "macos", "aarch64"],
|
|
142
|
+
["darwin", "x64", "macos", "x86_64"],
|
|
143
|
+
["linux", "arm64", "linux", "aarch64"],
|
|
144
|
+
["linux", "x64", "linux", "x86_64"],
|
|
145
|
+
["win32", "x64", "windows", "x86_64"],
|
|
146
|
+
] as const)("maps %s/%s to %s/%s", (platform, arch, os, rustArch) => {
|
|
147
|
+
expect(grokPlatform(platform, arch)).toEqual({ os, arch: rustArch });
|
|
148
|
+
});
|
|
149
|
+
});
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
GROK_BUILD_VERSION,
|
|
5
|
+
GROK_CLIENT_IDENTIFIER,
|
|
6
|
+
GROK_CLIENT_MODE,
|
|
7
|
+
GROK_COMPACTION_AT,
|
|
8
|
+
GROK_COMPACTIONS_REMAINING_DEFAULT,
|
|
9
|
+
GROK_DOOM_LOOP_CHECK,
|
|
10
|
+
GROK_EXACT_REPETITION_CHECK,
|
|
11
|
+
} from "./grok-constants";
|
|
12
|
+
|
|
13
|
+
// Builders return plain lowercase-key records whose insertion order is the wire order the
|
|
14
|
+
// pinned grok-build emits. `host`, `content-length` and `accept-encoding` are left to the
|
|
15
|
+
// transport. The three header families (chat proxy, proxy GET, api.x.ai) are never merged.
|
|
16
|
+
|
|
17
|
+
export interface GrokPlatform {
|
|
18
|
+
os: "macos" | "windows" | "linux";
|
|
19
|
+
arch: "aarch64" | "x86_64";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Maps Node platform/arch to the Rust `std::env::consts` names grok-build reports. */
|
|
23
|
+
export function grokPlatform(
|
|
24
|
+
platform: NodeJS.Platform = process.platform,
|
|
25
|
+
arch: NodeJS.Architecture = process.arch,
|
|
26
|
+
): GrokPlatform {
|
|
27
|
+
// grok-build ships only these targets; anything else is reported as the nearest shipped one
|
|
28
|
+
// so the User-Agent never carries a value the real binary cannot emit.
|
|
29
|
+
const os = platform === "darwin" ? "macos" : platform === "win32" ? "windows" : "linux";
|
|
30
|
+
|
|
31
|
+
return { os, arch: arch === "arm64" ? "aarch64" : "x86_64" };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `grok-shell/<ver> (<os>; <arch>)` (grok-build 1.0.45 xai-grok-sampler/src/client.rs:457-463). */
|
|
35
|
+
export function grokShellUserAgent(platform: GrokPlatform = grokPlatform()): string {
|
|
36
|
+
return `grok-shell/${GROK_BUILD_VERSION} (${platform.os}; ${platform.arch})`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** `xai-grok-build/<ver>` (grok-build 1.0.45 media_tool_config.rs:104). */
|
|
40
|
+
export function grokMediaUserAgent(): string {
|
|
41
|
+
return `xai-grok-build/${GROK_BUILD_VERSION}`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const TRACEPARENT_PATTERN = /^00-(?!0{32})[0-9a-f]{32}-(?!0{16})[0-9a-f]{16}-01$/;
|
|
45
|
+
|
|
46
|
+
/** W3C trace context `00-<trace-id>-<parent-id>-01` with non-zero random ids. */
|
|
47
|
+
export function generateTraceparent(): string {
|
|
48
|
+
for (;;) {
|
|
49
|
+
const traceparent = `00-${randomBytes(16).toString("hex")}-${randomBytes(8).toString("hex")}-01`;
|
|
50
|
+
|
|
51
|
+
if (TRACEPARENT_PATTERN.test(traceparent)) return traceparent;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function bearerValue(bearer: string): string {
|
|
56
|
+
if (!bearer || /\s/.test(bearer)) throw new TypeError("Grok bearer token must be non-empty");
|
|
57
|
+
|
|
58
|
+
return `Bearer ${bearer}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function nonNegativeInteger(name: string, value: number): string {
|
|
62
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
63
|
+
throw new TypeError(`${name} must be a non-negative integer`);
|
|
64
|
+
|
|
65
|
+
return String(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function requiredValue(name: string, value: string): string {
|
|
69
|
+
if (!value || /[\r\n]/.test(value))
|
|
70
|
+
throw new TypeError(`${name} must be a non-empty header value`);
|
|
71
|
+
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface GrokChatHeaderOptions {
|
|
76
|
+
bearer: string;
|
|
77
|
+
model: string;
|
|
78
|
+
convId: string;
|
|
79
|
+
reqId: string;
|
|
80
|
+
sessionId: string;
|
|
81
|
+
agentId: string;
|
|
82
|
+
userId: string;
|
|
83
|
+
convGroupId: string;
|
|
84
|
+
turnIdx: number;
|
|
85
|
+
traceparent?: string;
|
|
86
|
+
transientRetry?: number;
|
|
87
|
+
compactionsRemaining?: number;
|
|
88
|
+
zstd: boolean;
|
|
89
|
+
platform?: GrokPlatform;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Headers for `POST {proxy}/responses`, in the order of the 1.0.60 golden capture. */
|
|
93
|
+
export function buildGrokChatHeaders(options: GrokChatHeaderOptions): Record<string, string> {
|
|
94
|
+
const traceparent = options.traceparent ?? generateTraceparent();
|
|
95
|
+
|
|
96
|
+
if (!TRACEPARENT_PATTERN.test(traceparent))
|
|
97
|
+
throw new TypeError("traceparent must be a W3C 00-<32hex>-<16hex>-01 value");
|
|
98
|
+
|
|
99
|
+
// A Map keeps insertion order, which is the wire order of the golden capture.
|
|
100
|
+
const headers = new Map(
|
|
101
|
+
Object.entries({
|
|
102
|
+
"content-type": "application/json",
|
|
103
|
+
"user-agent": grokShellUserAgent(options.platform),
|
|
104
|
+
"x-grok-client-mode": GROK_CLIENT_MODE,
|
|
105
|
+
"x-xai-token-auth": "xai-grok-cli",
|
|
106
|
+
"x-authenticateresponse": "authenticate-response",
|
|
107
|
+
"x-compactions-remaining": nonNegativeInteger(
|
|
108
|
+
"compactionsRemaining",
|
|
109
|
+
options.compactionsRemaining ?? GROK_COMPACTIONS_REMAINING_DEFAULT,
|
|
110
|
+
),
|
|
111
|
+
"x-compaction-at": String(GROK_COMPACTION_AT),
|
|
112
|
+
"x-grok-client-version": GROK_BUILD_VERSION,
|
|
113
|
+
"x-grok-user-id": requiredValue("userId", options.userId),
|
|
114
|
+
"x-grok-conv-group-id": requiredValue("convGroupId", options.convGroupId),
|
|
115
|
+
"x-grok-client-identifier": GROK_CLIENT_IDENTIFIER,
|
|
116
|
+
authorization: bearerValue(options.bearer),
|
|
117
|
+
traceparent,
|
|
118
|
+
"x-grok-conv-id": requiredValue("convId", options.convId),
|
|
119
|
+
"x-grok-req-id": requiredValue("reqId", options.reqId),
|
|
120
|
+
"x-grok-model-override": requiredValue("model", options.model),
|
|
121
|
+
"x-grok-session-id": requiredValue("sessionId", options.sessionId),
|
|
122
|
+
"x-grok-agent-id": requiredValue("agentId", options.agentId),
|
|
123
|
+
"x-grok-turn-idx": nonNegativeInteger("turnIdx", options.turnIdx),
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
// Not present in the capture; grok-build 1.0.45 client.rs:560-605 sends it with the turn
|
|
128
|
+
// index group on retries only.
|
|
129
|
+
if (options.transientRetry !== undefined)
|
|
130
|
+
headers.set(
|
|
131
|
+
"x-grok-transient-retry",
|
|
132
|
+
nonNegativeInteger("transientRetry", options.transientRetry),
|
|
133
|
+
);
|
|
134
|
+
headers.set("accept", "text/event-stream");
|
|
135
|
+
headers.set("x-grok-doom-loop-check", String(GROK_DOOM_LOOP_CHECK));
|
|
136
|
+
headers.set("x-grok-exact-repetition-check", String(GROK_EXACT_REPETITION_CHECK));
|
|
137
|
+
|
|
138
|
+
if (options.zstd) headers.set("content-encoding", "zstd");
|
|
139
|
+
|
|
140
|
+
return Object.fromEntries(headers);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface GrokProxyGetHeaderOptions {
|
|
144
|
+
bearer: string;
|
|
145
|
+
userId: string;
|
|
146
|
+
email?: string;
|
|
147
|
+
platform?: GrokPlatform;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Headers for proxy GETs (`/settings`, `/models`, `/billing`, `/user`). Order follows the
|
|
152
|
+
* 1.0.60 capture of `GET /settings`.
|
|
153
|
+
*/
|
|
154
|
+
export function buildGrokProxyGetHeaders(
|
|
155
|
+
options: GrokProxyGetHeaderOptions,
|
|
156
|
+
): Record<string, string> {
|
|
157
|
+
const headers = new Map([
|
|
158
|
+
["authorization", bearerValue(options.bearer)],
|
|
159
|
+
["x-xai-token-auth", "xai-grok-cli"],
|
|
160
|
+
["x-userid", requiredValue("userId", options.userId)],
|
|
161
|
+
["x-grok-client-version", GROK_BUILD_VERSION],
|
|
162
|
+
]);
|
|
163
|
+
|
|
164
|
+
if (options.email !== undefined) headers.set("x-email", requiredValue("email", options.email));
|
|
165
|
+
headers.set("x-grok-client-identifier", GROK_CLIENT_IDENTIFIER);
|
|
166
|
+
headers.set("x-grok-client-mode", GROK_CLIENT_MODE);
|
|
167
|
+
headers.set("accept", "*/*");
|
|
168
|
+
headers.set("user-agent", grokShellUserAgent(options.platform));
|
|
169
|
+
|
|
170
|
+
return Object.fromEntries(headers);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Headers for `api.x.ai` image/video calls. The proxy auth trio is never attached.
|
|
175
|
+
* `x-grok-session-id` is attached per request right after the bearer (grok-build xai-grok-tools
|
|
176
|
+
* image_gen/mod.rs:199-213, video_gen/mod.rs:258-270).
|
|
177
|
+
*/
|
|
178
|
+
export function buildGrokMediaHeaders(options: { bearer: string; sessionId: string }) {
|
|
179
|
+
return {
|
|
180
|
+
"user-agent": grokMediaUserAgent(),
|
|
181
|
+
authorization: bearerValue(options.bearer),
|
|
182
|
+
"x-grok-session-id": requiredValue("sessionId", options.sessionId),
|
|
183
|
+
"x-grok-client-version": GROK_BUILD_VERSION,
|
|
184
|
+
"x-grok-client-identifier": GROK_CLIENT_IDENTIFIER,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Headers for `api.x.ai` STT/TTS calls (grok-build 1.0.45 xai-grok-pager client_identity.rs).
|
|
190
|
+
* No session id: the voice client sends none (xai-grok-voice stt/streaming.rs:42-57).
|
|
191
|
+
*/
|
|
192
|
+
export function buildGrokVoiceHeaders(options: { bearer: string; platform?: GrokPlatform }) {
|
|
193
|
+
return {
|
|
194
|
+
"user-agent": grokShellUserAgent(options.platform),
|
|
195
|
+
authorization: bearerValue(options.bearer),
|
|
196
|
+
"x-grok-client-version": GROK_BUILD_VERSION,
|
|
197
|
+
"x-grok-client-identifier": GROK_CLIENT_IDENTIFIER,
|
|
198
|
+
};
|
|
199
|
+
}
|