kimi-webbridge-dsh 1.3.2 → 1.4.1
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 +42 -17
- package/lib/index.js +49 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,22 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Kimi WebBridge 的 dsh 插件:通过本机 kimi-webbridge 守护进程(`127.0.0.1:10086`)驱动用户的真实浏览器(保留登录态与 Cookie)。注册一个模型工具 `kimi_webbridge`,覆盖导航、点击、输入、读取页面(accessibility tree + @e 引用)、截图、JS 求值、CDP、网络、上传、PDF 导出、标签页与会话管理。
|
|
4
4
|
|
|
5
|
-
## 功能
|
|
6
|
-
|
|
7
|
-
| 能力 | 说明 |
|
|
8
|
-
|---|---|
|
|
9
|
-
| 浏览真实页面 | 在用户已登录的浏览器中导航、点击、填表、滚动 |
|
|
10
|
-
| 读页面 | `snapshot` 返回 accessibility tree 与 `@e` 元素引用 |
|
|
11
|
-
| 截图 / 导出 PDF | 结果写入本地文件,返回路径 |
|
|
12
|
-
| JS 求值 / CDP | `evaluate`(页面上下文)、`cdp`(chrome.debugger 直通) |
|
|
13
|
-
| 网络 / 上传 | 请求捕获与文件上传 |
|
|
14
|
-
| 会话分组 | 一个任务 = 一个 session = 一个标签页组,可一键清理 |
|
|
15
|
-
|
|
16
|
-
## 依赖
|
|
17
|
-
|
|
18
|
-
- **浏览器扩展**:需安装并连接 Kimi WebBridge 浏览器扩展 —— 从 [Chrome Web Store](https://chromewebstore.google.com/detail/kimi-webbridge/fldmhceldgbpfpkbgopacenieobmligc) 安装(`kimi-webbridge status` 显示 `extension_connected: true`;扩展版本应与守护进程一致)。
|
|
19
|
-
- **守护进程**:无需预装。插件在守护进程不可达时会自动启动它;二进制缺失时会自动从官方 CDN(cdn.kimi.com,与官方安装器同源)下载安装——全程无需手动运行任何安装命令。
|
|
20
|
-
|
|
21
5
|
## 安装(一次性,零手工配置)
|
|
22
6
|
|
|
23
7
|
```powershell
|
|
@@ -39,6 +23,47 @@ dsh web
|
|
|
39
23
|
- **截图返回文件路径**:用 read 工具打开查看。
|
|
40
24
|
- **守护进程不可达**:工具会自动启动;二进制缺失时自动从官方 CDN 下载安装。
|
|
41
25
|
|
|
26
|
+
## 依赖
|
|
27
|
+
|
|
28
|
+
- **浏览器扩展**:需安装并连接 Kimi WebBridge 浏览器扩展 —— 从 [Chrome Web Store](https://chromewebstore.google.com/detail/kimi-webbridge/fldmhceldgbpfpkbgopacenieobmligc) 安装(`kimi-webbridge status` 显示 `extension_connected: true`;扩展版本应与守护进程一致)。
|
|
29
|
+
- **守护进程**:无需预装。插件在守护进程不可达时会自动启动它;二进制缺失时会自动从官方 CDN(cdn.kimi.com,与官方安装器同源)下载安装——全程无需手动运行任何安装命令。
|
|
30
|
+
|
|
31
|
+
### 跨平台支持
|
|
32
|
+
|
|
33
|
+
插件根据运行时硬件自动选择并下载对应的守护进程二进制(含 SHA-256 校验,与官方清单核对后才安装):
|
|
34
|
+
|
|
35
|
+
| 平台 | 二进制 | 存档哈希(v1.11.6) |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| Windows x64 | `windows-amd64.exe` | `e085991e…90520` |
|
|
38
|
+
| macOS arm64 | `darwin-arm64` | `46fe401e…c9930` |
|
|
39
|
+
| macOS x64 | `darwin-amd64` | `edd1b126…e1ec54` |
|
|
40
|
+
| Linux arm64 | `linux-arm64` | `b1b139bf…b7923d` |
|
|
41
|
+
| Linux x64 | `linux-amd64` | `5c6eaf79…0150d` |
|
|
42
|
+
|
|
43
|
+
不支持的平台组合会明确报错并提示手动安装。
|
|
44
|
+
|
|
45
|
+
### 守护进程二进制位置
|
|
46
|
+
|
|
47
|
+
下载到用户目录(与官方安装器路径一致,无需管理员权限;按用户隔离):
|
|
48
|
+
|
|
49
|
+
| 平台 | 最终路径 |
|
|
50
|
+
|---|---|
|
|
51
|
+
| Windows | `%USERPROFILE%\.kimi-webbridge\bin\kimi-webbridge.exe` |
|
|
52
|
+
| macOS / Linux | `~/.kimi-webbridge/bin/kimi-webbridge`(自动 `chmod 755`) |
|
|
53
|
+
|
|
54
|
+
下载流程:先落盘为临时文件(`kimi-webbridge(.exe).tmp-{pid}-{时间戳}`)→ SHA-256 与官方清单核对 → 匹配才重命名为最终路径;不匹配则删除临时文件并中止,任何未验证的二进制都不会留在磁盘。该路径与官方安装器 / `kimi-webbridge upgrade` 命令完全一致,插件、官方工具共用同一份守护进程。
|
|
55
|
+
|
|
56
|
+
## 功能
|
|
57
|
+
|
|
58
|
+
| 能力 | 说明 |
|
|
59
|
+
|---|---|
|
|
60
|
+
| 浏览真实页面 | 在用户已登录的浏览器中导航、点击、填表、滚动 |
|
|
61
|
+
| 读页面 | `snapshot` 返回 accessibility tree 与 `@e` 元素引用 |
|
|
62
|
+
| 截图 / 导出 PDF | 结果写入本地文件,返回路径 |
|
|
63
|
+
| JS 求值 / CDP | `evaluate`(页面上下文)、`cdp`(chrome.debugger 直通) |
|
|
64
|
+
| 网络 / 上传 | 请求捕获与文件上传 |
|
|
65
|
+
| 会话分组 | 一个任务 = 一个 session = 一个标签页组,可一键清理 |
|
|
66
|
+
|
|
42
67
|
## 配置(可选)
|
|
43
68
|
|
|
44
69
|
在 profile 的用户补丁层(`~/.dsh/profiles/web/cordis.patch.yml`)按 id 覆盖配置(替换整份 config,未给出的键取默认值):
|
|
@@ -55,7 +80,7 @@ dsh web
|
|
|
55
80
|
| `baseUrl` | `http://127.0.0.1:10086` | 守护进程地址 |
|
|
56
81
|
| `requestTimeoutMs` | `120000` | 单次请求超时(毫秒) |
|
|
57
82
|
| `autoStartDaemon` | `true` | 守护进程未运行时自动启动 |
|
|
58
|
-
| `autoInstallDaemon` | `true` | 二进制缺失时自动从官方 CDN
|
|
83
|
+
| `autoInstallDaemon` | `true` | 二进制缺失时自动从官方 CDN 下载安装(关闭后需手动[从官方安装](https://www.kimi.ai/products/kimi-webbridge)) |
|
|
59
84
|
| `daemonVersion` | `latest` | 自动安装时的版本(可固定如 `0.3.0`) |
|
|
60
85
|
|
|
61
86
|
## 移除
|
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";
|
|
@@ -90,6 +91,19 @@ function releasePlatform() {
|
|
|
90
91
|
return null;
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Platform-aware manual-install hint shown when auto-install is disabled or fails.
|
|
96
|
+
* Windows users get the PowerShell one-liner; macOS/Linux users get the bash one-liner.
|
|
97
|
+
* @returns a short human-readable install instruction.
|
|
98
|
+
*/
|
|
99
|
+
function manualInstallHint() {
|
|
100
|
+
const page = "https://www.kimi.ai/products/kimi-webbridge";
|
|
101
|
+
if (process.platform === "win32") {
|
|
102
|
+
return `run \"irm https://cdn.kimi.com/webbridge/install.ps1 | iex\" in PowerShell (or install from ${page})`;
|
|
103
|
+
}
|
|
104
|
+
return `run \"curl -fsSL https://cdn.kimi.com/webbridge/install.sh | bash\" (or install from ${page})`;
|
|
105
|
+
}
|
|
106
|
+
|
|
93
107
|
/**
|
|
94
108
|
* One HTTP JSON round-trip with a timeout and caller-abort support.
|
|
95
109
|
* @param url - absolute URL.
|
|
@@ -194,22 +208,50 @@ function downloadFile(url, dest, { timeoutMs, maxRedirects = 3 } = {}) {
|
|
|
194
208
|
|
|
195
209
|
/**
|
|
196
210
|
* Download the daemon binary from the official CDN into ~/.kimi-webbridge/bin.
|
|
211
|
+
*
|
|
197
212
|
* The URL layout mirrors the official installer: {CDN}/{version}/releases/kimi-webbridge-{platform}.
|
|
198
|
-
*
|
|
213
|
+
* The platform is derived from the runtime hardware (see releasePlatform), so the
|
|
214
|
+
* correct binary for Windows / macOS / Linux is fetched automatically.
|
|
215
|
+
*
|
|
216
|
+
* When the release manifest (version.json) for the same version is available, the
|
|
217
|
+
* downloaded binary is verified against its published SHA-256 before being installed;
|
|
218
|
+
* a mismatch aborts the install and removes the file, so an unexpected binary can
|
|
219
|
+
* never land on disk.
|
|
220
|
+
*
|
|
221
|
+
* @returns { bin, url, sha256 } on success (sha256 is the manifest digest, or null when the manifest is unavailable).
|
|
199
222
|
*/
|
|
200
223
|
async function installDaemonBinary({ version, timeoutMs }) {
|
|
201
224
|
const platform = releasePlatform();
|
|
202
225
|
if (platform === null) {
|
|
203
226
|
throw new Error(`unsupported platform ${process.platform}-${process.arch} — install the daemon manually (see https://www.kimi.com/zh-cn/features/webbridge)`);
|
|
204
227
|
}
|
|
228
|
+
const manifestKey = platform.endsWith(".exe") ? platform.slice(0, -4) : platform;
|
|
205
229
|
const bin = daemonBinPath();
|
|
206
230
|
await mkdir(dirname(bin), { recursive: true });
|
|
207
|
-
const
|
|
231
|
+
const base = `${CDN_BASE}/${encodeURIComponent(version)}`;
|
|
232
|
+
const url = `${base}/releases/kimi-webbridge-${platform}`;
|
|
233
|
+
// Best-effort: fetch the release manifest for the expected SHA-256.
|
|
234
|
+
let expectedSha = null;
|
|
235
|
+
try {
|
|
236
|
+
const manifest = await httpJson(`${base}/version.json`, { method: "GET", timeoutMs });
|
|
237
|
+
if (manifest.status >= 200 && manifest.status < 300 && manifest.body !== null && typeof manifest.body === "object") {
|
|
238
|
+
expectedSha = manifest.body?.binaries?.[manifestKey]?.sha256 ?? null;
|
|
239
|
+
}
|
|
240
|
+
} catch {
|
|
241
|
+
// Manifest unavailable (e.g. old pinned version) — install without checksum.
|
|
242
|
+
}
|
|
208
243
|
const tmp = `${bin}.tmp-${process.pid}-${Date.now()}`;
|
|
209
244
|
await downloadFile(url, tmp, { timeoutMs });
|
|
245
|
+
if (expectedSha !== null) {
|
|
246
|
+
const actual = createHash("sha256").update(await readFile(tmp)).digest("hex");
|
|
247
|
+
if (actual !== expectedSha) {
|
|
248
|
+
await rm(tmp, { force: true });
|
|
249
|
+
throw new Error(`downloaded binary SHA-256 mismatch for ${platform}: expected ${expectedSha}, got ${actual}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
210
252
|
await rename(tmp, bin);
|
|
211
253
|
if (process.platform !== "win32") await chmod(bin, 0o755);
|
|
212
|
-
return { bin, url };
|
|
254
|
+
return { bin, url, sha256: expectedSha };
|
|
213
255
|
}
|
|
214
256
|
|
|
215
257
|
/** Start the daemon detached (idempotent — no-ops when port 10086 is already bound). */
|
|
@@ -326,13 +368,13 @@ function apply(ctx, config = {}) {
|
|
|
326
368
|
const notes = [];
|
|
327
369
|
if (!existsSync(daemonBinPath())) {
|
|
328
370
|
if (!autoInstallDaemon) {
|
|
329
|
-
throw new Error(`kimi-webbridge: daemon binary not found at ${daemonBinPath()} and autoInstallDaemon is disabled. Install it
|
|
371
|
+
throw new Error(`kimi-webbridge: daemon binary not found at ${daemonBinPath()} and autoInstallDaemon is disabled. Install it manually: ${manualInstallHint()}`);
|
|
330
372
|
}
|
|
331
373
|
try {
|
|
332
374
|
const { url } = await installDaemonBinary({ version: daemonVersion, timeoutMs: requestTimeoutMs });
|
|
333
375
|
notes.push(`installed daemon from ${url}`);
|
|
334
376
|
} catch (installError) {
|
|
335
|
-
throw new Error(`kimi-webbridge: daemon binary missing and auto-install failed: ${installError?.message ?? installError}. Install it manually:
|
|
377
|
+
throw new Error(`kimi-webbridge: daemon binary missing and auto-install failed: ${installError?.message ?? installError}. Install it manually: ${manualInstallHint()}`);
|
|
336
378
|
}
|
|
337
379
|
}
|
|
338
380
|
if (autoStartDaemon) {
|
|
@@ -341,7 +383,7 @@ function apply(ctx, config = {}) {
|
|
|
341
383
|
result = await attempt();
|
|
342
384
|
} catch (retryError) {
|
|
343
385
|
const hint = notes.length > 0 ? " " + notes.join("; ") + "." : "";
|
|
344
|
-
throw new Error(`kimi-webbridge: daemon at ${baseUrl} still unreachable after starting it.${hint} Check ~/.kimi-webbridge/logs/daemon.log or reinstall:
|
|
386
|
+
throw new Error(`kimi-webbridge: daemon at ${baseUrl} still unreachable after starting it.${hint} Check ~/.kimi-webbridge/logs/daemon.log, or reinstall: ${manualInstallHint()}`);
|
|
345
387
|
}
|
|
346
388
|
} else {
|
|
347
389
|
throw new Error(`kimi-webbridge: daemon at ${baseUrl} is not running and autoStartDaemon is disabled. Start it with: ${daemonBinPath()} start`);
|
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.
|
|
4
|
+
"version": "1.4.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|