Files
plugins/packages
yetone 744e1e26f3 autoclaw 0.2.12: the overseas chat sends the official 2.0.3 fingerprint, and X-Tm "linux" on Linux as the official client does (#367)
menhouran captured the official AutoClaw 2.0.3 Linux chat request and
corrected the report behind 0.2.7: the official client sends X-Tm "linux",
not "linux-x64". The overseas gateway refuses "linux" only beside a
non-official fingerprint (X-Channel AutoClaw4, X-Version 1.18.1, no
X-Auth-*); "linux-x64" got through only because it isn't the one value
checked.

Read from the official client itself: AutoClaw-2.0.3-x64.AppImage from
autoclaw.z.ai's Linux download (sha512 matches latest-linux.yml),
resources/app/dist/main.cjs, extracted with 7zz and never run.
createZworkManagedRequestHeaders and createZworkManagedModelRequestResolvers
build the chat headers:
- X-Tm from managedPlatform(): darwin mac, win32 win, else process.platform
  as is (Linux is "linux" on x64 and arm64);
- X-Auth-Sign = md5("100003&<seconds>&<appKey>"), the same identity and
  signature the plugin already sends on its sign-in/wallet paths;
- X-Channel official, X-Version app.getVersion() (2.0.3), X-Lang the
  product language (en in the reporter's capture), X-Product autoclaw,
  X-Client-Type pc, x_trace_id autoclaw-desktop;
- X-Request-Id = X-Trace-Id = a randomUUID per attempt; X-Session-Id the
  session's UUID; X-Authorization Bearer, no Authorization;
- the request goes through the OpenAI SDK 6.26.0 in Electron 42.6.1
  (Node v24.18.0), which adds User-Agent "OpenAI/JS 6.26.0" and
  X-Stainless-* (OS/Arch through the SDK's own normalizers).

The overseas chat now sends that set. X-Session-Id is a UUID derived from
the conversation's first non-system message, so it stays the same across a
conversation's turns as the official one does. The caller's own
X-Stainless-* headers are dropped. bizHeaders (sign-in, refresh, wallet,
check-in) keep AutoClaw4/1.18.1 and send X-Tm "linux" again, as before
0.2.7, when they worked on Linux. README says what is sent and that
linux-x64 was a bypass.

Not changed: the overseas chat path keeps /v1/chat/completions, which the
reporter verified; the official client posts to .../autoclaw/chat/completions.
X-Stainless-Timeout is 600, the SDK default when no per-request timeout is
passed; whether zwork passes one wasn't traced to the end.

Run: HOME=$(mktemp -d) bun test in packages/autoclaw on mote, 46 pass;
bun scripts/check.mjs autoclaw ok; the same suite on Linux (wsl-run,
magpie-desktop) 46 pass. The new tests on origin/main's index.mjs: 4 fail
(the three #367 tests and the UA check in the 406 test).
Not tried: a real overseas account (none here), on Linux or anywhere; the
reporter is asked to confirm on #367.
2026-10-29 01:46:07 +08:00
..
middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon.
2026-10-05 20:49:42 +08:00
middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon.
2026-10-05 20:49:42 +08:00