Skip to content

Commit a9c90f5

Browse files
committed
fix(xai): use provider client header constants
1 parent 1ba2599 commit a9c90f5

7 files changed

Lines changed: 20 additions & 17 deletions

File tree

‎bun.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"@corbits/codex-provider": "0.1.1",
9090
"@corbits/oauth-core": "0.2.0",
9191
"@corbits/openai-responses": "0.2.1",
92-
"@corbits/xai-provider": "0.1.1",
92+
"@corbits/xai-provider": "0.1.2",
9393
"@intx/agent": "workspace:*",
9494
"@intx/authz": "workspace:*",
9595
"@intx/crypto": "0.3.0",

‎src/auth/xai/auth-headers.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
import { describe, expect, test } from "bun:test";
2+
import {
3+
XAI_CLIENT_IDENTIFIER,
4+
XAI_CLIENT_VERSION,
5+
XAI_USER_AGENT,
6+
} from "@corbits/xai-provider";
27

38
import { xaiAuthHeadersForToken } from "./auth-headers.js";
49

@@ -17,6 +22,9 @@ describe("xaiAuthHeadersForToken", () => {
1722
expect(headers.authorization).toBe(
1823
`Bearer ${accessTokenWithSub("user-123")}`,
1924
);
25+
expect(headers["user-agent"]).toBe(XAI_USER_AGENT);
26+
expect(headers["x-grok-client-identifier"]).toBe(XAI_CLIENT_IDENTIFIER);
27+
expect(headers["x-grok-client-version"]).toBe(XAI_CLIENT_VERSION);
2028
});
2129

2230
test("omits x-grok-user-id when the JWT sub carries CR, LF, or NUL", () => {

‎src/auth/xai/auth-headers.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { xaiUserIdFromAccessToken } from "@corbits/xai-provider";
2-
31
import {
42
XAI_CLIENT_IDENTIFIER,
53
XAI_CLIENT_VERSION,
64
XAI_USER_AGENT,
7-
} from "./constants.js";
5+
xaiUserIdFromAccessToken,
6+
} from "@corbits/xai-provider";
87

98
export function xaiAuthHeadersForToken(token: {
109
readonly access: string;

‎src/auth/xai/constants.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ export const XAI_CALLBACK_HOST = callbackTarget.host;
3939
export const XAI_CALLBACK_PORT = callbackTarget.port;
4040
export const XAI_CALLBACK_PATH = callbackTarget.path;
4141

42-
// The CLI chat proxy speaks the OpenAI Responses API and authenticates the
43-
// caller by client headers in addition to the bearer token. Values mirror the
44-
// grok CLI's own request (captured live). Do not replace these with a product
45-
// user-agent — the proxy and billing surfaces expect the grok-shell identity.
46-
export const XAI_CLIENT_IDENTIFIER = "grok-shell";
47-
export const XAI_CLIENT_VERSION = "0.2.93";
48-
export const XAI_USER_AGENT = "grok-shell/0.2.93 (macos; aarch64)";
49-
5042
// Cap every token request to the xAI proxy. The refresh runs on the
5143
// send path before the inference fetch arms its inactivity/total timers, so a
5244
// stalled token endpoint would otherwise freeze the agent at turn 0.

‎src/config/xai-providers.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
describe("xAI OAuth provider projection", () => {
1919
test("default models lead with the CLI coding model", () => {
2020
expect(XAI_DEFAULT_MODELS.length).toBeGreaterThan(1);
21-
expect(XAI_DEFAULT_MODELS[0]).toBe("grok-4.5");
21+
expect(XAI_DEFAULT_MODELS[0]).toBe("grok-4.7");
2222
});
2323

2424
test("skips grok-4.7 insert when the vendor list already includes it", () => {

‎src/provider/grok-responses.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { describe, expect, test } from "bun:test";
2+
import {
3+
XAI_CLIENT_IDENTIFIER,
4+
XAI_CLIENT_VERSION,
5+
} from "@corbits/xai-provider";
26
import { BEARER_CREDENTIAL_SENTINEL } from "@intx/inference";
37
import type {
48
ConversationTurn,
@@ -254,8 +258,8 @@ describe("grok-responses buildRequest", () => {
254258
);
255259
expect(req.url).toBe("/responses");
256260
expect(req.headers["authorization"]).toBe(BEARER_CREDENTIAL_SENTINEL);
257-
expect(req.headers["x-grok-client-identifier"]).toBe("grok-shell");
258-
expect(req.headers["x-grok-client-version"]).toBe("0.2.93");
261+
expect(req.headers["x-grok-client-identifier"]).toBe(XAI_CLIENT_IDENTIFIER);
262+
expect(req.headers["x-grok-client-version"]).toBe(XAI_CLIENT_VERSION);
259263
expect(req.headers["x-grok-model-override"]).toBe("grok-4.5");
260264
expect(req.headers["x-grok-user-id"]).toBe("user-123");
261265
expect(req.headers["accept"]).toBe("text/event-stream");

0 commit comments

Comments
 (0)