driver.ts 2.4 KB

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