Files
plugins/packages
yetone 659967c9bc agent-office 0.1.1: an agent another agent killed is stopped, and any agent not at work can be cleared
flying_crp (X, 2026-10-31): when one agent hands work to another and then
interrupts it from the command line, the delegated session hangs in the
Agent Office as abnormal and can't be cleaned up; it only goes once the
session is deleted in magpie.

The cause: a killed agent writes no end of turn. Reproduced in a sandbox
HOME with the real CLIs:
- Codex 0.165 under SIGTERM or SIGKILL: the rollout ends at the
  function_call (on SIGINT it writes turn_aborted, which was fine).
- Claude Code 2.1.314 `claude -p` under SIGTERM: a tool_result
  ("Exit code 137") and no end_turn, and it removes its
  sessions/<pid>.json. Under SIGKILL: the file ends at tool_use, and the
  pid file stays with a dead pid.
The office read each file as at work, then "error · stuck" once quiet for
ten minutes, until hideAfter (6h, or never; a waiting session never
leaves). The page had no way to take one out.

The fix:
- lib/scan.mjs: for a source with a process folder (Claude Code's
  <config>/sessions, also Qoder, WorkBuddy and CodeBuddy), a session
  quiet mid-turn for 10s with no live process named in that folder is
  read as aborted ("stopped"). A folder that can't be read, a
  half-written file, or one that has never held a pid file means
  unknown, and nothing changes. A pid file from another pidDomain (WSL)
  counts as alive.
- page: Clear (清除) in the panel of any agent not at work (stuck,
  error, stopped, done, waiting) hides it until its session moves again.
  It is kept in the page's options as {key: at}, pruned to sessions
  live.js still has. This covers Codex and every agent with no process
  registry.

Run:
- On mote (mote-run): bun test in packages/agent-office gives 54 pass,
  0 fail. bun scripts/check.mjs exits 0.
- killed.test.mjs uses the real killed files (test/killed, trimmed and
  with paths replaced). With the old scan.mjs, 3 tests fail. With the old
  model.js, 2 fail.
- End to end: the real office.hooks.mjs over a sandbox HOME holding the
  killed Claude and Codex files and a live lead pid file. live.js had
  claude "aborted" and codex "tool". Then the real page in list mode, zh,
  at widths 1100 and 420: the Codex row shows 已 N 分 没有动静, its
  panel shows 清除, clicking it removes the row, and options.set gets
  cleared. Chromium ran on mote. WebKit ran on the Linux box (wsl-run),
  because WebKit on mote didn't launch within 180s while ~108 WebKit
  processes from other sessions were running. Screenshots were checked
  at both widths.

Not tried:
- A Codex liveness signal: its thread-writer-locks are flock-only files,
  which Node can't check. Codex relies on Clear.
- Windows: the pidDomain value and process.kill(pid, 0) there.
- Whether Qoder, WorkBuddy or CodeBuddy write pid files at all. Without
  them, nothing changes for those agents.
- Gemini, Qwen, dsh and pi killed mid-turn: they have no registry and
  rely on Clear.
- The page inside the real magpie window, and WebKitGTK.
2026-10-31 09:52:19 +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