@abacus-ai/cli 2.10.1-canary.3 → 2.10.1
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 +1 -1
- package/scripts/npm-wrapper/shim.cjs +4 -46
package/package.json
CHANGED
|
@@ -20,8 +20,6 @@ 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;
|
|
25
23
|
|
|
26
24
|
function readInstallSource() {
|
|
27
25
|
try {
|
|
@@ -33,42 +31,6 @@ function readInstallSource() {
|
|
|
33
31
|
}
|
|
34
32
|
}
|
|
35
33
|
|
|
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
|
-
|
|
72
34
|
function ensureBinary(version) {
|
|
73
35
|
const target = binaryFor(version);
|
|
74
36
|
if (fs.existsSync(target)) return target;
|
|
@@ -104,7 +66,10 @@ function newestCachedFallback(exclude) {
|
|
|
104
66
|
|
|
105
67
|
function run(binPath) {
|
|
106
68
|
const start = Date.now();
|
|
107
|
-
const res = spawnSync(binPath, process.argv.slice(2), {
|
|
69
|
+
const res = spawnSync(binPath, process.argv.slice(2), {
|
|
70
|
+
stdio: "inherit",
|
|
71
|
+
env: { ...process.env, ABACUSAI_INSTALL_SOURCE: readInstallSource() },
|
|
72
|
+
});
|
|
108
73
|
const launchFailed =
|
|
109
74
|
!!res.error ||
|
|
110
75
|
(!!res.signal && FATAL_SIGNALS.has(res.signal) && Date.now() - start < LAUNCH_FAILURE_MS);
|
|
@@ -117,13 +82,6 @@ if (!binPath) {
|
|
|
117
82
|
process.exit(1);
|
|
118
83
|
}
|
|
119
84
|
|
|
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
|
-
|
|
127
85
|
let { res, launchFailed } = run(binPath);
|
|
128
86
|
|
|
129
87
|
// A corrupt/incompatible release must not brick the CLI: if the binary couldn't
|