@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,35 @@
1
+ import type { ToolsInput } from '@mastra/core/agent';
2
+ import type { Mastra } from '@mastra/core/mastra';
3
+ import type { RequestContext } from '@mastra/core/request-context';
4
+ import { Workspace, LocalFilesystem, LocalSandbox } from '@mastra/core/workspace';
5
+ import type { SkillSource } from '@mastra/core/workspace';
6
+ export declare function buildSkillPaths(projectPath: string, configDir: string, homeDir?: string, pluginSkillPaths?: string[]): string[];
7
+ export interface WorkspaceSkillExtension {
8
+ /** Distinguishes extended workspaces from the default resolver cache. */
9
+ id: string;
10
+ /** Additional read-only skill roots prepended to normal project/global skill roots. */
11
+ paths: string[];
12
+ /** Compose the additional roots with the workspace's normal skill source. */
13
+ createSource: (fallback: SkillSource, fallbackSkillRoots: string[]) => SkillSource;
14
+ }
15
+ export declare function getDynamicWorkspace({ requestContext, mastra, skillExtension, backgroundToolsEnabled, plansDir, }: {
16
+ requestContext: RequestContext;
17
+ mastra?: Mastra;
18
+ skillExtension?: WorkspaceSkillExtension;
19
+ backgroundToolsEnabled?: boolean;
20
+ /** Host-configured plans directory the plan-mode write guard allows. */
21
+ plansDir?: string;
22
+ }): Promise<Workspace<LocalFilesystem, LocalSandbox, undefined>>;
23
+ /**
24
+ * Resolver for the agent's `goal.tools` config. Builds the request's workspace
25
+ * (same per-request resolution as the agent's own tools) and returns only the
26
+ * read-only verification subset, remapped to mastracode's tool names (`view`,
27
+ * `search_content`, etc.). Returns `undefined` when no workspace can be resolved
28
+ * (e.g. no project path), keeping the default judge text-only rather than
29
+ * throwing inside the goal step.
30
+ */
31
+ export declare function getGoalJudgeTools({ requestContext, mastra, }: {
32
+ requestContext: RequestContext;
33
+ mastra?: Mastra;
34
+ }): Promise<ToolsInput | undefined>;
35
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1,207 @@
1
+ import "../constants.js";
2
+ import { loadSettings, resolveLspSetting } from "../onboarding/settings.js";
3
+ import { isPathWithinRoot } from "../utils/path-security.js";
4
+ import { getPlansDir } from "../utils/plans.js";
5
+ import { GOAL_JUDGE_READONLY_TOOLS, createMastraCodeWorkspaceTools } from "./tool-availability.js";
6
+ import path, { dirname, join } from "path";
7
+ import fs, { existsSync } from "fs";
8
+ import os from "os";
9
+ import { fileURLToPath } from "url";
10
+ import { LocalFilesystem, LocalSandbox, Workspace, createWorkspaceTools } from "@mastra/core/workspace";
11
+ // src/agents/workspace.ts
12
+ function buildSandboxEnv() {
13
+ return {
14
+ ...process.env,
15
+ FORCE_COLOR: "1",
16
+ CLICOLOR_FORCE: "1",
17
+ TERM: process.env.TERM || "xterm-256color",
18
+ CI: "true",
19
+ NONINTERACTIVE: "1",
20
+ DEBIAN_FRONTEND: "noninteractive"
21
+ };
22
+ }
23
+ function collectSkillPaths(skillsDirs, allowedRoot) {
24
+ const paths = [];
25
+ const seen = /* @__PURE__ */ new Set();
26
+ let realAllowedRoot;
27
+ if (allowedRoot) try {
28
+ realAllowedRoot = fs.realpathSync(allowedRoot);
29
+ } catch {
30
+ return [];
31
+ }
32
+ for (const skillsDir of skillsDirs) {
33
+ const skillsDirExists = fs.existsSync(skillsDir);
34
+ if (skillsDirExists && realAllowedRoot) try {
35
+ const realSkillsDir = fs.realpathSync(skillsDir);
36
+ if (!isPathWithinRoot(realSkillsDir, realAllowedRoot)) continue;
37
+ } catch {
38
+ continue;
39
+ }
40
+ const resolved = path.resolve(skillsDir);
41
+ if (!seen.has(resolved)) {
42
+ seen.add(resolved);
43
+ paths.push(skillsDir);
44
+ }
45
+ if (!skillsDirExists) continue;
46
+ try {
47
+ const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
48
+ for (const entry of entries) if (entry.isSymbolicLink()) try {
49
+ const linkPath = path.join(skillsDir, entry.name);
50
+ const realPath = fs.realpathSync(linkPath);
51
+ if (realAllowedRoot && !isPathWithinRoot(realPath, realAllowedRoot)) continue;
52
+ if (fs.statSync(realPath).isDirectory()) {
53
+ const realParent = path.dirname(realPath);
54
+ if (realAllowedRoot && !isPathWithinRoot(realParent, realAllowedRoot)) continue;
55
+ if (!seen.has(realParent)) {
56
+ seen.add(realParent);
57
+ paths.push(realParent);
58
+ }
59
+ }
60
+ } catch {
61
+ continue;
62
+ }
63
+ } catch {}
64
+ }
65
+ return paths;
66
+ }
67
+ function buildSkillPaths(projectPath, configDir, homeDir = os.homedir(), pluginSkillPaths = []) {
68
+ const mastraCodeLocalSkillsPath = path.join(projectPath, configDir, "skills");
69
+ const claudeLocalSkillsPath = path.join(projectPath, ".claude", "skills");
70
+ const agentSkillsLocalPath = path.join(projectPath, ".agents", "skills");
71
+ const mastraCodeGlobalSkillsPath = path.join(homeDir, configDir, "skills");
72
+ const claudeGlobalSkillsPath = path.join(homeDir, ".claude", "skills");
73
+ const agentSkillsGlobalPath = path.join(homeDir, ".agents", "skills");
74
+ const paths = [
75
+ ...collectSkillPaths([
76
+ mastraCodeLocalSkillsPath,
77
+ claudeLocalSkillsPath,
78
+ agentSkillsLocalPath
79
+ ], projectPath),
80
+ ...collectSkillPaths([
81
+ mastraCodeGlobalSkillsPath,
82
+ claudeGlobalSkillsPath,
83
+ agentSkillsGlobalPath
84
+ ]),
85
+ ...pluginSkillPaths.flatMap((pluginSkillPath) => collectSkillPaths([pluginSkillPath], pluginSkillPath))
86
+ ];
87
+ const seenPaths = /* @__PURE__ */ new Set();
88
+ return paths.filter((skillPath) => {
89
+ let resolved;
90
+ try {
91
+ resolved = fs.realpathSync(skillPath);
92
+ } catch {
93
+ resolved = path.resolve(skillPath);
94
+ }
95
+ if (seenPaths.has(resolved)) return false;
96
+ seenPaths.add(resolved);
97
+ return true;
98
+ });
99
+ }
100
+ /**
101
+ * Paths the agent is always allowed to access (in addition to the project root
102
+ * and any per-thread sandboxAllowedPaths). The OS temp directory is included
103
+ * so the agent can use it as a scratchpad without requesting access every time.
104
+ */
105
+ const DEFAULT_ALLOWED_PATHS = [
106
+ os.tmpdir(),
107
+ "/tmp",
108
+ getPlansDir()
109
+ ].reduce((acc, p) => {
110
+ const resolved = path.resolve(p);
111
+ if (!acc.includes(resolved)) acc.push(resolved);
112
+ return acc;
113
+ }, []);
114
+ const WORKSPACE_ID_PREFIX = "mastra-code-workspace";
115
+ /**
116
+ * Detect the project's package runner from lock files.
117
+ * Used as a fallback packageRunner for LSP when no binary is found locally or on PATH.
118
+ */
119
+ function detectPackageRunner(projectPath) {
120
+ if (existsSync(join(projectPath, "pnpm-lock.yaml"))) return "pnpm dlx";
121
+ if (existsSync(join(projectPath, "bun.lockb")) || existsSync(join(projectPath, "bun.lock"))) return "bunx";
122
+ if (existsSync(join(projectPath, "yarn.lock"))) return "yarn dlx";
123
+ if (existsSync(join(projectPath, "package-lock.json"))) return "npx --yes";
124
+ return "npx --yes";
125
+ }
126
+ async function getDynamicWorkspace({ requestContext, mastra, skillExtension, backgroundToolsEnabled = false, plansDir }) {
127
+ const state = requestContext.get("controller")?.getState();
128
+ const rawProjectPath = state?.projectPath;
129
+ if (!rawProjectPath) throw new Error("Project path is required");
130
+ const projectPath = path.resolve(rawProjectPath);
131
+ const projectSkillPaths = buildSkillPaths(projectPath, state?.configDir ?? ".mastracode", state?.homeDir, state?.pluginSkillPaths ?? []);
132
+ const skillPaths = [...skillExtension?.paths ?? [], ...projectSkillPaths];
133
+ const extensionId = skillExtension ? `-${skillExtension.id}` : "";
134
+ const workspaceId = `${WORKSPACE_ID_PREFIX}-${projectPath}${extensionId}`;
135
+ const sandboxPaths = state?.sandboxAllowedPaths ?? [];
136
+ const allowedPaths = [
137
+ ...projectSkillPaths,
138
+ ...DEFAULT_ALLOWED_PATHS,
139
+ ...sandboxPaths.map((p) => path.resolve(p))
140
+ ];
141
+ const workspaceTools = createMastraCodeWorkspaceTools(backgroundToolsEnabled, plansDir);
142
+ let existing;
143
+ try {
144
+ existing = mastra?.getWorkspaceById(workspaceId, { optional: true });
145
+ } catch {}
146
+ if (existing) {
147
+ existing.filesystem.setAllowedPaths(allowedPaths);
148
+ existing.setToolsConfig(workspaceTools);
149
+ return existing;
150
+ }
151
+ const userLsp = resolveLspSetting(loadSettings().lsp);
152
+ let lspConfig = false;
153
+ if (userLsp !== false) {
154
+ const mcModulePath = join(dirname(fileURLToPath(import.meta.url)), "..");
155
+ lspConfig = {
156
+ maxOpenClients: 4,
157
+ ...userLsp,
158
+ packageRunner: userLsp.packageRunner || detectPackageRunner(projectPath),
159
+ searchPaths: [mcModulePath, ...userLsp.searchPaths ?? []]
160
+ };
161
+ }
162
+ const filesystem = new LocalFilesystem({
163
+ basePath: projectPath,
164
+ allowedPaths
165
+ });
166
+ return new Workspace({
167
+ id: workspaceId,
168
+ name: "Mastra Code Workspace",
169
+ filesystem,
170
+ sandbox: new LocalSandbox({
171
+ timeout: 3e4,
172
+ workingDirectory: projectPath,
173
+ env: buildSandboxEnv()
174
+ }),
175
+ tools: workspaceTools,
176
+ skills: skillPaths,
177
+ ...skillExtension ? { skillSource: skillExtension.createSource(filesystem, projectSkillPaths) } : {},
178
+ lsp: lspConfig
179
+ });
180
+ }
181
+ /**
182
+ * Resolver for the agent's `goal.tools` config. Builds the request's workspace
183
+ * (same per-request resolution as the agent's own tools) and returns only the
184
+ * read-only verification subset, remapped to mastracode's tool names (`view`,
185
+ * `search_content`, etc.). Returns `undefined` when no workspace can be resolved
186
+ * (e.g. no project path), keeping the default judge text-only rather than
187
+ * throwing inside the goal step.
188
+ */
189
+ async function getGoalJudgeTools({ requestContext, mastra }) {
190
+ let workspace;
191
+ try {
192
+ workspace = await getDynamicWorkspace({
193
+ requestContext,
194
+ mastra
195
+ });
196
+ } catch {
197
+ return;
198
+ }
199
+ const allTools = await createWorkspaceTools(workspace, {
200
+ requestContext,
201
+ workspace
202
+ });
203
+ const readonly = {};
204
+ for (const name of GOAL_JUDGE_READONLY_TOOLS) if (allTools[name]) readonly[name] = allTools[name];
205
+ return Object.keys(readonly).length > 0 ? readonly : void 0;
206
+ }
207
+ export { buildSkillPaths, getDynamicWorkspace, getGoalJudgeTools };
@@ -0,0 +1,18 @@
1
+ export declare function getMastraAnalyticsDistinctId(configPath?: string): string;
2
+ export type MastraCodeAnalyticsEvent = 'mastracode_session_started' | 'mastracode_prompt_submitted' | 'mastracode_thread_changed' | 'mastracode_model_changed' | 'mastracode_command_used' | 'mastracode_interactive_prompt_shown';
3
+ export interface MastraCodeAnalytics {
4
+ capture(event: MastraCodeAnalyticsEvent, properties?: Record<string, unknown>): void;
5
+ trackCommand(command: string, properties?: Record<string, unknown>): void;
6
+ trackInteractivePrompt(promptType: string, properties?: Record<string, unknown>): void;
7
+ shutdown(): Promise<void>;
8
+ isEnabled(): boolean;
9
+ }
10
+ interface MastraCodeAnalyticsOptions {
11
+ version: string;
12
+ host?: string;
13
+ apiKey?: string;
14
+ }
15
+ export declare function isTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
16
+ export declare function createMastraCodeAnalytics(options: MastraCodeAnalyticsOptions): MastraCodeAnalytics;
17
+ export {};
18
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1,159 @@
1
+ import path from "path";
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
3
+ import os from "os";
4
+ import { PostHog } from "posthog-node";
5
+ // src/analytics.ts
6
+ const POSTHOG_API_KEY = "phc_SBLpZVAB6jmHOct9CABq3PF0Yn5FU3G2FgT4xUr2XrT";
7
+ const POSTHOG_HOST = "https://us.posthog.com";
8
+ const MASTRA_SOURCE = "mastracode";
9
+ const TRUTHY_DISABLED_VALUES = /* @__PURE__ */ new Set([
10
+ "1",
11
+ "true",
12
+ "yes",
13
+ "on"
14
+ ]);
15
+ const ANALYTICS_CONFIG_PATH = path.join(os.homedir(), ".mastracode", "analytics.json");
16
+ function createMastraAnalyticsDistinctId() {
17
+ return `mastra-${globalThis.crypto.randomUUID()}`;
18
+ }
19
+ function isHostnameDerivedDistinctId(distinctId, hostname = os.hostname()) {
20
+ return distinctId === `mastra-${hostname}`;
21
+ }
22
+ function isValidMastraAnalyticsDistinctId(distinctId) {
23
+ return /^mastra-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(distinctId);
24
+ }
25
+ function writeAnalyticsConfig(distinctId, configPath = ANALYTICS_CONFIG_PATH) {
26
+ try {
27
+ mkdirSync(path.dirname(configPath), { recursive: true });
28
+ writeFileSync(configPath, JSON.stringify({ distinctId }));
29
+ } catch {}
30
+ }
31
+ function getMastraAnalyticsDistinctId(configPath = ANALYTICS_CONFIG_PATH) {
32
+ try {
33
+ if (existsSync(configPath)) {
34
+ const config = JSON.parse(readFileSync(configPath, "utf-8"));
35
+ if (config.distinctId && isValidMastraAnalyticsDistinctId(config.distinctId) && !isHostnameDerivedDistinctId(config.distinctId)) return config.distinctId;
36
+ }
37
+ } catch {}
38
+ const distinctId = createMastraAnalyticsDistinctId();
39
+ writeAnalyticsConfig(distinctId, configPath);
40
+ return distinctId;
41
+ }
42
+ function isAnalyticsDebugEnabled() {
43
+ return TRUTHY_DISABLED_VALUES.has(process.env.MASTRACODE_ANALYTICS_DEBUG?.trim().toLowerCase() ?? "");
44
+ }
45
+ function debugAnalytics(message, properties) {
46
+ if (!isAnalyticsDebugEnabled()) return;
47
+ const suffix = properties ? ` ${JSON.stringify(properties)}` : "";
48
+ process.stderr.write(`[mastracode analytics] ${message}${suffix}\n`);
49
+ }
50
+ var NoopMastraCodeAnalytics = class {
51
+ capture(event) {
52
+ debugAnalytics("capture skipped: telemetry disabled", { event });
53
+ }
54
+ trackCommand(command) {
55
+ debugAnalytics("command skipped: telemetry disabled", { command });
56
+ }
57
+ trackInteractivePrompt(promptType) {
58
+ debugAnalytics("interactive prompt skipped: telemetry disabled", { promptType });
59
+ }
60
+ async shutdown() {
61
+ debugAnalytics("shutdown skipped: telemetry disabled");
62
+ }
63
+ isEnabled() {
64
+ return false;
65
+ }
66
+ };
67
+ var PostHogMastraCodeAnalytics = class {
68
+ client;
69
+ distinctId;
70
+ sessionId = globalThis.crypto.randomUUID();
71
+ version;
72
+ constructor({ version, apiKey = POSTHOG_API_KEY, host = POSTHOG_HOST }) {
73
+ this.version = version;
74
+ this.distinctId = getMastraAnalyticsDistinctId();
75
+ this.client = new PostHog(apiKey, {
76
+ host,
77
+ flushAt: 1,
78
+ flushInterval: 0,
79
+ disableGeoip: false
80
+ });
81
+ this.client.register({ mastraSource: MASTRA_SOURCE });
82
+ debugAnalytics("enabled", {
83
+ host,
84
+ distinctId: this.distinctId,
85
+ version
86
+ });
87
+ }
88
+ capture(event, properties) {
89
+ try {
90
+ const eventProperties = {
91
+ ...this.getBaseProperties(),
92
+ ...properties
93
+ };
94
+ debugAnalytics("capture", {
95
+ event,
96
+ properties: eventProperties
97
+ });
98
+ this.client.capture({
99
+ distinctId: this.distinctId,
100
+ event,
101
+ properties: eventProperties
102
+ });
103
+ } catch (error) {
104
+ debugAnalytics("capture failed", {
105
+ event,
106
+ error: error instanceof Error ? error.message : String(error)
107
+ });
108
+ }
109
+ }
110
+ trackCommand(command, properties) {
111
+ this.capture("mastracode_command_used", {
112
+ command,
113
+ ...properties
114
+ });
115
+ }
116
+ trackInteractivePrompt(promptType, properties) {
117
+ this.capture("mastracode_interactive_prompt_shown", {
118
+ promptType,
119
+ ...properties
120
+ });
121
+ }
122
+ async shutdown() {
123
+ try {
124
+ debugAnalytics("shutdown start");
125
+ await this.client.shutdown();
126
+ debugAnalytics("shutdown complete");
127
+ } catch (error) {
128
+ debugAnalytics("shutdown failed", { error: error instanceof Error ? error.message : String(error) });
129
+ }
130
+ }
131
+ isEnabled() {
132
+ return true;
133
+ }
134
+ getBaseProperties() {
135
+ return {
136
+ mastraSource: MASTRA_SOURCE,
137
+ sessionId: this.sessionId,
138
+ version: this.version,
139
+ os: process.platform,
140
+ osVersion: os.release(),
141
+ nodeVersion: process.version,
142
+ platform: process.arch,
143
+ machineId: os.hostname()
144
+ };
145
+ }
146
+ };
147
+ function isTelemetryDisabled(env = process.env) {
148
+ const value = env.MASTRA_TELEMETRY_DISABLED;
149
+ if (!value) return false;
150
+ return TRUTHY_DISABLED_VALUES.has(value.trim().toLowerCase());
151
+ }
152
+ function createMastraCodeAnalytics(options) {
153
+ if (isTelemetryDisabled()) {
154
+ debugAnalytics("disabled by MASTRA_TELEMETRY_DISABLED", { value: process.env.MASTRA_TELEMETRY_DISABLED });
155
+ return new NoopMastraCodeAnalytics();
156
+ }
157
+ return new PostHogMastraCodeAnalytics(options);
158
+ }
159
+ export { createMastraCodeAnalytics, getMastraAnalyticsDistinctId, isTelemetryDisabled };
@@ -0,0 +1,210 @@
1
+ import type { ProcessAPIErrorArgs, ProcessInputArgs, ProcessInputResult, Processor } from '@mastra/core/processors';
2
+ import type { RequestContext } from '@mastra/core/request-context';
3
+ import type { ThinkingLevelSetting } from '../thinking.js';
4
+ import type { CredentialStore } from './types.js';
5
+ export declare const ACCOUNT_SWITCH_PART_TYPE = "data-mastracode-account-switch";
6
+ /** Labels and instance ids only — never token material (do-not list). */
7
+ export interface AccountSwitchPartData {
8
+ provider: string;
9
+ from: {
10
+ id: string;
11
+ label: string;
12
+ } | null;
13
+ to: {
14
+ id: string;
15
+ label: string;
16
+ } | null;
17
+ reason: 'rate-limit' | 'quota-exhausted' | 'auth-failed' | 'pool-exhausted' | 'persistent-outage' | 'preferred-routing';
18
+ at: string;
19
+ /**
20
+ * Set on a `to: null` part when a route pinned to a single account reported
21
+ * that account unusable. The provider's other subscriptions were never
22
+ * consulted (A12), so "all accounts unavailable" would misreport what
23
+ * happened.
24
+ */
25
+ exclusive?: boolean;
26
+ }
27
+ /** The store surface rotation needs; `AuthStorage` satisfies it structurally. */
28
+ export type RotationCredentialStore = CredentialStore & {
29
+ /**
30
+ * Force one refresh of the active account's tokens regardless of expiry
31
+ * (401/403 path — a rejected-but-unexpired token usually means clock skew
32
+ * or a refresh race). `AuthStorage` provides it for its active account;
33
+ * deployed per-tenant stores provide it for their single credential.
34
+ */
35
+ forceRefreshActiveAccount?(providerId: string, accountInstanceId?: string): Promise<string | undefined>;
36
+ };
37
+ /** Persisted data-part type for a model-route hop. */
38
+ export declare const MODEL_FALLBACK_PART_TYPE: 'data-mastracode-model-fallback';
39
+ /** Non-secret transcript payload for a model-route hop. */
40
+ export interface ModelFallbackPartData {
41
+ from: {
42
+ entryId: string;
43
+ label: string;
44
+ };
45
+ to: {
46
+ entryId: string;
47
+ label: string;
48
+ };
49
+ reason: 'pool-exhausted' | 'persistent-outage';
50
+ at: string;
51
+ }
52
+ /** Session-state key set when account rotation advances the model route. */
53
+ export declare const MODEL_FALLBACK_STATE_KEY: 'mastracodePendingModelFallback';
54
+ /** Payload written to session state under MODEL_FALLBACK_STATE_KEY. */
55
+ export interface PendingModelFallback {
56
+ fromEntryId: string;
57
+ toEntryId: string;
58
+ toModelId: string;
59
+ threadId?: string;
60
+ reason: 'pool-exhausted' | 'persistent-outage';
61
+ at: string;
62
+ }
63
+ export type RotationClassification = {
64
+ kind: 'rotate';
65
+ reason: 'rate-limit' | 'quota-exhausted' | 'auth-failed';
66
+ } | {
67
+ kind: 'hop';
68
+ } | {
69
+ kind: 'stream-cut';
70
+ } | {
71
+ kind: 'never';
72
+ };
73
+ /**
74
+ * Same-account retries for a stream the provider cut after accepting the
75
+ * request. Each one can cost a full stream (900 s on the ChatGPT Codex route),
76
+ * so the budget is small. This is the whole budget: Mastra Code's
77
+ * `StreamErrorRetryProcessor` leaves these errors to this processor.
78
+ */
79
+ export declare const MAX_STREAM_CUT_RETRIES = 2;
80
+ /**
81
+ * Whether the provider accepted the request and then the response stream died:
82
+ * the AI SDK reports a body that fails after a 2xx response as
83
+ * "Failed to process successful response" with the 2xx status, and the ChatGPT
84
+ * Codex backend ends streams at 900 s, sometimes with a `request_timeout` error
85
+ * frame first. Either way the account and the provider answered, so this is
86
+ * not an outage, and another account would be cut the same way.
87
+ *
88
+ * `@ai-sdk/openai` raises that frame with `code: 'request_timeout'` and a
89
+ * derived `statusCode: 504`, so callers must check this before any 5xx rule.
90
+ * Mastra Code's transient retry matchers call it first so that account
91
+ * rotation is the only processor that retries these errors.
92
+ */
93
+ export declare function isStreamCutAfterResponse(error: unknown): boolean;
94
+ /**
95
+ * The locked Q7 taxonomy. Rate limits and exhausted quotas rotate immediately
96
+ * (429 is not covered by any transient matcher, so it arrives here on first
97
+ * occurrence); auth failures and `ProviderAuthRequiredError` rotate after one
98
+ * forced refresh; 5xx/network hop only when the transient retry budget is
99
+ * already spent (they reach this processor because `StreamErrorRetryProcessor`
100
+ * declined); everything else never touches the registry.
101
+ */
102
+ export declare function classifyRotationError(error: unknown): RotationClassification;
103
+ /** Provider id off a router model id: `mastracode/<provider>/<model>` or `<provider>/<model>`. */
104
+ export declare function providerFromModelId(modelId: string): string | undefined;
105
+ /**
106
+ * Identify the provider an error came from: the request URL's hostname
107
+ * (`APICallError.url`, cause chain included), falling back to the router
108
+ * model id. Unknown → undefined (caller treats as never-rotate).
109
+ */
110
+ export declare function providerFromError(error: unknown): string | undefined;
111
+ /** Friendly names for the part/notice copy (display only — never auth data). */
112
+ export declare const PROVIDER_DISPLAY_NAMES: Record<string, string>;
113
+ /** Validates untrusted `reason` values (e.g. persisted message parts). */
114
+ export declare function isAccountSwitchReason(value: unknown): value is AccountSwitchPartData['reason'];
115
+ /**
116
+ * One-line transcript copy for a switch part. Shared by the live `info`
117
+ * controller event (the TUI shows controller `info` events as transcript
118
+ * lines, and no message event carries data parts mid-run) and by the TUI's
119
+ * history rendering of the persisted part — one formatter, identical text.
120
+ */
121
+ export declare function accountSwitchNoticeText(data: AccountSwitchPartData): string;
122
+ /** Transcript line for a model-route hop; shared by the live info event and the TUI's history render. */
123
+ export declare function modelFallbackNoticeText(data: ModelFallbackPartData): string;
124
+ /**
125
+ * Whether a persisted model-fallback reason is one this build understands.
126
+ * `REASON_TEXT` also covers the account-switch reasons, so the notice text
127
+ * alone would happily render a foreign value such as `rate-limit` as a
128
+ * model-fallback reason; history parsed from another build's part must be
129
+ * rejected instead.
130
+ */
131
+ export declare function isModelFallbackReason(value: unknown): value is ModelFallbackPartData['reason'];
132
+ export type RoutingControllerContext = {
133
+ session?: {
134
+ modelId?: unknown;
135
+ modeId?: unknown;
136
+ };
137
+ threadId?: unknown;
138
+ getState?: () => Record<string, unknown>;
139
+ setState?: (updates: Record<string, unknown>) => Promise<void>;
140
+ getThreadSetting?: (key: string) => Promise<unknown>;
141
+ setThreadSetting?: (setting: {
142
+ key: string;
143
+ value: unknown;
144
+ }) => Promise<void>;
145
+ isThreadActive?: () => boolean;
146
+ };
147
+ export declare class AccountRotationProcessor implements Processor {
148
+ private readonly options;
149
+ readonly id: 'mastracode-account-rotation';
150
+ constructor(options: {
151
+ credentialStore: RotationCredentialStore;
152
+ maxProcessorRetries: number;
153
+ settingsPath?: string;
154
+ /** The host has no modes, so per-mode thinking defaults never apply. */
155
+ modeless?: boolean;
156
+ /** Same host thinking default `getDynamicModel` uses, so a hop resolves at the same level. */
157
+ resolveDefaultThinkingLevel?: (ctx: {
158
+ requestContext: RequestContext;
159
+ }) => ThinkingLevelSetting | Promise<ThinkingLevelSetting>;
160
+ });
161
+ processAPIError(args: ProcessAPIErrorArgs): Promise<{
162
+ retry: boolean;
163
+ }>;
164
+ /**
165
+ * Resolve the request's host-supplied model route once and cache the reachable
166
+ * prefix in processor state. Resolution mirrors getDynamicModel so a hop is
167
+ * never announced for an entry core cannot reach.
168
+ */
169
+ private getModelRouteCascade;
170
+ /**
171
+ * Q14 gate: 400/unknown/unattributable errors never advance routes. Core's
172
+ * fallback array advances on ANY thrown error except TripWire
173
+ * (llm-execution-step.ts), so when the session route has another entry and the
174
+ * current entry is non-last, a bare `retry: false` would silently hop on an
175
+ * error class the user excluded from hop triggers. TripWire is the only
176
+ * no-advance escape: the runner rethrows it and the fallback loop declines
177
+ * to advance. No chain (or already on the last entry) → return and let the
178
+ * plain `retry: false` surface the error exactly as before.
179
+ */
180
+ private gateChainHop;
181
+ /** Announce and persist the next model-route hop before core advances. */
182
+ private emitModelFallbackPart;
183
+ /**
184
+ * Pool done for this request: every instance recorded in the tried-set and
185
+ * a `to: null` part emitted. Returns `retry: false` so core's fallback
186
+ * array can hop to the next route entry (announced by `emitModelFallbackPart`).
187
+ * Silent on the account part when the provider has no registry at all —
188
+ * there are no accounts to declare unavailable, but the hop still applies.
189
+ */
190
+ private declarePoolUnavailable;
191
+ }
192
+ /**
193
+ * Applies the pack's preferred account route once per request, before the
194
+ * first model call. Without a route it only reloads the credential store so
195
+ * the request sees accounts changed by other processes.
196
+ *
197
+ * TYPE CONSTRAINT: this class must NEVER implement `processAPIError`. It
198
+ * lives in `inputProcessors`; the runner walks input processors first when
199
+ * running `processAPIError`, so adding the method here would classify and
200
+ * rotate errors BEFORE `StreamErrorRetryProcessor`'s transient retries run.
201
+ */
202
+ export declare class AccountStartNoticeProcessor implements Processor {
203
+ private readonly options;
204
+ readonly id: 'mastracode-account-start-notice';
205
+ constructor(options: {
206
+ credentialStore: CredentialStore;
207
+ });
208
+ processInput(args: ProcessInputArgs): Promise<ProcessInputResult>;
209
+ }
210
+ //# sourceMappingURL=account-rotation-processor.d.ts.map