kimi-webbridge-dsh 1.4.0 → 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.
Files changed (3) hide show
  1. package/README.md +36 -25
  2. package/lib/index.js +16 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,16 +2,26 @@
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
- ## 功能
5
+ ## 安装(一次性,零手工配置)
6
6
 
7
- | 能力 | 说明 |
8
- |---|---|
9
- | 浏览真实页面 | 在用户已登录的浏览器中导航、点击、填表、滚动 |
10
- | 读页面 | `snapshot` 返回 accessibility tree 与 `@e` 元素引用 |
11
- | 截图 / 导出 PDF | 结果写入本地文件,返回路径 |
12
- | JS 求值 / CDP | `evaluate`(页面上下文)、`cdp`(chrome.debugger 直通) |
13
- | 网络 / 上传 | 请求捕获与文件上传 |
14
- | 会话分组 | 一个任务 = 一个 session = 一个标签页组,可一键清理 |
7
+ ```powershell
8
+ dsh plugin --profile web add kimi-webbridge-dsh
9
+ ```
10
+
11
+ 本包声明了 `dsh.bundle.patch`:`dsh plugin add` 会自动把它登记进 profile 的 bundle 层(`dsh.profile.bundles`),**无需手动编辑任何 cordis.patch.yml**。安装后重启一次 dsh web 即生效(bundle 在启动时加载):
12
+
13
+ ```powershell
14
+ dsh web
15
+ ```
16
+
17
+ ## 用法
18
+
19
+ 模型在新会话中可直接调用 `kimi_webbridge` 工具。核心规则:
20
+
21
+ - **一个任务 = 一个 session = 一个标签页组**:任务开始时选一个 session 名,之后每次调用都带上(如 `camping-research`)。
22
+ - **读页面用 snapshot**:返回 accessibility tree 和 `@e` 引用,点击/输入优先用 `@e` 引用而非手写 CSS。
23
+ - **截图返回文件路径**:用 read 工具打开查看。
24
+ - **守护进程不可达**:工具会自动启动;二进制缺失时自动从官方 CDN 下载安装。
15
25
 
16
26
  ## 依赖
17
27
 
