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.14 kB
TypeScript
/**
* detect — the prose grammar: which units of a reply state a negative claim, by a fixed list of
* phrases and nothing else (no model, no score).
*
* Pattern: units (`units.ts`) → language (`language.ts`) → the `none` and `complete` packs
* (`phrases.ts`, matched by `matcher.ts`). A hedge is not scope and changes nothing here:
* "based on the logs, there are no incidents" is a claim. A unit in a fenced block, or a
* claim phrase entirely inside inline code, is NOTED (`in-code-block`, with the
* phrase's span), not judged; a unit the English grammar cannot read is NOTED
* (`language-unsupported`) — never a silent pass.
* Role: integrity/ layer (L3), read by `prose.ts`. Pure and deterministic; linear in the text.
*
* A claim carries its span, its unit, its phrase id and the pack version. Its unit's tokens ride
* along for the resolver; rows built from a claim carry none of the text.
*/
import { type ResolvedNegativeClaimPhrases } from './phrases.js';
import { type TextSpan } from './units.js';
import { type Token } from './matcher.js';
export type ProseClaimKind = 'none' | 'complete';
/** One detected claim. */
export interface DetectedClaim {
readonly kind: ProseClaimKind;
readonly phraseId: string;
readonly packVersion: string;
/** The claim phrase's span in the text as given. */
readonly span: TextSpan;
/** The unit (clause) the claim is read in. */
readonly unit: TextSpan;
/** The unit's tokens — for the resolver; never written to a row. */
readonly tokens: readonly Token[];
}
/** A unit that could not be judged, said out loud. */
export interface DetectionNote {
readonly code: 'in-code-block' | 'language-unsupported';
readonly span: TextSpan;
readonly phraseId?: string;
readonly packVersion: string;
}
export interface Detection {
readonly claims: readonly DetectedClaim[];
readonly notes: readonly DetectionNote[];
}
/** Detect the negative claims of a reply. */
export declare function detectNegativeClaims(text: string, phrases?: ResolvedNegativeClaimPhrases): Detection;