@itsbfb/codex 0.159.2-tmux.2 → 0.172.0-autodark.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/bin/codex.js +17 -15
- package/package.json +3 -3
package/bin/codex.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { existsSync, readFileSync, realpathSync } from "fs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
|
+
import { constants } from "node:os";
|
|
7
8
|
import path from "path";
|
|
8
9
|
import { fileURLToPath } from "url";
|
|
9
10
|
|
|
@@ -111,12 +112,6 @@ function findCodexExecutable() {
|
|
|
111
112
|
|
|
112
113
|
const binaryPath = findCodexExecutable();
|
|
113
114
|
|
|
114
|
-
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
115
|
-
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
116
|
-
// executing. This allows us to forward those signals to the child process
|
|
117
|
-
// and guarantees that when either the child terminates or the parent
|
|
118
|
-
// receives a fatal signal, both processes exit in a predictable manner.
|
|
119
|
-
|
|
120
115
|
function isPnpmOwnedCodexInstall(nodeModulesDir) {
|
|
121
116
|
if (!existsSync(path.join(nodeModulesDir, ".modules.yaml"))) {
|
|
122
117
|
return false;
|
|
@@ -238,6 +233,17 @@ delete env.CODEX_MANAGED_BY_PNPM;
|
|
|
238
233
|
delete env.CODEX_MANAGED_BY_VITE_PLUS;
|
|
239
234
|
env[packageManagerEnvVar] = "1";
|
|
240
235
|
|
|
236
|
+
// Replace Node so the native binary receives signals and exits directly.
|
|
237
|
+
// Node exposes execve on Windows too, but calling it there is unsupported.
|
|
238
|
+
if (process.platform !== "win32" && typeof process.execve === "function") {
|
|
239
|
+
// Node ignores SIGXFSZ, and ignored signals survive execve. Installing a
|
|
240
|
+
// handler lets execve restore the default disposition in the native binary.
|
|
241
|
+
process.on("SIGXFSZ", () => {});
|
|
242
|
+
process.execve(binaryPath, [binaryPath, ...process.argv.slice(2)], env);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Older Node versions and Windows need a child process. Spawn asynchronously
|
|
246
|
+
// so Node can forward signals while the native binary is executing.
|
|
241
247
|
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
242
248
|
stdio: "inherit",
|
|
243
249
|
env,
|
|
@@ -252,14 +258,9 @@ child.on("error", (err) => {
|
|
|
252
258
|
process.exit(1);
|
|
253
259
|
});
|
|
254
260
|
|
|
255
|
-
//
|
|
256
|
-
//
|
|
257
|
-
// exiting immediately; once the child has been signaled we simply wait for
|
|
258
|
-
// its exit event which will in turn terminate the parent (see below).
|
|
261
|
+
// Keep forwarding signals until the child exits so a second signal can
|
|
262
|
+
// interrupt a graceful shutdown.
|
|
259
263
|
const forwardSignal = (signal) => {
|
|
260
|
-
if (child.killed) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
264
|
try {
|
|
264
265
|
child.kill(signal);
|
|
265
266
|
} catch {
|
|
@@ -287,8 +288,9 @@ const childResult = await new Promise((resolve) => {
|
|
|
287
288
|
});
|
|
288
289
|
|
|
289
290
|
if (childResult.type === "signal") {
|
|
290
|
-
//
|
|
291
|
-
|
|
291
|
+
// Preserve a failure exit code even if Node ignores the re-emitted signal.
|
|
292
|
+
process.exitCode = 128 + constants.signals[childResult.signal];
|
|
293
|
+
process.removeAllListeners(childResult.signal);
|
|
292
294
|
process.kill(process.pid, childResult.signal);
|
|
293
295
|
} else {
|
|
294
296
|
process.exit(childResult.exitCode);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itsbfb/codex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.172.0-autodark.1",
|
|
4
4
|
"description": "Codex CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"bin"
|
|
16
16
|
],
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@itsbfb/codex-darwin-arm64": "0.
|
|
19
|
-
"@itsbfb/codex-linux-x64": "0.
|
|
18
|
+
"@itsbfb/codex-darwin-arm64": "0.172.0-autodark.1-darwin-arm64",
|
|
19
|
+
"@itsbfb/codex-linux-x64": "0.172.0-autodark.1-linux-x64"
|
|
20
20
|
}
|
|
21
21
|
}
|