Skip to content

Bug: SDK query() fails - pathToClaudeCodeExecutable not set in mapCliOptionsToSDK #468

@Neuro987

Description

@Neuro987

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions