From 42acd1843509c02fe335e022d2da0d1413b928d7 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 15 Nov 2026 14:03:43 +0800 Subject: [PATCH] doubao-work 0.1.13: the built-in models, before the menu is read, are marked fell back MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With Doubao closed or the menu read failed, models() served the built-in three (or an older cache) unmarked. Archivemylife on X (agy-cli): "配置后报存提示成功,再打开还是全部都启用". The same class as agy-cli 0.1.61: a list that isn't the account's own, handed back as if it were, makes magpie relist on it and drop the models the user picked that aren't in it. Marked with Symbol.for("magpie.fellBack"), magpie's plugin host keeps the last good list (keepListed) and the picks. Run (mote-run, HOME=mktemp -d): doubao-work.test.mjs 59 pass on this change: all pass. Red on the old code with the new test: "models() and usage never start Doubao" fails. Not tried: a real account. --- packages/doubao-work/doubao-work.test.mjs | 7 ++++++- packages/doubao-work/index.mjs | 7 ++++++- packages/doubao-work/package.json | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/doubao-work/doubao-work.test.mjs b/packages/doubao-work/doubao-work.test.mjs index 8df7331..31b0326 100644 --- a/packages/doubao-work/doubao-work.test.mjs +++ b/packages/doubao-work/doubao-work.test.mjs @@ -863,6 +863,9 @@ test("models() and usage never start Doubao: they read from a window already ope const p = I.createPlugin({ doubao: d }) const listed = await p.provider.models({}, {}) expect(Object.keys(listed).length).toBeGreaterThan(0) + // the built-in three aren't the account's list: magpie keeps the one it + // had, and the models picked from it (Archivemylife on X, agy-cli's sibling) + expect(listed[Symbol.for("magpie.fellBack")]).toBe(true) const u = await p.auth.usage(async () => ({})) expect(u.signIn).toBe("kept") expect(u.error).toContain("没有打开") @@ -870,7 +873,9 @@ test("models() and usage never start Doubao: they read from a window already ope // open, the same window is read for both app.running = async () => 1 d.readAt = 0 - expect(Object.values(await p.provider.models({}, {})).map((m) => m.name)).toEqual(WORK) + const read = await p.provider.models({}, {}) + expect(Object.values(read).map((m) => m.name)).toEqual(WORK) + expect(read[Symbol.for("magpie.fellBack")]).toBeUndefined() expect((await p.auth.usage(async () => ({}))).error).toBeUndefined() expect(started).toBe(0) fs.rmSync(dir, { recursive: true, force: true }) diff --git a/packages/doubao-work/index.mjs b/packages/doubao-work/index.mjs index e95a3a4..ac13a69 100644 --- a/packages/doubao-work/index.mjs +++ b/packages/doubao-work/index.mjs @@ -79,7 +79,12 @@ export function createPlugin({ doubao = new Doubao(), newId, pick = choose } = { // a list never read from the menu is read now, so an account that // signed in before the plugin read menus isn't left with three if (typeof doubao?.ensureList === "function") await doubao.ensureList({ signal: AbortSignal.timeout(25000) }) - return models(modelTable(doubao)) + const out = models(modelTable(doubao)) + // a menu still never read (Doubao closed, or the read failed) gives + // the built-in three or an older cache: not the account's list, so + // magpie keeps the one it had and the models picked from it + if (typeof doubao?.modelList !== "function" || doubao.tableAt === 0) out[Symbol.for("magpie.fellBack")] = true + return out }, }, auth: { diff --git a/packages/doubao-work/package.json b/packages/doubao-work/package.json index 7bf6b44..8a346dd 100644 --- a/packages/doubao-work/package.json +++ b/packages/doubao-work/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-doubao-work-auth", - "version": "0.1.12", + "version": "0.1.13", "type": "module", "main": "./opencode.mjs", "files": [