driver.ts 2.3 KB

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