Files
plugins/packages
yetone 8163be365f zcode: test the system shape zcode.z.ai lets through (plugins#348)
XinOrigin's matrix on plugins#348 (11-04) says zcode.z.ai serves a Start
Plan request only when its system is an array of two or three text
blocks, ZCode's first byte for byte and its second as ZCode's begins; a
string, no system, the first block alone, the first with a block of the
caller's, or a fourth block answers 405/3012. The new test sends Claude
Code's shape (billing-header block, prompt, CLAUDE.md block, with
thinking adaptive, context_management and output_config), Codex's string
instructions, no system, and ZCode's first block alone, and checks each
goes out as the passing row: three text blocks, ZCode's first two
unchanged, the agent's text after ZCode's own sections in the third, the
top-level fields kept.

No code change: 0.1.51 already sends this shape (0.1.21 for #343, 0.1.48
for the 3.17.2 texts).

Live, on the owner's ZCode account (11-06 15:48 UTC, a GLM Coding Plan
account with no Start Plan gift), one request each to
zcode.z.ai/api/v1/zcode-plan/anthropic/v1/messages with 0.1.51's
startHeaders and dress:
- Claude Code-style system: 200 {"code":1005,"msg":"exceed quota limit"}
- the same with a 30KB agent system: 200, 1005
- Codex-style string system: 200, 1005
- Claude Code's top-level fields and a tool: 200, 1005
- control, ZCode's first block alone, not dressed: 405 code 3012
  (logid 20261106154826f91ddad38c8bfdefae1d)
So the system check runs before the quota check, and 0.1.51's dressing
gets past it. Not tried: a request on an account with a live gift (the
owner's has none), and a burst of requests.

Run on mote: bun test in packages/zcode, 201 pass, 0 fail, 12 runs in a
row; one earlier run had 5 reds in userid.test.mjs (expect(got.length)
.toBe(1)), not seen again in those 12 runs. bun scripts/check.mjs zcode
ok. Broken by hand: dress sending the agent's text as a fourth block
and more turns the new test red (Expected 3, Received 6); restored,
green.
2026-11-07 00:33:28 +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