@magpie-community/opencode-zcode-auth 0.1.2 → 0.1.3
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 +15 -7
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -39,7 +39,6 @@ const MODELS = [
|
|
|
39
39
|
{ id: "GLM-5-Turbo", context: 200_000, output: 64_000, efforts: ["none", "high"] },
|
|
40
40
|
]
|
|
41
41
|
const START_MODELS = MODELS.filter((m) => m.id !== "GLM-5.3")
|
|
42
|
-
const OUTPUT = 131_072 // when ZCode's config names none
|
|
43
42
|
|
|
44
43
|
const SITES = {
|
|
45
44
|
zai: { name: "Z.ai", api: ZAI_API, base: ZAI_BASE, subscribe: "z.ai/subscribe" },
|
|
@@ -975,7 +974,8 @@ const entry = (m) => ({
|
|
|
975
974
|
tool_call: true,
|
|
976
975
|
attachment: !!m.image,
|
|
977
976
|
modalities: { input: m.image ? ["text", "image"] : ["text"], output: ["text"] },
|
|
978
|
-
|
|
977
|
+
// what ZCode's config names, else 0 (unknown), as magpie's built-in
|
|
978
|
+
limit: { context: m.context || 0, output: m.output || 0 },
|
|
979
979
|
cost: { input: 0, output: 0, cache_read: 0, cache_write: 0 },
|
|
980
980
|
variants: variants(m.efforts),
|
|
981
981
|
})
|
|
@@ -1102,6 +1102,14 @@ export async function ZCodeAuthPlugin({ client }) {
|
|
|
1102
1102
|
const auth = await getAuth()
|
|
1103
1103
|
const s = stateOf(auth)
|
|
1104
1104
|
if (!s) return { error: "not signed in" }
|
|
1105
|
+
// every card starts from the plan the sign-in saved, as magpie's
|
|
1106
|
+
// built-in did: a reply without a level, a team detail that
|
|
1107
|
+
// failed or an error keeps it
|
|
1108
|
+
const saved = (out) => {
|
|
1109
|
+
const plan = s.plan || auth?.plan
|
|
1110
|
+
if (plan && !out.plan) out.plan = plan
|
|
1111
|
+
return out
|
|
1112
|
+
}
|
|
1105
1113
|
try {
|
|
1106
1114
|
if (isTeam(s)) {
|
|
1107
1115
|
let key = s.key
|
|
@@ -1112,12 +1120,12 @@ export async function ZCodeAuthPlugin({ client }) {
|
|
|
1112
1120
|
await client?.auth?.set?.({ path: { id: provider?.id ?? PROVIDER }, body: next }).catch?.(() => {})
|
|
1113
1121
|
}
|
|
1114
1122
|
}
|
|
1115
|
-
return await teamUsage(s, key)
|
|
1123
|
+
return saved(await teamUsage(s, key))
|
|
1116
1124
|
}
|
|
1117
|
-
if (await onStart(s)) return await startUsage(s)
|
|
1118
|
-
return await codingUsage(s)
|
|
1125
|
+
if (await onStart(s)) return saved(await startUsage(s))
|
|
1126
|
+
return saved(await codingUsage(s))
|
|
1119
1127
|
} catch (e) {
|
|
1120
|
-
return { error: e?.message ?? String(e) }
|
|
1128
|
+
return saved({ error: e?.message ?? String(e) })
|
|
1121
1129
|
}
|
|
1122
1130
|
},
|
|
1123
1131
|
methods: [
|
|
@@ -1145,4 +1153,4 @@ export async function ZCodeAuthPlugin({ client }) {
|
|
|
1145
1153
|
}
|
|
1146
1154
|
|
|
1147
1155
|
// for tests
|
|
1148
|
-
export const _internal = { limitWindows, termOf, startUsage, routes, teamKeys, ownSignIn, stateOf }
|
|
1156
|
+
export const _internal = { entry, limitWindows, termOf, startUsage, routes, teamKeys, ownSignIn, stateOf }
|
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.3",
|
|
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",
|