import type { Message, Session, ToolCall } from "../types/index.js"; import type { Embedder } from "./embeddings.js"; import { type SearchHit, type SearchOptions, type ToolCallHit } from "./search.js"; export declare const MAX_VARIANT_TERMS = 8; export declare const MAX_EVIDENCE_PER_RESULT = 8; export declare const MAX_TOOL_CALLS_PER_RESULT = 8; export declare const MAX_CONTEXT_MESSAGES_PER_RESULT = 24; export declare const MAX_CONTEXT_TOOL_CALLS_PER_RESULT = 64; export declare const MAX_RECENT_TOOL_CALLS_PER_RESULT = 12; export interface RecallOptions extends SearchOptions { /** Max results to return. */ limit?: number; /** * Whether to use semantic search when possible. Defaults to true, but it * degrades to lexical/tool/graph recall if embeddings or API credentials are * unavailable. */ semantic?: boolean; /** Deterministic fake embedders can be injected in tests. */ embedder?: Embedder; } export interface RecallEvidence { kind: "message" | "session" | "tool_call" | "semantic" | "graph"; signal: string; snippet: string; score?: number; } export interface RecallToolCall { id: string; tool_name: string; status: string | null; timestamp: string | null; snippet: string; input_preview: string | null; output_preview: string | null; } export interface CodingThreadEntities { file_paths: string[]; tool_names: string[]; commands: string[]; repos: string[]; branches: string[]; commits: string[]; } export interface RecallGraphContext { project: string | null; model: string | null; provider: string | null; repo: string | null; branch: string | null; commit: string | null; tools: string[]; } export interface RecallResume { available: boolean; command: string[] | null; shell_command: string | null; reason: string | null; } export interface RecallResult { session_id: string; source: string; source_id: string; source_path: string | null; title: string | null; project_name: string | null; project_path: string | null; started_at: string | null; updated_at: string | null; rank: number; score: number; reason: string; evidence: RecallEvidence[]; matching_tool_calls: RecallToolCall[]; touched_file_paths: string[]; coding_entities: CodingThreadEntities; related_graph_entities: RecallGraphContext; resume: RecallResume; } export interface RecallMetadata { query: string; query_variants: string[]; significant_terms: string[]; semantic: { attempted: boolean; status: "used" | "skipped" | "failed"; stored_embeddings: number; openai_api_key_present: boolean; reason: string | null; }; signals: Record; } export interface RecallResponse { query: string; count: number; results: RecallResult[]; metadata: RecallMetadata; } interface QueryVariant { query: string; label: string; weight: number; } export interface Candidate { sessionId: string; score: number; signals: Record; evidence: RecallEvidence[]; toolHitSnippets: string[]; } export declare function recallSessions(query: string, opts?: RecallOptions): Promise; export declare function buildQueryVariants(query: string, terms?: string[]): QueryVariant[]; export declare function significantTerms(query: string): string[]; export declare function extractCodingEntities(session: Session, messages: Message[], toolCalls: ToolCall[]): CodingThreadEntities; export declare function addSearchHits(candidates: Map, hits: SearchHit[], options: { kind: RecallEvidence["kind"]; signal: string; weight: number; scoreFromRank?: boolean; }): void; export declare function addToolHits(candidates: Map, hits: ToolCallHit[], options: { signal: string; weight: number; }): void; export declare function addCandidate(candidates: Map, sessionId: string, score: number, evidence?: RecallEvidence): Candidate; export declare function addEvidence(evidence: RecallEvidence[], next: RecallEvidence): void; export declare function shouldUseRecentFallback(query: string, terms: string[]): boolean; export declare function buildReason(candidate: Candidate, evidence: RecallEvidence[], toolCalls: RecallToolCall[], entities: CodingThreadEntities): string; export declare function evidencePriority(kind: RecallEvidence["kind"]): number; export declare function selectMatchingToolCalls(toolCalls: ToolCall[], terms: string[], query: string, toolHitSnippets: string[]): RecallToolCall[]; export declare function snippetForToolCall(toolCall: ToolCall, terms: string[], query: string): string; export declare function snippetAround(text: string, needles: string[]): string; export declare function preview(value: string | null | undefined, max?: number): string | null; export declare function buildResumeMetadata(session: Session): RecallResume; export declare function stripFtsMarkers(value: string): string; export {}; //# sourceMappingURL=recall.d.ts.map