@magpie-community/opencode-opendesign-auth 0.1.9 → 0.1.10
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 +35 -3
- package/opencode2.mjs +4 -1
- 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
|
@@ -366,16 +366,48 @@ function seed() {
|
|
|
366
366
|
return Object.fromEntries(Object.entries(MODELS).map(([id, m]) => [id, modelOf(id, m)]))
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
// withSeed() is a catalog entry's facts with the seed's filling what the
|
|
370
|
+
// entry leaves out: a limit, a cost or capability word the catalog doesn't
|
|
371
|
+
// give is the seed's, not modelOf's 200K/32K fallback or no word at all.
|
|
372
|
+
//
|
|
373
|
+
// input is the seed's and the catalog's together (#829). The seed's input is
|
|
374
|
+
// what amr-link's own catalog listed when models.mjs was last refreshed
|
|
375
|
+
// (refresh-models.mjs writes only what is listed), and DeepSeek V4.1 Flash
|
|
376
|
+
// Eco took an image on amr-link while the live entry left image out. The two
|
|
377
|
+
// mistakes don't cost the same: a kind listed that the model refuses is the
|
|
378
|
+
// vendor's visible error, while a kind dropped is silent, as magpie hands the
|
|
379
|
+
// image to another model for a description, at that account's cost, and
|
|
380
|
+
// sends this one text. So a catalog that lists text only takes nothing away
|
|
381
|
+
// from a kind the seed declares; refresh-models.mjs says when it does, and
|
|
382
|
+
// removing a kind is a change to models.mjs. A model the seed doesn't know,
|
|
383
|
+
// or a kind it doesn't declare, is the catalog's alone.
|
|
384
|
+
function withSeed(id, f) {
|
|
385
|
+
const s = MODELS[id] ?? {}
|
|
386
|
+
const positive = (n) => Number.isFinite(n) && n > 0
|
|
387
|
+
const seedInput = Array.isArray(s.input) ? s.input.filter((x) => typeof x === "string" && x !== "text") : []
|
|
388
|
+
return {
|
|
389
|
+
...f,
|
|
390
|
+
context: positive(f.context) ? f.context : s.context,
|
|
391
|
+
output: positive(f.output) ? f.output : s.output,
|
|
392
|
+
input: [...new Set([...seedInput, ...f.input])],
|
|
393
|
+
cost: f.cost || text(s.cost),
|
|
394
|
+
capability: f.capability || text(s.capability),
|
|
395
|
+
name: s.name ?? id,
|
|
396
|
+
efforts: s.efforts,
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
369
400
|
// modelsOf() shapes amr-link's live catalog as magpie's models: the list an
|
|
370
401
|
// 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
|
-
//
|
|
402
|
+
// model the seed knows keeps its name and its measured levels, which the
|
|
403
|
+
// catalog doesn't carry, and what the seed says of it that the catalog
|
|
404
|
+
// doesn't (withSeed).
|
|
373
405
|
function modelsOf(catalog) {
|
|
374
406
|
const out = {}
|
|
375
407
|
for (const m of catalog?.data ?? []) {
|
|
376
408
|
const id = text(m?.id)
|
|
377
409
|
if (!id) continue
|
|
378
|
-
out[id] = servedOf(id,
|
|
410
|
+
out[id] = servedOf(id, withSeed(id, facts(m)))
|
|
379
411
|
}
|
|
380
412
|
return out
|
|
381
413
|
}
|
package/opencode2.mjs
CHANGED
|
@@ -86,7 +86,10 @@ export function fieldsOf(prompts) {
|
|
|
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
88
|
// a prompt shown only when another answer says so can't be required
|
|
89
|
-
|
|
89
|
+
// a prompt shown only when another answer says so can't be required, and
|
|
90
|
+
// neither can one whose own validate() accepts an empty answer (the
|
|
91
|
+
// browser sign-in's optional API key)
|
|
92
|
+
if (!p.condition && p.required !== false) f.required = true
|
|
90
93
|
out.push(f)
|
|
91
94
|
}
|
|
92
95
|
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.10",
|
|
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
|