@openai/codex 0.47.0-alpha.1 → 0.47.0-alpha.3

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 CHANGED
@@ -80,6 +80,32 @@ function getUpdatedPath(newDirs) {
80
80
  return updatedPath;
81
81
  }
82
82
 
83
+ /**
84
+ * Use heuristics to detect the package manager that was used to install Codex
85
+ * in order to give the user a hint about how to update it.
86
+ */
87
+ function detectPackageManager() {
88
+ const userAgent = process.env.npm_config_user_agent || "";
89
+ if (/\bbun\//.test(userAgent)) {
90
+ return "bun";
91
+ }
92
+
93
+ const execPath = process.env.npm_execpath || "";
94
+ if (execPath.includes("bun")) {
95
+ return "bun";
96
+ }
97
+
98
+ if (
99
+ process.env.BUN_INSTALL ||
100
+ process.env.BUN_INSTALL_GLOBAL_DIR ||
101
+ process.env.BUN_INSTALL_BIN_DIR
102
+ ) {
103
+ return "bun";
104
+ }
105
+
106
+ return userAgent ? "npm" : null;
107
+ }
108
+
83
109
  const additionalDirs = [];
84
110
  const pathDir = path.join(archRoot, "path");
85
111
  if (existsSync(pathDir)) {
@@ -87,9 +113,16 @@ if (existsSync(pathDir)) {
87
113
  }
88
114
  const updatedPath = getUpdatedPath(additionalDirs);
89
115
 
116
+ const env = { ...process.env, PATH: updatedPath };
117
+ const packageManagerEnvVar =
118
+ detectPackageManager() === "bun"
119
+ ? "CODEX_MANAGED_BY_BUN"
120
+ : "CODEX_MANAGED_BY_NPM";
121
+ env[packageManagerEnvVar] = "1";
122
+
90
123
  const child = spawn(binaryPath, process.argv.slice(2), {
91
124
  stdio: "inherit",
92
- env: { ...process.env, PATH: updatedPath, CODEX_MANAGED_BY_NPM: "1" },
125
+ env,
93
126
  });
94
127
 
95
128
  child.on("error", (err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openai/codex",
3
- "version": "0.47.0-alpha.1",
3
+ "version": "0.47.0-alpha.3",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "codex": "bin/codex.js"