dsh-plugin-linux-computer-use 0.6.1 → 0.6.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 CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.6.2 - 2026-11-28
2
+
3
+ - **A sequence no longer trips its own idle guard.** Injected events reset Mutter's idle timer, so the second step of a `sequence` used to be refused as "the user is at the keyboard (last input 0.0s ago)". Input we injected ourselves is now recognised for 2.5 s.
4
+ - **`click {text}` works on Wayland.** It used to require a screen rectangle, which GTK 4 and Chromium never publish, so every text click answered "no element whose name or text matches". It now falls back to the widget's own click action and reports `via: "accessibility-action"`.
5
+
1
6
  # Changelog
2
7
 
3
8
  ## 0.6.1 - 2026-11-28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-linux-computer-use",
3
- "version": "0.6.1",
3
+ "version": "0.6.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",
@@ -109,6 +109,16 @@ def controller(reload_layout: bool = False) -> cu_input.InputController:
109
109
  return INPUT
110
110
 
111
111
 
112
+ # Injected events reset Mutter's idle timer, so a sequence would trip the very
113
+ # guard its own first step triggered. Anything inside this window is our echo.
114
+ SELF_ECHO_S = 2.5
115
+ _LAST_INJECT = {"at": 0.0}
116
+
117
+
118
+ def _stamp_injection() -> None:
119
+ _LAST_INJECT["at"] = time.monotonic()
120
+
121
+
112
122
  def _guard_input(what: str, args: dict | None = None) -> None:
113
123
  """Refuse to inject input while the session is locked or the user is active.
114
124
 
@@ -140,11 +150,17 @@ def _guard_input(what: str, args: dict | None = None) -> None:
140
150
  )
141
151
 
142
152
  if os.environ.get("DSH_LINUX_CU_ALLOW_ACTIVE_INPUT") == "1":
153
+ _stamp_injection()
143
154
  return
144
155
  if args and args.get("allow_active_input"):
156
+ _stamp_injection()
145
157
  return
146
158
  idle = cu_sys.idle_ms()
147
159
  if idle is None or idle >= IDLE_GUARD_MS:
160
+ _stamp_injection()
161
+ return
162
+ if (time.monotonic() - _LAST_INJECT["at"]) < SELF_ECHO_S:
163
+ _stamp_injection()
148
164
  return
149
165
  raise ToolError(
150
166
  f"refusing to {what}: the user is at the keyboard (last input {idle / 1000:.1f}s ago), "
@@ -501,21 +517,45 @@ def tool_click(args: dict) -> dict:
501
517
  _guard_input("click", args)
502
518
  text = args.get("text")
503
519
  if text and args.get("x") is None and args.get("y") is None:
504
- hits = [
505
- hit for hit in A11Y.find(
506
- query=str(text),
507
- role=args.get("role"),
508
- app=args.get("app"),
509
- limit=5,
510
- )
511
- if hit.get("center")
512
- ]
520
+ hits = A11Y.find(
521
+ query=str(text),
522
+ role=args.get("role"),
523
+ app=args.get("app"),
524
+ limit=5,
525
+ )
513
526
  if not hits:
514
527
  raise ToolError(
515
528
  f"no element whose name or text matches {text!r}; "
516
529
  "try ui_find to see what is there, or click by coordinates"
517
530
  )
518
531
  best = hits[0]
532
+ if not best.get("center") and not best.get("rect"):
533
+ # Wayland toolkits publish no screen rectangle, so the widget's own
534
+ # action is the only way in.
535
+ try:
536
+ done = A11Y.action(best["ref"], "click")
537
+ except cu_a11y.A11yError:
538
+ try:
539
+ done = A11Y.action(best["ref"], None)
540
+ except cu_a11y.A11yError as error:
541
+ raise ToolError(
542
+ f"{text!r} matched {best.get('role')} {best['ref']}, but it has no "
543
+ f"on-screen rectangle and no clickable action ({error})"
544
+ ) from error
545
+ return {
546
+ "clicked": {
547
+ "ref": best["ref"],
548
+ "role": best.get("role"),
549
+ "matched": best.get("name") or str(text)[:60],
550
+ "via": "accessibility-action",
551
+ "action": (done or {}).get("action"),
552
+ }
553
+ }
554
+ if not best.get("center"):
555
+ raise ToolError(
556
+ f"{text!r} matched {best.get('role')} {best['ref']}, which has neither a "
557
+ "clickable action nor a usable rectangle"
558
+ )
519
559
  button = _button_name(args.get("button", 1))
520
560
  count = max(1, min(int(args.get("count", 1)), 3))
521
561
  controller().click(best["center"][0], best["center"][1], button=button, count=count)