driver.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env node
  2. /** Inspect both public product-provider compositions without invoking them. */
  3. import { boot, 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. if (configPath === undefined) {
  8. throw new Error('product-provider Loader composition driver requires a config path')
  9. }
  10. let starts = 0
  11. const ctx = await boot(
  12. 'product-provider-loader-composition',
  13. resolveConfigPath(configPath, undefined),
  14. undefined,
  15. (hostCtx) => {
  16. hostCtx.on('subagent/start', () => {
  17. starts += 1
  18. })
  19. },
  20. )
  21. try {
  22. const providerNames = ['codex', 'claude-code'] as const
  23. const toolNames = ['subagent_codex', 'subagent_claude_code'] as const
  24. const providers = providerNames.map((providerName) => {
  25. const provider = ctx.subagents.getProvider(providerName)
  26. if (provider === undefined) {
  27. throw new Error(`${providerName} provider was not registered`)
  28. }
  29. return {
  30. name: provider.name,
  31. capabilities: provider.capabilities,
  32. inheritsParentContext: provider.inheritsParentContext,
  33. }
  34. })
  35. const tools = toolNames.map((toolName) => {
  36. const tool = ctx.tools.schemas().find(schema => schema.name === toolName)
  37. if (tool === undefined) throw new Error(`${toolName} tool was not registered`)
  38. const properties = tool.parameters.properties
  39. if (
  40. typeof properties !== 'object'
  41. || properties === null
  42. || Array.isArray(properties)
  43. ) {
  44. throw new Error(`${toolName} has invalid parameter properties`)
  45. }
  46. return {
  47. name: tool.name,
  48. parameterNames: Object.keys(properties).sort(),
  49. required: tool.parameters.required,
  50. }
  51. })
  52. process.stdout.write(`${JSON.stringify({
  53. registeredProviders: ctx.subagents.list(),
  54. providers,
  55. tools,
  56. starts,
  57. })}\n`)
  58. } finally {
  59. await ctx.fiber.dispose()
  60. }