@amaster.ai/pi-computer-use-cua-driver-linux-x64 0.1.1 → 0.1.3

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/SOURCE.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Cua Driver runtime
2
2
 
3
- This package redistributes the Linux runtime files from Cua Driver Rust 0.28.2 without modification.
3
+ This package redistributes the Linux runtime files from Cua Driver Rust 0.35.4 without modification.
4
4
 
5
- - Release: https://github.com/trycua/cua/releases/tag/cua-driver-rs-v0.28.2
6
- - Asset: `cua-driver-rs-0.28.2-linux-x86_64.tar.gz`
7
- - SHA256: `8f3e5b669e2bcd98d0eecc64f40640aac77f358b6332a06abc6ee79991620f7d`
5
+ - Release: https://github.com/trycua/cua/releases/tag/cua-driver-rs-v0.35.4
6
+ - Asset: `cua-driver-rs-0.35.4-linux-x86_64.tar.gz`
7
+ - SHA256: `1ec36fae1020879583dd424f4b3aa1f532bcac8417094b741729a2a70a29734e`
8
8
  - Upstream license: MIT; see `LICENSE.md`
package/bin/.version CHANGED
@@ -1 +1 @@
1
- cua-driver-rs-v0.28.2
1
+ cua-driver-rs-v0.35.4
Binary file
package/bin/cua-driver CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/cua-driver
3
- size: 50559360 bytes
4
- sha256: 3739101d072bdfdd83b7e70b3a16d9271f6eb124e7c5e69b3406f20f0910a4ca
3
+ size: 59606440 bytes
4
+ sha256: be267befd8f0ac294fced96cdf5763da19d3fb1526745fefd47274dea107a93e
@@ -1,4 +1,4 @@
1
- # cua WinRects — GNOME Shell helper extension (Wayland)
1
+ # cua WinRects: GNOME Shell helper extension (Wayland)
2
2
 
3
3
  A small GNOME Shell extension that lets cua-driver get **pixel coordinates**,
4
4
  activate an exact target window, capture the compositor stage, and draw the
@@ -7,30 +7,42 @@ these things globally.
7
7
 
8
8
  It exposes `org.cua.WinRects` on the session bus:
9
9
 
10
- - `GetVersion() -> uint` — a browser-sensitive API version. cua-driver only
10
+ - `GetVersion() -> uint`: a browser-sensitive API version. cua-driver only
11
11
  accepts it after resolving the immutable D-Bus owner and proving the owner is
12
12
  the current user's system-installed `gnome-shell` process.
13
- - `GetRects() -> json` — every window's frame geometry and surface-buffer
13
+ - `GetRects() -> json`: every window's frame geometry and surface-buffer
14
14
  origin. cua-driver combines the buffer origin with AT-SPI
15
15
  `CoordType::Window` per-widget coords: `screen = origin + window_xy`. This is
16
16
  the GNOME analogue of the X11 `_GTK_FRAME_EXTENTS` reconstruction (AT-SPI's
17
17
  `CoordType::Screen` is `(0,0)` for every widget on Mutter). Keeping the frame
18
18
  and buffer origins separate accounts for GTK client-side shadows.
19
- - `Activate(id) -> bool` — activate one Shell stable-sequence window and report
19
+ - `Activate(id) -> bool`: activate one Shell stable-sequence window and report
20
20
  whether the request was accepted. cua-driver verifies focus through a second
21
21
  `GetRects` snapshot before sending focus-bound portal/libei input, preventing
22
22
  input from leaking into whichever application happened to be focused.
23
- - `Capture() -> png_base64` — capture the compositor stage through Shell's
23
+ - `Capture() -> png_base64`: capture the compositor stage through Shell's
24
24
  screenshot API. cua-driver crops it with the same authoritative geometry.
25
- - `MoveCursor(x,y)` / `ClickPulse(x,y)` / `HideCursor()` — position and hide
25
+ - `MoveCursor(x,y)` / `ClickPulse(x,y)` / `HideCursor()`: position and hide
26
26
  the agent cursor as a Clutter actor on the compositor stage.
27
- - `SetCursorState(action,delivery,target,active)` — render the same 12 semantic
27
+ - `SetCursorState(action,delivery,target,active)`: render the same 12 semantic
28
28
  action states as the cross-platform `cua.default` cursor theme. Delivery and
