40 Commits
Author SHA1 Message Date
yetone 28ba363943 zen-free 0.1.28: DSH's edit, read and skill go reworded, edit and read renamed (#632)
SuperWheel bisected DSH 0.2.2-rc.3's 37-tool request against Zen on
2026-11-16 (#632): with 0.1.27 it still drew 429 FreeUsageLimitError.
Alone, only edit, read and skill were refused. Each of those three
descriptions was refused under a neutral name; edit and read were
refused by name together with their own parameters (neutral
description), while the same parameters under `foo` were served.

- REFUSED_DESCRIPTIONS: the three descriptions, matched whole after
  trimming, go reworded with the same meaning.
- REFUSED_WITH_PARAMETERS: edit (file_path, old_string, new_string)
  goes as text_replace, read (file_path, offset, limit) as file_view;
  a call of either comes back under DSH's name through the existing
  renamed map. A read or edit without those parameters (OpenCode's own
  read takes filePath) keeps its name.
- normalizeTools now renames before it adds the core stand-ins, so a
  renamed edit or read still has Zen's stand-in of that name beside it;
  `declared` is taken before the rename, as before.
- README says so.

Run (mote, HOME=$(mktemp -d)):
- bun test in packages/zen-free: 228 pass, 0 fail.
- bun scripts/check.mjs zen-free: ok.

Broken by hand: origin/main's provider.mjs with the new tests: the DSH
test fails on all three protocols.

Not tried: Zen itself. This machine's address is over Zen's free
allowance, so the reworded descriptions and the new names are not known
to be served; they are a guess built on the reporter's table (shorter
wordings and other names were served there). SuperWheel is asked to
replay the same 37 tools through 0.1.28.
2026-11-16 12:45:56 +08:00
yetone 0135b7b0ea agy-cli 0.1.32: the first model list after warming has agy's Claude and GPT models (#1064)
On a signed-in agy, `agy models` takes about 4.4s and `agy acp`'s
session/new about 3s. provider.models() needed three calls before
claude-opus-5-5, claude-sonnet-5-5 and gpt-oss-120b showed up, and
OpenCode 2.x calls it once.

What changed:
- packages/agy-cli/index.mjs:
  - The offered-model probe now starts in listAgyModels' .then, as soon as
    a non-empty list arrives and a caller asked for probeOffered. It no
    longer waits for the next models() call. A hung or failed `agy models`
    still never spawns the probe.
  - probeSignedIn reuses the `agy models` stdout it already has. The same
    parser (parseAgyModels, split out of listAgyModels) fills
    cachedModelCatalog, and the probe starts. Sign-in waits for the probe
    for at most 3s.
  - The offer (acpOfferedModels, acpOfferedKey, offeredProbeAt and any
    in-flight probe) is forgotten when agyPath changes and after a new
    sign-in finishes. A generation counter drops the answer of a probe
    that started before the reset.
  - provider.warming() returns a promise while a list or probe is still
    running, and null when nothing is.
