@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,537 @@
1
+ import type { Agent } from '@mastra/core/agent';
2
+ import { AgentController } from '@mastra/core/agent-controller';
3
+ import type { IntervalHandler, AgentControllerConfig, AgentControllerMode, AgentControllerSubagent, BuiltinToolId, Session } from '@mastra/core/agent-controller';
4
+ import { createCodingAgent } from '@mastra/core/coding-agent';
5
+ import type { PubSub } from '@mastra/core/events';
6
+ import { Knowledge } from '@mastra/core/knowledge';
7
+ import { Mastra } from '@mastra/core/mastra';
8
+ import type { InputProcessor, OutputProcessor } from '@mastra/core/processors';
9
+ import { RequestContext } from '@mastra/core/request-context';
10
+ import type { ApiRoute } from '@mastra/core/server';
11
+ import { MastraCompositeStore } from '@mastra/core/storage';
12
+ import type { MastraEmbeddingOptions, MastraVector } from '@mastra/core/vector';
13
+ import { GithubSignals } from '@mastra/github-signals';
14
+ import { Observability } from '@mastra/observability';
15
+ import type { AgentConnectionsSignalProviderOptions } from './agent-connections/signal-provider.js';
16
+ import type { MemoryEmbedder } from './agents/memory.js';
17
+ import { resolveModel } from './agents/model.js';
18
+ import type { PostToolObserver, ToolLike } from './agents/tools.js';
19
+ import { AuthStorage } from './auth/storage.js';
20
+ import { HookManager } from './hooks/index.js';
21
+ import type { McpServerConfig } from './mcp/index.js';
22
+ import { loadSettings } from './onboarding/settings.js';
23
+ import { PluginManager } from './plugins/manager.js';
24
+ import { ThreadScheduler } from './schedules/index.js';
25
+ import type { MastraCodeState } from './schema.js';
26
+ import type { ThinkingLevelSetting } from './thinking.js';
27
+ import type { StorageConfig } from './utils/project.js';
28
+ import type { StorageMaintenance } from './utils/storage-maintenance.js';
29
+ export interface MastraCodeConfig {
30
+ /** Working directory for project detection. Default: process.cwd() */
31
+ cwd?: string;
32
+ /** Home directory for global config discovery. Default: os.homedir() */
33
+ homeDir?: string;
34
+ /**
35
+ * Override modes (model IDs, colors, which modes exist). Default: build/plan/fast.
36
+ * `false` runs every session as the single Build agent with no mode switching:
37
+ * threads saved in another mode reopen as Build, and per-mode thinking defaults never apply.
38
+ */
39
+ modes?: AgentControllerMode[] | false;
40
+ /**
41
+ * Subagent definitions. Default: none. Pass `[...builtinSubagents]` to enable the
42
+ * explore/plan/execute subagents, or your own definitions.
43
+ */
44
+ subagents?: AgentControllerSubagent[];
45
+ /** Extra tools merged into the dynamic tool set. Can be a static record or a (sync or async) function that receives requestContext. */
46
+ extraTools?: Record<string, ToolLike | undefined> | ((ctx: {
47
+ requestContext: RequestContext;
48
+ }) => Record<string, ToolLike | undefined> | Promise<Record<string, ToolLike | undefined>>);
49
+ /** Observe completed tool calls without replacing or modifying the built-in tool implementation. */
50
+ postToolObserver?: PostToolObserver;
51
+ /**
52
+ * Stateless input processor instances prepended before Mastra Code's mandatory processors,
53
+ * or a per-request resolver for processors that depend on trusted request context.
54
+ * Embedders may extend processing but cannot replace built-in safety and compatibility policy.
55
+ */
56
+ inputProcessors?: InputProcessor[] | ((args: {
57
+ requestContext: RequestContext;
58
+ }) => InputProcessor[] | Promise<InputProcessor[]>);
59
+ /**
60
+ * Output processor instances appended after Mastra Code's built-in output processors,
61
+ * or a per-request resolver. They run before the memory layers the Agent appends,
62
+ * so changes they make to response messages are persisted.
63
+ */
64
+ outputProcessors?: OutputProcessor[] | ((args: {
65
+ requestContext: RequestContext;
66
+ }) => OutputProcessor[] | Promise<OutputProcessor[]>);
67
+ /** Tools removed from the dynamic tool set before exposure to the model */
68
+ disabledTools?: string[];
69
+ /**
70
+ * Agent controller built-in tools (e.g. `submit_plan`, `ask_user`) removed from
71
+ * every session. Unlike `disabledTools`, which filters Mastra Code's dynamic
72
+ * tools, this is forwarded to the AgentController. Prompt guidance for a
73
+ * disabled built-in is omitted so the model is never told to call it.
74
+ */
75
+ disableBuiltinTools?: BuiltinToolId[];
76
+ /**
77
+ * Workspace-relative directory agents write plan files into, overriding the
78
+ * per-session default (`.mastracode/plans`, or `.artifacts/plans` for Factory
79
+ * project sessions). Prompts and the plan-mode write guard of the default
80
+ * workspace use it; a custom `workspace` must apply its own guard.
81
+ */
82
+ plansDir?: string;
83
+ /**
84
+ * Custom storage config instead of auto-detected default, or a pre-built
85
+ * store instance. An instance is used as-is: no connection test and no
86
+ * LibSQL fallback — if the injected store fails, that's a hard error.
87
+ */
88
+ storage?: StorageConfig | MastraCompositeStore;
89
+ /** Scorers for the code agent. None run by default. */
90
+ scorers?: Parameters<typeof createCodingAgent>[0]['scorers'];
91
+ /** Disable persistence of rich scorer results. Default: true. */
92
+ disableScoreStorage?: boolean;
93
+ /** Backend for an injected custom storage instance. Inferred for LibSQLStore and PostgresStore. */
94
+ storageBackend?: 'libsql' | 'pg';
95
+ /** Pre-built vector store instance for recall search. Skips the default vector store creation. */
96
+ vector?: MastraVector;
97
+ /**
98
+ * Embedder for recall vectors: a `provider/model` router string (e.g.
99
+ * `'openai/text-embedding-3-small'`) or an AI SDK embedding model. Used only when a vector store
100
+ * is set. Omitted → local `fastembed.small` (bge-small, 384 dimensions).
101
+ */
102
+ embedder?: MemoryEmbedder;
103
+ /** Options passed to every embedding call, e.g. provider options or headers. */
104
+ embedderOptions?: MastraEmbeddingOptions;
105
+ /**
106
+ * Knowledge for the code agent, attached like an Agent's `knowledge`. Unset, it follows the
107
+ * `signals.experimentalKnowledge` global setting (off; on means `true`). `false` keeps it off
108
+ * whatever the setting. `true` uses a Knowledge on Mastra Code's own storage with the read, write and pin tools, writing to a
109
+ * shared `org:local` scope (the TUI's `/settings` Knowledge toggle). A `Knowledge` instance is
110
+ * attached as configured and registered on the mounted Mastra under its `id`; pass
111
+ * `{ key, instance }` to register it under another key.
112
+ */
113
+ knowledge?: false | true | Knowledge | {
114
+ key: string;
115
+ instance: Knowledge;
116
+ };
117
+ /**
118
+ * The scopes every Knowledge run acts with, like an Agent's `scopes`, such as `'org:acme'`. What a
119
+ * run may do on each comes from the Knowledge instance's scope declarations. Factory sessions
120
+ * add their own `org:` and `project:` scopes unless these name an `org:`; then they act with these
121
+ * alone, and a `project:`, `resource:` or `thread:` scope here is refused.
122
+ */
123
+ scopes?: string[];
124
+ /** Observational memory scope. Default: auto-detected from env/config files, falls back to 'thread' */
125
+ omScope?: 'thread' | 'resource';
126
+ /** Path to a custom settings.json file. Default: global settings */
127
+ settingsPath?: string;
128
+ /** Initial state overrides (yolo, thinkingLevel, etc.) */
129
+ initialState?: Partial<MastraCodeState>;
130
+ /**
131
+ * Host-owned thinking default for a request without its own level. When set,
132
+ * it replaces the settings.json defaults (`preferences.thinkingLevel` and the
133
+ * per-mode defaults); a session's own level still wins. Called on every model
134
+ * resolution, so a changed default applies to the next request.
135
+ */
136
+ resolveDefaultThinkingLevel?: (ctx: {
137
+ requestContext: RequestContext;
138
+ }) => ThinkingLevelSetting | Promise<ThinkingLevelSetting>;
139
+ /** Create a thread during local boot when no existing thread matches. Default: true */
140
+ createInitialThread?: boolean;
141
+ /** Trusted host instructions resolved outside mutable session state. */
142
+ hostInstructions?: string | ((ctx: {
143
+ requestContext: RequestContext;
144
+ }) => string | undefined | Promise<string | undefined>);
145
+ /** Whether approving a plan starts it as a goal in this host's clients. Set false when plan approval does not start a goal (Factory). Default: true */
146
+ planApprovalStartsGoal?: boolean;
147
+ /** Commit co-author identity included in coding-agent commit guidance. Unspecified fields use core defaults. */
148
+ coAuthor?: {
149
+ name?: string;
150
+ email?: string;
151
+ };
152
+ /** Override id generation for threads/messages. Primarily useful for deterministic tests. */
153
+ idGenerator?: AgentControllerConfig<MastraCodeState>['idGenerator'];
154
+ /** Override interval handlers. Default: gateway-sync */
155
+ intervalHandlers?: IntervalHandler[];
156
+ /** Override the workspace. Default: local filesystem + local sandbox based on detected project */
157
+ workspace?: AgentControllerConfig<MastraCodeState>['workspace'];
158
+ /** Override the config directory name. Default: '.mastracode'. Replaces '.mastracode' in all project-level and global config paths (MCP, hooks, commands, database, skills, agent instructions). */
159
+ configDir?: string;
160
+ /** Programmatic MCP server configurations, merged with (and overriding) file-based configs. */
161
+ mcpServers?: Record<string, McpServerConfig>;
162
+ /** Disable MCP server discovery. Default: false */
163
+ disableMcp?: boolean;
164
+ /** Disable hooks. Default: false */
165
+ disableHooks?: boolean;
166
+ /** Skip loading cwd/.env into the process environment. Useful for multi-session hosts. */
167
+ disableEnvFile?: boolean;
168
+ /** Disable plugin discovery/loading. Default: false */
169
+ disablePlugins?: boolean;
170
+ /** Disable the polling-based GitHub signal provider even when enabled in global settings. Default: false */
171
+ disableGithubSignals?: boolean;
172
+ /**
173
+ * Skip seeding observational-memory knobs (observer/reflector models,
174
+ * thresholds, caveman mode, attachment observation) from settings.json.
175
+ * Server deployments that persist memory settings in their own database
176
+ * (the factory's `memory-settings` domain) set this so the host machine's
177
+ * TUI settings file never leaks into server sessions. Default: false.
178
+ */
179
+ disableSettingsOmSeed?: boolean;
180
+ /** Override the plugin manager. Primarily useful for tests or embedding. */
181
+ pluginManager?: PluginManager;
182
+ /**
183
+ * Override the memory instance (or dynamic factory) passed to the AgentController.
184
+ * When provided, this replaces the default `getDynamicMemory(storage, vector)` which
185
+ * uses mastracode's built-in model gateway (Anthropic OAuth, OpenAI Codex,
186
+ * custom providers, and models.dev fallback).
187
+ *
188
+ * Use this when you need to override memory model behavior completely.
189
+ */
190
+ memory?: AgentControllerConfig<MastraCodeState>['memory'] | false;
191
+ /** Browser provider for browser automation tools. When set, the agent gains access to browser tools. */
192
+ browser?: AgentControllerConfig<MastraCodeState>['browser'];
193
+ /** PubSub for signal routing. When crossProcessPubSub is true, thread locks are disabled. */
194
+ pubsub?: PubSub;
195
+ /** Use Mastra Code's built-in Unix socket PubSub for local cross-process signal routing. */
196
+ unixSocketPubSub?: boolean;
197
+ /** Marks the configured PubSub as cross-process-safe, allowing Mastra Code to skip file thread locks. */
198
+ crossProcessPubSub?: boolean;
199
+ /** Agent connection state and discovery options. */
200
+ agentConnections?: AgentConnectionsSignalProviderOptions;
201
+ /**
202
+ * Enable experimental cross-agent communication: thread ownership
203
+ * advertisement, peer discovery, and the agent connection tools. Defaults to
204
+ * the `signals.experimentalCrossAgentSignals` global setting (off). With the
205
+ * built-in Unix socket PubSub (`unixSocketPubSub`, no `pubsub` injected),
206
+ * peer discovery also reaches agents in other projects on this machine.
207
+ */
208
+ crossAgentSignals?: boolean;
209
+ /**
210
+ * Enable the experimental agent schedule tools (`schedule_create`,
211
+ * `schedule_list`, `schedule_update`, `schedule_run`), which manage the same
212
+ * process-local schedules as `/schedules`. Defaults to the
213
+ * `signals.experimentalScheduleTools` global setting (off).
214
+ */
215
+ scheduleTools?: boolean;
216
+ /**
217
+ * Prepare the request context of a wake: a run on a thread with no inbound
218
+ * request, such as a notification or cross-agent signal delivered to an idle
219
+ * thread. Hosts that resolve credentials per tenant use this to attach the
220
+ * identity that owns `resourceId` before the run starts. Called only when a
221
+ * session owns `resourceId`, whenever Mastra Code builds a wake's stream
222
+ * options.
223
+ */
224
+ prepareWakeRequestContext?: (args: {
225
+ requestContext: RequestContext;
226
+ resourceId: string;
227
+ threadId: string;
228
+ }) => void | Promise<void>;
229
+ /**
230
+ * Bring the session that owns `resourceId` online when a notification is
231
+ * delivered and no session in this process owns it (a deferred delivery
232
+ * after the session closed, a restart, another replica). Without it such a
233
+ * notification stays pending until a process whose session runs the thread
234
+ * delivers it. Create the session as its owner, or throw when the owner
235
+ * can't be resolved. When set, a delivery that still finds no owning session
236
+ * fails with that error instead of running.
237
+ */
238
+ resumeWakeSession?: (args: {
239
+ resourceId: string;
240
+ threadId: string;
241
+ }) => Promise<void>;
242
+ }
243
+ export declare function createAuthStorage(): AuthStorage;
244
+ /**
245
+ * Resolve cloud observability credentials for the MastraPlatformExporter.
246
+ * Priority: per-resource settings > MASTRACODE_* environment variables > undefined (no exporter).
247
+ *
248
+ * The env vars are deliberately namespaced `MASTRACODE_*`, not `MASTRA_*`: the
249
+ * cwd `.env` is loaded into `process.env`, so reading `MASTRA_PROJECT_ID` /
250
+ * `MASTRA_CLOUD_ACCESS_TOKEN` would export Mastra Code's own traces into
251
+ * whatever Mastra project the user happens to be working in (and crash on
252
+ * project ids the exporter rejects).
253
+ */
254
+ export declare function resolveCloudObservabilityConfig(settings: ReturnType<typeof loadSettings>, authStorage: AuthStorage, resourceId: string, env?: NodeJS.ProcessEnv): {
255
+ accessToken: string;
256
+ projectId?: string;
257
+ } | undefined;
258
+ export declare function createMastraCodeAgentController(config?: MastraCodeConfig): Promise<{
259
+ controller: AgentController<MastraCodeState>;
260
+ storage: MastraCompositeStore;
261
+ storageMaintenance: StorageMaintenance;
262
+ createKnowledgeInspector: (session: Session<MastraCodeState>, knowledgeKey?: string) => Promise<import("./knowledge-inspector.js").KnowledgeInspector | undefined>;
263
+ observability: Observability;
264
+ observabilityExports: boolean;
265
+ memory: import("@mastra/core/base").DynamicArgument<import("@mastra/core/memory").MastraMemory> | (((ctx: {
266
+ requestContext: RequestContext;
267
+ }) => Promise<import("@mastra/memory").Memory>) & {
268
+ settled: () => Promise<void>;
269
+ }) | undefined;
270
+ knowledge: Knowledge | undefined;
271
+ knowledgeKey: string;
272
+ mcpManager: import("./mcp/manager.js").McpManager | undefined;
273
+ hookManager: HookManager | undefined;
274
+ pluginManager: PluginManager | undefined;
275
+ loadedPlugins: import("./plugins/types.js").LoadedPlugin[];
276
+ pluginTools: import("./plugin.js").MastraCodePluginTools;
277
+ signalsPubSub: PubSub | undefined;
278
+ authStorage: AuthStorage;
279
+ resolveModel: typeof resolveModel;
280
+ storageWarning: string | undefined;
281
+ observabilityWarning: string | undefined;
282
+ builtinOmPacks: import("./onboarding/packs.js").OMPack[];
283
+ effectiveDefaults: Record<string, string>;
284
+ githubSignals: GithubSignals | undefined;
285
+ backgroundToolsEnabled: boolean;
286
+ backgroundCompletionEvents: import("./agents/background-completion-events.js").BackgroundCompletionEvents | undefined;
287
+ sessionId: string;
288
+ ownerId: string;
289
+ projectPath: string;
290
+ codeAgent: Agent<string, import("@mastra/core/agent").ToolsInput, undefined, any, import("@mastra/core/agent").AgentEditorConfig | undefined>;
291
+ setActiveSession: (session: Session<MastraCodeState>) => void;
292
+ /**
293
+ * Starts the signal providers contributed by plugins. Called by the
294
+ * composition layer once the controller is inited, because that is when a
295
+ * Mastra instance exists — a provider without one has no storage, and
296
+ * nothing else will hand it one: the Agent propagates Mastra only to the
297
+ * providers in its own `signals` array, which these deliberately are not in.
298
+ */
299
+ startPluginSignalProviders: () => void;
300
+ /**
301
+ * Stops every plugin-contributed signal provider and stops listening for
302
+ * plugin reloads. The inverse of `startPluginSignalProviders`, for an
303
+ * embedder that is done with this controller: a `pluginManager` shared
304
+ * across controllers (`MastraCodeConfig.pluginManager`) outlives any one of
305
+ * them, so without this its providers keep polling and its reload listener
306
+ * keeps firing for a controller that is gone.
307
+ */
308
+ stopPluginSignalProviders: () => void;
309
+ /** Process-local `/schedules` scheduler. Call `stop()` on shutdown. */
310
+ threadScheduler: ThreadScheduler;
311
+ /**
312
+ * Starts delivering the due notifications of this controller's sessions'
313
+ * resources from this process. Called by the composition layer once the
314
+ * controller is inited. A no-op when the embedder configured its own
315
+ * PubSub, whose shared dispatch schedule keeps delivering everything.
316
+ */
317
+ startNotificationDispatch: () => void;
318
+ /**
319
+ * Stops advertising every live session's threads and releases their
320
+ * ownership claims. Call first on shutdown: a claim otherwise stays held
321
+ * (and renewed) through the rest of teardown, so a restarted process cannot
322
+ * claim the thread — and peers cannot reach it — until this one exits.
323
+ */
324
+ releaseThreadClaims: () => void;
325
+ /** Stops this process's notification dispatch and releases its leases. Call on shutdown. */
326
+ stopNotificationDispatch: () => Promise<void>;
327
+ /**
328
+ * Hands Mastra to the statically configured input processors.
329
+ *
330
+ * The Agent does this itself, but only for processors configured as a
331
+ * plain array (`Array.isArray` in `__registerMastra`). This lane is a
332
+ * function so plugins can contribute to it, which takes those processors
333
+ * out of that branch — including any an embedder passed as
334
+ * `config.inputProcessors`, some of which need Mastra to work at all
335
+ * (`CostGuardProcessor` reads observability storage there). Doing it here
336
+ * keeps that unchanged.
337
+ *
338
+ * Plugin processors are deliberately not included: they come and go with
339
+ * their plugin, and the registry keeps the first instance registered under
340
+ * an id forever, which would leave a retired instance behind. Plugins
341
+ * reach Mastra through `getController()` on the plugin context instead.
342
+ */
343
+ registerConfiguredProcessorsWithMastra: () => void;
344
+ }>;
345
+ /**
346
+ * Result of {@link createMastraCodeAgentController}: every shared resource plus the
347
+ * inert AgentController, ready to be either booted locally or mounted on a server
348
+ * Mastra.
349
+ */
350
+ export type MastraCodeAgentController = Awaited<ReturnType<typeof createMastraCodeAgentController>>;
351
+ /**
352
+ * Wires the session-scoped concerns MastraCode layers on top of a Session:
353
+ * hookManager thread-id sync, GitHub PR polling for the current thread, and
354
+ * per-thread persistence of the mastracode-only `/om` settings.
355
+ *
356
+ * Used by {@link bootLocalAgentController} for the single local session. A server can
357
+ * call this for any session it mints if it wants the same background wiring.
358
+ */
359
+ export declare function wireSessionConcerns(base: Pick<MastraCodeAgentController, 'hookManager' | 'githubSignals' | 'setActiveSession'>, session: Session<MastraCodeState>): Promise<void>;
360
+ /**
361
+ * Case 3 (AgentController local + TUI/headless): build the controller, let it stand up its
362
+ * own internal Mastra via `init()`, and mint the single eager session that all
363
+ * work in this process runs through. The AgentController owns no session of its own.
364
+ */
365
+ export declare function bootLocalAgentController(config?: MastraCodeConfig): Promise<{
366
+ controller: AgentController<MastraCodeState>;
367
+ storage: MastraCompositeStore;
368
+ storageMaintenance: StorageMaintenance;
369
+ createKnowledgeInspector: (session: Session<MastraCodeState>, knowledgeKey?: string) => Promise<import("./knowledge-inspector.js").KnowledgeInspector | undefined>;
370
+ observability: Observability;
371
+ observabilityExports: boolean;
372
+ memory: import("@mastra/core/base").DynamicArgument<import("@mastra/core/memory").MastraMemory> | (((ctx: {
373
+ requestContext: RequestContext;
374
+ }) => Promise<import("@mastra/memory").Memory>) & {
375
+ settled: () => Promise<void>;
376
+ }) | undefined;
377
+ knowledge: Knowledge | undefined;
378
+ knowledgeKey: string;
379
+ mcpManager: import("./mcp/manager.js").McpManager | undefined;
380
+ hookManager: HookManager | undefined;
381
+ pluginManager: PluginManager | undefined;
382
+ loadedPlugins: import("./plugins/types.js").LoadedPlugin[];
383
+ pluginTools: import("./plugin.js").MastraCodePluginTools;
384
+ signalsPubSub: PubSub | undefined;
385
+ authStorage: AuthStorage;
386
+ resolveModel: typeof resolveModel;
387
+ storageWarning: string | undefined;
388
+ observabilityWarning: string | undefined;
389
+ builtinOmPacks: import("./onboarding/packs.js").OMPack[];
390
+ effectiveDefaults: Record<string, string>;
391
+ githubSignals: GithubSignals | undefined;
392
+ backgroundToolsEnabled: boolean;
393
+ backgroundCompletionEvents: import("./agents/background-completion-events.js").BackgroundCompletionEvents | undefined;
394
+ sessionId: string;
395
+ ownerId: string;
396
+ projectPath: string;
397
+ codeAgent: Agent<string, import("@mastra/core/agent").ToolsInput, undefined, any, import("@mastra/core/agent").AgentEditorConfig | undefined>;
398
+ setActiveSession: (session: Session<MastraCodeState>) => void;
399
+ /**
400
+ * Starts the signal providers contributed by plugins. Called by the
401
+ * composition layer once the controller is inited, because that is when a
402
+ * Mastra instance exists — a provider without one has no storage, and
403
+ * nothing else will hand it one: the Agent propagates Mastra only to the
404
+ * providers in its own `signals` array, which these deliberately are not in.
405
+ */
406
+ startPluginSignalProviders: () => void;
407
+ /**
408
+ * Stops every plugin-contributed signal provider and stops listening for
409
+ * plugin reloads. The inverse of `startPluginSignalProviders`, for an
410
+ * embedder that is done with this controller: a `pluginManager` shared
411
+ * across controllers (`MastraCodeConfig.pluginManager`) outlives any one of
412
+ * them, so without this its providers keep polling and its reload listener
413
+ * keeps firing for a controller that is gone.
414
+ */
415
+ stopPluginSignalProviders: () => void;
416
+ /** Process-local `/schedules` scheduler. Call `stop()` on shutdown. */
417
+ threadScheduler: ThreadScheduler;
418
+ /**
419
+ * Starts delivering the due notifications of this controller's sessions'
420
+ * resources from this process. Called by the composition layer once the
421
+ * controller is inited. A no-op when the embedder configured its own
422
+ * PubSub, whose shared dispatch schedule keeps delivering everything.
423
+ */
424
+ startNotificationDispatch: () => void;
425
+ /**
426
+ * Stops advertising every live session's threads and releases their
427
+ * ownership claims. Call first on shutdown: a claim otherwise stays held
428
+ * (and renewed) through the rest of teardown, so a restarted process cannot
429
+ * claim the thread — and peers cannot reach it — until this one exits.
430
+ */
431
+ releaseThreadClaims: () => void;
432
+ /** Stops this process's notification dispatch and releases its leases. Call on shutdown. */
433
+ stopNotificationDispatch: () => Promise<void>;
434
+ /**
435
+ * Hands Mastra to the statically configured input processors.
436
+ *
437
+ * The Agent does this itself, but only for processors configured as a
438
+ * plain array (`Array.isArray` in `__registerMastra`). This lane is a
439
+ * function so plugins can contribute to it, which takes those processors
440
+ * out of that branch — including any an embedder passed as
441
+ * `config.inputProcessors`, some of which need Mastra to work at all
442
+ * (`CostGuardProcessor` reads observability storage there). Doing it here
443
+ * keeps that unchanged.
444
+ *
445
+ * Plugin processors are deliberately not included: they come and go with
446
+ * their plugin, and the registry keeps the first instance registered under
447
+ * an id forever, which would leave a retired instance behind. Plugins
448
+ * reach Mastra through `getController()` on the plugin context instead.
449
+ */
450
+ registerConfiguredProcessorsWithMastra: () => void;
451
+ session: Session<MastraCodeState>;
452
+ knowledgeInspector: import("./knowledge-inspector.js").KnowledgeInspector | undefined;
453
+ knowledgeInspectorUnavailableReason: string | undefined;
454
+ }>;
455
+ /** Result of {@link mountAgentControllerOnMastra}: shared handles plus the owning Mastra. */
456
+ export type MountedMastraCode = MastraCodeAgentController & {
457
+ mastra: Mastra;
458
+ };
459
+ /**
460
+ * Cases 1 & 2 (AgentController in Server + Web/TUI): build the controller, register it on a
461
+ * server-owned Mastra, THEN init it. Registering before `init()` is what makes
462
+ * the controller inherit the server's Mastra (storage, agents, gateways) instead of
463
+ * spinning up its own internal one — there is a single shared Mastra.
464
+ *
465
+ * No eager session is minted: each client (browser or terminal) creates/resumes
466
+ * its own isolated session via `controller.createSession({ resourceId })`, so one
467
+ * server can drive many concurrent users.
468
+ *
469
+ * Pass an existing `mastra` to mount onto a Mastra that already hosts other
470
+ * primitives; otherwise a Mastra is created that owns the controller's storage so
471
+ * durability is configured in one place.
472
+ */
473
+ export declare function mountAgentControllerOnMastra(config?: MastraCodeConfig & {
474
+ mastra?: Mastra;
475
+ controllerId?: string;
476
+ buildApiRoutes?: (deps: {
477
+ controller: MountedMastraCode['controller'];
478
+ authStorage: AuthStorage;
479
+ }) => ApiRoute[];
480
+ /**
481
+ * Additional `server` config to fold onto the constructed Mastra alongside
482
+ * the assembled `apiRoutes` (e.g. `middleware`, `cors`). Used by the
483
+ * platform entry (`src/mastra/index.ts`) to own the WorkOS gate + tenant
484
+ * dispatcher + CORS on the instance the deployer generates its server from.
485
+ * Ignored when `mastra` is provided (mounting onto a caller-owned instance).
486
+ */
487
+ buildServerConfig?: (deps: {
488
+ controller: MountedMastraCode['controller'];
489
+ authStorage: AuthStorage;
490
+ }) => Omit<NonNullable<ConstructorParameters<typeof Mastra>[0]>['server'], 'apiRoutes'>;
491
+ }): Promise<MountedMastraCode>;
492
+ /**
493
+ * Assemble everything needed to construct the server-owned Mastra WITHOUT
494
+ * constructing it, so a caller (the platform entry `src/mastra/index.ts`) can
495
+ * run the `new Mastra(...)` literal in its own module. The deployer's
496
+ * `checkConfigExport` Babel plugin only marks the config valid when it finds a
497
+ * top-level `new Mastra(...)` exported as `mastra` in the ENTRY file; hiding the
498
+ * construction inside this helper would trip the "Invalid Mastra config" warning.
499
+ *
500
+ * Returns the constructor args plus a `finalize()` that runs the post-construct
501
+ * boot (`controller.init()` + `startWorkers()`). The controller is registered on
502
+ * the Mastra via the `agentControllers` arg at construction time.
503
+ */
504
+ export declare function prepareAgentControllerMount(config?: MastraCodeConfig & {
505
+ mastra?: Mastra;
506
+ controllerId?: string;
507
+ buildApiRoutes?: (deps: {
508
+ controller: MountedMastraCode['controller'];
509
+ authStorage: AuthStorage;
510
+ }) => ApiRoute[];
511
+ buildServerConfig?: (deps: {
512
+ controller: MountedMastraCode['controller'];
513
+ authStorage: AuthStorage;
514
+ }) => Omit<NonNullable<ConstructorParameters<typeof Mastra>[0]>['server'], 'apiRoutes'>;
515
+ }): Promise<{
516
+ base: Awaited<ReturnType<typeof createMastraCodeAgentController>>;
517
+ mastraArgs: NonNullable<ConstructorParameters<typeof Mastra>[0]>;
518
+ finalize: () => Promise<void>;
519
+ }>;
520
+ /**
521
+ * Back-compat alias. Historically `createMastraCode` built and booted a local
522
+ * controller with a single session; that behavior now lives in
523
+ * {@link bootLocalAgentController}. New code should call the explicit factory for its
524
+ * case: `bootLocalAgentController` (local) or {@link mountAgentControllerOnMastra} (server).
525
+ */
526
+ export declare const createMastraCode: typeof bootLocalAgentController;
527
+ export { builtinSubagents, resolveSubagentsSetting } from './agents/subagents/index.js';
528
+ export * from './knowledge-inspector.js';
529
+ export { LOCAL_KNOWLEDGE_ORG_ID } from './knowledge-scope.js';
530
+ /**
531
+ * Programmatic headless API. `runMC` runs an already-built controller/session
532
+ * (from {@link createMastraCode}) as an async-iterable run that also resolves to
533
+ * a typed result. Also available via the `mastracode/headless` subpath.
534
+ */
535
+ export { runMC, runMCCli, hasHeadlessFlag, autoApprovePolicy, denyPolicy, permissionModeToPolicy, formatHuman, formatJsonl, renderTextResult, renderJsonResult, } from './headless/index.js';
536
+ export type { RunMCOptions, RunMCResult, RunMCStatus, RunMCUsage, RunMCToolCall, RunMCToolResult, RunMCError, RunMCThreadOptions, MCRun, ResolutionPolicy, PermissionMode, } from './headless/index.js';
537
+ //# sourceMappingURL=index.d.ts.map