cli-setu 0.3.5 → 0.3.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-setu",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Bridge your terminal to your phone — run and approve Claude Code, Codex CLI and other AI coding agents from anywhere.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -0,0 +1,40 @@
1
+ // node-pty 1.1.0 ships its macOS "spawn-helper" program WITHOUT the execute bit
2
+ // (-rw-r--r-- in the npm tarball) and its install script does not fix that, so on a Mac every
3
+ // terminal start fails with "posix_spawnp failed". Found 2026-11-15 by the GitHub Actions macOS
4
+ // job (the first real macOS run of this CLI). Linux builds the helper itself (already
5
+ // executable) and Windows has no helper, so only the prebuilt macOS one is affected.
6
+ //
7
+ // ensureSpawnHelperExecutable() runs before node-pty is first used and adds the execute bits to
8
+ // every spawn-helper it can find. It never throws: a read-only install folder or a missing file
9
+ // must not stop the CLI, node-pty then reports its own clear error.
10
+ 'use strict';
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+
14
+ function helperCandidates(ptyDir, platform, arch) {
15
+ return [
16
+ path.join(ptyDir, 'build', 'Release', 'spawn-helper'),
17
+ path.join(ptyDir, 'build', 'Debug', 'spawn-helper'),
18
+ path.join(ptyDir, 'prebuilds', `${platform}-${arch}`, 'spawn-helper'),
19
+ ];
20
+ }
21
+
22
+ // Returns the list of files it changed (for tests and diagnostics).
23
+ function ensureSpawnHelperExecutable(opts = {}) {
24
+ const platform = opts.platform || process.platform;
25
+ if (platform === 'win32') return [];
26
+ let ptyDir = opts.ptyDir;
27
+ if (!ptyDir) {
28
+ try { ptyDir = path.dirname(require.resolve('node-pty/package.json')); } catch { return []; }
29
+ }
30
+ const changed = [];
31
+ for (const file of helperCandidates(ptyDir, platform, opts.arch || process.arch)) {
32
+ try {
33
+ const mode = fs.statSync(file).mode;
34
+ if ((mode & 0o111) !== 0o111) { fs.chmodSync(file, mode | 0o755); changed.push(file); }
35
+ } catch { /* file not there, or not ours to change: nothing to do */ }
36
+ }
37
+ return changed;
38
+ }
39
+
40
+ module.exports = { ensureSpawnHelperExecutable, helperCandidates };
package/src/supervisor.js CHANGED
@@ -28,6 +28,8 @@
28
28
  // card, no usage tracking) instead of refusing to start. See
29
29
  // cli-adapters/README.md for the adapter interface this script drives.
30
30
 
31
+ // macOS: node-pty's prebuilt spawn-helper ships without the execute bit (see ptyHelperPerms.js).
32
+ require('./ptyHelperPerms').ensureSpawnHelperExecutable();
31
33
  const pty = require('node-pty');
32
34
  const { Terminal: HeadlessTerminal } = require('@xterm/headless');
33
35
  const fs = require('fs');
@@ -2249,7 +2251,18 @@ async function main() {
2249
2251
  const cleanupAndExit = () => {
2250
2252
  process.exitCode = 0;
2251
2253
  ptyProcess.kill();
2252
- setTimeout(() => process.exit(0), 1500).unref(); // safety net - see onExit's own comment
2254
+ // Safety net - see onExit's own comment. 2026-11-15: on a slow machine the shell can take longer
2255
+ // than this timer to die (the Actions Linux node 20 job lost the end notice once), and onExit is
2256
+ // the only place that tells the backend the session ended. So when the net fires first, send
2257
+ // that notice here (bounded to 2 s, best effort) and only then exit. finishedExiting stops the
2258
+ // notice being sent twice (onExit sets it the moment it runs).
2259
+ setTimeout(() => {
2260
+ if (finishedExiting) return; // onExit is already ending the process, with its own notice
2261
+ finishedExiting = true;
2262
+ endSessionOnBackend({ fetchImpl: fetch, authServer: AUTH_SERVER, deviceToken, sessionId: SESSION_ID, reason: 'exit' })
2263
+ .catch(() => {})
2264
+ .finally(() => process.exit(0));
2265
+ }, 1500).unref();
2253
2266
  };
2254
2267
  process.on('SIGINT', cleanupAndExit);
2255
2268
  process.on('SIGTERM', cleanupAndExit);