loader-composition.e2e.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 { runLoaderSmoke } from '@deepseek-ai/dsh-loader-smoke'
  6. const PRODUCTION_PROFILE_PROCESS_TIMEOUT_MS = 60_000
  7. const PRODUCTION_PROFILE_TEST_TIMEOUT_MS = PRODUCTION_PROFILE_PROCESS_TIMEOUT_MS + 15_000
  8. const fixtureDir = fileURLToPath(new URL(
  9. './fixtures/loader/',
  10. import.meta.url,
  11. ))
  12. const driver = join(fixtureDir, 'driver.ts')
  13. const configPath = join(fixtureDir, 'codex.patch.yml')
  14. const packageDir = fileURLToPath(new URL('..', import.meta.url))
  15. const manifest = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8')) as {
  16. dsh?: { bundle?: { patch?: string } }
  17. }
  18. const bundlePatch = manifest.dsh?.bundle?.patch
  19. if (bundlePatch === undefined) throw new Error('Codex package must declare a Bundle patch')
  20. const bundlePatchPath = join(packageDir, bundlePatch)
  21. const repoTsconfig = fileURLToPath(new URL('../../../../tsconfig.json', import.meta.url))
  22. describe('Codex provider public Loader composition', () => {
  23. it('loads the Bundle default, two named instances, their tools, and job controls without starting Codex', async () => {
  24. const { stdout, stderr } = await runLoaderSmoke({
  25. label: 'subagent-codex Loader composition',
  26. tempDirPrefix: 'dsh-subagent-codex-loader-',
  27. binScript: driver,
  28. libBinScript: driver,
  29. configPath,
  30. binArgs: [configPath, bundlePatchPath],
  31. tsconfigPath: repoTsconfig,
  32. processTimeoutMs: PRODUCTION_PROFILE_PROCESS_TIMEOUT_MS,
  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', 'codex-primary', 'codex-secondary'],
  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. }, PRODUCTION_PROFILE_TEST_TIMEOUT_MS)
  97. })