@@ -32,26 +42,27 @@ Kimi WebBridge 的 dsh 插件:通过本机 kimi-webbridge 守护进程(`127.
32
42
 
33
43
  不支持的平台组合会明确报错并提示手动安装。
34
44
 
35
- ## 安装(一次性,零手工配置)
45
+ ### 守护进程二进制位置
36
46
 
37
- ```powershell
38
- dsh plugin --profile web add kimi-webbridge-dsh
39
- ```
40
-
41
- 本包声明了 `dsh.bundle.patch`:`dsh plugin add` 会自动把它登记进 profile 的 bundle 层(`dsh.profile.bundles`),**无需手动编辑任何 cordis.patch.yml**。安装后重启一次 dsh web 即生效(bundle 在启动时加载):
47
+ 下载到用户目录(与官方安装器路径一致,无需管理员权限;按用户隔离):
42
48
 
43
- ```powershell
44
- dsh web
45
- ```
49
+ | 平台 | 最终路径 |
50
+ |---|---|
51
+ | Windows | `%USERPROFILE%\.kimi-webbridge\bin\kimi-webbridge.exe` |
52
+ | macOS / Linux | `~/.kimi-webbridge/bin/kimi-webbridge`(自动 `chmod 755`) |
46
53
 
47
- ## 用法
54
+ 下载流程:先落盘为临时文件(`kimi-webbridge(.exe).tmp-{pid}-{时间戳}`)→ SHA-256 与官方清单核对 → 匹配才重命名为最终路径;不匹配则删除临时文件并中止,任何未验证的二进制都不会留在磁盘。该路径与官方安装器 / `kimi-webbridge upgrade` 命令完全一致,插件、官方工具共用同一份守护进程。
48
55
 
49
- 模型在新会话中可直接调用 `kimi_webbridge` 工具。核心规则:
56
+ ## 功能
50
57
 
51
- - **一个任务 = 一个 session = 一个标签页组**:任务开始时选一个 session 名,之后每次调用都带上(如 `camping-research`)。
52
- - **读页面用 snapshot**:返回 accessibility tree 和 `@e` 引用,点击/输入优先用 `@e` 引用而非手写 CSS。
53
- - **截图返回文件路径**:用 read 工具打开查看。
54
- - **守护进程不可达**:工具会自动启动;二进制缺失时自动从官方 CDN 下载安装。
58
+ | 能力 | 说明 |
59
+ |---|---|
60
+ | 浏览真实页面 | 在用户已登录的浏览器中导航、点击、填表、滚动 |
61
+ | 读页面 | `snapshot` 返回 accessibility tree 与 `@e` 元素引用 |
62
+ | 截图 / 导出 PDF | 结果写入本地文件,返回路径 |
63
+ | JS 求值 / CDP | `evaluate`(页面上下文)、`cdp`(chrome.debugger 直通) |
64
+ | 网络 / 上传 | 请求捕获与文件上传 |
65
+ | 会话分组 | 一个任务 = 一个 session = 一个标签页组,可一键清理 |
55
66
 
56
67
  ## 配置(可选)
57
68
 
@@ -69,7 +80,7 @@ dsh web
69
80
  | `baseUrl` | `http://127.0.0.1:10086` | 守护进程地址 |
70
81
  | `requestTimeoutMs` | `120000` | 单次请求超时(毫秒) |
71
82
  | `autoStartDaemon` | `true` | 守护进程未运行时自动启动 |
72
- | `autoInstallDaemon` | `true` | 二进制缺失时自动从官方 CDN 下载安装(关闭后需手动运行 `irm https://cdn.kimi.com/webbridge/install.ps1 | iex`) |
83
+ | `autoInstallDaemon` | `true` | 二进制缺失时自动从官方 CDN 下载安装(关闭后需手动[从官方安装](https://www.kimi.ai/products/kimi-webbridge)) |
73
84
  | `daemonVersion` | `latest` | 自动安装时的版本(可固定如 `0.3.0`) |
74
85
 
75
86
  ## 移除
package/lib/index.js CHANGED
@@ -91,6 +91,19 @@ function releasePlatform() {
91
91
  return null;
92
92
  }
93
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
+
94
107
  /**
95
108
  * One HTTP JSON round-trip with a timeout and caller-abort support.
96
109
  * @param url - absolute URL.
@@ -355,13 +368,13 @@ function apply(ctx, config = {}) {
355
368
  const notes = [];
356
369
  if (!existsSync(daemonBinPath())) {
357
370
  if (!autoInstallDaemon) {
358
- throw new Error(`kimi-webbridge: daemon binary not found at ${daemonBinPath()} and autoInstallDaemon is disabled. Install it with: irm https://cdn.kimi.com/webbridge/install.ps1 | iex`);
371
+ throw new Error(`kimi-webbridge: daemon binary not found at ${daemonBinPath()} and autoInstallDaemon is disabled. Install it manually: ${manualInstallHint()}`);
359
372
  }
360
373
  try {
361
374
  const { url } = await installDaemonBinary({ version: daemonVersion, timeoutMs: requestTimeoutMs });
362
375
  notes.push(`installed daemon from ${url}`);
363
376
  } catch (installError) {
364
- throw new Error(`kimi-webbridge: daemon binary missing and auto-install failed: ${installError?.message ?? installError}. Install it manually: irm https://cdn.kimi.com/webbridge/install.ps1 | iex`);
377
+ throw new Error(`kimi-webbridge: daemon binary missing and auto-install failed: ${installError?.message ?? installError}. Install it manually: ${manualInstallHint()}`);
365
378
  }
366
379
  }
367
380
  if (autoStartDaemon) {
@@ -370,7 +383,7 @@ function apply(ctx, config = {}) {
370
383
  result = await attempt();
371
384
  } catch (retryError) {
372
385
  const hint = notes.length > 0 ? " " + notes.join("; ") + "." : "";
373
- throw new Error(`kimi-webbridge: daemon at ${baseUrl} still unreachable after starting it.${hint} Check ~/.kimi-webbridge/logs/daemon.log or reinstall: irm https://cdn.kimi.com/webbridge/install.ps1 | iex`);
386
+ throw new Error(`kimi-webbridge: daemon at ${baseUrl} still unreachable after starting it.${hint} Check ~/.kimi-webbridge/logs/daemon.log, or reinstall: ${manualInstallHint()}`);
374
387
  }
375
388
  } else {
376
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.0",
4
+ "version": "1.4.1",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "keywords": [