Files
plugins/packages
yetone 7fdc07f150 kiro 0.1.14: an account is named by its email and the way it was signed in to, "email (Google)", "email (GitHub)" (#309)
magpie names a plugin's account by its accountId (host.js whoOf) and,
when two read the same, adds the slot: molvqingtai's Google and GitHub
accounts of one email read "email (uid-slot)". The accountId is now the
email and the way, as Kiro's sign-in page names it: Google, GitHub,
Builder ID, IAM Identity Center, Internal. A way not known (kiro-cli's
or the Kiro IDE's sign-in, which carry no loginProvider) keeps the bare
email, and magpie's slot stays the fallback.

- browserSignIn's success names the account so.
- An account kept by its bare email, with a known loginProvider, is
  given the name the way the uid was in 0.1.13: by the save after a
  request, model listing or usage read (once per token), and in
  auth.refresh's result (host.js renew merges it over the old).
- Sibling: usage's user is the same name for a sign-in kept here
  (magpie's quota card shows it); kiro-cli's and the IDE's stay bare.

The window: magpie's settle (internal/plugin/host.js) replaces an account
only when whoOf (the accountId) is equal and the uids don't differ. An
old account still named "email", signed in again the same way before
its first use on 0.1.14, has "email (Google)" against "email" and is
kept beside it as a second account. The plugin can't close it: its
client.auth has set/remove for the account in scope only, and a sign-in
result is matched by name alone. Any use (magpie's usage read, a
request, a renewal) renames it first, after which the sign-in replaces
it. Said in the README.

Run at d767d1c + this change:
- accounts.test.mjs on the old index.mjs: 3 fail (the two existing
  tests' labelled expectations, and the bare-email rename), 2 pass (the
  kiro-cli bare-email guard, and the no-save case). On the new: 5 pass.
- HOME=$(mktemp -d) bun test: 2104 pass, 0 fail, 184 files.
- bun scripts/check.mjs: ok.
Not tried: a real Kiro sign-in; the names were checked only against the
tests' fake Kiro.
2026-10-22 15:31:02 +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