ae3c2ec4e90da14caef83f52894c510e9ffc1ea4
107
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
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
|
||
|
|
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. |
||
|
|
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
|
||
|
|
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 ( |
||
|
|
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
|
||
|
|
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 ( |
||
|
|
e3c09f4f36 |
plugin: a request is told the provider info built once per account, not built again per fetch
host.js ran info(provider, key) on every fetch, to hand chat.headers
hooks the provider. Each build rebuilt the model list from models.dev and
config, read and parsed plugin-auth.json twice, JSON-cloned the list and
asked the plugin's provider.models hook, which real plugins (cursor, zed
and others) answer by asking the vendor once their own TTL runs out. It ran
even when no plugin had a chat.headers hook.
infoOf(id, key) now keeps the info per account. Any change to the
account's sign-in (setAuth, removeAuth, settle, client.auth.set, renew,
take, reload, all through forgetAccount), new provider options, or a new
models.dev file builds it again, once. providers() seeds the cache with
what it built. The loader, usage and check-in read it too; check's strict
build stays direct. chat.headers gets the shared object, as OpenCode hands
plugins the provider it keeps, and the request asks for it only when a
plugin has a chat.headers hook.
Measured (TestPerfScratch harness, not committed; fake plugin, sandbox
HOME, loaded machine, two runs each):
- {} body, 1-event reply, 400 fetches: models hook asked 400 -> 0 times.
- same, a plugin with 300 config models: 0.995-1.17 ms -> 0.27-0.29 ms
wall per fetch, host CPU 1.23-1.33 ms -> 0.30 ms per fetch, host RSS
87-89 MB -> ~54 MB.
- 246 KB body, 2 MB SSE reply, 40 fetches: host CPU 10.25 -> 8.25 ms per
fetch, models hook asked 40 -> 0 times.
- idle host CPU ~10-20 ms per 10 s before and after.
Tests: TestFetchBuildsInfoOnce counts the fake's models hook (new
FAKE_MODELS_LOG): 20 fetches ask it 0 more times, a new sign-in and new
options each ask it exactly once, and chat.headers and the loader still
see fake-1 and every model. Broken by hand twice, red both times:
returning no cached info ("20 requests asked the models hook 20 more
times, want 0"), and not forgetting it on sign-in ("after a new sign-in
... 0 times, want 1"). host_flow_test's mid-setup case now stubs infoOf
and registers a chat.headers hook for its "info" stage, which red on
this change without it (the stage was never entered).
Run: go test ./internal/plugin -count=1 ok (159.5s);
TestFlowAbortDuringSetup|TestFetchBuildsInfoOnce -count=2 ok.
|
||
|
|
7ba1b49846 |
plugin: a plugin's usage resets carry the team's and each window's
ZCode's built-in showed the personal plan's and the team's resets with each
reset's end; a plugin's usage could carry only one. host.js now passes a
plugin's resets.team and resets.each through, and movedCards shows them as
the built-in did. zcode 0.1.19 sends them.
TestPluginUsage's team and each check (plugin_usage_test.go) goes red without it.
Run at
|
||
|
|
e733b0722e |
plugins: a provider plugin says which service tiers a model serves, and Codex offers them (#2514)
Lovest on Discord (#general, v0.1.1267): a provider plugin had no way to
say a model is served at Fast or Ultrafast, so Codex never offered them for
plugin models, and the host dropped the field anyway.
- host.js keeps m.serviceTiers (tiersOf: string ids or {id} objects,
trimmed, de-duplicated, anything else dropped) as plugin.Model.ServiceTiers.
- pluginCatalog puts them on catalog.Model.Tiers; CodexTiers offers a
plugin's tiers when it declares any, so codexcat writes service_tiers
(priority named Fast) into Codex's catalog and /v1/models.
- forwardTranslated keeps service_tier (OwnTier) for a plugin provider only
when the request is translated to its Chat or Responses and the tier is
one the model declares (provider.PluginTiers). A request relayed in its
own protocol was already sent as the client wrote it; unchanged. Cursor's
fast flag and #1954's ChatGPT tiers are untouched (#1954 not on main yet).
- Docs: serviceTiers in site/public/docs plugins (en, zh, ja) and a
"service tiers" section in docs/subsystems/provider-plugins.md.
Tests (internal/gateway/plugin_tiers_test.go, fake plugin FAKE_TIERS):
TestPluginModelServiceTiersListed (fake-1 priority=Fast + ultrafast,
fake-resp ultrafast, fake-claude none) and TestPluginServiceTierReachesFetch
(Responses→plugin Chat and Chat→plugin Responses send a declared tier,
drop an undeclared one; same-protocol relays as before).
Broken by hand: OwnTier branch forced false → 3 translated cases red;
CodexTiers without IsPlugin → listed test red; host.js serviceTiers: [] →
listed test red. Restored → green.
gofmt -l clean; go vet -tags nogui with GOOS=darwin, linux, windows clean.
Not tried with a real vendor plugin that serves ultrafast.
Full suite: go test -timeout 45m ./... at af9e0d6b2 (sandbox HOME, load
average ~408 from other sessions): every package ok except agent and
gateway, which timed out at 45m with no failed test (rerun whole: timed
out again, 0 failures), gui (TestMainWindowCorners killed, #1936),
TestVendorThatStopsMidAnswerIsSaid (filed #2535) and
TestSetAnswersWhileDevinAndProvidersHang (#1375). The reds and the tests
running at each timeout (TestCodexKeptOnChatGPT, TestReplyNamesMember)
pass rerun alone, except TestMainWindowCorners (#1936). CI is the gate.
|
||
|
|
b6533893a7 |
plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:
- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
"page") sections beside Subscriptions, Gateway middleware and Agents,
each card with its own chip (a new Tools chip, the Page chip). Before,
both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
magpie.page.file is a Page, and that file must be committed, as a
provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
routing strategy, tools, an agent, a page) and its "Write a plugin" link
opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
registry kinds and the community package names for each, in en, zh, ja.
Run at the reviewed head (on origin/main
|