Files
plugins/packages/devin/images.test.mjs
T
yetone 95f7b51737 devin 0.1.15: every account's model list is Devin's own for its token, so Gemini 4 Argon is listed on Windows and without the CLI (#115)
On Windows the devin CLI reads %APPDATA%\devin\ whatever folder it is
given (#17), so cliAnswersFor turned it away for every account before
looking at whose sign-in it reads, and an account without the CLI never
asked at all. Both kept the 2026-09-30 SNAPSHOT, which has no Gemini 4
Argon; moving a built-in Devin with it ticked then failed with "the
plugin doesn't serve Gemini 4 Argon" (NieiR).

The list now comes from GetCliModelConfigs, asked with the account's
token (the call the plugin already made for images): its configs carry
each model's label, context (18), output (model_info 13), family uid
(model_info 23) and family label (30.1). Read over Devin's real response
for the owner's account, parseConfigFamilies gives exactly the 52
families and 262 variants `devin models list --format json` prints, in
its order, less Adaptive and Fusion. When Devin can't be asked, the CLI's
list is used if the CLI names the account Devin names the token's, even
when it reads its own folder (the Windows case); else SNAPSHOT, now
refreshed from the CLI (Gemini 4 Argon and Claude Haiku 5.5 added,
Inkling and Claude Sonnet 4.5 kept for the accounts still offered them).

Run:
- TMPDIR/HOME in a scratch dir, bun test packages/devin: 54 pass, 0 fail.
  With index.mjs put back to 0.1.14, the 4 new identity tests fail
  (parseConfigFamilies missing; familiesFor without gemini-4-argon;
  "models list" never run for a same-account CLI reading its own folder;
  provider.models without gemini-4-argon).
- bun scripts/check.mjs devin passes.
- Real account (owner's Devin, sandbox HOME, no devin CLI on PATH):
  provider.models gave 85 models with gemini-4-argon (1048576/1000000)
  and claude-haiku-5-5; 0.1.14 gave the declared list only.
Not tried: the Windows box itself; the new path doesn't run the CLI.
2026-10-14 15:57:04 +08:00

115 lines
6.0 KiB
JavaScript

// Which models take images is what Devin tells its CLI's model picker
// (GetCliModelConfigs), as magpie's built-in asks it (devin_images.go):
// swe-2 was said to take none, models.dev not knowing Devin's own ids, and
// agents dropped its images (面条 on magpie's Discord).
import { afterEach, expect, test } from "bun:test"
import { existsSync, mkdtempSync, realpathSync, rmSync } from "node:fs"
import { join } from "node:path"
import { homedir, tmpdir } from "node:os"
import { DevinAuthPlugin, _internal } from "./index.mjs"
const real = globalThis.fetch
const path = process.env.PATH
afterEach(() => {
globalThis.fetch = real
if (process.env.PATH !== path) rmSync(process.env.PATH, { recursive: true, force: true })
process.env.PATH = path
_internal.forgetSaid()
})
const { PB, parseModelConfigs, listed, familiesOf, SNAPSHOT, SNAPSHOT_IMAGES, withImages, runtimeModel, configModel } = _internal
const sandboxed = () => {
if (![tmpdir(), realpathSync(tmpdir())].some((t) => homedir().startsWith(t))) throw new Error("run with HOME=$(mktemp -d) bun test")
}
// withoutCli takes the devin CLI out of reach: the plugin finds it on PATH
// (and in ~/.local/bin, which the sandboxed HOME leaves empty), so a machine
// with the CLI installed would otherwise take the CLI's path
const withoutCli = () => {
sandboxed()
process.env.PATH = mkdtempSync(join(tmpdir(), "no-devin-"))
for (const p of ["/usr/local/bin/devin", "/opt/homebrew/bin/devin"]) if (existsSync(p)) throw new Error(p + " is the devin CLI: these tests need a machine without it there")
}
// configs is a GetCliModelConfigsResponse naming each id, with
// supports_images set where it is true (proto3 leaves a false one out),
// and the id's family as SNAPSHOT has it (model_info's family uid, the
// family metadata's label), as Devin's own response has them
const configs = (said) => {
const out = new PB()
for (const [id, images] of Object.entries(said)) {
const c = new PB().str(1, "label " + id)
if (images) c.varint(5, 1)
const fam = SNAPSHOT.find(([, , , vs]) => vs.some(([v]) => v === id))
if (fam) c.bytes(23, new PB().str(23, fam[0]).done()).bytes(30, new PB().str(1, fam[1]).done())
out.bytes(1, c.str(22, id).done())
}
return out.done()
}
test("GetCliModelConfigs is read for each model's supports_images", () => {
expect(parseModelConfigs(configs({ "swe-2-high": true, "glm-5-2": false }))).toEqual({ "swe-2-high": true, "glm-5-2": false })
expect(parseModelConfigs(new Uint8Array())).toBe(null)
})
test("swe-2 and swe-1.7 take images in the list a new account is given, GLM and DeepSeek V4 Flash don't", async () => {
sandboxed()
const config = {}
await (await DevinAuthPlugin()).config(config)
const ms = config.provider.devin.models
for (const id of ["swe-2", "swe-1.7", "swe-1.7-lightning", "kimi-k3", "gpt-6-1-sol"]) {
expect([id, ms[id].attachment, ms[id].modalities.input]).toEqual([id, true, ["text", "image"]])
}
for (const id of ["glm-5.2", "deepseek-v4-flash", "inkling"]) {
expect([id, ms[id].attachment, ms[id].modalities.input]).toEqual([id, false, ["text"]])
}
})
test("a family takes images when every variant Devin named says so, a variant as it says itself", () => {
const fs = familiesOf(SNAPSHOT)
const images = { ...SNAPSHOT_IMAGES, "swe-2-high": true, "swe-2-max": true, "swe-2-medium": false }
const ms = Object.fromEntries(listed(fs, ["swe-2-medium"], images).map((m) => [m.id, m]))
// its variants disagree: the family is Devin's word for none of them
expect(ms["swe-2"].image).toBe(undefined)
expect(ms["swe-2-medium"].image).toBe(false)
expect(runtimeModel(ms["swe-2-medium"]).capabilities.input.image).toBe(false)
expect(ms["swe-1.7"].image).toBe(true)
expect(configModel(ms["swe-1.7"]).modalities.input).toEqual(["text", "image"])
})
test("an account's list without the CLI takes what Devin says of images now", async () => {
withoutCli()
const asked = []
globalThis.fetch = async (url, init) => {
asked.push({ url: String(url), headers: init.headers, body: new Uint8Array(init.body) })
return new Response(configs({ "swe-2-high": true, "swe-2-medium": true, "swe-2-max": true, "glm-5-2": false, "deepseek-v4-flash-high": true, "deepseek-v4-flash-max": true }))
}
const hooks = await DevinAuthPlugin()
const config = {}
await hooks.config(config)
const given = Object.fromEntries(
Object.entries(config.provider.devin.models).map(([id, m]) => [id, { id, capabilities: { attachment: m.attachment, input: { text: true, image: m.modalities.input.includes("image") } } }]),
)
// what models.dev would say, before this: no images for swe-2
given["swe-2"].capabilities = { attachment: false, input: { text: true, image: false } }
given["not-devins"] = { id: "not-devins", capabilities: { attachment: false, input: { text: true, image: false } } }
const got = await hooks.provider.models({ models: given }, { auth: { type: "api", key: "devin-key" } })
expect(asked[0].url).toBe("https://server.codeium.com/exa.api_server_pb.ApiServerService/GetCliModelConfigs")
expect(asked[0].headers).toEqual({ "Content-Type": "application/proto", "Connect-Protocol-Version": "1" })
expect(new TextDecoder().decode(asked[0].body)).toContain("devin-key")
expect(got["swe-2"].capabilities).toMatchObject({ attachment: true, input: { text: true, image: true } })
// 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)
})
test("when Devin can't be asked, the list takes the snapshot's word", async () => {
withoutCli()
globalThis.fetch = async () => new Response("", { status: 503 })
const given = { "swe-2": { id: "swe-2", capabilities: { attachment: false, input: { text: true, image: false } } } }
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)
})