29
29
  target context appears as host-owned chips in the session badge rather than
30
30
  pointer-relative theme artwork. This contract requires helper v8.
31
- - `SetCursorColor(fill_color)` — apply the stable per-session fill selected by
31
+ - `SetCursorColor(fill_color)`: apply the stable per-session fill selected by
32
32
  cua-driver. The helper validates the `#RRGGBB` value, updates the matching
33
33
  glow, and keeps a white pointer outline.
34
+ - `CaptureWindow(id,pid) -> png_base64` (API 9): snapshot one window's own
35
+ compositor actor (`paint_to_content`), not the stage, so a covering window
36
+ never shows and the target is not activated. `pid` 0 skips the owner check.
37
+ A 1x1 transparent clone keeps Mutter painting a fully covered window and
38
+ expires 4 s after the last capture. Refused while the screen is locked, for
39
+ minimized windows, and above 32 MiB.
40
+ - `CaptureWindowPreview(id,pid,max_dimension) -> (png_base64, width, height)`
41
+ (API 10): the same capture, downscaled on the GPU so its long edge is at
42
+ most `max_dimension` (1 to 4096). `width`/`height` are the window's
43
+ full-size pixels, which cua-driver reports as the original size. cua-driver
44
+ removes GNOME's per-capture `Creation Time` PNG chunk, so identical frames
45
+ are byte-identical.
34
46
 
35
47
  It runs in the shell's privileged context, so **no xdg-desktop-portal grant** is
36
48
  needed (unlike libei/RemoteDesktop).
@@ -49,6 +61,12 @@ still work when it is absent, but pixel geometry, the Shell cursor, and safe
49
61
  foreground portal input are unavailable. cua-driver refuses focus-bound input
50
62
  instead of injecting into an unverified target.
51
63
 
64
+ With helper API 9 or newer, cua-driver captures GNOME windows only through
65
+ `CaptureWindow`; if the helper refuses a window, the screenshot fails rather
66
+ than falling back to a stage crop that could show another app. With an older
67
+ helper it still crops the stage to the window frame, which shows whatever
68
+ covers the window. Re-run the installer to get per-window capture.
69
+
52
70
  The semantic cursor requires helper v8. When an older helper is still loaded,
53
71
  cua-driver does not draw its legacy cursor. Re-run the helper installer, then
54
72
  reload the GNOME session so the new compositor-owned artwork becomes active.
@@ -60,6 +78,42 @@ the public name between verification and an activation request. One exact
60
78
  target is activated only for the bounded operation, then the previously
61
79
  focused Shell window is restored and verified.
62
80
 
