/** * CodexDriver — first proof-of-pattern driver in the new ProviderRuntime contract. * * This driver does not yet replace the existing Codex subprocess management in * `src/studio/harnesses.ts`. It demonstrates the new contract end-to-end: * * 1. Subprocess transport is injected (`spawnTransport`) so tests run without * a real `codex` binary on PATH. * 2. Lifecycle drives through the SessionMachine. * 3. Every observable thing emits a canonical `ProviderRuntimeEvent`. * 4. Errors are typed `HarnessError`s, not raw Errors. * * The cut-over to live Codex (replacing the old code path) lands behind the * `STUDIO_USE_NEW_HARNESS_LAYER=1` feature flag once all 7 drivers exist. */ import { Effect } from "effect"; import { type HarnessError } from "../contracts/errors.js"; import { BaseHarnessDriver, type HarnessDriverConfig, type HarnessTurnRequest } from "./base.js"; export interface CodexTransport { /** Send a line of input to the underlying codex process. */ write(line: string): Promise; /** Cleanly close the process. */ close(reason?: string): Promise; /** Force-terminate the process. */ kill(signal?: NodeJS.Signals): Promise; /** Subscribe to stdout/stderr lines. Returns an unsubscribe. */ onLine(cb: (line: string, stream: "stdout" | "stderr") => void): () => void; /** Subscribe to process exit. Returns an unsubscribe. */ onExit(cb: (code: number | null, signal: NodeJS.Signals | null) => void): () => void; } export interface CodexTransportFactory { (opts: { model: string; effort: string; env: NodeJS.ProcessEnv; cwd: string; }): Promise; } export interface CodexDriverOptions extends Record { model?: string; effort?: "low" | "medium" | "high" | "xhigh"; cwd?: string; env?: NodeJS.ProcessEnv; spawnTransport: CodexTransportFactory; } export declare class CodexDriver extends BaseHarnessDriver { private transport; private offLine; private offExit; constructor(config: HarnessDriverConfig); private opts; start(): Effect.Effect; sendTurn(req: HarnessTurnRequest): Effect.Effect; interrupt(reason?: string): Effect.Effect; shutdown(): Effect.Effect; private handleLine; private handleExit; } /** Canonical HarnessId for the Codex driver. Exported so callers can ask the * registry for it without re-deriving the prefix convention. */ export declare const CODEX_HARNESS_ID: import("../contracts/ids.js").Brand;