kimi-webbridge-dsh 1.3.1 → 1.4.0

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 (3) hide show
  1. package/README.md +14 -0
  2. package/lib/index.js +33 -4
  3. package/package.json +6 -4
package/README.md CHANGED
@@ -18,6 +18,20 @@ Kimi WebBridge 的 dsh 插件:通过本机 kimi-webbridge 守护进程(`127.
18
18
  - **浏览器扩展**:需安装并连接 Kimi WebBridge 浏览器扩展 —— 从 [Chrome Web Store](https://chromewebstore.google.com/detail/kimi-webbridge/fldmhceldgbpfpkbgopacenieobmligc) 安装(`kimi-webbridge status` 显示 `extension_connected: true`;扩展版本应与守护进程一致)。
19
19
  - **守护进程**:无需预装。插件在守护进程不可达时会自动启动它;二进制缺失时会自动从官方 CDN(cdn.kimi.com,与官方安装器同源)下载安装——全程无需手动运行任何安装命令。
20
20
 
21
+ ### 跨平台支持
22
+
23
+ 插件根据运行时硬件自动选择并下载对应的守护进程二进制(含 SHA-256 校验,与官方清单核对后才安装):
24
+
25
+ | 平台 | 二进制 | 存档哈希(v1.11.6) |
26
+ |---|---|---|
27
+ | Windows x64 | `windows-amd64.exe` | `e085991e…90520` |
28
+ | macOS arm64 | `darwin-arm64` | `46fe401e…c9930` |
29
+ | macOS x64 | `darwin-amd64` | `edd1b126…e1ec54` |
30
+ | Linux arm64 | `linux-arm64` | `b1b139bf…b7923d` |
31
+ | Linux x64 | `linux-amd64` | `5c6eaf79…0150d` |
32
+
33
+ 不支持的平台组合会明确报错并提示手动安装。
34
+
21
35
  ## 安装(一次性,零手工配置)
22
36
 
23
37
  ```powershell
package/lib/index.js CHANGED
@@ -2,8 +2,9 @@ import z from "@deepseek-ai/schemastery";
2
2
  import { TOOL_ABORTED, defineTool } from "@deepseek-ai/dsh-tools";
3
3
  import { HarnessError } from "@deepseek-ai/dsh-llm";
4
4
  import { spawn } from "node:child_process";
5
+ import { createHash } from "node:crypto";
5
6
  import { createWriteStream, existsSync } from "node:fs";
6
- import { chmod, mkdir, rename } from "node:fs/promises";
7
+ import { chmod, mkdir, readFile, rename, rm } from "node:fs/promises";
7
8
  import { request as httpRequest } from "node:http";
8
9
  import { request as httpsRequest } from "node:https";
9
10
  import { homedir } from "node:os";
@@ -194,22 +195,50 @@ function downloadFile(url, dest, { timeoutMs, maxRedirects = 3 } = {}) {
194
195
 
195
196
  /**
196
197
  * Download the daemon binary from the official CDN into ~/.kimi-webbridge/bin.
198
+ *
197
199
  * The URL layout mirrors the official installer: {CDN}/{version}/releases/kimi-webbridge-{platform}.
198
- * @returns { bin, url } on success.
200
+ * The platform is derived from the runtime hardware (see releasePlatform), so the
201
+ * correct binary for Windows / macOS / Linux is fetched automatically.
202
+ *
203
+ * When the release manifest (version.json) for the same version is available, the
204
+ * downloaded binary is verified against its published SHA-256 before being installed;
205
+ * a mismatch aborts the install and removes the file, so an unexpected binary can
206
+ * never land on disk.
207
+ *
208
+ * @returns { bin, url, sha256 } on success (sha256 is the manifest digest, or null when the manifest is unavailable).
199
209
  */
200
210
  async function installDaemonBinary({ version, timeoutMs }) {
201
211
  const platform = releasePlatform();
202
212
  if (platform === null) {
203
213
  throw new Error(`unsupported platform ${process.platform}-${process.arch} — install the daemon manually (see https://www.kimi.com/zh-cn/features/webbridge)`);
204
214
  }
215
+ const manifestKey = platform.endsWith(".exe") ? platform.slice(0, -4) : platform;
205
216
  const bin = daemonBinPath();
206
217
  await mkdir(dirname(bin), { recursive: true });
207
- const url = `${CDN_BASE}/${encodeURIComponent(version)}/releases/kimi-webbridge-${platform}`;
218
+ const base = `${CDN_BASE}/${encodeURIComponent(version)}`;
219
+ const url = `${base}/releases/kimi-webbridge-${platform}`;
220
+ // Best-effort: fetch the release manifest for the expected SHA-256.
221
+ let expectedSha = null;
222
+ try {
223
+ const manifest = await httpJson(`${base}/version.json`, { method: "GET", timeoutMs });
224
+ if (manifest.status >= 200 && manifest.status < 300 && manifest.body !== null && typeof manifest.body === "object") {
225
+ expectedSha = manifest.body?.binaries?.[manifestKey]?.sha256 ?? null;
226
+ }
227
+ } catch {
228
+ // Manifest unavailable (e.g. old pinned version) — install without checksum.
229
+ }
208
230
  const tmp = `${bin}.tmp-${process.pid}-${Date.now()}`;
209
231
  await downloadFile(url, tmp, { timeoutMs });
232
+ if (expectedSha !== null) {
233
+ const actual = createHash("sha256").update(await readFile(tmp)).digest("hex");
234
+ if (actual !== expectedSha) {
235
+ await rm(tmp, { force: true });
236
+ throw new Error(`downloaded binary SHA-256 mismatch for ${platform}: expected ${expectedSha}, got ${actual}`);
237
+ }
238
+ }
210
239
  await rename(tmp, bin);
211
240
  if (process.platform !== "win32") await chmod(bin, 0o755);
212
- return { bin, url };
241
+ return { bin, url, sha256: expectedSha };
213
242
  }
214
243
 
215
244
  /** Start the daemon detached (idempotent — no-ops when port 10086 is already bound). */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kimi-webbridge-dsh",
3
3
  "description": "Kimi WebBridge plugin for dsh: drive the user's real browser (their login sessions) through the local kimi-webbridge daemon at 127.0.0.1:10086. Registers a single kimi_webbridge tool covering navigate, click, fill, snapshot, screenshot, evaluate, cdp, network, upload, save_as_pdf, tab and session management.",
4
- "version": "1.3.1",
4
+ "version": "1.4.0",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "keywords": [
@@ -34,9 +34,11 @@
34
34
  "README.md",
35
35
  "cordis.patch.yml"
36
36
  ],
37
+ "peerDependencies": {
38
+ "@deepseek-ai/dsh-tools": ">=0.1.0-rc.7 <0.2.0",
39
+ "@deepseek-ai/dsh-llm": ">=0.1.0-rc.7 <0.2.0"
40
+ },
37
41
  "dependencies": {
38
- "@deepseek-ai/schemastery": "^3.18.1",
39
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
40
- "@deepseek-ai/dsh-llm": "^0.1.1-rc.2"
42
+ "@deepseek-ai/schemastery": "^3.18.1"
41
43
  }
42
44
  }