Commit Graph
73 Commits
Author SHA1 Message Date
ggbdpq a5ccf3f23f plugins: an update of an unfixed git source re-resolves the branch, not the lock's old commit (#2954)
What changed
- Before Bun resolves a git plugin's spec, the branches and tags of its
  repository are fetched into the bare clone Bun keeps in its install
  cache (refreshGitCache in gitrev.go): best-effort before install's
  bun add (a remote that can't be reached leaves the install to what the
  cache has), an error before reinstall's bun update (an update that
  didn't happen is not reported as done).
- When bun update exits 0 but the plugin is still behind the commit the
  update checks saw the repository at, reinstall says so instead of
  claiming the update.
- A spec that names a commit (#<sha>) is left alone: nothing is resolved
  for one, and its pin stands.
- docs/subsystems/provider-plugins.md: this git update path.

Why
A plugin added from an unfixed git+https://... URL could not be updated
(#2954): plugins/package.json named no commit, but Bun resolves a git
spec through its own bare clone of the repository in the install cache,
whose refs stay at the first install - a fetch there moves FETCH_HEAD,
not the clone's refs/heads. Every resolve after the first, bun update as
much as a bun add after a remove, therefore named the old commit again,
bun.lock re-recorded it (name@git+...#bb961b2...), and the update said it
had installed while node_modules kept 0.1.3. The lock is the record of
that resolution, not its cause. Verified with Bun 1.4.2 (the version
magpie runs) against a local git+file:// repository: after the branch
moved, bun update my-plugin answered "no changes" and exited 0, and so
did bun install with the lock entry dropped, bun update --force and bun
install --force; with the clone's refs fetched, the same bun update
installed the branch's commit now.

Run
go test ./internal/plugin/ -count=1 (ok; new: TestGitUpdateInstallsTheBran
chsCommitNow and TestGitUpdateKeepsACommitPin on the bun on PATH against
a local git+file:// repository, TestGitUpdateSaysWhenItDidnt with the
fake bun keeping the lock's commit, TestRefFixed,
TestSameRepoAndCloneOrigin)
go test ./internal/cli/ ./internal/provider/ -count=1 (ok)
gofmt -l (clean); go vet ./internal/plugin/ on darwin, linux and windows
(ok); builds of darwin and of windows (CGO_ENABLED=0 -tags production,
as the Makefile cross-compiles it) and of the 79 Linux packages that
don't need Linux GTK cgo (the GUI and cli are built natively per machine,
as the Makefile says).

Review (magpie): patch sha256 checked against the issue; read whole.
Run at the batch head on the Mac mini: go test ./internal/plugin
-count=1 ok, the real-Bun git e2e among them (not skipped); on the
Windows box TestGitUpdate* pass. Broken by hand: store.go at the base -
TestGitUpdateInstallsTheBranchsCommitNow ("still at 1.0.0, want
2.0.0") and TestGitUpdateSaysWhenItDidnt red; only install()'s refresh
removed - "installed again: 2.0.0, want 3.0.0". Not tried: a real
plugin from a real GitHub branch.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-31 02:00:10 +08:00
yetone f115122626 plugins: an Anthropic model under a loader base without /v1 goes to its /v1 (Copilot's Claude 404)
cyoking1 on X (tweet 2116084357731701020): every Claude model through
the GitHub Copilot plugin answered 404. pluginFetch took the loader's
baseURL first, and Copilot's loader says https://api.githubcopilot.com
for every model, while its Claude models are @ai-sdk/anthropic rows
whose own api.url is https://api.githubcopilot.com/v1 (models.dev).
magpie's /v1 is taken off the path, so the request went to
https://api.githubcopilot.com/messages.

pluginRequestBase now sends an Anthropic model whose own URL ends in
/v1 under the loader's base + /v1 when that base doesn't end in it,
as OpenCode's own Copilot provider does (packages/core/src/plugin/
provider/github-copilot.ts: `${loaded.baseURL}/v1` for messages
models). That covers every plugin, and Copilot Enterprise's
copilot-api.<host>. Unchanged: a base already ending in /v1 (zcode,
minimax, commandcode, zed), a model whose own URL has no /v1 (Kiro's
BASE), and every non-Anthropic model (Copilot's GPT on its bare base).
Every @ai-sdk/anthropic api.url in models.dev ends in /v1.

Run:
- Real account (owner's Copilot sign-in, token from the OAuth refresh):
  POST api.githubcopilot.com/messages claude-sonnet-5 -> 404
  "404 page not found"; /v1/messages -> 200 with a reply.
- TestPluginAnthropicBaseKeepsV1 (new): green; broken by hand (the
  /v1 append commented out) it is red on the copilot, trailing-slash
  and enterprise cases.
- mote: go test -count=1 ./internal/provider ./internal/plugin ok;
  go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./... clean; go build, GOOS=linux -tags nogui and GOOS=windows
  builds ok; gofmt -l empty.
- Full suite (-timeout 45m) started on mote at this head; pushed
  before it ends per the ship-at-once rule; reds get their own issues.

Not tried: a whole magpie gateway with the Copilot plugin signed in
end to end; the fix was checked at the base it computes and the real
endpoint by hand.
2026-10-30 16:59:04 +08:00
JoeyWu-tech 497100488a provider, library: a .git is a repository only when git takes it for one (#3675)
TestPluginToldWhereTheAgentWorks was red on any machine with an empty
.git above its temp folder. GitOnDisk took the first .git it met going
up as a repository, and on this box /tmp/.git is an empty folder (owned
by nobody), so every folder under /tmp read "yes". git passes such a
folder over and goes on up: git rev-parse under it says "not a git
repository".

GitOnDisk now reads each .git on the way as git's own search does
(repo_discovery_find_dir in git 2.56's setup.c), through GitAt:
- A folder counts when git takes it for a repository (is_git_directory):
  a HEAD git takes (a link into refs/, "ref: refs/...", or a commit's
  id), and objects and refs folders, in the folder its commondir names
  for a linked worktree. Any other folder, an empty one say, is passed
  over and the walk goes on up.
- A file counts when it is "gitdir: <folder>" naming such a folder,
  relative to the .git's own folder (a linked worktree's, a
  submodule's). Any other file, one over git's 1 MB, or one that is
  neither file nor folder is "no": git stops there with "not a git
  repository" (a worktree whose repository has gone) or "invalid
  gitfile format". (git 2.34 passed a .git that is neither file nor
  folder over; 2.55 and 2.56, CI's, stop at it.)
- A .git it can't read is unknown, and the header is left off. git
  passes such a folder over and stops at such a file, but either way
  it can't tell an empty .git from a repository it isn't let into
  (another user's, through a shared magpie), and a failed read is
  unknown here.
A bare repository kept as a folder's .git (git init --bare .git) is
still "yes": git finds one there, though no work tree. Not mirrored:
the filesystem boundary, GIT_CEILING_DIRECTORIES and safe.directory's
ownership check. Cost: the same one stat per folder on the way up; at
a .git, a read of HEAD (255 bytes at most) and stats of commondir,
objects and refs.

What a user sees: a request to a plugin provider from an agent that
doesn't say whether its folder is a repository (Codex, Pi) was told
"yes" for a project under a stray empty .git, under a worktree whose
repository was deleted, or under a .git file that names nothing. The
community ZCode plugin then tells the model "- <git label>: yes" and
Command Code's sends isGitRepo: true, so the model may run git commands
that fail with "not a git repository". They are now told "no", and
with a .git on the way magpie can't read, nothing (ZCode's plugin
leaves the line out, Command Code's sends false). Claude Code's and
OpenCode's requests say it themselves and are passed on as they say it,
so nothing changes for them; Claude Code 2.1.310's own check takes any
.git, an empty one too.

The only caller of GitOnDisk is tellWorkPlace (workdir.go), which needs
no change. The library's skill groups had the same first-.git walk:
gitRepoOf took the first .git within four folders of a linked skill for
its checkout, so an empty one between a skill and its clone left the
skill in no group, and gave one imported from there no From. gitRepoOf
now asks provider.GitAt, passes such a .git over to the clone's, and
reads the origin from the folder GitAt names (a linked worktree's
common one), which replaces gitdirConfig. gitdirConfig also took
"gitdir:" with no space after it, or with spaces around the line,
which git doesn't take; such a .git now traces to nothing, as git finds
nothing there. Checkouts git made are traced as before; the test's
fake ones had only a config and now have a HEAD, objects and refs.
Every other .git folder in the Go code is one a walk skips when it
copies, hashes or checks a skill (carry.go, skillcheck.go, skills.go,
skill_edits.go), or the one magpie removes from its own fetch of a
skill (skillgit.go), not a decision about a repository. The Claude
bridge's claudeWorkDir takes the temp folder for one in no repository;
Claude Code decides that for itself, and its git status is off for
every run (CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS), so it stays.

TestPluginToldWhereTheAgentWorks gets a real repository for "in a
repository" (HEAD, objects, refs; an empty .git was all it had) and a
case under an empty .git in its own temp folder, so it fails without
this on any machine. Its "not in one" cases, and the new provider
tests' "no" ones, still need no repository above the temp folder, as
the test did before. TestGitOnDiskIsWhatGitFinds lays out each kind of
.git by hand; TestGitOnDiskAgreesWithGit asks git rev-parse
--git-common-dir in each of those folders and in ones git made (init,
worktree add, a worktree whose record was removed, --separate-git-dir,
init --bare .git), for yes or no and where;
TestGitOnDiskUnreadIsUnknown locks a .git folder and a worktree's .git
file. provider-plugins.md and library.md say the same.

What was run (tree 9a4504d9, on origin/main 56602426, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077, git 2.34.1, with
the box's empty /tmp/.git above the tests' temp folders:
- TestPluginToldWhereTheAgentWorks -count=5, Bun 1.4.2: 5 of 5 ok.
  TestGitOnDisk* and TestSkillRepo*, -count=3: 15 of 15 ok. The same
  and TestPluginToldWhereTheAgentWorks, -race -count=2: 12 of 12, no
  race. internal/library and internal/provider whole: ok.
- 56602426's workplace.go and skill_from.go put back under the new
  tests: TestPluginToldWhereTheAgentWorks red 5 of 5, at
  plugin_workdir_test.go:125 both "not in one" and "not in one, under
  an empty .git": the plugin was told git "yes", want "no";
  TestSkillRepoTraced red, "write-a-prd: repo "", want
  "mattpocock/skills"".
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag
  on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log
  kept; 8m37s, load 32 at its start): 73 packages ok, and 14 tests red
  in 4 packages, none of them this commit's tests or what they cover.
  internal/gateway ran to its end (504s), so
  TestPluginToldWhereTheAgentWorks passed in it; internal/library and
  internal/provider ok. The reds: agent TestCodexDriftReached and
  TestCodexBehindReverseProxy (#3398); TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141);
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641: go build's own VCS
  stamping meets the same /tmp/.git, which this doesn't change); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask
  077, #3640); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

This commit is 595b361c rebased: the same internal/ patch-id, and
the same row in docs/subsystems/library.md, put in by git's 3-way
merge, as main's 33ccc618 (#2794) rewrote the Skills row, a line of its
context three rows above. The rest is what was run for 595b361c, at
tree d56bed31 on origin/main 098ac969, the same code (not this tree):
- main's GitOnDisk and gitRepoOf under the new tests (098ac969's
  workplace.go and skill_from.go put back):
  TestPluginToldWhereTheAgentWorks -count=5, Bun 1.4.2: red 5 of 5,
  "not in one" and "not in one, under an empty .git" told git "yes".
  With TMPDIR=/var/tmp/3675-clean, no .git above it: red 5 of 5 on the
  new case alone. TestSkillRepoTraced: red, write-a-prd: repo "", want
  "mattpocock/skills".
- Broken by hand, one at a time in workplace.go, each red in the
  GitOnDisk tests on what it breaks, and green again restored:
    any .git folder taken, main's rule for folders: "yes" under an
      empty .git, a zeroed HEAD and a HEAD alone, and for a locked .git
    a gitfile naming no repository, or not a gitfile, walked past:
      "yes" from the repository above it
    HEAD's content not read: "yes" for the zeroed HEAD; objects and
      refs not looked for: "yes" for a HEAD alone
    a HEAD at a commit not taken, or commondir not read: "no" for both
      linked worktrees; a worktree's own folder named, not its common
      one: the repository at .../worktrees/wt where git finds .../.git
    a HEAD linked into refs/ refused: "no"; a relative gitdir read
      from magpie's folder: "no" for the submodule; no 1 MB cap: "yes"
    ENOTDIR taken for a failed read: unknown for a gitfile naming a
      file; a .git it can't read walked past: "no" for both locked ones

Not tried: CI's git 2.55.0 (ubuntu) and 2.56.0 (macOS, Windows) under
TestGitOnDiskAgreesWithGit, which met git 2.34.1 alone; macOS and
Windows at all (Windows CI only compiles the tests); a real ZCode or
Command Code plugin end to end; a shared magpie told another user's
folder; the Library page itself.

Landed by yetone in a batch of Coffemon's patches from the issues.
What was run, go1.26.8, on origin/main cc81ad4ea, then again at
70a0c387c (gofmt, the three vets, the changed tests, umask 077):
- mote (macOS 27): gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet ./...: ok. edit and testenv at umask
  077; agent, provider, library and gateway with an empty .git above
  TMPDIR; davsync, imagemcp, plugin, library, edit, testenv whole; the
  changed tests in agent, provider, gateway and gui; the timing tests
  -count=10 (gateway, davsync, imagemcp) and -count=5 (agent): all ok.
  TestCoreScriptBudget ok: core 1,536,751 of 1,537,034, app.js
  1,312,975 of 1,315,316, no budget raised.
- Red on the old code: on origin/main, TestWriteAtomicReadOnlyHardLink
  at umask 077 and two Reasonix tests under an empty .git; on Linux
  (wsl-run) TestProgram at umask 077 with the old program.go. With
  each fix's code taken back to main's, the Gemini imageConfig tests,
  TestPluginToldWhereTheAgentWorks, TestSkillRepoTraced,
  TestTaggedHooksAlone, TestMainURL/TestMainView and update-auto,
  plugin-github-hooks, plugins-more-discover, plugin-namesake were
  red. Broken by hand: claudeKeyed always true (both
  OwnEndpointNeverAsked tests red), claudeAsk a no-op
  (TestClaudeFirstWriteAsksTheProxy red), GitAt taking any .git folder
  (the three TestGitOnDisk tests red).
- GUI: 123 files (plugins*, update-*, panel/tray/start/context, i18n,
  gui-zh-tw/ja/de and every file that evals app.js parts) in WebKit on
  Linux (wsl-run). 11 files had reds (click-scroll, panel-fold,
  plugin-card-update, plugin-github, plugin-move*, segs-glide,
  tray-totals, update-*), and run again side by side they fail the
  same on origin/main d80d75f30 (79 pass, 26 fail here; 78 and 27
  there). They are click-scroll guards ("the click must not scroll
  the page"), varying by language from run to run (#4385).
  copilot-ghe's route-after-close red is #1949, seen on main 244d80e23
  too. In Chromium on mote, Chromium segfaulted partway through files
  (#4125): context-map, context-scroll-end and context-tune fail the
  same on origin/main 0911a65e7, so the batch's own files
  (plugin-namesake, update-auto, plugins-more-discover,
  plugin-github-hooks) ran in Chromium on Linux: 62 of 62.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., mote)
  at 472a0608f (on 70a0c387c): every package ok but internal/gateway,
  whose five reds were #4362's (Antigravity turned-away and
  TestCodexSpentGrokFailingIsTold), fixed on main in d80d75f30. After
  the rebase on 244d80e23 the five pass, and gofmt, the three vets
  and the targeted runs above were run again: ok. In Linux the
  sign-in, copilot, plugin-github*, plugins-more-discover,
  plugin-namesake, plugin-gateway, update-auto, quota-refresh-order
  and i18n files ran in both engines: 475 pass, 4 fail (copilot-ghe
  #1949, plugin-github's click scroll, both red on main too).
- Rebased again on c7171a256, over its budget fix e94bf7a08: gofmt, vet of
  gui, gateway, provider and plugin, TestCoreScriptBudget (core
  1,536,265 of 1,536,586 with the batch's last commit, statusTErr and settingsErr), the Gemini,
  GitOnDisk and plugin tests, and in Linux both engines i18n-keys,
  update-mirror, plugin-namesake, plugins-more-discover,
  plugin-github-hooks and update-auto (138 of 138): ok.
Not tried: the whole GUI suite (mote's WebKit wouldn't launch and its
Chromium segfaulted, #4125); macOS WebKit; the real app's window.
2026-10-30 15:53:22 +08:00
yetone f11bf27c1f video: a plugin's model that gives video makes videos through its fetch on the account
XYenon asked for video for account-backed plugins: customVideomakers
left out every provider with an Account. A plugin's model that says it
gives video (capabilities.output.video / modalities.output) is now a
video maker (the Grok plugin keeps its own). Start, poll and content go
OpenAI-shaped to <base>/videos, /videos/{id} and /videos/{id}/content
through the plugin's fetch (videoBase now takes Provider.OpenAIBase,
the Chat base for any other provider). The video's id names the account
that started it (keyMark: "a" + signer), and markedKey asks after it on
that account of the plugin's (AlsoOn), as a key provider's videos are
asked on their key. Account and model holds (videoAsker,
videoModelHeld) and the start's usage row are the existing paths'.

Test: TestPluginMakesVideos (fake $FAKE_VIDEO, two accounts): started
by a key held to the second account, polled and fetched on it, a key
held to the first gets 403 on the poll, a key held to other models 403
on the start and the poll; the start is in the ledger. Broken by hand:
with the old video.go the video makers are empty (red); without the
account mark the poll goes to the first account and the content is
refused 403 (red).

Run on mote: gofmt -l clean; go vet ./internal/gateway ./internal/provider
./internal/plugin for darwin, linux (-tags nogui) and windows; go test
-count=1 -timeout 45m ./internal/gateway ./internal/plugin
./internal/provider ok at the tree of the video commit (7b8456f88), the three plugin-media commits
rebased on abd94e0b1 (gateway 504s, plugin 265s, provider 95s).
Not tried: a real Veo account through a plugin; no plugin serves
/videos yet.
2026-10-29 22:54:06 +08:00
yetone 6cb73ec4f0 gateway: embeddings and speech reach a plugin through its fetch whatever API its chat is on
XYenon asked how /v1/embeddings and /v1/audio/speech reach a plugin
whose models are all on Gemini's API. serveRetrieval sent them under
the provider's Chat base, which a plugin has only with an
@ai-sdk/openai-compatible model, so such a plugin was turned away 400
"has no OpenAI-style API". Provider.OpenAIBase is plugin://<id>/v1 for
a plugin (the Chat base for any other provider), and serveRetrieval
(embeddings, rerank, speech, transcriptions, translations) sends under
it: the request reaches the plugin's fetch OpenAI-shaped at
<base>/embeddings or /audio/speech, with the model's own id, for the
plugin to put in its vendor's shape. magpie converts none of them to
Gemini's embedContent or TTS; the plugin owns its vendor's protocol.
Key holds, account holds, masking and usage are serveRetrieval's, as
before.

Test: TestGooglePluginTakesEmbeddingsAndSpeech (fake $FAKE_GOOGLE: every
model on @ai-sdk/google, with $FAKE_KINDS' embedding and TTS): both
reach the vendor through the fetch, both are in the usage ledger, a
key held to other models gets 403 on each. Broken by hand: with the
old Base(provider.Chat) it is red (400 "has no OpenAI-style API").

Run on mote: gofmt -l clean; go vet ./internal/gateway ./internal/provider
./internal/plugin for darwin, linux (-tags nogui) and windows; go test
-count=1 -timeout 45m ./internal/gateway ./internal/plugin
./internal/provider ok at the tree of the video commit (7b8456f88), the three plugin-media commits
rebased on abd94e0b1 (gateway 504s, plugin 265s, provider 95s).
Not tried: a real Google AI Studio account through XYenon's plugin.
2026-10-29 22:54:06 +08:00
yetone e2b7233499 draw: a plugin's Gemini image model draws on generateContent through its fetch
XYenon (magpie-google-ai-studio, Discord) asked how a plugin's image
models reach /v1/images/generations and /v1/images/edits. A plugin's
model on Gemini's API (@ai-sdk/google) that says it gives images
(capabilities.output.image / modalities.output), or is named for them,
is now a drawer: Drawers lists it, and draw sends it to drawCodeAssist
(pluginDrawsGemini), as a Google sign-in's image models are drawn. That
asks generateContent with responseModalities ["TEXT","IMAGE"] through
the plugin's fetch, an edit's pictures as inlineData, and reads the
pictures from the answer. Request.draws asks for the IMAGE modality of
a model not named for images. Imagen (catalog.ImagesAPI, :predict) is
left out. The OpenAI-compatible plugin path (SenseNova) is unchanged.

Test: TestGeminiPluginDraws (fake plugin $FAKE_GEMINI_DRAWS: a model
named for images, one that only says it gives them, an Imagen).
Broken by hand: with the old draw.go the drawers are empty (red); with
the old codeassist.go the declared-only model is sent no
responseModalities (red).

Run on mote: gofmt -l clean; go vet ./internal/gateway ./internal/provider
./internal/plugin for darwin, linux (-tags nogui) and windows; go test
-count=1 -timeout 45m ./internal/gateway ./internal/plugin
./internal/provider ok at this commit on its first base 172e65c80
(gateway 515s, plugin 104s, provider 104s), and ok again with the next
two commits on top, rebased on abd94e0b1 (tree 7b8456f88: gateway 504s,
plugin 265s, provider 95s; vet for the three systems there too).
Not tried: a real Google AI Studio account through XYenon's plugin.
2026-10-29 22:54:06 +08:00
yetoneandggbdpq 8c63c5b787 provider, plugin: a plugin model that says it gives no text leaves the chat lists (#3279)
A plugin provider's list counted every model it named as a chat model.
XYenon's Google AI Studio plugin put gemini-embedding-001 and its TTS
models in the chat chips, the agents' lists and /v1/models. The plugin
does declare them: the embedding's capabilities.output is
{"text": false} and the TTS's says audio only. But the host's kinds()
kept only the true keys. That made "said it gives nothing" look the same
as "said nothing", and pluginCatalog never read Outputs.

- host.js passes outputsSaid, which is whether capabilities.output says
  yes or no to any kind (kindsSaid). It goes into plugin.Model.OutputsSaid.
- pluginCatalog leaves out a model whose outputs were declared and name
  no text, image or video (pluginTalks). Every chat list is built from
  that list: /v1/models, provider.Catalog (the agents' lists and routing),
  and Available (the editor's chips).
- A plugin that says nothing about outputs keeps every model, whatever
  the id. Image-only and video-only models stay where they are; #2792
  decides where they go.

Ported from ggbdpq's hunt65-c-3279-kinds (7391b0df2), with changes
after review. That patch found the right place (pluginCatalog) and
wrote the provider tests kept here. It judged an embedding by "embed" in
its id, because the host drops the declaration. So an embedding named
otherwise (bge-m3, text:false) stayed in the list. A plugin that says
nothing about outputs lost any model whose id held "embed" or "-tts",
which changes today's behaviour. An image-only model (outputs ["image"])
was dropped, though the patch said it left #2792's models alone. This
version fixes the declaration in the host instead and guesses nothing
from ids. catalog.textModel is unchanged.

Docs: docs/subsystems/provider-plugins.md, "A model that gives no text".

Run (mote, at base 96a703a59; then rebased onto 9f25de56c, which
changed only two mover mins, and ./internal/provider plus the e2e test
run again there: ok):
- TestPluginModelGivingNoTextLeavesTheChatLists (gateway, a real Bun
  host with the fake plugin under FAKE_KINDS, using XYenon's literal
  capabilities) is red on main: the embedding and the TTS are in
  /v1/models, the agents' catalog and Available. It is green with this
  change.
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway: ok (plugin 165s, provider
  121s, gateway 759s).
- GOOS=linux and GOOS=windows go vet of the three packages: clean.
  gofmt -l: clean.
Broken by hand:
- host.js without outputsSaid: the e2e test is red (embedding, bge-m3
  and TTS listed; rerun at this base).
- pluginTalks always true: the e2e test and both provider tests are red
  (rerun at this base: embedding, bge-m3 and TTS listed in each).
- ggbdpq's original product change with these tests: the e2e test is red
  on bge-m3. The unit test is red on bge-m3 kept, imagen-4 lost and
  embedder-chat lost.
Not tried: the reporter's real plugin with a Google AI Studio account.
The fixture is the plugin's parseModels output and the report's own
row. A TTS or embedding model still has no route of its own here.
Not run: the full ./... suite, and the GUI suite (no GUI file changed).

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-29 18:17:55 +08:00
yetone 046093bf7b gateway: a plugin's try with another candidate after it is told so, and gives way to a queue (#4049)
axuhere on X: on free models a request sat behind "模型请求正在排队 ·
预计等待超过 10 分钟" with other providers configured for the same
model, and asked for magpie to move on to the next provider and say why.

ba37e78b4 added provider.FallbackHeader and the host.js strip, and the
Qoder (0.2.40) and CodeArts (0.2.3) plugins answer a queued request at
once with a 503 + Retry-After and the queue's reason when they get it.
Only a model test sent it, so in a group or an account chain every
plugin still waited out its vendor's queue (Qoder up to 4 minutes,
CodeArts up to 5) while another candidate could answer.

- The try loop marks every try but the last (withFallback, from !last),
  and forwardOnce sets x-magpie-fallback: 1 on that plugin request. A
  header the agent sent under that name is dropped first.
- The plugin's 503 is busy, so the next candidate is asked and the
  trace's try says the queue (position, how many ahead). The last
  candidate is never told and waits as the vendor's client does.
- Qoder's mover min is already 0.2.48 on main, so no min change.

Run (mote-run, at this commit on origin/main 34b2dd9b7):
- New TestPluginToldAnotherFollows: a group of two fake-plugin members;
  the first is told and gives way with a 503 that names the queue, the
  second answers untold, a lone model is never told, the vendor never
  gets the header. With -run 'TestPluginToldAnotherFollows|
  TestPluginModelTest|TestPluginTold|TestMovedBuiltinsSayTheirPlugin'
  over internal/gateway, internal/provider and internal/plugin: ok.
- go vet (darwin, GOOS=linux, GOOS=windows) of internal/gateway,
  go build ./..., gofmt -l.

Broken by hand: without the gateway.go hunk, TestPluginToldAnotherFollows
fails with "the vendor saw [{path:/v1/chat/completions fallback:}]".

Not tried:
- A full ./... suite: mote was at load 380 with five other sessions'
  full suites running, so this was not added on top.
- A real Qoder or CodeArts queue through a group; the plugin side was
  tested in the plugins repo (bc25bc5, bace914), red on the old code.
- Trae's plugin doesn't give way: no real queued reply on its
  llm_utils_chat path has been captured.
- The screenshot's pill is Qoder.app's own client UI on Qoder's own
  models; magpie isn't on that path.
2026-10-29 15:19:30 +08:00
yetone e5e2aa58e5 routes: each provider's wallets go by what they have left in a group too (#4095)
mycf_711 (#4095, comment): SuperMagic's accounts asked directly went by
their points (6,636, 282, 119), but in group/deepseek-v4.1-flash1017
they went 282, 119, 6,635, the provider's listed order. A Smart group
weighs its members' accounts as one pool (planLevel → weigh over the
heads), and the pool held WorkBuddy's credits beside SuperMagic's
points: byLeft returned nil as soon as it saw two kinds of LeftIn, so
no balance ordered anyone. Each 400 「积分已不足」 was then met on the
small balances first.

byLeft now orders each kind (provider + unit) in the places its own
seats take: the told seats' places in the pool's order (Smart) or by
what magpie sent each lately (Pace, Least used, as their tie-break
after the balance), each kind's seats put into its places by what they
have left, and seats of two kinds keep that order between them. A seat
that told none still goes after those that did. It is one rank per
seat, so the comparators stay a consistent order; comparing two kinds
as a tie would not be. One kind alone orders exactly as before
(TestWalletsGoByWhatTheyHaveLeft unchanged).

Tests: TestWalletsOfSeveralProvidersEachGoByWhatTheyHaveLeft (routes:
Smart, Pace, Least used, the reporter's three behind a WorkBuddy seat,
two kinds interleaved, and Least used's token order between kinds) and
TestGroupWalletsGoByWhatTheyHaveLeft (gateway: weigh over a group's
pool with the reporter's balances, smart/pace/usage).
docs/subsystems/provider-plugins.md and gateway-routing.md say it.

Broken by hand: with the old strategies.go both tests are red (the
group keeps 632, 710, 051 under every routing).
Run on mote, at 157d575c3 with both #4095 commits on it (the pushed tree):
go test -count=1 -timeout 45m ./internal/gateway/... ./internal/routes/...
ok (gateway 781s, routes 0.4s); gofmt -l internal/gateway internal/routes
empty; GOOS=windows and GOOS=linux go vet ./internal/gateway/...
./internal/routes/... ok. The same was green at the earlier bases
40f206dff and 7a7931833. Pushed on 99299c7b1, whose commits since
157d575c3 change only internal/edit's tests; not run again there.
Not tried: a real group with SuperMagic and WorkBuddy accounts; the
affinity that keeps a conversation on a low wallet ("turn") is unchanged.
2026-10-29 01:14:42 +08:00
yetone 1319a44bbc docs: plugin guide says what four rules do when a plugin gets them wrong (plugins#468)
Guide (en, zh, ja) and provider-plugins.md:
- usage: leave used out rather than send 0; with amount/limit it is their
  share, with no count the window is text and routing doesn't read it;
  aside keeps a window out of routing whatever its count.
- sign-in: a model refused is 403/404, not 401; a 401 that says only
  that the model isn't served is read as kept.
- free comes only from the vendor's word; rate 0 is none given, never
  free (magpie infers nothing from rate).
- GitHub listing licence: from LICENSE as GitHub reads it, else
  package.json's license.

Docs only. Checked each claim against the source at this tree
(plugin_usage.go quotaOfPlugin, plugins.go modelOnly401, fallback.go
modelRefused, plugin/providers.go Model.Rate, models.go FreeModel,
github.go readTagged). Site deployed with wrangler and the pages read
back with curl.
2026-10-29 00:52:19 +08:00
yetone 602ad84adc plugin: the host is told the gateway's address (MAGPIE_ADDR), so a page's own service reaches it on any port
yuesh1_ on X (reply to 2115451149633626237) opened the community chat
page (Magiczerowxy/magpie-chat, @magpie-community/page-chat 0.1.16) and
got "127.0.0.1 拒绝了连接". That is Chromium's frame error: the plugin's
chat server on 127.0.0.1:3477 wasn't listening. Before v0.1.1905
(ca499953e) nothing started the host when the page opened (the WebKit
form of it is magpie-chat#2), so that symptom is most likely an older
magpie; it doesn't reproduce at main.

What does still fail at main is the next step. The chat server finds
the gateway from MAGPIE_ADDR, else http://127.0.0.1:3425, and magpie
never put MAGPIE_ADDR in the host's environment. With the gateway on
any other port (Settings, portable builds: magpie-chat#1) the page
opens with an empty model list and "Unable to connect".

hostEnv now sets MAGPIE_ADDR to hostAddr(): magpie's own MAGPIE_ADDR,
moved onto 127.0.0.1 when it listens on every interface, else Settings'
port on loopback (settings.SavedAddr). The running host records the
address it got, and proxyMoved replaces it once that differs, as it
already did for a moved proxy. plugin.Warm (called when a hosted page
opens) now goes through get() for a running host too, so opening the
page is the call that picks up a changed port.

Run:
- TestHostToldTheGatewayAddress (new): a probe plugin writes the
  MAGPIE_ADDR it was given. Settings port 3591 -> 127.0.0.1:3591; port
  moved to 3592, Warm -> 127.0.0.1:3592; MAGPIE_ADDR=0.0.0.0:4999 ->
  127.0.0.1:4999. Passes on mote and on Windows (win-run, -count=3).
- Broken by hand, each red: the old host.go ("with Settings' port 3591
  the plugin was told MAGPIE_ADDR=unset"); the addr check taken out of
  proxyMoved, and Warm's old Running() short cut, both ("after the port
  moved to 3592 ... told MAGPIE_ADDR=127.0.0.1:3591").
- Real use, sandbox HOME, real page-chat 0.1.16 from GitHub (7dbf8ff),
  gateway port set in Settings: at main its /api/bootstrap said
  gateway http://127.0.0.1:3425 with "Unable to connect" on mote and on
  Windows; with this change gateway http://127.0.0.1:3686 (mote) and
  :3591 (Windows), no error. Changing the page's options restarts the
  host and 3477 comes back, at main and here.
- gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...; go build for darwin, linux (nogui) and
  windows: all on mote.
- Full suite on mote: go test -tags nogui -timeout 45m ./... at base
  fc6f1d5e8, 77 packages ok, no FAIL. Rebased onto b69f8e96a (one
  usage commit), then go vet ./internal/... and internal/plugin,
  internal/usage and internal/gui again: ok. Pushed on 298bfce59, whose
  one line (Cursor's mover min in migrate_side.go) touches nothing here
  and wasn't run again with it.
- Windows, go test ./internal/plugin: TestPiPackage and
  TestLoadConcurrentWithSavesAndEdits red, both also red on origin/main
  b69f8e96a there (run alone, the latter 3 of 3); both are in #1827.

Not tried: a real WebView2 desktop window with the page open; the
reporter's magpie version is unknown, so their 拒绝 screen itself was
not reproduced.
2026-10-29 00:01:12 +08:00
yetone d4f1d6480c plugin: a program a plugin starts with no folder runs in plugin-work, not beside magpie's settings
jiakun_zhao on X asked whose page_<hash>.html, magpie_home.html,
magpie_install.sh and magpie_*.md files they had found after using the
chat page plugin (Magiczerowxy/magpie-chat). That plugin starts the
user's MCP servers from the plugin host with node:child_process spawn
and no cwd, and runs their tools for a model. The host runs in magpie's
config folder (~/.config/magpie), so every file such a tool saved by a
relative name went beside settings.json and providers.json, and a tool
told to write "providers.json" would have written over magpie's.

host.js's spawn wrapper (which already hands on the proxy and keeps
programs off the host's stdio) now starts a program that names no
folder of its own in <config>/plugin-work, created on first use, with
PWD to match outside Windows. A folder the plugin gives is kept.

Not the cause of files in the user's home folder: magpie's host never
runs in ~, and no magpie code names a file page_<hash>.html or calls a
user's MCP tool itself. Files in ~ come from a process whose folder was
~: the chat's server started by hand (node serve.mjs) from ~, or
another agent run there. Filed on magpie-chat for the plugin to give
its MCP servers a workspace of its own and tell the model where it is.

Run (mote, macOS):
- TestPluginProgramsRunInTheirOwnFolder (new; testdata/clicwd checks
  child_process spawn, spawn with env, execSync and Bun.spawn, plus an
  own cwd kept): ok. Red with origin/main's host.js put back by hand
  (plugin-work not made; programs ran in the config folder).
- go test ./internal/plugin ./internal/agentplug ./internal/pluginrt
  -count=1: ok (plugin 261s).
- go test ./internal/gateway -run Plugin -count=1 at 581d64b7d: ok.
- Windows (xiaomi-gpu, win-run): TestPluginProgramsRunInTheirOwnFolder,
  TestPluginCLIHasTheProxy, TestFakePlugin: ok.
- gofmt -l: clean.
Not tried: the full go test ./... suite, the real magpie-chat plugin
with a real MCP server and model, Linux.
2026-10-28 22:20:56 +08:00
yetone c48fccfad7 plugin: the dist index is read from GitHub beside jsDelivr's copy, so a plugin npm doesn't have is offered its newer version
star21321321124 on Discord: CodeArts 0.2.3 showed "已自动更新", the page said
every plugin was up to date, and Update did nothing, with 0.2.4 on the
plugins repo's dist branch. npm has neither CodeArts nor River (E404), so
npmAsk's version is the dist index's latest. With the 「国内镜像」 switch on,
index.json was read from jsDelivr first, and a 200 from it was final. A
jsDelivr edge serves the branch as it was when it cached it (s-maxage=43200):
on 10-28 gcore.jsdelivr.net served the index with codearts latest 0.2.3
(age 6631s) while raw.githubusercontent.com, cdn and fastly had 0.2.4. So
the hourly update, Check for updates and Update all saw 0.2.3.

readDistIndex now asks raw.githubusercontent.com beside the mirror (with
the switch on) and merges the two copies: every version either names,
each package's newer latest. Each version keeps the sha512 its own copy of
the branch names, which installDist checks the tarball against as before.
GitHub is waited for 5s (distGrace) past the mirror's answer; unreachable,
the mirror's copy is read alone, as before. Switch off: one read, as before.

River: on dist at 0.1.0 only, nothing newer; the test holds it "current".

Run (mote, at this tree rebased on f20118304):
- go test -tags nogui ./internal/plugin ./internal/source: ok
- go build ./...; go vet (darwin, linux, windows) of both packages: ok
- gofmt -l: clean
Broken by hand: the index read mirror-first again (the old rule) turns
TestDistOnlyPluginUpdatesPastAStaleMirror red in both subtests with
"Status:current Latest:0.2.3", what the user saw. The pure no-mirror case
(npm 404, dist 0.2.3/0.2.4, 0.2.3 installed) already passed on the old code.
Not run: full suite, GUI suite.
Not tried: a real magpie with the switch on against a stale edge (tests
can't reach the network); the stale gcore edge and fresh raw copy were
checked with curl only.
2026-10-28 13:55:16 +08:00
yetone 5ced5b1aa0 routing: a wallet's row says what of it lapses first, as the Usage card does (#3964)
MYCF711's SuperMagic plugin (magpie-magicrew-auth daca18e) sends a
balance window 积分余额 with runsOut, and 今日 / 限时 / 永久 as aside
rows. The Routing page already showed all four rows, in the stage row's
tooltip and the account list's .wins line, both through cardOf/winsOf
(the Usage page's own readings). The row's own text said only
"6,291 积分 left". For a wallet seat, quota() now adds the Usage card's
runsOutText for the card's window of the same balance and unit:
"6,291 积分 left · 185 积分 expire 23:59". It is client only. The
Go side (allowanceOf, Weighed) is unchanged, because the aside rows are
display only and routing weighs the total.

Run (mote, at 7b63feb90 + this):
- routing-wallet-lapse.test.cjs (new, the reporter's literal windows):
  chromium + webkit, en/zh/zh-TW/ja/de, 1100 and 420px, 22/22 ok.
- Broken by hand (quota without lapses): 11/11 red in chromium,
  expected '750 积分 left · 50 积分 expire Thu 02:06', actual
  '750 积分 left'.
- routing-wallet-balance, usage-wallet-balance, i18n-keys: ok.
- Every routing-*.test.cjs (124 files) + the two above: red only in 12
  files that are red the same way without this change at 4655e1659
  (83 fails there) and that have open issues: routing-intent-entry
  #3408, routing-manual #3409, routing-pause #3410, routing-rule-effort
  #3411, routing-steady #3412, routing-row-swap #3799, routing-model-rest
  #2115, routing-rule-drag #3789, routing-rule-remove #3094/#3096,
  routing-rules-line #3593, routing-story-shrinks #3954,
  routing-wb-restricted #1905. Mote was at load ~16-28 with another
  session's suites.
- go test -tags nogui ./internal/gui/ (budgets): ok.

Not run: the full Go suite and the whole GUI suite (another session's
were on mote; this commit touches no Go). Not tried: a real SuperMagic
account, or the Windows/Linux app.
2026-10-28 12:40:16 +08:00
yetone a05b373538 checkin: a plugin's until is when its answer stops holding (Qoder's 10:00 UTC+8)
sdytman on Discord: Qoder's daily credits start at 10:00, can the plugin's
check-in follow it? Qoder's /me/campaigns opens each day's CLAIM_BENEFIT
campaign at 10:00 and closes it at 09:59 the next day, UTC+8 (startAt and
endAt, read with a real account on 10-28; Qoder.app polls the list every 5
minutes). A check-in before 10:00 meets the day before's campaign. Since
#2696 the Qoder plugins are asked again every 30 minutes, so today's was
claimed somewhere between 10:00 and 10:30; a plain plugin was settled for
the Beijing day.

auth.checkin may now answer until (RFC 3339 or epoch ms); host.js passes
it as RFC 3339 (plugin.Checkin.Until), kept as ValidUntil. settled holds
an answer only until then, whatever its outcome; the loop wakes at it
instead of its next 30-minute look; an early done that carries it is not
provisional (#3326), as the vendor said when its day turns. Instants
throughout, so the machine's zone doesn't matter. The Qoder plugins send
until from 0.2.43 (plugins fd40b20): the check-in now lands at 10:01.

Run (mote): TestPluginCheckinAsksAgainAtUntil, minute by minute from
09:27 Beijing to the next day's 10:30, with time.Local UTC, UTC-8 and
Beijing: asks at 09:27, 10:01, 00:00 (the Beijing day), 10:01; a failure
in the 09:59 gap asked at 10:01:00 only. GOOS=linux and windows go vet;
go test -tags nogui -timeout 45m ./... all ok (76 packages). gofmt -l
clean.
Broken by hand, each red: settled ignoring ValidUntil (no 10:01 asks);
tick not waking at it (10:27 instead); provisional ignoring it (asked
every 30 minutes from 00:00 to 10:00); host.js dropping until (ValidUntil
zero).
Not tried: the Qoder plugin's recheck path with until (the fake plugin
is fakeco; the tick and settled it goes through are the same); a GUI
change (none: until isn't shown).
2026-10-28 09:51:43 +08:00
yetone 8bade6c5e2 provider: a plugin's usage window can be a prepaid wallet's balance (#3950)
SuperMagic's accounts (mycf_711's magicrew plugin) are prepaid wallets of
points with no total. A plugin can now send a usage window as
{name, balance: 6291, unit: "积分"} with no used or limit.

- host.js passes a finite balance on (at least 0), anything else as null.
  plugin.UsageWindow.Balance and provider.QuotaWindow.Balance are *float64.
- quotaOfPlugin keeps the figure and does not make the window Text or
  Aside, so routing knows the account with no Used invented. allowanceOf
  copies it into Limit.Balance; an empty wallet counts as used up.
  Allowance.Left(model) is the least balance of the windows that count
  the model.
- weighRouted fills routes.Seat.Left and Seat.LeftIn (the account's
  provider and unit). Smart, pace and usage (least used) put the seat
  with more left first where they would otherwise tie (byLeft), only
  when every seat with a balance shares one LeftIn: balances in two
  units or two providers are never compared. Tiers still come first.
- The Usage card, the Routing page (Weighed.Balance: the small row's
  text, no bar, a why sentence, the account list), magpie accounts and
  the status line show the figure, "6,291 积分 left", never a share.
- Docs: provider-plugins (new section), gateway-routing,
  providers-accounts, plugin-runtime, host.js typings and the site's
  plugins page (en, zh, ja).

Run, at base f13aafa87, on mote:
- go test -tags nogui -timeout 45m ./...: 72 packages ok; red were
  TestQuotaSpanCarriesEveryWindowField (this change's: its fixture now
  sets Balance, green after), and on the unchanged base too
  TestWSLColdPlaceOpensNothing (#3924), TestFetchAsksASharedBaseOnce and
  two siblings (#3854), TestTUIFetchesSubscriptionModels (#3919), all
  fixed on main since and run again after the rebase; and
  TestPluginStreamsPastTheBudgetWait (#3946), green alone on both.
- GOOS=linux and GOOS=windows go vet -tags nogui ./internal/..., go
  build ./..., gofmt -l: clean.
- New tests: TestPluginWalletBalanceIsAReading, TestAllowanceLeftIsTheLeastBalance,
  TestPluginHostPassesABalanceOn (through real Bun and host.js),
  TestWalletsGoByWhatTheyHaveLeft, TestWalletLeftWithinItsTier,
  TestWalletWithMoreLeftGoesFirst, TestQuotaCell's balance cases;
  usage-wallet-balance.test.cjs and routing-wallet-balance.test.cjs,
  34 of 34 in Chromium and WebKit, en zh zh-TW ja de, 1100/900/420/390px.
- GUI: every quota*, usage*, panel*, routing*, i18n* and tray* file (220
  files, 2928 tests), concurrency 4: 130 red, in 21 files. Those 21 files
  run again on an unchanged base copy and on this change, concurrency 2:
  the same 19 files red on both (126 and 131), the differing subtests
  being routing-rule-remove / rules-line / intent-entry flaps that go
  both ways. Each is filed (#3679, #2115, #3410, #3404, #3411, #3897,
  #1905, #3096, #3593, #3408, #3409, #3799, #3789, #3412, #3947, #3415,
  #3414, #1345); routing-story-shrinks had none and is #3954.

After rebasing on origin/main 833f51adc, on mote: Linux and Windows vet,
go build, gofmt clean; go test -tags nogui of internal/routes, provider,
gateway, cli, plugin, gui (the script budgets), agent and tui: all ok;
the two wallet GUI files and i18n-keys: 37 of 38, the red being
i18n-keys' "Runs as" (#3897, not this change).

Broken by hand, each red then restored: quotaReport's Balance copy
removed (TestQuotaSpanCarriesEveryWindowField red); byLeft always nil (routes and
gateway tests red); host.js's balance line removed (host test red);
quotaOfPlugin's balance copy removed (provider tests red); app.js and
client.js at base (both GUI files 34 of 34 red, "0% used" / "已用 0%").

Not tried: a real SuperMagic account or the magicrew plugin (it isn't
in the community repo; it needs to send balance), Windows and Linux
GUI apps, and the WebKitGTK app.
2026-10-28 08:28:56 +08:00
yetone 2b0387574e draw: an OpenAI-compatible plugin's image models draw (SenseNova's sensenova-u1.5-lite)
01huadalang (Discord, #feedback): SenseNova's sensenova-u1.5-lite can
draw, but magpie's image generation picker doesn't list it.
ab546a4ee (v0.1.1707) covered SenseNova added as a key provider. The
SenseNova plugin (aqiu817/magpie-sensenova, @ai-sdk/openai-compatible at
token.sensenova.cn/v1) lists the model from SenseNova's /models too, but
Drawers returned nothing for any plugin provider (p.Account != nil), so
neither the picker nor generate_image could reach it there.

- provider.PluginOpenAICompatible: the plugin speaks the model on
  @ai-sdk/openai-compatible.
- Drawers: a plugin provider's listed model that DrawsID and ImagesAPI
  and is spoken on openai-compatible is a drawer; drawImages sends it to
  /images/generations or /images/edits under the plugin's base, through
  its fetch (pluginFetch maps /v1/... onto the loader's base), in the
  shape ab546a4ee sends SenseNova (b64_json, JSON edits). An image model
  on another package (a vendor's own API) is not listed. Grok's and
  WorkBuddy's drawers are unchanged (checked before this branch).
- Fake plugin: $FAKE_SENSENOVA adds sensenova-u1.5-lite and a flux-2 on
  @ai-sdk/anthropic.
- docs/subsystems/provider-plugins.md says it.

Test: TestSenseNovaPluginDraws (internal/gateway) installs the fake
plugin as "sensenova" in a real Bun host in front of the fake SenseNova
of TestSenseNovaU1Draws: Drawers lists sensenova-u1.5-lite alone, a
generation and an edit come back through the plugin (b64, JSON images,
chat never asked). Broken by hand: without the plugin branch it is red
(drawers []); without the openai-compatible check it is red (drawers
[sensenova-u1.5-lite flux-2]).

Run at this head: gofmt -l, go vet, GOOS=windows go vet, GOOS=linux go
vet -tags nogui on internal/gateway and internal/provider (clean); go
test -tags nogui -timeout 45m ./internal/gateway ./internal/provider
./internal/plugin ./internal/catalog: gateway (716s), plugin, catalog
ok; provider crashes in TestUnreadLoginsWriteErrorsKeepCredentials
(#3632, open), and with it skipped fails TestFetchAsksASharedBaseOnce,
TestFetchAsksOneListOnceForTwoBasesOfIt and
TestFetchUnionsProtocolListsWithoutChat, red the same at the base
a47596ea6 without this change (#3854, open). Neither touched here.
After the rebase onto origin/main b103ed058: gofmt, vet (three OSes),
internal/gateway -run 'SenseNova|Draw|Image|Edit|GrokPlugin|Plugin',
internal/catalog, internal/provider -run Plugin: ok.

Not tried: a real SenseNova account or the real plugin (none here); the
images API shape is from SenseTime's launch post as ab546a4ee read it.
Not run: the full ./... suite and the GUI suite (no GUI file changed).

Reported by 01huadalang (Discord).
2026-10-27 23:45:57 +08:00
yetone 9bfe680481 plugin: a changed plugin option lists the providers again (plugins#430)
WorkBuddy's plugin 0.1.38 adds a "Free models only" switch (a plugin option)
that lists only WorkBuddy's free models and refuses any other before it is
sent. Its list goes by the switch, but SetProviderOptions only handed the
values over: the host cleared its infos while Go kept provCache, so the
Providers page and /v1/models showed the old list until something else
re-read it. SetProviderOptions now forgets the kept providers (whether the
host runs or not), so the next Cached() lists them again. Nothing else runs
on a change. The workbuddy mover's min is 0.1.38 (npm view --prefer-online
at landing: 0.1.38).

Run:
- go test ./internal/plugin ./internal/provider -count=1 -timeout 45m at
  this head (5a3292354 + this): internal/plugin ok (389s); internal/provider
  FAIL on TestUnreadLoginsWriteErrorsKeepCredentials, "close of synctest
  channel from outside bubble" in filememo.Forget, which is #3632 (open, on
  main since 091153bf, nothing here touches it). TestPluginOptions now lists
  a model only while its option is on, and only base-model after it is off.
- Rebased onto 3aead9c62 after the run; its new commits touch only
  internal/provider/codex_daemon*.go and codex_app_server_test.go. go vet
  ./internal/plugin ./internal/provider ok there; a rebuild to test again
  failed to link for a full disk (291MB free).
- gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/plugin
  ./internal/provider ok.
- Real accounts, sandbox HOME, dev build of this tree on 3516/3517 with the
  plugin added by path: POST /api/settings/plugin-option free_only on for
  workbuddy-ai took its list from 26 to 2 (hy3, deepseek-v4.1-flash) within
  2s with no restart; workbuddy kept 19. gpt-5.4 got the plugin's 404 and
  was not sent; hy3 and deepseek-v4.1-flash answered. Off: 26 again, and
  gpt-6-luna and gpt-5.4 answered.
Broken by hand: without forgetProviders in SetProviderOptions,
TestPluginOptions fails ("with beta on, optco lists "base-model"").
Not tried: the switch clicked in the GUI window (the API it calls was);
Windows and Linux apps.
2026-10-27 17:44:02 +08:00
JoeyWu-tech 6cb1cfb794 plugin: a lock behind package.json's dist tarball is mended, its tarballs kept (#3622)
Part 1 of 2, pruneDist (coffemon's first commit):

pruneDist took out every tarball in plugins/dist that
plugins/package.json doesn't name, as encoding/json reads it. Bun
installs a package from the tarball bun.lock's packages has it at, and
that can be one package.json has moved on from: gkd2323c's lock (#3622,
Windows, Bun 1.4.4) had autoclaw, codearts and cloudflare-workers-ai at
the tarballs before the ones package.json names, and those were gone
from plugins/dist, where nothing but pruneDist takes a file out. With
Bun's own copy of such a tarball, every bun command that changes
plugins/ puts the older version back; with none, every add and removal,
of any plugin, fails with "ENOENT extracting tarball from <that
package>" (part 2 has the likely why there was none).

Now a tarball the lock's packages has a package at stays, beside the
ones package.json names. Kept, it is what Bun installs: a package whose
lock is behind package.json stays at the older version without a word,
where 4e5b2ad8, once Bun had no copy, failed every command with ENOENT.
part 2 sends such a lock back to package.json before each bun
command when package.json has the package at a dist tarball too; with
package.json at npm it stays behind (#3720). package.json is read as
text, every dist/<file> in it counting, where encoding/json keeps one
value of a key named twice: Bun 1.4.0 adds a tarball's package a second
time instead of replacing it, the new tarball first, which Bun reads,
and encoding/json reads the second, so 4e5b2ad8 took out the tarball Bun
installs from. No magpie runs plugins on that Bun unless MAGPIE_BUN
names it (BunVersion has been 1.4.2 since 10-03, before plugins/dist
was), so that is how a decoded package.json loses it, not a path a user
is known to have taken. A tarball only the lock's workspaces names goes:
Bun 1.4.2 and 1.4.3 leave the one an add replaced there until their next
command, and nothing installs from it. With no bun.lock, package.json
alone decides, as before; with one that can't be read, nothing goes, as
with a package.json that can't be read.

This keeps the tarballs a lock has from going, and mends no lock: one
behind package.json's dist tarball, the reporter's or one that falls
behind later, is sent back by part 2, its tarball there or
gone.

What was run (tree 8f285445, on origin/main 4e5b2ad8, go1.26.8,
linux/amd64):
- TestDistTarballTheLockNamesStays (new): the reporter's package.json
  and lock, built around the lines #3622 quotes; the package.json real
  Bun 1.4.2 writes for `bun add ./dist/<0.2.6>` over 0.2.1, and the one
  Bun 1.4.0 writes (the package named twice), each with the lock both
  write, and the Bun 1.4.0 one with no lock; no lock; a lock that can't
  be read (a folder in its place). The tarballs the lock's packages or
  package.json name stay, the one only the lock's workspaces name goes,
  and one nothing names goes; with no lock package.json alone decides,
  and with an unreadable one nothing goes. With the change the TestDist
  tests are ok on each Bun. Broken by hand, each put back after, with
  Bun 1.4.2, 1.4.3 and 1.4.4 (outside graftcp, the proxy wrapper this
  box runs commands in, umask 077, logs kept):
  - 4e5b2ad8's pruneDist: the reporter's, both named-twice and the
    unreadable-lock cases red on each ("<tarball> taken out");
  - package.json decoded as 4e5b2ad8 did, the lock still read: the
    named-twice case with no lock red on each ("<0.2.6> taken out");
  - the whole lock read for tarballs instead of its packages: the
    workspaces case red on each ("0.2.1 kept"), and
    TestDistInstallsAPackageNPMDoesntHave red on 1.4.2 and 1.4.3
    (0.1.4's tarball stays after 0.1.3 is pinned: those two leave it in
    the workspaces).
- internal/plugin, -tags nogui, with Bun 1.4.4, the one magpie runs now:
  ok but TestPluginSOCKSProxy, red the same at origin/main 7a60e78c
  (#2207, open, filed for 1.4.3); TestFlowBigReplyProd and
  TestRenewOtherHost skip by their own condition.
- gofmt -l lists nothing; GOOS=linux, windows and darwin go vet -tags
  nogui ./..., GOOS=windows go vet ./..., GOOS=linux and darwin go build
  -tags nogui ./... and GOOS=windows go build ./...: exit 0 each. go vet
  and go build without the tag on linux: exit 1 (no GTK, WebKitGTK or
  fontconfig headers on this box).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
  (systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
  45m, log kept): 64 ok, internal/plugin among them, and 8 red, none in
  what this changes:
  - agent TestCodexDriftReached and TestCodexBehindReverseProxy: #3398;
    TestCursorFolderFromTheEditorIsNotTheCLI,
    TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
    TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
    TestOmpDetectedWithPiDir: #3141;
    TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
    #3641.
  - davsync TestSyncTeraCloudStillSeesOtherWrites: #3420.
  - edit TestWriteAtomicReadOnlyHardLink: this box's umask 077, #3640.
  - gateway TestPluginToldWhereTheAgentWorks: this box's /tmp/.git,
    #3675.
  - gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
    this box's millions of open fds, #3649.
  - provider: "fatal error: close of synctest channel from outside
    bubble" in TestUnreadLoginsWriteErrorsKeepCredentials, main's CI
    red, #3632; the package's tests after it didn't run.
  - sessions TestAgyTitleLater: a same-size write in the same mtime
    tick, 2 of 200 on main alone, #3708.
  - testenv TestProgram: this box's umask 077, #3640.

Not tried: Windows, where the reporter is (CI's Windows job runs none of
these tests: it compiles them and runs a named few). package.json and
the lock are read for the forward-slash form magpie hands Bun
("./dist/<file>"), which the reporter's Bun 1.4.4 on Windows kept in
both. A tarball they name only with backslashes goes, where 4e5b2ad8 on
Windows kept one package.json named so (it read package.json through
filepath.ToSlash).

Part 2 of 2, mendDist (coffemon's second commit):

The commit before keeps the tarballs bun.lock has packages at, but a
lock behind package.json stays behind: gkd2323c's (#3622, Windows, Bun
1.4.4) had autoclaw, codearts and cloudflare-workers-ai at tarballs
pruneDist had taken, while package.json and the lock's workspaces had
moved on. Bun installs what the lock has, at every command that changes
plugins/. From that tarball, kept now, or from its own copy of it, it
put the older version back without a word; with neither, every install,
update and removal, of any plugin, failed with "ENOENT extracting
tarball from <that package>". Bun keeps its copy of a local tarball in
its install cache as @T@<16hex>@@@1 on 1.4.2 and 1.4.3, and as
@T@sha512-<32hex>@@@1, the start of the tarball's sha512, on 1.4.4, so a
Bun moved to 1.4.4 has no copy of one an older Bun made (magpie takes a
Bun release two days after it is out, bunSettle: 1.4.4, out on 10-22,
from 10-24). pruneInstallCache leaves these copies alone (no package
name before their first @). On Linux, such a lock and copies made by
1.4.2 or by 1.4.3 give an add on 1.4.4 the reporter's error, for both
packages locked at gone tarballs; the same Bun's add succeeds and puts
both back at their older versions.

Now mendDist runs before each bun command that changes plugins/ (in
runBun and install, under installMu): the packages the lock has at a
dist tarball package.json doesn't name, while package.json has them at
one plugins/dist holds, get one `bun update --ignore-scripts` of them
all, which resolves them from package.json again. It comes after
a9242eb6's mendPackageJSON, which cuts what follows package.json's
object (plugins#405): mendDist decodes package.json, and with that tail
there it would return without a mend, leaving the lock behind for the
command. A package.json that names the lock's tarball too, as Bun
1.4.0's names a package twice, isn't behind. Nothing is asked of the
registry: no package on dist has a dependency (its index.json, 42
packages, on 10-26). `bun add` of them doesn't do it on Bun 1.4.2 and
1.4.3, which keep what the lock has, and with no copy of them, an update
of one package alone fails on the others still locked at gone tarballs.
Each mend is logged with the packages it sent back, so a lock that falls
behind again, which nothing here explains, leaves a line saying when.
What it can't mend is left to the command it comes before, as before:
package.json's tarball gone too, or a package.json or bun.lock it can't
read. A lock behind package.json across npm and plugins/dist it leaves
alone, and Bun installs the lock's version (#3720). A lock with nothing
stale costs reading the two files, decoding package.json and a scan of
the lock; a tarball is looked at only where the lock and package.json
name different ones.

A lock already behind, the reporter's among them, is sent back at the
next bun command magpie runs that changes plugins/, as package.json's
tarball is in plugins/dist: pruneDist never takes one package.json
names.

What was run (tree 5ae0b4a1, on origin/main 4e5b2ad8, go1.26.8,
linux/amd64):
- TestDistLockBehindPackageJSONIsMended (new), with real Bun: autoclaw
  and codearts installed from plugins/dist at 0.2.1 and 0.2.0, then at
  0.2.6 and 0.2.1 (the reporter's), and the lock's packages given back
  the entries Bun wrote for the first ones; with Bun's copies kept, with
  them gone, with the older tarballs put back in plugins/dist, as the
  commit before keeps them, and with the copies gone and plugins#405's
  tail after package.json's object. From each state an unrelated
  plugin's add (zcode) and then its removal succeed and leave both
  packages at package.json's versions, in node_modules and alone in the
  lock, and package.json's specs for both as they were; the add's prune
  takes the older tarballs. With the change the TestDist tests are ok on
  each Bun, and the two new ones at -count=10 on 1.4.2 and 1.4.4. Broken
  by hand, each put back after, with Bun 1.4.2, 1.4.3 and 1.4.4 (outside
  graftcp, the proxy wrapper this box runs commands in, umask 077, logs
  kept):
  - no mendDist: every case red on each, the older versions back with
    the copies or the older tarballs kept (`is at "0.2.1", want 0.2.6`),
    the add failing with "ENOENT extracting tarball from" both packages
    with the copies gone;
  - mendDist before install's add only: every case red at the removal on
    each, the older versions back, or with the copies gone package.json
    still naming zcode after Remove;
  - one `bun update` a package: both copies-gone cases red on each, the
    add failing with "ENOENT extracting tarball from" both packages, as
    with no mendDist (each update alone fails on the other's gone
    tarball);
  - `bun add` of package.json's tarballs instead of `bun update`: every
    case red on 1.4.2 and 1.4.3, ok on 1.4.4;
  - the trigger as first written (the lock's tarball gone): the
    tarballs-kept case red on each, the older versions back (`is at
    "0.2.1", want 0.2.6`);
  - mendDist before package.json's tail is cut: in install, the tail
    case red on each at the add, "ENOENT extracting tarball from" both
    packages; in runBun, red on each at the removal, package.json still
    naming zcode after Remove.
- internal/plugin, -tags nogui, with Bun 1.4.4, the one magpie runs now:
  ok but TestPluginSOCKSProxy, red the same at origin/main 7a60e78c
  (#2207, open, filed for 1.4.3); TestFlowBigReplyProd and
  TestRenewOtherHost skip by their own condition.
- gofmt -l lists nothing; GOOS=linux, windows and darwin go vet -tags
  nogui ./..., GOOS=windows go vet ./..., GOOS=linux and darwin go build
  -tags nogui ./... and GOOS=windows go build ./...: exit 0 each. go vet
  and go build without the tag on linux: exit 1 (no GTK, WebKitGTK or
  fontconfig headers on this box).
- Full suite, -tags nogui (CI's Linux job tags gtk3), outside graftcp
  (systemd-run, umask 077, Bun 1.4.2 first on PATH as on CI, -timeout
  45m, log kept): 65 ok, internal/plugin among them, and 7 red, none in
  what this changes:
  - agent TestCodexDriftReached: #3398; TestInstalledVersion,
    TestHowInstalled, TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
    TestQoderSettingsFromAnIDEPluginIsNotTheCLI and
    TestOmpDetectedWithPiDir: #3141;
    TestReasonixCLIRequiresSupportedNativeVersion and
    TestReasonixCLIRecoversAfterProbeTimeout: this box's /tmp/.git,
    #3641.
  - davsync TestSync and TestSyncTeraCloudStillSeesOtherWrites: #3420.
  - edit TestWriteAtomicReadOnlyHardLink: this box's umask 077, #3640.
  - gateway TestPluginToldWhereTheAgentWorks: this box's /tmp/.git,
    #3675.
  - gui TestGatewayHeldByAContainer and TestGatewayFixQuitsOnlyAMagpie:
    this box's millions of open fds, #3649.
  - provider: "fatal error: close of synctest channel from outside
    bubble" in TestUnreadLoginsWriteErrorsKeepCredentials, main's CI
    red, #3632; the package's tests after it didn't run.
  - testenv TestProgram: this box's umask 077, #3640.

Not tried: Windows, where the reporter is (CI's Windows job runs none of
these tests: it compiles them and runs a named few); the reporter's own
plugins/ folder; the step that left their lock's packages at the
tarballs before while package.json and the workspaces moved on. On Linux
each Bun from 1.4.2 to 1.4.4 writes the packages at the tarball an add
names, so the test makes that state by hand.

Review (macOS arm64, go1.26.8, squashed into one commit per issue, on
origin/main 1cbdda25b), plus the class plugins#405 belongs to, a file
here written over a longer one without truncating:
- bun.lock: real Bun 1.4.4 reads the lock's first object and goes on
  past bytes after it (a lock with an older lock's packages appended:
  `bun install` checked 1 install, no changes, tail left as it was). So
  a tail doesn't stop Bun, but pruneDist's and mendDist's regexp read
  the whole file: the tail's older tarball was kept, and sent to bun
  update before every command. Both now read lockHead, the first
  object, braces and quotes inside strings skipped.
  TestDistLockTailIsntRead (bun update run for a lock whose object is
  behind, not for one whose tail is, nor one with "}\"{]" in a string)
  and a TestDistTarballTheLockNamesStays case (the tail's tarball
  goes). Broken by hand: lockHead returning the whole file turned the
  tail case and both tail subtests red ("0.2.1 kept", "bun update run:
  true"); escapes not skipped turned the braces-in-strings subtest red.
- package.json: every magpie write of it is temp+rename (mendPackageJSON
  since a9242eb68) but the first one install makes, an os.WriteFile;
  that goes through edit.WriteAtomic now. bun's own writes are bun's.
- TestDist* ok on Bun 1.4.2, 1.4.3 and 1.4.4; broken by hand with
  1.4.4: mendDist's calls removed turned
  TestDistLockBehindPackageJSONIsMended red, and the old pruneDist
  turned TestDistTarballTheLockNamesStays red ("taken out").
- internal/plugin whole package ok (144s); gofmt clean; vet ok for
  linux nogui, windows, darwin nogui.
Not tried: Windows, where both reports come from.
2026-10-27 15:57:59 +08:00
yetoneandskygunner 51202cd431 plugin: a check-in outcome magpie doesn't know names what the plugin said
A plugin check-in that answered an outcome not in the list, with a
message, became failed with the plugin's message alone, so "the daily
credits were refreshed" read as magpie's own failure reason. The reason
now names the answer first: the plugin answered "yes": <message>. With
no message it stays "the plugin answered no outcome" or the answer.

Split out of skygunner's fix/usage-absent-used branch (#3650), which
carried it beside the usage fix.

Run: go test ./internal/provider -run TestPluginCheckinRunsAsTheBuiltinsDo
ok. Broken by hand: host.js's old line makes it red (Msg was the message
alone). Not tried: a real plugin answering an unknown outcome.

Co-authored-by: skygunner <skygunner@users.noreply.github.com>
2026-10-26 22:42:59 +08:00
yetoneandskygunner 9733ed1b4a usage: a plugin window that doesn't say used is no reading (#3650)
A plugin usage window that leaves out `used` was read as 0 in host.js
usageOf. The card then showed "100% left" (or NaN% once the GUI saw a
missing value), and allowanceOf ranked the account as the one with all
of its allowance left, so smart routing put spent accounts first.

Now a left-out used is null from the host, plugin.UsageWindow.Used is a
*float64, and quotaOfPlugin makes such a window Text and Aside: the card
shows its display (else "No allowance reported"), with no percentage and
no meter, and routing leaves it out. An account whose windows all tell no
share has no allowance and is not known to routing (routedAllowance), as
one never read: not preferred and not rested. A window that says used:0
is a reading at 0, as before.

Ported from skygunner's fix/usage-absent-used (6791aa99). Changed from
the branch:
- lastAllowances (the reading kept on disk) built an empty allowance for
  such an account, which routing read as known with all of it left. Both
  it and Allowances now go through routedAllowance.
- quotaText shows "No allowance reported" for a no-share window with no
  display, rather than a blank.
- A host-level test (the bun host with the fake plugin) and the GUI test
  widened to both engines, every language, 900 and 390px, used and left.
- The branch's check-in wording change is its own commit.
Note: an account whose windows are all aside or text was known with 0%
used before; it is now not known, so loginRoom won't pick it as the
next account with room.

Run at this tree (base 9298d2a7c):
- go test ./internal/provider -run 'Absent|NoShare|PluginUsage|PluginText|
  AllowancePooled|PluginPool|GLMPlan|WorkBuddyCredits|QuotasDedupe'  ok
- go test ./internal/plugin ok; gofmt -l empty; go vet ./...,
  GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok
- GUI: usage-no-reading.test.cjs chromium+webkit ok; i18n-keys ok;
  TestCoreScriptBudget ok (budget not raised)
Broken by hand, each red, then restored:
- quotaOfPlugin without the Text/Aside branch: 3 absent tests red
- routedAllowance always ok and allowanceOf not skipping Text:
  TestRoutingKnowsNoAccountThatSaidNoShare red
- host.js's old used line: TestPluginHostPassesAnAbsentUsedOn red
- usage-no-reading on origin/main's assets: red in both engines
  ("12 / 300 · NaN% used")
Not tried: a real Loomy account, a live routed request.

Co-authored-by: skygunner <skygunner@users.noreply.github.com>
2026-10-26 22:42:59 +08:00
yetone fed0055da8 plugin: a plugin stuck on its vendor no longer holds up the plugins loaded or listed with it
shualaitianduai on Discord: a plugin whose sign-in kept failing (401)
held up the plugins behind it. host.js loaded the plugins one after
another and answered init only when all were in, so a plugin function
that never returned held every other plugin until init's two-minute
deadline failed the whole host. providers() listed the providers one
after another too, so one stuck models hook held the whole list past
refreshDeadline (30s), and every provider's list went stale.

Now loadPlugins loads every plugin side by side, each given
pluginLoadWait (20s) for its import and plugin function, and each
config hook as long; one still loading is told as not loaded ("the
plugin's load didn't finish in 20s") and init answers with the rest.
Hooks are kept in the list's order, as before. providers() lists every
provider side by side and gives each models hook pluginListWait (20s,
inside refreshDeadline): one that hasn't answered is listed as fallen
back with that as its listError, so magpie keeps the list it had, and
that answer isn't kept for requests (keepInfo). Documented in
docs/subsystems/provider-plugins.md.

Run at this head (base origin/main e5dd86965), sandbox HOME, caches
pinned:
- TestStuckPluginLoadHoldsNoOther and TestStuckModelListHoldsNoOther
  (testdata/stuck): red on origin/main's host.js ("Plugins = [],
  starting plugins: context deadline exceeded" after 30s; "Providers
  = [], context deadline exceeded" after 15s), green here (2.1s each).
- go test -count=1 -timeout 45m ./internal/plugin/: ok (165s).
- go test ./internal/provider/: ok with
  -skip TestUnreadLoginsWriteErrorsKeepCredentials, which crashes with
  "close of synctest channel from outside bubble" in filememo.Forget,
  filed as #3632 and not touched here.
- go test -run Plugin ./internal/gateway/: ok.
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags
  nogui on internal/plugin: ok.
Not run before the push: the whole go test ./... (run after it); not
tried with the reporter's own plugin, which wasn't named.
2026-10-26 15:09:09 +08:00
yetone a2ff7e6cab plugin: add takes a community plugin's name (WorkBuddy, think-tags, qoder-cn)
Atlas on Discord (#help, 10-25, Linux): `magpie plugin add WorkBuddy`
said "isn't an npm package name". Worse, a bare `workbuddy` passed the
npm-name check and installed npm's unscoped workbuddy@latest, not
@magpie-community/opencode-workbuddy-auth.

plugin.Add, which the CLI, the Plugins page's field (/api/plugins/add)
and the movers all go through, now resolves a bare name first
(internal/plugin/resolve.go). Case aside, a name one community listing
goes by is its package, at the version given: the package or its bare
name, the short name (workbuddy, think-tags), the shown name (WorkBuddy,
Command Code), a provider id it serves or the subscription it replaces,
and a retired subscription's id through its mover (qoder-cn; provider
sets plugin.SubscriptionPlugin = MovePackage). The CLI says which
package it picked. A name two listings go by, or none that isn't an npm
name, is refused with the community plugins listed. A name no listing
goes by is npm's own package (opencode-gemini-auth keeps working), but
only when the list was fetched within the six hours: when the fetch
fails, the copy kept or built in may not name a newer plugin, so the
name is refused with why, and npm:<name> installs npm's package as
written. market() now says whether its list is a fresh fetch (marketErr).
Scoped names, paths and git specs are unchanged. A backup's or a sync's
plugins go in by their own spec (plugin.AddExact via addPluginExact),
never resolved, so a restore isn't held by GitHub being unreachable.
Update, Upgrade and InstallMissing use add with stored specs, unchanged.

Tests (fake registry over httptest, fake bun; no network):
TestResolveCommunityNames, TestResolveRefusesWhatItCantName,
TestResolveListUnread, TestAddByCommunityName. TestUpdateAllUpdatesAPinnedPlugin
adds an unscoped third-party name, so it now serves a registry.

Broken by hand: Add without resolve -> TestAddByCommunityName red with
the reporter's own error ("WorkBuddy" isn't an npm package name) and
workbuddy -> workbuddy@latest. The unread-list rule turned off (valid
name goes to npm regardless) -> TestResolveListUnread red.

Real use, sandbox HOME, built binary, real npm and GitHub:
`plugin add WorkBuddy` -> installed @magpie-community/opencode-workbuddy-auth@latest,
listed workbuddy and workbuddy-ai; `think-tags` -> middleware-think-tags;
`opencode-gemini-auth` -> npm's, google-plugin listed; `qoder-cn` with
MAGPIE_PLUGIN_MARKET=off -> opencode-qoder-auth; "Work Buddy Pro" ->
refused with the 38 community plugins listed; `twinz` with the list off
or at a dead URL -> refused, saying why and npm:twinz.

Run at this head (rebased on origin/main 42976f9a0): gofmt -l clean;
go vet (darwin) and GOOS=linux / GOOS=windows -tags nogui vet of
plugin, provider, cli, backup, gui clean; go test -timeout 45m
./internal/plugin ok (120s, after the pinned-update fix),
./internal/provider ./internal/cli ./internal/backup ./internal/gui ok.

Not tried: the full ./... suite; Windows and Linux runs of the tests.
No GUI JS changed: the Plugins page's field goes through the same Add,
and its status still says "<typed name> is installed" rather than the
package picked; the installed list shows the package.
2026-10-25 11:52:02 +08:00
yetone 5b32b7ea80 plugins: a Bun Windows can't load (0xc0000139, before 10 1809 / Server 2019) says so and what to do (zgcwkj on Discord)
zgcwkj runs magpie-cli-windows-amd64.exe as a Windows service (nssm) and
every plugin install failed with "bun add …: exit status 0xc0000139: (and
from the community repo's dist branch: bun add ./dist/….tgz: exit status
0xc0000139: )".

Why: 0xc0000139 is STATUS_ENTRYPOINT_NOT_FOUND, the loader refusing the
exe before it runs. Reading the PE imports (debug/pe) of Bun's
windows-x64(-baseline) zips: 1.3.14 and later, so magpie's floor 1.4.2
and the latest 1.4.4, import kernel32's CreatePseudoConsole,
ClosePseudoConsole and ResizePseudoConsole, which Windows has from 10
1809 (build 17763) / Server 2019 on. 1.3.13 doesn't. Bun's docs say
"Windows 10 version 1809 or later" (bun.com/docs/installation). So
Windows Server 2016 and Windows 10 1507 to 1803 (LTSB 2015/2016) can't
run any Bun magpie uses. 1.4.2's pinned SHA-256 matches the asset.

What changes:
- wontLoad (internal/plugin/bun.go) reads an exit of 0xc0000139 as
  "this Windows" and 0xc000001d or SIGILL as "this processor" (Bun's x64
  build targets SSE4.2), as a *BunUnstartableError whose message says
  which, the versions Bun needs, and MAGPIE_BUN.
- bun add, bun update, cantStart and whyDied (the host's start) wrap it.
- An install no longer tries the dist branch after it: that bun add
  can't start either, and its error read as the dist branch's.
- The GUI's fail() answers it with code bun_unstartable, bunWhy and
  said, an i18n.js key (bunSaid in api.go), which api() in app.js puts
  through t(): en, zh, zh-TW, ja, de, in the window and in magpie web.
  The sentences live in Go so app.js grows one line: with both in
  app.js, TestCoreScriptBudget was 128 bytes over app.js's budget and
  487 over the core's, and no budget is raised here.
  TestBunSaidIsTranslated fails when a language lacks one. The CLI
  prints the English message.
- No fallback to an older Bun: 1.3.13 is below BunVersion and Bun
  doesn't support that Windows, and the -baseline assets are now the
  same binary.
- docs/subsystems/provider-plugins.md says all this.

Run:
- New tests: TestWontLoadSaysWindowsOrCPU (injected NTSTATUS exits, a
  real kill -ILL), TestInstallOnUnstartableBunSaysWhyAndSkipsDist (0
  dist requests), TestHostOnUnstartableBunSaysWhy, TestFailSaysBun
  Unstartable, TestBunSaidIsTranslated, plugin-bun-unstartable.test.cjs (chromium and webkit,
  every language, window and web).
- Real Windows (10.0.26200 box, a sandbox dir of its own): a
  windows/amd64 nogui magpie-cli.exe with a fake magpie-bun.exe that
  exits 0xc0000139, `plugin add @magpie-community/opencode-raccoon-auth`
  printed the new message, and no dist folder was made.
- gofmt -l; go vet darwin, linux -tags nogui, windows; builds of all three.
- Full suite (go test -tags nogui -timeout 45m ./..., through
  suite-lock, at a6399dd49 plus this change with both sentences in app.js):
  every package ok except internal/gui's TestCoreScriptBudget (128
  bytes over app.js's budget, 487 over the core's). After the sentences
  moved to bunSaid: internal/gui and internal/plugin ok, budget
  included (core 1,528,331 of 1,528,525 before scoping the line to the
  code, ~20 bytes more after).
- GUI (chromium and webkit, node --test): i18n-keys, every plugin-*
  file and signin-paste-plugin, 660 of 660 before the move to bunSaid;
  after it 656 of 660 at load ~140: plugin-card-update webkit (#3079)
  and plugin-quota-error chromium ja, whose Chromium launch hit
  Playwright's 180s timeout before the test ran. Both files alone: 16
  of 16, 14 of 16 (which one not kept), 16 of 16, 16 of 16.
- Rebased on ff6090354: TestCoreScriptBudget, the new Go tests,
  plugin-bun-unstartable and i18n-keys again ok; gofmt; windows and
  linux vet of internal/plugin and internal/gui.

Broken by hand (each restored):
- wontLoad always nil: the three plugin tests fail, the install one
  with the reporter's exact "(and from the community repo's dist
  branch: …)" shape.
- the dist skip removed: 1 dist request.
- the whyDied check removed: the host test fails.
- fail()'s block removed: the gui Go test fails.
- app.js's line turned off: the GUI test fails, 16 of 16 (chromium).
- one language's key renamed: TestBunSaidIsTranslated fails (3 of 4).

Not tried: a real Windows before 1809 (the box is Windows 11) and a real
processor without SSE4.2; zgcwkj's Windows version is still unknown.
2026-10-25 05:54:07 +08:00
yetone 3a47e377e0 usage: a call whose vendor counts no cache is left out of every hit rate (#3464)
#3464 (zeewell on X): Kiro caches on its side, but its replies give only
credits and a context share, never cache tokens. Every hit rate outside
the Routing page read those calls' CacheRead of 0 as a miss. A Kiro-heavy
day showed "hit rate 6%" when the counted calls hit 90%.

The plugin already says so (opencode-kiro-auth 0.1.16 sends
usage.magpie_cache_unknown), and the gateway already kept it as
RouteUsage.CacheUnknown for Routing. This carries it the rest of the way:

- gateway: Usage.cacheNotCounted() (the vendor said so and no try
  reported a cache token) goes into usage.Record.CacheUnknown on every
  path that records a call: the gateway's own record, the OTel attempt
  path in observe.go, and trace's routeUsage.
- usage: Record.CacheUnknown is kept as ledger row flag 8192
  (rowCacheUnknown; grepped, no other flag uses that bit). Totals sums
  such calls' prompt into cache_unknown and counts them in
  cache_unknown_calls. Totals.HitRate leaves that prompt out of its
  denominator, and gives no rate when nothing is left.
- Old records: calls kept before the plugin said so carry no flag. A
  Kiro call (provider kiro or kiro-plugin) with no cache counted is read
  as uncounted (usage.CountsNoCache): in the ledger's row read, in
  Totals, and for Routing's history in internal/gui/trace.go
  (cacheCounted). The rule is scoped to Kiro's two ids, so another
  vendor's 0 stays a miss (tested).
- GUI: cacheHitOf in app.js drives the tray panel's card, the Usage
  page's agent rows and cache tile, the requests' Cache hit rate card and
  each ranking row. When only uncounted calls are left it shows "—" or
  nothing instead of 0%. Otherwise it says "{n} requests left out: their
  vendor doesn't count the cache". A request row's cache cells show "—",
  and its details say the vendor doesn't count the cache. The Context
  page (context.go, context.js) shows no cache for such a call and doesn't
  score it as a miss.
- No budget raised. This adds 625 bytes to app.js (1,320,224 to
  1,320,849, under its 1,321,336); d08b6118b had already moved the
  masking page's maskWho, maskProv and stillMotion out to
  plugins/redact, which an earlier version of this change did too.
- Strings in zh, zh-TW, ja and de. docs/subsystems/provider-plugins.md
  now describes the ledger side and what is not covered.

Not covered, filed: hit rates read from the agents' own session files
(the TUI and CLI session lists, the Sessions tab's totals) still count
Kiro's 0 as a miss (#3470). Found on the way: System One's calls are
recorded without their cache tokens (#3471).

Run at this tree (on origin/main e57e78563, fetched just before; the
54-file GUI run was at a84d2ec80, and the 14 files that main's
redact page change since could reach were run again here):
- gofmt -l . prints nothing. go build ./... ok. go vet ./... ok,
  GOOS=linux go vet -tags nogui ./... ok, GOOS=windows go vet ./... ok.
- go test -count=1 -timeout 45m ./internal/usage ./internal/gui
  ./internal/gateway: all ok (gateway 388s), TestCoreScriptBudget
  included.
- GUI, 54 files (ledger-*, panel-*, i18n-*, context-*, request*,
  usage-card*, usage-ledger and the masking/redact files),
  concurrency 2: WebKit 439/452, Chromium 444/457. The new
  ledger-cache-unknown test passed in both. Again here (ledger-*,
  masking-*, redact-*, mask-*, usage-ledger): WebKit 104/117,
  Chromium 109/122, the same reds. The reds, both already
  red alone on main before this change:
  - redact-words-any-case, 10/10 in each engine (#3500)
  - usage-ledger "newest live route needs no return-to-live button",
    en and zh in each engine (#3104)
- At earlier bases, with the same change: usage-agents-hide (#3414),
  usage-checkin's WebKit Qoder tab (#3091), usage-fold (#3415),
  usage-focus-steady (#3501) were red, each red alone on main too;
  usage-card-refresh read a row before it was laid out, under load
  (#3509); context-picks (#3483) and
  context-map's tile overlap (#3488) in Chromium. Filed while doing
  this: TestUsageReadAfterAppendHashesNothingOnAFineClock goes red
  about 1 in 20 on main aa3112f4e (#3511); it passed in this run.
- Red on the old code: the new Go tests in usage, gateway and gui, and
  ledger-cache-unknown.test.cjs (the old page shows "hit rate 6%"
  where this shows 90%). Each changed piece was broken by hand and
  turned a test red. The exception is the OTel attempt path in
  observe.go, which no test reaches.

Not tried: a real Kiro account through the GUI.
2026-10-25 01:23:42 +08:00
yetone 436bcc946d routing: a request whose vendor counts no cache tokens shows no hit rate, not 0% (zeewell on X)
zeewell on X: every Kiro request in a routing group showed cache 0%, for
claude-sonnet-5.5 and claude-opus-5.5 from Claude Code, with 148k to
182k tokens and consecutive calls.

The cause, from real Kiro calls on the owner's account (read-only, from
a sandbox): Kiro does cache. A repeated 900-line prefix cost 0.0912
credits and then 0.0484, with or without cachePoints, and with a fixed
conversationId too. But Kiro's reply holds only assistantResponseEvent,
metadataEvent {stopReason}, contextUsageEvent (a percent) and
meteringEvent (credits). There are no token counts at all, and
kiro-cli 2.32's own trace shows the same. The plugin wrote
cache_read_input_tokens: 0, which magpie showed as 0%.

opencode-kiro-auth 0.1.16 (plugins 9f6c4e8) now leaves the cache fields
out and says `magpie_cache_unknown: true`. This commit reads that field:
- aUsage reads it into Usage.cacheUnknown, ORed in Usage.add.
- routeUsage sets RouteUsage.CacheUnknown (cache_unknown, omitempty) on
  a try that counted no cache read or write.
- The Routing page's promptOf leaves such a try out of the hit rate. The
  row and its session then show no Cache metric, as for older history.

Clients are never told the field. Usage.anthropic() leaves it out, and
a passthrough forwards the plugin's bytes as they came. The gateway
already relays cache_control to an Anthropic-protocol plugin as Claude
Code sent it, so nothing was lost on the way to Kiro.

Left alone: the usage ledger. usage.Record has no such flag, so the
Usage page's aggregate hit rate still counts a Kiro prompt as a miss.
Filed as #3464.

Run at this head (rebased on origin/main 628e18987):
- gofmt -l internal/gateway internal/provider: clean.
- go vet ./internal/gateway ./internal/provider: clean on darwin, with
  GOOS=linux and with GOOS=windows.
- go test -timeout 45m ./internal/gateway ./internal/provider: ok, ok
  (465s, 126s).
- go test ./internal/gui -run Budget: ok.
- GUI: routing-request-metrics.test.cjs, chromium and webkit, en and zh:
  4 of 4 pass.
- Every routing-*.test.cjs, one base back, at load 130 to 150: the only
  reds were routing-intent-entry, routing-keys-fold and routing-manual.
  Run alone, those three files also go red on a fresh origin/main
  628e18987 worktree (8 reds there, 5 on this branch). They are already
  filed: #3408, #1612 and #3409. This change touches only promptOf's
  cache_unknown rows, which none of their fixtures have.

Broken by hand:
- With aUsage.usage() not carrying the field, TestCacheUnknownReachesTheRoute
  fails in its four Kiro cases (Claude Code whole and streamed, translated
  whole and streamed). The counted-miss case still passes, at 0%.
- With promptOf's skip removed, the GUI test fails in chromium for en and
  zh: "a vendor that counts no cache tokens has no hit rate, not 0%".

The test fixtures are the plugin's real reply bytes from Kiro, captured
10-24.

Not tried: a magpie build running the 0.1.16 plugin against Kiro from the
GUI. The plugin's own end-to-end run against Kiro gave
{"input_tokens":0,"output_tokens":19,"magpie_cache_unknown":true}.
2026-10-24 18:16:17 +08:00
yetone ed91aa04ef checkin: an inactive or ineligible check-in shows the plugin's reason (plugins#304)
Qoder's plugin 0.2.32 (magpie-community/plugins 74be632) says why no
check-in was offered: it asked with this machine's own device identity
and Qoder offered no campaign, and Qoder desktop can claim one it shows.
magpie dropped a hook's message for inactive and ineligible and showed
only "No check-in event now". Now:

- GUI: the Usage card's row reads "<label> · <message>", wrapped under
  the label rather than cut off with "…" (data-why, as a failed row's
  reason wraps, #821); Settings' check-in line under the plugin's switch
  carries it too. A result without a message reads as before. No new
  i18n keys: the message is the plugin's own text, as for failed rows.
- TUI: the Usage cell is too narrow, so it adds "c says why"; c's flash
  carries the message (checkinWhy).
- CLI: `magpie accounts checkin` prints it after the label.
- The Qoder mover's min is 0.2.32 (npm view --prefer-online: 0.2.32).
- docs/subsystems/provider-plugins.md says how the message is shown.

Run at this tree (based on origin/main dd1e8822d):
- go test -timeout 45m ./... (tee'd, grepped): every package ok
  but internal/handoff, whose TestTakeOnlyAFreshOfferForThisProgram
  could not bind a unix socket under my long scratch TMPDIR (path over
  104 bytes); with the default TMPDIR internal/handoff is ok.
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean.
- GUI, chromium and webkit: checkin-reason (new: en, zh, zh-TW, ja, de;
  900 and 440px), plugin-checkin, qoder-checkin-recheck, usage-checkin,
  checkin-account, checkin-early-done, usage-quota-head, i18n-keys:
  155/157. The 2 reds are usage-checkin's "webkit en/zh: Settings has a
  Qoder check-in tab", red the same on a fresh origin/main a9a001a7a
  (#2549, #3091).
- TestCoreScriptBudget: app.js 1,343,313 of 1,343,324, no raise.

Rebased on origin/main 4683a0382 (a9a001a7a's app.js line, 4683a0382's
provider change) and run again at this head: internal/gui (budget:
1,343,323 of 1,343,324), internal/cli, internal/tui and the whole
internal/provider ok; the same 8 GUI files in both engines, 155/157,
the same two #2549/#3091 reds.

Broken by hand: app.js's change reverted, checkin-reason goes red on the
reason; app.css's reverted, red on the wrap; checkinWhy returning "" in
internal/cli and internal/tui, TestCheckinSaysWhyNoneWasOffered red in
each.

Not tried: a real Qoder account offered no campaign (the fixture is the
plugin's own text); the real Linux app (WebKitGTK).
2026-10-24 14:52:13 +08:00
yetone a77b5b4fc9 gui: Check in now says what the press came to, not "refreshed" (#3326)
Promised to connoryang331 on #3326: a press of Check in now said "Check-in
status refreshed" whatever happened. It now says, in the same toast, a
count per kind (checkinPressSaid): "Claimed: 1 (+200 credits)",
"Already checked in today: N", "Not available yet: N" (inactive,
ineligible, or an "already" magpie asks again), "Check in in its own app:
N" (captcha, Trae's 9074), "Check-in failed for N account(s)" (red, as
before). No layout change. en, zh, zh-TW, ja, de.

A result counts as claimed now only when the vendor was asked on this
press: WorkBuddyCheckin.Asked is now sent as "asked" (omitempty). It is
still never kept: checkinNow writes the file before setting it. An
account claimed earlier today, settled and not asked, counts as already.
The TUI and CLI already say each account's result ("+N", "· already"),
unchanged.

app.js and the core budget: +771 bytes over the previous commit, 349 over
the budget after compacting the helper, raised by exactly that with the
reason in core_budget_test.go (the check-in row is the core's, the tray
panel draws it too).

Tests:
- checkin-early-done.test.cjs: the press's toast is "Claimed: 1 (+200
  credits)" in each language, and checkinPressSaid's text for already,
  not yet and a mix (claimed x2 +150, already, failed), bad = 1 for a
  failure. qoder-checkin-recheck.test.cjs now wants "Not available yet:
  1" for its inactive press.
- Red on the previous commit's app.js: both files 0/20 in Chromium.

Run at this tree:
- GUI: checkin-account, checkin-early-done, i18n-keys, plugin-checkin,
  qoder-checkin-recheck, usage-card-refresh, usage-checkin, Chromium and
  WebKit: 177/179; the 2 reds are usage-checkin's WebKit Qoder check-in
  tab, red alone on origin/main 0815c9186 (#2549, #3091).
- go test -tags nogui ./internal/gui/ -run Budget, ./internal/provider/
  -run 'Checkin|CheckIn': ok.
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./...
  at 70c6bb072 (this tree on the previous commit), sandbox HOME: 69
  packages ok, exit 0. go vet of internal/gui and internal/provider on
  darwin, linux (nogui) and windows clean; gofmt -l clean.

Not tried: a press against a real vendor account.
2026-10-23 19:03:58 +08:00
yetone 45fa29973c checkin: an early "already checked in" is asked again, not kept for the day (#3326)
connoryang331 (v0.1.1328, Windows): at 00:00:28 Beijing 14 of 29 plugin
check-ins (AutoClaw CN x5, WorkBuddy x2, CodeArts, Trae x3, MiniMax,
Raccoon x2) answered "already" (done). magpie kept that as the day's
result and never asked again, and Check in now answered from the record
without asking. A real claim at 10:54 paid +200: the vendors' days turn
later than Beijing midnight, so 00:00's "already" was yesterday's.

The class, in the checkiner every check-in shares (built-in and plugin):
- A done, inactive or ineligible answered before noon Beijing
  (checkinSureHour) for an account magpie hasn't seen claim that Beijing
  day is provisional. The loop asks it again 30 minutes (wbCheckinEvery)
  after the answer, until a claim or an answer from noon on: at most 24
  more asks a day per such account, none once magpie claims.
- A press (soon) asks again at once for done, inactive and ineligible,
  whatever the hour. own-app (Trae 9074) and captcha still stand.
- A claim stamps Claimed, carried over while later answers that day say
  done, so a done after magpie's own claim is settled (Qoder's claim then
  done case).
- The record goes out with again: true (worked out when shown, never
  kept). The card says "{name} says already checked in; its day may not
  have turned yet, so magpie asks again later" and keeps Check in now;
  Settings, TUI and CLI say the same. en, zh, zh-TW, ja, de.
- Qoder's recheck (#2696, pluginRechecks) is unchanged: its tests pass
  as they were.

The plugins repo does not cache "already": autoclaw reads the task list
or calls dailySignin each time, codearts, minimax, raccoon and trae ask
the server each call (read at magpie-community/plugins origin/main
652f06d). No plugin change, publish or mover min.

Tests:
- TestPluginCheckinEarlyDoneAskedAgain (the reporter's 00:00:28: loop at
  +29m no ask, +30m asks then claims; a press at 10:54 claims; done all
  day is 25 asks and settles at noon; done after magpie's claim settled)
  and TestWorkBuddyCheckinEarlyDoneAskedAgain.
- TestPluginCheckinOthersSettledForTheDay now answers at 12:00 Beijing
  and checks a press asks again (claimed still settled);
  TestPluginCheckinRunsAsTheBuiltinsDo, TestTraeCheckinAnswers and the
  WorkBuddy nothing-to-claim/refused tests follow the new rule.
- TestCheckinAgainNotShownAsToday (TUI words and cell).
- checkin-early-done.test.cjs: again card's wording, data-state wait,
  Check in now asks plugin-checkin {provider: autoclaw-cn}; a kept done
  is "Checked in today +50" with no press. Chromium and WebKit, 5
  languages, 900 and 440px, 20/20.

Red on the old code: with the non-test change reverse-applied (fields
kept so it compiles), TestPluginCheckinRunsAsTheBuiltinsDo,
TestPluginCheckinOthersSettledForTheDay (inactive, done, ineligible) and
all 4 subtests of TestPluginCheckinEarlyDoneAskedAgain fail; with
origin/main's app.js, checkin-early-done fails ("Checked in today").

Run at this tree:
- gofmt -l clean; go vet ./... (darwin), GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./... clean.
- go test -tags nogui ./internal/provider/ -run 'Checkin|CheckIn',
  ./internal/tui/ -run 'Checkin|OwnApp': ok.
- GUI: checkin-account, checkin-early-done, i18n-keys, plugin-checkin,
  qoder-checkin-recheck, usage-card-refresh, usage-checkin: 177/179. The
  2 reds are usage-checkin's "webkit en/zh: Settings has a Qoder check-in
  tab", red the same alone on origin/main 0815c9186 (filed #2549, #3091).
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./...
  at c1a72f2b4 (this tree on origin/main 0815c9186), sandbox HOME: 69
  packages ok, exit 0.

Not tried: real vendor accounts (no early-morning "already" to replay),
Linux and Windows at run time. A vendor whose day turns after noon
Beijing (a US day) is not covered.
2026-10-23 19:03:58 +08:00
yetoneandLoKi 21f7f9df23 checkin: the Qoder plugins' check-in is asked again within the day, as the built-in's was (#2696)
The native Qoder and Qoder CN plugin check-in (pluginCheckinProvider) built
its checkiner without recheck, while the built-in qoderCheckiner set it.
So an inactive or done result was kept for the whole Beijing day, and a
press of "Check in now" was answered from that record too. Qoder CN's
campaign runs 10:00 to 09:59 the next day (mufanmu), so an early read
describes yesterday's campaign and said nothing about today's.

What changed:
- provider: pluginRechecks(id) is true for "qoder" and "qoder-cn" only,
  and sets recheck on their checkiner. A press asks at once. The loop asks
  again after wbCheckinEvery (30m) for inactive and done. Every other
  plugin stays settled for the day.
- GUI (checkinRow): a Qoder account (built-in or plugin) whose check-in
  found no campaign today keeps "Check in now". A press reports "Check-in
  status refreshed" instead of "Checked in", since it may still find
  none. The unused "Checked in" key is replaced in all four languages.
- docs/subsystems/provider-plugins.md names the exception and the tests.

Taken from LoKi's (lokic7123-star) patch on the issue: the recheck on the
Qoder plugin ids, the Check in now button for an inactive Qoder card, and
the neutral press status. Their GUI test was adapted into
qoder-checkin-recheck.test.cjs.
Left out, as the earlier review asked: the blanket 30-minute message, the
UTC timestamps and the client-computed next check. Also left out: the
"Already checked in today" wording and the "· credit" display. That is
not this bug, and the TUI and CLI would need the same change.

Run:
- Red on the old code:
  - All 8 subtests of TestPluginCheckinQoderRechecksCampaigns
    ({qoder,qoder-cn} x {inactive,done} x {loop,press}) fail without
    the fix.
  - Forcing recheck on for every plugin turns
    TestPluginCheckinOthersSettledForTheDay red.
  - qoder-checkin-recheck.test.cjs is red on the origin/main assets (no
    .ci-now on the card).
- At 91bb01e65 (base 9572a3576):
  - Full suite: set -o pipefail; go test -timeout 45m ./... |
    tee. EXIT=0, 68 packages ok, run alone on the machine.
  - qoder-checkin-recheck.test.cjs passes 20/20: chromium and webkit,
    en/zh/zh-TW/ja/de, 900 and 440px.
  - 76 GUI files reachable from the change were run: check-in files,
    gui-*, i18n-keys and tray-usages. Reds:
    - login-import, chromium en/zh: red on main too (#1307).
    - quota-reads webkit de 360: red on main too (#2150, commented
      with its c.toFixed page error).
    - usage-checkin webkit en/zh, Qoder tab: red on main too (#2549).
    - update-wait chromium en and usage-alert webkit en: red only
      under load, pass alone (#3275).
- At this tree, rebased on 87d703c5c (b91bcf260, library only, came
  after). The 8 new main commits since
  9572a3576 bring app.js, i18n.js and provider plugin changes; none of
  them touches check-in code.
  - gofmt -l: clean.
  - go vet ./...: clean on darwin, linux (-tags nogui) and windows.
  - go test ./internal/provider/ ./internal/gui/ ./internal/plugin/
    ./internal/cli/: all ok. internal/gui includes TestCoreScriptBudget.
  - GUI, both engines: qoder-checkin-recheck, i18n-keys,
    plugin-checkin, checkin-account, account-models and
    plugin-keyless-signin pass 119/119.

Not tried:
- No real Qoder or Qoder CN account, and no campaign that opens
  mid-day.
- The full GUI suite: another session's full GUI run held the machine,
  so 76 files were run instead.
- Linux and Windows at runtime.

Reported by mufanmu and LoKi; patch by LoKi.

Co-authored-by: LoKi <317300729+lokic7123-star@users.noreply.github.com>
2026-10-22 21:18:13 +08:00
LoKi 5871f02dd6 plugins, provider, gui: a keyless plugin sign-in needs no key, and a single-identity plugin has one account (#2695, LoKi)
LoKi's patch (lokic7123-star), picked onto origin/main ef6f3749d. A plugin's api
method that has an authorize step and no prompts is reported as keyless:
PluginAPIKey accepts an empty key for that method only, the CLI and the
GUI skip the key field, and a plugin marked auth.single signs in again
on its first account instead of adding another one. Zen Free needs
magpie-community/plugins#205 (keyless and single on zen-free), merged and
published, before its users see this.

Added in review (yetone): TestPluginEmptyKeyOnlyKeyless, which checks that
an empty key is refused for a non-keyless api method, an oauth method
marked keyless, an out-of-range method and an unknown plugin.

Run at the stacked tree (this commit plus #2554 and #2862, on ef6f3749d):
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui, and
  GOOS=windows: ok.
- set -o pipefail; go test -count=1 -timeout 45m ./... under the suite
  lock: every package ok (SUITE_EXIT 0).
- GUI: plugin-keyless-signin, account-models, i18n-keys and
  models-select-all-api, chromium and webkit, every language they cover:
  all pass.
Red on the old code: TestPluginKeylessSingleIdentity "keyless metadata lost"; the
GUI test 10/10 red; without signInKey's single line, "single identity
duplicated"; TestPluginEmptyKeyOnlyKeyless red with the Keyless check
replaced by false.
Not tried: a real Zen Free sign-in (needs plugins#205 published).
2026-10-22 20:50:59 +08:00
yetone 9b0f48612b gateway: a plugin's model that searches by itself can be the web searcher
01huadalang (Discord #feedback, 10-20): Settings › Web search offered only
Antigravity; Trae's search model couldn't be picked, "可能也有别的模型能搜索
但是识别不到". partSearcher and modelSearches answer false for every
provider with an account behind it, so no plugin-served provider was ever
offered, and a plugin had no way to say which of its models searches.

A plugin now marks such a model with `searches: true` (in its config
models or the list its models hook gives). host.js passes it on,
plugin.Model carries it, and pluginCatalog makes it WebSearch "native".
partSearcher offers a plugin provider with such a model, with those models
only, at rank 4 (as Command Code's search models); remoteSearch asks it in
plain words, the way it asks Command Code's. A client's own web_search
sent to that model still goes to magpie's searcher (searchesModel is
unchanged): the plugin's upstream takes no web_search tool.

Behaviour change: a marked plugin model ranks ahead of Antigravity and
Google (rank 5) when magpie picks the searcher itself.

Run:
- TestPluginSearchModelIsASearcher (new; a fake plugin's model marked
  searches answers a weather question with a URL): red on the old code
  (the picker offers [], want the plugin's fake-search alone), green now.
- Broken by hand: host.js without the `searches` passthrough; the test
  goes red at the picker.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows on gateway,
  plugin, provider, catalog.
- set -o pipefail; go test -timeout 45m ./... at this tree: 68 ok, no FAIL.

Not tried: the Trae plugin itself. It declares nothing about search yet;
marking Trae CN's search_agent there needs a Trae account to try it with,
which this machine doesn't have. No GUI files changed.
2026-10-22 03:18:11 +08:00
yetone ba319a7587 gateway: the lone tool_choice none goes to the Grok plugin only (#3110)
19527ca8d sent a lone tool_choice "none" (tools turned off, none
declared) to every provider plugin on Responses. No other plugin's
vendor had been tried with one. commandcode, factory, opendesign and
zed don't touch tool_choice in their fetch/rewrite (git grep on
magpie-community/plugins origin/main), so it would have reached their
vendors as is, and a 400 there would be a regression. Only the Grok
plugin reads it, and grok 0.1.18 drops it before Grok.

keepsLoneNone now keeps it for the Grok plugin alone (still not when
the plugin points at xAI or Copilot, #378); forwardTranslated strips it
for every other upstream, as before 19527ca8d.

Run at this commit (on 19527ca8d):
- gofmt -l: clean
- go vet ./...: darwin, GOOS=linux -tags nogui, GOOS=windows: clean
- set -o pipefail; go test -timeout 45m ./...: exit 0, 68 packages ok
  (gateway 475.6s, provider 173.9s), no FAIL
- broken by hand: keepsLoneNone back to "any plugin" turns the new
  TestToolsOffWithoutToolsNotSentToOtherPlugins red; returning false
  turns TestToolsOffWithoutToolsReachesPlugin red; both green restored

Not tried: no vendor was sent a real request; with this change none
but Grok's plugin path can receive the lone "none", and that plugin
drops it.
2026-10-21 10:25:31 +08:00
yetone 19527ca8dd gateway: tools turned off with none declared reach a plugin as tool_choice none (#3110)
Cause: buildResponses wrote tool_choice only inside its tools block, so a
Chat "none", Anthropic {"type":"none"} or Gemini NONE with no tools was
dropped on the way to Responses. A provider plugin that adds a
server-side tool (Grok's x_search, plugins PR #263) couldn't tell
"tools off" from "no choice". The other builders (Chat, Anthropic,
Gemini, Code Assist) send no tool choice without tools, which is what
their vendors accept (OpenAI Chat refuses a lone tool_choice), so they
are unchanged.

Fix:
- buildResponses keeps a lone "none" (only "none"; "" and "auto"
  still go unsaid).
- forwardTranslated strips it again for every non-plugin upstream, and
  for a plugin on api.x.ai or Copilot (refusesLoneToolChoice, the #378
  rule now shared with passthrough). A vendor never sees it.
- The grok plugin's body shaping (grokPluginBody) keeps a lone "none";
  the built-in's grokBody still drops it. grok plugin 0.1.18
  (magpie-community/plugins aee6b9d, on npm) drops any lone tool_choice
  itself before Grok, so the mover's min goes 0.1.17 -> 0.1.18.

Run at this commit (worktree on efd1b697e):
- gofmt -l: clean
- go vet ./...: darwin, GOOS=linux -tags nogui, GOOS=windows: clean
- set -o pipefail; go test -timeout 45m ./...: exit 0, 68 packages ok
  (gateway 660.6s, provider 270.9s), no FAIL
- broken by hand, each went red then green on restore: removing the
  "none" emit (ReachesPlugin, PerBuilder/responses); grokPluginBody with
  keepNone=false (TestGrokPluginBodyKeepsLoneNone, ReachesPlugin);
  dropping the !p.IsPlugin() check (NotSentToVendor)
- plugins: bun test 2018 pass, 0 fail; the new tool-choice test is red
  against the old index.mjs

Not tried: live Grok, xAI or OpenAI with a lone "none". Other Responses
plugins (commandcode, factory, opendesign, zed) now get a lone "none" in
this case; their vendors take Codex's lone "auto", but this is untested.
2026-10-21 10:14:07 +08:00
yetone a8ecf4020e provider: a check-in file that can't be read or parsed stops the check-in
readCheckins, the reader every daily check-in shares (WorkBuddy, Trae CN,
MiniMax Code, Qoder and the plugins' own), took a file it couldn't read
or parse as empty. The next check-in then asked the vendor again for
every account and wrote its answers over the file: an account could be
checked in twice in one day, and the entries it couldn't read were lost.

readCheckins now returns an error for a file that is there but can't be
read, or doesn't parse into entries (cut short, zeroed, empty, `[]`,
`null`). A file not there is still empty. On the error:
- checkiner.checkinNow asks nothing and writes nothing. Each account it
  would look at is `failed` with the reason (the path and why), so the
  loop tries again after 30 minutes and a press (GUI, TUI, `magpie
  accounts checkin`) says why. The error is logged once while it stays
  the same.
- The readers that only show results (WithCheckins, *Checkins(),
  PluginCheckins) go through shownCheckins, which gives what last read
  from the file in this process, so a card keeps its last good data.
- adoptLegacyPluginCheckins' own strict copy of the read now uses
  readCheckins too.
Docs: providers-accounts.md no longer lists check-in marks among the
caches written over; provider-plugins.md says the plugin file's case.

Test: TestCheckinUnreadableFileLeftAlone writes a cut-short, zeroed,
empty, `[]` and `null` workbuddy-checkin.json, runs the loop and a press
against a fake WorkBuddy, and checks no status or claim request went out,
the file is byte for byte unchanged, and the result says the path; a
folder in place of plugin-checkin.json does the same through a plugin
checkiner. TestCheckinMissingFileIsEmpty and
TestCheckinUnreadableKeepsLastGood cover the other two sides.
Broken by hand (checkinNow taking the error as an empty map again): the
test went red, every case claimed (Asked true), and green once restored.

Run in a worktree at origin/main 62a1df801, sandbox HOME (testenv):
- gofmt -l . : clean
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./... : all exit 0
- set -o pipefail; go test -timeout 45m ./... : exit 0, 68 packages ok,
  none failed (internal/gateway 613s, internal/agent 529s,
  internal/provider 262s)
No red seen, so no issue filed.
2026-10-21 07:23:23 +08:00
yetone 62a1df8010 provider: a plugin's daily check-in reaches every sign-in, also two that share a display name (plugins#254)
AutoClaw's plugin can hold several sign-ins under one default display name,
which AutoClaw doesn't let the user change. plugin_checkin.go keyed each
account's check-in on "<provider>|<AccountID>", the display name, so
checkinNow's per-key dedupe asked only the first sign-in of each name, by
the loop and by Check in now alike; the others stayed 今日未签 for good,
and Settings showed one row, and one Off switch, per name.

Each sign-in is now keyed on the key plugin-auth.json keeps it under
(pluginCheckinKey: "autoclaw|autoclaw", "autoclaw|autoclaw#x1y2z3").
Two sign-ins never share it; a refresh writes the same key, and signing
in to an account already signed in goes back to its key (host.js
settle). The display name is shown only. Cards, Settings rows,
CheckinOff and Check in now all read the same key, so app.js is
unchanged. An account without an AccountID already had this key.

Upgrade (adoptLegacyPluginCheckins, run when the plugin's accounts are
listed): an entry kept as "<provider>|<display name>" goes
- in plugin-checkin.json, to the first sign-in in use of that name (the
  one the old key's check-in asked) and only to it, and the old entry
  is dropped: it isn't asked again today, and its namesakes, never asked,
  are;
- in settings.CheckinOff, to every sign-in of that name: the user turned
  that name off and none of its sign-ins was checked in since, so the
  upgrade switches none on (settings.EditCheckinOff edits that field
  alone from what the file holds).
A plugin-checkin.json that can't be read or parsed is left as it is and
carried over once it reads; writes go through writePrivate
(temp-and-rename). Known gap: a sign-in made the same day after another
was signed out can take the freed key and that day's result.

The fake plugin's check-in now records a signed-in account as
name@fake/uid so two of one name tell apart in the presses.

Tests:
- TestPluginCheckinTellsSignInsOfOneNameApart: four sign-ins, A/u1, A/u2,
  B/u3, B/u4 (the reporter's case). All four pressed once, none again
  that day, four entries kept, four Settings rows, every card marked;
  with A/u2 off, Check in now the next day presses the other three.
- TestPluginCheckinCarriesOverDisplayNameEntries: a plugin-checkin.json
  with fakeco|A@fake and fakeco|B@fake claimed today plus another
  plugin's entry, and CheckinOff ["workbuddy|123", "fakeco|B@fake"].
  A's check-in goes to its first sign-in only, the old entries go, the
  other plugin's stays, both B sign-ins are off and workbuddy|123 is
  kept; the loop then presses only A's namesake, and a second look
  presses nothing.
- TestPluginCheckinCarriesNothingOverAnUnreadableFile.

Broken by hand, each red:
1. key back on the display name: TellsApart pressed only A@fake/u1 and
   B@fake/u3; CarriesOver kept the old entries.
2. adoption not called: CarriesOver ("A's check-in went to ... ok false").
3. record to every heir: CarriesOver ("carried to both") and Unreadable.
4. Off to the first heir only: CarriesOver (CheckinOff lacks one B).
5. old entry kept: CarriesOver and Unreadable.
6. parse error ignored: Unreadable.

Run at 0f044e944 (origin/main) plus this change, macOS arm64, sandbox
HOMEs from testenv, shared GOCACHE:
- go test -race -count=20 -run TestPluginCheckin ./internal/provider: ok
- gofmt -l on the changed files: prints nothing
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows
  go vet ./...: clean
- go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok
- go test -timeout 45m ./...: exit 0, 68 packages ok, no FAIL
- after a comment-only rewrap: go test ./internal/provider
  ./internal/settings: ok
No GUI suite: internal/gui/assets is unchanged.
Not tried with real AutoClaw accounts or a real plugin-checkin.json from
the reporter.
2026-10-21 07:04:19 +08:00
yetone f76201a84a plugins: a sign-in page the plugin's CLI opened isn't opened again, Grok's opened twice on macOS (andyfmyth on X)
"magpie里的grok 登录验证 在mac下 似乎每次都会弹两次验证, 在浏览器窗口里".
Grok's plugin signs in through `grok login --device-auth`, and Grok Build
(1.0.50, the webbrowser crate) opens the device page itself, through
NSWorkspace on macOS and ShellExecuteW on Windows. Neither reads $BROWSER;
the macOS binary has no "BROWSER" string. magpie then opened the same URL
from /api/plugin-signin (desktop), startPluginSignIn/followSignIn (a
browser tab) or `magpie plugin login`. Reproduced in a sandbox
HOME/GROK_HOME: grok's device-code tab appeared in Chrome with magpie not
involved, with and without SSH_CONNECTION. Built-in grok is retired
(2927a161e), so the plugin's path is the only one.

- The plugin's authorize result can say `opened: true` (not OpenCode's).
  host.js passes it on as Authorization.Opened, then SignInState.Opened,
  and the desktop handler, the CLI and app.js (both open points) open
  nothing then; the link is still shown.
- opencode-grok-auth 0.1.17 (magpie-community/plugins 47fbf63, on npm per
  `npm view --prefer-online`) says opened on darwin/win32, and elsewhere
  gives grok BROWSER=true, a no-op, so magpie stays the one opener there.
  The grok mover min is raised to 0.1.17.
- No other plugin's CLI opens a page: devin, cursor, kiro and qoder run
  status/refresh commands only.
- docs/subsystems/provider-plugins.md says so.

Tests:
- TestPluginSignInPageOpensOnce: the fake plugin signs in through
  /api/plugin-signin. "cli-opened" opens 0 pages; otherwise 1. Red with
  the old gui/plugins.go ("opened 1 more times").
- plugin-signin-opened.test.cjs: in a browser tab, right away and after
  an install, 5 languages, Chromium and WebKit. Every "opened" case is
  red on HEAD's app.js (23 fail); 42/42 with the change.

Run at the change (base origin/main 2ceff7370):
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean.
- go test -p 4 -count=1 ./... -timeout 45m (load 150-380): every package
  ok except two.
  - gateway: TestVisionWaitIsntTheDescribersTime. It passes alone; filed
    as #2901.
  - gui: TestDockReopenKeepsTheWindowsSpace, TestMainWindowCorners,
    TestMainWindowRightToLeft, TestTrayCellClickReleasedPanel and
    TestCoveredWindowStaysUp, killed at their deadlines. All pass alone
    with TestPluginSignInPageOpensOnce; filed as #2645/#1936.
- GUI, both engines, at most 2 workers: plugin-signin-opened,
  plugin-signin, plugin-signin-no-url, plugin-moved-signin,
  signin-paste-plugin, signin-browser-down, signin-link,
  plugin-password-prompt and plugin-replaced. The run went 126 pass,
  10 fail, all launch or 5s timeouts at load ~380. Alone,
  plugin-signin-opened passes in both engines and password-prompt
  passes. signin-browser-down was red in one case per run, a different
  one each time. plugin-moved-signin (Chromium) is red alone at HEAD's
  app.js too. Both are filed as #2900.
- plugins: bun test packages/grok 49 pass; scripts/check.mjs ok. Its
  publish run is red only for middleware-think-tags's npm trust
  (plugins#180); grok 0.1.17 was published.
2026-10-19 12:42:48 +08:00
yetone de671719a0 provider: a retired built-in's failed move is tried again in 10 minutes, not 6 hours
A failed move waited moveRetry (6h) before KeepRetiringMoved tried it
again. That was fine while the built-in carried on serving the accounts.
A retired built-in serves nothing, so a move that failed for a moment
(npm out of reach, or the plugin listed in plugins.json but not installed
yet, which the real-account run on 85b8f6d4d hit with Command Code: the
first Move failed, the second worked) left the user's subscription
unserved for up to 6 hours unless they pressed Move.

- retryWait(id) is retiredRetry (10 minutes) for a retired built-in, and
  moveRetry otherwise. MoveRetiring and HandOver both use it (retryDue).
- KeepRetiringMoved's next run is brought forward to when a retired
  built-in's failed move is due (nextRetiringRun, at least a minute),
  instead of always an hour.
- docs/subsystems/provider-plugins.md says so.

TestMoveCutShort now also checks:
- a failed move 11 minutes old waits while the built-in serves it, and
  the next run is an hour;
- once retired, the next run is 10 minutes, it isn't tried at once, and
  it is moved after retiredRetry.

Broken by hand, each red:
- retryWait returning moveRetry for a retired built-in:
  "a retired built-in after retiredRetry: map[]"
- nextRetiringRun always an hour:
  "the next run after a retired built-in's failed move: 1h0m0s, not 10m0s"

Run: go test -tags nogui ./internal/provider -run TestMoveCutShort: ok.

What was run for the stack, at load ~300 (it was rebased from bad4508c4
onto 1acd79cdf; the only conflicts were in
docs/subsystems/gateway-routing.md, resolved to main's text with each
commit's own edit, checked word by word):

- At this commit's tree (bda209c1f, on 1e643ba7e; then rebased onto 1acd79cdf, where vet on all three systems and internal/gui ran clean):
  gofmt -l clean; go vet darwin/linux/windows clean; go test
  ./internal/provider ./internal/cli ./plugins/search ok; ./internal/gateway
  -run 'Jev|Auto|Review|Plugin|Retire|Move|Search' ok. The full suite
  wasn't run again on 1e643ba7e's four new commits (a provider display
  name, two Jev changes, auto-mode review), none in a file the stack
  touches but the gateway-routing doc; CI runs it before the tag.
- Full suite at 3f0858b6f (on c4aeaec74): gofmt -l
  clean, go vet darwin/linux/windows clean, go test -tags nogui ./...
  -count=1 -timeout 90m: 64 ok, exit 0.
- Full suite at a42a1090c (on 89521b03d) and ee288bc65 (on 717b69f78):
  the same, 64 ok, exit 0. Factory's own min commit (0.1.32) was dropped
  in the last rebase: main raised it to 0.1.33 in b5c76935b.
- Full suite at cbf4626a3 (on bad4508c4): gofmt -l clean, go vet darwin/linux/windows
  clean, go test -tags nogui ./... -count=1 -timeout 90m: 64 ok, exit 0.
  At 4c6c99bbd the same run had gateway red on TestPluginStreamLargeReplies
  only (#2551; passes alone, 181.957s).
- GUI: retired-move 4/0 in both engines. The remaining 519 files ran at
  85b8f6d4d, two at a time (3864 ok, 109 not ok when this was written;
  18 of the reds are browser launch timeouts). Each red file was run
  alone at the head, and those still red were run on origin/main
  bad4508c4:
  - red the same on main, filed: segs-glide 20/20 (#2683), routing-bodies
    (#2559, #2658), routing-model-rest (#2115), routing-keys-fold (#1612),
    routing-wb-restricted (#1905), provider-advanced-fold (#2552), sidebar
    (#2684), s3-sync (#2448), routing-request-metrics (#2571),
    rest-try-now (#2564), quota-name-translated and quota-count-wrap
    (#2228), lightweight (#2638), codex-predictions (#2624),
    gateway-key-models under load (#2648);
  - green alone: plugin-list-error, sessions-paging, plugin-kinds-discover,
    plugin-kernel, session-terminal, routing-time-went, routing-flood,
    routing-context-fold, routing-agent-gone, plugin-local,
    plugin-key-hint, name-suffix-no-names, nav-sub-unroll, model-api-gemini,
    model-api-preset.
  At ee288bc65: retired-move 4/0, routing-compaction 10/0,
  library-ime-scroll 18/0; title-bar-tools 4/6, red the same on main
  2042123f4 (#2740: a reload cuts off sideGwRead's read).
  The stack's only GUI change is the unmoved line in renderMovable, shown
  only when /api/providers has unmoved entries.
- Real accounts through the plugins (85b8f6d4d, sandbox HOME): grok,
  workbuddy, workbuddy-ai, cursor, zcode 200; devin, commandcode-plan,
  mimo-app 200 after a first timeout; qoder 401 shown as lapsed
  (plugins#181, the built-in had no 10605 handling either). Not tried:
  kiro, factory, zed (no account here).
- The built-in-only WorkBuddy model ids: the plugin reads WorkBuddy's live
  list, which doesn't offer them.
2026-10-17 23:15:26 +08:00
yetone 0f1666b387 provider: a built-in can be retired, its plugin serving it moved or not, and its unmoved accounts get a Move line
The owner (10-16) wants every deprecated built-in taken out of magpie,
one at a time. This is the ground for that; it retires nothing yet.

- retiredBuiltins / BuiltinRetired(id) in migrate.go name a built-in
  whose code is gone. Only an id with a mover can be retired.
- PluginServes(id) is Moved(id) or retired. Every gate that asked
  Moved(id) asks it now: sign-in, Factory keys, usage, logins, cards,
  forget, accounts, check-ins, plugin sign-in, the CLI's accounts and
  providers, the GUI's account label.
- A retired row's move.state is plugin, and its id is in onPlugins
  once the plugin is installed.
- /api/providers lists a retired subscription's built-in accounts that
  haven't moved in `unmoved` (MoveCandidate, now with the failed move's
  error and why). The GUI shows a quiet line over the Providers list
  for each, with Move / Try again (unmovedLine), in en, zh, zh-TW, ja
  and de.
- AGENTS.md and docs/subsystems/provider-plugins.md say what a retired
  built-in is.

Run at 270aa1c9c with this change:
- go test -tags nogui ./... -count=1 -timeout 90m: 66 packages ok.
- gofmt -l internal: nothing. GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: clean.
- GUI, both engines, en and zh: retired-move (new, 4/4), plugin-move,
  deprecation-notice, deprecated-subscriptions, plugin-move-unserved,
  plugin-movable-review, i18n-keys: 39 pass.
- TestRetiredBuiltinIsThePlugins -count=20 (it picks a mover at random).

The Move line is the Providers list's own, not a page that could be a
plugin. It took the core's scripts to 1,427,218 bytes, which the budget
main raised in 81313b912 (1,447,000, issue 2612) already holds;
TestCoreScriptBudget passes.

Broken by hand: retired-move goes red with unmovedLine not appended;
TestRetiredBuiltinIsThePlugins goes red with BuiltinRetired's Movable
check dropped.
2026-10-17 23:10:59 +08:00
yetone f550d3699c claude: a SOCKS proxy reaches Claude Code through magpie's HTTP bridge (#2651)
demystify0137's Claude account sits behind a socks5:// proxy. Every turn
was answered 502 after minutes of retries, Claude Code failing each try as
UnsupportedProxyProtocol: it is a Bun binary, and Bun takes only http://
and https:// proxies. magpie handed it the socks5:// URL as HTTPS_PROXY.

Every Claude Code magpie runs for the subscription now gets its env from
one helper, netproxy.EnvForBunWith, which sets the proxy as before and
puts the loopback HTTP bridge (netproxy.Bridge, #1409) in place of a SOCKS
URL: a turn (startRun), the model test (askClaude), /usage (claudeUsage),
sign-in (startClaudeSignIn) and the sign-in check (claudeSignedIn). Where
the bridge can't be used (it doesn't start, or Claude Code runs in WSL
under NAT, which doesn't reach this computer's loopback) the request fails
at once with that reason, instead of Claude Code retrying for minutes.
Other CLIs magpie runs with a proxy (grok, devin, cursor-agent) aren't Bun
(checked their binaries), and the settings.json env writer already leaves
SOCKS out.

What was run:
- Real Claude Code 2.1.302 in a sandbox HOME with a fake API key, through
  a fake SOCKS5 proxy (temporary test, removed): raw socks5:// gave "API
  Error: Unable to connect to API (UnsupportedProxyProtocol)" with 0
  SOCKS connections; bridged it reached Anthropic, 401 "Invalid API key",
  7 SOCKS connections.
- New tests TestEnvForBunWithBridgesTheProvidersSOCKS,
  TestClaudeCodeGivenTheBridgeForASOCKSProxy (turn, askClaude,
  claudeUsage), TestClaudeSignInBridgesASOCKSProxy. With proxied()
  put back to EnvWith both gateway and provider tests went red ("Claude
  Code was given the SOCKS proxy: https=socks5://127.0.0.1:1...",
  "login-proxy: Claude Code ran with HTTPS_PROXY=\"socks5://127.0.0.1:1\"").
- gofmt -l clean; go vet -tags nogui ./... on darwin, GOOS=linux and
  GOOS=windows at 8b1fad8f5: ok.
- Full suite at 8b1fad8f5 (this and #2649 on origin/main 9f9bfc160),
  -tags nogui -timeout 100m, load ~290: every package ok except three
  timing reds outside this change, each green alone with -count=3:
  TestBurstTellsNoSpeed (#2719), TestFXStateDoesNotWait (fixed on main since, bad4508c4),
  TestTaggedReposSlowRead (#1889). internal/agent passed (3659s); at
  -timeout 45m it timed out twice at the earlier base 7660399a1 with no
  --- FAIL before the deadline (#2544), and passed alone at 100m (2790s).
- Rebased onto origin/main 17557132c (7 commits, none in these files):
  gofmt and vet on all three systems, then internal/gateway,
  internal/provider, internal/netproxy and internal/claudebridge at
  9af3bb98b: ok. The whole suite wasn't run again at this head.

Not tried: Windows, or Claude Code in WSL (mirrored or NAT).
2026-10-17 19:55:49 +08:00
yetone 8233eadaec provider, gateway: a plugin's model served at priority has fast mode, whichever plugin (Lovest on Discord)
Since #2514 a plugin can say which tiers its vendor serves a model at
(serviceTiers). CanFast still returned true only for Cursor's plugin, so
no other plugin's models could be a group's fast member or an agent's
fast pick. The Routing and Agents pickers (gui/groups.go, agent/route.go
FastFor) and SetFastPick/SaveGroup all read CanFast, so they refused too.

Changes:
- CanFast: a plugin's model has fast mode when the plugin says it is
  served at "priority", on its Chat or Responses API (pluginTierOn), where
  the gateway sends service_tier. This holds for any plugin. Cursor's
  fast flag and -fast sibling logic are kept below it, unchanged.
- UltraOn/CanUltra: such a model can also be picked Ultrafast when the
  plugin says "ultrafast". Before, plugins were excluded outright.
- forwardTranslated: a plugin's request whose agent spoke Claude's API
  carries fast mode as speed "fast", with no tier. It is now given tier
  "priority" ("ultrafast" for an Ultrafast pick) when the model is served
  at that tier. Before, Claude Code's fast pick on a tiered plugin went
  out with no service_tier.
- The "no fast mode" error names plugins.
- docs/subsystems/provider-plugins.md says all of this.

Test: TestPluginTiersGiveFastMode (gateway, fake plugin with FAKE_TIERS):
- CanFast and CanUltra: fake-1 (priority+ultrafast) true/true,
  fake-resp (ultrafast only) false/false, fake-claude (none) false/false.
- fake-claude is refused as a fast member and as a fast pick.
- A fast group member reaches the plugin's fetch as priority from Chat,
  Responses and Anthropic.
- Claude Code's fast pick sends priority, its Ultrafast pick sends
  ultrafast, and another agent's request sends none.

Broken by hand, each then restored green:
- CanFast's tier check off (the old behaviour): red on CanFast(fake-1),
  CanUltra(fake-1) and the fast member being refused.
- forwardTranslated's Fast-to-tier off: red on the anthropic member, the
  fast pick (nil, want priority) and the Ultrafast pick.
- UltraOn's plugin branch off: red on CanUltra(fake-1) and "no account
  offers Ultrafast".
Existing TestPluginServiceTierReachesFetch, TestPluginModelServiceTiers*
and TestCursorPlugin* pass.

No GUI asset changed (the pickers only read canFast/UltraOK from Go), so
the GUI suite was not run.

Run:
- gofmt -l: clean.
- go vet: darwin, GOOS=linux -tags nogui, GOOS=windows -tags nogui.
- go test -tags nogui -timeout 90m ./... at 9f9bfc160+this: EXIT=0, 66
  packages ok, none failed (agent 3928s, gateway 2739s, provider 785s).
  The timeout is 90m because the load average was ~150-270, and 45m cut
  agent and gateway short on this box earlier today.
- Rebased then onto bf931f82c (4 commits, gateway/gui among them): vet
  of gateway, provider, agent and gui (darwin), gateway and provider
  (linux, windows nogui), and every gateway/provider test matching Fast,
  PluginServiceTier, PluginModelServiceTiers or CursorPlugin, green there.
2026-10-17 18:38:09 +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
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 e733b0722e plugins: a provider plugin says which service tiers a model serves, and Codex offers them (#2514)
Lovest on Discord (#general, v0.1.1267): a provider plugin had no way to
say a model is served at Fast or Ultrafast, so Codex never offered them for
plugin models, and the host dropped the field anyway.

- host.js keeps m.serviceTiers (tiersOf: string ids or {id} objects,
  trimmed, de-duplicated, anything else dropped) as plugin.Model.ServiceTiers.
- pluginCatalog puts them on catalog.Model.Tiers; CodexTiers offers a
  plugin's tiers when it declares any, so codexcat writes service_tiers
  (priority named Fast) into Codex's catalog and /v1/models.
- forwardTranslated keeps service_tier (OwnTier) for a plugin provider only
  when the request is translated to its Chat or Responses and the tier is
  one the model declares (provider.PluginTiers). A request relayed in its
  own protocol was already sent as the client wrote it; unchanged. Cursor's
  fast flag and #1954's ChatGPT tiers are untouched (#1954 not on main yet).
- Docs: serviceTiers in site/public/docs plugins (en, zh, ja) and a
  "service tiers" section in docs/subsystems/provider-plugins.md.

Tests (internal/gateway/plugin_tiers_test.go, fake plugin FAKE_TIERS):
TestPluginModelServiceTiersListed (fake-1 priority=Fast + ultrafast,
fake-resp ultrafast, fake-claude none) and TestPluginServiceTierReachesFetch
(Responses→plugin Chat and Chat→plugin Responses send a declared tier,
drop an undeclared one; same-protocol relays as before).
Broken by hand: OwnTier branch forced false → 3 translated cases red;
CodexTiers without IsPlugin → listed test red; host.js serviceTiers: [] →
listed test red. Restored → green.

gofmt -l clean; go vet -tags nogui with GOOS=darwin, linux, windows clean.
Not tried with a real vendor plugin that serves ultrafast.
Full suite: go test -timeout 45m ./... at af9e0d6b2 (sandbox HOME, load
average ~408 from other sessions): every package ok except agent and
gateway, which timed out at 45m with no failed test (rerun whole: timed
out again, 0 failures), gui (TestMainWindowCorners killed, #1936),
TestVendorThatStopsMidAnswerIsSaid (filed #2535) and
TestSetAnswersWhileDevinAndProvidersHang (#1375). The reds and the tests
running at each timeout (TestCodexKeptOnChatGPT, TestReplyNamesMember)
pass rerun alone, except TestMainWindowCorners (#1936). CI is the gate.
2026-10-16 18:13:15 +08:00
yetone e894443932 trae: a check-in Trae CN refused 9074 says Trae refused it and to check in in the Trae CN app, not that Trae pays only its own app (#1920)
#1920 showed Buddy Switch checking in third-party Trae CN accounts, so
"Trae CN only gives check-in credits to its own app" wasn't true. What is
known is that Trae CN answered the claim 9074 (当前参与用户太多). The
own-app outcome stays as it was (the day's answer, no Check in now), but a
Trae account (By "trae") now has its own text in every place it shows:

- GUI card and Settings line: two new keys in en, zh, zh-TW, ja and de
  ("Trae CN refused this check-in (9074: too many taking part); check in
  in the Trae CN app" / "Trae CN 拒绝了这次签到(9074 当前参与用户太多),
  请在 Trae CN App 里签到"). WorkBuddy keeps the shared own-app key.
- TUI line and cell, CLI: provider.TraeRefusedWords; the cell says
  "签到 refused by Trae CN (9074) · check in in its app".
- trae_checkin.go, workbuddy_checkin.go and provider-plugins.md comments
  and the claim's fallback message say the same. They also note the
  plugin side: since @magpie-community/opencode-trae-auth 0.2.14 the
  account the machine's own Trae CN client is signed in as checks in with
  the client's device id, read only. No id is made up or rotated (#1705).

Ran (worktree at origin/main 9d97fd073, -tags nogui, -p 1):
- gofmt -l internal/: clean. go vet ./internal/{tui,cli,provider} for
  darwin, linux and windows.
- go test ./internal/tui ./internal/cli: ok.
- go test -run 'Trae|Checkin|WorkBuddy' ./internal/provider: ok.
- GUI: usage-checkin.test.cjs and i18n-keys.test.cjs in Chromium and
  WebKit, en and zh: 31 pass, 0 fail.

Broken by hand:
- app.js's card without the Trae branch: the renamed usage-checkin test
  fails in chromium en/zh and webkit en/zh (4 of 4).
- pages.go's ownAppWords without the Trae branch: the new
  TestTraeOwnAppSaysTraeRefused fails.

Not tried: a real Trae CN account. No test checks the CLI line on its
own. The ja, de and zh-TW strings are checked only by i18n-keys.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 118f4f28bf plugin: a community plugin npm doesn't have installs from the plugins repo's dist branch, so a reviewed plugin no longer waits unmerged for an owner's npm 2FA (magpie-community/plugins#84)
npm's Trusted Publishing can't create a package, so a new plugin's first
version needs an owner's 2FA, and reviewed PRs sat unmerged for it. A
trust made after 2026-09-03 also allows stage publish only, which is why
npm refused zed 0.1.7 and zen-free 0.1.7.

The plugins repo now packs every merged version onto its `dist` branch
(scripts/dist.mjs, magpie-community/plugins f5308cd): tgz/<file> and an
index.json with each version's sha512, manifest and README, with no
credentials. magpie still asks npm first. Only when `bun add` fails for a
@magpie-community package at latest or an exact version, and not because
of the user's minimumReleaseAge (that hold is kept), does installDist
fetch the tarball. It refuses the tarball unless its sha512 is the index's,
keeps it in plugins/dist and runs `bun add ./dist/<file>`. A later npm
install replaces it, and pruneDist removes tarballs package.json no longer
names. npmAsk (market version, Update, the hourly check) takes dist's
latest when npm errors or is behind, and Readme falls back to dist's. The
branch is read through jsDelivr when the China mirror switch is on, else
raw.githubusercontent.com. installMu is now held for the whole install,
fallback included.

Run at this head (on origin/main 8d2a4a7da):
- go test ./... -count=1: all ok but internal/gateway, which hit the
  600s default timeout inside a file rename. The disk was at 5.3 GB free
  and the load around 22. Rerun alone with -timeout 30m: ok in 559.7s.
- gofmt -l clean. GOOS=windows go vet ./... ok. GOOS=linux go vet ok on
  every magpie package that doesn't import Wails (its Linux files need
  cgo, which can't be cross-compiled from macOS).
- New tests, with real Bun 1.4.2 against a fake npm and a fake dist:
  TestDistInstallsAPackageNPMDoesntHave, TestDistServesAVersionNPMRefused,
  TestDistRefusesATarballNotItsIndexs and TestDistWanted.
  TestUpdateBunHoldsBackSaysWhy now has dist holding the held version too.
- Broken by hand, each went red: no fallback, no sha512 check, no prune,
  no dist version in npmAsk, a loose file regexp, and no minAge guard.
- The real dist branch serves index.json and zed's 0.1.7 tarball from
  raw (200). jsDelivr's @dist answered 200, cold in ~20s.

- Real use, sandbox HOME, live npm and live dist: Info said zed 0.1.7
  (npm has 0.1.6), and Add@0.1.7 installed it from dist, package.json
  naming ./dist/magpie-community-opencode-zed-auth-0.1.7.tgz.

Not tried: the GUI's Add on the live branch, or the China mirror path.
2026-10-15 05:18:56 +08:00
yetone 4e9335c96c plugin: Windows on ARM downloads Bun's native windows-aarch64 build and runs plugins, not "Bun has no build for windows/arm64" (#2183, EdwinDigital)
bunTargetFor turned windows/arm64 away, so magpie-windows-arm64.exe
listed a plugin as on while its host never started, and its providers
never showed. Bun publishes bun-windows-aarch64.zip (1.4.2 and later),
so windows/arm64 now maps to it, with no baseline suffix (arm64 has no
baseline build). Its SHA-256 a7a16b87…0cfd is added to bunSums, taken
from Bun 1.4.2's SHASUMS256.txt, so the download is still checked and
can come through a mirror. The provider-plugins page says so.

What was run (macOS arm64, sandbox HOME, private GOCACHE):
- TestWindowsOnArmGetsNativeBun (new): with windows/arm64 stubbed,
  Bun() downloads bun-windows-aarch64.zip from an httptest release and
  runs it; the checksum is the official one. Old bun.go: FAIL
  "bunTarget = "", Bun has no build for windows/arm64".
- TestBunTargetForMusl gains windows/arm64 and now checks every
  target has a checksum; TestBunDefaultSums and TestBunTarget list
  bun-windows-aarch64. Both FAIL on the old code.
- go test ./internal/plugin/ ok; gofmt -l clean; go vet darwin,
  GOOS=linux -tags nogui, GOOS=windows clean;
  GOOS=windows GOARCH=arm64 go build ok.
- Downloaded the real bun-v1.4.2/bun-windows-aarch64.zip: SHA-256
  matches, it holds bun-windows-aarch64/bun.exe, a PE32+ Aarch64 binary.
Not tried: a real Windows ARM64 machine (the Windows box is x64), so
the plugin host starting on that bun is not verified.
2026-10-14 20:56:18 +08:00
yetone 33da86c71a provider: removing a plugin sets its providers' model picks in providers.json aside, and adding it again puts them back (#2057, dawn1095)
A plugin's provider leaves a record in providers.json once the user
picks its models: its id and nothing of its own (OnlyPicks). Removing
the plugin left those records behind. Nothing listed them, `magpie
provider rm` couldn't reach them, and a sync or backup asked for a
sign-in to them on every run.

RemovePlugin now finds the ids the plugin's providers are stored under
(PluginID of each provider plugin.Listed gives for its spec), and moves
the records with those ids that hold only picks into providers.json's
new pluginLeft, under the plugin's package name. Left alone:
- any record with an endpoint or a key (the user's own provider,
  whatever its id);
- a built-in's ids (accountIDs) and "magpie";
- an id another installed plugin serves too;
- everything, when the plugins' listing isn't known (no cache and no
  plugin-providers.json): unknown is not "none is the user's".
provider.AddPlugin (CLI, GUI, backup restore) puts the set-aside
records back, each one whose id has no record now; one the user has
given to a provider since stays aside. plugin.Listed is new: the cached
listing, or plugin-providers.json.

Run:
- plugin_left_test.go, four tests with user-owned records beside the
  plugin's (a user "zap" with an endpoint next to the plugin's
  zap-plugin, a hand-made "mine", a built-in's picks, another plugin's
  and a shared id). Each guarantee broken by hand turned its test red:
  no set-aside, no OnlyPicks check, no other-plugin exclusion, no
  unknown-listing guard, take-back over the user's record, no take-back.
- go test ./... in a sandbox HOME; gofmt -l; go vet darwin, linux
  (-tags nogui), windows.
Not done: records left by plugins removed before this change stay where
they are; turning a plugin off (not removing it) sets nothing aside;
`magpie provider rm` still can't name such a leftover. The move flow
(installPlugin) still adds through plugin.Add, since its own
migration owns those records. Not tried with a real plugin removal in
the GUI.
2026-10-14 13:20:13 +08:00