/**
 * Clustering Service - Orchestrates document clustering pipeline
 *
 * Pipeline:
 *   1. Fetch document-level embeddings (average-pool chunk embeddings, L2-normalize)
 *   2. Call Python clustering worker (HDBSCAN / agglomerative / kmeans)
 *   3. Store cluster + document_cluster records with provenance
 *
 * CRITICAL: NEVER use console.log() - stdout is JSON-RPC protocol.
 * Use console.error() for all logging.
 *
 * @module services/clustering/clustering-service
 */
import Database from 'better-sqlite3';
import { DatabaseService } from '../storage/database/index.js';
import { VectorService } from '../storage/vector.js';
import type { ClusterRunConfig, ClusterRunResult } from '../../models/cluster.js';
/** Document with its average-pooled embedding */
interface DocumentEmbedding {
    document_id: string;
    embedding: Float32Array;
    chunk_count: number;
}
/**
 * Compute document-level embeddings by average-pooling chunk embeddings.
 *
 * For each document that has embeddings, fetches all chunk-based vectors
 * from vec_embeddings, computes the element-wise mean, and L2-normalizes.
 *
 * sqlite-vec has NO native vector averaging -- we extract to TypeScript.
 *
 * @param conn - Raw better-sqlite3 connection (for direct vec_embeddings queries)
 * @param documentIds - Optional filter; if empty, includes all documents with embeddings
 * @returns Array of DocumentEmbedding with 768-dim Float32Array per document
 */
export declare function computeDocumentEmbeddings(conn: Database.Database, documentIds?: string[]): DocumentEmbedding[];
/**
 * Compute cosine similarity between a document embedding and a centroid.
 * Both vectors are assumed to be L2-normalized, so similarity = dot product.
 */
export declare function cosineSimilarity(a: Float32Array | number[], b: number[]): number;
/**
 * Run the full clustering pipeline:
 *   1. Compute document-level embeddings
 *   2. Validate minimum document count
 *   3. Call Python clustering worker
 *   4. Create provenance records
 *   5. Store clusters + document_cluster assignments
 *
 * @param db - DatabaseService instance
 * @param vector - VectorService instance (unused directly but validates vec loaded)
 * @param config - Clustering configuration
 * @param documentIds - Optional filter (empty = all documents with embeddings)
 * @returns ClusterRunResult with full results
 */
export declare function runClustering(db: DatabaseService, _vector: VectorService, config: ClusterRunConfig, documentIds?: string[]): Promise<ClusterRunResult>;
export {};
//# sourceMappingURL=clustering-service.d.ts.map