echo.e2e.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { fileURLToPath } from 'node:url'
  2. import { describe, expect, it } from 'vitest'
  3. import { LOADER_SMOKE_TEST_TIMEOUT_MS, runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
  4. /**
  5. * Keyless-by-nature Loader-path coverage for examples/echo-agent. The real
  6. * tree uses its deterministic mock model, so this suite is both the boot smoke
  7. * and the complete behavior proof for the example.
  8. */
  9. const binScript = fileURLToPath(new URL('../../../packages/examples/stdio-demo/src/bin.ts', import.meta.url))
  10. const configPath = fileURLToPath(new URL('../cordis.yml', import.meta.url))
  11. const tsconfigPath = fileURLToPath(new URL('../../../tsconfig.json', import.meta.url))
  12. async function runEcho(stdinLines: readonly string[]): Promise<string> {
  13. const { stdout } = await runLoaderSmoke({
  14. label: 'echo-agent',
  15. tempDirPrefix: 'echo-smoke-',
  16. binScript,
  17. configPath,
  18. tsconfigPath,
  19. stdinLines,
  20. })
  21. return stdout
  22. }
  23. describe('echo-agent keyless smoke (real cordis.yml via the Loader)', () => {
  24. it('boots, prints its welcome banner, and exits cleanly on stdin EOF', async () => {
  25. expect(await runEcho([])).toContain('echo-agent ready.')
  26. }, LOADER_SMOKE_TEST_TIMEOUT_MS)
  27. it('runs the echo tool round-trip for an "echo …" line', async () => {
  28. const stdout = await runEcho(['echo hello world'])
  29. expect(stdout).toContain('[tool call] echo')
  30. expect(stdout).toContain('[tool result] ECHO: HELLO WORLD')
  31. }, LOADER_SMOKE_TEST_TIMEOUT_MS)
  32. it('streams a direct canned reply for a non-echo line', async () => {
  33. const stdout = await runEcho(['just chatting'])
  34. expect(stdout).toContain('just chatting')
  35. expect(stdout).not.toContain('[tool call]')
  36. }, LOADER_SMOKE_TEST_TIMEOUT_MS)
  37. })