export type { Lens, HydeTargetCorpus } from '../hyde/lens.inferrer.js'; /** A single lens embedding ready for search. */ export interface LensEmbedding { /** Free-text lens label (e.g. "crypto infrastructure VC"). */ lens: string; /** Which corpus to search. */ corpus: 'profiles' | 'intents' | 'premises'; /** 2000-dim embedding vector. */ embedding: number[]; } /** Options for searchWithHydeEmbeddings (network scope, limits, min score). */ export interface HydeSearchOptions { /** Network IDs to scope the search (members / assigned intents only). */ indexScope: string[]; /** Exclude this user ID from results (e.g. source intent owner). */ excludeUserId?: string; /** Max results per lens before merge (default 10). */ limitPerStrategy?: number; /** Max results after merge/rank (default 20). */ limit?: number; /** Minimum cosine similarity for intent searches (default 0.40). */ minScore?: number; /** * Discovery corpus gating, composed by the caller (defaults preserve legacy behavior). * Omitted fields default to: intents true, profile true, profileCorpus 'premise'. */ corpusGating?: { /** Search the intents corpus. */ intents?: boolean; /** Search the active profile corpus. */ profile?: boolean; /** Which corpus backs 'profiles' lens hints and profile searches. */ profileCorpus?: 'premise' | 'user_context'; }; } /** A single candidate from HyDE search (intent, premise, or user_context), with score and which lens matched. */ export interface HydeCandidate { type: 'intent' | 'premise' | 'user_context'; id: string; userId: string; score: number; /** Free-text lens label that produced this match. */ matchedVia: string; networkId: string; /** Candidate document text (populated for user_context matches; used as candidatePayload). */ text?: string; /** Set after merge when user matched via multiple lenses. */ matchedLenses?: string[]; } export interface EmbeddingGenerateOptions { signal?: AbortSignal; } export interface EmbeddingGenerator { generate(text: string | string[], dimensions?: number, options?: EmbeddingGenerateOptions): Promise; } export interface VectorSearchResult { item: T; score: number; } export type VectorStoreOption = { limit?: number; filter?: Record; candidates?: (T & { embedding?: number[] | null; })[]; minScore?: number; }; export interface VectorStore { /** * Search for similar items in the vector store. * * @param queryVector - The embedding vector to search for * @param collection - The logical name of the collection (e.g., 'profiles', 'intents') * @param options - generic options including limit, filter, and candidates */ search(queryVector: number[], collection: string, options?: VectorStoreOption): Promise[]>; } /** * Embedder: generate embeddings and run vector / HyDE search. * Implementations: OpenAI/OpenRouter for generate, pgvector for search. */ export interface Embedder extends EmbeddingGenerator, VectorStore { /** * Multi-lens HyDE search: run one vector search per lens embedding, * then merge, deduplicate by userId, and rank (boost for multiple lens matches). * * @param lensEmbeddings - Array of lens embeddings to search with * @param options - indexScope, excludeUserId, limits, minScore * @returns Deduplicated, ranked candidates (intent or premise) with scores */ searchWithHydeEmbeddings(lensEmbeddings: LensEmbedding[], options: HydeSearchOptions): Promise; }