/**
 * Knowledge Search Service
 *
 * Provides pluggable search strategies for knowledge documents.
 * Defaults to `Fts5SearchStrategy` (SQLite FTS5 with native BM25
 * ranking) and falls back to `KeywordSearchStrategy` for docs not
 * yet indexed. The Gemini embedding and local-vector strategies
 * remain available for callers that need semantic similarity but
 * are no longer wired as the default.
 *
 * @module services/knowledge/knowledge-search.service
 */
import type { KnowledgeDocumentSummary, KnowledgeScope } from '../../types/knowledge.types.js';
/**
 * Apply temporal decay to a search score (#154).
 * Score decays by half every TEMPORAL_DECAY_HALF_LIFE_DAYS days.
 * Documents tagged with evergreen/decision tags bypass decay entirely.
 *
 * @param score - Raw relevance score
 * @param createdAt - ISO timestamp of document creation
 * @param tags - Document tags
 * @returns Decayed score
 */
export declare function applyTemporalDecay(score: number, createdAt: string, tags: string[]): number;
/**
 * A document scored by a search strategy.
 */
export interface ScoredDocument {
    /** The matched document summary */
    document: KnowledgeDocumentSummary;
    /** Relevance score (higher is more relevant) */
    score: number;
}
/**
 * Search options passed to strategies.
 */
export interface SearchOptions {
    scope?: KnowledgeScope;
    projectPath?: string;
    category?: string;
    limit?: number;
}
/**
 * Strategy interface for scoring documents against a query.
 */
export interface KnowledgeSearchStrategy {
    /**
     * Score documents against a query. Returns documents sorted by relevance.
     *
     * @param query - The search query
     * @param documents - Candidate documents to score (may be ignored by some strategies)
     * @param options - Optional scope and filtering parameters
     * @returns Documents sorted by descending score
     */
    search(query: string, documents: KnowledgeDocumentSummary[], options?: SearchOptions): Promise<ScoredDocument[]>;
}
/**
 * Keyword-based search strategy (default fallback, zero dependencies).
 *
 * Splits the query into words and scores documents by matching against
 * title (3x weight), tags (2x weight), and preview (1x weight).
 */
export declare class KeywordSearchStrategy implements KnowledgeSearchStrategy {
    /**
     * Score documents using keyword matching.
     *
     * @param query - Search query text
     * @param documents - Documents to score
     * @param options - Optional search parameters (ignored)
     * @returns Scored documents sorted by relevance
     */
    search(query: string, documents: KnowledgeDocumentSummary[], options?: SearchOptions): Promise<ScoredDocument[]>;
}
/**
 * SQLite FTS5-based search strategy (V2 Default).
 *
 * Utilizes the FTS5 virtual table for lightning-fast full-text search
 * with native BM25 ranking. Bypasses the memory-intensive candidate
 * listing for large knowledge bases.
 */
export declare class Fts5SearchStrategy implements KnowledgeSearchStrategy {
    private readonly logger;
    private readonly fallback;
    private readonly globalFts5;
    private readonly projectFts5Cache;
    constructor();
    private getProjectFts5;
    search(query: string, documents: KnowledgeDocumentSummary[], options?: SearchOptions): Promise<ScoredDocument[]>;
}
/**
 * Gemini embedding-based semantic search strategy.
 *
 * @deprecated Use Fts5SearchStrategy for technical knowledge.
 * Semantic search is now primarily for Agent Memory via MemoryService.
 *
 * Calls the Gemini Embedding API to embed query text, then computes
 * cosine similarity against document embeddings. Falls back to
 * KeywordSearchStrategy if the API call fails.
 */
export declare class GeminiEmbeddingStrategy implements KnowledgeSearchStrategy {
    private readonly apiKey;
    private readonly fallback;
    private readonly logger;
    /**
     * Creates a GeminiEmbeddingStrategy instance.
     *
     * @param apiKey - Gemini API key for embedding requests
     */
    constructor(apiKey: string);
    /**
     * Embed a single text string via the Gemini API.
     *
     * @param text - Text to embed
     * @returns Embedding vector, or null on failure
     */
    private embed;
    /**
     * Score documents using Gemini embeddings and cosine similarity.
     * Falls back to keyword search if embedding fails.
     *
     * @param query - Search query text
     * @param documents - Documents to score
     * @param options - Optional search parameters
     * @returns Scored documents sorted by relevance
     */
    search(query: string, documents: KnowledgeDocumentSummary[], options?: SearchOptions): Promise<ScoredDocument[]>;
}
/**
 * Local vector search strategy using SQLite-backed VectorStoreService.
 *
 * @deprecated Use Fts5SearchStrategy for primary knowledge retrieval.
 *
 * Stores embeddings locally on-device so that recall works offline.
 * Uses the Gemini API to generate embeddings (when available) and
 * persists them in the local vector store. Subsequent searches skip
 * the embedding API for documents that already have stored vectors.
 * Falls back to keyword search when no API key is configured or
 * when embedding generation fails.
 */
