@christiandoxa/prodex 0.2.96

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Christian Doxa Hamasiah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @christiandoxa/prodex
2
+
3
+ This package is the npm launcher for the native `prodex` binary.
4
+
5
+ It mirrors the published Rust crate version from crates.io and uses the same
6
+ native-binary pattern as `@openai/codex`: npm resolves the right platform
7
+ package, launches the native `prodex` binary, and injects a `codex` shim so the
8
+ Rust binary can delegate to `@openai/codex` without requiring a separate global
9
+ install.
10
+
11
+ The npm package version is intended to stay aligned with the published
12
+ `prodex` crate version.
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("node:fs");
5
+ const path = require("node:path");
6
+ const { spawn } = require("node:child_process");
7
+ const { createRequire } = require("node:module");
8
+
9
+ const requireFromHere = createRequire(__filename);
10
+
11
+ function resolveCodexBin() {
12
+ let packageJsonPath;
13
+ try {
14
+ packageJsonPath = requireFromHere.resolve("@openai/codex/package.json");
15
+ } catch {
16
+ process.stderr.write(
17
+ "Unable to locate @openai/codex. Reinstall @christiandoxa/prodex so its runtime dependency is present.\n",
18
+ );
19
+ process.exit(1);
20
+ }
21
+
22
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
23
+ if (typeof packageJson.bin === "string") {
24
+ return path.resolve(path.dirname(packageJsonPath), packageJson.bin);
25
+ }
26
+ if (packageJson.bin && typeof packageJson.bin === "object") {
27
+ const candidate = packageJson.bin.codex ?? Object.values(packageJson.bin)[0];
28
+ if (typeof candidate === "string") {
29
+ return path.resolve(path.dirname(packageJsonPath), candidate);
30
+ }
31
+ }
32
+ return path.resolve(path.dirname(packageJsonPath), "bin", "codex.js");
33
+ }
34
+
35
+ const codexBin = resolveCodexBin();
36
+ const child = spawn(process.execPath, [codexBin, ...process.argv.slice(2)], {
37
+ env: process.env,
38
+ stdio: "inherit",
39
+ });
40
+
41
+ child.on("error", (error) => {
42
+ process.stderr.write(`${error.message}\n`);
43
+ process.exit(1);
44
+ });
45
+
46
+ child.on("exit", (code, signal) => {
47
+ if (signal) {
48
+ process.kill(process.pid, signal);
49
+ return;
50
+ }
51
+ process.exit(code ?? 1);
52
+ });
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@christiandoxa/prodex",
3
+ "version": "0.2.96",
4
+ "description": "Safe multi-account auto-rotate for Codex CLI with isolated CODEX_HOME profiles",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "prodex": "./prodex"
8
+ },
9
+ "files": [
10
+ "prodex",
11
+ "lib",
12
+ "README.md",
13
+ "LICENSE"
14
+ ],
15
+ "dependencies": {
16
+ "@openai/codex": "^0.118.0"
17
+ },
18
+ "optionalDependencies": {
19
+ "@christiandoxa/prodex-linux-x64": "0.2.96",
20
+ "@christiandoxa/prodex-linux-arm64": "0.2.96",
21
+ "@christiandoxa/prodex-darwin-x64": "0.2.96",
22
+ "@christiandoxa/prodex-darwin-arm64": "0.2.96",
23
+ "@christiandoxa/prodex-win32-x64": "0.2.96",
24
+ "@christiandoxa/prodex-win32-arm64": "0.2.96"
25
+ },
26
+ "engines": {
27
+ "node": ">=18"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/christiandoxa/prodex.git",
35
+ "directory": "npm/prodex"
36
+ }
37
+ }
package/prodex ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const fs = require("node:fs");
5
+ const os = require("node:os");
6
+ const path = require("node:path");
7
+ const { spawn } = require("node:child_process");
8
+ const { createRequire } = require("node:module");
9
+
10
+ const PLATFORM_PACKAGES = {
11
+ linux: {
12
+ x64: {
13
+ packageName: "@christiandoxa/prodex-linux-x64",
14
+ binaryFileName: "prodex",
15
+ },
16
+ arm64: {
17
+ packageName: "@christiandoxa/prodex-linux-arm64",
18
+ binaryFileName: "prodex",
19
+ },
20
+ },
21
+ darwin: {
22
+ x64: {
23
+ packageName: "@christiandoxa/prodex-darwin-x64",
24
+ binaryFileName: "prodex",
25
+ },
26
+ arm64: {
27
+ packageName: "@christiandoxa/prodex-darwin-arm64",
28
+ binaryFileName: "prodex",
29
+ },
30
+ },
31
+ win32: {
32
+ x64: {
33
+ packageName: "@christiandoxa/prodex-win32-x64",
34
+ binaryFileName: "prodex.exe",
35
+ },
36
+ arm64: {
37
+ packageName: "@christiandoxa/prodex-win32-arm64",
38
+ binaryFileName: "prodex.exe",
39
+ },
40
+ },
41
+ };
42
+
43
+ const requireFromHere = createRequire(__filename);
44
+ const packageJson = requireFromHere("./package.json");
45
+ const packageRoot = path.dirname(requireFromHere.resolve("./package.json"));
46
+ const codexShimPath = path.join(packageRoot, "lib", "codex-shim.cjs");
47
+ const platformPackage = PLATFORM_PACKAGES[process.platform]?.[process.arch];
48
+
49
+ if (!platformPackage) {
50
+ process.stderr.write(
51
+ `Unsupported platform for @christiandoxa/prodex: ${process.platform} ${process.arch}\n`,
52
+ );
53
+ process.exit(1);
54
+ }
55
+
56
+ let nativeBinaryPath;
57
+ try {
58
+ const platformPackageJsonPath = requireFromHere.resolve(
59
+ `${platformPackage.packageName}/package.json`,
60
+ );
61
+ nativeBinaryPath = path.join(
62
+ path.dirname(platformPackageJsonPath),
63
+ "vendor",
64
+ platformPackage.binaryFileName,
65
+ );
66
+ } catch {
67
+ process.stderr.write(
68
+ `Unable to locate ${platformPackage.packageName}; reinstall @christiandoxa/prodex with optional dependencies enabled.\n`,
69
+ );
70
+ process.exit(1);
71
+ }
72
+
73
+ if (!fs.existsSync(nativeBinaryPath)) {
74
+ process.stderr.write(`Missing prodex native binary at ${nativeBinaryPath}\n`);
75
+ process.exit(1);
76
+ }
77
+
78
+ const shimDir = fs.mkdtempSync(path.join(os.tmpdir(), "prodex-codex-"));
79
+ const codexCmd = path.join(shimDir, "codex");
80
+ const codexCmdWindows = path.join(shimDir, "codex.cmd");
81
+
82
+ fs.writeFileSync(
83
+ codexCmd,
84
+ `#!/bin/sh\nexec node ${JSON.stringify(codexShimPath)} "$@"\n`,
85
+ { mode: 0o755 },
86
+ );
87
+ fs.writeFileSync(
88
+ codexCmdWindows,
89
+ `@echo off\r\nnode ${JSON.stringify(codexShimPath)} %*\r\n`,
90
+ { mode: 0o755 },
91
+ );
92
+
93
+ const cleanup = () => {
94
+ try {
95
+ fs.rmSync(shimDir, { recursive: true, force: true });
96
+ } catch {
97
+ // Best-effort cleanup only.
98
+ }
99
+ };
100
+
101
+ const child = spawn(nativeBinaryPath, process.argv.slice(2), {
102
+ env: {
103
+ ...process.env,
104
+ PATH: `${shimDir}${path.delimiter}${process.env.PATH ?? ""}`,
105
+ PRODEX_CODEX_BIN: "codex",
106
+ npm_package_name: packageJson.name,
107
+ npm_package_version: packageJson.version,
108
+ },
109
+ stdio: "inherit",
110
+ });
111
+
112
+ for (const signalName of ["SIGINT", "SIGTERM", "SIGHUP"]) {
113
+ process.on(signalName, () => {
114
+ child.kill(signalName);
115
+ });
116
+ }
117
+
118
+ child.on("error", (error) => {
119
+ cleanup();
120
+ process.stderr.write(`${error.message}\n`);
121
+ process.exit(1);
122
+ });
123
+
124
+ child.on("exit", (code, signal) => {
125
+ cleanup();
126
+ if (signal) {
127
+ process.kill(process.pid, signal);
128
+ return;
129
+ }
130
+ process.exit(code ?? 1);
131
+ });