dsh-gui-control 0.1.0 → 0.1.2

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,97 +1,91 @@
1
- # dsh-gui-control
2
-
3
- **给 DeepSeek Harness 的 Windows 桌面操控:不是"帮我点一下这个按钮",而是"以后这个活都交给你"。**
1
+ <div align="center">
4
2
 
5
- 大多数桌面 Agent 解决的是「一次性操作」——看一眼、点一下、再看一眼。这个插件多做一层:**把一套动作固化成任务文件**,跑的时候模型完全不参与,带条件校验、失败分类、以及"这一次到底有没有真的发出去"的判定。
3
+ <img src="https://raw.githubusercontent.com/seetown/dsh-gui-control/main/assets/icon-180.png" width="88" alt="dsh-gui-control">
6
4
 
7
- <!-- TODO: 15 秒 GIF:左边敲一句话,右边 WPS 表格被填好 -->
8
-
9
- ## 演示
5
+ # dsh-gui-control
10
6
 
11
- **打开 B 站 → 搜索番剧 → 播到指定集数**(模型自己找搜索框、点卡片、跳剧集)
7
+ **给 DeepSeek Harness 的 Windows 桌面操控:不是「帮我点一下」,而是「以后这个活都交给你」。**
12
8
 
13
- ![B 站选集](https://raw.githubusercontent.com/seetown/dsh-gui-control/main/demo/4-bilibili.gif)
9
+ <p>
10
+ <a href="https://www.npmjs.com/package/dsh-gui-control"><img alt="npm" src="https://img.shields.io/npm/v/dsh-gui-control.svg?color=cb3837"></a>
11
+ <img alt="platform" src="https://img.shields.io/badge/platform-Windows-0078d4.svg">
12
+ <img alt="license" src="https://img.shields.io/badge/license-MIT-blue.svg">
13
+ <a href="https://github.com/topics/dsh-plugin"><img alt="dsh-plugin" src="https://img.shields.io/badge/topic-dsh--plugin-6f42c1.svg"></a>
14
+ </p>
14
15
 
15
- **语义点击:鼠标位移 0 像素**(直接调用控件的 Invoke,鼠标不动、窗口在后台也能点)
16
+ [中文说明](#中文说明) · [English](#english)
16
17
 
17
- ![语义点击](https://raw.githubusercontent.com/seetown/dsh-gui-control/main/demo/3-calc.gif)
18
+ </div>
18
19
 
19
- **填一列数据**(17 步 / 0.9 秒 / 一次调用,执行期间模型完全不参与)
20
+ ---
20
21
 
21
- ![填表](https://raw.githubusercontent.com/seetown/dsh-gui-control/main/demo/2-sheet.gif)
22
+ <div align="center">
22
23
 
23
- > 把 `seetown` 换成你的 GitHub 用户名,图才会显示。
24
+ <img src="https://raw.githubusercontent.com/seetown/dsh-gui-control/main/demo/0-hero.gif" width="820" alt="一句话把数据填进表格">
24
25
 
25
- ## 三个工具
26
+ </div>
26
27
 
27
- | 工具 | 作用 |
28
- |---|---|
29
- | `gui_snapshot` | 读窗口的无障碍树(文本,精确、便宜、与位置无关),或带屏幕坐标刻度尺的截图 |
30
- | `gui_act` | 做一个动作,带**身份校验**和**投递判定** |
31
- | `gui_task` | 跑一个声明式任务文件:一步调用完成多步,带条件等待、重试、风险闸门 |
28
+ ---
32
29
 
33
- ## 为什么不是又一个 pyautogui 封装
30
+ ## 中文说明
34
31
 
35
- ### 1. 投递语义:知道"有没有真的发出去"
32
+ ### 它和别的桌面 Agent 有什么不同
36
33
 
37
- 每个动作返回三选一的判定:
34
+ 大多数桌面自动化解决的是**一次性操作**:看一眼屏幕、点一下、再看一眼。这个插件多做一层——**把一套动作固化成任务文件**,跑的时候模型完全不参与。
38
35
 
39
- | 判定 | 含义 | 能不能重试 |
36
+ | | 常见做法 | dsh-gui-control |
40
37
  |---|---|---|
41
- | `not_delivered` | 什么都没发出去(派发前就被拒) | ✅ 安全重试 |
42
- | `delivered_unverified` | 发出去了,但效果没确认 | ❌ **绝对不能盲目重放** |
43
- | `delivered_verified` | 发出去了,且后置条件验证通过 | ❌ |
38
+ | 感知 | 截图 → 模型猜坐标 | **无障碍树优先**,按控件名定位;树不可用时才截图 |
39
+ | 一次任务的往返 | 每步一次模型调用 | 一次调用跑完整个任务文件 |
40
+ | 失败之后 | 不知道点没点上 | **投递判定**:没发出去 / 可能发出去了 / 已验证 |
41
+ | 重复执行 | 每次重跑一遍 | 任务文件可复用,带条件等待与重试 |
44
42
 
45
- 这条区分决定了「发送消息 / 删除文件 / 提交表单」这类不可逆操作是否安全。实测:控件不存在时判 `not_delivered/retry=safe`;点了但校验超时判 `delivered_unverified/retry=unsafe`。
43
+ ### 演示
46
44
 
47
- ### 2. 元素身份,而不是坐标或序号
45
+ **① 打开 B 站 → 搜番剧 → 播到指定集数**
48
46
 
49
- `uia-pick` 支持 `expect`(名字)和 `expectId`(AutomationId)。页面重排后序号漂移,它会**在派发前拒绝**并回报实际值:
47
+ ![B 站选集](https://raw.githubusercontent.com/seetown/dsh-gui-control/main/demo/4-bilibili.gif)
50
48
 
51
- ```
52
- identity mismatch at index 0: expected id "NoSuchAutomationId", found "CloseButton"
53
- ```
49
+ **② 语义点击:鼠标位移 0 像素**(直接调用控件的 Invoke,鼠标不动、窗口在后台也能点)
54
50
 
55
- ### 3. 三通道并存,不赌单一来源
51
+ ![语义点击](https://raw.githubusercontent.com/seetown/dsh-gui-control/main/demo/3-calc.gif)
56
52
 
57
- - **UIA**:能读树的窗口,语义点击,鼠标不动、不抢焦点
58
- - **OCR**:文字密集但无树的界面(本地 Windows.Media.Ocr,不外传图片)
59
- - **坐标 + 刻度尺截图**:画布、游戏、自绘列表
53
+ **③ 填一列数据**(17 步 / 0.9 秒 / 一次调用)
60
54
 
61
- WPS 表格这类「有窗口但没有单元格节点」的应用,只有后两条路能走。
55
+ ![填表](https://raw.githubusercontent.com/seetown/dsh-gui-control/main/demo/2-sheet.gif)
62
56
 
63
- ## 安装
57
+ ### 安装
64
58
 
65
59
  ```bash
66
- # 从本地目录(开发时)
67
- dsh plugin add /absolute/path/to/dsh-gui-control
68
-
69
- # 从 npm
70
60
  dsh plugin add dsh-gui-control
71
61
  ```
72
62
 
73
- 装完**无需重启**:三个工具会在当前会话直接出现。
63
+ 或从源码:
74
64
 
75
- 要求:Windows 10 1809+,PowerShell 5.1(系统自带),DeepSeek Harness 0.1.5-rc.2 ~ 0.2.x。
65
+ ```bash
66
+ dsh plugin add seetown/dsh-gui-control
67
+ ```
76
68
 
77
- ## 用法
69
+ 要求:Windows 10 1809+、PowerShell 5.1、DeepSeek Harness 0.1.5-rc.2 ~ 0.2.x。装完不需要重启。
70
+
71
+ ### 三个工具
72
+
73
+ | 工具 | 作用 |
74
+ |---|---|
75
+ | `gui_snapshot` | 读窗口的无障碍树(文本,精确、便宜、与位置无关),或带屏幕坐标刻度尺的截图 |
76
+ | `gui_act` | 执行一个动作,带身份校验和投递判定 |
77
+ | `gui_task` | 跑声明式任务文件:一次调用完成多步,带条件、重试、风险闸门 |
78
78
 
79
79
  ```
80
80
  gui_snapshot { window: "Notepad", mode: "tree" }
81
- → MenuI 文件
82
- Butto 关闭标签页
83
- Docum 文本编辑器
84
- ...
81
+ → Butto 关闭标签页 / Docum 文本编辑器 / MenuI 文件 ...
85
82
 
86
83
  gui_act { action: "click_text", window: "Notepad", text: "最大化" }
87
84
  → click ok via InvokePattern | verified: text appeared
88
-
89
- gui_task { file: "C:\\tasks\\fill-sheet.json", dryRun: true }
90
- → task fill-sheet ok in 0 ms
91
- 1. ok click 412 ms not_delivered
92
- 2. ok type 380 ms delivered_unverified
93
85
  ```
94
86
 
87
+ **优先用 `click_text` 而不是坐标**:它按控件名定位,鼠标不动,窗口布局变了也不会点错。
88
+
95
89
  ### 任务文件
96
90
 
97
91
  ```json
@@ -99,7 +93,6 @@ gui_task { file: "C:\\tasks\\fill-sheet.json", dryRun: true }
99
93
  "name": "fill-sheet",
100
94
  "steps": [
101
95
  { "do": "activate", "win": "工作簿1" },
102
- { "do": "click", "x": 129, "y": 449 },
103
96
  { "do": "type", "text": "项目" },
104
97
  { "do": "key", "key": "tab" },
105
98
  { "do": "type", "text": "金额" },
@@ -109,57 +102,85 @@ gui_task { file: "C:\\tasks\\fill-sheet.json", dryRun: true }
109
102
  }
110
103
  ```
111
104
 
112
- 步骤字段:`do` + 该动作的参数,外加 `until`(轮询到条件成立才算过)、`untilTimeout`、`retry`、`risk`。
105
+ 每步字段:`do` + 该动作参数,外加 `until`(轮询到条件成立才算过)、`untilTimeout`、`retry`、`risk`。
113
106
 
114
- `risk: "high"` 的步骤默认**拒绝执行**,必须显式 `confirm: true`;`dryRun: true` 只看计划不碰桌面。
107
+ - `risk: "high"` 的步骤默认**拒绝执行**,必须显式 `confirm: true`
108
+ - `dryRun: true` 只返回计划,不碰桌面
115
109
 
116
- ## 性能实测
110
+ ### 投递语义
117
111
 
118
- | 操作 | 耗时 |
119
- |---|---|
120
- | 动作(单步,守护进程) | 10.8 ms |
121
- | UIA 点击(语义) | 26–34 ms |
122
- | 紧凑树读取(`uia-mini`) | 86 ms,865 字符(比完整 dump 省 88%) |
123
- | 7 步任务(含启动计算器) | 680 ms,一次调用 |
124
- | 桌面建 3 个文件夹 | 3.45 s,3 次全部成功 |
112
+ 每个动作返回三选一:
113
+
114
+ | 判定 | 含义 | 能否重试 |
115
+ |---|---|---|
116
+ | `not_delivered` | 什么都没发出去(派发前就被拒) | ✅ 安全 |
117
+ | `delivered_unverified` | 发出去了,效果未确认 | ❌ 不能盲目重放 |
118
+ | `delivered_verified` | 发出去了,且后置条件验证通过 | ❌ |
125
119
 
126
- 守护进程常驻,首次调用预热约 1 秒;之后每个动作是一次 loopback TCP 往返。
120
+ 这一条决定了「发消息 / 删文件 / 提交表单」这类不可逆操作是否安全。
127
121
 
128
- ## 安全
122
+ ### 安全
129
123
 
130
124
  - 只监听 `127.0.0.1:38471`,不对外暴露
131
- - 密码字段读取一律输出 `<redacted>`
125
+ - 密码字段一律输出 `<redacted>`
132
126
  - 高风险步骤需要显式确认
133
- - 失败区分「没发出去」和「可能发出去了」,后者绝不自动重放
127
+ - 结果不明时**绝不自动重试**
134
128
 
135
- **注意**:这个插件能操控整台机器的鼠标键盘。装之前请知情,只在可信环境使用。
129
+ > 这个插件能操控整台机器的鼠标键盘。装之前请知情,只在可信环境使用。
136
130
 
137
- ## 已知限制
131
+ ### 实测数据
132
+
133
+ | 操作 | 耗时 |
134
+ |---|---|
135
+ | 单步动作(常驻进程) | 10.8 ms |
136
+ | 语义点击(UIA 树) | 26–34 ms |
137
+ | 紧凑树读取 | 86 ms,865 字符(比完整 dump 省 88%) |
138
+ | 7 步任务(含启动计算器) | 680 ms,一次调用 |
139
+ | 桌面建 3 个文件夹 | 3.45 s,3/3 成功 |
140
+ | WPS 填 2×3 表格 | 0.9 s,17 步 |
141
+
142
+ 首次调用会预热常驻进程(约 1 秒),之后每个动作是一次 loopback 往返。
143
+
144
+ ### 已知限制
138
145
 
139
146
  - **仅 Windows**(Win32 + UI Automation)
140
- - 需要 PowerShell 5.1;没有它在 PATH 上的发行版会失败
141
- - 部分应用不暴露无障碍树(游戏、画布、未开无障碍的 Electron),此时只能走截图 + OCR,速度和准确率都会下降
142
- - 坐标是物理像素,前提是进程声明了 per-monitor DPI 感知(已内置)
147
+ - 需要 PowerShell 5.1
148
+ - 画布类应用(WPS 表格、游戏、自绘列表)没有无障碍树,只能截图 + OCR,准确率下降
149
+ - 网页任务目前基于截图;CDP 通道已实现但尚未接入工具
143
150
 
144
- ## Roadmap
151
+ ### Roadmap
145
152
 
146
153
  - [ ] 截图自动编号(Set-of-Marks),把坐标估计降级成编号分类
154
+ - [ ] 接入 CDP:网页任务按选择器操作,而不是按坐标
147
155
  - [ ] 任务库与意图路由:一句话命中现成任务
148
- - [ ] macOS / Linux 适配(目前是 Win32 专用)
149
-
150
- ## License
151
-
152
- MIT
156
+ - [ ] macOS / Linux 适配
153
157
 
154
158
  ---
155
159
 
156
- # English
160
+ ## English
157
161
 
158
162
  **Windows desktop control for DeepSeek Harness.** Not "click that button for me" — "this job is yours from now on."
159
163
 
160
- Most desktop agents do one-off operations: look, click, look again. This plugin adds a layer underneath: **turn a sequence into a task file** that runs with no model in the loop, with conditions, failure classification, and a verdict on whether the input actually reached the application.
164
+ Most desktop agents do one-off operations: look, click, look again. This one adds a layer underneath: **it turns a sequence into a task file** that runs with no model in the loop.
165
+
166
+ ### What makes it different
167
+
168
+ | | Typical approach | dsh-gui-control |
169
+ |---|---|---|
170
+ | Perception | Screenshot, then the model guesses coordinates | **Accessibility tree first**, addressed by control name; screenshots only when no tree exists |
171
+ | Round trips per task | One model call per step | One call runs the whole task file |
172
+ | After a failure | Unknown whether it landed | **Delivery verdict**: not delivered / may have landed / verified |
173
+ | Repeating a flow | Replay it by hand | Task files are reusable, with conditions and retries |
174
+
175
+ ### Install
176
+
177
+ ```bash
178
+ dsh plugin add dsh-gui-control
179
+ ```
180
+
181
+ Windows 10 1809+, PowerShell 5.1, DeepSeek Harness 0.1.5-rc.2 – 0.2.x. No restart needed.
161
182
 
162
- ## Three tools
183
+ ### Three tools
163
184
 
164
185
  | Tool | Purpose |
165
186
  |---|---|
@@ -167,22 +188,30 @@ Most desktop agents do one-off operations: look, click, look again. This plugin
167
188
  | `gui_act` | One action, with an identity check and a delivery verdict |
168
189
  | `gui_task` | Run a declarative task file: many steps in one call, with conditions, retries and a risk gate |
169
190
 
170
- ## Delivery semantics
191
+ ### Delivery semantics
171
192
 
172
193
  | Verdict | Meaning | Retry |
173
194
  |---|---|---|
174
195
  | `not_delivered` | Nothing was sent | ✅ safe |
175
196
  | `delivered_unverified` | Input may have landed, effect unconfirmed | ❌ never blind-retry |
176
- | `delivered_verified` | Landed and the post-condition held | ❌ |
197
+ | `delivered_verified` | Landed, and the post-condition held | ❌ |
177
198
 
178
199
  That distinction is what makes "send a message / delete a file / submit a form" safe to automate.
179
200
 
180
- ## Install
201
+ ### Security
181
202
 
182
- ```bash
183
- dsh plugin add dsh-gui-control
184
- ```
203
+ Loopback-only (`127.0.0.1:38471`), password fields are redacted, high-risk steps require explicit confirmation, and an uncertain outcome is never retried automatically.
204
+
205
+ > This plugin drives the real mouse and keyboard of the whole machine. Install it knowingly, in a trusted environment.
206
+
207
+ ### Limitations
208
+
209
+ Windows only; PowerShell 5.1 required; canvas-like apps (spreadsheets, games, self-drawn lists) expose no accessibility tree and fall back to screenshot + OCR with lower accuracy; web tasks currently use screenshots (the CDP path exists but is not wired into the tools yet).
210
+
211
+ ---
212
+
213
+ <div align="center">
185
214
 
186
- Windows 10 1809+, PowerShell 5.1, DeepSeek Harness 0.1.5-rc.2 – 0.2.x. Tools appear immediately, no restart.
215
+ MIT © [seetown](https://github.com/seetown)
187
216
 
188
- MIT.
217
+ </div>
@@ -0,0 +1,4 @@
1
+ 11-04 06:29:09.359 uia loaded
2
+ 11-04 06:29:09.384 listening on 38471 (pid 22708)
3
+ 11-04 06:29:27.993 uia loaded
4
+ 11-04 06:29:28.018 listening on 38471 (pid 35504)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gui-control",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Windows desktop control for DeepSeek Harness: read a window's accessibility tree, act with identity checks and delivery semantics, and run repeatable task files.",
5
5
  "license": "MIT",
6
6
  "type": "module",