dsh-cua-linux 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,85 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here.
4
+ This project follows [Semantic Versioning](https://semver.org/).
5
+
6
+ ## 0.1.0 — first public release
7
+
8
+ Two channels, chosen by target: X11 for the desktop, the DevTools Protocol for Chromium.
9
+
10
+ **Desktop (X11 / XWayland)** — 7 tools
11
+
12
+ - `cua_linux_probe` reports what the session can actually do: session type, X11 sockets,
13
+ XTEST, `/dev/uinput`, libei, external tools and open DevTools ports. Read-only.
14
+ - `cua_linux_windows` lists visible windows with WM_CLASS, title, position, size and
15
+ stacking order.
16
+ - `cua_linux_screenshot` captures the screen or one window as PNG. It captures the root
17
+ and crops, because `GetImage` on a child window returns black under a compositor.
18
+ - `cua_linux_click` / `cua_linux_scroll` act at window-local coordinates and activate the
19
+ window first — under X11 the pointer hits the topmost window, so an unactivated click
20
+ lands somewhere else without any error.
21
+ - `cua_linux_key` / `cua_linux_type` drive XTEST. Non-ASCII input is refused explicitly:
22
+ XTEST can only send keycodes and cannot produce an IME commit.
23
+
24
+ **Browser (CDP)** — 8 tools
25
+
26
+ - `cua_browser_launch`, `cua_browser_pages`, `cua_browser_goto`, `cua_browser_fill`,
27
+ `cua_browser_click`, `cua_browser_key`, `cua_browser_read`, `cua_browser_screenshot`.
28
+ - Built on Node's own `fetch` and `WebSocket`: no extra dependency.
29
+ - `Input.insertText` writes CJK and emoji without an input method or the clipboard.
30
+ - Clicks are real mouse events at the element's centre, not `el.click()`.
31
+ - Works while the window is hidden or covered, because it never touches pixels.
32
+
33
+ **Verification**
34
+
35
+ Every action reports what it observed instead of a bare `ok`:
36
+
37
+ - X11: the region around the action point is compared before and after, with a noise
38
+ baseline taken first so a blinking caret is not mistaken for a successful action; the
39
+ whole window is a fallback tier so an effect elsewhere is still reported.
40
+ - Browser: `fill` reads `element.value` back and fails on mismatch; clicks and keys watch
41
+ DOM mutations and URL changes.
42
+ - Three outcomes are kept distinct: verified, dispatched-without-feedback, undecidable.
43
+
44
+ **Known limits**
45
+
46
+ - X11 only. Native Wayland windows ignore XTEST; `cua_linux_probe` reports whether
47
+ `/dev/uinput` or libei are available.
48
+ - ASCII only on the desktop channel; use CDP for browsers.
49
+ - X11 injection is global, so tools activate the target window (and steal focus).
50
+ - Upgrading the package requires restarting DSH: the host does not re-run `apply()` for an
51
+ already-loaded bundle.
52
+
53
+ ---
54
+
55
+ ### Pre-public development
56
+
57
+ Versions `0.0.1` through `0.3.1` below were local iterations, never published. They are
58
+ kept for the maintainer's record; the public history starts at `0.1.0`.
59
+
60
+ #### 0.3.1 — English tool messages
61
+
62
+ - Every model-facing string (verification verdicts, action results, error paths, probe
63
+ report) is English. Tool descriptions stay Chinese, matching other plugins in this list.
64
+
65
+ #### 0.3.0 — verification quality
66
+
67
+ - Region-based verification, noise baseline, signal-to-noise decision.
68
+ - Fixed: the `✓` prefix was printed twice for browser-side verdicts.
69
+
70
+ #### 0.2.0 — act/verify loop
71
+
72
+ - Pixel diff for X11, read-back for `fill`, MutationObserver and URL for browser clicks.
73
+ - Out-of-bounds coordinates fail before any event is sent.
74
+
75
+ #### 0.1.0 — CDP channel
76
+
77
+ - 8 tools over the DevTools Protocol with no extra dependency.
78
+
79
+ #### 0.0.2 — X11 channel
80
+
81
+ - Window enumeration, EWMH activation, root-capture screenshots, clicks, keys, typing.
82
+
83
+ #### 0.0.1 — first installable bundle
84
+
85
+ - `cua_linux_probe`.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-computer-use-linux contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,89 @@
1
- # Temporary Holding Version
1
+ # dsh-cua-linux
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
+ [Chinese](README.zh.md)
4
+
5
+ A Linux (X11 / XWayland) computer-use backend for [DeepSeek Harness](https://github.com/deepseek-ai).
6
+
7
+ The official `dsh-computer-use` plugin drives the desktop through the `cua-driver` native
8
+ agent, which has no Linux provider: on Linux its accessibility tree comes back empty, clicks
9
+ never reach the target window, and text input is refused. This plugin fills that gap, and adds
10
+ a second channel that browsers deserve.
11
+
12
+ Two channels, picked by target:
13
+
14
+ | Channel | Used for | How |
15
+ |---|---|---|
16
+ | **CDP** | Chromium / Edge / Electron pages | DevTools Protocol over the built-in `fetch` + `WebSocket`. No extra dependency. |
17
+ | **X11** | everything else | Raw X11 protocol via the pure-JS `x11` package; XTEST for input. |
18
+
19
+ ## Install
20
+
21
+ ```sh
22
+ dsh plugin add ethanrise/dsh-cua-linux
23
+ ```
24
+
25
+ Requirements: Linux with an X11 session (or XWayland for X11 clients), Node ≥ 22.18.
26
+ No `xdotool`, no ImageMagick, no Python.
27
+
28
+ ## Tools
29
+
30
+ | Tool | What it does |
31
+ |---|---|
32
+ | `cua_linux_probe` | Read-only: session type, X11 sockets, XTEST, `/dev/uinput`, libei, external tools, open DevTools ports |
33
+ | `cua_linux_windows` | Enumerate visible windows: id, WM_CLASS, title, position, size, stacking order |
34
+ | `cua_linux_screenshot` | PNG of the whole screen or one window (root capture, cropped — child-window `GetImage` returns black under a compositor) |
35
+ | `cua_linux_click` | Click at window-local coordinates; activates the window first; left/middle/right, repeated |
36
+ | `cua_linux_key` | Key combos and named keys (`ctrl+t`, `Return`, `Escape`) |
37
+ | `cua_linux_type` | ASCII text via XTEST. Non-ASCII is refused explicitly — XTEST cannot produce an IME commit |
38
+ | `cua_linux_scroll` | Wheel, vertical or horizontal |
39
+ | `cua_browser_launch` | Start a Chromium with `--remote-debugging-port` on an isolated profile |
40
+ | `cua_browser_pages` | List page targets |
41
+ | `cua_browser_goto` | Navigate and wait for quiescence |
42
+ | `cua_browser_fill` | Fill a field through `Input.insertText` — CJK and emoji land directly, no IME, no clipboard |
43
+ | `cua_browser_click` | Real mouse events at the element's centre (`dispatchMouseEvent`, not `el.click()`) |
44
+ | `cua_browser_key` | Enter / Tab / Escape / Backspace / arrows |
45
+ | `cua_browser_read` | `innerText` of a selector, or the whole body |
46
+ | `cua_browser_screenshot` | PNG through the render pipeline; works while the window is hidden |
47
+
48
+ ## Every action verifies itself
49
+
50
+ An injection tool that returns `ok` without looking is worse than useless: the model keeps
51
+ acting on a state it never reached. Each action therefore reports what was observed.
52
+
53
+ - X11: a **region** around the action point is compared before/after (90 px for clicks,
54
+ 220 px for scrolls); the whole window is a fallback tier so "the change happened elsewhere"
55
+ is reported rather than missed.
56
+ - A **noise baseline** is taken first (two frames 250 ms apart), so a blinking caret is not
57
+ mistaken for a successful action. The decision is signal-to-noise, not raw difference.
58
+ - Browser `fill` reads `element.value` back and fails on mismatch.
59
+ - Browser `click` / `key` watch DOM mutations and URL changes.
60
+
61
+ Three outcomes, deliberately distinct:
62
+
63
+ ```
64
+ ✓ Area around the action point changed (7471 px / 31.21%)
65
+ ⚠ nothing changed around the action point or elsewhere — the event was dispatched
66
+ but no feedback was observed; it may be a repeat action, a non-interactive
67
+ target, or an operation that does not repaint
68
+ ? Undecidable: the region changes on its own (1.20%), while the action changed
69
+ only 0.13%
70
+ ```
71
+
72
+ `⚠` says the event **was** sent; it does not say the operation failed. A second click on an
73
+ already-focused field legitimately changes nothing, and wording it as "failed" invites a retry
74
+ that can be harmful.
75
+
76
+ ## Known limits
77
+
78
+ - **X11 only.** Native Wayland windows ignore XTEST. `cua_linux_probe` reports whether
79
+ `/dev/uinput` or libei are available; a Wayland backend is not implemented yet.
80
+ - **Non-ASCII input over X11 is not supported.** Use the CDP channel for browsers, or the
81
+ plugin will tell you why instead of dropping characters.
82
+ - **X11 injection is global.** Events go to the focused window, so the target must be
83
+ activated — which the tools do by default, at the cost of stealing focus.
84
+ - **New tools need a restart.** The harness does not re-run a plugin's `apply()` for an
85
+ already-loaded bundle, so upgrading the package requires restarting DSH.
86
+
87
+ ## License
88
+
89
+ MIT
package/README.zh.md ADDED
@@ -0,0 +1,78 @@
1
+ # dsh-cua-linux(中文)
2
+
3
+ [English](README.md)
4
+
5
+ 给 DeepSeek Harness 补上 Linux(X11 / XWayland)的 computer-use 后端。
6
+
7
+ 官方 `dsh-computer-use` 走 `cua-driver` 原生驱动,没有 Linux provider:在 Linux 上 AX 树为空、
8
+ 点击落不到目标窗口、文本输入被拒绝。本插件补的就是这一层,并且额外提供浏览器该走的那条通道。
9
+
10
+ ## 安装
11
+
12
+ ```sh
13
+ dsh plugin add ethanrise/dsh-cua-linux
14
+ ```
15
+
16
+ 要求:X11 会话(或 XWayland)、Node ≥ 22.18。不需要 `xdotool`、ImageMagick、Python。
17
+
18
+ ## 两条通道
19
+
20
+ | 通道 | 适用 | 原理 |
21
+ |---|---|---|
22
+ | **CDP** | Chromium / Edge / Electron 页面 | DevTools Protocol,走 Node 内置 `fetch` + `WebSocket`,零依赖 |
23
+ | **X11** | 其他一切 | 纯 JS 的 `x11` 包直连 X server,XTEST 注入 |
24
+
25
+ 浏览器场景不要用像素:selector 定位、`insertText` 免输入法、视口坐标与窗口是否可见无关。
26
+ 实测同一个搜索任务,X11 通道输中文要 1263ms(剪贴板握手),CDP 是 `insertText` 立即完成。
27
+
28
+ ## 动作闭环
29
+
30
+ 注入类工具最大的问题是「静默成功」。每个动作都带一条可复核的判定:
31
+
32
+ - X11:比动作点**附近**的区域(点击 90px、滚动 220px),整窗作为兜底
33
+ - 先采两帧(间隔 250ms)测「自发变化率」,光标闪烁不再被当成动作生效
34
+ - 浏览器 `fill` 读回 `element.value` 严格比对;`click` / `key` 看 DOM 突变与 URL 变化
35
+
36
+ 三种结论刻意分开,实测输出如下(工具报文统一用英文,便于国际化):
37
+
38
+ ```
39
+ ✓ Area around the action point changed (7471 px / 31.21%) 生效
40
+ ⚠ nothing changed around the action point or elsewhere … 已发出但无反馈
41
+ ? Undecidable: the region changes on its own (1.20%) … 无法判定(转圈/视频)
42
+ ```
43
+
44
+ ## 已知边界
45
+
46
+ - **只支持 X11**。原生 Wayland 窗口收不到 XTEST 事件;`cua_linux_probe` 会报告 `/dev/uinput`
47
+ 和 libei 的可用性,Wayland 后端尚未实现
48
+ - **X11 下无法输入非 ASCII**(XTEST 只能发 keycode),浏览器请走 CDP
49
+ - **X11 注入是全局的**:事件发给焦点窗口,所以工具默认会先激活目标窗口(代价是抢焦点)
50
+ - **新工具要重启才生效**:宿主不会对已加载的插件重跑 `apply()`,升级包后需重启 DSH
51
+
52
+ ## 踩过的坑(写给下一个维护者)
53
+
54
+ 1. **XTEST `FakeInput` 的第 4 个参数是 root window,不是可选的窗口 id。**
55
+ 传 `0` 时鼠标移动和点击居然还能用,按键却会被服务器静默丢弃。
56
+
57
+ 2. **`X.require('xtest')` 必须传回调**,不传会在扩展加载完成时抛
58
+ `TypeError: callback is not a function`,栈指向 xcore 内部。
59
+
60
+ 3. **`XRaiseWindow` 在 mutter 下无效**,置顶必须发 EWMH `_NET_ACTIVE_WINDOW`,
61
+ 且 `source indication` 用 `2`(pager)才不会被防焦点窃取拦下。
62
+
63
+ 4. **对子窗口 `GetImage` 在 compositor 下常拿到黑图**,稳定做法是抓 root 再按窗口几何裁剪。
64
+
65
+ 5. **只等 selector 出现会截到空白页**。点提交后页面开始导航,旧文档里的 selector 仍然命中,
66
+ 于是读/截到的是导航后的新页。必须等「readyState=complete 且 body 文本长度稳定」。
67
+
68
+ 6. **同一 profile 不能起第二个 Chrome**:单例锁会把新进程变成"把 URL 转给已有实例然后退出",
69
+ `--remote-debugging-port` 自然起不来。
70
+
71
+ 7. **`pkill -f <pattern>` 会匹配到执行它的 shell 自己**,用 `pkill -f 'cua-[a-z0-9]'` 规避。
72
+
73
+ 8. **目标输入框开着中文输入法时,ASCII 会进入候选串**(composition)而不是直接上屏,
74
+ 这是真实环境行为,不是插件 bug。
75
+
76
+ ## License
77
+
78
+ MIT
Binary file
Binary file
Binary file
@@ -0,0 +1,6 @@
1
+ # dsh-cua-linux bundle patch:把本插件插入 profile 的图层栈。
2
+ # 由 dsh.bundle.patch 消费;insert 的 name 必须是本包的包名,加载器从 profile 的
3
+ # node_modules 解析它并作为 Cordis 插件加载。
4
+ - insert:
5
+ - id: dsh-cua-linux
6
+ name: dsh-cua-linux