agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
97 lines • 4.95 kB
TypeScript
export declare function normalizeToken(raw: string): string;
/** How many digit characters a string carries. */
export declare function countDigits(v: string): number;
/**
* Split free text into candidate tokens.
*
* Used on the answer (to find values to ground) and on any tool-result text
* that is not JSON. Token boundaries are the whole point: a value that appears
* only as a SUBSTRING of an unrelated field must not read as grounded, so
* matching is always token-exact and never substring.
*/
export declare function tokenize(text: string): string[];
/**
* Answer-side spellings, before numeric canonicalization, for precision and
* exactly-two-endpoint ranges. Ordinary tokenization remains unchanged on the
* evidence and exemption sides. A non-range en-dash token is split normally by
* the caller after it has declined the range grammar.
*/
export declare function answerTokenSpellings(text: string): string[];
/**
* The spellings of one normalized value that count as the SAME value when
* looking it up.
*
* Only one rule so far, and it is a real one: an FCID is read off a switch as
* `0xef0101` and quoted back sometimes as `ef0101`. Both sides expand, so the
* prefix can be dropped by either the tool or the model without either being
* accused of inventing it.
*
* Deliberately NOT here (9.110.0): a glued-unit number's bare form. Applied
* on the INDEX side it would let a result's `latency 2024ms` ground an
* answer's prose year `2024`, which weakens the gate; the glued spelling is
* met on the LOOKUP side only, by the candidate that came from one
* (`evidence/extract.ts · candidateForms`).
*/
export declare function lookupForms(normalized: string): readonly string[];
/**
* The one spelling every equivalent value shares — the LAST of
* `lookupForms`, so `0xef0101` and `ef0101` both canonicalise to `ef0101`.
* A reader that must file one thing per VALUE (`findings/contingent.ts`,
* one row per value per moment) keys on this rather than on the spelling
* the model happened to use.
*/
export declare function canonicalForm(normalized: string): string;
/** Text as compared: Unicode NFC, trimmed, every run of white space one space. */
export declare const textOf: (value: string) => string;
/**
* A full Unicode case fold WITHOUT the Turkic mappings: each character
* upper- then lower-cased on its own (so `ß` and `ẞ` fold to `ss`, `fi` to
* `fi`, a final `ς` to `σ`), except the dotless `ı`, which stays `ı`. It
* never decides agreement (`caseOnly` does, on the letters as written): two
* texts it folds alike are only texts the comparison cannot tell apart.
*/
export declare const foldCase: (text: string) => string;
/**
* A text's bare letters: compatibility forms unified (NFKC: a ligature, the
* long s, a full-width letter, a superscript digit), case folded, every mark
* dropped (an accent, the Greek tonos, the dot over `İ`) and the dotless
* `ı` read as `i`. Only to tell texts that differ in no letter from a
* contradiction: two texts alike here are never compared.
*/
export declare const bareLetters: (text: string) => string;
export declare const hasDigit: (text: string) => boolean;
/** How a word is cased: all lower, all upper, a capital first letter, or mixed. */
export declare function casing(word: string): 'lower' | 'upper' | 'capitalized' | 'mixed';
/**
* A word the case rule compares across casings (`caseOnly`): letters only,
* more than three of them, cased all lower, all upper or with a capital first
* letter. The rule cannot tell where such a word's case carries meaning
* (`Polish`, `polish`). A short word (`MW`, `Co`), a mixed-case one
* (`aB3xZ9`, `iPhone`) and anything with a digit or another mark keeps its
* case as written.
*/
export declare const foldableWord: (word: string) => boolean;
/**
* Two word texts that differ in case alone: as many words, and every word
* that differs is a foldable word with the same letters, letter for letter,
* in another case — its locale-free lower case (`toLowerCase`) is the
* other's: `Settled` and `SETTLED`, `STRAẞE` and `Straße` (`ẞ` is the capital
* of `ß`). Letters are compared as written, before any fold, so `ß` is never
* `ss`: `Masse`, `maße`, `MAẞE` and `MASSE` against `Maße` differ in letters.
*/
export declare function caseOnly(a: string, b: string): boolean;
/**
* Whether two names are ONE name: the same text (`textOf`), or texts with no
* digit that differ in the case of foldable words alone (`caseOnly`) — the
* claim comparator's `agrees`. `payments` / `PAYMENTS` are one name;
* `ARRAY-X9` / `array-x9` (a digit), `MW` / `mW` (a short word) and `iPhone` /
* `iphone` (mixed case) are not.
*
* @example
* ```ts
* sameName('Payments', 'payments'); // true
* sameName('MW', 'mW'); // false
* ```
*/
export declare function sameName(a: string, b: string): boolean;
//# sourceMappingURL=normalize.d.ts.map