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 81313b912 (1,447,000, issue 2612) already holds;
TestCoreScriptBudget passes.

Broken by hand: retired-move goes red with unmovedLine not appended;
TestRetiredBuiltinIsThePlugins goes red with BuiltinRetired's Movable
check dropped.
This commit is contained in:
yetone
2026-10-17 23:10:59 +08:00
parent 1acd79cdfc
commit 0f1666b387
21 changed files with 343 additions and 29 deletions
+8
View File
@@ -69,6 +69,14 @@ Two cases decide it:
installing it again gives the subscription back.
- **Not moved:** the user is still signed in through the built-in: the
move hasn't run yet, or it failed (tried again after six hours).
- **Retired:** the built-in's code is gone (`retiredBuiltins` in
`internal/provider/migrate.go`; `provider.BuiltinRetired(id)`). The
plugin serves it, moved or not. Accounts not moved yet are served by
nothing; a line over the Providers list says so, with why and a Move
(`providers.unmoved`, `unmovedLine` in app.js). With no row of its own,
the Add sheet leaves it to the Plugins page (`unusedSub`). The
built-ins are retired one at a time, each with its code; gates ask
`provider.PluginServes(id)` (moved or retired).
For a moved subscription, the plugin does everything: sign-in, refresh,
models, requests, usage and errors. It runs in the plugin host
+2
View File
@@ -19,6 +19,8 @@ The `movers` map assembled in `internal/provider/migrate*.go` is the authoritati
`provider.Moved(id)` identifies a subscription whose migration state in `migrations.json` is `plugin`. In `/api/providers`, its row exposes `move.state == "plugin"`; the GUI also receives its id in `onPlugins`.
A retired built-in (`retiredBuiltins` in [`migrate.go`](../../internal/provider/migrate.go), `provider.BuiltinRetired(id)`) has no built-in code left: the plugin serves it whether or not a move has run, and its row's `move.state` is `plugin`. Gates that once asked `Moved(id)` ask `provider.PluginServes(id)`, which is moved or retired. Built-in accounts of a retired subscription that haven't moved yet are served by nothing; `/api/providers` lists them in `unmoved` (each a `MoveCandidate`, with the failed move's `error` and `why`), and the GUI shows a line over the Providers list with a Move button (`unmovedLine` in `app.js`). Built-ins are retired one at a time, each in the commit that removes its code.
| Operation | Built-in owns the subscription | Plugin owns the subscription |
| --- | --- | --- |
| Sign-in, refresh, and models | Built-in provider implementation | Community plugin through magpie's plugin integration |
+2 -2
View File
@@ -438,7 +438,7 @@ func addAccount(agentID string) error {
return fmt.Errorf("sign-in canceled")
}
}
if _, plug := provider.PluginOf(agentID); plug || provider.Moved(agentID) {
if _, plug := provider.PluginOf(agentID); plug || provider.PluginServes(agentID) {
return pluginLogin(context.Background(), agentID, "")
}
if p, _ := claudeCode.downloaded(); agentID == "claude" && runtime.GOOS != "windows" && claudeCode.own() == "" && p == "" {
@@ -557,7 +557,7 @@ func importAccounts(args []string) error {
id = "antigravity"
case "factory", "droid":
id = "factory"
if provider.Moved(id) {
if provider.PluginServes(id) {
return fmt.Errorf("Factory runs on its plugin now: add the key with magpie accounts add factory")
}
default:
+1 -1
View File
@@ -813,7 +813,7 @@ func showProvider(p provider.Provider) error {
from := p.Account.Agent + "'s own sign-in"
if p.IsPlugin() {
from = p.Name + "'s sign-in"
if provider.Moved(p.ID) {
if provider.PluginServes(p.ID) {
from = p.ID + "'s own sign-in" // as the built-in said
}
}
+47 -2
View File
@@ -6016,8 +6016,10 @@ function renderMovable() {
let hid = "";
try { hid = localStorage.getItem("magpie.deprecatedHidden") || ""; } catch {}
const ids = ps.map((p) => p.id).join(",");
box.hidden = !ps.length || hid === ids;
if (box.hidden) return;
const unmoved = providers.unmoved || [];
box.hidden = (!ps.length || hid === ids) && !unmoved.length;
for (const p of unmoved) box.append(unmovedLine(p));
if (!ps.length || hid === ids) return;
const names = ps.map((p) => p.name).join(t(", "));
// one quiet line over the list, as calm as its rows: an amber dot, what
// happened and why, and the two answers on the right (the owner: 这个太丑了 —
@@ -6042,6 +6044,49 @@ function renderMovable() {
box.append(card);
}
// unmovedLine: a retired built-in whose accounts haven't moved to its
// plugin (a failed install): nothing serves them, so it is never hidden.
// An amber dot, what happened and why, and the move, tried again here.
const unmovedSaid = {}; // provider id → { busy } or { why }
function unmovedLine(p) {
const card = el("div", "deprecation unmoved");
card.setAttribute("role", "note");
card.dataset.id = p.id;
const body = el("div", "dep-body");
const said = unmovedSaid[p.id];
const why = said?.why || moveWhy(p, p);
body.append(el("div", "dep-head", t("{name}'s built-in subscription is retired, and its accounts haven't moved to its plugin yet", { name: p.name })),
el("p", "dep-why", why ? t("Nothing serves them until they move: {error}", { error: why }) : t("Nothing serves them until they move. Moving keeps your accounts, models and agents as they are.")));
const acts = el("div", "dep-acts");
const b = el("button", "text action", said?.busy || (why ? t("Try again") : t("Move to the plugin")));
b.title = p.package; // the npm package: for the curious, not the sentence
b.disabled = b.classList.toggle("busy", !!said?.busy);
b.onclick = async () => {
unmovedSaid[p.id] = { busy: t("Installing the plugin and checking each account…") };
renderMovable();
try {
providers = await api("provider/move", { id: p.id });
delete unmovedSaid[p.id];
renderProviders();
const now = providers.providers.find((x) => x.id === p.id);
const accts = now?.account?.logins?.length || 0, models = (now?.models || []).filter((x) => x.on).length;
saidMoved(t("{name} now runs on its plugin — {accounts}, {models}.", {
name: p.name,
accounts: t(accts === 1 ? "{n} account" : "{n} accounts", { n: accts }),
models: t(models === 1 ? "{n} model" : "{n} models", { n: models }),
}));
state = await api("state");
renderAgents();
} catch (e) {
unmovedSaid[p.id] = { why: moveWhy({ why: e.why, error: e.message }, p) };
renderMovable();
}
};
acts.append(b);
card.append(el("span", "dep-dot"), body, acts);
return card;
}
// Sign-ins magpie found but leaves alone, so nobody wonders why an agent that
// is clearly logged in is not in the list: the ones the user removed.
function renderExcluded() {
+12
View File
@@ -1454,6 +1454,9 @@ const I18N = {
"Runs on": "运行方式",
"Move to the plugin": "迁移到插件",
"magpie's built-in · or the community {name} plugin, with the same accounts": "magpie 内置 · 也可改用社区 {name} 插件,账号不变",
"{name}'s built-in subscription is retired, and its accounts haven't moved to its plugin yet": "{name} 的内置订阅已下线,它的账号还没迁移到插件",
"Nothing serves them until they move: {error}": "迁移之前,它们无法使用:{error}",
"Nothing serves them until they move. Moving keeps your accounts, models and agents as they are.": "迁移之前,它们无法使用。迁移会保留你的账号、模型和智能体设置。",
"The community {name} plugin, with the accounts you had here.": "社区 {name} 插件,沿用你在这里的账号。",
"It stays built-in: {error}": "仍使用内置:{error}",
"Installing the plugin and checking each account…": "正在安装插件并逐个检查账号…",
@@ -5142,6 +5145,9 @@ const I18N = {
"Runs on": "執行方式",
"Move to the plugin": "遷移到外掛",
"magpie's built-in · or the community {name} plugin, with the same accounts": "magpie 內建 · 也可改用社群 {name} 外掛,帳號不變",
"{name}'s built-in subscription is retired, and its accounts haven't moved to its plugin yet": "{name} 的內建訂閱已下線,它的帳號還沒遷移到外掛",
"Nothing serves them until they move: {error}": "遷移之前,它們無法使用:{error}",
"Nothing serves them until they move. Moving keeps your accounts, models and agents as they are.": "遷移之前,它們無法使用。遷移會保留你的帳號、模型和智慧體設定。",
"The community {name} plugin, with the accounts you had here.": "社群 {name} 外掛,沿用你在這裡的帳號。",
"It stays built-in: {error}": "仍使用內建:{error}",
"Installing the plugin and checking each account…": "正在安裝外掛並逐個檢查帳號…",
@@ -8807,6 +8813,9 @@ const I18N = {
"Runs on": "実行方法",
"Move to the plugin": "プラグインに移行",
"magpie's built-in · or the community {name} plugin, with the same accounts": "magpie の組み込み · または同じアカウントでコミュニティの {name} プラグイン",
"{name}'s built-in subscription is retired, and its accounts haven't moved to its plugin yet": "{name} の組み込みサブスクリプションは終了しました。アカウントはまだプラグインに移行されていません",
"Nothing serves them until they move: {error}": "移行するまで使えません:{error}",
"Nothing serves them until they move. Moving keeps your accounts, models and agents as they are.": "移行するまで使えません。移行してもアカウント、モデル、エージェントはそのままです。",
"The community {name} plugin, with the accounts you had here.": "コミュニティの {name} プラグイン(ここで使っていたアカウントのまま)。",
"It stays built-in: {error}": "組み込みのままです:{error}",
"Installing the plugin and checking each account…": "プラグインをインストールし、各アカウントを確認しています…",
@@ -12502,6 +12511,9 @@ const I18N = {
"Runs on": "Läuft über",
"Move to the plugin": "Zur Erweiterung umziehen",
"magpie's built-in · or the community {name} plugin, with the same accounts": "in magpie integriert · oder die Community-Erweiterung {name}, mit denselben Konten",
"{name}'s built-in subscription is retired, and its accounts haven't moved to its plugin yet": "Das integrierte Abo von {name} ist eingestellt, und seine Konten sind noch nicht zur Erweiterung umgezogen",
"Nothing serves them until they move: {error}": "Bis zum Umzug funktionieren sie nicht: {error}",
"Nothing serves them until they move. Moving keeps your accounts, models and agents as they are.": "Bis zum Umzug funktionieren sie nicht. Der Umzug behält deine Konten, Modelle und Agenten bei.",
"The community {name} plugin, with the accounts you had here.": "Die Community-Erweiterung {name}, mit den Konten, die Sie hier hatten.",
"It stays built-in: {error}": "Es bleibt integriert: {error}",
"Installing the plugin and checking each account…": "Erweiterung wird installiert und jedes Konto geprüft…",
+23 -3
View File
@@ -261,7 +261,8 @@ type providerJSON struct {
type moveJSON struct {
Package string `json:"package"`
// State is "" (built-in, never moved), "plugin", "back" or "failed"
// State is "" (built-in, never moved), "plugin", "back" or "failed";
// a retired built-in's row is its plugin's, "plugin"
State string `json:"state"`
Error string `json:"error,omitempty"`
// Why is a failed move's reason, which the page says in its language
@@ -366,7 +367,7 @@ func accountLabel(p provider.Provider) (name, icon string) {
if name == "" {
name = p.Name
}
if provider.Moved(pp.ID) {
if provider.PluginServes(pp.ID) {
icon = p.Icon // the built-in's, as it was
}
return name, icon
@@ -490,6 +491,9 @@ type providersJSON struct {
// MovesTo is the plugin each of them goes to, for the add sheet's
// offer to install it before signing in
MovesTo map[string]string `json:"movesTo,omitempty"`
// Unmoved are the retired built-ins whose accounts haven't moved onto
// their plugins yet, served by nothing until they do, with why
Unmoved []provider.MoveCandidate `json:"unmoved,omitempty"`
// Moved is the agents the change moved off models it stopped serving
// (agent.Reseat), for the page to say so.
Moved []agent.Move `json:"moved,omitempty"`
@@ -639,7 +643,11 @@ func providerInfoWith(p provider.Provider, agents []agentUse, desktop map[string
}
out.Key.Set = p.Key != ""
out.Key.Masked = provider.Mask(p.Key)
if provider.Movable(p.ID) {
if provider.BuiltinRetired(p.ID) {
// only its plugin's row is listed now: built-in accounts not moved
// yet are providersJSON.Unmoved's
out.Move = &moveJSON{Package: provider.MovePackage(p.ID), State: provider.MovePlugin}
} else if provider.Movable(p.ID) {
m, _ := provider.MigrationOf(p.ID)
out.Move = &moveJSON{Package: provider.MovePackage(p.ID), State: m.State, Error: m.Err, Why: m.Why}
if m.State == provider.MoveMoving {
@@ -831,12 +839,24 @@ func providersState() providersJSON {
s := providersJSON{Providers: []providerJSON{}, Presets: []presetJSON{}, Excluded: []excludedJSON{}}
s.OnPlugins = provider.OnPlugins()
s.Movable = provider.MovableIDs()
// a retired built-in whose plugin is installed is the plugin's, moved
// or not: the add sheet signs in to it through the plugin alone
for _, id := range s.Movable {
if _, ok := provider.PluginOf(id); ok && provider.BuiltinRetired(id) && !slices.Contains(s.OnPlugins, id) {
s.OnPlugins = append(s.OnPlugins, id)
}
}
for _, id := range s.Movable {
if s.MovesTo == nil {
s.MovesTo = map[string]string{}
}
s.MovesTo[id] = provider.MovePackage(id)
}
for _, c := range provider.MoveCandidates() {
if provider.BuiltinRetired(c.ID) {
s.Unmoved = append(s.Unmoved, c)
}
}
if err := provider.FileError(); err != nil {
s.FileError = err.Error()
}
+157
View File
@@ -0,0 +1,157 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// A retired built-in subscription (Zed here) whose accounts haven't moved
// onto its community plugin yet is served by nothing, so it has no row: a
// quiet line over the list says so, with its move. A move that fails says
// why in the line, in the reader's language, and the button becomes "Try
// again"; one that goes through takes the line away and lists Zed as its
// plugin's, whose editor says the plugin runs it with no way back and shows
// no plugin:// endpoints to test. The add sheet offers Zed once, as the
// plugin's, and before the move, with no plugin installed, not at all: it
// is the Plugins page's. In English and Chinese; the API is faked here.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const assets = path.resolve(__dirname, "../assets");
const pkg = "@magpie-community/opencode-zed-auth";
function serve(lang, posts, hold) {
let move = { package: pkg, state: "" };
let tries = 0;
const payload = () => {
const onPlugin = move.state === "plugin";
const zed = {
id: "zed", name: "Zed", icon: "zed", chat: "plugin://zed/v1", responses: "", anthropic: "plugin://zed", catalog: "",
models: Array.from({ length: 30 }, (_, i) => ({ id: "m" + i, name: "Model " + i, on: i === 0 })),
agents: [], fallback: [], headers: {}, keyList: [], key: {},
account: { agent: "zed", agentName: "Zed", user: "ada", logins: [{ user: "ada", active: true, on: true, own: true }, { user: "bob", on: true }] },
move: { package: pkg, state: "plugin" },
};
return {
providers: onPlugin ? [zed] : [], presets: [], excluded: [], gateway: { running: true, window: true },
plugins: onPlugin ? [{ id: "zed", pid: "zed", name: "Zed", icon: "zed", spec: pkg, signedIn: true, models: 1, methods: [] }] : [],
onPlugins: onPlugin ? ["zed"] : [],
movable: ["zed"], movesTo: { zed: pkg },
unmoved: onPlugin ? [] : [{ id: "zed", name: "Zed", package: pkg, accounts: 2, ...(move.why ? { why: move.why, error: move.error } : {}) }],
};
};
return async (route) => {
const url = new URL(route.request().url());
const json = (data) => route.fulfill({ json: data });
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
if (url.pathname === "/api/state") return json({ agents: [], profiles: [], settings: { lang, theme: "light" } });
if (url.pathname === "/api/providers") return json(payload());
if (url.pathname === "/api/groups") return json({ groups: [] });
// the page asks for the market in parts (#488)
if (url.pathname === "/api/plugins/market" || url.pathname === "/api/plugins" || url.pathname === "/api/plugins/listings") {
const m = ({ listings: [{ package: pkg, name: "Zed", icon: "zed", providers: ["zed"], community: true, replaces: "zed", summary: { en: "Zed", zh: "Zed" }, npm: { version: "0.1.0" } }],
state: { bun: true, bunVersion: "1.3.0", plugins: [], movable: move.state === "plugin" ? [] : [{ id: "zed", name: "Zed", package: pkg, accounts: 2 }] } });
return json(url.pathname === "/api/plugins" ? m.state : url.pathname === "/api/plugins/listings" ? { listings: m.listings } : m);
}
if (url.pathname === "/api/provider/move") {
posts.push({ path: url.pathname, body: route.request().postDataJSON() });
// the first move is held until the test has read the busy button,
// so a slow machine can't end it before the button is looked at
if (!tries) await new Promise((r) => (hold.release = r));
// the first move can't reach npm; the second goes through
if (!tries++) {
move = { package: pkg, state: "failed", error: "magpie couldn't reach npm to install the plugin.", why: { code: "offline" } };
return route.fulfill({ status: 400, json: { error: move.error, why: move.why } });
}
move = { package: pkg, state: "plugin" };
return json(payload());
}
if (url.pathname.startsWith("/api/")) return json({});
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
try { await route.fulfill({ body: await fs.readFile(file), contentType }); } catch { await route.fulfill({ status: 404, body: "" }); }
};
}
const L = {
en: { line: "Zed's built-in subscription is retired, and its accounts haven't moved to its plugin yet",
move: "Move to the plugin", busy: "Installing the plugin and checking each account…", again: "Try again", retired: "magpie's built-in is retired, so this subscription stays on its plugin.",
failed: "Nothing serves them until they move: magpie couldn't reach npm to install the plugin. Check the network or proxy, then try again.",
onPlugin: "The community Zed plugin", done: "Zed now runs on its plugin — 2 accounts, 1 model.",
subs: "Subscriptions", card: "Move" },
zh: { line: "Zed 的内置订阅已下线,它的账号还没迁移到插件",
move: "迁移到插件", busy: "正在安装插件并逐个检查账号…", again: "重试", retired: "magpie 的内置已下线,此订阅一直由插件运行。",
failed: "迁移之前,它们无法使用:无法连接 npm 安装插件,请检查网络或代理后重试。",
onPlugin: "社区 Zed 插件", done: "Zed 已改由插件运行:2 个账号,1 个模型。",
subs: "订阅", card: "迁移" },
};
const launch = (engine) => engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" });
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh"]) {
test(`${engine} ${lang}: a retired subscription's accounts move to its plugin from the line over the list`, async (t) => {
const w = L[lang];
const browser = await launch(engine);
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(5000);
const errors = [], posts = [], hold = {};
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", serve(lang, posts, hold));
await page.goto("http://magpie.test/?view=providers");
// no row: nothing serves it; the line over the list says so
const line = page.locator("#movable");
const btn = line.locator("button");
await btn.waitFor();
assert.ok((await line.innerText()).includes(w.line), "no line saying Zed's accounts haven't moved");
assert.equal(await page.locator('#providers .row.provider[data-id="zed"]').count(), 0, "a row for the retired built-in");
assert.equal(await btn.innerText(), w.move);
assert.equal(await btn.getAttribute("title"), pkg, "the package isn't in the tooltip");
assert.ok(!(await line.innerText()).includes(pkg), "names the npm package in the sentence");
// nothing serves it and it has no row, so the add sheet (open from
// the start: the list is empty) leaves it to the Plugins page
const sheet = page.locator("#addSheet");
if (await sheet.isHidden()) await page.locator("#addProvider").click();
await sheet.locator(".kind b", { hasText: w.subs }).waitFor();
assert.equal(await sheet.locator('.tile[data-pick="Zed"]').count(), 0, "the add sheet offers a retired built-in nothing serves");
await btn.click();
await page.waitForFunction((busy) => document.querySelector("#movable button")?.textContent === busy, w.busy);
assert.equal(await btn.isDisabled(), true, "the button can be pressed again mid-move");
// let the held move go, once its request is in
for (let i = 0; !hold.release && i < 250; i++) await page.waitForTimeout(20);
assert.ok(hold.release, "the move was never asked");
hold.release();
// it fails: said in the line, and Try again
await page.waitForFunction((want) => document.querySelector("#movable")?.innerText.includes(want), w.failed);
assert.equal(await btn.innerText(), w.again);
assert.equal(await btn.isDisabled(), false);
await page.evaluate(() => renderProviders());
assert.ok((await line.innerText()).includes(w.failed), "a redraw forgot why the move failed");
// tried again, it goes through: the line goes, Zed is its plugin's
await btn.click();
await page.waitForFunction((s) => document.querySelector("#status").textContent.startsWith(s), w.done);
assert.equal(await line.isVisible(), false, "the line still offers the move");
assert.deepEqual(posts.map((p) => [p.path, p.body.id]), [["/api/provider/move", "zed"], ["/api/provider/move", "zed"]]);
await page.locator("#providers .row.provider", { hasText: "Zed" }).first().click();
const ed = page.locator("#modal .editor");
await ed.locator(".hint", { hasText: w.retired }).waitFor();
assert.equal(await ed.locator(".move button").count(), 0, "a moved subscription offers a way back");
assert.ok((await ed.innerText()).includes(w.onPlugin), "doesn't say the plugin runs it");
// its plugin:// URLs are magpie's own: no Endpoints, no Test
assert.equal(await ed.locator(".eps").count(), 0, "shows the plugin:// endpoints");
if (process.env.ARTIFACT_DIR) await ed.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `plugin-moved-${engine}-${lang}.png`) });
await page.keyboard.press("Escape");
// the add sheet offers Zed once, as the plugin's
await page.locator("#modal").waitFor({ state: "hidden" });
if (await sheet.isHidden()) await page.locator("#addProvider").click();
await sheet.locator(".kind b", { hasText: w.subs }).waitFor();
assert.equal(await sheet.locator('.tile[data-pick="Zed"]').count(), 1);
await page.keyboard.press("Escape");
assert.deepEqual(errors, []);
});
}
}
+2 -2
View File
@@ -904,7 +904,7 @@ func Accounts() []Provider {
}
}
// a built-in moved onto its plugin is the plugin's now (migrate.go)
out = slices.DeleteFunc(out, func(p Provider) bool { return Moved(p.ID) })
out = slices.DeleteFunc(out, func(p Provider) bool { return PluginServes(p.ID) })
return placeMoved(out, pluginAccounts())
}
@@ -923,7 +923,7 @@ func placeMoved(out, plugins []Provider) []Provider {
}
var rest []Provider
for _, p := range plugins {
if !Moved(p.ID) || !slices.Contains(builtinOrder, p.ID) {
if !PluginServes(p.ID) || !slices.Contains(builtinOrder, p.ID) {
rest = append(rest, p)
continue
}
+1 -1
View File
@@ -86,7 +86,7 @@ var cardAgents = []string{"claude", "codex", "copilot", "kiro", "zcode", "workbu
func cardLogins() []Login {
agents := []string{}
for _, id := range cardAgents {
if Moved(id) || id == "kiro" && kiroKey() != "" {
if PluginServes(id) || id == "kiro" && kiroKey() != "" {
continue
}
agents = append(agents, id)
+1 -1
View File
@@ -94,7 +94,7 @@ func factoryAddKey(ctx context.Context, key string) ImportedAccount {
if user == "" {
return ImportedAccount{User: factoryKeyName(key), Status: "failed", Error: "Factory took the key but didn't say whose account it is"}
}
if Moved("factory") {
if PluginServes("factory") {
return factoryKeyToPlugin(wctx, user, c)
}
status := "added"
+1 -1
View File
@@ -107,7 +107,7 @@ func forgetPluginAccounts(pp plugin.Provider) error {
}
}
loginsMu.Unlock()
if Moved(pp.ID) {
if PluginServes(pp.ID) {
// moving back would bring the accounts forgotten back from the
// backup the move set aside
mv := movers[pp.ID]
+1 -1
View File
@@ -856,7 +856,7 @@ func Logins(agent string) []Login {
{MiMoID, mimoLoginList}, {ChatGPTAPIID, siwcLoginList}, {"gemini", func() []Login { return googleLoginList("gemini") }},
{"antigravity", func() []Login { return googleLoginList("antigravity") }},
} {
if !Moved(b.id) {
if !PluginServes(b.id) {
side = append(side, b.list()...)
continue
}
+38 -7
View File
@@ -14,12 +14,13 @@ package provider
// one that fails otherwise goes along untried, since the built-in is
// retired and the plugin is where the account is fixed now;
// 4. the id changes hands: the built-in's saved accounts go out of
// logins.json into migrations.json, kept for going back.
// logins.json into migrations.json.
//
// A failure on the way (the install, the plugin not serving the id, a
// sign-in it won't import) puts everything back as it was — the plugin's
// newer tokens included, since a refresh token used once is spent — and
// the built-in carries on. MoveBack undoes a move the same way.
// sign-in it won't import) puts the built-in's saved accounts back as they
// were — the plugin's newer tokens included, since a refresh token used
// once is spent — for the next try. The built-in serves nothing either
// way (Retired): MoveCandidates lists the accounts still to move, and why.
import (
"context"
@@ -143,6 +144,13 @@ func installFailed(pkg string, err error) error {
// nameOf is the built-in id's name, as the providers list shows it.
func nameOf(id string) string {
// a retired built-in is listed no more: the name it had
if c, ok := movedCards[id]; ok {
return c.name
}
if id == QoderCNID {
return "Qoder CN"
}
for _, p := range All() {
if p.ID == id && !p.IsPlugin() && p.Name != "" {
return p.Name
@@ -246,6 +254,22 @@ var errStays = errors.New("stays with the plugin")
// Movable is whether the built-in id has a plugin it can move to.
func Movable(id string) bool { return movers[id] != nil }
// BuiltinRetired is whether magpie's built-in id is retired: its plugin serves
// it, and the built-in serves nothing, moved or not. One whose accounts
// haven't moved yet (a failed install, an account the plugin turned away)
// is listed by MoveCandidates with why, until it moves. The built-ins are
// retired one by one, each with its code (the owner, 10-16: 陆续把内置
// Provider下线掉), so this is the set retired so far.
func BuiltinRetired(id string) bool { return Movable(id) && retiredBuiltins[id] }
// retiredBuiltins are the built-in subscriptions whose code is gone.
var retiredBuiltins = map[string]bool{}
// PluginServes is whether the built-in id's subscription is its plugin's to
// serve, and magpie's built-in code serves none of it: moved onto its plugin,
// or retired.
func PluginServes(id string) bool { return Moved(id) || BuiltinRetired(id) }
// MovableIDs are the built-ins that have a plugin to move to, by id: the
// page marks them deprecated, moved or not.
func MovableIDs() []string {
@@ -263,6 +287,9 @@ type MoveCandidate struct {
Name string `json:"name"`
Package string `json:"package"`
Accounts int `json:"accounts"`
// Error and Why are the last try's failure, when one failed
Error string `json:"error,omitempty"`
Why *MoveWhy `json:"why,omitempty"`
}
// MoveCandidates are the built-ins not on their plugins that have accounts
@@ -277,7 +304,11 @@ func MoveCandidates() []MoveCandidate {
continue
}
if accts, err := mv.out(); err == nil && len(accts) > 0 {
out = append(out, MoveCandidate{ID: id, Name: nameOf(id), Package: mv.pkg, Accounts: len(accts)})
c := MoveCandidate{ID: id, Name: nameOf(id), Package: mv.pkg, Accounts: len(accts)}
if m, ok := MigrationOf(id); ok && m.State == MoveFailed {
c.Error, c.Why = m.Err, m.Why
}
out = append(out, c)
}
}
sort.Slice(out, func(i, j int) bool { return out[i].Name < out[j].Name })
@@ -342,7 +373,7 @@ func Moved(id string) bool {
// built-in's, its plugin's now.
func movedAgent(agent string) bool {
for id, mv := range movers {
if slices.Contains(mv.agents, agent) && Moved(id) {
if slices.Contains(mv.agents, agent) && PluginServes(id) {
return true
}
}
@@ -1040,7 +1071,7 @@ func KeepRetiringMoved(ctx context.Context) {
maps.Copy(moves, HandOver(ctx, true))
for id, err := range moves {
if err != nil {
log.Printf("moving %s to its plugin: %s (it stays built-in)", id, err)
log.Printf("moving %s to its plugin: %s (nothing serves it until it moves)", id, err)
} else {
log.Printf("moved %s to its plugin, %s", id, MovePackage(id))
}
+39
View File
@@ -0,0 +1,39 @@
package provider
import (
"strings"
"testing"
)
// A retired built-in is its plugin's to serve before any move: signing in
// to the built-in is turned away, and only an id with a plugin can be
// retired. An id not retired is the plugin's only once moved.
func TestRetiredBuiltinIsThePlugins(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("XDG_CONFIG_HOME", home+"/.config")
id := ""
for m := range movers {
if !retiredBuiltins[m] {
id = m
break
}
}
if id == "" {
t.Skip("every built-in with a plugin is retired")
}
if PluginServes(id) {
t.Fatalf("%s is the plugin's with nothing moved or retired", id)
}
retiredBuiltins[id], retiredBuiltins["claude"] = true, true
t.Cleanup(func() { delete(retiredBuiltins, id); delete(retiredBuiltins, "claude") })
if !PluginServes(id) || !BuiltinRetired(id) {
t.Fatalf("retired %s isn't the plugin's", id)
}
if BuiltinRetired("claude") || PluginServes("claude") {
t.Fatal("claude, which has no plugin, is retired")
}
if _, err := StartSignInWith(id, SignInOptions{}); err == nil || !strings.Contains(err.Error(), "plugin") {
t.Fatalf("signing in to the retired built-in: %v", err)
}
}
+1 -1
View File
@@ -59,7 +59,7 @@ var movedNames = map[string]string{CommandCodePlanID: "Command Code Plan"}
// pluginCard is the name and icon pp's usage cards show.
func pluginCard(pp plugin.Provider) (string, string) {
if c, ok := movedCards[pp.ID]; ok && Moved(pp.ID) {
if c, ok := movedCards[pp.ID]; ok && PluginServes(pp.ID) {
return c.name, c.icon
}
name := pp.Name
+3 -3
View File
@@ -48,7 +48,7 @@ const (
// installed (zenmux, #867), when it is id-plugin — but for a built-in moved
// onto the plugin, whose id the plugin has now.
func PluginID(id string) string {
if Moved(id) {
if PluginServes(id) {
return id
}
if slices.Contains(accountIDs, id) || Preset(id) != nil || id == "magpie" || customIDs()[id] {
@@ -241,7 +241,7 @@ func pluginCatalog(pp plugin.Provider) []catalog.Model {
// So does Cline's plugin, which resells others' models as the
// ClinePass built-in does and gives no levels of its own: signed in
// through it, ClinePass showed none where its API key showed them
if len(c.Efforts) == 0 && (Moved(pp.ID) || pp.ID == "cline") {
if len(c.Efforts) == 0 && (PluginServes(pp.ID) || pp.ID == "cline") {
c.Efforts = borrowedEfforts(m.ID)
}
// OpenCode's price of a model it has none for is 0, as the
@@ -376,7 +376,7 @@ func pluginProvider(pp plugin.Provider, l pluginLogin) Provider {
a.sign = func(ctx context.Context, req *http.Request, body []byte) error { return nil }
a.transport = func(req *http.Request) (*http.Response, error) { return pluginFetch(pp, acct.Key, req) }
p := Provider{ID: id, Name: name, Icon: PluginIcon(pp), Account: a}
if c, ok := movedCards[pp.ID]; ok && Moved(pp.ID) {
if c, ok := movedCards[pp.ID]; ok && PluginServes(pp.ID) {
p.Name, p.Icon, p.Website = c.name, c.icon, c.site // as the built-in was
m, _ := MigrationOf(pp.ID)
a.moved, a.wasHost = true, m.Host
+1 -1
View File
@@ -77,7 +77,7 @@ var pluginRunsCLI = map[string]bool{"grok": true}
// through and this machine lacks: a moved built-in's, or one in
// pluginRunsCLI.
func pluginCLI(id string) (agentCLI, bool) {
if Moved(PluginID(id)) {
if PluginServes(PluginID(id)) {
return missingCLI(PluginID(id))
}
if pluginRunsCLI[id] {
+1 -1
View File
@@ -246,7 +246,7 @@ func StartSignInWith(agent string, o SignInOptions) (SignInState, error) {
}
// one moved onto its plugin signs in there: an account signed in to
// here would be the built-in's, which nothing serves now
if Moved(agent) {
if PluginServes(agent) {
return SignInState{}, fmt.Errorf("%s runs on its plugin: sign in through the plugin (magpie plugin login %s)", agent, agent)
}
s := &signInFlow{verifier: randomToken(48), state: randomToken(24), done: make(chan struct{}), site: site}
+1 -1
View File
@@ -423,7 +423,7 @@ func fetchSubscriptionUsage(ctx context.Context) []SubscriptionQuota {
// would be a second card of the same account
placed := map[string]bool{}
moved := func(id string) bool {
if !Moved(id) {
if !PluginServes(id) {
return false
}
placed[id] = true
+1 -1
View File
@@ -416,7 +416,7 @@ func HasWorkBuddy() bool { return len(wbCheckinAccounts()) > 0 }
// moved back), whose cards had their credits by day but no check-in
// (#694, Dazzle-sys on 0.1.774: 没看到).
func wbCheckinAccounts() []wbAccount {
if Moved(wbCN.id) {
if PluginServes(wbCN.id) {
pp, ok := PluginOf(wbCN.id)
if !ok || pluginChecksIn(pp) {
return nil