/** * Claude Code Executor * * Agent executor for Claude Code CLI integration. * * @module agents/claude/executor */ import { BaseAgentExecutor } from "../base/base-executor.js"; import type { ClaudeCodeConfig } from "./types/config.js"; import type { AgentCapabilities, SpawnedChild, OutputChunk, NormalizedEntry } from "../types/agent-executor.js"; import type { ExecutionTask } from "../../engine/types.js"; import type { ManagedProcess } from "../../process/types.js"; /** * Claude Code Executor * * Integrates with Claude Code CLI for agentic task execution. * Supports bidirectional protocol, tool approvals, session resume, and MCP servers. * * @example Basic usage * ```typescript * const executor = new ClaudeCodeExecutor({ * workDir: '/path/to/project', * print: true, * outputFormat: 'stream-json', * }); * * const result = await executor.executeTask({ * id: 'task-1', * type: 'claude-code', * prompt: 'List all TypeScript files', * workDir: '/path/to/project', * }); * ``` * * @example With approval service * ```typescript * const executor = new ClaudeCodeExecutor(config); * executor.setApprovalService(new CustomApprovalService()); * * const result = await executor.executeTask(task); * ``` */ export declare class ClaudeCodeExecutor extends BaseAgentExecutor { private readonly config; /** * Create a new ClaudeCodeExecutor * * @param config - Claude Code configuration */ constructor(config: ClaudeCodeConfig); /** * Execute a new task with Claude Code * * Spawns a Claude CLI process, sets up bidirectional protocol, * and sends the initial prompt. * * @param task - Task to execute * @returns Spawned process with protocol peer */ executeTask(task: ExecutionTask): Promise; /** * Resume a previous Claude Code session * * Spawns Claude with --resume flag and sends new prompt. * * @param task - Task to execute * @param sessionId - Previous session ID * @returns Spawned process with protocol peer */ resumeTask(task: ExecutionTask, sessionId: string): Promise; /** * Normalize Claude Code output to unified format * * Converts stream-json messages to normalized entries for UI rendering. * * @param outputStream - Raw output chunks * @param workDir - Working directory * @returns Normalized entries */ normalizeOutput(outputStream: AsyncIterable, workDir: string): AsyncIterable; /** * Get Claude Code capabilities * * @returns Capabilities object */ getCapabilities(): AgentCapabilities; /** * Send an additional message to a running Claude process * * Allows sending mid-execution guidance while Claude is actively working on a task. * The message is sent via the protocol peer's bidirectional stream-json protocol. * * @param process - The managed process from executeTask() or resumeTask() * @param message - Message content to send * @throws Error if process doesn't have a protocol peer attached * * @example * ```typescript * const spawned = await executor.executeTask(task); * * // Later, while task is running: * await executor.sendMessage(spawned.process, 'Also add unit tests'); * ``` */ sendMessage(process: ManagedProcess, message: string): Promise; /** * Interrupt a running Claude process * * Sends an interrupt signal to stop the current operation. Claude handles * the interrupt gracefully - it may finish the current tool operation * before stopping. * * Falls back to SIGINT if no protocol peer is attached. * * @param process - The managed process to interrupt * * @example * ```typescript * const spawned = await executor.executeTask(task); * * // User wants to cancel: * await executor.interrupt(spawned.process); * ``` */ interrupt(process: ManagedProcess): Promise; /** * Check if Claude Code is available * * Verifies that the claude executable exists in PATH. * * @returns True if claude is available */ checkAvailability(): Promise; /** * Build command-line arguments for Claude CLI * * @param resume - Whether this is a resume operation * @param sessionId - Session ID for resume * @param workDir - Working directory for directory restriction * @returns Array of CLI arguments */ private buildArgs; /** * Build settings JSON with directory guard hook * * Creates a settings object that configures a PreToolUse hook to restrict * file operations to the specified working directory. * * @param workDir - Working directory to restrict to * @returns Settings object for --settings flag */ private buildDirectoryGuardSettings; /** * Build hook configuration * * Enables PreToolUse hook for approval flow. * * @returns Hook configuration */ private buildHooks; } //# sourceMappingURL=executor.d.ts.map