- scripts/opencode2.mjs, copied byte for byte to every
  packages/*/opencode2.mjs: after the first background refresh, the
  adapter awaits hooks.provider.warming() once, for at most 60s, and then
  refreshes once more. It does not loop. Plugins without warming() behave
  as before.
- Not done: the issue's on-disk catalog cache (point 3), skipped as asked.

Known gap: agy-cli has no `config` hook, so under OpenCode 2.x the adapter
lists no provider for it. refresh() returns before it calls
provider.models(), so the follow-up refresh can't add agy's models on 2.x
until agy-cli gets a config hook.

Tests: test/testkit.mjs's fake agy takes a sessionNewDelayMs. The new
tests in test/catalog.mjs set 1.5s on both `agy models` and session/new
and wait for state through warming(), with no fixed sleeps:
- On a slow cold start, the first models() after warming lists Claude and
  GPT, from one probe spawn.
- authorize() on a signed-in agy fills the catalog, and the next models()
  runs no second `agy models`.
- The sign-in wait is bounded: with a 6s session/new, sign-in returns in
  about 4.5s.
- Changing agyPath probes again.
The hang test now awaits warming() before it counts acp spawns.
scripts/opencode2.test.mjs: the warming list is read a second time when
warming ends, and only once when nothing is warming.

Run on Linux (a separate test Mac was over its load limit):
- packages/agy-cli bun test: 17 pass, 0 fail.
- bun scripts/check.mjs agy-cli: ok.
- bun scripts/check.mjs (all packages): ok.
- Root bun test in a temp HOME: 8530 pass, 19 skip, 0 fail.

Broken by hand on Linux, each red, then restored green:
- No probe in the .then: the slow cold-start test.
- probeSignedIn drops the list: the authorize and bounded-wait tests.
- agyPath change keeps the old offer: the agyPath test.
- Unbounded sign-in wait: the bounded-wait test (7514ms).
- Probe also on a failed listing: the hang test.
- origin/main's index.mjs with the new tests: all four #1064 tests.
- Adapter reads the list once: the warming adapter test, and the
  copy-identity check.

Not tried: a real agy (no Google sign-in, no network). The reset after
login.finish has no unit test of its own.

Reported-by: hiee3
2026-11-13 10:59:13 +08:00
yetone 34786edadb qoder 0.2.65: two tool calls at one index with their own ids are two (#930)
Qoder Ultimate sent two native tool calls at tool_calls[].index 0, each
with its own id and name. events() kept one call per upstream index, so
the second call's arguments were sent as more of the first:
{"key":"A"}{"key":"B"}, which the client refused as unparseable JSON.

A fragment with a non-empty id that differs from the open call's id at
that index now starts a new call with an output index of its own. A
fragment with no id, or the open call's id, still goes on with the open
call (OpenAI's argument fragments, and relays that repeat the id). A call
pushed aside before it got a name still counts as nameless (#579).
After two ids at one index, id-less fragments go to the newer call; the
report suggested failing there instead, but OpenAI streams each call's
fragments right after its start, so the newest is the one open.

Siblings with the same index-keyed fold, fixed the same way:
- zed 0.1.19: chatWhole (a streamed chat reply folded for stream:false).
- codearts 0.3.7: completionFromChunks.
- zen-free 0.1.27: stream.mjs chatAccumulator, and tool-response.mjs's
  chat buffer, which gives each call its own index when two collided.
- page-chat 0.1.13: lib/server.mjs folds through toolCallFolder.
Looked at and left: codearts' stream name restorer and kimi-desktop's
Agent hold pass fragments through unchanged and join no arguments;
zed's streaming path passes Zed's chunks through, and magpie's gateway
already starts a new call on a new id (internal/gateway/chat.go).

Run (WSL magpie-desktop, bun 1.4.2, node 22):
- pedh's repro.mjs with his fixture: [0,0] gave one tool event plus an
  args event on 0.2.64; now two tool events (index 0 and 1), each with
  valid JSON. [0,1] unchanged.
- HOME=$(mktemp -d) bun test packages/qoder packages/zed
  packages/codearts packages/zen-free packages/chat: 987 pass, 0 fail,
  1 skip (the epub reader's, as before). bun scripts/check.mjs: every
  package and registry.json ok.

Broken by hand:
- qoder back to index-only: 3 of the new tests fail (two ids, id-less
  after a second id, streaming adapter).
- qoder starting a call on any fragment without the open id: 8 fail,
  the id-less continuation test among them.
- qoder treating any id as new: the repeated-id test fails.
- zed, codearts, zen-free (both) on main's code and chat keyed by index
  only: each new collision test fails (5 of 5).

Not tried: a real Qoder account (no Qoder Ultimate here), real Zed,
CodeArts or OpenCode Zen replies with a collision, and the chat page
in a browser.

Reported-by: pedh <pedh@users.noreply.github.com>
2026-11-10 16:56:37 +08:00
我是一条没有名字的区 087c36123d inkstone 0.1.3: image-caps preflight, a zero-prompt browser sign-in, key calls on the session cookie (#832)
inkstone 0.1.3 (#832, yunwang2442-creator):

- Image requests are prechecked before they leave: 8 images, 10MB each, 40MB in all.
  - A request over a cap gets a local 400 shape refusal, so magpie asks the next account and rests none.
  - The plan's invalid_media / media_fetch_failed / unsupported_media_type errors become the same kind of refusal.
- The body rewrite strips the reasoning fields and sets image detail to auto.
- A zero-prompt browser sign-in comes first, and a second browser method reuses a pasted key.
  - Neither browser method is offered when no Chromium-family browser is found (#825).
- The /keys calls ride the session cookie, without the pagination query. Key creation retries the console's -15100 "refresh page and retry".
- The #826 metadata token read is kept, and its test is back.
- The fake browser is built once per user and source hash (#824), and the title wait reads only on Windows.
- maxConcurrency is 4.
- The doubled comment line is dropped from every opencode2.mjs copy, agy-cli's included.

Reviewed at 88e66bde, on mote (macOS, Bun 1.4.2) with a temp HOME:
- full bun test: 6853 pass / 0 fail; both checks exit 0
- bun scripts/check.mjs and bun scripts/check.mjs inkstone: exit 0
- 21 hand breaks: 20 red, 1 not caught (the /keys pagination test calls protocol.listKeys directly; follow-up filed)

Not tried: a real InkStone account or sign-in, Windows and Linux runs.
2026-11-07 22:24:56 +08:00
我是一条没有名字的区 e7004d9354 inkstone 0.1.0: Intern InkStone (书生·端砚) Token Plan, browser sign-in, credit card and ink-* key chat (#775)
New package @magpie-community/opencode-inkstone-auth 0.1.0 for Intern
InkStone (书生·端砚, Shanghai AI Lab) Token Plan, provider id
`intern-inkstone`. Community package by yunwang2442-creator.

What it does:
- Browser sign-in (Edge/Chrome, its own profile under
  $XDG_CONFIG_HOME or ~/.config/magpie/inkstone-browser, or
  %LOCALAPPDATA%\magpie\inkstone-browser). The login window has no
  debugging port. A headless CDP read takes the uaa-token cookie, and the
  same read renews it silently later.
- Usage card: ink-credit balance, 5-hour and 7-day windows, credit packs.
- Chat: a pasted ink-* API key, or one the sign-in creates, named
  ink-<host4>-<acct4>-<rand4> (18 of the console's 20 characters). An
  idempotency clash (-15109) retries with a fresh name, up to three times.
  Pruning is on by default. It only touches this machine's and account's
  prefix, keeps the newest two and the key this sign-in created, and never
  deletes manual keys or keys of unknown age.
- Closing on Unix: SIGTERM, then SIGKILL only after a 15s grace. Leftover
  browsers are matched by --user-data-dir=<escaped profile>, and Windows
  uses .Contains().
- The login wait comes from an injected waitForLogin in tests. No env
  hook is left in production code.
- Hosts: discovery.intern-ai.org.cn, discovery-api.intern-ai.org.cn,
  127.0.0.1 (CDP).

Outside the package: scripts/opencode2.mjs lets a prompt with
`required: false` stay optional (`p.required !== false`). Every package's
copy is synced byte for byte, so all 39 copies in the merged tree are blob
afe074cb. No other package sets `required: false` on a prompt, so this
changes nothing for them. Also a root README row and a registry entry.

Review at 36412a15, on mote, HOME=$(mktemp -d), Bun 1.4.2:
- bun test packages/inkstone: 68 pass, 0 fail in Asia/Shanghai, UTC,
  America/Los_Angeles and Pacific/Kiritimati.
- bun scripts/check.mjs inkstone and bun scripts/check.mjs: ok.
- bun test (repo), on 36412a15 merged with origin/main e7cb9dc5:
  6743 pass, 20 skip, 0 fail. main has since moved by cline 0.1.14 and
  zcode 0.1.55 only, and none of the adapter copies changed.
- Broken by hand, each red: no protectName protection; prune_keys default
  off; no post-sign-in prune; no SIGTERM on close; the -15109 retry keeping
  its name.

Not tried: a real InkStone account sign-in on macOS, Linux or Windows (no
account here); a live chat request; magpie end to end with the plugin.
2026-11-07 15:07:06 +08:00
yetone 54633128a1 zen-free 0.1.26: a tool named run_code goes as exec_program (#704)
alonewolfsy-web (#704): DeepSeek Harness desktop 0.2.1-rc.5 gets 429
FreeUsageLimitError on every main request through Zen's free tier. DSH's
main request offers one tool, run_code, and the reporter's one-variable
bisection against the inference endpoint shows Zen refuses any declared
name containing "run_code", in any case, the underscore needed
(run_code_v2, host_run_code, RUN_CODE, Run_Code refused; exec_program,
code_run, runCode, run-code served; description and schema not read).

The existing word rule (REFUSED_WORD, /terminal/i -> console, #624)
becomes a list, REFUSED_WORDS, and run_code -> exec_program is its
second entry. The served word takes the found word's case (EXEC_PROGRAM,
Exec_Program, exec_program), so terminal's renames are unchanged.
Everything else is the existing path: renameRefused renames the tool,
the agent's past calls and tool_choice; nameGuard brings a call of
exec_program back as run_code, streamed or not, in chat, responses and
messages; an agent's own exec_program keeps its name and DSH's goes as
exec_program_2 (the existing collision loop). README says so.

Run (mote, bun 1.4.2): packages/zen-free bun test 222 pass, 0 fail;
bun scripts/check.mjs rc=0.
Broke it by hand: provider.mjs from origin/main under the new tests ->
the 6 new #704 tests fail (3 protocols x client stream on/off), each
with the call coming back as exec_program, not run_code.
Real use: one sandbox-HOME run on mote with the public key against the
real Zen endpoint (big-pickle, beam-free, flint-40b-free). Every request
was 429 FreeUsageLimitError, the controls too (tools named Bash and
code_run), so that network's allowance was spent and the run tells
nothing about run_code either way. Not verified live; the reporter's
bisection is what the rule rests on.
2026-11-04 13:43:59 +08:00
yetone 1865969e1f zen-free 0.1.25: ZCode 3.17.2 workflow tool pairs go under other names (#693)
Version bump for #694 (merged). 0.1.24 was never visible on npm (latest 0.1.23).
Run: PR tests on mote at the reviewed head, see #694 merge body.
2026-11-04 10:06:40 +08:00
CueBeiXing bf2dbd28f0 zen-free: ZCode 3.17.2 workflow tool pairs go under other names (#694)
Reviewed every line at 4619beb34bdfc3a2d16ee067a12e10f064501e6c.

Adds two REFUSED_TOGETHER pairs (CreateWorkflow+GetWorkflowRun, AmendWorkflow+FillWorkflowHole) for ZCode 3.17.2. The rename and the way back reuse the existing renameRefused / nameGuard paths unchanged, so tools, past calls and tool_choice are renamed and replies (streamed or not) come back under ZCode's names in chat, responses and messages.

Run on mote at that head (node --test packages/zen-free/*.test.mjs, node 22): 212 of 216 pass. The 4 reds (3 "sends OpenCode's own headers" tests and keyless.test.mjs) fail the same on origin/main in a worktree (208 of 212; node 22 adds accept-language/sec-fetch-mode headers), so they are not from this PR.
Broke it by hand: provider.mjs from origin/main with the PR's tests -> the 3 new per-protocol round-trip tests fail (index.test 55-57); the lone-name test passes both ways, as it should.
Not tried: a real ZCode request against Zen (the reporter's bisection is taken from the PR).
Version bump follows on main (0.1.25).
2026-11-04 10:06:25 +08:00
yetone 17e5ef7457 all: load on OpenCode 2.x through a default {id, setup} (#657)
nbczw8750 (#657): trae 0.2.26 on OpenCode 2.2.5 fails with "Plugin
must export a default definition with an id and an effect or setup
function. (cause: SchemaError(Missing key at ["default"]))". 2.x
imports a package's exports["."] (a plugin dir and an npm install
alike) and has no V1 path at all, so every package here that serves
models failed the same way, not only trae.

Every one of the 32 model packages now has:
- opencode2.mjs, exports["."]: a copy of scripts/opencode2.mjs, an
  adapter that runs the package's V1 plugins inside 2.x's promise
  API. Config providers become 2.x providers (package pinned so the
  aisdk sdk hook runs), V1 auth methods become integration methods
  (oauth auto/code with forms; api without authorize as a key method),
  V1 credentials are kept in metadata.v1, the loader's baseURL,
  apiKey, headers and fetch are applied through the sdk hook, an
  auth.set renewal is stored per credential, and credential.switched
  /updated reload the account's own model list.
- opencode.mjs, main: re-exports the V1 plugin functions only.
  OpenCode 1.x and magpie's host.js take main. On 1.x, trae 0.2.26's
  main exported a non-plugin (_internal) and 1.19.5 refused it ("Plugin
  export is not a function"); the new main fixes that too.
- both files in "files"; patch version bumped. devin already had 2.x
  and is unchanged.

scripts/check.mjs fails a model package whose 2.x entry has no default
{id, setup}, whose opencode2.mjs differs from the canonical one, whose
entry is missing from files, or whose main exports a non-plugin.

Run at this head (mote):
- HOME=$(mktemp -d) bun test, as CI runs it: 4900 pass, 0 fail
  (4914 tests, 374 files). A first run set globalThis.fetch for the
  whole process from opencode2.test and failed 528 tests in other
  packages; the block is now set and put back around that file's tests.
- bun scripts/check.mjs: every package passes. With the network
  blocked cloudflare-workers-ai fails on its fetched catalog, the same
  on origin/main.
- Real OpenCode 2.2.5 (npm opencode-ai), sandbox HOME, packed trae
  0.2.27: loads with no error; /api/integration lists trae-cn "Trae CN"
  and trae-global "Trae Global" with their browser sign-ins; `auth
  login` starts the trae.cn authorization and waits (cancelled there);
  with a fake credential POSTed to /api/credential, `opencode models`
  lists trae-cn's six models.
- Real 2.2.5 with a fake V1 key plugin through the same adapter
  against a local fake server: `auth login` with a key, `models`,
  `opencode run` reached /real/v1/chat/completions with the loader's
  "Bearer loader-sk-fake" and header, and printed the fake's reply;
  with @ai-sdk/anthropic it reached /real/v1/messages with x-api-key
  from the loader. This run found the key method missing after 2.x's
  second integration transform (a once-only flag outside the
  transform); fixed, and opencode2.test checks a rebuild.
- Real OpenCode 1.19.5, sandbox HOME, trae 0.2.27: `opencode models`
  lists trae-cn and trae-global models; 0.2.26 failed there.

Broken by hand (scratch copy, bun test scripts/ and check.mjs):
- trae's exports back to "./index.mjs": the trae 2.x test fails
  (default.id undefined), check fails trae with "OpenCode 2.x:
  ./index.mjs has no default {id, setup} (plugins#657)".
- zed's opencode2.mjs changed: the copies test fails, check fails zed
  "differs from scripts/opencode2.mjs".
- the key flag back outside the transform: the 1.x plugin test fails
  on the rebuilt sign-ins (key missing).

Not tried: a real sign-in with a real account on 2.x; Windows (the
reporter's OS); chat.headers, chat.params, usage and tool hooks, which
the adapter doesn't carry to 2.x; the tools/pages packages (calc,
goanyapi, layerfs, search1api, aelios, agent-console, chat,
fingerprint, nowledge-mem, kimi-desktop), which still load only on 1.x.
2026-11-03 13:54:26 +08:00
yetone 0793242b6b zen-free 0.1.23: DSH's tools Zen refuses by name go under other names (#632)
jdld-ybd saw every DSH call to a Zen free model answered 429
FreeUsageLimitError while other agents through the same magpie, plugin
and address were served, and a plain request on the same model was
served too: the refusal is in DSH's own request body, as #624's was.

A real 80-tool DSH request was bisected against Zen on 2026-10-30
(Ebony-Vinyl/dsh-our-free-model#709): DSH's subagent_fork on its own,
and its read_image offered beside working_directory, each got 429 at
once; the same names with only description or parameters changed still
got 429; the whole request with just those two names changed was
served. DSH 0.2.1 offers all three by default (and terminal_*, which
0.1.22 already sends as console_*).

The #624 pair becomes one table of names Zen refuses together:
subagent_fork goes as conversation_delegate, and working_directory as
workspace_directory when read_image is offered too (the names that
request was served under), in past calls and tool_choice too, on Chat,
Responses and Messages; a call of one comes back under DSH's name.
read_image or working_directory alone keeps its name.

Run at this head on mote (bun 1.4.2, HOME=$(mktemp -d)):
- packages/zen-free bun test: 212 pass, 0 fail.
- whole repo bun test: 4795 pass, 14 skip, 0 fail.
- bun scripts/check.mjs zen-free: ok.

Broken by hand:
- origin/main's provider.mjs: the three per-protocol #632 tests red.
- working_directory renamed without read_image: "read_image or
  working_directory alone goes as named" red.

Not tried: a request to the real Zen or with DSH. Every probe from this
network, a plain request without tools included, is answered 429
FreeUsageLimitError today (the address's allowance is spent until 00:00
UTC), so the gate rests on that bisection, not on one of ours.
2026-11-02 18:53:19 +08:00
yetone 1080b81c7d zen-free 0.1.22: tool names Zen refuses go under other names (#624)
alonewolfsy-web bisected a real Claude Code desktop request that Zen's
free tier answered 429 FreeUsageLimitError while 0.1.21 had added the
environment block and core tools: a tool name with "terminal" in it (an
MCP server's terminal tools), and ReportFindings offered beside
ScheduleWakeup, as Claude Code desktop does, each got 429 at once; the
same request with those tools renamed was served (their patch, 40+ real
requests). Either of the pair alone was served.

Such tools now go to Zen under other names of the same words
(mcp__ide__terminal_run as mcp__ide__console_run, RunTerminal as
RunConsole, ReportFindings and ScheduleWakeup as findings_report and
wakeup_schedule, with _2 when the agent has that name), in the agent's
past calls and tool_choice too, on Chat, Responses and Messages. A call
of one comes back under the agent's own name (toolPolicy.renamed, read
first by nameGuard). A request without them is sent as before, and one
of the pair alone keeps its name.

Run at this head on mote (bun 1.4.2, HOME=$(mktemp -d)):
- packages/zen-free bun test: 208 pass, 0 fail.
- whole repo bun test: 4785 pass, 14 skip, 0 fail.
- bun scripts/check.mjs zen-free: ok.

Broken by hand:
- origin/main's provider.mjs: the three per-protocol #624 tests red.
- origin/main's tool-response.mjs (no renamed lookup): the same three red.
- the pair renamed even alone: "a request without a refused name" red.

Not tried: a request to the real Zen. Every probe from this network was
answered 429 FreeUsageLimitError today, a plain control without tools
included (the address's free allowance is spent until 00:00 UTC), so the
gate itself rests on the reporter's bisection. Not tried with Claude Code
desktop.
2026-11-02 17:07:12 +08:00
yetone 0678f8613f zen-free 0.1.21: another agent's <env> block is not taken for OpenCode's
The plugin added OpenCode's environment block unless a system message
already carried any <env> ... Working directory: ... </env>. Claude Code up
to about 2.1.100 ends its own prompt with such a block ("Here is useful
information about the environment you are running in:\n<env>\nWorking
directory: ..."), so its requests went to Zen without OpenCode's block,
while Pi's prompt, which has none, always got it. Zen gives a request
without OpenCode's block a small daily allowance on the same per-address
count, so it served Pi and answered Claude Code 429 FreeUsageLimitError
from the same machine (MrHayesLin and GuodingZ47927 on X, 2026-11-01).

Now only OpenCode's own block counts: <env>, then "  Working directory: "
two spaces in, as OpenCode 1.x and 2.x write it. Claude Code's block stays
and OpenCode's, naming the same folder, follows it. magpie's built-in Zen
path gets the same check in the same change.

Run at this tree on mote: bun test in packages/zen-free (204 pass, 0 fail),
bun scripts/check.mjs (every package ok).
Broken by hand: with the old regex the new case is red in all three
protocols (chat, responses, anthropic).
Checked by hand: Claude Code 2.0.76, 2.1.0 and 2.1.100 (npm) carry the
block; 2.1.316 (latest) has none, and its requests already got OpenCode's
block through this plugin (sandbox HOME, fake upstream).
Not tried: a request to Zen itself. Every machine here leaves from one
address whose free quota was spent today (real OpenCode 2.2.5 got the
same 429), so it can't be compared before 00:00 UTC. Why a current Claude
Code (2.1.316) is refused, if it is, is not known yet.
2026-11-01 22:07:03 +08:00
yetone 85019888d7 zen-free 0.1.20: send each protocol where OpenCode 2 does
0.1.19 matched OpenCode 2.2.5's headers and body, but the capture behind
it set OpenCode's baseURL to the recorder, so the path wasn't compared.
OpenCode 2.2.5 reads models.dev's v2 catalog
(models.opencode.ai/experimental/v2.0/api.json; models-dev.ts takes each
model's api.base_url), which gives every opencode model, the 38 free
chat ones included, https://opencode.ai/inference/openai/v1 for
chat-completions and responses and /inference/anthropic/v1 for messages.
The plugin sent all of them to /inference/v1, where no OpenCode 2
request goes. It now sends each to OpenCode's base; a baseURL given in
options (the tests' fixtures) is still asked as given. The model list
stays at /inference/v1/models: OpenCode reads its catalog instead, and
/inference/openai/v1/models is a 404 (checked on mote).

Run:
- bun test in packages/zen-free on mote (temp HOME as CI) and in WSL
  magpie-desktop: 204 pass.
- Broken by hand: upstream back to baseURL: the inference-path test red.
- OpenCode's captured request replayed from mote at
  /inference/openai/v1/chat/completions and at /inference/v1: both 429
  FreeUsageLimitError, as everything from our egress IP is.

Not tried: a 200 (the IP's free limit is spent, see 0.1.19's body), and
a capture of OpenCode at its default URL (TLS to opencode.ai; the path
comes from its source and the catalog instead).
2026-11-01 13:47:44 +08:00
yetone d62193c43c zen-free 0.1.19: send OpenCode 2.2.5's request, header for header
laomao04_65777 (magpie Discord, 11-01) gets 429 FreeUsageLimitError
("Free models work in OpenCode") on every Zen free model through
zen-free 0.1.18, while real OpenCode works on the same machine.

OpenCode 2.2.5 (@opencode/cli, npm latest; release binary from
anomalyco/opencode) was run in a sandbox HOME on mote against a recording
proxy, and its primary chat request was diffed against 0.1.18's
carrying the same body. 0.1.18 differed in:
- User-Agent opencode/latest/2.0.25/cli, not 2.2.5;
- x-opencode-project "global" on every request. OpenCode 2 sends
  sha1("directory:" + folder), or sha1("git-remote:host/path") in a
  repository with a remote (packages/core/src/project.ts), and "global"
  only from a repository with no remote and no commit;
- no b3 or traceparent trace headers;
- Accept set by hand, so it went first, where OpenCode's is fetch's own,
  after Connection;
- the model list GET went with User-Agent Bun/1.4.2;
- the stand-in tools were 1.x's (bash, filePath), with no required or
  strict:false; 2.x has shell and path;
- the environment block lacked 2.x's "Prefer <tmp>/opencode ..." line.

All of them now match. The version is read from OpenCode's own updater
(opencode.ai/update/api/latest/cli/npm) at most every six hours, never
older than the built-in 2.2.5, which stays when it can't be read. Not
asked when a test gives its own baseURL.

Run:
- bun test in packages/zen-free on mote (macOS) and in WSL magpie-desktop
  (Linux), with HOME a temp dir as CI: 204 pass.
- bun scripts/check.mjs on mote: every package ok.
- Broken by hand: project back to "global", b3 removed, version back to
  2.0.25: 8 tests red (the three header tests, the four project tests,
  the updater test).
- Recapture on mote: the plugin's loader.fetch given OpenCode 2.2.5's own
  captured body, at the same recorder. Headers in order and the body are
  byte for byte the same as OpenCode's once the per-request session,
  trace and span ids are masked. 0.1.18's capture differs as listed
  above. The model list GET now goes as opencode/latest/2.2.5/cli.

Not tried: a 200. Real OpenCode 2.2.5 itself gets the same 429 from our
egress IP (mote, this Mac and xiaomi-gpu share it), as do replays of its
captured request with a fresh project id, so the free limit on that IP
is spent and no request from it can show the fix served. The title
request an agent sends still goes with the environment block and tools
added (as since 0.1.15), which OpenCode's own title request has not;
an agent's title request can't be told from its turn.
2026-11-01 13:44:22 +08:00
yetone 1f56706556 zen-free 0.1.18: the environment block names a real directory, since Zen refuses "Working directory: unknown"
shanmao_10826 on magpie's #help, 10-29: every free model (deepseek-v4.1-
flash-free and others) answers 429 "Free usage limit reached. Free
models work in OpenCode", while OpenCode itself on the same machine works.

Cause, found against opencode.ai from the Linux box (xiaomi-gpu WSL) on
2026-10-29, deepseek-v4.1-flash-free, one request each, minutes apart,
same IP, only the system prompt and stub-tool text changed:
- the plugin's own request through loader.fetch (0.1.17): 429
  FreeUsageLimitError, the reporter's message;
- "You are opencode." + <env> Working directory: /tmp/x: 200;
- the plugin's exact block "<env>\n  Working directory: unknown\n</env>"
  (alone, or after a prompt, either tool description): 429;
- the same block with /tmp/x for "unknown": 200;
- the plugin's stub description "Not available. Never call this tool."
  with a path in the block: 200.
So Zen now refuses the literal placeholder 0.1.15 to 0.1.17 added, the
plugin's fingerprint, as it refused the plugin's old User-Agent on 10-26.
Headers were diffed against OpenCode v2.2.0 (packages/core/src/session/
model-request.ts, app.ts useragent, plugin/provider/opencode.ts): the
same set the plugin sends; nothing new on the request since 2.0.25. Zen's
server code is no longer public (packages/console's handler went on
10-11), so this was found by bisecting real requests.

Fix: the block added is OpenCode 2.2.0's own (instructions/builtins.ts:
the intro line, Working directory, Workspace root folder, Is directory a
git repo, Platform; not its line about OpenCode's temp folder), with the
directory the agent's own prompt or first user message names (Codex's
<cwd>, a "Working directory:" line, Kimi's "The current working directory
is `...`"; absolute paths only), or the user's home folder when none is
named. A prompt that already has a block goes as it is, as before.

Run:
- Real, through the fixed plugin's loader.fetch from the same IP right
  after the 429s: deepseek-v4.1-flash-free with no prompt 200, with an
  agent prompt naming its directory 200, glm-5.3-flash-free 200.
- New test (the block names the stated or home directory, never a
  placeholder; Codex/Kimi/Windows/Anthropic cases): red on origin/main's
  provider.mjs (1 fail of 44 in index.test.mjs), green with it.
- HOME=$(mktemp -d) bun test in packages/zen-free: 201 pass, 0 fail.
- HOME=$(mktemp -d) bun test at the repo root: 3131 pass, 1 fail, the
  fail is layerfs "item 3: an import skips secret-shaped files", red the
  same at origin/main cc3f000, filed as #477.
- bun scripts/check.mjs: ok.
All on the Linux box (wsl-run); mote was unreachable.

Not tried: the reporter's own agent through magpie (they didn't say
which); a Responses or Anthropic free model (Zen lists none free); a
Windows or macOS host (the block's Platform and home path differ there).
2026-10-29 11:38:06 +08:00
MYCF711 4115073df3 zen-free 0.1.17: deepseek-v4.1-flash-free's context floor is the measured 258,624 (#448)
deepseek-v4.1-flash-free's context is raised to the measured floor 258,624 (a 200 with upstream usage in 576 + cache_read 258,048 on 2026-10-26) whenever Zen's catalog reports less or nothing; a larger catalog value (262,144, 1,000,000) passes through. Output stays 32,000. Upstream data issue: anomalyco/models.dev#11768. Version 0.1.17.

Run at 4ff44683d6e326a2baaafa5fb12216b4298d0858, and merged onto main 95fa761, on mote (mote-run, sandbox HOME):
- bun test packages/zen-free: 200 pass, 0 fail (both trees).
- bun scripts/check.mjs zen-free: ok.
- Broke it by hand on the merged tree: always using the floor (no Math.max) and keying the floor to another id each turn the new test red (4 pass / 1 fail); restored, green.
- npm pack (0.1.17) and imported the packed index.mjs (exports ZenFreePlugin); buildModels over the live models.dev opencode catalog (deepseek-v4.1-flash-free at 200000/32000 today) gives context 258624, output 32000; big-pickle unchanged at 200000.
- npm has 0.1.16; 0.1.17 is free.

Not tried: a real request over 258,624 tokens; the true ceiling is still unknown. The code comment does not carry the models.dev issue link (it is in the PR body).
2026-10-28 23:42:14 +08:00
yetone f32736f015 zen-free 0.1.16: requests go with OpenCode 2.0.25's User-Agent, since Zen refuses the 1.19.0 one 0.1.15 sent
杨梅 (yangmei_61422) on magpie's Discord, 10-26: Zen Free from Kimi
Code/Work fails again ("反代失败") a day after 0.1.15.

Cause, found against opencode.ai from this machine on 2026-10-26: Zen's
free tier now answers 429 FreeUsageLimitError ("Free usage limit
reached. Free models work in OpenCode") to the exact User-Agent 0.1.6 to
0.1.15 sent, OpenCode 1.19.0's
`opencode/1.19.0 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14`,
whatever the body says. One request (short system prompt + the <env>
block + the five core tools, our other headers), only the UA changed:
that exact string 429; with provider-utils 4.0.24, bun 1.3.15, opencode
1.19.1, the ai-sdk or runtime part dropped, or an "x " prefix: 200;
"opencode/latest/2.0.25/cli" (what OpenCode 2.0.25 sends,
`opencode/${channel}/${version}/${name}` in its binary): 200. So it is
that one string, the plugin's fingerprint, not a version floor. The env
block is still needed: 2.0.25's UA without it is 429. Path
(/inference/v1), project "global", x-opencode-request and the
x-session-* pair made no difference either way.

Fix: userAgent() is OpenCode 2.0.25's on every protocol, and the header
set is the one captured from 2.0.25 on 10-25: its session id also under
x-session-affinity and x-session-id, no x-opencode-request. A caller's
own session headers still never go on.

Run:
- Real, through the plugin's loader.fetch: a Kimi Code request (its
  system.md rendered, Shell/ReadFile/Glob/Grep/WriteFile/StrReplaceFile/
  SetTodoList with Kimi's own descriptions, UA KimiCLI/1.0) and a plain
  one. At origin/main (0.1.15): deepseek-v4.1-flash-free 429
  FreeUsageLimitError for both. With this change: deepseek-v4.1-flash-
  free, glm-5.3-flash-free and big-pickle 200 for both.
- tools-smoke.mjs, real: big-pickle and mimo-v2.6-flash-free, stream and
  not, 200 with a Bash call.
- Header tests (project identity x4, per-protocol header set x3, the
  streaming one): red on origin/main's provider.mjs (8 of 199 fail),
  green with it.
- HOME=$(mktemp -d) bun test at the repo root: 2675 pass, 0 fail;
  bun scripts/check.mjs: ok.

Not tried: Kimi Code or Kimi Work themselves through magpie (the request
was built from Kimi CLI's installed prompt and tool files); a Responses
or Anthropic free model (Zen lists none free now).
2026-10-26 15:07:51 +08:00
yetone 564719b9d9 zen-free 0.1.15: an agent's prompt goes with OpenCode's environment block, so Zen serves it as OpenCode's
杨梅 on magpie's Discord: deepseek-v4.1-flash-free and glm-5.3-flash-free
answered from OpenCode, while the same models from Kimi Work and WorkBuddy
failed at once with 429 (magpie: "额度用尽").

Cause, found against opencode.ai from this machine on 2026-10-25: Zen's
free tier tells OpenCode's requests by the body, not the headers. A
request whose system messages carry OpenCode's environment block (`<env>`,
a `Working directory:` line, `</env>`) is served; one without gets a small
allowance a day, then 429 FreeUsageLimitError "Free usage limit reached.
Free models work in OpenCode", Retry-After to 00:00 UTC. Captured real
OpenCode 2.0.25 (sandbox HOME, MITM with a sandbox CA) and replayed its
request: 200. Its headers with another system prompt, or without tools:
429. Our headers (1.19.0 UA, /inference/v1) with its body: 200, so UA,
path (/inference/openai/v1 vs /inference/v1), session ids, project and
trace headers don't matter. Bisected the prompt to the <env> block: case
sensitive, needs "Working directory:", counts only in a system message
(in a user message or a tool description it doesn't), value free
("unknown", "/" and "" all pass), and still needs tools (the core
stand-ins already sent pass).

Fix: addEnvironment appends "<env>\n  Working directory: unknown\n</env>"
to the agent's first system message (a part of its own for content in
parts, a new first system message when there is none), Anthropic's
`system` and Responses' `instructions` likewise. A prompt that already
has a block, as OpenCode's does, goes as it is. The directory isn't known
in the plugin and the agent's own prompt says it, so it is said as
unknown, not a path that would mislead the model or leak the user's.

Run:
- Real, through the plugin's loader.fetch from this machine (whose
  non-OpenCode allowance was used up): a WorkBuddy-like request (its own
  system prompt, a Read tool, WorkBuddy UA) at origin/main's provider.mjs:
  deepseek-v4.1-flash-free 429 FreeUsageLimitError (2.3s), glm-5.3
  stream 429 (1.8s), the reporter's case. With this change: deepseek 200,
  glm-5.3 stream 200, big-pickle 200.
- tools-smoke.mjs, real: big-pickle and mimo-v2.6-flash-free, stream and
  not, 200 with a Bash call.
- New test, per protocol: the block added once after the agent's prompt,
  added with no prompt and for content in parts, added when the block is
  only in a user message, an OpenCode prompt left as it is. Red on
  origin/main's provider.mjs (3 of 3 fail), green with it.
- HOME=$(mktemp -d) bun test at the repo root: 2670 tests, 0 fail;
  bun scripts/check.mjs: ok.

Not tried: a Responses or Anthropic Messages free model against Zen
(Zen lists none free now; all eight are Chat), so where Zen looks for the
block on those two is a guess from Chat's. Kimi Work and WorkBuddy
themselves weren't run; their request was built by hand.
2026-10-25 18:33:40 +08:00
yetone 7ee60f8253 zen-free 0.1.14: keyless single-identity sign-in (#205, LoKi) 2026-10-22 21:12:33 +08:00
lokic7123-starandLoKi 52968f2d34 zen-free: declare keyless single-identity access (#205, LoKi)
Marks Zen Free's api method keyless and its auth single, so magpie's host (yetone/magpie#2695, 5871f02dd) signs it in with no key field and Sign in again instead of another account. authorize is unchanged; older hosts and OpenCode keep the public-key flow.

Run at the PR head 29f0e9b38: bun test in packages/zen-free under a sandbox HOME, 175 pass, 0 fail. Checked against magpie main: host.js reads m.keyless (api method with authorize) and auth.single, the two fields this sets.

Co-authored-by: LoKi <317300729+lokic7123-star@users.noreply.github.com>
2026-10-22 21:12:09 +08:00
yetone c7186858da zen-free 0.1.13: a later null or empty tool-call id keeps the id already streamed (#188, zhengguangzhuo)
Releases ec884d0 (#259). Only the version changes here.

Run on origin/main 915f143 plus this bump: bun scripts/check.mjs passed;
packages/zen-free bun test (temp HOME): 195 pass, 0 fail. #188's literal
repro script (node) prints call_0/call_1 for both null and "" and exits 0.
2026-10-20 16:14:01 +08:00
zhengguangzhuo ec884d09dc zen-free: a later null or empty tool-call id keeps the id already streamed (#188, #259)
When a Chat Completions stream sends a call's id first and then id: null or
id: "" in a later delta for the same index, the buffered call kept the later
value, so the client got null/"" ids and a later request failed with
"Duplicate value for 'tool_call_id'" (#188). A later null or empty id now
keeps the id already buffered; an id that first arrives in a later delta is
still taken.

Run at the reviewed head 8f19ba1e6bf09f105a47e4fb2f7233de22a99b06 (base 5b68df0, main):
- packages/zen-free: bun test (bun 1.4.2, temp HOME): 195 pass, 0 fail.
- bun scripts/check.mjs: passes.
- #188's literal repro script (node 22.22.0): prints call_0/call_1 for both
  null and "" and exits 0; on main's tool-response.mjs it prints [null,null]
  and ["",""] and fails its assert.
- The PR's new test with main's tool-response.mjs: red (null, '' instead of
  call_0, call_1); green with the fix.
2026-10-20 15:56:03 +08:00
yetone 5b68df0057 zen-free 0.1.12: a null name or arguments in a streamed function delta adds nothing, instead of failing the turn (#252, ChuHanModel)
Releases 2ef6d6b (#252). Only the version changes here.

Run on 2ef6d6b plus this bump: bun scripts/check.mjs passed;
node --test packages/zen-free/ all pass. The PR's head was run in full
before the merge (HOME=$(mktemp -d) bun test: 1853 pass, 0 fail).
2026-10-20 03:54:57 +08:00
初寒 2ef6d6b62b zen-free: a null name or arguments in a streamed function delta adds nothing, instead of failing the turn (#252, ChuHanModel)
A Chat Completions stream whose tool_calls or function_call delta carries
`"name": null` or `"arguments": null` (some OpenAI-compatible vendors send
these) failed the whole turn with "Invalid upstream function delta".
appendFunction now treats a null/undefined name or arguments as no new
bytes and keeps the fragments already buffered. Other non-string types
still fail. The name is still checked on the whole concatenated value when
the choice finishes, so a call whose name stays null is still left out with
its note; skipping null can't let a call past the policy.

Siblings: no other package vendors tool-response.mjs (grep for "Invalid
upstream function delta" finds only zen-free); zed's tool-call merge
already appends only truthy arguments.

Run at the reviewed head 48a266070ed1ad3e63fa864e438af8163110f5f6:
- Fix removed by hand: 4 new tests red (tool_calls / function_call
  "ignores null fields..." and "still drops calls whose name remains null",
  failing on `!values.some(value => value.error)`), 104 pass. Restored:
  node --test packages/zen-free/tool-response.test.mjs 108 pass, 0 fail.
- HOME=$(mktemp -d) bun test: 1853 pass, 0 fail across 168 files.
- bun scripts/check.mjs: passed.

Version bump to zen-free 0.1.12 follows in its own commit.
2026-10-20 03:51:50 +08:00
yetone d556ef8dda zen-free 0.1.11: a call of a tool the agent doesn't have reaches the agent as called (#209, xiotbox)
#209: since 0.1.3 (#76) a call whose name the agent has no spelling of
(DSH with pwsh declared: psh, pash, ppwsh, pshh, bash, shell_command) was
left out with a text note, and a reply of only such calls was rewritten
to a plain stop. DSH read that as a finished answer: 16 of xiotbox's 19
cases ended an autonomous turn, and the model never saw an error it
could correct.

Now nameGuard answers the model's own name when no declared tool folds
to it, so every protocol (Chat JSON/SSE, Responses, Messages) hands the
call on with its id, arguments and tool-call finish, as every other
provider in magpie does. The agent answers an unknown name itself (DSH's
ToolRuntime, Claude Code's "No such tool available", Codex's
"unsupported call", OpenCode's invalid tool) and the model corrects it.
Case and separator folding (todowrite -> todo_write, bash -> Bash) is
unchanged, and an ambiguous fold is still never guessed: it goes on as
called. Only a call with no name is still left out with the note. Any
correction budget is the agent's, as with any provider; the plugin keeps
no per-turn state.

Tests: the #76/#209 names (bedit, bcp, ash, mcp__netcatcatty__unused,
psh, pash, ppwsh, pshh, shell_command) alone and beside a declared call,
JSON and streamed, in all three protocols: the call arrives with its id,
no note, no error, a tool-call finish; a Responses or Messages stream
comes through frame for frame. index.test's plugin-level case (loader
fetch against a local fake Zen) now expects an undeclared `edit` handed
on as a tool call. The leave-out machinery tests use a nameless call.

Run:
- packages/zen-free `bun test`: 174 pass, 0 fail. With nameGuard put
  back to `|| null`: 28 fail.
- `node --test` (Node 25.8.2 and 22.22.0): 171 pass, 3 fail, the
  "sends OpenCode's own headers" tests, red the same on origin/main
  0b58032: Node's fetch adds accept-language and sec-fetch-mode. magpie
  and OpenCode run the plugin in Bun. Filed as #212.
- Whole repo, TMPDIR and HOME in a scratch dir, `bun test`: 1771 pass,
  0 fail. `bun scripts/check.mjs zen-free`: ok.
- Not tried live against Zen or with DSH: the fix is in what the plugin
  hands on, shown against a fake upstream.
2026-10-17 21:46:41 +08:00
yetone fe5631c1cb zen-free 0.1.10: the sign-in says a personal OpenCode key belongs in the built-in OpenCode Zen (TradingLife on Discord)
A user typed keys made under several OpenCode accounts into Zen Free's key
field and expected several accounts. The method's authorize() always
returns key "public", and magpie's host stores result.key over the typed
key (host.js save), so every such sign-in is the same shared credential
and the typed key is dropped. The label and README now say so and point
own keys to magpie's built-in OpenCode Zen provider (several keys,
rotation and failover).

Run: bun test in packages/zen-free, 174 pass 0 fail. Read host.js
apiKey/save on magpie 63be47717 to confirm the stored key is "public".
Not tried: a sign-in through magpie's GUI with the new label.
2026-10-16 16:59:02 +08:00
yetone da27b4ce6b zen-free 0.1.9: a free model Zen lists is offered the hour it lists it, before OpenCode's catalog or docs describe it, and a list read with them out of reach isn't said as fallen back (yetone/magpie#2385)
Zen made deepseek-v4.1-flash-free free (in its /models as the public key
reads it, 2026-10-15) and the plugin never offered it. Two causes:

- buildModels left out a listed model that neither the catalog
  (models.opencode.ai) nor the docs' endpoint table described: a free
  model Zen lists before they catch up, or every model but the snapshot's
  when either can't be read. A listed id ending in -free with no word from
  either is now asked through the provider's own package
  (openai-compatible, chat), as OpenCode asks a model with no package of
  its own. A paid or unknown id that doesn't say -free still needs the
  catalog; the docs saying SystemOne still keep one out.
- A discovery with the catalog or the docs unread was marked
  magpie.fellBack, though Zen's own list was read. magpie answers a
  fallen-back list by keeping the last list read in full
  (plugin.keepListed), so a user who can't reach GitHub's raw host or the
  catalog kept that old list, and every model Zen made free since stayed
  out. Only a failed read of Zen's /models is fallen back now; models
  verified before are still kept while Zen lists them.

Tests (no network; the fixture server serves
fixtures/zen-models-2026-10-15.json, Zen's /models byte for byte):
- "a free model Zen lists that the catalog and the docs don't describe is
  offered, on chat (#2385)": catalog 503, docs 404 -> the ten free models
  Zen lists (Jev, "test" and the paid ones out), deepseek-v4.1-flash-free
  on chat, muse-spark-1.3 on Responses, not fallen back; a request for it
  goes to /chat/completions
- "... before the catalog has it is offered with the catalog read (#2385)"
- models.test: an unknown -free id is offered on the provider's package,
  "unknown-paid", "freebie" and "free-model" aren't, SystemOne stays out
  (replaces "unknown models require a known protocol rather than a
  guessed chat endpoint")
- two partial-discovery tests now expect no fellBack
Broken by hand: models.mjs back to 0.1.8's -> 3 fail; provider.mjs back
to 0.1.8's -> 3 fail; both fixed: bun test 174 pass, 0 fail (bun 1.4.2).
bun scripts/check.mjs zen-free: ok.

Not tried: a live request to deepseek-v4.1-flash-free through the plugin
(one GET of Zen's /models was the only network used). A future free
model Zen serves on Responses or Messages that the catalog doesn't
describe yet would be offered on chat and refused by Zen until the
catalog has it.

No magpie mover to raise: zen-free isn't a moved built-in, and magpie
updates @magpie-community plugins by itself within the hour.
2026-10-15 19:46:57 +08:00
yetone cbff94eb43 zen-free 0.1.8: the free models Zen lists are offered again when OpenCode's docs or catalog can't be read, and the docs are read from where they moved (yetone/magpie#2305, MiniFullC)
The reporter, on 0.1.7 with the public key, saw only Big Pickle, Space
Bunny Free and Muse Spark 1.3 Free: the three models the plugin knows
offline. Two causes:

- DOCS pointed at packages/web/src/content/docs/zen.mdx, which OpenCode
  removed on 2026-10-12 (anomalyco/opencode#54761, "replace old Zen and Go
  pages with V2 console docs"). It answers 404, so every discovery since
  was partial. The endpoint table now lives in
  services/www/src/docs/content/console/models.mdx; parseProtocolDocs
  reads its rows as they are.
- A listed model the catalog (models.opencode.ai) didn't describe and the
  docs didn't name was left out. When the catalog can't be read, that is
  every listed model but the three in bootstrapProvider, which is the
  reporter's list exactly. bootstrapProtocols is now a snapshot of the
  console docs' free rows (2026-10-15), used under whatever the docs say,
  and bootstrapProvider gains the catalog's metadata for Cat Jam, Step 5
  Preview, LongCat 2.5 Preview, MiMo-V2.6-Flash and Nemotron 3.5
  Lightning Free.

Not changed, on purpose: jev-1.13-free is a SystemOne decision model
(docs: endpoint /v1/systemone, no AI SDK package), which can't answer a
chat, so it stays out as SystemOne models always have. exo-free is
"deprecated" in the catalog and not in Zen's /models list now.

Tests (no network; the fixture server): "listed free models are offered
when the catalog and the docs can't be read" (catalog 503, docs 404,
listing big-pickle, step-5-preview-free, cat-jam-free, jev-1.13-free,
paid -> the three free chat models only) and "reads the console docs'
endpoint table, and Jev stays out as SystemOne" (literal rows from the new
page). Both fail on 0.1.7's models.mjs/provider.mjs (2 fail, 170 pass)
and pass with the change; bun test: 172 pass. bun scripts/check.mjs ok.

Real use (live Zen, public key, this checkout): discovery now lists
big-pickle cat-jam-free longcat-2.5-preview-free mimo-v2.6-flash-free
muse-spark-1.3-contributor-free nemotron-3.5-lightning-free
space-bunny-free step-5-preview-free, not fallen back (0.1.7: the same
eight with the docs 404 marking it partial). A request to cat-jam-free
through the plugin's fetch streamed 200; step-5-preview-free answered
Zen's own 429 "Upstream request failed: Endpoint is unavailable." twice.
The reporter's catalog failure itself wasn't reproduced from here.
2026-10-15 12:08:28 +08:00
yetone 5fc0a75292 zen-free 0.1.7: free models answer again, asked at opencode.ai/inference/v1 with stand-in tools that take a parameter (c9cu on Discord)
c9cu on magpie v0.1.1239: "opencode muse 1.3 又不行了". Every free model
answered 403 FreeTierError "OpenCode's free tier can only be used from
within OpenCode" through 0.1.6 and magpie's built-in alike.

Found against the real upstream on 2026-10-15, with OpenCode 1.19.0's
own requests captured through a local proxy under a sandbox HOME:
- OpenCode now asks https://opencode.ai/inference/v1 (models.dev gives
  it this URL). Its own captured request, replayed word for word, is
  200 there and 403 at /zen/v1.
- Zen also refuses bash or read offered with no parameters, as the
  stand-ins here were ({"properties":{}}); one property is enough.

Now:
- DEFAULT_BASE is the inference API. A request still sent to a model
  listed at /zen/v1 is accepted and asked at the inference API.
- Each stand-in takes OpenCode's own first parameter (bash command,
  read/edit filePath, glob/grep pattern), still "Never call this tool".

Run:
- bun test in packages/zen-free: 170 pass. With 0.1.6's provider.mjs
  put back by hand: 13 fail (the 12 tool-guard tests on the stand-ins'
  parameters, and the new inference-API test).
- bun tools-smoke.mjs against the real Zen: big-pickle,
  mimo-v2.6-flash-free and muse-spark-1.3-contributor-free, streamed and
  not, all 200 with a Bash call.
- npm shows 0.1.1 as latest: publish runs refused this package (no
  Trusted Publisher), so 0.1.2 to 0.1.6 never reached users; 4ef68fb's
  NPM_TOKEN path is what publishes this one.
2026-10-15 02:00:11 +08:00
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
yetone e87ea310c3 zen-free tests: the other 32+ MiB guard tests get the CRLF test's 60 s timeout
"cumulative pending chat tools are limited across choices and calls" and
"chat: completed tool buffers release their cumulative budget" push 33-34
MiB through guardToolResponse and timed out at bun's 5 s default on a
machine at load ~200-280 (5104 ms, 5299 ms, 5525 ms). The CRLF test had
the same cause and already carries { timeout: 60_000 }; its two siblings
that also move 32+ MiB ("single SSE event limit is 32 MiB...", "text
streams larger than 32 MiB...") get it too. The work itself is the
point of the tests (the 32 MiB limit), so it isn't shrunk.

Run: bun test in packages/zen-free 3x at load ~200: 166 pass each time.
Before the change the same file failed at this load. Tests only, no
version bump, nothing published.
2026-10-14 18:28:35 +08:00
yetone 643ef5018e zen-free: README says the free tier now works only inside OpenCode itself (#100, #108)
Since 10-13 Zen answers free-tier requests from anything but OpenCode
with 403 FreeTierError. OpenCode limits it on purpose, so the plugin
won't get past it: the README now says so and points to an OpenCode Zen
paid key or OpenCode Go instead.

README only. No version bump, so the publish workflow (which runs on
packages/*/package.json) doesn't run, and 0.1.5 stays unpublished. The
code on main is left as it is.
2026-10-14 07:53:51 +08:00
yetone 9074723932 zen-free 0.1.5: a request carries a session id OpenCode itself could have made, so Zen's free tier serves it again (#100, xqvvu)
Zen's chat endpoints now answer the free tier's requests 403 FreeTierError
("can only be used from within OpenCode") unless x-opencode-session looks
like an id OpenCode made. 0.1.4 sent a sha256 cut to the ses_ shape; Zen
decodes the id as OpenCode's identifier.ts lays it out (12 hex of
~(Date.now()*0x1000 + counter), then 14 base62) and turns away one whose
counter is not small.

