@mastra/code-sdk 0.0.0-fix-workflow-step-timing-and-parallel-status-20260715180716

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 (468) hide show
  1. package/CHANGELOG.md +285 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +50 -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 +173 -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 +166 -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 +54 -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 +34 -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 +5 -0
  23. package/dist/acp.js.map +1 -0
  24. package/dist/agents/instructions.d.ts +6 -0
  25. package/dist/agents/instructions.d.ts.map +1 -0
  26. package/dist/agents/instructions.js +41 -0
  27. package/dist/agents/instructions.js.map +1 -0
  28. package/dist/agents/mastracode-gateway.d.ts +67 -0
  29. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  30. package/dist/agents/mastracode-gateway.js +446 -0
  31. package/dist/agents/mastracode-gateway.js.map +1 -0
  32. package/dist/agents/memory.d.ts +13 -0
  33. package/dist/agents/memory.d.ts.map +1 -0
  34. package/dist/agents/memory.js +107 -0
  35. package/dist/agents/memory.js.map +1 -0
  36. package/dist/agents/model.d.ts +55 -0
  37. package/dist/agents/model.d.ts.map +1 -0
  38. package/dist/agents/model.js +115 -0
  39. package/dist/agents/model.js.map +1 -0
  40. package/dist/agents/modes/build.d.ts +10 -0
  41. package/dist/agents/modes/build.d.ts.map +1 -0
  42. package/dist/agents/modes/build.js +45 -0
  43. package/dist/agents/modes/build.js.map +1 -0
  44. package/dist/agents/modes/explore.d.ts +10 -0
  45. package/dist/agents/modes/explore.d.ts.map +1 -0
  46. package/dist/agents/modes/explore.js +38 -0
  47. package/dist/agents/modes/explore.js.map +1 -0
  48. package/dist/agents/modes/plan.d.ts +6 -0
  49. package/dist/agents/modes/plan.d.ts.map +1 -0
  50. package/dist/agents/modes/plan.js +38 -0
  51. package/dist/agents/modes/plan.js.map +1 -0
  52. package/dist/agents/prompts/agent-instructions.d.ts +20 -0
  53. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  54. package/dist/agents/prompts/agent-instructions.js +82 -0
  55. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  56. package/dist/agents/prompts/build.d.ts +12 -0
  57. package/dist/agents/prompts/build.d.ts.map +1 -0
  58. package/dist/agents/prompts/build.js +73 -0
  59. package/dist/agents/prompts/build.js.map +1 -0
  60. package/dist/agents/prompts/fast.d.ts +5 -0
  61. package/dist/agents/prompts/fast.d.ts.map +1 -0
  62. package/dist/agents/prompts/fast.js +22 -0
  63. package/dist/agents/prompts/fast.js.map +1 -0
  64. package/dist/agents/prompts/index.d.ts +19 -0
  65. package/dist/agents/prompts/index.d.ts.map +1 -0
  66. package/dist/agents/prompts/index.js +57 -0
  67. package/dist/agents/prompts/index.js.map +1 -0
  68. package/dist/agents/prompts/model.d.ts +5 -0
  69. package/dist/agents/prompts/model.d.ts.map +1 -0
  70. package/dist/agents/prompts/model.js +22 -0
  71. package/dist/agents/prompts/model.js.map +1 -0
  72. package/dist/agents/prompts/plan.d.ts +6 -0
  73. package/dist/agents/prompts/plan.d.ts.map +1 -0
  74. package/dist/agents/prompts/plan.js +107 -0
  75. package/dist/agents/prompts/plan.js.map +1 -0
  76. package/dist/agents/prompts/tool-guidance.d.ts +13 -0
  77. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  78. package/dist/agents/prompts/tool-guidance.js +181 -0
  79. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  80. package/dist/agents/sandbox-filesystem.d.ts +89 -0
  81. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  82. package/dist/agents/sandbox-filesystem.js +268 -0
  83. package/dist/agents/sandbox-filesystem.js.map +1 -0
  84. package/dist/agents/sandbox-reattach.d.ts +19 -0
  85. package/dist/agents/sandbox-reattach.d.ts.map +1 -0
  86. package/dist/agents/sandbox-reattach.js +17 -0
  87. package/dist/agents/sandbox-reattach.js.map +1 -0
  88. package/dist/agents/thread-caveman-state.d.ts +17 -0
  89. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  90. package/dist/agents/thread-caveman-state.js +96 -0
  91. package/dist/agents/thread-caveman-state.js.map +1 -0
  92. package/dist/agents/tool-availability.d.ts +10 -0
  93. package/dist/agents/tool-availability.d.ts.map +1 -0
  94. package/dist/agents/tool-availability.js +105 -0
  95. package/dist/agents/tool-availability.js.map +1 -0
  96. package/dist/agents/tools.d.ts +19 -0
  97. package/dist/agents/tools.d.ts.map +1 -0
  98. package/dist/agents/tools.js +145 -0
  99. package/dist/agents/tools.js.map +1 -0
  100. package/dist/agents/workspace.d.ts +22 -0
  101. package/dist/agents/workspace.d.ts.map +1 -0
  102. package/dist/agents/workspace.js +226 -0
  103. package/dist/agents/workspace.js.map +1 -0
  104. package/dist/analytics.d.ts +18 -0
  105. package/dist/analytics.d.ts.map +1 -0
  106. package/dist/analytics.js +152 -0
  107. package/dist/analytics.js.map +1 -0
  108. package/dist/auth/index.d.ts +9 -0
  109. package/dist/auth/index.d.ts.map +1 -0
  110. package/dist/auth/index.js +11 -0
  111. package/dist/auth/index.js.map +1 -0
  112. package/dist/auth/pkce.d.ts +13 -0
  113. package/dist/auth/pkce.d.ts.map +1 -0
  114. package/dist/auth/pkce.js +21 -0
  115. package/dist/auth/pkce.js.map +1 -0
  116. package/dist/auth/providers/anthropic.d.ts +17 -0
  117. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  118. package/dist/auth/providers/anthropic.js +94 -0
  119. package/dist/auth/providers/anthropic.js.map +1 -0
  120. package/dist/auth/providers/github-copilot.d.ts +100 -0
  121. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  122. package/dist/auth/providers/github-copilot.js +302 -0
  123. package/dist/auth/providers/github-copilot.js.map +1 -0
  124. package/dist/auth/providers/openai-codex.d.ts +95 -0
  125. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  126. package/dist/auth/providers/openai-codex.js +527 -0
  127. package/dist/auth/providers/openai-codex.js.map +1 -0
  128. package/dist/auth/storage.d.ts +91 -0
  129. package/dist/auth/storage.d.ts.map +1 -0
  130. package/dist/auth/storage.js +187 -0
  131. package/dist/auth/storage.js.map +1 -0
  132. package/dist/auth/types.d.ts +68 -0
  133. package/dist/auth/types.d.ts.map +1 -0
  134. package/dist/auth/types.js +1 -0
  135. package/dist/auth/types.js.map +1 -0
  136. package/dist/clipboard/index.d.ts +26 -0
  137. package/dist/clipboard/index.d.ts.map +1 -0
  138. package/dist/clipboard/index.js +192 -0
  139. package/dist/clipboard/index.js.map +1 -0
  140. package/dist/constants.d.ts +10 -0
  141. package/dist/constants.d.ts.map +1 -0
  142. package/dist/constants.js +23 -0
  143. package/dist/constants.js.map +1 -0
  144. package/dist/error-classification.d.ts +10 -0
  145. package/dist/error-classification.d.ts.map +1 -0
  146. package/dist/error-classification.js +14 -0
  147. package/dist/error-classification.js.map +1 -0
  148. package/dist/evals/context-builder.d.ts +41 -0
  149. package/dist/evals/context-builder.d.ts.map +1 -0
  150. package/dist/evals/context-builder.js +120 -0
  151. package/dist/evals/context-builder.js.map +1 -0
  152. package/dist/evals/index.d.ts +4 -0
  153. package/dist/evals/index.d.ts.map +1 -0
  154. package/dist/evals/index.js +8 -0
  155. package/dist/evals/index.js.map +1 -0
  156. package/dist/evals/scorers/classify-command.d.ts +31 -0
  157. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  158. package/dist/evals/scorers/classify-command.js +52 -0
  159. package/dist/evals/scorers/classify-command.js.map +1 -0
  160. package/dist/evals/scorers/efficiency.d.ts +44 -0
  161. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  162. package/dist/evals/scorers/efficiency.js +201 -0
  163. package/dist/evals/scorers/efficiency.js.map +1 -0
  164. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  165. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  166. package/dist/evals/scorers/extract-tools.js +56 -0
  167. package/dist/evals/scorers/extract-tools.js.map +1 -0
  168. package/dist/evals/scorers/index.d.ts +3 -0
  169. package/dist/evals/scorers/index.d.ts.map +1 -0
  170. package/dist/evals/scorers/index.js +7 -0
  171. package/dist/evals/scorers/index.js.map +1 -0
  172. package/dist/evals/scorers/outcome.d.ts +49 -0
  173. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  174. package/dist/evals/scorers/outcome.js +238 -0
  175. package/dist/evals/scorers/outcome.js.map +1 -0
  176. package/dist/headless/cli.d.ts +42 -0
  177. package/dist/headless/cli.d.ts.map +1 -0
  178. package/dist/headless/cli.js +196 -0
  179. package/dist/headless/cli.js.map +1 -0
  180. package/dist/headless/flags.d.ts +33 -0
  181. package/dist/headless/flags.d.ts.map +1 -0
  182. package/dist/headless/flags.js +188 -0
  183. package/dist/headless/flags.js.map +1 -0
  184. package/dist/headless/format.d.ts +38 -0
  185. package/dist/headless/format.d.ts.map +1 -0
  186. package/dist/headless/format.js +85 -0
  187. package/dist/headless/format.js.map +1 -0
  188. package/dist/headless/index.d.ts +25 -0
  189. package/dist/headless/index.d.ts.map +1 -0
  190. package/dist/headless/index.js +32 -0
  191. package/dist/headless/index.js.map +1 -0
  192. package/dist/headless/policy.d.ts +17 -0
  193. package/dist/headless/policy.d.ts.map +1 -0
  194. package/dist/headless/policy.js +38 -0
  195. package/dist/headless/policy.js.map +1 -0
  196. package/dist/headless/run-mc.d.ts +7 -0
  197. package/dist/headless/run-mc.d.ts.map +1 -0
  198. package/dist/headless/run-mc.js +296 -0
  199. package/dist/headless/run-mc.js.map +1 -0
  200. package/dist/headless/types.d.ts +134 -0
  201. package/dist/headless/types.d.ts.map +1 -0
  202. package/dist/headless/types.js +9 -0
  203. package/dist/headless/types.js.map +1 -0
  204. package/dist/hooks/config.d.ts +11 -0
  205. package/dist/hooks/config.d.ts.map +1 -0
  206. package/dist/hooks/config.js +78 -0
  207. package/dist/hooks/config.js.map +1 -0
  208. package/dist/hooks/executor.d.ts +13 -0
  209. package/dist/hooks/executor.d.ts.map +1 -0
  210. package/dist/hooks/executor.js +125 -0
  211. package/dist/hooks/executor.js.map +1 -0
  212. package/dist/hooks/index.d.ts +6 -0
  213. package/dist/hooks/index.d.ts.map +1 -0
  214. package/dist/hooks/index.js +16 -0
  215. package/dist/hooks/index.js.map +1 -0
  216. package/dist/hooks/manager.d.ts +47 -0
  217. package/dist/hooks/manager.d.ts.map +1 -0
  218. package/dist/hooks/manager.js +284 -0
  219. package/dist/hooks/manager.js.map +1 -0
  220. package/dist/hooks/types.d.ts +152 -0
  221. package/dist/hooks/types.d.ts.map +1 -0
  222. package/dist/hooks/types.js +7 -0
  223. package/dist/hooks/types.js.map +1 -0
  224. package/dist/index.d.ts +243 -0
  225. package/dist/index.d.ts.map +1 -0
  226. package/dist/index.js +730 -0
  227. package/dist/index.js.map +1 -0
  228. package/dist/ipc/ipc-reporter.d.ts +14 -0
  229. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  230. package/dist/ipc/ipc-reporter.js +24 -0
  231. package/dist/ipc/ipc-reporter.js.map +1 -0
  232. package/dist/lsp/client.d.ts +56 -0
  233. package/dist/lsp/client.d.ts.map +1 -0
  234. package/dist/lsp/client.js +309 -0
  235. package/dist/lsp/client.js.map +1 -0
  236. package/dist/lsp/index.d.ts +4 -0
  237. package/dist/lsp/index.d.ts.map +1 -0
  238. package/dist/lsp/index.js +9 -0
  239. package/dist/lsp/index.js.map +1 -0
  240. package/dist/lsp/language.d.ts +9 -0
  241. package/dist/lsp/language.d.ts.map +1 -0
  242. package/dist/lsp/language.js +48 -0
  243. package/dist/lsp/language.js.map +1 -0
  244. package/dist/lsp/manager.d.ts +34 -0
  245. package/dist/lsp/manager.d.ts.map +1 -0
  246. package/dist/lsp/manager.js +97 -0
  247. package/dist/lsp/manager.js.map +1 -0
  248. package/dist/lsp/server.d.ts +27 -0
  249. package/dist/lsp/server.d.ts.map +1 -0
  250. package/dist/lsp/server.js +128 -0
  251. package/dist/lsp/server.js.map +1 -0
  252. package/dist/lsp/workspace.d.ts +9 -0
  253. package/dist/lsp/workspace.d.ts.map +1 -0
  254. package/dist/lsp/workspace.js +52 -0
  255. package/dist/lsp/workspace.js.map +1 -0
  256. package/dist/mcp/config.d.ts +34 -0
  257. package/dist/mcp/config.d.ts.map +1 -0
  258. package/dist/mcp/config.js +205 -0
  259. package/dist/mcp/config.js.map +1 -0
  260. package/dist/mcp/index.d.ts +5 -0
  261. package/dist/mcp/index.d.ts.map +1 -0
  262. package/dist/mcp/index.js +10 -0
  263. package/dist/mcp/index.js.map +1 -0
  264. package/dist/mcp/manager.d.ts +49 -0
  265. package/dist/mcp/manager.d.ts.map +1 -0
  266. package/dist/mcp/manager.js +374 -0
  267. package/dist/mcp/manager.js.map +1 -0
  268. package/dist/mcp/types.d.ts +85 -0
  269. package/dist/mcp/types.d.ts.map +1 -0
  270. package/dist/mcp/types.js +1 -0
  271. package/dist/mcp/types.js.map +1 -0
  272. package/dist/onboarding/custom-packs.d.ts +7 -0
  273. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  274. package/dist/onboarding/custom-packs.js +20 -0
  275. package/dist/onboarding/custom-packs.js.map +1 -0
  276. package/dist/onboarding/custom-providers.d.ts +4 -0
  277. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  278. package/dist/onboarding/custom-providers.js +28 -0
  279. package/dist/onboarding/custom-providers.js.map +1 -0
  280. package/dist/onboarding/index.d.ts +5 -0
  281. package/dist/onboarding/index.d.ts.map +1 -0
  282. package/dist/onboarding/index.js +21 -0
  283. package/dist/onboarding/index.js.map +1 -0
  284. package/dist/onboarding/om-settings.d.ts +20 -0
  285. package/dist/onboarding/om-settings.d.ts.map +1 -0
  286. package/dist/onboarding/om-settings.js +26 -0
  287. package/dist/onboarding/om-settings.js.map +1 -0
  288. package/dist/onboarding/packs.d.ts +48 -0
  289. package/dist/onboarding/packs.d.ts.map +1 -0
  290. package/dist/onboarding/packs.js +111 -0
  291. package/dist/onboarding/packs.js.map +1 -0
  292. package/dist/onboarding/settings.d.ts +327 -0
  293. package/dist/onboarding/settings.d.ts.map +1 -0
  294. package/dist/onboarding/settings.js +598 -0
  295. package/dist/onboarding/settings.js.map +1 -0
  296. package/dist/permissions.d.ts +55 -0
  297. package/dist/permissions.d.ts.map +1 -0
  298. package/dist/permissions.js +119 -0
  299. package/dist/permissions.js.map +1 -0
  300. package/dist/plugin.d.ts +81 -0
  301. package/dist/plugin.d.ts.map +1 -0
  302. package/dist/plugin.js +30 -0
  303. package/dist/plugin.js.map +1 -0
  304. package/dist/plugins/dependencies.d.ts +9 -0
  305. package/dist/plugins/dependencies.d.ts.map +1 -0
  306. package/dist/plugins/dependencies.js +111 -0
  307. package/dist/plugins/dependencies.js.map +1 -0
  308. package/dist/plugins/install.d.ts +21 -0
  309. package/dist/plugins/install.d.ts.map +1 -0
  310. package/dist/plugins/install.js +200 -0
  311. package/dist/plugins/install.js.map +1 -0
  312. package/dist/plugins/loader.d.ts +15 -0
  313. package/dist/plugins/loader.d.ts.map +1 -0
  314. package/dist/plugins/loader.js +221 -0
  315. package/dist/plugins/loader.js.map +1 -0
  316. package/dist/plugins/manager.d.ts +60 -0
  317. package/dist/plugins/manager.d.ts.map +1 -0
  318. package/dist/plugins/manager.js +378 -0
  319. package/dist/plugins/manager.js.map +1 -0
  320. package/dist/plugins/manifest.d.ts +14 -0
  321. package/dist/plugins/manifest.d.ts.map +1 -0
  322. package/dist/plugins/manifest.js +75 -0
  323. package/dist/plugins/manifest.js.map +1 -0
  324. package/dist/plugins/package-link.d.ts +3 -0
  325. package/dist/plugins/package-link.d.ts.map +1 -0
  326. package/dist/plugins/package-link.js +77 -0
  327. package/dist/plugins/package-link.js.map +1 -0
  328. package/dist/plugins/paths.d.ts +10 -0
  329. package/dist/plugins/paths.d.ts.map +1 -0
  330. package/dist/plugins/paths.js +26 -0
  331. package/dist/plugins/paths.js.map +1 -0
  332. package/dist/plugins/registry.d.ts +8 -0
  333. package/dist/plugins/registry.d.ts.map +1 -0
  334. package/dist/plugins/registry.js +96 -0
  335. package/dist/plugins/registry.js.map +1 -0
  336. package/dist/plugins/scaffold.d.ts +10 -0
  337. package/dist/plugins/scaffold.d.ts.map +1 -0
  338. package/dist/plugins/scaffold.js +152 -0
  339. package/dist/plugins/scaffold.js.map +1 -0
  340. package/dist/plugins/types.d.ts +45 -0
  341. package/dist/plugins/types.d.ts.map +1 -0
  342. package/dist/plugins/types.js +1 -0
  343. package/dist/plugins/types.js.map +1 -0
  344. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  345. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  346. package/dist/processors/plan-rejection-abort.js +53 -0
  347. package/dist/processors/plan-rejection-abort.js.map +1 -0
  348. package/dist/providers/amazon-bedrock-gateway.d.ts +40 -0
  349. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  350. package/dist/providers/amazon-bedrock-gateway.js +79 -0
  351. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  352. package/dist/providers/amazon-bedrock.d.ts +28 -0
  353. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  354. package/dist/providers/amazon-bedrock.js +62 -0
  355. package/dist/providers/amazon-bedrock.js.map +1 -0
  356. package/dist/providers/claude-max.d.ts +50 -0
  357. package/dist/providers/claude-max.d.ts.map +1 -0
  358. package/dist/providers/claude-max.js +151 -0
  359. package/dist/providers/claude-max.js.map +1 -0
  360. package/dist/providers/github-copilot.d.ts +58 -0
  361. package/dist/providers/github-copilot.d.ts.map +1 -0
  362. package/dist/providers/github-copilot.js +263 -0
  363. package/dist/providers/github-copilot.js.map +1 -0
  364. package/dist/providers/openai-codex.d.ts +70 -0
  365. package/dist/providers/openai-codex.d.ts.map +1 -0
  366. package/dist/providers/openai-codex.js +291 -0
  367. package/dist/providers/openai-codex.js.map +1 -0
  368. package/dist/schema.d.ts +167 -0
  369. package/dist/schema.d.ts.map +1 -0
  370. package/dist/schema.js +92 -0
  371. package/dist/schema.js.map +1 -0
  372. package/dist/theme-palette.d.ts +17 -0
  373. package/dist/theme-palette.d.ts.map +1 -0
  374. package/dist/theme-palette.js +17 -0
  375. package/dist/theme-palette.js.map +1 -0
  376. package/dist/tool-names.d.ts +73 -0
  377. package/dist/tool-names.d.ts.map +1 -0
  378. package/dist/tool-names.js +43 -0
  379. package/dist/tool-names.js.map +1 -0
  380. package/dist/tools/index.d.ts +6 -0
  381. package/dist/tools/index.d.ts.map +1 -0
  382. package/dist/tools/index.js +9 -0
  383. package/dist/tools/index.js.map +1 -0
  384. package/dist/tools/request-sandbox-access.d.ts +6 -0
  385. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  386. package/dist/tools/request-sandbox-access.js +88 -0
  387. package/dist/tools/request-sandbox-access.js.map +1 -0
  388. package/dist/tools/utils.d.ts +20 -0
  389. package/dist/tools/utils.d.ts.map +1 -0
  390. package/dist/tools/utils.js +22 -0
  391. package/dist/tools/utils.js.map +1 -0
  392. package/dist/tools/web-search.d.ts +35 -0
  393. package/dist/tools/web-search.d.ts.map +1 -0
  394. package/dist/tools/web-search.js +65 -0
  395. package/dist/tools/web-search.js.map +1 -0
  396. package/dist/utils/binaries.d.ts +7 -0
  397. package/dist/utils/binaries.d.ts.map +1 -0
  398. package/dist/utils/binaries.js +74 -0
  399. package/dist/utils/binaries.js.map +1 -0
  400. package/dist/utils/debug-log.d.ts +12 -0
  401. package/dist/utils/debug-log.d.ts.map +1 -0
  402. package/dist/utils/debug-log.js +55 -0
  403. package/dist/utils/debug-log.js.map +1 -0
  404. package/dist/utils/errors.d.ts +36 -0
  405. package/dist/utils/errors.d.ts.map +1 -0
  406. package/dist/utils/errors.js +207 -0
  407. package/dist/utils/errors.js.map +1 -0
  408. package/dist/utils/gateway-sync.d.ts +26 -0
  409. package/dist/utils/gateway-sync.d.ts.map +1 -0
  410. package/dist/utils/gateway-sync.js +49 -0
  411. package/dist/utils/gateway-sync.js.map +1 -0
  412. package/dist/utils/path-security.d.ts +2 -0
  413. package/dist/utils/path-security.d.ts.map +1 -0
  414. package/dist/utils/path-security.js +9 -0
  415. package/dist/utils/path-security.js.map +1 -0
  416. package/dist/utils/plan-diff.d.ts +25 -0
  417. package/dist/utils/plan-diff.d.ts.map +1 -0
  418. package/dist/utils/plan-diff.js +43 -0
  419. package/dist/utils/plan-diff.js.map +1 -0
  420. package/dist/utils/plans.d.ts +56 -0
  421. package/dist/utils/plans.d.ts.map +1 -0
  422. package/dist/utils/plans.js +99 -0
  423. package/dist/utils/plans.js.map +1 -0
  424. package/dist/utils/project.d.ts +160 -0
  425. package/dist/utils/project.d.ts.map +1 -0
  426. package/dist/utils/project.js +302 -0
  427. package/dist/utils/project.js.map +1 -0
  428. package/dist/utils/signals-pubsub.d.ts +41 -0
  429. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  430. package/dist/utils/signals-pubsub.js +104 -0
  431. package/dist/utils/signals-pubsub.js.map +1 -0
  432. package/dist/utils/slash-command-loader.d.ts +52 -0
  433. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  434. package/dist/utils/slash-command-loader.js +177 -0
  435. package/dist/utils/slash-command-loader.js.map +1 -0
  436. package/dist/utils/slash-command-processor.d.ts +14 -0
  437. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  438. package/dist/utils/slash-command-processor.js +96 -0
  439. package/dist/utils/slash-command-processor.js.map +1 -0
  440. package/dist/utils/stdin-pipe.d.ts +33 -0
  441. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  442. package/dist/utils/stdin-pipe.js +72 -0
  443. package/dist/utils/stdin-pipe.js.map +1 -0
  444. package/dist/utils/storage-factory.d.ts +50 -0
  445. package/dist/utils/storage-factory.d.ts.map +1 -0
  446. package/dist/utils/storage-factory.js +101 -0
  447. package/dist/utils/storage-factory.js.map +1 -0
  448. package/dist/utils/storage-maintenance.d.ts +103 -0
  449. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  450. package/dist/utils/storage-maintenance.js +236 -0
  451. package/dist/utils/storage-maintenance.js.map +1 -0
  452. package/dist/utils/thread-lock.d.ts +26 -0
  453. package/dist/utils/thread-lock.d.ts.map +1 -0
  454. package/dist/utils/thread-lock.js +108 -0
  455. package/dist/utils/thread-lock.js.map +1 -0
  456. package/dist/utils/token-estimator.d.ts +3 -0
  457. package/dist/utils/token-estimator.d.ts.map +1 -0
  458. package/dist/utils/token-estimator.js +21 -0
  459. package/dist/utils/token-estimator.js.map +1 -0
  460. package/dist/utils/update-check.d.ts +52 -0
  461. package/dist/utils/update-check.d.ts.map +1 -0
  462. package/dist/utils/update-check.js +177 -0
  463. package/dist/utils/update-check.js.map +1 -0
  464. package/dist/voice/stt-registry.d.ts +64 -0
  465. package/dist/voice/stt-registry.d.ts.map +1 -0
  466. package/dist/voice/stt-registry.js +126 -0
  467. package/dist/voice/stt-registry.js.map +1 -0
  468. package/package.json +94 -0
