@openclaw/kimi-provider 2026.9.7 → 2026.10.1-beta.1
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/dist/index.js +2 -4
- package/dist/stream.js +29 -60
- package/package.json +4 -4
- package/dist/replay-policy.js +0 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { a as normalizeKimiCodingModelId, i as buildKimiCodingProvider, o as openclaw_plugin_default } from "./.setup/provider-catalog-Bc73oFLX.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { applyKimiCodeConfig } from "./onboard.js";
|
|
3
3
|
import { isKimiK3ModelId, resolveThinkingProfile } from "./provider-policy-api.js";
|
|
4
|
-
import { KIMI_REPLAY_POLICY } from "./replay-policy.js";
|
|
5
4
|
import { wrapKimiProviderStream } from "./stream.js";
|
|
6
5
|
import { findNormalizedProviderValue } from "openclaw/plugin-sdk/provider-auth";
|
|
7
6
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
@@ -24,7 +23,6 @@ var kimi_coding_default = defineSingleProviderPluginEntry({
|
|
|
24
23
|
envVars: ["KIMI_API_KEY", "KIMICODE_API_KEY"],
|
|
25
24
|
manifestAuth: {
|
|
26
25
|
promptMessage: "Enter Kimi API key",
|
|
27
|
-
defaultModel: KIMI_CODING_MODEL_REF,
|
|
28
26
|
expectedProviders: [
|
|
29
27
|
"kimi",
|
|
30
28
|
"kimi-code",
|
|
@@ -60,7 +58,7 @@ var kimi_coding_default = defineSingleProviderPluginEntry({
|
|
|
60
58
|
if (providerId !== PROVIDER_ID && !PROVIDER_ALIASES.includes(providerId)) return;
|
|
61
59
|
return /\b(?:weekly(?:\s+\(7-day\))?|(?:7|seven)[ -]day)\s+(?:usage\s+)?limit\b/i.test(errorMessage) || /\bquota\s+will\s+reset\b/i.test(errorMessage) ? "rate_limit" : void 0;
|
|
62
60
|
},
|
|
63
|
-
buildReplayPolicy: () =>
|
|
61
|
+
buildReplayPolicy: () => ({ preserveSignatures: false }),
|
|
64
62
|
normalizeResolvedModel: ({ model }) => {
|
|
65
63
|
const normalizedId = normalizeKimiCodingModelId(model.id);
|
|
66
64
|
return normalizedId === model.id ? void 0 : {
|
package/dist/stream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isKimiK3ModelId } from "./provider-policy-api.js";
|
|
2
|
-
import { isRecord,
|
|
2
|
+
import { asFiniteNumberInRange, asOptionalObjectRecord, isRecord, parseBooleanValue } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { streamSimple } from "openclaw/plugin-sdk/llm";
|
|
4
4
|
import { normalizeOpenAICompatibleReasoningReplay, streamWithPayloadPatch, transformProviderStreamMessages } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
5
5
|
//#region extensions/kimi-coding/stream.ts
|
|
@@ -28,52 +28,38 @@ const KIMI_K3_THINKING_EFFORTS = {
|
|
|
28
28
|
xhigh: "max",
|
|
29
29
|
max: "max"
|
|
30
30
|
};
|
|
31
|
-
function normalizeKimiThinkingBudgetTokens(value) {
|
|
32
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return;
|
|
33
|
-
const normalized = Math.floor(value);
|
|
34
|
-
return normalized >= 1024 ? normalized : void 0;
|
|
35
|
-
}
|
|
36
|
-
function normalizeKimiAnthropicMaxTokens(value) {
|
|
37
|
-
if (typeof value !== "number" || !Number.isFinite(value)) return;
|
|
38
|
-
const normalized = Math.floor(value);
|
|
39
|
-
return normalized > 0 ? normalized : void 0;
|
|
40
|
-
}
|
|
41
31
|
function ensureKimiAnthropicMaxTokens(payloadObj, thinkingConfig) {
|
|
42
32
|
if (thinkingConfig.type !== "enabled" || thinkingConfig.budget_tokens === void 0) return;
|
|
43
33
|
const required = Math.max(KIMI_ANTHROPIC_MIN_OUTPUT_TOKENS, thinkingConfig.budget_tokens + KIMI_ANTHROPIC_VISIBLE_OUTPUT_RESERVE_TOKENS);
|
|
44
|
-
const current =
|
|
45
|
-
payloadObj.max_tokens = current === void 0 ? required : Math.max(current, required);
|
|
34
|
+
const current = asFiniteNumberInRange(payloadObj.max_tokens, { min: 1 });
|
|
35
|
+
payloadObj.max_tokens = current === void 0 ? required : Math.max(Math.floor(current), required);
|
|
46
36
|
}
|
|
47
37
|
function normalizeKimiThinkingType(value) {
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!normalized) return;
|
|
52
|
-
if ([
|
|
38
|
+
if (isRecord(value)) return normalizeKimiThinkingType(value.type);
|
|
39
|
+
const enabled = parseBooleanValue(value, {
|
|
40
|
+
truthy: [
|
|
53
41
|
"enabled",
|
|
54
42
|
"enable",
|
|
55
43
|
"on",
|
|
56
44
|
"true"
|
|
57
|
-
]
|
|
58
|
-
|
|
45
|
+
],
|
|
46
|
+
falsy: [
|
|
59
47
|
"disabled",
|
|
60
48
|
"disable",
|
|
61
49
|
"off",
|
|
62
50
|
"false"
|
|
63
|
-
]
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (isRecord(value)) return normalizeKimiThinkingType(value.type);
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
return enabled === void 0 ? void 0 : enabled ? "enabled" : "disabled";
|
|
67
54
|
}
|
|
68
55
|
function normalizeKimiThinkingConfig(value) {
|
|
69
56
|
const type = normalizeKimiThinkingType(value);
|
|
70
57
|
if (!type) return;
|
|
71
|
-
if (type === "disabled") return { type
|
|
72
|
-
|
|
73
|
-
const budgetTokens = normalizeKimiThinkingBudgetTokens(value.budget_tokens ?? value.budgetTokens);
|
|
58
|
+
if (type === "disabled" || !isRecord(value)) return { type };
|
|
59
|
+
const budgetTokens = asFiniteNumberInRange(value.budget_tokens ?? value.budgetTokens, { min: 1024 });
|
|
74
60
|
return budgetTokens === void 0 ? { type: "enabled" } : {
|
|
75
61
|
type: "enabled",
|
|
76
|
-
budget_tokens: budgetTokens
|
|
62
|
+
budget_tokens: Math.floor(budgetTokens)
|
|
77
63
|
};
|
|
78
64
|
}
|
|
79
65
|
function resolveKimiThinkingConfig(configured, thinkingLevel) {
|
|
@@ -88,9 +74,6 @@ function resolveKimiThinkingConfig(configured, thinkingLevel) {
|
|
|
88
74
|
budget_tokens: levelBudgetTokens
|
|
89
75
|
};
|
|
90
76
|
}
|
|
91
|
-
function stripTaggedToolCallCounter(value) {
|
|
92
|
-
return value.trim().replace(/:\d+$/, "");
|
|
93
|
-
}
|
|
94
77
|
function parseKimiTaggedToolCalls(text) {
|
|
95
78
|
const trimmed = text.trim();
|
|
96
79
|
if (!trimmed.startsWith(TOOL_CALLS_SECTION_BEGIN) || !trimmed.endsWith(TOOL_CALLS_SECTION_END)) return null;
|
|
@@ -117,7 +100,7 @@ function parseKimiTaggedToolCalls(text) {
|
|
|
117
100
|
return null;
|
|
118
101
|
}
|
|
119
102
|
if (!isRecord(parsedArgs)) return null;
|
|
120
|
-
const name =
|
|
103
|
+
const name = rawId.replace(/:\d+$/, "");
|
|
121
104
|
if (!name) return null;
|
|
122
105
|
toolCalls.push({
|
|
123
106
|
type: "toolCall",
|
|
@@ -130,22 +113,13 @@ function parseKimiTaggedToolCalls(text) {
|
|
|
130
113
|
return toolCalls.length > 0 ? toolCalls : null;
|
|
131
114
|
}
|
|
132
115
|
function rewriteKimiTaggedToolCallsInMessage(message) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (!Array.isArray(content)) return;
|
|
116
|
+
const record = asOptionalObjectRecord(message);
|
|
117
|
+
if (!record || !Array.isArray(record.content)) return;
|
|
136
118
|
let changed = false;
|
|
137
119
|
const nextContent = [];
|
|
138
|
-
for (const block of content) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const typedBlock = block;
|
|
144
|
-
if (typedBlock.type !== "text" || typeof typedBlock.text !== "string") {
|
|
145
|
-
nextContent.push(block);
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
const parsed = parseKimiTaggedToolCalls(typedBlock.text);
|
|
120
|
+
for (const block of record.content) {
|
|
121
|
+
const typedBlock = asOptionalObjectRecord(block);
|
|
122
|
+
const parsed = typedBlock?.type === "text" && typeof typedBlock.text === "string" ? parseKimiTaggedToolCalls(typedBlock.text) : null;
|
|
149
123
|
if (!parsed) {
|
|
150
124
|
nextContent.push(block);
|
|
151
125
|
continue;
|
|
@@ -154,9 +128,8 @@ function rewriteKimiTaggedToolCallsInMessage(message) {
|
|
|
154
128
|
changed = true;
|
|
155
129
|
}
|
|
156
130
|
if (!changed) return;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (typedMessage.stopReason === "stop") typedMessage.stopReason = "toolUse";
|
|
131
|
+
record.content = nextContent;
|
|
132
|
+
if (record.stopReason === "stop") record.stopReason = "toolUse";
|
|
160
133
|
}
|
|
161
134
|
function createKimiToolCallMarkupWrapper(baseStreamFn) {
|
|
162
135
|
const underlying = baseStreamFn ?? streamSimple;
|
|
@@ -217,23 +190,19 @@ function wrapKimiProviderStream(ctx) {
|
|
|
217
190
|
});
|
|
218
191
|
});
|
|
219
192
|
}
|
|
220
|
-
function stripContentBlockCacheControl(block) {
|
|
221
|
-
if (!block || typeof block !== "object") return;
|
|
222
|
-
const record = block;
|
|
223
|
-
delete record.cache_control;
|
|
224
|
-
if (record.type === "tool_result" && Array.isArray(record.content)) for (const nestedBlock of record.content) stripContentBlockCacheControl(nestedBlock);
|
|
225
|
-
}
|
|
226
193
|
function stripContentArrayCacheControl(value) {
|
|
227
194
|
if (!Array.isArray(value)) return;
|
|
228
|
-
for (const block of value)
|
|
195
|
+
for (const block of value) {
|
|
196
|
+
const record = asOptionalObjectRecord(block);
|
|
197
|
+
if (!record) continue;
|
|
198
|
+
delete record.cache_control;
|
|
199
|
+
if (record.type === "tool_result") stripContentArrayCacheControl(record.content);
|
|
200
|
+
}
|
|
229
201
|
}
|
|
230
202
|
function stripAnthropicCacheControlMarkers(payloadObj) {
|
|
231
203
|
stripContentArrayCacheControl(payloadObj.system);
|
|
232
204
|
if (!Array.isArray(payloadObj.messages)) return;
|
|
233
|
-
for (const message of payloadObj.messages)
|
|
234
|
-
if (!message || typeof message !== "object") continue;
|
|
235
|
-
stripContentArrayCacheControl(message.content);
|
|
236
|
-
}
|
|
205
|
+
for (const message of payloadObj.messages) stripContentArrayCacheControl(asOptionalObjectRecord(message)?.content);
|
|
237
206
|
}
|
|
238
207
|
//#endregion
|
|
239
208
|
export { wrapKimiProviderStream };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/kimi-provider",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.10.1-beta.1",
|
|
4
4
|
"description": "OpenClaw Kimi provider plugin.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"minHostVersion": ">=2026.6.8"
|
|
19
19
|
},
|
|
20
20
|
"compat": {
|
|
21
|
-
"pluginApi": ">=2026.
|
|
21
|
+
"pluginApi": ">=2026.10.1-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.
|
|
24
|
+
"openclawVersion": "2026.10.1-beta.1",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"assets/activity.svg"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"openclaw": ">=2026.
|
|
43
|
+
"openclaw": ">=2026.10.1-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|
package/dist/replay-policy.js
DELETED