@agent-sh/computer-use-linux 0.7.37 → 0.7.39

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/README.md CHANGED
@@ -185,10 +185,10 @@ Validated manually on Ubuntu 25.10 (GNOME Shell 50.1, Wayland). niri window list
185
185
  | KDE Plasma / KWin | temporary KWin DBus scripting | Lists and focuses windows through Plasma 5 or 6 `org.kde.KWin` scripting APIs when the session bus exposes them. IDs are derived from the KWin window UUID, stay the same for a window across calls, and fit JavaScript integers. |
186
186
  | Hyprland | `hyprctl clients -j` and `hyprctl dispatch focuswindow` | Requires `hyprctl` in the desktop session. With `COMPUTER_USE_LINUX_HYPRLAND_BACKGROUND=1`, targeted keyboard input uses `send_key_state` and targeted capture uses `grim -T`, so neither focuses the window. |
187
187
  | niri | `niri msg` with a direct JSON IPC fallback | Lists toplevels and focuses exact window IDs. Export the session's `NIRI_SOCKET`; otherwise discovery requires an unambiguous socket matching `WAYLAND_DISPLAY`. The fallback works without the `niri` binary. Missing positions remain `null`; bounds are omitted if output scaling is unknown or mixed. |
188
- | i3, Sway | `i3-msg`; on i3, optional `xprop` for PID hydration | Lists and focuses windows over the active i3 or Sway IPC socket. On Sway this covers native Wayland and Xwayland windows, with pids from the tree. X11 windows keep their X11 id; a native Wayland window on Sway gets 2^32 plus its container id, so the two never collide. |
188
+ | i3, Sway | `i3-msg`, or `swaymsg` when i3 is not installed; on i3, optional `xprop` for PID hydration | Lists and focuses windows over the active i3 or Sway IPC socket. On Sway this covers native Wayland and Xwayland windows, with pids from the tree, and bounds scaled to capture pixels when every output has the same scale (left out with mixed scales). The socket is the first live one of `I3SOCK` and `SWAYSOCK`, then the newest i3 socket, then the newest Sway socket in `XDG_RUNTIME_DIR`. X11 windows keep their X11 id; a native Wayland window on Sway gets 2^32 plus its container id, so the two never collide. |
189
189
  | labwc with Selkies IPC | `$XDG_RUNTIME_DIR/labwc.sock` | Requires the Selkies IPC patch; stock labwc has no such socket. Lists windows and focuses unique app-id/title matches through `wlr-foreign-toplevel-management`. IDs include pid, app id and title, fit JavaScript integers, and change when the title changes. Ambiguous windows are rejected. Bounds are omitted because the IPC does not expose output scaling. |
190
190
  | COSMIC Wayland | `computer-use-linux-cosmic` helper | Installed automatically by `./install.sh`, `cargo install`, and npm. For custom/manual layouts, put the helper next to the main binary, on `PATH`, or point `COMPUTER_USE_LINUX_COSMIC_HELPER` at it. The on-screen indicator was validated here (three outputs, mixed fractional scaling). |
191
- | Other wlroots compositors (stock labwc, phoc, river-classic) | `zwlr_foreign_toplevel_manager_v1` on `WAYLAND_DISPLAY` | Lists toplevels with title, app id, and activated/minimized state, and focuses unique app-id/title matches. The protocol reports no pids or bounds. IDs derive from the app id and title, fit JavaScript integers, and change when the title changes; windows sharing both are rejected for exact focus. On Sway it answers only when the i3 backend does not: when `i3-msg` is missing, cannot reach the IPC socket, or lists no windows. Compositors that do not advertise the protocol, such as Cage, are not supported. |
191
+ | Other wlroots compositors (stock labwc, phoc, river-classic) | `zwlr_foreign_toplevel_manager_v1` on `WAYLAND_DISPLAY` | Lists toplevels with title, app id, and activated/minimized state, and focuses unique app-id/title matches. The protocol reports no pids or bounds. IDs derive from the app id and title, fit JavaScript integers, and change when the title changes; windows sharing both are rejected for exact focus. On Sway it answers only when the i3 backend does not: when neither `i3-msg` nor `swaymsg` is installed, the IPC socket cannot be reached, or it lists no windows. Compositors that do not advertise the protocol, such as Cage, are not supported. |
192
192
  | Generic X11 / XFCE / other EWMH WMs | `wmctrl` plus `xprop` | Lists, focuses, moves, and resizes windows; keyboard input prefers `xdotool`/XTEST, and scroll uses xdotool wheel buttons. Window origins are read from the X server, since `wmctrl -lG` counts the frame offset twice. |
