@openclaw/kimi-provider 2026.7.2-beta.4 → 2026.7.2-beta.7

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 CHANGED
@@ -10,3 +10,16 @@ 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 { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, KIMI_CODING_LEGACY_MODEL_IDS, buildKimiCodingProvider, normalizeKimiCodingModelId } from "./provider-catalog.js";
1
+ import { a as normalizeKimiCodingModelId, i as buildKimiCodingProvider, n as KIMI_CODING_DEFAULT_MODEL_ID, r as KIMI_CODING_LEGACY_MODEL_IDS, t as KIMI_CODING_BASE_URL } from "./provider-catalog-DesMT16v.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,10 +1,9 @@
1
- import { isKimiK3ModelId, resolveThinkingProfile } from "./provider-policy-api.js";
2
- import { buildKimiCodingProvider, normalizeKimiCodingModelId } from "./provider-catalog.js";
1
+ import { a as normalizeKimiCodingModelId, i as buildKimiCodingProvider, o as openclaw_plugin_default } from "./provider-catalog-DesMT16v.js";
3
2
  import { KIMI_CODING_MODEL_REF, applyKimiCodeConfig } from "./onboard.js";
3
+ import { isKimiK3ModelId, resolveThinkingProfile } from "./provider-policy-api.js";
4
4
  import { KIMI_REPLAY_POLICY } from "./replay-policy.js";
5
5
  import { wrapKimiProviderStream } from "./stream.js";
6
- import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
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";
10
9
  //#region extensions/kimi-coding/index.ts
@@ -16,75 +15,61 @@ function findExplicitProviderConfig(providers, providerId) {
16
15
  const match = Object.entries(providers).find(([configuredProviderId]) => normalizeProviderId(configuredProviderId) === normalizedProviderId);
17
16
  return isRecord(match?.[1]) ? match[1] : void 0;
18
17
  }
