/** * Skill discovery ranking for `skill_show({ query })`. The built-in ranker counts the query words * found as substrings of a skill's name and description; an extension can replace it with * {@link registerSkillRanker}, for example a model-backed ranker. */ import type { ExtensionContext } from "../../core/extensions/types.ts"; /** A skill as the ranker sees it. */ export interface SkillSearchDocument { name: string; description: string; } export interface SkillSearchMatch { name: string; score: number; } /** What a ranker may use besides the query: the caller's cancellation and session (model access). */ export interface SkillRankOptions { signal?: AbortSignal; /** Absent when the caller has no session. A ranker that needs one falls back to its own default. */ ctx?: ExtensionContext; } /** * Ranks skills for a query. Rankers may be asynchronous. Returning `undefined` (or throwing) means * "could not rank": `skill_show` falls back to the built-in ranker. Any array is authoritative: an * empty one means no skill fits, and `skill_show` reports no match without falling back. A non-empty * array whose names are all unknown to `skill_show` counts as a broken ranker and falls back. */ export interface SkillRanker { rank(query: string, documents: readonly SkillSearchDocument[], limit: number, options?: SkillRankOptions): SkillSearchMatch[] | undefined | Promise; } /** Query terms shorter than this are ignored: they match nearly everything as substrings. */ export declare const MIN_SKILL_QUERY_TERM_LENGTH = 3; /** * Ranks by how many distinct whitespace-separated query terms are case-insensitive substrings of * "name description": more terms first, ties in input order, at least one term to match. Not every * term is required, so a plain-words query still finds skills when no model ranker answers. * Always answers: an empty array when nothing matches. */ export declare const substringSkillRanker: { rank(query: string, documents: readonly SkillSearchDocument[], limit: number, _options?: SkillRankOptions | undefined): SkillSearchMatch[]; }; /** * Make `ranker` the one `skill_show({ query })` uses, until the returned function is called. * Kept on `globalThis` so every copy of this module sees the same ranker. */ export declare function registerSkillRanker(ranker: SkillRanker): () => void; /** The registered ranker, or the built-in substring ranker. */ export declare function getSkillRanker(): SkillRanker;