@magpie-community/opencode-opendesign-auth 0.1.9 → 0.1.11
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 +8 -3
- package/index.mjs +53 -5
- package/opencode2.mjs +4 -2
- package/package.json +1 -1
- package/refresh-models.mjs +22 -10
package/README.md
CHANGED
|
@@ -60,7 +60,11 @@ 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 and
|
|
62
62
|
input modalities come from that same catalog; the quota multiplier (`rate`)
|
|
63
|
-
comes from `rates.mjs`, the plan's own table (below).
|
|
63
|
+
comes from `rates.mjs`, the plan's own table (below). What the catalog leaves
|
|
64
|
+
out of a model `models.mjs` knows is the seed's: its limits, and every input
|
|
65
|
+
kind the seed declares (#829: the catalog left image out of DeepSeek V4.1
|
|
66
|
+
Flash Eco, which takes images). A kind the catalog adds is added; a kind is
|
|
67
|
+
removed only by changing `models.mjs`.
|
|
64
68
|
|
|
65
69
|
Reasoning levels are not in the catalog, so `models.mjs` records the ones
|
|
66
70
|
measured against `amr-link` (#137): every model took `reasoning_effort`
|
|
@@ -105,8 +109,9 @@ bun refresh-models.mjs # or OPENDESIGN_KEY=sk-amr-… bun …
|
|
|
105
109
|
```
|
|
106
110
|
|
|
107
111
|
The script keeps the names and measured levels already there — the catalog
|
|
108
|
-
carries neither — and
|
|
109
|
-
|
|
112
|
+
carries neither — and, as the plugin does, the input kinds, limits and words
|
|
113
|
+
the catalog leaves out. It prints each kind it kept that way. It reads nothing
|
|
114
|
+
else: no secret is written to the file or printed.
|
|
110
115
|
|
|
111
116
|
Requests go to `https://amr-link.open-design.ai/v1`, each model on the API
|
|
112
117
|
amr-link answers its thinking on (measured, plugins#141): chat completions
|
package/index.mjs
CHANGED
|
@@ -280,6 +280,18 @@ function levelsOf(m) {
|
|
|
280
280
|
return Array.isArray(m?.efforts) ? m.efforts.filter((e) => typeof e === "string" && e) : []
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
// CAP is the most output a model may be asked for where amr-link's catalog
|
|
284
|
+
// (metadata.context_budget) says more than its API takes. Asking for more is
|
|
285
|
+
// a 400 "Open Design: The request could not be completed." that names no
|
|
286
|
+
// field, so nothing can lower it and retry. A client that names no limit
|
|
287
|
+
// (Codex) is given the published one by magpie, so every turn would fail
|
|
288
|
+
// (#827, Gitleonan, measured 2026-11-09 on two accounts): glm-5.3-flash took
|
|
289
|
+
// 131072 and refused 132000 (one account took 232000), and gemini-3.8-flash
|
|
290
|
+
// took 65536 and refused 65537 on both. The cap is applied here, not in
|
|
291
|
+
// models.mjs: the live catalog's number overrides the seed's (withSeed), and
|
|
292
|
+
// refresh-models.mjs writes the vendor's number back into the seed.
|
|
293
|
+
const CAP = { "glm-5.3-flash": 131072, "gemini-3.8-flash": 65536 }
|
|
294
|
+
|
|
283
295
|
// modelOf turns one model's facts — models.mjs's, or amr-link's catalog
|
|
284
296
|
// read again — into the model magpie shows, as the provider's config has
|
|
285
297
|
// it. A model reasons when it has levels, or else when the vendor calls it
|
|
@@ -305,7 +317,7 @@ function modelOf(id, m) {
|
|
|
305
317
|
...(rate && { rate }),
|
|
306
318
|
limit: {
|
|
307
319
|
context: Number.isFinite(context) && context > 0 ? context : 200_000,
|
|
308
|
-
output: Number.isFinite(output) && output > 0 ? output : 32_000,
|
|
320
|
+
output: Math.min(Number.isFinite(output) && output > 0 ? output : 32_000, CAP[id] ?? Infinity),
|
|
309
321
|
},
|
|
310
322
|
modalities: { input: ["text", ...input], output: ["text"] },
|
|
311
323
|
}
|
|
@@ -366,16 +378,48 @@ function seed() {
|
|
|
366
378
|
return Object.fromEntries(Object.entries(MODELS).map(([id, m]) => [id, modelOf(id, m)]))
|
|
367
379
|
}
|
|
368
380
|
|
|
381
|
+
// withSeed() is a catalog entry's facts with the seed's filling what the
|
|
382
|
+
// entry leaves out: a limit, a cost or capability word the catalog doesn't
|
|
383
|
+
// give is the seed's, not modelOf's 200K/32K fallback or no word at all.
|
|
384
|
+
//
|
|
385
|
+
// input is the seed's and the catalog's together (#829). The seed's input is
|
|
386
|
+
// what amr-link's own catalog listed when models.mjs was last refreshed
|
|
387
|
+
// (refresh-models.mjs writes only what is listed), and DeepSeek V4.1 Flash
|
|
388
|
+
// Eco took an image on amr-link while the live entry left image out. The two
|
|
389
|
+
// mistakes don't cost the same: a kind listed that the model refuses is the
|
|
390
|
+
// vendor's visible error, while a kind dropped is silent, as magpie hands the
|
|
391
|
+
// image to another model for a description, at that account's cost, and
|
|
392
|
+
// sends this one text. So a catalog that lists text only takes nothing away
|
|
393
|
+
// from a kind the seed declares; refresh-models.mjs says when it does, and
|
|
394
|
+
// removing a kind is a change to models.mjs. A model the seed doesn't know,
|
|
395
|
+
// or a kind it doesn't declare, is the catalog's alone.
|
|
396
|
+
function withSeed(id, f) {
|
|
397
|
+
const s = MODELS[id] ?? {}
|
|
398
|
+
const positive = (n) => Number.isFinite(n) && n > 0
|
|
399
|
+
const seedInput = Array.isArray(s.input) ? s.input.filter((x) => typeof x === "string" && x !== "text") : []
|
|
400
|
+
return {
|
|
401
|
+
...f,
|
|
402
|
+
context: positive(f.context) ? f.context : s.context,
|
|
403
|
+
output: positive(f.output) ? f.output : s.output,
|
|
404
|
+
input: [...new Set([...seedInput, ...f.input])],
|
|
405
|
+
cost: f.cost || text(s.cost),
|
|
406
|
+
capability: f.capability || text(s.capability),
|
|
407
|
+
name: s.name ?? id,
|
|
408
|
+
efforts: s.efforts,
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
369
412
|
// modelsOf() shapes amr-link's live catalog as magpie's models: the list an
|
|
370
413
|
// account's plan entitles it to right now, as provider.models gives them. A
|
|
371
|
-
// model the seed knows keeps its name and its measured levels
|
|
372
|
-
//
|
|
414
|
+
// model the seed knows keeps its name and its measured levels, which the
|
|
415
|
+
// catalog doesn't carry, and what the seed says of it that the catalog
|
|
416
|
+
// doesn't (withSeed).
|
|
373
417
|
function modelsOf(catalog) {
|
|
374
418
|
const out = {}
|
|
375
419
|
for (const m of catalog?.data ?? []) {
|
|
376
420
|
const id = text(m?.id)
|
|
377
421
|
if (!id) continue
|
|
378
|
-
out[id] = servedOf(id,
|
|
422
|
+
out[id] = servedOf(id, withSeed(id, facts(m)))
|
|
379
423
|
}
|
|
380
424
|
return out
|
|
381
425
|
}
|
|
@@ -448,7 +492,11 @@ export const OpenDesignAuthPlugin = async () => {
|
|
|
448
492
|
const models = { ...seed(), ...(was.models ?? {}) }
|
|
449
493
|
for (const [id, m] of Object.entries(models)) {
|
|
450
494
|
const rate = RATES[id] === undefined ? undefined : "x" + RATES[id]
|
|
451
|
-
|
|
495
|
+
// a kept copy's limit is capped too: an earlier version wrote the
|
|
496
|
+
// catalog's 232000 for glm-5.3-flash, which amr-link refuses (CAP)
|
|
497
|
+
const out = Number(m.limit?.output)
|
|
498
|
+
const limit = CAP[id] && !(out > 0 && out <= CAP[id]) ? { limit: { ...(m.limit ?? {}), output: CAP[id] } } : {}
|
|
499
|
+
models[id] = { ...m, ...limit, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, ...(rate && { rate }) }
|
|
452
500
|
}
|
|
453
501
|
cfg.provider[ID] = {
|
|
454
502
|
name: "Open Design",
|
package/opencode2.mjs
CHANGED
|
@@ -85,8 +85,10 @@ export function fieldsOf(prompts) {
|
|
|
85
85
|
if (p.placeholder) f.placeholder = String(p.placeholder)
|
|
86
86
|
if (p.type === "select" && Array.isArray(p.options))
|
|
87
87
|
f.options = p.options.map((o) => ({ value: String(o.value), label: String(o.label ?? o.value), ...(o.hint ? { description: String(o.hint) } : {}) }))
|
|
88
|
-
// a prompt shown only when another answer says so can't be required
|
|
89
|
-
|
|
88
|
+
// a prompt shown only when another answer says so can't be required, and
|
|
89
|
+
// neither can one whose own validate() accepts an empty answer (the
|
|
90
|
+
// browser sign-in's optional API key)
|
|
91
|
+
if (!p.condition && p.required !== false) f.required = true
|
|
90
92
|
out.push(f)
|
|
91
93
|
}
|
|
92
94
|
return out.length ? out : undefined
|
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.11",
|
|
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": "./opencode.mjs",
|
package/refresh-models.mjs
CHANGED
|
@@ -64,23 +64,35 @@ try {
|
|
|
64
64
|
;({ MODELS: before } = await import(pathToFileURL(TARGET).href))
|
|
65
65
|
} catch {}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
// input is the catalog's kinds and the seed's together, as the plugin serves
|
|
68
|
+
// them (withSeed in index.mjs, #829): a catalog entry that leaves image out
|
|
69
|
+
// doesn't take it from a model the seed declares it for. A kind kept that way
|
|
70
|
+
// is printed, so removing it is a choice made in models.mjs, not a refresh's.
|
|
71
|
+
const kinds = (l) => (Array.isArray(l) ? l.filter((x) => typeof x === "string" && x !== "text") : [])
|
|
72
|
+
const input = (id, m) => {
|
|
73
|
+
const said = kinds(m?.architecture?.input_modalities)
|
|
74
|
+
const kept = kinds(before[id]?.input).filter((x) => !said.includes(x))
|
|
75
|
+
if (kept.length) console.log(`${id}: kept ${kept.join(", ")} from models.mjs; the catalog doesn't list it`)
|
|
76
|
+
return [...new Set([...kinds(before[id]?.input), ...said])]
|
|
70
77
|
}
|
|
78
|
+
const positive = (n) => Number.isFinite(n) && n > 0
|
|
71
79
|
const lines = []
|
|
72
80
|
for (const m of catalog) {
|
|
73
81
|
const id = m.id.trim()
|
|
74
82
|
const meta = m.metadata ?? {}
|
|
75
83
|
const facts = []
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
// what the catalog leaves out is the seed's, as the plugin serves it
|
|
85
|
+
const was = before[id] ?? {}
|
|
86
|
+
const context = positive(Number(meta.context_limit)) ? Number(meta.context_limit) : Number(was.context)
|
|
87
|
+
const output = positive(Number(meta.context_budget)) ? Number(meta.context_budget) : Number(was.output)
|
|
88
|
+
if (positive(context)) facts.push(`context: ${context}`)
|
|
89
|
+
if (positive(output)) facts.push(`output: ${output}`)
|
|
90
|
+
const extra = input(id, m)
|
|
81
91
|
if (extra.length) facts.push(`input: [${extra.map((x) => JSON.stringify(x)).join(", ")}]`)
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
const cost = typeof meta.cost === "string" && meta.cost.trim() ? meta.cost : was.cost
|
|
93
|
+
const capability = typeof meta.capability === "string" && meta.capability.trim() ? meta.capability : was.capability
|
|
94
|
+
if (typeof cost === "string") facts.push(`cost: ${JSON.stringify(cost)}`)
|
|
95
|
+
if (typeof capability === "string") facts.push(`capability: ${JSON.stringify(capability)}`)
|
|
84
96
|
const efforts = before[id]?.efforts
|
|
85
97
|
if (Array.isArray(efforts)) facts.push(`efforts: [${efforts.map((x) => JSON.stringify(x)).join(", ")}]`)
|
|
86
98
|
const name = before[id]?.name ?? id
|