Bisected against the real upstream by replaying 0.1.4's captured request:
- 0.1.4's ses_e9283da055b15JwOAra76bwUx4: 403. The same request with the
  session of a real OpenCode 1.19.0 run: 200. The real UA alone, or a real
  msg_ request id alone: still 403.
- Any timestamp passes (epoch 0, a year back, an hour ahead); the low 3 hex
  ffe/ffd/ff0 (counter 1/2/15) pass, f00/c00/800/001 get 403; 25 or 27
  characters after ses_ get 403.

Now:
- sessionID makes a real descending id with the current time and counter,
  kept per conversation (sha256 of the signal, at most 1000 kept) so a
  conversation's turns share one session. An id the caller sent through
  that OpenCode could have made is passed on unchanged.
- x-opencode-request is an ascending msg_ id, x-opencode-session-id is
  sent too, and the User-Agent is OpenCode 1.19.0's
  (opencode/1.19.0 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14), as
  captured from the real client.

Run: bun test in packages/zen-free, 166 pass. With 0.1.4's hash put back,
the new session tests and the streaming header test go red (3 fail).
tools-smoke.mjs against the real opencode.ai: big-pickle,
mimo-v2.6-flash-free and muse-spark-1.3-contributor-free each 200 with a
Bash call, streamed and not; 0.1.4's provider.mjs in the same run: 403
FreeTierError.

