Files
plugins/packages
yetone 1c9ade6c81 loomy 0.1.12: a 401/403 from a proxy no longer signs an account out
jenxingyoung on X: four Loomy accounts behind a proxy, a different one
signed out each day, none used anywhere else.

Loomy's gateway never answers a dead session with a 401 or 403. A made-up,
dropped or missing token gets HTTP 200 with code 100002 on every path
(chat, draw, models, points records, first-login; probed 2026-11-16 and
2026-11-17). The plugin still read any 401/403 as "signed out": chat and
draw returned a bare 401 (magpie's host marks the account lapsed on that),
and usage and check-in threw an expired error. So a proxy or firewall
turning one request away marked a good account for sign-in again, a
different account each time.

- 401/403 is a sign-in verdict only when its body carries 020002/100002.
  Otherwise chat and draw answer 502 with x-magpie-sign-in: kept (magpie
  tries the next account and leaves this one signed in), usage reports
  the error with signIn "kept", check-in reports "failed". The message
  names the status, says it isn't a sign-out, and quotes the body.
- A lapsed account's message gives the day it was signed in (signedInAt,
  kept at SMS sign-in; older accounts from expires - 14 days). No
  lifetime is claimed: the client asks for 14 days, but agent2api found
  sessions served past that.
- SMS sign-in returns uid (the vendor's userid) beside the masked phone.
- A pasted session is named by its last six characters instead of the
  one name "手动粘贴" every paste shared, which made a second pasted
  account replace the first in magpie's account list.

No renewal exists to add: Loomy's client 0.9.39, its web app,
magpie-providers-hub and agent2api only sign in again. A truly lapsed
account still needs an SMS code; magpie's "Sign in again" on the row is
one click.

Run (mote, HEAD afe4c086 + this change):
- HOME=<temp> bun test packages/loomy: 46 pass, 0 fail.
- HOME=$(mktemp -d) bun test (root): packages/loomy 46 pass, 0 fail.
  Other packages red on mote only (7910 pass, 563 fail: kimi-desktop,
  zen-free, inkstone, zcode, qoder ...), none touched here; CI's test
  job is green at afe4c086 on ubuntu. bun scripts/check.mjs: ok.
Broken by hand: index.mjs at afe4c086 with the new tests and fake: 9 of
the 10 new or changed tests fail (37 pass, 9 fail). The pasted-session
"names no day" test is a guard and passes on both.
Not tried: a real Loomy account (none here), so the session's real
lifetime is unmeasured, and the user's proxy's actual 401/403 body is
not seen; the fix holds for any body without a sign-in code.
2026-11-17 10:08:33 +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