marchen_cc on X: 「从文件导入账号」 took no WorkBuddy sign-in file. The cause
was not WorkBuddy's: magpie's import reached only built-ins (Codex,
Claude, Antigravity, Factory), and a plugin had no way to say it could
read a file. This adds that for every plugin subscription:
- A plugin's auth may have import(texts, {signal}), returning sign-in
results, with importFrom (and importFroms by language) saying which
file to choose. The host's importFiles op keeps each one as a sign-in
is kept (keptAs, saved under signInKey, settled), so an account
already there comes back "updated"; it is cancellable (signInSteps)
and takes at most 100.
- /api/signin/import and `magpie accounts import <plugin> <files>` go
to provider.ImportPluginFiles when PluginImportable(id); the editor's
「从文件导入账号…」 row and the import sheet show for such a plugin, in
its own words (importSay), moved subscriptions included (subOf).
- docs/subsystems/provider-plugins.md: "Accounts from a file".
- WorkBuddy's mover min goes to 0.2.32, which reads the desktop app's
.info sign-in or a JSON credential, and sends a cloud-hosted
enterprise account (*.sso.copilot.tencent.com, *.copilot.qq.com,
*.sso.codebuddy.cn, iOA apart) to its enterprise's address (emilochen
on X), published and checked with npm view --prefer-online.
- TestCoreScriptBudget +468 for the import branch, packed to one
statement. importSay is read as the Providers rows draw, so it has
no lazy page; nothing else was moved out (#2710). The budget's
arithmetic was checked over this tree: 1,267,762, at the new cap.
Run on mote (mica's disk is full; mote over its cores) at this change
on 3f6b1b0c9; ac1702c33 (the library plugin and its GUI test, no core
script) landed after, and the core budget's arithmetic was redone at
this head:
gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows on
internal/{gui,plugin,provider,cli}; go test -count=1 of those four:
all ok. GUI (chromium + webkit, en and zh): plugin-import,
login-import, factory-key, plugin-moved-signin, i18n-keys: 23 pass, 1 fail: i18n-keys "a plugin's words are its own",
memory_mcp.go's "No folder", red on main since 72facf72e (#6422).
Plugins repo: workbuddy import.test.mjs 6 of 6, bun scripts/check.mjs
ok, root bun test 8534 pass / 1 fail (agy-cli smoke under load, green on a rerun: 8535 pass, 0 fail;
unrelated, plugins #1070).
Broken by hand: without the host's importFiles handler,
TestPluginImportFiles goes red; without importable in pluginSubs,
plugin-import.test.cjs goes red ("WorkBuddy lists no import").
Not tried: a real WorkBuddy desktop .info file or a real enterprise
account on a cloud-hosted domain; the fixtures follow WorkBuddy's own
client source. Not tried on Windows or Linux beyond vet.
16 lines
879 B
JavaScript
16 lines
879 B
JavaScript
// A plugin that takes accounts from a file (magpie's auth.import): each
|
|
// line "who:refresh" is one account; "bad" lines are refused.
|
|
export const ImporterPlugin = async () => ({
|
|
auth: {
|
|
provider: "importer",
|
|
importFrom: "Choose the Importer app's accounts file",
|
|
importFroms: { zh: "选择 Importer 的账号文件" },
|
|
methods: [{ type: "oauth", label: "Browser", authorize: async () => ({ url: "https://importer.invalid", method: "code", callback: async () => ({ type: "failed" }) }) }],
|
|
import: async (texts) => texts.flatMap((t) => t.split("\n").filter(Boolean).map((line) => {
|
|
const [who, refresh] = line.split(":")
|
|
if (who === "bad") return { type: "failed", error: "Importer refused it", accountId: "bad" }
|
|
return { type: "success", refresh, access: "a-" + refresh, expires: Date.now() + 3600e3, accountId: who }
|
|
})),
|
|
},
|
|
})
|