codex-copilot-dx 0.4.22 → 0.4.23

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/cli.mjs CHANGED
@@ -96,7 +96,7 @@ async function reuseRunningAdapterIfAvailable() {
96
96
  console.log(status("ok", "Claude App support available with --configure-claude-desktop"));
97
97
  }
98
98
 
99
- openCodex();
99
+ await openCodex();
100
100
  console.log(`
101
101
  ${status("ok", "Ready, using the existing codex-copilot-dx adapter")}
102
102
 
@@ -179,7 +179,7 @@ try {
179
179
  }
180
180
 
181
181
  // Launch Codex when available.
182
- openCodex();
182
+ await openCodex();
183
183
 
184
184
  // Periodically refresh the model list + endpoint cache so a long-running
185
185
  // adapter picks up newly released models without a restart.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "0.4.22",
3
+ "version": "0.4.23",
4
4
  "description": "Use Codex Desktop, Claude Code, and Claude App with GitHub Copilot",
5
5
  "type": "module",
6
6
  "bin": {
package/src/launcher.mjs CHANGED
@@ -3,17 +3,62 @@ import { status } from "./status.mjs";
3
3
 
4
4
  export { ensureAuth } from "./auth.mjs";
5
5
 
6
- export function openCodex() {
7
- if (process.platform === "darwin") {
6
+ // The Codex desktop app was folded into the ChatGPT app, but it keeps the
7
+ // original bundle identifier. Launching by bundle id works for both the old
8
+ // Codex.app and the new ChatGPT.app regardless of where they are installed.
9
+ const CODEX_BUNDLE_ID = "com.openai.codex";
10
+ const APP_PATH_CANDIDATES = [
11
+ "/Applications/Codex.app",
12
+ "/Applications/ChatGPT.app",
13
+ ];
14
+
15
+ export function autoLaunchEnabled(env = process.env) {
16
+ const raw = env.CCDX_AUTO_LAUNCH;
17
+ if (raw === undefined || raw === "") return true;
18
+ return !/^(0|false|no|off)$/i.test(String(raw).trim());
19
+ }
20
+
21
+ // Run `open` and resolve to true only when it exits successfully.
22
+ function tryOpen(args, { spawnImpl = spawn } = {}) {
23
+ return new Promise((resolve) => {
24
+ let child;
8
25
  try {
9
- spawn("open", ["/Applications/Codex.app"], { detached: true, stdio: "ignore" });
10
- console.log(status("ok", "Codex app launched"));
26
+ child = spawnImpl("open", args, { stdio: "ignore" });
11
27
  } catch {
12
- console.log(status("warn", "Codex app not found at /Applications/Codex.app"));
13
- console.log(status("info", "Download Codex from https://openai.com/codex"));
28
+ resolve(false);
29
+ return;
14
30
  }
15
- } else {
16
- console.log(status("warn", "Auto-launch is not supported on this platform"));
17
- console.log(status("info", "Open Codex manually; it will connect to the adapter."));
31
+ child.on("error", () => resolve(false));
32
+ child.on("exit", (code) => resolve(code === 0));
33
+ });
34
+ }
35
+
36
+ // Build the ordered list of launch attempts: bundle id first, then paths.
37
+ export function launchAttempts() {
38
+ return [["-b", CODEX_BUNDLE_ID], ...APP_PATH_CANDIDATES.map((path) => [path])];
39
+ }
40
+
41
+ export async function openCodex({ env = process.env, spawnImpl = spawn, platform = process.platform } = {}) {
42
+ if (platform !== "darwin") {
43
+ console.log(status("warn", "Auto-launch is only supported on macOS"));
44
+ console.log(status("info", "Open Codex or the ChatGPT app manually; it will connect to the adapter."));
45
+ return false;
18
46
  }
47
+
48
+ if (!autoLaunchEnabled(env)) {
49
+ console.log(status("info", "Auto-launch disabled (CCDX_AUTO_LAUNCH=0); open Codex or the ChatGPT app manually."));
50
+ return false;
51
+ }
52
+
53
+ for (const args of launchAttempts()) {
54
+ if (await tryOpen(args, { spawnImpl })) {
55
+ console.log(status("ok", "Codex app launched"));
56
+ return true;
57
+ }
58
+ }
59
+
60
+ console.log(status("warn", "Could not launch the Codex app (checked com.openai.codex, Codex.app, ChatGPT.app)"));
61
+ console.log(status("info", "Open Codex or the ChatGPT app manually; it will connect to the adapter."));
62
+ console.log(status("info", "Download it from https://openai.com/codex"));
63
+ return false;
19
64
  }