Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 33 additions & 155 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"@iarna/toml": "^2.2.5",
"@modelcontextprotocol/sdk": "^1.29.0",
"@octokit/rest": "^22.0.0",
"@openai/codex": "^0.104.0",
"@openai/codex-sdk": "^0.101.0",
"@openai/codex": "^0.125.0",
"@openai/codex-sdk": "^0.125.0",
"@replit/codemirror-minimap": "^0.5.2",
"@tailwindcss/typography": "^0.5.16",
"@uiw/react-codemirror": "^4.23.13",
Expand Down
15 changes: 9 additions & 6 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import { validateApiKey, authenticateToken, authenticateWebSocket } from './midd
import { IS_PLATFORM } from './constants/config.js';
import { enqueueTelemetryEvent } from './telemetry.js';
import { resolveCursorCliCommand, isCursorLoginCommand, isGeminiLoginCommand, normalizeCursorLoginCommand } from './utils/cursorCommand.js';
import { buildCodexCliEnv, codexCommandForShell } from './utils/codexCli.js';
import { getGeminiApiKeyForUser, withGeminiApiKeyEnv } from './utils/geminiApiKey.js';
import {
DEFAULT_BACKEND_PORT,
Expand Down Expand Up @@ -2031,18 +2032,18 @@ function handleShellConnection(ws) {
}
}
} else if (provider === 'codex') {
// Use codex command
const codexCommand = codexCommandForShell(process.env, os.platform());
if (os.platform() === 'win32') {
if (hasSession && sessionId) {
shellCommand = `Set-Location -Path "${projectPath}"; codex resume ${sessionId}; if ($LASTEXITCODE -ne 0) { codex }`;
shellCommand = `Set-Location -Path "${projectPath}"; ${codexCommand} resume ${sessionId}; if ($LASTEXITCODE -ne 0) { ${codexCommand} }`;
} else {
shellCommand = `Set-Location -Path "${projectPath}"; codex`;
shellCommand = `Set-Location -Path "${projectPath}"; ${codexCommand}`;
}
} else {
if (hasSession && sessionId) {
shellCommand = `cd "${projectPath}" && codex resume ${sessionId} || codex`;
shellCommand = `cd "${projectPath}" && ${codexCommand} resume ${sessionId} || ${codexCommand}`;
} else {
shellCommand = `cd "${projectPath}" && codex`;
shellCommand = `cd "${projectPath}" && ${codexCommand}`;
}
}
} else if (provider === 'gemini') {
Expand Down Expand Up @@ -2112,7 +2113,9 @@ function handleShellConnection(ws) {
cols: termCols,
rows: termRows,
cwd: spawnCwd,
env: buildEmbeddedShellEnv(process.env)
env: provider === 'codex'
? buildEmbeddedShellEnv(buildCodexCliEnv(process.env))
: buildEmbeddedShellEnv(process.env)
});

console.log('🟢 Shell process started with PTY, PID:', shellProcess.pid);
Expand Down
7 changes: 5 additions & 2 deletions server/routes/cli-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import os from 'os';
import fetch from 'node-fetch';
import { resolveCursorCliCommand } from '../utils/cursorCommand.js';
import { resolveAvailableCliCommand } from '../utils/cliResolution.js';
import { buildCodexCliEnv, getCodexCliCommand } from '../utils/codexCli.js';
import {
DEFAULT_OLLAMA_URL,
detectGPUs,
Expand Down Expand Up @@ -840,7 +841,8 @@ function checkCursorStatus() {
// 2. OPENAI_API_KEY from server environment variable
// 3. OPENAI_API_KEY from ~/.codex/auth.json
async function checkCodexCredentials() {
let cliCommand = process.env.CODEX_CLI_PATH || 'codex';
const codexCliEnv = buildCodexCliEnv(process.env);
let cliCommand = getCodexCliCommand(process.env);
try {
if (isCliMockedMissing('codex')) {
return {
Expand All @@ -856,7 +858,8 @@ async function checkCodexCredentials() {
const resolvedCliCommand = await resolveAvailableCliCommand({
envVarName: 'CODEX_CLI_PATH',
defaultCommands: ['codex'],
appendWindowsSuffixes: true
appendWindowsSuffixes: true,
env: codexCliEnv
});
cliCommand = resolvedCliCommand || cliCommand;

Expand Down
19 changes: 19 additions & 0 deletions server/utils/__tests__/codexCli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest';
import path from 'path';
import { buildCodexCliEnv, codexCommandForShell } from '../codexCli.js';

describe('codexCli', () => {
it('removes Dr. Claw local node_modules/.bin from Codex CLI PATH probes', () => {
const localBin = path.join(process.cwd(), 'node_modules', '.bin');
const externalBin = path.join(path.sep, 'usr', 'local', 'bin');
const env = buildCodexCliEnv({
PATH: [localBin, externalBin].join(path.delimiter),
});

expect(env.PATH.split(path.delimiter)).toEqual([externalBin]);
});

it('uses CODEX_CLI_PATH as the shell command when configured', () => {
expect(codexCommandForShell({ CODEX_CLI_PATH: '/opt/homebrew/bin/codex' }, 'darwin')).toBe("'/opt/homebrew/bin/codex'");
});
});
Loading
Loading