@magpie-community/opencode-opendesign-auth 0.1.12 → 0.1.13

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/index.mjs CHANGED
@@ -42,6 +42,11 @@ const MODEL_WIRE = {
42
42
  "glm-5.3-flash": "anthropic",
43
43
  }
44
44
  const wireOf = (id) => WIRE[MODEL_WIRE[id]] ?? WIRE.chat
45
+ // alsoOf are the two APIs besides its own a model is served on (below),
46
+ // which magpie relays a client's request to as it was sent rather than
47
+ // translating it to the declared one (m.also; gaubeebangeel on X:
48
+ // OpenDesign's Anthropic request to a chat model went as chat completions)
49
+ const alsoOf = (id) => Object.values(WIRE).filter((w) => w !== wireOf(id))
45
50
  // The API a model is declared on is only its default: amr-link serves
46
51
  // every model on all three (keyblues, plugins#888: each of the fourteen
47
52
  // answered on chat completions and Responses at /v1 and on Anthropic's
@@ -346,6 +351,7 @@ function modelOf(id, m) {
346
351
  // the API magpie asks this model on (WIRE above), per model
347
352
  api: { npm: wireOf(id) },
348
353
  provider: { npm: wireOf(id) },
354
+ also: alsoOf(id),
349
355
  ...(rate && { rate }),
350
356
  limit: {
351
357
  context: Number.isFinite(context) && context > 0 ? context : 200_000,
@@ -370,6 +376,7 @@ function servedOf(id, m) {
370
376
  id,
371
377
  name: c.name,
372
378
  api: { id, url: LINK, npm: wireOf(id) },
379
+ also: alsoOf(id),
373
380
  status: "active",
374
381
  headers: {},
375
382
  options: {},
@@ -528,7 +535,7 @@ export const OpenDesignAuthPlugin = async () => {
528
535
  // catalog's 232000 for glm-5.3-flash, which amr-link refuses (CAP)
529
536
  const out = Number(m.limit?.output)
530
537
  const limit = CAP[id] && !(out > 0 && out <= CAP[id]) ? { limit: { ...(m.limit ?? {}), output: CAP[id] } } : {}
531
- models[id] = { ...m, ...limit, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, ...(rate && { rate }) }
538
+ models[id] = { ...m, ...limit, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, also: alsoOf(id), ...(rate && { rate }) }
532
539
  }
533
540
  cfg.provider[ID] = {
534
541
  name: "Open Design",
package/opencode2.mjs CHANGED
@@ -575,7 +575,31 @@ async function setupPlugin(ctx, fn, live) {
575
575
  }
576
576
  } catch {}
577
577
  })()
578
- void refresh()
578
+ // A plugin still reading its list in the background when the first read
579
+ // returned (agy-cli: `agy models` and a session probe take seconds, and
580
+ // the first read gets its static list) says so through
581
+ // provider.warming(): the list is read once more when that ends, once,
582
+ // and no later than a minute on.
583
+ const warmed = async () => {
584
+ let w
585
+ try {
586
+ w = typeof hooks.provider?.warming === "function" ? hooks.provider.warming() : null
587
+ } catch {
588
+ return
589
+ }
590
+ if (!w || typeof w.then !== "function") return
591
+ let timer
592
+ await Promise.race([
593
+ Promise.resolve(w).catch(() => {}),
594
+ new Promise((r) => {
595
+ timer = setTimeout(r, 60_000)
596
+ timer.unref?.()
597
+ }),
598
+ ])
599
+ clearTimeout(timer)
600
+ if (live.on) await refresh()
601
+ }
602
+ void refresh().then(warmed, () => {})
579
603
  }
580
604
 
581
605
  export async function setup(ctx, mod = v1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-opendesign-auth",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
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",