WorkBuddy's plugin 0.1.38 adds a "Free models only" switch (a plugin option) that lists only WorkBuddy's free models and refuses any other before it is sent. Its list goes by the switch, but SetProviderOptions only handed the values over: the host cleared its infos while Go kept provCache, so the Providers page and /v1/models showed the old list until something else re-read it. SetProviderOptions now forgets the kept providers (whether the host runs or not), so the next Cached() lists them again. Nothing else runs on a change. The workbuddy mover's min is 0.1.38 (npm view --prefer-online at landing: 0.1.38). Run: - go test ./internal/plugin ./internal/provider -count=1 -timeout 45m at this head (5a3292354+ this): internal/plugin ok (389s); internal/provider FAIL on TestUnreadLoginsWriteErrorsKeepCredentials, "close of synctest channel from outside bubble" in filememo.Forget, which is #3632 (open, on main since091153bf, nothing here touches it). TestPluginOptions now lists a model only while its option is on, and only base-model after it is off. - Rebased onto3aead9c62after the run; its new commits touch only internal/provider/codex_daemon*.go and codex_app_server_test.go. go vet ./internal/plugin ./internal/provider ok there; a rebuild to test again failed to link for a full disk (291MB free). - gofmt -l clean; GOOS=linux and GOOS=windows go vet ./internal/plugin ./internal/provider ok. - Real accounts, sandbox HOME, dev build of this tree on 3516/3517 with the plugin added by path: POST /api/settings/plugin-option free_only on for workbuddy-ai took its list from 26 to 2 (hy3, deepseek-v4.1-flash) within 2s with no restart; workbuddy kept 19. gpt-5.4 got the plugin's 404 and was not sent; hy3 and deepseek-v4.1-flash answered. Off: 26 again, and gpt-6-luna and gpt-5.4 answered. Broken by hand: without forgetProviders in SetProviderOptions, TestPluginOptions fails ("with beta on, optco lists "base-model""). Not tried: the switch clicked in the GUI window (the API it calls was); Windows and Linux apps.
42 lines
1.9 KiB
JavaScript
42 lines
1.9 KiB
JavaScript
// A plugin declaring switches for its provider (auth.options, magpie's own
|
|
// 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: [
|
|
{ key: "auto-claim", label: " Claim rewards ", description: "Claims the daily reward when usage is read.", default: true },
|
|
{ key: "beta", label: "Beta models", confirm: "Beta models may be withdrawn." },
|
|
{ key: "beta", label: "the same key again" }, // dropped
|
|
{ key: "Bad Key", label: "not a key" }, // dropped
|
|
{ key: "nolabel" }, // dropped
|
|
{ key: "long", label: "L".repeat(200), description: "D".repeat(1000), default: "yes" }, // default is no boolean: off
|
|
...Array.from({ length: 20 }, (_, i) => ({ key: "o" + i, label: "Option " + i })),
|
|
],
|
|
methods: [
|
|
{
|
|
type: "api",
|
|
label: "API key",
|
|
prompts: [{ type: "text", key: "probe", message: "probe", validate: () => JSON.stringify([input.magpie?.options("optco"), input.magpie?.option("optco", "beta"), input.magpie?.option("optco", "nope")]) }],
|
|
},
|
|
],
|
|
},
|
|
})
|
|
|
|
// a provider whose plugin declares none
|
|
export const Plain = async () => ({ auth: { provider: "plain", options: "not a list", methods: [{ type: "api", label: "API key" }] } })
|