loader-composition.e2e.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { readFileSync } from 'node:fs'
  2. import { join } from 'node:path'
  3. import { fileURLToPath } from 'node:url'
  4. import { describe, expect, it } from 'vitest'
  5. import {
  6. LOADER_SMOKE_TEST_TIMEOUT_MS,
  7. runLoaderSmoke,
  8. } from '@deepseek-ai/dsh-loader-smoke'
  9. const fixtureDir = fileURLToPath(new URL(
  10. '../../../../examples/acp-agent/tests/fixtures/subagent/subagent-codex/',
  11. import.meta.url,
  12. ))
  13. const driver = join(fixtureDir, 'driver.ts')
  14. const configPath = join(fixtureDir, 'cordis.yml')
  15. const packageDir = fileURLToPath(new URL('..', import.meta.url))
  16. const manifest = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8')) as {
  17. dsh?: { bundle?: { patch?: string } }
  18. }
  19. const bundlePatch = manifest.dsh?.bundle?.patch
  20. if (bundlePatch === undefined) throw new Error('Codex package must declare a Bundle patch')
  21. const bundlePatchPath = join(packageDir, bundlePatch)
  22. const repoTsconfig = fileURLToPath(new URL('../../../../tsconfig.json', import.meta.url))
  23. describe('Codex provider public Loader composition', () => {
  24. it('loads the opt-in package, one-shot task tool, and job controls without starting Codex', async () => {
  25. const { stdout, stderr } = await runLoaderSmoke({
  26. label: 'subagent-codex Loader composition',
  27. tempDirPrefix: 'dsh-subagent-codex-loader-',
  28. binScript: driver,
  29. libBinScript: driver,
  30. configPath,
  31. binArgs: [configPath, bundlePatchPath],
  32. tsconfigPath: repoTsconfig,
  33. env: {
  34. // Loading the optional package must not probe or start a Codex binary.
  35. PATH: '',
  36. },
  37. })
  38. expect(stderr).toBe('')
  39. expect(JSON.parse(stdout)).toEqual({
  40. providers: ['codex'],
  41. provider: {
  42. name: 'codex',
  43. capabilities: {
  44. outputSchema: false,
  45. depthLimit: false,
  46. toolFilter: false,
  47. persona: false,
  48. },
  49. inheritsParentContext: false,
  50. },
  51. tool: {
  52. name: 'subagent_codex',
  53. parameterNames: ['description', 'prompt', 'run_in_background'],
  54. required: ['description', 'prompt'],
  55. },
  56. jobTools: ['job_kill', 'job_list', 'job_output'],
  57. starts: 0,
  58. })
  59. }, LOADER_SMOKE_TEST_TIMEOUT_MS)
  60. })