@magpie-community/opencode-opendesign-auth 0.1.8 → 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 CHANGED
@@ -58,9 +58,13 @@ is there for a machine that can't open the approval page.
58
58
  Nothing is listed per account at request time from anywhere but the vendor:
59
59
  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
- account is offered is what its plan entitles it to right now. Limits, input
62
- modalities and the vendor's own cost words (`rate`, e.g. `x0.5` for "low")
63
- come from that same catalog.
61
+ account is offered is what its plan entitles it to right now. Limits and
62
+ input modalities come from that same catalog; the quota multiplier (`rate`)
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`
@@ -69,6 +73,33 @@ catalog calls `standard` too. Those models reason at `low` and `high`;
69
73
  GPT-6 Luna has no levels. A model the seed doesn't know reasons when its
70
74
  vendor tier is `advanced`, with no levels until it is measured.
71
75
 
76
+ `deepseek-v4.1-flash-eco` is the same model on the low-priority, high-quota
77
+ schedule (the vendor's announcement: 模型效果完全无损), so `models.mjs` gives
78
+ it DeepSeek V4.1 Flash's limits, input kinds and levels; only the quota
79
+ multiplier differs (0.27× against 0.5×).
80
+
81
+ ### Quota multipliers
82
+
83
+ `rate` is the plan's deduction multiplier — what one dollar of model spend
84
+ takes out of the Design Plan allowance — not the catalog's cost word. The
85
+ table in `rates.mjs` is the vendor's published one,
86
+ [模型额度与使用说明](https://open-design.ai/zh/model-credits/) (read
87
+ 2026-11-06; Go, Plus, Pro and Max carry the same table):
88
+
89
+ | Model | Rate |
90
+ | --- | --- |
91
+ | DeepSeek V4.1 Flash | 0.5× |
92
+ | DeepSeek V4.1 Flash Eco | 0.27× |
93
+ | DeepSeek V4 Flash, DeepSeek V4 Flash Vision Exp, DeepSeek V4 Pro, GLM-5.3 Flash, Hy4 Preview, Kimi K2.7 Code, MiMo V2.6 Flash, MiMo V2.6 Pro, MiniMax M3.1 Flash | 1× |
94
+ | Claude Haiku 5.5, GLM-5.3 Flash-X | 2× |
95
+ | GPT-6 Luna | 4× |
96
+
97
+ The catalog's own cost words stay as the fallback for a model the table
98
+ doesn't name yet; they disagree with the plan for most models (Claude Haiku
99
+ 5.5 and GPT-6 Luna are "low" there but 2× and 4× here). DeepSeek V4.1
100
+ Flash's 0.25× "限时谷价" row is a time-limited promotional price, not a
101
+ second model id, so the model keeps 0.5×.
102
+
72
103
  `models.mjs` is the seed the provider has *before* anyone signs in. Refresh
73
104
  it from the live catalog with:
74
105
 
@@ -78,8 +109,9 @@ bun refresh-models.mjs # or OPENDESIGN_KEY=sk-amr-… bun …
78
109
  ```
79
110
 
80
111
  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.
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.
83
115
 
84
116
  Requests go to `https://amr-link.open-design.ai/v1`, each model on the API
