ac4af582301a4e8a29245dbba767eba31334ddf9
67
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e0f6eda641 |
gateway: a probe's reply that thinks its 16 tokens and ends unsaid is answered (plugins#827)
Through a Remote magpie, the plain model test of Open Design's
glm-5.3-flash was red. The model always thinks. It spent the test's 16
tokens on that and ended after content_block_stop, with no message_delta
or message_stop. So:
- translate made it a 502 "ended before it was complete";
- the 502 is busy, so the remote retried it and waited out its 60s
patience;
- the asking magpie had given the remote only 20s (testWait), and said
no answer came.
Each step is now fixed for the class, not for this model:
- A reply whose request was capped at a short probe's worth
(cutVoidTokens, 1024) and that spent some of it, then ended cleanly
with nothing saying it ended, ended at its length (endsAtProbeCap).
- This holds in translate, in streamTranslated and in gathered (a
Responses plugin's stream asked whole becomes response.incomplete at
max_output_tokens).
- It covers Anthropic and Responses upstreams only. Gemini always
ends with a finishReason, so a Gemini stream without one stays a cut
(TestGeminiUpstreamEndedShort, asked for 256, caught a wider first
draft).
- A reply asked for more than 1024, or one that spent nothing, is
still the 502.
- A client may say how long it waits (provider.WaitHeader,
X-Magpie-Wait, in seconds). The gateway then takes no same-one retry
pause and no patience round that would end within clientRoom (10s) of
that wait (keptAlive.outlives), so the client gets the error while it
still waits. Like every X-Magpie- header, it is not sent upstream.
- A model test through a remote magpie waits pluginTestWait (60s), as a
plugin's test does here, and sends that wait as X-Magpie-Wait.
Not changed: a stream relayed as it came (passthrough to an agent of the
same protocol) still gets no end added. That is filed as #5736 and named
in gateway-routing.md.
Run, through mote-run:
- At the pushed tree, rebased on origin/main
|
||
|
|
c57a5f7f58 |
gateway: a vendor's redirect to another origin is sent no provider key
Go's http.Client follows up to 10 redirects to any host, https to http included, and on a hop to another domain drops only Authorization, Cookie and WWW-Authenticate. So a vendor (or anything answering at its URL) that redirected elsewhere got x-api-key, x-goog-api-key, api-key and a provider's own headers sent there; Authorization too when only the port differed, and all of them in the clear on an https to http hop on the same host. The class is fixed where the requests leave: - provider.KeepsCredentials is a CheckRedirect that follows a redirect only to the request's own origin (scheme, host, port; or http to https on the same host and default ports), at most 10, and gives any other 3xx back as the answer (http.ErrUseLastResponse). - provider.Keyed(c) is a copy of c with c's own CheckRedirect, then KeepsCredentials. Provider.do, the choke point of every p.Do, sends through it, and every http.DefaultClient.Do in internal/provider that carries a credential is Keyed(http.DefaultClient).Do. A copy per call, since netproxy.Install sets the default client's transport at run time. Left alone: Grok's public download, Antigravity's version URL and cline.go's unsigned read. - the gateway's client (s.client, every vendor call), the Codex relay's and the Codex websocket's take KeepsCredentials, and so does chatgpt_api's siwcClient. The native route needs nothing more: the vendor's 3xx comes back to the caller as it came, Location included, and the caller decides. Translated routes don't follow either, rather than following with credentials stripped: it is the rule search_api.go had already (#1580), no vendor magpie speaks to was found redirecting its API to another origin, a stripped request elsewhere would only fail with a confusing 401, and the vendor-URL downloads (video, images) are fetched unsigned through vendorClient, so they are not affected. Tests: TestRedirectKeepsTheKeyAtItsOrigin (307 and 302 elsewhere with Authorization, x-api-key, x-goog-api-key, api-key and a custom header; a same-origin redirect followed with every key; three clients), TestRedirectNeverDowngrades (an https vendor's redirect to http on its own host and port), TestSameOrigin, TestKeyedKeepsTheClientsRule, TestNativeRedirectKeepsTheKey (Anthropic and Gemini providers with an own header) and TestChatRedirectKeepsTheKey. Broken by hand: with Provider.do back on client.Do and s.client without CheckRedirect, the thief got every key header, /away answered 200, the https vendor's /plain was followed (400 from the TLS port spoken to in http), the native route's claudeish and gem answered the thief's {"stolen":true} with Authorization, X-Api-Key and X-Relay-Secret sent there, and the chat route sent Api-Key, Authorization and X-Relay-Secret to it. TestSameOrigin and TestKeyedKeepsTheClientsRule don't depend on the wiring and passed. Run on mote at the pushed head 883690a0b (this commit and the next, on origin/main |
||
|
|
78128b5101 |
provider: a plugin's thinking model listed as, or the same as, another takes that model's levels (axelburks)
axelburks on Discord: a plugin's model that thinks and declares no
variants, set the same as and listed as claude-opus-5.5, took Claude Opus
5.5's price but showed its reasoning levels unknown, none ticked.
Cause: pluginCatalog borrowed levels for the plugin's own model id
(borrowedEfforts(m.ID)), which no catalog knows, so it got none; the
rename to the id the user lists it by (localIDs.list) then kept that
empty list. The price is looked up by the listed/same-as id, which is why
only the levels were missing.
Fix: a model whose levels were borrowed (catalog.Model.EffortsBorrowed,
set only in pluginCatalog's borrow) borrows them again for the id it is
listed by, which also follows the user's same-as. Levels the plugin's
own variants give stay first, and the levels the user kept narrow the
borrowed ones as before (effortsKept).
Test: TestPluginModelListedAsBorrowsLevels (listed as and same as one
id, listed by a name of the user's own, a model with variants of its
own, the price, and kept levels narrowing them).
Red on the old code: with the localid.go hunk reverted it fails with
"claude-opus-5.5 listed with levels [] ... want [low medium high xhigh
max]", the same for the gateway's p.Efforts and for my-opus.
Broken by hand: dropping the EffortsBorrowed set in plugins.go turns it
red (4 "want [low" errors). TestPluginThinkingModelBorrowsEfforts and
TestClinePluginBorrowsEfforts stay green.
Run on mote at this tree (on
|
||
|
|
f3681b90c3 |
gui: the Agents page says a model's load by the picked model and in its picker (axelburks on Discord)
axelburks (Discord #feedback) could see a model's load only on its provider's page, too deep to judge which model to pick on the Agents page. A plugin's reported load (magpie.load) now shows there too, as the same quiet grey badge the provider page uses: - by the picked model in each agent's model row, before the chevron; - on each row of that row's model picker, after the speed. GET /api/model-loads (speeds.go) answers every fresh load (LoadFresh, 5 minutes) by "provider/model" lowercased, the ref /api/model-speeds uses: plugin.FreshLoads copies the fresh entries under one lock, and provider.ModelLoads keys them by magpie's provider id, the user's own listed id too (ModelIDs), with model@size falling back to its model as ModelLoad does. With no plugin reporting it is one lock and an empty map. The page reads it when a model picker opens and with the Agents page's 15s drift check, each throttled to once per 30s, and the drift read only while a row shows a magpie model. No new poll; /api/state and Option are unchanged. The core script stays under its budget (1,533,802) by shortening comments in the picker and agent-row code; no budget raised. The route is named in the CLI's route list (read-only, U) like model-speeds. Run at this head (rebased on origin/main b4073c06a; the rebase onto |
||
|
|
5ec2375688 |
gateway: a call's HTTP headers both ways, masked, folded under its bodies
usrname1833 on Discord asked to see the raw request and response HTTP headers (查看原始请求和原始响应的http头), to debug as with a capture. magpie kept the client's request headers and its own response headers only in the request archive, and nothing of what went upstream. Now a call keeps its headers both ways (internal/gateway/wire_headers.go): - the client's, as they reached magpie: headerLogged in Handler() clones them for every request that isn't a GET, HEAD or OPTIONS; - each request magpie sent upstream for the call: method, address, headers, and the answer's status, protocol, headers and time, or the error. rpmTransport (under s.client) records it as it is sent; provider.SendsThroughPlugin records a plugin account's hand-off, shown as handed to the plugin, since the plugin's own request to its vendor is made in Bun and magpie doesn't see it (the view says so). The first 8 tries are kept, the rest counted. Recording copies each header map; nothing is masked or sorted as a request goes. Secrets are taken out when the headers are read (Call.Headers): by what each header is (new redact.SecretHeader, now behind redact.ScrubHeader: Authorization, cookies, x-api-key, api-key, any *-Key, *-Token, *-Secret, *-Auth, *-Signature, but Idempotency-Key and a count of tokens such as anthropic-ratelimit-tokens-remaining), any Bearer or Basic value, and redact.Scrub on the rest; an address loses its password, a secret-named query value (?key=) and its fragment. They live with the call in the 40-call ring; /api/gateway/call gives them as "headers". The request archive keeps the upstream ones as "upstream" beside the request's and response's headers, masked the same way. No body is stored that wasn't before. GUI: under a recent call's bodies on Gateway and a request's on Routing, "HTTP headers" folds open the client's headers, then each upstream request beside its answer (wireHeadersView, plugins/usage/page.js); the archive's copy shows its upstream requests too. Strings in all four languages. docs/subsystems/gui-shell.md describes it. Also changed by SecretHeader: the request archive no longer masks a rate-limit count header (…-tokens-remaining), which the old name rule took for a token. (provider.SecretHeader, which backups use, is another function and unchanged.) Tests: TestRecentCallHeadersBothWays (a fake vendor; the client's key and cookie, magpie's upstream key and the vendor's Set-Cookie all masked; status, protocol and response headers kept), TestRecentCallHeadersEachTry (a 429 then the next key, both kept in order), TestPluginHandOffHeaders, TestScrubURL, TestSecretHeaderRealNames (real header names both ways), TestArchiveOnThisComputer and TestRecentCallBodiesOnDemand extended, call-headers.test.cjs (Gateway, Routing and the archive's copy; chromium and webkit; en at 1100px, zh, zh-TW, ja, de at 380px and Routing at 440; nothing out of the box, no left-border accent). Run (on mote, macOS 27.2, through mote-run, unless named): - Full suite at ebd22b1b4 (the same change on |
||
|
|
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 |
||
|
|
4dfdd0cd63 |
provider: a provider switched off is asked for nothing, its plugin's model list included
ChangQiu on Discord switched a provider off long ago, and magpie still reached it. Routing, fallback, usage and balance reads, warmups, check-ins and keepalive were already held back (On(), leftAlone, KeepListsFresh). These were not: - The plugin host's providers listing ran every plugin's models hook, which asks the vendor, and its sign-in renewal (fresh), for every plugin provider, on or off. Go now passes the ids switched off (plugin.ListingOff, provider.pluginsOff: the provider's id and the plugin's own id, read from providers.json alone). host.js lists such an id without running a hook (info(..., quiet)), so its row stays and keepListed keeps the last list. - Sync (POST /api/sync, `magpie sync`) fetched every ready provider's list. Both now go through provider.RefreshLists, which skips one switched off. - Saving or switching on in the GUI fetched the list even for one left off; PrefillNewKeys asked one switched off too. What still asks one switched off, by the user's own click: the TUI's refetch, the provider Test button and `magpie provider models <id>` refetch. Tests: TestOffPluginProviderAskedNoModels (the fake plugin's models endpoint counts its hits: 0 while off, the list kept, asked again once switched on), TestPrefillAsksNoProviderSwitchedOff, TestPluginsOffNamesThePluginsOwnIDs and TestRefreshListsAsksNoProviderSwitchedOff. Run on mote at this head (first at |
||
|
|
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) |
||
|
|
9621168c46 |
provider: a plugin's thinking model with no variants borrows its maker's reasoning levels
laomao04_65777 on Discord: in Codex, with SenseTime Raccoon (商汤小浣熊) picked, the reasoning effort couldn't be switched. Cause: Raccoon's plugin lists its models as thinking with no variants. Its sn-* ids (sn-glm-5-3, sn-kimi-k3, sn-glm-5-3-flash, sn-deepseek-v4-1-flash, sn-deepseek-v4-pro) are ones models.dev knows under the maker's spelling (catalog.Knows). So levelsUnknown counted them as known and offered nothing, and pluginCatalog borrowed the maker's levels only for moved built-ins and Cline. Codex's catalog got supported_reasoning_levels [] and hid the picker. A custom provider's same id already borrows them (effortsOf), and an id models.dev doesn't know already got low/medium/high ( |
||
|
|
8d8df06399 |
plugin, gateway: a plugin reports its models' load, and busy models can go last (axelburks on Discord)
axelburks (Discord #feedback): an in-house vendor queues requests to
its busy models, and the plugin could only put the load in the model's
name, which changed only when magpie re-read the list.
- A provider plugin calls input.magpie.load(provider, {"<model id>":
0-100 | null}) whenever it likes, from its own timer. host.js
(reportLoad) clamps each number to 0-100, null clears a model, every
other value is dropped, at most 1000 a call, and it returns the count
taken. A provider that isn't a string or loads that isn't an object
throws a TypeError. It goes to Go as an unasked {event:"load"}.
- internal/plugin/load.go keeps each by provider and lowercased model
id. ModelLoad answers unknown once a load is older than LoadFresh
(5 minutes), never idle. model@size falls back to its model.
- The provider editor shows it by the model as a grey ctx badge
("87%", titled "87% busy now, as its plugin says").
- Settings > Network and sharing > Busy models last (settings.BusyLoad,
POST /api/settings/busy-load, Off by default, over 50/70/80/90% or
1-99 by hand): restLast puts a model reported over it behind the
ready candidates, ahead of the resting. The trace row has busy:<load>.
At a new turn affine moves a conversation off it (Why "busy",
busyBehind); within a turn it stays. after, readyForNew and leastHeld
skip it. Unknown load, a lone candidate, or all busy: nothing moves.
- Docs: site plugins page (en, zh, ja) "Model load" section and input
table; docs/subsystems provider-plugins.md and gateway-routing.md.
Run, all on mote via mote-run at a42736807's tree rebased on
origin/main
|
||
|
|
f1545e1477 |
gateway: a vendor's "model not served here" refusal fails a group over to its next member (#2887)
A routing group's first member answering ModelScope's 400 "Model id :
deepseek-ai/DeepSeek-V4.1-Flash , has no provider supported" ended the
group request: the words matched none of the refusal classes that make
a 400 retryable, so the client got the 400 and its own retries landed
on the same dead seat — the reporter watched 28 in a row, the later
members never asked.
What changed: unservedWords takes the vendor wordings that say the
model is served nowhere on this member — ModelScope's "has no provider
supported" (the report's usage.jsonl), and Azure OpenAI's for a
deployment its resource has none of, code DeploymentNotFound ("The API
deployment for this resource does not exist"; Microsoft Q&A, Stack
Overflow — its 404 fails over by status already, the wording covers the
400s a relay passes on). An unserved refusal keeps the poison pill's
line: a plain bad request ("Invalid parameter", "field required")
still ends the route, as it would fail on every member, and
shapeRefused still excludes these words — the seat rests on its
model's own key (restAfterMarked's unserved branch, the #1235
mechanism), so the key's other models stay live and the group's next
request passes the dead seat.
Run: go test ./internal/gateway/ (TestGroupFailsOverAModelWithNoProvider
red on upstream/main, green here; the family and the plain-400 guards
green); -race targeted; gofmt; vet darwin/linux/windows; builds
darwin, linux and windows (-tags nogui).
Reviewed and landed as one batch of 12 commits (gua's #4593, #3269,
#3881, #2887, #3289, #2718, #2855, Edward4226's #2718 key-path
sibling, and four review follow-ups). Run for the batch, whose last
commit's tree is 5d58a75f3:
- Full suite before the rebase (base
|
||
|
|
ca183561f7 |
gateway: an allowed_tools tool_choice reaches the Grok plugin (#3153)
grokShaped dropped a tool_choice object whose type isn't among grokTools on the plugin's path too, the same as for the built-in: a Responses request relayed to the Grok plugin in its own protocol reached the plugin's fetch with no tool_choice, so with the X search option on (grok 0.2.0) the plugin added x_search over a client's allowed_tools and a tool outside the allowed list went out. The plugin reads the choice and leaves an unsupported one out before Grok itself (every version since the TOOLS filter, the mover's min 0.1.18 among them), so grokPluginBody now keeps such an object, as it keeps the lone "none" (#3110); grokShaped's keepNone is forPlugin, since keeping is no longer only about "none". The built-in, which is Grok's last stop, still drops it. Run: - gofmt -l on the changed files: clean - go vet ./...: darwin and GOOS=windows clean; GOOS=linux vet needs -tags nogui (the GUI's wails doesn't vet without it), clean with it - go build: darwin, GOOS=linux -tags nogui and GOOS=windows: ok - go test -tags nogui ./internal/provider: ok 167.3s, no FAIL - go test ./internal/gateway -run 'TestToolsOffWithoutTools|TestGrok': ok - TestGrokPluginBodyKeepsUnsupportedToolChoice fails without the change ("plugin: tool_choice {Type: Mode: Tools:[]}"), passes with it; broken by hand, each way red then green on restore: deleting the choice whatever the path (plugin red), deleting only a supported type (built-in red) Landed (yetone): the next commit adds the end-to-end test through the gateway to the fake Grok plugin. Run at the pushed head on mote: go test ./... -timeout 45m on mote with this branch on |
||
|
|
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 |
||
|
|
9fa11784db |
provider: a provider's proxy and off switch are read from providers.json as parsed once
A live magpie's heap profile (v0.1.2404, 53 minutes) allocated 3.6 GB of its 33 GB in provider.load, a parse of the whole providers.json, mostly for one field of one provider: storedPicks (its proxy, 1.73 GB) and leftAlone (switched off or hidden, 1.24 GB), asked for each request and each background look, then customIDs, keptAs, loginSwitching and accountRemoved. These six only read, so they now go through storedFile: filememo's parse of the file, kept until its time or size changes (and its bytes, written in the last two seconds), and dropped by every write magpie makes (writePrivate's Forget). A file missing or not decoding goes the way load goes, to its last good generation. What load's other callers get is unchanged, as some of them edit what they read before a save. TestStoredParsedOnceUntilTheFileChanges: 30 providers of 100 models. storedPicks and leftAlone with the file unchanged take under 40 allocations (a parse is 3381); a provider switched off since is left alone at once; another process's edit of the same size is seen; a zeroed file still finds its providers. Broken by hand: storedFile parsing each time, red (3386 allocations); a broken file read as none, red. Run at this tree on mote: gofmt clean; go vet ./internal/provider on darwin, linux and windows; go test -count=1 -timeout 45m ./internal/provider (ok 116.0s) ./internal/gateway (ok 613.2s). |
||
|
|
7e0fe83d4b |
provider: Listed as works for signed-in accounts and plugins (zeewell on X)
zeewell asked to list SuperGrok's grok/grok-4.6@500k as grok-4.6, and Cursor, Devin and WorkBuddy models (all plugins) under ids of their own. v0.1.2345's "Listed as" took ids only for key/relay providers (takesModelIDs was p.Account == nil). Why the restriction was there: the wire rewrite (Settings.Wires) turns the request body's model back into the own id, but some code reads the model by the vendor's id before that and got the listed one: - plugin model lookup (pluginModel: the plugin's APIs, tiers, prices); - the Claude subscription run (--model given to Claude Code); - Code Assist/Antigravity variant choice (codeAssistBody, SentNameOnIn); - account plan lists (fallback's Account.Lists, effort Levels/Tiers, AccountServes); - moveModelRefs refused a provider with no providers.json entry, which is every plugin and account provider until a pick is set. Each now translates with OwnModelID / the provider's ModelIDs, so the upstream request still carries the vendor's or plugin's own id. Only a decide-only provider refuses an id. The GUI box already follows TakesModelIDs, so no GUI file changed. Tests (red on the old code, each fix reverted by hand one at a time): - TestModelIDRefused, TestModelIDAtAnAccount (takesModelIDs, AccountServes, SentNameOnIn); - TestLocalModelIDAtAPlugin (Bun fake plugin: /v1/models, upstream path, X-Plugin-Model, body, usage; red on pluginModel and on moveModelRefs); - TestLocalModelIDAtAnAntigravityAccount (codeAssistBody); - TestLocalModelIDAtAClaudeAccount (claude got --model my-sonnet); - antigravity pool test (fallback Lists, Levels). Run on mote: gofmt clean; go vet darwin/linux/windows ok; go test -tags nogui -count=1 -timeout 45m on internal/provider, gateway, cli, gui, settings, access, usage, plugin: all ok except internal/gui's TestSettingsSaveKeepsWhatItDoesNotSend (SearchAll), red on main since |
||
|
|
f115122626 |
plugins: an Anthropic model under a loader base without /v1 goes to its /v1 (Copilot's Claude 404)
cyoking1 on X (tweet 2116084357731701020): every Claude model through the GitHub Copilot plugin answered 404. pluginFetch took the loader's baseURL first, and Copilot's loader says https://api.githubcopilot.com for every model, while its Claude models are @ai-sdk/anthropic rows whose own api.url is https://api.githubcopilot.com/v1 (models.dev). magpie's /v1 is taken off the path, so the request went to https://api.githubcopilot.com/messages. pluginRequestBase now sends an Anthropic model whose own URL ends in /v1 under the loader's base + /v1 when that base doesn't end in it, as OpenCode's own Copilot provider does (packages/core/src/plugin/ provider/github-copilot.ts: `${loaded.baseURL}/v1` for messages models). That covers every plugin, and Copilot Enterprise's copilot-api.<host>. Unchanged: a base already ending in /v1 (zcode, minimax, commandcode, zed), a model whose own URL has no /v1 (Kiro's BASE), and every non-Anthropic model (Copilot's GPT on its bare base). Every @ai-sdk/anthropic api.url in models.dev ends in /v1. Run: - Real account (owner's Copilot sign-in, token from the OAuth refresh): POST api.githubcopilot.com/messages claude-sonnet-5 -> 404 "404 page not found"; /v1/messages -> 200 with a reply. - TestPluginAnthropicBaseKeepsV1 (new): green; broken by hand (the /v1 append commented out) it is red on the copilot, trailing-slash and enterprise cases. - mote: go test -count=1 ./internal/provider ./internal/plugin ok; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... clean; go build, GOOS=linux -tags nogui and GOOS=windows builds ok; gofmt -l empty. - Full suite (-timeout 45m) started on mote at this head; pushed before it ends per the ship-at-once rule; reds get their own issues. Not tried: a whole magpie gateway with the Copilot plugin signed in end to end; the fix was checked at the base it computes and the real endpoint by hand. |
||
|
|
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 ( |
||
|
|
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
|
||
|
|
3ec25523cb |
provider: a plugin's 401 about the model keeps the account's sign-in (plugins#468)
A plugin that answered "this model isn't available on your plan" with 401
marked the account as needing a new sign-in, and the gateway fails a 401
over to the provider's next account (retryable in fallback.go), so every
account of the provider was marked "sign-in has expired" for credentials
that were fine.
notePluginSignIn now reads a 401 that carries no X-Magpie-Sign-In as
"kept" when its body says the model isn't served (provider.ModelUnserved,
the gateway's unservedWords moved here, read decoded by catalog.Words)
and nothing of a token, key, credential, session or sign-in. Only the
first 64KB is read, and the body goes on whole.
Not changed: the gateway still rests the account under its failure
backoff for that answer; modelRefused still reads only 400/403/404/422 as
the model refused. The guide asks for 403/404 (docs commit).
The 401 bodies the community plugins hold for a sign-in that is gone
(magpie-community/plugins 95fa761, every package's tests), each in the
test's "marks" list and none read as kept (none names a model, which
ModelUnserved needs):
- devin: {"code":"unauthenticated","message":"invalid api key" / "bad key"}
- zed: "unauthorized", "", {"code":"upstream","message":"bad key",...}
- cline: {"error":{"message":"nope"}}, {"success":false,"error":
"unauthorized"}, {"message":"expired"}, "the sign-in lapsed — sign in
again"
- raccoon: "unauthorized", {"code":200003,"message":
"authorization_verify_error"}
- joycode: {"code":401,"msg":"登录票据已失效"}, "private-marker"
- zcode: "", {"code":1001,"msg":"Authorization Token非法"},
{"error":{"message":"token expired or incorrect"}}
- mimo: "", {"code":401}, {"error":{"message":"stale"}},
{"error":{"message":"Invalid API Key"}}
- cursor: "no", "Unauthorized — sign in to Cursor again in magpie",
Connect's ERROR_NOT_LOGGED_IN body
- search1api: {"message":"expired"}
No plugin source builds a 401 whose text names a model.
Run (mote, at this tree): gofmt -l clean; go vet ./..., GOOS=linux go vet
-tags nogui ./..., GOOS=windows go vet ./...; go test -tags nogui
-timeout 45m ./...
(go test -tags nogui -timeout 45m ./... at base
|
||
|
|
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
|
||
|
|
4391ff0f56 |
provider: asking a plugin for its model id replaces just the model (#4004)
When a plugin's model has an API id other than the one asked for, withModel decoded the whole request into a map and marshalled it again, which allocated 469 MiB for a 45 MiB body, about ten times the body. Now a body with one top-level "model" string gets just that string replaced, in one buffer of the body's size. Every other byte goes as it came. A body that isn't JSON, has no string model, or names "model" twice takes the old path. A body of null goes as it came; it was a panic, writing into a nil map. The gateway's own withModel (Codex backend) and rewriteModel are left as they are. TestCodexRewritesAsBefore pins the Codex backend's sorted bytes, and TestUpstreamBodiesUnchanged pins rewriteModel's handling of a duplicate model. Both went red when the splice was tried there. Run on mote at 3aa36bbea (since rebased onto main, which changed nothing in internal/provider or internal/gateway): - TestWithModelAsksForTheModel: a nested "model" is kept, spacing is kept, an escaped model is replaced, and a missing, numeric or duplicate model, a cut-off body and null are covered. - TestWithModelCopiesOnce: a 45 MiB body is copied once (45 MiB allocated). Against the old withModel, the test is red: 469 MiB allocated, and the body's < was escaped. - go vet ./internal/provider for darwin, linux and windows: ok. - go test ./internal/provider ./internal/gateway -timeout 45m: ok (106s, 495s), the plugin parity tests included. Not tried with a real account: none of the plugins signed in here (WorkBuddy, Devin, Cursor and others) has a model whose API id differs, so this path isn't reached by them today. |
||
|
|
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
|
||
|
|
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. |
||
|
|
afc99490f2 |
plugin: a fetch's body goes to the host in one line made for it (#3472)
Each plugin request was copied several times before it reached the plugin: - pluginFetch read the body with io.ReadAll, which grows from 512 bytes, so a 1 MB body was some 3 MB read. It now reads into a buffer of the request's Content-Length. - Fetch marshalled a map holding the FetchRequest and the body as []byte, so encoding/json base64'd the body into its own buffer and then copied it into the line, and enqueueOwned appended the newline in another copy. fetchLine now marshals the request without the body (FetchRequest.Body is json:"-") and appends the base64 body and window into one slice sized for the whole line; enqueueLine sends it as is. The frame is byte for byte what it was: TestFetchBodyWireIsUnchanged compares it with the old json.Marshal of the map, field order included (request fields, body, window). BenchmarkFetchBodyProd B/op, before -> after: 1 MiB 1,516,234 -> 1,411,609 8 MiB 14.4 MB -> 11.2 MB 16 MiB 29.7 MB -> 22.4 MB Through the gateway with the previous commit (probe, 60 requests of ~938 KB, per request including the test's client and fake vendor): /v1/chat/completions 21.2 MB -> 17.3 MB (24.4 MB before both, -29%) /v1/messages 33.7 MB -> 29.3 MB (39.8 MB before both, -26%) Server.serve's own share on /v1/messages: 29.1 -> 19.0 MB (-35%). What is left on top is buildChat's json.Marshal of the outgoing body, which the upstream byte fixtures pin; not changed here. Run at this head (base origin/main |
||
|
|
ffe493773c |
usage: magpie's own Test, Detect APIs and model list requests are rows of the request log, counted nowhere
neiko and gys619 on Discord: a provider's Test or Detect APIs left no
trace in Usage > Requests, so a failing test couldn't be read back.
The provider package marks the context of the editor's Test, Detect APIs
(and per-model detection) and a model list's refresh with a kind
(internal/probelog). Each request sent under the mark is written once:
by the provider's Do, or by probelog.Transport under http.DefaultClient
(netproxy.Install), whichever sends it first; the Claude Code run and
the gateway's translated test write theirs from their result. A row
keeps time, provider, account, model, host, path (no query, no
user:password), method, status, ms and the first 500 bytes of the error.
The row is usage.SourceProbe, agent "magpie", Kind provider_test /
api_detect / model_list ("Test", "Detect APIs", "Model list" in Called
for; purposes.js regenerated). The log index keeps probes apart
(logSnapshot.probes), so Visit, Load, Summarize, budgets, Vias, heatmap,
shared days, LastSeen and observers never meet one. The request page
lists them (probeChunk) and counts none: Row.IsProbe, since a packed row
keeps the row's Source and not its record's. The page shows a muted
badge "magpie's own · not counted in any total" (en, zh, zh-TW, ja, de);
no new control, no layout change.
Tests, each red on the old code:
- usage TestProbeRowsListedNotCounted: listed, clipped, and absent from
Sum, Through, every By group, Summarize, Load, LastSeen, OwnDays and
the observer; a provider filter lists it and sums 0.
- provider TestTestWritesItsRequestsDown / TestDetectWritesItsRequestsDown:
every request the fake server saw is exactly one row, with the right
kind, model and 401 text; an unmarked Do writes nothing.
- probelog TestNoteKeepsNoSecret, TestTransportOnce.
- GUI usage-ledger-probe: badge per language, both engines, 1180/420,
light and dark, no left border, no sideways scroll.
- gui TestProviderDetectDraft now expects the log line (source probe,
kind api_detect, no key) and leaves usage.jsonl out of the unchanged
config comparison.
Broken by hand, each went red: request_page's uncounted check,
log_index's probe skip, Append's observer skip, Do's Taken (6 rows for
4 requests), Test's and Detect's marks, probelog's query strip,
page.js's badge (11 GUI fails).
Run at this head (on origin/main
|
||
|
|
72109ea0eb |
provider: a plugin provider offers the models of every account switched on, not only the first's (#2554, willywang; LoKi)
pluginAccounts built the provider's catalog from its first login only, so
a model only a later account serves never showed or reached an agent.
Routing already sends each request to an account whose own list has the
model (perKeyBarred, Account.Lists), so the provider now offers the union
of the first account and every other account switched on, in catalog
order. An account switched off adds nothing; an account with no list of
its own means every model, as before. Reported by willywang, confirmed
again on v0.1.1320 by LoKi (lokic7123-star).
Run at the stacked tree (this commit with #2695 and #2862, on
|
||
|
|
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. |
||
|
|
19527ca8dd |
gateway: tools turned off with none declared reach a plugin as tool_choice none (#3110)
Cause: buildResponses wrote tool_choice only inside its tools block, so a
Chat "none", Anthropic {"type":"none"} or Gemini NONE with no tools was
dropped on the way to Responses. A provider plugin that adds a
server-side tool (Grok's x_search, plugins PR #263) couldn't tell
"tools off" from "no choice". The other builders (Chat, Anthropic,
Gemini, Code Assist) send no tool choice without tools, which is what
their vendors accept (OpenAI Chat refuses a lone tool_choice), so they
are unchanged.
Fix:
- buildResponses keeps a lone "none" (only "none"; "" and "auto"
still go unsaid).
- forwardTranslated strips it again for every non-plugin upstream, and
for a plugin on api.x.ai or Copilot (refusesLoneToolChoice, the #378
rule now shared with passthrough). A vendor never sees it.
- The grok plugin's body shaping (grokPluginBody) keeps a lone "none";
the built-in's grokBody still drops it. grok plugin 0.1.18
(magpie-community/plugins aee6b9d, on npm) drops any lone tool_choice
itself before Grok, so the mover's min goes 0.1.17 -> 0.1.18.
Run at this commit (worktree on
|
||
|
|
81a24cf8fe |
groups: a found group is listed as auto/<model id as the vendor spells it>
ZeroClover asked on X: Auto Group ids group/auto-<slug> can't be looked
up on models.dev. A found group is now listed and written as
auto/<model>, e.g. auto/claude-opus-5.5: /v1/models, the catalog, agent
configs, the GUI's Routing page and the CLI. Context and output limits
come from the model's metadata as before.
What stays the same:
- The internal id is still group/auto-<slug> (Group.Ref() gives the
public one). Every old form is still accepted as input forever:
provider.CanonicalRef turns auto/<model>[:level][[1m]] into it at the
gateway (validateModel), keys, stats, affinity and usage, so both ids
route to the same group and count as one.
- A key's model list allows a model by either id, group/* included
(allows() in key_models.go).
- Hand-made groups stay group/<id>.
- A provider whose stored id is "auto" keeps its models: while one
exists, found groups are listed by their old id (AutoRefsOn) and
auto/<x> means that provider's model. Documented in
docs/subsystems/gateway-routing.md.
Agent configs: SyncCatalog rewrites a field that holds a found group's
old id (renameFoundGroups), but only while the value is still what
applied.json says magpie wrote; a value the user set stays. A pick by
the old id written now is written as auto/<model> (Apply). Hidden,
picked and ordered model lists saved by the old id hold for the new one
(visible.go), and a bare model id still reaches its found group (bare.go).
Claude Code is given a dotted Claude version dashed (ClaudeSpelled), so
auto/claude-sonnet-4.5 sits in its settings as auto/claude-sonnet-4-5.
That routes to the same group, but with found groups off nothing reads
it back dotted, and Reseat took the field for changed and left the agent
on a group that was gone. Reseat now compares a group pick by its
canonical id (samePick). The old ids had no dots, so this is new with
auto/<model>.
Run at this tree (sandbox HOME, caches pinned):
- gofmt -l: clean. go vet ./...: clean on darwin, GOOS=linux -tags
nogui, GOOS=windows.
- go test -p 4 -timeout 45m ./...: every package ok except agent and
gateway, whose failures were the tests' expected ids (updated here)
and two regressions now fixed (bare ids; desktop models hiding groups
by prefix). Every failing test passes on rerun. Load average was
~210-290 from other sessions throughout.
- Reruns: provider, cli, codexcat ok. internal/gui: only
TestSetAnswersWhileDevinAndProvidersHang fails (set slow/slow-1 took
10.19s), and it fails the same in a git-archive export of
|
||
|
|
0f1666b387 |
provider: a built-in can be retired, its plugin serving it moved or not, and its unmoved accounts get a Move line
The owner (10-16) wants every deprecated built-in taken out of magpie,
one at a time. This is the ground for that; it retires nothing yet.
- retiredBuiltins / BuiltinRetired(id) in migrate.go name a built-in
whose code is gone. Only an id with a mover can be retired.
- PluginServes(id) is Moved(id) or retired. Every gate that asked
Moved(id) asks it now: sign-in, Factory keys, usage, logins, cards,
forget, accounts, check-ins, plugin sign-in, the CLI's accounts and
providers, the GUI's account label.
- A retired row's move.state is plugin, and its id is in onPlugins
once the plugin is installed.
- /api/providers lists a retired subscription's built-in accounts that
haven't moved in `unmoved` (MoveCandidate, now with the failed move's
error and why). The GUI shows a quiet line over the Providers list
for each, with Move / Try again (unmovedLine), in en, zh, zh-TW, ja
and de.
- AGENTS.md and docs/subsystems/provider-plugins.md say what a retired
built-in is.
Run at 270aa1c9c with this change:
- go test -tags nogui ./... -count=1 -timeout 90m: 66 packages ok.
- gofmt -l internal: nothing. GOOS=linux and GOOS=windows
go vet -tags nogui ./...: clean.
- GUI, both engines, en and zh: retired-move (new, 4/4), plugin-move,
deprecation-notice, deprecated-subscriptions, plugin-move-unserved,
plugin-movable-review, i18n-keys: 39 pass.
- TestRetiredBuiltinIsThePlugins -count=20 (it picks a mover at random).
The Move line is the Providers list's own, not a page that could be a
plugin. It took the core's scripts to 1,427,218 bytes, which the budget
main raised in
|
||
|
|
8233eadaec |
provider, gateway: a plugin's model served at priority has fast mode, whichever plugin (Lovest on Discord)
Since #2514 a plugin can say which tiers its vendor serves a model at
(serviceTiers). CanFast still returned true only for Cursor's plugin, so
no other plugin's models could be a group's fast member or an agent's
fast pick. The Routing and Agents pickers (gui/groups.go, agent/route.go
FastFor) and SetFastPick/SaveGroup all read CanFast, so they refused too.
Changes:
- CanFast: a plugin's model has fast mode when the plugin says it is
served at "priority", on its Chat or Responses API (pluginTierOn), where
the gateway sends service_tier. This holds for any plugin. Cursor's
fast flag and -fast sibling logic are kept below it, unchanged.
- UltraOn/CanUltra: such a model can also be picked Ultrafast when the
plugin says "ultrafast". Before, plugins were excluded outright.
- forwardTranslated: a plugin's request whose agent spoke Claude's API
carries fast mode as speed "fast", with no tier. It is now given tier
"priority" ("ultrafast" for an Ultrafast pick) when the model is served
at that tier. Before, Claude Code's fast pick on a tiered plugin went
out with no service_tier.
- The "no fast mode" error names plugins.
- docs/subsystems/provider-plugins.md says all of this.
Test: TestPluginTiersGiveFastMode (gateway, fake plugin with FAKE_TIERS):
- CanFast and CanUltra: fake-1 (priority+ultrafast) true/true,
fake-resp (ultrafast only) false/false, fake-claude (none) false/false.
- fake-claude is refused as a fast member and as a fast pick.
- A fast group member reaches the plugin's fetch as priority from Chat,
Responses and Anthropic.
- Claude Code's fast pick sends priority, its Ultrafast pick sends
ultrafast, and another agent's request sends none.
Broken by hand, each then restored green:
- CanFast's tier check off (the old behaviour): red on CanFast(fake-1),
CanUltra(fake-1) and the fast member being refused.
- forwardTranslated's Fast-to-tier off: red on the anthropic member, the
fast pick (nil, want priority) and the Ultrafast pick.
- UltraOn's plugin branch off: red on CanUltra(fake-1) and "no account
offers Ultrafast".
Existing TestPluginServiceTierReachesFetch, TestPluginModelServiceTiers*
and TestCursorPlugin* pass.
No GUI asset changed (the pickers only read canFast/UltraOK from Go), so
the GUI suite was not run.
Run:
- gofmt -l: clean.
- go vet: darwin, GOOS=linux -tags nogui, GOOS=windows -tags nogui.
- go test -tags nogui -timeout 90m ./... at 9f9bfc160+this: EXIT=0, 66
packages ok, none failed (agent 3928s, gateway 2739s, provider 785s).
The timeout is 90m because the load average was ~150-270, and 45m cut
agent and gateway short on this box earlier today.
- Rebased then onto
|
||
|
|
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.
|
||
|
|
4c07442d29 |
provider: a model no catalog prices is at the price its plugin lists, or $0 when the plugin says it is free; devin's mover needs 0.1.18 (太陽と向日葵 on Discord)
太陽と向日葵 on Discord: Usage no longer showed what calls through Devin cost. Devin's own models (SWE-2, SWE-1.7 Lightning) are in no catalog, and ListPrice read only catalogs. In the owner's ledger on origin/main, devin claude-opus-5-5 and deepseek-v4-1-flash rows are priced and the swe-1.7-lightning row is blank. Devin lists its own price for each paid model in GetCliModelConfigs, and devin 0.1.18 (plugins 43d93b0) now gives it as the model's cost. 0.1.18 also makes swe-2 free again: Devin's new -lightning variants under SWE-2 had taken that away on 0.1.17. After every catalog, ListPrice now takes the plugin's price (pluginListPrice, an input or output above 0, read with plugin.Cost, which now carries cache read and write). If there is none, a model the plugin marks free (plugin.Model.Free) costs $0 (pluginFree). A catalog's price is still kept over the plugin's, and a plugin model with neither stays unpriced. The devin mover's min is raised to 0.1.18 (npm view --prefer-online on registry.npmjs.org: 0.1.18). A row is added to providers-accounts.md. Run: TestPluginFreeModelCostsNothing (new) and TestPluginCatalogPriceAndImages, -p 1: ok. Broke it by hand: pluginListPrice off turns swe-1.7-lightning red; pluginFree off turns swe-2 red. gofmt -l clean. go vet -tags nogui ./... for darwin, linux and windows: ok. Real use: a sandbox HOME with only the owner's Devin key, plugin 0.1.18 and this build. - `magpie plugin list --json` on Devin's live answer: swe-2 free; swe-1.7-lightning 2.5/12.5 (cache 1); swe-2-high-lightning 1/5; claude-opus-5-5 4/20. - `magpie usage --csv`: the 10-03 swe-1.7-lightning row is $0.000819, where origin/main gave none. Not done: Cursor auto, Qoder's and WorkBuddy's own models have no USD price from their plugins (they list credit multipliers), so they stay unpriced unless marked free. Full suite: SUITE_LINE |
||
|
|
77f90fd84f |
gateway: a plugin whose config hook says searches: true is sent the client's web_search as sent (#2027, yudaleng)
A plugin in front of Anthropic's or OpenAI's own API (a CPA or sub2api relay whose quota the plugin reads) had no way to say its upstream runs the hosted web search tool: searchesItself returned at once for any signed-in account, letting only Codex and Grok through, so Claude Code's WebSearch and Codex's web_search always went through magpie's own search. Now a plugin's config hook can set `searches: true` on its provider, as it sets `decide` (#1514). The host passes it through (plugin.Provider.Searches), pluginProvider sets the provider's Searches, and searchesItself honours it for a plugin's provider only, on Anthropic or Responses and only where the plugin has a model on that API, the same rule a custom provider's "Searches the web by itself" has (#359). Another sign-in's Searches is never read; Codex and Grok are unchanged. As with a relay, searchRank leaves it out, so magpie never picks it to search for other models; Settings can name it by hand. Documented in docs/subsystems/provider-plugins.md and the plugin guide (site/public/docs plugins.html, en/zh/ja). Verified: - TestPluginSaidToSearch (new, gateway, through the real fake plugin on bun and New().Handler()): with FAKE_SEARCHES the plugin's upstream gets web_search_20250305; without it, it gets no search tool; Chat doesn't search and searchRank is -1 either way. - Broken by hand, each red: search.go reverted, plugins.go reverted, host.js reverted (each "searches by itself on Anthropic: false"); with the searchesItself assertion disabled and search.go reverted, the wire check fails "said to search true, the plugin was sent []". - TestMovedGrokSearchesItself, TestGrokPluginSearchesItself, TestWebSearch* pass. - go test -tags nogui ./internal/plugin ./internal/provider ok, and ./internal/gateway (see the run noted on #2027) under a sandbox HOME with pinned caches; gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on the three packages clean. - Not tried with a real CPA/sub2api plugin. |
||
|
|
b0a904bd9a |
provider, catalog: a model listed with a 512-token window is told to agents at models.dev's window, or none, never 512 (H20 on Discord)
H20 and others saw free models (hy3, Cline's free ones) at a 512-token context window, and Claude Code and Codex then treated them as unusable: they compact at once. Every agent and the gateway read a model's window from its catalog entry (Entry.Context, from WindowOf and ListedWindow), which took any positive window the vendor's or plugin's list gave as said. Where the 512 itself comes from isn't seen here: models.dev's cache (2026-10-12), Cline's live /ai/cline/models and recommended feed, the WorkBuddy and Cline plugins' static lists and magpie's own code give no window under 4095 for any of these models. It is in a vendor's live list read at run time (WorkBuddy's /v3/config maxInputTokens or a plugin's list); so the floor is where every listed window is read: - catalog.LeastWindow (2048) and catalog.Window: a window under it is not known. The smallest real chat windows are about 4096 (gpt-3.5-turbo-instruct's 4095, mythomax's 4096) and stand. - mdModel.window: a models.dev limit under it doesn't vote, so the other limit, or nothing, answers. - ListedWindow: a vendor's window under it falls back to models.dev's for the model, else 0 (the agent's default). - pluginCatalog: a plugin's input or context under it is none, so a 512 prompt cap under a 192K window leaves 192K. - planModels (Cline): a free model's 512 takes models.dev's too. - A window the user sets (Contexts) is theirs, however small. Tests, with the literal 512: TestTinyListedWindowIsUnknown (a Cline plugin listing cline-free/mimo-v2.6-flash and cline-free/hy3 at 512 is served at models.dev's 1048576 and 192000; one nothing knows at 0; a real 4096 stands; ListedWindow on a built-in's hy3 at 512 gives 192000; a user-set 1024 stands) and four new cases in TestWindowClampsInputAboveContext. Both fail on the code before (512, want 1048576 / 192000 / 0) and pass with it. Not verified: the reporter's own list, so which vendor sent 512 is inferred, not seen; not tried in a real Claude Code or Codex. Run for both commits, on origin/main |
||
|
|
1075991f90 |
gateway: a plugin's fetch is told the folder the agent works in and whether it is a git repository, never seeing magpie's own (plugins #86, Hipple)
A plugin runs in magpie's plugin host, so its process.cwd() is magpie's folder. The ZCode plugin's Start Plan request said that folder (C:\Users\<user>\.config\magpie) as the agent's "Primary working directory", with "Is a git repository: no", and the model looked there. forwardOnce now calls tellWorkPlace on every request to a plugin's provider. It reads the request as sent to the plugin with workPlace (the same reading rules by folder use) and sets two headers on the plugin's fetch: - x-magpie-work-dir (provider.WorkDirHeader): the folder, percent-encoded (url.PathEscape; decodeURIComponent reads it); - x-magpie-work-git (provider.WorkGitHeader): yes/no. The agent's own word beside the folder (Claude Code's "Is a git repository: true/false", OpenCode's "Is directory a git repo: yes/no") wins. Otherwise it is a .git in the folder or above it, when the folder is on this computer (provider.GitSaid, provider.GitOnDisk in the new workplace.go). Each is left off when unknown; a folder that isn't on this computer and that the agent didn't call a repository has no git value, never "no". host.js's fetch (unsaid) takes both headers off every request a plugin sends, so a plugin that forwards the headers it was given sends them to no vendor. Documented in docs/subsystems/provider-plugins.md. Run: TestPluginToldWhereTheAgentWorks (new) sends the captured Claude Code and Codex requests, and Pi-style ones from a temp repo subfolder and a plain folder, through the fake plugin to fake-claude and fake-1. It checks what the plugin read and that the vendor got neither header. Broken by hand: without the tellWorkPlace call every case fails; without unsaid in host.js it fails with "the vendor got X-Magpie-Work-Dir". go test internal/gateway (-timeout 40m), internal/provider, internal/plugin; gofmt -l; go vet on darwin, GOOS=linux and GOOS=windows for the three packages. |
||
|
|
2df2e0886d |
plugin, provider, gateway: a plugin's model is listed with every kind it takes and gives (audio, video, pdf), not image alone (#1595, tkhs101)
The plugin host read a model's capabilities.input only for "image", and
fromModelsDev hard-coded output to text, so /v1/models listed
opencode-zen-free's muse-spark-1.3-contributor-free (models.opencode.ai:
input text/image/audio/video/pdf) as ["text","image"] with no output.
- host.js: fromModelsDev and the config merge keep modalities.input and
.output whole; the listing sends inputs/outputs, the kinds the
capabilities object marks true, in OpenCode's order.
- plugin.Model gets Inputs/Outputs; pluginCatalog puts them on
catalog.Model's new InputModalities/OutputModalities (input only where
the plugin said what it takes, as ImageInput already is).
- catalog: models.dev entries and a vendor's live list (now reading
modalities.output) fill the same fields; Decorate carries the catalog's
when the live list says nothing, beside ImageInput.
- provider.Entry.Modalities() is what the gateway lists: the source's
kinds, with "image" still decided by Images, so the user's own
"takes images" override still wins and the other kinds stay.
Not changed: the 7 models the report lists as having lost their levels
have reasoning_options [] upstream (models.opencode.ai), so "reasoning,
no levels" is what they are; mimo-v2.6-flash turns away levels (#214).
DSH's model kinds and Muse's list still say text/image only.
Tests: TestPluginModelModalities (gateway) with the reporter's literal
metadata: muse-spark's config as opencode-zen-free 0.1.3's configModels
writes it, and mimo-v2.6-flash-free's capabilities as its models hook
lists them; a model said nothing of stays unlisted, and the image
override drops image only. TestFetchedModalitiesKeepEveryKind (catalog).
Broken by hand: host.js without inputs gives the report's [text image]
(red); Entry.Modalities without the Inputs branch (red); Decorate
without the fill (red). Run: go test catalog, plugin, provider, gateway;
gofmt -l; GOOS=linux and windows go vet on the four; go test ./...
green on 76db4c6c2+this; after rebasing on
|
||
|
|
4b2f2ec31e |
provider, plugin: a plugin can serve System One for its provider, and the models it marks are a routing group's classifier (#1514, FourLeafTec)
A plugin had no way to say its provider answers TypeSafe's System One,
so a free decision model a plugin reaches (mu-zi-lee/magpie-our-free-model)
could only be listed as a chat model.
Now the plugin's config hook sets `decide: true` on the provider, and
`decides: true` on a model, in the config hook or on the models hook's
list. host.js passes both through (plugin.Provider.Decide,
plugin.Model.Decides). pluginProvider sets the provider's Decide to its
own base, plugin://<id>/v1, so System One is asked at {baseURL}/systemone
through the loader's fetch with the account's sign-in: pluginFetch sends
nowhere but the loader's host, so an address the plugin named itself
couldn't be reached. AskSystemOne now sends with Provider.Do, as the
gateway's classifier already did, so the editor's test goes through the
fetch too (Do is client.Do for every provider without an account).
decide.go treats a plugin provider's decision models as the ones it marks
plus Jev's by name (jev-*): kept from agents, refused for chat ("only
decides"), refused as a group member, offered as a group's classifier
(Deciders, DecisionModels, Jev). A mark without `decide` on the provider
changes nothing. Docs: site plugins page (en, zh, ja) and
docs/subsystems/provider-plugins.md.
Thanks to FourLeafTec, whose reference commit (bc0b3fee in their fork)
proposed the two fields and the plugin base; this is written afresh.
Run:
- internal/gateway TestPluginServesSystemOne and
TestPluginMarksWithoutDecide, through the real bun plugin host with the
fake plugin (FAKE_DECIDE). Red with host.js, plugins.go and decide.go
reverted ("Decide = \"\""), with only host.js reverted, and with only
decide.go reverted (no classifiers, offered to agents, chat to one 200).
- go test -tags nogui ./... (temp HOME): every package ok; internal/gateway
hit the 10m default at load ~140 in TestLargeRequestEndpoints, then
passed alone with -timeout 40m (548s).
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui on
internal/plugin, internal/provider, internal/gateway.
- Real use: a nogui build in a sandbox HOME on 127.0.0.1:3612, a local
plugin declaring decide with judge-x marked, a fake vendor on 3613.
`magpie group rule add ... classifier=dec1514/judge-x` saved; judge-x
was not in /v1/models and not accepted as a member; a turn to the group
asked /v1/systemone judge-x (levels, then intent) with the plugin's key
and its fetch's own header, then went to chat-b; chat to judge-x
answered 400 "only decides".
- No GUI change: a plugin's editor is the account editor, which has no
address fields.
Co-authored-by: FourLeafTec <5875432+FourLeafTec@users.noreply.github.com>
|
||
|
|
d7f3c20be3 |
grok: a Codex subagent's plain agent_message goes to Grok as the user's message, not refused with 422 "unknown item type" (plugins#61, opencode-grok-auth 0.1.11)
Grok's Responses backend refuses a request carrying Codex MultiAgentV2's
agent_message item (a subagent's task, or its reply kept in the lead's
history) with 422 unknown item type "agent_message". plugins#61 counted
512 such 422s on a moved Grok subscription from 10-03 to 10-09, and fixed
it in @magpie-community/opencode-grok-auth 0.1.11 (on npm).
What changed:
- the grok mover's min goes from 0.1.10 to 0.1.11, so keepMovedCurrent
updates moved users' plugin, and its comment says the fix.
- grokBody (the built-in's request shaper, which also runs for the Grok
plugin's provider, plugins.go) does what the plugin does: an
agent_message whose content is a non-empty list of input_text /
input_image parts goes as {"type":"message","role":"user"}, with
"From <author> to <recipient>\n\n" (or From / To alone, or nothing)
as its first part, in its place among the input. One with
encrypted_content on the item or a part, an empty or null content, or a
part of another kind is left byte for byte, so magpie reads no sealed
task and the gateway's sealed-task guard still sees it. A body with no
agent_message is returned as it came.
Tests:
- provider: TestGrokBodyAgentMessageGoesAsUser (the plugin's task, reply
with an image between a call and its output, sender alone / recipient
alone / none) and TestGrokBodyLeavesSealedAgentMessage (the plugin's
seven sealed or malformed items, and an ordinary history byte for byte).
- gateway: TestGrokGetsAgentMessageAsUser (built-in, streamed and not,
through the handler) and its parity TestGrokPluginGetsAgentMessageAsUser
(the Grok plugin's provider, streamed, relayed).
- With origin/main's grok.go back, TestGrokBodyAgentMessageGoesAsUser,
TestGrokGetsAgentMessageAsUser and TestGrokPluginGetsAgentMessageAsUser
FAIL ("the agent_message went as" the untouched item); with the change
they pass.
Run: gofmt -l (nothing); go vet, GOOS=linux and GOOS=windows go vet
-tags nogui on ./internal/provider ./internal/gateway (clean);
go test -tags nogui ./internal/provider ./internal/gateway under a temp
HOME with pinned caches (ok). Not tried against the real Grok backend:
no live Grok request was made.
|
||
|
|
844b9ca3ac |
provider, gateway, gui: a custom provider's Base URL can be a Gemini API (generateContent): …/v1beta, its models listed from it, the key sent in x-goog-api-key (#1346, NagaseMinato)
The custom provider editor's Base URL has a fifth API, "Gemini compatible"
(Gemini 兼容 / Gemini 互換 / Gemini-kompatibel), beside OpenAI, Anthropic and
Responses; More endpoints has a Gemini URL; the CLI takes gemini=. A
Gemini URL is kept as its base (…/v1beta, a relay's path prefix kept, a
pasted models/…:generateContent cut off). Every client's request, Chat,
Messages, Responses or Gemini, streamed or not, goes upstream to
models/{model}:streamGenerateContent?alt=sse under it, with no model in
the body and the key in x-goog-api-key; models are listed from its
/models, a page at a time, keeping those that serve generateContent.
Detect doesn't ask a Gemini API and is hidden while it is picked.
Factory's Gemini route and Bearer token are unchanged.
With five APIs the pick no longer fits a 900px editor in English and
German, so it wraps to a second row, and its thumb now follows the
picked option onto that row.
Verified against fake httptest upstreams only; no real Gemini key or
relay was tried:
- TestCustomGeminiUpstream (gateway): chat, chat stream, messages, a
Gemini client's stream and non-stream, behind /proxy/v1beta. Fails with
"chat: 404" without the gateway.go change.
- TestCustomGeminiProvider, TestGeminiBase, TestFactoryGeminiUnchanged
(provider).
- go vet, HOME=$(mktemp -d) go test -tags nogui ./... (44 packages ok),
GOOS=linux and GOOS=windows go vet on the touched packages.
- provider-gemini.test.cjs (new, en/zh/ja/de, Chromium + WebKit, 8 pass;
fails with "900px: the thumb is 22px off" without the slide() fix),
and in both engines: provider-base-api, provider-detect,
provider-detect-models, provider-add-models, provider-output-picks,
provider-search, provider-url-each-api, seg-contrast, settings-groups,
menu-scroll, click-scroll, ledger-hscroll, strip-scrollbar,
view-scrollbar, usage-ledger-chart, system-one, gui-ja, gui-de,
gui-zh-tw: all pass.
|
||
|
|
5f0490a4ad | provider, catalog: a prompt cap above a model's window is held to the window (#1286) — a catalog row with limit.input over limit.context (opencode/hy3-free's 192K over 190K, Cloudflare AI Gateway's gpt-5 at 272K over 128K, venice/openai-gpt-52) was served past its window, to the gateway's /v1/models and to every agent compacting at it. The input limit still wins wherever it sits under the window (gpt-5's 272K of its 400K, a real prompt cap; OpenCode's own client compacts at input too), and a row naming only one number keeps it. TestPluginCatalogClampsInputAboveWindow and TestWindowClampsInputAboveContext fail without the change. go vet, go build -tags nogui and go test -tags nogui ./internal/provider ./internal/catalog under a temp HOME pass. (#1288) | ||
|
|
4788cf2bbd | plugin, gui: a plugin's account whose model list failed says why, rather than listing Auto alone (gnayiab on X) — with magpie in WSL, Cursor's plugin account offered only Auto: the plugin's models hook couldn't get the account's list and magpie, with no list kept from before, showed the plugin's defaults with nothing saying so, its editor even calling them "vendor list", and Refresh answered "1 models". The host now keeps why a models hook fell back (what it threw, else how its last fetch failed) for the provider and each account; plugin.Cached carries it with the accounts it reads again from the sign-ins; provider.ListError gives it for a plugin's account. The editor says "<provider> couldn't list its models: <why>" under the models (amber, no left border) and no longer calls the defaults the vendor's list, and Refresh fails with it. A list kept from before, or one that comes in, says nothing. en/zh/ja/de. Tried with the real Cursor plugin (0.1.9) in a sandbox: a key Cursor refuses shows "Cursor couldn't list its models: Cursor didn't take this API key" and Refresh says it; the owner's real account lists 72 models with nothing said, and Claude Code -p through the gateway ran a Bash tool on cursor/auto, composer-2.5 and claude-opus-5-thinking. The plugin itself, in WSL (magpie-desktop), listed 254 models and streamed chats with tools. TestFallenBackListSaysWhy (hook returns its defaults, throws, or hands back its own) fails without the change; plugin-list-error.test.cjs (Chromium and WebKit, en and zh) too; TestFallenBackListKeepsTheLastOne, account-models, plugin-signin and click-scroll pass. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. | ||
|
|
322842c1c0 | provider: ClinePass signed in through the Cline plugin shows the reasoning levels its API key does (zRain, Discord) — the plugin gives no levels of its own, and only a moved built-in borrowed its models' makers', so every plugin-served Cline model had none while the ClinePass built-in borrowed them. Cline's plugin now borrows as the built-in does. TestClinePluginBorrowsEfforts fails without the change. go vet, go build -tags nogui (darwin, GOOS=linux, GOOS=windows), go test -tags nogui ./... under a temp HOME pass. | ||
|
|
a717902822 | provider: a plugin's provider beside a provider of the user's own with its id is id-plugin, listed rather than hidden (lishouxian, #867) — a custom zenmux saved before @zenmux/pi-zenmux-oauth was installed took the id, so the plugin's ZenMux, once signed in (168 models), was skipped by allProviders and the sign-in ended in "signed in, but magpie can't list it"; and magpie provider rm zenmux hid the plugin's account rather than removing the custom entry. PluginID now gives id-plugin when a provider with an endpoint in providers.json has the id (customIDs, held per request like the rest), as it does for a built-in's or a preset's: the user's own keeps its id, models and agent/route references, the plugin's lists as zenmux-plugin, and rm zenmux removes the user's own. TestPluginIDBesideCustomProvider (fake plugin under bun) fails on the old code (PluginID(fakeco) = fakeco). go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. | ||
|
|
0d78acd62a | gateway: WorkBuddy's plans draw with the image models their config lists (freecss on Discord: let WorkBuddy's subscription image models be magpie's image models) — Settings › Models › image model, the Magpie Image MCP and /v1/images/* now offer a WorkBuddy plan's image models, for the China build (workbuddy) and WorkBuddy AI (workbuddy-ai), built-in or moved onto @magpie-community/opencode-workbuddy-auth. Which models are taken from GET <site>/v3/config, signed as a chat is, by their tags (text-to-image, image-to-image), with no ids written in: today the China desktop sign-in lists hunyuan-image-v3.0-art, WorkBuddy AI gpt-image-2.5-sunburst (which edits too). The list is kept an hour per account (5 min after a failed ask); Drawers answers at once and asks in the background. A drawing goes as WorkBuddy's CLI sends it, to <site>/v2/images/generations or /v2/images/edits in JSON: GPT Image with quality, background, output_format and b64_json; Hunyuan with model, prompt, n and size only; an edit's images as data URLs, to the model itself when it takes images or to its -edit beside it, else a 400 that says the model draws from a prompt only. WorkBuddy's {code, msg, data} is unwrapped (a non-zero code is a 502 with its msg); Hunyuan's COS URL is passed on as the other URL drawers' are. These models are never AutoDrawer's pick, since each image costs the plan's credits. For a moved plan the plugin's fetch signs and sends it: pluginFetch now also takes an absolute URL, only to the plugin base's own host, and Provider.Origin gives a provider's site. TestWorkBuddyDrawsWithItsConfigsModels, TestWorkBuddyAIDrawsGPTImage and TestWorkBuddyPluginDraws (fake upstream: config, generation, edit, envelope error, plugin path, foreign host refused) fail on the old code. Against the owner's real accounts (moved onto the plugin) in a sandbox gateway under a temp HOME: workbuddy/hunyuan-image-v3.0-art drew a 1024x1024 PNG (URL), workbuddy-ai/gpt-image-2.5-sunburst one in b64, an edit of it with gpt-image-2.5-sunburst turned the bird red, and an edit asked of hunyuan-image-v3.0-art got the 400 without a call; no token rotated. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. The GUI's model picker wasn't looked at (nogui sandbox). | ||
|
|
dff14ff465 | gui: the panel's reads build the catalog once per request (owner: 这个应该是 magpie API 慢, on a Discord report that the window renders slowly) — provider.Resolve rebuilt every provider's catalog (24 providers, 270 models: 35-90ms) for each model it was asked about, and /api/state and /api/groups resolve one for every agent and row; plugin.Cached re-read the plugins' files for each PluginOf, and resolveIn's fallbacks read All() and every provider's Available() again. A GET under /api/ now holds what it builds (provider.Hold: the entries, the plugins, All, which providers list a model) for the request, at most 1s while requests overlap; a save drops it (catalog.Touched → catalog.Forget, plugin.OnChange, setMigration, and any non-GET request). Outside a request nothing is held, so the gateway and tests behave as before. On the owner's config: state 4.2s → 0.42s, groups 6.7s → 0.26s, providers 1.4s → 0.33s. Sandbox (fixed build, GETs looping): a model saved through /api/provider/save is in providers, groups and state at once and gone after the restore. TestHoldBuildsOnce, TestHoldSeesWrites (fails with Forget unset). go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. | ||
|
|
33acb6bca0 |
providers: each model's credit rate shows by it in the provider's model list and an agent's model picker, Qoder's 0.5× and WorkBuddy's 0.03×, a discount's price before it struck through (01huadalang on Discord: qcoder 或者 workbuddy 能不能实时抓取或者按一段时间抓取能展示列表模型的积分消耗倍率,这样不用打开软件查看,能选择到便宜的模型) — magpie read each model's price only to tell free from not: Qoder's price_factor (06584e15) and WorkBuddy's "credits" ("x0.03", wbFreeCredits), so the lists said FREE or nothing, and picking a cheap model meant opening Qoder or WorkBuddy. catalog.Model now keeps the price, Rate (the credits a request costs, as a multiple; 0 is not listed, or Free) and RateWas (the price before a discount running now), and carries both through provider.Entry, agent.Option and the providers page's models. Qoder (and Qoder CN): Rate is the price_factor; RateWas an active promotion's before_promotion_price_factor, else an original_price_factor above the price (Qwen3.8-Flash: free, 0.1× struck through), and a promotion's 0 that isn't free is its price before times its discount_factor. WorkBuddy and WorkBuddy AI (the CodeBuddy plan; both builds read the same /v3/config): Rate is the credits (wbCredits; x0.00 stays FREE, an unreadable or infinite rate is none). A plugin's model gives it as it gives free: rate and rateWas on the model its provider.models hook lists, a number (0.5) or as the vendor writes it ("x0.03", "0.5×"), which host.js reads (rateOf) into plugin.Model.Rate/RateWas and pluginCatalog keeps; the moved Qoder and WorkBuddy users get it once their plugins send it. The badge is small and grey (the context badge's colours, no uppercase), beside FREE where that shows, its title saying what a request costs (每次请求消耗 0.5× 积分;折扣前 / 限时免费,原价). Rates are as of the provider's last list: a built-in's is fetched at start-up when it has none, on Refresh and when its key changes, a plugin's when its plugins are asked again (start-up, a sign-in, a plugin change); nothing asks on a timer. Kiro, Cursor, ZCode and Devin list no per-model rate magpie reads, so they show none. TestParseModelsRate (qoder) and TestWBCreditsRate (provider) are new and don't build without the change; TestFakePlugin now checks a plugin's rate given as a number and as "x0.03" (0 for both with host.js not reading them). model-rate.test.cjs (WebKit, en and zh: the chips' badges and titles, struck-through prices, grey not green, no stripe, a click picks and scrolls nothing, the picker's badges) fails without the change and passes with it; click-scroll, models-free-only, model-pick and favorite-star pass in WebKit. No request was made to Qoder, WorkBuddy or any vendor. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME, go test ./internal/gui pass.
|
||
|
|
723b0f34f5 | zcode: a Start Plan request goes over HTTP/1.1, as ZCode, its OpenCode plugin and zcode2api-plus speak to zcode.z.ai (ARNO on Discord, v0.1.639: magpie's built-in ZCode answered 405 / code 3012, "network firewall blocked", while his ZCode plugin run in magpie's plugin host got through on the same machine, account and moment) — the two requests, captured side by side against a local TLS server, carry the same path, headers, auth and body (the prompts' hashes match the plugin's); what differs is the connection: the gateway's client speaks HTTP/2 wherever it is offered, and zcode.z.ai offers it, while the plugin (Bun's fetch), ZCode itself (Node's fetch) and zcode2api-plus (Go, HTTP/2 turned off) all speak HTTP/1.1, which changes the TLS hello's ALPN too, a field Alibaba Cloud's firewall fingerprint can take in. A Start Plan request (to zcodeStartBase) now goes through zcodeStartClient, HTTP/1.1 only and otherwise as the gateway's transport (netproxy's proxy, the same wait for the head); Account.clientFor lets an account pick the client for a request, Provider.Do honouring it; a Coding Plan account still goes through the gateway's client. TestZCodeStartHTTP1 (a TLS server offering HTTP/2, an HTTP/2 client given: the Start Plan request arrived as HTTP/2.0 without the change; now HTTP/1.1, the Coding Plan request still HTTP/2.0). No request was made to z.ai; whether this alone lets the Start Plan through is for ARNO's account to say. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. | ||
|
|
c2947dd6e7 |
zed: an OpenAI model's request reaches Zed's cloud in the Responses types it reads, so Codex on a Zed GPT model is answered (nico on Discord: "failed to parse OpenAI Responses API request: unknown variant developer, expected one of user, assistant, system, tool", and with it no model switch mid-thread and no auto-review) — Zed's cloud parses the request into its own types (zed-industries/zed crates/open_ai/src/responses.rs: Role user/assistant/system/tool, items message/function_call/function_call_output/custom_tool_call(_output)/reasoning/compaction/compaction_trigger, tools function/custom, include reasoning.encrypted_content only) and refuses the whole request over anything else. The Zed plugin (@magpie-community/opencode-zed-auth) gets Codex's Responses request relayed as Codex sent it, developer messages and all — its permissions message on every request, the one a model switch adds, the auto-review's — so every Codex turn on a Zed OpenAI model failed. The plugin's account now fits the body as grokBody does Grok's (ZedBody): a developer message goes as a system one where it stands (Zed's own client sends system messages too), the shorthand {role, content} gets its type and a string content becomes a list, reasoning's null content goes, an agent_message is the user's turn, an item Zed has no type for (a web_search_call an OpenAI model ran) is left out, namespaced tools go flat and their calls come back under the namespace (as Grok's), other tool types go, include keeps reasoning.encrypted_content alone, a function tool_choice is required, and a reasoning summary Zed doesn't know goes. The built-in Zed account already folded developer messages in; its OpenAI request goes through the same fitting, so a web search offered with no search API no longer leaves a web_search tool and web_search_call.action.sources in it. Codex's prompts and instructions are unchanged. TestZedPluginGetsNoDeveloperRole (a Codex-shaped request through the fake plugin to a fake upstream that parses as Zed's cloud: fails with the exact 400 without the change) and TestZedBuiltInResponsesParse fail without it. No request was made to Zed. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass.
|
||
|
|
a999770531 | plugins: a plugin's subscription does what a built-in's does, in seven places it didn't (the user: 要保证插件订阅 provider 跟内置的订阅 provider所有逻辑都要一模一样) — an installed plugin's provider id is kept for it signed in or not, as a built-in's is: a provider of the user's own isn't saved on it, renamed onto it or imported as it (freeID gives id-2). A plugin's account whose plan lacks the model is tried after the ones that list it, as a Codex Free account behind a Plus, by the list the plugin told for it. Cursor's plugin has fast mode where the built-in Cursor has it: a model with a -fast one is saved :fast in a group and sent service_tier "priority", one without is refused. Removing a plugin's provider hides it as a built-in's is, its accounts kept and shown again from Hidden or by signing in, rather than signing every account out ("stays signed in" said so already). magpie accounts lists, adds, switches and forgets a plugin's accounts by its provider's id or name. Grok's plugin beside the built-in Grok (grok-plugin) searches by itself as Grok does. A plugin's plan is named as its built-in's ("Cursor Pro", "SuperGrok"), and a plugin's resets are shown but have no Use button or Auto-use, which spent Codex's reset of the same user. TestPluginIDReservedSignedOut, TestPluginAccountLackingTheModelGoesLast, TestCursorPluginGroupFast, TestAccountsOfAPlugin, TestGrokPluginSearchesItself, plugin-plan and codex-auto-reset fail without the change; TestPluginSignIn and TestPluginAccounts now expect a removed plugin hidden. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestClaudeSignedOut failed once under load, passes alone); the gateway, provider and plugin suites and TestAccountsOfAPlugin pass on Windows, the plugin tests on Linux. |