Bug Description
When using claude-code-ui in SDK mode, the query() call from @anthropic-ai/claude-agent-sdk fails with:
ReferenceError: Claude Code executable not found at C:\Users\...\node_modules\@anthropic-ai\claude-agent-sdk\cli.js.
Is options.pathToClaudeCodeExecutable set?
Root Cause
In server/claude-sdk.js, the mapCliOptionsToSDK() function (around line 133) does not set pathToClaudeCodeExecutable in the sdkOptions object. The SDK then defaults to looking for cli.js within its own package directory (claude-agent-sdk/cli.js), which doesn't exist — the actual Claude Code executable is at @anthropic-ai/claude-code/cli.js.
This follows the same pattern as #221 (settingSources missing) and #329 (maxThinkingTokens missing) — mapCliOptionsToSDK is missing a required SDK option.
Suggested Fix
Add pathToClaudeCodeExecutable to mapCliOptionsToSDK() in server/claude-sdk.js:
function mapCliOptionsToSDK(options = {}) {
const { sessionId, cwd, toolsSettings, permissionMode, images } = options;
const sdkOptions = {};
// Set Claude Code executable path
sdkOptions.pathToClaudeCodeExecutable = process.env.CLAUDE_CLI_PATH || 'claude';
// Map working directory
// ... rest of function
This respects the existing CLAUDE_CLI_PATH environment variable (already documented in cli.js line 174) and falls back to the claude command on PATH.
Environment
- OS: Windows 10
- claude-code-ui: latest (npm
@siteboon/claude-code-ui)
- claude-agent-sdk: bundled version in node_modules
- claude-code: globally installed via npm
Related Issues
Bug Description
When using
claude-code-uiin SDK mode, thequery()call from@anthropic-ai/claude-agent-sdkfails with:Root Cause
In
server/claude-sdk.js, themapCliOptionsToSDK()function (around line 133) does not setpathToClaudeCodeExecutablein thesdkOptionsobject. The SDK then defaults to looking forcli.jswithin its own package directory (claude-agent-sdk/cli.js), which doesn't exist — the actual Claude Code executable is at@anthropic-ai/claude-code/cli.js.This follows the same pattern as #221 (
settingSourcesmissing) and #329 (maxThinkingTokensmissing) —mapCliOptionsToSDKis missing a required SDK option.Suggested Fix
Add
pathToClaudeCodeExecutabletomapCliOptionsToSDK()inserver/claude-sdk.js:This respects the existing
CLAUDE_CLI_PATHenvironment variable (already documented incli.jsline 174) and falls back to theclaudecommand on PATH.Environment
@siteboon/claude-code-ui)Related Issues
spawn ENOENT), likely same root causemapCliOptionsToSDK)mapCliOptionsToSDK)