import type { DecisionRequest, Decision } from "../decision.js"; import type { CrashGuard } from "./crash-guard.js"; import type { Launched, Launcher } from "./launcher.js"; import type { TaskRunner } from "../run.js"; import type { Report } from "./report.js"; import type { StageSpec, StopOn } from "./spec.js"; import { type StageRecord, type StageResult, type Status } from "./state.js"; import { Variables } from "./variables.js"; /** * One step of a pipeline. The base runs what every stage shares: its folder * with the inputs linked in, loops over lines or files, the outputs check, * timing. A subclass runs one item. */ export declare abstract class Stage { readonly spec: StageSpec; readonly folder: string; /** The field and file a loop's items are joined into. */ protected abstract readonly result: { field: "report" | "log"; extension: string; }; /** `folder` is the stage's own folder in the pipeline folder, like `2-review`. */ constructor(spec: StageSpec, folder?: string); get id(): string; get timeout(): number | undefined; /** The files the stage leaves in the pipeline folder on its own. */ abstract files(): string[]; /** Files the stage reads: the loop's list, and the folder an `each_file` mask starts with. */ inputs(): string[]; /** The stage's folder, absolute. */ dir(context: StageContext): string; produces(file: string): boolean; stopsOn(reason: StopOn): boolean; skip(record: StageRecord, reason: string): void; run(context: StageContext, record: StageRecord): Promise; protected abstract runItem(context: StageContext, item: Item, vars: Variables): Promise; protected outcome(done: Launched, status: Status, reason?: string | null): StageResult; private runOne; private runLoop; private linkInputs; private items; private emptyLoop; private joinItems; } export interface StageContext { dir: string; vars: Variables; launcher: Launcher; /** Runs an agent stage in this process. */ runTask: TaskRunner; /** Asks a decision model, `model` or TESTEIYA_DECISION_MODEL. */ decide: (request: DecisionRequest, model?: string) => Promise; /** Records the stage and exits when that agent stage crashes the process. */ guard: CrashGuard; /** The `testeiya` CLI an agent stage spawns under TESTEIYA_PIPELINE_SPAWN=1. */ cli: string; model?: string; /** Set only for the stage whose report the pipeline posts. */ report: Report | null; /** Why an input is not in the folder. */ missing(input: string): string; /** A stage's task, `{{ }}` filled in with these variables. */ task(stage: Stage, vars: Variables): string; /** The folder holding an input: the folder of the stage that wrote it, `.` for the top, null when absent. */ locate(input: string, reader: Stage): string | null; } export interface Item { /** `.1`, `.2`, … in a loop, empty otherwise. */ suffix: string; item?: string; resumed: boolean; }