@evalops/maestro 0.10.18 → 0.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (922) hide show
  1. package/README.md +56 -1
  2. package/dist/agent/action-approval.d.ts +12 -2
  3. package/dist/agent/action-approval.d.ts.map +1 -1
  4. package/dist/agent/action-approval.js +19 -32
  5. package/dist/agent/action-approval.js.map +1 -1
  6. package/dist/agent/agent.d.ts +1 -0
  7. package/dist/agent/agent.d.ts.map +1 -1
  8. package/dist/agent/agent.js +26 -0
  9. package/dist/agent/agent.js.map +1 -1
  10. package/dist/agent/compaction.d.ts +2 -0
  11. package/dist/agent/compaction.d.ts.map +1 -1
  12. package/dist/agent/compaction.js +4 -2
  13. package/dist/agent/compaction.js.map +1 -1
  14. package/dist/agent/index.d.ts +1 -1
  15. package/dist/agent/index.d.ts.map +1 -1
  16. package/dist/agent/index.js +1 -1
  17. package/dist/agent/index.js.map +1 -1
  18. package/dist/agent/modes.d.ts +56 -4
  19. package/dist/agent/modes.d.ts.map +1 -1
  20. package/dist/agent/modes.js +163 -2
  21. package/dist/agent/modes.js.map +1 -1
  22. package/dist/agent/prompt-recovery.d.ts.map +1 -1
  23. package/dist/agent/prompt-recovery.js +1 -3
  24. package/dist/agent/prompt-recovery.js.map +1 -1
  25. package/dist/agent/providers/anthropic.d.ts.map +1 -1
  26. package/dist/agent/providers/anthropic.js +9 -1
  27. package/dist/agent/providers/anthropic.js.map +1 -1
  28. package/dist/agent/providers/codex-app-server.d.ts +12 -0
  29. package/dist/agent/providers/codex-app-server.d.ts.map +1 -0
  30. package/dist/agent/providers/codex-app-server.js +788 -0
  31. package/dist/agent/providers/codex-app-server.js.map +1 -0
  32. package/dist/agent/providers/google-gemini-cli.js +14 -3
  33. package/dist/agent/providers/google.js +22 -3
  34. package/dist/agent/providers/scripted.d.ts +11 -0
  35. package/dist/agent/providers/scripted.d.ts.map +1 -0
  36. package/dist/agent/providers/scripted.js +399 -0
  37. package/dist/agent/providers/scripted.js.map +1 -0
  38. package/dist/agent/providers/vertex.js +14 -3
  39. package/dist/agent/scenario-source.d.ts +19 -0
  40. package/dist/agent/scenario-source.d.ts.map +1 -0
  41. package/dist/agent/scenario-source.js +112 -0
  42. package/dist/agent/scenario-source.js.map +1 -0
  43. package/dist/agent/subagent-specs.d.ts +1 -1
  44. package/dist/agent/subagent-specs.js +1 -1
  45. package/dist/agent/subagent-specs.js.map +1 -1
  46. package/dist/agent/swarm/executor.d.ts +25 -0
  47. package/dist/agent/swarm/executor.d.ts.map +1 -1
  48. package/dist/agent/swarm/executor.js +795 -20
  49. package/dist/agent/swarm/executor.js.map +1 -1
  50. package/dist/agent/swarm/runtime-events.d.ts +11 -0
  51. package/dist/agent/swarm/runtime-events.d.ts.map +1 -0
  52. package/dist/agent/swarm/runtime-events.js +26 -0
  53. package/dist/agent/swarm/runtime-events.js.map +1 -0
  54. package/dist/agent/swarm/types.d.ts +78 -0
  55. package/dist/agent/swarm/types.d.ts.map +1 -1
  56. package/dist/agent/swarm/types.js.map +1 -1
  57. package/dist/agent/tracing.d.ts +1 -1
  58. package/dist/agent/tracing.d.ts.map +1 -1
  59. package/dist/agent/tracing.js +17 -9
  60. package/dist/agent/tracing.js.map +1 -1
  61. package/dist/agent/transport/create-provider-stream.d.ts.map +1 -1
  62. package/dist/agent/transport/create-provider-stream.js +14 -0
  63. package/dist/agent/transport/create-provider-stream.js.map +1 -1
  64. package/dist/agent/transport/stable-stringify.d.ts +2 -0
  65. package/dist/agent/transport/stable-stringify.d.ts.map +1 -0
  66. package/dist/agent/transport/stable-stringify.js +14 -0
  67. package/dist/agent/transport/stable-stringify.js.map +1 -0
  68. package/dist/agent/transport/tool-execution-bridge.d.ts.map +1 -1
  69. package/dist/agent/transport/tool-execution-bridge.js +2 -15
  70. package/dist/agent/transport/tool-execution-bridge.js.map +1 -1
  71. package/dist/agent/transport/tool-safety-pipeline.d.ts +5 -1
  72. package/dist/agent/transport/tool-safety-pipeline.d.ts.map +1 -1
  73. package/dist/agent/transport/tool-safety-pipeline.js +184 -36
  74. package/dist/agent/transport/tool-safety-pipeline.js.map +1 -1
  75. package/dist/agent/transport.d.ts +8 -0
  76. package/dist/agent/transport.d.ts.map +1 -1
  77. package/dist/agent/transport.js +1613 -68
  78. package/dist/agent/transport.js.map +1 -1
  79. package/dist/agent/types.d.ts +170 -2
  80. package/dist/agent/types.d.ts.map +1 -1
  81. package/dist/agent/types.js.map +1 -1
  82. package/dist/api/enterprise-routes.d.ts.map +1 -1
  83. package/dist/api/enterprise-routes.js +34 -3
  84. package/dist/api/enterprise-routes.js.map +1 -1
  85. package/dist/app-server/in-process-client.d.ts +32 -0
  86. package/dist/app-server/in-process-client.d.ts.map +1 -0
  87. package/dist/app-server/in-process-client.js +73 -0
  88. package/dist/app-server/in-process-client.js.map +1 -0
  89. package/dist/app-server/session-api.d.ts +36 -0
  90. package/dist/app-server/session-api.d.ts.map +1 -0
  91. package/dist/app-server/session-api.js +713 -0
  92. package/dist/app-server/session-api.js.map +1 -0
  93. package/dist/approvals/platform-action-approval.d.ts +3 -1
  94. package/dist/approvals/platform-action-approval.d.ts.map +1 -1
  95. package/dist/approvals/platform-action-approval.js +16 -9
  96. package/dist/approvals/platform-action-approval.js.map +1 -1
  97. package/dist/approvals/service-client.d.ts.map +1 -1
  98. package/dist/approvals/service-client.js +7 -7
  99. package/dist/approvals/service-client.js.map +1 -1
  100. package/dist/audit/logger.d.ts +4 -4
  101. package/dist/bootstrap/agent-creation-setup.d.ts +4 -0
  102. package/dist/bootstrap/agent-creation-setup.d.ts.map +1 -1
  103. package/dist/bootstrap/agent-creation-setup.js +3 -1
  104. package/dist/bootstrap/agent-creation-setup.js.map +1 -1
  105. package/dist/bootstrap/auth-setup.js +1 -1
  106. package/dist/bootstrap/auth-setup.js.map +1 -1
  107. package/dist/bootstrap/event-subscriptions-setup.d.ts +6 -0
  108. package/dist/bootstrap/event-subscriptions-setup.d.ts.map +1 -1
  109. package/dist/bootstrap/event-subscriptions-setup.js +26 -2
  110. package/dist/bootstrap/event-subscriptions-setup.js.map +1 -1
  111. package/dist/bootstrap/model-resolution-setup.d.ts.map +1 -1
  112. package/dist/bootstrap/model-resolution-setup.js +4 -1
  113. package/dist/bootstrap/model-resolution-setup.js.map +1 -1
  114. package/dist/bootstrap/tools-setup.d.ts +2 -1
  115. package/dist/bootstrap/tools-setup.d.ts.map +1 -1
  116. package/dist/bootstrap/tools-setup.js +5 -1
  117. package/dist/bootstrap/tools-setup.js.map +1 -1
  118. package/dist/cli/args.d.ts +9 -1
  119. package/dist/cli/args.d.ts.map +1 -1
  120. package/dist/cli/args.js +130 -5
  121. package/dist/cli/args.js.map +1 -1
  122. package/dist/cli/commands/a2a.d.ts +9 -0
  123. package/dist/cli/commands/a2a.d.ts.map +1 -0
  124. package/dist/cli/commands/a2a.js +1714 -0
  125. package/dist/cli/commands/a2a.js.map +1 -0
  126. package/dist/cli/commands/agents.d.ts +16 -2
  127. package/dist/cli/commands/agents.d.ts.map +1 -1
  128. package/dist/cli/commands/agents.js +223 -35
  129. package/dist/cli/commands/agents.js.map +1 -1
  130. package/dist/cli/commands/codex.d.ts +1 -1
  131. package/dist/cli/commands/codex.d.ts.map +1 -1
  132. package/dist/cli/commands/codex.js +145 -39
  133. package/dist/cli/commands/codex.js.map +1 -1
  134. package/dist/cli/commands/context.d.ts +10 -0
  135. package/dist/cli/commands/context.d.ts.map +1 -0
  136. package/dist/cli/commands/context.js +176 -0
  137. package/dist/cli/commands/context.js.map +1 -0
  138. package/dist/cli/commands/hosted-runner.d.ts +1 -0
  139. package/dist/cli/commands/hosted-runner.d.ts.map +1 -1
  140. package/dist/cli/commands/hosted-runner.js +9 -1
  141. package/dist/cli/commands/hosted-runner.js.map +1 -1
  142. package/dist/cli/commands/modes.d.ts +8 -0
  143. package/dist/cli/commands/modes.d.ts.map +1 -0
  144. package/dist/cli/commands/modes.js +151 -0
  145. package/dist/cli/commands/modes.js.map +1 -0
  146. package/dist/cli/commands/operating-plane.d.ts +14 -0
  147. package/dist/cli/commands/operating-plane.d.ts.map +1 -0
  148. package/dist/cli/commands/operating-plane.js +160 -0
  149. package/dist/cli/commands/operating-plane.js.map +1 -0
  150. package/dist/cli/commands/run.d.ts +87 -0
  151. package/dist/cli/commands/run.d.ts.map +1 -0
  152. package/dist/cli/commands/run.js +356 -0
  153. package/dist/cli/commands/run.js.map +1 -0
  154. package/dist/cli/commands/scenario.d.ts +7 -0
  155. package/dist/cli/commands/scenario.d.ts.map +1 -0
  156. package/dist/cli/commands/scenario.js +195 -0
  157. package/dist/cli/commands/scenario.js.map +1 -0
  158. package/dist/cli/commands/skill.d.ts +7 -0
  159. package/dist/cli/commands/skill.d.ts.map +1 -0
  160. package/dist/cli/commands/skill.js +286 -0
  161. package/dist/cli/commands/skill.js.map +1 -0
  162. package/dist/cli/headless-protocol.d.ts +55 -1
  163. package/dist/cli/headless-protocol.d.ts.map +1 -1
  164. package/dist/cli/headless-protocol.js +446 -7
  165. package/dist/cli/headless-protocol.js.map +1 -1
  166. package/dist/cli/headless-runtime-selection.d.ts +38 -0
  167. package/dist/cli/headless-runtime-selection.d.ts.map +1 -0
  168. package/dist/cli/headless-runtime-selection.js +48 -0
  169. package/dist/cli/headless-runtime-selection.js.map +1 -0
  170. package/dist/cli/headless.d.ts +5 -1
  171. package/dist/cli/headless.d.ts.map +1 -1
  172. package/dist/cli/headless.js +11 -1
  173. package/dist/cli/headless.js.map +1 -1
  174. package/dist/cli/help.d.ts +3 -1
  175. package/dist/cli/help.d.ts.map +1 -1
  176. package/dist/cli/help.js +135 -30
  177. package/dist/cli/help.js.map +1 -1
  178. package/dist/cli/system-prompt.d.ts +22 -4
  179. package/dist/cli/system-prompt.d.ts.map +1 -1
  180. package/dist/cli/system-prompt.js +224 -127
  181. package/dist/cli/system-prompt.js.map +1 -1
  182. package/dist/cli-tui/commands/a2a-handlers.d.ts +7 -0
  183. package/dist/cli-tui/commands/a2a-handlers.d.ts.map +1 -0
  184. package/dist/cli-tui/commands/a2a-handlers.js +160 -0
  185. package/dist/cli-tui/commands/a2a-handlers.js.map +1 -0
  186. package/dist/cli-tui/commands/command-catalog.d.ts.map +1 -1
  187. package/dist/cli-tui/commands/command-catalog.js +15 -0
  188. package/dist/cli-tui/commands/command-catalog.js.map +1 -1
  189. package/dist/cli-tui/commands/command-registry-adapter.js +10 -1
  190. package/dist/cli-tui/commands/command-registry-adapter.js.map +1 -1
  191. package/dist/cli-tui/commands/handlers/mode-handler.d.ts.map +1 -1
  192. package/dist/cli-tui/commands/handlers/mode-handler.js +22 -10
  193. package/dist/cli-tui/commands/handlers/mode-handler.js.map +1 -1
  194. package/dist/cli-tui/commands/mcp-handlers.d.ts.map +1 -1
  195. package/dist/cli-tui/commands/mcp-handlers.js +6 -5
  196. package/dist/cli-tui/commands/mcp-handlers.js.map +1 -1
  197. package/dist/cli-tui/commands/types.d.ts +1 -0
  198. package/dist/cli-tui/commands/types.d.ts.map +1 -1
  199. package/dist/cli-tui/commands/types.js.map +1 -1
  200. package/dist/cli-tui/commands/utility-handlers.d.ts +4 -0
  201. package/dist/cli-tui/commands/utility-handlers.d.ts.map +1 -1
  202. package/dist/cli-tui/commands/utility-handlers.js +45 -6
  203. package/dist/cli-tui/commands/utility-handlers.js.map +1 -1
  204. package/dist/cli-tui/run/run-shell-command.d.ts.map +1 -1
  205. package/dist/cli-tui/run/run-shell-command.js +14 -5
  206. package/dist/cli-tui/run/run-shell-command.js.map +1 -1
  207. package/dist/cli-tui/run/streaming-shell-command.d.ts.map +1 -1
  208. package/dist/cli-tui/run/streaming-shell-command.js +14 -5
  209. package/dist/cli-tui/run/streaming-shell-command.js.map +1 -1
  210. package/dist/cli-tui/selectors/model-selector.d.ts +1 -0
  211. package/dist/cli-tui/selectors/model-selector.d.ts.map +1 -1
  212. package/dist/cli-tui/selectors/model-selector.js +6 -2
  213. package/dist/cli-tui/selectors/model-selector.js.map +1 -1
  214. package/dist/cli-tui/tui-renderer/command-registry-options.d.ts.map +1 -1
  215. package/dist/cli-tui/tui-renderer/command-registry-options.js +5 -0
  216. package/dist/cli-tui/tui-renderer/command-registry-options.js.map +1 -1
  217. package/dist/cli-tui/utils/commands/review-prompt.d.ts +1 -1
  218. package/dist/cli-tui/utils/commands/review-prompt.d.ts.map +1 -1
  219. package/dist/cli-tui/utils/commands/review-prompt.js +8 -3
  220. package/dist/cli-tui/utils/commands/review-prompt.js.map +1 -1
  221. package/dist/cli-tui/utils/runtime-badges.d.ts +1 -0
  222. package/dist/cli-tui/utils/runtime-badges.d.ts.map +1 -1
  223. package/dist/cli-tui/utils/runtime-badges.js +7 -0
  224. package/dist/cli-tui/utils/runtime-badges.js.map +1 -1
  225. package/dist/cli-tui/utils/text-formatting.d.ts +1 -0
  226. package/dist/cli-tui/utils/text-formatting.d.ts.map +1 -1
  227. package/dist/cli-tui/utils/text-formatting.js +5 -0
  228. package/dist/cli-tui/utils/text-formatting.js.map +1 -1
  229. package/dist/cli.js +49158 -26161
  230. package/dist/cli.js.map +1 -1
  231. package/dist/codex/app-server-client.d.ts +139 -0
  232. package/dist/codex/app-server-client.d.ts.map +1 -0
  233. package/dist/codex/app-server-client.js +352 -0
  234. package/dist/codex/app-server-client.js.map +1 -0
  235. package/dist/codex/compatibility.d.ts +48 -0
  236. package/dist/codex/compatibility.d.ts.map +1 -0
  237. package/dist/codex/compatibility.js +344 -0
  238. package/dist/codex/compatibility.js.map +1 -0
  239. package/dist/codex/subagent-dispatch-table.d.ts +66 -0
  240. package/dist/codex/subagent-dispatch-table.d.ts.map +1 -0
  241. package/dist/codex/subagent-dispatch-table.js +127 -0
  242. package/dist/codex/subagent-dispatch-table.js.map +1 -0
  243. package/dist/codex/subagent-workgraph.d.ts +56 -0
  244. package/dist/codex/subagent-workgraph.d.ts.map +1 -0
  245. package/dist/codex/subagent-workgraph.js +89 -0
  246. package/dist/codex/subagent-workgraph.js.map +1 -0
  247. package/dist/config/constants.d.ts +3 -1
  248. package/dist/config/constants.d.ts.map +1 -1
  249. package/dist/config/constants.js +9 -0
  250. package/dist/config/constants.js.map +1 -1
  251. package/dist/config/feature-flags.d.ts +10 -1
  252. package/dist/config/feature-flags.d.ts.map +1 -1
  253. package/dist/config/feature-flags.js +17 -6
  254. package/dist/config/feature-flags.js.map +1 -1
  255. package/dist/config/index.d.ts +1 -1
  256. package/dist/config/index.d.ts.map +1 -1
  257. package/dist/config/index.js +1 -1
  258. package/dist/config/index.js.map +1 -1
  259. package/dist/config/toml-config.d.ts +32 -0
  260. package/dist/config/toml-config.d.ts.map +1 -1
  261. package/dist/config/toml-config.js +152 -43
  262. package/dist/config/toml-config.js.map +1 -1
  263. package/dist/connectors/service-client.d.ts.map +1 -1
  264. package/dist/connectors/service-client.js +4 -7
  265. package/dist/connectors/service-client.js.map +1 -1
  266. package/dist/context/manifest-types.d.ts +59 -0
  267. package/dist/context/manifest-types.d.ts.map +1 -0
  268. package/dist/context/manifest-types.js +2 -0
  269. package/dist/context/manifest-types.js.map +1 -0
  270. package/dist/context/manifest.d.ts +16 -0
  271. package/dist/context/manifest.d.ts.map +1 -0
  272. package/dist/context/manifest.js +503 -0
  273. package/dist/context/manifest.js.map +1 -0
  274. package/dist/db/schema.d.ts +10 -1
  275. package/dist/db/schema.d.ts.map +1 -1
  276. package/dist/db/schema.js.map +1 -1
  277. package/dist/evalops/env-aliases.d.ts +13 -0
  278. package/dist/evalops/env-aliases.d.ts.map +1 -0
  279. package/dist/evalops/env-aliases.js +60 -0
  280. package/dist/evalops/env-aliases.js.map +1 -0
  281. package/dist/evalops/managed-context.d.ts.map +1 -1
  282. package/dist/evalops/managed-context.js +28 -62
  283. package/dist/evalops/managed-context.js.map +1 -1
  284. package/dist/guardian/config.d.ts.map +1 -1
  285. package/dist/guardian/config.js +1 -0
  286. package/dist/guardian/config.js.map +1 -1
  287. package/dist/guardian/runner.d.ts +2 -0
  288. package/dist/guardian/runner.d.ts.map +1 -1
  289. package/dist/guardian/runner.js +105 -2
  290. package/dist/guardian/runner.js.map +1 -1
  291. package/dist/guardian/types.d.ts +1 -0
  292. package/dist/guardian/types.d.ts.map +1 -1
  293. package/dist/guardian/types.js.map +1 -1
  294. package/dist/index.d.ts +5 -1
  295. package/dist/index.d.ts.map +1 -1
  296. package/dist/index.js +5 -1
  297. package/dist/index.js.map +1 -1
  298. package/dist/main.d.ts.map +1 -1
  299. package/dist/main.js +267 -55
  300. package/dist/main.js.map +1 -1
  301. package/dist/mcp/config.d.ts.map +1 -1
  302. package/dist/mcp/config.js +89 -7
  303. package/dist/mcp/config.js.map +1 -1
  304. package/dist/mcp/manager.d.ts +5 -1
  305. package/dist/mcp/manager.d.ts.map +1 -1
  306. package/dist/mcp/manager.js +159 -4
  307. package/dist/mcp/manager.js.map +1 -1
  308. package/dist/mcp/platform-plugin.d.ts.map +1 -1
  309. package/dist/mcp/platform-plugin.js +9 -26
  310. package/dist/mcp/platform-plugin.js.map +1 -1
  311. package/dist/mcp/schema.d.ts +15 -0
  312. package/dist/mcp/schema.d.ts.map +1 -1
  313. package/dist/mcp/schema.js +24 -0
  314. package/dist/mcp/schema.js.map +1 -1
  315. package/dist/mcp/tool-bridge.d.ts +39 -10
  316. package/dist/mcp/tool-bridge.d.ts.map +1 -1
  317. package/dist/mcp/tool-bridge.js +101 -24
  318. package/dist/mcp/tool-bridge.js.map +1 -1
  319. package/dist/mcp/types.d.ts +27 -0
  320. package/dist/mcp/types.d.ts.map +1 -1
  321. package/dist/mcp/types.js.map +1 -1
  322. package/dist/mcp/workspace-trust.d.ts +10 -0
  323. package/dist/mcp/workspace-trust.d.ts.map +1 -0
  324. package/dist/mcp/workspace-trust.js +295 -0
  325. package/dist/mcp/workspace-trust.js.map +1 -0
  326. package/dist/memory/service-client.d.ts +1 -0
  327. package/dist/memory/service-client.d.ts.map +1 -1
  328. package/dist/memory/service-client.js +194 -9
  329. package/dist/memory/service-client.js.map +1 -1
  330. package/dist/models/builtin.d.ts.map +1 -1
  331. package/dist/models/builtin.js +66 -25
  332. package/dist/models/builtin.js.map +1 -1
  333. package/dist/models/config-loader.d.ts +10 -10
  334. package/dist/models/config-loader.d.ts.map +1 -1
  335. package/dist/models/config-loader.js +2 -0
  336. package/dist/models/config-loader.js.map +1 -1
  337. package/dist/models/registry.d.ts +1 -0
  338. package/dist/models/registry.d.ts.map +1 -1
  339. package/dist/models/registry.js +1 -0
  340. package/dist/models/registry.js.map +1 -1
  341. package/dist/oauth/device-identity.d.ts.map +1 -1
  342. package/dist/oauth/device-identity.js +1 -3
  343. package/dist/oauth/device-identity.js.map +1 -1
  344. package/dist/oauth/evalops.d.ts.map +1 -1
  345. package/dist/oauth/evalops.js +2 -5
  346. package/dist/oauth/evalops.js.map +1 -1
  347. package/dist/opentelemetry.d.ts.map +1 -1
  348. package/dist/opentelemetry.js +12 -12
  349. package/dist/opentelemetry.js.map +1 -1
  350. package/dist/package-version.d.ts +2 -0
  351. package/dist/package-version.d.ts.map +1 -0
  352. package/dist/package-version.js +11 -0
  353. package/dist/package-version.js.map +1 -0
  354. package/dist/packages/constants.d.ts +3 -0
  355. package/dist/packages/constants.d.ts.map +1 -0
  356. package/dist/packages/constants.js +3 -0
  357. package/dist/packages/constants.js.map +1 -0
  358. package/dist/packages/inspection.d.ts.map +1 -1
  359. package/dist/packages/inspection.js +2 -1
  360. package/dist/packages/inspection.js.map +1 -1
  361. package/dist/packages/search.d.ts.map +1 -1
  362. package/dist/packages/search.js +1 -1
  363. package/dist/packages/search.js.map +1 -1
  364. package/dist/platform/a2a-capability-market.d.ts +21 -0
  365. package/dist/platform/a2a-capability-market.d.ts.map +1 -0
  366. package/dist/platform/a2a-capability-market.js +176 -0
  367. package/dist/platform/a2a-capability-market.js.map +1 -0
  368. package/dist/platform/a2a-client.d.ts +119 -0
  369. package/dist/platform/a2a-client.d.ts.map +1 -1
  370. package/dist/platform/a2a-client.js +413 -24
  371. package/dist/platform/a2a-client.js.map +1 -1
  372. package/dist/platform/a2a-fleet.d.ts +41 -0
  373. package/dist/platform/a2a-fleet.d.ts.map +1 -0
  374. package/dist/platform/a2a-fleet.js +109 -0
  375. package/dist/platform/a2a-fleet.js.map +1 -0
  376. package/dist/platform/a2a-maestro-peer.d.ts +20 -0
  377. package/dist/platform/a2a-maestro-peer.d.ts.map +1 -0
  378. package/dist/platform/a2a-maestro-peer.js +176 -0
  379. package/dist/platform/a2a-maestro-peer.js.map +1 -0
  380. package/dist/platform/a2a-peer-pairing.d.ts +107 -0
  381. package/dist/platform/a2a-peer-pairing.d.ts.map +1 -0
  382. package/dist/platform/a2a-peer-pairing.js +489 -0
  383. package/dist/platform/a2a-peer-pairing.js.map +1 -0
  384. package/dist/platform/a2a-peer-registry.d.ts +68 -0
  385. package/dist/platform/a2a-peer-registry.d.ts.map +1 -0
  386. package/dist/platform/a2a-peer-registry.js +320 -0
  387. package/dist/platform/a2a-peer-registry.js.map +1 -0
  388. package/dist/platform/a2a-task-ledger.d.ts +86 -0
  389. package/dist/platform/a2a-task-ledger.d.ts.map +1 -0
  390. package/dist/platform/a2a-task-ledger.js +546 -0
  391. package/dist/platform/a2a-task-ledger.js.map +1 -0
  392. package/dist/platform/a2a-work-graph.d.ts +43 -0
  393. package/dist/platform/a2a-work-graph.d.ts.map +1 -0
  394. package/dist/platform/a2a-work-graph.js +267 -0
  395. package/dist/platform/a2a-work-graph.js.map +1 -0
  396. package/dist/platform/agent-registry-client.d.ts +327 -0
  397. package/dist/platform/agent-registry-client.d.ts.map +1 -0
  398. package/dist/platform/agent-registry-client.js +803 -0
  399. package/dist/platform/agent-registry-client.js.map +1 -0
  400. package/dist/platform/agent-runtime-client.d.ts +135 -1
  401. package/dist/platform/agent-runtime-client.d.ts.map +1 -1
  402. package/dist/platform/agent-runtime-client.js +467 -10
  403. package/dist/platform/agent-runtime-client.js.map +1 -1
  404. package/dist/platform/cerebro-facts-client.d.ts.map +1 -1
  405. package/dist/platform/cerebro-facts-client.js +4 -7
  406. package/dist/platform/cerebro-facts-client.js.map +1 -1
  407. package/dist/platform/client.d.ts.map +1 -1
  408. package/dist/platform/client.js +3 -12
  409. package/dist/platform/client.js.map +1 -1
  410. package/dist/platform/core-services.d.ts +68 -0
  411. package/dist/platform/core-services.d.ts.map +1 -1
  412. package/dist/platform/core-services.js +68 -0
  413. package/dist/platform/core-services.js.map +1 -1
  414. package/dist/platform/fermata-eval-client.d.ts +195 -0
  415. package/dist/platform/fermata-eval-client.d.ts.map +1 -0
  416. package/dist/platform/fermata-eval-client.js +146 -0
  417. package/dist/platform/fermata-eval-client.js.map +1 -0
  418. package/dist/platform/fermata-scenario-suite.d.ts +99 -0
  419. package/dist/platform/fermata-scenario-suite.d.ts.map +1 -0
  420. package/dist/platform/fermata-scenario-suite.js +459 -0
  421. package/dist/platform/fermata-scenario-suite.js.map +1 -0
  422. package/dist/platform/maestro-timeline-client.d.ts.map +1 -1
  423. package/dist/platform/maestro-timeline-client.js +5 -11
  424. package/dist/platform/maestro-timeline-client.js.map +1 -1
  425. package/dist/platform/operating-plane-client.d.ts +156 -0
  426. package/dist/platform/operating-plane-client.d.ts.map +1 -0
  427. package/dist/platform/operating-plane-client.js +131 -0
  428. package/dist/platform/operating-plane-client.js.map +1 -0
  429. package/dist/platform/operating-plane-summary.d.ts +47 -0
  430. package/dist/platform/operating-plane-summary.d.ts.map +1 -0
  431. package/dist/platform/operating-plane-summary.js +209 -0
  432. package/dist/platform/operating-plane-summary.js.map +1 -0
  433. package/dist/platform/tool-execution-client.d.ts.map +1 -1
  434. package/dist/platform/tool-execution-client.js +4 -11
  435. package/dist/platform/tool-execution-client.js.map +1 -1
  436. package/dist/prompts/service-client.d.ts.map +1 -1
  437. package/dist/prompts/service-client.js +3 -5
  438. package/dist/prompts/service-client.js.map +1 -1
  439. package/dist/prompts/system-prompt.d.ts +3 -0
  440. package/dist/prompts/system-prompt.d.ts.map +1 -1
  441. package/dist/prompts/system-prompt.js +13 -3
  442. package/dist/prompts/system-prompt.js.map +1 -1
  443. package/dist/prompts/types.d.ts +2 -0
  444. package/dist/prompts/types.d.ts.map +1 -1
  445. package/dist/prompts/types.js.map +1 -1
  446. package/dist/providers/api-keys.d.ts +1 -1
  447. package/dist/providers/api-keys.d.ts.map +1 -1
  448. package/dist/providers/api-keys.js +2 -1
  449. package/dist/providers/api-keys.js.map +1 -1
  450. package/dist/providers/auth.d.ts.map +1 -1
  451. package/dist/providers/auth.js +48 -25
  452. package/dist/providers/auth.js.map +1 -1
  453. package/dist/remote-runner/attach-client.d.ts.map +1 -1
  454. package/dist/remote-runner/attach-client.js +1 -0
  455. package/dist/remote-runner/attach-client.js.map +1 -1
  456. package/dist/remote-runner/client.d.ts.map +1 -1
  457. package/dist/remote-runner/client.js +4 -7
  458. package/dist/remote-runner/client.js.map +1 -1
  459. package/dist/rpc/rpc-types.d.ts.map +1 -1
  460. package/dist/rpc/rpc-types.js +1 -0
  461. package/dist/rpc/rpc-types.js.map +1 -1
  462. package/dist/safety/action-firewall.d.ts.map +1 -1
  463. package/dist/safety/action-firewall.js +69 -6
  464. package/dist/safety/action-firewall.js.map +1 -1
  465. package/dist/safety/attack-patterns.d.ts.map +1 -1
  466. package/dist/safety/attack-patterns.js +31 -14
  467. package/dist/safety/attack-patterns.js.map +1 -1
  468. package/dist/safety/bash-parser.d.ts.map +1 -1
  469. package/dist/safety/bash-parser.js +4 -3
  470. package/dist/safety/bash-parser.js.map +1 -1
  471. package/dist/safety/execpolicy.d.ts +15 -3
  472. package/dist/safety/execpolicy.d.ts.map +1 -1
  473. package/dist/safety/execpolicy.js +248 -37
  474. package/dist/safety/execpolicy.js.map +1 -1
  475. package/dist/safety/governance-service-client.d.ts.map +1 -1
  476. package/dist/safety/governance-service-client.js +4 -7
  477. package/dist/safety/governance-service-client.js.map +1 -1
  478. package/dist/safety/guarded-files.d.ts +34 -0
  479. package/dist/safety/guarded-files.d.ts.map +1 -0
  480. package/dist/safety/guarded-files.js +372 -0
  481. package/dist/safety/guarded-files.js.map +1 -0
  482. package/dist/safety/loop-detector.d.ts.map +1 -1
  483. package/dist/safety/loop-detector.js +6 -1
  484. package/dist/safety/loop-detector.js.map +1 -1
  485. package/dist/safety/permission-profile.d.ts +47 -0
  486. package/dist/safety/permission-profile.d.ts.map +1 -0
  487. package/dist/safety/permission-profile.js +349 -0
  488. package/dist/safety/permission-profile.js.map +1 -0
  489. package/dist/safety/safety-middleware.d.ts +5 -1
  490. package/dist/safety/safety-middleware.d.ts.map +1 -1
  491. package/dist/safety/safety-middleware.js +3 -2
  492. package/dist/safety/safety-middleware.js.map +1 -1
  493. package/dist/safety/suspicious-patterns.d.ts.map +1 -1
  494. package/dist/safety/suspicious-patterns.js +12 -7
  495. package/dist/safety/suspicious-patterns.js.map +1 -1
  496. package/dist/safety/tool-categorization.js +1 -1
  497. package/dist/safety/tool-categorization.js.map +1 -1
  498. package/dist/safety/validators/path-policy-validator.d.ts.map +1 -1
  499. package/dist/safety/validators/path-policy-validator.js +7 -0
  500. package/dist/safety/validators/path-policy-validator.js.map +1 -1
  501. package/dist/sandbox/index.d.ts +6 -1
  502. package/dist/sandbox/index.d.ts.map +1 -1
  503. package/dist/sandbox/index.js +30 -4
  504. package/dist/sandbox/index.js.map +1 -1
  505. package/dist/sandbox/native-sandbox.d.ts +3 -0
  506. package/dist/sandbox/native-sandbox.d.ts.map +1 -1
  507. package/dist/sandbox/native-sandbox.js +139 -18
  508. package/dist/sandbox/native-sandbox.js.map +1 -1
  509. package/dist/sentry.d.ts +17 -0
  510. package/dist/sentry.d.ts.map +1 -0
  511. package/dist/sentry.js +91 -0
  512. package/dist/sentry.js.map +1 -0
  513. package/dist/server/agent-runtime-ledger.d.ts +141 -0
  514. package/dist/server/agent-runtime-ledger.d.ts.map +1 -0
  515. package/dist/server/agent-runtime-ledger.js +334 -0
  516. package/dist/server/agent-runtime-ledger.js.map +1 -0
  517. package/dist/server/agent-trajectory-inspection.d.ts +104 -0
  518. package/dist/server/agent-trajectory-inspection.d.ts.map +1 -0
  519. package/dist/server/agent-trajectory-inspection.js +168 -0
  520. package/dist/server/agent-trajectory-inspection.js.map +1 -0
  521. package/dist/server/agent-trajectory-replay.d.ts +56 -0
  522. package/dist/server/agent-trajectory-replay.d.ts.map +1 -0
  523. package/dist/server/agent-trajectory-replay.js +214 -0
  524. package/dist/server/agent-trajectory-replay.js.map +1 -0
  525. package/dist/server/agent-trajectory-scenarios.d.ts +109 -0
  526. package/dist/server/agent-trajectory-scenarios.d.ts.map +1 -0
  527. package/dist/server/agent-trajectory-scenarios.js +822 -0
  528. package/dist/server/agent-trajectory-scenarios.js.map +1 -0
  529. package/dist/server/agent-trajectory-scorers.d.ts +61 -0
  530. package/dist/server/agent-trajectory-scorers.d.ts.map +1 -0
  531. package/dist/server/agent-trajectory-scorers.js +162 -0
  532. package/dist/server/agent-trajectory-scorers.js.map +1 -0
  533. package/dist/server/agent-trajectory-validation.d.ts +7 -0
  534. package/dist/server/agent-trajectory-validation.d.ts.map +1 -0
  535. package/dist/server/agent-trajectory-validation.js +101 -0
  536. package/dist/server/agent-trajectory-validation.js.map +1 -0
  537. package/dist/server/agent-trajectory.d.ts +50 -0
  538. package/dist/server/agent-trajectory.d.ts.map +1 -0
  539. package/dist/server/agent-trajectory.js +159 -0
  540. package/dist/server/agent-trajectory.js.map +1 -0
  541. package/dist/server/app-context.d.ts +18 -0
  542. package/dist/server/app-context.d.ts.map +1 -1
  543. package/dist/server/app-context.js.map +1 -1
  544. package/dist/server/handlers/headless-sessions.d.ts.map +1 -1
  545. package/dist/server/handlers/headless-sessions.js +64 -27
  546. package/dist/server/handlers/headless-sessions.js.map +1 -1
  547. package/dist/server/handlers/health.d.ts +6 -0
  548. package/dist/server/handlers/health.d.ts.map +1 -1
  549. package/dist/server/handlers/health.js +6 -0
  550. package/dist/server/handlers/health.js.map +1 -1
  551. package/dist/server/handlers/hosted-runner-drain.d.ts +69 -1
  552. package/dist/server/handlers/hosted-runner-drain.d.ts.map +1 -1
  553. package/dist/server/handlers/hosted-runner-drain.js +309 -18
  554. package/dist/server/handlers/hosted-runner-drain.js.map +1 -1
  555. package/dist/server/handlers/hosted-runner-identity.d.ts +16 -0
  556. package/dist/server/handlers/hosted-runner-identity.d.ts.map +1 -1
  557. package/dist/server/handlers/hosted-runner-identity.js +43 -0
  558. package/dist/server/handlers/hosted-runner-identity.js.map +1 -1
  559. package/dist/server/handlers/mode.d.ts.map +1 -1
  560. package/dist/server/handlers/mode.js +3 -1
  561. package/dist/server/handlers/mode.js.map +1 -1
  562. package/dist/server/handlers/pending-requests.d.ts.map +1 -1
  563. package/dist/server/handlers/pending-requests.js +336 -51
  564. package/dist/server/handlers/pending-requests.js.map +1 -1
  565. package/dist/server/handlers/platform-a2a-push.d.ts +6 -0
  566. package/dist/server/handlers/platform-a2a-push.d.ts.map +1 -0
  567. package/dist/server/handlers/platform-a2a-push.js +136 -0
  568. package/dist/server/handlers/platform-a2a-push.js.map +1 -0
  569. package/dist/server/handlers/sessions.d.ts.map +1 -1
  570. package/dist/server/handlers/sessions.js +21 -1
  571. package/dist/server/handlers/sessions.js.map +1 -1
  572. package/dist/server/headless-runtime-service.d.ts +9 -2
  573. package/dist/server/headless-runtime-service.d.ts.map +1 -1
  574. package/dist/server/headless-runtime-service.js +39 -0
  575. package/dist/server/headless-runtime-service.js.map +1 -1
  576. package/dist/server/hosted-agent-runtime-progress.d.ts +144 -0
  577. package/dist/server/hosted-agent-runtime-progress.d.ts.map +1 -0
  578. package/dist/server/hosted-agent-runtime-progress.js +1650 -0
  579. package/dist/server/hosted-agent-runtime-progress.js.map +1 -0
  580. package/dist/server/hosted-runner-lease.d.ts +41 -0
  581. package/dist/server/hosted-runner-lease.d.ts.map +1 -0
  582. package/dist/server/hosted-runner-lease.js +140 -0
  583. package/dist/server/hosted-runner-lease.js.map +1 -0
  584. package/dist/server/hosted-session-manager.d.ts +16 -8
  585. package/dist/server/hosted-session-manager.d.ts.map +1 -1
  586. package/dist/server/hosted-session-manager.js +98 -76
  587. package/dist/server/hosted-session-manager.js.map +1 -1
  588. package/dist/server/junit-xml.d.ts +2 -0
  589. package/dist/server/junit-xml.d.ts.map +1 -0
  590. package/dist/server/junit-xml.js +9 -0
  591. package/dist/server/junit-xml.js.map +1 -0
  592. package/dist/server/routes.d.ts.map +1 -1
  593. package/dist/server/routes.js +6 -0
  594. package/dist/server/routes.js.map +1 -1
  595. package/dist/server/scenario-recorder.d.ts +56 -0
  596. package/dist/server/scenario-recorder.d.ts.map +1 -0
  597. package/dist/server/scenario-recorder.js +109 -0
  598. package/dist/server/scenario-recorder.js.map +1 -0
  599. package/dist/server/scripted-scenario-runner.d.ts +46 -0
  600. package/dist/server/scripted-scenario-runner.d.ts.map +1 -0
  601. package/dist/server/scripted-scenario-runner.js +190 -0
  602. package/dist/server/scripted-scenario-runner.js.map +1 -0
  603. package/dist/server/server-middlewares.d.ts +6 -2
  604. package/dist/server/server-middlewares.d.ts.map +1 -1
  605. package/dist/server/server-middlewares.js +8 -2
  606. package/dist/server/server-middlewares.js.map +1 -1
  607. package/dist/server/server-request-manager.d.ts +9 -1
  608. package/dist/server/server-request-manager.d.ts.map +1 -1
  609. package/dist/server/server-request-manager.js +49 -4
  610. package/dist/server/server-request-manager.js.map +1 -1
  611. package/dist/services/intelligent-router/service.d.ts +2 -0
  612. package/dist/services/intelligent-router/service.d.ts.map +1 -1
  613. package/dist/services/intelligent-router/service.js +4 -0
  614. package/dist/services/intelligent-router/service.js.map +1 -1
  615. package/dist/services/service-authority.d.ts +25 -0
  616. package/dist/services/service-authority.d.ts.map +1 -0
  617. package/dist/services/service-authority.js +143 -0
  618. package/dist/services/service-authority.js.map +1 -0
  619. package/dist/services/workspace-config/service.d.ts +2 -0
  620. package/dist/services/workspace-config/service.d.ts.map +1 -1
  621. package/dist/services/workspace-config/service.js +4 -0
  622. package/dist/services/workspace-config/service.js.map +1 -1
  623. package/dist/session/manager.d.ts +8 -2
  624. package/dist/session/manager.d.ts.map +1 -1
  625. package/dist/session/manager.js +19 -4
  626. package/dist/session/manager.js.map +1 -1
  627. package/dist/session/session-branch.d.ts.map +1 -1
  628. package/dist/session/session-branch.js +5 -1
  629. package/dist/session/session-branch.js.map +1 -1
  630. package/dist/session/session-catalog.d.ts +7 -2
  631. package/dist/session/session-catalog.d.ts.map +1 -1
  632. package/dist/session/session-catalog.js +13 -2
  633. package/dist/session/session-catalog.js.map +1 -1
  634. package/dist/session/session-context.d.ts +6 -2
  635. package/dist/session/session-context.d.ts.map +1 -1
  636. package/dist/session/session-context.js +44 -4
  637. package/dist/session/session-context.js.map +1 -1
  638. package/dist/session/session-graph-projection.d.ts +32 -0
  639. package/dist/session/session-graph-projection.d.ts.map +1 -0
  640. package/dist/session/session-graph-projection.js +133 -0
  641. package/dist/session/session-graph-projection.js.map +1 -0
  642. package/dist/session/types.d.ts +18 -0
  643. package/dist/session/types.d.ts.map +1 -1
  644. package/dist/session/types.js +8 -0
  645. package/dist/session/types.js.map +1 -1
  646. package/dist/session/wire-format.generated.d.ts +3 -0
  647. package/dist/session/wire-format.generated.d.ts.map +1 -1
  648. package/dist/session/wire-format.generated.js +20 -0
  649. package/dist/session/wire-format.generated.js.map +1 -1
  650. package/dist/skills/eval-harness.d.ts +38 -0
  651. package/dist/skills/eval-harness.d.ts.map +1 -0
  652. package/dist/skills/eval-harness.js +112 -0
  653. package/dist/skills/eval-harness.js.map +1 -0
  654. package/dist/skills/index.d.ts +5 -1
  655. package/dist/skills/index.d.ts.map +1 -1
  656. package/dist/skills/index.js +5 -1
  657. package/dist/skills/index.js.map +1 -1
  658. package/dist/skills/linter.d.ts +36 -0
  659. package/dist/skills/linter.d.ts.map +1 -0
  660. package/dist/skills/linter.js +398 -0
  661. package/dist/skills/linter.js.map +1 -0
  662. package/dist/skills/loader.d.ts +36 -6
  663. package/dist/skills/loader.d.ts.map +1 -1
  664. package/dist/skills/loader.js +169 -86
  665. package/dist/skills/loader.js.map +1 -1
  666. package/dist/skills/package-contract.d.ts +45 -0
  667. package/dist/skills/package-contract.d.ts.map +1 -0
  668. package/dist/skills/package-contract.js +153 -0
  669. package/dist/skills/package-contract.js.map +1 -0
  670. package/dist/skills/runtime-activation.d.ts +68 -0
  671. package/dist/skills/runtime-activation.d.ts.map +1 -0
  672. package/dist/skills/runtime-activation.js +228 -0
  673. package/dist/skills/runtime-activation.js.map +1 -0
  674. package/dist/skills/service-client.d.ts.map +1 -1
  675. package/dist/skills/service-client.js +3 -4
  676. package/dist/skills/service-client.js.map +1 -1
  677. package/dist/skills/tool.d.ts.map +1 -1
  678. package/dist/skills/tool.js +2 -0
  679. package/dist/skills/tool.js.map +1 -1
  680. package/dist/skills/types.d.ts +14 -0
  681. package/dist/skills/types.d.ts.map +1 -1
  682. package/dist/skills/types.js.map +1 -1
  683. package/dist/telemetry/agent-operating-plane-context.d.ts +24 -0
  684. package/dist/telemetry/agent-operating-plane-context.d.ts.map +1 -0
  685. package/dist/telemetry/agent-operating-plane-context.js +54 -0
  686. package/dist/telemetry/agent-operating-plane-context.js.map +1 -0
  687. package/dist/telemetry/beacon.d.ts +24 -0
  688. package/dist/telemetry/beacon.d.ts.map +1 -0
  689. package/dist/telemetry/beacon.js +115 -0
  690. package/dist/telemetry/beacon.js.map +1 -0
  691. package/dist/telemetry/cli-command-aggregator.d.ts +36 -0
  692. package/dist/telemetry/cli-command-aggregator.d.ts.map +1 -0
  693. package/dist/telemetry/cli-command-aggregator.js +251 -0
  694. package/dist/telemetry/cli-command-aggregator.js.map +1 -0
  695. package/dist/telemetry/cli-startup.d.ts +21 -0
  696. package/dist/telemetry/cli-startup.d.ts.map +1 -0
  697. package/dist/telemetry/cli-startup.js +83 -0
  698. package/dist/telemetry/cli-startup.js.map +1 -0
  699. package/dist/telemetry/disablement.d.ts +13 -0
  700. package/dist/telemetry/disablement.d.ts.map +1 -0
  701. package/dist/telemetry/disablement.js +19 -0
  702. package/dist/telemetry/disablement.js.map +1 -0
  703. package/dist/telemetry/index.d.ts +6 -2
  704. package/dist/telemetry/index.d.ts.map +1 -1
  705. package/dist/telemetry/index.js +6 -2
  706. package/dist/telemetry/index.js.map +1 -1
  707. package/dist/telemetry/maestro-event-bus.d.ts +52 -0
  708. package/dist/telemetry/maestro-event-bus.d.ts.map +1 -1
  709. package/dist/telemetry/maestro-event-bus.js +179 -3
  710. package/dist/telemetry/maestro-event-bus.js.map +1 -1
  711. package/dist/telemetry/maestro-event-catalog.d.ts +3 -1
  712. package/dist/telemetry/maestro-event-catalog.d.ts.map +1 -1
  713. package/dist/telemetry/maestro-event-catalog.js +2 -0
  714. package/dist/telemetry/maestro-event-catalog.js.map +1 -1
  715. package/dist/telemetry/maestro-platform-replay-fixture.d.ts.map +1 -1
  716. package/dist/telemetry/maestro-platform-replay-fixture.js +74 -9
  717. package/dist/telemetry/maestro-platform-replay-fixture.js.map +1 -1
  718. package/dist/telemetry/maestro-publisher-conformance-fixture.d.ts +1 -1
  719. package/dist/telemetry/maestro-publisher-conformance-fixture.d.ts.map +1 -1
  720. package/dist/telemetry/maestro-publisher-conformance-fixture.js +46 -11
  721. package/dist/telemetry/maestro-publisher-conformance-fixture.js.map +1 -1
  722. package/dist/telemetry/mcp-beacon.d.ts +20 -0
  723. package/dist/telemetry/mcp-beacon.d.ts.map +1 -0
  724. package/dist/telemetry/mcp-beacon.js +54 -0
  725. package/dist/telemetry/mcp-beacon.js.map +1 -0
  726. package/dist/telemetry/metadata-normalization.d.ts +7 -0
  727. package/dist/telemetry/metadata-normalization.d.ts.map +1 -0
  728. package/dist/telemetry/metadata-normalization.js +189 -0
  729. package/dist/telemetry/metadata-normalization.js.map +1 -0
  730. package/dist/telemetry/meter-service-client.d.ts.map +1 -1
  731. package/dist/telemetry/meter-service-client.js +5 -10
  732. package/dist/telemetry/meter-service-client.js.map +1 -1
  733. package/dist/telemetry/metrics.d.ts +123 -0
  734. package/dist/telemetry/metrics.d.ts.map +1 -0
  735. package/dist/telemetry/metrics.js +184 -0
  736. package/dist/telemetry/metrics.js.map +1 -0
  737. package/dist/telemetry/turn-tracker.d.ts +1 -0
  738. package/dist/telemetry/turn-tracker.d.ts.map +1 -1
  739. package/dist/telemetry/turn-tracker.js +22 -1
  740. package/dist/telemetry/turn-tracker.js.map +1 -1
  741. package/dist/telemetry/wide-events.d.ts +31 -1
  742. package/dist/telemetry/wide-events.d.ts.map +1 -1
  743. package/dist/telemetry/wide-events.js +229 -1
  744. package/dist/telemetry/wide-events.js.map +1 -1
  745. package/dist/telemetry.d.ts +39 -3
  746. package/dist/telemetry.d.ts.map +1 -1
  747. package/dist/telemetry.js +160 -3
  748. package/dist/telemetry.js.map +1 -1
  749. package/dist/testing/test-verification-hook.d.ts.map +1 -1
  750. package/dist/testing/test-verification-hook.js +34 -21
  751. package/dist/testing/test-verification-hook.js.map +1 -1
  752. package/dist/tools/apply-patch-parser.d.ts +26 -0
  753. package/dist/tools/apply-patch-parser.d.ts.map +1 -0
  754. package/dist/tools/apply-patch-parser.js +146 -0
  755. package/dist/tools/apply-patch-parser.js.map +1 -0
  756. package/dist/tools/apply-patch.d.ts +42 -0
  757. package/dist/tools/apply-patch.d.ts.map +1 -0
  758. package/dist/tools/apply-patch.js +648 -0
  759. package/dist/tools/apply-patch.js.map +1 -0
  760. package/dist/tools/ask-user.d.ts +1 -0
  761. package/dist/tools/ask-user.d.ts.map +1 -1
  762. package/dist/tools/background/tool-handler.d.ts +1 -0
  763. package/dist/tools/background/tool-handler.d.ts.map +1 -1
  764. package/dist/tools/bash.d.ts +1 -0
  765. package/dist/tools/bash.d.ts.map +1 -1
  766. package/dist/tools/codesearch.d.ts +1 -0
  767. package/dist/tools/codesearch.d.ts.map +1 -1
  768. package/dist/tools/conductor-client.d.ts +1 -0
  769. package/dist/tools/conductor-client.d.ts.map +1 -1
  770. package/dist/tools/conductor-client.js +63 -0
  771. package/dist/tools/conductor-client.js.map +1 -1
  772. package/dist/tools/diff.d.ts +1 -0
  773. package/dist/tools/diff.d.ts.map +1 -1
  774. package/dist/tools/edit.d.ts +1 -0
  775. package/dist/tools/edit.d.ts.map +1 -1
  776. package/dist/tools/extract-document.d.ts +1 -0
  777. package/dist/tools/extract-document.d.ts.map +1 -1
  778. package/dist/tools/find.d.ts +10 -0
  779. package/dist/tools/find.d.ts.map +1 -1
  780. package/dist/tools/find.js +236 -27
  781. package/dist/tools/find.js.map +1 -1
  782. package/dist/tools/gh.d.ts +3 -0
  783. package/dist/tools/gh.d.ts.map +1 -1
  784. package/dist/tools/index.d.ts +50 -0
  785. package/dist/tools/index.d.ts.map +1 -1
  786. package/dist/tools/index.js +4 -0
  787. package/dist/tools/index.js.map +1 -1
  788. package/dist/tools/list.d.ts +1 -0
  789. package/dist/tools/list.d.ts.map +1 -1
  790. package/dist/tools/notebook.d.ts +1 -0
  791. package/dist/tools/notebook.d.ts.map +1 -1
  792. package/dist/tools/oracle.d.ts +1 -0
  793. package/dist/tools/oracle.d.ts.map +1 -1
  794. package/dist/tools/oracle.js +17 -32
  795. package/dist/tools/oracle.js.map +1 -1
  796. package/dist/tools/parallel-execution.d.ts +13 -2
  797. package/dist/tools/parallel-execution.d.ts.map +1 -1
  798. package/dist/tools/parallel-execution.js +178 -7
  799. package/dist/tools/parallel-execution.js.map +1 -1
  800. package/dist/tools/parallel-ripgrep.d.ts +1 -0
  801. package/dist/tools/parallel-ripgrep.d.ts.map +1 -1
  802. package/dist/tools/pipeline.d.ts +4 -0
  803. package/dist/tools/pipeline.d.ts.map +1 -1
  804. package/dist/tools/read.d.ts +1 -0
  805. package/dist/tools/read.d.ts.map +1 -1
  806. package/dist/tools/search.d.ts +1 -0
  807. package/dist/tools/search.d.ts.map +1 -1
  808. package/dist/tools/status.d.ts +1 -0
  809. package/dist/tools/status.d.ts.map +1 -1
  810. package/dist/tools/todo.d.ts +1 -0
  811. package/dist/tools/todo.d.ts.map +1 -1
  812. package/dist/tools/tool-dsl.d.ts +5 -1
  813. package/dist/tools/tool-dsl.d.ts.map +1 -1
  814. package/dist/tools/tool-dsl.js +1 -0
  815. package/dist/tools/tool-dsl.js.map +1 -1
  816. package/dist/tools/tool-result-cache.d.ts.map +1 -1
  817. package/dist/tools/tool-result-cache.js +1 -0
  818. package/dist/tools/tool-result-cache.js.map +1 -1
  819. package/dist/tools/typebox-tool.d.ts.map +1 -1
  820. package/dist/tools/typebox-tool.js +3 -0
  821. package/dist/tools/typebox-tool.js.map +1 -1
  822. package/dist/tools/webfetch.d.ts +1 -0
  823. package/dist/tools/webfetch.d.ts.map +1 -1
  824. package/dist/tools/websearch.d.ts +1 -0
  825. package/dist/tools/websearch.d.ts.map +1 -1
  826. package/dist/tools/write.d.ts +1 -0
  827. package/dist/tools/write.d.ts.map +1 -1
  828. package/dist/utils/abort-error.d.ts +2 -0
  829. package/dist/utils/abort-error.d.ts.map +1 -0
  830. package/dist/utils/abort-error.js +7 -0
  831. package/dist/utils/abort-error.js.map +1 -0
  832. package/dist/utils/downstream.d.ts.map +1 -1
  833. package/dist/utils/downstream.js +4 -0
  834. package/dist/utils/downstream.js.map +1 -1
  835. package/dist/utils/logger.d.ts +3 -0
  836. package/dist/utils/logger.d.ts.map +1 -1
  837. package/dist/utils/logger.js +14 -3
  838. package/dist/utils/logger.js.map +1 -1
  839. package/dist/utils/path-containment.d.ts +2 -0
  840. package/dist/utils/path-containment.d.ts.map +1 -0
  841. package/dist/utils/path-containment.js +14 -0
  842. package/dist/utils/path-containment.js.map +1 -0
  843. package/dist/utils/prompt-safe-text.d.ts +7 -0
  844. package/dist/utils/prompt-safe-text.d.ts.map +1 -0
  845. package/dist/utils/prompt-safe-text.js +44 -0
  846. package/dist/utils/prompt-safe-text.js.map +1 -0
  847. package/dist/version.json +2 -2
  848. package/dist/web-server.d.ts.map +1 -1
  849. package/dist/web-server.js +32 -7
  850. package/dist/web-server.js.map +1 -1
  851. package/dist/workspace/root-resolver.d.ts +4 -1
  852. package/dist/workspace/root-resolver.d.ts.map +1 -1
  853. package/dist/workspace/root-resolver.js +16 -6
  854. package/dist/workspace/root-resolver.js.map +1 -1
  855. package/node_modules/@evalops/contracts/dist/advisor-effort.d.ts +8 -0
  856. package/node_modules/@evalops/contracts/dist/advisor-effort.d.ts.map +1 -0
  857. package/node_modules/@evalops/contracts/dist/advisor-effort.js +35 -0
  858. package/node_modules/@evalops/contracts/dist/advisor-effort.js.map +1 -0
  859. package/node_modules/@evalops/contracts/dist/delegation-prompt.d.ts +10 -0
  860. package/node_modules/@evalops/contracts/dist/delegation-prompt.d.ts.map +1 -0
  861. package/node_modules/@evalops/contracts/dist/delegation-prompt.js +48 -0
  862. package/node_modules/@evalops/contracts/dist/delegation-prompt.js.map +1 -0
  863. package/node_modules/@evalops/contracts/dist/guarded-files-settings.d.ts +20 -0
  864. package/node_modules/@evalops/contracts/dist/guarded-files-settings.d.ts.map +1 -0
  865. package/node_modules/@evalops/contracts/dist/guarded-files-settings.js +147 -0
  866. package/node_modules/@evalops/contracts/dist/guarded-files-settings.js.map +1 -0
  867. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.d.ts +2 -0
  868. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.d.ts.map +1 -1
  869. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.js +1 -0
  870. package/node_modules/@evalops/contracts/dist/headless-protocol-generated.js.map +1 -1
  871. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.d.ts +280 -5
  872. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.d.ts.map +1 -1
  873. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.js +36 -1
  874. package/node_modules/@evalops/contracts/dist/headless-protocol-schemas.generated.js.map +1 -1
  875. package/node_modules/@evalops/contracts/dist/index.d.ts +15 -1
  876. package/node_modules/@evalops/contracts/dist/index.d.ts.map +1 -1
  877. package/node_modules/@evalops/contracts/dist/index.js +6 -0
  878. package/node_modules/@evalops/contracts/dist/index.js.map +1 -1
  879. package/node_modules/@evalops/contracts/dist/maestro-app-server.d.ts +593 -0
  880. package/node_modules/@evalops/contracts/dist/maestro-app-server.d.ts.map +1 -0
  881. package/node_modules/@evalops/contracts/dist/maestro-app-server.js +218 -0
  882. package/node_modules/@evalops/contracts/dist/maestro-app-server.js.map +1 -0
  883. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.d.ts +91 -0
  884. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.d.ts.map +1 -1
  885. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.js +92 -61
  886. package/node_modules/@evalops/contracts/dist/proto/maestro/v1/headless_pb.js.map +1 -1
  887. package/node_modules/@evalops/contracts/dist/runtime-app-server.d.ts +3 -0
  888. package/node_modules/@evalops/contracts/dist/runtime-app-server.d.ts.map +1 -1
  889. package/node_modules/@evalops/contracts/dist/runtime-constraints.d.ts +28 -0
  890. package/node_modules/@evalops/contracts/dist/runtime-constraints.d.ts.map +1 -0
  891. package/node_modules/@evalops/contracts/dist/runtime-constraints.js +71 -0
  892. package/node_modules/@evalops/contracts/dist/runtime-constraints.js.map +1 -0
  893. package/node_modules/@evalops/contracts/dist/runtime-server-request.d.ts +7 -0
  894. package/node_modules/@evalops/contracts/dist/runtime-server-request.d.ts.map +1 -1
  895. package/node_modules/@evalops/contracts/dist/runtime-server-request.js +2 -0
  896. package/node_modules/@evalops/contracts/dist/runtime-server-request.js.map +1 -1
  897. package/node_modules/@evalops/contracts/dist/scenario.d.ts +191 -0
  898. package/node_modules/@evalops/contracts/dist/scenario.d.ts.map +1 -0
  899. package/node_modules/@evalops/contracts/dist/scenario.js +4 -0
  900. package/node_modules/@evalops/contracts/dist/scenario.js.map +1 -0
  901. package/node_modules/@evalops/contracts/dist/schemas.d.ts +17 -3
  902. package/node_modules/@evalops/contracts/dist/schemas.d.ts.map +1 -1
  903. package/node_modules/@evalops/contracts/dist/schemas.js +16 -0
  904. package/node_modules/@evalops/contracts/dist/schemas.js.map +1 -1
  905. package/node_modules/@evalops/contracts/package.json +1 -1
  906. package/node_modules/@evalops/tui/package.json +1 -1
  907. package/package.json +41 -7
  908. package/skills/incident-triage/SKILL.md +40 -0
  909. package/skills/incident-triage/mcp.json +14 -0
  910. package/skills/incident-triage/reference/triage.md +20 -0
  911. package/skills/incident-triage/toolbox/incident-timeline +22 -0
  912. package/skills/incident-triage/toolbox/incident-timeline.cmd +16 -0
  913. package/skills/pr-review/SKILL.md +40 -0
  914. package/skills/pr-review/mcp.json +14 -0
  915. package/skills/pr-review/reference/rubric.md +20 -0
  916. package/skills/pr-review/toolbox/review-summary +20 -0
  917. package/skills/pr-review/toolbox/review-summary.cmd +14 -0
  918. package/skills/release-verification/SKILL.md +40 -0
  919. package/skills/release-verification/mcp.json +15 -0
  920. package/skills/release-verification/reference/checklist.md +21 -0
  921. package/skills/release-verification/toolbox/release-readiness +18 -0
  922. package/skills/release-verification/toolbox/release-readiness.cmd +12 -0
