Skip to content

Commit 51129b6

Browse files
committed
chore(cl-6815): trim unreachable usage formatters, demo, kickoff stub
Decision: usage display is not a product surface — delete fetch/format helpers and their tests rather than wiring them in. Keep only the live auth-header helpers used by oauth-scope-check, renamed usage.ts -> auth-headers.ts. Delete src/tui/demo.ts (410 lines, README-only reference) and the unreferenced workflows/kickoff stub. Net-negative.
1 parent 174d7e3 commit 51129b6

14 files changed

Lines changed: 45 additions & 1010 deletions

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { CODEX_CLIENT_VERSION, CODEX_ORIGINATOR } from "./constants.js";
2+
3+
export function codexAuthHeadersForToken(
4+
token: {
5+
readonly access: string;
6+
readonly accountId?: string | undefined;
7+
},
8+
commandName: string,
9+
): Record<string, string> {
10+
const headers: Record<string, string> = {
11+
authorization: `Bearer ${token.access}`,
12+
originator: CODEX_ORIGINATOR,
13+
"user-agent": `${commandName} (${CODEX_ORIGINATOR}/${CODEX_CLIENT_VERSION})`,
14+
};
15+
if (token.accountId !== undefined)
16+
headers["chatgpt-account-id"] = token.accountId;
17+
return headers;
18+
}

‎src/auth/codex/constants.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ const codexRedirect = new URL(CODEX_REDIRECT_URI);
1111
export const CODEX_CALLBACK_PORT = Number(codexRedirect.port);
1212
export const CODEX_CALLBACK_PATH = codexRedirect.pathname;
1313

14-
// Live usage/quota for the prepaid plan (window %, reset, credits) and the
15-
// account's available model catalog. The models endpoint requires a
14+
// The account's available model catalog. The models endpoint requires a
1615
// client_version query param.
17-
export const CODEX_USAGE_PATH = "/codex/usage";
1816
export const CODEX_MODELS_PATH = "/codex/models";
1917
export const CODEX_CLIENT_VERSION = "0.50.0";
2018

‎src/auth/codex/usage.ts‎

Lines changed: 0 additions & 214 deletions
This file was deleted.

‎src/auth/oauth-scope-check.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import {
1919
} from "./codex/constants.js";
2020
import { refreshStagedCodexTokens } from "./codex/session.js";
2121
import type { CodexTokens } from "./codex/store.js";
22-
import { codexAuthHeadersForToken } from "./codex/usage.js";
22+
import { codexAuthHeadersForToken } from "./codex/auth-headers.js";
2323
import { XAI_BASE_URL, XAI_TOKEN_TIMEOUT_MS } from "./xai/constants.js";
2424
import { refreshStagedXaiTokens } from "./xai/session.js";
2525
import type { XaiTokens } from "./xai/store.js";
26-
import { xaiAuthHeadersForToken } from "./xai/usage.js";
26+
import { xaiAuthHeadersForToken } from "./xai/auth-headers.js";
2727

2828
export type OAuthScopeCheckKind = "codex" | "xai";
2929

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { xaiUserIdFromAccessToken } from "@corbits/xai-provider";
2+
3+
import {
4+
XAI_CLIENT_IDENTIFIER,
5+
XAI_CLIENT_VERSION,
6+
XAI_USER_AGENT,
7+
} from "./constants.js";
8+
9+
export function xaiAuthHeadersForToken(token: {
10+
readonly access: string;
11+
}): Record<string, string> {
12+
const headers: Record<string, string> = {
13+
authorization: `Bearer ${token.access}`,
14+
"user-agent": XAI_USER_AGENT,
15+
"x-grok-client-identifier": XAI_CLIENT_IDENTIFIER,
16+
"x-grok-client-version": XAI_CLIENT_VERSION,
17+
};
18+
const userId = xaiUserIdFromAccessToken(token.access);
19+
if (userId !== undefined) headers["x-grok-user-id"] = userId;
20+
return headers;
21+
}

‎src/auth/xai/constants.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export const XAI_CLIENT_IDENTIFIER = "grok-shell";
2222
export const XAI_CLIENT_VERSION = "0.2.93";
2323
export const XAI_USER_AGENT = "grok-shell/0.2.93 (macos; aarch64)";
2424

25-
export const XAI_BILLING_URL = "https://cli-chat-proxy.grok.com/v1/billing";
26-
27-
// Cap every token and billing request to the xAI proxy. The refresh runs on the
25+
// Cap every token request to the xAI proxy. The refresh runs on the
2826
// send path before the inference fetch arms its inactivity/total timers, so a
2927
// stalled token endpoint would otherwise freeze the agent at turn 0.
3028
export const XAI_TOKEN_TIMEOUT_MS = 15_000;

0 commit comments

Comments
 (0)