dsh-computer-use-ng 0.0.0-stage → 0.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.
package/README.md CHANGED
@@ -1,3 +1,704 @@
1
- # Temporary Holding Version
1
+ # dsh-computer-use-ng
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **让 DeepSeek Harness 像人一样操作桌面。** 观察屏幕、定位界面元素、移动独立虚拟光标、点击、输入、滚动和拖拽。
4
+ >
5
+ > **Give DeepSeek Harness a safe, observable Computer Use layer.** Observe desktop applications, locate UI elements, and act through an isolated virtual cursor.
6
+
7
+ [![CI](https://github.com/AndroidSix/dsh-computer-use-ng/actions/workflows/ci.yml/badge.svg)](https://github.com/AndroidSix/dsh-computer-use-ng/actions/workflows/ci.yml)
8
+ [![npm version](https://img.shields.io/npm/v/dsh-computer-use-ng)](https://www.npmjs.com/package/dsh-computer-use-ng)
9
+ [![npm downloads](https://img.shields.io/npm/dw/dsh-computer-use-ng)](https://www.npmjs.com/package/dsh-computer-use-ng)
10
+ [![GitHub stars](https://img.shields.io/github/stars/AndroidSix/dsh-computer-use-ng)](https://github.com/AndroidSix/dsh-computer-use-ng)
11
+ [![License](https://img.shields.io/github/license/AndroidSix/dsh-computer-use-ng)](LICENSE)
12
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D22.18.0-339933)](https://nodejs.org/)
13
+ [![Platforms](https://img.shields.io/badge/platform-macOS%20%7C%20Windows%20%7C%20Linux-lightgrey)](#platform-support--平台支持)
14
+
15
+ ![dsh-computer-use-ng verified desktop demo](assets/demo-verified.png)
16
+
17
+ > **真实演示 · Real demo:** a local, non-sensitive page was observed, filled, clicked, and verified through the Computer Use action loop.
18
+
19
+ > **社区维护分支 · Community-maintained continuation.** 本项目基于 Wei Jerry 的 [dsh-computer-use](https://github.com/988hj7tczd-oss/dsh-computer-use)(MIT)独立维护,自 0.4.0 起重点跟进 DSH 0.2+。与原作者无隶属关系;原作者与贡献者的署名保留在 [NOTICE](NOTICE) 中。
20
+
21
+ **中文文档 · English documentation**
22
+
23
+ - [中文文档](#中文文档)
24
+ - [English Documentation](#english-documentation)
25
+
26
+ ## 生态入口 · Ecosystem
27
+
28
+ | 入口 | 作用 | Link |
29
+ |---|---|---|
30
+ | **harness-desktop** | 开箱即用的 DeepSeek Harness 桌面客户端 · Ready-to-use desktop client | [下载 / Download](https://github.com/988hj7tczd-oss/harness-desktop/releases) |
31
+ | **AI House** | 发现 AI 工具、模型和 Agent · Discover AI tools and agents | [工具中心 / Tools](https://www.aibunkhouse.com/tools) |
32
+ | **npm** | 安装和查看包信息 · Install and inspect the package | [dsh-computer-use-ng](https://www.npmjs.com/package/dsh-computer-use-ng) |
33
+ | **awesome-dsh-plugin** | 发现更多 DeepSeek Harness 插件 · Discover more plugins | [Plugin list](https://github.com/988hj7tczd-oss/awesome-dsh-plugin) |
34
+ | **上游项目** | 原始项目与历史版本 · Original project and historical releases | [dsh-computer-use](https://github.com/988hj7tczd-oss/dsh-computer-use) |
35
+
36
+ ### 维护说明 · Maintenance
37
+
38
+ - 本仓库是独立维护分支,版本线从 `0.4.0` 开始;首个版本重点修复 DSH 0.2.1-rc.2 兼容性。
39
+ - 工具名(`screen_observe`、`computer_click` 等)保持不变,已有提示词和工作流无需改写。
40
+ - 本仓库从新的 Git 历史开始,不包含上游的提交历史或内部项目文档;MIT 署名见 [NOTICE](NOTICE)。
41
+ - 问题反馈、功能请求和 PR 请提到本仓库,而不是上游仓库。
42
+ - npm 包名 `dsh-computer-use-ng`,发布账号 `androidsup`;也可以用固定版本 `dsh-computer-use-ng@0.4.0`。
43
+
44
+ ---
45
+
46
+ # 中文文档
47
+
48
+ ## 这是什么?
49
+
50
+ `dsh-computer-use-ng` 是 DeepSeek Harness 的跨平台 Computer Use 插件,为 AI Agent 增加一套可观察、可约束、可验证的桌面操作能力。
51
+
52
+ 它不是传统的鼠标宏:Agent 必须先观察目标窗口,再基于新鲜快照执行动作。点击、双击和右键操作通过 cua-driver 的独立虚拟光标完成,用户可以看到操作过程,而不是让程序悄悄发送一串不可见事件。
53
+
54
+ 适合用于:
55
+
56
+ - 让 DeepSeek Harness 操作原生 macOS、Windows 和 Linux 桌面应用;
57
+ - 操作 Electron、Canvas 或游戏等 Accessibility/AX 信息不完整的界面;
58
+ - 构建“打开应用 → 观察 → 点击 → 输入 → 再观察验证”的 Agent 闭环;
59
+ - 为桌面自动化、内部工具和个人工作流增加可审计的 Computer Use 执行层;
60
+ - 研究 Computer Use、视觉定位和安全护栏。
61
+
62
+ > 本项目是开源社区插件,不是 DeepSeek 官方产品,也不代表 DeepSeek 的官方立场。
63
+
64
+ ## 为什么需要它?
65
+
66
+ 普通文本 Agent 可以生成答案,但无法直接完成很多桌面任务。`dsh-computer-use-ng` 把桌面交互拆成三个阶段:
67
+
68
+ ```text
69
+ 观察 Observation → 决策 Decision → 受约束执行 Guarded Action
70
+ ```
71
+
72
+ ```mermaid
73
+ flowchart LR
74
+ A[DeepSeek Harness Agent] --> B[dsh-computer-use-ng]
75
+ B --> C[安全护栏 Guard]
76
+ C --> D[AX / UIA 界面树]
77
+ C --> E[虚拟光标与键盘]
78
+ D --> F[cua-driver]
79
+ E --> F
80
+ F --> G[桌面应用 Desktop Apps]
81
+ ```
82
+
83
+ 核心原则:
84
+
85
+ 1. **先观察,再操作**:没有新鲜观察快照时,动作会被拒绝;
86
+ 2. **模型所见即所点**:元素编号和坐标来自同一窗口截图空间;
87
+ 3. **语义优先**:优先使用 `element` 编号,坐标模式保留视觉操作自由度;
88
+ 4. **失败关闭**:目标不明确、快照过期、应用不在白名单时不继续执行。
89
+
90
+ ## 能力一览
91
+
92
+ | 能力 | 说明 |
93
+ |---|---|
94
+ | 屏幕观察 | 读取目标窗口元数据、Accessibility/AX/UIA 元素和坐标 |
95
+ | 三种观察模式 | `ax` 零视觉 Token、`native` 主模型直读图片、`vision` 视觉观察者 |
96
+ | 独立虚拟光标 | 点击、双击、右键会显示虚拟光标移动和操作过程,不抢用户真实鼠标 |
97
+ | 文本与快捷键 | 输入文本、发送 `return`、`cmd+c`、`ctrl+shift+p` 等按键 |
98
+ | 滚动与拖拽 | 支持上下左右滚动和窗口本地截图坐标拖拽 |
99
+ | 应用管理 | 列出运行中的应用,后台启动应用,按需前置窗口 |
100
+ | 安全护栏 | 快照 TTL、应用白名单、危险操作审批、密码框保护 |
101
+ | 跨平台 | macOS 已验证;Windows/Linux 需按真实环境完成平台验收 |
102
+
103
+ ## 12 个模型工具
104
+
105
+ | 工具 | 作用 | 主要参数 |
106
+ |---|---|---|
107
+ | `screen_observe` | 获取窗口、AX/UIA 元素、坐标或截图 | `window`, `mode`, `query`, `maxElements` |
108
+ | `screen_zoom` | 截取并放大窗口局部区域 | `window_id`, `pid`, `x1`, `y1`, `x2`, `y2` |
109
+ | `computer_click` | 点击元素或截图坐标 | `element` 或 `x,y`,可选 `count` |
110
+ | `computer_double_click` | 双击元素或坐标 | `element` 或 `x,y` |
111
+ | `computer_right_click` | 右键点击元素或坐标 | `element` 或 `x,y` |
112
+ | `computer_type` | 向焦点或指定元素输入文本 | `text`, 可选 `element` |
113
+ | `computer_key` | 发送按键或快捷键 | `key`,例如 `return`、`cmd+c` |
114
+ | `computer_scroll` | 在目标窗口滚动 | `direction`, `amount`, 可选 `element` |
115
+ | `computer_drag` | 拖拽窗口中的区域 | `from_x`, `from_y`, `to_x`, `to_y` |
116
+ | `computer_wait` | 等待界面加载或动画完成 | `ms`,最大 60000 |
117
+ | `app_list` | 列出正在运行的应用 | 无 |
118
+ | `app_launch` | 启动应用 | `name` 或 `bundle_id`,可选 `bring_to_front` |
119
+
120
+ ## 版本兼容
121
+
122
+ - 当前插件版本:**0.4.0**
123
+ - DSH 运行时:`>=0.1.2-rc.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0`(已在 **0.2.1-rc.2** 实测通过)
124
+ - Node.js:`>=22.18.0`
125
+ - `@deepseek-ai/dsh-tools` / `@deepseek-ai/schemastery` 只声明为宿主 `peerDependencies`,不随插件打包,避免同进程出现第二份 DSH 模块
126
+
127
+ > 0.2 的 DSH 版本号是预发布版本(例如 `0.2.1-rc.2`)。普通范围 `<0.2.0` 在 node-semver 下不包含它,因此这里使用显式的 0.2 预发布区间;旧版 0.1.x 运行时仍受支持。
128
+
129
+ ## 快速开始
130
+
131
+ ### 方式一:DSH 插件管理器(推荐)
132
+
133
+ ```bash
134
+ # 如果装过旧版 dsh-computer-use,先卸载,避免同名工具重复注册
135
+ dsh plugin --profile desktop remove dsh-computer-use
136
+
137
+ # 从 npm 安装(推荐)
138
+ dsh plugin --profile desktop add dsh-computer-use-ng
139
+
140
+ # 或固定版本
141
+ dsh plugin --profile desktop add dsh-computer-use-ng@0.4.0
142
+
143
+ # 或直接从 GitHub 固定 tag 安装
144
+ dsh plugin --profile desktop add github:AndroidSix/dsh-computer-use-ng#v0.4.0
145
+ ```
146
+
147
+ 安装完成后重启 DSH,或在插件页确认 `dsh-computer-use-ng` 已启用。
148
+
149
+ ### 方式二:使用 harness-desktop
150
+
151
+ 普通桌面用户建议先下载 [harness-desktop](https://github.com/988hj7tczd-oss/harness-desktop/releases)。它是一个开箱即用的 DeepSeek Harness 桌面客户端,支持 macOS、Windows 和 Linux。
152
+
153
+ ```text
154
+ 1. 下载并启动 harness-desktop
155
+ 2. 完成首启配置
156
+ 3. 安装本插件
157
+ 4. 重启 harness-desktop
158
+ 5. 在对话中让 Agent 操作桌面
159
+ ```
160
+
161
+ ### 方式三:从 GitHub 源码安装
162
+
163
+ ```bash
164
+ git clone https://github.com/AndroidSix/dsh-computer-use-ng.git
165
+ cd dsh-computer-use-ng
166
+
167
+ # 先预演,不写入配置
168
+ ./install.sh --dry-run
169
+
170
+ # 安装到用户级 patch 层
171
+ ./install.sh
172
+
173
+ # 安装后重启 harness-desktop
174
+ ```
175
+
176
+ 安装脚本只做两件事:
177
+
178
+ 1. 将插件链接到 `$DSH_HOME/profiles/desktop/node_modules/dsh-computer-use-ng`(找不到 `desktop` 时回退到 `web`);
179
+ 2. 在 `$DSH_HOME/cordis.patch.yml` 注册插件。
180
+
181
+ 脚本使用用户级 patch 层,不修改项目代码,也不修改其他 profile 的配置。
182
+
183
+ ### Windows / Linux
184
+
185
+ `install.sh` 默认使用 `$HOME/.dsh`。Windows 或 Linux 用户请先指定自己的 DSH home:
186
+
187
+ ```bash
188
+ export DSH_HOME="/path/to/your/dsh-home"
189
+ ./install.sh --dry-run
190
+ ./install.sh
191
+ ```
192
+
193
+ 如果系统不支持符号链接,请使用宿主 DSH 的插件管理方式,或按照 `docs/store-evidence.md` 中的手动安装说明操作。
194
+
195
+ ### 方式四:npm 包
196
+
197
+ ```bash
198
+ npm install -g dsh-computer-use-ng
199
+ ```
200
+
201
+ 安装后仍需要让 DSH profile 加载该 bundle,并确认 `cua-driver` 已经安装且在 `PATH` 中,或设置:
202
+
203
+ ```bash
204
+ export CUA_DRIVER_BIN=/path/to/cua-driver
205
+ ```
206
+
207
+ 在 Windows 官方安装器布局中,插件还会自动探测
208
+ `%USERPROFILE%\\.cua-driver\\packages\\current\\cua-driver.exe`;GUI 宿主的 PATH 不完整时无需手工把目录加入 PATH。
209
+
210
+ 安装完成后重启宿主,再通过 `app_list` 或 `screen_observe` 验证工具是否出现。
211
+
212
+ ## 第一个完整任务
213
+
214
+ 安装并授权后,可以让 Agent 执行下面的任务:
215
+
216
+ ```text
217
+ 请完成以下桌面任务:
218
+
219
+ 1. 使用 app_list 列出正在运行的应用;
220
+ 2. 使用 app_launch 打开一个普通桌面应用;
221
+ 3. 使用 screen_observe 观察目标窗口;
222
+ 4. 找到目标按钮,优先使用 element 编号点击;
223
+ 5. 使用 computer_type 输入一段非敏感测试文本;
224
+ 6. 再次使用 screen_observe 验证文本已经出现;
225
+ 7. 如果界面发生变化,请重新观察,不要使用旧元素编号继续操作;
226
+ 8. 如果动作被安全护栏拒绝,请报告拒绝原因,不要绕过护栏。
227
+ ```
228
+
229
+ ### 推荐的操作循环
230
+
231
+ ```text
232
+ app_list / app_launch
233
+ ↓
234
+ screen_observe
235
+ ↓
236
+ computer_click / computer_type / computer_key
237
+ ↓
238
+ computer_wait(如需等待)
239
+ ↓
240
+ screen_observe 验证结果
241
+ ```
242
+
243
+ 每一次界面明显变化后,都应重新调用 `screen_observe`。元素编号属于某一次观察快照,不应跨页面、弹窗或长时间等待复用。
244
+
245
+ ## 观察模式
246
+
247
+ `screen_observe` 的 `mode` 有三种选择:
248
+
249
+ | 模式 | 原理 | 成本 | 适用场景 |
250
+ |---|---|---|---|
251
+ | `ax`(默认) | 读取 AX/UIA 界面树并返回编号和坐标 | 不消耗视觉 Token | 原生应用、元素树完整的界面 |
252
+ | `native` | 将截图作为图片块交给当前对话模型 | 图片 Token;不额外调用视觉观察者 | Canvas、游戏、Electron 或 AX 树为空的界面 |
253
+ | `vision` | 通过 Harness 的 `ctx.llm` 调用视觉模型,返回结构化元素列表 | 额外一次视觉模型调用 | 当前主模型不支持图片输入时 |
254
+
255
+ ### `native` 模式
256
+
257
+ 当前对话模型必须声明支持 `image` 输入,例如视觉模型。插件通过 Harness attachments 传递图片,不额外发起独立视觉 API 请求。
258
+
259
+ ```text
260
+ screen_observe(mode="native")
261
+ ```
262
+
263
+ ### `vision` 模式
264
+
265
+ 默认观察模型为:
266
+
267
+ ```text
268
+ provider: deepseek-official
269
+ model: deepseek-v4-flash-vision-exp
270
+ ```
271
+
272
+ 老版本 Harness 需要在模型配置中声明:
273
+
274
+ ```yaml
275
+ models:
276
+ - id: deepseek-v4-flash-vision-exp
277
+ input: [text, image]
278
+ ```
279
+
280
+ 当 DeepSeek 视觉观察者不可用时,插件可以尝试 GLM 视觉兜底。GLM 兜底需要 `ZHIPU_API_KEY`,并可能受到免费模型访问量限制。
281
+
282
+ ### 自动降级
283
+
284
+ 当 AX/UIA 树为空时,插件会尝试:
285
+
286
+ ```text
287
+ native(当前路由支持图片时)
288
+ → vision(宿主存在可用视觉模型时)
289
+ → ax(返回可用的界面树信息或明确错误)
290
+ ```
291
+
292
+ ## 坐标语义
293
+
294
+ 从 v0.2.0 起,所有坐标均为:
295
+
296
+ > **窗口本地截图像素(window-local screenshot pixels)**
297
+
298
+ 这意味着:
299
+
300
+ - 坐标原点在目标窗口左上角;
301
+ - `screen_observe` 输出的 `@(x,y)` 与 `computer_click(x=,y=)` 使用同一坐标系;
302
+ - 不需要乘以 2;
303
+ - 不需要加屏幕坐标或窗口偏移;
304
+ - 使用 `screen_zoom` 时,返回图片是局部区域,但点击仍应使用整窗截图坐标。
305
+
306
+ 优先使用:
307
+
308
+ ```text
309
+ computer_click(element=5)
310
+ ```
311
+
312
+ 只有在元素无法通过 AX/UIA 识别,或视觉模式给出坐标时,才使用:
313
+
314
+ ```text
315
+ computer_click(x=640, y=420)
316
+ ```
317
+
318
+ ## 安全模型
319
+
320
+ ### 已内置的安全机制
321
+
322
+ 1. **无快照拒绝**:没有先调用 `screen_observe`,动作不会执行;
323
+ 2. **观察快照 TTL**:快照过期后动作被拒绝,必须重新观察;
324
+ 3. **应用白名单**:配置 `allowedApps` 后,只允许指定应用接受操作;
325
+ 4. **危险操作审批**:元素标签命中删除、支付、购买、转账、退出登录等词时请求用户确认;
326
+ 5. **密码框保护**:检测到 `AXSecureTextField` / `AXPasswordField` 时拒绝自动输入;
327
+ 6. **键盘前台重试审批**:键盘/文本优先后台投递;只有驱动明确拒绝后台投递并建议前台模式、且当前工具/平台支持时,才请求用户对本次前台重试授权;未获 `allowed-once` 不切换焦点、不重试;
328
+ 7. **固定 argv 调用**:通过宿主以非 shell 方式启动 `cua-driver`;
329
+ 8. **权限边界声明**:核心桌面路径不读取业务文件或额外凭据;仅当用户配置视觉 GLM fallback 时,才读取指定 key 来源并向 GLM API 发起请求;没有 npm lifecycle 安装脚本。
330
+
331
+ ### 重要限制
332
+
333
+ 语义安全检测依赖观察到的元素标签,主要对 `element` 编号模式有效:
334
+
335
+ - `x/y` 坐标模式无法提前知道目标语义,主要依赖快照 TTL 和可见操作;
336
+ - `computer_type` 和 `computer_key` 作用于当前焦点时,无法预判最终目标内容;
337
+ - 驱动拒绝后台键盘/文本投递时,前台重试会先请求本次用户批准;授权后可能切换目标窗口焦点;
338
+ - `computer_key` 不会阻止 `cmd+q`、`ctrl+alt+delete` 等系统快捷键;
339
+ - 不要把本插件的操作权限授予不可信 Agent;
340
+ - 密码、API Key 和其他敏感信息必须由用户本人输入。
341
+
342
+ ## 配置
343
+
344
+ 插件配置位于 DSH 的用户级 patch 层:
345
+
346
+ ```yaml
347
+ - id: dsh-computer-use-ng
348
+ config:
349
+ ttlMs: 30000
350
+ maxElements: 500
351
+ allowedApps: []
352
+ cursorTheme: com.dsh.computeruse.rainbow
353
+ nativeImage: auto
354
+ visionProvider: deepseek-official
355
+ visionModel: deepseek-v4-flash-vision-exp
356
+ ```
357
+
358
+ | 配置项 | 默认值 | 说明 |
359
+ |---|---:|---|
360
+ | `ttlMs` | `30000` | 观察快照有效期,单位毫秒;多步任务建议显式设置 30000-60000 |
361
+ | `maxElements` | `500` | 单次观察最多返回的编号元素数量 |
362
+ | `allowedApps` | `[]` | 空数组表示不限制;非空时只允许列表中的应用 |
363
+ | `cursorTheme` | `com.dsh.computeruse.rainbow` | 虚拟光标主题;空字符串使用引擎默认主题 |
364
+ | `nativeImage` | `auto` | `auto` 自动降级;`full` 原图;`compact` 始终使用小图 |
365
+ | `visionProvider` | `deepseek-official` | `vision` 模式使用的 provider |
366
+ | `visionModel` | `deepseek-v4-flash-vision-exp` | `vision` 模式使用的视觉模型 |
367
+
368
+ > 安装脚本或 bundle patch 可能覆盖代码层默认值。请以实际生成的 `$DSH_HOME/cordis.patch.yml` 为准;多步任务建议显式写入 `ttlMs`,不要依赖隐式默认值。
369
+
370
+ ## 平台支持 · Platform Support
371
+
372
+ | 平台 | 状态 | 说明 |
373
+ |---|---|---|
374
+ | macOS | ✅ 已验证 | 可能需要 Accessibility 和 Screen Recording 权限 |
375
+ | Windows | ⛔ BLOCKED | 当前无 Windows 10/11 真机;路径和按键逻辑已测试,真实 GUI 未验收 |
376
+ | Linux | ⛔ 未验证 | 桌面环境、Accessibility 栈和窗口管理器可能影响元素识别 |
377
+
378
+ 测试通过不代表所有应用的界面树都完全一致。AX/UIA 不完整时,请使用 `native` 或 `vision` 模式,并在提交问题时附上操作系统、目标应用和 `screen_observe` 输出。
379
+
380
+ ## 故障排查
381
+
382
+ | 现象 | 常见原因 | 处理方式 |
383
+ |---|---|---|
384
+ | `cua-driver not found` | 引擎不在 PATH 或官方安装器路径不可用 | 安装 cua-driver,确认 `~/.cua-driver/packages/current/cua-driver.exe` 存在,或设置 `CUA_DRIVER_BIN` |
385
+ | 没有可见窗口 | 图形会话或窗口权限不可用 | 确认目标应用正在运行并重新观察 |
386
+ | 快照已过期 | 超过 `ttlMs` | 重新调用 `screen_observe` |
387
+ | 元素编号点击失败 | 界面已经变化 | 重新观察后再使用新编号 |
388
+ | AX/UIA 树为空 | Canvas、游戏、Electron 或特殊窗口 | 使用 `native` 或 `vision` |
389
+ | native 被拒绝 | 当前主模型没有 image 输入能力 | 切换视觉模型或使用 `vision` |
390
+ | vision 模型不可用 | provider/model 未注册 image 输入 | 配置 `visionProvider` / `visionModel` |
391
+ | GLM fallback 不可用 | 没有 `ZHIPU_API_KEY` 或遇到限流 | 配置 Key,或使用 Harness 视觉模型 |
392
+ | 危险操作被拒绝 | 需要用户审批 | 检查审批提示,不要绕过安全护栏 |
393
+ | Windows 管理员窗口无法操作 | 目标窗口权限级别更高 | 使用普通用户窗口 |
394
+
395
+ ## 开发与验证
396
+
397
+ 项目使用隔离 profile 开发,避免污染真实 GUI 配置:
398
+
399
+ ```bash
400
+ npm install
401
+ npm run check
402
+
403
+ # 运行时验证需要已安装 harness-desktop 和 cua-driver
404
+ node verify-runtime.mjs
405
+ ```
406
+
407
+ macOS headless 验证示例:
408
+
409
+ ```bash
410
+ DSH_HOME=$PWD/.dsh-p0 ELECTRON_RUN_AS_NODE=1 \
411
+ /Applications/harness-desktop.app/Contents/MacOS/harness-desktop --expose-internals \
412
+ /Applications/harness-desktop.app/Contents/Resources/app/node_modules/@deepseek-ai/dsh/lib/bin.js \
413
+ --profile test "请调用 screen_observe 观察当前窗口并报告"
414
+ ```
415
+
416
+ 更多证据:
417
+
418
+ - [权限声明](PERMISSIONS.md)
419
+ - [验证报告](VERIFICATION.md)
420
+ - [Windows 测试指南](WINDOWS_TEST.md)
421
+ - [Store 安装证据](docs/store-evidence.md)
422
+ - [运行时验证脚本](verify-runtime.mjs)
423
+
424
+ ## 相关项目
425
+
426
+ - [harness-desktop](https://github.com/988hj7tczd-oss/harness-desktop):开箱即用的 DeepSeek Harness 桌面客户端;
427
+ - [awesome-dsh-plugin](https://github.com/988hj7tczd-oss/awesome-dsh-plugin):DeepSeek Harness 插件精选列表;
428
+ - [AI House 工具中心](https://www.aibunkhouse.com/tools):发现更多 AI 工具、模型和 Agent;
429
+ - [cua-driver](https://github.com/trycua/cua):底层跨平台桌面驱动;
430
+ - [npm package](https://www.npmjs.com/package/dsh-computer-use-ng):安装包和版本信息;
431
+ - [GitHub 仓库](https://github.com/AndroidSix/dsh-computer-use-ng):本维护分支的源码与 issue;
432
+ - [上游项目](https://github.com/988hj7tczd-oss/dsh-computer-use):原始项目与历史版本。
433
+
434
+ ## License
435
+
436
+ [MIT License](LICENSE)
437
+
438
+ ---
439
+
440
+ # English Documentation
441
+
442
+ ## What is dsh-computer-use-ng?
443
+
444
+ `dsh-computer-use-ng` is a cross-platform Computer Use plugin for DeepSeek Harness. It gives an AI agent an observable, guarded, and verifiable desktop action layer.
445
+
446
+ The plugin is designed around an explicit loop:
447
+
448
+ ```text
449
+ Observe → Decide → Execute with Guardrails → Observe and Verify
450
+ ```
451
+
452
+ It can inspect desktop windows, expose actionable AX/UIA elements, use a screenshot-based visual fallback, and operate through an isolated virtual cursor. It is useful for desktop automation, Computer Use research, internal workflows, and agentic applications that need bounded desktop actions.
453
+
454
+ > This is a community plugin, not an official DeepSeek product and not affiliated with DeepSeek.
455
+ >
456
+ > **Maintenance:** this repository is an independently maintained continuation of [dsh-computer-use](https://github.com/988hj7tczd-oss/dsh-computer-use) (MIT). The version line starts at `0.4.0`; issues and PRs belong to this repository. Original authorship is recorded in [NOTICE](NOTICE).
457
+
458
+ ## Highlights
459
+
460
+ - Observe native desktop windows and accessibility trees;
461
+ - Use `ax`, `native`, or `vision` observation modes;
462
+ - Click, double-click, right-click, type, press keys, scroll, and drag;
463
+ - Launch applications and list running applications;
464
+ - Bind actions to fresh observation snapshots;
465
+ - Restrict actions to an application allowlist;
466
+ - Request approval for risky semantic targets;
467
+ - Refuse automated typing into password fields;
468
+ - Fall back to screenshots when AX/UIA data is incomplete;
469
+ - macOS has been verified; Windows has logic/path coverage but real GUI validation is blocked; Linux has not been verified.
470
+
471
+ ## Compatibility
472
+
473
+ - Plugin version: **0.4.0**
474
+ - DSH runtime: `>=0.1.2-rc.1 <0.2.0-0 || >=0.2.0-rc.1 <0.3.0-0` (verified on **0.2.1-rc.2**)
475
+ - Node.js: `>=22.18.0`
476
+ - `@deepseek-ai/dsh-tools` and `@deepseek-ai/schemastery` are host `peerDependencies` only, so the profile never materializes a second copy of a DSH module in the host process
477
+
478
+ > DSH 0.2 versions are prereleases (for example `0.2.1-rc.2`). Under node-semver a plain `<0.2.0` range excludes them, so the manifest carries explicit 0.2 prerelease branches. The 0.1.x line remains supported.
479
+
480
+ ## Quick Start
481
+
482
+ ### Install with the DSH plugin manager (recommended)
483
+
484
+ ```bash
485
+ # Remove the original plugin first if it is installed, to avoid duplicate tool names.
486
+ dsh plugin --profile desktop remove dsh-computer-use
487
+
488
+ # Install from npm
489
+ dsh plugin --profile desktop add dsh-computer-use-ng
490
+
491
+ # Or pin a version
492
+ dsh plugin --profile desktop add dsh-computer-use-ng@0.4.0
493
+
494
+ # Or install from the GitHub tag
495
+ dsh plugin --profile desktop add github:AndroidSix/dsh-computer-use-ng#v0.4.0
496
+ ```
497
+
498
+ Restart DSH, or confirm in the Plugins page that `dsh-computer-use-ng` is enabled.
499
+
500
+ ### Recommended desktop experience
501
+
502
+ Download [harness-desktop](https://github.com/988hj7tczd-oss/harness-desktop/releases), the ready-to-use DeepSeek Harness desktop client. After the host is installed, install this plugin and restart the host.
503
+
504
+ ### Install from source
505
+
506
+ ```bash
507
+ git clone https://github.com/AndroidSix/dsh-computer-use-ng.git
508
+ cd dsh-computer-use-ng
509
+
510
+ ./install.sh --dry-run
511
+ ./install.sh
512
+ ```
513
+
514
+ The installer creates a user-level plugin link and registers the bundle in the DSH home patch layer. It does not modify project source files or other profiles.
515
+
516
+ On Windows or Linux, set `DSH_HOME` to the actual DSH home directory before running the script:
517
+
518
+ ```bash
519
+ export DSH_HOME="/path/to/your/dsh-home"
520
+ ./install.sh
521
+ ```
522
+
523
+ ### Install the npm package
524
+
525
+ ```bash
526
+ npm install -g dsh-computer-use-ng
527
+ ```
528
+
529
+ Make sure the host loads the bundle and that `cua-driver` is available in `PATH`, or set `CUA_DRIVER_BIN` to its absolute path.
530
+
531
+ On Windows, the official installer layout is also detected automatically at
532
+ `%USERPROFILE%\\.cua-driver\\packages\\current\\cua-driver.exe`, which covers GUI hosts whose PATH does not include the driver.
533
+
534
+ ## Tools
535
+
536
+ | Tool | Purpose | Main parameters |
537
+ |---|---|---|
538
+ | `screen_observe` | Observe a window, AX/UIA elements, coordinates, or a screenshot | `window`, `mode`, `query`, `maxElements` |
539
+ | `screen_zoom` | Capture a smaller region for visual inspection | `window_id`, `pid`, `x1`, `y1`, `x2`, `y2` |
540
+ | `computer_click` | Click an element or screenshot coordinate | `element` or `x,y`; optional `count` |
541
+ | `computer_double_click` | Double-click an element or coordinate | `element` or `x,y` |
542
+ | `computer_right_click` | Right-click an element or coordinate | `element` or `x,y` |
543
+ | `computer_type` | Type into the focused or selected field | `text`, optional `element` |
544
+ | `computer_key` | Send a key or shortcut | `key`, e.g. `return`, `cmd+c` |
545
+ | `computer_scroll` | Scroll a target window | `direction`, `amount`, optional `element` |
546
+ | `computer_drag` | Drag between screenshot coordinates | `from_x`, `from_y`, `to_x`, `to_y` |
547
+ | `computer_wait` | Wait for a page load or animation | `ms`, max 60000 |
548
+ | `app_list` | List running applications | none |
549
+ | `app_launch` | Launch an application | `name` or `bundle_id`; optional `bring_to_front` |
550
+
551
+ ## The standard action loop
552
+
553
+ ```text
554
+ app_list / app_launch
555
+ ↓
556
+ screen_observe
557
+ ↓
558
+ computer_click / computer_type / computer_key
559
+ ↓
560
+ computer_wait
561
+ ↓
562
+ screen_observe to verify the result
563
+ ```
564
+
565
+ A snapshot is observation-local. If the UI changes, observe again before using an element index or coordinate from the previous state.
566
+
567
+ ## Observation modes
568
+
569
+ | Mode | How it works | Best for |
570
+ |---|---|---|
571
+ | `ax` | Returns a compact AX/UIA tree with indexed elements and coordinates | Native applications with usable accessibility data |
572
+ | `native` | Returns the screenshot as an image block for the current multimodal model | Canvas, games, Electron, or windows with incomplete AX/UIA data |
573
+ | `vision` | Uses a Harness `ctx.llm` vision model to describe the screenshot | Text-only main models that need a separate observer |
574
+
575
+ `native` requires the current route to declare image input support. `vision` uses the configured `visionProvider` and `visionModel`; the default model is `deepseek-v4-flash-vision-exp`. The optional GLM fallback requires `ZHIPU_API_KEY` and may be rate-limited.
576
+
577
+ When the accessibility tree is empty, the fallback order is:
578
+
579
+ ```text
580
+ native → vision → ax
581
+ ```
582
+
583
+ The plugin chooses a path that is available and returns an explicit error when no visual route can be used.
584
+
585
+ ## Coordinate semantics
586
+
587
+ Since v0.2.0, all coordinates are **window-local screenshot pixels**:
588
+
589
+ - the origin is the top-left corner of the target window;
590
+ - coordinates returned by `screen_observe` and coordinates accepted by `computer_click` share the same space;
591
+ - do not multiply by two;
592
+ - do not add a screen or window offset;
593
+ - `screen_zoom` returns a cropped image, but click coordinates remain coordinates in the full-window screenshot space.
594
+
595
+ Prefer semantic element actions:
596
+
597
+ ```text
598
+ computer_click(element=5)
599
+ ```
600
+
601
+ Use `x,y` when the target is not exposed through AX/UIA or when a visual observer provides coordinates.
602
+
603
+ ## Security model
604
+
605
+ The plugin includes:
606
+
607
+ 1. **Observe-before-act**: actions without a fresh observation are rejected;
608
+ 2. **Snapshot TTL**: expired snapshots require a new observation;
609
+ 3. **Application allowlists**: `allowedApps` can restrict the operation scope;
610
+ 4. **Risky-action approval**: labels such as delete, pay, purchase, transfer, or sign out can require user approval;
611
+ 5. **Password-field protection**: automated typing into password fields is refused;
612
+ 6. **Keyboard foreground retry approval**: keyboard/text actions use background delivery first; after an explicit driver refusal and only where the driver supports the mode, foreground retry requires one-time user approval. Without approval, focus is not changed and no retry occurs;
613
+ 7. **Fixed non-shell driver invocation**: the host starts `cua-driver` with fixed argv;
614
+ 8. **Explicit permission boundaries**: the core desktop path does not read business files or extra credentials. The optional GLM fallback reads only its configured key source and sends an HTTPS request to the GLM vision API; there are no npm lifecycle scripts.
615
+
616
+ Semantic checks are strongest for `element`-based actions. Coordinate actions and unfocused `computer_type`/`computer_key` calls cannot predict the final semantic target. `computer_key` does not validate system shortcuts. Do not give this capability to an untrusted agent, and always type passwords and secrets yourself.
617
+
618
+ If the driver reports `background_unavailable`, the plugin asks for one-time approval before retrying in foreground mode where the current tool/platform supports it; that retry may bring the target window forward. Rejecting or lacking approval leaves the action refused.
619
+
620
+ ## Configuration
621
+
622
+ ```yaml
623
+ - id: dsh-computer-use-ng
624
+ config:
625
+ ttlMs: 30000
626
+ maxElements: 500
627
+ allowedApps: []
628
+ cursorTheme: com.dsh.computeruse.rainbow
629
+ nativeImage: auto
630
+ visionProvider: deepseek-official
631
+ visionModel: deepseek-v4-flash-vision-exp
632
+ ```
633
+
634
+ | Option | Default | Description |
635
+ |---|---:|---|
636
+ | `ttlMs` | `30000` | Observation lifetime in milliseconds |
637
+ | `maxElements` | `500` | Maximum indexed elements returned by observation |
638
+ | `allowedApps` | `[]` | Empty means unrestricted; otherwise only listed apps are allowed |
639
+ | `cursorTheme` | `com.dsh.computeruse.rainbow` | Virtual cursor theme; empty uses the engine default |
640
+ | `nativeImage` | `auto` | `auto`, `full`, or `compact` screenshot strategy |
641
+ | `visionProvider` | `deepseek-official` | Provider used by `vision` mode |
642
+ | `visionModel` | `deepseek-v4-flash-vision-exp` | Image-capable observer model |
643
+
644
+ If an installer or bundle patch overrides the code-level default, the generated `$DSH_HOME/cordis.patch.yml` is authoritative. For multi-step tasks, set `ttlMs` explicitly instead of relying on an implicit default.
645
+
646
+ ## Platform support
647
+
648
+ | Platform | Status | Notes |
649
+ |---|---|---|
650
+ | macOS | ✅ Verified | Accessibility and Screen Recording permissions may be required |
651
+ | Windows | ⛔ Blocked | Logic/path coverage exists; real GUI validation requires a Windows 10/11 regular-user desktop session |
652
+ | Linux | ⛔ Not verified | Desktop environment, accessibility stack, and window manager can affect element discovery |
653
+
654
+ The macOS path has been verified in the project evidence. Windows and Linux still require a real platform run before they can be advertised as fully tested. This does not mean every application exposes an identical accessibility tree. For incomplete AX/UIA data, use `native` or `vision` and include the OS, target application, and observation output in bug reports.
655
+
656
+ ## Troubleshooting
657
+
658
+ | Symptom | Likely cause | Action |
659
+ |---|---|---|
660
+ | `cua-driver not found` | Driver is not in `PATH` or the official installer path is unavailable | Install it, confirm `~/.cua-driver/packages/current/cua-driver.exe` exists, or set `CUA_DRIVER_BIN` |
661
+ | No visible windows | Missing graphical session or permission | Confirm the target app is visible and observe again |
662
+ | Snapshot expired | `ttlMs` elapsed | Call `screen_observe` again |
663
+ | Element click failed | The UI changed | Observe again and use the new index |
664
+ | Empty AX/UIA tree | Canvas, game, Electron, or special window | Use `native` or `vision` |
665
+ | `native` rejected | Main route is not image-capable | Switch to an image-capable model or use `vision` |
666
+ | Vision model unavailable | Provider/model lacks image input declaration | Configure `visionProvider` / `visionModel` |
667
+ | GLM fallback unavailable | Missing `ZHIPU_API_KEY` or rate limit | Configure the key or use a Harness vision model |
668
+ | `background_unavailable` | Driver cannot deliver keyboard/text in the background | Approve the one-time foreground retry if changing window focus is acceptable |
669
+ | Risky action rejected | User approval was not granted | Follow the approval result; do not bypass the guard |
670
+ | Windows elevated window rejected | Target has a higher privilege level | Use a regular-user window |
671
+
672
+ ## Development and verification
673
+
674
+ ```bash
675
+ npm install
676
+ npm run check
677
+ node verify-runtime.mjs
678
+ ```
679
+
680
+ The runtime verification requires a working `harness-desktop` installation and `cua-driver`. Additional evidence is available in:
681
+
682
+ - [PERMISSIONS.md](PERMISSIONS.md)
683
+ - [VERIFICATION.md](VERIFICATION.md)
684
+ - [WINDOWS_TEST.md](WINDOWS_TEST.md)
685
+ - [docs/store-evidence.md](docs/store-evidence.md)
686
+ - [verify-runtime.mjs](verify-runtime.mjs)
687
+
688
+ ## Ecosystem
689
+
690
+ - [harness-desktop](https://github.com/988hj7tczd-oss/harness-desktop) — a ready-to-use DeepSeek Harness desktop client;
691
+ - [awesome-dsh-plugin](https://github.com/988hj7tczd-oss/awesome-dsh-plugin) — a curated list of DeepSeek Harness plugins;
692
+ - [AI House Tools](https://www.aibunkhouse.com/tools) — discover AI tools, models, and agents;
693
+ - [cua-driver](https://github.com/trycua/cua) — the underlying cross-platform desktop driver;
694
+ - [npm package](https://www.npmjs.com/package/dsh-computer-use-ng) — package versions and downloads;
695
+ - [GitHub repository](https://github.com/AndroidSix/dsh-computer-use-ng) — source and issue tracker for this maintained branch;
696
+ - [Upstream project](https://github.com/988hj7tczd-oss/dsh-computer-use) — the original project and historical releases.
697
+
698
+ ## License
699
+
700
+ [MIT License](LICENSE)
701
+
702
+ ---
703
+
704
+ Not affiliated with DeepSeek. DeepSeek Harness is an open-source project by [DeepSeek AI](https://deepseek.com).