devin 0.1.42: the snapshot list, served when Devin can't be asked, is marked fell back

When neither GetCliModelConfigs nor the devin CLI named the account's models, the models hook served the snapshot list (with images) 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): images.test.mjs 5 pass on this change: all pass.
Red on the old code with the new test: "when Devin can't be asked" fails (fellBack undefined).
Not tried: a real account.
This commit is contained in:
yetone
2026-11-15 14:03:54 +08:00
parent e4c825b554
commit 6c6677d0f3
3 changed files with 15 additions and 2 deletions
+4
View File
@@ -102,6 +102,7 @@ test("an account's list without the CLI takes what Devin says of images now", as
// Devin's word now over the snapshot's
expect(got["deepseek-v4-flash"].capabilities.input.image).toBe(true)
expect(got["glm-5.2"].capabilities.input.image).toBe(false)
expect(got[Symbol.for("magpie.fellBack")]).toBeUndefined()
})
test("when Devin can't be asked, the list takes the snapshot's word", async () => {
@@ -111,4 +112,7 @@ test("when Devin can't be asked, the list takes the snapshot's word", async () =
const got = await (await DevinAuthPlugin()).provider.models({ models: given }, { auth: { type: "api", key: "devin-key" } })
expect(got["swe-2"].capabilities).toEqual({ attachment: true, input: { text: true, image: true } })
expect(withImages(given, [{ id: "swe-2" }])).toEqual(given)
// the snapshot isn'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(got[Symbol.for("magpie.fellBack")]).toBe(true)
})
+10 -1
View File
@@ -605,6 +605,12 @@ function runtimeModel(m) {
// withImages is a list of models with what entries (listed's) say of their
// images on them; a model they say nothing of is left as it was.
// fellBack marks a list that isn't the account's own (magpie's plugin
// host reads Symbol.for("magpie.fellBack"))
function fellBack(models) {
return Object.assign(models, { [Symbol.for("magpie.fellBack")]: true })
}
function withImages(models, entries) {
const by = new Map(entries.map((m) => [m.id, m.image]))
return Object.fromEntries(
@@ -3292,7 +3298,10 @@ export async function DevinAuthPlugin({ client, magpie } = {}, options = {}) {
const images = await imagesFor(key, server)
const { free, prices } = await configsFor(key, server)
const families = await ownFamilies(key, server)
if (!families) return withImages(provider.models, listed(familiesOf(SNAPSHOT), Object.keys(provider?.models ?? {}), images))
// neither Devin nor the CLI named the account's models: the list
// is the snapshot's, so magpie keeps the account's last good list
// (and the models the user picked from it) over this one
if (!families) return fellBack(withImages(provider.models, listed(familiesOf(SNAPSHOT), Object.keys(provider?.models ?? {}), images)))
return Object.fromEntries(listed(families, Object.keys(provider?.models ?? {}), images, free, prices).map((m) => [m.id, runtimeModel(m)]))
},
},
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-devin-auth",
"version": "0.1.41",
"version": "0.1.42",
"description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie",
"type": "module",
"main": "./index.mjs",