@openclaw/kimi-provider 2026.7.2-beta.1 → 2026.7.2-beta.3
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 +7 -14
- package/dist/provider-catalog.js +40 -17
- package/dist/provider-policy-api.js +30 -0
- package/dist/stream.js +38 -5
- package/npm-shrinkwrap.json +2 -2
- package/openclaw.plugin.json +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isKimiK3ModelId, resolveThinkingProfile } from "./provider-policy-api.js";
|
|
1
2
|
import { buildKimiCodingProvider, normalizeKimiCodingModelId } from "./provider-catalog.js";
|
|
2
3
|
import { KIMI_CODING_MODEL_REF, applyKimiCodeConfig } from "./onboard.js";
|
|
3
4
|
import { KIMI_REPLAY_POLICY } from "./replay-policy.js";
|
|
@@ -30,7 +31,7 @@ var kimi_coding_default = definePluginEntry({
|
|
|
30
31
|
providerId: PROVIDER_ID,
|
|
31
32
|
methodId: "api-key",
|
|
32
33
|
label: "Kimi Code API key (subscription)",
|
|
33
|
-
hint: "Kimi
|
|
34
|
+
hint: "Kimi Code membership · https://www.kimi.com/membership/pricing",
|
|
34
35
|
optionKey: "kimiCodeApiKey",
|
|
35
36
|
flagName: "--kimi-code-api-key",
|
|
36
37
|
envVar: "KIMI_API_KEY",
|
|
@@ -42,14 +43,14 @@ var kimi_coding_default = definePluginEntry({
|
|
|
42
43
|
"kimi-coding"
|
|
43
44
|
],
|
|
44
45
|
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/
|
|
46
|
+
noteMessage: ["Kimi uses a dedicated coding endpoint and API key.", "Get your API key at: https://www.kimi.com/code/console"].join("\n"),
|
|
46
47
|
noteTitle: "Kimi",
|
|
47
48
|
wizard: {
|
|
48
49
|
choiceId: "kimi-code-api-key",
|
|
49
50
|
choiceLabel: "Kimi Code API key (subscription)",
|
|
50
51
|
groupId: "moonshot",
|
|
51
|
-
groupLabel: "Moonshot AI (Kimi
|
|
52
|
-
groupHint: "Kimi
|
|
52
|
+
groupLabel: "Moonshot AI (Kimi)",
|
|
53
|
+
groupHint: "Kimi Code membership · https://www.kimi.com/membership/pricing"
|
|
53
54
|
}
|
|
54
55
|
})],
|
|
55
56
|
catalog: {
|
|
@@ -80,16 +81,8 @@ var kimi_coding_default = definePluginEntry({
|
|
|
80
81
|
id: normalizedId
|
|
81
82
|
};
|
|
82
83
|
},
|
|
83
|
-
resolveThinkingProfile
|
|
84
|
-
|
|
85
|
-
id: "off",
|
|
86
|
-
label: "off"
|
|
87
|
-
}, {
|
|
88
|
-
id: "low",
|
|
89
|
-
label: "on"
|
|
90
|
-
}],
|
|
91
|
-
defaultLevel: "off"
|
|
92
|
-
}),
|
|
84
|
+
resolveThinkingProfile,
|
|
85
|
+
wrapSimpleCompletionStreamFn: (ctx) => isKimiK3ModelId(ctx.modelId) ? wrapKimiProviderStream(ctx) : ctx.streamFn,
|
|
93
86
|
wrapStreamFn: wrapKimiProviderStream
|
|
94
87
|
});
|
|
95
88
|
}
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { KIMI_K3_MODEL_IDS } from "./provider-policy-api.js";
|
|
1
2
|
//#region extensions/kimi-coding/provider-catalog.ts
|
|
2
3
|
const KIMI_BASE_URL = "https://api.kimi.com/coding/";
|
|
3
4
|
const KIMI_CODING_USER_AGENT = "claude-code/0.1.0";
|
|
4
5
|
const KIMI_DEFAULT_MODEL_ID = "kimi-for-coding";
|
|
6
|
+
const KIMI_HIGHSPEED_MODEL_ID = "kimi-for-coding-highspeed";
|
|
5
7
|
const KIMI_LEGACY_MODEL_IDS = ["kimi-code", "k2p5"];
|
|
6
8
|
const KIMI_CODING_DEFAULT_CONTEXT_WINDOW = 262144;
|
|
7
9
|
const KIMI_CODING_DEFAULT_MAX_TOKENS = 32768;
|
|
@@ -17,23 +19,44 @@ function buildKimiCodingProvider() {
|
|
|
17
19
|
baseUrl: KIMI_BASE_URL,
|
|
18
20
|
api: "anthropic-messages",
|
|
19
21
|
headers: { "User-Agent": KIMI_CODING_USER_AGENT },
|
|
20
|
-
models: [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
22
|
+
models: [
|
|
23
|
+
{
|
|
24
|
+
id: KIMI_DEFAULT_MODEL_ID,
|
|
25
|
+
name: "Kimi Code",
|
|
26
|
+
reasoning: true,
|
|
27
|
+
input: [...KIMI_CODING_INPUT],
|
|
28
|
+
cost: KIMI_CODING_DEFAULT_COST,
|
|
29
|
+
contextWindow: KIMI_CODING_DEFAULT_CONTEXT_WINDOW,
|
|
30
|
+
maxTokens: KIMI_CODING_DEFAULT_MAX_TOKENS
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: KIMI_HIGHSPEED_MODEL_ID,
|
|
34
|
+
name: "Kimi K2.7 Code HighSpeed",
|
|
35
|
+
reasoning: true,
|
|
36
|
+
input: [...KIMI_CODING_INPUT],
|
|
37
|
+
cost: KIMI_CODING_DEFAULT_COST,
|
|
38
|
+
contextWindow: KIMI_CODING_DEFAULT_CONTEXT_WINDOW,
|
|
39
|
+
maxTokens: KIMI_CODING_DEFAULT_MAX_TOKENS
|
|
40
|
+
},
|
|
41
|
+
...KIMI_K3_MODEL_IDS.map((id) => ({
|
|
42
|
+
id,
|
|
43
|
+
name: id === "k3" ? "Kimi K3" : "Kimi K3 (1M)",
|
|
44
|
+
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
|
+
},
|
|
54
|
+
input: [...KIMI_CODING_INPUT],
|
|
55
|
+
cost: KIMI_CODING_DEFAULT_COST,
|
|
56
|
+
contextWindow: id === "k3" ? KIMI_CODING_DEFAULT_CONTEXT_WINDOW : 1048576,
|
|
57
|
+
maxTokens: KIMI_CODING_DEFAULT_MAX_TOKENS
|
|
58
|
+
}))
|
|
59
|
+
]
|
|
37
60
|
};
|
|
38
61
|
}
|
|
39
62
|
function normalizeKimiCodingModelId(modelId) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region extensions/kimi-coding/provider-policy-api.ts
|
|
2
|
+
const KIMI_K3_MODEL_IDS = ["k3", "k3[1m]"];
|
|
3
|
+
function isKimiK3ModelId(modelId) {
|
|
4
|
+
return KIMI_K3_MODEL_IDS.includes(modelId.trim().toLowerCase());
|
|
5
|
+
}
|
|
6
|
+
function resolveThinkingProfile({ modelId }) {
|
|
7
|
+
if (isKimiK3ModelId(modelId)) return {
|
|
8
|
+
levels: [{
|
|
9
|
+
id: "off",
|
|
10
|
+
label: "off"
|
|
11
|
+
}, {
|
|
12
|
+
id: "max",
|
|
13
|
+
label: "max"
|
|
14
|
+
}],
|
|
15
|
+
defaultLevel: "max",
|
|
16
|
+
preserveWhenCatalogReasoningFalse: true
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
levels: [{
|
|
20
|
+
id: "off",
|
|
21
|
+
label: "off"
|
|
22
|
+
}, {
|
|
23
|
+
id: "low",
|
|
24
|
+
label: "on"
|
|
25
|
+
}],
|
|
26
|
+
defaultLevel: "off"
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { KIMI_K3_MODEL_IDS, isKimiK3ModelId, resolveThinkingProfile };
|
package/dist/stream.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isKimiK3ModelId } from "./provider-policy-api.js";
|
|
1
2
|
import { normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
2
3
|
import { streamSimple } from "openclaw/plugin-sdk/llm";
|
|
3
4
|
import { streamWithPayloadPatch } from "openclaw/plugin-sdk/provider-stream-shared";
|
|
@@ -100,8 +101,10 @@ function resolveKimiThinkingConfig(params) {
|
|
|
100
101
|
budget_tokens: levelBudgetTokens
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
104
|
+
function resolveKimiK3ThinkingType(params) {
|
|
105
|
+
const configured = normalizeKimiThinkingConfig(params.configuredThinking);
|
|
106
|
+
if (configured) return configured.type;
|
|
107
|
+
return params.thinkingLevel === "off" ? "disabled" : "enabled";
|
|
105
108
|
}
|
|
106
109
|
function stripTaggedToolCallCounter(value) {
|
|
107
110
|
return value.trim().replace(/:\d+$/, "");
|
|
@@ -218,9 +221,35 @@ function createKimiToolCallMarkupWrapper(baseStreamFn) {
|
|
|
218
221
|
return wrapStreamMessageObjects(maybeStream, rewriteKimiTaggedToolCallsInMessage);
|
|
219
222
|
};
|
|
220
223
|
}
|
|
221
|
-
function createKimiThinkingWrapper(baseStreamFn, thinkingConfig) {
|
|
224
|
+
function createKimiThinkingWrapper(baseStreamFn, thinkingConfig, k3ThinkingType) {
|
|
222
225
|
const underlying = baseStreamFn ?? streamSimple;
|
|
223
226
|
return (model, context, options) => streamWithPayloadPatch(underlying, model, context, options, (payloadObj) => {
|
|
227
|
+
if (model.api === "anthropic-messages" && isKimiK3ModelId(model.id)) {
|
|
228
|
+
const outputConfig = payloadObj.output_config;
|
|
229
|
+
if (k3ThinkingType === "disabled") {
|
|
230
|
+
payloadObj.thinking = { type: "disabled" };
|
|
231
|
+
if (outputConfig && typeof outputConfig === "object" && !Array.isArray(outputConfig)) {
|
|
232
|
+
const nextOutputConfig = { ...outputConfig };
|
|
233
|
+
delete nextOutputConfig.effort;
|
|
234
|
+
if (Object.keys(nextOutputConfig).length > 0) payloadObj.output_config = nextOutputConfig;
|
|
235
|
+
else delete payloadObj.output_config;
|
|
236
|
+
} else delete payloadObj.output_config;
|
|
237
|
+
} else {
|
|
238
|
+
payloadObj.thinking = {
|
|
239
|
+
type: "adaptive",
|
|
240
|
+
display: "summarized"
|
|
241
|
+
};
|
|
242
|
+
payloadObj.output_config = outputConfig && typeof outputConfig === "object" && !Array.isArray(outputConfig) ? {
|
|
243
|
+
...outputConfig,
|
|
244
|
+
effort: "max"
|
|
245
|
+
} : { effort: "max" };
|
|
246
|
+
}
|
|
247
|
+
delete payloadObj.reasoning;
|
|
248
|
+
delete payloadObj.reasoning_effort;
|
|
249
|
+
delete payloadObj.reasoningEffort;
|
|
250
|
+
stripAnthropicCacheControlMarkers(payloadObj);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
224
253
|
const normalized = typeof thinkingConfig === "string" ? { type: thinkingConfig } : thinkingConfig;
|
|
225
254
|
payloadObj.thinking = model.api === "anthropic-messages" ? { ...normalized } : { type: normalized.type };
|
|
226
255
|
if (model.api === "anthropic-messages") ensureKimiAnthropicMaxTokens(payloadObj, normalized);
|
|
@@ -255,7 +284,11 @@ function wrapKimiProviderStream(ctx) {
|
|
|
255
284
|
configuredThinking: ctx.extraParams?.thinking,
|
|
256
285
|
thinkingLevel: ctx.thinkingLevel
|
|
257
286
|
});
|
|
258
|
-
|
|
287
|
+
const k3ThinkingType = resolveKimiK3ThinkingType({
|
|
288
|
+
configuredThinking: ctx.extraParams?.thinking,
|
|
289
|
+
thinkingLevel: ctx.thinkingLevel
|
|
290
|
+
});
|
|
291
|
+
return createKimiToolCallMarkupWrapper(createKimiThinkingWrapper(ctx.streamFn, thinkingConfig, k3ThinkingType));
|
|
259
292
|
}
|
|
260
293
|
//#endregion
|
|
261
|
-
export {
|
|
294
|
+
export { wrapKimiProviderStream };
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/kimi-provider",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.3",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/kimi-provider",
|
|
9
|
-
"version": "2026.7.2-beta.
|
|
9
|
+
"version": "2026.7.2-beta.3"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
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)",
|
|
61
|
+
"groupHint": "Kimi Code membership · https://www.kimi.com/membership/pricing",
|
|
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.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.3",
|
|
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.3"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.7.2-beta.
|
|
24
|
+
"openclawVersion": "2026.7.2-beta.3",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"README.md"
|
|
40
40
|
],
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"openclaw": ">=2026.7.2-beta.
|
|
42
|
+
"openclaw": ">=2026.7.2-beta.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"openclaw": {
|