Files
plugins/packages
yetone a810ee7e88 zen-free 0.1.6: a free-model request carries exactly the headers OpenCode 1.19.0 sends to Zen, and none of the caller's (xiaoxiaofeixz on magpie's Discord, #100, #108)
Since 10-13 Zen answers 403 FreeTierError ("OpenCode's free tier can only
be used from within OpenCode") to a free-model request that isn't
OpenCode's. npm still serves 0.1.1, which gets that 403 on every model;
0.1.5's OpenCode-form session id (9074723) fixed it but never reached npm.
The owner allows mimicking OpenCode's client on this route (client
mimicry is allowed for every vendor but Claude Code), so this reverses
643ef50's README note.

Diffed against the release binary itself: OpenCode 1.19.0
(anomalyco/opencode v1.19.0) run in a sandbox HOME with the opencode
provider's baseURL pointed at a local capture server, on chat, responses
and messages. It sends accept */*, content-type, user-agent
"opencode/1.19.0 ai-sdk/provider-utils/<v> runtime/bun/1.3.14" (4.0.23
chat, 4.0.40 responses, 4.0.46 messages), x-opencode-project, -session,
-request, -client, -session-id, and the key (authorization, or x-api-key
with anthropic-version). It sends no x-session-id or x-session-affinity
to its own gateway (session/llm/request.ts). 0.1.5 differed in: those two
extra headers, accept text/event-stream, the chat UA on every protocol,
and every header the caller sent going on (through magpie: the agent's
own User-Agent, x-stainless-*, anthropic-beta...).

0.1.6 builds the upstream headers from that list alone: the caller's are
read only for the session and project, anthropic-version/-beta kept on
messages. The new per-protocol test checks the exact set and fails on
0.1.5 (4 fails); the forced-streaming test now expects no
x-session-id/x-session-affinity.

Run:
- bun test in packages/zen-free: 169 pass, 3 runs; bun scripts/check.mjs
  zen-free passes.
- Real opencode.ai, anonymous key "public": npm's 0.1.1 gets 403
  FreeTierError on big-pickle, mimo-v2.6-flash-free and
  muse-spark-1.3-contributor-free, streamed and not. 0.1.6's
  tools-smoke.mjs: 200 with a Bash call on all three streamed and on
  big-pickle not streamed; muse non-streamed 200 without a call;
  mimo non-streamed timed out at 90s, the same on 0.1.5.
- magpie 0.1.1208 in a sandbox HOME (scripts/try.sh zen-free): sign-in
  with public, then `provider test opencode-zen-free`: chat (big-pickle)
  and responses (muse-spark) both pass.
Not tried: a messages-protocol free model (Zen has none free now), Windows.
2026-10-14 18:57:57 +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
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