diff --git a/packages/devin/images.test.mjs b/packages/devin/images.test.mjs index cd5f1c1..17f2a84 100644 --- a/packages/devin/images.test.mjs +++ b/packages/devin/images.test.mjs @@ -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) }) diff --git a/packages/devin/index.mjs b/packages/devin/index.mjs index b490a5b..731d3b5 100644 --- a/packages/devin/index.mjs +++ b/packages/devin/index.mjs @@ -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)])) }, }, diff --git a/packages/devin/package.json b/packages/devin/package.json index 6bf80da..d70cfff 100644 --- a/packages/devin/package.json +++ b/packages/devin/package.json @@ -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",