From 73d1f898221c4300f3b677076f8936eafc892272 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 15 Nov 2026 14:03:43 +0800 Subject: [PATCH] inkstone 0.1.6: the declared models kept after a failed catalogue read are marked fell back MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A failed /v1/models read returned the declared set; marked on a copy (non-enumerable, so the list itself is unchanged). 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): api.test.mjs 15 pass on this change: all pass. Red on the old code with the new test: "a catalogue read that fails keeps the declared models" fails. Not tried: a real account. --- packages/inkstone/api.test.mjs | 4 ++++ packages/inkstone/index.mjs | 4 +++- packages/inkstone/package.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/inkstone/api.test.mjs b/packages/inkstone/api.test.mjs index a03482b..af49201 100644 --- a/packages/inkstone/api.test.mjs +++ b/packages/inkstone/api.test.mjs @@ -48,6 +48,7 @@ test("the listing is the key's live set intersected with the public metadata", a expect(models["glm-5.3"].reasoning).toBe(true) expect(models["Agents-A1"].capabilities.input.image).toBe(true) expect(models["glm-5.3"].variants).toBeUndefined() + expect(models[Symbol.for("magpie.fellBack")]).toBeUndefined() // the magpie-only price markers reach provider.models too expect(models["glm-5.3"].rate).toBe(8) expect(models["glm-5.3"].free).toBeUndefined() @@ -91,6 +92,9 @@ test("a catalogue read that fails keeps the declared models", async () => { const given = { "glm-5.3": {} } const got = await p.provider.models({ id: "intern-inkstone", models: given }, { auth }) expect(got).toEqual(given) + // and says they aren't the account's list, so magpie keeps the one it + // had and the models picked from it (Archivemylife on X, agy-cli's sibling) + expect(got[Symbol.for("magpie.fellBack")]).toBe(true) }) test("an account with no auth yet still sees the bootstrap list", async () => { diff --git a/packages/inkstone/index.mjs b/packages/inkstone/index.mjs index 9eb23d6..4b42c85 100644 --- a/packages/inkstone/index.mjs +++ b/packages/inkstone/index.mjs @@ -469,7 +469,9 @@ export async function InkStoneAuthPlugin({ client, magpie } = {}, options = {}) // A refused key calls nothing; a failed read keeps the known set. if (e?.refused || e?.status === 401 || e?.status === 403) return {} log("warn", `inkstone: keeping the declared models (${e?.message ?? e})`) - return declared + // not the account's list: magpie keeps the one it had, and the + // models picked from it, over these (Symbol.for("magpie.fellBack")) + return Object.defineProperty({ ...declared }, Symbol.for("magpie.fellBack"), { value: true }) } }, }, diff --git a/packages/inkstone/package.json b/packages/inkstone/package.json index 4fdea70..c2385da 100644 --- a/packages/inkstone/package.json +++ b/packages/inkstone/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-inkstone-auth", - "version": "0.1.5", + "version": "0.1.6", "description": "Intern InkStone (书生·端砚) TokenPlan in OpenCode and magpie: one console sign-in gives the ink-credit balance, the 5-hour and 7-day windows and the credit packs, and (with an API key) the plan's models for chat", "type": "module", "main": "./opencode.mjs",