@@ -0,0 +1,55 @@
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
+ type ResolvedModel = GatewayLanguageModel;
9
+ export declare function createMastraCodeGateway(options: MastraCodeGatewayOptions): MastraCodeGateway;
10
+ export declare function createMastraCodeModelCatalogProvider(gateway: MastraModelGatewayInterface): import("@mastra/core/harness").CustomModelCatalogProvider;
11
+ /**
12
+ * Placeholder for future model ID normalization.
13
+ * Currently returns the input unchanged, but exists as a seam
14
+ * for aliasing, casing fixes, or validation in the future.
15
+ */
16
+ export declare function resolveModelId(modelId: string): string;
17
+ /**
18
+ * Resolve a model ID to the correct provider instance.
19
+ * Shared by the main agent, observer, and reflector.
20
+ *
21
+ * - For anthropic/* models: Uses stored OAuth credentials when present, otherwise direct API key
22
+ * - For openai/* models: Uses OAuth when configured, otherwise direct API key from AuthStorage
23
+ * - For moonshotai/* models: Uses Moonshot AI Anthropic-compatible endpoint
24
+ * - For all other providers: Uses Mastra's model router (models.dev gateway)
25
+ */
26
+ export declare function resolveModel(modelId: string, options?: {
27
+ thinkingLevel?: ThinkingLevel;
28
+ remapForCodexOAuth?: boolean;
29
+ requestContext?: RequestContext;
30
+ }): GatewayLanguageModel;
31
+ /**
32
+ * Dynamic model function that reads the current model from controller state.
33
+ * This allows runtime model switching via the /models picker.
34
+ */
35
+ export declare function getDynamicModel({ requestContext }: {
36
+ requestContext: RequestContext;
37
+ }): ResolvedModel;
38
+ /**
39
+ * Goal judge model resolver for the agent's `goal.judge` config. Resolves the
40
+ * configured goal judge model through mastracode's gateway so provider
41
+ * credentials (stored in auth storage, not just env) are injected — a bare model
42
+ * id handed to core's default model router would fail to find the API key.
43
+ *
44
+ * Returns `undefined` when no judge model is configured, which keeps the goal
45
+ * step a complete no-op (the goal mechanism requires a judge to do anything).
46
+ *
47
+ * `settingsPath` must be the same source `createMastraCode()` reads from so the
48
+ * judge model and the goal budget (`goalMaxTurns`) come from one config — with a
49
+ * custom `settingsPath` a bare `loadSettings()` here could read a different file
50
+ * and silently turn the goal step into a no-op.
51
+ */
52
+ export declare function getGoalJudgeModel({ requestContext }: {
53
+ requestContext: RequestContext;
54
+ }, settingsPath?: string): ResolvedModel | undefined;
55
+ //# 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;AAClE,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;AAElG,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+DtB;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,115 @@
1
+ import { loadSettings } from "../onboarding/settings.js";
2
+ import { AMAZON_BEDROCK_GATEWAY_ID, createAmazonBedrockGateway } from "../providers/amazon-bedrock-gateway.js";
3
+ import {
4
+ MASTRA_GATEWAY_PREFIX,
5
+ MASTRACODE_GATEWAY_ID,
6
+ MastraCodeGateway,
7
+ reloadAuthStorage,
8
+ stripMastraGatewayPrefix
9
+ } from "./mastracode-gateway.js";
10
+ import {
11
+ getAnthropicApiKey,
12
+ getOpenAIApiKey,
13
+ MASTRACODE_GATEWAY_ID as MASTRACODE_GATEWAY_ID2,
14
+ MastraCodeGateway as MastraCodeGateway2,
15
+ remapOpenAIModelForCodexOAuth,
16
+ resolveAuth
17
+ } from "./mastracode-gateway.js";
18
+ function getAgentControllerHeaders(requestContext) {
19
+ const agentControllerContext = requestContext?.get("controller");
20
+ const headers = {
21
+ ...agentControllerContext?.threadId ? { "x-thread-id": agentControllerContext.threadId } : {},
22
+ ...agentControllerContext?.resourceId ? { "x-resource-id": agentControllerContext.resourceId } : {}
23
+ };
24
+ return Object.keys(headers).length > 0 ? headers : void 0;
25
+ }
26
+ function createMastraCodeGateway(options) {
27
+ return new MastraCodeGateway(options);
28
+ }
29
+ function createMastraCodeModelCatalogProvider(gateway) {
30
+ return gateway instanceof MastraCodeGateway ? gateway.createModelCatalogProvider() : MastraCodeGateway.createModelCatalogProvider(gateway);
31
+ }
32
+ function resolveModelId(modelId) {
33
+ return modelId;
34
+ }
35
+ function resolveModel(modelId, options) {
36
+ reloadAuthStorage();
37
+ const headers = getAgentControllerHeaders(options?.requestContext);
38
+ const settings = loadSettings();
39
+ const bedrockLegacyPrefix = `${MASTRACODE_GATEWAY_ID}/amazon-bedrock/`;
40
+ const normalizedInput = modelId.startsWith(bedrockLegacyPrefix) ? modelId.slice(MASTRACODE_GATEWAY_ID.length + 1) : modelId;
41
+ const isMastraGatewayModel = normalizedInput.startsWith(MASTRA_GATEWAY_PREFIX);
42
+ const normalizedModelId = stripMastraGatewayPrefix(normalizedInput);
43
+ const [providerId, ...modelParts] = normalizedModelId.split("/");
44
+ const bareModelId = modelParts.join("/");
45
+ if (!providerId || !bareModelId) {
46
+ throw new Error(`Invalid model id: ${modelId}`);
47
+ }
48
+ if (providerId === AMAZON_BEDROCK_GATEWAY_ID) {
49
+ const bedrockGateway = createAmazonBedrockGateway();
50
+ const routerId2 = `${AMAZON_BEDROCK_GATEWAY_ID}/${bareModelId}`;
51
+ const auth2 = bedrockGateway.resolveAuth({
52
+ gatewayId: AMAZON_BEDROCK_GATEWAY_ID,
53
+ providerId: AMAZON_BEDROCK_GATEWAY_ID,
54
+ modelId: bareModelId,
55
+ routerId: routerId2
56
+ });
57
+ return bedrockGateway.resolveLanguageModel({
58
+ providerId: AMAZON_BEDROCK_GATEWAY_ID,
59
+ modelId: bareModelId,
60
+ apiKey: auth2?.apiKey ?? "",
61
+ headers
62
+ });
63
+ }
64
+ const routerId = `${MASTRACODE_GATEWAY_ID}/${normalizedModelId}`;
65
+ const mgApiKey = MastraCodeGateway.getMastraGatewayApiKey();
66
+ const rawGatewayBase = settings.memoryGateway?.baseUrl ?? process.env["MASTRA_GATEWAY_URL"] ?? "https://gateway-api.mastra.ai";
67
+ const gateway = createMastraCodeGateway({
68
+ mastraGatewayBaseUrl: rawGatewayBase.replace(/\/+$/, "").replace(/\/v1$/, ""),
69
+ mastraGatewayApiKey: mgApiKey,
70
+ routeThroughMastraGateway: Boolean(mgApiKey && isMastraGatewayModel),
71
+ thinkingLevel: options?.thinkingLevel,
72
+ customProviders: settings.customProviders
73
+ });
74
+ const auth = gateway.resolveAuth({
75
+ gatewayId: MASTRACODE_GATEWAY_ID,
76
+ providerId,
77
+ modelId: bareModelId,
78
+ routerId
79
+ });
80
+ return gateway.resolveLanguageModel({
81
+ providerId,
82
+ modelId: bareModelId,
83
+ apiKey: auth?.apiKey ?? mgApiKey ?? "",
84
+ headers
85
+ });
86
+ }
87
+ function getDynamicModel({ requestContext }) {
88
+ const agentControllerContext = requestContext.get("controller");
89
+ const modelId = agentControllerContext?.session?.modelId;
90
+ if (!modelId) {
91
+ throw new Error("No model selected. Use /models to select a model first.");
92
+ }
93
+ const thinkingLevel = agentControllerContext?.state?.thinkingLevel;
94
+ return resolveModel(modelId, { thinkingLevel, remapForCodexOAuth: true, requestContext });
95
+ }
96
+ function getGoalJudgeModel({ requestContext }, settingsPath) {
97
+ const judgeModelId = loadSettings(settingsPath).models.goalJudgeModel;
98
+ if (!judgeModelId) return void 0;
99
+ return resolveModel(judgeModelId, { remapForCodexOAuth: true, requestContext });
100
+ }
101
+ export {
102
+ MASTRACODE_GATEWAY_ID2 as MASTRACODE_GATEWAY_ID,
103
+ MastraCodeGateway2 as MastraCodeGateway,
104
+ createMastraCodeGateway,
105
+ createMastraCodeModelCatalogProvider,
106
+ getAnthropicApiKey,
107
+ getDynamicModel,
108
+ getGoalJudgeModel,
109
+ getOpenAIApiKey,
110
+ remapOpenAIModelForCodexOAuth,
111
+ resolveAuth,
112
+ resolveModel,
113
+ resolveModelId
114
+ };
115
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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 } 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 {\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';\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 normalizedInput = modelId.startsWith(bedrockLegacyPrefix)\n ? modelId.slice(MASTRACODE_GATEWAY_ID.length + 1)\n : modelId;\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 const gateway = createMastraCodeGateway({\n mastraGatewayBaseUrl: rawGatewayBase.replace(/\\/+$/, '').replace(/\\/v1$/, ''),\n mastraGatewayApiKey: mgApiKey,\n routeThroughMastraGateway: Boolean(mgApiKey && isMastraGatewayModel),\n thinkingLevel: options?.thinkingLevel,\n customProviders: settings.customProviders,\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":"AAGA,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B,kCAAkC;AAEtE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA,yBAAAA;AAAA,EACA,qBAAAC;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,SAAS,0BAA0B,gBAAkE;AACnG,QAAM,yBAAyB,gBAAgB,IAAI,YAAY;AAC/D,QAAM,UAAU;AAAA,IACd,GAAI,wBAAwB,WAAW,EAAE,eAAe,uBAAuB,SAAS,IAAI,CAAC;AAAA,IAC7F,GAAI,wBAAwB,aAAa,EAAE,iBAAiB,uBAAuB,WAAW,IAAI,CAAC;AAAA,EACrG;AAEA,SAAO,OAAO,KAAK,OAAO,EAAE,SAAS,IAAI,UAAU;AACrD;AAEO,SAAS,wBAAwB,SAAsD;AAC5F,SAAO,IAAI,kBAAkB,OAAO;AACtC;AAEO,SAAS,qCAAqC,SAAsC;AACzF,SAAO,mBAAmB,oBACtB,QAAQ,2BAA2B,IACnC,kBAAkB,2BAA2B,OAAO;AAC1D;AAOO,SAAS,eAAe,SAAyB;AACtD,SAAO;AACT;AAWO,SAAS,aACd,SACA,SACsB;AACtB,oBAAkB;AAClB,QAAM,UAAU,0BAA0B,SAAS,cAAc;AACjE,QAAM,WAAW,aAAa;AAK9B,QAAM,sBAAsB,GAAG,qBAAqB;AACpD,QAAM,kBAAkB,QAAQ,WAAW,mBAAmB,IAC1D,QAAQ,MAAM,sBAAsB,SAAS,CAAC,IAC9C;AACJ,QAAM,uBAAuB,gBAAgB,WAAW,qBAAqB;AAC7E,QAAM,oBAAoB,yBAAyB,eAAe;AAClE,QAAM,CAAC,YAAY,GAAG,UAAU,IAAI,kBAAkB,MAAM,GAAG;AAC/D,QAAM,cAAc,WAAW,KAAK,GAAG;AACvC,MAAI,CAAC,cAAc,CAAC,aAAa;AAC/B,UAAM,IAAI,MAAM,qBAAqB,OAAO,EAAE;AAAA,EAChD;AAEA,MAAI,eAAe,2BAA2B;AAC5C,UAAM,iBAAiB,2BAA2B;AAClD,UAAMC,YAAW,GAAG,yBAAyB,IAAI,WAAW;AAC5D,UAAMC,QAAO,eAAe,YAAY;AAAA,MACtC,WAAW;AAAA,MACX,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,UAAAD;AAAA,IACF,CAAC;AACD,WAAO,eAAe,qBAAqB;AAAA,MACzC,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQC,OAAM,UAAU;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,WAAW,GAAG,qBAAqB,IAAI,iBAAiB;AAE9D,QAAM,WAAW,kBAAkB,uBAAuB;AAC1D,QAAM,iBACJ,SAAS,eAAe,WAAW,QAAQ,IAAI,oBAAoB,KAAK;AAC1E,QAAM,UAAU,wBAAwB;AAAA,IACtC,sBAAsB,eAAe,QAAQ,QAAQ,EAAE,EAAE,QAAQ,SAAS,EAAE;AAAA,IAC5E,qBAAqB;AAAA,IACrB,2BAA2B,QAAQ,YAAY,oBAAoB;AAAA,IACnE,eAAe,SAAS;AAAA,IACxB,iBAAiB,SAAS;AAAA,EAC5B,CAAC;AAED,QAAM,OAAO,QAAQ,YAAY;AAAA,IAC/B,WAAW;AAAA,IACX;AAAA,IACA,SAAS;AAAA,IACT;AAAA,EACF,CAAC;AAED,SAAO,QAAQ,qBAAqB;AAAA,IAClC;AAAA,IACA,SAAS;AAAA,IACT,QAAQ,MAAM,UAAU,YAAY;AAAA,IACpC;AAAA,EACF,CAAC;AACH;AAMO,SAAS,gBAAgB,EAAE,eAAe,GAAsD;AACrG,QAAM,yBAAyB,eAAe,IAAI,YAAY;AAE9D,QAAM,UAAU,wBAAwB,SAAS;AACjD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,gBAAgB,wBAAwB,OAAO;AAErD,SAAO,aAAa,SAAS,EAAE,eAAe,oBAAoB,MAAM,eAAe,CAAC;AAC1F;AAgBO,SAAS,kBACd,EAAE,eAAe,GACjB,cAC2B;AAC3B,QAAM,eAAe,aAAa,YAAY,EAAE,OAAO;AACvD,MAAI,CAAC,aAAc,QAAO;AAC1B,SAAO,aAAa,cAAc,EAAE,oBAAoB,MAAM,eAAe,CAAC;AAChF;","names":["MASTRACODE_GATEWAY_ID","MastraCodeGateway","routerId","auth"]}
@@ -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,45 @@
1
+ const buildMode = {
2
+ id: "build",
3
+ name: "Build",
4
+ description: "Task execution with write capabilities. Use for 'implement feature X', 'fix bug Y', 'refactor module Z'.",
5
+ 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.
6
+
7
+ ## Rules
8
+ - You have FULL ACCESS to read, write, and execute within your task scope.
9
+ - Stay focused on the specific task given. Do not make unrelated changes.
10
+ - Read files before modifying them \u2014 use view first, then string_replace_lsp or write_file.
11
+ - Verify your changes work by running relevant tests or checking for errors.
12
+
13
+ ## Tool Strategy
14
+ - **Read first**: Always view a file before editing it
15
+ - **Edit precisely**: Use string_replace_lsp with enough context to match uniquely
16
+ - **Use specialized tools**: Prefer view/search_content/find_files over shell commands for reading
17
+ - **Parallelize**: Make independent tool calls together (e.g., view multiple files at once)
18
+
19
+ ## Workflow
20
+ . Understand the task and explore relevant code
21
+ . For complex tasks (3+ steps): track progress internally and summarize it in your final answer
22
+ . Make changes incrementally \u2014 verify each change before moving on
23
+ . Run tests or type-check to verify
24
+
25
+ ## Efficiency
26
+ Your output returns to the parent agent. Be concise:
27
+ - Don't repeat file contents in your response
28
+ - Summarize what changed, don't narrate each step
29
+ - Keep your final summary under 300 words
30
+
31
+ ## Output Format
32
+ End with a structured summary:
33
+ . **Completed**: What you implemented (1-2 sentences)
34
+ . **Changes**: Files modified/created
35
+ . **Verification**: How you verified it works
36
+ . **Notes**: Follow-up needed (if any)`,
37
+ defaultModelId: "openai/gpt-5.5",
38
+ metadata: {
39
+ default: true
40
+ }
41
+ };
42
+ export {
43
+ buildMode
44
+ };
45
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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":"AASO,MAAM,YAAiC;AAAA,EAC5C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aACE;AAAA,EACF,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgCd,gBAAgB;AAAA,EAChB,UAAU;AAAA,IACR,SAAS;AAAA,EACX;AACF;","names":[]}
@@ -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,38 @@
1
+ import { EXPLORE_MODE_AVAILABLE_TOOLS } from "../tool-availability.js";
2
+ const fastMode = {
3
+ id: "fast",
4
+ name: "Explore",
5
+ description: "Read-only codebase exploration. Use for questions like 'find all usages of X', 'how does module Y work'.",
6
+ defaultModelId: "openai/gpt-5.4-mini",
7
+ instructions: `You are an expert code explorer. Your job is to investigate a codebase and answer a specific question or gather specific information.
8
+
9
+ ## Rules
10
+ - You have READ-ONLY access. You cannot modify files or run commands.
11
+ - Be thorough \u2014 search broadly first, then drill into relevant files.
12
+ - After gathering enough information, produce a clear, concise summary of your findings.
13
+
14
+ ## Tool Strategy
15
+ - **Start broad**: Use find_files (glob) to understand project structure
16
+ - **Search smart**: Use search_content (grep) with specific patterns \u2014 avoid overly broad searches
17
+ - **Read efficiently**: Use view with view_range for large files \u2014 don't read entire files if you only need a section
18
+ - **Parallelize**: Make multiple independent tool calls in one round when exploring different areas
19
+
20
+ ## Efficiency
21
+ Your output returns to the parent agent. Be concise:
22
+ - Don't include raw file contents in your response \u2014 summarize what you found
23
+ - Reference files by path and line number, not by copying code
24
+ - If a search returns many results, report the count and key examples, not every match
25
+
26
+ ## Output Format
27
+ End with a structured summary:
28
+ . **Answer**: Direct answer to the question (1-2 sentences)
29
+ . **Key Files**: Most relevant files with line numbers
30
+ . **Details**: Additional context if needed
31
+
32
+ Keep your summary under 300 words.`,
33
+ availableTools: [...EXPLORE_MODE_AVAILABLE_TOOLS]
34
+ };
35
+ export {
36
+ fastMode
37
+ };
38
+ //# sourceMappingURL=explore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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":"AAQA,SAAS,oCAAoC;AAEtC,MAAM,WAAgC;AAAA,EAC3C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,aACE;AAAA,EACF,gBAAgB;AAAA,EAChB,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2Bd,gBAAgB,CAAC,GAAG,4BAA4B;AAClD;","names":[]}
@@ -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,38 @@
1
+ import { PLAN_MODE_AVAILABLE_TOOLS } from "../tool-availability.js";
2
+ const planMode = {
3
+ id: "plan",
4
+ name: "Plan",
5
+ transitionsTo: "build",
6
+ defaultModelId: "openai/gpt-5.5",
7
+ description: "Read-only analysis and planning. Use for 'create an implementation plan for X', 'analyze the architecture of Y'.",
8
+ 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.
9
+
10
+ ## Rules
11
+ - You have READ-ONLY access to the project. You cannot modify project files or run commands.
12
+ - 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.
13
+ - First, explore the codebase to understand existing patterns, architecture, and conventions.
14
+ - Produce a concrete, actionable plan \u2014 not vague suggestions.
15
+
16
+ ## Tool Strategy
17
+ - **Discover structure**: Use find_files (glob) to understand project layout and find relevant files
18
+ - **Find patterns**: Use search_content (grep) to locate existing implementations, imports, and conventions
19
+ - **Understand deeply**: Use view with view_range to read specific sections of key files
20
+ - **Parallelize**: Make multiple independent tool calls when exploring different areas
21
+
22
+ ## Plan Delivery
23
+ - 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).
24
+ - Start the file with a \`# Title\` heading describing the plan.
25
+ - 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.
26
+ - Do NOT output the plan as text \u2014 it MUST live in the plan file.
27
+ - Be concise: reference files by path and line number, don't include raw contents.
28
+ - Focus on actionable details, not general observations.
29
+ - To revise after "Request changes", edit the same file in place with \`string_replace_lsp\`, and call \`submit_plan\` again with the same path.`,
30
+ metadata: {
31
+ default: false
32
+ },
33
+ availableTools: [...PLAN_MODE_AVAILABLE_TOOLS]
34
+ };
35
+ export {
36
+ planMode
37
+ };
38
+ //# sourceMappingURL=plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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":"AAIA,SAAS,iCAAiC;AAEnC,MAAM,WAAgC;AAAA,EAC3C,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,aACE;AAAA,EACF,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBd,UAAU;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EAEA,gBAAgB,CAAC,GAAG,yBAAyB;AAC/C;","names":[]}
@@ -0,0 +1,20 @@
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
+ }
10
+ /**
11
+ * Load all agent instruction files from global and project locations.
12
+ * Returns an array of instruction sources, with global ones first.
13
+ */
14
+ export declare function loadAgentInstructions(projectPath: string, configDirName?: string): InstructionSource[];
15
+ export declare function getStaticallyLoadedInstructionPaths(projectPath: string): string[];
16
+ /**
17
+ * Format loaded instructions into a string for the system prompt.
18
+ */
19
+ export declare function formatAgentInstructions(sources: InstructionSource[]): string;
20
+ //# 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;AAmBH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC7B;AAgBD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,SAAqB,GAAG,iBAAiB,EAAE,CAiDlH;AAED,wBAAgB,mCAAmC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjF;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAS5E"}
@@ -0,0 +1,82 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join, normalize } from "node:path";
4
+ import { DEFAULT_CONFIG_DIR } from "../../constants.js";
5
+ const INSTRUCTION_FILES = ["AGENTS.md", "CLAUDE.md"];
6
+ const PROJECT_LOCATIONS = [
7
+ "",
8
+ // project root
9
+ ".claude",
10
+ ".mastracode"
11
+ ];
12
+ const GLOBAL_LOCATIONS = [".claude", ".mastracode", ".config/claude", ".config/mastracode"];
13
+ function findInstructionFile(basePath) {
14
+ for (const filename of INSTRUCTION_FILES) {
15
+ const fullPath = join(basePath, filename);
16
+ if (existsSync(fullPath)) {
17
+ return fullPath;
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ function loadAgentInstructions(projectPath, configDirName = DEFAULT_CONFIG_DIR) {
23
+ const sources = [];
24
+ const home = homedir();
25
+ const projectLocations = PROJECT_LOCATIONS.map((loc) => loc === ".mastracode" ? configDirName : loc);
26
+ const globalLocations = GLOBAL_LOCATIONS.map((loc) => {
27
+ if (loc === ".mastracode") return configDirName;
28
+ if (loc === ".config/mastracode") return ".config/" + configDirName.replace(/^\./, "");
29
+ return loc;
30
+ });
31
+ for (const location of globalLocations) {
32
+ const basePath = join(home, location);
33
+ const filePath = findInstructionFile(basePath);
34
+ if (filePath) {
35
+ try {
36
+ const content = readFileSync(filePath, "utf-8").trim();
37
+ if (content) {
38
+ sources.push({ path: filePath, content, scope: "global" });
39
+ break;
40
+ }
41
+ } catch {
42
+ }
43
+ }
44
+ }
45
+ for (const location of projectLocations) {
46
+ const basePath = location ? join(projectPath, location) : projectPath;
47
+ const filePath = findInstructionFile(basePath);
48
+ if (filePath) {
49
+ try {
50
+ const content = readFileSync(filePath, "utf-8").trim();
51
+ if (content) {
52
+ sources.push({ path: filePath, content, scope: "project" });
53
+ break;
54
+ }
55
+ } catch {
56
+ }
57
+ }
58
+ }
59
+ return sources;
60
+ }
61
+ function getStaticallyLoadedInstructionPaths(projectPath) {
62
+ return loadAgentInstructions(projectPath).map((source) => normalize(source.path));
63
+ }
64
+ function formatAgentInstructions(sources) {
65
+ if (sources.length === 0) return "";
66
+ const sections = sources.map((source) => {
67
+ const label = source.scope === "global" ? "Global" : "Project";
68
+ return `<!-- ${label} instructions from ${source.path} -->
69
+ ${source.content}`;
70
+ });
71
+ return `
72
+ # Agent Instructions
73
+
74
+ ${sections.join("\n\n")}
75
+ `;
76
+ }
77
+ export {
78
+ formatAgentInstructions,
79
+ getStaticallyLoadedInstructionPaths,
80
+ loadAgentInstructions
81
+ };
82
+ //# sourceMappingURL=agent-instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/agents/prompts/agent-instructions.ts"],"sourcesContent":["/**\n * Load project and global agent instruction files (AGENTS.md, CLAUDE.md).\n * Prefers AGENTS.md over CLAUDE.md when multiple exist at the same location.\n */\n\nimport { existsSync, readFileSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join, normalize } from 'node:path';\nimport { DEFAULT_CONFIG_DIR } from '../../constants.js';\n\n// Filenames to check, in order of preference\nconst INSTRUCTION_FILES = ['AGENTS.md', 'CLAUDE.md'];\n\n// Locations to scan (relative to project root or home)\nconst PROJECT_LOCATIONS = [\n '', // project root\n '.claude',\n '.mastracode',\n];\n\nconst GLOBAL_LOCATIONS = ['.claude', '.mastracode', '.config/claude', '.config/mastracode'];\n\nexport interface InstructionSource {\n path: string;\n content: string;\n scope: 'global' | 'project';\n}\n\n/**\n * Find the first existing instruction file at a given base path.\n * Prefers AGENTS.md over CLAUDE.md.\n */\nfunction findInstructionFile(basePath: string): string | null {\n for (const filename of INSTRUCTION_FILES) {\n const fullPath = join(basePath, filename);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n return null;\n}\n\n/**\n * Load all agent instruction files from global and project locations.\n * Returns an array of instruction sources, with global ones first.\n */\nexport function loadAgentInstructions(projectPath: string, configDirName = DEFAULT_CONFIG_DIR): InstructionSource[] {\n const sources: InstructionSource[] = [];\n const home = homedir();\n\n // Derive location arrays from the base constants, substituting the config dir name\n const projectLocations = PROJECT_LOCATIONS.map(loc => (loc === '.mastracode' ? configDirName : loc));\n const globalLocations = GLOBAL_LOCATIONS.map(loc => {\n if (loc === '.mastracode') return configDirName;\n // XDG-style path (~/.config/<name>): strip the leading dot since the\n // .config/ prefix already signals a hidden/config directory.\n if (loc === '.config/mastracode') return '.config/' + configDirName.replace(/^\\./, '');\n return loc;\n });\n\n // Load global instructions first\n for (const location of globalLocations) {\n const basePath = join(home, location);\n const filePath = findInstructionFile(basePath);\n if (filePath) {\n try {\n const content = readFileSync(filePath, 'utf-8').trim();\n if (content) {\n sources.push({ path: filePath, content, scope: 'global' });\n break; // Only use first found global instruction file\n }\n } catch {\n // Skip unreadable files\n }\n }\n }\n\n // Load project instructions\n for (const location of projectLocations) {\n const basePath = location ? join(projectPath, location) : projectPath;\n const filePath = findInstructionFile(basePath);\n if (filePath) {\n try {\n const content = readFileSync(filePath, 'utf-8').trim();\n if (content) {\n sources.push({ path: filePath, content, scope: 'project' });\n break; // Only use first found project instruction file\n }\n } catch {\n // Skip unreadable files\n }\n }\n }\n\n return sources;\n}\n\nexport function getStaticallyLoadedInstructionPaths(projectPath: string): string[] {\n return loadAgentInstructions(projectPath).map(source => normalize(source.path));\n}\n\n/**\n * Format loaded instructions into a string for the system prompt.\n */\nexport function formatAgentInstructions(sources: InstructionSource[]): string {\n if (sources.length === 0) return '';\n\n const sections = sources.map(source => {\n const label = source.scope === 'global' ? 'Global' : 'Project';\n return `<!-- ${label} instructions from ${source.path} -->\\n${source.content}`;\n });\n\n return `\\n# Agent Instructions\\n\\n${sections.join('\\n\\n')}\\n`;\n}\n"],"mappings":"AAKA,SAAS,YAAY,oBAAoB;AACzC,SAAS,eAAe;AACxB,SAAS,MAAM,iBAAiB;AAChC,SAAS,0BAA0B;AAGnC,MAAM,oBAAoB,CAAC,aAAa,WAAW;AAGnD,MAAM,oBAAoB;AAAA,EACxB;AAAA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,mBAAmB,CAAC,WAAW,eAAe,kBAAkB,oBAAoB;AAY1F,SAAS,oBAAoB,UAAiC;AAC5D,aAAW,YAAY,mBAAmB;AACxC,UAAM,WAAW,KAAK,UAAU,QAAQ;AACxC,QAAI,WAAW,QAAQ,GAAG;AACxB,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;AAMO,SAAS,sBAAsB,aAAqB,gBAAgB,oBAAyC;AAClH,QAAM,UAA+B,CAAC;AACtC,QAAM,OAAO,QAAQ;AAGrB,QAAM,mBAAmB,kBAAkB,IAAI,SAAQ,QAAQ,gBAAgB,gBAAgB,GAAI;AACnG,QAAM,kBAAkB,iBAAiB,IAAI,SAAO;AAClD,QAAI,QAAQ,cAAe,QAAO;AAGlC,QAAI,QAAQ,qBAAsB,QAAO,aAAa,cAAc,QAAQ,OAAO,EAAE;AACrF,WAAO;AAAA,EACT,CAAC;AAGD,aAAW,YAAY,iBAAiB;AACtC,UAAM,WAAW,KAAK,MAAM,QAAQ;AACpC,UAAM,WAAW,oBAAoB,QAAQ;AAC7C,QAAI,UAAU;AACZ,UAAI;AACF,cAAM,UAAU,aAAa,UAAU,OAAO,EAAE,KAAK;AACrD,YAAI,SAAS;AACX,kBAAQ,KAAK,EAAE,MAAM,UAAU,SAAS,OAAO,SAAS,CAAC;AACzD;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AAGA,aAAW,YAAY,kBAAkB;AACvC,UAAM,WAAW,WAAW,KAAK,aAAa,QAAQ,IAAI;AAC1D,UAAM,WAAW,oBAAoB,QAAQ;AAC7C,QAAI,UAAU;AACZ,UAAI;AACF,cAAM,UAAU,aAAa,UAAU,OAAO,EAAE,KAAK;AACrD,YAAI,SAAS;AACX,kBAAQ,KAAK,EAAE,MAAM,UAAU,SAAS,OAAO,UAAU,CAAC;AAC1D;AAAA,QACF;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,oCAAoC,aAA+B;AACjF,SAAO,sBAAsB,WAAW,EAAE,IAAI,YAAU,UAAU,OAAO,IAAI,CAAC;AAChF;AAKO,SAAS,wBAAwB,SAAsC;AAC5E,MAAI,QAAQ,WAAW,EAAG,QAAO;AAEjC,QAAM,WAAW,QAAQ,IAAI,YAAU;AACrC,UAAM,QAAQ,OAAO,UAAU,WAAW,WAAW;AACrD,WAAO,QAAQ,KAAK,sBAAsB,OAAO,IAAI;AAAA,EAAS,OAAO,OAAO;AAAA,EAC9E,CAAC;AAED,SAAO;AAAA;AAAA;AAAA,EAA6B,SAAS,KAAK,MAAM,CAAC;AAAA;AAC3D;","names":[]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Build mode prompt — full tool access, make changes and verify.
3
+ */
4
+ import type { PromptContext } from './index.js';
5
+ /**
6
+ * Dynamic build mode prompt function.
7
+ * When an approved plan exists in state, prepends it so the agent
8
+ * knows exactly what to implement.
9
+ */
10
+ export declare function buildModePromptFn(ctx: PromptContext): string;
11
+ export declare const buildModePrompt = "\n# Build Mode\n\nYou are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.\n\n## Working Style\n\n**For simple tasks** (typo fixes, small edits, single-file changes):\n- Just do it. No need to explain your plan first.\n\n**For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):\n- Use the available task-management tools to create and update your task list\n- Work on ONE step at a time \u2014 complete it and verify it works before moving on\n- If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user\n\n## The Implementation Loop\n\nFor each change you make:\n\n1. **Understand** \u2014 Read the relevant code. Check how similar things are done elsewhere.\n2. **Implement** \u2014 Make the change. Follow existing patterns and conventions.\n3. **Verify** \u2014 Test that it works. Don't assume \u2014 actually run it.\n4. **Prove** \u2014 Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.\n5. **Clean up** \u2014 Ensure no broken code, no debug statements, no half-done features.\n\nOnly move to the next change after the current one is verified and proved to be working.\n\n## Verification is Required\n\nBefore considering any task complete:\n- Run relevant tests (check package.json for test scripts)\n- For TypeScript, run `tsc --noEmit` to catch type errors\n- If there are no automated tests, manually verify the behavior works as expected\n- Confirm the result makes sense in the codebase and improves the requested behavior\n- Use available task-checking tools to ensure all tracked tasks are done\n\n**Don't mark something as done until you've verified and proved it actually works.**\n\n## Error Recovery\n\nWhen something breaks:\n1. Read the full error output carefully \u2014 don't guess\n2. Find the root cause, not just the symptom\n3. Fix it properly \u2014 no casts or suppressions to hide errors\n4. Re-run to confirm the fix\n5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option\n\n## Git in Build Mode\n\n- Before committing, verify the code compiles and passes lint\n- Use descriptive branch names: `feat/...`, `fix/...`, `refactor/...`\n";
12
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/build.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAiB5D;AAED,eAAO,MAAM,eAAe,00EAmD3B,CAAC"}
@@ -0,0 +1,73 @@
1
+ function buildModePromptFn(ctx) {
2
+ if (ctx.activePlan) {
3
+ return `# Approved Plan
4
+
5
+ **${ctx.activePlan.title}**
6
+
7
+ ${ctx.activePlan.plan}
8
+
9
+ ---
10
+
11
+ Implement the approved plan above. Follow the steps in order and verify each step works before moving on.
12
+
13
+ ` + buildModePrompt;
14
+ }
15
+ return buildModePrompt;
16
+ }
17
+ const buildModePrompt = `
18
+ # Build Mode
19
+
20
+ You are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.
21
+
22
+ ## Working Style
23
+
24
+ **For simple tasks** (typo fixes, small edits, single-file changes):
25
+ - Just do it. No need to explain your plan first.
26
+
27
+ **For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):
28
+ - Use the available task-management tools to create and update your task list
29
+ - Work on ONE step at a time \u2014 complete it and verify it works before moving on
30
+ - If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user
31
+
32
+ ## The Implementation Loop
33
+
34
+ For each change you make:
35
+
36
+ 1. **Understand** \u2014 Read the relevant code. Check how similar things are done elsewhere.
37
+ 2. **Implement** \u2014 Make the change. Follow existing patterns and conventions.
38
+ 3. **Verify** \u2014 Test that it works. Don't assume \u2014 actually run it.
39
+ 4. **Prove** \u2014 Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.
40
+ 5. **Clean up** \u2014 Ensure no broken code, no debug statements, no half-done features.
41
+
42
+ Only move to the next change after the current one is verified and proved to be working.
43
+
44
+ ## Verification is Required
45
+
46
+ Before considering any task complete:
47
+ - Run relevant tests (check package.json for test scripts)
48
+ - For TypeScript, run \`tsc --noEmit\` to catch type errors
49
+ - If there are no automated tests, manually verify the behavior works as expected
50
+ - Confirm the result makes sense in the codebase and improves the requested behavior
51
+ - Use available task-checking tools to ensure all tracked tasks are done
52
+
53
+ **Don't mark something as done until you've verified and proved it actually works.**
54
+
55
+ ## Error Recovery
56
+
57
+ When something breaks:
58
+ 1. Read the full error output carefully \u2014 don't guess
59
+ 2. Find the root cause, not just the symptom
60
+ 3. Fix it properly \u2014 no casts or suppressions to hide errors
61
+ 4. Re-run to confirm the fix
62
+ 5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option
63
+
64
+ ## Git in Build Mode
65
+
66
+ - Before committing, verify the code compiles and passes lint
67
+ - Use descriptive branch names: \`feat/...\`, \`fix/...\`, \`refactor/...\`
68
+ `;
69
+ export {
70
+ buildModePrompt,
71
+ buildModePromptFn
72
+ };
73
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/agents/prompts/build.ts"],"sourcesContent":["/**\n * Build mode prompt — full tool access, make changes and verify.\n */\n\nimport type { PromptContext } from './index.js';\n\n/**\n * Dynamic build mode prompt function.\n * When an approved plan exists in state, prepends it so the agent\n * knows exactly what to implement.\n */\nexport function buildModePromptFn(ctx: PromptContext): string {\n if (ctx.activePlan) {\n return (\n `# Approved Plan\n\n**${ctx.activePlan.title}**\n\n${ctx.activePlan.plan}\n\n---\n\nImplement the approved plan above. Follow the steps in order and verify each step works before moving on.\n\n` + buildModePrompt\n );\n }\n return buildModePrompt;\n}\n\nexport const buildModePrompt = `\n# Build Mode\n\nYou are in BUILD mode. You have full access to all tools and can read, write, edit, and execute commands.\n\n## Working Style\n\n**For simple tasks** (typo fixes, small edits, single-file changes):\n- Just do it. No need to explain your plan first.\n\n**For non-trivial tasks** (3+ files, architectural decisions, unclear requirements):\n- Use the available task-management tools to create and update your task list\n- Work on ONE step at a time — complete it and verify it works before moving on\n- If multiple approaches are plausible and the choice would materially affect scope, behavior, or risk, stop and ask the user\n\n## The Implementation Loop\n\nFor each change you make:\n\n1. **Understand** — Read the relevant code. Check how similar things are done elsewhere.\n2. **Implement** — Make the change. Follow existing patterns and conventions.\n3. **Verify** — Test that it works. Don't assume — actually run it.\n4. **Prove** — Proactively prove that the change is good, makes sense in context, is a positive contribution, and works fully. The burden of proof is on YOU.\n5. **Clean up** — Ensure no broken code, no debug statements, no half-done features.\n\nOnly move to the next change after the current one is verified and proved to be working.\n\n## Verification is Required\n\nBefore considering any task complete:\n- Run relevant tests (check package.json for test scripts)\n- For TypeScript, run \\`tsc --noEmit\\` to catch type errors\n- If there are no automated tests, manually verify the behavior works as expected\n- Confirm the result makes sense in the codebase and improves the requested behavior\n- Use available task-checking tools to ensure all tracked tasks are done\n\n**Don't mark something as done until you've verified and proved it actually works.**\n\n## Error Recovery\n\nWhen something breaks:\n1. Read the full error output carefully — don't guess\n2. Find the root cause, not just the symptom\n3. Fix it properly — no casts or suppressions to hide errors\n4. Re-run to confirm the fix\n5. If progress is blocked after reasonable attempts, briefly explain the blocker, what you've tried, and the next best option\n\n## Git in Build Mode\n\n- Before committing, verify the code compiles and passes lint\n- Use descriptive branch names: \\`feat/...\\`, \\`fix/...\\`, \\`refactor/...\\`\n`;\n"],"mappings":"AAWO,SAAS,kBAAkB,KAA4B;AAC5D,MAAI,IAAI,YAAY;AAClB,WACE;AAAA;AAAA,IAEF,IAAI,WAAW,KAAK;AAAA;AAAA,EAEtB,IAAI,WAAW,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMjB;AAAA,EAEF;AACA,SAAO;AACT;AAEO,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Fast mode prompt — quick answers and small edits, minimal overhead.
3
+ */
4
+ export declare const fastModePrompt = "\n# Fast Mode\n\nYou are in FAST mode. Optimize for speed and brevity.\n\n## Rules\n- Keep responses short. Under 200 words unless the task genuinely requires more.\n- Skip planning. Just do the task directly.\n- For questions: give the direct answer, not a tutorial.\n- For edits: make the change, show what you did, move on.\n- Don't explore the codebase more than necessary for the immediate task.\n\n## When to Use Tools vs. Just Answer\n- If the user asks a general programming question, answer directly from knowledge. Don't search the codebase.\n- If the user asks about THIS project's code, use tools to look it up \u2014 don't guess.\n- If the user asks for a quick edit and you know the file, read it and edit it. Don't ask for confirmation.\n- One tool call to read + one to edit is ideal. Minimize round trips.\n";
5
+ //# sourceMappingURL=fast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fast.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/fast.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,6zBAiB1B,CAAC"}