pi-provider-kimi-code 0.1.3 → 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.
Files changed (2) hide show
  1. package/index.ts +12 -9
  2. 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 = "kimi-cli/1.0.0 (external, cli)";
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,10 +276,7 @@ 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
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-provider-kimi-code",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "pi custom provider extension for Kimi Code models with OAuth device-code login",
5
5
  "type": "module",
6
6
  "license": "MIT",