export declare class LocalVectorSearchStrategy implements KnowledgeSearchStrategy {
    private readonly vectorStore;
    private readonly apiKey;
    private readonly fallback;
    private readonly logger;
    /**
     * Creates a LocalVectorSearchStrategy instance.
     *
     * @param apiKey - Optional Gemini API key for generating embeddings
     */
    constructor(apiKey?: string);
    /**
     * Embed a single text string via the Gemini API.
     *
     * @param text - Text to embed
     * @returns Embedding vector, or null on failure
     */
    private embed;
    /**
     * Get or create an embedding for a document, persisting it locally.
     *
     * @param docId - Document identifier
     * @param docText - Text to embed (used only if no stored embedding)
     * @param scope - Storage scope
     * @param projectPath - Project path for project scope
     * @returns The embedding vector, or null if unavailable
     */
    private getOrCreateEmbedding;
    /**
     * Score documents using local vector search with cosine similarity.
     * Falls back to keyword search when embeddings are unavailable.
     *
     * @param query - Search query text
     * @param documents - Documents to score
     * @param options - Optional search parameters
     * @returns Scored documents sorted by relevance
     */
    search(query: string, documents: KnowledgeDocumentSummary[], options?: SearchOptions): Promise<ScoredDocument[]>;
}
/**
 * BM25-inspired keyword scoring for hybrid search (#152).
 *
 * Computes a simplified BM25-like score for a document against a query.
 * Uses term frequency with diminishing returns (k1 saturation).
 *
 * @param query - Search query text
 * @param docText - Document text to score
 * @returns BM25-inspired score (higher is better)
 */
export declare function bm25Score(query: string, docText: string): number;
/**
 * Hybrid search strategy: vector similarity (70%) + BM25 keywords (30%) (#152).
 *
 * Combines semantic vector search with BM25 keyword matching for more
 * accurate retrieval. Proper nouns, technical terms, and IDs are caught
 * by BM25 while conceptual matches come from vector similarity.
 */
export declare class HybridSearchStrategy implements KnowledgeSearchStrategy {
    private readonly vectorStrategy;
    private readonly keywordStrategy;
    private readonly logger;
    private readonly vectorWeight;
    private readonly keywordWeight;
    constructor(apiKey?: string, vectorWeight?: number, keywordWeight?: number);
    search(query: string, documents: KnowledgeDocumentSummary[], options?: SearchOptions): Promise<ScoredDocument[]>;
}
/**
 * Knowledge Search Service singleton.
 *
 * Strategy selection priority:
 * 1. Fts5SearchStrategy (V2 Default — SQLite FTS5)
 * 2. HybridSearchStrategy (when embedding API key is set — vector 70% + BM25 30%) (#152)
 * 3. KeywordSearchStrategy (default, zero dependencies)
 */
export declare class KnowledgeSearchService {
    private static instance;
    private readonly strategy;
    private readonly logger;
    private constructor();
    /**
     * Get the singleton instance.
     *
     * @returns KnowledgeSearchService instance
     */
    static getInstance(): KnowledgeSearchService;
    /**
     * Reset the singleton (for testing).
     */
    static resetInstance(): void;
    /**
     * Search knowledge documents using the configured strategy.
     *
     * @param query - Search query text
     * @param scope - Document scope ('global' or 'project')
     * @param projectPath - Project path (required when scope is 'project')
     * @param category - Optional category filter
     * @param limit - Maximum number of results (default 5)
     * @returns Matching document summaries sorted by relevance
     */
    search(query: string, scope: KnowledgeScope, projectPath?: string, category?: string, limit?: number): Promise<KnowledgeDocumentSummary[]>;
}
//# sourceMappingURL=knowledge-search.service.d.ts.map