worker.ts 894 B

123456789101112131415161718
  1. /**
  2. * The worker-thread entry the engine spawns: bootstrap ./session.ts on the
  3. * real `parentPort`. Deliberately a single statement — every piece of logic
  4. * lives in `runWorkerSession`, which the unit suite drives in-process over a
  5. * `MessageChannel` (code inside a real Worker is invisible to main-process
  6. * coverage); loading this module on the main thread throws via
  7. * `requireParentPort`, which is how the suite covers the file itself.
  8. *
  9. * @module @deepseek-ai/dsh-workflow-workerthread/worker
  10. */
  11. import { parentPort, workerData } from 'node:worker_threads'
  12. import { requireParentPort, runWorkerSession } from './session.ts'
  13. import type { WorkerInit } from './types.ts'
  14. // workerData is `any` at the node:worker_threads boundary; the engine is the
  15. // only spawner and always provides a WorkerInit.
  16. void runWorkerSession(requireParentPort(parentPort), workerData as WorkerInit)