Files
plugins/packages
yetone 4b3af4a565 agy-cli 0.1.89: a session whose agy never loads the client's tools fails and says why (#1239)
pi declared read, bash, edit and write through the gateway on Windows and
the model saw only agy's own manage_task; `read` came back
`unknown tool: "read"`. agy reads a client's tools from the bridge's
ide-tools MCP server, which it starts by running `nc` from PATH. When
that never answers, #waitForToolList gave up after 5s without a word and
the turn ran with no client tool at all, for every client.

On Windows agy 1.5 runs only nc.exe, never the nc.cmd the bridge falls
back to. A failed nc.exe build was swallowed and cached for the whole
host process, so every session after it had no tools until magpie
restarted.

- A session that declares tools and whose agy hasn't listed them after
  AGY_BRIDGE_TOOL_LIST_WAIT_MS (now 20s) fails with 502
  tools_not_loaded, naming the cause: on Windows, the nc.exe build's own
  failure (not Bun, non-ASCII folder, bun build's exit code or "wrote no
  nc.exe" plus its last stderr lines); elsewhere, the `nc` MCP server
  that never answered. No session/prompt is sent.
- A live agy that never listed the tools a follow-up declares (started
  with none) is replaced (session_new reason tools_unlisted), not reused.
- On Windows a failed nc.exe build is tried again after 5 minutes,
  rather than never.

Tests: test/tools-listed.mjs (new, in agy-cli.test.mjs). The testkit's
fake agy can now not list tools (listTools), or not keep a watch
(watchTools), and records each listing.

Run at this tree:
- mica-run, HOME=$(mktemp -d): cd packages/agy-cli && bun test:
  41 pass 0 fail; bun scripts/check.mjs agy-cli: ok. (mote was at load
  130.) An earlier run of the same suite had test/usage.mjs red twice on
  its 3s usage-query deadline at mica load 23; it passed 41/41 twice
  alone. That is #1191.
- win-run on xiaomi-gpu (real Windows, Bun 1.4.2): tools-listed.mjs and
  windows-nc.mjs, 13 pass 0 fail. The first Windows run caught that the
  platform-neutral cases took the real win32 path; they now pin linux.

Broken by hand: tools-listed.mjs against the old index.mjs
(AGY_BRIDGE_TEST_INDEX = HEAD's copy): 3 of 5 red. The unlisted session
ran its turn (200, end_turn after 5s), the follow-up ran on the agy that
never listed Read, and the failed Windows build was never retried. The
two cases that should hold either way pass.

Earlier, on xiaomi-gpu: a real nc.exe built in ~335ms, and the shim
answered tools/list in 137ms first and ~28ms after.

Not tried: a real agy turn or a real Windows agy session. There is no
usable account: the Mac one is banned, and Windows agy answers
session/new with "Authentication required". So the reporter's exact
trigger (which nc.exe build failure, or none) isn't confirmed. The error
now names it on their machine.
2026-11-17 19:25:36 +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