@arnilo/prism-provider-zai 0.0.14 → 0.0.16
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/CHANGELOG.md +11 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/models.js +1 -4
- package/dist/provider.js +10 -14
- package/dist/thinking.js +6 -10
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.16] - 2026-07-26
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Released with exact 0.0.16 graph.
|
|
7
|
+
|
|
8
|
+
## [0.0.15] - 2026-07-26
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Released with exact 0.0.15 graph.
|
|
13
|
+
|
|
3
14
|
## [0.0.14] - 2026-07-26
|
|
4
15
|
|
|
5
16
|
### Changed
|
|
@@ -44,7 +55,6 @@
|
|
|
44
55
|
|
|
45
56
|
- Malformed streamed tool-call arguments yield recoverable tool calls via `toolCallFromArgumentsText` instead of throwing `ProviderTransportError` / terminal stream errors.
|
|
46
57
|
|
|
47
|
-
|
|
48
58
|
## [0.0.8] - 2026-07-20
|
|
49
59
|
|
|
50
60
|
- Released with the exact 0.0.8 first-party package graph.
|
|
@@ -76,7 +86,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
76
86
|
|
|
77
87
|
- Pinned the required `@arnilo/prism` peer and package metadata to 0.0.5; runtime behavior is unchanged.
|
|
78
88
|
|
|
79
|
-
|
|
80
89
|
## [0.0.4] - 2026-07-14
|
|
81
90
|
|
|
82
91
|
### Changed
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export interface ZaiProviderPackageOptions {
|
|
|
7
7
|
readonly models?: readonly ModelConfig[];
|
|
8
8
|
}
|
|
9
9
|
export declare function createZaiProviderPackage(options?: ZaiProviderPackageOptions): ProviderPackage;
|
|
10
|
-
export { defineZaiModel,
|
|
11
|
-
export { createZaiProvider, toZaiMessage,
|
|
10
|
+
export { defineZaiModel, type ListZaiModelsOptions, listZaiModels, mapZaiModel, type ZaiModelConfig, type ZaiModelEntry, zaiModels, } from "./models.js";
|
|
11
|
+
export { createZaiProvider, toZaiMessage, ZAI_DEFAULT_BASE_URL, type ZaiProviderOptions, zaiBody, zaiEvents, } from "./provider.js";
|
|
12
12
|
export { zaiClearThinking, zaiPreserveThinking, zaiReasoningEffort, zaiThinking, zaiToolStream, } from "./thinking.js";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineProviderPackage } from "@arnilo/prism";
|
|
2
|
-
import { createZaiProvider } from "./provider.js";
|
|
3
2
|
import { zaiModels } from "./models.js";
|
|
3
|
+
import { createZaiProvider } from "./provider.js";
|
|
4
4
|
export function createZaiProviderPackage(options = {}) {
|
|
5
5
|
const providerId = options.id ?? "zai";
|
|
6
6
|
return defineProviderPackage({
|
|
@@ -16,6 +16,6 @@ export function createZaiProviderPackage(options = {}) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
export { defineZaiModel, listZaiModels, mapZaiModel, zaiModels, } from "./models.js";
|
|
19
|
-
export { createZaiProvider, toZaiMessage, zaiBody, zaiEvents,
|
|
19
|
+
export { createZaiProvider, toZaiMessage, ZAI_DEFAULT_BASE_URL, zaiBody, zaiEvents, } from "./provider.js";
|
|
20
20
|
export { zaiClearThinking, zaiPreserveThinking, zaiReasoningEffort, zaiThinking, zaiToolStream, } from "./thinking.js";
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
package/dist/models.js
CHANGED
|
@@ -165,10 +165,7 @@ function limitsForZaiModel(modelId) {
|
|
|
165
165
|
}
|
|
166
166
|
function looksLikeReasoningModel(modelId) {
|
|
167
167
|
const id = modelId.toLowerCase();
|
|
168
|
-
return (id.includes("glm-5")
|
|
169
|
-
|| id.includes("glm-4.7")
|
|
170
|
-
|| id.includes("glm-4.6")
|
|
171
|
-
|| id.includes("glm-4.5"));
|
|
168
|
+
return id.includes("glm-5") || id.includes("glm-4.7") || id.includes("glm-4.6") || id.includes("glm-4.5");
|
|
172
169
|
}
|
|
173
170
|
function looksLikeVisionModel(modelId) {
|
|
174
171
|
const id = modelId.toLowerCase();
|
package/dist/provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertStructuredOutputRequestSupported, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, resolveCredentialValue, toolCallFromArgumentsText } from "@arnilo/prism";
|
|
1
|
+
import { assertStructuredOutputRequestSupported, providerDone, providerError, providerTextDelta, providerThinkingDelta, providerToolCall, providerToolCallDelta, providerUsage, resolveCredentialValue, toolCallFromArgumentsText, } from "@arnilo/prism";
|
|
2
2
|
import { applyOpenAIChatStructuredOutput, mapOpenAIChatUsage, serializeOpenAITool } from "@arnilo/prism/providers/openai";
|
|
3
3
|
import { readBoundedResponseText, readSseData } from "@arnilo/prism/providers/transport";
|
|
4
4
|
import { zaiPreserveThinking, zaiReasoningEffort, zaiThinking, zaiToolStream } from "./thinking.js";
|
|
@@ -20,10 +20,10 @@ export function createZaiProvider(options = {}) {
|
|
|
20
20
|
headers: {
|
|
21
21
|
...request.options?.headers,
|
|
22
22
|
"content-type": "application/json",
|
|
23
|
-
...(token ? { authorization: `Bearer ${token}` } : {})
|
|
23
|
+
...(token ? { authorization: `Bearer ${token}` } : {}),
|
|
24
24
|
},
|
|
25
25
|
body: JSON.stringify(zaiBody(request)),
|
|
26
|
-
signal: request.signal
|
|
26
|
+
signal: request.signal,
|
|
27
27
|
});
|
|
28
28
|
if (!response.ok) {
|
|
29
29
|
return yield providerError(new Error(`Z.AI request failed: ${response.status} ${await readBoundedResponseText(response, { secrets })}`), secrets);
|
|
@@ -35,7 +35,7 @@ export function createZaiProvider(options = {}) {
|
|
|
35
35
|
catch (error) {
|
|
36
36
|
yield providerError(error, secrets);
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
export function zaiBody(request) {
|
|
@@ -55,7 +55,7 @@ export function zaiBody(request) {
|
|
|
55
55
|
// Resolved official fields win over raw compat/extra escape hatches.
|
|
56
56
|
thinking: zaiThinking(request),
|
|
57
57
|
reasoning_effort: zaiReasoningEffort(request),
|
|
58
|
-
tool_stream: zaiToolStream(request)
|
|
58
|
+
tool_stream: zaiToolStream(request),
|
|
59
59
|
};
|
|
60
60
|
applyOpenAIChatStructuredOutput(body, request.options?.structuredOutput);
|
|
61
61
|
return clean(body);
|
|
@@ -91,7 +91,7 @@ export async function* zaiEvents(body, signal) {
|
|
|
91
91
|
index,
|
|
92
92
|
id: tool.id,
|
|
93
93
|
name: tool.function?.name,
|
|
94
|
-
argumentsText: tool.function?.arguments
|
|
94
|
+
argumentsText: tool.function?.arguments,
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -112,15 +112,13 @@ export async function* zaiEvents(body, signal) {
|
|
|
112
112
|
export function toZaiMessage(message, model, preserveThinking = false) {
|
|
113
113
|
const capabilities = model.capabilities ?? {};
|
|
114
114
|
const thinkingParts = message.content.filter((part) => part.type === "thinking");
|
|
115
|
-
const reasoningContent = preserveThinking && thinkingParts.length > 0
|
|
116
|
-
? thinkingParts.map((part) => part.text).join("\n")
|
|
117
|
-
: undefined;
|
|
115
|
+
const reasoningContent = preserveThinking && thinkingParts.length > 0 ? thinkingParts.map((part) => part.text).join("\n") : undefined;
|
|
118
116
|
if (message.role === "tool") {
|
|
119
117
|
const result = message.content.find((part) => part.type === "tool_result");
|
|
120
118
|
return {
|
|
121
119
|
role: "tool",
|
|
122
120
|
tool_call_id: result?.toolCallId ?? "",
|
|
123
|
-
content: result ? JSON.stringify(result.result ?? result.error ?? null) : ""
|
|
121
|
+
content: result ? JSON.stringify(result.result ?? result.error ?? null) : "",
|
|
124
122
|
};
|
|
125
123
|
}
|
|
126
124
|
if (message.role === "assistant") {
|
|
@@ -133,9 +131,9 @@ export function toZaiMessage(message, model, preserveThinking = false) {
|
|
|
133
131
|
tool_calls: toolCalls.map((call) => ({
|
|
134
132
|
id: call.id,
|
|
135
133
|
type: "function",
|
|
136
|
-
function: { name: call.name, arguments: JSON.stringify(call.arguments) }
|
|
134
|
+
function: { name: call.name, arguments: JSON.stringify(call.arguments) },
|
|
137
135
|
})),
|
|
138
|
-
reasoning_content: reasoningContent
|
|
136
|
+
reasoning_content: reasoningContent,
|
|
139
137
|
});
|
|
140
138
|
}
|
|
141
139
|
}
|
|
@@ -145,8 +143,6 @@ export function toZaiMessage(message, model, preserveThinking = false) {
|
|
|
145
143
|
content.push({ type: "text", text: part.text });
|
|
146
144
|
}
|
|
147
145
|
else if (part.type === "thinking") {
|
|
148
|
-
// Handled via reasoning_content when preserving; otherwise dropped.
|
|
149
|
-
continue;
|
|
150
146
|
}
|
|
151
147
|
else if (part.type === "image") {
|
|
152
148
|
if (!capabilities.input?.includes("image")) {
|
package/dist/thinking.js
CHANGED
|
@@ -30,9 +30,7 @@ export function zaiThinking(request) {
|
|
|
30
30
|
* @see https://docs.z.ai/guides/capabilities/thinking
|
|
31
31
|
*/
|
|
32
32
|
export function zaiReasoningEffort(request) {
|
|
33
|
-
const effort = request.options?.compat?.reasoning_effort
|
|
34
|
-
?? request.options?.compat?.reasoningEffort
|
|
35
|
-
?? request.model.compat?.reasoning_effort;
|
|
33
|
+
const effort = request.options?.compat?.reasoning_effort ?? request.options?.compat?.reasoningEffort ?? request.model.compat?.reasoning_effort;
|
|
36
34
|
return typeof effort === "string" ? effort : undefined;
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
@@ -52,9 +50,7 @@ export function zaiClearThinking(request) {
|
|
|
52
50
|
const fromThinkingObject = readClearThinkingFromObject(request.options?.compat?.thinking ?? request.model.compat?.thinking);
|
|
53
51
|
if (fromThinkingObject !== undefined)
|
|
54
52
|
return fromThinkingObject;
|
|
55
|
-
const value = request.options?.compat?.clear_thinking
|
|
56
|
-
?? request.options?.compat?.clearThinking
|
|
57
|
-
?? request.model.compat?.clear_thinking;
|
|
53
|
+
const value = request.options?.compat?.clear_thinking ?? request.options?.compat?.clearThinking ?? request.model.compat?.clear_thinking;
|
|
58
54
|
return typeof value === "boolean" ? value : undefined;
|
|
59
55
|
}
|
|
60
56
|
/**
|
|
@@ -66,10 +62,10 @@ export function zaiPreserveThinking(request) {
|
|
|
66
62
|
const clear = zaiClearThinking(request);
|
|
67
63
|
if (clear === true)
|
|
68
64
|
return false;
|
|
69
|
-
const value = request.options?.compat?.preserveThinking
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
const value = request.options?.compat?.preserveThinking ??
|
|
66
|
+
request.options?.compat?.preserve_thinking ??
|
|
67
|
+
request.model.compat?.preserveThinking ??
|
|
68
|
+
request.model.compat?.preserve_thinking;
|
|
73
69
|
if (typeof value === "boolean")
|
|
74
70
|
return value;
|
|
75
71
|
// clear_thinking:false implies preserved thinking even without an explicit preserve flag.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arnilo/prism-provider-zai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Z.AI provider package for Prism.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"pack:dry-run": "npm pack --dry-run"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@arnilo/prism": "0.0.
|
|
28
|
+
"@arnilo/prism": "0.0.16"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@arnilo/prism": "file:../.."
|