agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
27 lines (26 loc) • 1.5 kB
TypeScript
/**
* classify/mock — a scripted `Classifier` for tests and the bench.
*
* Pattern: the `mock()` LLM provider's shape — a script, replayed in order,
* or a function of the request; every request recorded on `calls`.
* Role: the one classifier the suite and `bench/findings-shuffle.mjs`
* may run without a key. It produces exactly what its script says
* (a scripted distribution is still the SCRIPT's data, never the
* library's guess) and throws exactly what the script throws, so a
* failure path is testable to the byte.
*/
import { type Classifier, type ClassifyRequest, type ClassifyResult } from './types.js';
/** A classifier that answers from a script and records what it was asked. */
export interface MockClassifier extends Classifier {
/** Every request, in call order — plain references to what the caller passed. */
readonly calls: readonly ClassifyRequest[];
}
export type MockClassifierScript = readonly ClassifyResult[] | ((request: ClassifyRequest, index: number) => ClassifyResult | Promise<ClassifyResult>);
/**
* `mockClassifier([r1, r2])` answers r1 then r2 and refuses a third call
* (`ClassifierError`, so the exhaustion is a failure row, never a repeat);
* `mockClassifier((req, i) => …)` computes each answer, and may throw to
* script a failure. `name` is `'mock'`; the result's `model` is the
* script's own.
*/
export declare function mockClassifier(script: MockClassifierScript): MockClassifier;