@codexed/codex 0.132.0-codexed.2 → 0.133.0-codexed.2

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 +33 -25
  2. package/package.json +4 -4
package/bin/codex.js CHANGED
@@ -77,33 +77,43 @@ if (!platformPackage) {
77
77
 
78
78
  const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
79
79
  const localVendorRoot = path.join(__dirname, "..", "vendor");
80
- const localBinaryPath = path.join(
81
- localVendorRoot,
82
- targetTriple,
83
- "codex",
84
- codexBinaryName,
85
- );
86
-
87
- let vendorRoot;
80
+ const packageBinaryPath = (vendorRoot) =>
81
+ path.join(vendorRoot, targetTriple, "bin", codexBinaryName);
82
+ const legacyBinaryPath = (vendorRoot) =>
83
+ path.join(vendorRoot, targetTriple, "codex", codexBinaryName);
84
+
85
+ function resolveNativePackage(vendorRoot) {
86
+ const packageRoot = path.join(vendorRoot, targetTriple);
87
+ const binaryPath = packageBinaryPath(vendorRoot);
88
+ if (existsSync(binaryPath)) {
89
+ return {
90
+ binaryPath,
91
+ pathDir: path.join(packageRoot, "codex-path"),
92
+ };
93
+ }
94
+
95
+ const legacyPath = legacyBinaryPath(vendorRoot);
96
+ if (existsSync(legacyPath)) {
97
+ return {
98
+ binaryPath: legacyPath,
99
+ pathDir: path.join(packageRoot, "path"),
100
+ };
101
+ }
102
+
103
+ return null;
104
+ }
105
+
106
+ let nativePackage;
88
107
  try {
89
108
  const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
90
- vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
109
+ nativePackage = resolveNativePackage(
110
+ path.join(path.dirname(packageJsonPath), "vendor"),
111
+ );
91
112
  } catch {
92
- if (existsSync(localBinaryPath)) {
93
- vendorRoot = localVendorRoot;
94
- } else {
95
- const packageManager = detectPackageManager();
96
- const updateCommand =
97
- packageManager === "bun"
98
- ? "bun install -g @codexed/codex@latest"
99
- : "npm install -g @codexed/codex@latest";
100
- throw new Error(
101
- `Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
102
- );
103
- }
113
+ nativePackage = resolveNativePackage(localVendorRoot);
104
114
  }
105
115
 
106
- if (!vendorRoot) {
116
+ if (!nativePackage) {
107
117
  const packageManager = detectPackageManager();
108
118
  const updateCommand =
109
119
  packageManager === "bun"
@@ -114,8 +124,7 @@ if (!vendorRoot) {
114
124
  );
115
125
  }
116
126
 
117
- const archRoot = path.join(vendorRoot, targetTriple);
118
- const binaryPath = path.join(archRoot, "codex", codexBinaryName);
127
+ const { binaryPath, pathDir } = nativePackage;
119
128
 
120
129
  // Use an asynchronous spawn instead of spawnSync so that Node is able to
121
130
  // respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
@@ -159,7 +168,6 @@ function detectPackageManager() {
159
168
  }
160
169
 
161
170
  const additionalDirs = [];
162
- const pathDir = path.join(archRoot, "path");
163
171
  if (existsSync(pathDir)) {
164
172
  additionalDirs.push(pathDir);
165
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexed/codex",
3
- "version": "0.132.0-codexed.2",
3
+ "version": "0.133.0-codexed.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -21,8 +21,8 @@
21
21
  "postinstall": "node scripts/postinstall.mjs"
22
22
  },
23
23
  "optionalDependencies": {
24
- "@codexed/codex-linux-x64": "0.132.0-codexed.2",
25
- "@codexed/codex-linux-arm64": "0.132.0-codexed.2",
26
- "@codexed/codex-win32-x64": "0.132.0-codexed.2"
24
+ "@codexed/codex-linux-x64": "0.133.0-codexed.2",
25
+ "@codexed/codex-linux-arm64": "0.133.0-codexed.2",
26
+ "@codexed/codex-win32-x64": "0.133.0-codexed.2"
27
27
  }
28
28
  }