85
117
  amr-link answers its thinking on (measured, plugins#141): chat completions
package/index.mjs CHANGED
@@ -17,6 +17,7 @@ import { hostname } from "node:os"
17
17
  import pkg from "./package.json" with { type: "json" }
18
18
 
19
19
  import { MODELS } from "./models.mjs"
20
+ import { RATES } from "./rates.mjs"
20
21
 
21
22
  const ID = "opendesign"
22
23
  const CONTROL = "https://amr-api.open-design.ai"
@@ -49,11 +50,21 @@ const TIMEOUT = 20_000
49
50
  const HOUR = 3600
50
51
  const WEEK = 7 * 24 * HOUR
51
52
 
52
- // The vendor's spending words as magpie's rate, and its quality words as
53
+ // The vendor's spending words as magpie's rate — the fallback only now: the
54
+ // plan's real deduction multipliers are the table rates.mjs holds, and the
55
+ // catalog's words disagree with it for most models. Its quality words say
53
56
  // whether the model thinks before it answers.
54
57
  const COST = { low: "x0.5", medium: "x1", high: "x2", very_high: "x4" }
55
58
  const THINKING = { advanced: true, standard: false }
56
59
 
60
+ // rateOf is a model's quota multiplier as magpie reads a rate ("x0.5"): the
61
+ // plan's own multiplier when rates.mjs names the model, and its catalog cost
62
+ // word for one the table doesn't name yet.
63
+ const rateOf = (id, m) => {
64
+ const named = RATES[id]
65
+ return named === undefined ? COST[text(m?.cost)] : "x" + named
66
+ }
67
+
57
68
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
58
69
  const text = (v) => (typeof v === "string" && v.trim() ? v.trim() : "")
59
70
 
@@ -275,7 +286,7 @@ function levelsOf(m) {
275
286
  // "advanced". variants are its levels as @ai-sdk/openai options: magpie
276
287
  // shows a model's levels only from its variants, and only when it reasons.
277
288
  function modelOf(id, m) {
278
- const rate = COST[text(m?.cost)]
289
+ const rate = rateOf(id, m)
279
290
  const levels = levelsOf(m)
280
291
  const thinking = levels.length > 0 || (THINKING[text(m?.capability)] ?? !!m?.reasoning)
281
292
  const context = Number(m?.context)
@@ -355,16 +366,48 @@ function seed() {
355
366
  return Object.fromEntries(Object.entries(MODELS).map(([id, m]) => [id, modelOf(id, m)]))
356
367
  }
357
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
+
358
400
  // modelsOf() shapes amr-link's live catalog as magpie's models: the list an
359
401
  // account's plan entitles it to right now, as provider.models gives them. A
360
- // model the seed knows keeps its name and its measured levels; the catalog
361
- // carries ids only.
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).
362
405
  function modelsOf(catalog) {
363
406
  const out = {}
364
407
  for (const m of catalog?.data ?? []) {
365
408
  const id = text(m?.id)
366
409
  if (!id) continue
367
- out[id] = servedOf(id, { ...facts(m), name: MODELS[id]?.name ?? id, efforts: MODELS[id]?.efforts })
410
+ out[id] = servedOf(id, withSeed(id, facts(m)))
368
411
  }
369
412
  return out
370
413
  }
@@ -430,12 +473,14 @@ export const OpenDesignAuthPlugin = async () => {
430
473
  config: async (cfg) => {
431
474
  cfg.provider ??= {}
432
475
  const was = cfg.provider[ID] ?? {}
433
- // the wire is this plugin's to declare, never a kept copy's: magpie
434
- // hands back what the hook last wrote, and a model kept from 0.1.5
435
- // would otherwise stay on the Responses API it chose for every model
476
+ // the wire and the quota multiplier are this plugin's to declare, never
477
+ // a kept copy's: magpie hands back what the hook last wrote, and a model
478
+ // kept from an earlier version would otherwise stay on the Responses API
479
+ // it chose for every model, or on a rate the plan no longer charges
436
480
  const models = { ...seed(), ...(was.models ?? {}) }
437
481
  for (const [id, m] of Object.entries(models)) {
438
- models[id] = { ...m, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) } }
482
+ const rate = RATES[id] === undefined ? undefined : "x" + RATES[id]
483
+ models[id] = { ...m, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, ...(rate && { rate }) }
439
484
  }
440
485
  cfg.provider[ID] = {
441
486
  name: "Open Design",
@@ -505,4 +550,4 @@ export const OpenDesignAuthPlugin = async () => {
505
550
 
506
551
  // _internal is what the tests read through; magpie calls every exported
507
552
  // function as a plugin, so only the plugin itself is exported bare.
508
- export const _internal = { authOf, allowances, controlKeyOf, credits, modelsOf, money, runtimeKeyOf, said, startDevice, thePlan, usedPercent, waitForDevice, windowName, when, workspaceOf }
553
+ export const _internal = { authOf, allowances, controlKeyOf, credits, modelsOf, money, rateOf, runtimeKeyOf, said, startDevice, thePlan, usedPercent, waitForDevice, windowName, when, workspaceOf }
package/models.mjs CHANGED
@@ -6,10 +6,11 @@
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;
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.
9
+ // words, which the plugin turns into magpie's thinking flag (the rate is
10
+ // rates.mjs's, the plan's own deduction multiplier); efforts: the reasoning
11
+ // levels amr-link was seen to take and think at, measured, not read (#137;
12
+ // max too, plugins#141: the vendor names low, high and max when asked for one
13
+ // it doesn't take), so a refresh keeps them.
13
14
 
14
15
  export const MODELS = {
15
16
  "claude-haiku-5.5": { name: "Claude Haiku 5.5", context: 1000000, output: 132000, input: ["image", "file"], cost: "low", capability: "standard", efforts: ["low", "high", "max"] },
@@ -17,6 +18,9 @@ export const MODELS = {
17
18
  "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
19
  "deepseek-v4-pro": { name: "DeepSeek V4 Pro", context: 1048000, output: 232000, cost: "high", capability: "advanced", efforts: ["low", "high", "max"] },
19
20
  "deepseek-v4.1-flash": { name: "DeepSeek V4.1 Flash", context: 1048000, output: 232000, input: ["image"], cost: "low", capability: "advanced", efforts: ["low", "high", "max"] },
21
+ // the same model on the low-priority, high-quota schedule: same limits, same
22
+ // measured levels as the line above (its rate, 0.27×, is rates.mjs's)
23
+ "deepseek-v4.1-flash-eco": { name: "DeepSeek V4.1 Flash Eco", context: 1048000, output: 232000, input: ["image"], cost: "low", capability: "advanced", efforts: ["low", "high", "max"] },
20
24
  "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
25
  "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
26
  "gpt-6-luna": { name: "GPT-6 Luna", context: 1050000, output: 304000, input: ["image", "file"], cost: "low", capability: "standard", efforts: [] },
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
- if (!p.condition) f.required = true
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.8",
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",
@@ -9,6 +9,7 @@
9
9
  "opencode.mjs",
10
10
  "opencode2.mjs",
11
11
  "models.mjs",
12
+ "rates.mjs",
12
13
  "refresh-models.mjs",
13
14
  "README.md"
14
15
  ],
package/rates.mjs ADDED
@@ -0,0 +1,34 @@
1
+ // The Design Plan's own deduction multipliers — the "额度扣除倍率" table that
2
+ // https://open-design.ai/zh/model-credits/ publishes (read 2026-11-06; Go,
3
+ // Plus, Pro and Max carry the same table). A rate is what one dollar of model
4
+ // spend takes out of the plan's allowance: 0.27× is cheaper than 1×, 4× is
5
+ // four times dearer.
6
+ //
7
+ // The catalog's cost words are a different thing, and mostly disagree:
8
+ // amr-link calls Claude Haiku 5.5 and GPT-6 Luna "low" while the plan charges
9
+ // 2× and 4× for them, calls GLM-5.3 Flash and MiMo V2.6 Flash "low" while the
10
+ // plan charges 1×, and calls DeepSeek V4 Pro "high" and GLM-5.3 Flash-X
11
+ // "medium" while the plan charges 1× and 2×. So a rate read off those words is
12
+ // wrong for most models; the table below wins, and only a model it doesn't
13
+ // name (a new one) falls back to its catalog word.
14
+ //
15
+ // DeepSeek V4.1 Flash's 0.25× "限时谷价" / "Off-peak promo" row is a
16
+ // time-limited promotional price, not a second model id; the model keeps 0.5×.
17
+ // DeepSeek V4.1 Flash Eco is the same model on the low-priority, high-quota
18
+ // schedule (the vendor's announcement: 模型效果完全无损), charged 0.27×.
19
+ export const RATES = {
20
+ "claude-haiku-5.5": 2,
21
+ "deepseek-v4-flash": 1,
22
+ "deepseek-v4-flash-vision-exp": 1,
23
+ "deepseek-v4-pro": 1,
24
+ "deepseek-v4.1-flash": 0.5,
25
+ "deepseek-v4.1-flash-eco": 0.27,
26
+ "glm-5.3-flash": 1,
27
+ "glm-5.3-flashx": 2,
28
+ "gpt-6-luna": 4,
29
+ "hy4-preview": 1,
30
+ "kimi-k2.7-code": 1,
31
+ "mimo-v2.6-flash": 1,
32
+ "mimo-v2.6-pro": 1,
33
+ "minimax-m3.1-flash": 1,
34
+ }
@@ -64,23 +64,35 @@ try {
64
64
  ;({ MODELS: before } = await import(pathToFileURL(TARGET).href))
65
65
  } catch {}
66
66
 
67
- const input = (m) => {
68
- const said = Array.isArray(m?.architecture?.input_modalities) ? m.architecture.input_modalities : []
69
- return said.filter((x) => typeof x === "string" && x !== "text")
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
- const context = Number(meta.context_limit)
77
- const output = Number(meta.context_budget)
78
- if (Number.isFinite(context) && context > 0) facts.push(`context: ${context}`)
79
- if (Number.isFinite(output) && output > 0) facts.push(`output: ${output}`)
80
- const extra = input(m)
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
- if (typeof meta.cost === "string") facts.push(`cost: ${JSON.stringify(meta.cost)}`)
83
- if (typeof meta.capability === "string") facts.push(`capability: ${JSON.stringify(meta.capability)}`)
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
@@ -95,9 +107,10 @@ const header = `// The models an account is offered before anyone has signed in
95
107
  //
96
108
  // name: what the model is called; context/output: its token limits; input:
97
109
  // the non-text modalities it takes; cost and capability: the vendor's own
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.
110
+ // words, which the plugin turns into magpie's thinking flag (the rate is
111
+ // rates.mjs's, the plan's own deduction multiplier); efforts: the reasoning
112
+ // levels amr-link was seen to take and think at, measured, not read (#137),
113
+ // so a refresh keeps them.
101
114
 
102
115
  export const MODELS = {
103
116
  ${lines.join("\n")}