@mmmbuto/codex-cli-termux 0.53.1-termux → 0.53.2-termux

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.
Files changed (2) hide show
  1. package/bin/codex.js +66 -0
  2. package/package.json +6 -4
package/bin/codex.js ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ // Wrapper for Codex CLI on Termux (Android ARM64)
3
+ // Sets CODEX_MANAGED_BY_NPM=1 to enable auto-update functionality
4
+
5
+ import { spawn } from "node:child_process";
6
+ import path from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ // Get directory of this script
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+
13
+ // Path to the Rust binary
14
+ const binaryPath = path.join(__dirname, "codex");
15
+
16
+ // Set environment variable to enable npm auto-update
17
+ const env = {
18
+ ...process.env,
19
+ CODEX_MANAGED_BY_NPM: "1",
20
+ };
21
+
22
+ // Spawn the Rust binary with all arguments
23
+ const child = spawn(binaryPath, process.argv.slice(2), {
24
+ stdio: "inherit",
25
+ env,
26
+ });
27
+
28
+ // Handle spawn errors (e.g., binary not found or not executable)
29
+ child.on("error", (err) => {
30
+ console.error("Failed to start Codex:", err.message);
31
+ process.exit(1);
32
+ });
33
+
34
+ // Forward termination signals to child process
35
+ const forwardSignal = (signal) => {
36
+ if (child.killed) {
37
+ return;
38
+ }
39
+ try {
40
+ child.kill(signal);
41
+ } catch {
42
+ /* ignore */
43
+ }
44
+ };
45
+
46
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
47
+ process.on(sig, () => forwardSignal(sig));
48
+ });
49
+
50
+ // Wait for child to exit and mirror its exit status
51
+ const childResult = await new Promise((resolve) => {
52
+ child.on("exit", (code, signal) => {
53
+ if (signal) {
54
+ resolve({ type: "signal", signal });
55
+ } else {
56
+ resolve({ type: "code", exitCode: code ?? 1 });
57
+ }
58
+ });
59
+ });
60
+
61
+ // Exit with same code/signal as child
62
+ if (childResult.type === "signal") {
63
+ process.kill(process.pid, childResult.signal);
64
+ } else {
65
+ process.exit(childResult.exitCode);
66
+ }
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@mmmbuto/codex-cli-termux",
3
- "version": "0.53.1-termux",
4
- "description": "OpenAI Codex CLI v0.53.0 with auto-update fix for Termux (Android ARM64)",
5
- "main": "bin/codex",
3
+ "version": "0.53.2-termux",
4
+ "description": "OpenAI Codex CLI v0.53.0 with full auto-update support for Termux (Android ARM64)",
5
+ "type": "module",
6
+ "main": "bin/codex.js",
6
7
  "bin": {
7
- "codex": "bin/codex"
8
+ "codex": "bin/codex.js"
8
9
  },
9
10
  "files": [
11
+ "bin/codex.js",
10
12
  "bin/codex"
11
13
  ],
12
14
  "keywords": [