import type { ToolSearchDocument, ToolSearchSource } from "./document.ts";
export interface Bm25Result {
    readonly name: string;
    readonly score: number;
    readonly exact: boolean;
    /** Share of the query's content terms that this document contains (0..1). */
    readonly coverage: number;
    readonly doc: ToolSearchDocument;
}
/**
 * Precision gate applied after scoring. A hit must contain at least `minCoverage`
 * of the query's content terms AND score at least `minScoreRatio` of the best
 * non-exact hit; exact-name hits always pass.
 */
export interface Bm25Precision {
    readonly minCoverage: number;
    readonly minScoreRatio: number;
}
/**
 * Half of the query's content terms and a third of the best score: a single
 * incidental term ("search" inside a six-word query) no longer surfaces an
 * unrelated tool, while a two-word query still tolerates one missing term.
 */
export declare const DEFAULT_BM25_PRECISION: Bm25Precision;
export interface Bm25SearchOptions {
    readonly source?: ToolSearchSource;
    readonly group?: string;
    /** Disable the exact-name short-circuit (used to prove BM25-alone behaviour). */
    readonly exactMatch?: boolean;
    /** Drop weak hits; omitted means every positive score is returned. */
    readonly precision?: Bm25Precision;
}
export interface Bm25Index {
    search(query: string, limit?: number, options?: Bm25SearchOptions): Bm25Result[];
}
export declare function buildBm25Index(docs: readonly ToolSearchDocument[]): Bm25Index;
/**
 * Fold the plural a tool description tends to use ("forecasts", "messages")
 * onto the singular a query tends to use. Deliberately minimal: only a trailing
 * "s" on words of four or more letters that do not end in "ss" or "us".
 */
export declare function stemToken(token: string): string;
/** Tokenise searchable text into lowercase word tokens, splitting identifiers. */
export declare function tokenizeToolText(text: string): string[];
/** Normalize a searchable name for separator- and case-insensitive exact matching. */
export declare function normalizeToolName(name: string): string;
//# sourceMappingURL=bm25.d.ts.map