🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(hetero): find the Codex CLI in ChatGPT.app's codex-cli package layout (#20445)
Arvin Xue97afd315fab
diff --git a/apps/desktop/src/main/modules/binaries/__tests__/cliAgentBinaries.test.ts b/apps/desktop/src/main/modules/binaries/__tests__/cliAgentBinaries.test.tsindex b407b61cc24..def65f9aa3e 100644--- a/apps/desktop/src/main/modules/binaries/__tests__/cliAgentBinaries.test.ts+++ b/apps/desktop/src/main/modules/binaries/__tests__/cliAgentBinaries.test.ts@@ -453,13 +453,15 @@ describe('cliAgentBinaries', () => {const status = await codexBinary.detect();expect(status.available).toBe(true);- expect(status.path).toBe('/Applications/ChatGPT.app/Contents/Resources/codex');+ expect(status.path).toBe(+ '/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex',+ );expect(status.version).toBe('0.138.0');expect(execFileMock).toHaveBeenCalledTimes(2);expect(execFileMock.mock.calls[0]![0]).toBe('which');expect(execFileMock.mock.calls[1]![0]).toBe(- '/Applications/ChatGPT.app/Contents/Resources/codex',+ '/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex',);} finally {process.env.PATH = originalPath;@@ -476,17 +478,15 @@ describe('cliAgentBinaries', () => {try {callExecFileError(new Error('not found')); // which codex- callExecFileError(new Error('ENOENT')); // /Applications/ChatGPT.app- callExecFileError(new Error('ENOENT')); // ~/Applications/ChatGPT.app- callExecFileError(new Error('ENOENT')); // /Applications/Codex.app- callExecFileError(new Error('ENOENT')); // ~/Applications/Codex.app+ // ChatGPT.app (two layouts) + Codex.app × /Applications and ~/Applications+ for (let i = 0; i < 6; i++) callExecFileError(new Error('ENOENT'));const { codexBinary } = await import('../cliAgentBinaries');const status = await codexBinary.detect();expect(status.available).toBe(false);- expect(execFileMock).toHaveBeenCalledTimes(5);- expect(execFileMock.mock.calls[4]![0]).toBe(+ expect(execFileMock).toHaveBeenCalledTimes(7);+ expect(execFileMock.mock.calls[6]![0]).toBe(path.join(os.homedir(), 'Applications', 'Codex.app', 'Contents', 'Resources', 'codex'),);} finally {diff --git a/packages/heterogeneous-agents/src/spawn/resolveCliCommand.test.ts b/packages/heterogeneous-agents/src/spawn/resolveCliCommand.test.tsindex 3c21cc81f82..b7766f51df2 100644--- a/packages/heterogeneous-agents/src/spawn/resolveCliCommand.test.ts+++ b/packages/heterogeneous-agents/src/spawn/resolveCliCommand.test.ts@@ -659,8 +659,37 @@ build commit: 6756e52a9238b6d493928e55b05127957dbfefb4`);const status = await detectHeterogeneousCliCommand('codex', 'codex');expect(status.available).toBe(true);- expect(status.path).toBe('/Applications/ChatGPT.app/Contents/Resources/codex');+ expect(status.path).toBe(+ '/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex',+ );expect(execFileMock.mock.calls[2]![0]).toBe(+ '/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex',+ );+ } finally {+ process.env.PATH = originalPath;+ if (originalShell === undefined) delete process.env.SHELL;+ else process.env.SHELL = originalShell;+ }+ });++ it('falls back to the flat ChatGPT.app CLI from bundles before the codex-cli package layout', async () => {+ const originalPath = process.env.PATH;+ const originalShell = process.env.SHELL;+ process.env.PATH = '/usr/bin:/bin';+ delete process.env.SHELL;++ try {+ callExecFileError(new Error('not found')); // which codex+ callExecFileError(new Error('ENOENT')); // /Applications/ChatGPT.app codex-cli/bin/codex+ callExecFileError(new Error('ENOENT')); // ~/Applications/ChatGPT.app codex-cli/bin/codex+ callExecFile('codex-cli 0.142.5'); // /Applications/ChatGPT.app flat codex++ const { detectHeterogeneousCliCommand } = await importModule();+ const status = await detectHeterogeneousCliCommand('codex', 'codex');++ expect(status.available).toBe(true);+ expect(status.path).toBe('/Applications/ChatGPT.app/Contents/Resources/codex');+ expect(execFileMock.mock.calls[3]![0]).toBe('/Applications/ChatGPT.app/Contents/Resources/codex',);} finally {@@ -678,8 +707,8 @@ build commit: 6756e52a9238b6d493928e55b05127957dbfefb4`);try {callExecFileError(new Error('not found')); // which codex- callExecFileError(new Error('ENOENT')); // /Applications/ChatGPT.app- callExecFileError(new Error('ENOENT')); // ~/Applications/ChatGPT.app+ // ChatGPT.app: codex-cli/bin/codex then flat codex, /Applications and ~/Applications+ for (let i = 0; i < 4; i++) callExecFileError(new Error('ENOENT'));callExecFile('codex-cli 0.142.5'); // /Applications/Codex.appconst { detectHeterogeneousCliCommand } = await importModule();@@ -687,7 +716,7 @@ build commit: 6756e52a9238b6d493928e55b05127957dbfefb4`);expect(status.available).toBe(true);expect(status.path).toBe('/Applications/Codex.app/Contents/Resources/codex');- expect(execFileMock.mock.calls[3]![0]).toBe(+ expect(execFileMock.mock.calls[5]![0]).toBe('/Applications/Codex.app/Contents/Resources/codex',);} finally {@@ -1314,10 +1343,8 @@ build commit: 6756e52a9238b6d493928e55b05127957dbfefb4`);try {callExecFileError(new Error('not found')); // which codex- callExecFileError(new Error('ENOENT')); // /Applications/ChatGPT.app- callExecFileError(new Error('ENOENT')); // ~/Applications/ChatGPT.app- callExecFileError(new Error('ENOENT')); // /Applications/Codex.app- callExecFileError(new Error('ENOENT')); // ~/Applications/Codex.app+ // ChatGPT.app (two layouts) + Codex.app × /Applications and ~/Applications+ for (let i = 0; i < 6; i++) callExecFileError(new Error('ENOENT'));const { resolveHeteroSpawnCommand } = await importModule();const resolved = await resolveHeteroSpawnCommand('codex', 'codex');diff --git a/packages/heterogeneous-agents/src/spawn/resolveCliCommand.ts b/packages/heterogeneous-agents/src/spawn/resolveCliCommand.tsindex ab319bd9333..04edfff7222 100644--- a/packages/heterogeneous-agents/src/spawn/resolveCliCommand.ts+++ b/packages/heterogeneous-agents/src/spawn/resolveCliCommand.ts@@ -793,16 +793,19 @@ const getWellKnownCommandPaths = (agentType: HeterogeneousCliAgentType): string[if (platform() !== 'darwin') return [];- // Codex.app was renamed to ChatGPT.app. Prefer the current bundle name,- // while keeping Codex.app as a fallback for older installations.- return ['ChatGPT.app', 'Codex.app'].flatMap((appBundleName) => {- const bundledCli = path.join(appBundleName, 'Contents', 'Resources', 'codex');-- return [- path.join('/Applications', bundledCli),- path.join(homedir(), 'Applications', bundledCli),- ];- });+ // Codex.app was renamed to ChatGPT.app. ChatGPT.app 26.9 then moved the+ // CLI from `Resources/codex` into a self-contained `Resources/codex-cli/`+ // package whose `codex-package.json` declares `bin/codex` as the+ // entrypoint. Probe newest first; legacy Codex.app only ever shipped the+ // flat binary.+ return [+ path.join('ChatGPT.app', 'Contents', 'Resources', 'codex-cli', 'bin', 'codex'),+ path.join('ChatGPT.app', 'Contents', 'Resources', 'codex'),+ path.join('Codex.app', 'Contents', 'Resources', 'codex'),+ ].flatMap((bundledCli) => [+ path.join('/Applications', bundledCli),+ path.join(homedir(), 'Applications', bundledCli),+ ]);}case 'cursor': {if (platform() !== 'darwin' && platform() !== 'linux') return [];