Not done here: magpie maps this 403 to permission_error, which reads as a
sign-in problem; that is magpie's gateway, not this package.
2026-10-13 13:10:07 +08:00
yetone b033987516 zen-free: a declared name of separators only matches only itself, and the unused injected set is gone (#76 follow-up, tkhs101)
foldsTo kept a declared name whose fold is "" (an agent declaring "_"),
so any call of separators only ("--", "-", "__") was handed that tool:
an empty fold matching an empty fold, not a name matching a name. Such a
name is now skipped in the fold maps, so it matches only itself and the
other calls are left out with the note like any unknown name.

normalizeTools still built and returned `injected`, which nothing has
read since the guard folds over `declared` alone; it is gone. The "Never
call this tool" stubs are sent as before.

Run: packages/zen-free `bun test` 162 pass; the new test goes red with
the foldsTo change taken out. Whole repo `bun test` (temp HOME and
TMPDIR) and `node --test packages/zen-free` pass; `bun scripts/check.mjs
zen-free` ✓. Rides in 0.1.4 with the #91 change.
2026-10-12 18:18:36 +08:00
yetone 6a5dd01d5d zen-free 0.1.4: a streamed Chat reply Zen closes before its [DONE] ends cut short, with a note, instead of failing the turn (#91, tkhs101)
Zen now and then closes a space-bunny-free Chat Completions stream after
some frames, with no finish_reason, usage or [DONE] (~0.1% of turns in
the reporter's logs). The tool guard turned that into an error frame at
the end of the 200 stream, so the agent threw away the reasoning and text
it already had, and magpie can't ask a Zen Chat reply to go on.

Now, for a client that streams, a Chat reply cut short that has said
something (text or reasoning) and has no tool call pending ends as an
ordinary answer: each open choice gets the note "(The reply was cut
short: Zen closed the stream before it finished. Ask again to go on.)"
and finish_reason "stop", then [DONE]. A reply whose every choice had
finished only gets its [DONE]. It still fails when a tool call is
pending (its arguments may be half written), when nothing was said
(an empty reply), and when the reply is collapsed for a client that
doesn't stream (nothing reached the client yet, so magpie can ask
again). Anthropic Messages and Responses streams cut short still fail:
magpie's gateway tells such a reply from a whole one itself (#370) and,
for an Anthropic upstream reached through translation, goes on with it
(continuation.go); a made-up message_stop or response.completed here
would stop that. The error that remains names the reply's id, the
events and bytes received, and an unfinished tool call, as the reporter
asked. The README also says the free tier needs tools, which is why the
five core tools are sent.

Run: packages/zen-free `bun test` and `node --test` (161 pass). The new
tests use the reporter's three frames byte for byte, at chunk sizes 7, 31
and 4096; all 6 go red on the old tool-response.mjs/provider.mjs.
Broken by hand: dropping the pending-call check turns the "still fails"
test red; ending cut short for non-streaming clients too turns the loader
test and the "still fails" test red. Whole repo `bun test` with a temp
HOME and TMPDIR: 1109 pass. `bun scripts/check.mjs`: all ✓. Through the
plugin's loader against a node fake upstream on 127.0.0.1:3720 that sends
role, reasoning and two text frames 50 ms apart and FINs: streamed → 200
with the text, the note, stop and [DONE]; not streamed → 502 "Upstream SSE
ended without a completion marker (reply x2, 4 events, 659 bytes
received)". Not run: real Zen (the cut can't be provoked) or magpie's
plugin host.
2026-10-12 18:18:35 +08:00
yetone da7e2f67a5 zen-free 0.1.3: a call of a tool the agent doesn't have is left out with a note, not a failed turn (#76, tkhs101)
#76: Zen's free models sometimes call a tool by a name the agent never
declared (tkhs101's table: bedit, bcp, ash, mcp__netcatcatty__unused,
beside declared edit, bash, mcp__netcatty-external__list_hosts). The
guard answered each with "Upstream called a tool not declared by the
client", which failed the whole turn. The rows without a name are from
before 0.1.1 (published 10-10 11:51 UTC), which added the name.

Now such a call (or one with no name) is left out of the reply instead:
- chat: dropped from tool_calls/function_call; the reply's content says
  "(The model called a tool this agent doesn't have: "bedit". The call
  was left out.)"; kept calls are renumbered from 0; finish_reason
  becomes "stop" when no call is left, including a repeated finish.
