Commit Graph
111 Commits
Author SHA1 Message Date
yetone ddd6c649b3 draw: a plugin's model that says it gives images alone is an image model
maonekone (Discord #feedback, 11-09): a plugin can't say which of its
models draw; magpie took a plugin's image model only by its name
(DrawsID and ImagesAPI words). Now a model the plugin lists with
modalities.output ["image"] (no text), on its openai-compatible API, is
listed among the drawers and drawn at the images API through the
plugin's fetch, whatever its name. A model that answers in text and
images still chats.

Run (mote): TestPluginDeclaredDrawerDraws red on the old code ("drawers
[]"); with only the listing change, red again (the draw went to chat
completions); green with both. go vet ./internal/gateway ok; go test
-run "Draw|Image|SenseNova|Loomy|Plugin" ./internal/gateway ok (74s).
Not tried: a real plugin declaring such a model; the full suite.

Reported-by: maonekone (Discord #feedback)
2026-11-09 22:39:41 +08:00
yetone 5611e7274e plugin: a plugin's sign-in words show in the window's language when it gives them
mahiro233 on Discord (v0.1.3372, Kiro plugin 0.1.34): in a Chinese
window, the Kiro sheet's "Choose a sign-in method" and its choices read in
English, while the rest of the sheet is Chinese. magpie showed a plugin's
method labels, questions and choices only as the plugin wrote them, and no
plugin had a way to give them in another language.

A plugin may now give them by language, magpie's own fields beside
OpenCode's English, as a page gives its titles: a method's labels, a
question's messages, a select option's labels and hints, each
{"zh": "…", "zh-TW": "…", "ja": "…", "de": "…"}. host.js passes them on
(byLang: string values, codes of 1-16 characters, at most 16, empty ones
left out); plugin.Method and plugin.Prompt carry them; the app shows the
window's language, then its first part, else the English (inLang), on the
way picker, a question, its choices and their hints, a key's field and
the site step's other ways. `magpie plugin login` stays English. Kiro
0.1.35 gives its words in all four (plugins 588b3611).

Tests: TestPluginSignInWordsByLanguage (a plugin's words reach magpie as
given, bad ones left out, none for a plugin that gives none);
TestPluginOwnIconAndKeyHint compares a Method with reflect.DeepEqual now
that it holds a map. The GUI side is checked by plugin-ask-ways.test.cjs
in the next commit.

Run on mote at this tree: gofmt -l empty; go vet ./internal/plugin
./internal/provider ./internal/gui (darwin), linux -tags nogui, windows:
ok; go test -count=1 ./internal/plugin ./internal/provider ./internal/cli:
ok. Broken by hand: with origin/main's host.js the new test fails (no
labels, messages or hints reach magpie). Not tried: a real Kiro sign-in
(no keys or passwords entered anywhere); the full suite is queued on mote
under suite.lock after the push.
2026-11-09 18:29:55 +08:00
yetone a6a99717e0 gateway: thinking with no signature never goes to Claude
citricdu (Discord, 0.1.3356): Claude Code auto-compacted a session on a
Smart group that had moved to Cursor's Grok 4.7, then the group went
back to Kiro's Claude Opus 5.5. The compacted history kept a thinking
block Grok made, which magpie hands a Messages client signed "", and
Kiro answered 13 times in a row with a bare invalid_request_error. The
same request without the block was answered.

withoutForeignThinking dropped only DeepSeek's UUID-signed blocks and
kept an empty signature on purpose ("a block with no signature Claude
takes"), and Kiro's refusal names nothing boundRefusal reads, so
refuseBoundThinking never mended it. Now every thinking block whose
signature is empty, blank or missing is left out for an upstream
serving Claude (api.anthropic.com, or a claude- model: relays, Bedrock
and Vertex ids, a plugin's fetch such as Kiro's), on every route
forwardOnce takes (relayed, translated, plugin, count_tokens), and
refuseBoundThinking runs it too. Text, tool_use and tool_result stay;
Claude's own signed thinking and redacted_thinking are untouched. A
model that learned thinkingBackNeeded (DeepSeek under another name)
keeps its unsigned blocks. Chat and Responses translated into Messages
already dropped unsigned thinking in anthropicBody.

Tests: TestUnsignedThinkingNotSentToClaude builds the reporter's shape
(the compaction summary, then two tool turns opening with Grok's
thinking signed "") against a fake Kiro that gives the same bare 400,
relayed and through the fake plugin's fetch (FAKE_KIRO model added).
TestGrokThinkingThenClaude runs the switch itself: a group answered by
a Chat Grok, then moved to Claude mid tool loop.
TestWithoutForeignThinking adds an unsigned block, Bedrock and Vertex
ids, a missing and a blank signature.

Run (mote, at this head rebased on 136178803):
- gofmt -l: clean; go vet ./internal/gateway: clean
- go test -run 'TestUnsignedThinkingNotSentToClaude|TestGrokThinkingThenClaude|TestWithoutForeignThinking|TestDeepSeekThinkingThenClaude|Bound|TestPluginBoundThinkingLeftOut|ThinkingBack' ./internal/gateway: ok
Broken by hand: the old predicate (DeepSeek signatures only, the
"signature" precheck only) put back: TestWithoutForeignThinking,
TestUnsignedThinkingNotSentToClaude/relayed and
TestGrokThinkingThenClaude fail (Kiro relay 400 "Improperly formed
request."). The plugin subtest passes on the old code too.
Not run before push: the full suite and the Linux/Windows vet; they
are queued behind other sessions' suites, and their result follows.
Not tried: a real Kiro or Anthropic account; Kiro's exact error text
is the reporter's description, not captured bytes.

Reported-by: citricdu (Discord)
2026-11-09 17:24:09 +08:00
ggbdpq 3da58c3dfc fix(plugin): end ordinary RPCs' plugin work when their caller leaves (#4678)
A plugin model list's deadline and an ordinary RPC's cancellation released
only the caller. inTime raced the hook without stopping it, and host.go
marked only gatewayRequest cancellable, so a cancelled usage or providers
call never told the host: the plugin's task kept running, the host's
pending count kept it, and repeated reads left task after task alive past
their callers. Reported with an offline host-script reproduction that
shows abort reaching none of three pending usage tasks and five model
tasks outliving their deadlines.

The cancellation path a fetch and a gateway request already take now
carries ordinary RPCs too:

- host.go marks every call but init cancellable, so a caller whose
  context ends has the host told (the existing callAborting write), the
  way it already tells it of a stopped fetch. init is left alone: a start
  that overruns is stopped whole.
- host.js registers each ordinary RPC's AbortController; an aborted
  RPC's answer, nobody's then, is not sent.
- the handler is handed the signal: usage passes it to the plugin's
  auth.usage hook as its own options, and a model list's hook options
  carry it, with the listWait deadline aborting the same controller, so
  vendor I/O that supports stopping stops at the deadline or when the
  caller leaves, whichever comes first.

Sign-in renewal and its persistence are untouched: fresh() runs before
the hooks, and an aborted RPC's handler still finishes what it saves.

Refs #4678

Generated-by: GLM-5.3-Flash (ZCode)

Reviewed and ported, narrowed: an aborted ordinary RPC is no longer
answered "Aborted" at once and dropped from pending. It stays pending
until its handler ends, as on main. host.go's stop() closes the host's
stdin and then gives a renewing host up to stopRenewing to save the
rotated token; with the early done(), host.js's own `pending === 0 &&
closed` exit ended the process at once under a cancelled call whose
handler was still renewing or saving (keepSignedIn, set, signOut, a
usage hook mid-refresh). The Go side needs no answer: an aborted call
is released once its abort is written. The signal to the usage and
models hooks, and the listWait deadline aborting the models hook, are
kept as the patch had them.
TestCancelledCallKeepsTheHostTillItsHookEnds is new: a usage hook that
ends 600ms after its abort, then Settle() closing the host's stdin; the
hook's end must reach its trace.

Run on mote (darwin arm64, Go 1.26.8, Bun via testenv): go test -tags
nogui -count=1 ./internal/plugin/... ok 102.8s; -run Plugin
./internal/gateway/ ok 52.1s and ./internal/provider/ ok 13.3s.
Broken by hand: host.js and host.go at main, tests kept:
TestOrdinaryCallCancelTellsTheHost FAIL "the host was told of the
cancellation didn't happen", TestCancelledUsageReachesThePlugin FAIL
"the plugin's usage hook was handed a signal didn't happen",
TestModelListDeadlineTellsTheHook FAIL "the models hook was handed a
signal didn't happen". host.js as the patch had it (early answer):
TestCancelledCallKeepsTheHostTillItsHookEnds FAIL "the host left
before the hook ended; trace: {"signal":"live"}...".
Not tried: the reporter's replay.py against the built host, and a real
plugin's usage hook that passes the signal to its fetch. The reporter's
"host lives on after stdin closes with a task pending" row is unchanged
by design: that is the renewal safeguard.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-11-06 05:53:23 +08:00
yetone ed7aeb052f plugins: a package that declares magpie.agent is an agent, with a main or without (plugins#737)
miaocell's magpie-agent-deva ships a Bun module as its main beside its
moejs agent file (deva.agent.js), because the agent needs a runtime. The
market's GitHub list decided the kind by whether a main was there, so it
listed the package under Providers, and the Installed row wore a Provider
chip and a provider logo though the module serves no provider.

Now readTagged gives Kind "agent" to any package that declares
magpie.agent; middleware, page and hooks still need no main to be that
kind. The file looked for in the repository is still the module Bun
loads (its main), or the agent file when there is no main. The Installed
row of an agent plugin wears Provider only when its module serves a
provider, and its logo is the agent glyph unless it does. The moejs
descriptor contract is unchanged. The community registry.json already
gives kimi-desktop and reasonix-desktop (both with a main) kind agent;
the plugins repo's check now fails an agent package listed as any other
kind.

Docs: docs/reference.md, docs/subsystems/provider-plugins.md, and
site/public/docs plugins.html in en, zh and ja say an agent that needs a
runtime keeps its agent file and adds a Bun main, and is listed as an
agent either way.

Run (on mote, at this head rebased on b047cfe73):
- TestTaggedAgentWithMain (new; the reporter's real package.json,
  index.mjs and deva.agent.js in testdata): go test -run
  'Tagged|PkgEntry|Readme|GitHub' ./internal/plugin ok. Red with
  github.go at its parent: kind "".
- plugin-agent.test.cjs (new rows: an agent with a main and no
  provider, one switched off, one that serves a provider), chromium and
  webkit, en, zh, zh-TW, ja, de: ok. Red at origin/main b047cfe73: the
  deva row's chips were [Agent, Provider].
- Every plugin*.test.cjs plus i18n-keys, both engines: 1090 of 1094 ok.
  The 4 reds are plugin-move-unserved "Try again takes the models
  unticked" (Model 1 folded behind "Show the other 29"), red the same
  at origin/main b047cfe73; filed as #4410.
- gofmt -l, go vet ./internal/plugin ./internal/gui, GOOS=linux and
  GOOS=windows go vet ./internal/plugin, go test -run 'Budget|I18n'
  ./internal/gui (TestCoreScriptBudget, budget not raised): ok.

Not tried: installing magpie-agent-deva from the real GitHub list in a
running app (the list is read from the test server); Windows and Linux
runs of the GUI tests.
2026-11-05 03:54:41 +08:00
yetone 79477604a5 providers: a plugin option that says placement "top" sits under the accounts, above Routing (#5269)
mycf_711 (#5269): WorkBuddy Pro's plugin-level "panel" switch was drawn in
Plugin options, under the whole model list, so it took a scroll every time.
An option in auth.options may now say `placement: "top"`: the provider's
editor draws those in a Plugin options block right under the accounts,
above Routing, and the rest under the models as before. The note that the
plugin reads them goes with the first block. host.js keeps placement only
when it is "top" (anything else is left out, so the option goes under the
models), and plugin.Option carries it to /api/providers. A plugin that says
no placement is drawn exactly as before, and an older magpie ignores the
field. Documented in docs/subsystems/provider-plugins.md and
docs/reference.md.

Run (mote, through mote-run):
- new internal/gui/tests/plugin-option-placement.test.cjs: chromium 31/31,
  webkit 31/31 (1100 and 420 wide, en/zh/zh-TW/ja/de; mixed, top only,
  none or an unknown placement; the top switch posted on Save).
- plugin-options.test.cjs 11/11 and plugin-option-words.test.cjs 21/21,
  i18n-keys 4/4, each in chromium and webkit.
- go test ./internal/plugin ok (TestPluginOptions checks "top" kept and
  "sidebar" left out); go test -run Budget|Script|Asset ./internal/gui ok.
- gofmt -l internal/plugin empty; go vet ./internal/plugin ./internal/gui
  ./internal/cli, GOOS=linux -tags nogui and GOOS=windows vet of
  internal/plugin ok.

Broken by hand:
- app.js put back to its parent: the placement test fails "mixed" and
  "top" in both engines (blocks under the models), "none" still passes.
- host.js's placement line removed: TestPluginOptions fails
  "second = {... Placement:}".

Not tried: a real WorkBuddy Pro plugin (Gitee, private) with the field;
the full go test ./... and the whole GUI suite run after the next commit.
2026-11-05 00:55:36 +08:00
yetone 083821dc96 plugins: a search entry can use the plugin's own sign-in, with its own rests
Asked for by axelburks on Discord. A plugin's search hook entry can name
a provider its own auth hook signs in to, `auth: "<provider id>"`. It then
takes no key. The host picks an account, renews it under `fresh` (the wait
counts within the search's time), runs the hook in `inScope`, and gives it
`ctx.getAuth()`, which returns that account's sign-in. A token the hook saves
with client.auth.set goes to the same account.

The gateway (askSearchSignedIn) asks one account at a time. It takes the
accounts that are on, in the order the provider's model requests take them
(accountsOn, now shared with fallback.go), and puts an account resting from
a search refusal last. A refusal rests only that account's search
(restSearchKey "account <key>"), never its models' rest (restingUntil). Every
attempt gets its own request-log row. An entry without `auth`, or naming a
provider the plugin doesn't sign in to, is a keyed entry as before, with no
getAuth. In Settings → Search, a bound entry shows "Signs in with {name}" in
place of the key field, and the row says whether it is signed in and how
many accounts are on (every language).
Docs: reference.md (with an example), plugin-runtime, plugin-tools and
provider-plugins.

Run on mote at f44fa2ef6 + this change. After rebasing on acd789d45 (an
unrelated responses_ws change), go build ./... and -run "Search|Budget"
on plugin, gateway and provider are ok again at this tree.
- gofmt -l clean; go vet ./internal/... ok; Linux and Windows vet of
  plugin/gateway/provider/gui ok
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway ./internal/gui: plugin, provider and gateway
  ok; gui red only in TestMainWindowCorners/macOS_26_SDK, mote's
  macOS 27 title bar, already filed as #3949
- node --test on 15 GUI files: search-signs-in, search-api, search-keys,
  search-order, search-all, search-first, search-instead, searcher-pick,
  searcher-then, provider-search, settings-search, i18n-keys, gui-zh-tw,
  gui-ja, gui-de. 207 of 207 pass (chromium and webkit, 980/420px, en/zh).

Broken by hand. Each break made its test red:
- B1, no ctx.getAuth: plugin TestPluginSearchSignsIn "ctx.getAuth is not a
  function"
- B2, no renewal: "searched as due@seek acc-due", "the renewal never began"
- B3, gateway with no auth branch: gateway TestPluginSearchSignsIn "signed
  in: k9 undefined"
- B4, a refusal that also rests the model account: "a search's rate limit
  rested a@seek for its models"
- B5, getAuth handing out the provider's first account: "as the second
  account: a@seek acc-a"
- B6, the hook run outside inScope: "a token saved while searching as b: a
  rotated-b@seek"
- B7, getAuth given to every entry: "keyed: k9 function"
- settings.js showing the key field for a bound entry: search-signs-in red
  in every engine, width and language

Not tried: a real search vendor or Axel's own plugin; real accounts; runs
on the Windows or Linux boxes; the full GUI suite. The full go test ./...
runs after the push.
2026-11-04 20:55:42 +08:00
yetone 75e30625f5 plugin: a command that serves no pages moves a page's service off the app's port (#5187)
MYCF711 (#5187, Windows, 0.1.2901): magpie plugin update run while the
app runs hung with no output. Its host loads every plugin, and
page-chat's service waits for port 3477, which the app's host holds:
each CLI command that starts a host waited ~6s on it, then kept trying
the port every second in the background, so it could take 3477 from
the app's host when that restarted after the update.

Now magpie run with a command that serves no pages (anything but the
app, tray, tui, web, serve, a bare magpie or a magpie: link opened in
the app; servesPages) sets plugin.ServePages(false), and its host hands
a plugin whose magpie.page.service names an option a free port of its
own in that option (hostOptions). The plugin's other parts load at once
and the app's port is left alone. plugins.json is not changed, and a
service no option moves is started as before. The class, not
page-chat: any plugin page service declared with an option.

Run, at base 0ee424e3e plus this change:
- mote: go vet ./internal/plugin ./internal/cli (darwin), GOOS=linux go
  vet -tags nogui and GOOS=windows go vet of both, GOOS=linux nogui and
  GOOS=windows builds, go test -count=1 ./internal/plugin ./internal/cli:
  ok (280s, 65s). gofmt -l clean.
- Broken by hand: hostOptions handing options unchanged makes
  TestHostServingNoPagesLeavesHeldPort red (the load "didn't finish in
  10s") and TestHostOptionsMoveOnlyTheService red; servesPages returning
  true makes TestServesPages red on daemon, autostart, providers.
- Windows (xiaomi-gpu, win-run): the new tests and TestServesPages ok.
  Sandbox with page-chat and the reporter's git plugin
  (KevinFX-code/magpie-wps-lingxi), nogui builds:
  - 3477 held by bun, magpie plugin update: 13.9s before (page-chat
    "被占着" then "每秒试一次"), 10.6s after (page-chat "listening on
    127.0.0.1:51493").
  - beside magpie serve's host on 3477: 13.98s before, 12.4s after;
    serve's host keeps 3477.

Not tried / not reproduced: the reporter's literal no-output hang. Before
this change, update finished on 0.1.2909 in every setup tried (nogui
CLI with 3477 held, beside nogui serve, beside the release GUI exe in
the interactive session: 6-20s), so this removes the wait and the
port contention seen, not a hang reproduced. Not tried on Linux or the
macOS app.
2026-11-04 16:25:02 +08:00
yetone cd83c3147f plugin: a hook's auth.set doesn't sign in again an account signed out while it ran (#5126, #5119)
Cause: a plugin hook that saves a sign-in through client.auth.set (a
models list spending a rotating refresh token) wrote it into
plugin-auth.json unconditionally. A listing that began before a
sign-out, or before a failed move's putBack took the accounts back out
of the plugin (plugin.Take), landed after it and wrote the account in
again. TestMoveToPlugin's reset signs fakeco out, but a background
listing set off by the step before spent a@fake's "rot-a" token again
(rot-a+++++ seen in the file right after the sign-out), so the next
Move saw a@fake as the plugin's own (movedAccount.Was), restored it on
failure, and "the plugin kept an account of a failed move".
TestMoveCutShort (#5119) fails the same way: the account Take removed
came back through the same write. Not a leak between runs: the race is
inside one run, and more runs only gave it more chances. It is a real
bug for users too: signing out of a rotating-token account while its
models are listed brought it back.

Fix: inScope in host.js notes whether the account was signed in when
the call began (had); auth.set skips the write under the file's lock
when it was and is gone now, as renewLocked already does for renewals.
Sign-in steps (signingIn) are not held to it, their account is new.

Test: TestSignOutOutlastsRunningHook holds the fake plugin's models
hook (new FAKE_MODELS_HOLD: marker file in, release file out) across a
SignOut in a real host and checks the account stays gone, and that a
hook not raced still keeps the token it saved.

Run (all at this tree):
- mote-run go test -count=30 -run 'TestMoveToPlugin$|TestMoveCutShort$'
  ./internal/provider: ok. Before the fix the same run on mote failed
  3 TestMoveToPlugin + 9 TestMoveCutShort of 30 each; -count=15 of
  TestMoveToPlugin alone failed 2 to 4 of 15.
- wsl-run go test -count=20 of the two plus the new test: ok. Before
  the fix: 4 + 17 of 20 failed on Linux.
- mote-run go test -count=5 -run TestMoveToPlugin$: ok.
- mote-run go test -count=5 TestSignOutOutlastsRunningHook: ok.
- mote-run go test -timeout 45m ./internal/provider ./internal/plugin:
  ok (provider 171.6s, plugin 160.4s).
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet of both
  packages: ok.

Broken by hand: host.js reverted with the test kept:
TestSignOutOutlastsRunningHook red 3 of 3 ("the hook signed the account
in again"), and the provider tests red as above.

Not tried: a real vendor's rotating-token plugin signed out mid-listing
(the fake plugin's rot- sign-ins stand in for it); the full ./... suite
runs after the push.
2026-11-04 13:23:28 +08:00
yetone 90bf96a23d search: a plugin can give a web search API (its search hook)
treeman on Discord #help asked for web search to be pluggable so users can
add search vendors. A plugin's `search` hook, {search: {<id>: {name, keysURL?,
keyOptional?, url?, execute({query, count, key, url}, ctx)}}}, adds an API to
Settings > Models > Web search as `<plugin>:<id>`. It is added, keyed, ordered,
switched off and removed like Tavily or Brave. The built-in APIs stay built in.

How: host.js collects the hook's entries (id [a-z0-9-], an execute) into
Loaded.Searches and runs one with the `search` op (timeout from ctx, an error
with a numeric status comes back as a refusal). The host notes them in
plugin-searches.json (internal/plugin/search.go); provider.AllSearchVendors
adds the noted ones of plugins that are on to SearchVendors, so Ready, check,
the CLI and the GUI list see them. askSearchAPI hands a plugin vendor to
askPluginSearch below askSearchAPIKeys, so keys, rest on 401/402/403/429,
order, the masked query and the request-log row are the built-ins' own.

Run (mote, on this tree, whose base df7c94bdf was just fetched):
- go test -timeout 45m ./internal/plugin ./internal/provider ./internal/gateway
  ./internal/cli: ok.
- go vet native; GOOS=windows go vet plugin, provider, gateway, cli: ok;
  GOOS=linux go vet plugin, provider, gateway: ok. gofmt -l: empty.
- internal/gui: TestCoreScriptBudget and TestMainWindowCorners fail in a
  full run. This change touches no script (only api.go's loop), so the
  budget red is the base's (re-checked after the rebase, below);
  TestMainWindowCorners is AppKit on mote (macOS 27).
Broken by hand: skipping off plugins in NotedSearches turns TestPluginSearch
red; the refusal mapping removed turns TestPluginSearchAPI red.
Not tried: a real plugin against a real vendor's API; the GUI JS suite (no
GUI script changed); a Linux or Windows window; site/public/docs (en, zh, ja)
do not describe the hook yet. A plugin just added is listed once the host has
loaded it; RestoreSearchAPIs drops a plugin's entry on a machine without it.
The community README has the template (magpie-community/plugins 3ec42d4).

Reported by treeman.
2026-11-04 08:37:21 +08:00
yetone 4c0c6c02b8 plugin: keep idle plugin sign-ins alive in the background (#5080)
A plugin with auth.refresh had a sign-in renewed only when something
used the account (a request, its models, usage or check-in) within its
refreshLead of expiry. An account left idle past its token's life
lapsed. OrcaTerm's WeChat token lives two hours, and after that its
refresh answers SESSION_EXPIRED for good, so the user had to sign in
again (orinsid, magpie-community/plugins#675).

The gateway now renews each such sign-in as it comes due
(provider.KeepPluginsSignedIn, started beside KeepPluginsListed):

- Due times come from plugin-auth.json through filememo
  (plugin.RenewAt: expires less the lead the host reckons, now listed
  as Provider.Renews/RenewLead). Nothing is asked, and no host started,
  until an account is due. The loop sleeps until the next one, at most
  5 minutes, and renews them one after another.
- A due sign-in goes through the host's own renewal (host.js
  keepSignedIn, which shares renewal() with fresh()). It is one at a
  time per account whoever asks: a request arriving meanwhile waits
  for the same promise, under the cross-process lock file, through the
  account's proxy.
- Kept: accounts switched on and not marked, of a plugin provider not
  switched off, hidden (leftAlone) or being moved.
- A failed renewal marks nothing. It is held back for 1m, doubling to
  at most 30m, for that sign-in only. Only the plugin's
  signIn:"expired" marks it, as at a request.
- A plugin can opt out with auth.keepAlive: false. None in the plugins
  repo needs to: no refresh costs quota, the ones rotating single-use
  refresh tokens (Cline, Factory, Nous, SenseNova, CodeArts, Qoder,
  MiniMax) rotate at use already, and kimi-work's reference accounts
  and Raccoon's desktop reuse never refresh another app's token.

Docs: provider-plugins.md "A sign-in nothing uses"; leftAlone list in
providers-accounts.md.

Run at the pushed head, on mote (mote-run), -tags nogui:
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway: ok (109s, 119s, 637s), rebased on origin/main
  6cfe78635. Rebased again on b088fd0f0 (gateway.go, prompt.go
  changed): go build ./..., go vet of the three packages and the new
  tests plus TestLivePrompt*: ok.
- the new tests on Windows (win-run) and Linux (wsl-run): ok.
- GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...,
  go vet ./...: ok. gofmt -l: clean.

Broken by hand, each red, then restored:
- keepSignedIn refreshing by itself, not through renewal()/the lock:
  TestKeepSignedInRenewsIdleSignIns red (r-ok-busy renewed twice
  beside concurrent requests).
- keepAlive:false ignored: red (stayco listed as renewed).
- a network failure reported as gone: red (down: Gone true).
- Go backoff removed: TestKeeperBacksOffAFailedRenewal red.
- the On, Lapsed and leftAlone filters each dropped:
  TestKeptSignInsAreTheOnesSwitchedOn red.
The new tests don't compile on the old code (no KeepSignedIn).

Not tried: a real OrcaTerm account idling past its 2h token with the
gateway running; Windows/Linux runs of the new tests (vet only); a
magpie with many plugin accounts beyond the unit test's look.
2026-11-03 21:01:27 +08:00
yetone 441a2b6b16 plugin: a cancelled sign-in saves nothing, and a failed authorize says why (#5016)
Found reviewing magpie-community/plugins#658 (AStudio's and Agnes Code's
sign-ins wait up to 5 minutes for the vendor's desktop app).

Cancel didn't end a plugin sign-in. The window's Cancel (and the sign-in's
timeout) ended plugin.Finish's context, but "callback" was not a
cancellable call, so the host never heard: the plugin's wait went on, and
a session file written after Cancel still saved the account. Now
authorize, callback and apiKey are cancellable as gatewayRequest is
(host.go `cancellable`): magpie writes `abort`, host.js (`signInSteps`)
drops whatever the plugin answers after it, so nothing is saved, and
counts the call done at once. The plugin's wait is told too: every fetch
it makes for the sign-in carries the sign-in's signal
(`whileSigningIn`), and magpie's hook passes the signal as
callback(code, { signal }) / authorize(inputs, { signal }), which OpenCode
doesn't, so a plugin can stop polling a file. A plugin that ignores the
signal keeps running until its own deadline, but its answer is dropped.

An oauth method's authorize that returned { type: "failed", error } (no
callback) was stored and its missing callback called, so the user saw
"s.a.callback is not a function". host.js now answers that, or any result
with no callback, as the sign-in's failure, and plugin.Authorize returns
ErrFailed with the plugin's reason, for auto and code methods; an api
method's authorize already did. The GUI's start shows it as its failure,
`magpie plugin login` prints it.

Docs: provider-plugins.md, and the plugin guide (en, zh, ja) on failing
from authorize and the signal.

Not changed: #3083's timeout field, #4678's model/usage task lifetime.

Tests (testdata/signinend, no network; the vendor is testenv.FakeVendor):
TestCancelledSignInSavesNothing, TestCancelledSignInEndsThePluginsWait,
TestCancelledSignInEndsItsFetch, TestSignInFailsWithThePluginsReason
(internal/plugin), TestCancelledPluginSignInSavesNothing
(internal/provider, through StartPluginSignIn/CancelSignIn).

Run on mote (macOS 27), at this change on d73f2254d (the new tests and vet of both packages again after the rebase on 897e88d7e, which touches neither):
- go test -count=1 -timeout 45m ./internal/plugin/ ./internal/provider/:
  ok (134s, 145s); the new tests -v: all PASS.
- ./internal/cli ok; ./internal/gui FAIL only in
  TestMainWindowCorners/macOS_26_SDK, #3949 (macOS 27 on mote; this
  change touches no GUI code).
- GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./...: ok;
  gofmt -l: nothing.
- GUI (Chromium + WebKit): plugin-signin, plugin-signin-no-url,
  plugin-signin-opened (en, zh, zh-TW, ja, de), plugin-signin-scrolls,
  plugin-keyless-signin, plugin-moved-signin, signin-paste-plugin,
  signin-close, i18n-keys: 108/108.

Red on the old code (origin/main's host.js, host.go, providers.go): all
four plugin tests (an account saved after Cancel; the plugin's wait and
its fetch not ended, timed out; methods 2/3/4 said "s.a.callback is not
a function"), and TestCancelledPluginSignInSavesNothing.
Broken by hand: host.go's `cancellable` back to gatewayRequest only, all
three cancel tests red; the whileSigningIn line out of the fetch wrapper,
TestCancelledSignInEndsItsFetch red.

Not tried: the real AStudio and Agnes Code plugins (plugins#658) against
this host; the site's plugin guide isn't deployed by this commit.
2026-11-03 13:40:20 +08:00
ggbdpq d97e52aea5 draw: Loomy's Hy-Image generators draw on the images API (#4913)
iFlytek's Loomy gateway serves three image generators, each listed in
its /v1/models with type "image": Hy-Image-3.5-preview,
doubao-seedream-5-lite, qwen-image-3.0-pro. An OpenAI-compatible plugin
in front of it lists all three, and the reporter measured all three
answering a normal OpenAI-shaped draw on the images API with a 200 and
a URL each.

qwen-image and seedream match catalog.ImagesAPI's words, so those two
reach Settings' image generation picker and draw. hy-image matches only
DrawsID's "image", so Hy-Image-3.5-preview stayed a chat model with no
way to pick it for drawing — the same reason WorkBuddy's Hy-Image
models need their wbDrawers path.

Add "hy-image" to ImagesAPI's words: the model is then a drawer on the
plugin's row like the other two, and the gateway asks it on the images
API instead of chat. No other model's answer changes — every id the new
word catches was already a drawer by DrawsID's broader "image"; only
where it is asked moves.

Test: TestLoomyPluginDraws (internal/gateway) installs a fake Loomy
plugin listing the three generators beside a chat model, checks Drawers
lists all three, and draws Hy-Image-3.5-preview (images API, image
back, chat never asked). Broken by hand: without "hy-image" it is red
(drawers [doubao-seedream-5-lite qwen-image-3.0-pro], the Hy-Image one
missing).

Review: applied as ggbdpq posted it (patch sha256 checked against the
issue's). Broken by hand at the reviewed head: catalog.go reverted to
its parent, TestLoomyPluginDraws red; restored, green.

Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
  ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
  catalog, plugin and davsync ok; gateway red on one test only,
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity reaches it in a full package run). It passes run
  alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
  3c2dceb34. That commit changed member.go only, nothing these tests
  reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-03 07:43:18 +08:00
yetone a00b53f7b1 gateway: a plugin's fetch is told the session the agent named and its Claude Code subagent (plugins#620)
magpie builds each plugin's request itself, so the agent's own headers
(x-claude-code-session-id, x-claude-code-agent-id, x-opencode-session)
never reached a plugin. Devin's cache keepalive therefore keyed Claude
Code Auto's permission check by its text alone, and on the translated
path magpie merges consecutive same-role messages, so a check whose
history grew changed its first message in the middle and got a new key:
its older pings kept running beside the new ones (zelong77, plugins#620,
still seen on devin 0.1.33).

forwardOnce now sets X-Magpie-Session (sessionOf: the caller's own
X-Magpie-Session, else the agent's session header) and
X-Magpie-Subagent (Claude Code's agent id) on a plugin's request, after
deleting any the caller sent, and host.js's MAGPIE_ONLY list strips both
from what the plugin sends on, so the vendor never gets them. A request
naming no session has neither. devin 0.1.34 keys its pings by them.
docs/subsystems/provider-plugins.md says so.

Run at origin/main 1829cd52f plus these three commits (mote, macOS):
- gofmt -l internal/gateway internal/provider internal/plugin: clean.
- GOOS=linux and GOOS=windows go vet of the three: ok.
- go test -count=1 -timeout 45m ./internal/plugin ./internal/provider
  ./internal/gateway: plugin ok, provider ok; gateway one red,
  TestCodexPoolSaysTheClientsVersion, which passes alone (-count=3)
  and is another test's Codex identity leaking into it, filed as #4807,
  untouched by this change.
- -v: TestPluginToldTheSession and TestMovedBuiltinsSayTheirPlugin pass.
- Rebased onto origin/main 52195b6b0 (it brings #3388's provider
  change): gofmt clean, linux and windows vet ok,
  internal/provider and internal/plugin ok, internal/gateway -run
  'TestPlugin|TestMoved|Devin|WorkBuddy' ok. Pushed on 9f641daea,
  whose Codex app-server change (codex_app_server.go, codex_daemon.go,
  login_usage.go) touches none of these files; not run again on it.

Broken by hand:
- without the two Set lines in forwardOnce: TestPluginToldTheSession red
  (the plugin told nothing), on relayed Anthropic and translated Chat.
- without the MAGPIE_ONLY entries in host.js: red, the vendor got
  X-Magpie-Session.

Not tried: a real Devin account and a real Claude Code Auto session.
2026-11-02 18:32:47 +08:00
yetone e7fbbaab9f plugin: an author's own listing is kept, for a search to find (plugins#479)
On magpie-community/plugins#479 the owner ruled that registry.json
entries for packages published from their author's own repository
rightly leave out "community": true, and are shown under the
publisher's name, to a search alone. parseMarket dropped every entry
without the flag, so PinK (YuchenWell, plugins#617), and WispTerm,
CiteBox and Wisp Science (hoptoper) couldn't be found in magpie at
all.

What changed:
- parseMarket keeps a listing without the flag; Listing.Community
  says which it is. The new plugin.Community(l) picks the community's.
- Every reader of the market was re-derived:
  - plugins.js already browses community listings alone, matches a
    search over every listing (name, package, summary, providers, npm
    publisher), and shows a non-community card and page under its npm
    publisher, without the magpie community badge. Unchanged.
  - plugin.resolve (a short name like "river") reads the community's
    alone: an author's "pink" stays npm's own name "pink".
  - pluginAgents (/api/plugins/agents, the Agents page's suggestions)
    reads the community's alone, as Discover's Agents section does.
  - plugin.Icon's fallback by provider id reads the community's alone;
    its exact-package match reads all, so PinK's own icon shows.
  - pluginListings and pluginMarketState pass every listing on.
- Docs (en, zh, ja plugins.html) say such a package isn't browsed and
  is found by a search, under its publisher.

Tests:
- TestMarketKeepsAuthorsOwnListings parses registry.json's River and
  PinK entries as they are at plugins 486a68a5 (#617's base, lines
  126-130, PinK without the flag; testdata/registry-pink.json). PinK is
  kept, not community, with its kind, summary and icon; resolve("pink")
  is "pink" and resolve("river") the community's package.
- TestMarketSources now expects the non-community entry kept.
- plugin-authors-listing.test.cjs: PinK isn't browsed (Agents shows
  Kilo, no PinK anywhere), a search by name or publisher shows one PinK
  card under "zhouzhenzhou" with no badge, its page reads
  "zhouzhenzhou · magpie-plugin-pink" with no badge, River keeps its
  badge. en, zh, zh-TW, ja, de; 980 and 420 wide; chromium and webkit.

Broken by hand, each red, then put back:
- parseMarket's `&& l.Community` restored: TestMarketSources and
  TestMarketKeepsAuthorsOwnListings red.
- resolve without Community(): TestMarketKeepsAuthorsOwnListings red
  (pink resolved to magpie-plugin-pink).
- pluginAgents without Community(): TestPluginAgentsNotInstalled red.
- plugins.js Agents without the l.community filter, and the badge shown
  for every agent: plugin-authors-listing 0/22 each.

Run on mote at this head (rebased on a4916aec1; i18n-keys and plugin-authors-listing ran again there, both engines):
- gofmt -l: clean. GOOS=linux go vet -tags nogui and GOOS=windows go
  vet of internal/plugin and internal/gui: ok.
- go test -timeout 45m internal/plugin, internal/provider: ok.
  internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949,
  mote's macOS 27, nothing here touches it).
- At 3086c650b (rebased on 541102eba; the rebase since touched
  host.js, a gateway test and a provider test only): agent, agentplug,
  backup, davsync, library, middleware, usage and plugins/...: ok.
  cli: TestEveryRouteHasACommandOrIsNamed (#4826); gateway:
  TestCodexPoolSaysTheClientsVersion (#4807). Both filed, untouched
  here.
- node --test site/*.test.mjs: 80/80.
- GUI, every file that reaches the Plugins page (agent-plugin-agents,
  i18n-keys, market-*, plugin*; 1078 tests, both engines): 1074 pass,
  plugin-authors-listing 22/22. The 4 reds are plugin-move-unserved's
  "Try again takes the models unticked" (#4410, models folded behind
  "Show the other"), not reached here. The whole GUI suite wasn't run:
  mote held two other sessions' full suites for over an hour, and this
  changes no app.js, plugins.js, layout or API call. That run was at
  f5c956b84; after the rebase on a1f56720c (i18n.js and caller keys
  moved), plugin-authors-listing, i18n-keys, plugin-market and
  plugin-registry ran again: webkit's plugin-authors-listing and
  plugin-market timed out at mote load ~250 from other sessions' suites
  (#4125), and both passed 14/14 alone right after.

Not tried: a real magpie window against the live registry.json (the
listings come from a fixture and a faked API); the Icon fallback's
community-only rule has no test that goes red without it.
2026-11-02 14:12:20 +08:00
ggbdpq f0b9c8af9c provider, plugin: a plugin's word on its model's inputs stands without a word of images
pluginCatalog read a plugin's word on what its model takes only where the
plugin also said whether it takes images: the InputModalities assignment
sat whole behind ImageSaid, so a model said text alone (Command Code's
plans, no word of images, #4436) came out with no input modalities at
all, though the host had passed its inputs through.

But the host's passing them through is not the plugin saying them: for a
config model nothing was said of, the host's own default capabilities
say input {"text": true} (internal/plugin/host.js), and listing that as
the model's word would claim text-only of a model nobody described,
which the readers read as no images — what the #1595 guard exists to
keep out. The first cut gated on the inputs being non-empty and did
just that; this one asks the host whose word the kinds are instead.

inputSaid keeps that default ({"text": true} alone) out: whoever says
the kinds says them each, models.dev and the config expanding them all,
a plugin's models hook giving its own. The model carries inputsSaid as
it carries outputsSaid, and pluginCatalog gates InputModalities on it:
Command Code's plans list their inputs, a model nobody described still
lists none.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-02 07:40:21 +08:00
yetone d614f21721 gateway: a HEIC photo goes to the vendor as JPEG, or PNG with alpha (qikamatata on X)
Pi and Pi Desktop send an iPhone photo dragged in as image/heic, and
DeepSeek flash on WorkBuddy (a plugin's fetch) turned it away; most
vendors take JPEG, PNG, GIF and WebP only.

What: heicAsJPEG (heic.go) runs at the top of Server.serve, after
offAsNone, so every route below sees the converted image: a provider's
own, a plugin's fetch, the describer, every translation. count_tokens
does the same. It walks images through walkImages, the one image walker,
so it covers Chat image_url (string or object), Responses input_image,
Anthropic image blocks and Gemini inlineData, tool results included. It
goes by the bytes (ftyp + an HEVC still's brand), so a HEIC labelled
image/jpeg or image/png is converted too, and a JPEG labelled heic is
left alone. Other fields of the block (detail, cache_control) are kept.
Transparent images go as PNG, opaque ones as JPEG q90.

Cost: a body with no "image/hei" and no base64 ftyp mark ("eXB" + 5
chars, at the same place in any base64 that starts at the file) is not
walked. Caps: 48 MB of base64, 50 MP, the long side written at 4096 px,
one decode at a time, 30 s wait (a late result is cached for the next
turn), a 64 MB / 32 entry cache by sha256, since agents resend a
conversation's images every turn. Any failure, panic included, leaves
the image as it came. Measured on mote (M5 Pro): 12 MP 0.44 s, 24 MP
0.86 s, 48 MP 1.6 s / ~1 GB held, freed at once with FreeOSMemory.

Why gen2brain/h265 v0.2.4: pure Go (release builds are CGO_ENABLED=0),
MIT, no dependencies, SIMD on amd64 and arm64, maintained (latest
2026-10-29). Not chosen: gen2brain/heic (wazero WASM or a libheif dylib
through purego), jdeng/goheif (cgo libde265), OS converters (Windows
needs the paid HEVC extension, Linux tools are often missing).

Tests (heic_test.go, fixtures made on mote with sips, 1.6 KB each):
12 shapes converted with their kept fields, pixels kept, 7 non-HEIC
cases byte-identical, a cut file / a panicking decoder / a timeout go
as they came, and a plugin's fetch (fake plugin, new FAKE_SEES image
model) gets JPEG on /v1/chat/completions and /v1/messages.

Run at this tree (733fac48f + this change), on mote:
- gofmt -l internal: clean
- GOOS=darwin/linux/windows go vet -tags nogui ./internal/gateway
  ./internal/plugin: ok
- CGO_ENABLED=0 go build ./internal/gateway for darwin, linux, windows
  x amd64, arm64: ok
- go test ./internal/gateway ./internal/plugin -count=1 -timeout 45m:
  ok (774s, 134s)
- win-run (Windows amd64) and wsl-run (Linux amd64, AVX2 path):
  go test ./internal/gateway -run HEIC: ok

Broken by hand, each red, then restored:
- no heicAsJPEG call in serve: TestHEICReachesPluginAsJPEG red
- media_type not set for Anthropic: the messages subtests red
- no base64 mark scan: the "labelled jpeg/png" subtests red

Not tried: a real Pi -> WorkBuddy request with a real account; a real
iPhone gridded HEIC (only sips files and Apple's 26 MB wallpaper); a HEIC
behind an http URL (not fetched, goes as it came); Anthropic document
blocks, Responses input_file and images/edits.
2026-11-01 15:04:28 +08:00
yetone e84870f173 plugins: an option's words in the window's language, and a filtered model list says so (plugins#590)
anewuser6937 (Discord, plugins#590) saw one model in WorkBuddy's editor
and took the plugin for broken. They had turned on "Free models only"
themselves, but its label and description read in English in the Chinese
window, and nothing by the models said the list was filtered.

A plugin option (auth.options, magpie's own field; OpenCode's AuthHook is
provider/loader/methods and never reads it) may now give `labels`,
`descriptions` and `confirms`, each keyed by the window's language
("zh", "zh-TW", "ja", "de"), beside the plain strings, as a page's
`titles` do. The host keeps only non-empty strings under language names
of 16 or less, 16 languages at most, each capped as the plain one is
(60/300/300). The editor shows the exact language, then its first part
(zh-TW reads zh), else the plain words, in the row, the hint, and the
confirm dialog and its title. `filtersModels: true` says the plugin's
model list leaves models out while the switch is on; while one is on, as
saved, the Models field says under the chips "Only some models are
listed: the plugin option “…” is on." (zh 只列出部分模型:插件选项「…」已开启。,
zh-TW, ja, de too). An older plugin shows what it showed before, and an
older magpie shows a new plugin's plain words with no note.

WorkBuddy 0.2.10 gives "Free models only" in all four languages with
filtersModels (magpie-community/plugins aec58ae, on npm: `npm view
@magpie-community/opencode-workbuddy-auth@0.2.10 --prefer-online` on mote
says 0.2.10, latest), and the mover's min is raised to it so every moved
user gets it. The CLI's `magpie plugin options` stays English, as the CLI is.

The core scripts would have gone 608 bytes over their budget; three of the
provider editor's comments in app.js are cut down instead, no raise
(1,532,865 of 1,533,105).

Run, on mote (mote-run), at this tree:
- node --test plugin-option-words.test.cjs (new): Chromium and WebKit,
  1100 and 420 wide, en/zh/zh-TW/ja/de, switch on and off: each
  language's label and description, zh-TW falling back to zh and ja/de to
  the plain words for a zh-only option, the note exactly once under the
  chips in a .hint inside the editor with no sideways scroll, none while
  off, the confirm in the language. With app.js put back: 19 of 21 red
  in Chromium (only "en off" passes, both widths).
- With plugin-options.test.cjs and i18n-keys.test.cjs, both engines:
  68 pass, 0 fail.
- go test ./internal/plugin ./internal/provider ./internal/cli: ok.
  TestPluginOptions with host.js put back: red (empty maps, FiltersModels
  false). The real WorkBuddy 0.2.10 index.mjs loaded into this host
  (a temporary test, not kept): plugin.Providers lists free_only for
  workbuddy and workbuddy-ai with all four languages and filtersModels true.
- go test ./internal/gui: TestCoreScriptBudget ok after the cut. Red,
  and red the same at origin/main ed5872d18 (run there too):
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
  /macOS_26_SDK on macOS 27 (#3949); TestColdTurnsTaken red once in the
  package run and passed at origin/main (#4510, the same 0.00s red).
- gofmt -l: clean. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- plugins: HOME=$(mktemp -d) bun test packages/workbuddy 303 pass 0
  fail; the new freeonly test red 2 of 2 with index.mjs put back.

Not run: the whole GUI suite. mote and the WSL box were each running
another session's full GUI suite (hours left on both), and one runs per
machine; it runs on mote once that one ends. Not tried: a real WorkBuddy
account in the real app window. go test ./... was not run.
2026-11-01 13:24:50 +08:00
yetone 2c6b7c0632 gateway, provider, gui: Accounts at once keeps the first N accounts taking requests, the others in reserve
01huadalang on Discord (#feedback 1566170404542742740): three ZCode
accounts used at once from one address got the address refused with a
405; two were served. They asked for one account to be used until it
runs out, then the next. Even under "In order", ZCode's maxConcurrency 3
spilled a full lane onto the next account (laneMate) and rests spread
the load, so every account was in use at once.

A provider's MaxAccounts (the editor's Advanced → "Accounts at once",
beside Concurrency; `magpie provider at-once <id> [n|off|default]`) is
how many of its accounts or keys take requests at the same time.
provider.AtOnce() is the user's own value, else what its plugin
declares (maxAccounts on the auth hook or package.json magpie, read by
host.js atOnceOf), else no limit; the user's 0 is no limit over the
plugin's. perKeyBarred keeps the first N in the user's own order
(rank), preferring ones not resting, and keepAtOnce puts the rest after
everything as asides with candidate.reserve (Weighed.Reserve). So in any
routing mode a reserve is asked only once the kept ones failed or rest,
and a kept one that rests gives its seat to the first reserve next time.
Guards: laneMate never spills onto a reserve; a full queue (laneErr)
drops the provider's reserves (dropReserves) and turns the request away
with the 429; session affinity moves a conversation off a reserve once
the kept ones can take it (affine "reserve"; Strict still holds).
Routing says "in reserve · {n} at once" on the row and why in the
request's story. zcode 0.1.40 (plugins 26864ec, on npm) declares 2, and
its mover min is raised to 0.1.40 two commits on.

Known leak, in docs/subsystems/gateway-routing.md: a failure that rests
nobody (a 5xx on one try) still passes that one request to the reserve,
as it does to any next candidate.

Tests: TestAtOnceKeepsFirstInUserOrder (every routing mode, a dragged
order, a resting key handing over its seat), TestAtOnceFullLaneWaitsForTheKept,
TestAtOnceReserveTakesOverAndGivesBack, provider TestAtOnce, plugin
host maxAccounts (hook and package.json), gui TestAtOnceSave, cli
TestAtOnceCmd, provider-at-once.test.cjs (both engines, five languages,
900 and 360px).

Broken by hand, each red then restored: laneMate's reserve guard
removed (FullLane times out); affine's reserve case removed
(ReserveTakesOver answers on k3); keepAtOnce disabled (all three red);
dropReserves disabled (FullLane gets no reply); the Routing row's
reserve branch removed (provider-at-once's Routing test red in all 10
engine/language runs).

Core budget: the field adds ~530 bytes to app.js; the neighbouring
editor comments are cut to fit, so TestCoreScriptBudget passes with no
raise.

Run on mote, Go 1.26.8:
- full suite, -timeout 45m, at a7d4c662d (on origin/main e4384fc3c):
  gofmt and vet clean; every package ok but internal/gui, whose reds are
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514), TestMainWindowCorners
  (#3949) and TestColdTurnsTaken (#4510), each red on that main too, and
  TestCoreScriptBudget, fixed by the comment cut above.
- at this tree on bbdd9eb55 (the pushed head less 51f2f22ce and
  73b957069, gateway and provider): gofmt, go vet (darwin, and
  linux and windows with -tags nogui), and internal/gateway, provider,
  gui, cli, plugin and settings: all ok but internal/gui's
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners
  (#3949), both red on main; TestCoreScriptBudget passes
- at the pushed head (on 51f2f22ce): go vet of gateway and provider,
  and -run AtOnce|Nameless|ModelAPI|Reserve|FullLane over gateway,
  provider, gui and cli: ok
GUI, Playwright 1.62.0, both engines:
- the whole suite on Linux (WSL) at an earlier head; every red file run
  again at head and at main on mote, the same reds on both (filed:
  #4641 is new, the rest open already, e.g. #4600, #4461, #4082, #4210).
- at a7d4c662d on WSL: every editor-*, provider-* file, i18n-keys,
  gui-ja and seven routing files, 1185 pass, 34 red; all but four red
  on main e4384fc3c too (#4580, #3292, #4394 to #4397, #4600). The four:
  routing-many-keys (#4082) is red on main in two of three reruns as
  well; provider-gemini webkit ja's thumb (#4210) was red in 2 of 3 runs at head beside
  other files (318px off), 0 of 3 at main; alone, 4 of 4 green at both.
  The test reads the thumb 350ms after a click, a fixed wait (#4210,
  numbers added there).
- provider-at-once.test.cjs: green in both engines, five languages, at
  900 and 360px; editor-advanced-align 20 of 20 alone with the next
  commit.

Not tried: real ZCode accounts (none used, per the task) and a real 405,
so whether two at once always stays under ZCode's limit is the
reporter's finding; the user can set 1.
2026-11-01 07:39:08 +08:00
ggbdpq c26d16018f gateway: a plugin model that refuses temperature is asked without it, relayed or translated (#2492)
What changed: the plugin host carries a model's temperature where it is
said - the config model's temperature (Factory 0.1.31's configModels,
plugins#154), models.dev's own, or a models hook's model field - into
plugin.Model and pluginCatalog's catalog model, where
RejectsTemperature reads it as it reads a built-in's. A Chat or
Responses request relayed as it came to a model whose list refuses
temperature and top_p now leaves them out (passthrough), as the
translation of one (build) already did. A model nothing says so of
keeps what the client sent. OpenCode's capabilities.temperature is not
read: its false is what it reads a models.dev silence as, not a refusal
said.

Docs: the sampling row of gateway-routing, and provider-plugins' new
"A plugin model's sampling".

Run at ea3dee96 + this change, sandbox HOME:
go test -tags nogui -p 2 -run TestPluginModelRefusingTemperature
./internal/gateway/ - red at ea3dee96 without this change (the plugin's
fetch got temperature 0.7, top_p 0.9 relayed, temperature 0.7
translated; the model that says nothing keeps them), green with it;
ablation removed the four product files and went red the same way.
go test -tags nogui -p 2 -timeout 45m ./internal/gateway/ ok (291s);
go test -tags nogui -p 2 ./internal/plugin/ ok; -run
'TestRejectsTemperature|TestPluginModel|TestPluginCatalog|PluginParity|TestPlugin'
./internal/provider/ ok; -run
'TestSampling|TestUpstreamBytes|TestPassthrough|TestRelay'
./internal/gateway/ ok.
gofmt -l internal/ clean; go vet ./... (darwin, the
trayimage_darwin.go cgo warning as before), GOOS=linux go vet -tags
nogui ./... and GOOS=windows go vet ./... clean; go build and
GOOS=linux/windows go build ok.

Landed (yetone). Broken by hand on mote: with gateway.go, host.js,
internal/plugin/providers.go and internal/provider/plugins.go at
origin/main, TestPluginModelRefusingTemperature is red. passthrough
strips temperature and top_p for a provider whose catalog says
temperature false on Chat and Responses alike, the same rule build
applies. Run at the pushed head: go test ./... -timeout 45m on mote with this branch on 41b5c0f19: 83 packages ok. internal/gui is red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red alone at 41b5c0f19 too, and on TestColdTurnsTaken (#4510). internal/update is red on TestRelaunchOpenTriedAgain (#3881). The last two pass alone at 41b5c0f19 and here. Rebased on f856d381a: agent, gateway, plugin, provider and sessions ok, gui red on #4514 and #3949 only, gofmt -l clean, go vet ok for linux (nogui), windows and darwin. Rebased on bb478f0e5: agent and gateway ok, gui the same. The last rebase, onto 573b21f4b, brings in only internal/gui/providers*.go and internal/provider/models.go, which this branch doesn't touch.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:21:39 +08:00
JoeyWu-tech a246ad4cfc plugin: the pi tests' host loads the pinned pi, not npm's latest (#2865)
TestPiPackage added testdata/pi, and TestGatewayHookMixedPiPackage a
copy in a TempDir. Neither folder has a node_modules above it, so as the
host started, Bun took each import of pi from there as one to install
itself (its auto-install): first pi.js's resolve of
@earendil-works/pi-coding-agent from the package's folder, then the
extension's own imports, which jiti 2.7 imports natively under Bun
(tryNative) from the extension's folder. Each start asked npm for 115
manifests, and init waited on them under its 2 minute bound. This would
explain the red yetone sees under a full run, and with npm slow it is
red alone.
The host then ran npm's latest pi (1.4.0 today), not the 1.2.0
installPinnedPi installs from testdata/pi-lock, so #1879's pin never
reached the host. The test's Version(piAgent) check reads the plugins
folder's copy, so it passed.

Now both tests put their package in the plugins folder
(Dir()/fake-pi-package, Dir()/mixed-pi-package), beside the node_modules
installPinnedPi fills. pi.js and the extension both resolve the pinned
pi, and nothing is asked of npm as the host starts. fakepi.ts tells the
VERSION its import of pi reached, and TestPiPackage checks it is the
pinned one. With the old layout and npm reachable, that check is red.

Not changed: the app. A pi package added from a folder with no
node_modules above it should go the same way (the tests add theirs
through the same Add, as a path): pi.js and its extensions get npm's
latest from Bun as the host starts, and the pi ensurePi put in the
plugins folder for it isn't the one that runs. Making pi.js resolve
from the plugins folder alone isn't enough. Tried here with the old
layout, the host then waited on @earendil-works/pi-ai's manifest for the
extension's import instead, and both tests were still red. Each way out
changes how plugins load: JITI_TRY_NATIVE=0 in pi.js (every pi extension
then goes through jiti's transform and pi's aliases), `bun run
--no-install` for the host (auto-install also stops for OpenCode plugins
on disk), or a Bun.plugin onResolve for pi's scopes. That is the
maintainer's call, so it isn't in this commit.

Also not changed: installPinnedPi's `bun install --frozen-lockfile`
still fetches pi's 118 tarballs on every run, as the sandbox's install
cache starts empty, and the test skips when that fails (noted in #2865).

What was run (tree 8aee6487, on origin/main acdc85ac, go1.26.8,
linux/amd64, Linux 5.15, umask 077). This tree only rewords
TestPiPackage's version check message from tree 859ae995, where the
rest was run.
- At this tree (Bun 1.4.2, npm direct): TestPiPackage and
  TestGatewayHookMixedPiPackage pass. Broken by hand (TestPiPackage's
  package back in testdata/pi): red, `the extension's import reached pi
  1.4.0, not the 1.2.0 the lock installed`.
At 859ae995:
- A local npm relay as BUN_CONFIG_REGISTRY (Bun 1.4.2) that passes
  tarballs through at once and holds each manifest 150s, with
  `go test -tags nogui -count=1 -v -run
  'TestPiPackage$|TestGatewayHookMixedPiPackage$' ./internal/plugin/`,
  load 10 to 16:
  - origin/main acdc85ac: both red. `mixed package lost Pi providers:
    [] starting plugins: context deadline exceeded` (157.92s), and
    `Plugins = [], starting plugins: context deadline exceeded`
    (157.69s). Each test's host asked the relay for
    @earendil-works/pi-coding-agent's manifest as it started.
  - this tree: both pass (29.35s, and 181.28s, most of it the frozen
    install's tarballs through the relay), and the relay was asked for
    no manifest. With a print-only probe around the first Providers or
    Plugins call, the host started in 0.5s in each test.
  - main's layout with pi.js resolving pi only where a node_modules
    above the folder has it (tried, not kept): both still red (host
    start 122.0s and 104.8s), the relay asked for
    @earendil-works/pi-ai's manifest by the extension's import.
- Broken by hand: both packages back where main puts them (testdata/pi
  and a TempDir), the version check kept, the relay passing manifests
  through at once. TestPiPackage red on the version check (pi 1.4.0,
  not 1.2.0). The mixed test passed with a 60.7s host
  start (TestPiPackage's took 27.8s). 230 manifest requests: 115
  packages, once per host start.
- go test -tags nogui -count=1 -timeout 45m ./internal/plugin/ (Bun
  1.4.2, npm direct): ok, 340 PASS lines counting subtests, 2 skip
  (TestFlowBigReplyProd wants MAGPIE_FLOW_BIG, TestRenewOtherHost is run
  by TestRenewOnceAcrossHosts). TestPiPackage 10.49s,
  TestGatewayHookMixedPiPackage 22.77s.
- The same with -race: ok, the same counts, no race reported.
- 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; 9m49s,
  load 16 at its start): 79 packages ok, internal/plugin among them,
  and 8 tests red in 2 packages, each filed: agent TestInstalledVersion,
  TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649). Run by name at origin/main
  acdc85ac, all are red there too but the Qoder test, which passed
  alone.

Not tried: the real app, and macOS and Windows (the tests ran on Linux
only).

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote: TestPiPackage's package back at testdata/pi
  is red, "the extension's import reached pi 1.4.0, not the 1.2.0 the
  lock installed".
2026-10-31 17:00:14 +08:00
yetone 261117363e plugin host: a sign-in again joins its account when an older plugin named it another way (#4473)
officeace-auth 0.1.14 to 0.1.17 kept an account as accountId = the masked
phone ("189****8051") and uid = the Huawei domain id. The CodeArts
plugin's OfficeAce card (plugins#522) names a new sign-in by the domain
id, uid the same. settle joined a new sign-in to an old record only on an
equal account id, so signing in again added a second row (fakeco#xxxxxx)
and left the old one "Sign-in required", holding the user's name, proxy
and gateway keys.

settle now also joins two records with the same uid when one of them is
named by that uid (renamedBy): then the uid is the account's own id. The
joined record keeps the old record's accountId, since the user's name,
proxy and gateway keys are kept by it (#4416), as the CodeArts plugin's
renewals already keep a stored accountId.

The issue suggested joining on any equal uid. That is not safe: Kiro
keeps how an account was signed in to as its uid ("google"), so two
different Google sign-ins share one. The test signs in two such accounts
and checks they stay apart; with a uid-only rule they were joined.

Not covered: a re-sign-in where neither record is named by its uid (a
WorkBuddy nickname changed at the vendor) still adds a row; nothing in
the records proves those are one account.

Run:
- Reproduced first on origin/main's host.js: TestPluginReSignInJoinsAnOldIDShape,
  with the old record as officeace-auth 0.1.14's callback and
  credential.mjs write it (read from the npm tarball), was red: the
  sign-in again went to "fakeco#9oncv2" beside the old record.
- Broken by hand: renamedBy on uid alone -> red (two Google accounts of
  uid "google" joined); joined without keeping the old accountId -> red
  (accountId became the domain id). Green with the fix, and
  TestPluginSameNameOtherUID (#413) still green.
- Full go test ./... -timeout 45m on mote was still running at push
  (pushed without waiting, per the owner's rule); a red it shows that
  isn't on origin/main gets its own issue.

Not tried: a real Huawei Cloud sign-in in a running magpie; the CodeArts
plugin with the OfficeAce card is not on npm yet (plugins#522 is open).
2026-10-31 01:11:31 +08:00
yetone 3b5dccd527 accounts: a plugin account goes by its usage's name, not its id (#4416)
A Huawei Cloud CodeArts account is kept by its accountId, an IAM id
(iam::<domain>:user:<name>), and every list showed that id while its
quota card showed the masked phone the plugin's usage() names it by.
Display only: an account now reads as the name the user gave it, else
the `user` its plugin's last usage read gave (PluginUserOf: the
in-memory read, else quotas.json), else its id. The id stays the key
everything is kept by; nothing stored changes or migrates. A read that
fails keeps the last good name; nothing read yet is the id, never blank.

One rule in provider (AccountShown, AccountShownOf, AccountLabelOf),
used by every list: cards' Alias (Usage page, tray panel,
/v1/magpie/quotas, magpie quota), magpie accounts, magpie providers,
the TUI's Providers rows and quota titles, usageapi's Account filter,
the quota alert. The GUI gets it as /api/providers' accountUsers
(accountShownOf in app.js): the editor's account rows (the id in the
tooltip), the per-account proxy lines, Routing's userShown, the
Providers search, Hide accounts. app.js's account lookups share one
helper, so the core stays in its budget (1,536,561 of 1,536,586), with
no room added.

Run:
- go test ./... -timeout 45m on mote at 2f5a3f1c0 + this change: all ok
  but internal/agent TestPiModelsAskedOnTheirNativeAPI (fixed on main
  by 7474a86f1, green there; this is rebased onto it),
  internal/update TestRelaunchOpenTriedAgain (#3881, green alone x3),
  and internal/gui's real-window AppKit tests (TestPanelCloseHidesIt,
  TestMainWindowCorners, TestTrayCellClickReleasedPanel red the same
  on origin/main 99ad38b7c; #2645, #4125, #1936).
- go vet, GOOS=linux go vet -tags nogui, GOOS=windows go vet of the
  touched packages; gofmt -l clean.
- TestPluginAccountShownByItsUsageUser (new, real plugin host and fake
  plugin): id before a read, phone after, phone after a restart from
  quotas.json, phone kept over a failed read, own name wins, id when
  nothing is known. Red on the old code.
- GUI on the Linux box (mote's Chromium segfaults on these pages on
  origin/main too, #4125): account-plugin-user (new),
  routing-account-name (extended) and account-alias, Chromium and
  WebKit, every language, 34/34; the new checks red on the old code;
  the whole suite (make test-ui on the Linux box) was still running at
  push: 417 files in, 5 reds, none on a page this changes
  (account-models' row-moved check in WebKit, 81 vs 79px, and
  agent-models-all-hidden), not yet compared with origin/main; any
  that are new get an issue once it ends.
- At the rebased head (3bce283df): go test of provider, cli, tui,
  usageapi, plugin, agent -run TestPi, gui -run
  Budget|Provider|Quota|Account: all ok. Core scripts 1,535,513 of
  1,536,586.

Broken by hand: dropping the quotas.json fallback turns the test red
at "after a restart".

Not tried: a real Huawei CodeArts account (none here). A plugin whose
windows are all model pools isn't kept in quotas.json, so after a
restart it shows its id until its first read.
2026-10-31 01:01:49 +08:00
JoeyWu-tech ef7f55fe98 plugin: Discover lists a repository of gateway hooks alone, as a request hook (#3821)
MengXiangxi (#3821): a GitHub repository tagged magpie-plugin whose
package.json has magpie.hooks and no main, exports or index.js, a gateway
request hook alone that installs and runs, never showed in the Plugins
page's "Unofficial, on GitHub". readTagged read the magpie block's
middleware, agent and page but not hooks, so such a package was taken for
a provider: the file #1327's check looks for in the repository was its
entry as Bun resolves it, index.js, which it hasn't, and the 404 left it
out without a word. An inert index.js, as the reporter tried, lists it,
as a provider.

readTagged reads magpie.hooks. A package with hooks, no main or exports,
and none of middleware, agent or page is of kind "hooks", and the
file #1327's check looks for is its hooks file, so one whose hooks file
isn't committed (a dist built only to publish) is still left out, as a
middleware's is. The Plugins page picks "hooks" out with middleware, as
both run in the gateway (kindOf), and its chip says Request hook, as an
installed one's row does, through the word kindChip takes since the
previous commit. docs/subsystems/gateway-request-hooks.md says so. Not
changed: a raw 404 that GitHub's cache answers just after a push is
still kept for that push in this process (the reporter's second
point, #4067).

plugins.js grows 51 bytes for it. With the previous commit the core's
scripts are 24 bytes under main's, 1,527,948 of 1,528,076.

What was run (tree 79884772, on origin/main 56602426, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, the Go tests at umask 077:
- TestTaggedHooksAlone, new. IvanXxxxyyuffff/magpie-system-prompt-file's
  package.json as it is (a repository the report names) is kept, of kind
  hooks, with its spec, package and version 0.3.0, and its hooks file is
  the file asked for, never an index.js. someone/hooks-gone, whose hooks
  file is only in a dist it doesn't commit, is left out. With
  TestTaggedRepos*, -count=50: 350 of 350 pass; -race -count=20: 140 of
  140, no race.
- plugin-github-hooks.test.cjs, new. Seven repositories of
  /api/plugins/github's real answer of 2026-10-27 (two providers, three
  middleware, two of hooks alone): each of hooks alone has the gateway's
  chip saying Request hook and is picked out under Middleware, in
  English, Chinese, Traditional Chinese, Japanese and German at 980px and
  420px. Chromium and WebKit, 3 runs: 22 of 22 each run.
- Broken by hand, each red:
  - no kind made of magpie.hooks, as on main: TestTaggedHooksAlone,
    hooks alone not kept.
  - the kind made but the file looked for still the entry, index.js:
    the same.
  - the hooks file not looked for: TestTaggedHooksAlone, the hooks file
    not among the files asked for.
  - kindOf without hooks, so a Provider: plugin-github-hooks 0 of 22.
  - the card's chip not given its word: 0 of 22.
- TestCoreScriptBudget: ok.
- 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).
- The Plugins page's GUI files near the change, 24 with the new one and
  i18n-keys, each run by itself in Chromium and in WebKit: 42 of 48 runs
  green. The other 6 are red the same at 56602426, each file run the
  same way, and none is in what this changes:
  - i18n-keys, both engines: "a plugin's words are its own", for
    plugins/routing/i18n.js "masking…", which internal/masking/masking.go
    says too (#4053).
  - builtins, WebKit: Plugins › Built-in, the Observability switch's
    click times out, the stuck Plugins header (.lib-head.pm-head.stuck)
    over it taking the pointer.
  - plugin-github, WebKit: de 440, a click scrolls #view-plugins, 74 to
    139 (65 to 119 at 56602426; #3218 has the same check red in
    Chromium).
  - plugin-github-wait, Chromium: de 440, Try again moves #view-plugins
    by 2.
  - plugin-release, WebKit: en and zh read "Serves Zed\n" for "Serves
    Zed".
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log
  kept; 8m48s, load 32 at its start): 71 packages ok, internal/plugin
  among them, and 16 tests red in 6 packages, none of them this
  commit's tests or what they cover (internal/gui's are its gateway
  tests): agent TestCodexDriftReached (#3398); TestInstalledVersion,
  TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141); TestReasonixCLIRequiresSupportedNativeVersion
  and TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync
  TestSyncTeraCloudStillSeesOtherWrites (#3420); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask
  077, #3640); gateway TestPluginToldWhereTheAgentWorks (the
  /tmp/.git of #3675); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

The rest is what was run for 31a99237, at tree 2dd21699 on origin/main
508911e4, the same Go change (github.go has since taken e4ccf67b's
search timeout, in askTagged, not readTagged; 31a99237's plugins.js
named the card's chip by hand, not through kindChip, and had three
lines of comment this leaves out; not this tree):
- Real use: magpie web built at 508911e4 and at that change's code
  (529f07e5, the same but for the new GUI file), each in a sandbox HOME,
  asked real GitHub for /api/plugins/github. 508911e4 listed 163 and left
  IvanXxxxyyuffff/magpie-system-prompt-file out. That change listed 164,
  it and MengXiangxi/magpie-openviking (which now has the inert index.js)
  of kind hooks. cyberElar/magpie-x-search (#1327's, a command only) was
  left out by both.

Not tried: macOS and Windows; the real app's window (no display here, the
page in Playwright's browsers only).

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 5957d45ac1 plugin: a GitHub listing takes package.json's licence when GitHub names none (plugins#468)
GitHub's search gives NOASSERTION for a LICENSE file it can't match to a
licence (MIT's text with a line of credit added) and nothing for none;
magpie drops NOASSERTION, so such a card on Plugins > Discover had no
licence, while the same package from npm shows package.json's.
readTagged keeps package.json's license (a string) as PkgLicense, and
License falls back to it, on a fresh read and across searches (fresh).

Run (mote, at this tree): gofmt -l clean; vet on three OSes; go test
-tags nogui -timeout 45m ./...
(go test -tags nogui -timeout 45m ./... at base 5bfd76cd8: 77 packages ok, none failed (log kept whole). Rebased onto 602ad84ad and run again there: vet on three OSes ok; go test -tags nogui -count=1 ./internal/provider (195s) ./internal/plugin (268s) ./internal/gateway (677s) ok. Rebased onto b5d2858f4 and run again: usage, provider, plugin, gateway ok. Rebased onto 87a983423, the pushed base, and run again at this tree: gofmt -l clean; go vet ./internal/... ok, GOOS=linux and windows go vet of provider, plugin, gateway ok; go test -tags nogui -count=1 ./internal/provider (126s) ./internal/plugin (180s) ./internal/gateway (588s) ./internal/codexcat (1s) ok. Then rebased onto 3ec9babe7 to push; its three commits (WorkBuddy mover min, redact, sessions) share no file with this one, and the same packages are run again at the pushed head after the push).
Broken by hand: on the old github.go TestTaggedRepos is red:
"NOASSERTION, package.json MIT: {... License: ...}".
Not tried: the GUI card against a real NOASSERTION repository (the card
reads r.license as before; no GUI file changed).
2026-10-29 00:52:19 +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 ba37e78b4c provider: a plugin model's test is told a queue at once and warms its host first
mingxia_16024 on Discord (v0.1.1862): testing models on Qoder (CN and
international) and WorkBuddy always failed with "qfmodel: context deadline
exceeded", even though agents got answers from the same models.

Cause, checked with the owner's real Qoder account in a sandbox HOME:
- The test already takes the gateway's route: p.Do, then the plugin's
  fetch in the host.
- The Qoder plugin waits out Qoder's free-plan queue (plan queue p3) for
  up to 4 minutes, unless X-Magpie-Fallback is "1". magpie never sent
  that header.
- The probe gives up after 20s. A raw request with no deadline got its
  head after 3m49s.
- The probe's 20s also had to cover the plugin host's cold start and the
  account loader's first run, which can renew the sign-in. A first
  WorkBuddy AI test took 8.4s.

Changes:
- For a plugin provider, probe sends X-Magpie-Fallback: 1, so a queued
  model answers at once with the plugin's queue message.
- It starts the host and runs the account's loader (warmPlugin, through
  the account's proxy) under the caller's deadline, not the probe's.
- A plugin probe waits up to pluginTestWait (60s). The GUI gives a model
  test 3 minutes.
- host.js lists x-magpie-fallback in MAGPIE_ONLY, so no vendor receives
  it.

"Recent calls" lists only the gateway's own calls, for every provider. A
test is written to the Requests page as magpie's own test, timed-out
tries included, so that is unchanged.

The gateway still never sends the header when another candidate follows,
which Qoder 0.2.40 and CodeArts 0.2.3 expect: #4049.

Run (mote-run):
- New tests TestPluginModelTestSaysQueued and TestPluginModelTestColdHost.
  They use the fake plugin's new $FAKE_QUEUE and $FAKE_LOAD_WAIT, with a
  cold host from plugin.Restart.
- go test -tags nogui -timeout 45m ./... at 76218200a: every package ok (77), none FAIL.
- GOOS=linux and GOOS=windows go vet of internal/provider and
  internal/plugin, go build ./..., and gofmt -l.
- Real Qoder account, sandbox HOME, a TestModels of qfmodel:
  - before: failed at 20.00s, twice;
  - after: "Qoder queued the request for qfmodel (this plan's queue: p3);
    try again in 30s" in about 0.5s, twice. One more run got a 200 in
    767ms.

Broken by hand, each red:
- Without the header set: SaysQueued fails with "context deadline
  exceeded" at its 5s wait.
- Without warmPlugin: ColdHost fails with a deadline at 2001ms.
- Without the MAGPIE_ONLY entry: the vendor gets fallback="1".

Not tried:
- WorkBuddy CN with a real account. It reads the desktop app's sign-in,
  which the sandbox doesn't have.
- A cold start on a slow machine or on Windows.
- The GUI button itself. The handler is unchanged.
2026-10-28 18:24:50 +08:00
yetone 69626580bc checkin: each account is checked in through its own proxy, not the global one (#2777)
zRain on Discord (Windows, 0.1.1788, Loomy plugin 0.1.4): the global proxy
is a residential entry, the Loomy provider is set to direct. The balance
read went direct, but every check-in, the loop's and a press, went out
through the global proxy and got ECONNRESET. The usage read wraps its ctx
in ViaLogin (loginQuota); no check-in did, so netproxy.Choice was empty
and the plugin host fell back to the global proxy.

The wrap is made once, where checkiner runs an account's do
(checkin.go): ViaLogin(ctx, a.provider, a.User). That covers every
check-in at once: a plugin's own (plugin.AccountCheckin) and magpie's
Trae CN, MiniMax, Qoder and WorkBuddy check-ins, which reach the vendor
through plugin.Fetch(req.Context()). a.provider is the card id the
proxies are kept under (PluginID, as loginProvider gives the usage read),
and a.User the account's label as the accounts list shows it.

Sibling found on the way: Provider.Origin asked the plugin's loader
(LoaderOptions, which can renew the sign-in) with the bare ctx, before
WorkBuddy's search and draw paths put p.Via on it. It now asks through
p.Via(ctx). The other plugin-host entries were read and already carry
the proxy: sign-in (signInFlow.via, Via in PluginAPIKey and the CLI),
the move's Check (ViaLogin), usage (loginQuota), model lists
(listingProxies) and the gateway's fetch (p.Via in the gateway).

The direction is the one #2777 lays out; skygunner's fork wired the same
wrap per runner.

Test: TestPluginCheckinGoesThroughItsProxy. The fake plugin's check-in
asks $FAKE_CHECKIN_URL (http://vendor.invalid/checkin/<key>); the global
proxy (settings.Proxy, set before the host starts) and the account's own
are recording proxies that answer for it. The provider is direct, one
account has its own proxy. The loop and then a press must leave the
global proxy unasked, claim through the account's proxy, and fail the
direct account (vendor.invalid is reachable by no one).

Broken by hand: a.do(ctx) back in checkin.go turns it red as reported:
the global proxy was asked for both accounts, the direct one claimed
through it, and the account's own proxy saw nothing.

Run (on mote, at this tree): go test -tags nogui -count=1 -run
'TestPluginCheckin|TestMovedLoginProxy|TestPluginSignInGoesThroughItsProxy'
./internal/provider ok; full suite
go test -tags nogui -timeout 45m ./...: every package ok (76), at base a05b37353

Not tried: a real Loomy check-in on Windows; the Origin change has no
test of its own (the fake plugin's loader makes no request).
2026-10-28 10:09:51 +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 f6ed2c99bc effort: a vendor's light and extra_high are low and xhigh, in dsh, Pi and the gateway
nianshou5 (Discord) runs Trae's DeepSeek V4.1 Flash through the Our Free
Model plugin (github:mu-zi-lee/magpie-our-free-model). Its variants are
Trae's own names, light, high and extra_high, and dsh offered only
default and high: dshModelLevels (and Pi's piThinkingLevels) matched a
model's efforts to pi-ai's level names only, so light and extra_high
were dropped. The gateway dropped them too: effortOf read "light" as no
effort, and NearestEffort fitted an agent's low or xhigh to the plugin's
high.

catalog.EffortAliases names light as low and extra_high as xhigh
(EffortLevel). NearestEffort places a model's levels by the level they
name and returns the model's own word; the gateway's effortOf reads an
alias as its level. dsh's reasoningEfforts and Pi's thinkingLevelMap map
dsh's low/xhigh to the model's own word (modelEffort), which llm-pi-ai
sends on the wire as written (resolveModelReasoning in dsh-llm-pi-ai
reads each value as "the spelling dispatch sends"). Levels a user kept
are untouched: only the names a model lists are mapped.

Tests: TestDshOffersTraeNamedLevels (agent), TestNearestEffortTakesVendorWords
(catalog), TestPluginThinkingOff's new fake-trae subtests (gateway, a
real plugin host with the fake plugin listing light/high/extra_high).
Broken by hand: modelEffort without the alias, dsh levels [high] (the
report's picker); NearestEffort without EffortLevel, low/xhigh sent as
high; effortOf without the alias, light/extra_high sent as nothing.

Run on mote at this tree (base e4ccf67b1): go build, GOOS=linux and
GOOS=windows go vet -tags nogui ./... ok; go test -tags nogui -timeout 45m
./... : 73 packages ok, three red that are red the same on origin/main
7f32f0ec9 run alone: internal/agent TestWSLColdPlaceOpensNothing (#3924),
internal/tui TestTUIFetchesSubscriptionModels (#3919), internal/provider
synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so
the rest of internal/provider didn't run. No GUI file changed.
Rebased on 7f32f0ec9 (one agent file changed there): go build ./...,
internal/catalog whole and gateway/agent -run Effort|Dsh|Pi|ThinkingOff|Level
ok at this head.

Not tried: a real dsh session against the user's plugin (no Our Free
Model account here); dsh's parsing of a non-pi-ai wire value was read
from its source, not run.
2026-10-28 04:34:45 +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
yetoneandvincent 65ee8c65c6 gateway: a ZCode Start Plan trial that ended or is spent rests that trial alone, not the account (#3661)
orion-nebula-dev's routing log: GLM-5.3-Flash-Trial and GLM-5.3-Trial,
whose Start Plan trial had ended, were refused by the ZCode plugin with
400 "ZCode has no active limited quota for GLM-5.3-Trial". The word
"quota" made it failQuota, and restAfterMarked rested the account
("zcode@zcode"), so the subscription's GLM-5.3 and GLM-5.3-Flash were
paused with it.

zcodeTrialRefused narrows that rest to the trial entry (restID) when the
candidate is a zcode plugin account, the model ends in -Trial, and the
refusal is the plugin's own words naming that model:
- 400 "ZCode has no active limited quota for <model>" (the trial ended);
- 429 "ZCode's limited quota for <bucket> is exhausted or temporarily
  unavailable", where the bucket is the entry less -Trial (its bucket
  spent). skygunner's patch covered the 400 only and kept this 429 as an
  account rest; it is the trial bucket's, given by the plugin before
  anything is sent, so it rests the entry too.
Another model named, a model without -Trial, the ended words on a 429,
the account's own quota (400 or 429) or key (401), and the same words
from another vendor still rest the account.

The plugin is not changed: zcode 0.1.31 already leaves ended trials out
of its model list and its two refusals are exact, and open plugins PRs
#395 and #421 hold zcode's next version. A member the user kept in a
group is still asked, refused locally, and asked again a minute on (a
guessed quota rest); the Routing page strikes such a member as
"skipped", which the gateway doesn't do: filed as #3805.

Ported from skygunner's e04a1b994 (branch
fix/r25-expired-model-not-account-fault): the test plugin's
FAKE_ZCODE_TRIAL and FAKE_NO_FREE fixture is his; the matcher, the 429
case and the test were rewritten. Reported by orion-nebula-dev.

Run:
- TestZCodeTrialRefusalRestsTheTrialAlone: 12 cases, the reporter's
  literal plugin bodies. Each posts to a group of the trial then another
  provider, checks the try's rest key, then posts to a group of the
  account's GLM-5.3 then another provider: served by the account when
  only the trial rests, by the other provider when the account does.
- Broken by hand: the routing.go hook off -> the four trial cases red
  ("refusal rested \"zcode@api key\", want \"zcode@api key/GLM-5.3-Trial\"");
  the 429 branch off -> "trial spent" red; the zcode-only check off ->
  "another vendor's words" red. Green again after each.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and
  GOOS=windows; GOOS=linux go build -tags nogui ./...
- go test -timeout 45m -count=1 ./internal/gateway ./internal/plugin at
  f34a9f8cf (this change on b7d5a97fe): both ok (436s, 87s).

Not tried: a real ZCode account with an ended Start Plan trial (none to
hand); the full ./... suite (other sessions' suites were running); the
Windows box.

Co-authored-by: vincent <vincent@users.noreply.github.com>
2026-10-27 09:10:09 +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
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 3b5a2f612d dsh: Max reaches GLM-5.3 as max, asked adaptively with its level
01huadalang on Discord (10-24): DSH Desktop on magpie-anthropic, zcode
GLM-5.3 at Max; magpie's Routing log showed 77 of 78 requests at low,
one at high, never max.

What DSH sends, from the real app (DSH Desktop 0.2.1-rc.3's app.asar,
pi-ai 1.1.0 and dsh-llm-pi-ai, run read-only through node with
magpie's GLM-5.3 entry): at Max and at High alike, max_tokens 128000
and thinking enabled, budget_tokens 16384. pi-ai's clampReasoning turns
xhigh and max into high before thinkingBudgetForLevel, so no
thinkingBudgets setting can give Max a budget of its own. At Low it
sends 2048; with reasoning off, no thinking field.

What magpie did with it: 16384 is read as high (effortOfBudget) and
sent as output_config.effort high, so Max could never reach max. The
"low" rows were not reproduced: no request DSH builds at Max reads as
low here, and Z.ai refused none of the shapes (live, below), so no
refusal memory lowered it. A 2048 budget (a session or a subagent DSH
runs at Low; dsh-tool-subagent lets the model pick reasoning_effort)
reads as low, and that is the likeliest source. It is asked of the
reporter.

The fix, zero-config: Z.ai's GLM-5.2 and GLM-5.3 (the GLM half of
effortInOutputConfig) are written into dsh's magpie-anthropic route
with compat.forceAdaptiveThinking (gateway.AdaptiveWithEffort, beside
AdaptiveThinking). MiniMax-M3.1-Flash, the other half, is left on its
budget: adaptive wasn't tried on MiniMax (no key), so it is on #3496. pi-ai then sends thinking adaptive and
output_config.effort from magpie's thinkingLevelMap, max as max
(checked against the real asar: low/high/max each go as themselves).
The gateway already passes adaptive thinking with output_config.effort
through for these models (fitted to their levels, withOutputEffort;
TestGLMEffortInOutputConfig pins it), so the gateway only gains
AdaptiveWithEffort. No client name is keyed on, and a budget alone is
read as before. An adaptive-to-budget rewrite in withOutputEffort was
tried first and dropped: TestGLMEffortInOutputConfig pins adaptive
passing through, and Z.ai takes it.

Live, Z.ai GLM-5.3 with the zcode key (sandbox script, key never
printed): adaptive and enabled+effort both accepted; effort max
thought 1237-1427 chars against 426 at high, so max is a real tier.

Run, at this head rebased on origin/main 3be1f14eb (head 7ae044226):
- go build ./...; go vet of gateway and agent for darwin, linux and
  windows; gofmt -l clean.
- go test ./internal/gateway/ ./internal/agent/ ./internal/plugin/
  -timeout 45m at this head: ok (655s, 469s, 187s)
  (an earlier run, with the dropped rewrite, was red on
  TestGLMEffortInOutputConfig only, which led to dropping it).
- Own GOCACHE: the shared one had files trimmed mid-build by another
  run (vet "could not import sort").
- A first run hit "no space left on device" from another session's
  disk use (18G free after); rerun in full.
Broken by hand: with dshKindConfig back on AdaptiveThinking alone,
TestDshMaxReachesOutputEffortModels is red for GLM-5.3 and GLM-5.2. TestAdaptiveOnOutputEffortModelAsksItsLevel (the
gateway end, through a fake zcode plugin) passes on the old gateway
too: it holds that DSH's new shape reaches the vendor and the Routing
log as max, not a gateway change.
Not tried: DSH Desktop itself against this build (the app isn't
installed here; its pi-ai was run from the asar instead); MiniMax with
adaptive (left out, #3496); the whole go test ./... and GUI suite (no GUI change).
Siblings left alone, filed as #3496: Pi and omp hit the same pi-ai
clamp, MiniMax-M3.1-Flash above, and dsh to a DeepSeek model on DeepSeek's host (#3298) still
goes as a 16384 budget, since dsh's compat is per model id.
2026-10-24 23:27:25 +08:00
yetone 7d9165d842 gateway: tests for plugin-served Factory with Standard usage only, 99% caps and order routing (plugins#349)
TestPluginFactoryStandardOnlyCaps runs the fake plugin as factory (marked
moved, two OAuth accounts A then B, order routing, each capped at 99% with
SetAccountCap as `magpie provider account-cap factory <account> 99` does).
The windows are those Factory's plugin 0.1.38 reports with standard_only
on (limitWindows(l, true)): Standard's 5 hours and 7 days with no model
list, Droid Core's and Extra usage aside. The fake plugin gains
$FAKE_WINDOWS, a file of each account's windows read at each usage
reading, so routing reads them through the host and provider.Allowances,
not a stub.

What it holds, today's behaviour, no code change:
- A's 7 days at 99% (its 5 hours at 40%): A is not sent the request; B
  serves fake-1, fake-claude and glm-5.3 (a Droid Core model). The trace
  shows a@fake 99/99 left out with its reset. Core windows at 100% on an
  account below its Standard caps don't hold it.
- Both capped (A's 5 hours 99%, B's week 100%): 429 rate_limit_error,
  "usage cap reached: every account that serves ... - Factory (a@fake) is
  at 99% of a usage window, past its 99% cap, until <time>; Factory
  (b@fake) ...", advice naming magpie provider account-cap, Retry-After
  at the sooner reset (A's 5 hours), nothing sent to the vendor, logged
  "every account at its usage cap".
- A read again below its cap serves again; a kept reading still at 99%
  whose reset time has passed serves too.
- A conversation on A moves to B when A is capped. Once A is back: auto
  affinity with no cache worth keeping goes back to A; with B's cache
  (5000 cached tokens) it stays on B; affinity session stays on B. A new
  conversation goes to A.

Broken by hand, each red at the step it guards: capHeld returning nil
(A served while capped), allowanceOf keeping aside windows (glm-5.3 went
to B while A's Standard windows were below cap), CapHeld ignoring a
passed reset (429 where A should serve).

Run: go test -tags nogui ./internal/gateway -run
TestPluginFactoryStandardOnlyCaps -count=1 -v, ok; go test -tags nogui
./internal/gateway ./internal/plugin ./internal/provider ./internal/cli
-count=1 -timeout 45m at base ed91aa04e: all four ok (gateway 494s,
plugin 217s, provider 191s, cli 88s); rebased onto ef1a203df and the new
test run again there (below). gofmt -l clean; GOOS=linux go vet -tags
nogui and GOOS=windows go vet of ./internal/gateway clean. No full ./...
suite: tests and testdata only, and another session's full suite was
running.

Sandbox HOME, built binary, fake plugin as factory, two accounts signed in
with magpie plugin login factory (browser opener stubbed on PATH):
magpie provider account-cap factory alice@fake 99 -> "capped at 99% of
each usage window", saved as accountCaps in providers.json; --window
"7 days" 95 and default work; an unknown account and 150 are refused.

Not tried: real Factory accounts, the real plugin's own option toggle in
magpie (its own usage.test.mjs covers the switch), the Anthropic
/v1/messages route's 429 body.
2026-10-24 15:33:17 +08:00
yetone 3dc25a6168 tests: a plugin fake's vendor counts only its own test's requests (#3357)
Run 39913278700 at 65e80405b (ubuntu, Race): TestClinePluginPinsDeepSeekAndGLM
"the plugin sent 7 requests" for 6 asks, in 0.33s. #3347 was the same
class: TestPluginToldWhereTheAgentWorks got 2 for 1, in 0.66s.

Cause, as far as it is known. The extra request did not come from the
test's own route:
- not a gateway retry: retryPause is 1s, so a retried ask can't finish
  in 0.33s or 0.66s. #3347's "a first try failed with a 5xx and was
  retried" doesn't fit either run's time;
- not the plugin host: the gateway reaches the host over stdio JSON-RPC
  (no HTTP retry), and host.js fetchAs calls the loader's fetch once;
- a never-reset log of every request the cline test's vendor got showed
  exactly 12 (6 asks x 2 runs), all POST /v1/chat/completions from
  magpie/dev, with nothing in the background.
So the seventh came from outside the test. The likely sender is a late
request from another test, in this shard or another of race-shards.sh's
four processes, reaching a port the kernel handed to this test's
httptest server (the class d0ccbbebc met with a freed port). Which test
sent it is still unknown.

Fix the class: testenv.FakeVendor(t, h) serves a fake plugin's vendor
at $FAKE_BASE and sets $FAKE_RUN to a nonce made for the test. The fake,
renew and renewrace plugins send it as X-Fake-Run. A request without it
gets 421 and is logged with its method, URI, remote address, User-Agent,
Authorization and size, so the next one on CI names its sender. Every
gateway and plugin test that served the fake's vendor with
httptest.NewServer plus FAKE_BASE now uses it (10 gateway, 5 plugin
files). The cline test now counts against the asks' recorded tries, as
65e80405b did for the workdir test: it fails on a real duplicate and
logs each retry's status. No exactly-once guarantee was loosened.

Reproduction by injection, at be002aca0:
- a request to FAKE_BASE from outside the route, with the filter off:
  "the plugin sent 7 requests for 6 asks tried 6 times" (the CI shape);
  with it on, the test passes and logs the 421 line;
- the fake plugin fetching twice for glm-5.3 (a real duplicate) still
  fails: "sent 8 ... tried 6". Both breaks were restored.

Ran at be002aca0 (macOS, -tags nogui):
- gofmt -l clean; go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows ok;
- internal/plugin -race -count=20 ok (157.5s);
- the edited gateway files' tests -race -count=20 ok (93.1s);
Rebased on c8c6e7e23 (it brings TestPluginThinkingOff, on besideFake),
and ran there: gofmt -l clean; vet of the three packages for darwin,
linux nogui and windows ok; TestPluginThinkingOff, the cline and the
workdir tests -race -count=20 ok (18.3s); internal/gateway (363.6s),
internal/plugin (83.9s) and internal/testenv -timeout 45m ok, with no
421 line logged;
- a Linux container run of gateway.race in four shards like CI's,
  -test.v: ok, and no stray was seen.

Not tried: the stray was never caught in the act, here or in the
container, so the sender is a hypothesis. The count=20 run over all 142
besideFake tests hit 45m in TestPluginStreamLargeReplies (sizing, no
FAIL) and was narrowed to the edited files. No product code changed, so
the full ./... suite was not run.
2026-10-23 16:57:33 +08:00
yetone bac5be0677 plugin: one renewal of a sign-in at a time across magpie processes (plugins #331)
Cause: every magpie process that loads plugins runs a plugin host of its
own (the gateway, a CLI quota or usage command, a host restarting while
the old one finishes), and host.js's renew() kept a sign-in's renewal to
one at a time only inside one host (the in-memory renewing map). Two
hosts that found the same sign-in due each called the plugin's
auth.refresh with the same refresh token. A vendor that spends a refresh
token once (MiniMax, and about ten plugins' vendors: cline, codearts,
qoder, trae, workbuddy, raccoon, nous, kiro, factory) turned the second
away with invalid_grant, the plugin threw signIn "expired", renew() sent
it on without looking at the store again, and host.go -> provider's
notePluginLapse marked the account signed out, though the first host
had already saved a good token.

What changed, in internal/plugin/host.js only, for every plugin:
- renew() takes a lock file of the account's beside the store,
  plugin-auth.json.renew-<sha256(key)[:16]>.lock, holding the holder's
  pid and start time, across the plugin's auth.refresh, and lets it go
  in finally. It is separate from plugin-auth.json.lock, which changeAuth
  holds only for a write and never across an await. A lock whose pid
  is gone (process.kill(pid, 0), EPERM counted alive) is taken over at
  once, one older than 60s by anyone; a live holder is waited for with
  an async backoff (10ms to 500ms), never blocking the host's loop, and
  never past 120s. A lock is removed only while it holds the bytes read.
- Under the lock the sign-in is read again from the file (past
  readAuth's stat cache). Changed since the renewal began (another host
  renewed it, or it was signed out or in again), the renewal ends
  without calling the plugin; no longer due, likewise.
- A refresh that throws while the stored sign-in changed meanwhile (a
  magpie from before this lock spent the token and saved the new one)
  is logged, not reported expired.

Tests (internal/plugin/plugin_renew_race_test.go, fixture
testdata/renewrace): a fake vendor on loopback whose refresh tokens are
single-use.
- TestRenewOnceAcrossHosts: two hosts in two processes (this test binary
  and a child running TestRenewOtherHost) on one sandbox store. The
  first host's exchange is held until the second host is renewing too,
  waited on as state. One exchange, neither host says expired, both
  requests go with the new token, the store has it.
- TestRenewLockOfDeadHostAndRefusal: a lock naming a pid that has ended
  is taken over inside the request's wait and removed; a token the
  vendor never gave still says expired and leaves the account as it
  was; one refused after another magpie saved a new token says nothing
  and the next request goes with that token.

Broken by hand, each red:
- no lock (lockRenew returns at once): TestRenewOnceAcrossHosts red with
  exchanges [r1 r1], the other host said [expired], a request sent
  a-old - the issue's symptom; the dead-pid test red (lock left).
- no re-read under the lock (now = was): exchanges [r1 r1].
- the catch's check removed: "a token another magpie renewed meanwhile
  said expired".
- a dead pid counted alive: the dead-pid test red after its wait.
(Removing only the re-read's "changed" branch stays green: the "no
longer due" check under the lock catches the same case.)

Run at c909ca5e4 (on origin/main 84d902ce2): the new tests and
TestPluginRenewsSignIns -count=3, and -race -count=10 for the new ones;
gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows;
set -o pipefail; go test -tags nogui -timeout 45m ./... tee'd to a
log: all 88 packages pass (69 ok, 19 no test files), none red
(gateway 574s, agent 431s, plugin 265s, provider 246s). origin/main
was still 84d902ce2 at push.

Not tried: a real vendor account racing (MiniMax or another); Windows
and Linux runs of the new tests (process.kill(pid, 0) in Bun on Windows
is expected to work as in Node, not seen); the GUI suite (internal/gui
untouched). Not changed: a plugin that refreshes inside its own loader
(MiniMax's fetch on a 401, or within EARLY_MS) still de-dupes only in
its process; magpie's renewal comes before that window, so it is the
rarer path.

Reported by 1007cordon-ux (plugins #331).
2026-10-23 14:26:43 +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 226551d0d8 gateway: MiniMax M3.1-Flash is sent its effort in output_config (shin4 on plugins#316)
An OpenAI client's reasoning effort (Responses' reasoning.effort, Chat's
reasoning_effort) for MiniMax Code's MiniMax-M3.1-Flash or -Preview, built
into an Anthropic body for the minimax plugin, went as a thinking budget
alone. Under the reporter's 8192 cap medium, high, xhigh and max were all
budget_tokens 7168, so the level was lost before the plugin saw it.

The two models join GLM-5.2/5.3 in effortInOutputConfig: buildAnthropic
sends output_config.effort next to the budget, and an Anthropic client's
budget gets its nearest level there too (withOutputEffort, passthrough).
MiniMax Code's catalog marks M3.1-Flash forced_on at low..max. The budget
stays as it was (the owner's plan on plugins#317); dropping thinking for
the managed-login route, as MiniMax Code 3.1.4 does, stays the plugin's
call. Nothing goes into prompt text. Claude, MiniMax-M3 and other vendors'
models keep the budget alone. MiniMax's public Anthropic API doesn't list
M3.1-Flash (platform.minimax.io text-anthropic-api), so the rule reaches
MiniMax Code's subscription and any relay serving those two models.

Tests (internal/gateway/minimax_effort_test.go, fake plugin $FAKE_MINIMAX):
- TestMiniMaxPluginGetsTheNativeEffort: the reporter's Responses request
  and its Chat form, low..max, both models, on minimax-code and
  minimax-code-global through the plugin host (bun), plus an Anthropic
  client's budget 10000 -> medium; MiniMax-M3 keeps no output_config.
- TestNativeEffortLeavesOthersAlone: claude-sonnet-4-5, kimi-k3 and
  MiniMax-M3 on an Anthropic relay get budget 7168 and no output_config.

Run at e31e3699a + this change, sandbox HOME, pinned caches:
- with the regex change reverted, TestMiniMaxPluginGetsTheNativeEffort
  fails with the reporter's table ("/v1/responses MiniMax-M3.1-Flash
  medium: output_config <nil>, thinking map[budget_tokens:7168
  type:enabled]"); restored, passes.
- the regex widened by hand to minimax|claude|kimi: TestNativeEffort-
  LeavesOthersAlone fails for all three models; restored, passes.
- go test ./internal/gateway -run 'Effort|Adaptive|Think|GLM|MiniMax|
  Budget|Reasoning|Level': ok. go test ./internal/plugin/...: ok.
- gofmt -l: clean; go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.

Not run before this push: the full suite (the machine is at load ~210
with several sessions queued for it; it runs after, in turn). Not tried:
a real MiniMax Code account. Whether MiniMax's subscription endpoint
honours output_config.effort beside a budget (rather than with thinking
left out, as shin4's live run sent it) is not verified.
2026-10-22 19:36:50 +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 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 d2c434b5a6 gateway: ClinePass pins glm-5.3-flash through OpenRouter's provider.only (sdytman on Discord)
sdytman (#feedback, 10-20) found that Cline doesn't send every model
through Vercel's AI Gateway: glm-5.3-flash goes through OpenRouter
directly, which ignores providerOptions.gateway.only, so the Upstream
tick (dd70c5e6a) didn't pin it. OpenRouter reads a top-level
provider.only with its own slug, "z-ai" for Z.AI
(openrouter.ai/api/v1/providers; its glm-5.3-flash endpoints list
"Z.AI z-ai/fp8"). deepseek-v4.1-flash and deepseek-v4.1-flash-1017 do go
through Vercel, so they keep providerOptions.gateway.only ["deepseek"].

provider.ClinePin now returns the upstream and whether the model's route
is OpenRouter, from a table whose first entry is glm-5.3-flash by exact
name (glm-5.3-flashx and glm-5.3 stay on Vercel's "zai" as before; which
router Cline uses isn't visible from its feed or either router's model
list, both of which list every one of these models). clinePin appends
"provider":{"only":["z-ai"]} at the body's end for such a model, so the
cached prefix is unchanged, and leaves a body naming provider or
providerOptions itself as sent. Applies to the Cline plugin's provider
too, since magpie writes its requests before the plugin sends them.

Not tried with a real request: there is no Cline account here.

Broken by hand, each red: no glm-5.3-flash entry (gets providerOptions
zai), a client's own provider field not checked (two pin keys), and
providerOptions for every model (flash has no provider.only). Not tried
with a real ClinePass request: no account here.

Run: gofmt -l (none); go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows: clean. `set -o pipefail; go test -timeout 45m ./...` at
1ebda9026 (this batch on 318697dce, movers then at qoder 0.2.21,
workbuddy 0.1.26, no devin raise): 65 packages ok, exit 0. Rebased onto
a9304efe0 (codex images, codex list tag, sessions decoders): gofmt, the
three vets and go test of internal/gateway, internal/provider,
internal/plugin and internal/sessions ok. Then the mover mins were raised
to qoder 0.2.23, workbuddy 0.1.27 and devin 0.1.21 (the only change
since, three strings): gofmt, the three vets of internal/provider and
go test ./internal/provider/ ok at the head of this batch.
2026-10-21 01:11:05 +08:00
yetone dd70c5e6ae provider: ClinePass's Upstream tick pins GLM models to Z.ai too (sdytman on Discord)
sdytman (#feedback, 10-19) asked for GLM to have what DeepSeek has: with
Upstream ticked, a cline-pass/glm-* request goes only to Z.ai. ClinePin
now reads a maker table (deepseek -> deepseek, glm -> zai) and appends
providerOptions.gateway.only = ["zai"] for a GLM model, at the body's end
as before so the cached prefix is unchanged. cline-free/ models are never
pinned, other makers are unchanged, and a client's own providerOptions is
kept as sent. The tick stays one control; its label and hint now name
DeepSeek and GLM in en, zh, zh-TW, ja and de.

The slug: Cline routes through Vercel AI Gateway. Vercel's provider table
lists Z.ai as slug "zai" (name "Z.AI", website z.ai), and
ai-gateway.vercel.sh/v1/models/zai/glm-*/endpoints gives provider "zai".
sdytman called the upstream "z.ai", Z.ai's site and shown name; the
routing slug Vercel takes is "zai". Not tried with a real request: there is no
Cline account here, and both gateways answer 401 without a key.

The Cline plugin got the same change in
@magpie-community/opencode-cline-auth 0.1.9 (plugins ff13aac). There is
no cline mover, so no min to raise.

Run at 9b72add51 plus this change:
- gofmt -l: clean. go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok.
- go test -count=1 -timeout 45m ./...: every package ok except agent and
  gateway, both red from "no space left on device" (the disk filled
  during the run; 35 ENOSPC lines) and TestQueueRefusalIsInTheUsageLedger
  (#2541, already filed). Rerun with disk free: internal/agent ok; internal/gateway ran 45m
  at load ~270 with no failure (TestQueueRefusalIsInTheUsageLedger and
  both Cline pin tests passed) and timed out in
  TestPluginStreamLargeReplies; the 829 tests from that file on, run
  alone, ok (1318s).
- Broken by hand, each red: no glm entry (both gateway tests), cline-free
  pinned, every maker pinned to zai, the client's providerOptions written
  over (red only after adding the one-providerOptions-key check: gjson
  reads the first duplicate key, so the old check passed).
- GUI, chromium and webkit: clinepass-pin (red against origin/main's
  app.js), gui-de, gui-ja, gui-zh-tw, i18n-keys, add-sheet: 22/22.
2026-10-19 20:58:53 +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