/** * Simple Process Manager Implementation * * A straightforward implementation of IProcessManager that spawns a fresh * process for each task. This is the "simple first" approach that will later * be upgraded to support process pooling. * * Supports any CLI tool/agent (Claude Code, Codex, Gemini CLI, etc.) * * Key features: * - One process per task (no pooling) * - Event-based I/O streaming * - Graceful termination (SIGTERM → SIGKILL) * - Automatic cleanup * - Metrics tracking * - Agent-agnostic design * * @module execution/process/simple-manager */ import type { ManagedProcess, ProcessConfig, ProcessMetrics, OutputHandler, ErrorHandler } from "./types.js"; import type { IProcessManager } from "./manager.js"; /** * Simple process manager that spawns one process per task * * This implementation follows the "simple first" principle - it provides * a production-ready process manager without the complexity of pooling. * * Works with any CLI tool/agent by accepting executable path and args. * * @example * ```typescript * // Claude Code example * const manager = new SimpleProcessManager({ * executablePath: 'claude', * args: ['--print', '--output-format', 'stream-json'], * }); * * const process = await manager.acquireProcess({ * executablePath: 'claude', * args: ['--print', '--output-format', 'stream-json'], * workDir: '/path/to/project', * timeout: 300000, * }); * * // Codex example * const codexProcess = await manager.acquireProcess({ * executablePath: 'codex', * args: ['--mode', 'agent', '--json'], * workDir: '/path/to/project', * }); * ``` */ export declare class SimpleProcessManager implements IProcessManager { private readonly _defaultConfig; private _activeProcesses; private _cleanupTimers; private _outputBuffers; private _outputBufferSizes; private _outputHandlers; private _maxBufferSize; private _metrics; /** * Create a new SimpleProcessManager * * @param defaultConfig - Default configuration to merge with per-process config * @param maxBufferSize - Maximum output buffer size per process in bytes (default: 1MB, use Infinity for no limit) */ constructor(_defaultConfig?: Partial, maxBufferSize?: number); acquireProcess(config: ProcessConfig): Promise; /** * Spawn a process with the given configuration * * @param config - Process configuration * @returns ChildProcess instance */ private spawnProcess; /** * Set up event handlers for a managed process * * Handles lifecycle events: * - exit: Process terminated normally or abnormally * - error: Process encountered an error * - stdout/stderr data: Track activity for idle detection * * @param managedProcess - The managed process to set up handlers for * @param config - Process configuration (for timeout) */ private setupProcessHandlers; releaseProcess(processId: string): Promise; terminateProcess(processId: string, signal?: NodeJS.Signals): Promise; sendInput(processId: string, input: string): Promise; /** * Close stdin stream for a process * * Signals EOF to the process, useful for programs that wait for stdin to close. * * @param processId - ID of the process */ closeInput(processId: string): void; onOutput(processId: string, handler: OutputHandler): void; onError(processId: string, handler: ErrorHandler): void; getProcess(processId: string): ManagedProcess | null; getActiveProcesses(): ManagedProcess[]; getMetrics(): ProcessMetrics; shutdown(): Promise; } //# sourceMappingURL=simple-manager.d.ts.map