/** * Claude SDK Executor * * Alternative executor that uses @anthropic-ai/claude-agent-sdk instead of * spawning CLI processes. Provides native streaming input and interrupt support. * * @module agents/claude/sdk-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"; /** * Extended config for SDK executor that adds model support */ export interface ClaudeSDKConfig extends ClaudeCodeConfig { /** * Model to use for queries */ model?: string; } /** * Claude SDK Executor * * Uses @anthropic-ai/claude-agent-sdk for execution instead of CLI spawning. * Provides native streaming input and interrupt support. * * **Advantages over CLI executor:** * - No process spawning overhead * - Native AsyncIterable streaming input * - Cleaner interrupt handling * - Type-safe SDK messages * * **When to use:** * - When you need simpler integration * - When programmatic permission handling is preferred * - When you want typed message interfaces * * @example * ```typescript * const executor = new ClaudeSDKExecutor({ * workDir: '/path/to/project', * }); * * const spawned = await executor.executeTask({ * id: 'task-1', * type: 'custom', * prompt: 'Build a feature', * workDir: '/path/to/project', * config: {}, * }); * * // Send mid-execution message * await executor.sendMessage(spawned.process, 'Also add tests'); * * // Interrupt if needed * await executor.interrupt(spawned.process); * ``` */ export declare class ClaudeSDKExecutor extends BaseAgentExecutor { private readonly config; private queryFn; private sdkAvailable; /** * Create a new ClaudeSDKExecutor * * @param config - Claude SDK configuration */ constructor(config: ClaudeSDKConfig); /** * Execute a new task with Claude SDK * * Starts an SDK query with streaming input support. * * @param task - Task to execute * @returns Spawned process wrapper */ executeTask(task: ExecutionTask): Promise; /** * Resume a previous Claude SDK session * * @param task - Task to execute * @param sessionId - Previous session ID * @returns Spawned process wrapper */ resumeTask(task: ExecutionTask, sessionId: string): Promise; /** * Send an additional message to a running SDK query * * Pushes the message to the async queue which streams to the SDK. * * @param process - The managed process from executeTask() * @param message - Message content to send */ sendMessage(process: ManagedProcess, message: string): Promise; /** * Interrupt a running SDK query * * Calls the SDK's interrupt() method for graceful cancellation. * * @param process - The managed process to interrupt */ interrupt(process: ManagedProcess): Promise; /** * Normalize SDK output to unified format * * Converts SDK messages to normalized entries for UI rendering. * * @param outputStream - Raw output chunks (from virtual stdout) * @param workDir - Working directory * @returns Normalized entries */ normalizeOutput(outputStream: AsyncIterable, workDir: string): AsyncIterable; /** * Get Claude SDK capabilities * * @returns Capabilities object */ getCapabilities(): AgentCapabilities; /** * Check if Claude SDK is available * * Attempts to dynamically import the SDK. * * @returns True if SDK is available */ checkAvailability(): Promise; /** * Get the SDK query function (dynamic import) * * @private */ private getQueryFunction; /** * Create a user message for the SDK * * @private */ private createUserMessage; /** * Create a virtual ManagedProcess from SDK query * * @private */ private createSDKProcess; /** * Process SDK query output in background * * Reads messages from query and writes to virtual stdout. * * @private */ private processQueryOutput; /** * Convert SDK message to stream-json format * * @private */ private convertToStreamJson; } //# sourceMappingURL=sdk-executor.d.ts.map