/** * Memory scopes at run time: the subagents each open scope holds, and the * ledger it keeps. * * A scope opens with a visit of the node it is named after (the run itself * for `flow`), or with each item of a `map` and each branch of a `parallel`, * and holds one subagent per agent, spawned the first time a node inside it * asks and resumed by every later one. Whoever opens, closes: what opened a * scope closes its subagents when it ends, in a `finally`. */ import type { Ledger } from "../../review/index.ts"; import type { KeptLedger } from "./journal.ts"; import type { Subagent } from "../../subagent.ts"; import type { SubmitTool } from "./submit.ts"; import type { VerdictSlot } from "./verdict.ts"; /** A subagent a visit asks, and the tools it answers a typed or a verdict node with. */ export type Held = { /** Closed by whoever opened it: the visit, or the scope that keeps it. */ readonly subagent: Subagent; /** The `submit` tool it was spawned with, when a node it serves is typed. */ readonly submit?: SubmitTool; /** The `verdict` tool it was spawned with, when a node it serves has `verdict:`. */ readonly verdict?: VerdictSlot; }; /** The memory scopes open where a visit stands, outermost first. */ export declare class Frames { private readonly frames; private constructor(); /** The scope `flow` of a flow walked inside the visit `path`: the run's own at `""`, or a call's. */ static root(path: string): Frames; /** The scopes inside the structural node `id`, which opens one of its own at the visit `path`, keeping `ledger` when it has one. */ inside(id: string, path: string, ledger?: KeptLedger): Frames; /** The visit that opened the scope named `scope`, the nearest one: where its subagents leave their transcripts. */ home(scope: string): string; /** * Runs `use` on the subagent of `agent` in the scope named `scope`, opened * by `open` the first time. One visit at a time: a subagent takes one turn * at once, and branches running together may share an outer scope's. */ use(scope: string, agent: string, open: () => Promise, use: (held: Held) => Promise): Promise; /** The ledger of the scope named `scope`, the nearest one. */ ledger(scope: string): KeptLedger; /** Closes the subagents of the innermost scope, the one this visit opened. */ close(): Promise; private frame; } /** * `own`, a block's own id as its body reads it, with `ledger` added the way * `.ledger` reads it: the open obligations at the moment the address * is read, since a verdict in the same iteration changes them. */ export declare function withLedger(own: T, ledger: Ledger | undefined): T; //# sourceMappingURL=frames.d.ts.map