@mastra/code-sdk 0.0.0-esbuild-bundle-worker-20260807173433

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 (491) hide show
  1. package/CHANGELOG.md +1349 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +70 -0
  4. package/dist/acp/agent.d.ts +35 -0
  5. package/dist/acp/agent.d.ts.map +1 -0
  6. package/dist/acp/agent.js +161 -0
  7. package/dist/acp/agent.js.map +1 -0
  8. package/dist/acp/event-mapper.d.ts +22 -0
  9. package/dist/acp/event-mapper.d.ts.map +1 -0
  10. package/dist/acp/event-mapper.js +214 -0
  11. package/dist/acp/event-mapper.js.map +1 -0
  12. package/dist/acp/index.d.ts +8 -0
  13. package/dist/acp/index.d.ts.map +1 -0
  14. package/dist/acp/index.js +65 -0
  15. package/dist/acp/index.js.map +1 -0
  16. package/dist/acp/server.d.ts +7 -0
  17. package/dist/acp/server.d.ts.map +1 -0
  18. package/dist/acp/server.js +35 -0
  19. package/dist/acp/server.js.map +1 -0
  20. package/dist/acp.d.ts +2 -0
  21. package/dist/acp.d.ts.map +1 -0
  22. package/dist/acp.js +2 -0
  23. package/dist/agents/credential-resolver.d.ts +51 -0
  24. package/dist/agents/credential-resolver.d.ts.map +1 -0
  25. package/dist/agents/credential-resolver.js +52 -0
  26. package/dist/agents/credential-resolver.js.map +1 -0
  27. package/dist/agents/custom-provider-source.d.ts +35 -0
  28. package/dist/agents/custom-provider-source.d.ts.map +1 -0
  29. package/dist/agents/custom-provider-source.js +25 -0
  30. package/dist/agents/custom-provider-source.js.map +1 -0
  31. package/dist/agents/instructions.d.ts +6 -0
  32. package/dist/agents/instructions.d.ts.map +1 -0
  33. package/dist/agents/instructions.js +32 -0
  34. package/dist/agents/instructions.js.map +1 -0
  35. package/dist/agents/mastracode-gateway.d.ts +74 -0
  36. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  37. package/dist/agents/mastracode-gateway.js +400 -0
  38. package/dist/agents/mastracode-gateway.js.map +1 -0
  39. package/dist/agents/memory.d.ts +13 -0
  40. package/dist/agents/memory.d.ts.map +1 -0
  41. package/dist/agents/memory.js +116 -0
  42. package/dist/agents/memory.js.map +1 -0
  43. package/dist/agents/model.d.ts +59 -0
  44. package/dist/agents/model.d.ts.map +1 -0
  45. package/dist/agents/model.js +132 -0
  46. package/dist/agents/model.js.map +1 -0
  47. package/dist/agents/modes/build.d.ts +10 -0
  48. package/dist/agents/modes/build.d.ts.map +1 -0
  49. package/dist/agents/modes/build.js +44 -0
  50. package/dist/agents/modes/build.js.map +1 -0
  51. package/dist/agents/modes/explore.d.ts +10 -0
  52. package/dist/agents/modes/explore.d.ts.map +1 -0
  53. package/dist/agents/modes/explore.js +39 -0
  54. package/dist/agents/modes/explore.js.map +1 -0
  55. package/dist/agents/modes/plan.d.ts +6 -0
  56. package/dist/agents/modes/plan.d.ts.map +1 -0
  57. package/dist/agents/modes/plan.js +37 -0
  58. package/dist/agents/modes/plan.js.map +1 -0
  59. package/dist/agents/prompts/agent-instructions.d.ts +61 -0
  60. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  61. package/dist/agents/prompts/agent-instructions.js +201 -0
  62. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  63. package/dist/agents/prompts/build.d.ts +12 -0
  64. package/dist/agents/prompts/build.d.ts.map +1 -0
  65. package/dist/agents/prompts/build.js +76 -0
  66. package/dist/agents/prompts/build.js.map +1 -0
  67. package/dist/agents/prompts/fast.d.ts +5 -0
  68. package/dist/agents/prompts/fast.d.ts.map +1 -0
  69. package/dist/agents/prompts/fast.js +26 -0
  70. package/dist/agents/prompts/fast.js.map +1 -0
  71. package/dist/agents/prompts/index.d.ts +19 -0
  72. package/dist/agents/prompts/index.d.ts.map +1 -0
  73. package/dist/agents/prompts/index.js +65 -0
  74. package/dist/agents/prompts/index.js.map +1 -0
  75. package/dist/agents/prompts/model.d.ts +5 -0
  76. package/dist/agents/prompts/model.d.ts.map +1 -0
  77. package/dist/agents/prompts/model.js +23 -0
  78. package/dist/agents/prompts/model.js.map +1 -0
  79. package/dist/agents/prompts/plan.d.ts +6 -0
  80. package/dist/agents/prompts/plan.d.ts.map +1 -0
  81. package/dist/agents/prompts/plan.js +111 -0
  82. package/dist/agents/prompts/plan.js.map +1 -0
  83. package/dist/agents/prompts/tool-guidance.d.ts +13 -0
  84. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  85. package/dist/agents/prompts/tool-guidance.js +149 -0
  86. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  87. package/dist/agents/sandbox-filesystem.d.ts +99 -0
  88. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  89. package/dist/agents/sandbox-filesystem.js +328 -0
  90. package/dist/agents/sandbox-filesystem.js.map +1 -0
  91. package/dist/agents/sandbox-reattach.d.ts +19 -0
  92. package/dist/agents/sandbox-reattach.d.ts.map +1 -0
  93. package/dist/agents/sandbox-reattach.js +15 -0
  94. package/dist/agents/sandbox-reattach.js.map +1 -0
  95. package/dist/agents/thread-caveman-state.d.ts +17 -0
  96. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  97. package/dist/agents/thread-caveman-state.js +107 -0
  98. package/dist/agents/thread-caveman-state.js.map +1 -0
  99. package/dist/agents/tool-availability.d.ts +10 -0
  100. package/dist/agents/tool-availability.d.ts.map +1 -0
  101. package/dist/agents/tool-availability.js +87 -0
  102. package/dist/agents/tool-availability.js.map +1 -0
  103. package/dist/agents/tools.d.ts +19 -0
  104. package/dist/agents/tools.d.ts.map +1 -0
  105. package/dist/agents/tools.js +105 -0
  106. package/dist/agents/tools.js.map +1 -0
  107. package/dist/agents/workspace.d.ts +32 -0
  108. package/dist/agents/workspace.d.ts.map +1 -0
  109. package/dist/agents/workspace.js +251 -0
  110. package/dist/agents/workspace.js.map +1 -0
  111. package/dist/analytics.d.ts +18 -0
  112. package/dist/analytics.d.ts.map +1 -0
  113. package/dist/analytics.js +163 -0
  114. package/dist/analytics.js.map +1 -0
  115. package/dist/auth/authorization-input.d.ts +16 -0
  116. package/dist/auth/authorization-input.d.ts.map +1 -0
  117. package/dist/auth/authorization-input.js +42 -0
  118. package/dist/auth/authorization-input.js.map +1 -0
  119. package/dist/auth/device-code.d.ts +93 -0
  120. package/dist/auth/device-code.d.ts.map +1 -0
  121. package/dist/auth/device-code.js +129 -0
  122. package/dist/auth/device-code.js.map +1 -0
  123. package/dist/auth/index.d.ts +10 -0
  124. package/dist/auth/index.d.ts.map +1 -0
  125. package/dist/auth/index.js +6 -0
  126. package/dist/auth/pkce.d.ts +13 -0
  127. package/dist/auth/pkce.d.ts.map +1 -0
  128. package/dist/auth/pkce.js +32 -0
  129. package/dist/auth/pkce.js.map +1 -0
  130. package/dist/auth/providers/anthropic.d.ts +40 -0
  131. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  132. package/dist/auth/providers/anthropic.js +126 -0
  133. package/dist/auth/providers/anthropic.js.map +1 -0
  134. package/dist/auth/providers/github-copilot.d.ts +154 -0
  135. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  136. package/dist/auth/providers/github-copilot.js +340 -0
  137. package/dist/auth/providers/github-copilot.js.map +1 -0
  138. package/dist/auth/providers/openai-codex.d.ts +139 -0
  139. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  140. package/dist/auth/providers/openai-codex.js +519 -0
  141. package/dist/auth/providers/openai-codex.js.map +1 -0
  142. package/dist/auth/providers/xai.d.ts +64 -0
  143. package/dist/auth/providers/xai.d.ts.map +1 -0
  144. package/dist/auth/providers/xai.js +205 -0
  145. package/dist/auth/providers/xai.js.map +1 -0
  146. package/dist/auth/storage.d.ts +91 -0
  147. package/dist/auth/storage.d.ts.map +1 -0
  148. package/dist/auth/storage.js +197 -0
  149. package/dist/auth/storage.js.map +1 -0
  150. package/dist/auth/types.d.ts +89 -0
  151. package/dist/auth/types.d.ts.map +1 -0
  152. package/dist/auth/types.js +1 -0
  153. package/dist/clipboard/index.d.ts +26 -0
  154. package/dist/clipboard/index.d.ts.map +1 -0
  155. package/dist/clipboard/index.js +226 -0
  156. package/dist/clipboard/index.js.map +1 -0
  157. package/dist/constants.d.ts +10 -0
  158. package/dist/constants.d.ts.map +1 -0
  159. package/dist/constants.js +18 -0
  160. package/dist/constants.js.map +1 -0
  161. package/dist/error-classification.d.ts +10 -0
  162. package/dist/error-classification.d.ts.map +1 -0
  163. package/dist/error-classification.js +22 -0
  164. package/dist/error-classification.js.map +1 -0
  165. package/dist/evals/context-builder.d.ts +41 -0
  166. package/dist/evals/context-builder.d.ts.map +1 -0
  167. package/dist/evals/context-builder.js +161 -0
  168. package/dist/evals/context-builder.js.map +1 -0
  169. package/dist/evals/index.d.ts +4 -0
  170. package/dist/evals/index.d.ts.map +1 -0
  171. package/dist/evals/index.js +5 -0
  172. package/dist/evals/scorers/classify-command.d.ts +31 -0
  173. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  174. package/dist/evals/scorers/classify-command.js +73 -0
  175. package/dist/evals/scorers/classify-command.js.map +1 -0
  176. package/dist/evals/scorers/efficiency.d.ts +44 -0
  177. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  178. package/dist/evals/scorers/efficiency.js +259 -0
  179. package/dist/evals/scorers/efficiency.js.map +1 -0
  180. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  181. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  182. package/dist/evals/scorers/extract-tools.js +60 -0
  183. package/dist/evals/scorers/extract-tools.js.map +1 -0
  184. package/dist/evals/scorers/index.d.ts +3 -0
  185. package/dist/evals/scorers/index.d.ts.map +1 -0
  186. package/dist/evals/scorers/index.js +3 -0
  187. package/dist/evals/scorers/outcome.d.ts +49 -0
  188. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  189. package/dist/evals/scorers/outcome.js +347 -0
  190. package/dist/evals/scorers/outcome.js.map +1 -0
  191. package/dist/goal-manager.d.ts +78 -0
  192. package/dist/goal-manager.d.ts.map +1 -0
  193. package/dist/goal-manager.js +273 -0
  194. package/dist/goal-manager.js.map +1 -0
  195. package/dist/goal-signal.d.ts +14 -0
  196. package/dist/goal-signal.d.ts.map +1 -0
  197. package/dist/goal-signal.js +17 -0
  198. package/dist/goal-signal.js.map +1 -0
  199. package/dist/headless/cli.d.ts +42 -0
  200. package/dist/headless/cli.d.ts.map +1 -0
  201. package/dist/headless/cli.js +195 -0
  202. package/dist/headless/cli.js.map +1 -0
  203. package/dist/headless/flags.d.ts +33 -0
  204. package/dist/headless/flags.d.ts.map +1 -0
  205. package/dist/headless/flags.js +190 -0
  206. package/dist/headless/flags.js.map +1 -0
  207. package/dist/headless/format.d.ts +38 -0
  208. package/dist/headless/format.d.ts.map +1 -0
  209. package/dist/headless/format.js +89 -0
  210. package/dist/headless/format.js.map +1 -0
  211. package/dist/headless/index.d.ts +25 -0
  212. package/dist/headless/index.d.ts.map +1 -0
  213. package/dist/headless/index.js +6 -0
  214. package/dist/headless/policy.d.ts +17 -0
  215. package/dist/headless/policy.d.ts.map +1 -0
  216. package/dist/headless/policy.js +42 -0
  217. package/dist/headless/policy.js.map +1 -0
  218. package/dist/headless/run-mc.d.ts +7 -0
  219. package/dist/headless/run-mc.d.ts.map +1 -0
  220. package/dist/headless/run-mc.js +346 -0
  221. package/dist/headless/run-mc.js.map +1 -0
  222. package/dist/headless/types.d.ts +158 -0
  223. package/dist/headless/types.d.ts.map +1 -0
  224. package/dist/headless/types.js +18 -0
  225. package/dist/headless/types.js.map +1 -0
  226. package/dist/hooks/config.d.ts +11 -0
  227. package/dist/hooks/config.d.ts.map +1 -0
  228. package/dist/hooks/config.js +73 -0
  229. package/dist/hooks/config.js.map +1 -0
  230. package/dist/hooks/executor.d.ts +13 -0
  231. package/dist/hooks/executor.d.ts.map +1 -0
  232. package/dist/hooks/executor.js +128 -0
  233. package/dist/hooks/executor.js.map +1 -0
  234. package/dist/hooks/index.d.ts +6 -0
  235. package/dist/hooks/index.d.ts.map +1 -0
  236. package/dist/hooks/index.js +5 -0
  237. package/dist/hooks/manager.d.ts +47 -0
  238. package/dist/hooks/manager.d.ts.map +1 -0
  239. package/dist/hooks/manager.js +225 -0
  240. package/dist/hooks/manager.js.map +1 -0
  241. package/dist/hooks/types.d.ts +152 -0
  242. package/dist/hooks/types.d.ts.map +1 -0
  243. package/dist/hooks/types.js +8 -0
  244. package/dist/hooks/types.js.map +1 -0
  245. package/dist/index.d.ts +258 -0
  246. package/dist/index.d.ts.map +1 -0
  247. package/dist/index.js +740 -0
  248. package/dist/index.js.map +1 -0
  249. package/dist/ipc/ipc-reporter.d.ts +14 -0
  250. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  251. package/dist/ipc/ipc-reporter.js +21 -0
  252. package/dist/ipc/ipc-reporter.js.map +1 -0
  253. package/dist/lsp/client.d.ts +56 -0
  254. package/dist/lsp/client.d.ts.map +1 -0
  255. package/dist/lsp/client.js +251 -0
  256. package/dist/lsp/client.js.map +1 -0
  257. package/dist/lsp/index.d.ts +4 -0
  258. package/dist/lsp/index.d.ts.map +1 -0
  259. package/dist/lsp/index.js +4 -0
  260. package/dist/lsp/language.d.ts +9 -0
  261. package/dist/lsp/language.d.ts.map +1 -0
  262. package/dist/lsp/language.js +44 -0
  263. package/dist/lsp/language.js.map +1 -0
  264. package/dist/lsp/manager.d.ts +34 -0
  265. package/dist/lsp/manager.d.ts.map +1 -0
  266. package/dist/lsp/manager.js +82 -0
  267. package/dist/lsp/manager.js.map +1 -0
  268. package/dist/lsp/server.d.ts +27 -0
  269. package/dist/lsp/server.d.ts.map +1 -0
  270. package/dist/lsp/server.js +159 -0
  271. package/dist/lsp/server.js.map +1 -0
  272. package/dist/lsp/workspace.d.ts +9 -0
  273. package/dist/lsp/workspace.d.ts.map +1 -0
  274. package/dist/lsp/workspace.js +55 -0
  275. package/dist/lsp/workspace.js.map +1 -0
  276. package/dist/mcp/config.d.ts +54 -0
  277. package/dist/mcp/config.d.ts.map +1 -0
  278. package/dist/mcp/config.js +240 -0
  279. package/dist/mcp/config.js.map +1 -0
  280. package/dist/mcp/index.d.ts +5 -0
  281. package/dist/mcp/index.d.ts.map +1 -0
  282. package/dist/mcp/index.js +3 -0
  283. package/dist/mcp/manager.d.ts +98 -0
  284. package/dist/mcp/manager.d.ts.map +1 -0
  285. package/dist/mcp/manager.js +612 -0
  286. package/dist/mcp/manager.js.map +1 -0
  287. package/dist/mcp/state.d.ts +33 -0
  288. package/dist/mcp/state.d.ts.map +1 -0
  289. package/dist/mcp/state.js +88 -0
  290. package/dist/mcp/state.js.map +1 -0
  291. package/dist/mcp/types.d.ts +120 -0
  292. package/dist/mcp/types.d.ts.map +1 -0
  293. package/dist/mcp/types.js +1 -0
  294. package/dist/onboarding/custom-packs.d.ts +7 -0
  295. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  296. package/dist/onboarding/custom-packs.js +17 -0
  297. package/dist/onboarding/custom-packs.js.map +1 -0
  298. package/dist/onboarding/custom-providers.d.ts +4 -0
  299. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  300. package/dist/onboarding/custom-providers.js +30 -0
  301. package/dist/onboarding/custom-providers.js.map +1 -0
  302. package/dist/onboarding/index.d.ts +5 -0
  303. package/dist/onboarding/index.d.ts.map +1 -0
  304. package/dist/onboarding/index.js +3 -0
  305. package/dist/onboarding/om-settings.d.ts +25 -0
  306. package/dist/onboarding/om-settings.d.ts.map +1 -0
  307. package/dist/onboarding/om-settings.js +47 -0
  308. package/dist/onboarding/om-settings.js.map +1 -0
  309. package/dist/onboarding/packs.d.ts +46 -0
  310. package/dist/onboarding/packs.d.ts.map +1 -0
  311. package/dist/onboarding/packs.js +160 -0
  312. package/dist/onboarding/packs.js.map +1 -0
  313. package/dist/onboarding/settings.d.ts +338 -0
  314. package/dist/onboarding/settings.d.ts.map +1 -0
  315. package/dist/onboarding/settings.js +673 -0
  316. package/dist/onboarding/settings.js.map +1 -0
  317. package/dist/permissions.d.ts +55 -0
  318. package/dist/permissions.d.ts.map +1 -0
  319. package/dist/permissions.js +132 -0
  320. package/dist/permissions.js.map +1 -0
  321. package/dist/plugin.d.ts +81 -0
  322. package/dist/plugin.d.ts.map +1 -0
  323. package/dist/plugin.js +28 -0
  324. package/dist/plugin.js.map +1 -0
  325. package/dist/plugins/dependencies.d.ts +9 -0
  326. package/dist/plugins/dependencies.d.ts.map +1 -0
  327. package/dist/plugins/dependencies.js +88 -0
  328. package/dist/plugins/dependencies.js.map +1 -0
  329. package/dist/plugins/install.d.ts +21 -0
  330. package/dist/plugins/install.d.ts.map +1 -0
  331. package/dist/plugins/install.js +190 -0
  332. package/dist/plugins/install.js.map +1 -0
  333. package/dist/plugins/loader.d.ts +15 -0
  334. package/dist/plugins/loader.d.ts.map +1 -0
  335. package/dist/plugins/loader.js +206 -0
  336. package/dist/plugins/loader.js.map +1 -0
  337. package/dist/plugins/manager.d.ts +64 -0
  338. package/dist/plugins/manager.d.ts.map +1 -0
  339. package/dist/plugins/manager.js +384 -0
  340. package/dist/plugins/manager.js.map +1 -0
  341. package/dist/plugins/manifest.d.ts +14 -0
  342. package/dist/plugins/manifest.d.ts.map +1 -0
  343. package/dist/plugins/manifest.js +50 -0
  344. package/dist/plugins/manifest.js.map +1 -0
  345. package/dist/plugins/package-link.d.ts +3 -0
  346. package/dist/plugins/package-link.d.ts.map +1 -0
  347. package/dist/plugins/package-link.js +61 -0
  348. package/dist/plugins/package-link.js.map +1 -0
  349. package/dist/plugins/paths.d.ts +10 -0
  350. package/dist/plugins/paths.d.ts.map +1 -0
  351. package/dist/plugins/paths.js +25 -0
  352. package/dist/plugins/paths.js.map +1 -0
  353. package/dist/plugins/registry.d.ts +8 -0
  354. package/dist/plugins/registry.d.ts.map +1 -0
  355. package/dist/plugins/registry.js +112 -0
  356. package/dist/plugins/registry.js.map +1 -0
  357. package/dist/plugins/scaffold.d.ts +10 -0
  358. package/dist/plugins/scaffold.d.ts.map +1 -0
  359. package/dist/plugins/scaffold.js +116 -0
  360. package/dist/plugins/scaffold.js.map +1 -0
  361. package/dist/plugins/types.d.ts +45 -0
  362. package/dist/plugins/types.d.ts.map +1 -0
  363. package/dist/plugins/types.js +1 -0
  364. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  365. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  366. package/dist/processors/plan-rejection-abort.js +54 -0
  367. package/dist/processors/plan-rejection-abort.js.map +1 -0
  368. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  369. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  370. package/dist/providers/amazon-bedrock-gateway.js +152 -0
  371. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  372. package/dist/providers/amazon-bedrock.d.ts +28 -0
  373. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  374. package/dist/providers/amazon-bedrock.js +83 -0
  375. package/dist/providers/amazon-bedrock.js.map +1 -0
  376. package/dist/providers/claude-max.d.ts +52 -0
  377. package/dist/providers/claude-max.d.ts.map +1 -0
  378. package/dist/providers/claude-max.js +171 -0
  379. package/dist/providers/claude-max.js.map +1 -0
  380. package/dist/providers/github-copilot.d.ts +60 -0
  381. package/dist/providers/github-copilot.d.ts.map +1 -0
  382. package/dist/providers/github-copilot.js +265 -0
  383. package/dist/providers/github-copilot.js.map +1 -0
  384. package/dist/providers/openai-codex.d.ts +72 -0
  385. package/dist/providers/openai-codex.d.ts.map +1 -0
  386. package/dist/providers/openai-codex.js +302 -0
  387. package/dist/providers/openai-codex.js.map +1 -0
  388. package/dist/providers/xai.d.ts +33 -0
  389. package/dist/providers/xai.d.ts.map +1 -0
  390. package/dist/providers/xai.js +70 -0
  391. package/dist/providers/xai.js.map +1 -0
  392. package/dist/schema.d.ts +192 -0
  393. package/dist/schema.d.ts.map +1 -0
  394. package/dist/schema.js +98 -0
  395. package/dist/schema.js.map +1 -0
  396. package/dist/theme-palette.d.ts +17 -0
  397. package/dist/theme-palette.d.ts.map +1 -0
  398. package/dist/theme-palette.js +21 -0
  399. package/dist/theme-palette.js.map +1 -0
  400. package/dist/tool-names.d.ts +73 -0
  401. package/dist/tool-names.d.ts.map +1 -0
  402. package/dist/tool-names.js +52 -0
  403. package/dist/tool-names.js.map +1 -0
  404. package/dist/tools/index.d.ts +6 -0
  405. package/dist/tools/index.d.ts.map +1 -0
  406. package/dist/tools/index.js +3 -0
  407. package/dist/tools/request-sandbox-access.d.ts +6 -0
  408. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  409. package/dist/tools/request-sandbox-access.js +79 -0
  410. package/dist/tools/request-sandbox-access.js.map +1 -0
  411. package/dist/tools/utils.d.ts +20 -0
  412. package/dist/tools/utils.d.ts.map +1 -0
  413. package/dist/tools/utils.js +32 -0
  414. package/dist/tools/utils.js.map +1 -0
  415. package/dist/tools/web-search.d.ts +35 -0
  416. package/dist/tools/web-search.d.ts.map +1 -0
  417. package/dist/tools/web-search.js +61 -0
  418. package/dist/tools/web-search.js.map +1 -0
  419. package/dist/utils/binaries.d.ts +7 -0
  420. package/dist/utils/binaries.d.ts.map +1 -0
  421. package/dist/utils/binaries.js +78 -0
  422. package/dist/utils/binaries.js.map +1 -0
  423. package/dist/utils/debug-log.d.ts +12 -0
  424. package/dist/utils/debug-log.d.ts.map +1 -0
  425. package/dist/utils/debug-log.js +59 -0
  426. package/dist/utils/debug-log.js.map +1 -0
  427. package/dist/utils/errors.d.ts +36 -0
  428. package/dist/utils/errors.d.ts.map +1 -0
  429. package/dist/utils/errors.js +172 -0
  430. package/dist/utils/errors.js.map +1 -0
  431. package/dist/utils/gateway-sync.d.ts +26 -0
  432. package/dist/utils/gateway-sync.d.ts.map +1 -0
  433. package/dist/utils/gateway-sync.js +61 -0
  434. package/dist/utils/gateway-sync.js.map +1 -0
  435. package/dist/utils/path-security.d.ts +2 -0
  436. package/dist/utils/path-security.d.ts.map +1 -0
  437. package/dist/utils/path-security.js +10 -0
  438. package/dist/utils/path-security.js.map +1 -0
  439. package/dist/utils/plan-diff.d.ts +25 -0
  440. package/dist/utils/plan-diff.d.ts.map +1 -0
  441. package/dist/utils/plan-diff.js +62 -0
  442. package/dist/utils/plan-diff.js.map +1 -0
  443. package/dist/utils/plans.d.ts +56 -0
  444. package/dist/utils/plans.d.ts.map +1 -0
  445. package/dist/utils/plans.js +117 -0
  446. package/dist/utils/plans.js.map +1 -0
  447. package/dist/utils/project.d.ts +160 -0
  448. package/dist/utils/project.d.ts.map +1 -0
  449. package/dist/utils/project.js +364 -0
  450. package/dist/utils/project.js.map +1 -0
  451. package/dist/utils/signals-pubsub.d.ts +41 -0
  452. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  453. package/dist/utils/signals-pubsub.js +122 -0
  454. package/dist/utils/signals-pubsub.js.map +1 -0
  455. package/dist/utils/slash-command-loader.d.ts +52 -0
  456. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  457. package/dist/utils/slash-command-loader.js +141 -0
  458. package/dist/utils/slash-command-loader.js.map +1 -0
  459. package/dist/utils/slash-command-processor.d.ts +14 -0
  460. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  461. package/dist/utils/slash-command-processor.js +105 -0
  462. package/dist/utils/slash-command-processor.js.map +1 -0
  463. package/dist/utils/stdin-pipe.d.ts +33 -0
  464. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  465. package/dist/utils/stdin-pipe.js +96 -0
  466. package/dist/utils/stdin-pipe.js.map +1 -0
  467. package/dist/utils/storage-factory.d.ts +50 -0
  468. package/dist/utils/storage-factory.d.ts.map +1 -0
  469. package/dist/utils/storage-factory.js +121 -0
  470. package/dist/utils/storage-factory.js.map +1 -0
  471. package/dist/utils/storage-maintenance.d.ts +103 -0
  472. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  473. package/dist/utils/storage-maintenance.js +274 -0
  474. package/dist/utils/storage-maintenance.js.map +1 -0
  475. package/dist/utils/thread-lock.d.ts +26 -0
  476. package/dist/utils/thread-lock.d.ts.map +1 -0
  477. package/dist/utils/thread-lock.js +112 -0
  478. package/dist/utils/thread-lock.js.map +1 -0
  479. package/dist/utils/token-estimator.d.ts +3 -0
  480. package/dist/utils/token-estimator.d.ts.map +1 -0
  481. package/dist/utils/token-estimator.js +21 -0
  482. package/dist/utils/token-estimator.js.map +1 -0
  483. package/dist/utils/update-check.d.ts +101 -0
  484. package/dist/utils/update-check.d.ts.map +1 -0
  485. package/dist/utils/update-check.js +383 -0
  486. package/dist/utils/update-check.js.map +1 -0
  487. package/dist/voice/stt-registry.d.ts +64 -0
  488. package/dist/voice/stt-registry.d.ts.map +1 -0
  489. package/dist/voice/stt-registry.js +144 -0
  490. package/dist/voice/stt-registry.js.map +1 -0
  491. package/package.json +96 -0