19
- var kimi_coding_default = definePluginEntry({
18
+ var kimi_coding_default = defineSingleProviderPluginEntry({
20
19
  id: PLUGIN_ID,
21
20
  name: "Kimi Provider",
22
21
  description: "Bundled Kimi provider plugin",
23
- register(api) {
24
- api.registerProvider({
25
- id: PROVIDER_ID,
26
- label: "Kimi",
27
- aliases: ["kimi-code", "kimi-coding"],
28
- docsPath: "/providers/moonshot",
29
- envVars: ["KIMI_API_KEY", "KIMICODE_API_KEY"],
30
- auth: [createProviderApiKeyAuthMethod({
31
- providerId: PROVIDER_ID,
32
- methodId: "api-key",
33
- label: "Kimi Code API key (subscription)",
34
- hint: "Kimi Code membership · https://www.kimi.com/membership/pricing",
35
- optionKey: "kimiCodeApiKey",
36
- flagName: "--kimi-code-api-key",
37
- envVar: "KIMI_API_KEY",
38
- promptMessage: "Enter Kimi API key",
39
- defaultModel: KIMI_CODING_MODEL_REF,
40
- expectedProviders: [
41
- "kimi",
42
- "kimi-code",
43
- "kimi-coding"
44
- ],
45
- applyConfig: (cfg) => applyKimiCodeConfig(cfg),
46
- noteMessage: ["Kimi uses a dedicated coding endpoint and API key.", "Get your API key at: https://www.kimi.com/code/console"].join("\n"),
47
- noteTitle: "Kimi",
48
- wizard: {
49
- choiceId: "kimi-code-api-key",
50
- choiceLabel: "Kimi Code API key (subscription)",
51
- groupId: "moonshot",
52
- groupLabel: "Moonshot AI (Kimi)",
53
- groupHint: "Kimi Code membership · https://www.kimi.com/membership/pricing"
54
- }
55
- })],
56
- catalog: {
57
- order: "simple",
58
- run: async (ctx) => {
59
- const apiKey = ctx.resolveProviderApiKey(PROVIDER_ID).apiKey;
60
- if (!apiKey) return null;
61
- const explicitProvider = findExplicitProviderConfig(ctx.config.models?.providers, PROVIDER_ID);
62
- const builtInProvider = buildKimiCodingProvider();
63
- const explicitBaseUrl = normalizeOptionalString(explicitProvider?.baseUrl) ?? "";
64
- const explicitHeaders = isRecord(explicitProvider?.headers) ? explicitProvider.headers : void 0;
65
- return { provider: {
66
- ...builtInProvider,
67
- ...explicitBaseUrl ? { baseUrl: explicitBaseUrl } : {},
68
- ...explicitHeaders ? { headers: {
69
- ...builtInProvider.headers,
70
- ...explicitHeaders
71
- } } : {},
72
- apiKey
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
- });
22
+ manifest: openclaw_plugin_default,
23
+ provider: {
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
+ manifestAuth: {
30
+ promptMessage: "Enter Kimi API key",
31
+ defaultModel: KIMI_CODING_MODEL_REF,
32
+ expectedProviders: [
33
+ "kimi",
34
+ "kimi-code",
35
+ "kimi-coding"
36
+ ],
37
+ applyConfig: applyKimiCodeConfig,
38
+ noteMessage: ["Kimi uses a dedicated coding endpoint and API key.", "Get your API key at: https://www.kimi.com/code/console"].join("\n"),
39
+ noteTitle: "Kimi"
40
+ },
41
+ catalog: {
42
+ order: "simple",
43
+ run: async (ctx) => {
44
+ const apiKey = ctx.resolveProviderApiKey(PROVIDER_ID).apiKey;
45
+ if (!apiKey) return null;
46
+ const explicitProvider = findExplicitProviderConfig(ctx.config.models?.providers, PROVIDER_ID);
47
+ const builtInProvider = buildKimiCodingProvider();
48
+ const explicitBaseUrl = normalizeOptionalString(explicitProvider?.baseUrl) ?? "";
49
+ const explicitHeaders = isRecord(explicitProvider?.headers) ? explicitProvider.headers : void 0;
50
+ return { provider: {
51
+ ...builtInProvider,
52
+ ...explicitBaseUrl ? { baseUrl: explicitBaseUrl } : {},
53
+ ...explicitHeaders ? { headers: {
54
+ ...builtInProvider.headers,
55
+ ...explicitHeaders
56
+ } } : {},
57
+ apiKey
58
+ } };
59
+ }
60
+ },
61
+ buildReplayPolicy: () => KIMI_REPLAY_POLICY,
62
+ normalizeResolvedModel: ({ model }) => {
63
+ const normalizedId = normalizeKimiCodingModelId(model.id);
64
+ return normalizedId === model.id ? void 0 : {
65
+ ...model,
66
+ id: normalizedId
67
+ };
68
+ },
69
+ normalizeModelId: ({ modelId }) => normalizeKimiCodingModelId(modelId),
70
+ resolveThinkingProfile,
71
+ wrapSimpleCompletionStreamFn: (ctx) => isKimiK3ModelId(ctx.modelId) ? wrapKimiProviderStream(ctx) : ctx.streamFn,
72
+ wrapStreamFn: wrapKimiProviderStream
88
73
  }
89
74
  });
90
75
  //#endregion
package/dist/onboard.js CHANGED
@@ -1,10 +1,10 @@
1
- import { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, buildKimiCodingProvider } from "./provider-catalog.js";
1
+ import { i as buildKimiCodingProvider, n as KIMI_CODING_DEFAULT_MODEL_ID, t as KIMI_CODING_BASE_URL } from "./provider-catalog-DesMT16v.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[0];
7
+ return buildKimiCodingProvider().models.find((model) => model.id === KIMI_CODING_DEFAULT_MODEL_ID);
8
8
  }
9
9
  const kimiCodingPresetAppliers = createDefaultModelPresetAppliers({
10
10
  primaryModelRef: KIMI_MODEL_REF,
@@ -0,0 +1,163 @@
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,69 +1,2 @@
1
- import { KIMI_K3_MODEL_IDS } from "./provider-policy-api.js";
2
- //#region extensions/kimi-coding/provider-catalog.ts
3
- const KIMI_BASE_URL = "https://api.kimi.com/coding/";
4
- const KIMI_CODING_USER_AGENT = "claude-code/0.1.0";
5
- const KIMI_DEFAULT_MODEL_ID = "kimi-for-coding";
6
- const KIMI_HIGHSPEED_MODEL_ID = "kimi-for-coding-highspeed";
7
- const KIMI_LEGACY_MODEL_IDS = ["kimi-code", "k2p5"];
8
- const KIMI_CODING_DEFAULT_CONTEXT_WINDOW = 262144;
9
- const KIMI_CODING_DEFAULT_MAX_TOKENS = 32768;
10
- const KIMI_CODING_DEFAULT_COST = {
11
- input: 0,
12
- output: 0,
13
- cacheRead: 0,
14
- cacheWrite: 0
15
- };
16
- const KIMI_CODING_INPUT = ["text", "image"];
17
- function buildKimiCodingProvider() {
18
- return {
19
- baseUrl: KIMI_BASE_URL,
20
- api: "anthropic-messages",
21
- headers: { "User-Agent": KIMI_CODING_USER_AGENT },
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
- ]
60
- };
61
- }
62
- function normalizeKimiCodingModelId(modelId) {
63
- return KIMI_LEGACY_MODEL_IDS.includes(modelId) ? KIMI_DEFAULT_MODEL_ID : modelId;
64
- }
65
- const KIMI_CODING_BASE_URL = KIMI_BASE_URL;
66
- const KIMI_CODING_DEFAULT_MODEL_ID = KIMI_DEFAULT_MODEL_ID;
67
- const KIMI_CODING_LEGACY_MODEL_IDS = KIMI_LEGACY_MODEL_IDS;
68
- //#endregion
1
+ import { a as normalizeKimiCodingModelId, i as buildKimiCodingProvider, n as KIMI_CODING_DEFAULT_MODEL_ID, r as KIMI_CODING_LEGACY_MODEL_IDS, t as KIMI_CODING_BASE_URL } from "./provider-catalog-DesMT16v.js";
69
2
  export { KIMI_CODING_BASE_URL, KIMI_CODING_DEFAULT_MODEL_ID, KIMI_CODING_LEGACY_MODEL_IDS, buildKimiCodingProvider, normalizeKimiCodingModelId };
@@ -1,18 +1,24 @@
1
1
  //#region extensions/kimi-coding/provider-policy-api.ts
2
- const KIMI_K3_MODEL_IDS = ["k3", "k3[1m]"];
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
- return KIMI_K3_MODEL_IDS.includes(modelId.trim().toLowerCase());
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
- id: "off",
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 resolveKimiK3ThinkingType(params) {
97
+ function resolveKimiK3ThinkingConfig(params) {
105
98
  const configured = normalizeKimiThinkingConfig(params.configuredThinking);
106
- if (configured) return configured.type;
107
- return params.thinkingLevel === "off" ? "disabled" : "enabled";
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, k3ThinkingType) {
221
+ function createKimiThinkingWrapper(baseStreamFn, thinkingConfig, k3ThinkingConfig) {
225
222
  const underlying = baseStreamFn ?? streamSimple;
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" };
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
- return;
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 k3ThinkingType = resolveKimiK3ThinkingType({
295
+ const k3ThinkingConfig = resolveKimiK3ThinkingConfig({
288
296
  configuredThinking: ctx.extraParams?.thinking,
289
297
  thinkingLevel: ctx.thinkingLevel
290
298
  });
291
- return createKimiToolCallMarkupWrapper(createKimiThinkingWrapper(ctx.streamFn, thinkingConfig, k3ThinkingType));
299
+ return createKimiToolCallMarkupWrapper(createKimiThinkingWrapper(ctx.streamFn, thinkingConfig, k3ThinkingConfig));
292
300
  }
293
301
  //#endregion
294
302
  export { wrapKimiProviderStream };
@@ -17,6 +17,105 @@
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
+ },
20
119
  "modelPricing": {
21
120
  "providers": {
22
121
  "kimi": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/kimi-provider",
3
- "version": "2026.7.2-beta.4",
3
+ "version": "2026.7.2-beta.7",
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.4"
21
+ "pluginApi": ">=2026.7.2-beta.7"
22
22
  },
23
23
  "build": {
24
- "openclawVersion": "2026.7.2-beta.4",
24
+ "openclawVersion": "2026.7.2-beta.7",
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.4"
41
+ "openclaw": ">=2026.7.2-beta.7"
43
42
  },
44
43
  "peerDependenciesMeta": {
45
44
  "openclaw": {
@@ -1,12 +0,0 @@
1
- {
2
- "name": "@openclaw/kimi-provider",
3
- "version": "2026.7.2-beta.4",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "@openclaw/kimi-provider",
9
- "version": "2026.7.2-beta.4"
10
- }
11
- }
12
- }