devin 0.1.8: which models take images is what Devin tells its CLI's model picker (面条 on magpie's Discord: swe-2 takes images) — devin models list says nothing of images and models.dev doesn't know Devin's own ids, so swe-2, swe-1.7 and the like were listed as text-only and agents dropped their images. Once signed in, with the CLI or without it, the plugin asks GetCliModelConfigs (the read-only call the CLI's picker makes, as magpie's built-in does in devin_images.go) and puts each model's supports_images on it: a variant its own, a family and its fast run what all its variants say. It is cached as the list is (5 minutes, 1 after a failure). The config hook's list says what Devin said on 2026-10-05 (GLM-5.2/5.3, Inkling, Nemotron, DeepSeek V4 Flash and V4 Pro take none, every other one does); a model Devin says nothing of keeps models.dev's word. With the owner's real Devin account: swe-2-high/medium/max, swe-1-7, swe-1-7-medium and swe-1-7-lightning(-medium) described an inline PNG's colours through the plugin's fetch, and provider.models listed swe-2 with image input, with the CLI and without it. images.test.mjs (5 tests) fails on 0.1.7; bun test (31 pass) and bun scripts/check.mjs devin pass.
This commit is contained in:
@@ -79,6 +79,14 @@ the account keeps the declared list. The list is
|
||||
cached for 5 minutes; after a failed read, the plugin tries again after 1
|
||||
minute.
|
||||
|
||||
Which models take images is what Devin tells its CLI's model picker
|
||||
(`GetCliModelConfigs`, each model's `supports_images`), asked once signed
|
||||
in, with or without the CLI, and cached as the list is: `swe-2`, `swe-1.7`
|
||||
and most others do; GLM-5.2, GLM-5.3, Inkling, Nemotron, DeepSeek V4 Flash
|
||||
and V4 Pro don't. Before Devin is asked, or when it can't be, the declared
|
||||
list says what Devin said on 2026-10-05. A model Devin says nothing of
|
||||
takes models.dev's word.
|
||||
|
||||
## Not included
|
||||
|
||||
magpie's built-in Devin account does more than this plugin:
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
// 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 { realpathSync } from "node:fs"
|
||||
import { homedir, tmpdir } from "node:os"
|
||||
import { DevinAuthPlugin, _internal } from "./index.mjs"
|
||||
|
||||
const real = globalThis.fetch
|
||||
afterEach(() => {
|
||||
globalThis.fetch = real
|
||||
_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")
|
||||
}
|
||||
|
||||
// configs is a GetCliModelConfigsResponse naming each id, with
|
||||
// supports_images set where it is true (proto3 leaves a false one out)
|
||||
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)
|
||||
out.bytes(1, c.str(22, id))
|
||||
}
|
||||
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 () => {
|
||||
sandboxed()
|
||||
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).toEqual({ 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)
|
||||
expect(got["not-devins"]).toEqual(given["not-devins"])
|
||||
})
|
||||
|
||||
test("when Devin can't be asked, the list takes the snapshot's word", async () => {
|
||||
sandboxed()
|
||||
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)
|
||||
})
|
||||
+131
-19
@@ -224,7 +224,11 @@ function variantFor(families, model, effort) {
|
||||
// A variant in keep (one the user picked: swe-2-medium) stays, at the one
|
||||
// effort its id is at, and goes to Devin as it is, as magpie's built-in
|
||||
// keeps it (devinCollapse).
|
||||
function listed(families, keep = []) {
|
||||
// Each entry says whether it takes images (image) as images, Devin's word
|
||||
// for each variant id, gives it: a variant its own, a family (and its fast
|
||||
// run) what all its variants Devin named say; undefined when Devin said
|
||||
// nothing of it or its variants disagree.
|
||||
function listed(families, keep = [], images = {}) {
|
||||
const out = []
|
||||
const seen = new Set()
|
||||
const add = (m) => {
|
||||
@@ -235,16 +239,17 @@ function listed(families, keep = []) {
|
||||
for (const f of families) {
|
||||
const context = f.models.find((m) => m.context)?.context ?? 0
|
||||
const output = f.models.find((m) => m.output)?.output ?? 0
|
||||
add({ id: f.uid, name: f.label, context, output, efforts: efforts(f, "") })
|
||||
const image = familyImages(f, images)
|
||||
add({ id: f.uid, name: f.label, context, output, efforts: efforts(f, ""), image })
|
||||
for (const t of tiers(f)) {
|
||||
const id = f.uid + "-" + t
|
||||
if (families.some((g) => named(g, id))) continue
|
||||
add({ id, name: f.label + " " + TIERS.find(([w]) => w === t)[1], context, output, efforts: efforts(f, t) })
|
||||
add({ id, name: f.label + " " + TIERS.find(([w]) => w === t)[1], context, output, efforts: efforts(f, t), image })
|
||||
}
|
||||
if (f.models.length === 1) continue
|
||||
for (const m of f.models) {
|
||||
if (m.id === f.uid || tierOf(m.id)[1]) continue
|
||||
add({ id: m.id, name: m.name, context: m.context || context, output: m.output || output, efforts: [] })
|
||||
add({ id: m.id, name: m.name, context: m.context || context, output: m.output || output, efforts: [], image: images[m.id] })
|
||||
}
|
||||
}
|
||||
for (const id of keep) {
|
||||
@@ -253,16 +258,102 @@ function listed(families, keep = []) {
|
||||
const m = f?.models.find((m) => m.id === id)
|
||||
const level = tierOf(id)[1]
|
||||
if (!m && !level) continue
|
||||
add({ id, name: m?.name || id, context: m?.context ?? 0, output: m?.output ?? 0, efforts: level ? [level] : [] })
|
||||
add({ id, name: m?.name || id, context: m?.context ?? 0, output: m?.output ?? 0, efforts: level ? [level] : [], image: images[id] })
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// seesImages is whether a model takes images, as magpie's built-in tells
|
||||
// it for Devin's ids (models.go: m.Images || catalog.SeesImages): Devin's
|
||||
// list says nothing of images, so it is models.dev's word for the id — most
|
||||
// of the providers listing it taking images — from the catalog magpie's
|
||||
// `magpie sync` or OpenCode keeps, and no when neither has it.
|
||||
// familyImages is what a family's variants Devin named all say of images.
|
||||
function familyImages(f, images) {
|
||||
let said
|
||||
for (const m of f.models) {
|
||||
const v = images[m.id]
|
||||
if (typeof v !== "boolean") continue
|
||||
if (said !== undefined && said !== v) return undefined
|
||||
said = v
|
||||
}
|
||||
return said
|
||||
}
|
||||
|
||||
// Which of Devin's models take images is what Devin tells its CLI's model
|
||||
// picker (GetCliModelConfigs: each ClientModelConfig's supports_images), as
|
||||
// magpie's built-in asks it (devin_images.go): `devin models list` says
|
||||
// nothing of images and models.dev doesn't know Devin's own ids, so swe-2
|
||||
// was said to take none and agents dropped its images (面条 on magpie's
|
||||
// Discord). NO_IMAGES are the ids Devin said take none, as of 2026-10-05;
|
||||
// every other id in SNAPSHOT takes them, which is what a list is told
|
||||
// before Devin is asked, or when it can't be.
|
||||
const NO_IMAGES = new Set([
|
||||
"glm-5-2", "glm-5-2-max", "glm-5-2-1m", "glm-5-2-max-1m", "glm-5-2-none", "glm-5-2-none-1m",
|
||||
"glm-5-3-low", "glm-5-3-high", "glm-5-3-max",
|
||||
"inkling-none", "inkling-low", "inkling-medium", "inkling-high", "inkling-xhigh", "inkling-max",
|
||||
"deepseek-v4-flash-high", "deepseek-v4-flash-max", "deepseek-v4-pro-high", "deepseek-v4-pro-max",
|
||||
"nemotron-3-ultra-none", "nemotron-3-ultra-medium", "nemotron-3-ultra-high",
|
||||
])
|
||||
const SNAPSHOT_IMAGES = Object.fromEntries(SNAPSHOT.flatMap(([, , , vs]) => vs.map(([id]) => [id, !NO_IMAGES.has(id)])))
|
||||
|
||||
const MODEL_CONFIGS_RPC = "/exa.api_server_pb.ApiServerService/GetCliModelConfigs"
|
||||
|
||||
// parseModelConfigs reads GetCliModelConfigsResponse: its
|
||||
// client_model_configs (1), each with its model_uid (22) and
|
||||
// supports_images (5), a bool proto3 leaves out when false.
|
||||
function parseModelConfigs(b) {
|
||||
const out = {}
|
||||
for (const f of fields(b)) {
|
||||
if (f.num !== 1 || f.wire !== 2) continue
|
||||
let uid = ""
|
||||
let images = false
|
||||
for (const g of fields(f.data)) {
|
||||
if (g.num === 22 && g.wire === 2) uid = dec.decode(g.data)
|
||||
else if (g.num === 5 && g.wire === 0) images = g.n !== 0
|
||||
}
|
||||
if (uid) out[uid] = images
|
||||
}
|
||||
return Object.keys(out).length ? out : null
|
||||
}
|
||||
|
||||
// Each account's word on images, kept and asked again as its list is.
|
||||
const said = new Map()
|
||||
|
||||
// imagesFor is what Devin says of each model id's images for key's
|
||||
// account, SNAPSHOT_IMAGES under it; with wait false, a first ask isn't
|
||||
// waited for.
|
||||
async function imagesFor(key, server, wait = true) {
|
||||
let c = said.get(key)
|
||||
if (!c) said.set(key, (c = { images: null, at: 0, failed: 0, asking: null }))
|
||||
const ask = () =>
|
||||
(c.asking ??= (async () => {
|
||||
try {
|
||||
const res = await fetch(server + MODEL_CONFIGS_RPC, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/proto", "Connect-Protocol-Version": "1" },
|
||||
body: new PB().bytes(1, metadata(key)).done(),
|
||||
signal: AbortSignal.timeout(15_000),
|
||||
})
|
||||
if (!res.ok) throw new Error(`GetCliModelConfigs: ${res.status}`)
|
||||
const images = parseModelConfigs(new Uint8Array(await res.arrayBuffer()))
|
||||
if (!images) throw new Error("GetCliModelConfigs: no models")
|
||||
Object.assign(c, { images, at: Date.now(), failed: 0 })
|
||||
} catch {
|
||||
c.failed = Date.now()
|
||||
} finally {
|
||||
c.asking = null
|
||||
}
|
||||
})())
|
||||
if (!c.images || Date.now() - c.at >= FRESH) {
|
||||
if (Date.now() - c.failed >= RETRY) {
|
||||
const p = ask()
|
||||
if (wait && !c.images) await p
|
||||
}
|
||||
}
|
||||
return { ...SNAPSHOT_IMAGES, ...(c.images ?? {}) }
|
||||
}
|
||||
|
||||
// seesImages is whether a model Devin said nothing of takes images, as
|
||||
// magpie's built-in tells it (models.go: m.Images || catalog.SeesImages):
|
||||
// models.dev's word for the id — most of the providers listing it taking
|
||||
// images — from the catalog magpie's `magpie sync` or OpenCode keeps, and
|
||||
// no when neither has it.
|
||||
let seen = null
|
||||
function seesImages(id) {
|
||||
if (!seen) {
|
||||
@@ -291,7 +382,7 @@ function seesImages(id) {
|
||||
const bare = (id) => String(id).toLowerCase().split("/").pop()
|
||||
|
||||
function configModel(m) {
|
||||
const image = seesImages(m.id)
|
||||
const image = m.image ?? seesImages(m.id)
|
||||
return {
|
||||
id: m.id,
|
||||
name: m.name,
|
||||
@@ -306,7 +397,7 @@ function configModel(m) {
|
||||
}
|
||||
|
||||
function runtimeModel(m) {
|
||||
const image = seesImages(m.id)
|
||||
const image = m.image ?? seesImages(m.id)
|
||||
return {
|
||||
id: m.id,
|
||||
providerID: ID,
|
||||
@@ -331,6 +422,20 @@ 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.
|
||||
function withImages(models, entries) {
|
||||
const by = new Map(entries.map((m) => [m.id, m.image]))
|
||||
return Object.fromEntries(
|
||||
Object.entries(models ?? {}).map(([id, m]) => {
|
||||
const image = by.get(id)
|
||||
if (typeof image !== "boolean") return [id, m]
|
||||
const caps = m?.capabilities ?? {}
|
||||
return [id, { ...m, capabilities: { ...caps, attachment: image, input: { ...(caps.input ?? { text: true }), image } } }]
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
// ---- the devin CLI -----------------------------------------------------------------
|
||||
|
||||
// cliPath finds the devin CLI, "" without one.
|
||||
@@ -885,6 +990,11 @@ const joinNonEmpty = (...s) => s.filter(Boolean).join("\n\n")
|
||||
|
||||
const osName = () => (process.platform === "win32" ? "windows" : process.platform)
|
||||
|
||||
// metadata is what each request says of the client: the CLI's own (with
|
||||
// its ide and extension names alone Devin lists one model).
|
||||
const metadata = (key) =>
|
||||
new PB().str(1, "devin-cli").str(2, CLI_VERSION).str(3, key).str(4, "en").str(5, osName()).str(7, CLI_VERSION).str(12, "chisel").str(28, "chisel")
|
||||
|
||||
// build is the GetChatMessage request for a chat completion, to the model
|
||||
// uid.
|
||||
function build(chat, uid, key) {
|
||||
@@ -963,8 +1073,7 @@ function build(chat, uid, key) {
|
||||
msgs[at].text = joinNonEmpty(instructions, msgs[at].text)
|
||||
}
|
||||
|
||||
const meta = new PB().str(1, "devin-cli").str(2, CLI_VERSION).str(3, key).str(4, "en").str(5, osName()).str(7, CLI_VERSION).str(12, "chisel").str(28, "chisel")
|
||||
const out = new PB().bytes(1, meta)
|
||||
const out = new PB().bytes(1, metadata(key))
|
||||
for (const m of msgs) out.bytes(3, encodeMsg(m))
|
||||
out.varint(7, 5)
|
||||
const max = chat.max_completion_tokens || chat.max_tokens || 128000 // the server holds it to the model's own
|
||||
@@ -1331,21 +1440,24 @@ export async function DevinAuthPlugin() {
|
||||
npm: CHAT,
|
||||
api: BASE,
|
||||
...was,
|
||||
models: { ...Object.fromEntries(listed(familiesOf(SNAPSHOT)).map((m) => [m.id, configModel(m)])), ...(was.models ?? {}) },
|
||||
models: { ...Object.fromEntries(listed(familiesOf(SNAPSHOT), [], SNAPSHOT_IMAGES).map((m) => [m.id, configModel(m)])), ...(was.models ?? {}) },
|
||||
}
|
||||
},
|
||||
// the account's list, as the devin CLI gives it
|
||||
// the account's list, as the devin CLI gives it, with what Devin says
|
||||
// of each model's images; with no CLI, the list it was given with that
|
||||
provider: {
|
||||
id: ID,
|
||||
async models(provider, { auth } = {}) {
|
||||
if (auth?.type !== "api" || !auth.key || !cliPath()) return provider.models
|
||||
if (auth?.type !== "api" || !auth.key) return provider.models
|
||||
const { key, server } = await live(auth)
|
||||
const images = await imagesFor(key, server)
|
||||
if (!cliPath()) return withImages(provider.models, listed(familiesOf(SNAPSHOT), Object.keys(provider?.models ?? {}), images))
|
||||
const families = await familiesFor(key, server)
|
||||
return Object.fromEntries(listed(families, Object.keys(provider?.models ?? {})).map((m) => [m.id, runtimeModel(m)]))
|
||||
return Object.fromEntries(listed(families, Object.keys(provider?.models ?? {}), images).map((m) => [m.id, runtimeModel(m)]))
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// for tests
|
||||
export const _internal = { seesImages, forgetImages: () => (seen = null), effortOf, runtimeModel, configModel, live, build, failure, complete, parseFamilies, listed, variantFor, familiesOf, SNAPSHOT, parseStatus, readsHome, tierName, whoByKey, success, familiesFor, readCredentials, credentials, fields, frame, PB, events, frames }
|
||||
export const _internal = { seesImages, imagesFor, forgetSaid: () => said.clear(), parseModelConfigs, SNAPSHOT_IMAGES, withImages, forgetImages: () => (seen = null), effortOf, runtimeModel, configModel, live, build, failure, complete, parseFamilies, listed, variantFor, familiesOf, SNAPSHOT, parseStatus, readsHome, tierName, whoByKey, success, familiesFor, readCredentials, credentials, fields, frame, PB, events, frames }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-devin-auth",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.8",
|
||||
"description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
Reference in New Issue
Block a user