sryimnoob123 measured amr-link with reasoning_effort high and low on all 11 models (magpie 0.1.1254, Windows): every one answered 200, and all but gpt-6-luna streamed reasoning, four the catalog calls "standard" too. Their install showed all 11 with reasoning false and no levels. Two causes: - provider.models gave the live list in the config's shape (reasoning: true, modalities: [...]). magpie's plugin host reads a listed model's thinking from capabilities.reasoning and its kinds from capabilities.input, so for a signed-in account every model read as not reasoning, with no image input. It now gives OpenCode's model shape (servedOf: api, capabilities, variants), as minimax/workbuddy do. - No model had levels: nothing declared variants, and magpie shows a model's levels only from them. models.mjs now records the measured levels (efforts): ["low", "high"] on the 10 that thought, [] on gpt-6-luna (took it, never thought). Only the two levels the table shows were given. A model with levels reasons whatever its capability word; one the seed doesn't know keeps the old rule (advanced reasons) with no levels. refresh-models.mjs keeps efforts like names. Run: - bun test packages/opendesign: 21 pass, 0 fail. New: "a signed-in account's models reason at the levels amr-link took (#137)", "the seed's models carry the measured levels as the config's variants"; the live-list test now pins the OpenCode shape. - Broken by hand: modelsOf back on modelOf (config shape) -> 2 fail; efforts not passed from the seed to the live list -> 1 fail. - magpie origin/main internal/plugin/host.js run under bun with a preloaded fetch stub serving a 3-model catalog (init + providers, a stored oauth account): with 0.1.4 gpt-6-luna, deepseek-v4-pro and claude-haiku-5.5 all list reasoning=false variants=[] image=false; with this change luna false/[]/image true, v4-pro true/[low high], haiku true/[low high]/image true, url the amr-link base. - refresh-models.mjs against the same stub: efforts kept per model. - bun scripts/check.mjs: every package ok. - TMPDIR/HOME isolated bun test (whole repo): 1526 pass, 0 fail. A first run had 1 fail, packages/grok/login.test.mjs "a login's link is still handed on" timing out at 5s with load average ~100; alone 3/3 pass and the rerun of the whole repo passed. Untouched package; not filed. Not tried: a real Open Design account (none here) or magpie's `model efforts` command end to end; the levels rest on the reporter's table. Full suite: bun test (whole repo, with factory 0.1.30 below it): 1527 pass, 0 fail
108 lines
4.4 KiB
JavaScript
108 lines
4.4 KiB
JavaScript
// Regenerates models.mjs — the models the provider offers before anyone has
|
|
// signed in — from amr-link's live catalog, which is the account's own list
|
|
// (it is what the plugin reads for a signed-in account too).
|
|
//
|
|
// bun refresh-models.mjs # key from magpie's sign-in
|
|
// OPENDESIGN_KEY=sk-amr-… bun refresh-models.mjs
|
|
//
|
|
// The key is the account's runtime key: magpie keeps it in plugin-auth.json
|
|
// after `magpie plugin login opendesign`, and it is never printed or written
|
|
// anywhere but the Authorization header. A name already in models.mjs is
|
|
// kept — the catalog carries ids, not names.
|
|
//
|
|
// magpie runs a plugin host per command, so `magpie plugin login` has to have
|
|
// finished before this reads the key it saved.
|
|
|
|
import { existsSync, readFileSync, writeFileSync } from "node:fs"
|
|
import { homedir } from "node:os"
|
|
import { dirname, join } from "node:path"
|
|
import { fileURLToPath, pathToFileURL } from "node:url"
|
|
|
|
// the seed this writes, beside the script: the package root here, and the
|
|
// package root when npm installs it
|
|
const HERE = dirname(fileURLToPath(import.meta.url))
|
|
const TARGET = join(HERE, "models.mjs")
|
|
const API = "https://amr-link.open-design.ai/v1"
|
|
|
|
if (!existsSync(TARGET)) {
|
|
console.error("no models.mjs beside this script")
|
|
process.exit(1)
|
|
}
|
|
|
|
const magpieKey = () => {
|
|
const dir = process.env.XDG_CONFIG_HOME || join(homedir(), ".config")
|
|
try {
|
|
const auth = JSON.parse(readFileSync(join(dir, "magpie", "plugin-auth.json"), "utf8")).opendesign
|
|
return auth?.access || auth?.key || ""
|
|
} catch {
|
|
return ""
|
|
}
|
|
}
|
|
|
|
const key = (process.env.OPENDESIGN_KEY || "").trim() || magpieKey()
|
|
if (!key) {
|
|
console.error("No key: sign in with `magpie plugin login opendesign`, or set OPENDESIGN_KEY=sk-amr-…")
|
|
process.exit(1)
|
|
}
|
|
|
|
const res = await fetch(`${API}/models`, { headers: { authorization: `Bearer ${key}` } })
|
|
if (!res.ok) {
|
|
console.error(`amr-link answered ${res.status}: ${(await res.text()).slice(0, 200)}`)
|
|
process.exit(1)
|
|
}
|
|
const body = await res.json()
|
|
const catalog = (body?.data ?? []).filter((m) => typeof m?.id === "string" && m.id.trim())
|
|
if (!catalog.length) {
|
|
console.error("amr-link listed no models")
|
|
process.exit(1)
|
|
}
|
|
|
|
// names already chosen are kept, and so are the measured reasoning levels:
|
|
// the catalog has ids only, and says nothing of efforts
|
|
let before = {}
|
|
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")
|
|
}
|
|
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)
|
|
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 efforts = before[id]?.efforts
|
|
if (Array.isArray(efforts)) facts.push(`efforts: [${efforts.map((x) => JSON.stringify(x)).join(", ")}]`)
|
|
const name = before[id]?.name ?? id
|
|
lines.push(` ${JSON.stringify(id)}: { name: ${JSON.stringify(name)}${facts.length ? ", " + facts.join(", ") : ""} },`)
|
|
}
|
|
|
|
const header = `// The models an account is offered before anyone has signed in — the seed
|
|
// magpie and OpenCode read for the provider. Regenerate with
|
|
// \`bun refresh-models.mjs\` (beside this seed): it
|
|
// reads amr-link's catalog at the signed-in account's key, which is the same
|
|
// list a signed-in account is given again on every listing.
|
|
//
|
|
// name: what the model is called; context/output: its token limits; input:
|
|
// the non-text modalities it takes; cost and capability: the vendor's own
|
|
// words, which the plugin turns into magpie's rate and thinking flags;
|
|
// efforts: the reasoning levels amr-link was seen to take and think at,
|
|
// measured, not read (#137), so a refresh keeps them.
|
|
|
|
export const MODELS = {
|
|
${lines.join("\n")}
|
|
}
|
|
`
|
|
writeFileSync(TARGET, header)
|
|
console.log(`${TARGET}: ${lines.length} models`)
|