()
| 4 | const startup = workerData as SemanticIndexWorkerStartupOptions |
| 5 | |
| 6 | async function main(): Promise<void> { |
| 7 | const { createSemanticIndexWorkerRuntime, createSemanticIndexWorkerServiceFactory } = |
| 8 | (await import('./worker-runtime.js')) as typeof import('./worker-runtime') |
| 9 | const runtime = createSemanticIndexWorkerRuntime({ |
| 10 | serviceFactory: createSemanticIndexWorkerServiceFactory(startup), |
| 11 | }) |
| 12 | |
| 13 | parentPort?.on('message', async (message) => { |
| 14 | const payload = message as { id: string; method: string; args?: unknown[] } |
| 15 | try { |
| 16 | const result = await runtime.handleRequest(payload.method, payload.args ?? []) |
| 17 | parentPort?.postMessage({ id: payload.id, success: true, result }) |
| 18 | } catch (error) { |
| 19 | parentPort?.postMessage({ |
| 20 | id: payload.id, |
| 21 | success: false, |
| 22 | error: error instanceof Error ? error.message : String(error), |
| 23 | }) |
| 24 | } |
| 25 | }) |
| 26 | } |
| 27 | |
| 28 | void main().catch((error) => { |
| 29 | console.error('[semantic-index] worker failed to start:', error instanceof Error ? error.message : String(error)) |
no test coverage detected