inkstone 0.1.6: the declared models kept after a failed catalogue read are marked fell back
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.
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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 })
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user