@amaster.ai/pi-computer-use-cua-driver-linux-x64 0.1.2 → 0.1.4
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 +4 -4
- package/bin/.version +1 -1
- package/bin/cua-cursor-theme +0 -0
- package/bin/cua-driver +2 -2
- package/bin/wayland-helper/README.md +54 -0
- package/bin/wayland-helper/install.sh +18 -3
- package/bin/wayland-helper/winrects@cua/extension.js +101 -1
- package/bin/wayland-helper/winrects@cua/metadata.json +1 -1
- package/package.json +2 -2
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.
|
|
3
|
+
This package redistributes the Linux runtime files from Cua Driver Rust 0.37.0 without modification.
|
|
4
4
|
|
|
5
|
-
- Release: https://github.com/trycua/cua/releases/tag/cua-driver-rs-v0.
|
|
6
|
-
- Asset: `cua-driver-rs-0.
|
|
7
|
-
- SHA256: `
|
|
5
|
+
- Release: https://github.com/trycua/cua/releases/tag/cua-driver-rs-v0.37.0
|
|
6
|
+
- Asset: `cua-driver-rs-0.37.0-linux-x86_64.tar.gz`
|
|
7
|
+
- SHA256: `d9421e143df6da3c695f5007f4db25fa619473d62965927e880c1dbfeeab1bf2`
|
|
8
8
|
- Upstream license: MIT; see `LICENSE.md`
|
package/bin/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
cua-driver-rs-v0.
|
|
1
|
+
cua-driver-rs-v0.37.0
|
package/bin/cua-cursor-theme
CHANGED
|
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:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 60265296 bytes
|
|
4
|
+
sha256: bbc8ef6a338d3e4206195afb40984bd58a9a7f333a7e35543443add0c4137a11
|
|
@@ -31,6 +31,18 @@ It exposes `org.cua.WinRects` on the session bus:
|
|
|
31
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
|
-
|
|
11
|
-
|
|
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
|
|
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();
|
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.
|
|
3
|
+
"version": "0.1.4",
|
|
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.
|
|
31
|
+
"cuaDriverVersion": "0.37.0"
|
|
32
32
|
}
|