UNPKG

agentfootprint

Version:

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

39 lines (38 loc) • 1.85 kB
/** * scripts/inert — a dynamic value (a tool's name, a provider's call id) written * into a library line as an inline code span that cannot leave its line. * * Pattern: pure leaf. * Role: core/ layer leaf, asked by the attachment's lines (`attachment.ts`) * for every name and id they print. * Emits: N/A. * * THE RULE. A provider may hand the library any string as a call id: line * breaks, a sentence, a fence. Interpolated as it is, a blank line in an id ends * the library's label paragraph, and the rest of the id renders as a paragraph * of its own — text nobody checked, under the answer, in the library's voice. * So a value is written as inline code: * * - every character that can end a line, turn the line's direction or hide * (C0 and C1 controls, DEL, U+2028 and U+2029, format characters such as a * bidi override or a zero-width joiner, a lone surrogate) is written as * `\u{…}`, its code point in hex; * - at most {@link MAX_INERT_POINTS} code points are written, then `…`; * - the delimiter is one backtick longer than the longest run inside, with a * space at either end when the value begins or ends with a backtick or a * space (CommonMark's code-span rule), so nothing inside can close it. * * Inside a code span nothing is Markdown: no emphasis, no link, no HTML, no * line ending. The value is shown, never interpreted. * * @example * ```ts * inertCode('c1'); // '`c1`' * inertCode('c1\n\nRevenue was 98765.'); // '`c1\u{a}\u{a}Revenue was 98765.`' * inertCode('a`b'); // '``a`b``' * ``` */ /** Code points of a value written; the rest is `…`. */ export declare const MAX_INERT_POINTS = 64; /** `value` as an inline code span that stays on its line. */ export declare function inertCode(value: string): string;