agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
45 lines (44 loc) • 2.41 kB
TypeScript
/**
* middleware/rewrites — which arguments a before-tool middleware rewrote, read
* off the record: the ONE reading the answer's standing and the answer's
* "Assumed" block both take.
*
* Pattern: One pure function over committed rows. No scope, no clock; the
* input is read, never trusted.
* Role: core/agent leaf (honesty layer 2). Under the inputs layer, a
* before-tool rewrite of a RULED tool's arguments is filed on
* `middlewareDecisions` with the NAMES of the keys it changed
* (`MiddlewareDecision.changedKeys`, stamped by
* `arguments/dispatch.ts` · `withChangedKeys`) and, when the middleware
* declared one, where each value came from
* (`allow(args, why, { from })`). The layer checked the value BEFORE
* the chain ran, so a rewrite supersedes the layer's row: the value
* the call ran with is the rewrite's. Two readers must agree on that —
* `assessment/assess.ts` · `readArgumentVerdicts` (the standing) and
* `arguments/serve.ts` · `assumedBlockOf` (the "Assumed" block) —
* and both load through `import()` (the fold on first use, the block
* under the arm), so neither can own the reading for the other: it
* lives here, once, and a plain agent's graph carries it for neither.
* Emits: N/A.
*
* @example
* ```ts
* argumentRewritesOf([
* { at: 'tool', toolCallId: 'c1', changedKeys: ['window'], from: { window: 'person' }, … },
* ]).get('c1')?.get('window'); // { index: 0, origin: 'person' }
* ```
*/
/** A before-tool rewrite of one argument — the last per (call, argument). */
export interface ArgumentRewrite {
/** Where the rewrite's row sits in `middlewareDecisions` — the witness a reader points at. */
readonly index: number;
/** The middleware's declared origin for the argument (`'person' | 'app' | 'default'`), when it declared one. */
readonly origin?: string;
}
/**
* The before-tool middleware rewrites on the record — `middlewareDecisions`
* rows at `'tool'` that carry `changedKeys` — keyed by call, then argument,
* the LAST rewrite winning, because the value the call ran with is the last
* link's. Anything that is not such a row is skipped.
*/
export declare function argumentRewritesOf(decisions: unknown): ReadonlyMap<string, ReadonlyMap<string, ArgumentRewrite>>;