worker.ts 1020 B

1234567891011121314151617181920
  1. /**
  2. * The worker-thread entrypoint: self-executing glue over
  3. * `bootstrap.ts`'s {@link runWorkerMain}, kept to the spawn wiring alone.
  4. * Like `bin.ts` CLI entrypoints, this file executes only inside a spawned
  5. * worker isolate — a place the coverage provider cannot observe — so it is
  6. * excluded from the coverage gate while every line of actual logic lives in
  7. * `bootstrap.ts`, unit-tested in-process; the real spawn path is pinned by
  8. * the integration tests that run genuine workers.
  9. *
  10. * @module @deepseek-ai/dsh-code-runtime-worker/src/worker
  11. */
  12. import { parentPort, workerData } from 'node:worker_threads'
  13. import { runWorkerMain } from './bootstrap.ts'
  14. import type { WorkerBootData } from './protocol.ts'
  15. // A worker always has a parent port; guard loudly rather than run detached.
  16. if (!parentPort) throw new Error('dsh-code-runtime-worker: worker entry loaded outside a worker thread')
  17. void runWorkerMain(parentPort, workerData as WorkerBootData, { stdout: process.stdout, stderr: process.stderr })