@openclaw/kimi-provider 2026.7.2-beta.3 → 2026.7.2-beta.5
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 +107 -68
- package/dist/provider-catalog.js +23 -13
- package/dist/provider-policy-api.js +16 -10
- package/dist/stream.js +63 -55
- package/package.json +4 -5
- package/npm-shrinkwrap.json +0 -12
package/dist/index.js
CHANGED
|
@@ -3,10 +3,63 @@ import { buildKimiCodingProvider, normalizeKimiCodingModelId } from "./provider-
|
|
|
3
3
|
import { KIMI_CODING_MODEL_REF, applyKimiCodeConfig } from "./onboard.js";
|
|
4
4
|
import { KIMI_REPLAY_POLICY } from "./replay-policy.js";
|
|
5
5
|
import { wrapKimiProviderStream } from "./stream.js";
|
|
6
|
-
import {
|
|
7
|
-
import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key";
|
|
6
|
+
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
8
7
|
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-shared";
|
|
9
8
|
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
+
//#region extensions/kimi-coding/openclaw.plugin.json
|
|
10
|
+
var openclaw_plugin_default = {
|
|
11
|
+
id: "kimi",
|
|
12
|
+
activation: { "onStartup": false },
|
|
13
|
+
enabledByDefault: true,
|
|
14
|
+
providers: ["kimi", "kimi-coding"],
|
|
15
|
+
providerRequest: { "providers": {
|
|
16
|
+
"kimi": {
|
|
17
|
+
"family": "moonshot",
|
|
18
|
+
"compatibilityFamily": "moonshot"
|
|
19
|
+
},
|
|
20
|
+
"kimi-coding": {
|
|
21
|
+
"family": "moonshot",
|
|
22
|
+
"compatibilityFamily": "moonshot"
|
|
23
|
+
}
|
|
24
|
+
} },
|
|
25
|
+
modelPricing: { "providers": {
|
|
26
|
+
"kimi": {
|
|
27
|
+
"openRouter": { "provider": "moonshotai" },
|
|
28
|
+
"liteLLM": { "provider": "moonshot" }
|
|
29
|
+
},
|
|
30
|
+
"kimi-coding": {
|
|
31
|
+
"openRouter": { "provider": "moonshotai" },
|
|
32
|
+
"liteLLM": { "provider": "moonshot" }
|
|
33
|
+
}
|
|
34
|
+
} },
|
|
35
|
+
setup: { "providers": [{
|
|
36
|
+
"id": "kimi",
|
|
37
|
+
"envVars": ["KIMI_API_KEY", "KIMICODE_API_KEY"]
|
|
38
|
+
}, {
|
|
39
|
+
"id": "kimi-coding",
|
|
40
|
+
"envVars": ["KIMI_API_KEY", "KIMICODE_API_KEY"]
|
|
41
|
+
}] },
|
|
42
|
+
providerAuthChoices: [{
|
|
43
|
+
"provider": "kimi",
|
|
44
|
+
"method": "api-key",
|
|
45
|
+
"choiceId": "kimi-code-api-key",
|
|
46
|
+
"appGuidedSecret": true,
|
|
47
|
+
"choiceLabel": "Kimi Code API key (subscription)",
|
|
48
|
+
"groupId": "moonshot",
|
|
49
|
+
"groupLabel": "Moonshot AI (Kimi)",
|
|
50
|
+
"groupHint": "Kimi Code membership · https://www.kimi.com/membership/pricing",
|
|
51
|
+
"optionKey": "kimiCodeApiKey",
|
|
52
|
+
"cliFlag": "--kimi-code-api-key",
|
|
53
|
+
"cliOption": "--kimi-code-api-key <key>",
|
|
54
|
+
"cliDescription": "Kimi Code API key (subscription)"
|
|
55
|
+
}],
|
|
56
|
+
configSchema: {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"additionalProperties": false,
|
|
59
|
+
"properties": {}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
10
63
|
//#region extensions/kimi-coding/index.ts
|
|
11
64
|
const PLUGIN_ID = "kimi";
|
|
12
65
|
const PROVIDER_ID = "kimi";
|
|
@@ -16,75 +69,61 @@ function findExplicitProviderConfig(providers, providerId) {
|
|
|
16
69
|
const match = Object.entries(providers).find(([configuredProviderId]) => normalizeProviderId(configuredProviderId) === normalizedProviderId);
|
|
17
70
|
return isRecord(match?.[1]) ? match[1] : void 0;
|
|
18
71
|
}
|
|
19
|
-
var kimi_coding_default =
|
|
72
|
+
var kimi_coding_default = defineSingleProviderPluginEntry({
|
|
20
73
|
id: PLUGIN_ID,
|
|
21
74
|
name: "Kimi Provider",
|
|
22
75
|
description: "Bundled Kimi provider plugin",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
buildReplayPolicy: () => KIMI_REPLAY_POLICY,
|
|
77
|
-
normalizeResolvedModel: ({ model }) => {
|
|
78
|
-
const normalizedId = normalizeKimiCodingModelId(model.id);
|
|
79
|
-
return normalizedId === model.id ? void 0 : {
|
|
80
|
-
...model,
|
|
81
|
-
id: normalizedId
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
resolveThinkingProfile,
|
|
85
|
-
wrapSimpleCompletionStreamFn: (ctx) => isKimiK3ModelId(ctx.modelId) ? wrapKimiProviderStream(ctx) : ctx.streamFn,
|
|
86
|
-
wrapStreamFn: wrapKimiProviderStream
|
|
87
|
-
});
|
|
76
|
+
manifest: openclaw_plugin_default,
|
|
77
|
+
provider: {
|
|
78
|
+
id: PROVIDER_ID,
|
|
79
|
+
label: "Kimi",
|
|
80
|
+
aliases: ["kimi-code", "kimi-coding"],
|
|
81
|
+
docsPath: "/providers/moonshot",
|
|
82
|
+
envVars: ["KIMI_API_KEY", "KIMICODE_API_KEY"],
|
|
83
|
+
manifestAuth: {
|
|
84
|
+
promptMessage: "Enter Kimi API key",
|
|
85
|
+
defaultModel: KIMI_CODING_MODEL_REF,
|
|
86
|
+
expectedProviders: [
|
|
87
|
+
"kimi",
|
|
88
|
+
"kimi-code",
|
|
89
|
+
"kimi-coding"
|
|
90
|
+
],
|
|
91
|
+
applyConfig: applyKimiCodeConfig,
|
|
92
|
+
noteMessage: ["Kimi uses a dedicated coding endpoint and API key.", "Get your API key at: https://www.kimi.com/code/console"].join("\n"),
|
|
93
|
+
noteTitle: "Kimi"
|
|
94
|
+
},
|
|
95
|
+
catalog: {
|
|
96
|
+
order: "simple",
|
|
97
|
+
run: async (ctx) => {
|
|
98
|
+
const apiKey = ctx.resolveProviderApiKey(PROVIDER_ID).apiKey;
|
|
99
|
+
if (!apiKey) return null;
|
|
100
|
+
const explicitProvider = findExplicitProviderConfig(ctx.config.models?.providers, PROVIDER_ID);
|
|
101
|
+
const builtInProvider = buildKimiCodingProvider();
|
|
102
|
+
const explicitBaseUrl = normalizeOptionalString(explicitProvider?.baseUrl) ?? "";
|
|
103
|
+
const explicitHeaders = isRecord(explicitProvider?.headers) ? explicitProvider.headers : void 0;
|
|
104
|
+
return { provider: {
|
|
105
|
+
...builtInProvider,
|
|
106
|
+
...explicitBaseUrl ? { baseUrl: explicitBaseUrl } : {},
|
|
107
|
+
...explicitHeaders ? { headers: {
|
|
108
|
+
...builtInProvider.headers,
|
|
109
|
+
...explicitHeaders
|
|
110
|
+
} } : {},
|
|
111
|
+
apiKey
|
|
112
|
+
} };
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
buildReplayPolicy: () => KIMI_REPLAY_POLICY,
|
|
116
|
+
normalizeResolvedModel: ({ model }) => {
|
|
117
|
+
const normalizedId = normalizeKimiCodingModelId(model.id);
|
|
118
|
+
return normalizedId === model.id ? void 0 : {
|
|
119
|
+
...model,
|
|
120
|
+
id: normalizedId
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
normalizeModelId: ({ modelId }) => normalizeKimiCodingModelId(modelId),
|
|
124
|
+
resolveThinkingProfile,
|
|
125
|
+
wrapSimpleCompletionStreamFn: (ctx) => isKimiK3ModelId(ctx.modelId) ? wrapKimiProviderStream(ctx) : ctx.streamFn,
|
|
126
|
+
wrapStreamFn: wrapKimiProviderStream
|
|
88
127
|
}
|
|
89
128
|
});
|
|
90
129
|
//#endregion
|
package/dist/provider-catalog.js
CHANGED
|
@@ -13,6 +13,23 @@ const KIMI_CODING_DEFAULT_COST = {
|
|
|
13
13
|
cacheRead: 0,
|
|
14
14
|
cacheWrite: 0
|
|
15
15
|
};
|
|
16
|
+
const KIMI_K3_COST = {
|
|
17
|
+
input: 3,
|
|
18
|
+
output: 15,
|
|
19
|
+
cacheRead: .3,
|
|
20
|
+
cacheWrite: 0
|
|
21
|
+
};
|
|
22
|
+
const KIMI_K3_CONTEXT_WINDOW = 1048576;
|
|
23
|
+
const KIMI_K3_MAX_TOKENS = 131072;
|
|
24
|
+
const KIMI_K3_THINKING_LEVEL_MAP = {
|
|
25
|
+
off: null,
|
|
26
|
+
minimal: "low",
|
|
27
|
+
low: "low",
|
|
28
|
+
medium: "high",
|
|
29
|
+
high: "high",
|
|
30
|
+
xhigh: "max",
|
|
31
|
+
max: "max"
|
|
32
|
+
};
|
|
16
33
|
const KIMI_CODING_INPUT = ["text", "image"];
|
|
17
34
|
function buildKimiCodingProvider() {
|
|
18
35
|
return {
|
|
@@ -40,26 +57,19 @@ function buildKimiCodingProvider() {
|
|
|
40
57
|
},
|
|
41
58
|
...KIMI_K3_MODEL_IDS.map((id) => ({
|
|
42
59
|
id,
|
|
43
|
-
name: id === "k3" ? "Kimi K3" : "Kimi K3 (
|
|
60
|
+
name: id === "k3" ? "Kimi K3" : "Kimi K3 (256k)",
|
|
44
61
|
reasoning: true,
|
|
45
|
-
thinkingLevelMap: {
|
|
46
|
-
off: null,
|
|
47
|
-
minimal: null,
|
|
48
|
-
low: null,
|
|
49
|
-
medium: null,
|
|
50
|
-
high: null,
|
|
51
|
-
xhigh: "max",
|
|
52
|
-
max: "max"
|
|
53
|
-
},
|
|
62
|
+
thinkingLevelMap: { ...KIMI_K3_THINKING_LEVEL_MAP },
|
|
54
63
|
input: [...KIMI_CODING_INPUT],
|
|
55
|
-
cost:
|
|
56
|
-
contextWindow: id === "k3" ?
|
|
57
|
-
maxTokens:
|
|
64
|
+
cost: KIMI_K3_COST,
|
|
65
|
+
contextWindow: id === "k3" ? KIMI_K3_CONTEXT_WINDOW : KIMI_CODING_DEFAULT_CONTEXT_WINDOW,
|
|
66
|
+
maxTokens: KIMI_K3_MAX_TOKENS
|
|
58
67
|
}))
|
|
59
68
|
]
|
|
60
69
|
};
|
|
61
70
|
}
|
|
62
71
|
function normalizeKimiCodingModelId(modelId) {
|
|
72
|
+
if (modelId === "k3[1m]") return "k3";
|
|
63
73
|
return KIMI_LEGACY_MODEL_IDS.includes(modelId) ? KIMI_DEFAULT_MODEL_ID : modelId;
|
|
64
74
|
}
|
|
65
75
|
const KIMI_CODING_BASE_URL = KIMI_BASE_URL;
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
//#region extensions/kimi-coding/provider-policy-api.ts
|
|
2
|
-
const KIMI_K3_MODEL_IDS = ["k3", "k3
|
|
2
|
+
const KIMI_K3_MODEL_IDS = ["k3", "k3-256k"];
|
|
3
|
+
const KIMI_K3_LEGACY_MODEL_IDS = ["k3[1m]"];
|
|
4
|
+
const KIMI_K3_THINKING_LEVELS = [
|
|
5
|
+
{ id: "off" },
|
|
6
|
+
{ id: "minimal" },
|
|
7
|
+
{ id: "low" },
|
|
8
|
+
{ id: "medium" },
|
|
9
|
+
{ id: "high" },
|
|
10
|
+
{ id: "adaptive" },
|
|
11
|
+
{ id: "xhigh" },
|
|
12
|
+
{ id: "max" }
|
|
13
|
+
];
|
|
3
14
|
function isKimiK3ModelId(modelId) {
|
|
4
|
-
|
|
15
|
+
const normalized = modelId.trim().toLowerCase();
|
|
16
|
+
return KIMI_K3_MODEL_IDS.includes(normalized) || KIMI_K3_LEGACY_MODEL_IDS.includes(normalized);
|
|
5
17
|
}
|
|
6
18
|
function resolveThinkingProfile({ modelId }) {
|
|
7
19
|
if (isKimiK3ModelId(modelId)) return {
|
|
8
|
-
levels:
|
|
9
|
-
|
|
10
|
-
label: "off"
|
|
11
|
-
}, {
|
|
12
|
-
id: "max",
|
|
13
|
-
label: "max"
|
|
14
|
-
}],
|
|
15
|
-
defaultLevel: "max",
|
|
20
|
+
levels: KIMI_K3_THINKING_LEVELS,
|
|
21
|
+
defaultLevel: "high",
|
|
16
22
|
preserveWhenCatalogReasoningFalse: true
|
|
17
23
|
};
|
|
18
24
|
return {
|
package/dist/stream.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isKimiK3ModelId } from "./provider-policy-api.js";
|
|
2
2
|
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { streamSimple } from "openclaw/plugin-sdk/llm";
|
|
4
|
-
import { streamWithPayloadPatch } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
4
|
+
import { normalizeOpenAICompatibleReasoningReplay, streamWithPayloadPatch } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
5
5
|
//#region extensions/kimi-coding/stream.ts
|
|
6
6
|
const TOOL_CALLS_SECTION_BEGIN = "<|tool_calls_section_begin|>";
|
|
7
7
|
const TOOL_CALLS_SECTION_END = "<|tool_calls_section_end|>";
|
|
@@ -19,6 +19,15 @@ const KIMI_ANTHROPIC_THINKING_BUDGETS = {
|
|
|
19
19
|
};
|
|
20
20
|
const KIMI_ANTHROPIC_VISIBLE_OUTPUT_RESERVE_TOKENS = 1024;
|
|
21
21
|
const KIMI_ANTHROPIC_MIN_OUTPUT_TOKENS = 16e3;
|
|
22
|
+
const KIMI_K3_THINKING_EFFORTS = {
|
|
23
|
+
minimal: "low",
|
|
24
|
+
low: "low",
|
|
25
|
+
medium: "high",
|
|
26
|
+
high: "high",
|
|
27
|
+
adaptive: "high",
|
|
28
|
+
xhigh: "max",
|
|
29
|
+
max: "max"
|
|
30
|
+
};
|
|
22
31
|
function normalizeKimiThinkingBudgetTokens(value) {
|
|
23
32
|
if (typeof value !== "number" || !Number.isFinite(value)) return;
|
|
24
33
|
const normalized = Math.floor(value);
|
|
@@ -35,22 +44,6 @@ function ensureKimiAnthropicMaxTokens(payloadObj, thinkingConfig) {
|
|
|
35
44
|
const current = normalizeKimiAnthropicMaxTokens(payloadObj.max_tokens);
|
|
36
45
|
payloadObj.max_tokens = current === void 0 ? required : Math.max(current, required);
|
|
37
46
|
}
|
|
38
|
-
function messageHasOpenAIToolCalls(message) {
|
|
39
|
-
return Array.isArray(message.tool_calls) && message.tool_calls.length > 0;
|
|
40
|
-
}
|
|
41
|
-
function ensureKimiOpenAIReasoningContent(payloadObj) {
|
|
42
|
-
if (!Array.isArray(payloadObj.messages)) return;
|
|
43
|
-
for (const message of payloadObj.messages) {
|
|
44
|
-
if (!message || typeof message !== "object") continue;
|
|
45
|
-
const record = message;
|
|
46
|
-
if (record.role !== "assistant" || !messageHasOpenAIToolCalls(record)) continue;
|
|
47
|
-
if (!("reasoning_content" in record)) record.reasoning_content = "";
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function stripKimiOpenAIReasoningContent(payloadObj) {
|
|
51
|
-
if (!Array.isArray(payloadObj.messages)) return;
|
|
52
|
-
for (const message of payloadObj.messages) if (message && typeof message === "object") delete message.reasoning_content;
|
|
53
|
-
}
|
|
54
47
|
function normalizeKimiThinkingType(value) {
|
|
55
48
|
if (typeof value === "boolean") return value ? "enabled" : "disabled";
|
|
56
49
|
if (typeof value === "string") {
|
|
@@ -101,10 +94,14 @@ function resolveKimiThinkingConfig(params) {
|
|
|
101
94
|
budget_tokens: levelBudgetTokens
|
|
102
95
|
};
|
|
103
96
|
}
|
|
104
|
-
function
|
|
97
|
+
function resolveKimiK3ThinkingConfig(params) {
|
|
105
98
|
const configured = normalizeKimiThinkingConfig(params.configuredThinking);
|
|
106
|
-
if (configured) return
|
|
107
|
-
|
|
99
|
+
if (configured?.type === "disabled") return { type: "disabled" };
|
|
100
|
+
if (!configured && params.thinkingLevel === "off") return { type: "disabled" };
|
|
101
|
+
return {
|
|
102
|
+
type: "adaptive",
|
|
103
|
+
effort: params.thinkingLevel && params.thinkingLevel !== "off" ? KIMI_K3_THINKING_EFFORTS[params.thinkingLevel] : "high"
|
|
104
|
+
};
|
|
108
105
|
}
|
|
109
106
|
function stripTaggedToolCallCounter(value) {
|
|
110
107
|
return value.trim().replace(/:\d+$/, "");
|
|
@@ -221,45 +218,56 @@ function createKimiToolCallMarkupWrapper(baseStreamFn) {
|
|
|
221
218
|
return wrapStreamMessageObjects(maybeStream, rewriteKimiTaggedToolCallsInMessage);
|
|
222
219
|
};
|
|
223
220
|
}
|
|
224
|
-
function createKimiThinkingWrapper(baseStreamFn, thinkingConfig,
|
|
221
|
+
function createKimiThinkingWrapper(baseStreamFn, thinkingConfig, k3ThinkingConfig) {
|
|
225
222
|
const underlying = baseStreamFn ?? streamSimple;
|
|
226
|
-
return (model, context, options) =>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
223
|
+
return (model, context, options) => {
|
|
224
|
+
const runtimeModel = model.api === "anthropic-messages" && isKimiK3ModelId(model.id) ? {
|
|
225
|
+
...model,
|
|
226
|
+
compat: {
|
|
227
|
+
...model.compat,
|
|
228
|
+
allowEmptySignature: true
|
|
229
|
+
}
|
|
230
|
+
} : model;
|
|
231
|
+
return streamWithPayloadPatch(underlying, runtimeModel, context, options, (payloadObj) => {
|
|
232
|
+
if (model.api === "anthropic-messages" && isKimiK3ModelId(model.id)) {
|
|
233
|
+
const outputConfig = payloadObj.output_config;
|
|
234
|
+
if (k3ThinkingConfig.type === "disabled") {
|
|
235
|
+
payloadObj.thinking = { type: "disabled" };
|
|
236
|
+
if (outputConfig && typeof outputConfig === "object" && !Array.isArray(outputConfig)) {
|
|
237
|
+
const nextOutputConfig = { ...outputConfig };
|
|
238
|
+
delete nextOutputConfig.effort;
|
|
239
|
+
if (Object.keys(nextOutputConfig).length > 0) payloadObj.output_config = nextOutputConfig;
|
|
240
|
+
else delete payloadObj.output_config;
|
|
241
|
+
} else delete payloadObj.output_config;
|
|
242
|
+
} else {
|
|
243
|
+
payloadObj.thinking = {
|
|
244
|
+
type: "adaptive",
|
|
245
|
+
display: "summarized"
|
|
246
|
+
};
|
|
247
|
+
payloadObj.output_config = outputConfig && typeof outputConfig === "object" && !Array.isArray(outputConfig) ? {
|
|
248
|
+
...outputConfig,
|
|
249
|
+
effort: k3ThinkingConfig.effort
|
|
250
|
+
} : { effort: k3ThinkingConfig.effort };
|
|
251
|
+
}
|
|
252
|
+
delete payloadObj.reasoning;
|
|
253
|
+
delete payloadObj.reasoning_effort;
|
|
254
|
+
delete payloadObj.reasoningEffort;
|
|
255
|
+
stripAnthropicCacheControlMarkers(payloadObj);
|
|
256
|
+
return;
|
|
246
257
|
}
|
|
258
|
+
const normalized = typeof thinkingConfig === "string" ? { type: thinkingConfig } : thinkingConfig;
|
|
259
|
+
payloadObj.thinking = model.api === "anthropic-messages" ? { ...normalized } : { type: normalized.type };
|
|
260
|
+
if (model.api === "anthropic-messages") ensureKimiAnthropicMaxTokens(payloadObj, normalized);
|
|
261
|
+
else normalizeOpenAICompatibleReasoningReplay(payloadObj, {
|
|
262
|
+
thinkingEnabled: normalized.type === "enabled",
|
|
263
|
+
shouldBackfillAssistantMessage: (message) => Array.isArray(message.tool_calls) && message.tool_calls.length > 0
|
|
264
|
+
});
|
|
247
265
|
delete payloadObj.reasoning;
|
|
248
266
|
delete payloadObj.reasoning_effort;
|
|
249
267
|
delete payloadObj.reasoningEffort;
|
|
250
268
|
stripAnthropicCacheControlMarkers(payloadObj);
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const normalized = typeof thinkingConfig === "string" ? { type: thinkingConfig } : thinkingConfig;
|
|
254
|
-
payloadObj.thinking = model.api === "anthropic-messages" ? { ...normalized } : { type: normalized.type };
|
|
255
|
-
if (model.api === "anthropic-messages") ensureKimiAnthropicMaxTokens(payloadObj, normalized);
|
|
256
|
-
else if (normalized.type === "enabled") ensureKimiOpenAIReasoningContent(payloadObj);
|
|
257
|
-
else stripKimiOpenAIReasoningContent(payloadObj);
|
|
258
|
-
delete payloadObj.reasoning;
|
|
259
|
-
delete payloadObj.reasoning_effort;
|
|
260
|
-
delete payloadObj.reasoningEffort;
|
|
261
|
-
stripAnthropicCacheControlMarkers(payloadObj);
|
|
262
|
-
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
263
271
|
}
|
|
264
272
|
function stripContentBlockCacheControl(block) {
|
|
265
273
|
if (!block || typeof block !== "object") return;
|
|
@@ -284,11 +292,11 @@ function wrapKimiProviderStream(ctx) {
|
|
|
284
292
|
configuredThinking: ctx.extraParams?.thinking,
|
|
285
293
|
thinkingLevel: ctx.thinkingLevel
|
|
286
294
|
});
|
|
287
|
-
const
|
|
295
|
+
const k3ThinkingConfig = resolveKimiK3ThinkingConfig({
|
|
288
296
|
configuredThinking: ctx.extraParams?.thinking,
|
|
289
297
|
thinkingLevel: ctx.thinkingLevel
|
|
290
298
|
});
|
|
291
|
-
return createKimiToolCallMarkupWrapper(createKimiThinkingWrapper(ctx.streamFn, thinkingConfig,
|
|
299
|
+
return createKimiToolCallMarkupWrapper(createKimiThinkingWrapper(ctx.streamFn, thinkingConfig, k3ThinkingConfig));
|
|
292
300
|
}
|
|
293
301
|
//#endregion
|
|
294
302
|
export { wrapKimiProviderStream };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/kimi-provider",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.5",
|
|
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.7.2-beta.
|
|
21
|
+
"pluginApi": ">=2026.7.2-beta.5"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.7.2-beta.
|
|
24
|
+
"openclawVersion": "2026.7.2-beta.5",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -35,11 +35,10 @@
|
|
|
35
35
|
"files": [
|
|
36
36
|
"dist/**",
|
|
37
37
|
"openclaw.plugin.json",
|
|
38
|
-
"npm-shrinkwrap.json",
|
|
39
38
|
"README.md"
|
|
40
39
|
],
|
|
41
40
|
"peerDependencies": {
|
|
42
|
-
"openclaw": ">=2026.7.2-beta.
|
|
41
|
+
"openclaw": ">=2026.7.2-beta.5"
|
|
43
42
|
},
|
|
44
43
|
"peerDependenciesMeta": {
|
|
45
44
|
"openclaw": {
|
package/npm-shrinkwrap.json
DELETED