UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

56 lines (55 loc) • 3.37 kB
/** * subflowRecords — where a subflow mount's OWN log is, read through the * library's door. * * Pattern: pure lookups over `RuntimeSnapshot.subflowResults`. * Role: what `inspect_subflow` opens, and what every outer tool asks when * it is handed an id it does not know. Nothing here formats an * answer beyond the absence reasons, which belong to the record. * * WHY THE MAP, AND WHY `getSubtreeSnapshot`. A subflow runs in an isolated * runtime and commits to its own log; the run's `commitLog` holds only the * mount boundary (seed in, merge-back out). footprintjs keeps each mount's log * in `subflowResults`, DUAL-KEYED — the subflow path (latest iteration) and * each mount's `runtimeStageId` (`sf-tools#11`) — and nested mounts are * merged UP into the same flat map (`sf-a/sf-b#7`). `getSubtreeSnapshot` is * the library's public door to one entry (history, fold base, tree, state); * this module only decides WHICH entry, and says why when there is none. * * Mounts are addressed by `runtimeStageId`, never by path: a mount inside a * loop runs several times, and the path key names only the last one. */ import type { RuntimeSnapshot } from 'footprintjs'; /** The subflow results map, when the snapshot carries one as a map. */ export declare function subflowResultsOf(snapshot: RuntimeSnapshot): Record<string, unknown> | undefined; /** * The mount whose OWN log holds step `id` — the one level directly above it. * * Only per-mount keys (`…#n`) are asked: a path key is an alias of its last * iteration, and asking it would name the wrong iteration. The mount's own id * is excluded — a subflow's log opens with its mount's seed commit, so every * mount id is ALSO in the log one level down. */ export declare function homeMountOf(results: Record<string, unknown>, id: string): string | undefined; /** * The chain of mounts from the outer run down to `mount` — outermost first, * `mount` last — so a nested subflow is opened one level at a time. Undefined * when no chain reaches a step of the outer run (`isOuterStep`). */ export declare function mountChain(results: Record<string, unknown>, mount: string, isOuterStep: (id: string) => boolean): string[] | undefined; /** Did this mount's own log write `path` (engine path form)? */ export declare function subflowWrote(entry: unknown, path: string): boolean; /** Does `mount`'s own log open with the mount's seed commit (its own id first)? */ export declare function opensWithSeed(results: Record<string, unknown> | undefined, mount: string): boolean; /** Commits in `mount`'s own log (the mount's seed included); 0 when it kept none. */ export declare function innerCommitCount(results: Record<string, unknown> | undefined, mount: string): number; /** * Open `mount`'s own record — or say, in the record's terms, why it cannot be. * * The inner snapshot is the subflow's own: its history as the commit log, its * OWN fold base (`treeContext.initialState`, normally `{}` — the seed is a * commit), its tree, and its served state (under `getSnapshot({ redact: true * })` the nested mirror, so the redacted view stays redacted). It keeps the * whole flat results map, so a mount nested inside it opens the same way. */ export declare function openSubflow(snapshot: RuntimeSnapshot, mount: string): RuntimeSnapshot | string;