real-model.e2e.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. import { readFile, writeFile } from 'node:fs/promises'
  2. import { join } from 'node:path'
  3. import { fileURLToPath } from 'node:url'
  4. import { describe, expect, it } from 'vitest'
  5. import { runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
  6. const binScript = fileURLToPath(new URL('../../../packages/examples/cli-demo/src/bin.ts', import.meta.url))
  7. const configPath = fileURLToPath(new URL('../cordis.yml', import.meta.url))
  8. const tsconfigPath = fileURLToPath(new URL('../../../tsconfig.json', import.meta.url))
  9. const hasKey = Boolean(process.env.DEEPSEEK_API_KEY)
  10. describe.skipIf(!hasKey)('headless-agent with real model', () => {
  11. it('modifies a temporary workspace and verifies the file outside the agent', async () => {
  12. let verified = ''
  13. const { stdout } = await runLoaderSmoke({
  14. label: 'headless-agent real model',
  15. tempDirPrefix: 'headless-agent-real-',
  16. binScript,
  17. configPath,
  18. binArgs: [
  19. '--config',
  20. configPath,
  21. 'Read task.txt, replace its complete contents with exactly "value=after" followed by a newline, read it again, and report briefly.',
  22. ],
  23. tsconfigPath,
  24. processTimeoutMs: 120_000,
  25. prepare: cwd => writeFile(join(cwd, 'task.txt'), 'value=before\n'),
  26. inspect: async (cwd) => { verified = await readFile(join(cwd, 'task.txt'), 'utf8') },
  27. })
  28. expect(verified).toBe('value=after\n')
  29. expect(stdout.trim().length).toBeGreaterThan(0)
  30. }, 135_000)
  31. })