@mastra/code-sdk 0.0.0-agent-tags-alpha-20261125185303

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 (407) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +284 -0
  3. package/dist/acp/agent.d.ts +48 -0
  4. package/dist/acp/agent.js +414 -0
  5. package/dist/acp/errors.d.ts +3 -0
  6. package/dist/acp/errors.js +11 -0
  7. package/dist/acp/event-mapper.d.ts +28 -0
  8. package/dist/acp/event-mapper.js +274 -0
  9. package/dist/acp/index.d.ts +9 -0
  10. package/dist/acp/index.js +21 -0
  11. package/dist/acp/runtime.d.ts +5 -0
  12. package/dist/acp/runtime.js +91 -0
  13. package/dist/acp/server.d.ts +4 -0
  14. package/dist/acp/server.js +35 -0
  15. package/dist/acp/skills.d.ts +6 -0
  16. package/dist/acp/skills.js +30 -0
  17. package/dist/acp.d.ts +2 -0
  18. package/dist/acp.js +1 -0
  19. package/dist/agent-connections/messaging-processor.d.ts +17 -0
  20. package/dist/agent-connections/messaging-processor.js +131 -0
  21. package/dist/agent-connections/ownership.d.ts +24 -0
  22. package/dist/agent-connections/ownership.js +96 -0
  23. package/dist/agent-connections/registry.d.ts +20 -0
  24. package/dist/agent-connections/registry.js +167 -0
  25. package/dist/agent-connections/session-advertisement.d.ts +27 -0
  26. package/dist/agent-connections/session-advertisement.js +86 -0
  27. package/dist/agent-connections/signal-provider.d.ts +141 -0
  28. package/dist/agent-connections/signal-provider.js +35 -0
  29. package/dist/agent-connections/state-processor.d.ts +23 -0
  30. package/dist/agent-connections/state-processor.js +270 -0
  31. package/dist/agent-connections/thread-state.d.ts +41 -0
  32. package/dist/agent-connections/thread-state.js +157 -0
  33. package/dist/agent-connections/tools.d.ts +133 -0
  34. package/dist/agent-connections/tools.js +616 -0
  35. package/dist/agent-connections/types.d.ts +99 -0
  36. package/dist/agent-connections/types.js +4 -0
  37. package/dist/agent-connections/untrusted-text.d.ts +5 -0
  38. package/dist/agent-connections/untrusted-text.js +19 -0
  39. package/dist/agents/background-completion-events.d.ts +16 -0
  40. package/dist/agents/background-completion-events.js +16 -0
  41. package/dist/agents/background-completion.d.ts +22 -0
  42. package/dist/agents/background-completion.js +73 -0
  43. package/dist/agents/context-audit.d.ts +84 -0
  44. package/dist/agents/context-audit.js +115 -0
  45. package/dist/agents/credential-resolver.d.ts +74 -0
  46. package/dist/agents/credential-resolver.js +142 -0
  47. package/dist/agents/custom-provider-source.d.ts +35 -0
  48. package/dist/agents/custom-provider-source.js +22 -0
  49. package/dist/agents/fastembed-subprocess.d.ts +52 -0
  50. package/dist/agents/fastembed-subprocess.js +282 -0
  51. package/dist/agents/instructions.d.ts +42 -0
  52. package/dist/agents/instructions.js +69 -0
  53. package/dist/agents/mastracode-gateway.d.ts +85 -0
  54. package/dist/agents/mastracode-gateway.js +500 -0
  55. package/dist/agents/memory.d.ts +36 -0
  56. package/dist/agents/memory.js +248 -0
  57. package/dist/agents/model.d.ts +158 -0
  58. package/dist/agents/model.js +382 -0
  59. package/dist/agents/modes/build.d.ts +12 -0
  60. package/dist/agents/modes/build.js +33 -0
  61. package/dist/agents/modes/explore.d.ts +10 -0
  62. package/dist/agents/modes/explore.js +25 -0
  63. package/dist/agents/modes/plan.d.ts +8 -0
  64. package/dist/agents/modes/plan.js +43 -0
  65. package/dist/agents/prompts/agent-instructions.d.ts +122 -0
  66. package/dist/agents/prompts/agent-instructions.js +617 -0
  67. package/dist/agents/prompts/build.d.ts +12 -0
  68. package/dist/agents/prompts/build.js +73 -0
  69. package/dist/agents/prompts/fast.d.ts +5 -0
  70. package/dist/agents/prompts/fast.js +23 -0
  71. package/dist/agents/prompts/index.d.ts +61 -0
  72. package/dist/agents/prompts/index.js +141 -0
  73. package/dist/agents/prompts/model.d.ts +5 -0
  74. package/dist/agents/prompts/model.js +20 -0
  75. package/dist/agents/prompts/plan.d.ts +11 -0
  76. package/dist/agents/prompts/plan.js +132 -0
  77. package/dist/agents/prompts/tool-guidance.d.ts +18 -0
  78. package/dist/agents/prompts/tool-guidance.js +158 -0
  79. package/dist/agents/sandbox-filesystem.d.ts +232 -0
  80. package/dist/agents/sandbox-filesystem.js +851 -0
  81. package/dist/agents/subagents/execute.d.ts +3 -0
  82. package/dist/agents/subagents/execute.js +24 -0
  83. package/dist/agents/subagents/explore.d.ts +3 -0
  84. package/dist/agents/subagents/explore.js +15 -0
  85. package/dist/agents/subagents/index.d.ts +6 -0
  86. package/dist/agents/subagents/index.js +15 -0
  87. package/dist/agents/subagents/plan.d.ts +3 -0
  88. package/dist/agents/subagents/plan.js +15 -0
  89. package/dist/agents/thread-caveman-state.d.ts +17 -0
  90. package/dist/agents/thread-caveman-state.js +104 -0
  91. package/dist/agents/tool-availability.d.ts +17 -0
  92. package/dist/agents/tool-availability.js +134 -0
  93. package/dist/agents/tools.d.ts +37 -0
  94. package/dist/agents/tools.js +154 -0
  95. package/dist/agents/workflow-builder-agent.d.ts +2 -0
  96. package/dist/agents/workflow-builder-agent.js +79 -0
  97. package/dist/agents/workspace.d.ts +35 -0
  98. package/dist/agents/workspace.js +207 -0
  99. package/dist/analytics.d.ts +18 -0
  100. package/dist/analytics.js +159 -0
  101. package/dist/auth/account-rotation-processor.d.ts +210 -0
  102. package/dist/auth/account-rotation-processor.js +662 -0
  103. package/dist/auth/account-routing-context.d.ts +17 -0
  104. package/dist/auth/account-routing-context.js +38 -0
  105. package/dist/auth/authorization-input.d.ts +16 -0
  106. package/dist/auth/authorization-input.js +39 -0
  107. package/dist/auth/device-code.d.ts +93 -0
  108. package/dist/auth/device-code.js +126 -0
  109. package/dist/auth/index.d.ts +13 -0
  110. package/dist/auth/index.js +9 -0
  111. package/dist/auth/pkce.d.ts +13 -0
  112. package/dist/auth/pkce.js +29 -0
  113. package/dist/auth/provider-auth-error.d.ts +24 -0
  114. package/dist/auth/provider-auth-error.js +44 -0
  115. package/dist/auth/providers/anthropic.d.ts +40 -0
  116. package/dist/auth/providers/anthropic.js +117 -0
  117. package/dist/auth/providers/github-copilot.d.ts +154 -0
  118. package/dist/auth/providers/github-copilot.js +359 -0
  119. package/dist/auth/providers/kimi-coding.d.ts +38 -0
  120. package/dist/auth/providers/kimi-coding.js +225 -0
  121. package/dist/auth/providers/openai-codex.d.ts +141 -0
  122. package/dist/auth/providers/openai-codex.js +531 -0
  123. package/dist/auth/providers/xai.d.ts +64 -0
  124. package/dist/auth/providers/xai.js +223 -0
  125. package/dist/auth/storage.d.ts +222 -0
  126. package/dist/auth/storage.js +805 -0
  127. package/dist/auth/types.d.ts +164 -0
  128. package/dist/auth/types.js +1 -0
  129. package/dist/clipboard/index.d.ts +26 -0
  130. package/dist/clipboard/index.js +224 -0
  131. package/dist/constants.d.ts +29 -0
  132. package/dist/constants.js +34 -0
  133. package/dist/error-classification.d.ts +10 -0
  134. package/dist/error-classification.js +19 -0
  135. package/dist/evals/context-builder.d.ts +41 -0
  136. package/dist/evals/context-builder.js +156 -0
  137. package/dist/evals/index.d.ts +4 -0
  138. package/dist/evals/index.js +5 -0
  139. package/dist/evals/scorers/classify-command.d.ts +30 -0
  140. package/dist/evals/scorers/classify-command.js +61 -0
  141. package/dist/evals/scorers/efficiency.d.ts +44 -0
  142. package/dist/evals/scorers/efficiency.js +256 -0
  143. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  144. package/dist/evals/scorers/extract-tools.js +57 -0
  145. package/dist/evals/scorers/index.d.ts +3 -0
  146. package/dist/evals/scorers/index.js +3 -0
  147. package/dist/evals/scorers/outcome.d.ts +49 -0
  148. package/dist/evals/scorers/outcome.js +360 -0
  149. package/dist/experimental-agent.d.ts +19 -0
  150. package/dist/experimental-agent.js +45 -0
  151. package/dist/factory/client.d.ts +44 -0
  152. package/dist/factory/client.js +110 -0
  153. package/dist/factory/remote-controller.d.ts +34 -0
  154. package/dist/factory/remote-controller.js +40 -0
  155. package/dist/factory/remote-session.d.ts +210 -0
  156. package/dist/factory/remote-session.js +415 -0
  157. package/dist/goal-manager.d.ts +114 -0
  158. package/dist/goal-manager.js +351 -0
  159. package/dist/goal-signal.d.ts +14 -0
  160. package/dist/goal-signal.js +14 -0
  161. package/dist/headless/cli.d.ts +55 -0
  162. package/dist/headless/cli.js +261 -0
  163. package/dist/headless/flags.d.ts +33 -0
  164. package/dist/headless/flags.js +207 -0
  165. package/dist/headless/format.d.ts +41 -0
  166. package/dist/headless/format.js +94 -0
  167. package/dist/headless/index.d.ts +25 -0
  168. package/dist/headless/index.js +6 -0
  169. package/dist/headless/policy.d.ts +17 -0
  170. package/dist/headless/policy.js +39 -0
  171. package/dist/headless/run-mc.d.ts +7 -0
  172. package/dist/headless/run-mc.js +438 -0
  173. package/dist/headless/types.d.ts +175 -0
  174. package/dist/headless/types.js +16 -0
  175. package/dist/hooks/config.d.ts +11 -0
  176. package/dist/hooks/config.js +77 -0
  177. package/dist/hooks/executor.d.ts +13 -0
  178. package/dist/hooks/executor.js +128 -0
  179. package/dist/hooks/index.d.ts +6 -0
  180. package/dist/hooks/index.js +5 -0
  181. package/dist/hooks/manager.d.ts +75 -0
  182. package/dist/hooks/manager.js +289 -0
  183. package/dist/hooks/types.d.ts +180 -0
  184. package/dist/hooks/types.js +5 -0
  185. package/dist/index.d.ts +537 -0
  186. package/dist/index.js +1399 -0
  187. package/dist/ipc/ipc-reporter.d.ts +14 -0
  188. package/dist/ipc/ipc-reporter.js +18 -0
  189. package/dist/knowledge-inspector.d.ts +139 -0
  190. package/dist/knowledge-inspector.js +533 -0
  191. package/dist/knowledge-scope-id.d.ts +7 -0
  192. package/dist/knowledge-scope-id.js +10 -0
  193. package/dist/knowledge-scope.d.ts +41 -0
  194. package/dist/knowledge-scope.js +85 -0
  195. package/dist/lsp/client.d.ts +56 -0
  196. package/dist/lsp/client.js +248 -0
  197. package/dist/lsp/index.d.ts +4 -0
  198. package/dist/lsp/index.js +4 -0
  199. package/dist/lsp/language.d.ts +9 -0
  200. package/dist/lsp/language.js +41 -0
  201. package/dist/lsp/manager.d.ts +34 -0
  202. package/dist/lsp/manager.js +79 -0
  203. package/dist/lsp/server.d.ts +27 -0
  204. package/dist/lsp/server.js +158 -0
  205. package/dist/lsp/workspace.d.ts +9 -0
  206. package/dist/lsp/workspace.js +52 -0
  207. package/dist/mcp/config.d.ts +77 -0
  208. package/dist/mcp/config.js +313 -0
  209. package/dist/mcp/index.d.ts +6 -0
  210. package/dist/mcp/index.js +3 -0
  211. package/dist/mcp/manager.d.ts +104 -0
  212. package/dist/mcp/manager.js +693 -0
  213. package/dist/mcp/state.d.ts +35 -0
  214. package/dist/mcp/state.js +94 -0
  215. package/dist/mcp/types.d.ts +139 -0
  216. package/dist/mcp/types.js +1 -0
  217. package/dist/onboarding/custom-packs.d.ts +7 -0
  218. package/dist/onboarding/custom-packs.js +17 -0
  219. package/dist/onboarding/custom-providers.d.ts +4 -0
  220. package/dist/onboarding/custom-providers.js +27 -0
  221. package/dist/onboarding/index.d.ts +5 -0
  222. package/dist/onboarding/index.js +3 -0
  223. package/dist/onboarding/om-settings.d.ts +47 -0
  224. package/dist/onboarding/om-settings.js +80 -0
  225. package/dist/onboarding/pack-activation.d.ts +43 -0
  226. package/dist/onboarding/pack-activation.js +105 -0
  227. package/dist/onboarding/packs.d.ts +106 -0
  228. package/dist/onboarding/packs.js +283 -0
  229. package/dist/onboarding/settings.d.ts +563 -0
  230. package/dist/onboarding/settings.js +1110 -0
  231. package/dist/permissions.d.ts +55 -0
  232. package/dist/permissions.js +139 -0
  233. package/dist/platform/index.d.ts +74 -0
  234. package/dist/platform/index.js +199 -0
  235. package/dist/plugin.d.ts +156 -0
  236. package/dist/plugin.js +27 -0
  237. package/dist/plugins/dependencies.d.ts +9 -0
  238. package/dist/plugins/dependencies.js +84 -0
  239. package/dist/plugins/install.d.ts +21 -0
  240. package/dist/plugins/install.js +187 -0
  241. package/dist/plugins/loader.d.ts +25 -0
  242. package/dist/plugins/loader.js +264 -0
  243. package/dist/plugins/manager.d.ts +115 -0
  244. package/dist/plugins/manager.js +507 -0
  245. package/dist/plugins/manifest.d.ts +14 -0
  246. package/dist/plugins/manifest.js +47 -0
  247. package/dist/plugins/package-link.d.ts +3 -0
  248. package/dist/plugins/package-link.js +58 -0
  249. package/dist/plugins/paths.d.ts +10 -0
  250. package/dist/plugins/paths.js +22 -0
  251. package/dist/plugins/registry.d.ts +8 -0
  252. package/dist/plugins/registry.js +109 -0
  253. package/dist/plugins/scaffold.d.ts +10 -0
  254. package/dist/plugins/scaffold.js +115 -0
  255. package/dist/plugins/signal-lane.d.ts +59 -0
  256. package/dist/plugins/signal-lane.js +163 -0
  257. package/dist/plugins/types.d.ts +95 -0
  258. package/dist/plugins/types.js +1 -0
  259. package/dist/process-memory-diagnostics.d.ts +136 -0
  260. package/dist/process-memory-diagnostics.js +497 -0
  261. package/dist/processors/plan-rejection-abort.d.ts +16 -0
  262. package/dist/processors/plan-rejection-abort.js +62 -0
  263. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  264. package/dist/providers/amazon-bedrock-gateway.js +142 -0
  265. package/dist/providers/amazon-bedrock.d.ts +28 -0
  266. package/dist/providers/amazon-bedrock.js +99 -0
  267. package/dist/providers/anthropic-prompt-cache.d.ts +19 -0
  268. package/dist/providers/anthropic-prompt-cache.js +8 -0
  269. package/dist/providers/anthropic-thinking.d.ts +5 -0
  270. package/dist/providers/anthropic-thinking.js +22 -0
  271. package/dist/providers/claude-max.d.ts +67 -0
  272. package/dist/providers/claude-max.js +232 -0
  273. package/dist/providers/github-copilot-gateway.d.ts +35 -0
  274. package/dist/providers/github-copilot-gateway.js +58 -0
  275. package/dist/providers/github-copilot.d.ts +60 -0
  276. package/dist/providers/github-copilot.js +320 -0
  277. package/dist/providers/google-thinking.d.ts +31 -0
  278. package/dist/providers/google-thinking.js +64 -0
  279. package/dist/providers/google-vertex-gateway.d.ts +23 -0
  280. package/dist/providers/google-vertex-gateway.js +49 -0
  281. package/dist/providers/google-vertex.d.ts +6 -0
  282. package/dist/providers/google-vertex.js +51 -0
  283. package/dist/providers/kimi-coding.d.ts +14 -0
  284. package/dist/providers/kimi-coding.js +80 -0
  285. package/dist/providers/model-ids.d.ts +53 -0
  286. package/dist/providers/model-ids.js +132 -0
  287. package/dist/providers/openai-codex.d.ts +114 -0
  288. package/dist/providers/openai-codex.js +427 -0
  289. package/dist/providers/provider-thinking.d.ts +23 -0
  290. package/dist/providers/provider-thinking.js +61 -0
  291. package/dist/providers/thinking-request.d.ts +14 -0
  292. package/dist/providers/thinking-request.js +87 -0
  293. package/dist/providers/xai.d.ts +33 -0
  294. package/dist/providers/xai.js +72 -0
  295. package/dist/schedules/index.d.ts +10 -0
  296. package/dist/schedules/index.js +6 -0
  297. package/dist/schedules/interval.d.ts +49 -0
  298. package/dist/schedules/interval.js +212 -0
  299. package/dist/schedules/prompt.d.ts +36 -0
  300. package/dist/schedules/prompt.js +36 -0
  301. package/dist/schedules/run-script.d.ts +8 -0
  302. package/dist/schedules/run-script.js +80 -0
  303. package/dist/schedules/scheduler.d.ts +101 -0
  304. package/dist/schedules/scheduler.js +167 -0
  305. package/dist/schedules/tools.d.ts +57 -0
  306. package/dist/schedules/tools.js +217 -0
  307. package/dist/schema.d.ts +499 -0
  308. package/dist/schema.js +131 -0
  309. package/dist/theme-palette.d.ts +17 -0
  310. package/dist/theme-palette.js +18 -0
  311. package/dist/thinking-catalog.d.ts +4 -0
  312. package/dist/thinking-catalog.js +13 -0
  313. package/dist/thinking.d.ts +37 -0
  314. package/dist/thinking.js +134 -0
  315. package/dist/tool-names.d.ts +77 -0
  316. package/dist/tool-names.js +53 -0
  317. package/dist/tools/index.d.ts +6 -0
  318. package/dist/tools/index.js +3 -0
  319. package/dist/tools/request-sandbox-access.d.ts +6 -0
  320. package/dist/tools/request-sandbox-access.js +80 -0
  321. package/dist/tools/utils.d.ts +20 -0
  322. package/dist/tools/utils.js +31 -0
  323. package/dist/tools/web-search.d.ts +116 -0
  324. package/dist/tools/web-search.js +158 -0
  325. package/dist/tools/workflows/create-workflow.d.ts +7 -0
  326. package/dist/tools/workflows/create-workflow.js +82 -0
  327. package/dist/tools/workflows/delete-workflow.d.ts +7 -0
  328. package/dist/tools/workflows/delete-workflow.js +18 -0
  329. package/dist/tools/workflows/ephemeral-memory.d.ts +28 -0
  330. package/dist/tools/workflows/ephemeral-memory.js +41 -0
  331. package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
  332. package/dist/tools/workflows/extract-json-schema.js +19 -0
  333. package/dist/tools/workflows/get-workflow.d.ts +11 -0
  334. package/dist/tools/workflows/get-workflow.js +31 -0
  335. package/dist/tools/workflows/list-available-agents.d.ts +8 -0
  336. package/dist/tools/workflows/list-available-agents.js +29 -0
  337. package/dist/tools/workflows/list-available-classifiers.d.ts +19 -0
  338. package/dist/tools/workflows/list-available-classifiers.js +53 -0
  339. package/dist/tools/workflows/list-available-tools.d.ts +9 -0
  340. package/dist/tools/workflows/list-available-tools.js +37 -0
  341. package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
  342. package/dist/tools/workflows/list-available-workflows.js +29 -0
  343. package/dist/tools/workflows/list-workflows.d.ts +9 -0
  344. package/dist/tools/workflows/list-workflows.js +30 -0
  345. package/dist/tools/workflows/run-workflow.d.ts +9 -0
  346. package/dist/tools/workflows/run-workflow.js +49 -0
  347. package/dist/tools/workflows/save-workflow.d.ts +1125 -0
  348. package/dist/tools/workflows/save-workflow.js +25 -0
  349. package/dist/tools/workflows/tool-ids.d.ts +16 -0
  350. package/dist/tools/workflows/tool-ids.js +17 -0
  351. package/dist/utils/binaries.d.ts +7 -0
  352. package/dist/utils/binaries.js +97 -0
  353. package/dist/utils/debug-log.d.ts +12 -0
  354. package/dist/utils/debug-log.js +56 -0
  355. package/dist/utils/discarding-scores-storage.d.ts +33 -0
  356. package/dist/utils/discarding-scores-storage.js +51 -0
  357. package/dist/utils/errors.d.ts +36 -0
  358. package/dist/utils/errors.js +215 -0
  359. package/dist/utils/gateway-sync.d.ts +26 -0
  360. package/dist/utils/gateway-sync.js +58 -0
  361. package/dist/utils/local-observability.d.ts +19 -0
  362. package/dist/utils/local-observability.js +54 -0
  363. package/dist/utils/maintenance-lock.d.ts +42 -0
  364. package/dist/utils/maintenance-lock.js +196 -0
  365. package/dist/utils/notification-dispatch.d.ts +74 -0
  366. package/dist/utils/notification-dispatch.js +128 -0
  367. package/dist/utils/open-url.d.ts +10 -0
  368. package/dist/utils/open-url.js +27 -0
  369. package/dist/utils/path-security.d.ts +2 -0
  370. package/dist/utils/path-security.js +7 -0
  371. package/dist/utils/plan-diff.d.ts +25 -0
  372. package/dist/utils/plan-diff.js +59 -0
  373. package/dist/utils/plans.d.ts +61 -0
  374. package/dist/utils/plans.js +120 -0
  375. package/dist/utils/project.d.ts +160 -0
  376. package/dist/utils/project.js +361 -0
  377. package/dist/utils/prune-cli.d.ts +24 -0
  378. package/dist/utils/prune-cli.js +124 -0
  379. package/dist/utils/signals-pubsub.d.ts +103 -0
  380. package/dist/utils/signals-pubsub.js +409 -0
  381. package/dist/utils/slash-command-loader.d.ts +52 -0
  382. package/dist/utils/slash-command-loader.js +139 -0
  383. package/dist/utils/slash-command-processor.d.ts +14 -0
  384. package/dist/utils/slash-command-processor.js +106 -0
  385. package/dist/utils/stdin-pipe.d.ts +33 -0
  386. package/dist/utils/stdin-pipe.js +93 -0
  387. package/dist/utils/storage-factory.d.ts +50 -0
  388. package/dist/utils/storage-factory.js +118 -0
  389. package/dist/utils/storage-maintenance.d.ts +121 -0
  390. package/dist/utils/storage-maintenance.js +352 -0
  391. package/dist/utils/thread-lock.d.ts +26 -0
  392. package/dist/utils/thread-lock.js +109 -0
  393. package/dist/utils/token-estimator.d.ts +3 -0
  394. package/dist/utils/token-estimator.js +19 -0
  395. package/dist/utils/update-check.d.ts +151 -0
  396. package/dist/utils/update-check.js +430 -0
  397. package/dist/utils/wake-session.d.ts +44 -0
  398. package/dist/utils/wake-session.js +83 -0
  399. package/dist/voice/stt-registry.d.ts +67 -0
  400. package/dist/voice/stt-registry.js +144 -0
  401. package/dist/voice/transcribe.d.ts +10 -0
  402. package/dist/voice/transcribe.js +75 -0
  403. package/dist/workflows/register-primitives.d.ts +52 -0
  404. package/dist/workflows/register-primitives.js +40 -0
  405. package/dist/workflows/service.d.ts +64 -0
  406. package/dist/workflows/service.js +50 -0
  407. package/package.json +117 -0
