import Store from 'electron-store'; import { DocumentMetadata } from '../types'; const store = new Store<{ documents: Record; }>(); class VectorStoreService { private documents: Map; constructor() { this.documents = new Map(Object.entries(store.get('documents', {}))); // Add example documents if none exist if (this.documents.size === 0) { const examples: DocumentMetadata[] = [ { path: 'C:/example/llm-only', type: 'directory', lastModified: Date.now(), size: 0, hasEmbeddings: true, hasOcr: false }, { path: 'C:/example/ocr-only', type: 'directory', lastModified: Date.now(), size: 0, hasEmbeddings: false, hasOcr: true }, { path: 'C:/example/both-enabled', type: 'directory', lastModified: Date.now(), size: 0, hasEmbeddings: true, hasOcr: true } ]; examples.forEach(doc => { this.documents.set(doc.path, doc); }); store.set('documents', Object.fromEntries(this.documents)); } } public async addDocument(content: string, metadata: DocumentMetadata): Promise { // TODO: Implement vector storage this.documents.set(metadata.path, metadata); store.set('documents', Object.fromEntries(this.documents)); } public async deleteDocument(path: string): Promise { this.documents.delete(path); store.set('documents', Object.fromEntries(this.documents)); } public async updateDocument(content: string, metadata: DocumentMetadata): Promise { await this.addDocument(content, metadata); } public getDocuments(): DocumentMetadata[] { return Array.from(this.documents.values()); } } export const vectorStoreService = new VectorStoreService();