loader-composition.e2e.ts 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 Bundle default, two named instances, their tools, 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-primary', 'codex-secondary', 'codex'],
  41. providerDetails: [
  42. {
  43. name: 'codex',
  44. capabilities: {
  45. outputSchema: false,
  46. depthLimit: false,
  47. toolFilter: false,
  48. persona: false,
  49. },
  50. inheritsParentContext: false,
  51. },
  52. {
  53. name: 'codex-primary',
  54. capabilities: {
  55. outputSchema: false,
  56. depthLimit: false,
  57. toolFilter: false,
  58. persona: false,
  59. },
  60. inheritsParentContext: false,
  61. },
  62. {
  63. name: 'codex-secondary',
  64. capabilities: {
  65. outputSchema: false,
  66. depthLimit: false,
  67. toolFilter: false,
  68. persona: false,
  69. },
  70. inheritsParentContext: false,
  71. },
  72. ],
  73. tools: [
  74. {
  75. name: 'subagent_codex',
  76. parameterNames: ['description', 'prompt', 'run_in_background'],
  77. required: ['description', 'prompt'],
  78. },
  79. {
  80. name: 'subagent_codex_primary',
  81. parameterNames: ['description', 'prompt', 'run_in_background'],
  82. required: ['description', 'prompt'],
  83. },
  84. {
  85. name: 'subagent_codex_secondary',
  86. parameterNames: ['description', 'prompt', 'run_in_background'],
  87. required: ['description', 'prompt'],
  88. },
  89. ],
  90. jobTools: ['job_kill', 'job_list', 'job_output'],
  91. starts: 0,
  92. })
  93. }, LOADER_SMOKE_TEST_TIMEOUT_MS)
  94. })