1
0

source-worker.compat.spec.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Keyless runtime smoke for the source-mode workflow worker. The Node
  3. * compatibility matrix runs this WHOLE file, so renaming or removing its test
  4. * cannot turn the runtime proof into a successful zero-match filter.
  5. */
  6. import { expect, it, vi } from 'vitest'
  7. import { Context } from '@deepseek-ai/cordis'
  8. import type { Agent } from '@deepseek-ai/dsh-agent'
  9. import SubagentRuntime from '@deepseek-ai/dsh-subagent'
  10. import type { SubagentProvider } from '@deepseek-ai/dsh-subagent'
  11. import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection'
  12. import WorkerThreadWorkflowEngine from '../src/index.ts'
  13. import { SessionId } from '@deepseek-ai/dsh-session'
  14. // A fresh thread compiles the source runtime. Leave contention headroom on
  15. // shared CI runners without weakening any engine-level timeout assertion.
  16. vi.setConfig({ testTimeout: 30_000 })
  17. it('runs the default config through the source worker', async () => {
  18. const ctx = new Context()
  19. await ctx.plugin(SessionProjectionRegistry)
  20. const subagents = await ctx.plugin(SubagentRuntime)
  21. const provider: SubagentProvider = {
  22. name: 'spawn',
  23. capabilities: { agentOptions: true, outputSchema: true, depthLimit: true, toolFilter: true, persona: true },
  24. inheritsParentContext: false,
  25. start: () => Promise.reject(new Error('source-worker compat script must not start a child')),
  26. }
  27. ctx.subagents.registerProvider(provider)
  28. const engine = await ctx.plugin(WorkerThreadWorkflowEngine, {})
  29. const parent = { id: SessionId('workflow-compat-parent'), options: {} } as unknown as Agent
  30. try {
  31. const run = ctx.workflowEngine.start({
  32. script: 'return 6 * 7',
  33. meta: { name: 'source-worker-compat', description: 'exercise the unbuilt worker entry' },
  34. parent,
  35. })
  36. try {
  37. await expect(run.result).resolves.toMatchObject({ value: 42, stopReason: 'completed', agentsStarted: 0 })
  38. } finally {
  39. await run.dispose()
  40. }
  41. } finally {
  42. await engine.dispose()
  43. await subagents.dispose()
  44. }
  45. })