@openclaw/kimi-provider 2026.10.5-beta.3 → 2026.10.10-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/README.md +4 -2
- package/dist/index.js +23 -5
- package/dist/provider-catalog.js +1 -2
- package/dist/provider-policy-api.js +15 -3
- package/dist/stream.js +24 -17
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -29,5 +29,7 @@ Model rows live in `openclaw.plugin.json` under `modelCatalog.providers.kimi`.
|
|
|
29
29
|
`moonshot` catalog for the same model.
|
|
30
30
|
- Legacy `k3[1m]` was retired upstream and normalizes to `k3` for shipped
|
|
31
31
|
configurations.
|
|
32
|
-
- `KIMI_K3_MODEL_IDS` in `provider-policy-api.ts`
|
|
33
|
-
|
|
32
|
+
- `KIMI_K3_MODEL_IDS` in `provider-policy-api.ts` covers the catalog rows with a
|
|
33
|
+
K3 `thinkingLevelMap` and the self-hosted wire ID `kimi-k3` (case-insensitive).
|
|
34
|
+
The wire ID stays off by default. OpenAI-compatible requests use the same
|
|
35
|
+
low/high/max effort mapping as hosted K3, sent as `reasoning_effort`.
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { a as normalizeKimiCodingModelId, i as buildKimiCodingProvider, o as openclaw_plugin_default } from "./.setup/provider-catalog-Bc73oFLX.mjs";
|
|
2
2
|
import { applyKimiCodeConfig } from "./onboard.js";
|
|
3
|
-
import { isKimiK3ModelId, resolveThinkingProfile } from "./provider-policy-api.js";
|
|
4
|
-
import {
|
|
5
|
-
import { findNormalizedProviderValue } from "openclaw/plugin-sdk/provider-auth";
|
|
3
|
+
import { KIMI_K3_THINKING_EFFORTS, isKimiK3ModelId, resolveThinkingProfile } from "./provider-policy-api.js";
|
|
4
|
+
import { createLazyRuntimeModule, createLazyRuntimeSurface } from "openclaw/plugin-sdk/lazy-runtime";
|
|
6
5
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
7
|
-
import { normalizeProviderId } from "openclaw/plugin-sdk/provider-model-
|
|
6
|
+
import { findNormalizedProviderKey, normalizeProviderId } from "openclaw/plugin-sdk/provider-model-metadata";
|
|
8
7
|
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
8
|
//#region extensions/kimi-coding/index.ts
|
|
10
9
|
const PLUGIN_ID = "kimi";
|
|
11
10
|
const PROVIDER_ID = "kimi";
|
|
12
11
|
const PROVIDER_ALIASES = ["kimi-code", "kimi-coding"];
|
|
12
|
+
const loadStreamRuntime = createLazyRuntimeModule(() => import("./stream.js"));
|
|
13
|
+
function wrapKimiProviderStream(ctx) {
|
|
14
|
+
const loadStream = createLazyRuntimeSurface(loadStreamRuntime, (runtime) => runtime.wrapKimiProviderStream(ctx));
|
|
15
|
+
return async (model, context, options) => {
|
|
16
|
+
options?.signal?.throwIfAborted();
|
|
17
|
+
const stream = await loadStream();
|
|
18
|
+
options?.signal?.throwIfAborted();
|
|
19
|
+
return stream(model, context, options);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
13
22
|
var kimi_coding_default = defineSingleProviderPluginEntry({
|
|
14
23
|
id: PLUGIN_ID,
|
|
15
24
|
name: "Kimi Provider",
|
|
@@ -37,7 +46,8 @@ var kimi_coding_default = defineSingleProviderPluginEntry({
|
|
|
37
46
|
run: async (ctx) => {
|
|
38
47
|
const apiKey = ctx.resolveProviderApiKey(PROVIDER_ID).apiKey;
|
|
39
48
|
if (!apiKey) return null;
|
|
40
|
-
const
|
|
49
|
+
const explicitProviderKey = findNormalizedProviderKey(ctx.config.models?.providers, PROVIDER_ID);
|
|
50
|
+
const explicitProvider = explicitProviderKey === void 0 ? void 0 : ctx.config.models?.providers?.[explicitProviderKey];
|
|
41
51
|
const builtInProvider = buildKimiCodingProvider();
|
|
42
52
|
const explicitBaseUrl = normalizeOptionalString(explicitProvider?.baseUrl) ?? "";
|
|
43
53
|
const explicitHeaders = isRecord(explicitProvider?.headers) ? explicitProvider.headers : void 0;
|
|
@@ -61,6 +71,14 @@ var kimi_coding_default = defineSingleProviderPluginEntry({
|
|
|
61
71
|
buildReplayPolicy: () => ({ preserveSignatures: false }),
|
|
62
72
|
normalizeResolvedModel: ({ model }) => {
|
|
63
73
|
const normalizedId = normalizeKimiCodingModelId(model.id);
|
|
74
|
+
if (model.api === "openai-completions" && isKimiK3ModelId(normalizedId)) return {
|
|
75
|
+
...model,
|
|
76
|
+
id: normalizedId,
|
|
77
|
+
thinkingLevelMap: {
|
|
78
|
+
...KIMI_K3_THINKING_EFFORTS,
|
|
79
|
+
...model.thinkingLevelMap
|
|
80
|
+
}
|
|
81
|
+
};
|
|
64
82
|
return normalizedId === model.id ? void 0 : {
|
|
65
83
|
...model,
|
|
66
84
|
id: normalizedId
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, KIMI_CODING_LEGACY_MODEL_IDS, buildKimiCodingProvider, normalizeKimiCodingModelId };
|
|
1
|
+
export { t as KIMI_CODING_BASE_URL, n as KIMI_CODING_DEFAULT_MODEL_ID, r as KIMI_CODING_LEGACY_MODEL_IDS, i as buildKimiCodingProvider, a as normalizeKimiCodingModelId } from "./.setup/provider-catalog-Bc73oFLX.mjs";
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
//#region extensions/kimi-coding/provider-policy-api.ts
|
|
2
|
-
const KIMI_K3_MODEL_IDS = [
|
|
2
|
+
const KIMI_K3_MODEL_IDS = [
|
|
3
|
+
"k3",
|
|
4
|
+
"k3-256k",
|
|
5
|
+
"kimi-k3"
|
|
6
|
+
];
|
|
3
7
|
const KIMI_K3_LEGACY_MODEL_IDS = ["k3[1m]"];
|
|
8
|
+
const KIMI_K3_THINKING_EFFORTS = {
|
|
9
|
+
minimal: "low",
|
|
10
|
+
low: "low",
|
|
11
|
+
medium: "high",
|
|
12
|
+
high: "high",
|
|
13
|
+
xhigh: "max",
|
|
14
|
+
max: "max"
|
|
15
|
+
};
|
|
4
16
|
const KIMI_K3_THINKING_LEVELS = [
|
|
5
17
|
{ id: "off" },
|
|
6
18
|
{ id: "minimal" },
|
|
@@ -18,7 +30,7 @@ function isKimiK3ModelId(modelId) {
|
|
|
18
30
|
function resolveThinkingProfile({ modelId }) {
|
|
19
31
|
if (isKimiK3ModelId(modelId)) return {
|
|
20
32
|
levels: KIMI_K3_THINKING_LEVELS,
|
|
21
|
-
defaultLevel: "high",
|
|
33
|
+
defaultLevel: modelId.trim().toLowerCase() === "kimi-k3" ? "off" : "high",
|
|
22
34
|
preserveWhenCatalogReasoningFalse: true
|
|
23
35
|
};
|
|
24
36
|
return {
|
|
@@ -33,4 +45,4 @@ function resolveThinkingProfile({ modelId }) {
|
|
|
33
45
|
};
|
|
34
46
|
}
|
|
35
47
|
//#endregion
|
|
36
|
-
export { KIMI_K3_MODEL_IDS, isKimiK3ModelId, resolveThinkingProfile };
|
|
48
|
+
export { KIMI_K3_MODEL_IDS, KIMI_K3_THINKING_EFFORTS, isKimiK3ModelId, resolveThinkingProfile };
|
package/dist/stream.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { isKimiK3ModelId } from "./provider-policy-api.js";
|
|
1
|
+
import { KIMI_K3_THINKING_EFFORTS, isKimiK3ModelId } from "./provider-policy-api.js";
|
|
2
2
|
import { asFiniteNumberInRange, asOptionalObjectRecord, isRecord, parseBooleanValue } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
|
-
import { streamSimple } from "openclaw/plugin-sdk/llm";
|
|
3
|
+
import { resolveOpenAIRequestReasoning, 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
|
|
6
6
|
const TOOL_CALLS_SECTION_BEGIN = "<|tool_calls_section_begin|>";
|
|
@@ -19,15 +19,6 @@ 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
|
-
};
|
|
31
22
|
function ensureKimiAnthropicMaxTokens(payloadObj, thinkingConfig) {
|
|
32
23
|
if (thinkingConfig.type !== "enabled" || thinkingConfig.budget_tokens === void 0) return;
|
|
33
24
|
const required = Math.max(KIMI_ANTHROPIC_MIN_OUTPUT_TOKENS, thinkingConfig.budget_tokens + KIMI_ANTHROPIC_VISIBLE_OUTPUT_RESERVE_TOKENS);
|
|
@@ -141,13 +132,17 @@ function createKimiToolCallMarkupWrapper(baseStreamFn) {
|
|
|
141
132
|
}
|
|
142
133
|
function wrapKimiProviderStream(ctx) {
|
|
143
134
|
const configured = normalizeKimiThinkingConfig(ctx.extraParams?.thinking);
|
|
135
|
+
const extraBody = asOptionalObjectRecord(ctx.extraParams?.extra_body ?? ctx.extraParams?.extraBody);
|
|
136
|
+
const templateKwargs = asOptionalObjectRecord(extraBody?.chat_template_kwargs ?? ctx.extraParams?.chat_template_kwargs ?? ctx.extraParams?.chatTemplateKwargs);
|
|
144
137
|
const underlying = ctx.streamFn ?? streamSimple;
|
|
145
138
|
return createKimiToolCallMarkupWrapper((model, context, options) => {
|
|
146
|
-
const
|
|
139
|
+
const api = ctx.sourceApi ?? model.api;
|
|
140
|
+
const anthropic = api === "anthropic-messages";
|
|
147
141
|
const k3 = anthropic && isKimiK3ModelId(model.id);
|
|
142
|
+
const openaiK3 = api === "openai-completions" && isKimiK3ModelId(model.id);
|
|
148
143
|
const thinkingLevel = options?.reasoning ?? ctx.thinkingLevel ?? (k3 ? "high" : void 0);
|
|
149
144
|
const thinkingConfig = resolveKimiThinkingConfig(configured, thinkingLevel);
|
|
150
|
-
const enabledLevel = thinkingLevel && thinkingLevel !== "off" ? thinkingLevel : k3 ? "high" : "low";
|
|
145
|
+
const enabledLevel = thinkingLevel && thinkingLevel !== "off" ? thinkingLevel : k3 || openaiK3 ? "high" : "low";
|
|
151
146
|
const nativeLevel = enabledLevel === "adaptive" ? "high" : enabledLevel;
|
|
152
147
|
const reasoning = thinkingConfig.type === "disabled" ? "off" : k3 ? KIMI_K3_THINKING_EFFORTS[nativeLevel] : nativeLevel;
|
|
153
148
|
const runtimeModel = k3 ? {
|
|
@@ -156,6 +151,12 @@ function wrapKimiProviderStream(ctx) {
|
|
|
156
151
|
...model.compat,
|
|
157
152
|
allowEmptySignature: true
|
|
158
153
|
}
|
|
154
|
+
} : openaiK3 ? {
|
|
155
|
+
...model,
|
|
156
|
+
thinkingLevelMap: {
|
|
157
|
+
...KIMI_K3_THINKING_EFFORTS,
|
|
158
|
+
...model.thinkingLevelMap
|
|
159
|
+
}
|
|
159
160
|
} : model;
|
|
160
161
|
return streamWithPayloadPatch(underlying, runtimeModel, context, {
|
|
161
162
|
...options,
|
|
@@ -183,10 +184,16 @@ function wrapKimiProviderStream(ctx) {
|
|
|
183
184
|
}
|
|
184
185
|
payloadObj.thinking = anthropic ? { ...thinkingConfig } : { type: thinkingConfig.type };
|
|
185
186
|
if (anthropic) ensureKimiAnthropicMaxTokens(payloadObj, thinkingConfig);
|
|
186
|
-
else
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
else {
|
|
188
|
+
if (openaiK3 && reasoning !== "off" && templateKwargs?.reasoning_effort === void 0) {
|
|
189
|
+
const { effort } = resolveOpenAIRequestReasoning(runtimeModel, reasoning);
|
|
190
|
+
if (effort !== void 0) payloadObj.reasoning_effort = effort;
|
|
191
|
+
}
|
|
192
|
+
normalizeOpenAICompatibleReasoningReplay(payloadObj, {
|
|
193
|
+
thinkingEnabled: thinkingConfig.type === "enabled",
|
|
194
|
+
shouldBackfillAssistantMessage: (message) => Array.isArray(message.tool_calls) && message.tool_calls.length > 0
|
|
195
|
+
});
|
|
196
|
+
}
|
|
190
197
|
});
|
|
191
198
|
});
|
|
192
199
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/kimi-provider",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.10-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.10.
|
|
21
|
+
"pluginApi": ">=2026.10.10-beta.1"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.10.
|
|
24
|
+
"openclawVersion": "2026.10.10-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.10.
|
|
43
|
+
"openclaw": ">=2026.10.10-beta.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|