@magpie-community/opencode-zcode-auth 0.1.4 → 0.1.6
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 +13 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -282,13 +282,18 @@ const isNum = (v) => typeof v === "number" && Number.isFinite(v)
|
|
|
282
282
|
|
|
283
283
|
// limitWindows are /api/monitor/usage/quota/limit's limits as windows: what
|
|
284
284
|
// is used of the whole when both are told (the whole less what remains, or
|
|
285
|
-
// the current value), else the percentage given.
|
|
285
|
+
// the current value), else the percentage given. TIME_LIMIT is the month's
|
|
286
|
+
// MCP tool calls, which ZCode shows but never stops the models on, so it is
|
|
287
|
+
// set aside, as is a limit whose whole is told as 0: no cap (an older
|
|
288
|
+
// plan's), which the vendor may still give as 100% used.
|
|
286
289
|
function limitWindows(d) {
|
|
287
290
|
const out = []
|
|
288
291
|
for (const x of d?.limits ?? []) {
|
|
289
292
|
const span = spanOf(Math.trunc(Number(x?.unit) || 0), x?.number)
|
|
290
293
|
const w = { name: windowName(span), used: 0 }
|
|
294
|
+
if (String(x?.type ?? "").toUpperCase() === "TIME_LIMIT") (w.name = "MCP · Month"), (w.aside = true)
|
|
291
295
|
if (isNum(x?.percentage)) w.used = x.percentage
|
|
296
|
+
if (x?.usage === 0) (w.used = 0), (w.aside = true)
|
|
292
297
|
if (isNum(x?.usage) && x.usage > 0) {
|
|
293
298
|
const total = x.usage
|
|
294
299
|
if (isNum(x.remaining)) {
|
|
@@ -1043,9 +1048,14 @@ export async function ZCodeAuthPlugin({ client }) {
|
|
|
1043
1048
|
const start = await onStart(s).catch(() => false)
|
|
1044
1049
|
const base = start ? START_BASE : s.base
|
|
1045
1050
|
let ms = modelsOf(await zcodeConfig().catch(() => null), planID(base))
|
|
1046
|
-
|
|
1051
|
+
// ZCode's config can't be had: its table stands in, and magpie keeps
|
|
1052
|
+
// the list it was told last, as the built-in keeps the one it fetched last
|
|
1053
|
+
const fell = !ms.length
|
|
1054
|
+
if (fell) ms = start ? START_MODELS : MODELS
|
|
1047
1055
|
const url = s.base + "/v1"
|
|
1048
|
-
|
|
1056
|
+
const out = Object.fromEntries(ms.map((m) => [m.id, model(m, url)]))
|
|
1057
|
+
if (fell) out[Symbol.for("magpie.fellBack")] = true
|
|
1058
|
+
return out
|
|
1049
1059
|
},
|
|
1050
1060
|
},
|
|
1051
1061
|
auth: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-zcode-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
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",
|