feat(session): validate agents and browse workspace directories

This commit is contained in:
weishu
2026-08-25 16:12:29 +08:00
parent a04275b51d
commit e5a8212f4a
77 changed files with 3409 additions and 312 deletions
@@ -181,4 +181,15 @@ describe('resolveCodexCommand', () => {
args: []
});
});
it('uses the fixed macOS Codex app executable when PATH has no CLI', async () => {
setPlatform('darwin');
const { MACOS_CODEX_APP_COMMAND, resolveCodexCommand } = await import('./codexExecutable');
existsSyncMock.mockImplementation((candidate: string) => candidate === MACOS_CODEX_APP_COMMAND);
expect(resolveCodexCommand()).toEqual({
command: MACOS_CODEX_APP_COMMAND,
args: []
});
});
});
+17 -2
View File
@@ -2,6 +2,7 @@ import { execFileSync } from 'node:child_process';
import { existsSync } from 'node:fs';
import { homedir } from 'node:os';
import path from 'node:path';
import { resolveExecutable } from '@/agent/agentLaunchCommand';
const windowsPath = path.win32;
@@ -67,8 +68,22 @@ function resolveWindowsCodexCommand(): CodexCommand {
return { command: 'codex', args: [] };
}
export function resolveCodexCommand(): CodexCommand {
if (process.platform !== 'win32') {
export const MACOS_CODEX_APP_COMMAND = '/Applications/Codex.app/Contents/Resources/codex';
export function resolveCodexCommand(
env: Record<string, string | undefined> = process.env,
platform: NodeJS.Platform = process.platform,
): CodexCommand {
if (platform !== 'win32') {
const command = resolveExecutable('codex', {
platform,
pathValue: env.PATH,
pathExt: env.PATHEXT,
});
if (command) return { command, args: [] };
if (platform === 'darwin' && existsSync(MACOS_CODEX_APP_COMMAND)) {
return { command: MACOS_CODEX_APP_COMMAND, args: [] };
}
return { command: 'codex', args: [] };
}