@openclaw/kimi-provider 2026.7.2-beta.7 → 2026.7.34
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/README.md +0 -13
- package/dist/api.js +1 -1
- package/dist/index.js +77 -55
- package/dist/onboard.js +2 -2
- package/dist/provider-catalog.js +45 -1
- package/dist/stream.js +33 -74
- package/openclaw.plugin.json +2 -101
- package/package.json +4 -4
- package/dist/provider-catalog-DesMT16v.js +0 -163
- package/dist/provider-policy-api.js +0 -36
package/README.md
CHANGED
|
@@ -10,16 +10,3 @@ openclaw gateway restart
|
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
See <https://docs.openclaw.ai/providers/moonshot> for setup and configuration.
|
|
13
|
-
|
|
14
|
-
## Catalog notes
|
|
15
|
-
|
|
16
|
-
Model rows live in `openclaw.plugin.json` under `modelCatalog.providers.kimi`.
|
|
17
|
-
|
|
18
|
-
- `k3` serves up to 1M context, tier-gated server-side; `k3-256k` is the cheaper
|
|
19
|
-
256K variant of the same weights. Both point at `moonshot/kimi-k3` through
|
|
20
|
-
`upstreamModel`, which keeps their `compat` capability tiers aligned with the
|
|
21
|
-
`moonshot` catalog for the same model.
|
|
22
|
-
- Legacy `k3[1m]` was retired upstream and normalizes to `k3` for shipped
|
|
23
|
-
configurations.
|
|
24
|
-
- `KIMI_K3_MODEL_IDS` in `provider-policy-api.ts` must cover exactly the catalog
|
|
25
|
-
rows that carry a K3 `thinkingLevelMap`; `provider-catalog.test.ts` asserts it.
|
package/dist/api.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, KIMI_CODING_LEGACY_MODEL_IDS, buildKimiCodingProvider, normalizeKimiCodingModelId } from "./provider-catalog.js";
|
|
2
2
|
import { KIMI_CODING_MODEL_REF, KIMI_MODEL_REF } from "./onboard.js";
|
|
3
3
|
export { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, KIMI_CODING_LEGACY_MODEL_IDS, KIMI_CODING_MODEL_REF, KIMI_MODEL_REF, buildKimiCodingProvider, normalizeKimiCodingModelId };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildKimiCodingProvider, normalizeKimiCodingModelId } from "./provider-catalog.js";
|
|
2
2
|
import { KIMI_CODING_MODEL_REF, applyKimiCodeConfig } from "./onboard.js";
|
|
3
|
-
import { isKimiK3ModelId, resolveThinkingProfile } from "./provider-policy-api.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
9
|
//#region extensions/kimi-coding/index.ts
|
|
@@ -15,61 +15,83 @@ function findExplicitProviderConfig(providers, providerId) {
|
|
|
15
15
|
const match = Object.entries(providers).find(([configuredProviderId]) => normalizeProviderId(configuredProviderId) === normalizedProviderId);
|
|
16
16
|
return isRecord(match?.[1]) ? match[1] : void 0;
|
|
17
17
|
}
|
|
18
|
-
var kimi_coding_default =
|
|
18
|
+
var kimi_coding_default = definePluginEntry({
|
|
19
19
|
id: PLUGIN_ID,
|
|
20
20
|
name: "Kimi Provider",
|
|
21
21
|
description: "Bundled Kimi provider plugin",
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"kimi-
|
|
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
|
-
|
|
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
|
+
});
|
|
73
95
|
}
|
|
74
96
|
});
|
|
75
97
|
//#endregion
|
package/dist/onboard.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, buildKimiCodingProvider } from "./provider-catalog.js";
|
|
2
2
|
import { createDefaultModelPresetAppliers } from "openclaw/plugin-sdk/provider-onboard";
|
|
3
3
|
//#region extensions/kimi-coding/onboard.ts
|
|
4
4
|
const KIMI_MODEL_REF = `kimi/${KIMI_CODING_DEFAULT_MODEL_ID}`;
|
|
5
5
|
const KIMI_CODING_MODEL_REF = KIMI_MODEL_REF;
|
|
6
6
|
function resolveKimiCodingDefaultModel() {
|
|
7
|
-
return buildKimiCodingProvider().models
|
|
7
|
+
return buildKimiCodingProvider().models[0];
|
|
8
8
|
}
|
|
9
9
|
const kimiCodingPresetAppliers = createDefaultModelPresetAppliers({
|
|
10
10
|
primaryModelRef: KIMI_MODEL_REF,
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,2 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
//#region extensions/kimi-coding/provider-catalog.ts
|
|
2
|
+
const KIMI_BASE_URL = "https://api.kimi.com/coding/";
|
|
3
|
+
const KIMI_CODING_USER_AGENT = "claude-code/0.1.0";
|
|
4
|
+
const KIMI_DEFAULT_MODEL_ID = "kimi-for-coding";
|
|
5
|
+
const KIMI_LEGACY_MODEL_IDS = ["kimi-code", "k2p5"];
|
|
6
|
+
const KIMI_CODING_DEFAULT_CONTEXT_WINDOW = 262144;
|
|
7
|
+
const KIMI_CODING_DEFAULT_MAX_TOKENS = 32768;
|
|
8
|
+
const KIMI_CODING_DEFAULT_COST = {
|
|
9
|
+
input: 0,
|
|
10
|
+
output: 0,
|
|
11
|
+
cacheRead: 0,
|
|
12
|
+
cacheWrite: 0
|
|
13
|
+
};
|
|
14
|
+
const KIMI_CODING_INPUT = ["text", "image"];
|
|
15
|
+
function buildKimiCodingProvider() {
|
|
16
|
+
return {
|
|
17
|
+
baseUrl: KIMI_BASE_URL,
|
|
18
|
+
api: "anthropic-messages",
|
|
19
|
+
headers: { "User-Agent": KIMI_CODING_USER_AGENT },
|
|
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
|
+
}))]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function normalizeKimiCodingModelId(modelId) {
|
|
40
|
+
return KIMI_LEGACY_MODEL_IDS.includes(modelId) ? KIMI_DEFAULT_MODEL_ID : modelId;
|
|
41
|
+
}
|
|
42
|
+
const KIMI_CODING_BASE_URL = KIMI_BASE_URL;
|
|
43
|
+
const KIMI_CODING_DEFAULT_MODEL_ID = KIMI_DEFAULT_MODEL_ID;
|
|
44
|
+
const KIMI_CODING_LEGACY_MODEL_IDS = KIMI_LEGACY_MODEL_IDS;
|
|
45
|
+
//#endregion
|
|
2
46
|
export { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, KIMI_CODING_LEGACY_MODEL_IDS, buildKimiCodingProvider, normalizeKimiCodingModelId };
|
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
|
@@ -17,105 +17,6 @@
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
"modelCatalog": {
|
|
21
|
-
"providers": {
|
|
22
|
-
"kimi": {
|
|
23
|
-
"baseUrl": "https://api.kimi.com/coding/",
|
|
24
|
-
"api": "anthropic-messages",
|
|
25
|
-
"headers": {
|
|
26
|
-
"User-Agent": "claude-code/0.1.0"
|
|
27
|
-
},
|
|
28
|
-
"defaultModel": "kimi-for-coding",
|
|
29
|
-
"models": [
|
|
30
|
-
{
|
|
31
|
-
"id": "k3",
|
|
32
|
-
"name": "Kimi K3",
|
|
33
|
-
"reasoning": true,
|
|
34
|
-
"upstreamModel": "moonshot/kimi-k3",
|
|
35
|
-
"thinkingLevelMap": {
|
|
36
|
-
"off": null,
|
|
37
|
-
"minimal": "low",
|
|
38
|
-
"low": "low",
|
|
39
|
-
"medium": "high",
|
|
40
|
-
"high": "high",
|
|
41
|
-
"xhigh": "max",
|
|
42
|
-
"max": "max"
|
|
43
|
-
},
|
|
44
|
-
"input": ["text", "image"],
|
|
45
|
-
"contextWindow": 1048576,
|
|
46
|
-
"maxTokens": 131072,
|
|
47
|
-
"cost": {
|
|
48
|
-
"input": 3,
|
|
49
|
-
"output": 15,
|
|
50
|
-
"cacheRead": 0.3,
|
|
51
|
-
"cacheWrite": 0
|
|
52
|
-
},
|
|
53
|
-
"compat": {
|
|
54
|
-
"codeMode": "preferred"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"id": "k3-256k",
|
|
59
|
-
"name": "Kimi K3 (256k)",
|
|
60
|
-
"reasoning": true,
|
|
61
|
-
"upstreamModel": "moonshot/kimi-k3",
|
|
62
|
-
"thinkingLevelMap": {
|
|
63
|
-
"off": null,
|
|
64
|
-
"minimal": "low",
|
|
65
|
-
"low": "low",
|
|
66
|
-
"medium": "high",
|
|
67
|
-
"high": "high",
|
|
68
|
-
"xhigh": "max",
|
|
69
|
-
"max": "max"
|
|
70
|
-
},
|
|
71
|
-
"input": ["text", "image"],
|
|
72
|
-
"contextWindow": 262144,
|
|
73
|
-
"maxTokens": 131072,
|
|
74
|
-
"cost": {
|
|
75
|
-
"input": 3,
|
|
76
|
-
"output": 15,
|
|
77
|
-
"cacheRead": 0.3,
|
|
78
|
-
"cacheWrite": 0
|
|
79
|
-
},
|
|
80
|
-
"compat": {
|
|
81
|
-
"codeMode": "preferred"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
"id": "kimi-for-coding",
|
|
86
|
-
"name": "Kimi Code",
|
|
87
|
-
"reasoning": true,
|
|
88
|
-
"input": ["text", "image"],
|
|
89
|
-
"contextWindow": 262144,
|
|
90
|
-
"maxTokens": 32768,
|
|
91
|
-
"cost": {
|
|
92
|
-
"input": 0,
|
|
93
|
-
"output": 0,
|
|
94
|
-
"cacheRead": 0,
|
|
95
|
-
"cacheWrite": 0
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"id": "kimi-for-coding-highspeed",
|
|
100
|
-
"name": "Kimi K2.7 Code HighSpeed",
|
|
101
|
-
"reasoning": true,
|
|
102
|
-
"input": ["text", "image"],
|
|
103
|
-
"contextWindow": 262144,
|
|
104
|
-
"maxTokens": 32768,
|
|
105
|
-
"cost": {
|
|
106
|
-
"input": 0,
|
|
107
|
-
"output": 0,
|
|
108
|
-
"cacheRead": 0,
|
|
109
|
-
"cacheWrite": 0
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
"discovery": {
|
|
116
|
-
"kimi": "static"
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
20
|
"modelPricing": {
|
|
120
21
|
"providers": {
|
|
121
22
|
"kimi": {
|
|
@@ -156,8 +57,8 @@
|
|
|
156
57
|
"appGuidedSecret": true,
|
|
157
58
|
"choiceLabel": "Kimi Code API key (subscription)",
|
|
158
59
|
"groupId": "moonshot",
|
|
159
|
-
"groupLabel": "Moonshot AI (Kimi)",
|
|
160
|
-
"groupHint": "Kimi
|
|
60
|
+
"groupLabel": "Moonshot AI (Kimi K2.6)",
|
|
61
|
+
"groupHint": "Kimi K2.6",
|
|
161
62
|
"optionKey": "kimiCodeApiKey",
|
|
162
63
|
"cliFlag": "--kimi-code-api-key",
|
|
163
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.34",
|
|
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.34"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.7.
|
|
24
|
+
"openclawVersion": "2026.7.34",
|
|
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.34"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { buildManifestModelProviderConfig } from "openclaw/plugin-sdk/provider-catalog-shared";
|
|
2
|
-
//#region extensions/kimi-coding/openclaw.plugin.json
|
|
3
|
-
var openclaw_plugin_default = {
|
|
4
|
-
id: "kimi",
|
|
5
|
-
activation: { "onStartup": false },
|
|
6
|
-
enabledByDefault: true,
|
|
7
|
-
providers: ["kimi", "kimi-coding"],
|
|
8
|
-
providerRequest: { "providers": {
|
|
9
|
-
"kimi": {
|
|
10
|
-
"family": "moonshot",
|
|
11
|
-
"compatibilityFamily": "moonshot"
|
|
12
|
-
},
|
|
13
|
-
"kimi-coding": {
|
|
14
|
-
"family": "moonshot",
|
|
15
|
-
"compatibilityFamily": "moonshot"
|
|
16
|
-
}
|
|
17
|
-
} },
|
|
18
|
-
modelCatalog: {
|
|
19
|
-
"providers": { "kimi": {
|
|
20
|
-
"baseUrl": "https://api.kimi.com/coding/",
|
|
21
|
-
"api": "anthropic-messages",
|
|
22
|
-
"headers": { "User-Agent": "claude-code/0.1.0" },
|
|
23
|
-
"defaultModel": "kimi-for-coding",
|
|
24
|
-
"models": [
|
|
25
|
-
{
|
|
26
|
-
"id": "k3",
|
|
27
|
-
"name": "Kimi K3",
|
|
28
|
-
"reasoning": true,
|
|
29
|
-
"upstreamModel": "moonshot/kimi-k3",
|
|
30
|
-
"thinkingLevelMap": {
|
|
31
|
-
"off": null,
|
|
32
|
-
"minimal": "low",
|
|
33
|
-
"low": "low",
|
|
34
|
-
"medium": "high",
|
|
35
|
-
"high": "high",
|
|
36
|
-
"xhigh": "max",
|
|
37
|
-
"max": "max"
|
|
38
|
-
},
|
|
39
|
-
"input": ["text", "image"],
|
|
40
|
-
"contextWindow": 1048576,
|
|
41
|
-
"maxTokens": 131072,
|
|
42
|
-
"cost": {
|
|
43
|
-
"input": 3,
|
|
44
|
-
"output": 15,
|
|
45
|
-
"cacheRead": .3,
|
|
46
|
-
"cacheWrite": 0
|
|
47
|
-
},
|
|
48
|
-
"compat": { "codeMode": "preferred" }
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"id": "k3-256k",
|
|
52
|
-
"name": "Kimi K3 (256k)",
|
|
53
|
-
"reasoning": true,
|
|
54
|
-
"upstreamModel": "moonshot/kimi-k3",
|
|
55
|
-
"thinkingLevelMap": {
|
|
56
|
-
"off": null,
|
|
57
|
-
"minimal": "low",
|
|
58
|
-
"low": "low",
|
|
59
|
-
"medium": "high",
|
|
60
|
-
"high": "high",
|
|
61
|
-
"xhigh": "max",
|
|
62
|
-
"max": "max"
|
|
63
|
-
},
|
|
64
|
-
"input": ["text", "image"],
|
|
65
|
-
"contextWindow": 262144,
|
|
66
|
-
"maxTokens": 131072,
|
|
67
|
-
"cost": {
|
|
68
|
-
"input": 3,
|
|
69
|
-
"output": 15,
|
|
70
|
-
"cacheRead": .3,
|
|
71
|
-
"cacheWrite": 0
|
|
72
|
-
},
|
|
73
|
-
"compat": { "codeMode": "preferred" }
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
"id": "kimi-for-coding",
|
|
77
|
-
"name": "Kimi Code",
|
|
78
|
-
"reasoning": true,
|
|
79
|
-
"input": ["text", "image"],
|
|
80
|
-
"contextWindow": 262144,
|
|
81
|
-
"maxTokens": 32768,
|
|
82
|
-
"cost": {
|
|
83
|
-
"input": 0,
|
|
84
|
-
"output": 0,
|
|
85
|
-
"cacheRead": 0,
|
|
86
|
-
"cacheWrite": 0
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"id": "kimi-for-coding-highspeed",
|
|
91
|
-
"name": "Kimi K2.7 Code HighSpeed",
|
|
92
|
-
"reasoning": true,
|
|
93
|
-
"input": ["text", "image"],
|
|
94
|
-
"contextWindow": 262144,
|
|
95
|
-
"maxTokens": 32768,
|
|
96
|
-
"cost": {
|
|
97
|
-
"input": 0,
|
|
98
|
-
"output": 0,
|
|
99
|
-
"cacheRead": 0,
|
|
100
|
-
"cacheWrite": 0
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
} },
|
|
105
|
-
"discovery": { "kimi": "static" }
|
|
106
|
-
},
|
|
107
|
-
modelPricing: { "providers": {
|
|
108
|
-
"kimi": {
|
|
109
|
-
"openRouter": { "provider": "moonshotai" },
|
|
110
|
-
"liteLLM": { "provider": "moonshot" }
|
|
111
|
-
},
|
|
112
|
-
"kimi-coding": {
|
|
113
|
-
"openRouter": { "provider": "moonshotai" },
|
|
114
|
-
"liteLLM": { "provider": "moonshot" }
|
|
115
|
-
}
|
|
116
|
-
} },
|
|
117
|
-
setup: { "providers": [{
|
|
118
|
-
"id": "kimi",
|
|
119
|
-
"envVars": ["KIMI_API_KEY", "KIMICODE_API_KEY"]
|
|
120
|
-
}, {
|
|
121
|
-
"id": "kimi-coding",
|
|
122
|
-
"envVars": ["KIMI_API_KEY", "KIMICODE_API_KEY"]
|
|
123
|
-
}] },
|
|
124
|
-
providerAuthChoices: [{
|
|
125
|
-
"provider": "kimi",
|
|
126
|
-
"method": "api-key",
|
|
127
|
-
"choiceId": "kimi-code-api-key",
|
|
128
|
-
"appGuidedSecret": true,
|
|
129
|
-
"choiceLabel": "Kimi Code API key (subscription)",
|
|
130
|
-
"groupId": "moonshot",
|
|
131
|
-
"groupLabel": "Moonshot AI (Kimi)",
|
|
132
|
-
"groupHint": "Kimi Code membership · https://www.kimi.com/membership/pricing",
|
|
133
|
-
"optionKey": "kimiCodeApiKey",
|
|
134
|
-
"cliFlag": "--kimi-code-api-key",
|
|
135
|
-
"cliOption": "--kimi-code-api-key <key>",
|
|
136
|
-
"cliDescription": "Kimi Code API key (subscription)"
|
|
137
|
-
}],
|
|
138
|
-
configSchema: {
|
|
139
|
-
"type": "object",
|
|
140
|
-
"additionalProperties": false,
|
|
141
|
-
"properties": {}
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region extensions/kimi-coding/provider-catalog.ts
|
|
146
|
-
const KIMI_PROVIDER_ID = "kimi";
|
|
147
|
-
const KIMI_CODING_CATALOG = openclaw_plugin_default.modelCatalog.providers.kimi;
|
|
148
|
-
const KIMI_LEGACY_MODEL_IDS = ["kimi-code", "k2p5"];
|
|
149
|
-
const KIMI_CODING_BASE_URL = KIMI_CODING_CATALOG.baseUrl;
|
|
150
|
-
const KIMI_CODING_DEFAULT_MODEL_ID = KIMI_CODING_CATALOG.defaultModel;
|
|
151
|
-
const KIMI_CODING_LEGACY_MODEL_IDS = KIMI_LEGACY_MODEL_IDS;
|
|
152
|
-
function buildKimiCodingProvider() {
|
|
153
|
-
return buildManifestModelProviderConfig({
|
|
154
|
-
providerId: KIMI_PROVIDER_ID,
|
|
155
|
-
catalog: KIMI_CODING_CATALOG
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
function normalizeKimiCodingModelId(modelId) {
|
|
159
|
-
if (modelId === "k3[1m]") return "k3";
|
|
160
|
-
return KIMI_LEGACY_MODEL_IDS.includes(modelId) ? KIMI_CODING_DEFAULT_MODEL_ID : modelId;
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
export { normalizeKimiCodingModelId as a, buildKimiCodingProvider as i, KIMI_CODING_DEFAULT_MODEL_ID as n, openclaw_plugin_default as o, KIMI_CODING_LEGACY_MODEL_IDS as r, KIMI_CODING_BASE_URL as t };
|
|
@@ -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 };
|