import type { CodeIdentity } from "../../runDirectory/codeIdentity.js"; import type { AgencyConfig } from "../../config/config.js"; import { buildForkOptions, type RunLimits } from "../../runtime/ipc.js"; /** One run's execution job, mirroring the EvalTarget kinds: a compiled file * entry to fork and invoke over IPC, or a substituted command argv to * spawn. */ export type EvalRunnerJob = { kind: "file"; compiledEntryPath: string; node: string; input?: string | Record; cwd: string; statelogPath: string; /** Identity of the seeded agent code, recorded on the trace's agentStart. */ code: CodeIdentity; /** The trace id the child adopts, minted by the harness so the run * directory can key the workdir and the run row before the child * writes a byte. */ traceId: string; } | { kind: "command"; argv: string[]; cwd: string; statelogPath: string; traceId: string; }; /** How to actually run one job. The default dispatches by kind (fork for * files, spawn for commands); tests inject a fake. Must never throw — * failures are returned as `{ ok: false, errorMessage }`. On success the * runner may report the path where it actually wrote the statelog. */ export type EvalInputRunner = (job: EvalRunnerJob) => Promise<{ ok: true; statelogPath?: string; } | { ok: false; errorMessage: string; }>; /** The run limits a suite's config asks for: `eval.limits` overlaid on the * defaults. Only wall clock is configurable so far. The schema already * rejects non-positive values at config load; the guard here covers configs * built programmatically, where 0/-1/NaN would otherwise reach setTimeout * and fail every run instantly with a wall_clock limit error. */ export declare function limitsFromConfig(config: AgencyConfig, timeoutSecOverride?: number): RunLimits; export declare function costCapFromConfig(config: AgencyConfig): number; /** Accumulates a run's LLM spend and answers "over the cap?". Enforcement * necessarily lags by one LLM call — a call's cost is known only after it * returns — so this is a backstop, the same trade every cost guard makes. * Shared by the fork runner (fed by IPC cost telemetry) and the spawn * runner (fed by tailing the statelog). */ export declare function makeCostCapTracker(capUsd: number): { add(costUsd: unknown): boolean; total(): number; exceededMessage(): string; }; /** The fork options for a file-target eval child, with one env subtraction: * a harness-set (or shell-stray) AGENCY_TRACE_ID must not leak in — file * targets get their trace id from their own run, and inheriting one would * merge unrelated runs into a single trace. Same precedent as run() * clearing AGENCY_RUN_POLICY (lib/cli/commands.ts). Exported for tests. */ export declare function evalForkOptions(limits: RunLimits, cwd: string): ReturnType; export declare function makeSubprocessRunner(pipeAgentOutput: boolean, limits?: RunLimits, maxCostUsd?: number): EvalInputRunner;