/** * Walking a checked flow: a sequence node after node, each visit announced on * the event stream, and a failure travelling up until a node absorbs it. * * Our code decides what runs next. A model's output is a value a `choice` * reads; it never names a node. The blocks that open branches are in * `blocks.ts` and `choice.ts`, the loop in `loop.ts`, a call in `call.ts`, * and each comes back through {@link Run.sequence}. What the walk is given * is in `world.ts`. */ import type { Agent } from "../../agent.ts"; import type { GitResult } from "../../git/index.ts"; import type { ScriptOutcome } from "../../verify.ts"; import type { CheckedAgentNode, CheckedAskNode, CheckedCallNode, CheckedCheckNode, CheckedCommitNode, CheckedFlow, CheckedNode } from "../checked.ts"; import { type AgentRun, type Attempt } from "./agent.ts"; import { type AskingRun, type Card, type Heard } from "./ask.ts"; import { type CallingRun } from "./call.ts"; import { type CheckingRun } from "./check.ts"; import { type CommitOutcome, type CommittingRun } from "./commit.ts"; import type { Copies } from "./copies.ts"; import { type Ended, type Walked } from "./ended.ts"; import type { Frames, Held } from "./frames.ts"; import type { Journal } from "./journal.ts"; import type { Replay } from "./replay.ts"; import type { Values } from "./values.ts"; import type { Walk } from "./world.ts"; /** * Where a visit stands: what it reads, the memory scopes open around it, the * signal that cuts it short, the run's own or a `fail-fast` block's, and the * working tree it acts in: the run's, or its branch's copy inside a * `copies: true` block. A dry run has none. */ export type Here = { readonly values: Values; readonly frames: Frames; readonly cut: AbortSignal; readonly tree: string | undefined; }; /** What a block needs of the walk: the run's signal, the copies it makes, the journal, what a resume kept of it, and a sequence walked inside it. */ export type Walker = { readonly signal: AbortSignal; readonly copies?: Copies; readonly journal: Journal; readonly replay?: Replay; sequence(nodes: readonly CheckedNode[], prefix: string, here: Here): Promise; }; /** * One run of a checked flow, or of a flow it calls: a callee's is the run's * own, one call further down. The world and the settings are the run's, * whatever file a node is in, so one queue of cards and one run branch serve * every call. What a file writes, `model:` and `timeout:`, is read from the * callee outward, and the world is told each node by its address through the * calls, `spec/ask_next`. */ export declare class Run implements AgentRun, AskingRun, CallingRun, CheckingRun, CommittingRun, Walker { readonly signal: AbortSignal; readonly copies?: Copies; readonly journal: Journal; readonly replay?: Replay; private readonly walk; /** The flow walked, then each one that called it, outward. */ private readonly stack; /** The address of the call this flow is walked for, through the calls above it; `""` at the root. */ private readonly prefix; private readonly shared; constructor(walk: Walk, stack?: readonly CheckedFlow[], prefix?: string); called(node: CheckedCallNode): Run; whole(node: CheckedCallNode, path: string): Ended | undefined; /** `nodes` in order, inside the visit `prefix`. A failure not absorbed ends the sequence there. */ sequence(nodes: readonly CheckedNode[], prefix: string, here: Here): Promise; timeoutFor(node: CheckedAgentNode): number; deadline(attempt: Attempt): AbortSignal; check(node: CheckedCheckNode, path: string, signal: AbortSignal, tree: string | undefined): Promise; commit(node: CheckedCommitNode, path: string, message: string): Promise; diff(tree: string | undefined): Promise>; ask(node: CheckedAskNode, path: string, card: Card, cut: AbortSignal): Promise; stop(): void; /** * A subagent with the tools every node it serves answers with: one node * without `memory:`, every node sharing it with one. The flow asked for a * typed value or a verdict, so the agent is given the tool that hands it * back; `tools:` is an allowlist, and it covers ours too. An agent whose * `tools:` names `subagent` is handed one. Its transcript goes in `home`. */ open(agent: Agent, node: CheckedAgentNode, path: string, tree: string | undefined, home: string): Promise; /** * The `subagent` tool of `holder`, handed to it once its id is known: its * children are drawn from the agents the flow names, which the snapshot * keeps, and their transcripts go beside `holder`'s. */ private delegate; /** * One visit, between its `visit_start` and its `visit_end`, each * written down before it is told; or, on a resume, how it ended before, * neither told nor written again. */ private visit; private dispatch; /** The address of `at`, an address in this flow's file, through the calls that reached it. */ private address; /** `node` as the world is told it: at its address through the calls. */ private addressed; } //# sourceMappingURL=walk.d.ts.map