@openclaw/kimi-provider 2026.7.2-beta.5 → 2026.8.1-beta.2
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 +13 -0
- package/dist/api.js +1 -1
- package/dist/index.js +2 -56
- package/dist/onboard.js +2 -2
- package/dist/provider-catalog-DesMT16v.js +163 -0
- package/dist/provider-catalog.js +1 -78
- package/dist/stream.js +41 -41
- package/openclaw.plugin.json +99 -0
- package/package.json +4 -4
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 {
|
|
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,65 +1,11 @@
|
|
|
1
|
-
import {
|
|
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
6
|
import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-entry";
|
|
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";
|
package/dist/onboard.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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 };
|
package/dist/provider-catalog.js
CHANGED
|
@@ -1,79 +1,2 @@
|
|
|
1
|
-
import {
|
|
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_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
|
-
const KIMI_CODING_INPUT = ["text", "image"];
|
|
34
|
-
function buildKimiCodingProvider() {
|
|
35
|
-
return {
|
|
36
|
-
baseUrl: KIMI_BASE_URL,
|
|
37
|
-
api: "anthropic-messages",
|
|
38
|
-
headers: { "User-Agent": KIMI_CODING_USER_AGENT },
|
|
39
|
-
models: [
|
|
40
|
-
{
|
|
41
|
-
id: KIMI_DEFAULT_MODEL_ID,
|
|
42
|
-
name: "Kimi Code",
|
|
43
|
-
reasoning: true,
|
|
44
|
-
input: [...KIMI_CODING_INPUT],
|
|
45
|
-
cost: KIMI_CODING_DEFAULT_COST,
|
|
46
|
-
contextWindow: KIMI_CODING_DEFAULT_CONTEXT_WINDOW,
|
|
47
|
-
maxTokens: KIMI_CODING_DEFAULT_MAX_TOKENS
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: KIMI_HIGHSPEED_MODEL_ID,
|
|
51
|
-
name: "Kimi K2.7 Code HighSpeed",
|
|
52
|
-
reasoning: true,
|
|
53
|
-
input: [...KIMI_CODING_INPUT],
|
|
54
|
-
cost: KIMI_CODING_DEFAULT_COST,
|
|
55
|
-
contextWindow: KIMI_CODING_DEFAULT_CONTEXT_WINDOW,
|
|
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
|
-
]
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function normalizeKimiCodingModelId(modelId) {
|
|
72
|
-
if (modelId === "k3[1m]") return "k3";
|
|
73
|
-
return KIMI_LEGACY_MODEL_IDS.includes(modelId) ? KIMI_DEFAULT_MODEL_ID : modelId;
|
|
74
|
-
}
|
|
75
|
-
const KIMI_CODING_BASE_URL = KIMI_BASE_URL;
|
|
76
|
-
const KIMI_CODING_DEFAULT_MODEL_ID = KIMI_DEFAULT_MODEL_ID;
|
|
77
|
-
const KIMI_CODING_LEGACY_MODEL_IDS = KIMI_LEGACY_MODEL_IDS;
|
|
78
|
-
//#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";
|
|
79
2
|
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,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 {
|
|
4
|
+
import { createPayloadPatchStreamWrapper, normalizeOpenAICompatibleReasoningReplay } 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|>";
|
|
@@ -219,7 +219,45 @@ function createKimiToolCallMarkupWrapper(baseStreamFn) {
|
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
function createKimiThinkingWrapper(baseStreamFn, thinkingConfig, k3ThinkingConfig) {
|
|
222
|
-
const
|
|
222
|
+
const payloadWrapper = createPayloadPatchStreamWrapper(baseStreamFn ?? streamSimple, ({ payload: payloadObj, model }) => {
|
|
223
|
+
if (model.api === "anthropic-messages" && isKimiK3ModelId(model.id)) {
|
|
224
|
+
const outputConfig = payloadObj.output_config;
|
|
225
|
+
if (k3ThinkingConfig.type === "disabled") {
|
|
226
|
+
payloadObj.thinking = { type: "disabled" };
|
|
227
|
+
if (outputConfig && typeof outputConfig === "object" && !Array.isArray(outputConfig)) {
|
|
228
|
+
const nextOutputConfig = { ...outputConfig };
|
|
229
|
+
delete nextOutputConfig.effort;
|
|
230
|
+
if (Object.keys(nextOutputConfig).length > 0) payloadObj.output_config = nextOutputConfig;
|
|
231
|
+
else delete payloadObj.output_config;
|
|
232
|
+
} else delete payloadObj.output_config;
|
|
233
|
+
} else {
|
|
234
|
+
payloadObj.thinking = {
|
|
235
|
+
type: "adaptive",
|
|
236
|
+
display: "summarized"
|
|
237
|
+
};
|
|
238
|
+
payloadObj.output_config = outputConfig && typeof outputConfig === "object" && !Array.isArray(outputConfig) ? {
|
|
239
|
+
...outputConfig,
|
|
240
|
+
effort: k3ThinkingConfig.effort
|
|
241
|
+
} : { effort: k3ThinkingConfig.effort };
|
|
242
|
+
}
|
|
243
|
+
delete payloadObj.reasoning;
|
|
244
|
+
delete payloadObj.reasoning_effort;
|
|
245
|
+
delete payloadObj.reasoningEffort;
|
|
246
|
+
stripAnthropicCacheControlMarkers(payloadObj);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const normalized = typeof thinkingConfig === "string" ? { type: thinkingConfig } : thinkingConfig;
|
|
250
|
+
payloadObj.thinking = model.api === "anthropic-messages" ? { ...normalized } : { type: normalized.type };
|
|
251
|
+
if (model.api === "anthropic-messages") ensureKimiAnthropicMaxTokens(payloadObj, normalized);
|
|
252
|
+
else normalizeOpenAICompatibleReasoningReplay(payloadObj, {
|
|
253
|
+
thinkingEnabled: normalized.type === "enabled",
|
|
254
|
+
shouldBackfillAssistantMessage: (message) => Array.isArray(message.tool_calls) && message.tool_calls.length > 0
|
|
255
|
+
});
|
|
256
|
+
delete payloadObj.reasoning;
|
|
257
|
+
delete payloadObj.reasoning_effort;
|
|
258
|
+
delete payloadObj.reasoningEffort;
|
|
259
|
+
stripAnthropicCacheControlMarkers(payloadObj);
|
|
260
|
+
});
|
|
223
261
|
return (model, context, options) => {
|
|
224
262
|
const runtimeModel = model.api === "anthropic-messages" && isKimiK3ModelId(model.id) ? {
|
|
225
263
|
...model,
|
|
@@ -228,45 +266,7 @@ function createKimiThinkingWrapper(baseStreamFn, thinkingConfig, k3ThinkingConfi
|
|
|
228
266
|
allowEmptySignature: true
|
|
229
267
|
}
|
|
230
268
|
} : model;
|
|
231
|
-
return
|
|
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;
|
|
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
|
-
});
|
|
269
|
+
return payloadWrapper(runtimeModel, context, options);
|
|
270
270
|
};
|
|
271
271
|
}
|
|
272
272
|
function stripContentBlockCacheControl(block) {
|
package/openclaw.plugin.json
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "2026.8.1-beta.2",
|
|
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.
|
|
21
|
+
"pluginApi": ">=2026.8.1-beta.2"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.
|
|
24
|
+
"openclawVersion": "2026.8.1-beta.2",
|
|
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.
|
|
41
|
+
"openclaw": ">=2026.8.1-beta.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"openclaw": {
|