agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
26 lines (25 loc) • 1.17 kB
TypeScript
import type { Embedder, PairwiseSimilarityResult, SimilarityItem } from './types.js';
export interface PairwiseSimilarityArgs {
/** The texts to compare — e.g. `{ id: toolName, text: description }`. */
readonly items: readonly SimilarityItem[];
/**
* Injected embedder. Wrap in an `EmbeddingCache` so catalog
* descriptions embed once across lint runs (RFC-002 §3).
*/
readonly embedder: Embedder;
/** Abort signal threaded to the embedder (network backends). */
readonly signal?: AbortSignal;
}
/**
* Embed every item once (deduplicated batch) and compute the full
* cosine matrix plus ranked upper-triangle pairs (descending; ties
* keep input pair order).
*
* Invariants (pinned by property tests):
* - `matrix[i][j] === matrix[j][i]` — computed once, mirrored.
* - `matrix[i][i] === 1` EXACTLY — set by definition, so
* self-similarity is an invariant rather than a float artifact
* (and duplicate texts at different ids still compare via cosine).
* - N items → N·(N−1)/2 pairs.
*/
export declare function pairwiseSimilarity(args: PairwiseSimilarityArgs): Promise<PairwiseSimilarityResult>;