@magpie-community/opencode-zcode-auth 0.1.61 → 0.1.63
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 +5 -1
- package/opencode2.mjs +25 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1804,7 +1804,11 @@ function ownSignIn() {
|
|
|
1804
1804
|
else s = { ...s, jwt, base: s.base || ZAI_BASE, site: s.base === BIGMODEL_BASE ? "bigmodel" : "zai" }
|
|
1805
1805
|
if (!s.key && !s.jwt && !isTeam(s)) return null
|
|
1806
1806
|
let info = {}
|
|
1807
|
-
|
|
1807
|
+
// The JWT belongs to the app's active sign-in. Cached profiles from
|
|
1808
|
+
// another provider must not name it, and 3.18's China sign-in is zai_cn.
|
|
1809
|
+
const active = decrypt(key, store["oauth:active_provider"])
|
|
1810
|
+
const families = [...new Set([active, "zai", "zai_cn", "bigmodel"].filter((x) => ["zai", "zai_cn", "bigmodel"].includes(x)))]
|
|
1811
|
+
for (const name of families.map((x) => `oauth:${x}:user_info`)) {
|
|
1808
1812
|
const v = decrypt(key, store[name])
|
|
1809
1813
|
if (v && !first(info.email, info.name, info.user_id)) {
|
|
1810
1814
|
try {
|
package/opencode2.mjs
CHANGED
|
@@ -575,7 +575,31 @@ async function setupPlugin(ctx, fn, live) {
|
|
|
575
575
|
}
|
|
576
576
|
} catch {}
|
|
577
577
|
})()
|
|
578
|
-
|
|
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-zcode-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.63",
|
|
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, and claims its gift plans daily",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./opencode.mjs",
|