provider: every deprecated built-in moves onto its plugin, and there's no way back
The owner, 10-16: 陆续把内置Provider下线掉…一定要下线完毕. The plugins now do what the built-ins did (the parity batch up to53009f81a), so the built-ins are retired: - MoveRetiring moves every subscription with a mover (retiring is MovableIDs, the list was empty) that still has built-in accounts, from the gateway's hourly loop, six hours after a failed try as before. - A user who moved back is moved again. Only a move back made by removing or turning off the plugin (Migration.Left) is left as it is. - There is no move back from the GUI or the CLI. provider/moveback and `magpie plugins move-back` answer that the built-ins are retired. A moved subscription's editor says it stays on its plugin and shows no button, and the success line no longer offers to go back. New strings in zh, zh-TW, ja and de; the three unused ones are gone ("Moving back…" stays, for removing a plugin). - AGENTS.md and docs/subsystems/provider-plugins.md say so. Tests: - TestMoveRetiring's subtests check that a moved-back subscription is moved again and an off or removed plugin's is not. - TestMoveBackRefused goes red on the old handler. - plugin-move.test.cjs checks that a moved Zed has no button and says it stays. What was run, at63be47717with this change: - go test -tags nogui ./... -count=1 -timeout 90m: 65 packages ok. The gateway was red on TestUsageKeepsTimeToFirstToken (#2575, new) and TestVisionWaitIsntTheDescribersTime (#2444) at load ~260. Neither file is touched here, and both pass alone with -count=3. - gofmt -l is clean; GOOS=linux and GOOS=windows go vet of provider, gui and cli pass. - GUI, both engines: plugin-move, plugin-move-unserved and i18n-keys pass 23 of 23. - The other plugin-*.test.cjs files go red under parallel load as they do on untouched main (#1544, commented with the runs). Serially, then alone, they pass 28 of 28.
This commit is contained in:
@@ -61,7 +61,14 @@ Two cases decide it:
|
||||
gateway's hourly loop (`KeepRetiringMoved`) when it has, unless they moved
|
||||
back or the plugin is signed in under its own `-plugin` id already. Until
|
||||
then the Add sheet shows the plugin's tile only (`replacedSub` in app.js).
|
||||
- **Not moved:** the user is still signed in through the built-in.
|
||||
Since 10-16 the built-ins are being retired: the hourly loop's
|
||||
`MoveRetiring` moves every subscription with a mover that still has
|
||||
built-in accounts, a user who moved back included, and there is no way
|
||||
back from the GUI or CLI. Only removing or turning off the plugin puts the
|
||||
built-in back (`Left`), and that is left alone.
|
||||
- **Not moved:** the user is still signed in through the built-in: the
|
||||
move hasn't run yet, it failed (tried again after six hours), or they
|
||||
removed the plugin.
|
||||
|
||||
For a moved subscription, the plugin does everything: sign-in, refresh,
|
||||
models, requests, usage and errors. It runs in the plugin host
|
||||
|
||||
@@ -122,16 +122,16 @@ Migration records use four states:
|
||||
| --- | --- |
|
||||
| `moving` | Migration is in progress or was interrupted. An explicit retry first rolls back the interrupted move. |
|
||||
| `plugin` | The plugin owns the built-in provider id. This is the only state recognized by `Moved`. |
|
||||
| `back` | Ownership returned to the built-in. Automatic handover leaves it there. |
|
||||
| `back` | Ownership returned to the built-in. `MoveRetiring` moves it again, unless `Left` says the user removed or turned off the plugin. |
|
||||
| `failed` | Migration failed and the built-in continues serving. Automatic retry waits six hours. |
|
||||
|
||||
The editor's "Move to plugin" action calls `provider.Adopt`. With accounts, adoption delegates to `Move`, which imports and validates accounts and model coverage before committing plugin ownership. With no accounts, adoption verifies the package and the provider it serves, then records plugin ownership without account checks.
|
||||
|
||||
Installing the plugin independently can also hand over ownership through `provider.HandOver`. The package must be enabled, meet the mover's minimum version, and serve the expected provider. After add, update, or upgrade, the GUI calls `HandOver(ctx, false)`, which can adopt a built-in with no accounts. Existing built-in accounts wait for `HandOver(ctx, true)` in gateway maintenance.
|
||||
|
||||
`KeepRetiringMoved` first runs after 20 seconds, then hourly. Each cycle maintains moved plugin versions, calls `MoveRetiring`, then performs automatic handover. `MoveRetiring` moves subscriptions listed in `provider.Retiring` that have built-in accounts, preserving move-back choices and waiting six hours after a failed attempt. That list is currently empty. Handover preserves a plugin already signed in under its separate `-plugin` id and skips existing migration records except a `failed` record old enough to retry.
|
||||
`KeepRetiringMoved` first runs after 20 seconds, then hourly. Each cycle maintains moved plugin versions, calls `MoveRetiring`, then performs automatic handover. `MoveRetiring` moves every subscription with a mover (`retiring`, which is `MovableIDs`) that has built-in accounts, waiting six hours after a failed attempt. The built-ins are being retired (the owner, 10-16: 陆续把内置Provider下线掉), so a `back` record is moved again too; only one with `Left` set, a move back made by removing or turning off the plugin, is left. Handover preserves a plugin already signed in under its separate `-plugin` id and skips existing migration records except a `failed` record old enough to retry.
|
||||
|
||||
`MoveBack` restores built-in ownership and records `back`. Compatible accounts added through the plugin can return too; incompatible accounts can remain with the plugin under its separate id. Removing or disabling a plugin first moves affected built-ins back and stops if that fails. A package installed by the user remains after moving back; a migration-installed package is removed only when no remaining signed-in or moved provider needs it.
|
||||
There is no move back from the GUI or the CLI: `provider/moveback` and `magpie plugins move-back` answer that the built-ins are retired. `MoveBack` remains for removing or turning off a plugin. It restores built-in ownership and records `back` (with `Left`). Compatible accounts added through the plugin can return too; incompatible accounts can remain with the plugin under its separate id. Removing or disabling a plugin first moves affected built-ins back and stops if that fails. A package installed by the user remains after moving back; a migration-installed package is removed only when no remaining signed-in or moved provider needs it.
|
||||
|
||||
Removing a plugin also sets aside the model picks its providers left in `providers.json` (#2057, `plugin_left.go`). Before, nothing listed those records and `magpie provider rm` couldn't find them, so sync and backup asked for a sign-in to them on every run (`NotSignedIn`).
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ const usage = `magpie — one place to pick every agent's model
|
||||
magpie plugin [add <package>|rm|update|on|off|login <provider>|logout <provider>]
|
||||
OpenCode provider plugins and pi packages: subscriptions signed in to, and served, through a plugin
|
||||
magpie plugin move|migrate <subscription> run a built-in subscription's accounts on its community plugin
|
||||
magpie plugin move-back|unmigrate <subscription> go back to the built-in, with its accounts
|
||||
|
||||
magpie serve [--web[=host:port]] [--tls-cert <file> --tls-key <file>]
|
||||
run the gateway alone (the app runs it too); --web serves magpie web's page too, from the same process (127.0.0.1:3430 unless told);
|
||||
|
||||
@@ -29,7 +29,6 @@ const pluginUsage = `usage: magpie plugin [list] [--json]
|
||||
magpie plugin login <provider> [<method>] sign in to a provider a plugin adds
|
||||
magpie plugin logout <provider> forget the sign-in
|
||||
magpie plugin move|migrate <subscription> run a built-in subscription's accounts on its community plugin
|
||||
magpie plugin move-back|unmigrate <subscription> go back to the built-in, with its accounts
|
||||
magpie plugin builtin [on|off <id>] list magpie's built-in plugins (Sessions, Library, routing groups…), or turn one on or off
|
||||
magpie plugin preset essentials|all start the built-in plugins from the Essentials preset, or from all of them
|
||||
magpie plugin dump [--json] what plugins.yml comes to: each built-in plugin, its config, and the layer each value is from`
|
||||
@@ -151,20 +150,11 @@ func pluginCmd(args []string) error {
|
||||
if err := provider.Move(ctx, rest[0]); err != nil {
|
||||
return fmt.Errorf("%s stays built-in: %w", rest[0], err)
|
||||
}
|
||||
fmt.Println(green.Render("✓"), rest[0], "runs on", provider.MovePackage(rest[0]), muted.Render("(magpie plugin move-back "+rest[0]+" to undo)"))
|
||||
fmt.Println(green.Render("✓"), rest[0], "runs on", provider.MovePackage(rest[0]))
|
||||
return nil
|
||||
case "move-back", "moveback", "unmigrate":
|
||||
if len(rest) != 1 {
|
||||
return errors.New(pluginUsage)
|
||||
}
|
||||
if !provider.Moved(rest[0]) {
|
||||
return fmt.Errorf("%s isn't on its plugin", rest[0])
|
||||
}
|
||||
if err := provider.MoveBack(ctx, rest[0]); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(green.Render("✓"), rest[0], "is built-in again")
|
||||
return nil
|
||||
// the built-ins are retired: there is no going back to one
|
||||
return errors.New("magpie's built-in subscriptions are retired: their community plugins run them")
|
||||
case "builtin", "builtins", "built-in":
|
||||
return builtinCmd(rest)
|
||||
case "preset":
|
||||
|
||||
+15
-15
@@ -14560,7 +14560,8 @@ function moveWhy(m, p) {
|
||||
}
|
||||
|
||||
// renderMove: which runs the subscription, magpie's built-in or its
|
||||
// community plugin, and the move between them. The editor stays open
|
||||
// community plugin, and the move onto the plugin; the built-ins are
|
||||
// retired, so a moved one has no way back. The editor stays open
|
||||
// through it: the button says what it is doing, a failure is said under
|
||||
// it, and on success the field turns over where the reader is.
|
||||
// moveSaid keeps both through a redraw mid-move (an allowance landing):
|
||||
@@ -14584,42 +14585,41 @@ function renderMove(p) {
|
||||
const going = moveSaid[p.id];
|
||||
const failed = going?.why || m.state === "failed" && (m.why || m.error) && t("It stays built-in: {error}", { error: moveWhy(m, p) });
|
||||
say(failed || "");
|
||||
const idle = () => onPlugin ? t("Use the built-in again") : failed ? t("Try again") : t("Move to the plugin");
|
||||
const idle = () => failed ? t("Try again") : t("Move to the plugin");
|
||||
const b = el("button", "text action", going?.busy || idle()); // a button, not a line of text: it changes what runs the subscription
|
||||
b.disabled = b.classList.toggle("busy", !!going?.busy);
|
||||
b.onclick = async () => {
|
||||
b.classList.add("busy");
|
||||
b.disabled = true;
|
||||
say("");
|
||||
b.textContent = onPlugin ? t("Moving back…") : t("Installing the plugin and checking each account…");
|
||||
b.textContent = t("Installing the plugin and checking each account…");
|
||||
moveSaid[p.id] = { busy: b.textContent };
|
||||
try {
|
||||
// the models as the editor shows them picked, when changed and not
|
||||
// saved: the reason a move fails says to untick one there (noting_ever)
|
||||
const picks = !onPlugin && draft && editing === p.id ? chosenIds() : null;
|
||||
const picks = draft && editing === p.id ? chosenIds() : null;
|
||||
const was = pickedOf(p);
|
||||
const changed = picks && (picks.length !== was.length || picks.some((id) => !was.includes(id)));
|
||||
providers = await api("provider/" + (onPlugin ? "moveback" : "move"), changed ? { id: p.id, models: picks } : { id: p.id });
|
||||
providers = await api("provider/move", changed ? { id: p.id, models: picks } : { id: p.id });
|
||||
delete moveSaid[p.id];
|
||||
draft = null; // the provider changed under it
|
||||
renderProviders(); // the editor stays open, turned over, where it was
|
||||
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(onPlugin ? t("{name} is built-in again, with its accounts", { name: p.name })
|
||||
: t("{name} now runs on its plugin — {accounts}, {models}. Use the built-in again from here any time.", {
|
||||
name: p.name,
|
||||
accounts: t(accts === 1 ? "{n} account" : "{n} accounts", { n: accts }),
|
||||
models: t(models === 1 ? "{n} model" : "{n} models", { n: models }),
|
||||
}));
|
||||
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) {
|
||||
moveSaid[p.id] = { state: m.state, why: onPlugin ? e.message : t("It stays built-in: {error}", { error: moveWhy({ why: e.why, error: e.message }, p) }) };
|
||||
moveSaid[p.id] = { state: m.state, why: t("It stays built-in: {error}", { error: moveWhy({ why: e.why, error: e.message }, p) }) };
|
||||
if (!box.isConnected) return renderProviders();
|
||||
say(moveSaid[p.id].why);
|
||||
b.classList.remove("busy");
|
||||
b.disabled = false;
|
||||
b.textContent = onPlugin ? t("Use the built-in again") : t("Try again");
|
||||
b.textContent = t("Try again");
|
||||
}
|
||||
};
|
||||
box.append(said);
|
||||
@@ -14628,8 +14628,8 @@ function renderMove(p) {
|
||||
note.append(el("span", "badge deprecated", t("Deprecated")), el("span", "", t(DEPRECATED_WHY)));
|
||||
box.append(note);
|
||||
}
|
||||
box.append(b, why);
|
||||
return field(t("Runs on"), box, onPlugin ? t("Going back puts every account, with the plugin's newer sign-ins, back into the built-in.") : t("If an account doesn't work through the plugin, nothing changes."));
|
||||
if (!onPlugin) box.append(b, why);
|
||||
return field(t("Runs on"), box, onPlugin ? t("magpie's built-in is retired, so this subscription stays on its plugin.") : t("If an account doesn't work through the plugin, nothing changes."));
|
||||
}
|
||||
|
||||
async function providerAction(action, body, okMsg, base = "provider/") {
|
||||
|
||||
@@ -1444,7 +1444,6 @@ const I18N = {
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota. {agent} itself stays signed in as it is.": "网关优先用第一个账号;勾选多个时,前一个额度用完自动换下一个。{agent} 本身的登录不变。",
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota.": "网关优先用第一个账号;勾选多个时,前一个额度用完自动换下一个。",
|
||||
"Runs on": "运行方式",
|
||||
"Use the built-in again": "改回内置",
|
||||
"Move to the plugin": "迁移到插件",
|
||||
"magpie's built-in · or the community {name} plugin, with the same accounts": "magpie 内置 · 也可改用社区 {name} 插件,账号不变",
|
||||
"The community {name} plugin, with the accounts you had here.": "社区 {name} 插件,沿用你在这里的账号。",
|
||||
@@ -1457,9 +1456,8 @@ const I18N = {
|
||||
"the plugin doesn't serve {models}. Untick them under Models, or keep the built-in.": "插件不提供 {models}。可在「模型」里取消勾选,或继续使用内置。",
|
||||
"the plugin doesn't serve {models} for {user}, though the built-in does. Untick them under Models, or keep the built-in.": "插件没有为 {user} 提供 {models}(内置提供)。可在「模型」里取消勾选,或继续使用内置。",
|
||||
"{user} doesn't work through the plugin: {error}": "{user} 无法通过插件使用:{error}",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Use the built-in again from here any time.": "{name} 已改由插件运行:{accounts},{models}。可随时在此改回内置。",
|
||||
"{name} now runs on its plugin — {accounts}, {models}.": "{name} 已改由插件运行:{accounts},{models}。",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Its editor in Providers moves it back.": "{name} 已改由插件运行:{accounts},{models}。在「供应商」中编辑它即可改回。",
|
||||
"{name} is built-in again, with its accounts": "{name} 已连同账号改回内置",
|
||||
"{n} account": "{n} 个账号",
|
||||
"Deprecated": "已弃用",
|
||||
"Some subscriptions are reached in ways their vendors' terms may not allow. So that magpie itself isn't banned over them, subscription providers are being decoupled from magpie and run by community plugins instead.": "部分订阅的接入方式可能违反厂商条款。为免 magpie 本体因此被封禁,订阅供应商正逐步移出 magpie,改由社区插件提供。",
|
||||
@@ -1481,7 +1479,7 @@ const I18N = {
|
||||
"Moving…": "正在迁移…",
|
||||
"Move": "迁移",
|
||||
"Runs {name} on this plugin in place of the built-in, with the same accounts; nothing changes if one doesn't work through it": "改由此插件运行 {name},账号不变;有账号无法使用时不做改动",
|
||||
"Going back puts every account, with the plugin's newer sign-ins, back into the built-in.": "改回时,所有账号(连同插件里更新过的登录)都会回到内置。",
|
||||
"magpie's built-in is retired, so this subscription stays on its plugin.": "magpie 的内置已下线,此订阅一直由插件运行。",
|
||||
"If an account doesn't work through the plugin, nothing changes.": "若有账号无法通过插件使用,则不做任何改动。",
|
||||
"The gateway uses this account first": "网关优先使用这个账号",
|
||||
"Routing": "路由",
|
||||
@@ -5128,7 +5126,6 @@ const I18N = {
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota. {agent} itself stays signed in as it is.": "閘道優先用第一個帳號;勾選多個時,前一個額度用完自動換下一個。{agent} 本身的登入不變。",
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota.": "閘道優先用第一個帳號;勾選多個時,前一個額度用完自動換下一個。",
|
||||
"Runs on": "執行方式",
|
||||
"Use the built-in again": "改回內建",
|
||||
"Move to the plugin": "遷移到外掛",
|
||||
"magpie's built-in · or the community {name} plugin, with the same accounts": "magpie 內建 · 也可改用社群 {name} 外掛,帳號不變",
|
||||
"The community {name} plugin, with the accounts you had here.": "社群 {name} 外掛,沿用你在這裡的帳號。",
|
||||
@@ -5141,9 +5138,8 @@ const I18N = {
|
||||
"the plugin doesn't serve {models}. Untick them under Models, or keep the built-in.": "外掛不提供 {models}。可在「模型」裡取消勾選,或繼續使用內建。",
|
||||
"the plugin doesn't serve {models} for {user}, though the built-in does. Untick them under Models, or keep the built-in.": "外掛沒有為 {user} 提供 {models}(內建提供)。可在「模型」裡取消勾選,或繼續使用內建。",
|
||||
"{user} doesn't work through the plugin: {error}": "{user} 無法透過外掛使用:{error}",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Use the built-in again from here any time.": "{name} 已改由外掛執行:{accounts},{models}。可隨時在此改回內建。",
|
||||
"{name} now runs on its plugin — {accounts}, {models}.": "{name} 已改由外掛執行:{accounts},{models}。",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Its editor in Providers moves it back.": "{name} 已改由外掛執行:{accounts},{models}。在「供應商」中編輯它即可改回。",
|
||||
"{name} is built-in again, with its accounts": "{name} 已連同帳號改回內建",
|
||||
"{n} account": "{n} 個帳號",
|
||||
"Deprecated": "已棄用",
|
||||
"Some subscriptions are reached in ways their vendors' terms may not allow. So that magpie itself isn't banned over them, subscription providers are being decoupled from magpie and run by community plugins instead.": "部分訂閱的接入方式可能違反廠商條款。為免 magpie 本體因此被封禁,訂閱供應商正逐步移出 magpie,改由社群外掛提供。",
|
||||
@@ -5165,7 +5161,7 @@ const I18N = {
|
||||
"Moving…": "正在遷移…",
|
||||
"Move": "遷移",
|
||||
"Runs {name} on this plugin in place of the built-in, with the same accounts; nothing changes if one doesn't work through it": "改由此外掛執行 {name},帳號不變;有帳號無法使用時不做改動",
|
||||
"Going back puts every account, with the plugin's newer sign-ins, back into the built-in.": "改回時,所有帳號(連同外掛裡更新過的登入)都會回到內建。",
|
||||
"magpie's built-in is retired, so this subscription stays on its plugin.": "magpie 的內建已下線,此訂閱一直由外掛執行。",
|
||||
"If an account doesn't work through the plugin, nothing changes.": "若有帳號無法透過外掛使用,則不做任何改動。",
|
||||
"The gateway uses this account first": "閘道優先使用這個帳號",
|
||||
"Routing": "路由",
|
||||
@@ -8789,7 +8785,6 @@ const I18N = {
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota. {agent} itself stays signed in as it is.": "ゲートウェイは最初のアカウントを使います。複数にチェックを入れると、前のアカウントのクォータが切れたときに次へ移ります。{agent} 自身のサインインはそのままです。",
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota.": "ゲートウェイは最初のアカウントを使います。複数にチェックを入れると、前のアカウントのクォータが切れたときに次へ移ります。",
|
||||
"Runs on": "実行方法",
|
||||
"Use the built-in again": "組み込みに戻す",
|
||||
"Move to the plugin": "プラグインに移行",
|
||||
"magpie's built-in · or the community {name} plugin, with the same accounts": "magpie の組み込み · または同じアカウントでコミュニティの {name} プラグイン",
|
||||
"The community {name} plugin, with the accounts you had here.": "コミュニティの {name} プラグイン(ここで使っていたアカウントのまま)。",
|
||||
@@ -8802,9 +8797,8 @@ const I18N = {
|
||||
"the plugin doesn't serve {models}. Untick them under Models, or keep the built-in.": "プラグインは {models} を提供していません。「モデル」でチェックを外すか、組み込みのままにしてください。",
|
||||
"the plugin doesn't serve {models} for {user}, though the built-in does. Untick them under Models, or keep the built-in.": "組み込みは {user} に {models} を提供していますが、プラグインは提供していません。「モデル」でチェックを外すか、組み込みのままにしてください。",
|
||||
"{user} doesn't work through the plugin: {error}": "{user} はプラグイン経由で動作しません:{error}",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Use the built-in again from here any time.": "{name} はプラグインで動作するようになりました — {accounts}、{models}。ここからいつでも組み込みに戻せます。",
|
||||
"{name} now runs on its plugin — {accounts}, {models}.": "{name} はプラグインで動作するようになりました — {accounts}、{models}。",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Its editor in Providers moves it back.": "{name} はプラグインで動作するようになりました — {accounts}、{models}。「プロバイダ」のエディタで元に戻せます。",
|
||||
"{name} is built-in again, with its accounts": "{name} はアカウントごと組み込みに戻りました",
|
||||
"{n} account": "{n} アカウント",
|
||||
"Deprecated": "非推奨",
|
||||
"Some subscriptions are reached in ways their vendors' terms may not allow. So that magpie itself isn't banned over them, subscription providers are being decoupled from magpie and run by community plugins instead.": "一部のサブスクリプションは、ベンダーの規約で認められていない可能性のある方法で利用されています。magpie 自体が禁止されないよう、サブスクリプションのプロバイダは magpie から切り離され、代わりにコミュニティプラグインで動作するよう移行中です。",
|
||||
@@ -8826,7 +8820,7 @@ const I18N = {
|
||||
"Moving…": "移行中…",
|
||||
"Move": "移行",
|
||||
"Runs {name} on this plugin in place of the built-in, with the same accounts; nothing changes if one doesn't work through it": "組み込みの代わりにこのプラグインで {name} を同じアカウントのまま動作させます。いずれかのアカウントがこれで動作しない場合は何も変わりません",
|
||||
"Going back puts every account, with the plugin's newer sign-ins, back into the built-in.": "戻す場合は、プラグインで更新されたサインインを含め、すべてのアカウントが組み込みに戻ります。",
|
||||
"magpie's built-in is retired, so this subscription stays on its plugin.": "magpie の組み込みは廃止されたため、このサブスクリプションはプラグインで動作し続けます。",
|
||||
"If an account doesn't work through the plugin, nothing changes.": "いずれかのアカウントがプラグイン経由で動作しない場合は、何も変更されません。",
|
||||
"The gateway uses this account first": "ゲートウェイはこのアカウントを最初に使います",
|
||||
"Routing": "ルーティング",
|
||||
@@ -12480,7 +12474,6 @@ const I18N = {
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota. {agent} itself stays signed in as it is.": "Der Zugangspunkt verwendet das erste. Haken Sie weitere an, wechselt er zum nächsten, sobald das vorherige kein Kontingent mehr hat. {agent} selbst bleibt angemeldet wie bisher.",
|
||||
"The gateway uses the first. Tick more and it moves on to the next when the one before it is out of quota.": "Der Zugangspunkt verwendet das erste. Haken Sie weitere an, wechselt er zum nächsten, sobald das vorherige kein Kontingent mehr hat.",
|
||||
"Runs on": "Läuft über",
|
||||
"Use the built-in again": "Wieder integrierte Version verwenden",
|
||||
"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",
|
||||
"The community {name} plugin, with the accounts you had here.": "Die Community-Erweiterung {name}, mit den Konten, die Sie hier hatten.",
|
||||
@@ -12493,9 +12486,8 @@ const I18N = {
|
||||
"the plugin doesn't serve {models}. Untick them under Models, or keep the built-in.": "die Erweiterung stellt {models} nicht bereit. Entfernen Sie unter Modelle die Haken oder behalten Sie die integrierte Version.",
|
||||
"the plugin doesn't serve {models} for {user}, though the built-in does. Untick them under Models, or keep the built-in.": "die Erweiterung stellt {models} für {user} nicht bereit, die integrierte Version schon. Entfernen Sie unter Modelle die Haken oder behalten Sie die integrierte Version.",
|
||||
"{user} doesn't work through the plugin: {error}": "{user} funktioniert nicht über die Erweiterung: {error}",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Use the built-in again from here any time.": "{name} läuft jetzt über seine Erweiterung — {accounts}, {models}. Von hier aus können Sie jederzeit zur integrierten Version zurückkehren.",
|
||||
"{name} now runs on its plugin — {accounts}, {models}.": "{name} läuft jetzt über seine Erweiterung — {accounts}, {models}.",
|
||||
"{name} now runs on its plugin — {accounts}, {models}. Its editor in Providers moves it back.": "{name} läuft jetzt über seine Erweiterung — {accounts}, {models}. Über seinen Editor unter Anbieter wechseln Sie zurück.",
|
||||
"{name} is built-in again, with its accounts": "{name} ist wieder integriert, mit seinen Konten",
|
||||
"{n} account": "{n} Konto",
|
||||
"Deprecated": "Veraltet",
|
||||
"Some subscriptions are reached in ways their vendors' terms may not allow. So that magpie itself isn't banned over them, subscription providers are being decoupled from magpie and run by community plugins instead.": "Manche Abos werden auf eine Weise genutzt, die die Bedingungen ihrer Anbieter möglicherweise nicht erlauben. Damit magpie selbst deswegen nicht gesperrt wird, werden Abo-Anbieter von magpie entkoppelt und stattdessen von Community-Erweiterungen betrieben.",
|
||||
@@ -12517,7 +12509,7 @@ const I18N = {
|
||||
"Moving…": "Wird umgezogen…",
|
||||
"Move": "Umziehen",
|
||||
"Runs {name} on this plugin in place of the built-in, with the same accounts; nothing changes if one doesn't work through it": "Lässt {name} statt über die integrierte Version über diese Erweiterung laufen, mit denselben Konten; funktioniert eines nicht darüber, ändert sich nichts",
|
||||
"Going back puts every account, with the plugin's newer sign-ins, back into the built-in.": "Beim Zurückwechseln kommen alle Konten samt den neueren Anmeldungen aus der Erweiterung zurück in die integrierte Version.",
|
||||
"magpie's built-in is retired, so this subscription stays on its plugin.": "magpies integrierte Version ist eingestellt, daher bleibt dieses Abo bei seiner Erweiterung.",
|
||||
"If an account doesn't work through the plugin, nothing changes.": "Funktioniert ein Konto nicht über die Erweiterung, ändert sich nichts.",
|
||||
"The gateway uses this account first": "Der Zugangspunkt verwendet dieses Konto zuerst",
|
||||
"Routing": "Weiterleitung",
|
||||
|
||||
+11
-11
@@ -900,12 +900,15 @@ func failMove(rw http.ResponseWriter, err error) {
|
||||
_ = json.NewEncoder(rw).Encode(map[string]any{"error": err.Error(), "why": provider.WhyOf(err)})
|
||||
}
|
||||
|
||||
// moveProvider and moveBackProvider are provider.Move and MoveBack, for
|
||||
// tests to stand in for.
|
||||
// errRetired answers a move back to a built-in subscription, which magpie
|
||||
// no longer runs: its plugin does.
|
||||
var errRetired = errors.New("magpie's built-in subscriptions are retired: their community plugins run them")
|
||||
|
||||
// moveProvider and adoptProvider are provider.Move and Adopt, for tests
|
||||
// to stand in for.
|
||||
var (
|
||||
moveProvider = provider.Move
|
||||
moveBackProvider = provider.MoveBack
|
||||
adoptProvider = provider.Adopt
|
||||
moveProvider = provider.Move
|
||||
adoptProvider = provider.Adopt
|
||||
)
|
||||
|
||||
// moveContext keeps a move going though the page that asked for it goes
|
||||
@@ -1241,12 +1244,9 @@ func providerRoutes(mux *http.ServeMux, w Windows) {
|
||||
return
|
||||
}
|
||||
case "moveback":
|
||||
ctx, cancel := moveContext(r)
|
||||
defer cancel()
|
||||
if err := moveBackProvider(ctx, in.ID); err != nil {
|
||||
fail(rw, err)
|
||||
return
|
||||
}
|
||||
// the built-ins are retired: there is no going back to one
|
||||
fail(rw, errRetired)
|
||||
return
|
||||
case "quiet":
|
||||
// a removed account's "Add it back" line, dismissed (#116)
|
||||
if err := provider.QuietAccount(in.ID); err != nil {
|
||||
|
||||
@@ -21,8 +21,8 @@ func TestMoveOutlivesRequest(t *testing.T) {
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
t.Setenv("PATH", t.TempDir())
|
||||
oldMove, oldBack, oldAdopt := moveProvider, moveBackProvider, adoptProvider
|
||||
t.Cleanup(func() { moveProvider, moveBackProvider, adoptProvider = oldMove, oldBack, oldAdopt })
|
||||
oldMove, oldAdopt := moveProvider, adoptProvider
|
||||
t.Cleanup(func() { moveProvider, adoptProvider = oldMove, oldAdopt })
|
||||
var got []string
|
||||
check := func(ctx context.Context, id string) error {
|
||||
_, deadline := ctx.Deadline()
|
||||
@@ -33,16 +33,16 @@ func TestMoveOutlivesRequest(t *testing.T) {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
moveProvider, moveBackProvider, adoptProvider = check, check, check
|
||||
moveProvider, adoptProvider = check, check
|
||||
mux := http.NewServeMux()
|
||||
providerRoutes(mux, nil)
|
||||
for _, action := range []string{"move", "moveback", "adopt"} {
|
||||
for _, action := range []string{"move", "adopt"} {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel() // the page went away
|
||||
r := httptest.NewRequest("POST", "/api/provider/"+action, strings.NewReader(`{"id":"zed"}`)).WithContext(ctx)
|
||||
mux.ServeHTTP(httptest.NewRecorder(), r)
|
||||
}
|
||||
if strings.Join(got, ",") != "zed: going,zed: going,zed: going" {
|
||||
if strings.Join(got, ",") != "zed: going,zed: going" {
|
||||
t.Fatalf("%v", got)
|
||||
}
|
||||
}
|
||||
@@ -86,3 +86,24 @@ func TestMoveTakesEditorPicks(t *testing.T) {
|
||||
t.Fatalf("the move saw the picks %v", seen)
|
||||
}
|
||||
}
|
||||
|
||||
// The built-ins are retired: a move back is refused, and nothing is moved.
|
||||
func TestMoveBackRefused(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
|
||||
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
|
||||
t.Setenv("PATH", t.TempDir())
|
||||
oldMove, oldAdopt := moveProvider, adoptProvider
|
||||
t.Cleanup(func() { moveProvider, adoptProvider = oldMove, oldAdopt })
|
||||
moved := false
|
||||
moveProvider = func(context.Context, string) error { moved = true; return nil }
|
||||
adoptProvider = moveProvider
|
||||
mux := http.NewServeMux()
|
||||
providerRoutes(mux, nil)
|
||||
rec := httptest.NewRecorder()
|
||||
mux.ServeHTTP(rec, httptest.NewRequest("POST", "/api/provider/moveback", strings.NewReader(`{"id":"zed"}`)))
|
||||
if rec.Code < 400 || !strings.Contains(rec.Body.String(), "retired") || moved {
|
||||
t.Fatalf("%d %s moved=%v", rec.Code, rec.Body.String(), moved)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
// editor says which runs it, and "Move to the plugin" says what it is doing
|
||||
// on the button. A move that fails says why right under it, in the
|
||||
// reader's language, and the button becomes "Try again"; one that goes
|
||||
// through turns the field over in the editor, still open where it was, and
|
||||
// "Use the built-in again" posts provider/moveback. The add sheet no longer
|
||||
// through turns the field over in the editor, still open where it was, with
|
||||
// no way back: magpie's built-in is retired. The add sheet no longer
|
||||
// offers the built-in Zed once it runs on its plugin, and its editor shows
|
||||
// no plugin:// endpoints to test. The Plugins tab, opened as the page
|
||||
// (?view=plugins), shows its market and offers Zed's accounts on the
|
||||
@@ -72,12 +72,12 @@ function serve(lang, posts) {
|
||||
|
||||
const L = {
|
||||
en: { runs: "Runs on", line: "Zed's built-in subscription is deprecated", look: "Review the move",
|
||||
move: "Move to the plugin", busy: "Installing the plugin and checking each account…", again: "Try again", back: "Use the built-in again",
|
||||
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: "It stays built-in: magpie couldn't reach npm to install the plugin. Check the network or proxy, then try again.",
|
||||
onPlugin: "The community Zed plugin", builtin: "magpie's built-in · or the community Zed plugin", done: "Zed now runs on its plugin — 2 accounts, 1 model.",
|
||||
subs: "Subscriptions", card: "Move", own: "Zed itself stays signed in as it is." },
|
||||
zh: { runs: "运行方式", line: "Zed 的内置订阅已弃用", look: "查看迁移",
|
||||
move: "迁移到插件", busy: "正在安装插件并逐个检查账号…", again: "重试", back: "改回内置",
|
||||
move: "迁移到插件", busy: "正在安装插件并逐个检查账号…", again: "重试", retired: "magpie 的内置已下线,此订阅一直由插件运行。",
|
||||
failed: "仍使用内置:无法连接 npm 安装插件,请检查网络或代理后重试。",
|
||||
onPlugin: "社区 Zed 插件", builtin: "magpie 内置 · 也可改用社区 Zed 插件", done: "Zed 已改由插件运行:2 个账号,1 个模型。",
|
||||
subs: "订阅", card: "迁移", own: "Zed 本身的登录不变。" },
|
||||
@@ -87,7 +87,7 @@ const launch = (engine) => engine === "webkit" ? webkit.launch() : chromium.laun
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const lang of ["en", "zh"]) {
|
||||
test(`${engine} ${lang}: a built-in subscription moves to its plugin and back`, async (t) => {
|
||||
test(`${engine} ${lang}: a built-in subscription moves to its plugin for good`, async (t) => {
|
||||
const w = L[lang];
|
||||
const browser = await launch(engine);
|
||||
t.after(() => browser.close());
|
||||
@@ -167,13 +167,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
|
||||
// tried again, it goes through: the same editor, turned over
|
||||
await press();
|
||||
const back = ed.locator(".move button", { hasText: w.back });
|
||||
await back.waitFor();
|
||||
await ed.locator(".hint", { hasText: w.retired }).waitFor();
|
||||
assert.equal(await ed.locator(".move button").count(), 0, "a moved subscription still offers a way back");
|
||||
assert.equal(await page.locator("#modal .editor").count(), 1, "the editor closed");
|
||||
assert.ok((await ed.innerText()).includes(w.onPlugin), "doesn't say the plugin runs it");
|
||||
// as the built-in said: the agent's own sign-in is where it was
|
||||
assert.ok((await ed.innerText()).includes(w.own), "the moved Zed no longer says Zed stays signed in");
|
||||
assert.equal(await why.count() && await why.isVisible(), false, "the failure is still said");
|
||||
assert.ok(!(await why.count()) || !(await why.isVisible()), "the failure is still said");
|
||||
assert.equal(await body.evaluate((e) => e.scrollTop), top, "the move moved the editor");
|
||||
assert.equal(await ed.locator("details.advanced").evaluate((d) => d.open), true, "the move shut Advanced");
|
||||
assert.ok((await page.locator("#status").innerText()).startsWith(w.done), "no toast saying what moved");
|
||||
@@ -191,10 +191,6 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await sheet.locator('.tile[data-pick="Zed"]').count(), 1);
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
await page.locator(".row.provider", { hasText: "Zed" }).click();
|
||||
await back.click();
|
||||
for (let i = 0; i < 50 && posts.length < 3; i++) await page.waitForTimeout(50);
|
||||
assert.deepEqual(posts.map((p) => p.path), ["/api/provider/move", "/api/provider/move", "/api/provider/moveback"]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
|
||||
@@ -51,13 +51,14 @@ import (
|
||||
const (
|
||||
MoveMoving = "moving" // under way, or cut short (put back at the next try)
|
||||
MovePlugin = "plugin" // the plugin has the id
|
||||
MovedBack = "back" // the user moved it back: it stays built-in
|
||||
MovedBack = "back" // moved back to the built-in: moved again by itself, unless Left
|
||||
MoveFailed = "failed" // the last try failed: the built-in carries on
|
||||
)
|
||||
|
||||
// Retiring are the built-ins magpie moves onto their plugins by itself,
|
||||
// at start-up; the rest move only when the user asks.
|
||||
var Retiring = []string{}
|
||||
// retiring are the built-ins magpie moves onto their plugins by itself:
|
||||
// every one with a mover, since each built-in is being retired (the owner,
|
||||
// 10-16: 陆续把内置Provider下线掉). A tests' list stands in for it.
|
||||
var retiring = MovableIDs
|
||||
|
||||
// moveRetry is how long a failed move waits before it is tried again.
|
||||
const moveRetry = 6 * time.Hour
|
||||
@@ -77,6 +78,9 @@ type Migration struct {
|
||||
// Installed is whether the move installed the plugin: going back takes
|
||||
// it away again when it serves nothing else.
|
||||
Installed bool `json:"installed,omitempty"`
|
||||
// Left is a move back made by removing the plugin or turning it off:
|
||||
// the user's own choice, which no move undoes by itself.
|
||||
Left bool `json:"left,omitempty"`
|
||||
// Host is the built-in's API host, which the plugin's provider shows.
|
||||
Host string `json:"host,omitempty"`
|
||||
// Why is a failed move's reason, for the page to say in the user's
|
||||
@@ -1090,7 +1094,7 @@ func moveBack(ctx context.Context, id string, tidy bool) error {
|
||||
}
|
||||
}
|
||||
if err := setMigration(id, func(m *Migration) {
|
||||
*m = Migration{State: MovedBack, Package: mv.pkg, At: time.Now().UTC().Truncate(time.Second)}
|
||||
*m = Migration{State: MovedBack, Package: mv.pkg, At: time.Now().UTC().Truncate(time.Second), Left: !tidy}
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1139,20 +1143,21 @@ func pluginOn(id string) map[string]bool {
|
||||
}
|
||||
|
||||
// MoveRetiring moves the built-ins being retired that have accounts, at
|
||||
// start-up: once, or again moveRetry after one failed. One the user moved
|
||||
// back stays.
|
||||
// start-up: once, or again moveRetry after one failed. One moved back is
|
||||
// moved again (the way back is gone from the editor and the command line),
|
||||
// except one moved back by the user taking its plugin away or off.
|
||||
func MoveRetiring(ctx context.Context) map[string]error {
|
||||
if settings.AccountDiscoveryOff() {
|
||||
return nil
|
||||
}
|
||||
out := map[string]error{}
|
||||
for _, id := range Retiring {
|
||||
for _, id := range retiring() {
|
||||
m, ok := MigrationOf(id)
|
||||
switch {
|
||||
case ok && m.State == MovePlugin:
|
||||
tidyMoved(id)
|
||||
continue
|
||||
case ok && m.State == MovedBack:
|
||||
case ok && m.State == MovedBack && m.Left:
|
||||
continue
|
||||
case ok && m.State == MoveFailed && time.Since(m.At) < moveRetry:
|
||||
continue
|
||||
|
||||
@@ -268,11 +268,11 @@ func TestMoveToPlugin(t *testing.T) {
|
||||
}
|
||||
}
|
||||
loginsMu.Unlock()
|
||||
// the user moved it back: it isn't moved again by itself
|
||||
Retiring = []string{"fakeco"}
|
||||
t.Cleanup(func() { Retiring = nil })
|
||||
if errs := MoveRetiring(ctx); len(errs) != 0 || Moved("fakeco") {
|
||||
t.Fatalf("MoveRetiring moved one moved back: %v", errs)
|
||||
// the built-in is retired: one moved back is moved again by itself
|
||||
retiring = func() []string { return []string{"fakeco"} }
|
||||
t.Cleanup(func() { retiring = MovableIDs })
|
||||
if errs := MoveRetiring(ctx); errs["fakeco"] != nil || !Moved("fakeco") {
|
||||
t.Fatalf("MoveRetiring left one moved back built-in: %v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,8 +295,8 @@ func TestMoveCutShort(t *testing.T) {
|
||||
inUse := []string{"fake-1"}
|
||||
fakeMover(t, &inUse)
|
||||
movers["fakeco"].pkg = abs
|
||||
Retiring = []string{"fakeco"}
|
||||
t.Cleanup(func() { Retiring = nil })
|
||||
retiring = func() []string { return []string{"fakeco"} }
|
||||
t.Cleanup(func() { retiring = MovableIDs })
|
||||
loginsMu.Lock()
|
||||
_ = writeLogins([]savedLogin{fakeLogin("a@fake", "rot-a", false, true)})
|
||||
loginsMu.Unlock()
|
||||
@@ -600,6 +600,12 @@ func TestReleasePlugin(t *testing.T) {
|
||||
if op == "remove" && len(plugin.Load().Plugins) != 0 {
|
||||
t.Fatalf("not removed: %+v", plugin.Load().Plugins)
|
||||
}
|
||||
// the user took the plugin away: no move undoes that by itself
|
||||
retiring = func() []string { return []string{"fakeco"} }
|
||||
t.Cleanup(func() { retiring = MovableIDs })
|
||||
if errs := MoveRetiring(ctx); len(errs) != 0 || Moved("fakeco") {
|
||||
t.Fatalf("moved again onto a plugin the user took %s: %v", op, errs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user