Bläddra i källkod

Merge pull request #294 from deepseek-harness/codex/simp-prune-workflow-worker-surface

refactor: narrow workflow worker surface
Tianyi Cui 2 månader sedan
förälder
incheckning
6a0bb33eab

+ 1 - 1
docs/config-catalog.md

@@ -1139,7 +1139,7 @@ export interface Config {
 }
 ```
 
-Source: [`packages/workflow/workflow-workerthread/src/index.ts:36`](../packages/workflow/workflow-workerthread/src/index.ts)
+Source: [`packages/workflow/workflow-workerthread/src/index.ts:32`](../packages/workflow/workflow-workerthread/src/index.ts)
 
 ## Loadable plugins with no config
 

+ 2 - 0
packages/workflow/workflow-workerthread/README.md

@@ -2,6 +2,8 @@
 
 This package implements `WorkflowService` with one Node worker thread per run. The worker executes the orchestration script; child agents remain on the host and are reached through `ctx.subagents` over a typed host/worker protocol.
 
+The package root exports the default engine plugin and its `Config`; the worker protocol, runtime, and session modules stay private to the implementation. The operational `./worker` entry remains the engine's spawn target.
+
 The split has one primary purpose: a synchronous script loop cannot block the harness event loop, and a script that ignores cancellation can be terminated with its worker. It is not a security sandbox.
 
 ## Trust and isolation boundary

+ 1 - 5
packages/workflow/workflow-workerthread/src/index.ts

@@ -18,11 +18,7 @@ import { validateMeta } from './meta.ts'
 import type { WorkerInit, WorkerLimits } from './types.ts'
 
 export { validateMeta } from './meta.ts'
-export { HostToWorkerType, WorkerToHostType } from './protocol.ts'
-export type { HostToWorkerMessage, HostToWorkerPayloads, WorkerToHostMessage, WorkerToHostPayloads } from './protocol.ts'
 export { materializeFromRealm, MaterializeError } from './realm.ts'
-export { WorkflowExecution, type ExecutionObserver } from './runtime.ts'
-export { requireParentPort, runWorkerSession } from './session.ts'
 export type {
   ChildHandle,
   ChildPort,
@@ -83,7 +79,7 @@ function assertBodyParses(body: string, name: string): void {
  * `result` never rejects; the `workflow/*` events fire around the run per
  * the seam contract.
  */
-export class WorkerWorkflowEngine extends WorkflowService {
+class WorkerWorkflowEngine extends WorkflowService {
   static inject = ['subagents']
 
   static Config: z<Config> = z.object({

+ 3 - 1
packages/workflow/workflow-workerthread/tests/workflow-workerthread.spec.ts

@@ -9,7 +9,8 @@ import SubagentService from '@deepseek-ai/dsh-subagent'
 import type { SubagentCapabilities, SubagentProvider, SubagentResult, SubagentRun, SubagentStartRequest } from '@deepseek-ai/dsh-subagent'
 import type { WorkflowMeta, WorkflowResult, WorkflowResultInfo, WorkflowRunInfo } from '@deepseek-ai/dsh-workflow'
 import * as workerEngineModule from '../src/index.ts'
-import WorkerWorkflowEngine, { HostToWorkerType, WorkerToHostType, type Config } from '../src/index.ts'
+import WorkerWorkflowEngine, { type Config } from '../src/index.ts'
+import { HostToWorkerType, WorkerToHostType } from '../src/protocol.ts'
 
 /** A minimal parent stand-in: the engine only threads it through to the provider. */
 function fakeParent(): Agent {
@@ -1326,6 +1327,7 @@ describe('dsh-workflow-workerthread', () => {
 
     it('has the class-plugin export shape (default = the engine service class)', () => {
       expect(workerEngineModule.default).toBe(WorkerWorkflowEngine)
+      expect('WorkerWorkflowEngine' in workerEngineModule).toBe(false)
       const loader = Object.create(Loader.prototype) as Loader
       const unwrapped: unknown = loader.unwrapExports(workerEngineModule)
       expect(unwrapped).toBe(WorkerWorkflowEngine)