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