pi-provider-kimi-code 0.1.2 → 0.1.4
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/index.ts +25 -13
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
13
|
+
import os from "node:os";
|
|
13
14
|
import type { OAuthCredentials, OAuthLoginCallbacks } from "@mariozechner/pi-ai";
|
|
14
15
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
15
16
|
|
|
@@ -19,8 +20,9 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
|
19
20
|
|
|
20
21
|
const CLIENT_ID = "17e5f671-d194-4dfb-9706-5516cb48c098";
|
|
21
22
|
const OAUTH_HOST = "https://auth.kimi.com";
|
|
22
|
-
const KIMI_CLI_USER_AGENT = "
|
|
23
|
+
const KIMI_CLI_USER_AGENT = "KimiCLI/1.0.0";
|
|
23
24
|
const KIMI_PLATFORM = "kimi_cli";
|
|
25
|
+
const KIMI_CLI_VERSION = "1.0.0";
|
|
24
26
|
|
|
25
27
|
// =============================================================================
|
|
26
28
|
// Device identification
|
|
@@ -32,14 +34,15 @@ function createDeviceId(): string {
|
|
|
32
34
|
|
|
33
35
|
function getDeviceModel(): string {
|
|
34
36
|
const platform = process.platform;
|
|
35
|
-
const arch = process.arch;
|
|
37
|
+
const arch = os.machine() || process.arch;
|
|
38
|
+
const release = os.release();
|
|
36
39
|
if (platform === "darwin") {
|
|
37
|
-
return `macOS ${arch}`;
|
|
40
|
+
return release && arch ? `macOS ${release} ${arch}` : `macOS ${arch}`;
|
|
38
41
|
}
|
|
39
42
|
if (platform === "win32") {
|
|
40
|
-
return `Windows ${arch}`;
|
|
43
|
+
return release && arch ? `Windows ${release} ${arch}` : `Windows ${arch}`;
|
|
41
44
|
}
|
|
42
|
-
return `${platform} ${arch}`;
|
|
45
|
+
return release && arch ? `${platform} ${release} ${arch}` : `${platform} ${arch}`;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
const DEVICE_MODEL = getDeviceModel();
|
|
@@ -56,7 +59,10 @@ function getCommonHeaders(): Record<string, string> {
|
|
|
56
59
|
return {
|
|
57
60
|
"User-Agent": KIMI_CLI_USER_AGENT,
|
|
58
61
|
"X-Msh-Platform": KIMI_PLATFORM,
|
|
62
|
+
"X-Msh-Version": KIMI_CLI_VERSION,
|
|
63
|
+
"X-Msh-Device-Name": os.hostname(),
|
|
59
64
|
"X-Msh-Device-Model": DEVICE_MODEL,
|
|
65
|
+
"X-Msh-Os-Version": os.release(),
|
|
60
66
|
"X-Msh-Device-Id": getStableDeviceId(),
|
|
61
67
|
};
|
|
62
68
|
}
|
|
@@ -270,23 +276,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
270
276
|
apiKey: "KIMI_API_KEY",
|
|
271
277
|
api: "anthropic-messages",
|
|
272
278
|
|
|
273
|
-
headers:
|
|
274
|
-
"User-Agent": KIMI_CLI_USER_AGENT,
|
|
275
|
-
"X-Msh-Platform": KIMI_PLATFORM,
|
|
276
|
-
},
|
|
279
|
+
headers: getCommonHeaders(),
|
|
277
280
|
|
|
278
281
|
models: [
|
|
279
282
|
{
|
|
280
|
-
id: "kimi-
|
|
281
|
-
name: "Kimi
|
|
283
|
+
id: "kimi-code",
|
|
284
|
+
name: "Kimi Code (powered by kimi-k2.5)",
|
|
282
285
|
reasoning: true,
|
|
283
|
-
input: ["text"],
|
|
286
|
+
input: ["text", "image"],
|
|
284
287
|
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
285
288
|
contextWindow: 262144,
|
|
286
289
|
maxTokens: 32768,
|
|
287
290
|
},
|
|
288
291
|
{
|
|
289
|
-
id: "
|
|
292
|
+
id: "kimi-k2.5",
|
|
290
293
|
name: "Kimi K2.5",
|
|
291
294
|
reasoning: true,
|
|
292
295
|
input: ["text", "image"],
|
|
@@ -294,6 +297,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
294
297
|
contextWindow: 262144,
|
|
295
298
|
maxTokens: 32768,
|
|
296
299
|
},
|
|
300
|
+
{
|
|
301
|
+
id: "kimi-k2-thinking-turbo",
|
|
302
|
+
name: "Kimi K2 Thinking Turbo",
|
|
303
|
+
reasoning: true,
|
|
304
|
+
input: ["text"],
|
|
305
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
306
|
+
contextWindow: 262144,
|
|
307
|
+
maxTokens: 32768,
|
|
308
|
+
},
|
|
297
309
|
],
|
|
298
310
|
|
|
299
311
|
oauth: {
|