Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
plugin: a changed plugin option lists the providers again (plugins#430)
yetone9bfe680481a8
diff --git a/docs/subsystems/provider-plugins.md b/docs/subsystems/provider-plugins.mdindex 98ffd1163..c88dd199c 100644--- a/docs/subsystems/provider-plugins.md+++ b/docs/subsystems/provider-plugins.md@@ -66,7 +66,7 @@ Qoder plugins without `auth.checkin` still use [`qoder_checkin.go`](../../internA plugin can declare switches for its provider (#2038): its `auth` hook gains `options: [{key, label, description?, default?, confirm?}]`. The host ([`host.js`](../../internal/plugin/host.js) `optionsOf`) keeps an option whose `key` matches `[a-z0-9_-]{1,40}` and whose `label` isn't empty, drops a key seen before, caps the label at 60 characters and the description and `confirm` at 300, takes `default` only when it is `true`, and keeps the first 16. The provider is listed with them (`plugin.Provider.Options`).-The user's values are kept in `settings.PluginOptions` by the plugin's own provider id and the option's key, and set with `POST /api/settings/plugin-option {provider, key, on}`, which checks the key the same way. The host is handed them at `init` (`options`) and again after each change (`setProviderOptions`, `plugin.SetProviderOptions`, sent only to a host already running). A plugin reads them through `input.magpie.option(provider, key)` (the user's value, else the default; false for a key it didn't declare) or `input.magpie.options(provider)` (every declared key). Both read the current values each time, so a change reaches the plugin without a restart. A plugin written for older hosts checks `input.magpie?.option` first. Nothing runs when an option changes: magpie only keeps and hands over the value. The check-in switch is separate and unchanged.+The user's values are kept in `settings.PluginOptions` by the plugin's own provider id and the option's key, and set with `POST /api/settings/plugin-option {provider, key, on}`, which checks the key the same way. The host is handed them at `init` (`options`) and again after each change (`setProviderOptions`, `plugin.SetProviderOptions`, sent only to a host already running). A plugin reads them through `input.magpie.option(provider, key)` (the user's value, else the default; false for a key it didn't declare) or `input.magpie.options(provider)` (every declared key). Both read the current values each time, so a change reaches the plugin without a restart. A plugin written for older hosts checks `input.magpie?.option` first. When an option changes magpie keeps and hands over the value, and forgets the providers it keeps, so they are listed again: a models hook may list by an option (WorkBuddy's "Free models only", plugins#430). Nothing else runs. The check-in switch is separate and unchanged.The provider's editor lists them under *Plugin options* (`pluginOptionsField` in [`app.js`](../../internal/gui/assets/app.js), the values from `/api/providers`' `plugins[].options[].on`), an Off/On each beside the plugin's label and description, put in as text. One with `confirm` asks it before it is turned on. Changes wait for Save, which posts each changed one before the provider.@@ -214,7 +214,7 @@ Gateway parity tests in [`plugin_parity_test.go`](../../internal/gateway/plugin_[`plugin_checkin_test.go`](../../internal/provider/plugin_checkin_test.go) runs the fake plugin's `auth.checkin` (`FAKE_CHECKIN`) through the schedule: off, each outcome, no second press the same day, failures only after the retry window, the next day, cards and Settings, and the vendor check-in stepping aside; `TestPluginCheckinTellsSignInsOfOneNameApart` signs in four accounts under two names, two of each (plugins#254), and checks each is checked in, kept, carded and switched off on its own, and `TestPluginCheckinCarriesOverDisplayNameEntries` upgrades a file and an `Off` kept by display name. `TestPluginCheckinQoderRechecksCampaigns` holds the Qoder plugins' recheck, by the loop and a press, after `inactive` and `done`, `TestPluginCheckinOthersSettledForTheDay` every other plugin's day from noon Beijing, and `TestPluginCheckinEarlyDoneAskedAgain` the reporter's 00:00:28 done asked again by the loop and a press (#3326); `checkin-early-done.test.cjs` covers that card; `qoder-checkin-recheck.test.cjs` covers the card's press. `plugin-checkin.test.cjs` covers the card row and the Settings tab.-[`plugin_options_test.go`](../../internal/plugin/plugin_options_test.go) loads `testdata/options` in a real host: which declared options are kept and how they are capped, the user's value over the default at start, and a change read by the plugin after `SetProviderOptions` without a restart. [`plugin_option_api_test.go`](../../internal/gui/plugin_option_api_test.go) covers the endpoint, a bad key, and a Settings save keeping the values. `plugin-options.test.cjs` covers the editor in Chromium and WebKit, 1100 and 420 wide, in every language.+[`plugin_options_test.go`](../../internal/plugin/plugin_options_test.go) loads `testdata/options` in a real host: which declared options are kept and how they are capped, the user's value over the default at start, a change read by the plugin after `SetProviderOptions` without a restart, and a models hook's list that goes by an option following it after the change. [`plugin_option_api_test.go`](../../internal/gui/plugin_option_api_test.go) covers the endpoint, a bad key, and a Settings save keeping the values. `plugin-options.test.cjs` covers the editor in Chromium and WebKit, 1100 and 420 wide, in every language.[`plugin_cliproxy_test.go`](../../internal/plugin/plugin_cliproxy_test.go)'s `TestPluginHostTakesANewProxy` starts a real host without a proxy, sets one, and checks that a program the plugin starts gets it. [`plugin_lan_test.go`](../../internal/plugin/plugin_lan_test.go)'s `TestPluginLeavesTheUserNetworkDirect` checks with a real host that fetches (http:// and https://) and an HTTP/2 session to this computer's private address reach it directly with a proxy set, and that a public address and an unresolvable name still go through the proxy. `plugin-signed-out-account.test.cjs` covers a moved Grok account signed out while in use and as the agent's own, in Chromium and WebKit, en and zh, 420 and 1100 wide.diff --git a/internal/plugin/host.js b/internal/plugin/host.jsindex 828e8d6f9..5cf110a71 100644--- a/internal/plugin/host.js+++ b/internal/plugin/host.js@@ -1834,8 +1834,8 @@ const shown = (v, n) => (typeof v === "string" ? v.trim().slice(0, n) : "")// own field (#2038, Vocllum): auth.options, each {key, label, description?,// default?, confirm?}. magpie shows each as an Off/On switch in the// provider's editor and keeps what the user sets; the plugin reads it with-// input.magpie.option(provider, key). A switch is only kept and handed-// over, nothing is run when it changes. Keys are [a-z0-9_-], 1–40 long,+// input.magpie.option(provider, key). A switch is kept and handed over,+// and the models listed again (one may go by it); nothing else is run. Keys are [a-z0-9_-], 1–40 long,// the first of a key kept; at most MAX_OPTIONS; one without a key or a// label is left out.const MAX_OPTIONS = 16diff --git a/internal/plugin/plugin_options_test.go b/internal/plugin/plugin_options_test.goindex d1f6c30d9..18f2990d7 100644--- a/internal/plugin/plugin_options_test.go+++ b/internal/plugin/plugin_options_test.go@@ -87,6 +87,39 @@ func TestPluginOptions(t *testing.T) {if !OptionOn(s.PluginOptions, "optco", opts[0]) || !OptionOn(s.PluginOptions, "optco", opts[1]) || OptionOn(s.PluginOptions, "optco", opts[2]) {t.Error("OptionOn doesn't take the user's value, else the default")}+ // a models hook may list by a switch (WorkBuddy's "Free models only",+ // plugins#430): the providers kept are asked again after a change, so+ // the list follows the switch without a restart+ models := func() []string {+ t.Helper()+ Cached()+ Refreshed()+ for _, p := range Cached() {+ if p.ID == "optco" {+ var ids []string+ for _, m := range p.Models {+ ids = append(ids, m.ID)+ }+ return ids+ }+ }+ t.Fatal("optco isn't listed")+ return nil+ }+ if got := strings.Join(models(), " "); !strings.Contains(got, "beta-model") {+ t.Errorf("with beta on, optco lists %q, want beta-model", got)+ }+ s = settings.Load()+ s.PluginOptions = map[string]map[string]bool{"optco": {"beta": false}}+ if err := settings.Save(s); err != nil {+ t.Fatal(err)+ }+ if err := SetProviderOptions(ctx); err != nil {+ t.Fatal(err)+ }+ if got := strings.Join(models(), " "); strings.Contains(got, "beta-model") || !strings.Contains(got, "base-model") {+ t.Errorf("with beta off, optco lists %q, want base-model alone", got)+ }}func jsonOf(v any) string {diff --git a/internal/plugin/providers.go b/internal/plugin/providers.goindex a48e3758e..8b5c9a768 100644--- a/internal/plugin/providers.go+++ b/internal/plugin/providers.go@@ -165,8 +165,8 @@ type Provider struct {// Option is a switch a plugin declares for its provider (auth.options,// #2038): magpie shows it, keeps the user's value in settings'-// PluginOptions and hands it to the plugin (input.magpie.option). Nothing-// runs when it changes.+// PluginOptions and hands it to the plugin (input.magpie.option). A change+// has the providers listed again (SetProviderOptions); nothing else runs.type Option struct {Key string `json:"key"`Label string `json:"label"`@@ -187,12 +187,18 @@ func OptionOn(chosen map[string]map[string]bool, provider string, o Option) bool}// SetProviderOptions hands the user's option values (settings' PluginOptions) to-// the host running now; a host started later reads them at its start.+// the host running now; a host started later reads them at its start. The+// providers kept are asked again after: a models hook may list by an+// option (WorkBuddy's "Free models only", plugins#430), and the list+// follows the switch without a restart.func SetProviderOptions(ctx context.Context) error {if !Running() {+ forgetProviders()return nil}- return Call(ctx, "setProviderOptions", map[string]any{"options": settings.Load().PluginOptions}, nil)+ err := Call(ctx, "setProviderOptions", map[string]any{"options": settings.Load().PluginOptions}, nil)+ forgetProviders()+ return err}// Account is one account a provider is signed in to: Key is wherediff --git a/internal/plugin/testdata/options/index.js b/internal/plugin/testdata/options/index.jsindex ef37dd35e..8f6000506 100644--- a/internal/plugin/testdata/options/index.js+++ b/internal/plugin/testdata/options/index.js@@ -2,6 +2,20 @@// field, #2038) and reading them as they stand: its key prompt's check// answers with what input.magpie.options says, read when it is asked.export const Optco = async (input) => ({+ // its list goes by a switch, as WorkBuddy's "Free models only" does+ // (plugins#430): beta-model is listed only while beta is on+ config: async (cfg) => {+ cfg.provider ??= {}+ cfg.provider.optco ??= { name: "Optco", npm: "@ai-sdk/openai-compatible", api: "http://127.0.0.1:9/v1", models: { "base-model": { name: "Base" } } }+ },+ provider: {+ id: "optco",+ async models(provider) {+ const out = { ...provider.models }+ if (input.magpie?.option("optco", "beta")) out["beta-model"] = { ...out["base-model"], id: "beta-model", name: "Beta" }+ return out+ },+ },auth: {provider: "optco",options: [diff --git a/internal/provider/migrate_workbuddy.go b/internal/provider/migrate_workbuddy.goindex d5d0205d8..d254aab61 100644--- a/internal/provider/migrate_workbuddy.go+++ b/internal/provider/migrate_workbuddy.go@@ -16,7 +16,7 @@ func init() {for _, w := range []*wbSite{wbCN, wbAI} {movers[w.id] = &mover{pkg: "@magpie-community/opencode-workbuddy-auth",- min: "0.1.37", // 0.1.37: sign in with a WorkBuddy API key from the profile/keys page, sent as WorkBuddy's own client sends it (plugins #407); 0.1.35: used credits say when the plan's cycle starts again, as WorkBuddy's client does, so the card no longer reads "Not used yet" beside them (windy on Discord); 0.1.34: a free account's plan reads "Free plan" (plugins #337); 0.1.33: an untyped object oneOf goes to Kimi as type "object" (plugins #378); 0.1.32: plugins #346; 0.1.31: a 401 is renewed once, whatever the token's time, and sent once more; when the retry is refused too, the 401 says to sign in again (Providers → WorkBuddy → this account), and the account is marked expired only on WorkBuddy's word that the sign-in is gone (refresh token refused, or invalid_token with nothing to renew with) (wenchen855443 on X); 0.1.30: a refused line the model quotes back into an assistant message is reworded there too, so a long DeepSeek Harness chat isn't refused for good (plugins #291); 0.1.29: a system prompt WorkBuddy refuses as an unapproved channel (11128) is sent once more as the first user message's instructions, with WorkBuddy's default system prompt, since WorkBuddy checks only system and assistant messages; the refusal still rests no account (Wing on Discord); 0.1.28: a refusal of words not reworded yet ends in a hint that names no one client (plugins #279); 0.1.27: DeepSeek Harness's opening identity line is reworded to a neutral one, which WorkBuddy otherwise refuses as an unapproved channel (11128) (plugins #279, #280); 0.1.26: a model that says only supportsReasoning and a default effort lists low, high, max and that default, not "doesn't reason" (plugins #255); 0.1.25: WorkBuddy AI's fast, balanced and primary models keep the credit rate its config gives as "x0.34 credits", not unknown (plugins #216); 0.1.24: a refused sign-in on a chat over 2 MiB says the 401 and to sign in again: WorkBuddy's front door resets such a request instead of answering, so it read as 502 ECONNRESET (wyp on Discord); 0.1.23: credits used up leave the free models counted out of the credits window, so an account is not ranked spent for them (plugins #138); 0.1.22: an MCP server's tool schemas reach Kimi and DeepSeek: an enum with no type, or of several types, is typed, and true or false where a schema goes is {} or {"not": {}}, so they aren't 400 11133 "Invalid request parameters" (plugins #122); 0.1.21: a model free only at night (Hy4 preview) is never said free, and a whole-day discount shows the price before it, from WorkBuddy's modelPromotions (plugins #121); 0.1.20: tool results followed by the user's message reach WorkBuddy AI's gemini-3.8-flash, not 400 "the conversation must end with a user message" (plugins #113); 0.1.19: an enterprise account's card shows its credits, from the enterprise meter WorkBuddy's usage page reads (#1904); 0.1.18: WorkBuddy 5.6+ keeps its desktop sign-in encrypted, and the plugin says so and points to the browser sign-in instead of a 502 (plugins #18); 0.1.17: a restricted account's 403 11140 ends in provider.WBRestrictedHint, so it rests 2h as restricted (#1849); 0.1.16: WorkBuddy AI's GLM models are text-only, so magpie's image-describing model reads their images (Yirasumi on Discord); 0.1.15: a system prompt sent as a developer message passes the channel check, an object tool_choice is sent as WorkBuddy takes it, and max_completion_tokens goes as max_tokens so the cap holds (plugins #96); 0.1.14: the Credits window says when the soonest credits left run out, for Smart routing to spend them first (cdredfox on X); an enterprise account names its enterprise, so it lists and uses the enterprise's models, not the personal plan's (plugins #75); a chat's tools get shapes WorkBuddy AI's models take, so ZCode's and DeepSeek Harness's chats on deepseek-v4.1-flash aren't 400 "Invalid request parameters" (wyh on Discord); one user send is one request in the usage list: every step carries one X-Conversation-Request-ID, and both builds name the client (使用端) (plugins #48); credits used up (code 14018) say so, with the nested error message (plugins #25); Codex's and Claude Code's chats pass WorkBuddy's channel check (#182); a failure's status and its sign-in mark as the built-in's; each model's credit rate; the sign-in renewed ahead of time through auth.refresh; the credits' count beside their share (#659)+ min: "0.1.38", // 0.1.38: a "Free models only" switch lists only the free models and refuses any other before it is sent, so no credits are spent (plugins #430); 0.1.37: sign in with a WorkBuddy API key from the profile/keys page, sent as WorkBuddy's own client sends it (plugins #407); 0.1.35: used credits say when the plan's cycle starts again, as WorkBuddy's client does, so the card no longer reads "Not used yet" beside them (windy on Discord); 0.1.34: a free account's plan reads "Free plan" (plugins #337); 0.1.33: an untyped object oneOf goes to Kimi as type "object" (plugins #378); 0.1.32: plugins #346; 0.1.31: a 401 is renewed once, whatever the token's time, and sent once more; when the retry is refused too, the 401 says to sign in again (Providers → WorkBuddy → this account), and the account is marked expired only on WorkBuddy's word that the sign-in is gone (refresh token refused, or invalid_token with nothing to renew with) (wenchen855443 on X); 0.1.30: a refused line the model quotes back into an assistant message is reworded there too, so a long DeepSeek Harness chat isn't refused for good (plugins #291); 0.1.29: a system prompt WorkBuddy refuses as an unapproved channel (11128) is sent once more as the first user message's instructions, with WorkBuddy's default system prompt, since WorkBuddy checks only system and assistant messages; the refusal still rests no account (Wing on Discord); 0.1.28: a refusal of words not reworded yet ends in a hint that names no one client (plugins #279); 0.1.27: DeepSeek Harness's opening identity line is reworded to a neutral one, which WorkBuddy otherwise refuses as an unapproved channel (11128) (plugins #279, #280); 0.1.26: a model that says only supportsReasoning and a default effort lists low, high, max and that default, not "doesn't reason" (plugins #255); 0.1.25: WorkBuddy AI's fast, balanced and primary models keep the credit rate its config gives as "x0.34 credits", not unknown (plugins #216); 0.1.24: a refused sign-in on a chat over 2 MiB says the 401 and to sign in again: WorkBuddy's front door resets such a request instead of answering, so it read as 502 ECONNRESET (wyp on Discord); 0.1.23: credits used up leave the free models counted out of the credits window, so an account is not ranked spent for them (plugins #138); 0.1.22: an MCP server's tool schemas reach Kimi and DeepSeek: an enum with no type, or of several types, is typed, and true or false where a schema goes is {} or {"not": {}}, so they aren't 400 11133 "Invalid request parameters" (plugins #122); 0.1.21: a model free only at night (Hy4 preview) is never said free, and a whole-day discount shows the price before it, from WorkBuddy's modelPromotions (plugins #121); 0.1.20: tool results followed by the user's message reach WorkBuddy AI's gemini-3.8-flash, not 400 "the conversation must end with a user message" (plugins #113); 0.1.19: an enterprise account's card shows its credits, from the enterprise meter WorkBuddy's usage page reads (#1904); 0.1.18: WorkBuddy 5.6+ keeps its desktop sign-in encrypted, and the plugin says so and points to the browser sign-in instead of a 502 (plugins #18); 0.1.17: a restricted account's 403 11140 ends in provider.WBRestrictedHint, so it rests 2h as restricted (#1849); 0.1.16: WorkBuddy AI's GLM models are text-only, so magpie's image-describing model reads their images (Yirasumi on Discord); 0.1.15: a system prompt sent as a developer message passes the channel check, an object tool_choice is sent as WorkBuddy takes it, and max_completion_tokens goes as max_tokens so the cap holds (plugins #96); 0.1.14: the Credits window says when the soonest credits left run out, for Smart routing to spend them first (cdredfox on X); an enterprise account names its enterprise, so it lists and uses the enterprise's models, not the personal plan's (plugins #75); a chat's tools get shapes WorkBuddy AI's models take, so ZCode's and DeepSeek Harness's chats on deepseek-v4.1-flash aren't 400 "Invalid request parameters" (wyh on Discord); one user send is one request in the usage list: every step carries one X-Conversation-Request-ID, and both builds name the client (使用端) (plugins #48); credits used up (code 14018) say so, with the nested error message (plugins #25); Codex's and Claude Code's chats pass WorkBuddy's channel check (#182); a failure's status and its sign-in mark as the built-in's; each model's credit rate; the sign-in renewed ahead of time through auth.refresh; the credits' count beside their share (#659)agents: []string{w.id},out: func() ([]Moving, error) {var out []Moving