UNPKG

agentfootprint

Version:

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

42 lines (41 loc) • 2.13 kB
/** * findings/peel — the answer's `_findings` peel and the stream's filter, in * the ONE module an unarmed agent never loads. * * Both run `answerText.ts`'s scanner, which only `.findings()` agents use. * The stages that need it (`callLLM`, `route`) load this module through * `import()` when the arm is on — the optional-family law of docs-next's site * budget, the same as `judge.ts` and `toolChoice/compose.ts` — so a plain * agent's bundle carries none of it. Keep every static import of * `answerText.ts` inside this file and `answerText.ts` itself; * test/core/agent/findings/peel-lazy.test.ts pins that. */ import type { FindingsDeclaration } from './types.js'; export { reservedMemberFilter, withoutReservedMembers } from './answerText.js'; export interface PeeledAnswer { /** `raw` itself unless a `_findings` member was taken out of it. */ readonly content: string; readonly findings?: FindingsDeclaration; readonly malformed?: number; /** Opt-in bounded malformed-frame diagnostic, not a parsed declaration. */ readonly attemptedMalformed?: string; readonly attemptedTruncated?: true; } /** * Take the answer's `_findings` off, wherever the answer's TEXT carries it * (9.114.2; `answerText.ts` is the rule, shared with the stream). Every JSON * object in the answer that is not inside another object — the whole answer, * a code block holding one, one written in the prose — loses its own * `_findings` member and the separator that joined it, and nothing else moves: * the model's layout and the prose around it stay as written. Identity when * nothing was removed. * * The removed values are the answer's declaration: per object the LAST one * (JSON's own rule for a repeated key — what a whole-answer `JSON.parse` read * before 9.114.2), across objects in text order, their `previous` lists * joined. A value that is not JSON, or that a cut-off text left unfinished, is * dropped and counted (`malformed`), never guessed at. */ export declare function peelAnswerFindings(raw: string, options?: { readonly captureMalformed?: true; }): PeeledAnswer;