// src/application/context-storage/index.ts
import {
  EmbeddingService,
  VectorIndexer
} from "@contractspec/lib.knowledge/ingestion";
import {
  ContextSnapshotPipeline,
  PostgresContextStorage
} from "@contractspec/module.context-storage";
function createContextStorageService(options) {
  const store = new PostgresContextStorage({
    database: options.database,
    schema: options.schema,
    createTablesIfMissing: options.createTablesIfMissing
  });
  const embeddingService = options.embeddingProvider ? new EmbeddingService(options.embeddingProvider, options.embeddingBatchSize) : undefined;
  const vectorIndexer = options.vectorStoreProvider && options.vectorIndex ? new VectorIndexer(options.vectorStoreProvider, options.vectorIndex) : undefined;
  const pipeline = new ContextSnapshotPipeline({
    store,
    documentProcessor: options.documentProcessor,
    embeddingService,
    vectorIndexer
  });
  return { store, pipeline };
}
export {
  createContextStorageService
};
