Interface UnifiedRetrieverDeps

Dependencies injected into the UnifiedRetriever.

All dependencies are optional — the retriever gracefully skips sources whose dependencies are not provided. This allows incremental adoption: start with just vector + BM25, then add GraphRAG, RAPTOR, memory, etc.

Example

const deps: UnifiedRetrieverDeps = {
hybridSearcher: myHybridSearcher,
rerank: async (q, chunks, n) => chunks.slice(0, n),
emit: (event) => console.log(event.type),
};
interface UnifiedRetrieverDeps {
    hybridSearcher?: HybridSearcher;
    collectionName?: string;
    raptorTree?: RaptorTree;
    graphEngine?: IGraphRAGEngine;
    memoryManager?: ICognitiveMemoryManager;
    hydeRetriever?: HydeRetriever;
    multimodalIndexer?: MultimodalIndexer;
    vectorSearch?: ((query, topK) => Promise<RetrievedChunk[]>);
    rerank?: ((query, chunks, topN) => Promise<RetrievedChunk[]>);
    deepResearch?: ((query, sources) => Promise<{
        synthesis: string;
        sources: RetrievedChunk[];
    }>);
    decompose?: ((query, maxSubQueries) => Promise<string[]>);
    emit?: ((event) => void);
    rrfK?: number;
    defaultTopK?: number;
    maxSubQueries?: number;
    memoryCacheThreshold?: number;
    defaultMood?: {
        valence: number;
        arousal: number;
        dominance: number;
    };
}

Properties

hybridSearcher?: HybridSearcher

Hybrid dense+sparse searcher (vector + BM25). When provided, enables the vector and bm25 sources.

collectionName?: string

Vector store collection name for hybrid search.

Default

'knowledge-base'
raptorTree?: RaptorTree

RAPTOR hierarchical summary tree. When provided, enables the raptor source.

graphEngine?: IGraphRAGEngine

GraphRAG engine for entity/relationship traversal. When provided, enables the graph source.

memoryManager?: ICognitiveMemoryManager

Cognitive memory manager. When provided, enables the memory source and memory feedback loop.

hydeRetriever?: HydeRetriever

HyDE (Hypothetical Document Embedding) retriever. When provided and plan.hyde.enabled is true, generates hypothetical answers before embedding for improved recall.

multimodalIndexer?: MultimodalIndexer

Multimodal indexer for image/audio/video search. When provided, enables the multimodal source.

vectorSearch?: ((query, topK) => Promise<RetrievedChunk[]>)

Vector search function (fallback when hybridSearcher is not available).

Type declaration

    • (query, topK): Promise<RetrievedChunk[]>
    • Parameters

      • query: string

        The search query.

      • topK: number

        Maximum results to return.

      Returns Promise<RetrievedChunk[]>

Returns

Retrieved chunks.

rerank?: ((query, chunks, topN) => Promise<RetrievedChunk[]>)

Cross-encoder or LLM-based reranker.

Type declaration

    • (query, chunks, topN): Promise<RetrievedChunk[]>
    • Parameters

      • query: string

        The user query for relevance scoring.

      • chunks: RetrievedChunk[]

        Candidate chunks to rerank.

      • topN: number

        Maximum chunks to keep after reranking.

      Returns Promise<RetrievedChunk[]>

Returns

Reranked chunks.

deepResearch?: ((query, sources) => Promise<{
    synthesis: string;
    sources: RetrievedChunk[];
}>)

Deep research synthesis callback.

Type declaration

    • (query, sources): Promise<{
          synthesis: string;
          sources: RetrievedChunk[];
      }>
    • Parameters

      • query: string

        The user query.

      • sources: string[]

        Source hints for research.

      Returns Promise<{
          synthesis: string;
          sources: RetrievedChunk[];
      }>

Returns

Synthesis narrative and source chunks.

decompose?: ((query, maxSubQueries) => Promise<string[]>)

Query decomposition callback for complex strategies.

Type declaration

    • (query, maxSubQueries): Promise<string[]>
    • Parameters

      • query: string

        The original multi-part query.

      • maxSubQueries: number

        Maximum sub-queries to generate.

      Returns Promise<string[]>

Returns

Array of decomposed sub-query strings.

emit?: ((event) => void)

Event listener callback for retrieval lifecycle events.

Type declaration

rrfK?: number

RRF constant k. Higher values flatten score differences.

Default

60
defaultTopK?: number

Default topK for final results.

Default

10
maxSubQueries?: number

Maximum sub-queries for complex decomposition.

Default

5
memoryCacheThreshold?: number

Memory cache hit confidence threshold. Episodic memories above this confidence skip external sources.

Default

0.85
defaultMood?: {
    valence: number;
    arousal: number;
    dominance: number;
}

Default PAD mood state for memory operations. Used when no mood context is available.

Type declaration

  • valence: number
  • arousal: number
  • dominance: number