/** * Types for the process management module. */ import type { ChildProcess } from 'child_process'; /** * Internal state of a CodexProcessRunner. * - spawning: process.spawn() called but not yet confirmed running * - running: process confirmed alive (PID assigned) * - exiting: termination requested, waiting for exit * - exited: process has exited (terminal) */ export type ProcessState = 'spawning' | 'running' | 'exiting' | 'exited'; /** * Options for spawning a codex process. */ export interface SpawnOptions { /** Command args for `codex exec` */ args: string[]; /** Working directory */ cwd: string; /** Environment overrides */ env?: Record; /** Grace period in ms between SIGTERM and SIGKILL (default: 5000) */ killGraceMs?: number; } /** * A normalized event emitted by the process runner. * The `raw` field is the JSON string for storage; `parsed` is the object for subscribers. */ export interface ProcessEvent { /** The normalized JSON string (for storage in ring buffer / output file) */ raw: string; /** The parsed event object (for EventBus subscribers) */ parsed: ParsedProcessEvent; } /** * Parsed event from codex JSONL output. */ export interface ParsedProcessEvent { type: string; [key: string]: unknown; } /** * Callbacks for process runner events. */ export interface ProcessCallbacks { /** Called for each normalized JSONL event */ onEvent: (event: ProcessEvent) => void; /** Called when the process exits */ onExit: (info: ProcessExitInfo) => void; } /** * Information about how a process exited. */ export interface ProcessExitInfo { exitCode: number | null; signal: NodeJS.Signals | null; /** Whether the process was killed by us (cancel/timeout/shutdown) */ wasKilled: boolean; } /** * Handle to a running process, returned by the runner. */ export interface ProcessHandle { /** The PID of the child process (undefined if spawn failed) */ pid: number | undefined; /** The raw ChildProcess reference (for setProcess compatibility) */ childProcess: ChildProcess; /** Current runner state */ readonly state: ProcessState; /** Kill the process deterministically */ kill(): Promise; } //# sourceMappingURL=types.d.ts.map