driver.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env node
  2. /** Inspect the public Codex provider composition without invoking the product. */
  3. import { resolveConfigPath } from '@deepseek-ai/dsh-app-boot'
  4. import type {} from '@deepseek-ai/dsh-subagent'
  5. import type {} from '@deepseek-ai/dsh-tools'
  6. import { bootProductionProfile } from '../../../../../test-support/loader-smoke/tests/fixtures/production-profile.ts'
  7. const configPath = process.argv[2]
  8. const bundlePatchPath = process.argv[3]
  9. if (configPath === undefined || bundlePatchPath === undefined) {
  10. throw new Error('subagent-codex Loader composition driver requires config and Bundle patch paths')
  11. }
  12. let starts = 0
  13. const ctx = await bootProductionProfile({
  14. binName: 'subagent-codex-loader-composition',
  15. profile: 'headless',
  16. overlayPaths: [
  17. resolveConfigPath(bundlePatchPath, undefined),
  18. resolveConfigPath(configPath, undefined),
  19. ],
  20. prepare: (hostCtx) => {
  21. hostCtx.on('subagent/start', () => {
  22. starts += 1
  23. })
  24. },
  25. })
  26. try {
  27. const providerNames = ['codex', 'codex-primary', 'codex-secondary'] as const
  28. const toolNames = [
  29. 'subagent_codex',
  30. 'subagent_codex_primary',
  31. 'subagent_codex_secondary',
  32. ] as const
  33. const providers = providerNames.map((providerName) => {
  34. const provider = ctx.subagents.getProvider(providerName)
  35. if (provider === undefined) {
  36. throw new Error(`${providerName} provider was not registered`)
  37. }
  38. return {
  39. name: provider.name,
  40. capabilities: provider.capabilities,
  41. inheritsParentContext: provider.inheritsParentContext,
  42. }
  43. })
  44. const tools = toolNames.map((toolName) => {
  45. const tool = ctx.tools.schemas().find(schema => schema.name === toolName)
  46. if (tool === undefined) throw new Error(`${toolName} tool was not registered`)
  47. const properties = tool.parameters.properties
  48. if (
  49. typeof properties !== 'object'
  50. || properties === null
  51. || Array.isArray(properties)
  52. ) {
  53. throw new Error(`${toolName} has invalid parameter properties`)
  54. }
  55. return {
  56. name: tool.name,
  57. parameterNames: Object.keys(properties).sort(),
  58. required: tool.parameters.required,
  59. }
  60. })
  61. const jobTools = ctx.tools.schemas()
  62. .map(schema => schema.name)
  63. .filter(name => name === 'job_kill' || name === 'job_list' || name === 'job_output')
  64. .sort()
  65. process.stdout.write(`${JSON.stringify({
  66. providers: providerNames.filter(providerName => ctx.subagents.getProvider(providerName) !== undefined),
  67. providerDetails: providers,
  68. tools,
  69. jobTools,
  70. starts,
  71. })}\n`)
  72. } finally {
  73. await ctx.fiber.dispose()
  74. }