@magpie-community/opencode-zcode-auth 0.1.20 → 0.1.21
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/README.md +3 -2
- package/index.mjs +12 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,8 +21,9 @@ over Anthropic's Messages API. Provider id: `zcode`.
|
|
|
21
21
|
- zcode.z.ai serves the Start Plan only to requests that look like the
|
|
22
22
|
ZCode client's own, and refuses others with HTTP 405 "request has been
|
|
23
23
|
blocked due to unusual activity". So a Start Plan request goes as
|
|
24
|
-
ZCode's does: ZCode's headers, ZCode's system
|
|
25
|
-
agent's
|
|
24
|
+
ZCode's does: ZCode's headers, ZCode's three system blocks with the
|
|
25
|
+
agent's system prompt at the end of the third (a fourth block is
|
|
26
|
+
refused, #343), the day in a `<system-reminder>` turn before the agent's
|
|
26
27
|
turns, and the sign-in's device id in `metadata.user_id`. GLM Coding
|
|
27
28
|
Plan and team requests go as the agent sent them. One it still turns
|
|
28
29
|
away (a 405, the block page or code 3012) comes back with what to do
|
package/index.mjs
CHANGED
|
@@ -1484,7 +1484,8 @@ function contextPrefix() {
|
|
|
1484
1484
|
}
|
|
1485
1485
|
|
|
1486
1486
|
// dress is a Messages request body as ZCode sends it: ZCode's three cached
|
|
1487
|
-
// system blocks,
|
|
1487
|
+
// system blocks and no more, the agent's own system text at the end of the
|
|
1488
|
+
// third (#343); the context
|
|
1488
1489
|
// prefix as the first turn; no cache mark in the turns but on the last
|
|
1489
1490
|
// block of the last; none on the tools; metadata.user_id naming the
|
|
1490
1491
|
// sign-in's device. site names the powered-by line's provider, place where
|
|
@@ -1502,18 +1503,20 @@ function dress(text, site, device, place) {
|
|
|
1502
1503
|
const cached = (t) => ({ type: "text", text: t, cache_control: { type: "ephemeral" } })
|
|
1503
1504
|
const provider = site === "bigmodel" ? "bigmodel-api" : "zai-api"
|
|
1504
1505
|
const model = typeof b.model === "string" ? b.model : ""
|
|
1506
|
+
// The agent's own system text joins the third block, as ZCode's
|
|
1507
|
+
// ContextBuilder (3.14.3, glm/zcode.cjs assembleSystemMessages) joins
|
|
1508
|
+
// every dynamic system section, an added one too, with "\n\n" into
|
|
1509
|
+
// that one block: ZCode never sends more than three. zcode.z.ai turns a
|
|
1510
|
+
// fourth block away with 405/3012 (#343), and the first two must stay
|
|
1511
|
+
// byte for byte ZCode's.
|
|
1505
1512
|
const own = []
|
|
1506
1513
|
if (typeof b.system === "string") {
|
|
1507
|
-
if (b.system.trim()) own.push(
|
|
1514
|
+
if (b.system.trim()) own.push(b.system)
|
|
1508
1515
|
} else if (Array.isArray(b.system)) {
|
|
1509
|
-
for (const x of b.system) if (x?.type === "text" && typeof x.text === "string" && x.text) own.push(
|
|
1516
|
+
for (const x of b.system) if (x?.type === "text" && typeof x.text === "string" && x.text.trim()) own.push(x.text)
|
|
1510
1517
|
}
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
cached(PROMPT.stableSections.join("\n\n")),
|
|
1514
|
-
cached("\n\n" + [PROMPT.beforeEnvironment, environment(provider, model, place), PROMPT.afterEnvironment].join("\n\n")),
|
|
1515
|
-
...own,
|
|
1516
|
-
]
|
|
1518
|
+
const dynamic = [PROMPT.beforeEnvironment, environment(provider, model, place), PROMPT.afterEnvironment, ...own]
|
|
1519
|
+
b.system = [cached(PROMPT.cliPrefix), cached(PROMPT.stableSections.join("\n\n")), cached("\n\n" + dynamic.join("\n\n"))]
|
|
1517
1520
|
b.messages = [contextPrefix(), ...b.messages]
|
|
1518
1521
|
let last = null
|
|
1519
1522
|
for (const m of b.messages) {
|
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.21",
|
|
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",
|