Commit Graph
3844 Commits
Author SHA1 Message Date
yetone dccfefdf72 library: a skill brought in from an app's versioned folder follows the app's updates (#2635)
iomect's ego lite keeps its skill in a framework version folder and
points its own links at the current one:

  ~/.agents/skills/ego-browser -> ~/.local/share/ego/ego-skills
  ~/.local/share/ego/ego-skills -> ~/.local/share/ego/active_version_dir/Resources/ego-skills/ego-browser
  ~/.local/share/ego/active_version_dir -> /Applications/ego lite.app/.../Versions/0.6.0.12
  .../Versions/Current -> 0.6.0.12

ImportSkill linked the library to the fully resolved folder
(Versions/0.5.1.13/...). After the update to 0.6.0.12 the old folder was
still there, so the library and every agent it gives skills to kept the
old skill.

importSkill now links to linkVia(f.at, f.real), and Source.Dir is that
same path. linkVia follows the found entry's links one at a time, and
stops at the first one outside every skills folder (the agents', the
shared ~/.agents/skills and the library's): for ego that is
~/.local/share/ego/ego-skills, which the app keeps pointing at its
current version. A Versions/<v> part is named Versions/Current when
Current is a link to that same version, which covers an entry that links
straight into the versioned folder. If that path doesn't resolve to the
same folder as today, linkVia returns the resolved folder, as before.
Nothing else changes: every comparison of Source.Dir already goes
through realDir.

Tests (skill_version_test.go):
- TestImportedSkillFollowsAppUpdate uses the reporter's layout
  (ego lite.app, ego Framework.framework/Versions, active_version_dir,
  ego-skills, ~/.agents/skills/ego-browser), brings it in at 0.5.1.13,
  then moves the app's links to 0.6.0.12 and checks the library's skill
  is 0.6.0.12's, listed and not missing.
- TestImportedSkillThroughVersionsCurrent does the same with an entry
  linking straight into Versions/0.5.1.13.
- TestImportedSkillPlainLink checks that a link to a plain folder is
  still linked to that folder.

Broken by hand:
- with `via := f.real` (the old link), FollowsAppUpdate and
  ThroughVersionsCurrent went red (the skill stayed "ego 0.5.1.13");
- with the Versions/Current step taken out, ThroughVersionsCurrent went
  red.

Not done: a skill brought in before this keeps its old resolved link
until it is brought in again, or its link in the library is replaced.
No ego install here; the tests use the layout from the reporter's ls.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
go vet -tags nogui ./... clean. go test -timeout 45m ./... under
set -o pipefail with a sandbox HOME, load ~280: 65 packages ok
(internal/library 352s), internal/gui red with 8 real-window AppKit tests
killed at their deadlines (#2645). internal/gui doesn't use this code.
It passed alone with the real HOME, with this change (186s at load
~260-341) and on 8bb9375e7 without it (204s at ~300). With the sandbox HOME
it went red again when run alone; the runs are on #2645. No GUI files
touched.

Rebased onto ebf3f48f7, which changes nothing under internal/library or
internal/agent; go build ./... and go test ./internal/library ok there
(697s).
2026-10-17 11:01:48 +08:00
yetone ebf3f48f7f usage: a reported call takes first_text_ms and flow_ms, so a reasoning reply tells its speed and a burst is held (#2637)
POST /v1/magpie/usage/requests turned away first_text_ms and flow_ms as
"not a field a reported record takes", so a reported reasoning reply was
timed from its first reasoning token and a burst-at-the-end reply was
never held. The ingest now takes both, validated like ttft_ms (whole
milliseconds, 0..ingestMaxMillis, null = unset), and checks:
- first_text_ms <= ms, and first_text_ms >= ttft_ms when both are set
  (the first text is content too);
- flow_ms <= ms*10/8+1, since the gateway's flow is the tenth-to-nine-
  tenths span scaled by 10/8 and can exceed ms.
The fields reach usage.jsonl through the Record, so DecodeOf, Row.Decode
(ThinkPace, HeldShare) and the Reported totals read them as they do the
gateway's own rows. docs/reference.md and gateway-sessions.md say so.

Tests: TestUsageIngestTellsSpeed posts the reporter's literal repro
(grok-4.7, out 307, reasoning 129, ms 5035, ttft 4632, first_text 4700:
178 tokens over 335ms), a burst held by flow_ms, an even reply told, and
a ThinkPace hold, and checks the totals. TestUsageIngestTimesChecked
covers each bound, its edge, null and absent fields.

Broken by hand: old code fails both tests (field refused); dropping
FirstText tells repro-1 0; dropping Flow tells the burst 601/4035;
removing the ttft check accepts first_text 299 < ttft 300; bounding flow
by ms rejects the valid 1501.

Run at 8bb9375e7 + this diff: gofmt -l clean; go vet ./... on darwin,
GOOS=linux and GOOS=windows -tags nogui clean; set -o pipefail; go test
-timeout 45m ./... exit 0 (66 ok, gateway 1192s) under a sandbox HOME and
private GOCACHE (an earlier run against the shared cache had build
errors from cache files removed mid-run, not code). Machine load ~250.
Not tried with a real reporting client.
2026-10-17 10:14:03 +08:00
yetone 333c167575 routing: a rule can set the reasoning its model is asked for (#2633)
dengtongcai asked for a routing rule that picks both the model and the
reasoning it is asked for (a quick question goes to a cheap model at low).
A rule now has an output field, useEffort (low|medium|high|xhigh|max). When
the rule matches, its member is asked for that effort. A member's own fixed
effort still wins. Otherwise the rule beats the model's suffix, the turn's
pick and the agent's pick. The existing effort condition is unchanged.

- The value is fitted to the model's levels (max -> high on a model that
  tops out at high). A model with no Efforts is sent what the agent asked,
  untouched. Unset changes nothing. Failover members are not affected.
- The trace records it: Rule.UseEffort and the try's RuleEffort (the second
  Try construction in the candidate loop was missing it).
- Saving a group rejects an unknown value or one on a pause (cleanRules).
  The CLI takes use-effort=; the TUI and CLI lists show " at <effort>".
- GUI: a chip after the rule's model, picked from the app menu (pickFrom,
  no native select), set/changed from the rule's menu. A pause clears it.
  Strings in zh, zh-TW, ja, de.
- A Gemini-protocol client is left unchanged, as with every effort magpie
  sets.
- Docs: docs/subsystems/gateway-routing.md; site docs intent and start (en,
  zh, ja).

What was run, at d4c03a2c5 (rebased on d4a1b9baa) unless said:
- gofmt -l: none. go vet ./... (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: clean.
- go test -count=1 ./internal/gateway ./internal/provider ./internal/cli
  ./internal/tui: ok.
- The full go test -timeout 45m ./... under pipefail, before the rebase at
  6f950653f: every package ok except internal/gui. There, 8 real-window
  darwin tests were killed at their deadlines with the load average at
  150-300. Four passed on a rerun. TestMainWindowCorners,
  TestMainWindowRightToLeft, TestTrayCellClickReleasedPanel and
  TestCoveredWindowStaysUp fail the same way on a clean 6f950653f checkout
  (added to #1936). This change has no Go in internal/gui.
- Broken by hand: ruleEffort returning "" turns the four gateway tests red
  (Chat member, intent rule, failover member, Anthropic member). Returning
  the raw value for a model with no levels turns the unset/no-levels test
  red. Dropping the cleanRules checks turns TestCleanRulesUseEffort red.
  routing-rule-effort.test.cjs against the 6f950653f routing client.js and
  i18n.js is red.
- GUI: routing-rule-effort.test.cjs passes 18/18 in chromium and webkit
  (en, zh, zh-TW, ja, de; 1100 and 420 wide). The 140 GUI files that open
  the Routing view ran 560 tests before the run stopped with no summary.
  Two of the 560 were red: group-from-model-add (#2388) and
  name-suffix-where-named (filed #2640, a skeleton-row race). Both pass
  alone. The whole 791-file suite was not finished. At a load near 280 it
  covered about 20 files in 40 minutes. The reds it showed were in
  account-* files, and account-models passes 12/12 alone.
- Then rebased onto 8bb9375e7 (#2635, internal/library only) and
  go build ./... at the final head.
2026-10-17 10:04:39 +08:00
yetone 8bb9375e74 library: another app's MCP server in an agent's config is offered to bring in, not taken for the agent's own (#2635)
iomect's Codex server, written in ~/.codex/config.toml as

  [mcp_servers.netcatty-external]
  command = "/Applications/Netcatty.app/Contents/Resources/app.asar.unpacked/electron/cli/netcatty-external-mcp"
  args = []
  env = { NETCATTY_EXTERNAL_MCP_DISCOVERY_FILE = "…" }

never showed under the Library's servers found in agents. The TOML was
read correctly; the cause was appOwned. It marked any command under a
".app/Contents/" as one the agent's app writes itself (Codex's node_repl
and cua_repl, 0f9d60db0). The page leaves such servers out of the list to
bring in (client.js: foundServers.filter(f => !f.own)).

appOwned now takes the agent and counts only the agent's own install:
an .app bundle or WindowsApps package whose name has the agent's id or
name in it (Codex.app, "Codex Computer Use.app", OpenAI.Codex_…), plus
Codex's runtimes and cua_node folders for Codex. Netcatty.app in Codex's
config is now a found server like any other.

TestFoundServerFromAnotherApp uses the reporter's TOML as given, with the
**** placeholder in the path. It checks the found entry's command, empty
args, inline env and agent, and that Codex.app's computer-use is still
Codex's own. The existing TestFoundServersAppOwned and
TestRemoveFoundServerOwn pass unchanged.

I put the old ".app/contents/" match back by hand and
TestFoundServerFromAnotherApp went red (netcatty-external Own: true).

The issue's second part, imported skills not following an app update
(ego lite's Versions/0.5.0.13 -> 0.6.0.12), isn't in this commit.
ImportSkill links the library to the found skill's fully resolved path
(f.real). Whether ego links into Versions/Current or rewrites a
versioned link on update isn't known yet, so the issue asks the
reporter, and stays open.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
go vet -tags nogui ./... clean; go test -timeout 45m ./... at 7154fe61c, set -o pipefail: 66 packages ok, exit 0 (internal/library 372s under load ~280; internal/gateway cached from the run for d4a1b9baa, same code). No GUI files touched.
2026-10-17 09:39:47 +08:00
yetone d4a1b9baa7 gateway: a </think> inside code no longer ends a reply's thinking; a plugin's text keeps its <think> (#2634)
Kane-Kuroneko's Qoder replies through Codex began mid-sentence at a
backtick: the Chat decoder took any reply whose text began with <think>
as inline thinking up to the first literal </think>, even one inside an
inline-code example ("使用 `<think>...</think>` 标签"), for every Chat
upstream.

- The close is looked for only outside Markdown code (mdCode in
  chat.go): an inline span (taken to end with its line, so a stray
  backtick can't swallow the answer) or a fenced block. Backtick runs and
  a close split across chunks are held, as the tag tail was.
- A plugin's Chat reply is read as OpenCode reads it, its text as it came
  (decoderFor, used by streamTranslated, the continuation path and the
  search path): the plugin knows its vendor and gives reasoning apart.
  Qoder's plugin sends reasoning_content and has no splitter of its own.
- A reply that already gave thinking in reasoning_content/reasoning has
  no leading-tag lookup in its text.
- The line breaks after a close are left out however they're chunked:
  one character a delta used to leave "\n" at the head of the answer.
- Codex titles/descriptions/predictions (codex_titles.go) strip a leading
  block with the same close rule (afterThought), the sibling cut.
MiniMax (2ab69d0f) and Gemini's <thought> keep working: their existing
tests pass unchanged.

Tests use the reporter's literal bytes, whole, a character a delta and a
byte a delta: TestChatThinkCloseInCode, TestThinkExampleReachesClientsWhole
(Codex /v1/responses and Claude Code /v1/messages against a fake Chat
upstream), TestChatThinkTagAfterReasoningField, TestPluginThinkTagIsText
(the fake plugin as qoder, through Bun, with #2634's historical
boundary), TestAfterThoughtCloseInCode.

Broken by hand, each watched go red: close matched inside code ->
TestChatThinkCloseInCode, TestThinkExampleReachesClientsWhole,
TestAfterThoughtCloseInCode; reasoning-field rule off ->
TestChatThinkTagAfterReasoningField; plugin scope off ->
TestPluginThinkTagIsText; newline trim off -> TestChatThinkCloseInCode,
TestThinkExampleReachesClientsWhole, plus the existing MiniMax tests.

Run: gofmt -l clean; go vet ./... (darwin), GOOS=linux and GOOS=windows
go vet -tags nogui ./... clean; go test -timeout 45m ./... on this change plus the next
commit's library edit (the worktree held both while it ran): 64
packages ok, internal/gateway ok (524s), internal/library ok; internal/gui's
real-window darwin tests were killed at their 30s bar under a load
average of ~295, and internal/provider failed to link on a GOCACHE file
another run trimmed. Rerun alone: internal/provider ok (206s),
internal/gui ok (165s). No GUI files touched. Not tried
against real Qoder or MiniMax accounts.

Not changed: the plugins repo's think-tags middleware
(packages/think-tags) also ends a block at the first indexOf("</think>")
when a user turns it on.
2026-10-17 08:49:42 +08:00
c1e95f919b gateway: a key held to accounts is told only of the image and video models they serve (#2579)
A gateway key held to some accounts was told, in /v1/models' image and
video lists (drawerObjects, videomakerObjects), of every image and video
model its held models named, whether or not an account the key may use
serves it. Its chat list already applied accountServes; the two media
lists applied modelAllowed alone. Both now apply both, as entryAllowed
does. Reported by ggbdpq; the patch and test are ump45nose's
(fix/2579-image-video-account-serves, 592cc4db), with a t.Cleanup added
and the doc comments and failure message reworded.

Siblings: the other modelAllowed-only callers are not model lists (the
codex and desktop subagent picks, chatGPTSearchers, quotas_scope, which
handles accounts in card(), and videoModelHeld). The Drawers/Videomakers
uses in draw.go, video.go and drawing_route.go resolve a model, they do
not list them.

Run at this commit's tree (base 6f950653f):
- With the fix removed, TestGatewayKeyAccountsHoldTheImageAndVideoLists
  fails: "a key whose account serves no image or video model is told of
  image [grok/grok-imagine-image grok/grok-imagine-image-quality], video
  [grok/grok-imagine-video grok/grok-imagine-video-1.5]". With it, it and
  TestGatewayKeyModelsHoldTheImageAndVideoLists pass.
- gofmt -l: clean. go vet ./...; GOOS=linux go vet -tags nogui;
  GOOS=windows go vet (with and without -tags nogui): clean. Builds for
  darwin, linux (nogui) and windows: ok.
- go test -tags nogui -timeout 45m ./... with pipefail, sandbox HOME:
  every package ok, EXIT=0 (internal/gateway 1315s).

Co-authored-by: ggbdpq <67929842+ggbdpq@users.noreply.github.com>
Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-17 07:43:30 +08:00
yetone 6f950653fc gateway, codex: a model turned away for an image says why magpie takes it for text-only and where Accepts images is (KimYx0207 on X)
mark_li21 pasted an image in Codex through magpie and was told the model
doesn't take images, with no hint of why or where that is changed;
KimYx0207 asked that the refusal say the model's list has no image input
and point to Providers → Names & levels, so nobody switches models or
reinstalls Codex first.

Codex turns the image away itself ("… does not support image inputs.
Remove images or switch models."), and magpie can't word that. What it
can:

- Codex's /model: a model magpie hands Codex without "image" now reads
  "<name> (text only: Accepts images is in its provider's Names & levels
  in magpie) via magpie". It still ends " via magpie", which is how
  catalog.MagpieAdded tells magpie's entries from Codex's own. A model
  that sees and a routing group read as before.
- The gateway's own 400 (every other agent): after "does not support
  image input" it says why — Accepts images turned off by the user for
  it, or the provider's model list marking it as not taking images, or no
  model in the group marked as taking images — and names
  Providers → <provider> → Names & levels, before the note on image
  recognition it already gave.

Tests: TestCodexCatalogSaysTextOnly; TestTextOnlyRefusalSaysWhyAndWhere
(the user's own answer, a group); TestKnownTextOnlyModelRejectsImagesBeforeUpstream
now checks the why and the where on all four APIs. With codexcat.go and
gateway.go put back, all three are red.

Real use: a catalog from codexcat.Catalog handed to Codex 0.162.1 under a
sandbox CODEX_HOME (model_catalog_json, a dead provider URL); /model
lists "Text Model (text only: Accepts images is in its provider's Names
& levels in magpie) via magpie" and "Sees Model via magpie". Pasting an
image there wasn't tried.

Run at origin/main df3734b95 + this change: go test -tags nogui
-timeout 45m ./... 66 packages ok; gofmt -l clean; GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean. No GUI file changed, so the
GUI suite wasn't run.
2026-10-17 06:29:57 +08:00
yetone df3734b959 proc: the login shell's variables count only when exported, and Codex's proxy detail names the variable it read (#2627)
ReneXiong: Codex showed the "proxied" drift, "through the proxy at
http://127.0.0.1:7890, set in HTTP_PROXY", while Codex went direct. The
value was fish's universal http_proxy from an old Clash setup, never
exported (`set -S` says "unexported"), so no program fish starts has it.
shellEnv asks fish beside the login shell (zsh), and shellProbe printed
"$http_proxy" in the shell itself, which expands unexported variables too;
mergeShellEnv then filled zsh's empty value with fish's.

Fix at the shared reader: every shell is now asked to run
/bin/sh -c 'printf ... "$PATH" "$CODEX_HOME" ...', the form nushell already
used (still with its ^). A child sees only exported variables, so each
value is what an agent started from that shell gets. This covers every
reader of the probe: Codex's proxy (codexEnv), Claude Code's provider
switches (claudeShellEnv), and agentenv.Vars such as CODEX_HOME and
CLAUDE_CONFIG_DIR that magpie takes into its own environment; an
unexported zsh or bash variable no longer counts either, which matches what
an agent run from that terminal sees. Proxy variables are still merged from
fish when the login shell has none: a fish user who exports one runs Codex
with it from fish, so taking proxies from the login shell only (the
report's other suggestion) would miss that case.

codexProxyFor named HTTP_PROXY (or HTTPS_PROXY, ALL_PROXY) for a value in
the lowercase variable. It now names the one it read, in both the reqwest
and respect_system_proxy paths, and the detail's NO_PROXY advice matches a
lowercase name too (and not "the system's proxy settings").

Other proxy readers checked: the daemon's carried env, wslrun's proxyVars,
netproxy and the plugin host read magpie's own environment, not a shell;
the WSL probe scripts ask for no proxy variable.

Tests: TestLoginEnvUnexportedNotCounted, a login shell with the reporter's
literal values unexported beside an exported NO_PROXY; TestShellEnvRealFish
now writes the reporter's literal fish_variables lines and checks that
http_proxy, https_proxy and all_proxy read empty;
TestCodexProxyNamesItsVariable. Broken by hand, each went red: the old
in-shell printf (unexported values read back, in the fake shell and in real
fish 3.7.1), and env() naming keys[0].

Run: go test ./internal/proc and the codex proxy tests on darwin;
TestShellEnvRealFish, TestShellEnvFishLogin and
TestLoginEnvUnexportedNotCounted on real fish 3.7.1 in an alpine container
(linux/arm64), green with the fix and red without it; gofmt -l clean; go vet
-tags nogui ./... for darwin, linux and windows; the full go test -tags
nogui -timeout 45m ./... under pipefail, both fixes together on
origin/main ec6454395: exit 0, 66 packages ok, no FAIL.

Not tried: the reporter's Mac with fish itself, and nushell (not installed
here; TestShellEnvNushell's real-nu part skipped, its probe-shape check
passes).
2026-10-17 05:35:45 +08:00
yetone 742d6c06e0 gui: on Linux the window and its desktop entry name each other, and the icon is installed (#2626)
unfallenwill: the dock and the app grid showed a gear for magpie on Linux.
The desktop entry registerScheme writes had no StartupWMClass, and its
Icon=magpie named an icon nothing installed.

What the window reports, from the source (not guessed):
- GTK3 (gtk-3-24): an X11 window's WM_CLASS is (g_get_prgname(),
  gdk_get_program_class()), the class being the prgname with its first
  letter upper-cased; a Wayland xdg_toplevel's app_id is g_get_prgname(),
  falling back to the program class.
- Wails v3.0.0-beta.24 (gtk3 build, which magpie's Linux build uses):
  LinuxOptions.ProgramName goes to g_set_prgname before
  g_application_run. Without it the prgname is the executable's name,
  magpie-linux-amd64 for a release run as downloaded, which no entry names.

So magpie now sets ProgramName "magpie" (internal/gui/desktop.go), making
WM_CLASS ("magpie", "Magpie") and app_id "magpie", and the entry says
StartupWMClass=magpie. An ApplicationID was not used: WebKitGTK keys its
data folder by the prgname (~/.local/share/<prgname>), so "magpie" keeps an
install.sh user's data where it is. A binary run under another name had
its data under that name; keepWebData moves it to ~/.local/share/magpie
before the first webview, unless magpie's folder is there already (Go's
os.Rename refuses an existing directory, which is the guard).

registerScheme also writes a 256px icon to
$XDG_DATA_HOME/icons/hicolor/256x256/apps/magpie.png (temp file and rename,
skipped when the bytes match), and rewrites an earlier entry for the same
executable that lacks StartupWMClass. Flatpak is left alone as before.
install.sh's own entry gets StartupWMClass=magpie too. The icon is
build/icon/gen.go's 256px output (make icons now writes it), the same bytes
as site/public/img/icon-256.png.

Siblings checked: the autostart entry starts the app and needs no
StartupWMClass. The repo has no deb, rpm, AppImage, AUR or flatpak
packaging (#2225 plans deb/rpm); install.sh is the only other entry.

Tests: TestRegisterScheme checks the entry's StartupWMClass and Icon and
the installed PNG (256x256); TestRegisterSchemeBindsAnOlderEntry;
TestKeepWebData (moved, magpie's folder there already, no localstorage);
TestLinuxWindowNamedAsItsEntry (gui build); install.test.mjs asserts the
line. Each was broken by hand and went red: entry without StartupWMClass,
icon not installed, the short-circuit without the StartupWMClass check,
keepWebData returning at once, linuxOptions without ProgramName.

Run: the Linux tests cross-compiled (linux/arm64, nogui) and run in a
busybox container, the whole internal/gui package passing there;
TestLinuxWindowNamedAsItsEntry on darwin; node --test site/install.test.mjs
10/10; gofmt -l clean; go vet -tags nogui ./... for darwin, linux and
windows; the full go test -tags nogui -timeout 45m ./... under pipefail, both
fixes together on origin/main ec6454395: exit 0, 66 packages ok, no FAIL.

Not tried: a real Linux desktop (GNOME or KDE, X11 or Wayland). No such
session was available, so the dock icon itself was not seen; the binding
rests on the GTK and Wails source above. The gtk3-tagged gui build was not
compiled for Linux here (needs cgo and GTK).
2026-10-17 05:33:18 +08:00
yetoneandggbdpq ed0335f75c gateway: an assistant turn cut off before it said anything is left out of what a Chat upstream is sent (#2599)
timonwong (#2599): after the user stops a reply while the model is still
thinking, the agent keeps a turn with no text and no calls and sends it
again on every later turn. Translated (buildChat) or relayed, it reached
the Chat upstream as {"role":"assistant","content":""} (reasoning_content
alone, on DeepSeek), and DeepSeek and Kimi turned every request of the
conversation away: "Invalid assistant message: content or tool_calls must
be set".

One rule, withoutSilentAssistants (chat.go), runs on both Chat routes:
buildChat before pairToolMessages (Claude Code, Codex and Gemini clients,
and the plugins fed by buildChat), and silentAssistantsOut in passthrough
next to developerAsSystem (a Chat client's own body). An assistant
message with no content or only blank text parts, and no tool_calls or
function_call, is left out; the user messages it stood between join into
one (texts with a blank line, else their parts in order), so no two user
messages stand in a row. A prefill (prefix, partial, a Resume), a legacy
function_call, a refusal and an audio reply stay. A relayed body without
such a turn goes byte for byte. TestChatThinkingOnlyAssistantKeptOutside-
Exchange pinned the old pass-through; it now expects the joined message.

Built on ggbdpq's patch (cb438ebb on their fork) and its fake upstream,
written again because the review found it missed shapes the issue names:
- after a tool result it kept the empty turn ("a strict template wants the
  reply behind its tool message"), so the interruption mid tool loop still
  sent content "" and still got the 400. tool then user is what any agent
  sends when the user writes after a tool result; it is now left out.
- the relay dropped an assistant with a legacy function_call or a refusal
  and empty content, and a client's own prefix/partial prefill;
  kept blank text-part arrays (still refused); joined only string users;
  re-marshalled with HTML escaping.
- its Resume check compared a joinSplitCalls turn index with
  len(r.Messages)-1.

Verified (sandbox HOME, pinned caches, go1.26.8 darwin/arm64, base
origin/main 72d6103e2):
- The fake upstream refuses with the issue's literal 400 body any
  assistant without content or tool_calls, plus DeepSeek's #1462/#1822
  reasoning rule. On main's product code 18 subtests of the new tests go
  red with that 400 (Claude Code: thinking, redacted, empty text,
  thinking+empty text, [], "", after a tool result; Codex: lone reasoning,
  empty output_text, no content; Gemini thought-only; relay: "", null, no
  content, blank parts, after a tool result; relay keeps-what-speaks), and
  TestChatThinkingOnlyAssistantLeftOutOutsideExchange. With ggbdpq's
  product files instead, after-a-tool-result (both routes), blank parts
  and TestChatRelaySilentAssistantsOnly are red. With this change all
  pass; TestChatResumeEmptyPrefillKept is a guard, green before and after.
- gofmt -l: clean. go vet -tags nogui ./... for darwin, linux, windows:
  ok. Full suite with both this and the #2575 test change in the tree,
  set -o pipefail; go test -tags nogui -timeout 45m ./... : 66 packages
  ok, none failed (internal/gateway 825s, internal/provider 266s).
- Rebased onto origin/main ec6454395 (claude_subscription, ir.go):
  gofmt clean, vet darwin/linux/windows on internal/gateway and
  internal/settings ok; go test -tags nogui -timeout 45m
  ./internal/gateway ./internal/settings: ok (gateway 668s).
- Not tried against real DeepSeek or Kimi (the fake answers with the
  issue's bytes). Gemini and Responses upstreams are not changed; the
  Messages build already drops an empty turn and merges same-role
  neighbours (anthropicBody's push).

Co-authored-by: ggbdpq <67929842+ggbdpq@users.noreply.github.com>
2026-10-17 05:15:16 +08:00
yetoneandump45nose e903d87fbe gateway tests: TestUsageKeepsTimeToFirstToken sends each event after the agent got the last, not a fixed gap (#2575)
The test's vendor (paced) spaced its reasoning, text and end with a fixed
80ms sleep, and that sleep was all that kept them apart. On a loaded full
run the gateway read late, found the reasoning and the text waiting
together, and timed both at once ("usage ttft 228, first text 228" for
responses_from_chat). The gateway timed what it read correctly; the test
assumed the scheduler keeps up.

ump45nose's patch (test only): paced takes a heard hook, and the gap
before each marked event after the first starts only once the agent
(hearing, a ResponseRecorder that watches its body for "hmm" and then
"hi") has been sent the one before, with a 10s give-up so a missing word
fails instead of hanging. Every case runs twice, "on time" and "late",
where the gateway's first write to the agent is held three gaps while
the vendor's events come in. Other paced users leave heard nil.

Verified (sandbox HOME, pinned caches, go1.26.8 darwin/arm64, base
origin/main 72d6103e2):
- Cause, by injecting the delay: with the gate removed by hand (heard:
  nil) all five "late" cases go red, responses_from_chat in the issue's
  shape: "usage ttft 337, first text 337, ms 337"; chat, responses and
  chat_from_anthropic read the text and the end together (first text ==
  ms). With the gate all 10 pass.
- -count=10 with 12 `yes` CPU burners beside it, machine load ~280: ok.
  -race -count=3: ok. No case waits on the 10s give-up (each <0.6s).
- gofmt -l: clean. go vet -tags nogui ./... for darwin, linux, windows:
  ok. Full suite with both this and the #2599 change in the tree,
  set -o pipefail; go test -tags nogui -timeout 45m ./... : 66 packages
  ok, none failed (internal/gateway 825s, internal/provider 266s).
- Rebased onto origin/main ec6454395 (claude_subscription, ir.go):
  gofmt clean, vet darwin/linux/windows on internal/gateway and
  internal/settings ok; go test -tags nogui -timeout 45m
  ./internal/gateway ./internal/settings: ok (gateway 668s).

Co-authored-by: ump45nose <ump45nose@users.noreply.github.com>
2026-10-17 05:15:11 +08:00
yetone ec64543952 claude: a switch gives a Claude subscription's run the agent's instructions as its system prompt, in place of Claude Code's
Every request through a Claude subscription is answered by the real
Claude Code, which sends its own system prompt, with the agent's
instructions in the run's first user message. Settings › Replies › Short
Claude system prompt (claudeLeanPrompt, off by default) starts the run
with --system-prompt-file holding the agent's instructions instead
(without a client Claude Code's billing line, plus the tool-choice
line), and the first message holds the conversation alone. The file is
under the distro's mount in WSL. A request with client cache marks
(#1717) is never lean. The mode is part of the run's identity, so a run
started in one mode never takes the other's turns. The row says the
risk: requests look less like Claude Code's own.

Measured with a real Claude subscription, Sonnet 5.5, Claude Code
2.1.301, off then on:
- chat client, ~600-token prompt, 2 tools, 3 turns: 10,048 -> 6,580
  input tokens (-35%)
- claude -p as the client, Read and Bash, 4 requests: 85,453/85,471 ->
  81,948/81,977 (-4%)
A fixed ~0.9-1.2K tokens a request.

Run at this head (rebased on 72d6103e2):
- go test -tags nogui -timeout 45m -count=1 ./...: all 66 packages ok
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui ./... ok
- TestClaudeLeanPrompt*: 4 pass; each guard broken by hand goes red
  (cacheIdentity's lean bytes, the tool-results mode check, the
  client-cache exclusion, the WSL path)
- whole GUI suite (before the rebase, machine load ~300-430): the 23 red
  files were rerun alone here and on origin/main. mobile-web's settings
  screenshot differed from main because of the new row; it now takes
  the row out until BASE_REF has it, as it does for other new parts,
  and passes with claude-lean-prompt-setting (4 languages, 1100/420,
  chromium and webkit). The rest are red on main too or under load and
  already filed: usage-agents-hide (#2276, #2399), routing-bodies
  (#2559), routing-model-rest (#2115), sidebar-overlay-scrollbar
  (#1863); plugin-other-ways passed alone.
2026-10-17 04:39:59 +08:00
yetone 72d6103e28 gateway: a Chat tool in MCP's or another API's shape goes upstream as a Chat function tool (#2622)
jinyue806 (#2622): ZCode sends its tools on /v1/chat/completions in MCP's
shape, {"name","description","inputSchema"}, with no type and no function
object. magpie relayed them as they came, and SenseNova turned every request
with tools away ("field Tools[0].Type invalid, should be set"; a flat
{"type":"function","name":…} got "function cannot be empty"). A missing
type is invalid Chat Completions for every upstream, not SenseNova only, and
the translated routes were broken too: parseChat read no name from such a
tool, so Messages and Responses upstreams were offered a tool named "".

shapeChatTools puts a tool with its name at the top (no type, or type
"function" without a function object) into {"type":"function","function":
{name, description, parameters, strict}}, parameters taken from
parameters, inputSchema or input_schema; other fields stay beside it. It
runs right after liftMessageTools at the same two choke points: handle, for
every Chat body before routing (relay, schema fixers, redaction, plugins),
and parseChat, for a body that never came through handle. A tool that has
its function, a hosted tool (any other type) and one with no name are left
alone, and a request with nothing to shape is relayed byte for byte.

Verified:
- TestChatToolInAnotherShapeIsShaped sends the reporter's curl body with
  each of the four tool shapes from the report through the Chat relay,
  Messages and Responses. With shapeChatTools made a no-op by hand all 12
  subtests FAIL: relayed as {"name":"f","inputSchema":{…}} as it came, and
  translated as {"name":"",…}. TestShapeChatToolsLeavesChatShape (byte for
  byte on Chat-shaped/hosted/nameless tools; strict and cache_control kept)
  FAILs on the same break. Both pass restored.
- gofmt -l: clean. go vet -tags nogui ./... for darwin, linux, windows: ok.
- Full suite at 81313b912 + this change, sandbox HOME, pinned caches:
  set -o pipefail; go test -tags nogui -timeout 45m ./... : 59 packages ok
  (internal/gateway 1134s, internal/provider 548s). 7 packages failed only
  on "no space left on device" while the disk filled mid-run (cli
  TestModelDisableCmd, library TestAgentMCPFiles, sessions
  TestCodexTitleEvidenceBound, settings TestSaveConcurrent, and gui, tui,
  usage which printed PASS but couldn't write testlog.txt). Rerun once
  space was back (30G free): cli, gui, library, sessions, settings, tui,
  usage all ok.
- Rebased onto origin/main a69cd0707 (#2611's chat call ids, chattidy):
  gofmt clean, vet darwin/linux/windows on internal/gateway ok,
  go test -tags nogui -timeout 45m ./internal/gateway ./internal/source:
  ok (gateway 510s). No other package changed between the two bases.
- Not tried against the real SenseNova (no key here); the reporter's own
  table shows {"type":"function","function":{…}} answered 200.

The "inference request is invalid ... reason=unknown retryable=false" text
in the report is not magpie's (no such string in the repo); it is the
client's wrapper of the upstream error, so nothing changed there.
2026-10-17 04:07:25 +08:00
yetone a69cd07075 gateway: a Chat tool call kept with an empty id goes with one made from its place (#2611, RunMintOn)
RunMintOn's session held an assistant turn whose tool call had "id":""
and a tool result with "tool_call_id":"". magpie relayed it unchanged on
Chat->Chat, and WorkBuddy AI turned the whole request away (400, 11133).
Chat->Messages sent tool_use id "" and Chat->Responses gave the call a
random id while its result kept "".

- chatCallIDs (chat_call_ids.go) runs in attempt for every Chat request,
  before the relay, the translation and a plugin's fetch alike (a moved
  WorkBuddy AI goes through the plugin, so the edit must come first). An
  empty, null or missing call id gets "call_" + a hash of the call's
  message index, position, name and arguments: the same on every resend,
  so the prompt-cache prefix holds. A result with an empty tool_call_id
  takes the turn's unanswered calls in order. A body that already has its
  ids comes back byte-identical.
- chatTidy gives a stream's first fragment of each (choice, index) call an
  id when the upstream sent none, and drops an empty id on later ones;
  chatWhole fills a whole reply's empty ids.
- docs/subsystems/gateway-routing.md says so.

Tests (chat_call_ids_test.go), fixtures from the issue's literal bytes,
against a fake that refuses as WorkBuddy AI does:
- TestEmptyCallIDRelayedWithOne, TestEmptyCallIDReachesPluginWithOne
  (movedFake workbuddy-ai), TestEmptyCallIDTranslatedWithOne (messages,
  responses), TestChatCallIDsLeavesWhatHasIDs, TestStreamedCallGivenAnID,
  TestWholeReplyCallGivenAnID.
- Broken by hand, each watched red: edit removed (relay and plugin get
  the 400; translations send an empty or unpaired id); a random id in
  place of the placed one ("the made id changed between requests");
  stream mend off (first fragments' ids ""); whole mend off ("id":"").

Run at this change on origin/main 81313b912:
- gofmt -l: nothing. go vet -tags nogui ./... on darwin, GOOS=linux and
  GOOS=windows: nothing.
- go test -tags nogui -timeout 45m ./...: 64 packages ok; internal/agent
  and internal/gateway failed on "no space left on device" (the disk
  filled under other sessions' runs: agent's testlog.txt write after
  PASS, gateway's TestRotateSpreadsABurstOfNewConversations renaming
  providers.json). Rerun with space free: internal/agent ok 652.9s,
  internal/gateway ok 732.9s.
- Not tried against a real WorkBuddy AI account (no live configs).
2026-10-17 03:53:40 +08:00
yetone 065fc7500d LESSONS: 10-16: a move no user can undo shipped past #2596, one suite per machine, mover mins at landing
Folds the review of 10-16 04:00 to 10-17 04:00 (73 commits, v0.1.1261 to
v0.1.1276) into LESSONS.md: three new lessons (a change no user can
undo gets a real run per vendor, one full suite per machine, a mover's
min is npm's version at landing), and the criteria still missed on
10-16 (chosen GUI files under a tag, a suite at an older base than the
pushed head, a copied body, cancelled runs) with what was done right.

Docs only; every sha and number was checked with git log and gh.
2026-10-17 03:45:41 +08:00
yetoneandump45nose b7d9616d0e gateway: TestMaxRPMGroupPrefersMemberWithRoom checks the route never queued, not a fixed 1s (#2520)
The test gave the second request's round trip 1s as a stand-in for "didn't
wait for A's minute", and a loaded machine went over it (1.13s) with the
routing right. It now reads the second request's route from the trace:
done, one try, to pb, Queued 0 (the trace's Queued holds the wait for
room in the minute too). The time bound stays as a backstop at half the
minute, and the minute is now 20s instead of 5s, so the bar is 10s:
nothing waits for it when the routing is right.

Based on ump45nose's patch, which read usage.Load's record. The review
found that record's Queued and Tries are 0 for a non-streaming request
even after a 20s wait (Queued is filled only when TTFT > 0), so only its
provider check carried weight; the trace's try carries the wait
(Queued:19984 in the hand-broken run). The patch's 2.5s bar was also
under this machine's 2.97s round trip with B held 1.2s.

What ran (worktree at origin/main 81313b912, sandbox HOME, go1.26.8
darwin/arm64, load ~270-300):
- Flake reproduced: main's test with B's minuteVendor late 1200ms:
  "the second waited 2.969s", FAIL. The new test passes with it (3.57s)
  and -count=3 without it.
- Broken by hand: ready() ignoring MaxRPM makes the group wait for A:
  red on the vendor counts ("A saw 2, B 0"), and with that check turned
  to a Logf, red on the trace check (one try to pa, Queued 19984).
- gofmt -l . clean; go vet -tags nogui ./... for darwin, linux, windows.
- set -o pipefail; go test -count=1 -timeout 45m ./...: 65 packages ok,
  internal/gateway ok (1430s). internal/gui red on TestMainWindowCorners
  (#1936) and, on a rerun of internal/gui alone, also
  TestSetAnswersWhileDevinAndProvidersHang (#1375): filed load reds in a
  package this commit doesn't touch.

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-17 03:22:55 +08:00
yetoneandump45nose ff72eeda52 source: the last-source budget test reads which context ended instead of racing sleeps (#2608)
TestDoLastSourceUsesRemainingBudget slept 1100ms (official) and 700ms
(mirror) under a 2s parent, leaving ~300ms for scheduling. It now uses a
controlled RoundTripper: the official request waits on its candidate
context and must end with context.Canceled (its half of the budget), and
the mirror request must carry the parent's deadline and end with
DeadlineExceeded no earlier than it. A second test adds #2608's 350ms
pause before the mirror request. Patch by ump45nose; the review dropped
an unused parentDeadline field.

What ran (worktree at origin/main 81313b912, sandbox HOME, go1.26.8
darwin/arm64, load ~270-300):
- Flake reproduced: main's test with a 350ms pause before the mirror
  request: FAIL in 2.06s (official canceled, mirror deadline exceeded).
  The new tests pass with and without that pause.
- Broken by hand, both new tests red: candidateContext(..., true) for the
  last candidate ("mirror request ended with context canceled 495ms
  before the parent's deadline"), and a WithTimeout(remaining/2) on the
  last candidate ("mirror deadline = ..., want the parent's ...").
- gofmt -l . clean; go vet -tags nogui ./... for darwin, linux, windows.
- set -o pipefail; go test -count=1 -timeout 45m ./...: 65 packages ok,
  internal/source ok, internal/gateway ok (1430s). internal/gui red on
  TestMainWindowCorners (both SDKs "measuring the windows: signal:
  killed" at its 40s deadline, #1936) and, on a rerun of internal/gui
  alone, TestSetAnswersWhileDevinAndProvidersHang (#1375). Both are
  filed load reds in a package this commit doesn't touch.

Co-authored-by: ump45nose <52391318+ump45nose@users.noreply.github.com>
2026-10-17 03:22:55 +08:00
yetone 81313b9121 gui: the core script budget makes room for 10-16's core work (#2612)
TestCoreScriptBudget was red on macOS and ubuntu CI on main from
1978eabe5 (runs 38935231106 and 38939182388). The core's scripts were
1,426,102 bytes, 102 over 1,426,000. The total, counted at each commit:
9fcf6a6e7 1,424,832, then 1978eabe5's Settings › Long conversations
switch for Codex background compaction added 1,270. That switch is core
Settings, not a page that belongs in a plugin, and the GitHub list
loading (1d6f461a9) and the move to plugins (7d7dba31a, 9fcf6a6e7) that
used the rest of the room are core too. So the budget goes to
1,426,102 plus 1.5%, as the test's comment asks.

1978eabe5's body records its suite at a751f5282. That was before
1d6f461a9 and the 22:58 batch, so the budget passed there and failed
only at the pushed head.

app.js is 1,247,683 of its 1,250,000. It is not raised here. The next
core change to app.js that needs room says why in its own commit.

Run at 9228bd443 (origin/main) plus this change:
- go test -tags nogui -count=1 -run TestCoreScriptBudget ./internal/gui:
  ok. At the old 1_426_000: red with CI's message.
- go test -tags nogui -count=1 -timeout 30m ./internal/gui: ok (136s,
  load ~240).
- gofmt -l and go vet -tags nogui ./internal/gui: clean.
- Not run: the full suite. The change is one constant in a _test.go
  file that only TestCoreScriptBudget reads.
2026-10-17 01:50:12 +08:00
yetone 9228bd443f library: skills are grouped by source when the skills CLI keeps its lock under $XDG_STATE_HOME (@_yukirock on X)
skills 1.7 writes its global lock to $XDG_STATE_HOME/skills/.skill-lock.json
when that variable is set, and only to ~/.agents/.skill-lock.json otherwise.
The Library read only the ~/.agents one, so with XDG_STATE_HOME set every
`npx skills add` skill had no repository and the "By source" view could not
group them. Both locks are now read, the XDG one winning per skill, since a
lock written before the variable was set still names older skills.

XDG_STATE_HOME joins agentenv.Vars, so the desktop app takes it from the
login shell like the other folder variables (TestFolderVarsAreListed).

Not handled: a project install's ./skills-lock.json.

Run (worktree at origin/main 1eba266a9 plus this change):
- TestSkillRepoFromXDGLock: red on the old lock() (grill-me "", tdd
  "stale/repo"), green after.
- go test -p 2 -tags nogui -count=1 -timeout 45m ./...: 66 packages ok.
  The first run had TestFolderVarsAreListed red (fixed here) and
  TestMaxRPMWaitsForRoomInTheMinute red under load, the open #1791; the
  rerun had both green.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet clean.
2026-10-17 01:22:21 +08:00
yetone 1978eabe58 agent: Codex's background compaction is turned on from Settings › Long conversations (#2490, #2493)
Codex 0.163 can compact a long conversation in the background while a
turn goes on ([features.async_compaction]). A new row under Long
conversations turns it on, with the share of the window it starts at
(empty: Codex's own 65%). magpie writes it into each Codex config it
routes (codex_async.go):

- [features.async_compaction] enabled = true and
  model_async_compact_threshold_percent. Codex reads the threshold only
  in that table; one at the top level is ignored (tried).
- capabilities = { remote_compaction = "v2" } on [model_providers.magpie].
  Codex starts a background compaction only on a provider with v2, which
  it gives OpenAI and Azure alone. Tried with Codex 0.163 against a
  sandbox gateway and a fake upstream reporting 70% use: without the
  capability, no compaction in a whole turn; with it, compaction_trigger
  requests ran beside the turn's steps and the next step's input held
  the summary. The capability is written for a feature the user turned
  on by hand too (#2493 asked whether magpie supports it: it didn't).
  putProvider carries the table's capabilities over when a model switch
  writes it again.
- What magpie wrote is in the stash (codex.async). A value the user set,
  or changed since, is never written over and stays when the switch is
  turned off; a bare async_compaction = true, an inline or a dotted
  table is the user's as written. A config that doesn't parse is not
  written to.

Not tried: Codex signed in with ChatGPT (openai_base_url to magpie on
the built-in provider, v2 by default), only the custom provider path.

Tests: TestCodexAsyncCompactionWritten, ...KeepsTheUsers and
...KeepsUsersCapability (internal/agent), each red with the matching
part removed by hand (no writing; no capability carry-over; no
ownership check on enabled). codex-async-compact.test.cjs: Chromium and
WebKit, en/zh/zh-TW/ja/de, red with the 1-100 check removed;
compact-at, i18n-keys, settings-general, settings-search pass.
TestSettingsSaveKeepsWhatItDoesNotSend holds the two new fields.
gofmt clean; go vet -tags nogui on darwin, linux, windows.
Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main a751f5282: 65 packages ok, among them internal/agent (2124s), internal/gateway (1845s) and internal/sessions (148s). internal/gui was red on TestSetAnswersWhileDevinAndProvidersHang alone (the state after a set took 11.5s at load ~250; #1375); internal/gui run again alone: ok (206s).
2026-10-17 00:39:37 +08:00
yetone a2c4aab1ba gateway: DSH's session header and compaction mark are recorded, also through a remote magpie (#2505)
h4rk8s asked that the Requests list tell DSH's context compactions apart
and attribute usage per DSH session, also when the call goes through
Remote Magpie, from the headers DSH sends and never from the prompt.

- x-deepseek-harness-session-id joins sessionHeaders, after the others:
  sessionOf / nativeSessionOf / conversationID take it, so usage, the
  Routing page and affinity see DSH's session, and passOnCaller already
  sends a native session header on to a remote magpie.
- x-deepseek-harness-compact set (any value but "", 0, false, no, off)
  makes callKind "compact", which PurposeOf groups as Compaction. Only
  display reads that kind; routing is unchanged.
- withCaller keeps the mark on the caller and passOnCaller sends it on to
  a remote magpie, so the other magpie records the call as a compaction
  too. Neither header reaches a vendor (the request to it is built fresh).
- docs/subsystems/gateway-sessions.md says so.

Run:
- TestDshMarksSessionAndCompaction: direct and through a remote magpie
  (two gateways over httptest), marked and unmarked with a summarizing
  system prompt. Red on the old gateway.go/codex_backend.go/
  remote_magpie.go (session "", kind "", remote sent neither header),
  green now; asserts the vendor saw no x-deepseek-harness-* header.
- TestRemoteMagpieKeepsTheSession still green.
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows.
Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main a751f5282: 65 packages ok, among them internal/agent (2124s), internal/gateway (1845s) and internal/sessions (148s). internal/gui was red on TestSetAnswersWhileDevinAndProvidersHang alone (the state after a set took 11.5s at load ~250; #1375); internal/gui run again alone: ok (206s).
2026-10-17 00:39:36 +08:00
yetone 51adf96958 agent: a compat switch set by hand on a DSH model stays through a model refresh (#2504)
h4rk8s: a compat parameter set in DSH's Models page (maxTokensField, say)
went each time magpie wrote its routes again, because the route's
"models" list was put whole, and a model that only works with it failed
again.

dshPutRoute now carries every compat key from the model as it is in the
file onto the same model as magpie writes it, when the model is on the
same route and that route is still on the same protocol (api). A model
new to the route, or one on a route whose api changed, starts without
them. A switch magpie sets itself (forceAdaptiveThinking) is put as
magpie has it now. Name, contextWindow, maxTokens are still written from
the catalog.

Run:
- TestDshRefreshKeepsHandSetCompat: red with the dshKeepCompat call
  removed ("the hand-set compat went: map[]"), green with it; two syncs
  in a row keep it, deepseek/flash takes none, the stale name/context are
  rewritten.
- TestDshKeepCompatNotAcrossProtocols: an api change drops it.
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows.
Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main a751f5282: 65 packages ok, among them internal/agent (2124s), internal/gateway (1845s) and internal/sessions (148s). internal/gui was red on TestSetAnswersWhileDevinAndProvidersHang alone (the state after a set took 11.5s at load ~250; #1375); internal/gui run again alone: ok (206s).
2026-10-17 00:39:36 +08:00
ggbdpq ee2a7c7e86 sessions: OpenCode child rows no longer crowd the parent out of the trace window
What changed
- traceOpenCodeWindow keeps the latest main sessions. A child is not
  exported, so it no longer takes one of the Limit places. Limit newer
  children were filling the window and the parent was not read. The JSON
  store and the SQLite store share that window.

Run
- TestOpenCodeChildrenDoNotEvictParentTrace failed on a15e576 plus the
  test (sqlite and json: parent dropped behind 200 newer children, no
  spans) and passes with the window. go test -tags nogui -count=1 -p 2
  ./internal/sessions/ passed in a sandbox home (648s). gofmt -l on the
  three files printed nothing. go vet -tags nogui and go build -tags
  nogui with CGO_ENABLED=0 passed for windows, linux and darwin.
- Not run: the rest of the module, -race, a real OpenCode database, or
  a Langfuse server.

Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main a751f5282: 65 packages ok, among them internal/agent (2124s), internal/gateway (1845s) and internal/sessions (148s). internal/gui was red on TestSetAnswersWhileDevinAndProvidersHang alone (the state after a set took 11.5s at load ~250; #1375); internal/gui run again alone: ok (206s).

Generated-by: Grok 4.7 (Cursor)
2026-10-17 00:39:35 +08:00
yetone 138188a36d readme: 零词元 joins the README sponsors, a logo beside APINEBULA's
零词元 (zzq.si) paid for the README seat (owner confirmed the payment). Its
logo goes in the en and zh READMEs' Sponsors row after APINEBULA's, by
payment order, 36px high. The SVGs are the two they sent by mail, byte for
byte (sha256 93e7deae… for light; the dark one only turns the text white),
through <picture> like APINEBULA's. The link goes through
usemagpie.ai/go/zerotoken/readme to https://zzq.si, so its clicks are
counted; sponsors.js gives it a readme link only, as it has no home seat.

Run: node --test site/worker.test.mjs site/install.test.mjs (30 pass). Both
logos rendered in chromium, light and dark: the right one per scheme, same
height as APINEBULA's. Worker deployed (version 75899fbb); curl on
usemagpie.ai: /go/zerotoken/readme -> 302 https://zzq.si, /go/apinebula/readme
unchanged. Not checked: how GitHub itself renders the row (seen after push).
2026-10-16 23:29:45 +08:00
yetone 1eba266a90 gui: a moved Factory's waiting sign-in has one "Use an API key instead" link, its key import's
plugin-other-ways.test.cjs was red on main in both engines since
ee1df7e7a (bisected, 653cb8ee3 good): that commit let a moved Factory
import API keys to its plugin, so its waiting device-code box showed
"Use an API key instead" (the plugin's own key way) beside "Use an API
key instead…" (the import, one key or many, factory_key.go). Two links
that read as one. The plugin's link is left out when a moved
subscription's import is there; the key way is still counted, so there
is no "Other ways to sign in…" for Factory.

plugin-other-ways.test.cjs now checks one key link and that it opens
the import; with the app.js line put back it goes red ("two API key
links"). It, plugin-moved-signin, plugin-signin and signin-paste-plugin
pass in Chromium and WebKit, en and zh.
2026-10-16 22:58:42 +08:00
yetone e80fc7dc5d tests: TestFailOpen cuts only the spin short, not the throw and the string
It set the request limit to 50ms for all three hooks. In a full
go test ./... run (on bff7cbd24) the string case ran past 50ms
under load, and was counted "took too long" instead of "returned neither":
  state {... Calls:3 AvgMicro:44471 Failures:3 Last:onRequest: took too long ...}
Now the throw and the string run under the normal 250ms limit, and only
the spin gets 50ms.

Reproduced by injection: an 80ms busy loop in the string hook gives that
exact state line on the old test and passes on the new one. -race
-count=20 passes.
2026-10-16 22:58:41 +08:00
yetone 7d7dba31ae provider: removing or turning off a moved subscription's plugin moves nothing back
The built-ins are being retired (the owner, 10-16: 陆续把内置Provider下线掉),
so the last way back to one is gone. MoveBack, moveBack and releasePlugin
are removed, with the Left flag they set.

- SetPluginOff only turns the plugin off. A moved subscription stays
  moved, off with it.
- RemovePlugin records the moved ids as the new state "removed". The
  record keeps its accounts, which plugin.Remove leaves in the plugin's
  auth store. Nothing moves or installs it by itself: MoveRetiring
  skips it and keepMovedCurrent reads only "plugin".
- HandOver turns a removed record whose plugin is installed and current
  back into "plugin", record and all. So does Adopt (the editor's Move).
- MoveRetiring moves an old "back" record again, whatever Left said.
- Plugins page, rm/off confirms: "{names} stops working until the plugin
  is installed again. Its accounts are kept." / "... while the plugin
  is off." The status after removing no longer says it is back on the
  built-in.
- Strings: five old strings dropped ("Moving back…" among them), three
  new ones in zh, zh-TW, ja and de.
- `magpie plugins rm`/`off` say the same in their output.
- Docs: provider-plugins.md (the states table, the Move-back paragraph)
  and AGENTS.md.

Tests:
- TestNoWayBack is new. It covers a "back" record moved again, the
  plugin turned off (still moved, accounts kept), removed (removed, not
  reinstalled by keepMovedCurrent or MoveRetiring), installed again
  (HandOver), and removed again then Adopt.
- TestReleasePlugin and TestMoveBackKeepsLapse asserted the way back
  and are deleted.
- TestMove, TestHandOver, TestMoveTidiesItsPlugin and
  TestAdoptBeforeSigningIn no longer call MoveBack. TestKeepMovedCurrent
  uses the removed state.
- plugin-release.test.cjs checks the new asks and that the status names
  no built-in.

Run:
- Broken by hand:
  - With HEAD's migrate.go, TestNoWayBack is red at "turning the plugin
    off moved it back".
  - With HandOver's removed branch disabled, it is red at "installed
    again: map[], moved false".
- go test -tags nogui ./internal/provider -run
  'TestMove|TestNoWayBack|TestHandOver|TestKeepMovedCurrent|TestAdopt|TestInstallPlugin|TestWorkBuddyCheckin|Plugin|Migrat':
  ok.
- GUI (NODE_PATH playwright, --test-concurrency=1): plugin-release,
  plugin-move and i18n-keys, chromium and webkit: 17/17.
- gofmt -l clean; GOOS=linux and windows go vet of provider, gui and cli.
- Full suite: go test -tags nogui ./... -count=1 -timeout 90m at this commit rebased on 9b04c4e20 (with the TestFailOpen fix after it): 66 packages ok, none red. Before that fix, at bff7cbd24, 65 ok and internal/middleware TestFailOpen red under load (fixed at its cause in the next commit).
2026-10-16 22:58:41 +08:00
yetone f9ceac1628 provider: a move onto the plugin takes every account, and no model holds it back
The built-ins are retired (the owner, 10-16: 一定要下线完毕), so a move
can't be held back by something only the built-in could fix. Before, a
move failed when every account was lapsed, when one account's check
failed (the vendor unreachable through the plugin), when the vendor
refused every account, or when a model in use wasn't in the plugin's
list. Each of those left the user on a built-in that is going away.

Now Move installs the plugin and imports every account:
- one the vendor refuses goes along marked lapsed, as before;
- one already lapsed, or whose check fails otherwise, goes along untried
  and unmarked, for the plugin's own reads to judge, and is logged;
- no model is checked against the plugin's list.

Only an install failure, the plugin not serving the id, or a sign-in the
plugin won't import fails the move, which puts everything back and is
tried again after moveRetry. The movers' served (Devin, Cursor) and
builtin (ZCode) hooks, modelsInUse, modelNames, lapsedAll and devinBase
had no other use and are gone, with the tests of the hooks. The page still
translates an older magpie's lapsed, unserved and account whys, which
migrations.json can hold.

Tests:
- TestMoveEveryAccountLapsed and TestMoveTriesEachAccount are new, and
  TestMoveToPlugin's first case is now a refused account that moves.
  importAuth is a seam: the fake mover's "r-noimport" sign-in fails part
  way, so TestMoveToPlugin, TestMoveTidiesItsPlugin and TestMoveCutShort
  still test putting back.
- TestMoveCutShort's cut-short record now carries the sent sign-in's
  hash, as a real move writes it. Without it putBack took the built-in's
  sign-in as renewed. The old test passed only because the check renewed
  the token a second time.
- Broken by hand: with a failed check or a refusal returning an error
  again, TestMoveToPlugin and TestMoveTriesEachAccount go red.

What was run:
- go test -tags nogui ./internal/provider -run
  'Move|HandOver|Lapse|PutBack|Retir|Adopt|KeepMoved|ReleasePlugin|
  ZCodeStartPlan|Devin|Cursor' passes.
- go vet passes and gofmt -l is clean.
- At ab7b28510 on ba132d68b: go test -tags nogui ./... -count=1
  -timeout 90m, 66 packages ok, no FAIL; GOOS=linux and windows go vet
  of provider, gui and cli pass.
- Rebased onto origin/main with the next commit; the suite at that head
  is in its body.
2026-10-16 22:58:41 +08:00
yetone 9fcf6a6e7f provider: every deprecated built-in moves onto its plugin, and there's no way back
The owner, 10-16: 陆续把内置Provider下线掉…一定要下线完毕. The plugins now do
what the built-ins did (the parity batch up to 53009f81a), so the built-ins
are retired:

- MoveRetiring moves every subscription with a mover (retiring is
  MovableIDs, the list was empty) that still has built-in accounts, from
  the gateway's hourly loop, six hours after a failed try as before.
- A user who moved back is moved again. Only a move back made by removing
  or turning off the plugin (Migration.Left) is left as it is.
- There is no move back from the GUI or the CLI. provider/moveback and
  `magpie plugins move-back` answer that the built-ins are retired. A
  moved subscription's editor says it stays on its plugin and shows no
  button, and the success line no longer offers to go back. New strings
  in zh, zh-TW, ja and de; the three unused ones are gone ("Moving back…"
  stays, for removing a plugin).
- AGENTS.md and docs/subsystems/provider-plugins.md say so.

Tests:
- TestMoveRetiring's subtests check that a moved-back subscription is
  moved again and an off or removed plugin's is not.
- TestMoveBackRefused goes red on the old handler.
- plugin-move.test.cjs checks that a moved Zed has no button and says it
  stays.

What was run, at 63be47717 with this change:
- go test -tags nogui ./... -count=1 -timeout 90m: 65 packages ok. The
  gateway was red on TestUsageKeepsTimeToFirstToken (#2575, new) and
  TestVisionWaitIsntTheDescribersTime (#2444) at load ~260. Neither file
  is touched here, and both pass alone with -count=3.
- gofmt -l is clean; GOOS=linux and GOOS=windows go vet of provider, gui
  and cli pass.
- GUI, both engines: plugin-move, plugin-move-unserved and i18n-keys pass
  23 of 23.
- The other plugin-*.test.cjs files go red under parallel load as they do
  on untouched main (#1544, commented with the runs). Serially, then alone,
  they pass 28 of 28.
2026-10-16 22:58:40 +08:00
yetone 1d6f461a99 plugins: the Unofficial, on GitHub section shows while GitHub hasn't answered, looking, with cards still to come
On a slow line the section wasn't drawn until /api/plugins/github
answered, so Discover read as having no unofficial plugins (yetone:
当还没加载完的时候,压根就不显示,会让那些网慢的用户以为没有非官方插件).

While it waits, the section stands in its place before the field: its
head and hint, a quiet "Looking on GitHub" with three breathing dots
(role=status, aria-busy on the section), and three card-shaped ghosts
(logo, name, author, button, two lines, two chips) a soft light passes
over, each card a beat after the last. When GitHub answers, its cards
come in where the ghosts were with a short staggered fade-up. A search
while it waits shows the same. When the ask fails (and nothing was
loaded before) the section says "Couldn't ask GitHub: <error>" with Try
again, instead of disappearing. prefers-reduced-motion stops all of it.
Strings in zh, zh-TW, ja and de.

Run:
- new internal/gui/tests/plugin-github-wait.test.cjs: 18/18 on this tree
  (Chromium and WebKit; en, zh, ja, de; 980 and 440 wide; held, search
  while held, let go, 502 then Try again, no scroll on the click).
  With MAGPIE_WAIT_ASSETS at origin/main's assets: 9/9 red (Chromium).
  Screenshots of each state looked at.
- GUI files around it (plugin-*, i18n-*, builtins, nav-sub*,
  click-scroll, old-webkit, mobile-web): 602/620 under load. The reds,
  rerun one file at a time here and on origin/main a751f5282: the same
  31 pass / 6 fail on both; the fails are plugin-other-ways, filed as
  #2590. i18n-keys' plugins/routing duplicates and the nav-sub-unroll /
  plugin-market timeouts passed on the one-at-a-time rerun.
- go test ./internal/gui: TestMainWindowCorners killed at 40s at load
  ~140-200 (#1936, sighting added); alone it passes here and on main.
- node --check on plugins.js and i18n.js.
Not tried: the real app on Linux WebKitGTK (CSS animation of
background-position and opacity only, no view transition).
2026-10-16 22:50:26 +08:00
yetone a751f5282e gateway: TestRequestBodyProgressRenewsIdleDeadline leaves a loaded runner ten gaps of room in its idle window (#2567)
The 408 on macOS CI (run 38888578439, 19e9fc47f) was the test's timing,
not the gateway's renewal. idleBody moves the read deadline forward on
every wire byte, but the test gave it a 200ms idle window and 50ms gaps
between writes. The client and the gateway share one process with the
whole package, so on a loaded runner one gap ran past 200ms: a real
200ms idle that the gateway was right to refuse. A real upload uses the
60s default window and is not at risk.

The window is now 1s with sixteen writes 100ms apart. The test also
fails if the whole upload finishes inside one idle window, since then
nothing was renewed. A failure prints the longest gap it saw.

Run:
- Old test with one 250ms client stall injected after the second write:
  408 on identity, gzip and zstd.
- New test as written: green (1.5-1.7s per encoding). With the same
  250ms stall injected: green.
- New test with idleBody's SetReadDeadline renewal disabled: red, 408 on
  all three encodings (longest gap ~104ms, window 1s).
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: clean.
- Full go test -timeout 45m ./... through suite-lock (base ef6d5ca40),
  run at load 227-239: 64 packages ok. Not green:
  - internal/agent timed out at 45m (#2544);
  - TestIntentClassifierFails' slow step took 2.49s (#1829);
  - internal/gateway timed out at 45m in TestGroupFailsOverASchemaTooDeep
    (#2108).
  This change touches only a gateway test file, so the agent reds can't
  come from it.
- internal/gateway run alone afterwards, at load 301-333: ok (1480s).
2026-10-16 22:07:41 +08:00
yetone a4fa7bbd8c gui: "Waiting for a request" is a core word, and app.js's comment no longer says "New group" (#2586)
i18n-keys' "a plugin's words are its own" was red on main 9b04c4e20:
- 9b04c4e20 (#2118) uses "Waiting for a request" in plugins.js, as a
  gateway hook's idle state. Its translation was only in the Routing
  plugin's i18n.js, so with Routing off it showed in English. It moves
  to the core i18n.js in all four languages, beside the hook's other
  states ("Context injected" and the rest). Routing's empty list reads
  it from there.
- 78827954f's comment at app.js:31 said "New group". The check matches
  substrings, so the comment reworded is enough.

Run: i18n-keys is red on 9b04c4e20 and green with this. group-found-off,
group-new-head, group-template, gui-zh-tw, gui-ja and gui-de all pass,
in both engines.
2026-10-16 21:59:34 +08:00
yetone 2c72563dd1 usage: Requests splits and filters by gateway key, with "No gateway key" for the calls none made (#2521)
MauriceCarlo asked for two things on Usage → Requests.

1. The gateway-key filter should show even when one key has calls. The
   picker hides itself under two options, and with one key it had one,
   so calls made with that key couldn't be told from calls made with no
   key. A "No gateway key" choice (callerKey=none) now sits beside the
   keys whenever the period has calls with no key, or it is the current
   pick. A single key's picker therefore shows and separates the two.
   The hidden condition itself is left to #2499, which another session
   has.
2. The trend chart and the ranking can split by gateway key. LED_SPLITS
   gains "Gateway key". It's offered only while the period has a key's
   calls, and it falls back to Model otherwise. A click on a rank row
   picks that key, or none, and a second click lets go, as the other
   splits do.

Server:
- usage.Dimensions gains "callerKey". A row's key is its CallerKeyID, or
  NoCallerKey ("none") when it has none, and the filter takes "none" as
  calls without a key.
- Filter.Without(d) is the one place that clears a dimension's own pick,
  so the by-split lists every value. RequestPage's fast and slow paths
  both use it now; they each had their own switch.
- usageapi names the split's shares from the key labels: "No gateway key"
  for none, the ID if a key was deleted.
- OwnPage keeps a held key's view to its own share in by and in the
  chart's split, so one key never learns another's name or numbers. The
  series was already only its own rows.
- docs/reference.md documents callerKey=none and by.callerKey.

"No gateway key" goes into the core i18n.js. The gateway keys page says
"No gateway keys yet", and i18n-keys' "a plugin's words are its own"
matches on substrings.

Tests:
- TestCallerKeySplitAndNone runs the fast and the slow path over {},
  one key, none, and none+an agent, and checks by.callerKey. Broken by
  hand, it goes red: once with the none clause in the filter removed, and
  once with Without's callerKey case removed.
- TestUsageOverGateway: on loopback the split names both keys. A held
  key's by.callerKey is only its own. With the OwnPage scrub skipped, it
  goes red (another key's name leaked).
- usage-ledger-key-split is new, in both engines, all five languages, and
  1400 and 760 px. It checks:
  - the picker's options with the none choice;
  - filtering on none;
  - the split's rows, and a click picking and letting go;
  - no sideways scroll;
  - that a period with no key's calls shows neither the picker nor the
    pill.
  32/32 pass. With the none option removed by hand, 11 go red.

Run on origin/main d9b943555 (head 663db0ecf), with the #2517,
#2521 and #2522 changes, load ~240:
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: ok.
- go test -timeout 120m -count=1 ./... (pipefail): exit 0, every package
  ok (gateway 1416.8s, agent 1535.5s). Before the rebase, on 63be47717:
  - The 45m run had agent and gateway past 45m (#2544, #2108).
  - TestMainWindowCorners was killed at its deadline (#1936).
  - TestSkillRelinkKeepsUnreadableCopy failed (#2555; it passes alone).
  - gateway alone with 120m was ok.
- GUI, the 41 Requests/Usage files in serial, both engines, before the
  rebase: 493 pass, 3 fail. The 3 were usage-refresh "not yet 2 !== 1",
  the same on 63be47717 alone (1 of 3); seen again on #2184.
- Rebased, these all pass, 102/102: i18n-keys, usage-ledger-ttft,
  usage-ledger-key-split, usage-ledger, usage-speed, usage-ledger-detail,
  gui-ja, gui-de and gui-zh-tw.
- Rebased again onto 9b04c4e20, which touches ledger.go, request_page.go
  and gateway.go:
  - vet ×3: ok.
  - internal/usage, internal/usageapi and internal/cli: ok.
  - internal/gateway -run 'NativeCompaction|UsageOverGateway|Capped|Cap':
    ok.
  - usage-ledger-ttft, usage-ledger-key-split, usage-ledger and
    usage-speed: 86 pass. i18n-keys was red from main's own words (#2586,
    fixed in the next commit).
2026-10-16 21:59:33 +08:00
yetone dc1a9cde27 gui: Usage → Requests lists the first token's time in a column of its own (#2522)
tianxia3111 asked to compare time to first token down the request list
(首字时间). Until now it showed only inside a row's details and the
Duration tooltip. A "TTFT" column (zh 首响, zh-TW 首響, the word the
row details and Routing already use) now sits before Duration. Its
header tooltip reads "Time to first token". A row told from a session
file's times gets "≈", like Duration does. A row with none (not
streamed, or failed before a token) shows a faint dash, not 0 ms.

Narrow windows: ledFit used to have two stages, tight (Sent, Effort,
cache) and tighter (the price reference, shorter names). The new column
pushed the reporter-sized 975px window of #860 into tighter, so the
price reference went. A stage between them, tight2, now hides only the
TTFT column (LED_COLS opt level 2 → .lc-opt2). The hint then says the
first token is in each row's details too.

"TTFT" and "Time to first token" go into the core i18n.js, not the
plugin's. Other code says those words too, and i18n-keys' "a plugin's
words are its own" would fail otherwise.

Tests:
- usage-ledger-ttft is new: the header and its tooltip, the value and the
  dash, the ≈, and the column leaving at a narrow width with the hint. It
  runs in both engines and all five languages, 12/12.
- usage-ledger's column lists and usage-speed's narrow hint are updated,
  and usage-ledger-detail finds Duration by its class.
- The staged tree alone (index checked out): i18n-keys, usage-ledger-ttft,
  usage-ledger, usage-speed and usage-ledger-detail all pass, 61/61.

Run on origin/main d9b943555 (head 663db0ecf), with the #2517,
#2521 and #2522 changes, load ~240:
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: ok.
- go test -timeout 120m -count=1 ./... (pipefail): exit 0, every package
  ok (gateway 1416.8s, agent 1535.5s). Before the rebase, on 63be47717:
  - The 45m run had agent and gateway past 45m (#2544, #2108).
  - TestMainWindowCorners was killed at its deadline (#1936).
  - TestSkillRelinkKeepsUnreadableCopy failed (#2555; it passes alone).
  - gateway alone with 120m was ok.
- GUI, the 41 Requests/Usage files in serial, both engines, before the
  rebase: 493 pass, 3 fail. The 3 were usage-refresh "not yet 2 !== 1",
  the same on 63be47717 alone (1 of 3); seen again on #2184.
- Rebased, these all pass, 102/102: i18n-keys, usage-ledger-ttft,
  usage-ledger-key-split, usage-ledger, usage-speed, usage-ledger-detail,
  gui-ja, gui-de and gui-zh-tw.
- Rebased again onto 9b04c4e20, which touches ledger.go, request_page.go
  and gateway.go:
  - vet ×3: ok.
  - internal/usage, internal/usageapi and internal/cli: ok.
  - internal/gateway -run 'NativeCompaction|UsageOverGateway|Capped|Cap':
    ok.
  - usage-ledger-ttft, usage-ledger-key-split, usage-ledger and
    usage-speed: 86 pass. i18n-keys was red from main's own words (#2586,
    fixed in the next commit).
2026-10-16 21:59:33 +08:00
yetone 440f66701f gateway: a 429 for native compaction's one account says the compaction pinned it, not that every account is capped (#2517)
When a conversation was compacted natively, only the key or account that
sealed the compaction can read it (#1099), so checkpointReaders keeps the
candidates to that one. When that account was at its usage cap, the 429
and the call record said "every account that serves X is held at the
usage cap", although the other accounts were never candidates. That sent
lm0711 looking at routing modes, which can't change it.

checkpointHeld tells this case apart: the plan held only the sealer's
account(s), and others were left out for the checkpoint. The error then
names the account and its window, says the compaction it sealed is what
keeps the conversation there, that routing mode and stays don't change
that, and to raise the cap / spend credits or start a new conversation.
The record reads "native compaction's account at its usage cap" (or its
credits / both variants). cappedError and cappedRecord are unchanged for
every other 429; their text is split into heldReasons and heldAdvice so
both share it. docs/subsystems/gateway-routing.md says so.

Test: TestNativeCompactionWriterAtItsCap seals a checkpoint on one
account, caps it, and checks the 429 body and the record. Broken by hand
(checkpointHeld returning nil), it fails with the old "every account"
text.

Run on origin/main d9b943555 (head 663db0ecf), with the #2517,
#2521 and #2522 changes, load ~240:
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: ok.
- go test -timeout 120m -count=1 ./... (pipefail): exit 0, every package
  ok (gateway 1416.8s, agent 1535.5s). Before the rebase, on 63be47717:
  - The 45m run had agent and gateway past 45m (#2544, #2108).
  - TestMainWindowCorners was killed at its deadline (#1936).
  - TestSkillRelinkKeepsUnreadableCopy failed (#2555; it passes alone).
  - gateway alone with 120m was ok.
- GUI, the 41 Requests/Usage files in serial, both engines, before the
  rebase: 493 pass, 3 fail. The 3 were usage-refresh "not yet 2 !== 1",
  the same on 63be47717 alone (1 of 3); seen again on #2184.
- Rebased, these all pass, 102/102: i18n-keys, usage-ledger-ttft,
  usage-ledger-key-split, usage-ledger, usage-speed, usage-ledger-detail,
  gui-ja, gui-de and gui-zh-tw.
- Rebased again onto 9b04c4e20, which touches ledger.go, request_page.go
  and gateway.go:
  - vet ×3: ok.
  - internal/usage, internal/usageapi and internal/cli: ok.
  - internal/gateway -run 'NativeCompaction|UsageOverGateway|Capped|Cap':
    ok.
  - usage-ledger-ttft, usage-ledger-key-split, usage-ledger and
    usage-speed: 86 pass. i18n-keys was red from main's own words (#2586,
    fixed in the next commit).
2026-10-16 21:59:32 +08:00
yetone 61ca3924cb library: a pasted "npx skills add owner/repo --skill x" reads as its repo
The skills page's add field now takes the command a skills page offers
to copy (npx, bunx, pnpx, pnpm or yarn dlx, bun x, with -y, --skill and
--agent flags) and installs from the repository it names (RockyShowlle
on X). Anything else is used as typed.

Run at base 78827954f with both changes:
- Full suite: go test -p 2 -tags nogui -count=1 -timeout 45m ./... ok in 66 packages, no FAIL.
- gofmt -l is clean, and go vet passes for GOOS=linux and GOOS=windows.
- Broken by hand: with the change disabled, TestPastedRepoBindsSameCopy and TestSkillsCommand are red. Restored, they are green.
- Not tried: a real npx skills install, or a real repo paste in the GUI.
2026-10-16 21:46:44 +08:00
yetone 83f3316cfe library: a pasted repo binds a skill copy identical to its own, so it updates
When a skill in the library is a copy whose every file matches the
repository the user pastes, it is now bound to that repository, as if it
had been installed from there. Before, it was only grouped under the repo
and never updated (RockyShowlle on X). A copy that is linked from
elsewhere (npx skills, a git checkout) or that was edited stays grouped
only.

Run at base 78827954f with both changes:
- Full suite: go test -p 2 -tags nogui -count=1 -timeout 45m ./... ok in 66 packages, no FAIL.
- gofmt -l is clean, and go vet passes for GOOS=linux and GOOS=windows.
- Broken by hand: with the change disabled, TestPastedRepoBindsSameCopy and TestSkillsCommand are red. Restored, they are green.
- Not tried: a real npx skills install, or a real repo paste in the GUI.
2026-10-16 21:46:43 +08:00
yetoneandTsukikage7 9b04c4e20f plugin: async gateway request hooks, run in Bun before routing and after the reply (#2118)
A package's magpie.hooks entry (or a *.hooks.{js,mjs,ts,mts} file) exports
`async onRequest(body, ctx)` and an optional `onResponse(reply, ctx)`. They
run in the Bun plugin host, so a hook can await I/O, for example a context
service like PowerContext, which the sync moejs middleware can't. The
gateway still makes one model request per client request. A hook adds
context to the body; it doesn't register tools or run a loop, so magpie
doesn't become an agent runtime.

Ported from Tsukikage7/magpie#1. Changes from the fork:
- The entry name is magpie.hooks / *.hooks.*. The fork's magpie.gateway /
  *.gateway.mjs is already the middleware's alias, so a hook importing
  node:fs was also loaded as moejs middleware and failed there.
  TestGatewayHookNamesApartFromMiddleware fails if the two sets overlap.
- onRequest is rolled back, and counts as failed with no onResponse, when
  it throws, times out, returns non-JSON, or changes tools, tool_choice,
  function_call, functions, toolConfig, model or stream.
- onResponse gets the client-facing reply, merged through the gateway's own
  stream decoder, collector and renderer (no second merger).
- Codex's native passthrough (/backend-api/codex) runs the hooks too,
  without the sync middleware.
- The run ends with the request handler, not the client connection. Codex
  hangs up on response.completed, and the reply it got is still captured
  as a success. TestGatewayHookSeesReplyAfterClientHangsUp is red on the
  old `r.Context().Err()` check and green with -count=3.
- ctx.origin is host-derived (local / gateway-key / remote). Headers, keys
  and peer addresses never reach the hook.
- Plugins page: a hook package shows a "Request hook" chip, a diagnostics
  line (outcome code, calls, avg ms, bytes, failures; no content), and
  Options. Strings are in en, zh, zh-TW, ja and de.

Docs: docs/subsystems/gateway-request-hooks.md (new), provider-plugins.md,
gateway-middleware.md, and site docs plugins.html in en, zh and ja.

Real use, sandbox HOME on 127.0.0.1:3486 with the owner's real Codex Pro
sign-in. The probe hook adds a codename note and logs both callbacks:
- /v1/responses, /v1/messages, Gemini generateContent: stream and
  non-stream. onRequest's note reached the model (the answer had the
  codename), and onResponse got success=true and the whole reply.
- /v1/chat/completions: with the probe also changing `model`, the change
  was rolled back (the reply came from the asked model) and no onResponse
  ran. Without that change, earlier: stream and non-stream success.
- The real Codex CLI 0.162.1 `codex exec` through openai_base_url ->
  /backend-api/codex: the hook saw origin=local, agent=codex and the
  query; the answer had the codename; onResponse success=true (before the
  hang-up fix it never ran: the context was already cancelled).
- `magpie plugin list` shows only "async gateway hook onRequest" for the
  hook package, no failed middleware.

Tests (base origin/main 63be47717, macbook at load avg 220-340 from other
sessions' suites):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean. go build and GOOS=linux -tags nogui
  build: ok.
- go test ./... -timeout 45m: every package ok except:
  - agent, gateway and library timed out at 45m under the load;
  - gui's TestSetAnswersWhileDevinAndProvidersHang (#1375, also red on a
    clean 63be47717 run alone; commented there);
  - library's TestSkillRelinkKeepsUnreadableCopy, which passes -count=2 alone.
  Rerun at -timeout 150m: agent ok (4524s), library ok (2581s). gateway was
  ok except TestVisionWaitIsntTheDescribersTime's 300ms limit (#2444,
  commented), which passes -count=5 alone on this tree and on 63be47717.
- internal/plugin and internal/gateway hook tests: ok.
- GUI (chromium+webkit; en, zh, zh-TW, ja, de): plugin-gateway 12/12 twice.
  It failed earlier at load ~340, chromium only, on page.goto's 5s (#2542).
  All 43 plugin-*.test.cjs files and mobile-web are green except:
  - plugin-move: red on a clean 63be47717 too (#2399, commented);
  - plugin-moved-signin: one 5s waitFor under load, then 6/6 twice.

Rebased onto ea3dee96a (21 commits; main touched host.go, host.js, i18n.js and
the plugin docs; clean rebase), then rerun at the rebased head:
- gofmt, vet (darwin, linux nogui, windows) and build: clean.
- go test: plugin ok, cli ok, gateway -run 'Hook|Middleware|Codex|Plugin' ok.
  gui ok except TestMainWindowCorners, which was killed under load (#1936)
  and passes alone.
- GUI: plugin-gateway 12/12, plugin-middleware 24/24, plugin-tools 22/22,
  plugin-agent 22/22.
- Real account with the rebased binary: every protocol and the real Codex
  CLI gave the same results as above (codename answered, success=true,
  chat's model change rolled back).

Co-authored-by: Tsukikage7 <65526564+Tsukikage7@users.noreply.github.com>
2026-10-16 20:48:51 +08:00
yetone 78827954fb routing: with routing groups off, the Routing page says so and turns them on (bigbenniu on X)
bigbenniu on X: on a new install the Routing page had nothing past its
requests, no New group and no word of where it had gone. A new install's
Essentials preset leaves the "groups" built-in off, and everything marked
data-feature="groups" was hidden without a trace.

Now an element can be marked data-feature-off="<id>", the other way
round: featureStyle shows it only while that feature is off. Where the
routing groups were, the Routing page shows such a note: routing groups
are off in Plugins › Built-in, the groups magpie finds still route, your
own can't be made or changed here; and a "Turn on routing groups" button
that posts plugins/builtin {id:"groups",on:true}, applies the answer and
reloads the groups. It sits after the groups' own rows, so their order
(group-found-off's check) is as it was. Strings in zh, zh-TW, ja and de.

Run:
- internal/gui/tests/routing-groups-off.test.cjs (new), Chromium and
  WebKit, en and zh, 900 and 420px: groups off shows the note and its
  button, New group and the groups hidden, the note fits the window;
  the click posts {id:"groups",on:true}, the note goes, the groups and
  New group come back, the status says so; groups on shows no note;
  every new string in zh, zh-TW, ja and de. 18/18 with group-found-off.
  Red by hand two ways: without the note's data-feature-off (6 of 7
  red in Chromium), and without featureStyle's data-feature-off rule
  (6 of 7 red). Screenshots looked at, zh 900 and 420.
- 119 GUI files (routing*, group*, panel-routing*, builtins, *-off*):
  all pass but routing-bodies (10) and routing-keys-fold (5), which
  fail the same 15 on a fresh origin/main ea3dee96a run alone: #2559
  and #1612.
- go test -tags nogui ./internal/gui ok. No Go file changed.
Not tried in the real Wails window.
2026-10-16 20:42:04 +08:00
yetone ea3dee96a8 gateway: a URL magpie didn't choose is downloaded from public addresses only, wherever the request came from
5241de909 held an image URL a caller names to public addresses. This
carries the same guarantee to every URL magpie downloads that isn't its
own fixed vendor endpoint, and drops where the request came from as a
reason to reach a private address.

What is downloaded through the one restricted client now (every resolved
address checked and pinned, the dialled address checked again, each of up
to 5 redirects checked the same; loopback, RFC 1918, fc00::/7, link-local
with metadata, CGNAT, multicast, unspecified, documentation/reserved,
IPv4-mapped, NAT64/6to4/Teredo forms all refused):
- a caller's reference image (fetchPicture, draw.go), as before;
- web_fetch's page (search_fetch.go), as before;
- an image a vendor answers by URL, downloaded for a b64_json caller
  (draw.go) - was the gateway's unrestricted client;
- /v1/videos/{id}/content's video URL from the vendor's status
  (video.go) - was the gateway's unrestricted client;
- generate_image's own download of the gateway's image URL
  (internal/imagemcp) - was http.DefaultClient.
A vendor's answer can be steered by what the model is asked to do, so
its URLs are treated as a caller's.

Policy: a request from this computer gets nothing more. The exemption for
a loopback request that wasn't from a web page or through a forwarding
header (withPrivateFetch/privateFetchAllowed) is gone: a reverse proxy or
relay on the same host makes every request it carries arrive that way.
Two explicit allowances remain:
- settings.json "fetchPrivate" (settings.FetchPrivate): names, name:port,
  IPs and CIDR ranges the user lets magpie download from. None by
  default, no Settings page, per-machine (KeepOwn, kept across a GUI
  save). A settings.json that can't be read lets nothing extra in.
- for a vendor's URL only, the host:port of that provider's own
  configured endpoints (a LAN or local provider serving its own images).
The refusal says to send the image itself or name the host in
fetchPrivate. A vendor image that can't be downloaded is still answered
by its URL; a video is a 502.

Audited and left alone: kiro, codex_search, codex_backend and the
catalog/provider http.DefaultClient uses (fixed vendor endpoints);
remoteVideoURL (p.Do to the provider); the MCP proxy and mcpauth (URLs
the user configured); community plugins (only fixed vendor endpoints,
nothing a request names).

Docs: docs/subsystems/gateway-routing.md (the guard paragraph, web_fetch,
test command), docs/subsystems/sync-backup.md (FetchPrivate stays on
each computer).

Tests (new or rewritten): TestEditImageURLFromThisComputer (loopback,
[::1], and loopback with X-Forwarded-For as a same-host reverse proxy:
400 naming fetchPrivate, the private server never asked; with
fetchPrivate ["127.0.0.1"] it is fetched, a non-image still refused),
TestFetchPrivateEntries, TestVendorImageURLAtPrivateAddressNotFetched
(127.0.0.1, a name resolving to it, ::ffff:127.0.0.1; the vendor's own
host:port still fetched), TestVideoContentAtPrivateAddressNotFetched,
imagemcp TestVendorImageAtPrivateAddressNotFetched. gui's
TestSettingsSaveKeepsWhatItDoesNotSend sets FetchPrivate. The two imagemcp
download tests and TestImageByURLIsFetchedForB64Caller now name their
local file server in fetchPrivate / resolve files.test to a public
address.

Broken by hand, each red, restored:
- draw.go inline fetch on s.client -> TestVendorImageURLAtPrivateAddressNotFetched red
- video.go on s.client -> TestVideoContentAtPrivateAddressNotFetched red
- imagemcp on http.DefaultClient -> its TestVendorImageAtPrivateAddressNotFetched red
- fetchPicture unrestricted (the old local bypass) -> TestEditImageURLFromThisComputer red
- fetchPrivate ignored -> TestEditImageURLFromThisComputer, TestFetchPrivateEntries red
Not distinguished: settings.Load in place of LoadChecked passes too (an
unparsable file with no last good generation gives no list either way).
Not tried: a real reverse proxy (nginx/caddy) in front of a running
magpie; the X-Forwarded-For loopback request stands in for it. Not tried
against a real vendor's image or video URL.

gofmt -l clean; go vet -tags nogui darwin, GOOS=linux, GOOS=windows clean.
Full suite: go test -tags nogui -timeout 45m ./... at 8b84dc902 plus this
change: every package ok except agent and gateway (timed out at 45m at
load average ~370, no test failed before the timeout) and gui
(TestSettingsSaveKeepsWhatItDoesNotSend, fixed here by adding
FetchPrivate; TestSetAnswersWhileDevinAndProvidersHang 12.4s under load,
(4726s) with -timeout 150m at load ~220.

Rebased onto ba132d68b (17 commits; only the doc test line conflicted).
At the rebased head: gofmt clean, vet darwin/linux/windows clean, and
the Image/Draw/Video/Fetch/Edit/Private/Public tests in gateway, imagemcp,
gui and settings ok.
2026-10-16 20:12:05 +08:00
yetone 7170b5d8bd usage: the plan credits a reply says it cost are summed by model, agent and session (#2512)
wwcraft_ on Discord asked for the WorkBuddy credits spent on the Usage
page, by model, agent and session. WorkBuddy's chat stream ends with
usage.credit, the per-request figure its own app shows as "Credits
Consumed". The built-in and the moved plugin both hand that chunk to the
gateway's chat decoder (the plugin's renamed()/kept() pass usage on as it
came), so cUsage reads `credit` into Usage.Credits and the three record
sites keep it on the row. A reply that says nothing has no credits, not 0.

- usage: Record.Credits; Totals/Via sum Credits and count Credited; the
  packed row keeps it under its own flag bit (4096, in TestRowFlagsApart);
  the ledger CSV gains a trailing "credits" column.
- GUI: the Usage ranking's line says "0.7 credits" (积分, 積分,
  クレジット, Credits) beside the cost, its title how many requests said
  it; the Sessions page's Routed line says it per route. TUI usage page
  and `magpie usage` tables say it muted on the same line. No new layout.

Real replies on workbuddy-ai, 10-16: gemini-3.5-flash "credit":0.01;
deepseek-v4.1-flash, minimax-m3, kimi-k2.6 "credit":0; glm-5.3-flash
refused (14003). The tests use those bytes.

Run (at b07b518e7 on origin/main 63be47717, with #2511's commit):
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean; go build: ok.
- go test -timeout 45m ./... with pipefail, sandbox HOME: 63 packages ok,
  usage (200s), cli, tui, gui among them; agent, gateway and library timed
  out at load ~270 (see the #2511 commit); library ok alone, agent and
  gateway ok with -timeout 150m: agent ok (5529s); gateway red only in TestIntentClassifierGroup (#1813), TestMaxRPMWaitsForRoomInTheMinute (#1791) and TestMaxRPMGroupPrefersMemberWithRoom (#2520), known timing reds under load, each passing alone here -count=3 (19s).
- New: TestPlanCreditsReachTheLedger (chat stream, whole reply,
  translated /v1/messages, free 0, none), TestPlanCreditsSummed,
  TestPlanCreditsPacked, TestFormatCredits, TestUsageSaysCredits, and
  plan-credits.test.cjs (en, zh, zh-TW, ja, de; Chromium and WebKit;
  420px fit) 12/12.
- Broken by hand: dropping Credits at the record site turns the gateway
  test red; skipping it in unpack turns the usage tests red; dropping the
  ranking's ledCredits turns plan-credits red in every language.
- GUI reds elsewhere: see the #2511 commit (#2536, #2552, a
  provider-detect-draft load timeout that passes 3/3 alone).
- Rebased onto origin/main ba132d68b (13 commits; chat.go, gateway.go, app.js, i18n.js among theirs): gofmt and go vet ./internal/... clean; Credits/DeepSeek/Balance/Ledger/RowFlags tests in usage, gateway, provider, cli, tui ok; plan-credits 12/12, balance-parts 4/4, i18n-keys 3/3 in both engines.
2026-10-16 20:11:34 +08:00
yetone 1bc61b66d7 provider: DeepSeek's balance says its granted and topped-up parts under the total (#2511)
wwcraft_ on Discord asked for DeepSeek's 赠金 apart from what was topped
up. /user/balance gives each currency's granted_balance and
topped_up_balance beside total_balance; the card's main figure stays the
total, and the two parts are told under it as secondary detail, the way a
balance's other parts already show (no new layout). The GUI's card and
menu bar panel, the TUI's quota page and `magpie quota` say them, labels
in every language (en, zh, zh-TW, ja, de). A reply without the parts, or one
with nothing granted, reads as before.

Real reply, read once from the owner's DeepSeek key on 10-16:
{"currency":"CNY","total_balance":"134.13","granted_balance":"34.14",
"topped_up_balance":"99.98"}. Fed through readDeepSeek/readDeepSeekSplit:
"¥134.13", Granted ¥34.14, Topped up ¥99.98.

Run (at b07b518e7, this commit plus #2512's on origin/main 63be47717):
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: clean; go build: ok.
- go test -timeout 45m ./... with pipefail, sandbox HOME: 63 packages ok,
  provider, tui, cli, gui and usage among them. agent, gateway and library
  hit the 45m timeout at machine load ~270 on 14 cores; the tests running
  at the panic were 1s-1m14s old (TestCodexLoginAPI,
  TestLoopGuardLeavesOrdinaryRepliesAlone, TestZedMCP), not a hang. Rerun
  alone: library ok (1295s); agent and gateway timed out at 45m again, and
  ok with -timeout 150m: agent ok (5529s); gateway red only in TestIntentClassifierGroup (#1813), TestMaxRPMWaitsForRoomInTheMinute (#1791) and TestMaxRPMGroupPrefersMemberWithRoom (#2520), known timing reds under load, each passing alone here -count=3 (19s).
- GUI, Chromium and WebKit: balance-parts (DeepSeek's parts, en and zh,
  panel too) 4/4. Every GUI file touching balances, usage, sessions or
  i18n (176 files, 4 at a time): red only in model-id-space (#2536),
  provider-advanced-fold (#2552) and one provider-detect-draft case.
  The first two fail on origin/main 63be47717 run alone. The third was
  page.goto's 5s load timeout in the parallel run; run alone it passes
  20/20 three times here and on main, and this diff doesn't touch the
  provider editor (app.js changes are the balance card and the Usage
  ranking only).
- Broken by hand: dropping readDeepSeekSplit from DeepSeek's source
  turns TestDeepSeekBalanceSplit red (gift's split = "").
- Rebased onto origin/main ba132d68b (13 commits; chat.go, gateway.go, app.js, i18n.js among theirs): gofmt and go vet ./internal/... clean; Credits/DeepSeek/Balance/Ledger/RowFlags tests in usage, gateway, provider, cli, tui ok; plan-credits 12/12, balance-parts 4/4, i18n-keys 3/3 in both engines.
2026-10-16 20:11:33 +08:00
yetone d9b943555d agent: a key of the gateway's own in place of magpie's still reaches magpie (#2510, PaulT on Discord)
PaulT made a key under Gateway keys and put it in Hermes's config.yaml
(providers.magpie.api_key) in place of `magpie`. Requests went through
magpie, but the picker said Hermes's api_key was changed and that
magpie's gateway won't take its requests.

The class: wiringOff, and the key checks of Codex
([model_providers.magpie] experimental_bearer_token), Qwen Code
(env.MAGPIE_API_KEY) and Reasonix (its env file), accepted only the exact
key magpie wrote. A sync also wrote `magpie` back over the user's key,
in mergeKept (every yamlKept/jsonKept agent) and in Reasonix's install.

keyHolds(v, want) is the one check now. Where want is a key magpie gives
for its gateway (gateway.Token, the LAN key, or a TokenFor), it takes any
v that access.Authenticate takes, the same test dsh has used since #1332.
It never stands in for a URL or another value. A key the gateway doesn't
take, or one turned off, is still drift and is still written over.

Run, at 8b84dc902 in its own worktree, with a sandbox HOME:
- TestHermesWithAGatewayKeyOfTheUsers: an issued key in Hermes's
  config.yaml is no drift and survives a sync. A key the gateway doesn't
  take is drift and is replaced by the sync.
- TestKeyHoldsTakesAGatewayKey: covers magpie's own key, TokenFor, a
  foreign key, an empty key, and a URL or mode value.
- Broken by hand: with keyHolds back to v == want, both tests are red
  ("a key the gateway issued is drift"). With mergeKept's keep removed,
  the sync test is red ("a sync wrote over the user's key: magpie").
- gofmt -l clean; go vet -tags nogui on darwin, linux and windows ok.
- go test -timeout 45m ./... (pipefail): every package ok except these:
  - internal/agent and internal/gateway ran out of the 45m budget twice.
    The load average was ~130-250, from other sessions on this machine.
    Each was then run in full in shards, every test from its own
    go test -list, each shard with its own 45m: agent 855 tests in 3
    shards, ok. gateway 2113 tests in 5 shards, ok.
  - internal/gui: TestPanelJoinsFullScreenSpaces, open as #2450 (macOS 26.2).
  - gateway's TestMaxRPMGroupPrefersMemberWithRoom: a 1s bar under load,
    open as #2520. It passed in the sharded run.
- Not tried: a real Hermes run. It re-bootstraps its launcher under a
  sandbox HERMES_HOME, so this was read from the config only.
2026-10-16 20:08:01 +08:00
yetone 9e5fd84bf6 gui: the tray panel's Hide accounts covers its model picker too (#2509, PaulT on Discord)
With Hide accounts on, the panel's agent model picker (Hermes Agent's,
CODEX group: "GPT-6-Astra via magpie <address>") showed the Codex
account's address. In the panel the mask covered #view-agents only, and
the picker (#pop), menus and dialogs sit outside it, at the body. The
panel now masks the whole body, as its comment already said. The window
masks Routing and Usage as before. Its picker names no account, so it
needs no change.

Every picker shares this one #pop and #list, so this covers every
agent's picker in the panel. The TUI has no Hide accounts setting.

Run, at 8b84dc902 in its own worktree:
- account-mask.test.cjs: a picker row holding an address, its text and
  its tooltip, is masked and comes back on unmask. chromium+webkit, en+zh:
  4/4 pass. With the app.js change reverted it is 4/4 red.
- Every GUI file that opens the panel or masks (226 files, 3441 tests,
  chromium+webkit, every language): 13 red under load (avg ~130-250).
  Rerun one file at a time, 4 files stay red, and they are red the same
  way on origin/main 63be47717: provider-advanced-fold (#2552),
  usage-fold (#2163), model-id-space (#2536) and rest-try-now (filed now
  as #2564). None of them uses the panel's mask.
- Go: gofmt -l clean; go vet -tags nogui on darwin, linux and windows ok.
  For the full go test -timeout 45m ./... run, see the next commit.
2026-10-16 20:08:00 +08:00
yetone f54e76dbdd gateway: a request builds the providers once, and plugin-auth.json and the discovery setting are parsed once a version (#2502)
XcodeFish (#2502): with several agents at once the gateway sat at
100-350% CPU. Counting provider.AllBuilt around one streamed chat
request gave 3 full catalogue builds per request, and each build re-read
and re-parsed plugin-auth.json and settings.json (AccountDiscoveryOff
called Load() on every provider list).

- holdCatalog wraps the gateway's handler in provider.Hold() and
  filememo.Hold(), so one request builds the providers once and stats
  each file at most once a second. Hold already drops the cache on
  provider.Changed and on magpie's own writes; another program's write
  is seen within the second.
- plugin-auth.json is read through filememo (mtime, size, and the raw
  bytes while the file is under 2s old), so it is parsed once per
  version. A file that doesn't parse falls back to the last good .bak
  through lastgood, as settings does. Auths still hands each caller its
  own decoded map. The host looks at the file again before it reports a
  sign-in it just saved.
- AccountDiscoveryOff reads the setting through filememo with the same
  parse settings.Load uses (now settings.parse), under fileMu.

What was run:
- TestRequestBuildsProvidersOnce: two streamed requests, one build each
  (3 each before). Red with holdCatalog taken out.
- TestAuthParsedOncePerVersion: 100 rounds of Auths, SignedIn and the
  listing proxies parse plugin-auth.json zero more times; a caller's
  edit doesn't leak; a same-size rewrite is read; a zeroed file reads
  the .bak and stays signed in. Red with authRaw reading past filememo.
- TestAccountDiscoveryOffParsedOnce: 100 calls, no parse; a Save is
  read. Red with AccountDiscoveryOff back on Load().
- gofmt -l clean; go vet -tags nogui on darwin, linux and windows ok.
- Full suite, set -o pipefail; go test -p 4 -timeout 45m ./... at this
  pair rebased on 63be47717, machine load average 170-330 from other
  work: 63 packages ok; internal/agent and internal/gateway ran out of
  45m (#2544, #2191, #2108); internal/gui TestMainWindowCorners killed
  at its 40s deadline (#1936). Run alone afterwards, gateway and agent
  ran out of 45m again, and gateway's
  TestQuietCodexStreamKeptAliveThroughReplyWriters/a_middleware got its
  reply unchanged once, the middleware failing open on its time limit
  (filed #2565; 6/6 alone on 63be47717 and here).
- The same two packages on 63be47717 alone, side by side with this
  head under the same load: both ran out of 45m there too, in other
  tests, so the timeouts are not this change.

Not tried: a benchmark against a real many-agent load, or the
reporter's machine. The count of builds per request is the measure.
2026-10-16 20:05:11 +08:00
yetoneandXYenon 75245b73c1 gui: a plugin's page in the desktop window names wails:// in its policy, so its bridge loads (#2501)
XYenon (#2501): on macOS the Plugins page stops answering after 10s. A
plugin page is served in a frame with sandbox="allow-scripts", and its
CSP named its own folder as a scheme-less source (localhost/p/<tok>/).
Under wails://, WebKit doesn't match a scheme-less host source, so the
page's bridge.js was refused and the page never said it was ready.

ownWindow now records the scheme of the native handler's base URL
(wails on macOS and Linux, http on Windows, as Wails v3 beta.24's
assetserver_<os>.go sets them) in the request's context, and pagePolicy
writes that scheme in front of the page's own source. Web requests have
no scheme in the context, so the browser GUI keeps its relative source
and still works over HTTP, HTTPS and reverse proxies.

The patch and its test are the reporter's. The test now uses Wails' real
hosts (wails://localhost, or http://wails.localhost on Windows), not a
made-up one.

What was run:
- A WKWebView harness (Swift, a WKURLSchemeHandler for wails://) loading
  a page in a sandbox="allow-scripts" frame with the old and new CSP:
  with localhost/p/T/ the handler is never asked for bridge.js; with
  wails://localhost/p/T/ it is. At top level, with no frame, both load.
- TestPluginPageWindowPolicy fails on the old pagePolicy (bridge.js
  refused for the desktop case) and passes now.
- gofmt -l clean; go vet -tags nogui on darwin, linux and windows ok.
- Full suite, set -o pipefail; go test -p 4 -timeout 45m ./... at this
  pair rebased on 63be47717, machine load average 170-330 from other
  work: 63 packages ok; internal/agent and internal/gateway ran out of
  45m (#2544, #2191, #2108); internal/gui TestMainWindowCorners killed
  at its 40s deadline (#1936). Run alone afterwards, gateway and agent
  ran out of 45m again, and gateway's
  TestQuietCodexStreamKeptAliveThroughReplyWriters/a_middleware got its
  reply unchanged once, the middleware failing open on its time limit
  (filed #2565; 6/6 alone on 63be47717 and here).
- The same two packages on 63be47717 alone, side by side with this
  head under the same load: both ran out of 45m there too, in other
  tests, so the timeouts are not this change.

Not tried: the real desktop app with an installed plugin page, and
WebView2 on Windows or WebKitGTK on Linux. The Windows source is an
explicit http:// one, which WebView2 matches as before.

Co-authored-by: XYenon <20698483+XYenon@users.noreply.github.com>
2026-10-16 20:05:11 +08:00
yetone fa5295d011 panel: a Manual routing group's model is switched from the tray panel (#2489)
Jerell.OvO asked on Discord (#general) to change a Manual group's model
from the tray's dropdown. Until now that worked only on the group's card
on the Routing page or with `magpie group pick <id> <model>`.

- provider.PickGroup(id, pick) sets a Manual group's Pick and nothing
  else. It refuses a group that doesn't route by hand, a model not in
  the group, and an unknown or hidden group.
- POST /api/groups/pick {id, pick} calls it and answers with the groups'
  state. The panel doesn't send the whole group back the way the card's
  save does, so a stale panel copy can't overwrite an edit made on the
  Routing page in the meantime.
- Tray panel, Routing tab: under today's totals, one row per Manual group
  of two or more members that is on. The row has the group's name and its
  picked member as a sess-pick button. The button opens the app's menu
  (openProtoMenu, no native select), headed "Model every request goes
  to". It lists the members with the card's notes ("fast", the provider,
  and "no provider serves it now" for one not ready), and the picked
  member is ticked. Picking the ticked one posts nothing. No new layout,
  no left border.
- The tab reads the groups again when it is shown, and loadGroups redraws
  the panel. A pick made on the Routing page or from the CLI shows here.
- New string in zh, zh-TW, ja, de.

Tests:
- TestPickGroup (provider): switches and routes to the new member, keeps
  the rest of the group, refuses the three cases and changes nothing
  then. Red with the `g.Pick = pick` line removed.
- TestGroupsPick (gui): /api/groups/pick answers with picked = the new
  member and refuses a non-member.
- panel-routing-pick.test.cjs: a 440px panel in Chromium and WebKit, in
  en, zh, zh-TW, ja and de. 10/10 pass. Red with the row left out of
  renderPanel. Screenshots were checked in de (web) and zh-TW and en
  (app).
- gofmt -l clean; go vet -tags nogui for darwin, linux and windows: clean.
- GUI subset (panel-*, routing-*, i18n-*, header-relang,
  agent-notice-lang; 1199 cases) on 63be47717+this: 1175 pass. Each red
  was rerun file by file on this head and on a clean 63be47717 worktree.
  routing-bodies (10, also red alone on main): #2559. routing-keys-fold:
  #1612. routing-model-rest: #2115. routing-request-metrics (webkit):
  #2571. Those three are red the same on 63be47717. routing-effort-change,
  routing-flood and routing-wb-restricted pass alone on both. None of
  these open the tray panel, and the new code runs only there.

Full suite: `go test -timeout 45m ./...` under set -o pipefail with a
sandbox HOME, on 63be47717+this, load 250-300: 63 packages ok. Red:
internal/agent past 45m (#2544), internal/gateway past 45m (#2108),
TestAgentGoneInTheRetryPause/group_replan (#2543), TestIntentClassifierGroup
(#1813), TestMainWindowCorners (#1936). Each named test passes alone on
this head. A rerun of agent, gateway and gui timed out again in agent and
gateway, with TestMainWindowCorners again the only gui red. The earlier
TestPanelJoinsFullScreenSpaces red is gone after 63be47717. Rebased onto
b2764f7f9, which has six later commits that touch none of these files.
The targeted tests above were rerun there.

Rebased again onto ba132d68b (seven later commits, none touching these
files; one changes app.js). Rerun there: TestPickGroup, TestGroupsPick,
panel-routing-pick.test.cjs 10/10, gofmt -l clean.
2026-10-16 20:03:29 +08:00
yetone ba132d68b6 plugin: the GitHub plugin list reads every page of the search, not the top 50 (@HoGee_xxl on X)
@HoGee_xxl on X: the Plugins page's GitHub list showed 50 repositories
while the opencode-plugin topic held 59. askTagged asked GitHub's search
for one page of 50 and stopped, so every repository past the 50th by
stars never showed. It now reads pages of 100 until a short page or
total_count, up to the 1000 GitHub's search answers, and a repository
that moves between two pages (starred in between) is listed once.

Run:
- TestTaggedReposEveryPage (new): a fake search of 7 repositories served
  2 a page; all 7 listed, in order, once. Red with the page loop broken by
  hand (stop after page 1): only the first 2 listed.
- Full suite at 63be47717 plus this change, `go test -p 2 -tags nogui
  -count=1 -timeout 45m ./...` (load average 230-270): 63 packages ok;
  internal/agent and internal/gateway timed out at 45m with no test
  failed; internal/gui's TestSetAnswersWhileDevinAndProvidersHang red
  under load (a set took 22s), the open #1375 - output and cause
  commented there. internal/gui and internal/plugin then run alone:
  both ok (343s, 416s).
- gofmt -l empty; GOOS=linux and GOOS=windows go vet -tags nogui ./...
  exit 0.
Not tried against the real GitHub API in the app.
2026-10-16 19:43:37 +08:00
yetone 53009f81a4 provider: every mover's min is the plugin that closes its gap with the built-in
Moved users are kept on these versions by keepMovedCurrent, each on npm
(npm view --prefer-online):
- devin 0.1.20: JSON output when asked; tool result images on the tool message
- commandcode 0.1.13: Credits reset at the subscription's end (#2454)
- cursor 0.2.18: a failed tool result read as isError; keychain backoff
- zed 0.1.8: "No plan" for a free account
- zcode 0.1.19: personal and team resets; Start Plan hint
- kiro 0.1.12: JSON output (output_config.format)

Run at 63be47717 with this batch: go test -tags nogui ./... -count=1 -timeout 90m, 66 packages ok, no FAIL (load ~250). gofmt -l clean; GOOS=linux and GOOS=windows go vet of provider, gateway and plugin pass. (devin's min rose after the run: go test ./internal/provider -run 'Mover|Moved' ok.)
2026-10-16 19:38:06 +08:00
yetone 5b6fe16975 provider: a plugin sign-in whose page can't post back takes a pasted key (#2468)
Command Code's plugin sign-in opens Studio, which posts its key to
127.0.0.1; in Docker or on another machine nothing comes back. The sign-in
now asks for the key in place (PasteKey with the keys page), and a pasted
key is saved as the plugin's own api account (plugin.APIKey). An address
or a key with spaces is refused and the sign-in keeps waiting. The GUI
offers no second "Use an API key instead" beside it.

TestPluginSignInTakesAPastedKey and signin-paste-plugin.test.cjs
(chromium, webkit; en, zh: 8 pass) go red without it; the four sign-in
GUI files together pass 22.

Run at 63be47717 with this batch: go test -tags nogui ./... -count=1 -timeout 90m, 66 packages ok, no FAIL (load ~250). gofmt -l clean; GOOS=linux and GOOS=windows go vet of provider, gateway and plugin pass.
2026-10-16 19:38:05 +08:00