- responses: the function_call item becomes a message item with the
  note (added, text deltas, done, and in response.completed); its
  argument events are not passed on.
- anthropic: the tool_use block becomes a text block with the note; its
  input deltas are not passed on; stop_reason tool_use becomes end_turn
  when no call is left.
A call of an unsupported type (custom tools, non-object input) still
fails as before.

Run:
- bun test packages/zen-free: 155 pass, 0 fail; node --test
  packages/zen-free/*.test.mjs: 155/155; bun scripts/check.mjs zen-free.
- The new tests on the old tool-response.mjs: 35 fail.
- Breaking the finish rewrite by hand: 5 fail.
- Chat stream fixtures use the shape a live step-5-preview-free stream
  sent (name whole in the first delta, arguments in pieces, two
  tool_calls finishes). Zen sends names whole, so the names in #76 are
  the model's own; a real misnamed call was not reproduced live.
2026-10-11 08:06:44 +08:00
yetone 98e91cc4a2 zen-free 0.1.2: a model Zen no longer gives free is answered 404 naming the free ones, and one made free since is served (Jeremy.Zhou on magpie's Discord)
Jeremy.Zhou asked that dropped free models leave the list by themselves
and new ones join it. The list was already read from Zen's /models each
time the host lists models (magpie's start, refresh, and now its hourly
relist), with the last list kept when Zen's can't be read. Two request-time
gaps remained:

- A model not in the list (Zen dropped it) threw, which the host reports as
  a transport failure, so magpie rested the whole account. It is now a 404
  not_found_error, "Model X is not available as an OpenCode Zen free model
  now. Free models: ...", which magpie reads as that model alone refused.
- After the first list, a model not in it never asked Zen again, so one
  made free since stayed refused until a relist. Now it asks again, at
  most once a minute, so a hand-typed id doesn't list on every request.

A model on the wrong protocol still throws as before. README's Models
section says how the list stays current.

Run: bun test in packages/zen-free (32 pass; 3 of the new tests fail on
0.1.1's provider.mjs), bun scripts/check.mjs (ok). Real use against Zen
with the public key: glm-5-free gets the local 404 listing Zen's 11 free
models, big-pickle answers 200.
2026-10-10 22:51:40 +08:00
yetone f2e6f87984 zen-free: the CRLF event-limit test gets 60s, not bun's 5s
The test sends a 32 MiB SSE event through guardToolResponse twice (64 MiB
in all). On a loaded machine (load average ~110) it ran past bun's default
5s and failed, though it passes on an idle machine and on CI. The timeout
now leaves room for load; the assertions are unchanged.

Run: bun test in packages/zen-free (all pass).
2026-10-10 22:50:33 +08:00
yetone cdbaff644a zen-free 0.1.1: an OpenCode tool name is given the agent's own spelling, and a refused call names its tool (#76, tkhs101)
Zen's models open multi-step work with OpenCode's own todowrite, while
DeepSeek Harness declares todo_write. The guard folded names only for the
five core tools the plugin injects, so with an agent that declares all
five nothing was injected, nothing folded, and the whole turn died with
"Upstream called a tool not declared by the client" - without saying
which tool.

Now any call is given the agent's tool whose name differs only in case,
or else only in case and separators (todowrite -> todo_write, webfetch ->
web_fetch, BASH -> bash), when exactly one declared tool folds to it; a
name two declared tools fold to is still refused rather than guessed.
A refused call's error ends with the tool's name.

Run: bun test and node --test in packages/zen-free (141 pass; under a
load average of ~140 bun's 32 MiB buffer tests sometimes hit their 5s
timeout, the same on the old code, one run fully green); the new #76
tests fail on the old tool-response.mjs (6 red). bun scripts/check.mjs
zen-free. Live against Zen (step-5-preview-free, chat, stream): calls
pass with the folded names; the model didn't emit todowrite in 6 tries,
so the mapping itself is shown by the tests.
2026-10-10 17:46:44 +08:00
xiaofei f5dc146c2c Add OpenCode Zen Free provider plugin (#31)
* Add OpenCode Zen Free provider and market listing

* Guard Zen tool calls and address provider review

* Preserve upstream SSE error frames in Zen tool guard

* Restore Zen Free package name and simplify README title
2026-10-07 08:24:54 +08:00