source-worker.compat.spec.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 'cordis'
  8. import type { Agent } from '@deepseek-ai/dsh-agent'
  9. import SubagentService from '@deepseek-ai/dsh-subagent'
  10. import type { SubagentProvider } from '@deepseek-ai/dsh-subagent'
  11. import WorkerWorkflowEngine from '../src/index.ts'
  12. import { SessionId } from '@deepseek-ai/dsh-session'
  13. // A fresh thread compiles the source runtime. Leave contention headroom on
  14. // shared CI runners without weakening any engine-level timeout assertion.
  15. vi.setConfig({ testTimeout: 30_000 })
  16. it('runs the default config through the source worker', async () => {
  17. const ctx = new Context()
  18. const subagents = await ctx.plugin(SubagentService)
  19. const provider: SubagentProvider = {
  20. name: 'spawn',
  21. capabilities: { outputSchema: true, depthLimit: true, toolFilter: true, persona: true },
  22. inheritsParentContext: false,
  23. start: () => Promise.reject(new Error('source-worker compat script must not start a child')),
  24. }
  25. ctx.subagents.registerProvider(provider)
  26. const engine = await ctx.plugin(WorkerWorkflowEngine, {})
  27. const parent = { id: SessionId('workflow-compat-parent'), options: {} } as unknown as Agent
  28. try {
  29. const run = ctx.workflows.start({
  30. script: 'return 6 * 7',
  31. meta: { name: 'source-worker-compat', description: 'exercise the unbuilt worker entry' },
  32. parent,
  33. })
  34. try {
  35. await expect(run.result).resolves.toMatchObject({ value: 42, stopReason: 'completed', agentsStarted: 0 })
  36. } finally {
  37. await run.dispose()
  38. }
  39. } finally {
  40. await engine.dispose()
  41. await subagents.dispose()
  42. }
  43. })