@magpie-community/opencode-opendesign-auth 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/index.mjs +90 -9
- package/models.mjs +15 -12
- package/package.json +1 -1
- package/refresh-models.mjs +7 -2
package/README.md
CHANGED
|
@@ -60,8 +60,14 @@ magpie calls the plugin's `provider.models`, which reads `amr-link`'s live
|
|
|
60
60
|
`/v1/models` at that account's key on every listing, so what a signed-in
|
|
61
61
|
account is offered is what its plan entitles it to right now. Limits, input
|
|
62
62
|
modalities and the vendor's own cost words (`rate`, e.g. `x0.5` for "low")
|
|
63
|
-
come from that same catalog
|
|
64
|
-
|
|
63
|
+
come from that same catalog.
|
|
64
|
+
|
|
65
|
+
Reasoning levels are not in the catalog, so `models.mjs` records the ones
|
|
66
|
+
measured against `amr-link` (#137): every model took `reasoning_effort`
|
|
67
|
+
`low` and `high`, and all but GPT-6 Luna thought at them, the ones the
|
|
68
|
+
catalog calls `standard` too. Those models reason at `low` and `high`;
|
|
69
|
+
GPT-6 Luna has no levels. A model the seed doesn't know reasons when its
|
|
70
|
+
vendor tier is `advanced`, with no levels until it is measured.
|
|
65
71
|
|
|
66
72
|
`models.mjs` is the seed the provider has *before* anyone signs in. Refresh
|
|
67
73
|
it from the live catalog with:
|
|
@@ -71,12 +77,16 @@ magpie plugin login opendesign # once, so the key is on hand
|
|
|
71
77
|
bun refresh-models.mjs # or OPENDESIGN_KEY=sk-amr-… bun …
|
|
72
78
|
```
|
|
73
79
|
|
|
74
|
-
The script keeps the names already
|
|
75
|
-
and reads nothing else: no secret is written to the file or
|
|
80
|
+
The script keeps the names and measured levels already there — the catalog
|
|
81
|
+
carries neither — and reads nothing else: no secret is written to the file or
|
|
82
|
+
printed.
|
|
76
83
|
|
|
77
|
-
Requests go to
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
Requests go to `https://amr-link.open-design.ai/v1`, each model on the API
|
|
85
|
+
amr-link answers its thinking on (measured, plugins#141): chat completions
|
|
86
|
+
(`@ai-sdk/openai-compatible`) for most, the Responses API (`@ai-sdk/openai`)
|
|
87
|
+
for `claude-haiku-5.5` and `deepseek-v4-pro`, and Anthropic's messages
|
|
88
|
+
(`@ai-sdk/anthropic`) for `glm-5.3-flash`. Every model reasons at `low`,
|
|
89
|
+
`high` and `max`.
|
|
80
90
|
|
|
81
91
|
## Where the sign-in is kept
|
|
82
92
|
|
package/index.mjs
CHANGED
|
@@ -21,7 +21,28 @@ import { MODELS } from "./models.mjs"
|
|
|
21
21
|
const ID = "opendesign"
|
|
22
22
|
const CONTROL = "https://amr-api.open-design.ai"
|
|
23
23
|
const LINK = "https://amr-link.open-design.ai/v1"
|
|
24
|
-
|
|
24
|
+
// WHICH API each model is asked on: magpie reads the protocol off the AI SDK
|
|
25
|
+
// package a model declares (its api.npm) — "@ai-sdk/openai" is the Responses
|
|
26
|
+
// API, "@ai-sdk/anthropic" Anthropic's messages, the compatible package chat
|
|
27
|
+
// completions. amr-link answers thinking on a different one per model
|
|
28
|
+
// (sryimnoob123's measurements, plugins#141: a streaming request to each model
|
|
29
|
+
// on each of the three): chat completions carries the thinking of ten of the
|
|
30
|
+
// eleven; deepseek-v4-pro and claude-haiku-5.5 think longer on Responses, and
|
|
31
|
+
// glm-5.3-flash only thinks on Anthropic's messages among the two others.
|
|
32
|
+
const WIRE = {
|
|
33
|
+
chat: "@ai-sdk/openai-compatible",
|
|
34
|
+
responses: "@ai-sdk/openai",
|
|
35
|
+
anthropic: "@ai-sdk/anthropic",
|
|
36
|
+
}
|
|
37
|
+
const MODEL_WIRE = {
|
|
38
|
+
"claude-haiku-5.5": "responses",
|
|
39
|
+
"deepseek-v4-pro": "responses",
|
|
40
|
+
"glm-5.3-flash": "anthropic",
|
|
41
|
+
}
|
|
42
|
+
const wireOf = (id) => WIRE[MODEL_WIRE[id]] ?? WIRE.chat
|
|
43
|
+
// the provider's own default: a model this plugin doesn't name is asked on
|
|
44
|
+
// chat completions, where ten of the eleven thought
|
|
45
|
+
const NPM = WIRE.chat
|
|
25
46
|
const SOURCE = "opencode-opendesign-auth/" + pkg.version // as the manifest has it
|
|
26
47
|
const CLI_VERSION = "0.1.4" // what the sign-in says it is, as the CLI does
|
|
27
48
|
const TIMEOUT = 20_000
|
|
@@ -233,11 +254,24 @@ function thePlan(summary, tier) {
|
|
|
233
254
|
return "Design Plan " + t[0].toUpperCase() + t.slice(1)
|
|
234
255
|
}
|
|
235
256
|
|
|
257
|
+
// levelsOf is a model's reasoning levels: the ones models.mjs records as
|
|
258
|
+
// measured against amr-link (#137), where the vendor's capability word
|
|
259
|
+
// misleads both ways — "standard" models took reasoning_effort and thought
|
|
260
|
+
// at it, and GPT-6 Luna took it and never thought. A model the seed doesn't
|
|
261
|
+
// know has none until it is measured too.
|
|
262
|
+
function levelsOf(m) {
|
|
263
|
+
return Array.isArray(m?.efforts) ? m.efforts.filter((e) => typeof e === "string" && e) : []
|
|
264
|
+
}
|
|
265
|
+
|
|
236
266
|
// modelOf turns one model's facts — models.mjs's, or amr-link's catalog
|
|
237
|
-
// read again — into the model magpie shows
|
|
267
|
+
// read again — into the model magpie shows, as the provider's config has
|
|
268
|
+
// it. A model reasons when it has levels, or else when the vendor calls it
|
|
269
|
+
// "advanced". variants are its levels as @ai-sdk/openai options: magpie
|
|
270
|
+
// shows a model's levels only from its variants, and only when it reasons.
|
|
238
271
|
function modelOf(id, m) {
|
|
239
272
|
const rate = COST[text(m?.cost)]
|
|
240
|
-
const
|
|
273
|
+
const levels = levelsOf(m)
|
|
274
|
+
const thinking = levels.length > 0 || (THINKING[text(m?.capability)] ?? !!m?.reasoning)
|
|
241
275
|
const context = Number(m?.context)
|
|
242
276
|
const output = Number(m?.output)
|
|
243
277
|
const input = Array.isArray(m?.input) ? m.input.filter((x) => typeof x === "string" && x !== "text") : []
|
|
@@ -246,7 +280,11 @@ function modelOf(id, m) {
|
|
|
246
280
|
name: text(m?.name) || id,
|
|
247
281
|
attachment: true,
|
|
248
282
|
tool_call: true,
|
|
249
|
-
reasoning: thinking
|
|
283
|
+
reasoning: thinking,
|
|
284
|
+
...(levels.length && { variants: Object.fromEntries(levels.map((e) => [e, { reasoningEffort: e }])) }),
|
|
285
|
+
// the API magpie asks this model on (WIRE above), per model
|
|
286
|
+
api: { npm: wireOf(id) },
|
|
287
|
+
provider: { npm: wireOf(id) },
|
|
250
288
|
...(rate && { rate }),
|
|
251
289
|
limit: {
|
|
252
290
|
context: Number.isFinite(context) && context > 0 ? context : 200_000,
|
|
@@ -256,6 +294,41 @@ function modelOf(id, m) {
|
|
|
256
294
|
}
|
|
257
295
|
}
|
|
258
296
|
|
|
297
|
+
// KINDS are the kinds of input and output OpenCode's capabilities name.
|
|
298
|
+
const KINDS = ["text", "image", "audio", "video", "pdf"]
|
|
299
|
+
const kinds = (list) => Object.fromEntries(KINDS.map((k) => [k, list.includes(k)]))
|
|
300
|
+
|
|
301
|
+
// servedOf is modelOf's model as provider.models hands it back: OpenCode's
|
|
302
|
+
// model, not the config's. magpie reads a listed model's thinking from
|
|
303
|
+
// capabilities.reasoning and its kinds from capabilities.input, so a config
|
|
304
|
+
// shape there (reasoning: true beside no capabilities) listed every model a
|
|
305
|
+
// signed-in account has as one that doesn't reason, with no levels (#137).
|
|
306
|
+
function servedOf(id, m) {
|
|
307
|
+
const c = modelOf(id, m)
|
|
308
|
+
return {
|
|
309
|
+
id,
|
|
310
|
+
name: c.name,
|
|
311
|
+
api: { id, url: LINK, npm: wireOf(id) },
|
|
312
|
+
status: "active",
|
|
313
|
+
headers: {},
|
|
314
|
+
options: {},
|
|
315
|
+
cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
|
|
316
|
+
limit: c.limit,
|
|
317
|
+
capabilities: {
|
|
318
|
+
temperature: true,
|
|
319
|
+
reasoning: c.reasoning,
|
|
320
|
+
attachment: c.attachment,
|
|
321
|
+
toolcall: c.tool_call,
|
|
322
|
+
input: kinds(c.modalities.input),
|
|
323
|
+
output: kinds(c.modalities.output),
|
|
324
|
+
interleaved: false,
|
|
325
|
+
},
|
|
326
|
+
release_date: "",
|
|
327
|
+
variants: c.variants ?? {},
|
|
328
|
+
...(c.rate && { rate: c.rate }),
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
259
332
|
// facts() is amr-link's catalog entry in the seed's own shape.
|
|
260
333
|
function facts(m) {
|
|
261
334
|
const meta = m?.metadata ?? {}
|
|
@@ -277,14 +350,15 @@ function seed() {
|
|
|
277
350
|
}
|
|
278
351
|
|
|
279
352
|
// modelsOf() shapes amr-link's live catalog as magpie's models: the list an
|
|
280
|
-
// account's plan entitles it to right now,
|
|
281
|
-
// seed knows keeps its name; the catalog
|
|
353
|
+
// account's plan entitles it to right now, as provider.models gives them. A
|
|
354
|
+
// model the seed knows keeps its name and its measured levels; the catalog
|
|
355
|
+
// carries ids only.
|
|
282
356
|
function modelsOf(catalog) {
|
|
283
357
|
const out = {}
|
|
284
358
|
for (const m of catalog?.data ?? []) {
|
|
285
359
|
const id = text(m?.id)
|
|
286
360
|
if (!id) continue
|
|
287
|
-
out[id] =
|
|
361
|
+
out[id] = servedOf(id, { ...facts(m), name: MODELS[id]?.name ?? id, efforts: MODELS[id]?.efforts })
|
|
288
362
|
}
|
|
289
363
|
return out
|
|
290
364
|
}
|
|
@@ -350,12 +424,19 @@ export const OpenDesignAuthPlugin = async () => {
|
|
|
350
424
|
config: async (cfg) => {
|
|
351
425
|
cfg.provider ??= {}
|
|
352
426
|
const was = cfg.provider[ID] ?? {}
|
|
427
|
+
// the wire is this plugin's to declare, never a kept copy's: magpie
|
|
428
|
+
// hands back what the hook last wrote, and a model kept from 0.1.5
|
|
429
|
+
// would otherwise stay on the Responses API it chose for every model
|
|
430
|
+
const models = { ...seed(), ...(was.models ?? {}) }
|
|
431
|
+
for (const [id, m] of Object.entries(models)) {
|
|
432
|
+
models[id] = { ...m, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) } }
|
|
433
|
+
}
|
|
353
434
|
cfg.provider[ID] = {
|
|
354
435
|
name: "Open Design",
|
|
355
|
-
npm: NPM,
|
|
356
436
|
api: LINK,
|
|
357
437
|
...was,
|
|
358
|
-
|
|
438
|
+
npm: NPM,
|
|
439
|
+
models,
|
|
359
440
|
}
|
|
360
441
|
},
|
|
361
442
|
// the plan decides which models an account gets, so the list is read
|
package/models.mjs
CHANGED
|
@@ -6,18 +6,21 @@
|
|
|
6
6
|
//
|
|
7
7
|
// name: what the model is called; context/output: its token limits; input:
|
|
8
8
|
// the non-text modalities it takes; cost and capability: the vendor's own
|
|
9
|
-
// words, which the plugin turns into magpie's rate and thinking flags
|
|
9
|
+
// words, which the plugin turns into magpie's rate and thinking flags;
|
|
10
|
+
// efforts: the reasoning levels amr-link was seen to take and think at,
|
|
11
|
+
// measured, not read (#137; max too, plugins#141: the vendor names low, high
|
|
12
|
+
// and max when asked for one it doesn't take), so a refresh keeps them.
|
|
10
13
|
|
|
11
14
|
export const MODELS = {
|
|
12
|
-
"claude-haiku-5.5": { name: "Claude Haiku 5.5", context: 1000000, output: 132000, input: ["image", "file"], cost: "low", capability: "standard" },
|
|
13
|
-
"deepseek-v4-flash": { name: "DeepSeek V4 Flash", context: 1048000, output: 232000, cost: "medium", capability: "standard" },
|
|
14
|
-
"deepseek-v4-flash-vision-exp": { name: "DeepSeek V4 Flash Vision (exp)", context: 1048000, output: 232000, input: ["image"], cost: "medium", capability: "standard" },
|
|
15
|
-
"deepseek-v4-pro": { name: "DeepSeek V4 Pro", context: 1048000, output: 232000, cost: "high", capability: "advanced" },
|
|
16
|
-
"deepseek-v4.1-flash": { name: "DeepSeek V4.1 Flash", context: 1048000, output: 232000, input: ["image"], cost: "low", capability: "advanced" },
|
|
17
|
-
"glm-5.3-flash": { name: "GLM 5.3 Flash", context: 1048000, output: 232000, input: ["image", "video"], cost: "low", capability: "advanced" },
|
|
18
|
-
"glm-5.3-flashx": { name: "GLM 5.3 FlashX", context: 1000000, output: 232000, input: ["image", "file", "video"], cost: "medium", capability: "advanced" },
|
|
19
|
-
"gpt-6-luna": { name: "GPT-6 Luna", context: 1050000, output: 304000, input: ["image", "file"], cost: "low", capability: "standard" },
|
|
20
|
-
"kimi-k2.7-code": { name: "Kimi K2.7 Code", context: 262000, output: 262000, input: ["image"], cost: "medium", capability: "advanced" },
|
|
21
|
-
"mimo-v2.6-flash": { name: "MiMo V2.6 Flash", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "low", capability: "standard" },
|
|
22
|
-
"mimo-v2.6-pro": { name: "MiMo V2.6 Pro", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "medium", capability: "advanced" },
|
|
15
|
+
"claude-haiku-5.5": { name: "Claude Haiku 5.5", context: 1000000, output: 132000, input: ["image", "file"], cost: "low", capability: "standard", efforts: ["low", "high", "max"] },
|
|
16
|
+
"deepseek-v4-flash": { name: "DeepSeek V4 Flash", context: 1048000, output: 232000, cost: "medium", capability: "standard", efforts: ["low", "high", "max"] },
|
|
17
|
+
"deepseek-v4-flash-vision-exp": { name: "DeepSeek V4 Flash Vision (exp)", context: 1048000, output: 232000, input: ["image"], cost: "medium", capability: "standard", efforts: ["low", "high", "max"] },
|
|
18
|
+
"deepseek-v4-pro": { name: "DeepSeek V4 Pro", context: 1048000, output: 232000, cost: "high", capability: "advanced", efforts: ["low", "high", "max"] },
|
|
19
|
+
"deepseek-v4.1-flash": { name: "DeepSeek V4.1 Flash", context: 1048000, output: 232000, input: ["image"], cost: "low", capability: "advanced", efforts: ["low", "high", "max"] },
|
|
20
|
+
"glm-5.3-flash": { name: "GLM 5.3 Flash", context: 1048000, output: 232000, input: ["image", "video"], cost: "low", capability: "advanced", efforts: ["low", "high", "max"] },
|
|
21
|
+
"glm-5.3-flashx": { name: "GLM 5.3 FlashX", context: 1000000, output: 232000, input: ["image", "file", "video"], cost: "medium", capability: "advanced", efforts: ["low", "high", "max"] },
|
|
22
|
+
"gpt-6-luna": { name: "GPT-6 Luna", context: 1050000, output: 304000, input: ["image", "file"], cost: "low", capability: "standard", efforts: [] },
|
|
23
|
+
"kimi-k2.7-code": { name: "Kimi K2.7 Code", context: 262000, output: 262000, input: ["image"], cost: "medium", capability: "advanced", efforts: ["low", "high", "max"] },
|
|
24
|
+
"mimo-v2.6-flash": { name: "MiMo V2.6 Flash", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "low", capability: "standard", efforts: ["low", "high", "max"] },
|
|
25
|
+
"mimo-v2.6-pro": { name: "MiMo V2.6 Pro", context: 1048000, output: 232000, input: ["image", "audio", "video"], cost: "medium", capability: "advanced", efforts: ["low", "high", "max"] },
|
|
23
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-opendesign-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"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",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
package/refresh-models.mjs
CHANGED
|
@@ -57,7 +57,8 @@ if (!catalog.length) {
|
|
|
57
57
|
process.exit(1)
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
// names already chosen are kept
|
|
60
|
+
// names already chosen are kept, and so are the measured reasoning levels:
|
|
61
|
+
// the catalog has ids only, and says nothing of efforts
|
|
61
62
|
let before = {}
|
|
62
63
|
try {
|
|
63
64
|
;({ MODELS: before } = await import(pathToFileURL(TARGET).href))
|
|
@@ -80,6 +81,8 @@ for (const m of catalog) {
|
|
|
80
81
|
if (extra.length) facts.push(`input: [${extra.map((x) => JSON.stringify(x)).join(", ")}]`)
|
|
81
82
|
if (typeof meta.cost === "string") facts.push(`cost: ${JSON.stringify(meta.cost)}`)
|
|
82
83
|
if (typeof meta.capability === "string") facts.push(`capability: ${JSON.stringify(meta.capability)}`)
|
|
84
|
+
const efforts = before[id]?.efforts
|
|
85
|
+
if (Array.isArray(efforts)) facts.push(`efforts: [${efforts.map((x) => JSON.stringify(x)).join(", ")}]`)
|
|
83
86
|
const name = before[id]?.name ?? id
|
|
84
87
|
lines.push(` ${JSON.stringify(id)}: { name: ${JSON.stringify(name)}${facts.length ? ", " + facts.join(", ") : ""} },`)
|
|
85
88
|
}
|
|
@@ -92,7 +95,9 @@ const header = `// The models an account is offered before anyone has signed in
|
|
|
92
95
|
//
|
|
93
96
|
// name: what the model is called; context/output: its token limits; input:
|
|
94
97
|
// the non-text modalities it takes; cost and capability: the vendor's own
|
|
95
|
-
// words, which the plugin turns into magpie's rate and thinking flags
|
|
98
|
+
// words, which the plugin turns into magpie's rate and thinking flags;
|
|
99
|
+
// efforts: the reasoning levels amr-link was seen to take and think at,
|
|
100
|
+
// measured, not read (#137), so a refresh keeps them.
|
|
96
101
|
|
|
97
102
|
export const MODELS = {
|
|
98
103
|
${lines.join("\n")}
|