@abacus-ai/cli 2.10.1-canary.2 → 2.10.1-canary.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abacus-ai/cli",
3
- "version": "2.10.1-canary.2",
3
+ "version": "2.10.1-canary.3",
4
4
  "bin": {
5
5
  "abacusai": "scripts/npm-wrapper/shim.cjs"
6
6
  },
@@ -20,6 +20,8 @@ const binaryFor = (version) => path.join(VERSIONS_DIR, version, BINARY_NAME);
20
20
  // libc, truncated download. Distinct from a normal non-zero exit.
21
21
  const FATAL_SIGNALS = new Set(["SIGILL", "SIGSEGV", "SIGABRT", "SIGTRAP", "SIGBUS"]);
22
22
  const LAUNCH_FAILURE_MS = 3000;
23
+ const LAUNCHED_MARKER = ".launched";
24
+ const PREFLIGHT_TIMEOUT_MS = 10_000;
23
25
 
24
26
  function readInstallSource() {
25
27
  try {
@@ -31,6 +33,42 @@ function readInstallSource() {
31
33
  }
32
34
  }
33
35
 
36
+ function binaryEnv() {
37
+ return { ...process.env, ABACUSAI_INSTALL_SOURCE: readInstallSource() };
38
+ }
39
+
40
+ // process.execve is missing below Node 22.15 and throws on Windows. On Node a
41
+ // failed exec aborts the process rather than throwing, so the file is checked
42
+ // for exec permission up front; other failures are left to the spawn path.
43
+ function canExecInPlace(binPath) {
44
+ if (process.platform === "win32" || typeof process.execve !== "function") return false;
45
+ try {
46
+ fs.accessSync(binPath, fs.constants.X_OK);
47
+ return true;
48
+ } catch {
49
+ return false;
50
+ }
51
+ }
52
+
53
+ // An exec'd binary can't be rolled back if it never runs, so the first launch of
54
+ // a binary proves it with a --help run and records that beside it.
55
+ function proveLaunches(binPath) {
56
+ const marker = path.join(path.dirname(binPath), LAUNCHED_MARKER);
57
+ if (fs.existsSync(marker)) return true;
58
+ const res = spawnSync(binPath, ["--help"], {
59
+ stdio: "ignore",
60
+ env: binaryEnv(),
61
+ timeout: PREFLIGHT_TIMEOUT_MS,
62
+ });
63
+ if (res.error || res.status !== 0) return false;
64
+ try {
65
+ fs.writeFileSync(marker, "");
66
+ } catch {
67
+ /* the next launch proves it again */
68
+ }
69
+ return true;
70
+ }
71
+
34
72
  function ensureBinary(version) {
35
73
  const target = binaryFor(version);
36
74
  if (fs.existsSync(target)) return target;
@@ -66,10 +104,7 @@ function newestCachedFallback(exclude) {
66
104
 
67
105
  function run(binPath) {
68
106
  const start = Date.now();
69
- const res = spawnSync(binPath, process.argv.slice(2), {
70
- stdio: "inherit",
71
- env: { ...process.env, ABACUSAI_INSTALL_SOURCE: readInstallSource() },
72
- });
107
+ const res = spawnSync(binPath, process.argv.slice(2), { stdio: "inherit", env: binaryEnv() });
73
108
  const launchFailed =
74
109
  !!res.error ||
75
110
  (!!res.signal && FATAL_SIGNALS.has(res.signal) && Date.now() - start < LAUNCH_FAILURE_MS);
@@ -82,6 +117,13 @@ if (!binPath) {
82
117
  process.exit(1);
83
118
  }
84
119
 
120
+ // Replace this process with the binary instead of spawning it as a child, so
121
+ // the terminal's foreground process is `abacusai` itself, not the `node` that
122
+ // was waiting on it (VS Code labels its tab with that process's name).
123
+ if (canExecInPlace(binPath) && proveLaunches(binPath)) {
124
+ process.execve(binPath, [binPath, ...process.argv.slice(2)], binaryEnv());
125
+ }
126
+
85
127
  let { res, launchFailed } = run(binPath);
86
128
 
87
129
  // A corrupt/incompatible release must not brick the CLI: if the binary couldn't