@@ -26,6 +26,7 @@
26
26
  *
27
27
  * @module tools/parallel-execution
28
28
  */
29
+ import { isAbsolute, resolve } from "node:path";
29
30
  /**
30
31
  * Set of known read-only tool names.
31
32
  *
@@ -74,6 +75,7 @@ export const READ_ONLY_TOOLS = new Set([
74
75
  * operations on the same resources.
75
76
  */
76
77
  export const WRITE_TOOLS = new Set([
78
+ "apply_patch",
77
79
  "write",
78
80
  "Write",
79
81
  "edit",
@@ -92,7 +94,7 @@ export const WRITE_TOOLS = new Set([
92
94
  * @param annotations - Optional tool annotations
93
95
  * @returns true if the tool is read-only
94
96
  */
95
- export function isReadOnlyTool(toolName, annotations) {
97
+ export function isReadOnlyTool(toolName, annotations, _source) {
96
98
  // Check explicit annotation first
97
99
  if (annotations?.readOnlyHint === true) {
98
100
  return true;
@@ -103,6 +105,15 @@ export function isReadOnlyTool(toolName, annotations) {
103
105
  // Fall back to known tool lists
104
106
  return READ_ONLY_TOOLS.has(toolName);
105
107
  }
108
+ export function isParallelSafeTool(toolName, annotations, source) {
109
+ if (isReadOnlyTool(toolName, annotations, source)) {
110
+ return true;
111
+ }
112
+ if (annotations?.destructiveHint === true) {
113
+ return false;
114
+ }
115
+ return source?.type === "mcp" && source.supportsParallelToolCalls === true;
116
+ }
106
117
  /**
107
118
  * Check if a tool is a write/mutating operation.
108
119
  *
@@ -136,12 +147,18 @@ export function getOptimalConcurrency(toolCalls, tools, config) {
136
147
  return baseConcurrency;
137
148
  }
138
149
  // Build a map of tool names to annotations
139
- const toolAnnotations = new Map();
150
+ const toolMetadata = new Map();
140
151
  for (const tool of tools) {
141
- toolAnnotations.set(tool.name, tool.annotations);
152
+ toolMetadata.set(tool.name, {
153
+ annotations: tool.annotations,
154
+ source: tool.source,
155
+ });
142
156
  }
143
157
  // Check if all tools are read-only
144
- const allReadOnly = toolCalls.every((call) => isReadOnlyTool(call.name, toolAnnotations.get(call.name)));
158
+ const allReadOnly = toolCalls.every((call) => {
159
+ const metadata = toolMetadata.get(call.name);
160
+ return isReadOnlyTool(call.name, metadata?.annotations, metadata?.source);
161
+ });
145
162
  if (allReadOnly) {
146
163
  // Safe to use higher concurrency
147
164
  return Math.min(maxReadOnlyConcurrency, toolCalls.length);
@@ -160,14 +177,18 @@ export function getOptimalConcurrency(toolCalls, tools, config) {
160
177
  * @returns Object with readOnly and write arrays
161
178
  */
162
179
  export function partitionToolCalls(toolCalls, tools) {
163
- const toolAnnotations = new Map();
180
+ const toolMetadata = new Map();
164
181
  for (const tool of tools) {
165
- toolAnnotations.set(tool.name, tool.annotations);
182
+ toolMetadata.set(tool.name, {
183
+ annotations: tool.annotations,
184
+ source: tool.source,
185
+ });
166
186
  }
167
187
  const readOnly = [];
168
188
  const write = [];
169
189
  for (const call of toolCalls) {
170
- if (isReadOnlyTool(call.name, toolAnnotations.get(call.name))) {
190
+ const metadata = toolMetadata.get(call.name);
191
+ if (isReadOnlyTool(call.name, metadata?.annotations, metadata?.source)) {
171
192
  readOnly.push(call);
172
193
  }
173
194
  else {
@@ -176,6 +197,156 @@ export function partitionToolCalls(toolCalls, tools) {
176
197
  }
177
198
  return { readOnly, write };
178
199
  }
200
+ const PATH_SCOPED_MUTATION_TOOLS = new Set([
201
+ "apply_patch",
202
+ "write",
203
+ "Write",
204
+ "edit",
205
+ "Edit",
206
+ "MultiEdit",
207
+ "notebook_edit",
208
+ "NotebookEdit",
209
+ ]);
210
+ const PATH_ARGUMENT_KEYS = new Set([
211
+ "file",
212
+ "file_path",
213
+ "filePath",
214
+ "files",
215
+ "path",
216
+ "paths",
217
+ "target",
218
+ "targets",
219
+ "target_path",
220
+ "targetPath",
221
+ "notebook_path",
222
+ "notebookPath",
223
+ "output_path",
224
+ "outputPath",
225
+ ]);
226
+ const PATH_ARGUMENT_CONTAINER_KEYS = new Set([
227
+ "edits",
228
+ "operations",
229
+ "patches",
230
+ ]);
231
+ const PATCH_ARGUMENT_KEYS = new Set(["patch", "patch_text", "patchText"]);
232
+ function normalizeMutationPath(value, cwd = process.cwd()) {
233
+ const input = value.trim().replace(/\\/g, "/");
234
+ if (!input || /[*?[\]{}]/u.test(input)) {
235
+ return undefined;
236
+ }
237
+ const basePath = cwd.replace(/\\/g, "/");
238
+ let normalized = (isAbsolute(input) ? resolve(input) : resolve(basePath, input))
239
+ .replace(/\\/g, "/")
240
+ .replace(/\/+/g, "/");
241
+ normalized = normalized.toLowerCase();
242
+ if (normalized.length > 1) {
243
+ normalized = normalized.replace(/\/$/u, "");
244
+ }
245
+ return normalized || undefined;
246
+ }
247
+ function collectPathArgumentValues(value, paths, cwd, matchedKeys, stringIsPath) {
248
+ if (typeof value === "string") {
249
+ if (stringIsPath) {
250
+ const path = normalizeMutationPath(value, cwd);
251
+ if (path) {
252
+ paths.push(path);
253
+ }
254
+ }
255
+ return;
256
+ }
257
+ if (Array.isArray(value)) {
258
+ for (const entry of value) {
259
+ collectPathArgumentValues(entry, paths, cwd, matchedKeys, stringIsPath);
260
+ }
261
+ return;
262
+ }
263
+ if (value && typeof value === "object") {
264
+ for (const [key, nested] of Object.entries(value)) {
265
+ if (PATH_ARGUMENT_KEYS.has(key)) {
266
+ matchedKeys.add(key);
267
+ collectPathArgumentValues(nested, paths, cwd, matchedKeys, true);
268
+ continue;
269
+ }
270
+ if (PATCH_ARGUMENT_KEYS.has(key)) {
271
+ matchedKeys.add(key);
272
+ collectPatchHeaderPaths(nested, paths, cwd, matchedKeys);
273
+ continue;
274
+ }
275
+ if (PATH_ARGUMENT_CONTAINER_KEYS.has(key)) {
276
+ matchedKeys.add(key);
277
+ collectPathArgumentValues(nested, paths, cwd, matchedKeys, false);
278
+ }
279
+ }
280
+ }
281
+ }
282
+ function collectPatchHeaderPaths(value, paths, cwd, matchedKeys) {
283
+ if (typeof value === "string") {
284
+ for (const match of value.matchAll(/^\*\*\* (?:Update File|Add File|Delete File|Move to):\s+(.+)$/gmu)) {
285
+ const rawPath = match[1]?.trim();
286
+ if (!rawPath)
287
+ continue;
288
+ const path = normalizeMutationPath(rawPath, cwd);
289
+ if (path) {
290
+ paths.push(path);
291
+ matchedKeys.add("patch");
292
+ }
293
+ }
294
+ return;
295
+ }
296
+ if (Array.isArray(value)) {
297
+ for (const entry of value) {
298
+ collectPatchHeaderPaths(entry, paths, cwd, matchedKeys);
299
+ }
300
+ return;
301
+ }
302
+ if (value && typeof value === "object") {
303
+ collectPathArgumentValues(value, paths, cwd, matchedKeys, false);
304
+ }
305
+ }
306
+ export function getPathScopedMutation(toolCall, tool, cwd = process.cwd()) {
307
+ const annotations = tool?.annotations;
308
+ const source = annotations?.pathScopedMutationHint === true ? "annotation" : "known_tool";
309
+ const isPathScopedTool = annotations?.pathScopedMutationHint === true ||
310
+ PATH_SCOPED_MUTATION_TOOLS.has(tool?.name ?? toolCall.name);
311
+ if (!isPathScopedTool || annotations?.readOnlyHint === true) {
312
+ return undefined;
313
+ }
314
+ const args = toolCall.arguments &&
315
+ typeof toolCall.arguments === "object" &&
316
+ !Array.isArray(toolCall.arguments)
317
+ ? toolCall.arguments
318
+ : undefined;
319
+ if (!args) {
320
+ return undefined;
321
+ }
322
+ const paths = [];
323
+ const matchedKeys = new Set();
324
+ for (const [key, value] of Object.entries(args)) {
325
+ if (PATH_ARGUMENT_KEYS.has(key)) {
326
+ matchedKeys.add(key);
327
+ collectPathArgumentValues(value, paths, cwd, matchedKeys, true);
328
+ continue;
329
+ }
330
+ if (PATCH_ARGUMENT_KEYS.has(key)) {
331
+ matchedKeys.add(key);
332
+ collectPatchHeaderPaths(value, paths, cwd, matchedKeys);
333
+ continue;
334
+ }
335
+ if (PATH_ARGUMENT_CONTAINER_KEYS.has(key)) {
336
+ matchedKeys.add(key);
337
+ collectPathArgumentValues(value, paths, cwd, matchedKeys, false);
338
+ }
339
+ }
340
+ const uniquePaths = [...new Set(paths)];
341
+ return uniquePaths.length > 0
342
+ ? { paths: uniquePaths, source, argumentKeys: [...matchedKeys].sort() }
343
+ : undefined;
344
+ }
345
+ export function pathScopesOverlap(left, right) {
346
+ return left.paths.some((leftPath) => right.paths.some((rightPath) => leftPath === rightPath ||
347
+ leftPath.startsWith(`${rightPath}/`) ||
348
+ rightPath.startsWith(`${leftPath}/`)));
349
+ }
179
350
  /**
180
351
  * Add read-only annotation to a tool definition.
181
352
  *
@@ -1 +1 @@
1
- {"version":3,"file":"parallel-execution.js","sourceRoot":"","sources":["../../src/tools/parallel-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IACtC,eAAe;IACf,MAAM;IACN,MAAM;IACN,oBAAoB;IACpB,IAAI;IACJ,MAAM;IACN,eAAe;IACf,MAAM;IACN,MAAM;IACN,iBAAiB;IACjB,MAAM;IACN,QAAQ;IACR,kBAAkB;IAClB,6BAA6B;IAC7B,MAAM;IACN,cAAc;IACd,QAAQ;IACR,sBAAsB;IACtB,kBAAkB;IAClB,0BAA0B;IAC1B,uBAAuB;IACvB,wBAAwB;IACxB,wBAAwB;IACxB,wBAAwB;IACxB,4BAA4B;IAC5B,0BAA0B;IAC1B,2BAA2B;IAC3B,2BAA2B;IAC3B,2BAA2B;IAC3B,6BAA6B;IAC7B,KAAK;CACL,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GA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B,IAAO;IACxD,OAAO;QACN,GAAG,IAAI;QACP,WAAW,EAAE;YACZ,GAAG,IAAI,CAAC,WAAW;YACnB,YAAY,EAAE,IAAI;SAClB;KACD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAsB,IAAO;IAC3D,OAAO;QACN,GAAG,IAAI;QACP,WAAW,EAAE;YACZ,GAAG,IAAI,CAAC,WAAW;YACnB,eAAe,EAAE,IAAI;SACrB;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Parallel Execution - Optimized concurrent tool execution for read-only operations\n *\n * This module provides utilities for safely increasing concurrency when executing\n * read-only tools. Read-only tools can run in parallel without risk of conflicts,\n * enabling significant latency improvements for batch operations.\n *\n * ## Read-Only Tools\n *\n * Tools are considered read-only if they:\n * - Do not modify files or system state\n * - Are idempotent (same input = same output)\n * - Have no side effects on external systems\n *\n * Examples: read, list, find, search, diff, status\n *\n * ## Usage\n *\n * ```typescript\n * import { isReadOnlyTool, getOptimalConcurrency } from './parallel-execution.js';\n *\n * const tools = [readTool, listTool, findTool];\n * const allReadOnly = tools.every(t => isReadOnlyTool(t.name));\n * const concurrency = getOptimalConcurrency(tools, baseConcurrency);\n * ```\n *\n * @module tools/parallel-execution\n */\n\nimport type { AgentTool, ToolAnnotations } from \"../agent/types.js\";\n\n/**\n * Set of known read-only tool names.\n *\n * These tools are safe to execute in parallel because they:\n * - Only read data, never modify it\n * - Have no side effects\n * - Are idempotent\n */\nexport const READ_ONLY_TOOLS = new Set([\n\t// File reading\n\t\"Read\",\n\t\"read\",\n\t// Directory listing\n\t\"LS\",\n\t\"list\",\n\t// File finding\n\t\"Glob\",\n\t\"find\",\n\t// Content search\n\t\"Grep\",\n\t\"search\",\n\t\"parallel_ripgrep\",\n\t// Git operations (read-only)\n\t\"diff\",\n\t// System info\n\t\"status\",\n\t// Document extraction\n\t\"extract_document\",\n\t// VS Code read operations\n\t\"vscode_get_definition\",\n\t\"vscode_find_references\",\n\t\"vscode_get_diagnostics\",\n\t\"vscode_read_file_range\",\n\t// JetBrains read operations\n\t\"jetbrains_get_definition\",\n\t\"jetbrains_find_references\",\n\t\"jetbrains_get_diagnostics\",\n\t\"jetbrains_read_file_range\",\n\t// LSP operations (read-only)\n\t\"LSP\",\n]);\n\n/**\n * Set of known write/mutating tool names.\n *\n * These tools modify state and should not run concurrently with\n * operations on the same resources.\n */\nexport const WRITE_TOOLS = new Set([\n\t\"write\",\n\t\"Write\",\n\t\"edit\",\n\t\"Edit\",\n\t\"MultiEdit\",\n\t\"notebook_edit\",\n\t\"NotebookEdit\",\n\t\"bash\",\n\t\"Bash\",\n\t\"background_tasks\",\n]);\n\n/**\n * Check if a tool is read-only based on its name or annotations.\n *\n * @param toolName - Name of the tool\n * @param annotations - Optional tool annotations\n * @returns true if the tool is read-only\n */\nexport function isReadOnlyTool(\n\ttoolName: string,\n\tannotations?: ToolAnnotations,\n): boolean {\n\t// Check explicit annotation first\n\tif (annotations?.readOnlyHint === true) {\n\t\treturn true;\n\t}\n\tif (annotations?.readOnlyHint === false) {\n\t\treturn false;\n\t}\n\n\t// Fall back to known tool lists\n\treturn READ_ONLY_TOOLS.has(toolName);\n}\n\n/**\n * Check if a tool is a write/mutating operation.\n *\n * @param toolName - Name of the tool\n * @param annotations - Optional tool annotations\n * @returns true if the tool modifies state\n */\nexport function isWriteTool(\n\ttoolName: string,\n\tannotations?: ToolAnnotations,\n): boolean {\n\t// Check explicit annotation\n\tif (annotations?.destructiveHint === true) {\n\t\treturn true;\n\t}\n\n\treturn WRITE_TOOLS.has(toolName);\n}\n\n/**\n * Configuration for parallel execution optimization.\n */\nexport interface ParallelExecutionConfig {\n\t/** Base concurrency limit (default: 2) */\n\tbaseConcurrency?: number;\n\t/** Maximum concurrency for read-only batches (default: 8) */\n\tmaxReadOnlyConcurrency?: number;\n\t/** Whether to enable parallel optimization (default: true) */\n\tenabled?: boolean;\n}\n\n/**\n * Get the optimal concurrency level for a batch of tool calls.\n *\n * When all tools in a batch are read-only, we can safely increase\n * concurrency to improve latency. Write operations force serialization.\n *\n * @param toolCalls - Array of tool calls to analyze\n * @param tools - Tool definitions (for annotation lookup)\n * @param config - Parallel execution configuration\n * @returns Optimal concurrency level for this batch\n */\nexport function getOptimalConcurrency(\n\ttoolCalls: Array<{ name: string }>,\n\ttools: AgentTool[],\n\tconfig?: ParallelExecutionConfig,\n): number {\n\tconst baseConcurrency = config?.baseConcurrency ?? 2;\n\tconst maxReadOnlyConcurrency = config?.maxReadOnlyConcurrency ?? 8;\n\tconst enabled = config?.enabled ?? true;\n\n\tif (!enabled || toolCalls.length === 0) {\n\t\treturn baseConcurrency;\n\t}\n\n\t// Build a map of tool names to annotations\n\tconst toolAnnotations = new Map<string, ToolAnnotations | undefined>();\n\tfor (const tool of tools) {\n\t\ttoolAnnotations.set(tool.name, tool.annotations);\n\t}\n\n\t// Check if all tools are read-only\n\tconst allReadOnly = toolCalls.every((call) =>\n\t\tisReadOnlyTool(call.name, toolAnnotations.get(call.name)),\n\t);\n\n\tif (allReadOnly) {\n\t\t// Safe to use higher concurrency\n\t\treturn Math.min(maxReadOnlyConcurrency, toolCalls.length);\n\t}\n\n\t// Has write operations - use base concurrency\n\treturn baseConcurrency;\n}\n\n/**\n * Partition tool calls into read-only and write batches.\n *\n * This enables executing all read-only operations in parallel first,\n * then executing write operations with appropriate ordering.\n *\n * @param toolCalls - Array of tool calls\n * @param tools - Tool definitions\n * @returns Object with readOnly and write arrays\n */\nexport function partitionToolCalls<T extends { name: string }>(\n\ttoolCalls: T[],\n\ttools: AgentTool[],\n): { readOnly: T[]; write: T[] } {\n\tconst toolAnnotations = new Map<string, ToolAnnotations | undefined>();\n\tfor (const tool of tools) {\n\t\ttoolAnnotations.set(tool.name, tool.annotations);\n\t}\n\n\tconst readOnly: T[] = [];\n\tconst write: T[] = [];\n\n\tfor (const call of toolCalls) {\n\t\tif (isReadOnlyTool(call.name, toolAnnotations.get(call.name))) {\n\t\t\treadOnly.push(call);\n\t\t} else {\n\t\t\twrite.push(call);\n\t\t}\n\t}\n\n\treturn { readOnly, write };\n}\n\n/**\n * Add read-only annotation to a tool definition.\n *\n * Use this to mark custom tools as read-only for parallel execution.\n *\n * @param tool - Tool definition to annotate\n * @returns Tool with readOnlyHint annotation\n */\nexport function markReadOnly<T extends AgentTool>(tool: T): T {\n\treturn {\n\t\t...tool,\n\t\tannotations: {\n\t\t\t...tool.annotations,\n\t\t\treadOnlyHint: true,\n\t\t},\n\t};\n}\n\n/**\n * Add write/destructive annotation to a tool definition.\n *\n * @param tool - Tool definition to annotate\n * @returns Tool with destructiveHint annotation\n */\nexport function markDestructive<T extends AgentTool>(tool: T): T {\n\treturn {\n\t\t...tool,\n\t\tannotations: {\n\t\t\t...tool.annotations,\n\t\t\tdestructiveHint: true,\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"parallel-execution.js","sourceRoot":"","sources":["../../src/tools/parallel-execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOhD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IACtC,eAAe;IACf,MAAM;IACN,MAAM;IACN,oBAAoB;IACpB,IAAI;IACJ,MAAM;IACN,eAAe;IACf,MAAM;IACN,MAAM;IACN,iBAAiB;IACjB,MAAM;IACN,QAAQ;IACR,kBAAkB;IAClB,6BAA6B;IAC7B,MAAM;IACN,cAAc;IACd,QAAQ;IACR,sBAAsB;IACtB,kBAAkB;IAClB,0BAA0B;IAC1B,uBAAuB;IACvB,wBAAwB;IACxB,wBAAwB;IACxB,wBAAwB;IACxB,4BAA4B;IAC5B,0BAA0B;IAC1B,2BAA2B;IAC3B,2BAA2B;IAC3B,2BAA2B;IAC3B,6BAA6B;IAC7B,KAAK;CACL,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,CAAC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AAW,CAAC,MAAM,GAAG,CAAC;QAC5B,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;QACvE,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAChC,IAAwB,EACxB,KAAyB;IAEzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACnC,KAAK,CAAC,KAAK,CAAC,IAAI,CACf,CAAC,SAAS,EAAE,EAAE,CACb,QAAQ,KAAK,SAAS;QACtB,QAAQ,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC;QACpC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,CACrC,CACD,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAsB,IAAO;IACxD,OAAO;QACN,GAAG,IAAI;QACP,WAAW,EAAE;YACZ,GAAG,IAAI,CAAC,WAAW;YACnB,YAAY,EAAE,IAAI;SAClB;KACD,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAsB,IAAO;IAC3D,OAAO;QACN,GAAG,IAAI;QACP,WAAW,EAAE;YACZ,GAAG,IAAI,CAAC,WAAW;YACnB,eAAe,EAAE,IAAI;SACrB;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * Parallel Execution - Optimized concurrent tool execution for read-only operations\n *\n * This module provides utilities for safely increasing concurrency when executing\n * read-only tools. Read-only tools can run in parallel without risk of conflicts,\n * enabling significant latency improvements for batch operations.\n *\n * ## Read-Only Tools\n *\n * Tools are considered read-only if they:\n * - Do not modify files or system state\n * - Are idempotent (same input = same output)\n * - Have no side effects on external systems\n *\n * Examples: read, list, find, search, diff, status\n *\n * ## Usage\n *\n * ```typescript\n * import { isReadOnlyTool, getOptimalConcurrency } from './parallel-execution.js';\n *\n * const tools = [readTool, listTool, findTool];\n * const allReadOnly = tools.every(t => isReadOnlyTool(t.name));\n * const concurrency = getOptimalConcurrency(tools, baseConcurrency);\n * ```\n *\n * @module tools/parallel-execution\n */\n\nimport { isAbsolute, resolve } from \"node:path\";\nimport type {\n\tAgentTool,\n\tToolAnnotations,\n\tToolSourceMetadata,\n} from \"../agent/types.js\";\n\n/**\n * Set of known read-only tool names.\n *\n * These tools are safe to execute in parallel because they:\n * - Only read data, never modify it\n * - Have no side effects\n * - Are idempotent\n */\nexport const READ_ONLY_TOOLS = new Set([\n\t// File reading\n\t\"Read\",\n\t\"read\",\n\t// Directory listing\n\t\"LS\",\n\t\"list\",\n\t// File finding\n\t\"Glob\",\n\t\"find\",\n\t// Content search\n\t\"Grep\",\n\t\"search\",\n\t\"parallel_ripgrep\",\n\t// Git operations (read-only)\n\t\"diff\",\n\t// System info\n\t\"status\",\n\t// Document extraction\n\t\"extract_document\",\n\t// VS Code read operations\n\t\"vscode_get_definition\",\n\t\"vscode_find_references\",\n\t\"vscode_get_diagnostics\",\n\t\"vscode_read_file_range\",\n\t// JetBrains read operations\n\t\"jetbrains_get_definition\",\n\t\"jetbrains_find_references\",\n\t\"jetbrains_get_diagnostics\",\n\t\"jetbrains_read_file_range\",\n\t// LSP operations (read-only)\n\t\"LSP\",\n]);\n\n/**\n * Set of known write/mutating tool names.\n *\n * These tools modify state and should not run concurrently with\n * operations on the same resources.\n */\nexport const WRITE_TOOLS = new Set([\n\t\"apply_patch\",\n\t\"write\",\n\t\"Write\",\n\t\"edit\",\n\t\"Edit\",\n\t\"MultiEdit\",\n\t\"notebook_edit\",\n\t\"NotebookEdit\",\n\t\"bash\",\n\t\"Bash\",\n\t\"background_tasks\",\n]);\n\n/**\n * Check if a tool is read-only based on its name or annotations.\n *\n * @param toolName - Name of the tool\n * @param annotations - Optional tool annotations\n * @returns true if the tool is read-only\n */\nexport function isReadOnlyTool(\n\ttoolName: string,\n\tannotations?: ToolAnnotations,\n\t_source?: ToolSourceMetadata,\n): boolean {\n\t// Check explicit annotation first\n\tif (annotations?.readOnlyHint === true) {\n\t\treturn true;\n\t}\n\tif (annotations?.readOnlyHint === false) {\n\t\treturn false;\n\t}\n\n\t// Fall back to known tool lists\n\treturn READ_ONLY_TOOLS.has(toolName);\n}\n\nexport function isParallelSafeTool(\n\ttoolName: string,\n\tannotations?: ToolAnnotations,\n\tsource?: ToolSourceMetadata,\n): boolean {\n\tif (isReadOnlyTool(toolName, annotations, source)) {\n\t\treturn true;\n\t}\n\tif (annotations?.destructiveHint === true) {\n\t\treturn false;\n\t}\n\treturn source?.type === \"mcp\" && source.supportsParallelToolCalls === true;\n}\n\n/**\n * Check if a tool is a write/mutating operation.\n *\n * @param toolName - Name of the tool\n * @param annotations - Optional tool annotations\n * @returns true if the tool modifies state\n */\nexport function isWriteTool(\n\ttoolName: string,\n\tannotations?: ToolAnnotations,\n): boolean {\n\t// Check explicit annotation\n\tif (annotations?.destructiveHint === true) {\n\t\treturn true;\n\t}\n\n\treturn WRITE_TOOLS.has(toolName);\n}\n\n/**\n * Configuration for parallel execution optimization.\n */\nexport interface ParallelExecutionConfig {\n\t/** Base concurrency limit (default: 2) */\n\tbaseConcurrency?: number;\n\t/** Maximum concurrency for read-only batches (default: 8) */\n\tmaxReadOnlyConcurrency?: number;\n\t/** Whether to enable parallel optimization (default: true) */\n\tenabled?: boolean;\n}\n\n/**\n * Get the optimal concurrency level for a batch of tool calls.\n *\n * When all tools in a batch are read-only, we can safely increase\n * concurrency to improve latency. Write operations force serialization.\n *\n * @param toolCalls - Array of tool calls to analyze\n * @param tools - Tool definitions (for annotation lookup)\n * @param config - Parallel execution configuration\n * @returns Optimal concurrency level for this batch\n */\nexport function getOptimalConcurrency(\n\ttoolCalls: Array<{ name: string }>,\n\ttools: AgentTool[],\n\tconfig?: ParallelExecutionConfig,\n): number {\n\tconst baseConcurrency = config?.baseConcurrency ?? 2;\n\tconst maxReadOnlyConcurrency = config?.maxReadOnlyConcurrency ?? 8;\n\tconst enabled = config?.enabled ?? true;\n\n\tif (!enabled || toolCalls.length === 0) {\n\t\treturn baseConcurrency;\n\t}\n\n\t// Build a map of tool names to annotations\n\tconst toolMetadata = new Map<\n\t\tstring,\n\t\t{ annotations?: ToolAnnotations; source?: ToolSourceMetadata }\n\t>();\n\tfor (const tool of tools) {\n\t\ttoolMetadata.set(tool.name, {\n\t\t\tannotations: tool.annotations,\n\t\t\tsource: tool.source,\n\t\t});\n\t}\n\n\t// Check if all tools are read-only\n\tconst allReadOnly = toolCalls.every((call) => {\n\t\tconst metadata = toolMetadata.get(call.name);\n\t\treturn isReadOnlyTool(call.name, metadata?.annotations, metadata?.source);\n\t});\n\n\tif (allReadOnly) {\n\t\t// Safe to use higher concurrency\n\t\treturn Math.min(maxReadOnlyConcurrency, toolCalls.length);\n\t}\n\n\t// Has write operations - use base concurrency\n\treturn baseConcurrency;\n}\n\n/**\n * Partition tool calls into read-only and write batches.\n *\n * This enables executing all read-only operations in parallel first,\n * then executing write operations with appropriate ordering.\n *\n * @param toolCalls - Array of tool calls\n * @param tools - Tool definitions\n * @returns Object with readOnly and write arrays\n */\nexport function partitionToolCalls<T extends { name: string }>(\n\ttoolCalls: T[],\n\ttools: AgentTool[],\n): { readOnly: T[]; write: T[] } {\n\tconst toolMetadata = new Map<\n\t\tstring,\n\t\t{ annotations?: ToolAnnotations; source?: ToolSourceMetadata }\n\t>();\n\tfor (const tool of tools) {\n\t\ttoolMetadata.set(tool.name, {\n\t\t\tannotations: tool.annotations,\n\t\t\tsource: tool.source,\n\t\t});\n\t}\n\n\tconst readOnly: T[] = [];\n\tconst write: T[] = [];\n\n\tfor (const call of toolCalls) {\n\t\tconst metadata = toolMetadata.get(call.name);\n\t\tif (isReadOnlyTool(call.name, metadata?.annotations, metadata?.source)) {\n\t\t\treadOnly.push(call);\n\t\t} else {\n\t\t\twrite.push(call);\n\t\t}\n\t}\n\n\treturn { readOnly, write };\n}\n\nexport interface PathScopedMutation {\n\tpaths: string[];\n\tsource: \"annotation\" | \"known_tool\";\n\targumentKeys?: string[];\n}\n\nconst PATH_SCOPED_MUTATION_TOOLS = new Set([\n\t\"apply_patch\",\n\t\"write\",\n\t\"Write\",\n\t\"edit\",\n\t\"Edit\",\n\t\"MultiEdit\",\n\t\"notebook_edit\",\n\t\"NotebookEdit\",\n]);\n\nconst PATH_ARGUMENT_KEYS = new Set([\n\t\"file\",\n\t\"file_path\",\n\t\"filePath\",\n\t\"files\",\n\t\"path\",\n\t\"paths\",\n\t\"target\",\n\t\"targets\",\n\t\"target_path\",\n\t\"targetPath\",\n\t\"notebook_path\",\n\t\"notebookPath\",\n\t\"output_path\",\n\t\"outputPath\",\n]);\n\nconst PATH_ARGUMENT_CONTAINER_KEYS = new Set([\n\t\"edits\",\n\t\"operations\",\n\t\"patches\",\n]);\n\nconst PATCH_ARGUMENT_KEYS = new Set([\"patch\", \"patch_text\", \"patchText\"]);\n\nfunction normalizeMutationPath(\n\tvalue: string,\n\tcwd = process.cwd(),\n): string | undefined {\n\tconst input = value.trim().replace(/\\\\/g, \"/\");\n\tif (!input || /[*?[\\]{}]/u.test(input)) {\n\t\treturn undefined;\n\t}\n\tconst basePath = cwd.replace(/\\\\/g, \"/\");\n\tlet normalized = (\n\t\tisAbsolute(input) ? resolve(input) : resolve(basePath, input)\n\t)\n\t\t.replace(/\\\\/g, \"/\")\n\t\t.replace(/\\/+/g, \"/\");\n\tnormalized = normalized.toLowerCase();\n\tif (normalized.length > 1) {\n\t\tnormalized = normalized.replace(/\\/$/u, \"\");\n\t}\n\treturn normalized || undefined;\n}\n\nfunction collectPathArgumentValues(\n\tvalue: unknown,\n\tpaths: string[],\n\tcwd: string,\n\tmatchedKeys: Set<string>,\n\tstringIsPath: boolean,\n): void {\n\tif (typeof value === \"string\") {\n\t\tif (stringIsPath) {\n\t\t\tconst path = normalizeMutationPath(value, cwd);\n\t\t\tif (path) {\n\t\t\t\tpaths.push(path);\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\tif (Array.isArray(value)) {\n\t\tfor (const entry of value) {\n\t\t\tcollectPathArgumentValues(entry, paths, cwd, matchedKeys, stringIsPath);\n\t\t}\n\t\treturn;\n\t}\n\tif (value && typeof value === \"object\") {\n\t\tfor (const [key, nested] of Object.entries(\n\t\t\tvalue as Record<string, unknown>,\n\t\t)) {\n\t\t\tif (PATH_ARGUMENT_KEYS.has(key)) {\n\t\t\t\tmatchedKeys.add(key);\n\t\t\t\tcollectPathArgumentValues(nested, paths, cwd, matchedKeys, true);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (PATCH_ARGUMENT_KEYS.has(key)) {\n\t\t\t\tmatchedKeys.add(key);\n\t\t\t\tcollectPatchHeaderPaths(nested, paths, cwd, matchedKeys);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (PATH_ARGUMENT_CONTAINER_KEYS.has(key)) {\n\t\t\t\tmatchedKeys.add(key);\n\t\t\t\tcollectPathArgumentValues(nested, paths, cwd, matchedKeys, false);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction collectPatchHeaderPaths(\n\tvalue: unknown,\n\tpaths: string[],\n\tcwd: string,\n\tmatchedKeys: Set<string>,\n): void {\n\tif (typeof value === \"string\") {\n\t\tfor (const match of value.matchAll(\n\t\t\t/^\\*\\*\\* (?:Update File|Add File|Delete File|Move to):\\s+(.+)$/gmu,\n\t\t)) {\n\t\t\tconst rawPath = match[1]?.trim();\n\t\t\tif (!rawPath) continue;\n\t\t\tconst path = normalizeMutationPath(rawPath, cwd);\n\t\t\tif (path) {\n\t\t\t\tpaths.push(path);\n\t\t\t\tmatchedKeys.add(\"patch\");\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\tif (Array.isArray(value)) {\n\t\tfor (const entry of value) {\n\t\t\tcollectPatchHeaderPaths(entry, paths, cwd, matchedKeys);\n\t\t}\n\t\treturn;\n\t}\n\tif (value && typeof value === \"object\") {\n\t\tcollectPathArgumentValues(value, paths, cwd, matchedKeys, false);\n\t}\n}\n\nexport function getPathScopedMutation(\n\ttoolCall: { name: string; arguments?: unknown },\n\ttool?: AgentTool,\n\tcwd = process.cwd(),\n): PathScopedMutation | undefined {\n\tconst annotations = tool?.annotations;\n\tconst source =\n\t\tannotations?.pathScopedMutationHint === true ? \"annotation\" : \"known_tool\";\n\tconst isPathScopedTool =\n\t\tannotations?.pathScopedMutationHint === true ||\n\t\tPATH_SCOPED_MUTATION_TOOLS.has(tool?.name ?? toolCall.name);\n\tif (!isPathScopedTool || annotations?.readOnlyHint === true) {\n\t\treturn undefined;\n\t}\n\tconst args =\n\t\ttoolCall.arguments &&\n\t\ttypeof toolCall.arguments === \"object\" &&\n\t\t!Array.isArray(toolCall.arguments)\n\t\t\t? (toolCall.arguments as Record<string, unknown>)\n\t\t\t: undefined;\n\tif (!args) {\n\t\treturn undefined;\n\t}\n\tconst paths: string[] = [];\n\tconst matchedKeys = new Set<string>();\n\tfor (const [key, value] of Object.entries(args)) {\n\t\tif (PATH_ARGUMENT_KEYS.has(key)) {\n\t\t\tmatchedKeys.add(key);\n\t\t\tcollectPathArgumentValues(value, paths, cwd, matchedKeys, true);\n\t\t\tcontinue;\n\t\t}\n\t\tif (PATCH_ARGUMENT_KEYS.has(key)) {\n\t\t\tmatchedKeys.add(key);\n\t\t\tcollectPatchHeaderPaths(value, paths, cwd, matchedKeys);\n\t\t\tcontinue;\n\t\t}\n\t\tif (PATH_ARGUMENT_CONTAINER_KEYS.has(key)) {\n\t\t\tmatchedKeys.add(key);\n\t\t\tcollectPathArgumentValues(value, paths, cwd, matchedKeys, false);\n\t\t}\n\t}\n\tconst uniquePaths = [...new Set(paths)];\n\treturn uniquePaths.length > 0\n\t\t? { paths: uniquePaths, source, argumentKeys: [...matchedKeys].sort() }\n\t\t: undefined;\n}\n\nexport function pathScopesOverlap(\n\tleft: PathScopedMutation,\n\tright: PathScopedMutation,\n): boolean {\n\treturn left.paths.some((leftPath) =>\n\t\tright.paths.some(\n\t\t\t(rightPath) =>\n\t\t\t\tleftPath === rightPath ||\n\t\t\t\tleftPath.startsWith(`${rightPath}/`) ||\n\t\t\t\trightPath.startsWith(`${leftPath}/`),\n\t\t),\n\t);\n}\n\n/**\n * Add read-only annotation to a tool definition.\n *\n * Use this to mark custom tools as read-only for parallel execution.\n *\n * @param tool - Tool definition to annotate\n * @returns Tool with readOnlyHint annotation\n */\nexport function markReadOnly<T extends AgentTool>(tool: T): T {\n\treturn {\n\t\t...tool,\n\t\tannotations: {\n\t\t\t...tool.annotations,\n\t\t\treadOnlyHint: true,\n\t\t},\n\t};\n}\n\n/**\n * Add write/destructive annotation to a tool definition.\n *\n * @param tool - Tool definition to annotate\n * @returns Tool with destructiveHint annotation\n */\nexport function markDestructive<T extends AgentTool>(tool: T): T {\n\treturn {\n\t\t...tool,\n\t\tannotations: {\n\t\t\t...tool.annotations,\n\t\t\tdestructiveHint: true,\n\t\t},\n\t};\n}\n"]}
@@ -75,6 +75,7 @@ export declare const parallelRipgrepTool: Readonly<{
75
75
  headLimit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
76
76
  }>;
77
77
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
78
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
78
79
  toolType: string | undefined;
79
80
  inputExamples: unknown[] | undefined;
80
81
  allowedCallers: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"parallel-ripgrep.d.ts","sourceRoot":"","sources":["../../src/tools/parallel-ripgrep.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA4GH;;;GAGG;AACH,KAAK,WAAW,GAAG;IAClB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,kCAAkC;IAClC,OAAO,EAAE,MA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;;;;;;;;;;;;;;;;;;;;;EA4N9B,CAAC"}
@@ -60,6 +60,7 @@ export declare const pipelineSearchContactsTool: Readonly<{
60
60
  limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
61
61
  }>;
62
62
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
63
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
63
64
  toolType: string | undefined;
64
65
  inputExamples: unknown[] | undefined;
65
66
  allowedCallers: string[] | undefined;
@@ -85,6 +86,7 @@ export declare const pipelineSearchDealsTool: Readonly<{
85
86
  limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
86
87
  }>;
87
88
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
89
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
88
90
  toolType: string | undefined;
89
91
  inputExamples: unknown[] | undefined;
90
92
  allowedCallers: string[] | undefined;
@@ -113,6 +115,7 @@ export declare const pipelineCreateSignalTool: Readonly<{
113
115
  data: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
114
116
  }>;
115
117
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
118
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
116
119
  toolType: string | undefined;
117
120
  inputExamples: unknown[] | undefined;
118
121
  allowedCallers: string[] | undefined;
@@ -143,6 +146,7 @@ export declare const pipelineLogActivityTool: Readonly<{
143
146
  occurredAt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
144
147
  }>;
145
148
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
149
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
146
150
  toolType: string | undefined;
147
151
  inputExamples: unknown[] | undefined;
148
152
  allowedCallers: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/tools/pipeline.ts"],"names":[],"mappings":"AAwCA,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,C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sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"utf-8">, import("@sinclair/typebox").TLiteral<"utf-16le">, import("@sinclair/typebox").TLiteral<"latin1">, import("@sinclair/typebox").TLiteral<"ascii">]>>;
71
71
  }>;
72
72
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
73
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
73
74
  toolType: string | undefined;
74
75
  inputExamples: unknown[] | undefined;
75
76
  allowedCallers: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoOH;;;GAGG;AACH,KAAK,eAAe,GAAG;IACtB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2ZnB,CAAC"}
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoOH;;;GAGG;AACH,KAAK,eAAe,GAAG;IACtB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2ZnB,CAAC"}
@@ -90,6 +90,7 @@ export declare const searchTool: Readonly<{
90
90
  headLimit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
91
91
  }>;
92
92
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
93
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
93
94
  toolType: string | undefined;
94
95
  inputExamples: unknown[] | undefined;
95
96
  allowedCallers: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAIH,OAAO,EACN,KAAK,YAAY,EAMjB,MAAM,oBAAoB,CAAC;AAkI5B,KAAK,iBAAiB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAC7C,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsUrB,CAAC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/tools/search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAIH,OAAO,EACN,KAAK,YAAY,EAMjB,MAAM,oBAAoB,CAAC;AAkI5B,KAAK,iBAAiB,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAC7C,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsUrB,CAAC"}
@@ -9,6 +9,7 @@ export declare const statusTool: Readonly<{
9
9
  paths: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
10
10
  }>;
11
11
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
12
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
12
13
  toolType: string | undefined;
13
14
  inputExamples: unknown[] | undefined;
14
15
  allowedCallers: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,WAAW,CAAC;AA0EjE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;iBAEX,MAAM;iBAAW,YAAY;;iBAA7B,MAAM;iBAAW,YAAY;;EAyDvC,CAAC"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/tools/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,WAAW,CAAC;AA0EjE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;iBAEX,MAAM;iBAAW,YAAY;;iBAA7B,MAAM;iBAAW,YAAY;;EAyDvC,CAAC"}
@@ -122,6 +122,7 @@ export declare const todoTool: Readonly<{
122
122
  includeSummary: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
123
123
  }>;
124
124
  annotations: import("../agent/types.js").ToolAnnotations | undefined;
125
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
125
126
  toolType: string | undefined;
126
127
  inputExamples: unknown[] | undefined;
127
128
  allowedCallers: string[] | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"todo.d.ts","sourceRoot":"","sources":["../../src/tools/todo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAiBH,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAIrD,QAAA,MAAM,aAAa;;;;CAIT,CAAC;AAEX,KAAK,SAAS,GAAG,MAAM,OAAO,aAAa,CAAC;AAqK5C,KAAK,cAAc,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GA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,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+GnB,CAAC"}
@@ -64,7 +64,7 @@
64
64
  * @module tools/tool-dsl
65
65
  */
66
66
  import type { Static, TSchema } from "@sinclair/typebox";
67
- import type { AgentToolResult, AgentToolUpdateCallback, ToolAnnotations } from "../agent/types.js";
67
+ import type { AgentToolResult, AgentToolUpdateCallback, ToolAnnotations, ToolSourceMetadata } from "../agent/types.js";
68
68
  import type { Sandbox } from "../sandbox/types.js";
69
69
  export declare class ToolResponseBuilder<Details> {
70
70
  private _content;
@@ -89,6 +89,7 @@ export interface CreateToolOptions<Schema extends TSchema, Details> {
89
89
  description: string;
90
90
  schema: Schema;
91
91
  annotations?: ToolAnnotations;
92
+ source?: ToolSourceMetadata;
92
93
  toolType?: string;
93
94
  inputExamples?: unknown[];
94
95
  allowedCallers?: string[];
@@ -112,6 +113,7 @@ export declare function createTool<Schema extends TSchema, Details = undefined>(
112
113
  description: string;
113
114
  parameters: Schema;
114
115
  annotations: ToolAnnotations | undefined;
116
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
115
117
  toolType: string | undefined;
116
118
  inputExamples: unknown[] | undefined;
117
119
  allowedCallers: string[] | undefined;
@@ -142,6 +144,7 @@ export declare function createTextTool<Schema extends TSchema, Details = undefin
142
144
  description: string;
143
145
  parameters: Schema;
144
146
  annotations: ToolAnnotations | undefined;
147
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
145
148
  toolType: string | undefined;
146
149
  inputExamples: unknown[] | undefined;
147
150
  allowedCallers: string[] | undefined;
@@ -165,6 +168,7 @@ export declare function createJsonTool<Schema extends TSchema, Details = undefin
165
168
  description: string;
166
169
  parameters: Schema;
167
170
  annotations: ToolAnnotations | undefined;
171
+ source: import("../agent/types.js").McpToolSourceMetadata | undefined;
168
172
  toolType: string | undefined;
169
173
  inputExamples: unknown[] | undefined;
170
174
  allowedCallers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O;;GAwI/B;AAED,MAAM,WAAW,qBAAqB,CAAC,MAAM,SAAS,OAAO,EAAE,OAAO,CACrE,SAAQ,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC;IACvD,GAAG,EAAE,CACJ,MAAM,EAAE,OAAO,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,EAClD,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,KAE9B,OAAO,GACP,SAAS,GACT,mBAAmB,CAAC,OAAO,CAAC,GAC5B,eAAe,CAAC,OAAO,CAAC,GACxB,OAAO,CACL,OAAO,GACP,SAAS,GACT,mBAAmB,CAAC,OAAO,CAAC,GAC5B,eAAe,CAAC,OAAO,CAAC,CACzB,CAAC;CACL;AAED,wBAAgB,cAAc,CAAC,MAAM,SAAS,OAAO,EAAE,OAAO,GAAG,SAAS,EACzE,OAAO,EAAE,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;;0BAlNzB,OAAO,KAAK,OAAO;iCAqC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;8BAIvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;sCAIvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;0BAKtB,MAAM,UACV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WACtB,WAAW;kBACE,OAAO;;GA+K/B"}
@@ -140,6 +140,7 @@ export function createTool(options) {
140
140
  description: options.description,
141
141
  parameters: options.schema,
142
142
  annotations: options.annotations,
143
+ source: options.source,
143
144
  toolType: options.toolType,
144
145
  inputExamples: options.inputExamples,
145
146
  allowedCallers: options.allowedCallers,
@@ -1 +1 @@
1
- {"version":3,"file":"tool-dsl.js","sourceRoot":"","sources":["../../src/tools/tool-dsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAGH,OAAO,EAA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CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAClD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC1B,OAAO,MAAM,CAAC;YACf,CAAC;YACD,IAAI,MAAM,YAAY,mBAAmB,EAAE,CAAC;gBAC3C,OAAO,MAAM,CAAC;YACf,CAAC;YACD,IAAI,iBAAiB,CAAU,MAAM,CAAC,EAAE,CAAC;gBACxC,OAAO,MAAM,CAAC;YACf,CAAC;YACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CACzB,KAAc;IAEd,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,KAAK,CAAC,OAAO,CAAE,KAAkC,CAAC,OAAO,CAAC,CAC1D,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tool DSL - Domain-Specific Language for Creating Agent Tools\n *\n * This module provides a fluent, type-safe API for defining tools that can be\n * executed by the Composer agent. It handles schema validation, response building,\n * retry logic, and sandbox integration.\n *\n * ## Architecture\n *\n * ```\n * ┌─────────────────────────────────────────────────────────────────┐\n * │ Tool Creation Flow │\n * ├─────────────────────────────────────────────────────────────────┤\n * │ createTool(options) │\n * │ │ │\n * │ ▼ │\n * │ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │\n * │ │ Schema │───▶│ Validator │───▶│ execute() │ │\n * │ │ (TypeBox) │ │ (AJV) │ │ function │ │\n * │ └─────────────┘ └──────────────┘ └─────────────────┘ │\n * │ │ │\n * │ ▼ │\n * │ ┌─────────────────────────────────────┐ │\n * │ │ ToolResponseBuilder │ │\n * │ │ - text(), image(), error() │ │\n * │ │ - detail() for structured data │ │\n * │ └─────────────────────────────────────┘ │\n * └─────────────────────────────────────────────────────────────────┘\n * ```\n *\n * ## Tool Types\n *\n * | Factory | Return Type | Use Case |\n * |---------------|------------------|-----------------------------------|\n * | createTool | AgentToolResult | Full control over response |\n * | createTextTool| string → text | Simple text responses |\n * | createJsonTool| object → JSON | Structured data responses |\n *\n * ## Example\n *\n * ```typescript\n * import { createTool, Type } from './tool-dsl';\n *\n * const greetTool = createTool({\n * name: 'greet',\n * description: 'Greet a user by name',\n * schema: Type.Object({\n * name: Type.String({ description: 'Name to greet' }),\n * }),\n * run: async ({ name }, { respond }) => {\n * return respond.text(`Hello, ${name}!`);\n * },\n * });\n * ```\n *\n * ## Features\n *\n * - **Type-safe schemas**: Uses TypeBox for compile-time type inference\n * - **AJV validation**: Runtime validation with format support\n * - **Retry logic**: Built-in exponential backoff for transient failures\n * - **Sandbox support**: Tools can run in isolated environments\n * - **Context interpolation**: Environment variables and paths\n *\n * @module tools/tool-dsl\n */\n\nimport type { Static, TSchema } from \"@sinclair/typebox\";\nimport { Ajv, type ErrorObject, type ValidateFunction } from \"ajv\";\nimport addFormatsModule, { type FormatsPlugin } from \"ajv-formats\";\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tToolAnnotations,\n} from \"../agent/types.js\";\nimport type { Sandbox } from \"../sandbox/types.js\";\nimport { resolveDefaultExport } from \"../utils/module-interop.js\";\n\n// ESM/CJS interop: ajv-formats default may be nested under .default in some loaders\nconst addFormats = resolveDefaultExport<FormatsPlugin>(addFormatsModule);\n\n// Create a singleton AJV instance for schema validation\nlet ajv: Ajv | null = null;\ntry {\n\tajv = new Ajv({\n\t\t// Avoid unbounded error collection on large/invalid payloads\n\t\tallErrors: false,\n\t\tstrict: false,\n\t\tuseDefaults: true, // Apply schema defaults to input\n\t});\n\taddFormats(ajv);\n} catch {\n\t// AJV initialization failed (likely CSP restriction)\n\tajv = null;\n}\n\n// Cache compiled validators per schema to avoid recompiling on every execute()\nconst validatorCache = new WeakMap<TSchema, ValidateFunction>();\n\nfunction getOrCompileValidator(schema: TSchema): ValidateFunction | null {\n\tif (!ajv) return null;\n\n\tlet validate = validatorCache.get(schema);\n\tif (!validate) {\n\t\tvalidate = ajv.compile(schema);\n\t\tvalidatorCache.set(schema, validate);\n\t}\n\treturn validate;\n}\n\nexport class ToolResponseBuilder<Details> {\n\tprivate _content: (\n\t\t| { type: \"text\"; text: string }\n\t\t| { type: \"image\"; data: string; mimeType: string }\n\t)[] = [];\n\tprivate _details?: Details;\n\tprivate _isError = false;\n\n\ttext(content: string): this {\n\t\tthis._content.push({ type: \"text\", text: content });\n\t\treturn this;\n\t}\n\n\timage(base64: string, mimeType: string): this {\n\t\tthis._content.push({ type: \"image\", data: base64, mimeType });\n\t\treturn this;\n\t}\n\n\tdetail(details: Details): this {\n\t\tthis._details = details;\n\t\treturn this;\n\t}\n\n\terror(message: string): this {\n\t\tthis.text(message);\n\t\tthis._isError = true;\n\t\treturn this;\n\t}\n\n\tbuild(): AgentToolResult<Details> {\n\t\treturn {\n\t\t\tcontent: this._content,\n\t\t\tdetails: this._details,\n\t\t\tisError: this._isError,\n\t\t};\n\t}\n}\n\nexport interface ToolRunContext<Details> {\n\ttoolCallId: string;\n\tsignal?: AbortSignal;\n\trespond: ToolResponseBuilder<Details>;\n\tsandbox?: Sandbox;\n\tonUpdate?: AgentToolUpdateCallback<Details>;\n}\n\nexport interface CreateToolOptions<Schema extends TSchema, Details> {\n\tname: string;\n\tlabel?: string;\n\tdescription: string;\n\tschema: Schema;\n\tannotations?: ToolAnnotations;\n\ttoolType?: string;\n\tinputExamples?: unknown[];\n\tallowedCallers?: string[];\n\tdeferApiDefinition?: boolean;\n\trun: (\n\t\tparams: import(\"@sinclair/typebox\").Static<Schema>,\n\t\tcontext: ToolRunContext<Details>,\n\t) =>\n\t\t| undefined\n\t\t| ToolResponseBuilder<Details>\n\t\t| AgentToolResult<Details>\n\t\t| Promise<\n\t\t\t\tundefined | ToolResponseBuilder<Details> | AgentToolResult<Details>\n\t\t >;\n\tmaxRetries?: number;\n\tretryDelayMs?: number;\n\tshouldRetry?: (error: unknown) => boolean;\n\tgetToolUseSummary?: (params: Static<Schema>) => string | null;\n\tgetDisplayName?: (params: Static<Schema>) => string | null;\n\tgetActivityDescription?: (params: Static<Schema>) => string | null;\n}\n\ntype StaticSchema<Schema extends TSchema> = Static<Schema>;\n\nexport class ToolError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly code?: string,\n\t\tpublic readonly details?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ToolError\";\n\t}\n}\n\nexport function createTool<Schema extends TSchema, Details = undefined>(\n\toptions: CreateToolOptions<Schema, Details>,\n) {\n\treturn Object.freeze({\n\t\tname: options.name,\n\t\tlabel: options.label ?? options.name,\n\t\tdescription: options.description,\n\t\tparameters: options.schema,\n\t\tannotations: options.annotations,\n\t\ttoolType: options.toolType,\n\t\tinputExamples: options.inputExamples,\n\t\tallowedCallers: options.allowedCallers,\n\t\tdeferApiDefinition: options.deferApiDefinition,\n\t\tmaxRetries: options.maxRetries,\n\t\tretryDelayMs: options.retryDelayMs,\n\t\tshouldRetry: options.shouldRetry,\n\t\tgetToolUseSummary: options.getToolUseSummary\n\t\t\t? (params: Record<string, unknown>) =>\n\t\t\t\t\toptions.getToolUseSummary?.(params as StaticSchema<Schema>) ?? null\n\t\t\t: undefined,\n\t\tgetDisplayName: options.getDisplayName\n\t\t\t? (params: Record<string, unknown>) =>\n\t\t\t\t\toptions.getDisplayName?.(params as StaticSchema<Schema>) ?? null\n\t\t\t: undefined,\n\t\tgetActivityDescription: options.getActivityDescription\n\t\t\t? (params: Record<string, unknown>) =>\n\t\t\t\t\toptions.getActivityDescription?.(params as StaticSchema<Schema>) ??\n\t\t\t\t\tnull\n\t\t\t: undefined,\n\t\texecute: async (\n\t\t\ttoolCallId: string,\n\t\t\tparams: Record<string, unknown>,\n\t\t\tsignal?: AbortSignal,\n\t\t\tcontext?: { sandbox?: Sandbox },\n\t\t\tonUpdate?: AgentToolUpdateCallback<Details>,\n\t\t) => {\n\t\t\t// Validate params against schema using cached validator\n\t\t\tif (options.schema) {\n\t\t\t\tconst validate = getOrCompileValidator(options.schema);\n\t\t\t\tif (validate && !validate(params)) {\n\t\t\t\t\tconst errors =\n\t\t\t\t\t\t(validate.errors ?? [])\n\t\t\t\t\t\t\t.map((err) => {\n\t\t\t\t\t\t\t\tconst path =\n\t\t\t\t\t\t\t\t\terr.instancePath && err.instancePath.length > 1\n\t\t\t\t\t\t\t\t\t\t? err.instancePath.substring(1)\n\t\t\t\t\t\t\t\t\t\t: (err.params as { missingProperty?: string })\n\t\t\t\t\t\t\t\t\t\t\t\t.missingProperty || \"root\";\n\t\t\t\t\t\t\t\treturn ` - ${path}: ${err.message ?? \"invalid value\"}`;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join(\"\\n\") || \"Unknown validation error\";\n\t\t\t\t\tthrow new ToolError(\n\t\t\t\t\t\t`Validation failed for tool \"${options.name}\":\\n${errors}`,\n\t\t\t\t\t\t\"VALIDATION_ERROR\",\n\t\t\t\t\t\t{ params },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst maxRetries = options.maxRetries ?? 0;\n\t\t\tconst retryDelayMs = options.retryDelayMs ?? 1000;\n\t\t\tconst shouldRetry = options.shouldRetry ?? (() => true);\n\t\t\tconst typedParams = params as StaticSchema<Schema>;\n\n\t\t\tlet lastError: unknown;\n\t\t\tfor (let attempt = 0; attempt <= maxRetries; attempt++) {\n\t\t\t\tif (attempt > 0) {\n\t\t\t\t\t// Exponential backoff: delay * 2^(attempt-1)\n\t\t\t\t\tconst delay = retryDelayMs * 2 ** (attempt - 1);\n\t\t\t\t\tif (signal) {\n\t\t\t\t\t\tconst activeSignal = signal;\n\t\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\tif (activeSignal.aborted) {\n\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\t\t\t\t\tactiveSignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t}, delay);\n\t\t\t\t\t\t\tfunction onAbort() {\n\t\t\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\t\t\tactiveSignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tactiveSignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delay));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst builder = new ToolResponseBuilder<Details>();\n\t\t\t\t\tconst result = await options.run(typedParams, {\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\trespond: builder,\n\t\t\t\t\t\tsandbox: context?.sandbox,\n\t\t\t\t\t\tonUpdate,\n\t\t\t\t\t});\n\t\t\t\t\tif (result instanceof ToolResponseBuilder) {\n\t\t\t\t\t\treturn result.build();\n\t\t\t\t\t}\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t\treturn builder.build();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlastError = error;\n\t\t\t\t\tif (attempt < maxRetries && shouldRetry(error)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow lastError;\n\t\t},\n\t});\n}\n\nimport { getHomeDir } from \"../utils/path-expansion.js\";\nimport { expandUserPath as expandUserPathBase } from \"../utils/path-validation.js\";\n\n// Re-export shared path expansion utility to keep tool-dsl API stable\nexport const expandUserPath = expandUserPathBase;\n\n/**\n * Interpolate environment variables and context in a string.\n * Supports: ${env.VAR}, ${cwd}, ${home}\n */\nexport function interpolateContext(value: string): string {\n\treturn value\n\t\t.replace(/\\$\\{env\\.([^}]+)\\}/g, (_, varName) => process.env[varName] ?? \"\")\n\t\t.replace(/\\$\\{cwd\\}/g, process.cwd())\n\t\t.replace(/\\$\\{home\\}/g, getHomeDir());\n}\n\nexport interface CreateTextToolOptions<Schema extends TSchema, Details>\n\textends Omit<CreateToolOptions<Schema, Details>, \"run\"> {\n\trun: (\n\t\tparams: import(\"@sinclair/typebox\").Static<Schema>,\n\t\tcontext: ToolRunContext<Details>,\n\t) =>\n\t\t| string\n\t\t| undefined\n\t\t| ToolResponseBuilder<Details>\n\t\t| AgentToolResult<Details>\n\t\t| Promise<\n\t\t\t\t| string\n\t\t\t\t| undefined\n\t\t\t\t| ToolResponseBuilder<Details>\n\t\t\t\t| AgentToolResult<Details>\n\t\t >;\n}\n\nexport function createTextTool<Schema extends TSchema, Details = undefined>(\n\toptions: CreateTextToolOptions<Schema, Details>,\n) {\n\treturn createTool<Schema, Details>({\n\t\t...options,\n\t\trun: async (params, context) => {\n\t\t\tconst result = await options.run(params, context);\n\t\t\tif (typeof result === \"string\") {\n\t\t\t\treturn context.respond.text(result);\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t});\n}\n\nexport interface CreateJsonToolOptions<Schema extends TSchema, Details>\n\textends Omit<CreateToolOptions<Schema, Details>, \"run\"> {\n\trun: (\n\t\tparams: import(\"@sinclair/typebox\").Static<Schema>,\n\t\tcontext: ToolRunContext<Details>,\n\t) =>\n\t\t| unknown\n\t\t| undefined\n\t\t| ToolResponseBuilder<Details>\n\t\t| AgentToolResult<Details>\n\t\t| Promise<\n\t\t\t\t| unknown\n\t\t\t\t| undefined\n\t\t\t\t| ToolResponseBuilder<Details>\n\t\t\t\t| AgentToolResult<Details>\n\t\t >;\n}\n\nexport function createJsonTool<Schema extends TSchema, Details = undefined>(\n\toptions: CreateJsonToolOptions<Schema, Details>,\n) {\n\treturn createTool<Schema, Details>({\n\t\t...options,\n\t\trun: async (params, context) => {\n\t\t\tconst result = await options.run(params, context);\n\t\t\tif (result === undefined) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (result instanceof ToolResponseBuilder) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (isAgentToolResult<Details>(result)) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn context.respond.text(JSON.stringify(result, null, 2));\n\t\t},\n\t});\n}\n\nfunction isAgentToolResult<Details>(\n\tvalue: unknown,\n): value is AgentToolResult<Details> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"content\" in value &&\n\t\tArray.isArray((value as AgentToolResult<Details>).content)\n\t);\n}\n"]}
1
+ {"version":3,"file":"tool-dsl.js","sourceRoot":"","sources":["../../src/tools/tool-dsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAGH,OAAO,EAAE,GAAG,EAA2C,MAAM,KAAK,CAAC;AACnE,OAAO,gBAAwC,MAAM,aAAa,CAAC;AAQnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,oFAAoF;AACpF,MAAM,UAAU,GAAG,oBAAoB,CAAgB,gBAAgB,CAAC,CAAC;AAEzE,wDAAwD;AACxD,IAAI,GAAG,GAAe,IAAI,CAAC;AAC3B,IAAI,CAAC;IACJ,GAAG,GAAG,IAAI,GAAG,CAAC;QACb,6DAA6D;QAC7D,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,IAAI,EAAE,iCAAiC;KACpD,CAAC,CAAC;IACH,UAAU,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC;AAAC,MAAM,CAAC;IACR,qDAAqD;IACrD,GAAG,GAAG,IAAI,CAAC;AACZ,CAAC;AAED,+EA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zB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,KAAK,CAAC,OAAO,CAAE,KAAkC,CAAC,OAAO,CAAC,CAC1D,CAAC;AACH,CAAC","sourcesContent":["/**\n * Tool DSL - Domain-Specific Language for Creating Agent Tools\n *\n * This module provides a fluent, type-safe API for defining tools that can be\n * executed by the Composer agent. It handles schema validation, response building,\n * retry logic, and sandbox integration.\n *\n * ## Architecture\n *\n * ```\n * ┌─────────────────────────────────────────────────────────────────┐\n * │ Tool Creation Flow │\n * ├─────────────────────────────────────────────────────────────────┤\n * │ createTool(options) │\n * │ │ │\n * │ ▼ │\n * │ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │\n * │ │ Schema │───▶│ Validator │───▶│ execute() │ │\n * │ │ (TypeBox) │ │ (AJV) │ │ function │ │\n * │ └─────────────┘ └──────────────┘ └─────────────────┘ │\n * │ │ │\n * │ ▼ │\n * │ ┌─────────────────────────────────────┐ │\n * │ │ ToolResponseBuilder │ │\n * │ │ - text(), image(), error() │ │\n * │ │ - detail() for structured data │ │\n * │ └─────────────────────────────────────┘ │\n * └─────────────────────────────────────────────────────────────────┘\n * ```\n *\n * ## Tool Types\n *\n * | Factory | Return Type | Use Case |\n * |---------------|------------------|-----------------------------------|\n * | createTool | AgentToolResult | Full control over response |\n * | createTextTool| string → text | Simple text responses |\n * | createJsonTool| object → JSON | Structured data responses |\n *\n * ## Example\n *\n * ```typescript\n * import { createTool, Type } from './tool-dsl';\n *\n * const greetTool = createTool({\n * name: 'greet',\n * description: 'Greet a user by name',\n * schema: Type.Object({\n * name: Type.String({ description: 'Name to greet' }),\n * }),\n * run: async ({ name }, { respond }) => {\n * return respond.text(`Hello, ${name}!`);\n * },\n * });\n * ```\n *\n * ## Features\n *\n * - **Type-safe schemas**: Uses TypeBox for compile-time type inference\n * - **AJV validation**: Runtime validation with format support\n * - **Retry logic**: Built-in exponential backoff for transient failures\n * - **Sandbox support**: Tools can run in isolated environments\n * - **Context interpolation**: Environment variables and paths\n *\n * @module tools/tool-dsl\n */\n\nimport type { Static, TSchema } from \"@sinclair/typebox\";\nimport { Ajv, type ErrorObject, type ValidateFunction } from \"ajv\";\nimport addFormatsModule, { type FormatsPlugin } from \"ajv-formats\";\nimport type {\n\tAgentToolResult,\n\tAgentToolUpdateCallback,\n\tToolAnnotations,\n\tToolSourceMetadata,\n} from \"../agent/types.js\";\nimport type { Sandbox } from \"../sandbox/types.js\";\nimport { resolveDefaultExport } from \"../utils/module-interop.js\";\n\n// ESM/CJS interop: ajv-formats default may be nested under .default in some loaders\nconst addFormats = resolveDefaultExport<FormatsPlugin>(addFormatsModule);\n\n// Create a singleton AJV instance for schema validation\nlet ajv: Ajv | null = null;\ntry {\n\tajv = new Ajv({\n\t\t// Avoid unbounded error collection on large/invalid payloads\n\t\tallErrors: false,\n\t\tstrict: false,\n\t\tuseDefaults: true, // Apply schema defaults to input\n\t});\n\taddFormats(ajv);\n} catch {\n\t// AJV initialization failed (likely CSP restriction)\n\tajv = null;\n}\n\n// Cache compiled validators per schema to avoid recompiling on every execute()\nconst validatorCache = new WeakMap<TSchema, ValidateFunction>();\n\nfunction getOrCompileValidator(schema: TSchema): ValidateFunction | null {\n\tif (!ajv) return null;\n\n\tlet validate = validatorCache.get(schema);\n\tif (!validate) {\n\t\tvalidate = ajv.compile(schema);\n\t\tvalidatorCache.set(schema, validate);\n\t}\n\treturn validate;\n}\n\nexport class ToolResponseBuilder<Details> {\n\tprivate _content: (\n\t\t| { type: \"text\"; text: string }\n\t\t| { type: \"image\"; data: string; mimeType: string }\n\t)[] = [];\n\tprivate _details?: Details;\n\tprivate _isError = false;\n\n\ttext(content: string): this {\n\t\tthis._content.push({ type: \"text\", text: content });\n\t\treturn this;\n\t}\n\n\timage(base64: string, mimeType: string): this {\n\t\tthis._content.push({ type: \"image\", data: base64, mimeType });\n\t\treturn this;\n\t}\n\n\tdetail(details: Details): this {\n\t\tthis._details = details;\n\t\treturn this;\n\t}\n\n\terror(message: string): this {\n\t\tthis.text(message);\n\t\tthis._isError = true;\n\t\treturn this;\n\t}\n\n\tbuild(): AgentToolResult<Details> {\n\t\treturn {\n\t\t\tcontent: this._content,\n\t\t\tdetails: this._details,\n\t\t\tisError: this._isError,\n\t\t};\n\t}\n}\n\nexport interface ToolRunContext<Details> {\n\ttoolCallId: string;\n\tsignal?: AbortSignal;\n\trespond: ToolResponseBuilder<Details>;\n\tsandbox?: Sandbox;\n\tonUpdate?: AgentToolUpdateCallback<Details>;\n}\n\nexport interface CreateToolOptions<Schema extends TSchema, Details> {\n\tname: string;\n\tlabel?: string;\n\tdescription: string;\n\tschema: Schema;\n\tannotations?: ToolAnnotations;\n\tsource?: ToolSourceMetadata;\n\ttoolType?: string;\n\tinputExamples?: unknown[];\n\tallowedCallers?: string[];\n\tdeferApiDefinition?: boolean;\n\trun: (\n\t\tparams: import(\"@sinclair/typebox\").Static<Schema>,\n\t\tcontext: ToolRunContext<Details>,\n\t) =>\n\t\t| undefined\n\t\t| ToolResponseBuilder<Details>\n\t\t| AgentToolResult<Details>\n\t\t| Promise<\n\t\t\t\tundefined | ToolResponseBuilder<Details> | AgentToolResult<Details>\n\t\t >;\n\tmaxRetries?: number;\n\tretryDelayMs?: number;\n\tshouldRetry?: (error: unknown) => boolean;\n\tgetToolUseSummary?: (params: Static<Schema>) => string | null;\n\tgetDisplayName?: (params: Static<Schema>) => string | null;\n\tgetActivityDescription?: (params: Static<Schema>) => string | null;\n}\n\ntype StaticSchema<Schema extends TSchema> = Static<Schema>;\n\nexport class ToolError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly code?: string,\n\t\tpublic readonly details?: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ToolError\";\n\t}\n}\n\nexport function createTool<Schema extends TSchema, Details = undefined>(\n\toptions: CreateToolOptions<Schema, Details>,\n) {\n\treturn Object.freeze({\n\t\tname: options.name,\n\t\tlabel: options.label ?? options.name,\n\t\tdescription: options.description,\n\t\tparameters: options.schema,\n\t\tannotations: options.annotations,\n\t\tsource: options.source,\n\t\ttoolType: options.toolType,\n\t\tinputExamples: options.inputExamples,\n\t\tallowedCallers: options.allowedCallers,\n\t\tdeferApiDefinition: options.deferApiDefinition,\n\t\tmaxRetries: options.maxRetries,\n\t\tretryDelayMs: options.retryDelayMs,\n\t\tshouldRetry: options.shouldRetry,\n\t\tgetToolUseSummary: options.getToolUseSummary\n\t\t\t? (params: Record<string, unknown>) =>\n\t\t\t\t\toptions.getToolUseSummary?.(params as StaticSchema<Schema>) ?? null\n\t\t\t: undefined,\n\t\tgetDisplayName: options.getDisplayName\n\t\t\t? (params: Record<string, unknown>) =>\n\t\t\t\t\toptions.getDisplayName?.(params as StaticSchema<Schema>) ?? null\n\t\t\t: undefined,\n\t\tgetActivityDescription: options.getActivityDescription\n\t\t\t? (params: Record<string, unknown>) =>\n\t\t\t\t\toptions.getActivityDescription?.(params as StaticSchema<Schema>) ??\n\t\t\t\t\tnull\n\t\t\t: undefined,\n\t\texecute: async (\n\t\t\ttoolCallId: string,\n\t\t\tparams: Record<string, unknown>,\n\t\t\tsignal?: AbortSignal,\n\t\t\tcontext?: { sandbox?: Sandbox },\n\t\t\tonUpdate?: AgentToolUpdateCallback<Details>,\n\t\t) => {\n\t\t\t// Validate params against schema using cached validator\n\t\t\tif (options.schema) {\n\t\t\t\tconst validate = getOrCompileValidator(options.schema);\n\t\t\t\tif (validate && !validate(params)) {\n\t\t\t\t\tconst errors =\n\t\t\t\t\t\t(validate.errors ?? [])\n\t\t\t\t\t\t\t.map((err) => {\n\t\t\t\t\t\t\t\tconst path =\n\t\t\t\t\t\t\t\t\terr.instancePath && err.instancePath.length > 1\n\t\t\t\t\t\t\t\t\t\t? err.instancePath.substring(1)\n\t\t\t\t\t\t\t\t\t\t: (err.params as { missingProperty?: string })\n\t\t\t\t\t\t\t\t\t\t\t\t.missingProperty || \"root\";\n\t\t\t\t\t\t\t\treturn ` - ${path}: ${err.message ?? \"invalid value\"}`;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.join(\"\\n\") || \"Unknown validation error\";\n\t\t\t\t\tthrow new ToolError(\n\t\t\t\t\t\t`Validation failed for tool \"${options.name}\":\\n${errors}`,\n\t\t\t\t\t\t\"VALIDATION_ERROR\",\n\t\t\t\t\t\t{ params },\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst maxRetries = options.maxRetries ?? 0;\n\t\t\tconst retryDelayMs = options.retryDelayMs ?? 1000;\n\t\t\tconst shouldRetry = options.shouldRetry ?? (() => true);\n\t\t\tconst typedParams = params as StaticSchema<Schema>;\n\n\t\t\tlet lastError: unknown;\n\t\t\tfor (let attempt = 0; attempt <= maxRetries; attempt++) {\n\t\t\t\tif (attempt > 0) {\n\t\t\t\t\t// Exponential backoff: delay * 2^(attempt-1)\n\t\t\t\t\tconst delay = retryDelayMs * 2 ** (attempt - 1);\n\t\t\t\t\tif (signal) {\n\t\t\t\t\t\tconst activeSignal = signal;\n\t\t\t\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\tif (activeSignal.aborted) {\n\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\t\t\t\t\tactiveSignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t}, delay);\n\t\t\t\t\t\t\tfunction onAbort() {\n\t\t\t\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\t\t\t\tactiveSignal.removeEventListener(\"abort\", onAbort);\n\t\t\t\t\t\t\t\treject(new Error(\"Operation aborted\"));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tactiveSignal.addEventListener(\"abort\", onAbort, { once: true });\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, delay));\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst builder = new ToolResponseBuilder<Details>();\n\t\t\t\t\tconst result = await options.run(typedParams, {\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\trespond: builder,\n\t\t\t\t\t\tsandbox: context?.sandbox,\n\t\t\t\t\t\tonUpdate,\n\t\t\t\t\t});\n\t\t\t\t\tif (result instanceof ToolResponseBuilder) {\n\t\t\t\t\t\treturn result.build();\n\t\t\t\t\t}\n\t\t\t\t\tif (result) {\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}\n\t\t\t\t\treturn builder.build();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlastError = error;\n\t\t\t\t\tif (attempt < maxRetries && shouldRetry(error)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow lastError;\n\t\t},\n\t});\n}\n\nimport { getHomeDir } from \"../utils/path-expansion.js\";\nimport { expandUserPath as expandUserPathBase } from \"../utils/path-validation.js\";\n\n// Re-export shared path expansion utility to keep tool-dsl API stable\nexport const expandUserPath = expandUserPathBase;\n\n/**\n * Interpolate environment variables and context in a string.\n * Supports: ${env.VAR}, ${cwd}, ${home}\n */\nexport function interpolateContext(value: string): string {\n\treturn value\n\t\t.replace(/\\$\\{env\\.([^}]+)\\}/g, (_, varName) => process.env[varName] ?? \"\")\n\t\t.replace(/\\$\\{cwd\\}/g, process.cwd())\n\t\t.replace(/\\$\\{home\\}/g, getHomeDir());\n}\n\nexport interface CreateTextToolOptions<Schema extends TSchema, Details>\n\textends Omit<CreateToolOptions<Schema, Details>, \"run\"> {\n\trun: (\n\t\tparams: import(\"@sinclair/typebox\").Static<Schema>,\n\t\tcontext: ToolRunContext<Details>,\n\t) =>\n\t\t| string\n\t\t| undefined\n\t\t| ToolResponseBuilder<Details>\n\t\t| AgentToolResult<Details>\n\t\t| Promise<\n\t\t\t\t| string\n\t\t\t\t| undefined\n\t\t\t\t| ToolResponseBuilder<Details>\n\t\t\t\t| AgentToolResult<Details>\n\t\t >;\n}\n\nexport function createTextTool<Schema extends TSchema, Details = undefined>(\n\toptions: CreateTextToolOptions<Schema, Details>,\n) {\n\treturn createTool<Schema, Details>({\n\t\t...options,\n\t\trun: async (params, context) => {\n\t\t\tconst result = await options.run(params, context);\n\t\t\tif (typeof result === \"string\") {\n\t\t\t\treturn context.respond.text(result);\n\t\t\t}\n\t\t\treturn result;\n\t\t},\n\t});\n}\n\nexport interface CreateJsonToolOptions<Schema extends TSchema, Details>\n\textends Omit<CreateToolOptions<Schema, Details>, \"run\"> {\n\trun: (\n\t\tparams: import(\"@sinclair/typebox\").Static<Schema>,\n\t\tcontext: ToolRunContext<Details>,\n\t) =>\n\t\t| unknown\n\t\t| undefined\n\t\t| ToolResponseBuilder<Details>\n\t\t| AgentToolResult<Details>\n\t\t| Promise<\n\t\t\t\t| unknown\n\t\t\t\t| undefined\n\t\t\t\t| ToolResponseBuilder<Details>\n\t\t\t\t| AgentToolResult<Details>\n\t\t >;\n}\n\nexport function createJsonTool<Schema extends TSchema, Details = undefined>(\n\toptions: CreateJsonToolOptions<Schema, Details>,\n) {\n\treturn createTool<Schema, Details>({\n\t\t...options,\n\t\trun: async (params, context) => {\n\t\t\tconst result = await options.run(params, context);\n\t\t\tif (result === undefined) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (result instanceof ToolResponseBuilder) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tif (isAgentToolResult<Details>(result)) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn context.respond.text(JSON.stringify(result, null, 2));\n\t\t},\n\t});\n}\n\nfunction isAgentToolResult<Details>(\n\tvalue: unknown,\n): value is AgentToolResult<Details> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"content\" in value &&\n\t\tArray.isArray((value as AgentToolResult<Details>).content)\n\t);\n}\n"]}