zcode 0.1.55: no claim while ZCode asks its security check; the desktop's X-Title and a per-turn x-query-id

young02036 (Discord, 11-07): on an account with a GLM Coding Plan, the
GLM-5.3-Flash-Trial gift answers 405 code 3012 ("blocked due to unusual
activity") while the paid models work, and the plugin's daily check-in
gets a captcha every day while the app shows none.

Diffed against the official ZCode 3.17.2 (zip sha512 matched its
manifest; glm/zcode.cjs and app.asar's host and renderer code):

- The claim. The app's claimManualPlan posts the claim with
  X-Aliyun-Captcha-Verify-Param/Region, and its renderer always runs the
  traceless captcha first. client/configs says captcha.enabled true
  (testdata/client-configs-1107.json, the real reply cut down). The plugin
  can't make that proof, so each day's claim was one more refused claim.
  Now claimDaily reads client/configs (cached ten minutes, a failed read
  not kept) before posting: while captcha.enabled is not false nothing is
  posted and each plan answers captcha, "claim it in the ZCode app"; a
  config that doesn't read is failed, nothing posted. The captcha is not
  got past.
- X-Title. The desktop's model requests say "Z Code@electron"
  (sourceTitle from zcode-protocol-entrypoint); the plugin said
  "Z Code@cli".
- x-query-id. ZCode sends one per user query (query_<uuid>, prefix
  stripped). The Start Plan path now sends a UUID made from the session
  and the count of user text messages: the same through a turn's tool
  results, new with the next user message.

The 3012 itself: on the owner's account (no gift, so code 1005 "exceed
quota limit" means risk control let it through) every shape answered
200 code 1005: adaptive thinking with effort max and max_tokens 64000, a
1.6 MB body, max_tokens 200000, thinking enabled with budget 1024, and
X-Title electron. So the request's shape is not what trips 3012; the
reporter's account looks blocked by risk control as a whole, which only
ZCode support lifts. That the daily captcha-less claims fed it is a
guess.

Run (mote): HOME=$(mktemp -d) bun test in packages/zcode, 222 pass 0
fail; bun scripts/check.mjs zcode ok.
Broken by hand, each red, then restored (cmp ok): the claim gate removed
(2 fail), a config read failure taken as no captcha (1), x-query-id not
set (2), user turns counted wrong (1), the title back to cli (3).
Not tried: a real claim or a real 3012 account (the reporter's); the new
headers against an account that has a gift; Windows and Linux.

Reported-by: young02036
This commit is contained in:
yetone
2026-11-07 14:57:59 +08:00
parent e7cb9dc54c
commit ea9904d54c
7 changed files with 195 additions and 13 deletions
+24 -3
View File
@@ -248,7 +248,7 @@ test("a Start Plan request carries ZCode's headers, and only those", async () =>
"http-referer": "https://zcode.z.ai",
"user-agent": "ZCode/3.17.2 ai-sdk/anthropic/3.0.81",
"x-zcode-app-version": "3.17.2",
"x-title": "Z Code@cli",
"x-title": "Z Code@electron",
"x-release-channel": "production",
"x-client-language": o.locale,
"x-client-timezone": o.timeZone,
@@ -260,9 +260,12 @@ test("a Start Plan request carries ZCode's headers, and only those", async () =>
"x-zcode-session-type": "main",
"x-zcode-trace-id": h["x-zcode-trace-id"],
"x-zcode-query-source": "main_turn",
// the user's query this turn answers, as 3.17.2 names it
"x-query-id": _internal.queryOf(JSON.stringify(agentBody), _internal.sessionOf("", DEVICE)),
// the conversation, as ZCode names it; the agent told none (#387)
"x-session-id": _internal.sessionOf("", DEVICE),
})
expect(h["x-query-id"]).toMatch(UUID)
expect(h["x-api-key"]).toBeUndefined()
expect(h["x-device-mid"]).toBeUndefined()
})
@@ -297,7 +300,7 @@ test("a Start Plan request from Claude Code goes with ZCode's headers alone, wit
const h = own(r.headers)
for (const k of Object.keys(CLAUDE_CODE)) if (!TRANSPORT.has(k)) expect(h[k]).toBeUndefined()
expect(Object.keys(h).sort()).toEqual(
["authorization", "anthropic-version", "content-type", "http-referer", "user-agent", "x-zcode-app-version", "x-title", "x-release-channel", "x-client-language", "x-client-timezone", "x-zcode-agent", "x-platform", "x-os-category", "x-os-version", "x-request-id", "x-zcode-session-type", "x-zcode-trace-id", "x-zcode-query-source", "x-session-id"].sort(),
["authorization", "anthropic-version", "content-type", "http-referer", "user-agent", "x-zcode-app-version", "x-title", "x-release-channel", "x-client-language", "x-client-timezone", "x-zcode-agent", "x-platform", "x-os-category", "x-os-version", "x-request-id", "x-zcode-session-type", "x-zcode-trace-id", "x-zcode-query-source", "x-query-id", "x-session-id"].sort(),
)
expect(r.headers.accept).not.toBe(CLAUDE_CODE.accept)
}
@@ -375,7 +378,7 @@ test("a Start Plan body with no model has no powered-by line; a blank system add
test("a Start Plan request made as a Request, its body a stream, is dressed too", async () => {
const r = await send(start("zai"), JSON.stringify(agentBody), { asRequest: true })
expect(r.headers["x-title"]).toBe("Z Code@cli")
expect(r.headers["x-title"]).toBe("Z Code@electron")
expect(JSON.parse(r.body).system).toEqual(zcodeSystem("zai-api/GLM-5.3-Flash", undefined, AGENT_OWN))
expect(Number(r.headers["content-length"])).toBe(Buffer.byteLength(r.body))
})
@@ -755,3 +758,21 @@ test("a few caps do not hold the Start Plan, and coding plan caps hold nothing",
_internal.busyHold.now = () => Date.now()
}
})
// 3.17.2's x-query-id (createModelRequestAttributionHeaders) names the
// user's query: every request of one turn, the tool calls on the way
// among them, carries the same, and what the user says next a new one.
test("x-query-id is the turn's: the same through tool results, new for the next user message", () => {
const q = (messages, sid = "s1") => _internal.queryOf(JSON.stringify({ messages }), sid)
const ask = { role: "user", content: [{ type: "text", text: "fix it" }] }
const call = { role: "assistant", content: [{ type: "tool_use", id: "t1", name: "Bash", input: { command: "ls" } }] }
const result = { role: "user", content: [{ type: "tool_result", tool_use_id: "t1", content: "a.go" }] }
const first = q([ask])
expect(first).toMatch(UUID)
expect(q([ask, call, result])).toBe(first)
expect(q([ask, call, result, { role: "assistant", content: "done" }, { role: "user", content: "thanks" }])).not.toBe(first)
expect(q([ask], "s2")).not.toBe(first)
// nothing the user said, or a body that doesn't read: none
expect(q([result])).toBe("")
expect(_internal.queryOf("{", "s1")).toBe("")
})