81
+ ## Versions and other apps that bundle the helper
82
+
83
+ The extension is identified by its UUID, `winrects@cua`, and serves the
84
+ session-bus name `org.cua.WinRects`. Other apps ship the same helper: T3 Code
85
+ bundles it with its Linux build of Cua Driver. Keeping one UUID is deliberate.
86
+ Two copies under different UUIDs would both be enabled and race for the same
87
+ bus name and object path, and which one answered would be undefined. With one
88
+ UUID there is exactly one installed copy per user, and the rules below let
89
+ any copy serve every client:
90
+
91
+ - `GetVersion()` returns an integer API version, and `metadata.json`
92
+ `"version"` carries the same number.
93
+ - API versions only add methods. A method never changes or disappears in a
94
+ later version, so a newer helper serves every older client. Clients gate
95
+ each feature on `GetVersion()`.
96
+ - A version number names one method set everywhere. Versions 9 and 10 were
97
+ first defined in T3 Code's Linux patch to Cua Driver 0.34.0
98
+ ([pingdotgg/t3code#16975](https://github.com/pingdotgg/t3code/pull/16975))
99
+ and are adopted here unchanged, so T3 Code's v10 and this v10 are
100
+ interchangeable. Coordinate any new number with apps that bundle the helper.
101
+ - Installers never downgrade. `install.sh` and the cua-driver installers keep
102
+ an installed helper whose version is newer than the bundled one, and say so.
103
+ `install.sh --force` replaces it anyway.
104
+
105
+ | Version | Adds |
106
+ | ------- | ------------------------------------------------------------------ |
107
+ | 8 | The semantic `SetCursorState` contract; shipped by Cua Driver 0.34 |
108
+ | 9 | `CaptureWindow(id,pid)` |
109
+ | 10 | `CaptureWindowPreview(id,pid,max_dimension)` |
110
+
111
+ Cua Driver 0.34 and earlier bundle v8 or older, and their installers overwrite
112
+ an installed helper unconditionally. Running one of those installers after an app
113
+ installed v10 downgrades the helper until the newer app reinstalls it.
114
+
115
+ ## Other compositors
116
+
63
117
  wlroots compositors such as Sway and labwc do not need it: cua-driver uses
64
118
  foreign-toplevel activation, virtual-pointer input, and layer-shell there.
65
119
 
@@ -3,12 +3,28 @@
3
3
  # geometry (for AT-SPI coordinate reconstruction) and renders the agent cursor
4
4
  # on GNOME Mutter Wayland, where a normal client can do neither. Best-effort:
5
5
  # cua-driver works without it (just no screen coords / no cursor on Mutter).
6
+ #
7
+ # Other apps bundle the same helper (same UUID, shared additive API versions),
8
+ # so a newer installed copy is kept. Pass --force to install this one anyway.
6
9
  set -euo pipefail
7
10
  UUID="winrects@cua"
8
11
  SRC="$(cd "$(dirname "$0")" && pwd)/$UUID"
9
12
  DEST="${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions/$UUID"
10
- mkdir -p "$DEST"
11
- cp -f "$SRC/metadata.json" "$SRC/extension.js" "$DEST/"
13
+ FORCE=0
14
+ if [ "${1:-}" = "--force" ]; then FORCE=1; fi
15
+ metadata_version() {
16
+ sed -n 's/.*"version"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$1" 2>/dev/null | head -n 1 || true
17
+ }
18
+ BUNDLED=$(metadata_version "$SRC/metadata.json")
19
+ INSTALLED=$(metadata_version "$DEST/metadata.json")
20
+ if [ "$FORCE" != 1 ] && [ "${INSTALLED:-0}" -gt "${BUNDLED:-0}" ]; then
21
+ echo "Keeping the installed $UUID v$INSTALLED: it is newer than this bundle's v${BUNDLED:-?}."
22
+ echo "Its API includes everything this cua-driver uses. Pass --force to replace it."
23
+ else
24
+ mkdir -p "$DEST"
25
+ cp -f "$SRC/metadata.json" "$SRC/extension.js" "$DEST/"
26
+ echo "Installed $UUID v${BUNDLED:-?} to $DEST."
27
+ fi
12
28
  # Add to the enabled set (preserves existing).
13
29
  cur=$(gsettings get org.gnome.shell enabled-extensions 2>/dev/null || echo "@as []")
14
30
  python3 - "$cur" "$UUID" <<'PY'
@@ -20,6 +36,5 @@ import subprocess
20
36
  subprocess.run(["gsettings","set","org.gnome.shell","enabled-extensions",str(l)])
21
37
  print("enabled-extensions ->", l)
22
38
  PY
23
- echo "Installed $UUID to $DEST."
24
39
  echo "GNOME Shell scans extensions only at startup, so log out/in (or restart the"
25
40
  echo "session) ONCE to load it. After that: gnome-extensions info $UUID should show State: ACTIVE."
@@ -3,16 +3,20 @@ import GLib from 'gi://GLib';
3
3
  import Shell from 'gi://Shell';
4
4
  import St from 'gi://St';
5
5
  import Clutter from 'gi://Clutter';
6
+ import Cogl from 'gi://Cogl';
6
7
  import Cairo from 'cairo';
7
8
  import * as Main from 'resource:///org/gnome/shell/ui/main.js';
8
9
  import { Extension } from 'resource:///org/gnome/shell/extensions/extension.js';
9
10
 
10
11
  Gio._promisify(Shell.Screenshot.prototype, 'screenshot');
12
+ Gio._promisify(Shell.Screenshot, 'composite_to_stream');
11
13
 
12
14
  const IFACE = `<node><interface name="org.cua.WinRects">
13
15
  <method name="GetVersion"><arg type="u" direction="out" name="version"/></method>
14
16
  <method name="GetRects"><arg type="s" direction="out" name="json"/></method>
15
17
  <method name="Capture"><arg type="s" direction="out" name="png_base64"/></method>
18
+ <method name="CaptureWindow"><arg type="u" direction="in" name="id"/><arg type="u" direction="in" name="pid"/><arg type="s" direction="out" name="png_base64"/></method>
19
+ <method name="CaptureWindowPreview"><arg type="u" direction="in" name="id"/><arg type="u" direction="in" name="pid"/><arg type="u" direction="in" name="max_dimension"/><arg type="s" direction="out" name="png_base64"/><arg type="u" direction="out" name="width"/><arg type="u" direction="out" name="height"/></method>
16
20
  <method name="Activate"><arg type="u" direction="in" name="id"/><arg type="b" direction="out" name="activated"/></method>
17
21
  <method name="MoveCursor"><arg type="i" direction="in" name="x"/><arg type="i" direction="in" name="y"/></method>
18
22
  <method name="ClickPulse"><arg type="i" direction="in" name="x"/><arg type="i" direction="in" name="y"/></method>
@@ -680,6 +684,7 @@ function drawBadgeChip(cr, glyph, filled, fillColor) {
680
684
 
681
685
  export default class WinRectsExtension extends Extension {
682
686
  enable() {
687
+ this._captureClones = new Map();
683
688
  this._impl = Gio.DBusExportedObject.wrapJSObject(IFACE, this);
684
689
  this._impl.export(Gio.DBus.session, '/org/cua/WinRects');
685
690
  this._nameId = Gio.bus_own_name(
@@ -822,6 +827,11 @@ export default class WinRectsExtension extends Extension {
822
827
  });
823
828
  }
824
829
  disable() {
830
+ for (const entry of this._captureClones.values()) {
831
+ GLib.source_remove(entry.timeout);
832
+ entry.clone.destroy();
833
+ }
834
+ this._captureClones.clear();
825
835
  if (this._frameId) {
826
836
  GLib.source_remove(this._frameId);
827
837
  this._frameId = 0;
@@ -851,7 +861,7 @@ export default class WinRectsExtension extends Extension {
851
861
  }
852
862
  }
853
863
  GetVersion() {
854
- return 8;
864
+ return 10;
855
865
  }
856
866
  GetRects() {
857
867
  const actors = global.get_window_actors();
@@ -891,6 +901,96 @@ export default class WinRectsExtension extends Extension {
891
901
  }
892
902
  return JSON.stringify(out);
893
903
  }
904
+ CaptureWindowAsync([id, pid], invocation) {
905
+ return this._captureWindow(id, pid, 0, invocation);
906
+ }
907
+ CaptureWindowPreviewAsync([id, pid, maxDimension], invocation) {
908
+ if (maxDimension < 1 || maxDimension > 4096) {
909
+ invocation.return_dbus_error('org.cua.WinRects.InvalidSize', 'Invalid preview size');
910
+ return;
911
+ }
912
+ return this._captureWindow(id, pid, maxDimension, invocation);
913
+ }
914
+ async _captureWindow(id, pid, maxDimension, invocation) {
915
+ let stream;
916
+ try {
917
+ if (Main.sessionMode.isLocked || Main.sessionMode.isGreeter)
918
+ throw new Error('Desktop is unavailable');
919
+ const actor = global.get_window_actors().find(
920
+ candidate => candidate.meta_window?.get_stable_sequence() === id);
921
+ const window = actor?.meta_window;
922
+ if (!window || (pid !== 0 && window.get_pid() !== pid) || window.minimized)
923
+ throw new Error('Target window is unavailable');
924
+ // A mapped clone keeps Mutter from suspending a fully covered source.
925
+ // It paints no pixels and expires when capture requests stop.
926
+ let entry = this._captureClones.get(id);
927
+ if (entry) GLib.source_remove(entry.timeout);
928
+ else {
929
+ const clone = new Clutter.Clone({source: actor, opacity: 0, width: 1, height: 1, reactive: false});
930
+ global.stage.add_child(clone);
931
+ entry = {clone, timeout: 0};
932
+ this._captureClones.set(id, entry);
933
+ }
934
+ entry.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 4000, () => {
935
+ entry.clone.destroy();
936
+ this._captureClones.delete(id);
937
+ return GLib.SOURCE_REMOVE;
938
+ });
939
+ // Snapshot this actor, never the stage. Covered windows retain their own
940
+ // content; neither activation nor a desktop crop is needed.
941
+ const frame = window.get_frame_rect();
942
+ const buffer = window.get_buffer_rect();
943
+ const scale = actor.get_resource_scale();
944
+ const content = actor.paint_to_content(null);
945
+ const texture = content?.get_texture();
946
+ if (!texture || !Number.isFinite(scale) || scale <= 0)
947
+ throw new Error('Window content is unavailable');
948
+ const x = Math.round((frame.x - buffer.x) * scale);
949
+ const y = Math.round((frame.y - buffer.y) * scale);
950
+ const width = Math.round(frame.width * scale);
951
+ const height = Math.round(frame.height * scale);
952
+ if (x < 0 || y < 0 || width <= 0 || height <= 0 ||
953
+ x + width > texture.get_width() || y + height > texture.get_height())
954
+ throw new Error('Window content does not match its frame');
955
+ stream = Gio.MemoryOutputStream.new_resizable();
956
+ let captureTexture = texture;
957
+ let captureX = x, captureY = y, captureWidth = width, captureHeight = height;
958
+ if (maxDimension > 0 && Math.max(width, height) > maxDimension) {
959
+ const ratio = maxDimension / Math.max(width, height);
960
+ captureWidth = Math.max(1, Math.round(width * ratio));
961
+ captureHeight = Math.max(1, Math.round(height * ratio));
962
+ const context = global.stage.get_context().get_backend().get_cogl_context();
963
+ captureTexture = Cogl.Texture2D.new_with_size(context, captureWidth, captureHeight);
964
+ const framebuffer = Cogl.Offscreen.new_with_texture(captureTexture);
965
+ framebuffer.allocate();
966
+ framebuffer.set_viewport(0, 0, captureWidth, captureHeight);
967
+ framebuffer.orthographic(0, 0, captureWidth, captureHeight, -1, 1);
968
+ const pipeline = Cogl.Pipeline.new(context);
969
+ pipeline.set_layer_texture(0, texture);
970
+ framebuffer.draw_textured_rectangle(pipeline, 0, 0, captureWidth, captureHeight,
971
+ x / texture.get_width(), y / texture.get_height(),
972
+ (x + width) / texture.get_width(), (y + height) / texture.get_height());
973
+ framebuffer.finish();
974
+ captureX = 0;
975
+ captureY = 0;
976
+ }
977
+ await Shell.Screenshot.composite_to_stream(
978
+ captureTexture, captureX, captureY, captureWidth, captureHeight, 1, null, 0, 0, 1, stream);
979
+ stream.close(null);
980
+ if (Main.sessionMode.isLocked || Main.sessionMode.isGreeter)
981
+ throw new Error('Desktop became unavailable');
982
+ if (stream.get_data_size() > 32 * 1024 * 1024)
983
+ throw new Error('Window capture is too large');
984
+ const encoded = GLib.base64_encode(stream.steal_as_bytes().get_data());
985
+ invocation.return_value(maxDimension > 0
986
+ ? new GLib.Variant('(suu)', [encoded, width, height])
987
+ : new GLib.Variant('(s)', [encoded]));
988
+ } catch (error) {
989
+ invocation.return_dbus_error('org.cua.WinRects.CaptureFailed', String(error));
990
+ } finally {
991
+ if (stream && !stream.is_closed()) stream.close(null);
992
+ }
993
+ }
894
994
  async CaptureAsync(_params, invocation) {
895
995
  try {
896
996
  const shooter = new Shell.Screenshot();
@@ -3,5 +3,5 @@
3
3
  "name": "WinRects",
4
4
  "description": "Expose window geometry, capture, cursor, and verified activation for cua-driver on Wayland.",
5
5
  "shell-version": ["45", "46", "47", "48", "49", "50"],
6
- "version": 8
6
+ "version": 10
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amaster.ai/pi-computer-use-cua-driver-linux-x64",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Cua Driver runtime for pi-computer-use on Linux x64",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -28,5 +28,5 @@
28
28
  "./bin/wayland-helper/install.sh"
29
29
  ]
30
30
  },
31
- "cuaDriverVersion": "0.28.2"
31
+ "cuaDriverVersion": "0.35.4"
32
32
  }