193
193
 
194
194
  If you run on a desktop not covered above, or a covered backend does not come up cleanly, please open an issue with the output of `computer-use-linux doctor` so we can extend the matrix honestly.
@@ -500,13 +500,13 @@ bundle): `CUL_GNOME_EXTENSION_UUID`, `CUL_DBUS_SERVICE`, and
500
500
  UUID and DBus endpoint in both the Rust probes and the generated extension
501
501
  files.
502
502
 
503
- **npm wrapper** (set during `npm install`, or before running):
503
+ **npm wrapper** (set during `npm install`, or before running). The package's install script downloads the release binaries. When npm skipped it (npm 12 runs only install scripts it is told to allow), the wrapper runs the same download on first launch, with its output on stderr. A download that receives no data for 30 s fails:
504
504
 
505
505
  | Variable | Effect |
506
506
  | --- | --- |
507
507
  | `COMPUTER_USE_LINUX_BIN` | Run this absolute binary path instead of the one bundled by the npm package. Relative paths are ignored. |
508
508
  | `COMPUTER_USE_LINUX_DOWNLOAD_BASE` | Override the GitHub release base URL the installer downloads from (mirrors, air-gapped hosts). |
509
- | `COMPUTER_USE_LINUX_SKIP_DOWNLOAD=1` | Skip the post-install binary download entirely. |
509
+ | `COMPUTER_USE_LINUX_SKIP_DOWNLOAD=1` | Skip the binary download entirely, at install and at first launch. |
510
510
  | `COMPUTER_USE_LINUX_LOCAL_BINARY` / `…_LOCAL_COSMIC_HELPER` / `…_LOCAL_INDICATOR` | Install from a local build instead of downloading (used by CI and local testing). |
511
511
 
512
512
  ## Architecture
@@ -596,7 +596,7 @@ preserves application accessibility trees.
596
596
  - **`input.ydotool.ok = false` with an unsupported CLI message** — install ydotool 1.0.3 or newer. A running daemon or socket alone is not enough; `doctor` verifies the raw key, wheel, stdin typing, and absolute-movement command family before advertising the backend.
597
597
  - **`input.uinput.ok = false`** — `/dev/uinput` isn't accessible to your user. Fix: add yourself to the `input` group (`sudo usermod -aG input $USER`) and re-login. On distros that ship `uinput` as a kernel module without auto-loading it, add `uinput` to `/etc/modules-load.d/`. Direct uinput supplies absolute pointer input only, so `doctor` also requires a keyboard-capable portal, xdotool, or ydotool backend.
598
598
  - **Portal calls hang or time out** — `xdg-desktop-portal` or its backend (`-gnome`, `-gtk`, `-kde`, `-wlr`) crashed. Fix: check `journalctl --user -u xdg-desktop-portal -u xdg-desktop-portal-gnome --since '5 min ago'` and restart the relevant unit.
599
- - **KWin / Hyprland / niri / i3 / COSMIC / X11 windowing is unavailable** — check `doctor.windowing.backends`. KWin needs session-bus scripting; Hyprland needs `hyprctl`; niri needs the session's `NIRI_SOCKET`, or an unambiguous matching `niri.*.sock` in `XDG_RUNTIME_DIR`; i3 needs `i3-msg` and its IPC socket; generic X11 needs `wmctrl` and `xprop`. COSMIC needs `computer-use-linux-cosmic`, which the standard installers provide automatically; if you copied binaries by hand, copy the helper too or set `COMPUTER_USE_LINUX_COSMIC_HELPER`.
599
+ - **KWin / Hyprland / niri / i3 / COSMIC / X11 windowing is unavailable** — check `doctor.windowing.backends`. KWin needs session-bus scripting; Hyprland needs `hyprctl`; niri needs the session's `NIRI_SOCKET`, or an unambiguous matching `niri.*.sock` in `XDG_RUNTIME_DIR`; i3 and Sway need `i3-msg` or `swaymsg` and the IPC socket; generic X11 needs `wmctrl` and `xprop`. COSMIC needs `computer-use-linux-cosmic`, which the standard installers provide automatically; if you copied binaries by hand, copy the helper too or set `COMPUTER_USE_LINUX_COSMIC_HELPER`.
600
600
  - **niri windows list correctly but targeted screenshots or relative clicks fail** — niri may omit window positions, leaving `bounds.x`/`bounds.y` as `null`. Unknown or mixed output scaling also leaves bounds unavailable. Focus the window first (`activate_window`) and use full-screen coordinates after checking a fresh screenshot.
