driver.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/env node
  2. /** Inspect the public Claude Code Bundle 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('Claude Code Loader composition driver requires config and Bundle patch paths')
  11. }
  12. let starts = 0
  13. const ctx = await bootProductionProfile({
  14. binName: 'subagent-claude-code-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 = [
  28. 'codex',
  29. 'claude-code',
  30. 'claude-primary',
  31. 'claude-secondary',
  32. ] as const
  33. const toolNames = [
  34. 'subagent_codex',
  35. 'subagent_claude_code',
  36. 'subagent_claude_primary',
  37. 'subagent_claude_secondary',
  38. ] as const
  39. const providers = providerNames.map((providerName) => {
  40. const provider = ctx.subagents.getProvider(providerName)
  41. if (provider === undefined) {
  42. throw new Error(`${providerName} provider was not registered`)
  43. }
  44. return {
  45. name: provider.name,
  46. capabilities: provider.capabilities,
  47. inheritsParentContext: provider.inheritsParentContext,
  48. }
  49. })
  50. const tools = toolNames.map((toolName) => {
  51. const tool = ctx.tools.schemas().find(schema => schema.name === toolName)
  52. if (tool === undefined) throw new Error(`${toolName} tool was not registered`)
  53. const properties = tool.parameters.properties
  54. if (
  55. typeof properties !== 'object'
  56. || properties === null
  57. || Array.isArray(properties)
  58. ) {
  59. throw new Error(`${toolName} has invalid parameter properties`)
  60. }
  61. return {
  62. name: tool.name,
  63. parameterNames: Object.keys(properties).sort(),
  64. required: tool.parameters.required,
  65. }
  66. })
  67. const jobTools = ctx.tools.schemas()
  68. .map(schema => schema.name)
  69. .filter(name => name === 'job_kill' || name === 'job_list' || name === 'job_output')
  70. .sort()
  71. process.stdout.write(`${JSON.stringify({
  72. registeredProviders: ctx.subagents.list().filter(providerName =>
  73. providerNames.includes(providerName as typeof providerNames[number])).sort(),
  74. providers,
  75. tools,
  76. jobTools,
  77. starts,
  78. })}\n`)
  79. } finally {
  80. await ctx.fiber.dispose()
  81. }