-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(providers): Z.ai Start Plan provider (OAuth login, in-process traceless captcha, gateway wire) #4647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat(providers): Z.ai Start Plan provider (OAuth login, in-process traceless captcha, gateway wire) #4647
Changes from all commits
1c1fe0b
8ed2fc6
f533d19
eefbb72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"touched":[],"bashMutation":true,"reportedFindings":[],"findingEvents":[],"baseline":null,"stateErrors":[],"omittedReportedFindings":0,"omittedFindingEvents":0,"processing":null,"updatedAt":"2026-09-14T17:03:07.070Z"} |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -155,6 +155,8 @@ export interface LogEntry extends LogFailureAttribution { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timestamp: number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| provider: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Pool/account label the turn was served under (e.g. "p83fa8d", "main"); absent when unattributed. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| accountLogLabel?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| surface?: LogSurface; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| conversationId?: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -571,6 +573,34 @@ export default function Logs({ apiBase }: { apiBase: string }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| controller.abort(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, [apiBase]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Opaque log labels → human attribution (email masked per proxy privacy settings). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Fetched once per page: labels are stable for the lifetime of an account. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [accountLabels, setAccountLabels] = useState<Map<string, string>>(new Map()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const controller = new AbortController(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let cancelled = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fetch(`${apiBase}/api/account-labels`, { signal: controller.signal }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .then(res => (res.ok ? res.json() as Promise<{ labels?: Array<{ label?: unknown; email?: unknown; plan?: unknown }> }> : null)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+579
to
+583
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a connected-client dashboard initially has no shared GUI session, opening the Logs page starts this request before pairing and receives a 401. Completing the pairing changes the session state but not Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .then(body => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (cancelled || !body?.labels) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const map = new Map<string, string>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const row of body.labels) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof row.label !== "string" || !row.label) continue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const parts: string[] = []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof row.email === "string" && row.email) parts.push(row.email); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (typeof row.plan === "string" && row.plan) parts.push(row.plan); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (parts.length > 0) map.set(row.label, parts.join(" · ")); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!cancelled) setAccountLabels(map); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .catch(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Older proxy without the endpoint: fall back to the raw opaque labels. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cancelled = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| controller.abort(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, [apiBase]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+579
to
+603
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Add cleanup to the This effect creates an Two consequences follow:
The effect at lines 426-447 in this same file ( 🔧 Proposed fix to add cleanup and a stale-response guard const [accountLabels, setAccountLabels] = useState<Map<string, string>>(new Map());
useEffect(() => {
const controller = new AbortController();
+ let cancelled = false;
fetch(`${apiBase}/api/account-labels`, { signal: controller.signal })
.then(res => (res.ok ? res.json() as Promise<{ labels?: Array<{ label?: unknown; email?: unknown; plan?: unknown }> }> : null))
.then(body => {
- if (!body?.labels) return;
+ if (cancelled || !body?.labels) return;
const map = new Map<string, string>();
for (const row of body.labels) {
if (typeof row.label !== "string" || !row.label) continue;
const parts: string[] = [];
if (typeof row.email === "string" && row.email) parts.push(row.email);
if (typeof row.plan === "string" && row.plan) parts.push(row.plan);
if (parts.length > 0) map.set(row.label, parts.join(" · "));
}
setAccountLabels(map);
})
.catch(() => {
// Older proxy without the endpoint: fall back to the raw opaque labels.
});
+ return () => {
+ cancelled = true;
+ controller.abort();
+ };
}, [apiBase]);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // The hash is the source of truth for the active tab (#logs vs #logs/debug), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // so refresh/bookmark/back-forward keep the tab choice. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [tab, setTab] = useState<LogsTab>(readTabFromHash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -880,6 +910,7 @@ export default function Logs({ apiBase }: { apiBase: string }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <col className="logs-col-model" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <col className="logs-col-effort" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <col className="logs-col-provider" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <col className="logs-col-account" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <col className="logs-col-status" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <col className="logs-col-request" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <col className="logs-col-duration" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -893,6 +924,7 @@ export default function Logs({ apiBase }: { apiBase: string }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <th className="log-col-model">{t("logs.col.model")}</th> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <th>{t("logs.col.effort")}</th> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <th>{t("logs.col.provider")}</th> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <th>{t("logs.col.account")}</th> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <th>{t("logs.col.status")}</th> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <th>{t("logs.col.request")}</th> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <th className="num log-col-duration">{t("logs.col.duration")}</th> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -901,7 +933,7 @@ export default function Logs({ apiBase }: { apiBase: string }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <tbody> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {paddingTop > 0 && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td colSpan={10} className="logs-virtual-spacer" style={{ height: paddingTop }} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td colSpan={11} className="logs-virtual-spacer" style={{ height: paddingTop }} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {virtualRows.map(virtualRow => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -986,6 +1018,7 @@ export default function Logs({ apiBase }: { apiBase: string }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9% column and painted over the provider cell. */} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td className="mono log-reasoning-cell" title={reasoningWire}>{effortLabel(log)}</td> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td className="muted">{formatProviderDisplayName(log.provider, t)}</td> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td className="muted mono" title={log.accountLogLabel}>{accountLabels.get(log.accountLogLabel ?? "") ?? log.accountLogLabel ?? "—"}</td> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="log-status-cell"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span className="mono font-semibold" style={{ color: statusColor(log.status) }}>{log.status}</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1006,7 +1039,7 @@ export default function Logs({ apiBase }: { apiBase: string }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {paddingBottom > 0 && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td colSpan={10} className="logs-virtual-spacer" style={{ height: paddingBottom }} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <td colSpan={11} className="logs-virtual-spacer" style={{ height: paddingBottom }} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </tr> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </tbody> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,7 @@ | |
| "@modelcontextprotocol/sdk": "^1.30.0", | ||
| "@napi-rs/keyring": "1.3.0", | ||
| "bun": "1.4.0", | ||
| "happy-dom": "^20.11.6", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🤖 get_repo_knowledge executed:
Length of output: 17317 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- tracked manifest and likely security docs ---'
git ls-files | rg '(^|/)(package\.json|package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|SECURITY(\.md)?|CONTRIBUTING(\.md)?|README(\.md)?|.*security.*|.*dependency.*)$' | head -120
printf '%s\n' '--- package manifest ---'
cat -n package.json | sed -n '1,130p'
printf '%s\n' '--- happy-dom references ---'
rg -n -S --glob '!node_modules/**' --glob '!dist/**' 'happy-dom|captcha.?solver|captchaSolver|captcha' . | head -240
printf '%s\n' '--- dependency-related review evidence terms ---'
rg -n -i --glob '!node_modules/**' --glob '!dist/**' 'security review|dependency review|provenance|advisory|lifecycle.?script|isolation' . | head -240
printf '%s\n' '--- concise diff summary ---'
git diff --stat
git diff -- package.json | sed -n '1,180p'Repository: lidge-jun/opencodex Length of output: 50375 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- exact dependency-review guidance ---'
sed -n '350,380p' AGENTS.md
sed -n '55,78p' MAINTAINERS.md
printf '%s\n' '--- package state and lockfile binding ---'
git status --short
git diff --stat
sed -n '1,28p' bun.lock
sed -n '205,225p' bun.lock
printf '%s\n' '--- narrow happy-dom review-evidence search ---'
rg -n -i --glob '!bun.lock' --glob '!gui/bun.lock' --glob '!gui/**' --glob '!node_modules/**' 'happy-dom|dependency security review|dependency review' AGENTS.md MAINTAINERS.md CONTRIBUTING.md SECURITY.md devlog docs scripts src package.json .github 2>/dev/null | head -220
printf '%s\n' '--- solver and host imports/entry flow ---'
sed -n '1,45p' src/adapters/zcode-start-plan/captcha-solver.ts
sed -n '1,125p' src/adapters/zcode-start-plan/captcha-host.ts
sed -n '175,215p' src/adapters/zcode-start-plan.tsRepository: lidge-jun/opencodex Length of output: 27652 Record the required security review for
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| "zod": "4.4.3" | ||
| }, | ||
| "devDependencies": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /** | ||
| * ZCode client identity headers. | ||
| * | ||
| * Z.ai attributes GLM Coding Plan traffic to the client that sent it, and grants the | ||
| * ZCode harness an increased usage allowance (150%) over third-party clients. These | ||
| * builders reproduce the official client's LLM companion headers so plan-metered | ||
| * destinations are attributed correctly: | ||
| * | ||
| * - Identity: `HTTP-Referer`, `User-Agent: ZCode/<version>` (optionally with the AI SDK | ||
| * suffix the client appends on Anthropic-wire calls), `X-ZCode-App-Version`, `X-Title`, | ||
| * `X-Release-Channel`, `X-Client-Language`/`-Timezone` (always sent, "unknown" | ||
| * fallback), `X-Platform`, `X-Os-Category`, `X-Os-Version`, and `X-ZCode-Agent: glm` | ||
| * last. No `X-Device-Mid` on LLM calls. | ||
| * - Attribution: fresh `x-request-id`/`x-zcode-trace-id` per request and | ||
| * `x-zcode-session-type: main`; the coding-plan routes also carry `x-query-id` and | ||
| * `x-session-id`, which the plan gateway route omits. | ||
| * | ||
| * Eligibility is endpoint-based: only destinations that meter a plan subscription — | ||
| * the coding paths (`/api/coding/paas/v4`, the BigModel Responses v1 route) and the | ||
| * zcode.z.ai plan gateway — qualify. Pay-as-you-go endpoints (`/api/paas/v4`) have no | ||
| * subscription quota, so identifying there would be pointless noise. | ||
| */ | ||
| import { randomUUID } from "node:crypto"; | ||
| import { arch, platform, release } from "node:os"; | ||
|
|
||
| const ZCODE_APP_VERSION = process.env.ZCODE_PLAN_APP_VERSION?.trim() || "3.11.2"; | ||
| const ANTHROPIC_SDK_UA = "ai-sdk/anthropic/3.0.81"; | ||
| const ZCODE_PLAN_ORIGIN = "https://zcode.z.ai"; | ||
|
|
||
| function printable(value: string | undefined): string | undefined { | ||
| const v = value?.trim(); | ||
| return v && /^[\x20-\x7e]+$/.test(v) ? v : undefined; | ||
| } | ||
|
|
||
| function osCategory(p: string): string { | ||
| if (p === "darwin") return "macos"; | ||
| if (p === "win32") return "windows"; | ||
| return "linux"; | ||
| } | ||
|
|
||
| function clientLanguage(): string { | ||
| try { | ||
| return Intl.DateTimeFormat().resolvedOptions().locale || "unknown"; | ||
| } catch { | ||
| return "unknown"; | ||
| } | ||
| } | ||
|
|
||
| function clientTimezone(): string { | ||
| try { | ||
| return Intl.DateTimeFormat().resolvedOptions().timeZone || "unknown"; | ||
| } catch { | ||
| return "unknown"; | ||
| } | ||
| } | ||
|
|
||
| /** True for the plan-gateway send URLs this adapter targets. */ | ||
| export function isZcodePlanMeteredEndpoint(sendUrl: string | undefined): boolean { | ||
| if (!sendUrl) return false; | ||
| const url = sendUrl.replace(/\/+$/, "").toLowerCase(); | ||
| return url === "https://zcode.z.ai/api/v1/zcode-plan/anthropic/v1/messages" | ||
| || url === "https://zcode.z.ai/api/v1/zcode-plan/anthropic/v1/messages?beta=true"; | ||
| } | ||
|
|
||
| /** Companion headers the official client sends on every LLM completion. */ | ||
| export function buildZcodeIdentityHeaders(opts: { userAgentSuffix?: string } = {}): Record<string, string> { | ||
| const version = printable(ZCODE_APP_VERSION); | ||
| const osPlatform = printable(process.env.ZCODE_IDENTITY_PLATFORM ?? platform()) ?? ""; | ||
| const osArch = printable(process.env.ZCODE_IDENTITY_ARCH ?? arch()) ?? ""; | ||
| const osRelease = printable(process.env.ZCODE_IDENTITY_RELEASE ?? release()); | ||
| const releaseChannel = process.env.ZCODE_ENV?.trim().toLowerCase() === "test" ? "test" : "production"; | ||
| return { | ||
| "HTTP-Referer": ZCODE_PLAN_ORIGIN, | ||
| "User-Agent": `ZCode/${version ?? "unknown"}${opts.userAgentSuffix ? ` ${opts.userAgentSuffix}` : ""}`, | ||
| ...(version ? { "X-ZCode-App-Version": version } : {}), | ||
| "X-Title": "Z Code@cli", | ||
| "X-Release-Channel": releaseChannel, | ||
| "X-Client-Language": clientLanguage(), | ||
| "X-Client-Timezone": clientTimezone(), | ||
| ...(osPlatform && osArch ? { "X-Platform": `${osPlatform}-${osArch}` } : {}), | ||
| ...(osPlatform ? { "X-Os-Category": osCategory(osPlatform) } : {}), | ||
| ...(osRelease ? { "X-Os-Version": osRelease } : {}), | ||
| "X-ZCode-Agent": "glm", | ||
| }; | ||
| } | ||
|
|
||
| /** Fresh per-request attribution headers; scope selects the coding-plan-only pair. */ | ||
| export function buildZcodeTraceHeaders(scope: "start-plan" | "coding-plan" = "coding-plan"): Record<string, string> { | ||
| return { | ||
| "x-request-id": randomUUID(), | ||
| "x-zcode-session-type": "main", | ||
| "x-zcode-trace-id": randomUUID(), | ||
| ...(scope === "coding-plan" ? { "x-query-id": randomUUID(), "x-session-id": randomUUID() } : {}), | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 1500
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 6196
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 41357
Add
logs.col.accountto the Vietnamese catalog.vi.tsis a supported locale. Its catalog does not definelogs.col.account, while the other named locale files do. Add a Vietnamese translation togui/src/i18n/vi.ts.🤖 Prompt for AI Agents
Source: Learnings