loader-composition.e2e.ts 3.2 KB

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