@magpie-community/opencode-zcode-auth 0.1.11 → 0.1.12

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.
Files changed (2) hide show
  1. package/index.mjs +11 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -366,7 +366,9 @@ const isNum = (v) => typeof v === "number" && Number.isFinite(v)
366
366
  // the current value), else the percentage given. TIME_LIMIT is the month's
367
367
  // MCP tool calls, which ZCode shows but never stops the models on, so it is
368
368
  // set aside, as is a limit whose whole is told as 0: no cap (an older
369
- // plan's), which the vendor may still give as 100% used.
369
+ // plan's), which the vendor may still give as 100% used. A window whose
370
+ // count is told carries it as amount of limit, so magpie's card says the
371
+ // count as used or as left, as it says the share beside it (#659).
370
372
  function limitWindows(d) {
371
373
  const out = []
372
374
  for (const x of d?.limits ?? []) {
@@ -380,9 +382,13 @@ function limitWindows(d) {
380
382
  if (isNum(x.remaining)) {
381
383
  const used = total - x.remaining
382
384
  w.used = (100 * used) / total
385
+ w.amount = used
386
+ w.limit = total
383
387
  w.display = `${compact(used)} / ${compact(total)}`
384
388
  } else if (isNum(x.currentValue)) {
385
389
  if (!isNum(x.percentage)) w.used = (100 * x.currentValue) / total
390
+ w.amount = x.currentValue
391
+ w.limit = total
386
392
  w.display = `${compact(x.currentValue)} / ${compact(total)}`
387
393
  }
388
394
  }
@@ -508,7 +514,11 @@ async function giftOf(s) {
508
514
  const w = { name: base, used: 0, _plan: str(owner.name), _spent: giftSpent(x) }
509
515
  if (used === undefined) used = total !== undefined && left !== undefined ? total - left : 0
510
516
  if (total > 0) {
517
+ // the bucket's count as amount of limit, as the Coding windows' is
518
+ // (#659): magpie says it as used or as left, as it says the share
511
519
  w.used = (100 * used) / total
520
+ w.amount = used
521
+ w.limit = total
512
522
  w.display = `${compact(used)} / ${compact(total)}`
513
523
  }
514
524
  if (w._spent) w.used = Math.max(100, w.used)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-zcode-auth",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "OpenCode provider plugin: signs in to Z.ai's or BigModel's (智谱) GLM Coding Plan as ZCode does, including team seats and ZCode's Start Plan",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",