dsh-plugin-linux-computer-use 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/CHANGELOG.md +19 -0
- package/README.md +18 -0
- package/docs/RELEASING.md +56 -0
- package/package.json +5 -5
- package/server/cu_a11y.py +43 -0
- package/server/cu_input.py +25 -1
- package/server/linux_desktop_mcp.py +18 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.1 - 2026-11-25
|
|
4
|
+
|
|
5
|
+
- fix: send the complete `input_absinfo` when creating the absolute pointer.
|
|
6
|
+
libinput rejected the device with "kernel bug: kernel has only x or y
|
|
7
|
+
resolution, not both" and silently dropped every motion and button event, so
|
|
8
|
+
clicks did nothing while the keyboard and the wheel kept working.
|
|
9
|
+
|
|
10
|
+
## 0.1.1 - 2026-11-25
|
|
11
|
+
|
|
12
|
+
- `desktop_status` gained `reset_input`, which recreates the virtual keyboard,
|
|
13
|
+
pointer and wheel devices. The compositor can stop honouring devices that
|
|
14
|
+
were created before the desktop session restarted, and this is the cheapest
|
|
15
|
+
way to recover without restarting the server.
|
|
16
|
+
- The accessibility tree no longer takes the whole server down when AT-SPI is
|
|
17
|
+
unreachable: the reachability test runs in a throwaway child process, so a
|
|
18
|
+
dead accessibility bus turns into a normal tool error instead of a crash.
|
|
19
|
+
Logging out and back in while the server keeps running is exactly the case
|
|
20
|
+
that used to kill it.
|
|
21
|
+
|
|
3
22
|
## 0.1.0
|
|
4
23
|
|
|
5
24
|
First release.
|
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# dsh-plugin-linux-computer-use
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-plugin-linux-computer-use)
|
|
4
|
+
[](https://github.com/BeiningCheng/dsh-plugin-linux-computer-use/releases)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
3
7
|
**Computer Use for Ubuntu / GNOME Wayland, bridged into DeepSeek Harness as MCP tools.**
|
|
4
8
|
|
|
5
9
|
给 DeepSeek Harness 装上"手和眼睛":截屏、UI 树、鼠标键盘、剪贴板、进程、系统设置,全部以 `mcp__linux__*` 工具暴露给模型;外带一个 `linux_mcp_doctor` 诊断工具。**默认关闭**,在插件面板里手动打开。
|
|
@@ -98,6 +102,20 @@ python3 -u $MCP --clear-unlock-password # 从钥匙环删除
|
|
|
98
102
|
|
|
99
103
|
## 故障排查
|
|
100
104
|
|
|
105
|
+
### Pointer events are ignored
|
|
106
|
+
|
|
107
|
+
On rare sessions GNOME keeps the virtual pointer device open but stops
|
|
108
|
+
honouring its motion: keyboard and scroll still work, clicks do nothing.
|
|
109
|
+
|
|
110
|
+
1. `desktop_status` with `reset_input: true` recreates the devices
|
|
111
|
+
2. if that does not help, reboot the machine (a logout/login is not always
|
|
112
|
+
enough, because `dsh web` can survive it through systemd user lingering)
|
|
113
|
+
3. `dsh web` itself must run inside the current desktop session: its
|
|
114
|
+
`DBUS_SESSION_BUS_ADDRESS` is inherited, so an old process cannot reach the
|
|
115
|
+
accessibility bus or the portal any more
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
101
119
|
```bash
|
|
102
120
|
python3 -u ~/.local/share/dsh-linux-computer-use/linux_desktop_mcp.py --selftest
|
|
103
121
|
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
Maintainer notes. The npm account (`beiningcheng`) enforces **2FA with a security key only** —
|
|
4
|
+
TOTP cannot be configured on it any more, so every publish goes through one browser approval.
|
|
5
|
+
|
|
6
|
+
## Publish a new version
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# 1. bump the version and add a CHANGELOG entry
|
|
10
|
+
npm version patch # or minor / major, then edit CHANGELOG.md
|
|
11
|
+
|
|
12
|
+
# 2. publish — this needs a real TTY, so run it in a terminal, not in a pipe
|
|
13
|
+
HTTPS_PROXY=http://127.0.0.1:7897 HTTP_PROXY=http://127.0.0.1:7897 \
|
|
14
|
+
NODE_OPTIONS=--dns-result-order=ipv4first \
|
|
15
|
+
npm publish --cache /tmp/npmcache
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
When npm prints
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
Authenticate your account at:
|
|
22
|
+
https://www.npmjs.com/auth/cli/<uuid>
|
|
23
|
+
Press ENTER to open in the browser...
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
press **Enter**, then in the opened page click **Use security key** and complete the system
|
|
27
|
+
prompt. The CLI publishes as soon as the browser flow succeeds.
|
|
28
|
+
|
|
29
|
+
Notes that cost time to rediscover:
|
|
30
|
+
|
|
31
|
+
- The registry is IPv6-only in its DNS answer and this machine has no working IPv6 route, so
|
|
32
|
+
`NODE_OPTIONS=--dns-result-order=ipv4first` plus the local proxy is mandatory.
|
|
33
|
+
- `npm publish` in a non-TTY (piped) shell prints the auth URL as `***` and can never finish.
|
|
34
|
+
- A granular access token without *Bypass 2FA* gets `403 ... Two-factor authentication or
|
|
35
|
+
granular access token with bypass 2fa enabled is required to publish packages`.
|
|
36
|
+
- The registry briefly exposes a `0.0.0-stage` placeholder while a version is being processed;
|
|
37
|
+
it is not `latest` and can be ignored.
|
|
38
|
+
|
|
39
|
+
## GitHub release
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git push origin main
|
|
43
|
+
git tag -a v<version> -m "v<version>"
|
|
44
|
+
git push <remote-with-token> v<version>
|
|
45
|
+
npm pack --cache /tmp/npmcache
|
|
46
|
+
# then upload the tarball as a release asset through the API
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Marketplace listing
|
|
50
|
+
|
|
51
|
+
`awesome-dsh-plugin` takes one YAML file per plugin at
|
|
52
|
+
`data/plugins/<owner>__<repo>.yml` (see the repository's contributing guide). Gates:
|
|
53
|
+
|
|
54
|
+
- `package.json` must declare `dsh.bundle`
|
|
55
|
+
- the repository must be **at least 24 hours old**
|
|
56
|
+
- the repository must carry the `dsh-plugin` topic
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-linux-computer-use",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Computer Use for a Wayland Linux desktop in DeepSeek Harness: screenshots, UI tree, pointer and keyboard input, clipboard, processes and settings, bridged as mcp__linux__* tools. · 让 DSH 接管 Ubuntu/GNOME 桌面:截屏、UI 树、鼠标键盘、剪贴板、进程与系统设置。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,13 +48,13 @@
|
|
|
48
48
|
},
|
|
49
49
|
"repository": {
|
|
50
50
|
"type": "git",
|
|
51
|
-
"url": "git+https://github.com/
|
|
51
|
+
"url": "git+https://github.com/BeiningCheng/dsh-plugin-linux-computer-use.git"
|
|
52
52
|
},
|
|
53
|
-
"homepage": "https://github.com/
|
|
53
|
+
"homepage": "https://github.com/BeiningCheng/dsh-plugin-linux-computer-use#readme",
|
|
54
54
|
"bugs": {
|
|
55
|
-
"url": "https://github.com/
|
|
55
|
+
"url": "https://github.com/BeiningCheng/dsh-plugin-linux-computer-use/issues"
|
|
56
56
|
},
|
|
57
|
-
"author": "Beining Cheng
|
|
57
|
+
"author": "Beining Cheng",
|
|
58
58
|
"dsh": {
|
|
59
59
|
"bundle": {
|
|
60
60
|
"patch": "./cordis.patch.yml"
|
package/server/cu_a11y.py
CHANGED
|
@@ -15,6 +15,8 @@ unresponsive application must not hang the whole server.
|
|
|
15
15
|
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
|
|
18
|
+
import subprocess
|
|
19
|
+
import sys
|
|
18
20
|
import time
|
|
19
21
|
|
|
20
22
|
import gi
|
|
@@ -28,6 +30,37 @@ STATE_FLAGS = (
|
|
|
28
30
|
)
|
|
29
31
|
|
|
30
32
|
|
|
33
|
+
_PROBE_CACHE: "list[bool]" = []
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def a11y_reachable() -> bool:
|
|
37
|
+
"""True when Atspi.init() can run without aborting this process.
|
|
38
|
+
|
|
39
|
+
libatspi calls g_error() when it cannot reach the accessibility bus, which
|
|
40
|
+
kills the whole process instead of raising. The only safe test is to try it
|
|
41
|
+
in a throwaway child, so do that once and cache the answer.
|
|
42
|
+
"""
|
|
43
|
+
# Only a positive result is cached: the accessibility bus starts a moment
|
|
44
|
+
# after the desktop session does, so a failure now can become a success a
|
|
45
|
+
# second later.
|
|
46
|
+
if _PROBE_CACHE:
|
|
47
|
+
return _PROBE_CACHE[0]
|
|
48
|
+
code = (
|
|
49
|
+
"import gi;gi.require_version('Atspi','2.0');"
|
|
50
|
+
"from gi.repository import Atspi;Atspi.init();print('ok')"
|
|
51
|
+
)
|
|
52
|
+
try:
|
|
53
|
+
proc = subprocess.run(
|
|
54
|
+
[sys.executable, "-c", code], capture_output=True, timeout=20, check=False
|
|
55
|
+
)
|
|
56
|
+
ok = proc.returncode == 0 and b"ok" in proc.stdout
|
|
57
|
+
except Exception: # noqa: BLE001
|
|
58
|
+
ok = False
|
|
59
|
+
if ok:
|
|
60
|
+
_PROBE_CACHE.append(True)
|
|
61
|
+
return ok
|
|
62
|
+
|
|
63
|
+
|
|
31
64
|
class A11yError(RuntimeError):
|
|
32
65
|
"""The accessibility tree could not be read or the element is gone."""
|
|
33
66
|
|
|
@@ -120,6 +153,16 @@ class A11y:
|
|
|
120
153
|
def start(self) -> None:
|
|
121
154
|
if self._started:
|
|
122
155
|
return
|
|
156
|
+
# libatspi aborts the whole process (dbind-ERROR) when the session bus
|
|
157
|
+
# is gone, which is exactly what happens after the user logs out and
|
|
158
|
+
# back in while this server keeps running. Check first so the tools can
|
|
159
|
+
# report a fixable error instead of the server dying.
|
|
160
|
+
if not a11y_reachable():
|
|
161
|
+
raise A11yError(
|
|
162
|
+
"the accessibility bus is unreachable: this server has no working "
|
|
163
|
+
"session D-Bus connection. Restart the app that launched it (dsh web) "
|
|
164
|
+
"from a terminal in the current desktop session."
|
|
165
|
+
)
|
|
123
166
|
try:
|
|
124
167
|
# Tighten the D-Bus timeouts used for tree queries: one hung
|
|
125
168
|
# application must not stall a whole snapshot. 1s is far above the
|
package/server/cu_input.py
CHANGED
|
@@ -187,7 +187,10 @@ class UinputDevice:
|
|
|
187
187
|
def enable_abs(self, code: int, minimum: int, maximum: int) -> "UinputDevice":
|
|
188
188
|
fcntl.ioctl(self.fd, UI_SET_ABSBIT, code)
|
|
189
189
|
# struct uinput_abs_setup { __u16 code; __u16 pad; struct input_absinfo; }
|
|
190
|
-
|
|
190
|
+
# input_absinfo carries six ints (value, min, max, fuzz, flat, resolution);
|
|
191
|
+
# leaving one out makes libinput drop the device with "kernel has only x or
|
|
192
|
+
# y resolution, not both".
|
|
193
|
+
payload = struct.pack("HHiiiiii", code, 0, 0, minimum, maximum, 0, 0, 0)
|
|
191
194
|
fcntl.ioctl(self.fd, UI_ABS_SETUP, payload)
|
|
192
195
|
return self
|
|
193
196
|
|
|
@@ -256,6 +259,21 @@ class UinputBackend:
|
|
|
256
259
|
def available(cls, uinput_path: str = DEFAULT_UINPUT) -> bool:
|
|
257
260
|
return os.access(uinput_path, os.R_OK | os.W_OK)
|
|
258
261
|
|
|
262
|
+
def reset(self) -> None:
|
|
263
|
+
"""Drop every uinput device so the next call recreates them.
|
|
264
|
+
|
|
265
|
+
Useful after a compositor restart: mutter can stop honouring a
|
|
266
|
+
virtual pointer that was created before the session restarted.
|
|
267
|
+
"""
|
|
268
|
+
for attribute in ("_pointer", "_wheel", "_keyboard"):
|
|
269
|
+
device = getattr(self, attribute, None)
|
|
270
|
+
if device is not None:
|
|
271
|
+
try:
|
|
272
|
+
device.close()
|
|
273
|
+
except Exception: # noqa: BLE001
|
|
274
|
+
pass
|
|
275
|
+
setattr(self, attribute, None)
|
|
276
|
+
|
|
259
277
|
# -- devices ----------------------------------------------------------- #
|
|
260
278
|
def pointer(self) -> UinputDevice:
|
|
261
279
|
if self._pointer is None:
|
|
@@ -459,6 +477,12 @@ class InputController:
|
|
|
459
477
|
def backend_name(self) -> str:
|
|
460
478
|
return "uinput" if isinstance(self.backend, UinputBackend) else "ydotool"
|
|
461
479
|
|
|
480
|
+
def reset_input(self) -> None:
|
|
481
|
+
"""Recreate the injection devices (used after a session restart)."""
|
|
482
|
+
reset = getattr(self.backend, "reset", None)
|
|
483
|
+
if reset is not None:
|
|
484
|
+
reset()
|
|
485
|
+
|
|
462
486
|
# -- pointer ----------------------------------------------------------- #
|
|
463
487
|
def move(self, x: int, y: int) -> None:
|
|
464
488
|
self.move_to(x, y)
|
|
@@ -487,8 +487,11 @@ def tool_desktop_status(args: dict) -> dict:
|
|
|
487
487
|
except cu_display.PortalError as error:
|
|
488
488
|
status["display"] = {"error": str(error)}
|
|
489
489
|
try:
|
|
490
|
-
|
|
491
|
-
|
|
490
|
+
active = controller()
|
|
491
|
+
if args.get("reset_input"):
|
|
492
|
+
active.reset_input()
|
|
493
|
+
status["input_reset"] = True
|
|
494
|
+
status["input"] = {"backend": active.backend_name, "ready": True}
|
|
492
495
|
except Exception as error: # noqa: BLE001
|
|
493
496
|
status["input"] = {"ready": False, "error": str(error)}
|
|
494
497
|
token = cu_display.ScreencastSession.load_token()
|
|
@@ -898,7 +901,19 @@ TOOLS: list[dict] = [
|
|
|
898
901
|
"Self-check of the desktop server: input backend, capture permission token, "
|
|
899
902
|
"accessibility reachability and optional helper binaries."
|
|
900
903
|
),
|
|
901
|
-
"inputSchema": {
|
|
904
|
+
"inputSchema": {
|
|
905
|
+
"type": "object",
|
|
906
|
+
"properties": {
|
|
907
|
+
"reset_input": {
|
|
908
|
+
"type": "boolean",
|
|
909
|
+
"description": (
|
|
910
|
+
"Recreate the virtual input devices before reporting. Use it after the "
|
|
911
|
+
"desktop session restarted (log out and back in): the compositor can stop "
|
|
912
|
+
"honouring pointer devices that were created before the restart."
|
|
913
|
+
),
|
|
914
|
+
},
|
|
915
|
+
},
|
|
916
|
+
},
|
|
902
917
|
"handler": tool_desktop_status,
|
|
903
918
|
},
|
|
904
919
|
]
|