601
601
  - **Screenshots return black frames on multi-monitor setups** — known portal / compositor edge case. Use `get_app_state` with `include_screenshot: false` and rely on AT-SPI until the portal backend is healthy.
602
602
  - **`type_text` types into the wrong window** — pass an explicit target (`window_id`, `pid`, `wm_class`, `title`, or for terminals `tty` / `terminal_pid` / `terminal_command` / `terminal_cwd`). Without a target, input goes to whatever window currently has compositor focus.
@@ -3,7 +3,7 @@
3
3
 
4
4
  const fs = require('node:fs');
5
5
  const path = require('node:path');
6
- const { spawn } = require('node:child_process');
6
+ const { spawn, spawnSync } = require('node:child_process');
7
7
 
8
8
  const binaryName = `computer-use-linux-${process.platform}-${process.arch}`;
9
9
  const bundledBinary = path.join(__dirname, binaryName);
@@ -11,11 +11,20 @@ const binary = process.env.COMPUTER_USE_LINUX_BIN || bundledBinary;
11
11
  const bundledCosmicHelper = path.join(__dirname, 'computer-use-linux-cosmic');
12
12
  const bundledIndicator = path.join(__dirname, 'computer-use-linux-indicator');
13
13
 
14
- if (!fs.existsSync(binary)) {
14
+ // npm 12 skips install scripts it has not been told to allow, so a global
15
+ // install can arrive without the native binary. Run the installer on first
16
+ // launch. Its output goes to stderr: stdout is the MCP channel.
17
+ function installBinary() {
18
+ const installer = path.join(__dirname, '..', 'install.js');
19
+ const result = spawnSync(process.execPath, [installer], { stdio: ['ignore', 2, 2] });
20
+ return result.status === 0 && fs.existsSync(binary);
21
+ }
22
+
23
+ if (!fs.existsSync(binary) && (process.env.COMPUTER_USE_LINUX_BIN || !installBinary())) {
15
24
  console.error(
16
25
  [
17
26
  `computer-use-linux binary not found: ${binary}`,
18
- 'Reinstall the package, run `npm rebuild computer-use-linux`, or set COMPUTER_USE_LINUX_BIN.',
27
+ 'Run `node npm/install.js` in the package directory, allow its install script, or set COMPUTER_USE_LINUX_BIN.',
19
28
  ].join('\n')
20
29
  );
21
30
  process.exit(127);
package/npm/install.js CHANGED
@@ -18,36 +18,73 @@ const binDir = path.join(__dirname, 'bin');
18
18
  const binaryPath = path.join(binDir, `computer-use-linux-${process.platform}-${process.arch}`);
19
19
  const cosmicHelperPath = path.join(binDir, 'computer-use-linux-cosmic');
20
20
  const indicatorPath = path.join(binDir, 'computer-use-linux-indicator');
21
+ // A request that receives no bytes for this long is stalled. The wrapper
22
+ // installs on first launch, so a stalled download would otherwise hold the
23
+ // MCP client's startup open and outlive it when the client gives up.
24
+ const IDLE_TIMEOUT_MS = 30_000;
25
+
26
+ // Messages can carry paths and URLs from the environment. JSON string
27
+ // escaping turns CR, LF and the other C0 control characters (U+0000-U+001F)
28
+ // into visible escapes, so a value with a newline cannot forge a log line.
29
+ function say(write, message) {
30
+ const safe = JSON.stringify(String(message)).slice(1, -1);
31
+ write(`[computer-use-linux] ${safe}`);
32
+ }
21
33
 
22
34
  function fail(message) {
23
- console.error(`[computer-use-linux] ${message}`);
35
+ say(console.error, message);
24
36
  process.exit(1);
25
37
  }
26
38
 
39
+ // Write next to the destination, then rename over it, so a server starting
40
+ // at the same time (the wrapper installs on first launch) never runs a
41
+ // half-written binary.
42
+ function place(source, destination) {
43
+ const staging = `${destination}.tmp-${process.pid}-${crypto.randomBytes(4).toString('hex')}`;
44
+ try {
45
+ fs.copyFileSync(source, staging);
46
+ fs.chmodSync(staging, 0o755);
47
+ fs.renameSync(staging, destination);
48
+ } finally {
49
+ fs.rmSync(staging, { force: true });
50
+ }
51
+ }
52
+
27
53
  function copyLocalBinary(source) {
28
54
  fs.mkdirSync(binDir, { recursive: true });
29
- fs.copyFileSync(source, binaryPath);
30
- fs.chmodSync(binaryPath, 0o755);
55
+ // Main binary last, as in main(): its presence tells the wrapper the
56
+ // helpers are in place.
31
57
  if (process.env.COMPUTER_USE_LINUX_LOCAL_COSMIC_HELPER) {
32
- fs.copyFileSync(process.env.COMPUTER_USE_LINUX_LOCAL_COSMIC_HELPER, cosmicHelperPath);
33
- fs.chmodSync(cosmicHelperPath, 0o755);
58
+ place(process.env.COMPUTER_USE_LINUX_LOCAL_COSMIC_HELPER, cosmicHelperPath);
34
59
  }
35
60
  if (process.env.COMPUTER_USE_LINUX_LOCAL_INDICATOR) {
36
- fs.copyFileSync(process.env.COMPUTER_USE_LINUX_LOCAL_INDICATOR, indicatorPath);
37
- fs.chmodSync(indicatorPath, 0o755);
61
+ place(process.env.COMPUTER_USE_LINUX_LOCAL_INDICATOR, indicatorPath);
38
62
  }
39
- console.log(`[computer-use-linux] installed local binary from ${source}`);
63
+ place(source, binaryPath);
64
+ say(console.log, `installed local binary from ${source}`);
40
65
  }
41
66
 
42
67
  function download(url, destination, redirects = 5) {
43
68
  return new Promise((resolve, reject) => {
69
+ // An explicit timer, re-armed on every chunk: Node's socket idle timeout
70
+ // did not fire at the requested time during a stalled TLS handshake.
71
+ let idle = null;
72
+ const disarm = () => clearTimeout(idle);
73
+ const arm = () => {
74
+ disarm();
75
+ idle = setTimeout(() => {
76
+ request.destroy(new Error(`no data for ${IDLE_TIMEOUT_MS / 1000} s: ${url}`));
77
+ }, IDLE_TIMEOUT_MS);
78
+ };
44
79
  const request = https.get(url, (response) => {
80
+ arm();
45
81
  if (
46
82
  response.statusCode >= 300 &&
47
83
  response.statusCode < 400 &&
48
84
  response.headers.location &&
49
85
  redirects > 0
50
86
  ) {
87
+ disarm();
51
88
  response.resume();
52
89
  const nextUrl = new URL(response.headers.location, url).toString();
53
90
  download(nextUrl, destination, redirects - 1).then(resolve, reject);
@@ -55,6 +92,7 @@ function download(url, destination, redirects = 5) {
55
92
  }
56
93
 
57
94
  if (response.statusCode !== 200) {
95
+ disarm();
58
96
  response.resume();
59
97
  const error = new Error(`download failed with HTTP ${response.statusCode}: ${url}`);
60
98
  error.statusCode = response.statusCode;
@@ -63,11 +101,22 @@ function download(url, destination, redirects = 5) {
63
101
  }
64
102
 
65
103
  const file = fs.createWriteStream(destination, { mode: 0o600 });
104
+ response.on('data', arm);
66
105
  response.pipe(file);
67
- file.on('finish', () => file.close(resolve));
68
- file.on('error', reject);
106
+ file.on('finish', () => {
107
+ disarm();
108
+ file.close(resolve);
109
+ });
110
+ file.on('error', (error) => {
111
+ disarm();
112
+ reject(error);
113
+ });
114
+ });
115
+ arm();
116
+ request.on('error', (error) => {
117
+ disarm();
118
+ reject(error);
69
119
  });
70
- request.on('error', reject);
71
120
  });
72
121
  }
73
122
 
@@ -100,7 +149,7 @@ function sha256File(filePath) {
100
149
 
101
150
  async function main() {
102
151
  if (process.env.COMPUTER_USE_LINUX_SKIP_DOWNLOAD === '1') {
103
- console.log('[computer-use-linux] skipping binary download');
152
+ say(console.log, 'skipping binary download');
104
153
  return;
105
154
  }
106
155
 
@@ -124,6 +173,14 @@ async function main() {
124
173
  const baseUrl =
125
174
  process.env.COMPUTER_USE_LINUX_DOWNLOAD_BASE ||
126
175
  `https://github.com/agent-sh/computer-use-linux/releases/download/v${pkg.version}`;
176
+ // Refuse before downloading ~15 MB that could not be installed (a global
177
+ // prefix owned by root).
178
+ try {
179
+ fs.accessSync(fs.existsSync(binDir) ? binDir : path.dirname(binDir), fs.constants.W_OK);
180
+ } catch (error) {
181
+ fail(`cannot write ${binDir}: ${error.message}`);
182
+ }
183
+
127
184
  const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'computer-use-linux-'));
128
185
  const tmpBinary = path.join(tmpDir, asset);
129
186
  const tmpSha = path.join(tmpDir, `${asset}.sha256`);
@@ -133,7 +190,7 @@ async function main() {
133
190
  const tmpIndicatorSha = path.join(tmpDir, `${indicatorAsset}.sha256`);
134
191
 
135
192
  try {
136
- console.log(`[computer-use-linux] downloading ${asset} from ${baseUrl}`);
193
+ say(console.log, `downloading ${asset} from ${baseUrl}`);
137
194
  await download(`${baseUrl}/${asset}`, tmpBinary);
138
195
  await download(`${baseUrl}/${asset}.sha256`, tmpSha);
139
196
  await download(`${baseUrl}/${cosmicAsset}`, tmpCosmic);
@@ -163,18 +220,20 @@ async function main() {
163
220
  }
164
221
  }
165
222
 
223
+ // The wrapper only checks for the main binary, so it goes last: once it
224
+ // exists, the helpers it points the server at exist too.
166
225
  fs.mkdirSync(binDir, { recursive: true });
167
- fs.copyFileSync(tmpBinary, binaryPath);
168
- fs.chmodSync(binaryPath, 0o755);
169
- fs.copyFileSync(tmpCosmic, cosmicHelperPath);
170
- fs.chmodSync(cosmicHelperPath, 0o755);
226
+ place(tmpCosmic, cosmicHelperPath);
171
227
  if (hasIndicator) {
172
- fs.copyFileSync(tmpIndicator, indicatorPath);
173
- fs.chmodSync(indicatorPath, 0o755);
228
+ place(tmpIndicator, indicatorPath);
174
229
  } else {
175
230
  fs.rmSync(indicatorPath, { force: true });
176
231
  }
177
- console.log(`[computer-use-linux] installed ${asset} and ${cosmicAsset}${hasIndicator ? ` and ${indicatorAsset}` : ' (release has no indicator)'}`);
232
+ place(tmpBinary, binaryPath);
233
+ say(
234
+ console.log,
235
+ `installed ${asset} and ${cosmicAsset}${hasIndicator ? ` and ${indicatorAsset}` : ' (release has no indicator)'}`
236
+ );
178
237
  } finally {
179
238
  fs.rmSync(tmpDir, { recursive: true, force: true });
180
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-sh/computer-use-linux",
3
- "version": "0.7.37",
3
+ "version": "0.7.39",
4
4
  "description": "Native Linux desktop control for AI agents (MCP server, Pi tools, and CLI): semantic AT-SPI accessibility trees, screenshots, compositor window targeting, Wayland/X11 input, and an on-screen activity indicator.",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -7,7 +7,7 @@ export interface GeneratedMcpToolDefinition {
7
7
  annotations: Record<string, unknown>;
8
8
  }
9
9
 
10
- export const GENERATED_SERVER_VERSION = "0.7.37";
10
+ export const GENERATED_SERVER_VERSION = "0.7.39";
11
11
  export const GENERATED_TOOL_CATALOG_HASH = "626768053c7e97574226d8d8b382ced55272e50273dc6fe72a81d130b20fdb7a";
12
12
  export const GENERATED_SHELL_TOOL_CATALOG_HASH = "628cbd7dc623cfcf7ff2dc18c69960f4c964cf1566045d796e89a76ba7bba9e2";
13
13
  export const GENERATED_MCP_TOOLS =