import { join } from 'path' import type { KnowledgeCapacityPreflight, KnowledgeCapacityPreflightRequest, KnowledgeIndexProgress, KnowledgeIndexRequest, KnowledgeIndexResult, KnowledgeRuntimeStatus, KnowledgeSearchRequest, KnowledgeSearchResult, KnowledgeStatusRequest } from '../../shared/knowledge' import { KnowledgeWorkerHost } from './knowledge-worker-host' /** Minimal main-process service; no renderer API is exposed in Task 0~Task 2. */ export class KnowledgeService { private readonly worker: KnowledgeWorkerHost constructor(userDataPath: string, workerPath: string) { this.worker = new KnowledgeWorkerHost(workerPath) this.databaseRoot = join(userDataPath, 'knowledge') } private readonly databaseRoot: string index( request: Omit, onProgress?: (progress: KnowledgeIndexProgress) => void ): Promise { return this.worker.index({ ...request, databaseRoot: this.databaseRoot }, onProgress) } preflight( request: Omit ): Promise { return this.worker.preflight({ ...request, databaseRoot: this.databaseRoot }) } remove(accountId: string): Promise<{ removed: true }> { return this.worker.remove(accountId, this.databaseRoot) } search(request: Omit): Promise { return this.worker.search({ ...request, databaseRoot: this.databaseRoot }) } status(request: Omit): Promise { return this.worker.status({ ...request, databaseRoot: this.databaseRoot }) } dispose(): Promise { return this.worker.dispose() } }