@@ -0,0 +1,59 @@
1
+ import type { GatewayLanguageModel, MastraModelGatewayInterface } from '@mastra/core/llm';
2
+ import type { RequestContext } from '@mastra/core/request-context';
3
+ import type { ThinkingLevel } from '../providers/openai-codex.js';
4
+ import { MastraCodeGateway } from './mastracode-gateway.js';
5
+ import type { MastraCodeGatewayOptions } from './mastracode-gateway.js';
6
+ export { getAnthropicApiKey, getOpenAIApiKey, MASTRACODE_GATEWAY_ID, MastraCodeGateway, remapOpenAIModelForCodexOAuth, resolveAuth, } from './mastracode-gateway.js';
7
+ export type { MastraCodeCustomProvider, MastraCodeGatewayOptions } from './mastracode-gateway.js';
8
+ export { setCredentialStoreProvider, hasCredentialStoreProvider, resolveTenantFromRequestContext, } from './credential-resolver.js';
9
+ export type { CredentialTenant, CredentialStoreProvider } from './credential-resolver.js';
10
+ export { setCustomProvidersSource, hasCustomProvidersSource, resolveCustomProviders, } from './custom-provider-source.js';
11
+ export type { CustomProvidersSource } from './custom-provider-source.js';
12
+ type ResolvedModel = GatewayLanguageModel;
13
+ export declare function createMastraCodeGateway(options: MastraCodeGatewayOptions): MastraCodeGateway;
14
+ export declare function createMastraCodeModelCatalogProvider(gateway: MastraModelGatewayInterface): import("@mastra/core/harness").CustomModelCatalogProvider;
15
+ /**
16
+ * Placeholder for future model ID normalization.
17
+ * Currently returns the input unchanged, but exists as a seam
18
+ * for aliasing, casing fixes, or validation in the future.
19
+ */
20
+ export declare function resolveModelId(modelId: string): string;
21
+ /**
22
+ * Resolve a model ID to the correct provider instance.
23
+ * Shared by the main agent, observer, and reflector.
24
+ *
25
+ * - For anthropic/* models: Uses stored OAuth credentials when present, otherwise direct API key
26
+ * - For openai/* models: Uses OAuth when configured, otherwise direct API key from AuthStorage
27
+ * - For moonshotai/* models: Uses Moonshot AI Anthropic-compatible endpoint
28
+ * - For all other providers: Uses Mastra's model router (models.dev gateway)
29
+ */
30
+ export declare function resolveModel(modelId: string, options?: {
31
+ thinkingLevel?: ThinkingLevel;
32
+ remapForCodexOAuth?: boolean;
33
+ requestContext?: RequestContext;
34
+ }): GatewayLanguageModel;
35
+ /**
36
+ * Dynamic model function that reads the current model from controller state.
37
+ * This allows runtime model switching via the /models picker.
38
+ */
39
+ export declare function getDynamicModel({ requestContext }: {
40
+ requestContext: RequestContext;
41
+ }): ResolvedModel;
42
+ /**
43
+ * Goal judge model resolver for the agent's `goal.judge` config. Resolves the
44
+ * configured goal judge model through mastracode's gateway so provider
45
+ * credentials (stored in auth storage, not just env) are injected — a bare model
46
+ * id handed to core's default model router would fail to find the API key.
47
+ *
48
+ * Returns `undefined` when no judge model is configured, which keeps the goal
49
+ * step a complete no-op (the goal mechanism requires a judge to do anything).
50
+ *
51
+ * `settingsPath` must be the same source `createMastraCode()` reads from so the
52
+ * judge model and the goal budget (`goalMaxTurns`) come from one config — with a
53
+ * custom `settingsPath` a bare `loadSettings()` here could read a different file
54
+ * and silently turn the goal step into a no-op.
55
+ */
56
+ export declare function getGoalJudgeModel({ requestContext }: {
57
+ requestContext: RequestContext;
58
+ }, settingsPath?: string): ResolvedModel | undefined;
59
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/agents/model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,OAAO,EAGL,iBAAiB,EAGlB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,6BAA6B,EAC7B,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEzE,KAAK,aAAa,GAAG,oBAAoB,CAAC;AAa1C,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CAE5F;AAED,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,2BAA2B,6DAIxF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,aAAa,CAAC;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CAAE,GACzG,oBAAoB,CA+EtB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,GAAG,aAAa,CAWrG;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,EACtD,YAAY,CAAC,EAAE,MAAM,GACpB,aAAa,GAAG,SAAS,CAI3B"}
@@ -0,0 +1,132 @@
1
+ import { loadSettings, stripMastraCodeCustomProviderPrefix } from "../onboarding/settings.js";
2
+ import { hasCredentialStoreProvider, resolveCredentialStore, resolveTenantFromRequestContext, setCredentialStoreProvider } from "./credential-resolver.js";
3
+ import { AMAZON_BEDROCK_GATEWAY_ID, createAmazonBedrockGateway } from "../providers/amazon-bedrock-gateway.js";
4
+ import { hasCustomProvidersSource, resolveCustomProviders, setCustomProvidersSource } from "./custom-provider-source.js";
5
+ import { MASTRACODE_GATEWAY_ID, MASTRA_GATEWAY_PREFIX, MastraCodeGateway, getAnthropicApiKey, getOpenAIApiKey, reloadAuthStorage, remapOpenAIModelForCodexOAuth, resolveAuth, stripMastraGatewayPrefix } from "./mastracode-gateway.js";
6
+ //#region src/agents/model.ts
7
+ function getAgentControllerHeaders(requestContext) {
8
+ const agentControllerContext = requestContext?.get("controller");
9
+ const headers = {
10
+ ...agentControllerContext?.threadId ? { "x-thread-id": agentControllerContext.threadId } : {},
11
+ ...agentControllerContext?.resourceId ? { "x-resource-id": agentControllerContext.resourceId } : {}
12
+ };
13
+ return Object.keys(headers).length > 0 ? headers : void 0;
14
+ }
15
+ function createMastraCodeGateway(options) {
16
+ return new MastraCodeGateway(options);
17
+ }
18
+ function createMastraCodeModelCatalogProvider(gateway) {
19
+ return gateway instanceof MastraCodeGateway ? gateway.createModelCatalogProvider() : MastraCodeGateway.createModelCatalogProvider(gateway);
20
+ }
21
+ /**
22
+ * Placeholder for future model ID normalization.
23
+ * Currently returns the input unchanged, but exists as a seam
24
+ * for aliasing, casing fixes, or validation in the future.
25
+ */
26
+ function resolveModelId(modelId) {
27
+ return modelId;
28
+ }
29
+ /**
30
+ * Resolve a model ID to the correct provider instance.
31
+ * Shared by the main agent, observer, and reflector.
32
+ *
33
+ * - For anthropic/* models: Uses stored OAuth credentials when present, otherwise direct API key
34
+ * - For openai/* models: Uses OAuth when configured, otherwise direct API key from AuthStorage
35
+ * - For moonshotai/* models: Uses Moonshot AI Anthropic-compatible endpoint
36
+ * - For all other providers: Uses Mastra's model router (models.dev gateway)
37
+ */
38
+ function resolveModel(modelId, options) {
39
+ reloadAuthStorage();
40
+ const headers = getAgentControllerHeaders(options?.requestContext);
41
+ const settings = loadSettings();
42
+ const bedrockLegacyPrefix = `${MASTRACODE_GATEWAY_ID}/amazon-bedrock/`;
43
+ const bedrockNormalizedInput = modelId.startsWith(bedrockLegacyPrefix) ? modelId.slice(MASTRACODE_GATEWAY_ID.length + 1) : modelId;
44
+ const customProviders = resolveCustomProviders(options?.requestContext) ?? settings.customProviders;
45
+ const normalizedInput = stripMastraCodeCustomProviderPrefix(bedrockNormalizedInput, customProviders);
46
+ const isMastraGatewayModel = normalizedInput.startsWith(MASTRA_GATEWAY_PREFIX);
47
+ const normalizedModelId = stripMastraGatewayPrefix(normalizedInput);
48
+ const [providerId, ...modelParts] = normalizedModelId.split("/");
49
+ const bareModelId = modelParts.join("/");
50
+ if (!providerId || !bareModelId) throw new Error(`Invalid model id: ${modelId}`);
51
+ if (providerId === "amazon-bedrock") {
52
+ const bedrockGateway = createAmazonBedrockGateway();
53
+ const routerId = `${AMAZON_BEDROCK_GATEWAY_ID}/${bareModelId}`;
54
+ const auth = bedrockGateway.resolveAuth({
55
+ gatewayId: AMAZON_BEDROCK_GATEWAY_ID,
56
+ providerId: AMAZON_BEDROCK_GATEWAY_ID,
57
+ modelId: bareModelId,
58
+ routerId
59
+ });
60
+ return bedrockGateway.resolveLanguageModel({
61
+ providerId: AMAZON_BEDROCK_GATEWAY_ID,
62
+ modelId: bareModelId,
63
+ apiKey: auth?.apiKey ?? "",
64
+ headers
65
+ });
66
+ }
67
+ const routerId = `${MASTRACODE_GATEWAY_ID}/${normalizedModelId}`;
68
+ const mgApiKey = MastraCodeGateway.getMastraGatewayApiKey();
69
+ const rawGatewayBase = settings.memoryGateway?.baseUrl ?? process.env["MASTRA_GATEWAY_URL"] ?? "https://gateway-api.mastra.ai";
70
+ const credentialStore = resolveCredentialStore(options?.requestContext);
71
+ const gateway = createMastraCodeGateway({
72
+ mastraGatewayBaseUrl: rawGatewayBase.replace(/\/+$/, "").replace(/\/v1$/, ""),
73
+ mastraGatewayApiKey: mgApiKey,
74
+ routeThroughMastraGateway: Boolean(mgApiKey && isMastraGatewayModel),
75
+ thinkingLevel: options?.thinkingLevel,
76
+ customProviders,
77
+ credentialStore
78
+ });
79
+ const auth = gateway.resolveAuth({
80
+ gatewayId: MASTRACODE_GATEWAY_ID,
81
+ providerId,
82
+ modelId: bareModelId,
83
+ routerId
84
+ });
85
+ return gateway.resolveLanguageModel({
86
+ providerId,
87
+ modelId: bareModelId,
88
+ apiKey: auth?.apiKey ?? mgApiKey ?? "",
89
+ headers
90
+ });
91
+ }
92
+ /**
93
+ * Dynamic model function that reads the current model from controller state.
94
+ * This allows runtime model switching via the /models picker.
95
+ */
96
+ function getDynamicModel({ requestContext }) {
97
+ const agentControllerContext = requestContext.get("controller");
98
+ const modelId = agentControllerContext?.session?.modelId;
99
+ if (!modelId) throw new Error("No model selected. Use /models to select a model first.");
100
+ const thinkingLevel = agentControllerContext?.state?.thinkingLevel;
101
+ return resolveModel(modelId, {
102
+ thinkingLevel,
103
+ remapForCodexOAuth: true,
104
+ requestContext
105
+ });
106
+ }
107
+ /**
108
+ * Goal judge model resolver for the agent's `goal.judge` config. Resolves the
109
+ * configured goal judge model through mastracode's gateway so provider
110
+ * credentials (stored in auth storage, not just env) are injected — a bare model
111
+ * id handed to core's default model router would fail to find the API key.
112
+ *
113
+ * Returns `undefined` when no judge model is configured, which keeps the goal
114
+ * step a complete no-op (the goal mechanism requires a judge to do anything).
115
+ *
116
+ * `settingsPath` must be the same source `createMastraCode()` reads from so the
117
+ * judge model and the goal budget (`goalMaxTurns`) come from one config — with a
118
+ * custom `settingsPath` a bare `loadSettings()` here could read a different file
119
+ * and silently turn the goal step into a no-op.
120
+ */
121
+ function getGoalJudgeModel({ requestContext }, settingsPath) {
122
+ const judgeModelId = loadSettings(settingsPath).models.goalJudgeModel;
123
+ if (!judgeModelId) return void 0;
124
+ return resolveModel(judgeModelId, {
125
+ remapForCodexOAuth: true,
126
+ requestContext
127
+ });
128
+ }
129
+ //#endregion
130
+ export { MASTRACODE_GATEWAY_ID, MastraCodeGateway, createMastraCodeGateway, createMastraCodeModelCatalogProvider, getAnthropicApiKey, getDynamicModel, getGoalJudgeModel, getOpenAIApiKey, hasCredentialStoreProvider, hasCustomProvidersSource, remapOpenAIModelForCodexOAuth, resolveAuth, resolveCustomProviders, resolveModel, resolveModelId, resolveTenantFromRequestContext, setCredentialStoreProvider, setCustomProvidersSource };
131
+
132
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":[],"sources":["../../src/agents/model.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { GatewayLanguageModel, MastraModelGatewayInterface } from '@mastra/core/llm';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { loadSettings, stripMastraCodeCustomProviderPrefix } from '../onboarding/settings.js';\nimport { AMAZON_BEDROCK_GATEWAY_ID, createAmazonBedrockGateway } from '../providers/amazon-bedrock-gateway.js';\nimport type { ThinkingLevel } from '../providers/openai-codex.js';\nimport { resolveCredentialStore } from './credential-resolver.js';\nimport { resolveCustomProviders } from './custom-provider-source.js';\nimport {\n MASTRA_GATEWAY_PREFIX,\n MASTRACODE_GATEWAY_ID,\n MastraCodeGateway,\n reloadAuthStorage,\n stripMastraGatewayPrefix,\n} from './mastracode-gateway.js';\nimport type { MastraCodeGatewayOptions } from './mastracode-gateway.js';\n\nexport {\n getAnthropicApiKey,\n getOpenAIApiKey,\n MASTRACODE_GATEWAY_ID,\n MastraCodeGateway,\n remapOpenAIModelForCodexOAuth,\n resolveAuth,\n} from './mastracode-gateway.js';\nexport type { MastraCodeCustomProvider, MastraCodeGatewayOptions } from './mastracode-gateway.js';\nexport {\n setCredentialStoreProvider,\n hasCredentialStoreProvider,\n resolveTenantFromRequestContext,\n} from './credential-resolver.js';\nexport type { CredentialTenant, CredentialStoreProvider } from './credential-resolver.js';\nexport {\n setCustomProvidersSource,\n hasCustomProvidersSource,\n resolveCustomProviders,\n} from './custom-provider-source.js';\nexport type { CustomProvidersSource } from './custom-provider-source.js';\n\ntype ResolvedModel = GatewayLanguageModel;\ntype ModelRequestHeaders = Record<string, string>;\n\nfunction getAgentControllerHeaders(requestContext?: RequestContext): ModelRequestHeaders | undefined {\n const agentControllerContext = requestContext?.get('controller') as AgentControllerRequestContext<any> | undefined;\n const headers = {\n ...(agentControllerContext?.threadId ? { 'x-thread-id': agentControllerContext.threadId } : {}),\n ...(agentControllerContext?.resourceId ? { 'x-resource-id': agentControllerContext.resourceId } : {}),\n };\n\n return Object.keys(headers).length > 0 ? headers : undefined;\n}\n\nexport function createMastraCodeGateway(options: MastraCodeGatewayOptions): MastraCodeGateway {\n return new MastraCodeGateway(options);\n}\n\nexport function createMastraCodeModelCatalogProvider(gateway: MastraModelGatewayInterface) {\n return gateway instanceof MastraCodeGateway\n ? gateway.createModelCatalogProvider()\n : MastraCodeGateway.createModelCatalogProvider(gateway);\n}\n\n/**\n * Placeholder for future model ID normalization.\n * Currently returns the input unchanged, but exists as a seam\n * for aliasing, casing fixes, or validation in the future.\n */\nexport function resolveModelId(modelId: string): string {\n return modelId;\n}\n\n/**\n * Resolve a model ID to the correct provider instance.\n * Shared by the main agent, observer, and reflector.\n *\n * - For anthropic/* models: Uses stored OAuth credentials when present, otherwise direct API key\n * - For openai/* models: Uses OAuth when configured, otherwise direct API key from AuthStorage\n * - For moonshotai/* models: Uses Moonshot AI Anthropic-compatible endpoint\n * - For all other providers: Uses Mastra's model router (models.dev gateway)\n */\nexport function resolveModel(\n modelId: string,\n options?: { thinkingLevel?: ThinkingLevel; remapForCodexOAuth?: boolean; requestContext?: RequestContext },\n): GatewayLanguageModel {\n reloadAuthStorage();\n const headers = getAgentControllerHeaders(options?.requestContext);\n const settings = loadSettings();\n // Bedrock was previously cataloged under the MastraCode gateway namespace\n // (`mastracode/amazon-bedrock/<model>`). Normalize any legacy saved ids to the\n // standalone `amazon-bedrock/<model>` form so they resolve through the\n // dedicated Bedrock gateway.\n const bedrockLegacyPrefix = `${MASTRACODE_GATEWAY_ID}/amazon-bedrock/`;\n const bedrockNormalizedInput = modelId.startsWith(bedrockLegacyPrefix)\n ? modelId.slice(MASTRACODE_GATEWAY_ID.length + 1)\n : modelId;\n // Deployed web registers a custom providers source (DB-backed, tenant\n // scoped); when registered it is authoritative and settings.json custom\n // providers are ignored. Undefined = local settings-based behavior.\n const customProviders = resolveCustomProviders(options?.requestContext) ?? settings.customProviders;\n // Ids selected from the shared /models catalog were previously persisted in\n // the gateway-qualified `mastracode/<customProviderId>/<model>` form, which\n // parses the provider as `mastracode` and breaks provider config lookup.\n // Normalize at resolution time (in addition to stripping at selection time)\n // so already-saved ids and any surface that persists the raw catalog id\n // still resolve to the custom provider.\n const normalizedInput = stripMastraCodeCustomProviderPrefix(bedrockNormalizedInput, customProviders);\n const isMastraGatewayModel = normalizedInput.startsWith(MASTRA_GATEWAY_PREFIX);\n const normalizedModelId = stripMastraGatewayPrefix(normalizedInput);\n const [providerId, ...modelParts] = normalizedModelId.split('/');\n const bareModelId = modelParts.join('/');\n if (!providerId || !bareModelId) {\n throw new Error(`Invalid model id: ${modelId}`);\n }\n\n if (providerId === AMAZON_BEDROCK_GATEWAY_ID) {\n const bedrockGateway = createAmazonBedrockGateway();\n const routerId = `${AMAZON_BEDROCK_GATEWAY_ID}/${bareModelId}`;\n const auth = bedrockGateway.resolveAuth({\n gatewayId: AMAZON_BEDROCK_GATEWAY_ID,\n providerId: AMAZON_BEDROCK_GATEWAY_ID,\n modelId: bareModelId,\n routerId,\n });\n return bedrockGateway.resolveLanguageModel({\n providerId: AMAZON_BEDROCK_GATEWAY_ID,\n modelId: bareModelId,\n apiKey: auth?.apiKey ?? '',\n headers,\n });\n }\n\n const routerId = `${MASTRACODE_GATEWAY_ID}/${normalizedModelId}`;\n\n const mgApiKey = MastraCodeGateway.getMastraGatewayApiKey();\n const rawGatewayBase =\n settings.memoryGateway?.baseUrl ?? process.env['MASTRA_GATEWAY_URL'] ?? 'https://gateway-api.mastra.ai';\n // Deployed web registers a per-tenant credential store provider; when the\n // request carries an authenticated tenant, resolve credentials through the\n // caller's own store (user > org > env). Undefined = global AuthStorage.\n const credentialStore = resolveCredentialStore(options?.requestContext);\n const gateway = createMastraCodeGateway({\n mastraGatewayBaseUrl: rawGatewayBase.replace(/\\/+$/, '').replace(/\\/v1$/, ''),\n mastraGatewayApiKey: mgApiKey,\n routeThroughMastraGateway: Boolean(mgApiKey && isMastraGatewayModel),\n thinkingLevel: options?.thinkingLevel,\n customProviders,\n credentialStore,\n });\n\n const auth = gateway.resolveAuth({\n gatewayId: MASTRACODE_GATEWAY_ID,\n providerId,\n modelId: bareModelId,\n routerId,\n });\n\n return gateway.resolveLanguageModel({\n providerId,\n modelId: bareModelId,\n apiKey: auth?.apiKey ?? mgApiKey ?? '',\n headers,\n });\n}\n\n/**\n * Dynamic model function that reads the current model from controller state.\n * This allows runtime model switching via the /models picker.\n */\nexport function getDynamicModel({ requestContext }: { requestContext: RequestContext }): ResolvedModel {\n const agentControllerContext = requestContext.get('controller') as AgentControllerRequestContext<any> | undefined;\n\n const modelId = agentControllerContext?.session?.modelId;\n if (!modelId) {\n throw new Error('No model selected. Use /models to select a model first.');\n }\n\n const thinkingLevel = agentControllerContext?.state?.thinkingLevel as ThinkingLevel | undefined;\n\n return resolveModel(modelId, { thinkingLevel, remapForCodexOAuth: true, requestContext });\n}\n\n/**\n * Goal judge model resolver for the agent's `goal.judge` config. Resolves the\n * configured goal judge model through mastracode's gateway so provider\n * credentials (stored in auth storage, not just env) are injected — a bare model\n * id handed to core's default model router would fail to find the API key.\n *\n * Returns `undefined` when no judge model is configured, which keeps the goal\n * step a complete no-op (the goal mechanism requires a judge to do anything).\n *\n * `settingsPath` must be the same source `createMastraCode()` reads from so the\n * judge model and the goal budget (`goalMaxTurns`) come from one config — with a\n * custom `settingsPath` a bare `loadSettings()` here could read a different file\n * and silently turn the goal step into a no-op.\n */\nexport function getGoalJudgeModel(\n { requestContext }: { requestContext: RequestContext },\n settingsPath?: string,\n): ResolvedModel | undefined {\n const judgeModelId = loadSettings(settingsPath).models.goalJudgeModel;\n if (!judgeModelId) return undefined;\n return resolveModel(judgeModelId, { remapForCodexOAuth: true, requestContext });\n}\n"],"mappings":";;;;;;AA0CA,SAAS,0BAA0B,gBAAkE;CACnG,MAAM,yBAAyB,gBAAgB,IAAI,YAAY;CAC/D,MAAM,UAAU;EACd,GAAI,wBAAwB,WAAW,EAAE,eAAe,uBAAuB,SAAS,IAAI,CAAC;EAC7F,GAAI,wBAAwB,aAAa,EAAE,iBAAiB,uBAAuB,WAAW,IAAI,CAAC;CACrG;CAEA,OAAO,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,IAAI,UAAU,KAAA;AACrD;AAEA,SAAgB,wBAAwB,SAAsD;CAC5F,OAAO,IAAI,kBAAkB,OAAO;AACtC;AAEA,SAAgB,qCAAqC,SAAsC;CACzF,OAAO,mBAAmB,oBACtB,QAAQ,2BAA2B,IACnC,kBAAkB,2BAA2B,OAAO;AAC1D;;;;;;AAOA,SAAgB,eAAe,SAAyB;CACtD,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,aACd,SACA,SACsB;CACtB,kBAAkB;CAClB,MAAM,UAAU,0BAA0B,SAAS,cAAc;CACjE,MAAM,WAAW,aAAa;CAK9B,MAAM,sBAAsB,GAAG,sBAAsB;CACrD,MAAM,yBAAyB,QAAQ,WAAW,mBAAmB,IACjE,QAAQ,MAAM,sBAAsB,SAAS,CAAC,IAC9C;CAIJ,MAAM,kBAAkB,uBAAuB,SAAS,cAAc,KAAK,SAAS;CAOpF,MAAM,kBAAkB,oCAAoC,wBAAwB,eAAe;CACnG,MAAM,uBAAuB,gBAAgB,WAAW,qBAAqB;CAC7E,MAAM,oBAAoB,yBAAyB,eAAe;CAClE,MAAM,CAAC,YAAY,GAAG,cAAc,kBAAkB,MAAM,GAAG;CAC/D,MAAM,cAAc,WAAW,KAAK,GAAG;CACvC,IAAI,CAAC,cAAc,CAAC,aAClB,MAAM,IAAI,MAAM,qBAAqB,SAAS;CAGhD,IAAI,eAAA,kBAA0C;EAC5C,MAAM,iBAAiB,2BAA2B;EAClD,MAAM,WAAW,GAAG,0BAA0B,GAAG;EACjD,MAAM,OAAO,eAAe,YAAY;GACtC,WAAW;GACX,YAAY;GACZ,SAAS;GACT;EACF,CAAC;EACD,OAAO,eAAe,qBAAqB;GACzC,YAAY;GACZ,SAAS;GACT,QAAQ,MAAM,UAAU;GACxB;EACF,CAAC;CACH;CAEA,MAAM,WAAW,GAAG,sBAAsB,GAAG;CAE7C,MAAM,WAAW,kBAAkB,uBAAuB;CAC1D,MAAM,iBACJ,SAAS,eAAe,WAAW,QAAQ,IAAI,yBAAyB;CAI1E,MAAM,kBAAkB,uBAAuB,SAAS,cAAc;CACtE,MAAM,UAAU,wBAAwB;EACtC,sBAAsB,eAAe,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,SAAS,EAAE;EAC5E,qBAAqB;EACrB,2BAA2B,QAAQ,YAAY,oBAAoB;EACnE,eAAe,SAAS;EACxB;EACA;CACF,CAAC;CAED,MAAM,OAAO,QAAQ,YAAY;EAC/B,WAAW;EACX;EACA,SAAS;EACT;CACF,CAAC;CAED,OAAO,QAAQ,qBAAqB;EAClC;EACA,SAAS;EACT,QAAQ,MAAM,UAAU,YAAY;EACpC;CACF,CAAC;AACH;;;;;AAMA,SAAgB,gBAAgB,EAAE,kBAAqE;CACrG,MAAM,yBAAyB,eAAe,IAAI,YAAY;CAE9D,MAAM,UAAU,wBAAwB,SAAS;CACjD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,yDAAyD;CAG3E,MAAM,gBAAgB,wBAAwB,OAAO;CAErD,OAAO,aAAa,SAAS;EAAE;EAAe,oBAAoB;EAAM;CAAe,CAAC;AAC1F;;;;;;;;;;;;;;;AAgBA,SAAgB,kBACd,EAAE,kBACF,cAC2B;CAC3B,MAAM,eAAe,aAAa,YAAY,CAAC,CAAC,OAAO;CACvD,IAAI,CAAC,cAAc,OAAO,KAAA;CAC1B,OAAO,aAAa,cAAc;EAAE,oBAAoB;EAAM;CAAe,CAAC;AAChF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Execute subagent — focused task execution with write capabilities.
3
+ *
4
+ * This subagent is given a specific implementation task and uses both
5
+ * read and write tools to complete it. It can modify files, run commands,
6
+ * and perform actual development work within a constrained scope.
7
+ */
8
+ import type { AgentControllerMode } from '@mastra/core/agent-controller';
9
+ export declare const buildMode: AgentControllerMode;
10
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/agents/modes/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,eAAO,MAAM,SAAS,EAAE,mBAyCvB,CAAC"}
@@ -0,0 +1,44 @@
1
+ //#region src/agents/modes/build.ts
2
+ const buildMode = {
3
+ id: "build",
4
+ name: "Build",
5
+ description: "Task execution with write capabilities. Use for 'implement feature X', 'fix bug Y', 'refactor module Z'.",
6
+ instructions: `You are a focused execution agent. Your job is to complete a specific, well-defined task by making the necessary changes to the codebase.
7
+
8
+ ## Rules
9
+ - You have FULL ACCESS to read, write, and execute within your task scope.
10
+ - Stay focused on the specific task given. Do not make unrelated changes.
11
+ - Read files before modifying them — use view first, then string_replace_lsp or write_file.
12
+ - Verify your changes work by running relevant tests or checking for errors.
13
+
14
+ ## Tool Strategy
15
+ - **Read first**: Always view a file before editing it
16
+ - **Edit precisely**: Use string_replace_lsp with enough context to match uniquely
17
+ - **Use specialized tools**: Prefer view/search_content/find_files over shell commands for reading
18
+ - **Parallelize**: Make independent tool calls together (e.g., view multiple files at once)
19
+
20
+ ## Workflow
21
+ . Understand the task and explore relevant code
22
+ . For complex tasks (3+ steps): track progress internally and summarize it in your final answer
23
+ . Make changes incrementally — verify each change before moving on
24
+ . Run tests or type-check to verify
25
+
26
+ ## Efficiency
27
+ Your output returns to the parent agent. Be concise:
28
+ - Don't repeat file contents in your response
29
+ - Summarize what changed, don't narrate each step
30
+ - Keep your final summary under 300 words
31
+
32
+ ## Output Format
33
+ End with a structured summary:
34
+ . **Completed**: What you implemented (1-2 sentences)
35
+ . **Changes**: Files modified/created
36
+ . **Verification**: How you verified it works
37
+ . **Notes**: Follow-up needed (if any)`,
38
+ defaultModelId: "openai/gpt-5.5",
39
+ metadata: { default: true }
40
+ };
41
+ //#endregion
42
+ export { buildMode };
43
+
44
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","names":[],"sources":["../../../src/agents/modes/build.ts"],"sourcesContent":["/**\n * Execute subagent — focused task execution with write capabilities.\n *\n * This subagent is given a specific implementation task and uses both\n * read and write tools to complete it. It can modify files, run commands,\n * and perform actual development work within a constrained scope.\n */\nimport type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nexport const buildMode: AgentControllerMode = {\n id: 'build',\n name: 'Build',\n description:\n \"Task execution with write capabilities. Use for 'implement feature X', 'fix bug Y', 'refactor module Z'.\",\n instructions: `You are a focused execution agent. Your job is to complete a specific, well-defined task by making the necessary changes to the codebase.\n\n## Rules\n- You have FULL ACCESS to read, write, and execute within your task scope.\n- Stay focused on the specific task given. Do not make unrelated changes.\n- Read files before modifying them — use view first, then string_replace_lsp or write_file.\n- Verify your changes work by running relevant tests or checking for errors.\n\n## Tool Strategy\n- **Read first**: Always view a file before editing it\n- **Edit precisely**: Use string_replace_lsp with enough context to match uniquely\n- **Use specialized tools**: Prefer view/search_content/find_files over shell commands for reading\n- **Parallelize**: Make independent tool calls together (e.g., view multiple files at once)\n\n## Workflow\n. Understand the task and explore relevant code\n. For complex tasks (3+ steps): track progress internally and summarize it in your final answer\n. Make changes incrementally — verify each change before moving on\n. Run tests or type-check to verify\n\n## Efficiency\nYour output returns to the parent agent. Be concise:\n- Don't repeat file contents in your response\n- Summarize what changed, don't narrate each step\n- Keep your final summary under 300 words\n\n## Output Format\nEnd with a structured summary:\n. **Completed**: What you implemented (1-2 sentences)\n. **Changes**: Files modified/created\n. **Verification**: How you verified it works\n. **Notes**: Follow-up needed (if any)`,\n defaultModelId: 'openai/gpt-5.5',\n metadata: {\n default: true,\n },\n};\n"],"mappings":";AASA,MAAa,YAAiC;CAC5C,IAAI;CACJ,MAAM;CACN,aACE;CACF,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCd,gBAAgB;CAChB,UAAU,EACR,SAAS,KACX;AACF"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Explore subagent — read-only codebase exploration.
3
+ *
4
+ * This subagent is given a focused task (e.g., "find all usages of X",
5
+ * "understand how module Y works") and uses read-only tools to explore
6
+ * the codebase, then returns a concise summary of its findings.
7
+ */
8
+ import type { AgentControllerMode } from '@mastra/core/agent-controller';
9
+ export declare const fastMode: AgentControllerMode;
10
+ //# sourceMappingURL=explore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../../src/agents/modes/explore.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,eAAO,MAAM,QAAQ,EAAE,mBAkCtB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { EXPLORE_MODE_AVAILABLE_TOOLS } from "../tool-availability.js";
2
+ //#region src/agents/modes/explore.ts
3
+ const fastMode = {
4
+ id: "fast",
5
+ name: "Explore",
6
+ description: "Read-only codebase exploration. Use for questions like 'find all usages of X', 'how does module Y work'.",
7
+ defaultModelId: "openai/gpt-5.4-mini",
8
+ instructions: `You are an expert code explorer. Your job is to investigate a codebase and answer a specific question or gather specific information.
9
+
10
+ ## Rules
11
+ - You have READ-ONLY access. You cannot modify files or run commands.
12
+ - Be thorough — search broadly first, then drill into relevant files.
13
+ - After gathering enough information, produce a clear, concise summary of your findings.
14
+
15
+ ## Tool Strategy
16
+ - **Start broad**: Use find_files (glob) to understand project structure
17
+ - **Search smart**: Use search_content (grep) with specific patterns — avoid overly broad searches
18
+ - **Read efficiently**: Use view with view_range for large files — don't read entire files if you only need a section
19
+ - **Parallelize**: Make multiple independent tool calls in one round when exploring different areas
20
+
21
+ ## Efficiency
22
+ Your output returns to the parent agent. Be concise:
23
+ - Don't include raw file contents in your response — summarize what you found
24
+ - Reference files by path and line number, not by copying code
25
+ - If a search returns many results, report the count and key examples, not every match
26
+
27
+ ## Output Format
28
+ End with a structured summary:
29
+ . **Answer**: Direct answer to the question (1-2 sentences)
30
+ . **Key Files**: Most relevant files with line numbers
31
+ . **Details**: Additional context if needed
32
+
33
+ Keep your summary under 300 words.`,
34
+ availableTools: [...EXPLORE_MODE_AVAILABLE_TOOLS]
35
+ };
36
+ //#endregion
37
+ export { fastMode };
38
+
39
+ //# sourceMappingURL=explore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explore.js","names":[],"sources":["../../../src/agents/modes/explore.ts"],"sourcesContent":["/**\n * Explore subagent — read-only codebase exploration.\n *\n * This subagent is given a focused task (e.g., \"find all usages of X\",\n * \"understand how module Y works\") and uses read-only tools to explore\n * the codebase, then returns a concise summary of its findings.\n */\nimport type { AgentControllerMode } from '@mastra/core/agent-controller';\nimport { EXPLORE_MODE_AVAILABLE_TOOLS } from '../tool-availability.js';\n\nexport const fastMode: AgentControllerMode = {\n id: 'fast',\n name: 'Explore',\n description:\n \"Read-only codebase exploration. Use for questions like 'find all usages of X', 'how does module Y work'.\",\n defaultModelId: 'openai/gpt-5.4-mini',\n instructions: `You are an expert code explorer. Your job is to investigate a codebase and answer a specific question or gather specific information.\n\n## Rules\n- You have READ-ONLY access. You cannot modify files or run commands.\n- Be thorough — search broadly first, then drill into relevant files.\n- After gathering enough information, produce a clear, concise summary of your findings.\n\n## Tool Strategy\n- **Start broad**: Use find_files (glob) to understand project structure\n- **Search smart**: Use search_content (grep) with specific patterns — avoid overly broad searches\n- **Read efficiently**: Use view with view_range for large files — don't read entire files if you only need a section\n- **Parallelize**: Make multiple independent tool calls in one round when exploring different areas\n\n## Efficiency\nYour output returns to the parent agent. Be concise:\n- Don't include raw file contents in your response — summarize what you found\n- Reference files by path and line number, not by copying code\n- If a search returns many results, report the count and key examples, not every match\n\n## Output Format\nEnd with a structured summary:\n. **Answer**: Direct answer to the question (1-2 sentences)\n. **Key Files**: Most relevant files with line numbers\n. **Details**: Additional context if needed\n\nKeep your summary under 300 words.`,\n\n availableTools: [...EXPLORE_MODE_AVAILABLE_TOOLS],\n};\n"],"mappings":";;AAUA,MAAa,WAAgC;CAC3C,IAAI;CACJ,MAAM;CACN,aACE;CACF,gBAAgB;CAChB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;CA2Bd,gBAAgB,CAAC,GAAG,4BAA4B;AAClD"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Plan mode — read-only analysis and planning.
3
+ */
4
+ import type { AgentControllerMode } from '@mastra/core/agent-controller';
5
+ export declare const planMode: AgentControllerMode;
6
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/modes/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,eAAO,MAAM,QAAQ,EAAE,mBAmCtB,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { PLAN_MODE_AVAILABLE_TOOLS } from "../tool-availability.js";
2
+ //#region src/agents/modes/plan.ts
3
+ const planMode = {
4
+ id: "plan",
5
+ name: "Plan",
6
+ transitionsTo: "build",
7
+ defaultModelId: "openai/gpt-5.5",
8
+ description: "Read-only analysis and planning. Use for 'create an implementation plan for X', 'analyze the architecture of Y'.",
9
+ instructions: `You are an expert software architect and planner. Your job is to analyze a codebase and produce a detailed implementation plan for a given task.
10
+
11
+ ## Rules
12
+ - You have READ-ONLY access to the project. You cannot modify project files or run commands.
13
+ - The one exception is plan files: you can create and edit markdown files inside \`.mastracode/plans/\` using \`write_file\`, \`view\`, and \`string_replace_lsp\`. You may not write anywhere else.
14
+ - First, explore the codebase to understand existing patterns, architecture, and conventions.
15
+ - Produce a concrete, actionable plan — not vague suggestions.
16
+
17
+ ## Tool Strategy
18
+ - **Discover structure**: Use find_files (glob) to understand project layout and find relevant files
19
+ - **Find patterns**: Use search_content (grep) to locate existing implementations, imports, and conventions
20
+ - **Understand deeply**: Use view with view_range to read specific sections of key files
21
+ - **Parallelize**: Make multiple independent tool calls when exploring different areas
22
+
23
+ ## Plan Delivery
24
+ - Write your plan to a markdown file under \`.mastracode/plans/\` (e.g. \`.mastracode/plans/add-dark-mode.md\`) using \`write_file\`, then call \`submit_plan({ path })\` with the path to that file (never the plan body).
25
+ - Start the file with a \`# Title\` heading describing the plan.
26
+ - Reuse the same file while iterating on the same plan; only create a new file for a genuinely different plan so each plan stays available to review.
27
+ - Do NOT output the plan as text — it MUST live in the plan file.
28
+ - Be concise: reference files by path and line number, don't include raw contents.
29
+ - Focus on actionable details, not general observations.
30
+ - To revise after "Request changes", edit the same file in place with \`string_replace_lsp\`, and call \`submit_plan\` again with the same path.`,
31
+ metadata: { default: false },
32
+ availableTools: [...PLAN_MODE_AVAILABLE_TOOLS]
33
+ };
34
+ //#endregion
35
+ export { planMode };
36
+
37
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.js","names":[],"sources":["../../../src/agents/modes/plan.ts"],"sourcesContent":["/**\n * Plan mode — read-only analysis and planning.\n */\nimport type { AgentControllerMode } from '@mastra/core/agent-controller';\nimport { PLAN_MODE_AVAILABLE_TOOLS } from '../tool-availability.js';\n\nexport const planMode: AgentControllerMode = {\n id: 'plan',\n name: 'Plan',\n transitionsTo: 'build',\n defaultModelId: 'openai/gpt-5.5',\n description:\n \"Read-only analysis and planning. Use for 'create an implementation plan for X', 'analyze the architecture of Y'.\",\n instructions: `You are an expert software architect and planner. Your job is to analyze a codebase and produce a detailed implementation plan for a given task.\n\n## Rules\n- You have READ-ONLY access to the project. You cannot modify project files or run commands.\n- The one exception is plan files: you can create and edit markdown files inside \\`.mastracode/plans/\\` using \\`write_file\\`, \\`view\\`, and \\`string_replace_lsp\\`. You may not write anywhere else.\n- First, explore the codebase to understand existing patterns, architecture, and conventions.\n- Produce a concrete, actionable plan — not vague suggestions.\n\n## Tool Strategy\n- **Discover structure**: Use find_files (glob) to understand project layout and find relevant files\n- **Find patterns**: Use search_content (grep) to locate existing implementations, imports, and conventions\n- **Understand deeply**: Use view with view_range to read specific sections of key files\n- **Parallelize**: Make multiple independent tool calls when exploring different areas\n\n## Plan Delivery\n- Write your plan to a markdown file under \\`.mastracode/plans/\\` (e.g. \\`.mastracode/plans/add-dark-mode.md\\`) using \\`write_file\\`, then call \\`submit_plan({ path })\\` with the path to that file (never the plan body).\n- Start the file with a \\`# Title\\` heading describing the plan.\n- Reuse the same file while iterating on the same plan; only create a new file for a genuinely different plan so each plan stays available to review.\n- Do NOT output the plan as text — it MUST live in the plan file.\n- Be concise: reference files by path and line number, don't include raw contents.\n- Focus on actionable details, not general observations.\n- To revise after \"Request changes\", edit the same file in place with \\`string_replace_lsp\\`, and call \\`submit_plan\\` again with the same path.`,\n\n metadata: {\n default: false,\n },\n\n availableTools: [...PLAN_MODE_AVAILABLE_TOOLS],\n};\n"],"mappings":";;AAMA,MAAa,WAAgC;CAC3C,IAAI;CACJ,MAAM;CACN,eAAe;CACf,gBAAgB;CAChB,aACE;CACF,cAAc;;;;;;;;;;;;;;;;;;;;;;CAuBd,UAAU,EACR,SAAS,MACX;CAEA,gBAAgB,CAAC,GAAG,yBAAyB;AAC/C"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Load project and global agent instruction files (AGENTS.md, CLAUDE.md).
3
+ * Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.
4
+ */
5
+ export interface InstructionSource {
6
+ path: string;
7
+ content: string;
8
+ scope: 'global' | 'project';
9
+ /** Git ref the content was read from, when not read off the working tree. */
10
+ ref?: string;
11
+ }
12
+ /**
13
+ * Reads project-scope instruction files. The default implementation reads the
14
+ * working tree via `fs`; alternative readers can serve content from another
15
+ * source (e.g. a trusted git ref) while keeping working-tree paths as the
16
+ * addressing scheme.
17
+ */
18
+ export interface InstructionFileReader {
19
+ exists(path: string): boolean;
20
+ read(path: string): string;
21
+ /** Git ref backing this reader, recorded on the loaded sources. */
22
+ ref?: string;
23
+ }
24
+ /**
25
+ * Create a reader that serves instruction files from a git ref instead of the
26
+ * working tree. Paths are still addressed as working-tree paths under
27
+ * `projectPath`; content comes from `git show <ref>:<relpath>` so an untrusted
28
+ * checkout (e.g. a PR branch under review) cannot influence what is loaded.
29
+ * Tries `origin/<ref>` first (remote truth), then the local ref. Any git
30
+ * failure (missing ref, missing file, no repo) reports the file as absent.
31
+ */
32
+ export declare function createGitRefInstructionReader(projectPath: string, ref: string): InstructionFileReader;
33
+ /**
34
+ * Reader for the reactive reminder channel (AgentsMDInjector) that serves
35
+ * paths under `projectPath` from a trusted git ref. Paths outside the project
36
+ * fall back to the operator machine's filesystem (those are trusted); paths
37
+ * inside the project are only ever resolved against the ref, never the
38
+ * working tree, so an untrusted checkout cannot feed content in.
39
+ */
40
+ export declare function createGitRefReminderReader(projectPath: string, ref: string): {
41
+ pathExists: (path: string) => boolean;
42
+ isDirectory: (path: string) => boolean;
43
+ readFile: (path: string) => string;
44
+ };
45
+ /**
46
+ * Load all agent instruction files from global and project locations.
47
+ * Returns an array of instruction sources, with global ones first.
48
+ *
49
+ * `projectReader` controls where project-scope content comes from (defaults to
50
+ * the working tree). Global instructions read the operator machine's
51
+ * filesystem, unless `skipGlobal` keeps them out entirely.
52
+ */
53
+ export declare function loadAgentInstructions(projectPath: string, configDirName?: string, projectReader?: InstructionFileReader, { skipGlobal }?: {
54
+ skipGlobal?: boolean;
55
+ }): InstructionSource[];
56
+ export declare function getStaticallyLoadedInstructionPaths(projectPath: string, configDirName?: string, projectReader?: InstructionFileReader): string[];
57
+ /**
58
+ * Format loaded instructions into a string for the system prompt.
59
+ */
60
+ export declare function formatAgentInstructions(sources: InstructionSource[]): string;
61
+ //# sourceMappingURL=agent-instructions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-instructions.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/agent-instructions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC5B,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAOD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,qBAAqB,CA+BrG;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,GACV;IACD,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACvC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC,CA4CA;AAgBD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,aAAa,SAAqB,EAClC,aAAa,GAAE,qBAA2C,EAC1D,EAAE,UAAkB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACpD,iBAAiB,EAAE,CAwDrB;AAED,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,MAAM,EACnB,aAAa,SAAqB,EAClC,aAAa,CAAC,EAAE,qBAAqB,GACpC,MAAM,EAAE,CAEV;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAU5E"}