opendesign 0.1.10: a model keeps the seed's input kinds and limits the live catalog leaves out (#829)

modelsOf() built each signed-in model from amr-link's catalog entry alone
(facts(m)). When the entry for deepseek-v4.1-flash-eco didn't list image,
the seed's input: ["image"] was lost, magpie listed it text-only and
described the image with another vision model (claude-haiku-5.5), while
amr-link takes the image itself (the reporter's direct POST). Limits and
the cost/capability words had the same loss: an entry without them fell to
200K/32K and no word, not the seed's.

withSeed() now fills what the entry leaves out from models.mjs. Input is
the seed's kinds and the catalog's together, also when the catalog lists
text only: the seed's kinds are what the catalog itself listed at the last
refresh, and a kind wrongly dropped is silent (the image is swapped for a
description on another account's allowance), while a kind wrongly kept is
the vendor's visible error. A model or kind the seed doesn't declare is the
catalog's alone. refresh-models.mjs does the same merge and prints each
kind it kept, so removing one is an edit to models.mjs.

Siblings: astudio, cline and sensenova read input_modalities too. cline
leaves an absent list unsaid, sensenova already unions its curated list
with the live one, astudio has no seed kinds to lose. No change there.

Run on mote:
- bun test packages/opendesign: 29 pass.
- Broken by hand: the old index.mjs and refresh-models.mjs fail both new
  tests (image false; no "kept image" line, eco written without input);
  only the context fallback reverted fails the modelsOf test.
- bun scripts/check.mjs opendesign: ok.
- HOME=$(mktemp -d) bun test (whole repo): 6766 pass, 20 skip, 1 fail:
  reasonix-desktop "normal host exit flushes a disconnect and leaves an
  active connection configured" (1162ms), untouched here; it passes 3 of 3
  run alone. Its output was lost to a tail; not filed.

Not tried: a signed-in opendesign account (we have none), so whether the
live entry lists ["text"] or omits the modalities is not seen; the fix
covers both. refresh-models.mjs against the real catalog.

Reported-by: exposir
This commit is contained in:
yetone
2026-11-07 17:46:50 +08:00
parent 3b41dda9fd
commit 32bf0e68f9
6 changed files with 149 additions and 17 deletions
+8 -3
View File
@@ -60,7 +60,11 @@ magpie calls the plugin's `provider.models`, which reads `amr-link`'s live
`/v1/models` at that account's key on every listing, so what a signed-in
account is offered is what its plan entitles it to right now. Limits and
input modalities come from that same catalog; the quota multiplier (`rate`)
comes from `rates.mjs`, the plan's own table (below).
comes from `rates.mjs`, the plan's own table (below). What the catalog leaves
out of a model `models.mjs` knows is the seed's: its limits, and every input
kind the seed declares (#829: the catalog left image out of DeepSeek V4.1
Flash Eco, which takes images). A kind the catalog adds is added; a kind is
removed only by changing `models.mjs`.
Reasoning levels are not in the catalog, so `models.mjs` records the ones
measured against `amr-link` (#137): every model took `reasoning_effort`
@@ -105,8 +109,9 @@ bun refresh-models.mjs # or OPENDESIGN_KEY=sk-amr-… bun …
```
The script keeps the names and measured levels already there — the catalog
carries neither — and reads nothing else: no secret is written to the file or
printed.
carries neither — and, as the plugin does, the input kinds, limits and words
the catalog leaves out. It prints each kind it kept that way. It reads nothing
else: no secret is written to the file or printed.
Requests go to `https://amr-link.open-design.ai/v1`, each model on the API
amr-link answers its thinking on (measured, plugins#141): chat completions
+35 -3
View File
@@ -366,16 +366,48 @@ function seed() {
return Object.fromEntries(Object.entries(MODELS).map(([id, m]) => [id, modelOf(id, m)]))
}
// withSeed() is a catalog entry's facts with the seed's filling what the
// entry leaves out: a limit, a cost or capability word the catalog doesn't
// give is the seed's, not modelOf's 200K/32K fallback or no word at all.
//
// input is the seed's and the catalog's together (#829). The seed's input is
// what amr-link's own catalog listed when models.mjs was last refreshed
// (refresh-models.mjs writes only what is listed), and DeepSeek V4.1 Flash
// Eco took an image on amr-link while the live entry left image out. The two
// mistakes don't cost the same: a kind listed that the model refuses is the
// vendor's visible error, while a kind dropped is silent, as magpie hands the
// image to another model for a description, at that account's cost, and
// sends this one text. So a catalog that lists text only takes nothing away
// from a kind the seed declares; refresh-models.mjs says when it does, and
// removing a kind is a change to models.mjs. A model the seed doesn't know,
// or a kind it doesn't declare, is the catalog's alone.
function withSeed(id, f) {
const s = MODELS[id] ?? {}
const positive = (n) => Number.isFinite(n) && n > 0
const seedInput = Array.isArray(s.input) ? s.input.filter((x) => typeof x === "string" && x !== "text") : []
return {
...f,
context: positive(f.context) ? f.context : s.context,
output: positive(f.output) ? f.output : s.output,
input: [...new Set([...seedInput, ...f.input])],
cost: f.cost || text(s.cost),
capability: f.capability || text(s.capability),
name: s.name ?? id,
efforts: s.efforts,
}
}
// modelsOf() shapes amr-link's live catalog as magpie's models: the list an
// account's plan entitles it to right now, as provider.models gives them. A
// model the seed knows keeps its name and its measured levels; the catalog
// carries ids only.
// model the seed knows keeps its name and its measured levels, which the
// catalog doesn't carry, and what the seed says of it that the catalog
// doesn't (withSeed).
function modelsOf(catalog) {
const out = {}
for (const m of catalog?.data ?? []) {
const id = text(m?.id)
if (!id) continue
out[id] = servedOf(id, { ...facts(m), name: MODELS[id]?.name ?? id, efforts: MODELS[id]?.efforts })
out[id] = servedOf(id, withSeed(id, facts(m)))
}
return out
}
+31
View File
@@ -284,6 +284,37 @@ test("a kept model's rate is re-declared, so a charge an earlier version wrote c
expect(models["brand-new-9"].rate).toBe("x1")
})
// #829 (exposir): the signed-in catalog's DeepSeek V4.1 Flash Eco entry
// left image out, so it was served text-only and magpie sent another model's
// description of the image instead, while amr-link took the image itself
test("a kind the seed declares stays when the catalog leaves it out (#829)", () => {
const models = I.modelsOf({
data: [
// listed, text only
{ id: "deepseek-v4.1-flash-eco", architecture: { input_modalities: ["text"] }, metadata: { cost: "low", capability: "advanced", context_limit: 1048000, context_budget: 232000 } },
// no architecture at all, nor limits or words
{ id: "glm-5.3-flashx" },
// the catalog's own kinds add to the seed's
{ id: "kimi-k2.7-code", architecture: { input_modalities: ["text", "image", "video"] } },
// a model the seed says takes text only stays text only
{ id: "deepseek-v4-pro", architecture: { input_modalities: ["text"] } },
// a model the seed doesn't know is the catalog's alone
{ id: "brand-new-9", architecture: { input_modalities: ["text"] } },
],
})
const input = (id) => Object.entries(models[id].capabilities.input).filter(([, on]) => on).map(([k]) => k)
expect(asMagpieReads(models["deepseek-v4.1-flash-eco"]).image).toBe(true)
expect(input("deepseek-v4.1-flash-eco")).toEqual(["text", "image"])
expect(input("glm-5.3-flashx")).toEqual(["text", "image", "video"])
expect(input("kimi-k2.7-code")).toEqual(["text", "image", "video"])
expect(input("deepseek-v4-pro")).toEqual(["text"])
expect(input("brand-new-9")).toEqual(["text"])
// the limits and words the catalog leaves out are the seed's, not 200K/32K
expect(models["glm-5.3-flashx"].limit).toEqual({ context: 1000000, output: 232000 })
expect(models["glm-5.3-flashx"].rate).toBe("x2")
expect(models["brand-new-9"].limit).toEqual({ context: 200000, output: 32000 })
})
test("an empty catalog is no models", () => {
expect(I.modelsOf({ data: [] })).toEqual({})
expect(I.modelsOf(null)).toEqual({})
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-opendesign-auth",
"version": "0.1.9",
"version": "0.1.10",
"description": "Open Design Cloud (Design Plan) in OpenCode and magpie: the account's device sign-in, its models, and the plan's 5-hour and 7-day allowance",
"type": "module",
"main": "./opencode.mjs",
+22 -10
View File
@@ -64,23 +64,35 @@ try {
;({ MODELS: before } = await import(pathToFileURL(TARGET).href))
} catch {}
const input = (m) => {
const said = Array.isArray(m?.architecture?.input_modalities) ? m.architecture.input_modalities : []
return said.filter((x) => typeof x === "string" && x !== "text")
// input is the catalog's kinds and the seed's together, as the plugin serves
// them (withSeed in index.mjs, #829): a catalog entry that leaves image out
// doesn't take it from a model the seed declares it for. A kind kept that way
// is printed, so removing it is a choice made in models.mjs, not a refresh's.
const kinds = (l) => (Array.isArray(l) ? l.filter((x) => typeof x === "string" && x !== "text") : [])
const input = (id, m) => {
const said = kinds(m?.architecture?.input_modalities)
const kept = kinds(before[id]?.input).filter((x) => !said.includes(x))
if (kept.length) console.log(`${id}: kept ${kept.join(", ")} from models.mjs; the catalog doesn't list it`)
return [...new Set([...kinds(before[id]?.input), ...said])]
}
const positive = (n) => Number.isFinite(n) && n > 0
const lines = []
for (const m of catalog) {
const id = m.id.trim()
const meta = m.metadata ?? {}
const facts = []
const context = Number(meta.context_limit)
const output = Number(meta.context_budget)
if (Number.isFinite(context) && context > 0) facts.push(`context: ${context}`)
if (Number.isFinite(output) && output > 0) facts.push(`output: ${output}`)
const extra = input(m)
// what the catalog leaves out is the seed's, as the plugin serves it
const was = before[id] ?? {}
const context = positive(Number(meta.context_limit)) ? Number(meta.context_limit) : Number(was.context)
const output = positive(Number(meta.context_budget)) ? Number(meta.context_budget) : Number(was.output)
if (positive(context)) facts.push(`context: ${context}`)
if (positive(output)) facts.push(`output: ${output}`)
const extra = input(id, m)
if (extra.length) facts.push(`input: [${extra.map((x) => JSON.stringify(x)).join(", ")}]`)
if (typeof meta.cost === "string") facts.push(`cost: ${JSON.stringify(meta.cost)}`)
if (typeof meta.capability === "string") facts.push(`capability: ${JSON.stringify(meta.capability)}`)
const cost = typeof meta.cost === "string" && meta.cost.trim() ? meta.cost : was.cost
const capability = typeof meta.capability === "string" && meta.capability.trim() ? meta.capability : was.capability
if (typeof cost === "string") facts.push(`cost: ${JSON.stringify(cost)}`)
if (typeof capability === "string") facts.push(`capability: ${JSON.stringify(capability)}`)
const efforts = before[id]?.efforts
if (Array.isArray(efforts)) facts.push(`efforts: [${efforts.map((x) => JSON.stringify(x)).join(", ")}]`)
const name = before[id]?.name ?? id
+52
View File
@@ -0,0 +1,52 @@
// refresh-models.mjs rewrites models.mjs from amr-link's catalog. A kind, a
// limit or a word the catalog leaves out is kept from the seed, as the plugin
// serves it (#829), so a refresh doesn't take image from DeepSeek V4.1 Flash
// Eco. The script runs on a copy of the package, with fetch stubbed.
import { test, expect } from "bun:test"
import { copyFileSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { pathToFileURL } from "node:url"
const CATALOG = {
data: [
{ id: "deepseek-v4.1-flash-eco", architecture: { input_modalities: ["text"] }, metadata: { cost: "low", capability: "advanced", context_limit: 1048000, context_budget: 232000 } },
{ id: "glm-5.3-flashx" },
{ id: "kimi-k2.7-code", architecture: { input_modalities: ["text", "image", "video"] }, metadata: { context_limit: 262000 } },
{ id: "deepseek-v4-pro", architecture: { input_modalities: ["text"] }, metadata: { cost: "high" } },
{ id: "brand-new-9", architecture: { input_modalities: ["text"] } },
],
}
test("a refresh keeps what the catalog leaves out of a seed model (#829)", async () => {
const dir = mkdtempSync(join(tmpdir(), "opendesign-refresh-"))
try {
for (const f of ["refresh-models.mjs", "models.mjs"]) copyFileSync(join(import.meta.dir, f), join(dir, f))
writeFileSync(
join(dir, "stub.mjs"),
`globalThis.fetch = async (url) => {
if (String(url) !== "https://amr-link.open-design.ai/v1/models") throw new Error("unexpected fetch " + url)
return Response.json(${JSON.stringify(CATALOG)})
}\n`,
)
const run = Bun.spawnSync([process.execPath, "--preload", join(dir, "stub.mjs"), join(dir, "refresh-models.mjs")], {
cwd: dir,
env: { PATH: process.env.PATH ?? "", HOME: dir, XDG_CONFIG_HOME: dir, OPENDESIGN_KEY: "sk-amr-test" },
})
const out = run.stdout.toString()
expect([run.exitCode, run.stderr.toString()]).toEqual([0, ""])
expect(out).toContain("deepseek-v4.1-flash-eco: kept image from models.mjs")
// a fresh URL, so this isn't the copy's import from before the write
const { MODELS } = await import(pathToFileURL(join(dir, "models.mjs")).href + "?after")
expect(Object.keys(MODELS)).toEqual(CATALOG.data.map((m) => m.id))
expect(MODELS["deepseek-v4.1-flash-eco"]).toEqual({ name: "DeepSeek V4.1 Flash Eco", context: 1048000, output: 232000, input: ["image"], cost: "low", capability: "advanced", efforts: ["low", "high", "max"] })
expect(MODELS["glm-5.3-flashx"]).toEqual({ name: "GLM 5.3 FlashX", context: 1000000, output: 232000, input: ["image", "file", "video"], cost: "medium", capability: "advanced", efforts: ["low", "high", "max"] })
expect(MODELS["kimi-k2.7-code"].input).toEqual(["image", "video"])
expect(MODELS["deepseek-v4-pro"].input).toBeUndefined()
expect(MODELS["brand-new-9"]).toEqual({ name: "brand-new-9" })
// the package's own seed is untouched
expect(readFileSync(join(import.meta.dir, "models.mjs"), "utf8")).toContain('"deepseek-v4.1-flash-eco"')
} finally {
rmSync(dir, { recursive: true, force: true })
}
})