@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,158 @@
1
+ import { loadSettings } from "../onboarding/settings.js";
2
+ import { truncateStringForTokenEstimate } from "../utils/token-estimator.js";
3
+ import { createTool, isValidationError } from "@mastra/core/tools";
4
+ import { z } from "zod";
5
+ // src/tools/web-search.ts
6
+ const MAX_WEB_SEARCH_TOKENS = 2e3;
7
+ const MAX_WEB_EXTRACT_TOKENS = 2e3;
8
+ const MIN_RELEVANCE_SCORE = .25;
9
+ const parallelWebSearchInputSchema = z.object({ query: z.string().min(1).describe("The search query") });
10
+ function requireParallelOutput(output, operation) {
11
+ if (output === void 0) throw new Error(`Parallel ${operation} returned no output`);
12
+ if (isValidationError(output)) throw new Error(output.message);
13
+ return output;
14
+ }
15
+ /**
16
+ * Check whether a Tavily API key is available in the environment.
17
+ * Used to select model-independent web tools before falling back to
18
+ * model-native web search.
19
+ */
20
+ function hasTavilyKey() {
21
+ return !!process.env.TAVILY_API_KEY;
22
+ }
23
+ /** Check whether a Parallel API key is available in the environment. */
24
+ function hasParallelKey() {
25
+ return !!process.env.PARALLEL_API_KEY;
26
+ }
27
+ /**
28
+ * Wraps the @mastra/tavily search tool with mastracode-specific behavior:
29
+ * relevance filtering, markdown string formatting, and token truncation.
30
+ * The underlying Tavily tool handles client init, input validation, and the API call.
31
+ */
32
+ async function createWebSearchTool() {
33
+ const { createTavilySearchTool } = await import("@mastra/tavily");
34
+ const tavilySearchTool = createTavilySearchTool();
35
+ return createTool({
36
+ id: "web-search",
37
+ description: tavilySearchTool.description,
38
+ inputSchema: tavilySearchTool.inputSchema,
39
+ execute: async (input, context) => {
40
+ const output = await tavilySearchTool.execute(input, context);
41
+ const parts = [];
42
+ if (output.answer) parts.push(`Answer: ${output.answer}`);
43
+ const filtered = output.results.filter((r) => (r.score ?? 1) >= MIN_RELEVANCE_SCORE);
44
+ for (const r of filtered) parts.push(`## ${r.title}\n${r.url}\n${r.content}`);
45
+ const images = (output.images || []).map((img) => img.url).filter(Boolean);
46
+ if (images.length > 0) parts.push(`Images:\n${images.join("\n")}`);
47
+ const text = parts.join("\n\n");
48
+ return truncateStringForTokenEstimate(text, MAX_WEB_SEARCH_TOKENS);
49
+ }
50
+ });
51
+ }
52
+ /**
53
+ * Wraps the @mastra/tavily extract tool with mastracode-specific behavior:
54
+ * markdown string formatting and token truncation.
55
+ */
56
+ async function createWebExtractTool() {
57
+ const { createTavilyExtractTool } = await import("@mastra/tavily");
58
+ const tavilyExtractTool = createTavilyExtractTool();
59
+ return createTool({
60
+ id: "web-extract",
61
+ description: tavilyExtractTool.description,
62
+ inputSchema: tavilyExtractTool.inputSchema,
63
+ execute: async (input, context) => {
64
+ const output = await tavilyExtractTool.execute(input, context);
65
+ const parts = [];
66
+ for (const r of output.results) parts.push(`## ${r.url}\n${r.rawContent}`);
67
+ for (const r of output.failedResults) parts.push(`## ${r.url}\nError: ${r.error}`);
68
+ const text = parts.join("\n\n");
69
+ return truncateStringForTokenEstimate(text, MAX_WEB_EXTRACT_TOKENS);
70
+ }
71
+ });
72
+ }
73
+ /**
74
+ * Wraps the @mastra/parallel search tool with Mastra Code's standard tool id,
75
+ * markdown string output, and token truncation.
76
+ */
77
+ async function createParallelWebSearchTool() {
78
+ const { createParallelSearchTool } = await import("@mastra/parallel");
79
+ const parallelSearchTool = createParallelSearchTool();
80
+ return createTool({
81
+ id: "web-search",
82
+ description: parallelSearchTool.description,
83
+ inputSchema: parallelWebSearchInputSchema,
84
+ execute: async (input, context) => {
85
+ const output = requireParallelOutput(await parallelSearchTool.execute({ searchQueries: [input.query] }, context), "search");
86
+ const parts = [];
87
+ for (const result of output.results) {
88
+ const title = result.title || result.url;
89
+ const excerpts = (result.excerpts || []).filter(Boolean).join("\n");
90
+ parts.push([
91
+ `## ${title}`,
92
+ result.url,
93
+ excerpts
94
+ ].filter(Boolean).join("\n"));
95
+ }
96
+ return truncateStringForTokenEstimate(parts.join("\n\n"), MAX_WEB_SEARCH_TOKENS);
97
+ }
98
+ });
99
+ }
100
+ /**
101
+ * Wraps the @mastra/parallel extract tool with Mastra Code's standard tool id,
102
+ * markdown string output, and token truncation.
103
+ */
104
+ async function createParallelWebExtractTool() {
105
+ const { createParallelExtractTool } = await import("@mastra/parallel");
106
+ const parallelExtractTool = createParallelExtractTool();
107
+ return createTool({
108
+ id: "web-extract",
109
+ description: parallelExtractTool.description,
110
+ inputSchema: parallelExtractTool.inputSchema,
111
+ execute: async (input, context) => {
112
+ const output = requireParallelOutput(await parallelExtractTool.execute(input, context), "extract");
113
+ const parts = [];
114
+ for (const result of output.results) {
115
+ const content = result.fullContent || (result.excerpts || []).filter(Boolean).join("\n");
116
+ parts.push([`## ${result.url}`, content].filter(Boolean).join("\n"));
117
+ }
118
+ for (const error of output.errors) {
119
+ const status = error.httpStatusCode ? ` (${error.httpStatusCode})` : "";
120
+ parts.push([
121
+ `## ${error.url}`,
122
+ `Error: ${error.errorType}${status}`,
123
+ error.content
124
+ ].filter(Boolean).join("\n"));
125
+ }
126
+ return truncateStringForTokenEstimate(parts.join("\n\n"), MAX_WEB_EXTRACT_TOKENS);
127
+ }
128
+ });
129
+ }
130
+ /**
131
+ * Resolve which model-independent web provider to use. An explicit user
132
+ * preference wins while its API key is configured; otherwise `auto` picks the
133
+ * first configured provider key (Tavily, then Parallel).
134
+ */
135
+ function resolveWebSearchProvider(preference = "auto") {
136
+ if (preference === "tavily" && hasTavilyKey()) return "tavily";
137
+ if (preference === "parallel" && hasParallelKey()) return "parallel";
138
+ if (hasTavilyKey()) return "tavily";
139
+ if (hasParallelKey()) return "parallel";
140
+ }
141
+ /**
142
+ * Create the configured model-independent web tools for the provider selected
143
+ * via the `webSearchProvider` preference (set in the TUI settings panel).
144
+ * Returns `undefined` synchronously when no provider key is configured, so the
145
+ * provider SDK (Tavily pulls in tiktoken, ~15 MB) only loads when one is.
146
+ */
147
+ function createConfiguredWebTools() {
148
+ const provider = resolveWebSearchProvider(loadSettings().preferences.webSearchProvider);
149
+ if (provider === "parallel") return loadWebTools(createParallelWebSearchTool, createParallelWebExtractTool);
150
+ if (provider === "tavily") return loadWebTools(createWebSearchTool, createWebExtractTool);
151
+ }
152
+ async function loadWebTools(createSearch, createExtract) {
153
+ return {
154
+ web_search: await createSearch(),
155
+ web_extract: await createExtract()
156
+ };
157
+ }
158
+ export { createConfiguredWebTools, createParallelWebExtractTool, createParallelWebSearchTool, createWebExtractTool, createWebSearchTool, hasParallelKey, hasTavilyKey, resolveWebSearchProvider };
@@ -0,0 +1,7 @@
1
+ export declare const createWorkflowTool: import("@mastra/core/tools").Tool<{
2
+ request: string;
3
+ }, {
4
+ summary: string;
5
+ workflowId?: string | undefined;
6
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "create-workflow", unknown>;
7
+ //# sourceMappingURL=create-workflow.d.ts.map
@@ -0,0 +1,82 @@
1
+ import { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, RequestContext } from "@mastra/core/request-context";
2
+ import { createTool } from "@mastra/core/tools";
3
+ import { z } from "zod";
4
+ // src/tools/workflows/create-workflow.ts
5
+ /**
6
+ * Coerce an unknown thrown value into a readable string. Sub-agent tool errors
7
+ * come through the stream in various shapes (Error, plain object, string) —
8
+ * normalise so the parent tool's error message is always useful.
9
+ */
10
+ function stringifyError(err) {
11
+ if (err instanceof Error) return err.message;
12
+ if (typeof err === "string") return err;
13
+ try {
14
+ return JSON.stringify(err) ?? String(err);
15
+ } catch {
16
+ return String(err);
17
+ }
18
+ }
19
+ const createWorkflowTool = createTool({
20
+ id: "create-workflow",
21
+ description: "Build and save a Dynamic Workflow on behalf of the user. Pass the user request verbatim — a focused sub-agent handles discovery, construction, and persistence, then returns a summary. Use this whenever the user asks to \"build a workflow\", \"compose a workflow\", or similar. Do NOT try to construct workflows inline yourself.",
22
+ inputSchema: z.object({ request: z.string().describe("The user request, verbatim — do not paraphrase or summarise.") }),
23
+ outputSchema: z.object({
24
+ summary: z.string().describe("Natural-language summary of what the sub-agent built. Relay this to the user."),
25
+ workflowId: z.string().optional().describe("The id of the saved workflow, if save-workflow returned ok.")
26
+ }),
27
+ execute: async ({ request }, { mastra, requestContext }) => {
28
+ if (!mastra) throw new Error("create-workflow requires a Mastra context.");
29
+ const builder = mastra.getAgent("workflow-builder");
30
+ if (!builder) throw new Error("The \"workflow-builder\" sub-agent is not registered on this Mastra instance. Cannot build workflows.");
31
+ const builderRequestContext = requestContext ? new RequestContext(requestContext.entries()) : void 0;
32
+ builderRequestContext?.delete(MASTRA_THREAD_ID_KEY);
33
+ builderRequestContext?.delete(MASTRA_RESOURCE_ID_KEY);
34
+ const stream = await builder.stream(request, { requestContext: builderRequestContext });
35
+ let workflowId;
36
+ let saveAttempted = false;
37
+ let saveSucceeded = false;
38
+ const toolErrors = [];
39
+ const reader = stream.fullStream.getReader();
40
+ let streamCompleted = false;
41
+ try {
42
+ while (true) {
43
+ const { value, done } = await reader.read();
44
+ if (done) {
45
+ streamCompleted = true;
46
+ break;
47
+ }
48
+ if (value?.type === "tool-call" && value.payload?.toolName === "save-workflow") saveAttempted = true;
49
+ if (value?.type === "tool-result" && value.payload?.toolName === "save-workflow") {
50
+ const result = value.payload.result;
51
+ if (result && result.ok === true && typeof result.id === "string") {
52
+ workflowId = result.id;
53
+ saveSucceeded = true;
54
+ }
55
+ }
56
+ if (value?.type === "tool-error" && typeof value.payload?.toolName === "string") toolErrors.push({
57
+ toolName: value.payload.toolName,
58
+ error: stringifyError(value.payload.error)
59
+ });
60
+ }
61
+ } finally {
62
+ if (!streamCompleted) await reader.cancel().catch(() => void 0);
63
+ reader.releaseLock();
64
+ }
65
+ const summary = await stream.text;
66
+ const saveErrors = toolErrors.filter((e) => e.toolName === "save-workflow");
67
+ if (saveErrors.length > 0 && !saveSucceeded) throw new Error(`create-workflow failed: save-workflow threw ${saveErrors.length} error(s):\n- ${saveErrors.map((e) => e.error).join("\n- ")}\n\nSub-agent summary (unreliable, save did not succeed):\n${summary}`);
68
+ if (!saveAttempted) {
69
+ const otherErrors = toolErrors.length ? `\n\nOther sub-agent tool errors:\n- ${toolErrors.map((e) => `${e.toolName}: ${e.error}`).join("\n- ")}` : "";
70
+ throw new Error(`create-workflow failed: the workflow-builder sub-agent never called save-workflow. No workflow was persisted.${otherErrors}\n\nSub-agent summary:\n${summary}`);
71
+ }
72
+ if (!saveSucceeded) {
73
+ const otherErrors = toolErrors.length ? `\n\nSub-agent tool errors:\n- ${toolErrors.map((e) => `${e.toolName}: ${e.error}`).join("\n- ")}` : "";
74
+ throw new Error(`create-workflow failed: save-workflow was called but did not return { ok: true }.${otherErrors}\n\nSub-agent summary:\n${summary}`);
75
+ }
76
+ return {
77
+ summary,
78
+ workflowId
79
+ };
80
+ }
81
+ });
82
+ export { createWorkflowTool };
@@ -0,0 +1,7 @@
1
+ export declare const deleteWorkflowTool: import("@mastra/core/tools").Tool<{
2
+ id: string;
3
+ }, {
4
+ ok: true;
5
+ id: string;
6
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "delete-workflow", unknown>;
7
+ //# sourceMappingURL=delete-workflow.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { deleteWorkflow } from "../../workflows/service.js";
2
+ import { createTool } from "@mastra/core/tools";
3
+ import { z } from "zod";
4
+ // src/tools/workflows/delete-workflow.ts
5
+ const deleteWorkflowTool = createTool({
6
+ id: "delete-workflow",
7
+ description: "Remove a saved workflow from storage and unregister the live in-process Workflow instance. Idempotent. Subsequent save-workflow calls with the same id re-register cleanly.",
8
+ inputSchema: z.object({ id: z.string().describe("The workflow id to delete.") }),
9
+ outputSchema: z.object({
10
+ ok: z.literal(true),
11
+ id: z.string()
12
+ }),
13
+ execute: async ({ id }, { mastra }) => {
14
+ if (!mastra) throw new Error("delete-workflow requires a Mastra context.");
15
+ return deleteWorkflow(mastra, id);
16
+ }
17
+ });
18
+ export { deleteWorkflowTool };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Sub-invocations launched from a parent chat turn (workflow agent steps,
3
+ * sub-agent tool calls) must run under a fresh isolated Mastra memory scope
4
+ * so they don't:
5
+ *
6
+ * - write their prompts/responses into the parent chat thread's history, or
7
+ * - contend with the parent turn's memory-dependent processors
8
+ * (observational-memory, task-state, working-memory-state).
9
+ *
10
+ * `withEphemeralMemory` copies the caller's request context into a child,
11
+ * replaces its MastraMemory with a fresh thread id and inherited resource id,
12
+ * then passes that isolated child to `fn`. The parent context is never mutated,
13
+ * so concurrent sub-invocations cannot overwrite or restore each other's
14
+ * memory values. Isolation writes the ephemeral ids instead of scrubbing them:
15
+ * inner agent invocations resolve their thread/resource via those reserved
16
+ * keys, and leaving them unset causes downstream storage saves to throw
17
+ * "Thread ID is required".
18
+ *
19
+ * Callers can override the ephemeral thread id (e.g. for tests) via
20
+ * `options.threadId`.
21
+ */
22
+ import { RequestContext } from '@mastra/core/request-context';
23
+ interface EphemeralMemoryOptions {
24
+ threadId?: string;
25
+ }
26
+ export declare function withEphemeralMemory<T>(requestContext: RequestContext | undefined, fn: (requestContext: RequestContext | undefined) => Promise<T>, options?: EphemeralMemoryOptions): Promise<T>;
27
+ export {};
28
+ //# sourceMappingURL=ephemeral-memory.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { MASTRA_RESOURCE_ID_KEY, MASTRA_THREAD_ID_KEY, RequestContext } from "@mastra/core/request-context";
2
+ // src/tools/workflows/ephemeral-memory.ts
3
+ /**
4
+ * Sub-invocations launched from a parent chat turn (workflow agent steps,
5
+ * sub-agent tool calls) must run under a fresh isolated Mastra memory scope
6
+ * so they don't:
7
+ *
8
+ * - write their prompts/responses into the parent chat thread's history, or
9
+ * - contend with the parent turn's memory-dependent processors
10
+ * (observational-memory, task-state, working-memory-state).
11
+ *
12
+ * `withEphemeralMemory` copies the caller's request context into a child,
13
+ * replaces its MastraMemory with a fresh thread id and inherited resource id,
14
+ * then passes that isolated child to `fn`. The parent context is never mutated,
15
+ * so concurrent sub-invocations cannot overwrite or restore each other's
16
+ * memory values. Isolation writes the ephemeral ids instead of scrubbing them:
17
+ * inner agent invocations resolve their thread/resource via those reserved
18
+ * keys, and leaving them unset causes downstream storage saves to throw
19
+ * "Thread ID is required".
20
+ *
21
+ * Callers can override the ephemeral thread id (e.g. for tests) via
22
+ * `options.threadId`.
23
+ */
24
+ async function withEphemeralMemory(requestContext, fn, options = {}) {
25
+ if (!requestContext) return fn(void 0);
26
+ const childRequestContext = new RequestContext(requestContext.entries());
27
+ const mastraMemory = requestContext.get("MastraMemory");
28
+ const resourceId = requestContext.get(MASTRA_RESOURCE_ID_KEY);
29
+ const ephemeralThreadId = options.threadId ?? globalThis.crypto.randomUUID();
30
+ const parentResourceId = mastraMemory?.resourceId ?? resourceId ?? "";
31
+ childRequestContext.set("MastraMemory", {
32
+ thread: { id: ephemeralThreadId },
33
+ resourceId: parentResourceId,
34
+ memoryConfig: void 0
35
+ });
36
+ childRequestContext.set(MASTRA_THREAD_ID_KEY, ephemeralThreadId);
37
+ if (parentResourceId) childRequestContext.set(MASTRA_RESOURCE_ID_KEY, parentResourceId);
38
+ else childRequestContext.delete(MASTRA_RESOURCE_ID_KEY);
39
+ return fn(childRequestContext);
40
+ }
41
+ export { withEphemeralMemory };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Extract a JSON Schema from a Mastra tool's schema field. Tools created via
3
+ * `createTool({...})` wrap their Zod schemas with `toStandardSchema`, exposing
4
+ * `['~standard'].jsonSchema` as a `{ input(opts), output(opts) }` converter
5
+ * (see packages/schema-compat/src/standard-schema/adapters/zod-v3.ts:110-119).
6
+ * `direction` selects which side — pass 'input' for inputSchema, 'output' for
7
+ * outputSchema. Returns undefined if the schema is missing or not
8
+ * standard-schema-compliant — the workflow-builder agent then knows the tool's
9
+ * shape is opaque and must reshape via mapping.
10
+ */
11
+ export declare function extractJsonSchema(maybeSchema: unknown, direction: 'input' | 'output'): unknown | undefined;
12
+ //# sourceMappingURL=extract-json-schema.d.ts.map
@@ -0,0 +1,19 @@
1
+ // src/tools/workflows/extract-json-schema.ts
2
+ /**
3
+ * Extract a JSON Schema from a Mastra tool's schema field. Tools created via
4
+ * `createTool({...})` wrap their Zod schemas with `toStandardSchema`, exposing
5
+ * `['~standard'].jsonSchema` as a `{ input(opts), output(opts) }` converter
6
+ * (see packages/schema-compat/src/standard-schema/adapters/zod-v3.ts:110-119).
7
+ * `direction` selects which side — pass 'input' for inputSchema, 'output' for
8
+ * outputSchema. Returns undefined if the schema is missing or not
9
+ * standard-schema-compliant — the workflow-builder agent then knows the tool's
10
+ * shape is opaque and must reshape via mapping.
11
+ */
12
+ function extractJsonSchema(maybeSchema, direction) {
13
+ try {
14
+ return (maybeSchema?.["~standard"]?.jsonSchema)?.[direction]?.({ target: "draft-2020-12" });
15
+ } catch {
16
+ return;
17
+ }
18
+ }
19
+ export { extractJsonSchema };
@@ -0,0 +1,11 @@
1
+ export declare const getWorkflowTool: import("@mastra/core/tools").Tool<{
2
+ id: string;
3
+ }, {
4
+ id: string;
5
+ description?: string | undefined;
6
+ status: "active" | "archived";
7
+ inputSchema?: any;
8
+ outputSchema?: any;
9
+ graph?: any[] | undefined;
10
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "get-workflow", unknown>;
11
+ //# sourceMappingURL=get-workflow.d.ts.map
@@ -0,0 +1,31 @@
1
+ import { getWorkflow } from "../../workflows/service.js";
2
+ import { createTool } from "@mastra/core/tools";
3
+ import { z } from "zod";
4
+ // src/tools/workflows/get-workflow.ts
5
+ const getWorkflowTool = createTool({
6
+ id: "get-workflow",
7
+ description: "Return the full stored definition of a workflow (input/output schemas + the step graph).",
8
+ inputSchema: z.object({ id: z.string().describe("The workflow id.") }),
9
+ outputSchema: z.object({
10
+ id: z.string(),
11
+ description: z.string().optional(),
12
+ status: z.enum(["active", "archived"]),
13
+ inputSchema: z.any().optional(),
14
+ outputSchema: z.any().optional(),
15
+ graph: z.array(z.any()).optional()
16
+ }),
17
+ execute: async ({ id }, { mastra }) => {
18
+ if (!mastra) throw new Error("get-workflow requires a Mastra context.");
19
+ const def = await getWorkflow(mastra, id);
20
+ if (!def) throw new Error(`No workflow with id "${id}".`);
21
+ return {
22
+ id: def.id,
23
+ description: def.description,
24
+ status: def.status,
25
+ inputSchema: def.inputSchema,
26
+ outputSchema: def.outputSchema,
27
+ graph: def.graph
28
+ };
29
+ }
30
+ });
31
+ export { getWorkflowTool };
@@ -0,0 +1,8 @@
1
+ export declare const listAvailableAgentsTool: import("@mastra/core/tools").Tool<Record<string, never>, {
2
+ agents: {
3
+ id: string;
4
+ description?: string | undefined;
5
+ outputShape: string;
6
+ }[];
7
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "list-available-agents", unknown>;
8
+ //# sourceMappingURL=list-available-agents.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { createTool } from "@mastra/core/tools";
2
+ import { z } from "zod";
3
+ // src/tools/workflows/list-available-agents.ts
4
+ /**
5
+ * Sub-agent tool: list agents the workflow-builder can reference in agent-step
6
+ * entries of a Dynamic Workflow graph. Read-only.
7
+ */
8
+ /** Self / management tools the workflow-builder shouldn't recursively try to compose. */
9
+ const WORKFLOW_BUILDER_NOISE_AGENTS = /* @__PURE__ */ new Set(["workflow-builder"]);
10
+ const listAvailableAgentsTool = createTool({
11
+ id: "list-available-agents",
12
+ description: "Returns the agents currently registered on the Mastra instance. The agent ids returned here are the only valid values you can put in `{ type: \"agent\", agentId }` graph entries. `outputShape` describes the default text output; an entry-level `outputSchema` replaces that default with structured output.",
13
+ inputSchema: z.object({}),
14
+ outputSchema: z.object({ agents: z.array(z.object({
15
+ id: z.string(),
16
+ description: z.string().optional(),
17
+ outputShape: z.string()
18
+ })) }),
19
+ execute: async (_input, { mastra }) => {
20
+ if (!mastra) throw new Error("list-available-agents requires a Mastra context.");
21
+ const all = mastra.listAgents?.() ?? {};
22
+ return { agents: Object.entries(all).filter(([id]) => !WORKFLOW_BUILDER_NOISE_AGENTS.has(id)).map(([id, a]) => ({
23
+ id,
24
+ description: a?.description,
25
+ outputShape: "Default: { text: string }. An entry-level outputSchema produces that schema instead."
26
+ })) };
27
+ }
28
+ });
29
+ export { listAvailableAgentsTool };
@@ -0,0 +1,19 @@
1
+ export declare const listAvailableClassifiersTool: import("@mastra/core/tools").Tool<Record<string, never>, {
2
+ classifiers: {
3
+ id: string;
4
+ questions?: {
5
+ id: string;
6
+ type: "boolean" | "choice" | "score";
7
+ instructions?: any;
8
+ choices?: string[] | undefined;
9
+ criteria?: any;
10
+ answerPath: string;
11
+ routingPath: string;
12
+ }[] | undefined;
13
+ outputPaths: {
14
+ answers: string;
15
+ usage: string;
16
+ };
17
+ }[];
18
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "list-available-classifiers", unknown>;
19
+ //# sourceMappingURL=list-available-classifiers.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { createTool } from "@mastra/core/tools";
2
+ import { z } from "zod";
3
+ // src/tools/workflows/list-available-classifiers.ts
4
+ function describeQuestions(questions) {
5
+ if (!questions) return void 0;
6
+ return Object.entries(questions).map(([id, question]) => ({
7
+ id,
8
+ type: question.type,
9
+ instructions: question.instructions,
10
+ choices: question.type === "choice" ? Object.keys(question.criteria) : void 0,
11
+ criteria: question.criteria,
12
+ answerPath: `inputData.answers.${id}`,
13
+ routingPath: `inputData.answers.${id}.${question.type === "choice" ? "choice" : question.type === "score" ? "score" : "probability"}`
14
+ }));
15
+ }
16
+ const listAvailableClassifiersTool = createTool({
17
+ id: "list-available-classifiers",
18
+ description: "Returns configured classifiers registered on the Mastra instance. The ids returned here are the only valid values for `{ type: \"classifier\", classifierId }`. Each row includes question metadata and stable output paths for routing with conditional entries.",
19
+ inputSchema: z.object({}),
20
+ outputSchema: z.object({ classifiers: z.array(z.object({
21
+ id: z.string(),
22
+ questions: z.array(z.object({
23
+ id: z.string(),
24
+ type: z.enum([
25
+ "choice",
26
+ "score",
27
+ "boolean"
28
+ ]),
29
+ instructions: z.any().optional(),
30
+ choices: z.array(z.string()).optional(),
31
+ criteria: z.any().optional(),
32
+ answerPath: z.string(),
33
+ routingPath: z.string()
34
+ })).optional(),
35
+ outputPaths: z.object({
36
+ answers: z.string(),
37
+ usage: z.string()
38
+ })
39
+ })) }),
40
+ execute: async (_input, { mastra }) => {
41
+ if (!mastra) throw new Error("list-available-classifiers requires a Mastra context.");
42
+ const all = mastra.listClassifiers?.() ?? {};
43
+ return { classifiers: Object.entries(all).filter(([, classifier]) => classifier.questions !== void 0).map(([id, classifier]) => ({
44
+ id,
45
+ questions: describeQuestions(classifier.questions),
46
+ outputPaths: {
47
+ answers: "inputData.answers.<question>",
48
+ usage: "inputData.usage"
49
+ }
50
+ })) };
51
+ }
52
+ });
53
+ export { listAvailableClassifiersTool };
@@ -0,0 +1,9 @@
1
+ export declare const listAvailableToolsTool: import("@mastra/core/tools").Tool<Record<string, never>, {
2
+ tools: {
3
+ id: string;
4
+ description?: string | undefined;
5
+ inputSchema?: any;
6
+ outputSchema?: any;
7
+ }[];
8
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "list-available-tools", unknown>;
9
+ //# sourceMappingURL=list-available-tools.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { extractJsonSchema } from "./extract-json-schema.js";
2
+ import { WORKFLOW_BUILDER_NOISE_TOOL_IDS } from "./tool-ids.js";
3
+ import { createTool } from "@mastra/core/tools";
4
+ import { z } from "zod";
5
+ // src/tools/workflows/list-available-tools.ts
6
+ /**
7
+ * Sub-agent tool: list tools the workflow-builder can reference in tool-step
8
+ * entries of a Dynamic Workflow graph. Returns JSON Schema for inputs/outputs
9
+ * so the LLM has ground truth instead of guessing.
10
+ */
11
+ /** Authoring and management tools are not valid workflow building blocks. */
12
+ const WORKFLOW_BUILDER_NOISE_TOOLS = new Set(WORKFLOW_BUILDER_NOISE_TOOL_IDS);
13
+ const listAvailableToolsTool = createTool({
14
+ id: "list-available-tools",
15
+ description: "Returns the tools currently registered on the Mastra instance. The tool ids returned here are the only valid values you can put in `{ type: \"tool\", toolId }` graph entries. Each row includes `inputSchema` and `outputSchema` as JSON Schema — read them to know what fields the tool accepts and emits; never invent field names.",
16
+ inputSchema: z.object({}),
17
+ outputSchema: z.object({ tools: z.array(z.object({
18
+ id: z.string(),
19
+ description: z.string().optional(),
20
+ inputSchema: z.any().optional(),
21
+ outputSchema: z.any().optional()
22
+ })) }),
23
+ execute: async (_input, { mastra }) => {
24
+ if (!mastra) throw new Error("list-available-tools requires a Mastra context.");
25
+ const all = mastra.listTools?.() ?? {};
26
+ return { tools: Object.entries(all).filter(([id]) => !WORKFLOW_BUILDER_NOISE_TOOLS.has(id)).map(([id, t]) => {
27
+ const tool = t;
28
+ return {
29
+ id,
30
+ description: tool?.description,
31
+ inputSchema: extractJsonSchema(tool?.inputSchema, "input"),
32
+ outputSchema: extractJsonSchema(tool?.outputSchema, "output")
33
+ };
34
+ }) };
35
+ }
36
+ });
37
+ export { listAvailableToolsTool };
@@ -0,0 +1,9 @@
1
+ export declare const listAvailableWorkflowsTool: import("@mastra/core/tools").Tool<Record<string, never>, {
2
+ workflows: {
3
+ id: string;
4
+ description?: string | undefined;
5
+ inputSchema?: any;
6
+ outputSchema?: any;
7
+ }[];
8
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "list-available-workflows", unknown>;
9
+ //# sourceMappingURL=list-available-workflows.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { extractJsonSchema } from "./extract-json-schema.js";
2
+ import { createTool } from "@mastra/core/tools";
3
+ import { z } from "zod";
4
+ // src/tools/workflows/list-available-workflows.ts
5
+ const listAvailableWorkflowsTool = createTool({
6
+ id: "list-available-workflows",
7
+ description: "Returns the workflows currently registered on the Mastra instance (both code-defined and dynamic). The ids returned here are the only valid values you can put in `{ type: \"workflow\", workflowId }` graph entries. Each row includes `inputSchema` and `outputSchema` as JSON Schema — read them to know what shape the nested workflow expects and produces; never invent field names.",
8
+ inputSchema: z.object({}),
9
+ outputSchema: z.object({ workflows: z.array(z.object({
10
+ id: z.string(),
11
+ description: z.string().optional(),
12
+ inputSchema: z.any().optional(),
13
+ outputSchema: z.any().optional()
14
+ })) }),
15
+ execute: async (_input, { mastra }) => {
16
+ if (!mastra) throw new Error("list-available-workflows requires a Mastra context.");
17
+ const all = mastra.listWorkflows?.() ?? {};
18
+ return { workflows: Object.entries(all).map(([id, wf]) => {
19
+ const w = wf;
20
+ return {
21
+ id,
22
+ description: w?.description,
23
+ inputSchema: extractJsonSchema(w?.inputSchema, "input"),
24
+ outputSchema: extractJsonSchema(w?.outputSchema, "output")
25
+ };
26
+ }) };
27
+ }
28
+ });
29
+ export { listAvailableWorkflowsTool };
@@ -0,0 +1,9 @@
1
+ export declare const listWorkflowsTool: import("@mastra/core/tools").Tool<Record<string, never>, {
2
+ workflows: {
3
+ id: string;
4
+ description?: string | undefined;
5
+ status: "active" | "archived";
6
+ }[];
7
+ total: number;
8
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "list-workflows", unknown>;
9
+ //# sourceMappingURL=list-workflows.d.ts.map