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": [