@@ -0,0 +1,77 @@
1
+ import { DEFAULT_CONFIG_DIR } from "../constants.js";
2
+ import * as path$1 from "path";
3
+ import * as fs$1 from "fs";
4
+ import * as os$1 from "os";
5
+ // src/hooks/config.ts
6
+ /**
7
+ * Hook configuration loading from filesystem.
8
+ * Loads from global (~/.mastracode/hooks.json) and project (.mastracode/hooks.json).
9
+ * Global hooks run first, project hooks append.
10
+ */
11
+ const VALID_EVENTS = [
12
+ "PreToolUse",
13
+ "PostToolUse",
14
+ "Stop",
15
+ "UserPromptSubmit",
16
+ "SessionStart",
17
+ "SessionEnd",
18
+ "Notification",
19
+ "AgentStart",
20
+ "AgentEnd",
21
+ "PermissionRequest",
22
+ "PermissionResult",
23
+ "Interrupt",
24
+ "SubagentStart",
25
+ "SubagentEnd"
26
+ ];
27
+ function loadHooksConfig(projectDir, configDirName = DEFAULT_CONFIG_DIR, homeDir) {
28
+ const globalPath = getGlobalHooksPath(configDirName, homeDir);
29
+ const projectPath = getProjectHooksPath(projectDir, configDirName);
30
+ return mergeConfigs(loadSingleConfig(globalPath), isSameFile(globalPath, projectPath) ? {} : loadSingleConfig(projectPath));
31
+ }
32
+ function isSameFile(a, b) {
33
+ try {
34
+ return fs$1.realpathSync(a) === fs$1.realpathSync(b);
35
+ } catch {
36
+ return path$1.resolve(a) === path$1.resolve(b);
37
+ }
38
+ }
39
+ function getProjectHooksPath(projectDir, configDirName = DEFAULT_CONFIG_DIR) {
40
+ return path$1.join(projectDir, configDirName, "hooks.json");
41
+ }
42
+ function getGlobalHooksPath(configDirName = DEFAULT_CONFIG_DIR, homeDir = os$1.homedir()) {
43
+ return path$1.join(homeDir, configDirName, "hooks.json");
44
+ }
45
+ function loadSingleConfig(filePath) {
46
+ try {
47
+ if (!fs$1.existsSync(filePath)) return {};
48
+ const raw = fs$1.readFileSync(filePath, "utf-8");
49
+ return validateConfig(JSON.parse(raw));
50
+ } catch {
51
+ return {};
52
+ }
53
+ }
54
+ function validateConfig(raw) {
55
+ if (!raw || typeof raw !== "object") return {};
56
+ const config = {};
57
+ const obj = raw;
58
+ for (const event of VALID_EVENTS) if (Array.isArray(obj[event])) {
59
+ const hooks = obj[event].filter(isValidHook);
60
+ if (hooks.length > 0) config[event] = hooks;
61
+ }
62
+ return config;
63
+ }
64
+ function isValidHook(raw) {
65
+ if (!raw || typeof raw !== "object") return false;
66
+ const obj = raw;
67
+ return obj.type === "command" && typeof obj.command === "string";
68
+ }
69
+ function mergeConfigs(global, project) {
70
+ const merged = {};
71
+ for (const event of VALID_EVENTS) {
72
+ const combined = [...global[event] ?? [], ...project[event] ?? []];
73
+ if (combined.length > 0) merged[event] = combined;
74
+ }
75
+ return merged;
76
+ }
77
+ export { VALID_EVENTS, getGlobalHooksPath, getProjectHooksPath, loadHooksConfig };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Hook process execution.
3
+ * Spawns shell commands, handles stdin/stdout/exit-code protocol.
4
+ */
5
+ import type { HookDefinition, HookStdin, HookResult, HookEventResult } from './types.js';
6
+ export declare function executeHook(hook: HookDefinition, stdinPayload: HookStdin): Promise<HookResult>;
7
+ export declare function matchesHook(hook: HookDefinition, context: {
8
+ tool_name?: string;
9
+ }): boolean;
10
+ export declare function runHooksForEvent(hooks: HookDefinition[], stdinPayload: HookStdin, matchContext?: {
11
+ tool_name?: string;
12
+ }): Promise<HookEventResult>;
13
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1,128 @@
1
+ import { isBlockingEvent } from "./types.js";
2
+ import { spawn } from "child_process";
3
+ // src/hooks/executor.ts
4
+ /**
5
+ * Hook process execution.
6
+ * Spawns shell commands, handles stdin/stdout/exit-code protocol.
7
+ */
8
+ const DEFAULT_TIMEOUT = 1e4;
9
+ async function executeHook(hook, stdinPayload) {
10
+ const timeout = hook.timeout ?? DEFAULT_TIMEOUT;
11
+ const startTime = Date.now();
12
+ return new Promise((resolve) => {
13
+ const isWindows = process.platform === "win32";
14
+ const shell = isWindows ? "cmd" : "/bin/sh";
15
+ const shellArgs = isWindows ? ["/c", hook.command] : ["-c", hook.command];
16
+ const child = spawn(shell, shellArgs, {
17
+ stdio: [
18
+ "pipe",
19
+ "pipe",
20
+ "pipe"
21
+ ],
22
+ cwd: stdinPayload.cwd,
23
+ ...isWindows ? { windowsVerbatimArguments: true } : {},
24
+ env: {
25
+ ...process.env,
26
+ MASTRA_HOOK_EVENT: stdinPayload.hook_event_name
27
+ }
28
+ });
29
+ let stdout = "";
30
+ let stderr = "";
31
+ let timedOut = false;
32
+ let resolved = false;
33
+ const timer = setTimeout(() => {
34
+ timedOut = true;
35
+ child.kill("SIGKILL");
36
+ }, timeout);
37
+ child.stdout?.on("data", (data) => {
38
+ stdout += data.toString();
39
+ });
40
+ child.stderr?.on("data", (data) => {
41
+ stderr += data.toString();
42
+ });
43
+ child.on("close", (exitCode) => {
44
+ clearTimeout(timer);
45
+ if (resolved) return;
46
+ resolved = true;
47
+ let parsedStdout;
48
+ if (stdout.trim()) try {
49
+ parsedStdout = JSON.parse(stdout.trim());
50
+ } catch {}
51
+ resolve({
52
+ hook,
53
+ exitCode: exitCode ?? 1,
54
+ stdout: parsedStdout,
55
+ stderr: stderr.trim() || void 0,
56
+ timedOut,
57
+ durationMs: Date.now() - startTime
58
+ });
59
+ });
60
+ child.on("error", (error) => {
61
+ clearTimeout(timer);
62
+ if (resolved) return;
63
+ resolved = true;
64
+ resolve({
65
+ hook,
66
+ exitCode: 1,
67
+ stderr: error.message,
68
+ timedOut: false,
69
+ durationMs: Date.now() - startTime
70
+ });
71
+ });
72
+ child.stdin?.on("error", () => {});
73
+ try {
74
+ child.stdin?.write(JSON.stringify(stdinPayload));
75
+ child.stdin?.end();
76
+ } catch {}
77
+ });
78
+ }
79
+ function matchesHook(hook, context) {
80
+ if (!hook.matcher) return true;
81
+ if (hook.matcher.tool_name) {
82
+ if (!context.tool_name) return false;
83
+ try {
84
+ return new RegExp(hook.matcher.tool_name).test(context.tool_name);
85
+ } catch {
86
+ return false;
87
+ }
88
+ }
89
+ return true;
90
+ }
91
+ async function runHooksForEvent(hooks, stdinPayload, matchContext = {}) {
92
+ const results = [];
93
+ const warnings = [];
94
+ let additionalContext;
95
+ const applicable = hooks.filter((h) => matchesHook(h, matchContext));
96
+ if (applicable.length === 0) return {
97
+ allowed: true,
98
+ results: [],
99
+ warnings: []
100
+ };
101
+ const blocking = isBlockingEvent(stdinPayload.hook_event_name);
102
+ for (const hook of applicable) {
103
+ const result = await executeHook(hook, stdinPayload);
104
+ results.push(result);
105
+ if (result.stdout?.additionalContext) additionalContext = additionalContext ? `${additionalContext}\n${result.stdout.additionalContext}` : result.stdout.additionalContext;
106
+ if (result.timedOut) {
107
+ warnings.push(`Hook timed out after ${hook.timeout ?? DEFAULT_TIMEOUT}ms: ${hook.command}`);
108
+ continue;
109
+ }
110
+ if (result.exitCode === 2 && blocking) return {
111
+ allowed: false,
112
+ blockReason: result.stdout?.reason || result.stderr || `Blocked by hook: ${hook.description || hook.command}`,
113
+ additionalContext,
114
+ results,
115
+ warnings
116
+ };
117
+ if (result.exitCode === 0) continue;
118
+ const warnMsg = result.stderr || `Hook exited with code ${result.exitCode}`;
119
+ warnings.push(`${hook.description || hook.command}: ${warnMsg}`);
120
+ }
121
+ return {
122
+ allowed: true,
123
+ additionalContext,
124
+ results,
125
+ warnings
126
+ };
127
+ }
128
+ export { executeHook, matchesHook, runHooksForEvent };
@@ -0,0 +1,6 @@
1
+ export { HookManager } from './manager.js';
2
+ export { loadHooksConfig, getProjectHooksPath, getGlobalHooksPath, VALID_EVENTS } from './config.js';
3
+ export { executeHook, runHooksForEvent, matchesHook } from './executor.js';
4
+ export { isBlockingEvent } from './types.js';
5
+ export type { HookEventName, HookDefinition, HookMatcher, HooksConfig, HookStdin, HookStdinBase, HookStdinToolEvent, HookStdinUserPrompt, HookStdinStop, HookStdinSession, SessionStartSource, HookStdinNotification, HookStdinAgentStart, HookStdinAgentEnd, HookStdinPermissionRequest, HookStdinPermissionResult, HookStdinInterrupt, HookStdinSubagentStart, HookStdinSubagentEnd, HookStdout, HookResult, HookEventResult, BlockingHookEvent, LifecycleHookEvent, PermissionKind, PermissionDecision, InterruptReason, } from './types.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { HookManager } from "./manager.js";
2
+ import { VALID_EVENTS, getGlobalHooksPath, getProjectHooksPath, loadHooksConfig } from "./config.js";
3
+ import { executeHook, matchesHook, runHooksForEvent } from "./executor.js";
4
+ import { isBlockingEvent } from "./types.js";
5
+ export { HookManager, VALID_EVENTS, executeHook, getGlobalHooksPath, getProjectHooksPath, isBlockingEvent, loadHooksConfig, matchesHook, runHooksForEvent };
@@ -0,0 +1,75 @@
1
+ import type { HooksConfig, HookEventResult, SessionStartSource, PermissionKind, PermissionDecision, InterruptReason, SessionWorktreeInfo } from './types.js';
2
+ export declare class HookManager {
3
+ private config;
4
+ private projectDir;
5
+ private sessionId;
6
+ private configDirName;
7
+ private homeDir?;
8
+ private runId?;
9
+ /**
10
+ * Run id each pending permission prompt was raised under. A suspended run can
11
+ * end (clearing runId) while its prompt stays open, so the result must not
12
+ * read the current run id.
13
+ */
14
+ private permissionRunIds;
15
+ private worktree?;
16
+ /** True once SessionStart has fired, so later thread binds announce themselves. */
17
+ private sessionStarted;
18
+ /**
19
+ * The latest queued SessionStart, settled or not. SessionStart runs one after another,
20
+ * and other events wait for it, so hooks see each session in order and before its events.
21
+ */
22
+ private pendingSessionStart?;
23
+ constructor(projectDir: string, sessionId: string, configDirName?: string, homeDir?: string, worktree?: SessionWorktreeInfo);
24
+ reload(): void;
25
+ /**
26
+ * Bind hooks to a thread. After SessionStart has fired, binding a different thread
27
+ * (the first message creating one, `/new`, a resumed thread) fires SessionStart again
28
+ * with `source: 'thread_change'`, so a hook that tracks sessions learns the new id
29
+ * before any event of that thread reaches it.
30
+ */
31
+ setSessionId(sessionId: string): void;
32
+ /** Dispatch an event's hooks once any queued SessionStart has finished. */
33
+ private dispatch;
34
+ /** Set the active agent run id. Included as `run_id` in all hook stdin while a run is active. */
35
+ setRunId(runId: string): void;
36
+ /** Clear the active run id. Call only after end-of-run hooks (AgentEnd, Stop) have been dispatched. */
37
+ clearRunId(): void;
38
+ getRunId(): string | undefined;
39
+ hasHooks(): boolean;
40
+ getConfig(): HooksConfig;
41
+ getConfigPaths(): {
42
+ project: string;
43
+ global: string;
44
+ };
45
+ /**
46
+ * Build the common stdin base fields. `run_id` is included when an active run
47
+ * is set, so every event dispatched during a run carries the same identifier.
48
+ */
49
+ private baseStdinFields;
50
+ /**
51
+ * Session stdin, carrying worktree identity when there is one. Emitted on both
52
+ * session events so a hook that provisions on start can tear down on end using
53
+ * the same fields.
54
+ */
55
+ private sessionStdin;
56
+ runPreToolUse(toolName: string, toolInput: unknown): Promise<HookEventResult>;
57
+ runPostToolUse(toolName: string, toolInput: unknown, toolOutput: unknown, toolError: boolean): Promise<HookEventResult>;
58
+ runUserPromptSubmit(userMessage: string): Promise<HookEventResult>;
59
+ runStop(assistantMessage: string | undefined, stopReason: 'complete' | 'aborted' | 'error'): Promise<HookEventResult>;
60
+ runSessionStart(source?: SessionStartSource): Promise<HookEventResult>;
61
+ runSessionEnd(): Promise<HookEventResult>;
62
+ /**
63
+ * Fire notification hooks (non-blocking, fire-and-forget).
64
+ * Called when the TUI is waiting for user input.
65
+ */
66
+ runNotification(reason: string, message?: string): void;
67
+ runAgentStart(): Promise<HookEventResult>;
68
+ runAgentEnd(stopReason: 'complete' | 'aborted' | 'error' | 'suspended'): Promise<HookEventResult>;
69
+ runPermissionRequest(permissionKind: PermissionKind, toolCallId: string, toolName: string, toolInput?: unknown): Promise<HookEventResult>;
70
+ runPermissionResult(permissionKind: PermissionKind, toolCallId: string, toolName: string, decision: PermissionDecision, toolInput?: unknown): Promise<HookEventResult>;
71
+ runInterrupt(reason: InterruptReason): Promise<HookEventResult>;
72
+ runSubagentStart(toolCallId: string, agentType: string, task: string, modelId?: string, forked?: boolean): Promise<HookEventResult>;
73
+ runSubagentEnd(toolCallId: string, agentType: string, result: unknown, isError: boolean, durationMs: number): Promise<HookEventResult>;
74
+ }
75
+ //# sourceMappingURL=manager.d.ts.map
@@ -0,0 +1,289 @@
1
+ import { DEFAULT_CONFIG_DIR } from "../constants.js";
2
+ import { getGlobalHooksPath, getProjectHooksPath, loadHooksConfig } from "./config.js";
3
+ import { runHooksForEvent } from "./executor.js";
4
+ // src/hooks/manager.ts
5
+ /**
6
+ * HookManager — high-level orchestration for the hooks system.
7
+ * Created once at startup, provides methods for each lifecycle event.
8
+ */
9
+ const emptyResult = () => ({
10
+ allowed: true,
11
+ results: [],
12
+ warnings: []
13
+ });
14
+ var HookManager = class {
15
+ config;
16
+ projectDir;
17
+ sessionId;
18
+ configDirName;
19
+ homeDir;
20
+ runId;
21
+ /**
22
+ * Run id each pending permission prompt was raised under. A suspended run can
23
+ * end (clearing runId) while its prompt stays open, so the result must not
24
+ * read the current run id.
25
+ */
26
+ permissionRunIds = /* @__PURE__ */ new Map();
27
+ worktree;
28
+ /** True once SessionStart has fired, so later thread binds announce themselves. */
29
+ sessionStarted = false;
30
+ /**
31
+ * The latest queued SessionStart, settled or not. SessionStart runs one after another,
32
+ * and other events wait for it, so hooks see each session in order and before its events.
33
+ */
34
+ pendingSessionStart;
35
+ constructor(projectDir, sessionId, configDirName = DEFAULT_CONFIG_DIR, homeDir, worktree) {
36
+ this.worktree = worktree;
37
+ this.projectDir = projectDir;
38
+ this.sessionId = sessionId;
39
+ this.configDirName = configDirName;
40
+ this.homeDir = homeDir;
41
+ this.config = loadHooksConfig(projectDir, configDirName, homeDir);
42
+ }
43
+ reload() {
44
+ this.config = loadHooksConfig(this.projectDir, this.configDirName, this.homeDir);
45
+ }
46
+ /**
47
+ * Bind hooks to a thread. After SessionStart has fired, binding a different thread
48
+ * (the first message creating one, `/new`, a resumed thread) fires SessionStart again
49
+ * with `source: 'thread_change'`, so a hook that tracks sessions learns the new id
50
+ * before any event of that thread reaches it.
51
+ */
52
+ setSessionId(sessionId) {
53
+ if (sessionId === this.sessionId) return;
54
+ this.sessionId = sessionId;
55
+ if (this.sessionStarted) this.runSessionStart("thread_change").catch(() => {});
56
+ }
57
+ /** Dispatch an event's hooks once any queued SessionStart has finished. */
58
+ async dispatch(...args) {
59
+ if (this.pendingSessionStart) await this.pendingSessionStart;
60
+ return runHooksForEvent(...args);
61
+ }
62
+ /** Set the active agent run id. Included as `run_id` in all hook stdin while a run is active. */
63
+ setRunId(runId) {
64
+ this.runId = runId;
65
+ }
66
+ /** Clear the active run id. Call only after end-of-run hooks (AgentEnd, Stop) have been dispatched. */
67
+ clearRunId() {
68
+ this.runId = void 0;
69
+ }
70
+ getRunId() {
71
+ return this.runId;
72
+ }
73
+ hasHooks() {
74
+ return Object.keys(this.config).length > 0;
75
+ }
76
+ getConfig() {
77
+ return this.config;
78
+ }
79
+ getConfigPaths() {
80
+ return {
81
+ project: getProjectHooksPath(this.projectDir, this.configDirName),
82
+ global: getGlobalHooksPath(this.configDirName, this.homeDir)
83
+ };
84
+ }
85
+ /**
86
+ * Build the common stdin base fields. `run_id` is included when an active run
87
+ * is set, so every event dispatched during a run carries the same identifier.
88
+ */
89
+ baseStdinFields(hook_event_name) {
90
+ const base = {
91
+ session_id: this.sessionId,
92
+ cwd: this.projectDir,
93
+ hook_event_name
94
+ };
95
+ if (this.runId) base.run_id = this.runId;
96
+ return base;
97
+ }
98
+ /**
99
+ * Session stdin, carrying worktree identity when there is one. Emitted on both
100
+ * session events so a hook that provisions on start can tear down on end using
101
+ * the same fields.
102
+ */
103
+ sessionStdin(hook_event_name, source) {
104
+ const stdin = this.baseStdinFields(hook_event_name);
105
+ if (source) stdin.source = source;
106
+ if (this.worktree) {
107
+ stdin.worktree_path = this.worktree.path;
108
+ if (this.worktree.branch) stdin.branch = this.worktree.branch;
109
+ if (this.worktree.mainRepoPath) stdin.main_repo_path = this.worktree.mainRepoPath;
110
+ }
111
+ return stdin;
112
+ }
113
+ async runPreToolUse(toolName, toolInput) {
114
+ const hooks = this.config.PreToolUse;
115
+ if (!hooks || hooks.length === 0) return emptyResult();
116
+ const stdin = {
117
+ ...this.baseStdinFields("PreToolUse"),
118
+ tool_name: toolName,
119
+ tool_input: toolInput
120
+ };
121
+ return this.dispatch(hooks, stdin, { tool_name: toolName });
122
+ }
123
+ async runPostToolUse(toolName, toolInput, toolOutput, toolError) {
124
+ const hooks = this.config.PostToolUse;
125
+ if (!hooks || hooks.length === 0) return emptyResult();
126
+ const stdin = {
127
+ ...this.baseStdinFields("PostToolUse"),
128
+ tool_name: toolName,
129
+ tool_input: toolInput,
130
+ tool_output: toolOutput,
131
+ tool_error: toolError
132
+ };
133
+ return this.dispatch(hooks, stdin, { tool_name: toolName });
134
+ }
135
+ async runUserPromptSubmit(userMessage) {
136
+ const hooks = this.config.UserPromptSubmit;
137
+ if (!hooks || hooks.length === 0) return emptyResult();
138
+ const stdin = {
139
+ ...this.baseStdinFields("UserPromptSubmit"),
140
+ user_message: userMessage
141
+ };
142
+ return this.dispatch(hooks, stdin);
143
+ }
144
+ async runStop(assistantMessage, stopReason) {
145
+ const hooks = this.config.Stop;
146
+ if (!hooks || hooks.length === 0) return emptyResult();
147
+ const stdin = {
148
+ ...this.baseStdinFields("Stop"),
149
+ assistant_message: assistantMessage,
150
+ stop_reason: stopReason
151
+ };
152
+ return this.dispatch(hooks, stdin);
153
+ }
154
+ async runSessionStart(source = "startup") {
155
+ this.sessionStarted = true;
156
+ const hooks = this.config.SessionStart;
157
+ if (!hooks || hooks.length === 0) return emptyResult();
158
+ const stdin = this.sessionStdin("SessionStart", source);
159
+ const previous = this.pendingSessionStart;
160
+ const run = previous ? previous.then(() => runHooksForEvent(hooks, stdin)) : runHooksForEvent(hooks, stdin);
161
+ const settled = run.then(() => {}, () => {});
162
+ this.pendingSessionStart = settled;
163
+ settled.then(() => {
164
+ if (this.pendingSessionStart === settled) this.pendingSessionStart = void 0;
165
+ });
166
+ return run;
167
+ }
168
+ async runSessionEnd() {
169
+ const hooks = this.config.SessionEnd;
170
+ if (!hooks || hooks.length === 0) return emptyResult();
171
+ const stdin = this.sessionStdin("SessionEnd");
172
+ return this.dispatch(hooks, stdin);
173
+ }
174
+ /**
175
+ * Fire notification hooks (non-blocking, fire-and-forget).
176
+ * Called when the TUI is waiting for user input.
177
+ */
178
+ runNotification(reason, message) {
179
+ const hooks = this.config.Notification;
180
+ if (!hooks || hooks.length === 0) return;
181
+ const stdin = {
182
+ ...this.baseStdinFields("Notification"),
183
+ reason,
184
+ message
185
+ };
186
+ this.dispatch(hooks, stdin).catch(() => {});
187
+ }
188
+ async runAgentStart() {
189
+ const hooks = this.config.AgentStart;
190
+ if (!hooks || hooks.length === 0) return emptyResult();
191
+ const runId = this.runId;
192
+ if (!runId) return emptyResult();
193
+ const stdin = {
194
+ ...this.baseStdinFields("AgentStart"),
195
+ run_id: runId
196
+ };
197
+ return this.dispatch(hooks, stdin);
198
+ }
199
+ async runAgentEnd(stopReason) {
200
+ const hooks = this.config.AgentEnd;
201
+ if (!hooks || hooks.length === 0) return emptyResult();
202
+ const runId = this.runId;
203
+ if (!runId) return emptyResult();
204
+ const stdin = {
205
+ ...this.baseStdinFields("AgentEnd"),
206
+ run_id: runId,
207
+ stop_reason: stopReason
208
+ };
209
+ return this.dispatch(hooks, stdin);
210
+ }
211
+ async runPermissionRequest(permissionKind, toolCallId, toolName, toolInput) {
212
+ const runId = this.runId;
213
+ if (runId) this.permissionRunIds.set(toolCallId, runId);
214
+ const hooks = this.config.PermissionRequest;
215
+ if (!hooks || hooks.length === 0) return emptyResult();
216
+ if (!runId) return emptyResult();
217
+ const stdin = {
218
+ ...this.baseStdinFields("PermissionRequest"),
219
+ run_id: runId,
220
+ permission_kind: permissionKind,
221
+ tool_call_id: toolCallId,
222
+ tool_name: toolName,
223
+ ...toolInput !== void 0 ? { tool_input: toolInput } : {}
224
+ };
225
+ return this.dispatch(hooks, stdin);
226
+ }
227
+ async runPermissionResult(permissionKind, toolCallId, toolName, decision, toolInput) {
228
+ const runId = this.permissionRunIds.get(toolCallId) ?? this.runId;
229
+ this.permissionRunIds.delete(toolCallId);
230
+ const hooks = this.config.PermissionResult;
231
+ if (!hooks || hooks.length === 0) return emptyResult();
232
+ if (!runId) return emptyResult();
233
+ const stdin = {
234
+ ...this.baseStdinFields("PermissionResult"),
235
+ run_id: runId,
236
+ permission_kind: permissionKind,
237
+ tool_call_id: toolCallId,
238
+ tool_name: toolName,
239
+ decision,
240
+ ...toolInput !== void 0 ? { tool_input: toolInput } : {}
241
+ };
242
+ return this.dispatch(hooks, stdin);
243
+ }
244
+ async runInterrupt(reason) {
245
+ const hooks = this.config.Interrupt;
246
+ if (!hooks || hooks.length === 0) return emptyResult();
247
+ const runId = this.runId;
248
+ if (!runId) return emptyResult();
249
+ const stdin = {
250
+ ...this.baseStdinFields("Interrupt"),
251
+ run_id: runId,
252
+ reason
253
+ };
254
+ return this.dispatch(hooks, stdin);
255
+ }
256
+ async runSubagentStart(toolCallId, agentType, task, modelId, forked) {
257
+ const hooks = this.config.SubagentStart;
258
+ if (!hooks || hooks.length === 0) return emptyResult();
259
+ const runId = this.runId;
260
+ if (!runId) return emptyResult();
261
+ const stdin = {
262
+ ...this.baseStdinFields("SubagentStart"),
263
+ run_id: runId,
264
+ tool_call_id: toolCallId,
265
+ agent_type: agentType,
266
+ task,
267
+ ...modelId !== void 0 ? { model_id: modelId } : {},
268
+ ...forked !== void 0 ? { forked } : {}
269
+ };
270
+ return this.dispatch(hooks, stdin);
271
+ }
272
+ async runSubagentEnd(toolCallId, agentType, result, isError, durationMs) {
273
+ const hooks = this.config.SubagentEnd;
274
+ if (!hooks || hooks.length === 0) return emptyResult();
275
+ const runId = this.runId;
276
+ if (!runId) return emptyResult();
277
+ const stdin = {
278
+ ...this.baseStdinFields("SubagentEnd"),
279
+ run_id: runId,
280
+ tool_call_id: toolCallId,
281
+ agent_type: agentType,
282
+ result,
283
+ is_error: isError,
284
+ duration_ms: durationMs
285
+ };
286
+ return this.dispatch(hooks, stdin);
287
+ }
288
+ };
289
+ export { HookManager };