import type { EvalTarget } from "../../agentTarget.js"; import type { AgencyConfig } from "../../config/config.js"; import { type AgentSeed } from "./seed.js"; import { type EvalInputRunner } from "./subprocess.js"; export type RunAgentOptions = { /** The staging directory for THIS run — the statelog lands in * /agent/, the agent executes in /workdir/. A suite * allocates one per test and folds it into the run directory afterwards. */ runDir: string; /** The trace id the run adopts. The harness mints it so the run directory * can key the workdir and the run row even when the agent never starts. */ traceId: string; config: AgencyConfig; /** The test's fixture directory; contents land at the workdir root. */ seedFiles?: string; /** Optimizer candidate edits, applied last (over both seed ingredients). */ overlayFiles?: Record; /** Which files the agent contributes to the workdir. Computed from the * agent's imports when omitted, which is right for a one-off run. The * optimizer supplies one instead, for two reasons: the import walk is * expensive and would otherwise repeat for every one of hundreds of * candidate runs, and every candidate's overlay was computed against the * files as they were at discovery time — recomputing mid-optimization * could see a changed checkout and mis-align the overlays. */ seed?: AgentSeed; /** Show the agent's stdout/stderr live in this process (default true). * The optimizer sets false: it runs many agents and the interleaved * output would be noise — the statelog keeps the evidence either way. */ pipeOutput?: boolean; /** The test's per-test wall-clock override, in seconds. */ timeoutSec?: number; }; /** Test seam: inject a fake in place of the subprocess fork. */ export type RunAgentDeps = { runner?: EvalInputRunner; }; /** What one run left behind, for the suite to fold into the run directory: * the staged statelog (when the agent wrote one), the workdir, and the seeded * agent entry (file targets) whose closure hash the trace recorded. */ export type AgentRunArtifacts = { runDir: string; workdir: string; statelogPath: string | null; seededAgentEntry: string | null; }; export type AgentRun = /** Ran and left a statelog behind. `output` is the trace's last recorded * eval output; the statelog is the evidence anything downstream reads. */ ({ status: "success"; output: unknown; } & AgentRunArtifacts) /** Anything else: crashed, failed to seed/compile, or the run left no * statelog behind (a completed run always writes one, so its absence is a * failure too). */ | ({ status: "error"; errorMessage: string; } & AgentRunArtifacts); /** * Run one agent, once, and collect what happened. The level-1 atom: suites, * grading, and optimizing all compose over this. Never throws — every failure * is an error result with error.txt written. Both target kinds run through * the same pipeline; only seeding (commands compile nothing) and execution * (fork vs spawn) branch — extraction, salvage, and error-writing are one * path. */ export declare function runAgent(target: EvalTarget, input: string | Record | undefined, options: RunAgentOptions, deps?: RunAgentDeps): Promise;