/** * One stage of a hand-walked chain: what a name points at, and how it runs. * * A stage is deliberately either a flow or a lone agent - `explore` is a * fan-out and a synthesis, `planner` is one turn, and both are perfectly good * things to put between two others. They answer in different shapes, and this * is where that stops mattering: a `FlowResult` and a `Result` both come out * of here as the same fields. * * It lives apart from the commands for the usual reason: resolution has to * happen **before** anything is spawned, so that a typo costs a second rather * than a step of real work, and a function that only resolves can be asserted * on without running anything. A flow is held to this terminal there too, so * a flow that cannot run here is refused before its first turn. */ import { type Agent, type CheckedRun, type Usage } from "../../src/index.ts"; import type { Deps } from "../deps.ts"; import type { CommandCtx } from "../pi.ts"; /** What a step turned out to name, checked to run here. Resolved before anything is spawned. */ export type Target = { kind: "flow"; run: CheckedRun; } | { kind: "agent"; agent: Agent; }; /** What a stage produced. A failure is `failed` here, never a throw. */ export type Done = { /** The material the next step may carry. */ output: string; /** What it cost, whether it worked or not. */ usage: Usage; /** Set if and only if the stage failed: what went wrong, and what can be done with what ran. */ failed?: { why: string; next: string; }; }; /** What running a stage needs from the command that asked for it. */ export type Stage = { ctx: CommandCtx; deps: Deps; /** Where this stage's transcripts and `usage.json` land, and a flow's run directory. */ dir: string; /** Beats the flow file's model, and the agent's frontmatter. */ model?: string; /** The footer while it runs. */ status: string; }; /** * The flow or agent a name points at, flows first. * * Flows first because a flow is *asked for* by name and an agent is * discovered, and `--agent` is there so that a name held by both is not a dead * end. A name held by neither says so in one message rather than sending * whoever typed it round two listings. */ export declare function resolveTarget(name: string, forceAgent: boolean, ctx: CommandCtx, deps: Deps, agents: Agent[]): Promise; /** Every agent `target` runs. */ export declare function agentsIn(target: Target): Agent[]; /** * Runs the stage under the live view, and flattens the two shapes into one. * * The caller has no business knowing which of the two ran: what a step keeps is * the output, the usage and whether it worked, and that is the same either way. * A flow runs in `dir` as its run directory, so `/run resume` can carry on * one that stopped. */ export declare function runStage(target: Target, input: string, stage: Stage): Promise; //# sourceMappingURL=stage.d.ts.map