065ca02c283feb5587d29b328dcd92aee5d60b67
117
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
f92c0a2bdd |
plugins: a plugin is told the effort asked, and its usage windows keep their pool and family
What a ported Antigravity needs from the host, kept generic:
- The gateway puts the request's reasoning effort on a plugin's fetch as
X-Magpie-Effort (provider.EffortHeader), so a plugin that serves one
model at several levels can pick the level. host.js strips it with the
other magpie-only headers, so the vendor never sees it.
- A plugin's usage window may name a Pool and a Family; quotaOfPlugin
passes them through, so PooledWindows names a shared pool
("Gemini · 7 days") as it does for the built-in.
Run (WSL magpie-desktop; mote unreachable, kex reset):
- TestPluginToldTheEffort: xhigh, low and none reach the plugin; the
vendor gets no X-Magpie-Effort. Red with the MAGPIE_ONLY entry removed
by hand (the vendor saw the header).
- TestPluginWindowsKeepPoolAndFamily, TestPluginToldTheSession: pass.
- Full suite: in the next commit's body (run at the head of both).
|
||
|
|
e115b96411 |
plugin: an api sign-in whose prompts ask the key asks no second key
An OpenCode plugin's "api" auth method with its own prompts and an authorize (inkstone's API key ways, Devin's session token in magpie-community/plugins#928) asks the key in its prompts and returns it from authorize(inputs). The GUI asked those prompts and then always showed a key field of its own, so the user typed the same token twice and the second entry went nowhere. The host's save() also copied every answer into the account's metadata, so the token sat there a second time in plain text. - host.js marks such a method keyAsked (type api, prompts, authorize). The GUI's startPluginSignIn signs in with no key field for it, as for keyless, and a rejected answer asks the prompts again on Try again. PluginAPIKey and `magpie plugin` login skip the empty-key check for it (Method.NoKey). - save() keeps only select answers (choices, never secrets) beside the authorize result's own metadata. A method with no authorize still keeps every answer, as OpenCode does. - An authorize that gives no key, with no key typed, is now an error instead of an "ok" that saved nothing. OpenCode itself differs: its v1 CLI (providers.ts) asks the prompts, then always asks "Enter your API key", saves result.key ?? the typed key, and merges the answers into metadata; its TUI never calls authorize for api methods. magpie-community plugins are written for magpie's flow and read the key from inputs, so this follows them. Plugins that read prompt answers back from metadata (grep of magpie-community/plugins packages): zcode (site, a select), joycode (tenant) and agnes (keyProfile, consoleToken). None has an authorize, so none changes. Every api+authorize plugin (inkstone, cloudflare-workers-ai, sensenova, agnes-code, astudio, sap-aicore, Devin #928) puts what it needs in its result's metadata itself; sensenova's apiKey: undefined workaround is now moot. Run on mote (macOS 27, Go 1.26.8, Playwright 1.62.0) at this change on origin/main |
||
|
|
84a6d6a813 |
usage: Cursor calls made outside magpie are counted on the Usage page (WaiooT on X)
WaiooT asked for Cursor's usage to be counted. The quota card was there
already (the plugin's auth.usage); what was missing was the calls the
account made in Cursor's own editor and cursor-agent, which never pass
magpie's gateway.
The Cursor plugin (0.2.44, magpie-community/plugins f73ba656) gains
auth.calls: it reads Cursor's own usage list,
DashboardService/GetFilteredUsageEvents (the call cursor.com's Usage
page makes), keeps the signed-in user's events (owningUser = GetMe's
userId), and leaves out the conversations it sent itself for magpie.
magpie side:
- host.js: a provider says `calls` when its plugin has auth.calls; a
`calls` RPC normalises the reply (a call without an rid or time is
dropped, cost only when a number >= 0).
- plugin.AccountCalls / plugin.OutsideCall.
- usage.ReadOutsideCalls, run by the gateway a minute after the start
and every 10 minutes: each account's calls since its mark go in as
reported calls (IngestReported, request id "cursor:<usageEventId>", so
each is written once across restarts), by agent "cursor", provider
cursor, with Cursor's own cost. The first reading goes 30 days back,
but never before the gateway's last call to that provider, which older
plugin versions couldn't tell apart. A failed reading keeps its mark;
each later one starts 30 minutes back for events listed late.
Marks are kept in plugin-calls.json beside usage.jsonl.
- Cursor's mover min 0.2.43 -> 0.2.44 (npm view --prefer-online: 0.2.44).
- docs/subsystems/provider-plugins.md: "Calls an account made outside
magpie".
Run (mote, at this head):
- go vet for darwin, GOOS=linux -tags nogui and GOOS=windows on
internal/usage, internal/plugin, internal/gateway, internal/provider: ok.
- gofmt -l: clean.
- go test -count=1 -timeout 45m ./internal/usage ./internal/plugin
./internal/provider ./internal/gateway: all ok (usage 36s, plugin 129s, provider 152s,
gateway 937s), at 96d9b9ccd before the rebase onto origin/main (2
commits, none touching these files).
- Plugin: the cursor package's whole suite (410 pass) and
scripts/check.mjs on mote; a real-account auth.calls read returned 43
calls with models, tokens and cents.
Broken by hand:
- lastThrough's start removed: TestOutsideCallsStartAfterTheGateway red.
- RequestID left empty: TestOutsideCallsCounted red (rows written again
after a restart).
- host.js's rid/time filter removed: TestPluginOutsideCalls red ("4
calls, want 2").
- Plugin: owningUser and own-conversation filters removed: calls.test.mjs
red.
Not tried:
- A full magpie gateway with the plugin installed reading a real
account end to end (the plugin read was real; the magpie side ran
against the fake plugin and stand-ins).
- A team account (teamId), and the Cursor editor itself (none installed
here); the editor's and cursor-agent's calls are one list, both shown
as the Cursor agent.
- Two computers running magpie on one Cursor account each count the
other's gateway calls as made outside magpie.
- No GUI change: the rows use the reported-row path the Usage page has.
|
||
|
|
9309e28ced |
plugins: a plugin's provider in front of a vendor's API is that vendor to the gateway (songlairui on X, #5462, #5464)
A plugin whose provider's `api` is on a vendor's preset host (a Mistral Vibe plugin's https://api.mistral.ai/v1) got none of what magpie does for that vendor, since its Host() is the plugin's id. An earlier turn's thinking went to the plugin's fetch as reasoning_content, and Mistral turned the whole request away (422 extra_forbidden); the plugin had to rewrite the body itself. provider.VendorHost and VendorPreset now resolve a plugin's declared `api` host to the preset that names it (every Chat, Responses and Anthropic base of every preset and region; local and remote magpie presets excluded, and an api on loopback, a private address, .local or .localhost names no vendor). For every other provider, and a moved subscription, they are Host() and Preset as before. The gateway's vendor checks read them: 38 p.Host() sites, Mistral's, OpenRouter's, DeepSeek's, Kimi's and DashScope's preset checks. Host() stays the plugin's id where calls are kept and shown; requests still go only to the plugin's fetch. Search and the video plan check are unchanged. No community plugin's api is on a preset host today (checked at plugins 7b52e3fc), so none changes. Any plugin gets this with no new field; documented in docs/subsystems/provider-plugins.md and the plugin docs (en, zh, ja). Run (mote): go vet ./... darwin, GOOS=linux -tags nogui, GOOS=windows; go test -count=1 -timeout 45m ./internal/provider ./internal/plugin ./internal/gateway: ok (provider 209s, plugin 182s, gateway 1002s). gofmt -l clean. Broken by hand: pluginVendor resolving nothing (the old behaviour) turns TestPluginVendor red, and TestPluginInFrontOfMistralIsMistral red on both halves: the translated Claude Code turn is answered Mistral's 422 extra_forbidden, and the relayed Chat request carries reasoning_content. Not tried: a real Mistral Vibe key through the reporter's plugin; Windows and Linux runs of the tests (no OS-specific code). |
||
|
|
16dcfa504a |
plugin: a models hook that refused a sign-in isn't asked again for it at once (JZGiVvkSOA75376 on X)
Two dead Zed sign-ins were listed ~30 times a minute, each listing asking Zed for a model token and getting 401 again. A models hook that throws with signIn "expired" is now held for that sign-in (its access, refresh or key): the listing falls back as it did, with the same error, and the hook isn't asked until the same backoff as a failed renewal (30s doubling to 30 minutes) has passed. Signing in again asks at once. This is in the host, so it holds for every plugin, not only Zed. Run: go test -run 'TestRefusedListIsNotAskedAgain|TestFetchBuildsInfoOnce| TestPluginRenewsSignIns|TestRenewRetryBacksOff' ./internal/plugin on mote: ok. Broken by hand: skipping the hold makes TestRefusedListIsNotAskedAgain red (3 listings asked 3 more times). |
||
|
|
6e2dcc4a10 |
plugin: a sign-in that won't renew is asked again later and later, not at once (JZGiVvkSOA75376 on X)
Two dead ima accounts (magpie-ima-auth 0.3.0) were renewed ~80 times a minute: its auth.refresh catches ima's "sign in again", warns and gives back undefined, and the host took that as "nothing to do" without noting a failure, so every request, models listing and usage read asked again. A refresh that gives nothing back while the sign-in is due now counts as a failed renewal. A failed renewal of the same sign-in waits 30s, then doubles each time up to 30 minutes, for every plugin; a new sign-in starts afresh, and one the vendor turned away for good is still never tried again. Run: go test -run 'TestPluginRenewsSignIns|TestRenewRetryBacksOff|TestAuthLock' ./internal/plugin on mote: ok. Broken by hand: dropping the failure note on an empty refresh makes TestPluginRenewsSignIns red (r-none renewed three times); a flat 30s retry makes TestRenewRetryBacksOff red. |
||
|
|
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)
|
||
|
|
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.
|
||
|
|
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
|
||
|
|
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> |
||
|
|
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 |
||
|
|
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. |
||
|
|
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
|
||
|
|
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
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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
|
||
|
|
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) |
||
|
|
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 (
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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).
|
||
|
|
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 |
||
|
|
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 |
||
|
|
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 (
|
||
|
|
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 ( |
||
|
|
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 |
||
|
|
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
|
||
|
|
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 |
||
|
|
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
|
||
|
|
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
|
||
|
|
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
|
||
|
|
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). |
||
|
|
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 |
||
|
|
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. |
||
|
|
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 ( |
||
|
|
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
|
||
|
|
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> |
||
|
|
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
|
||
|
|
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
|
||
|
|
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 |
||
|
|
3dc25a6168 |
tests: a plugin fake's vendor counts only its own test's requests (#3357)
Run 39913278700 at |
||
|
|
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 |
||
|
|
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 |