fix(claude-agent): don't fail-fast in buildOptions
resolveClaudeBinary threw eagerly inside buildOptions, breaking unit tests that mock the SDK at the module level (env, redesign, interrupt-restart- regression suites). The user-facing fail-fast already lives in isAvailable(); in buildOptions, fall back to omitting pathToClaudeCodeExecutable so the SDK surfaces its own error if the binary truly is missing.
This commit is contained in:
@@ -1381,16 +1381,6 @@ export class ClaudeAgentClient implements AgentClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveClaudeBinary(): Promise<string> {
|
|
||||||
const found = await findExecutable("claude");
|
|
||||||
if (found) {
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
throw new Error(
|
|
||||||
"Claude binary not found. Install Claude Code (https://github.com/anthropics/claude-code) and ensure it is available in your shell PATH.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function resolveClaudeVersion(
|
async function resolveClaudeVersion(
|
||||||
runtimeSettings?: ProviderRuntimeSettings,
|
runtimeSettings?: ProviderRuntimeSettings,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
@@ -2293,7 +2283,7 @@ class ClaudeAgentSession implements AgentSession {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const claudeBinary = await resolveClaudeBinary();
|
const claudeBinary = await findExecutable("claude");
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
{
|
{
|
||||||
claudeBinary,
|
claudeBinary,
|
||||||
@@ -2314,7 +2304,7 @@ class ClaudeAgentSession implements AgentSession {
|
|||||||
allowDangerouslySkipPermissions: true,
|
allowDangerouslySkipPermissions: true,
|
||||||
agents: this.defaults?.agents,
|
agents: this.defaults?.agents,
|
||||||
canUseTool: this.handlePermissionRequest,
|
canUseTool: this.handlePermissionRequest,
|
||||||
pathToClaudeCodeExecutable: claudeBinary,
|
...(claudeBinary ? { pathToClaudeCodeExecutable: claudeBinary } : {}),
|
||||||
// Use Claude Code preset system prompt and load CLAUDE.md files
|
// Use Claude Code preset system prompt and load CLAUDE.md files
|
||||||
// Append provider-agnostic system prompt and orchestrator instructions for agents.
|
// Append provider-agnostic system prompt and orchestrator instructions for agents.
|
||||||
systemPrompt: {
|
systemPrompt: {
|
||||||
|
|||||||
Reference in New Issue
Block a user