/** * LLM-reasoned entity ranking via Claude Haiku. * * Given a pool of candidate entities (from memory-search) and a natural-language * ranking criterion, returns a ranked ordering with per-item reasoning. When the * LLM is unavailable (missing OAuth credentials, network error, schema-violating * `tool_use.input`, or all hallucinated nodeIds), returns an error reason that * callers use to produce an unranked result with a visible * "[Ranking unavailable: ...]" notice. * * Trust boundary: the `criteria` string comes from an agent (admin, public, or * workflow). The system prompt explicitly sandboxes it as a ranking directive — * any imperative verbs inside it are data, not instructions. This follows the * same pattern as email/screening.ts. * * Hallucination defence: Haiku only sees nodeIds from the candidate pool, and * the post-validator discards any nodeId in its response that is not in the * input set. If all rankings are hallucinated, we return an error. * * Output is structured by construction: forced tool-use against * `RankerOutputTool.input_schema` so Anthropic validates the response shape at * the API boundary. Markdown-fence and malformed-JSON failure modes are * impossible under this contract. */ import { type OauthLlmTool } from "../../../../../lib/oauth-llm/dist/index.js"; export interface RankCandidate { nodeId: string; labels: string[]; properties: Record; related: Array<{ relationship: string; direction: string; labels: string[]; properties: Record; }>; } export interface Ranking { nodeId: string; rank: number; reasoning: string; } export type RankResult = { kind: "ranked"; rankings: Ranking[]; hallucinated: number; } | { kind: "error"; reason: string; }; export declare const RankerOutputTool: OauthLlmTool; /** * Rank a pool of candidates against a natural-language criterion via Haiku. * * Returns: * { kind: "ranked", rankings, hallucinated } on success (hallucinated counts * nodeIds Haiku invented that were filtered out) * { kind: "error", reason } when the LLM is unavailable or its output * cannot be used — callers should return the unranked memory-search * results prefixed with "[Ranking unavailable: ]". * (vocabulary — was `kind: "fallback"`.) */ export declare function rankCandidates(candidates: RankCandidate[], criteria: string, accountId: string): Promise; //# sourceMappingURL=llm-ranker.d.ts.map