pi-provider-kimi-code 0.6.10 → 0.6.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-provider-kimi-code",
3
- "version": "0.6.10",
3
+ "version": "0.6.11",
4
4
  "description": "Kimi Code models (K3, K2.7, HighSpeed) in Pi: OAuth shared login with kimi-code CLI, file uploads, and Kimi-native tools",
5
5
  "keywords": [
6
6
  "ai-provider",
package/src/constants.ts CHANGED
@@ -41,14 +41,10 @@ export function getDefaultBaseUrl(protocol: KimiWireProtocol): string {
41
41
 
42
42
  export const DEFAULT_BASE_URL = getDefaultBaseUrl(ENV_KIMI_CODE_PROTOCOL);
43
43
 
44
- export const PROVIDER_VERSION = "0.6.10";
45
-
46
- // Upstream kimi-code CLI version — used in User-Agent and X-Msh-Version
47
- // headers to match the official client's identity. Update this when
48
- // syncing with https://github.com/MoonshotAI/kimi-code.
49
- export const KIMI_UPSTREAM_VERSION = "0.34.0";
50
- export const KIMI_CODE_USER_AGENT = `kimi-code-cli/${KIMI_UPSTREAM_VERSION}`;
51
- export const KIMI_PLATFORM = "kimi_code_cli";
44
+ export const PROVIDER_VERSION = "0.6.11";
45
+
46
+ export const KIMI_CODE_USER_AGENT = `pi-provider-kimi-code/${PROVIDER_VERSION}`;
47
+ export const KIMI_PLATFORM = "pi";
52
48
 
53
49
  export function getKimiCodeHome(): string {
54
50
  const value = process.env.KIMI_CODE_HOME?.trim();
package/src/device.ts CHANGED
@@ -8,12 +8,12 @@ import { readFile } from "node:fs/promises";
8
8
  import os from "node:os";
9
9
  import { dirname } from "node:path";
10
10
 
11
- import {
12
- DEVICE_ID_PATH,
13
- KIMI_CODE_USER_AGENT,
14
- KIMI_UPSTREAM_VERSION,
15
- KIMI_PLATFORM,
16
- } from "./constants.ts";
11
+ // Namespace import (not a named import of VERSION) so a missing export on old
12
+ // pi versions degrades to undefined rather than a module-link error that kills
13
+ // the whole extension load.
14
+ import * as piAgent from "@earendil-works/pi-coding-agent";
15
+
16
+ import { DEVICE_ID_PATH, KIMI_CODE_USER_AGENT, KIMI_PLATFORM } from "./constants.ts";
17
17
 
18
18
  function createDeviceId(): string {
19
19
  return randomBytes(16).toString("hex");
@@ -165,6 +165,13 @@ export function getOsVersion(): string {
165
165
  return os.release();
166
166
  }
167
167
 
168
+ // The running pi TUI's version, read off pi-coding-agent's VERSION export (it
169
+ // reads its own package.json at module load).
170
+ export function getPiVersion(): string {
171
+ const version = (piAgent as { VERSION?: unknown }).VERSION;
172
+ return typeof version === "string" && version ? version : "unknown";
173
+ }
174
+
168
175
  export function asciiHeaderValue(value: string, fallback = "unknown"): string {
169
176
  const trimmed = value.trim();
170
177
  /* oxlint-disable-next-line no-control-regex */
@@ -214,7 +221,7 @@ export function getCommonHeaders(): Record<string, string> {
214
221
  const headers = {
215
222
  "User-Agent": KIMI_CODE_USER_AGENT,
216
223
  "X-Msh-Platform": KIMI_PLATFORM,
217
- "X-Msh-Version": KIMI_UPSTREAM_VERSION,
224
+ "X-Msh-Version": getPiVersion(),
218
225
  "X-Msh-Device-Name": os.hostname(),
219
226
  "X-Msh-Device-Model": getDeviceModel(),
220
227
  "X-Msh-Os-Version": getOsVersion(),