/** * Codex CLI executor using JSONL protocol. * * Executor for OpenAI Codex CLI that runs in non-interactive mode (codex exec) * with JSON output for structured parsing. * * @module agents/codex/executor */ import { BaseAgentExecutor } from "../base/base-executor.js"; import type { ExecutionTask } from "../../engine/types.js"; import type { SpawnedChild, OutputChunk, NormalizedEntry, AgentCapabilities } from "../types/agent-executor.js"; import type { CodexConfig } from "./types/config.js"; /** * Codex CLI executor using JSONL protocol. * * Runs codex in non-interactive mode (`codex exec`) with JSON output * for automated task execution. * * @example Basic usage * ```typescript * const executor = new CodexExecutor({ * workDir: '/path/to/project', * autoApprove: true, * model: 'gpt-5-codex' * }); * * const spawned = await executor.executeTask({ * id: 'task-1', * type: 'custom', * prompt: 'Implement user authentication', * workDir: '/path/to/project', * config: {}, * }); * * // Process output * const outputStream = executor.createOutputChunks(spawned.process); * for await (const entry of executor.normalizeOutput(outputStream, '/path/to/project')) { * console.log(entry.type.kind, entry.content); * } * ``` */ export declare class CodexExecutor extends BaseAgentExecutor { private config; /** * Create a new Codex executor. * * @param config - Configuration options */ constructor(config: CodexConfig); /** * Execute a new task with Codex CLI. * * Spawns codex process in non-interactive mode (codex exec), * sends the prompt to stdin, and immediately closes stdin. * * @param task - Task to execute * @returns Spawned child process * @throws {Error} If codex is not available or spawn fails */ executeTask(task: ExecutionTask): Promise; /** * Resume a previous task session. * * Uses `codex exec resume ` to continue a previous conversation. * The session ID is the thread_id from a previous execution's thread.started event. * * @param task - Task with new prompt * @param sessionId - Session ID (thread_id) to resume * @returns Spawned child process * @throws {Error} If codex is not available or spawn fails */ resumeTask(task: ExecutionTask, sessionId: string): Promise; /** * Normalize Codex JSONL output to unified format. * * Parses line-delimited JSON from Codex CLI and converts to * normalized entries. Captures thread_id as sessionId for session tracking. * * Event types: * - thread.started: Contains thread_id (session ID) * - turn.started: Turn begins * - item.completed: Agent message, reasoning, or tool call completed * - turn.completed: Turn ends with usage stats * * @param outputStream - Stream of output chunks * @param _workDir - Working directory for path resolution * @returns Async iterable of normalized entries */ normalizeOutput(outputStream: AsyncIterable, _workDir: string): AsyncIterable; /** * Get Codex executor capabilities. * * @returns Agent capabilities descriptor */ getCapabilities(): AgentCapabilities; /** * Check if Codex CLI is available. * * Checks if codex executable exists in PATH. * * @returns True if codex is available, false otherwise */ checkAvailability(): Promise; /** * Build command-line arguments for codex. * * @returns Array of command-line arguments * @private */ private buildArgs; /** * Build arguments for resuming a session. * * @param sessionId - Session ID to resume * @returns Array of command-line arguments * @private */ private buildResumeArgs; } //# sourceMappingURL=executor.d.ts.map