@mastra/code-sdk 0.0.0-client-tool-results-20260912062135

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 (594) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +37 -0
  3. package/dist/acp/agent.d.ts +35 -0
  4. package/dist/acp/agent.d.ts.map +1 -0
  5. package/dist/acp/agent.js +161 -0
  6. package/dist/acp/agent.js.map +1 -0
  7. package/dist/acp/event-mapper.d.ts +22 -0
  8. package/dist/acp/event-mapper.d.ts.map +1 -0
  9. package/dist/acp/event-mapper.js +214 -0
  10. package/dist/acp/event-mapper.js.map +1 -0
  11. package/dist/acp/index.d.ts +8 -0
  12. package/dist/acp/index.d.ts.map +1 -0
  13. package/dist/acp/index.js +65 -0
  14. package/dist/acp/index.js.map +1 -0
  15. package/dist/acp/server.d.ts +7 -0
  16. package/dist/acp/server.d.ts.map +1 -0
  17. package/dist/acp/server.js +35 -0
  18. package/dist/acp/server.js.map +1 -0
  19. package/dist/acp.d.ts +2 -0
  20. package/dist/acp.d.ts.map +1 -0
  21. package/dist/acp.js +2 -0
  22. package/dist/agents/context-audit.d.ts +84 -0
  23. package/dist/agents/context-audit.d.ts.map +1 -0
  24. package/dist/agents/context-audit.js +118 -0
  25. package/dist/agents/context-audit.js.map +1 -0
  26. package/dist/agents/credential-resolver.d.ts +63 -0
  27. package/dist/agents/credential-resolver.d.ts.map +1 -0
  28. package/dist/agents/credential-resolver.js +97 -0
  29. package/dist/agents/credential-resolver.js.map +1 -0
  30. package/dist/agents/custom-provider-source.d.ts +35 -0
  31. package/dist/agents/custom-provider-source.d.ts.map +1 -0
  32. package/dist/agents/custom-provider-source.js +25 -0
  33. package/dist/agents/custom-provider-source.js.map +1 -0
  34. package/dist/agents/instructions.d.ts +29 -0
  35. package/dist/agents/instructions.d.ts.map +1 -0
  36. package/dist/agents/instructions.js +58 -0
  37. package/dist/agents/instructions.js.map +1 -0
  38. package/dist/agents/mastracode-gateway.d.ts +74 -0
  39. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  40. package/dist/agents/mastracode-gateway.js +431 -0
  41. package/dist/agents/mastracode-gateway.js.map +1 -0
  42. package/dist/agents/memory.d.ts +30 -0
  43. package/dist/agents/memory.d.ts.map +1 -0
  44. package/dist/agents/memory.js +171 -0
  45. package/dist/agents/memory.js.map +1 -0
  46. package/dist/agents/model.d.ts +81 -0
  47. package/dist/agents/model.d.ts.map +1 -0
  48. package/dist/agents/model.js +155 -0
  49. package/dist/agents/model.js.map +1 -0
  50. package/dist/agents/modes/build.d.ts +10 -0
  51. package/dist/agents/modes/build.d.ts.map +1 -0
  52. package/dist/agents/modes/build.js +49 -0
  53. package/dist/agents/modes/build.js.map +1 -0
  54. package/dist/agents/modes/explore.d.ts +10 -0
  55. package/dist/agents/modes/explore.d.ts.map +1 -0
  56. package/dist/agents/modes/explore.js +42 -0
  57. package/dist/agents/modes/explore.js.map +1 -0
  58. package/dist/agents/modes/plan.d.ts +6 -0
  59. package/dist/agents/modes/plan.d.ts.map +1 -0
  60. package/dist/agents/modes/plan.js +42 -0
  61. package/dist/agents/modes/plan.js.map +1 -0
  62. package/dist/agents/prompts/agent-instructions.d.ts +70 -0
  63. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  64. package/dist/agents/prompts/agent-instructions.js +211 -0
  65. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  66. package/dist/agents/prompts/build.d.ts +12 -0
  67. package/dist/agents/prompts/build.d.ts.map +1 -0
  68. package/dist/agents/prompts/build.js +76 -0
  69. package/dist/agents/prompts/build.js.map +1 -0
  70. package/dist/agents/prompts/fast.d.ts +5 -0
  71. package/dist/agents/prompts/fast.d.ts.map +1 -0
  72. package/dist/agents/prompts/fast.js +26 -0
  73. package/dist/agents/prompts/fast.js.map +1 -0
  74. package/dist/agents/prompts/index.d.ts +50 -0
  75. package/dist/agents/prompts/index.d.ts.map +1 -0
  76. package/dist/agents/prompts/index.js +119 -0
  77. package/dist/agents/prompts/index.js.map +1 -0
  78. package/dist/agents/prompts/model.d.ts +5 -0
  79. package/dist/agents/prompts/model.d.ts.map +1 -0
  80. package/dist/agents/prompts/model.js +23 -0
  81. package/dist/agents/prompts/model.js.map +1 -0
  82. package/dist/agents/prompts/plan.d.ts +6 -0
  83. package/dist/agents/prompts/plan.d.ts.map +1 -0
  84. package/dist/agents/prompts/plan.js +111 -0
  85. package/dist/agents/prompts/plan.js.map +1 -0
  86. package/dist/agents/prompts/tool-guidance.d.ts +18 -0
  87. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  88. package/dist/agents/prompts/tool-guidance.js +180 -0
  89. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  90. package/dist/agents/sandbox-filesystem.d.ts +117 -0
  91. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  92. package/dist/agents/sandbox-filesystem.js +356 -0
  93. package/dist/agents/sandbox-filesystem.js.map +1 -0
  94. package/dist/agents/subagents/execute.d.ts +3 -0
  95. package/dist/agents/subagents/execute.d.ts.map +1 -0
  96. package/dist/agents/subagents/execute.js +27 -0
  97. package/dist/agents/subagents/execute.js.map +1 -0
  98. package/dist/agents/subagents/explore.d.ts +3 -0
  99. package/dist/agents/subagents/explore.d.ts.map +1 -0
  100. package/dist/agents/subagents/explore.js +18 -0
  101. package/dist/agents/subagents/explore.js.map +1 -0
  102. package/dist/agents/subagents/plan.d.ts +3 -0
  103. package/dist/agents/subagents/plan.d.ts.map +1 -0
  104. package/dist/agents/subagents/plan.js +18 -0
  105. package/dist/agents/subagents/plan.js.map +1 -0
  106. package/dist/agents/thread-caveman-state.d.ts +17 -0
  107. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  108. package/dist/agents/thread-caveman-state.js +107 -0
  109. package/dist/agents/thread-caveman-state.js.map +1 -0
  110. package/dist/agents/tool-availability.d.ts +10 -0
  111. package/dist/agents/tool-availability.d.ts.map +1 -0
  112. package/dist/agents/tool-availability.js +96 -0
  113. package/dist/agents/tool-availability.js.map +1 -0
  114. package/dist/agents/tools.d.ts +36 -0
  115. package/dist/agents/tools.d.ts.map +1 -0
  116. package/dist/agents/tools.js +117 -0
  117. package/dist/agents/tools.js.map +1 -0
  118. package/dist/agents/workflow-builder-agent.d.ts +2 -0
  119. package/dist/agents/workflow-builder-agent.d.ts.map +1 -0
  120. package/dist/agents/workflow-builder-agent.js +80 -0
  121. package/dist/agents/workflow-builder-agent.js.map +1 -0
  122. package/dist/agents/workspace.d.ts +32 -0
  123. package/dist/agents/workspace.d.ts.map +1 -0
  124. package/dist/agents/workspace.js +208 -0
  125. package/dist/agents/workspace.js.map +1 -0
  126. package/dist/analytics.d.ts +18 -0
  127. package/dist/analytics.d.ts.map +1 -0
  128. package/dist/analytics.js +163 -0
  129. package/dist/analytics.js.map +1 -0
  130. package/dist/auth/authorization-input.d.ts +16 -0
  131. package/dist/auth/authorization-input.d.ts.map +1 -0
  132. package/dist/auth/authorization-input.js +42 -0
  133. package/dist/auth/authorization-input.js.map +1 -0
  134. package/dist/auth/device-code.d.ts +93 -0
  135. package/dist/auth/device-code.d.ts.map +1 -0
  136. package/dist/auth/device-code.js +129 -0
  137. package/dist/auth/device-code.js.map +1 -0
  138. package/dist/auth/index.d.ts +12 -0
  139. package/dist/auth/index.d.ts.map +1 -0
  140. package/dist/auth/index.js +8 -0
  141. package/dist/auth/pkce.d.ts +13 -0
  142. package/dist/auth/pkce.d.ts.map +1 -0
  143. package/dist/auth/pkce.js +32 -0
  144. package/dist/auth/pkce.js.map +1 -0
  145. package/dist/auth/provider-auth-error.d.ts +12 -0
  146. package/dist/auth/provider-auth-error.d.ts.map +1 -0
  147. package/dist/auth/provider-auth-error.js +16 -0
  148. package/dist/auth/provider-auth-error.js.map +1 -0
  149. package/dist/auth/providers/anthropic.d.ts +40 -0
  150. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  151. package/dist/auth/providers/anthropic.js +126 -0
  152. package/dist/auth/providers/anthropic.js.map +1 -0
  153. package/dist/auth/providers/github-copilot.d.ts +154 -0
  154. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  155. package/dist/auth/providers/github-copilot.js +340 -0
  156. package/dist/auth/providers/github-copilot.js.map +1 -0
  157. package/dist/auth/providers/kimi-coding.d.ts +38 -0
  158. package/dist/auth/providers/kimi-coding.d.ts.map +1 -0
  159. package/dist/auth/providers/kimi-coding.js +232 -0
  160. package/dist/auth/providers/kimi-coding.js.map +1 -0
  161. package/dist/auth/providers/openai-codex.d.ts +139 -0
  162. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  163. package/dist/auth/providers/openai-codex.js +519 -0
  164. package/dist/auth/providers/openai-codex.js.map +1 -0
  165. package/dist/auth/providers/xai.d.ts +64 -0
  166. package/dist/auth/providers/xai.d.ts.map +1 -0
  167. package/dist/auth/providers/xai.js +205 -0
  168. package/dist/auth/providers/xai.js.map +1 -0
  169. package/dist/auth/storage.d.ts +92 -0
  170. package/dist/auth/storage.d.ts.map +1 -0
  171. package/dist/auth/storage.js +211 -0
  172. package/dist/auth/storage.js.map +1 -0
  173. package/dist/auth/types.d.ts +89 -0
  174. package/dist/auth/types.d.ts.map +1 -0
  175. package/dist/auth/types.js +1 -0
  176. package/dist/clipboard/index.d.ts +26 -0
  177. package/dist/clipboard/index.d.ts.map +1 -0
  178. package/dist/clipboard/index.js +226 -0
  179. package/dist/clipboard/index.js.map +1 -0
  180. package/dist/constants.d.ts +10 -0
  181. package/dist/constants.d.ts.map +1 -0
  182. package/dist/constants.js +18 -0
  183. package/dist/constants.js.map +1 -0
  184. package/dist/error-classification.d.ts +10 -0
  185. package/dist/error-classification.d.ts.map +1 -0
  186. package/dist/error-classification.js +22 -0
  187. package/dist/error-classification.js.map +1 -0
  188. package/dist/evals/context-builder.d.ts +41 -0
  189. package/dist/evals/context-builder.d.ts.map +1 -0
  190. package/dist/evals/context-builder.js +161 -0
  191. package/dist/evals/context-builder.js.map +1 -0
  192. package/dist/evals/index.d.ts +4 -0
  193. package/dist/evals/index.d.ts.map +1 -0
  194. package/dist/evals/index.js +5 -0
  195. package/dist/evals/scorers/classify-command.d.ts +31 -0
  196. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  197. package/dist/evals/scorers/classify-command.js +73 -0
  198. package/dist/evals/scorers/classify-command.js.map +1 -0
  199. package/dist/evals/scorers/efficiency.d.ts +44 -0
  200. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  201. package/dist/evals/scorers/efficiency.js +259 -0
  202. package/dist/evals/scorers/efficiency.js.map +1 -0
  203. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  204. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  205. package/dist/evals/scorers/extract-tools.js +60 -0
  206. package/dist/evals/scorers/extract-tools.js.map +1 -0
  207. package/dist/evals/scorers/index.d.ts +3 -0
  208. package/dist/evals/scorers/index.d.ts.map +1 -0
  209. package/dist/evals/scorers/index.js +3 -0
  210. package/dist/evals/scorers/outcome.d.ts +49 -0
  211. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  212. package/dist/evals/scorers/outcome.js +347 -0
  213. package/dist/evals/scorers/outcome.js.map +1 -0
  214. package/dist/goal-manager.d.ts +78 -0
  215. package/dist/goal-manager.d.ts.map +1 -0
  216. package/dist/goal-manager.js +273 -0
  217. package/dist/goal-manager.js.map +1 -0
  218. package/dist/goal-signal.d.ts +14 -0
  219. package/dist/goal-signal.d.ts.map +1 -0
  220. package/dist/goal-signal.js +17 -0
  221. package/dist/goal-signal.js.map +1 -0
  222. package/dist/headless/cli.d.ts +42 -0
  223. package/dist/headless/cli.d.ts.map +1 -0
  224. package/dist/headless/cli.js +209 -0
  225. package/dist/headless/cli.js.map +1 -0
  226. package/dist/headless/flags.d.ts +33 -0
  227. package/dist/headless/flags.d.ts.map +1 -0
  228. package/dist/headless/flags.js +190 -0
  229. package/dist/headless/flags.js.map +1 -0
  230. package/dist/headless/format.d.ts +38 -0
  231. package/dist/headless/format.d.ts.map +1 -0
  232. package/dist/headless/format.js +89 -0
  233. package/dist/headless/format.js.map +1 -0
  234. package/dist/headless/index.d.ts +25 -0
  235. package/dist/headless/index.d.ts.map +1 -0
  236. package/dist/headless/index.js +6 -0
  237. package/dist/headless/policy.d.ts +17 -0
  238. package/dist/headless/policy.d.ts.map +1 -0
  239. package/dist/headless/policy.js +42 -0
  240. package/dist/headless/policy.js.map +1 -0
  241. package/dist/headless/run-mc.d.ts +7 -0
  242. package/dist/headless/run-mc.d.ts.map +1 -0
  243. package/dist/headless/run-mc.js +346 -0
  244. package/dist/headless/run-mc.js.map +1 -0
  245. package/dist/headless/types.d.ts +158 -0
  246. package/dist/headless/types.d.ts.map +1 -0
  247. package/dist/headless/types.js +19 -0
  248. package/dist/headless/types.js.map +1 -0
  249. package/dist/hooks/config.d.ts +11 -0
  250. package/dist/hooks/config.d.ts.map +1 -0
  251. package/dist/hooks/config.js +73 -0
  252. package/dist/hooks/config.js.map +1 -0
  253. package/dist/hooks/executor.d.ts +13 -0
  254. package/dist/hooks/executor.d.ts.map +1 -0
  255. package/dist/hooks/executor.js +129 -0
  256. package/dist/hooks/executor.js.map +1 -0
  257. package/dist/hooks/index.d.ts +6 -0
  258. package/dist/hooks/index.d.ts.map +1 -0
  259. package/dist/hooks/index.js +5 -0
  260. package/dist/hooks/manager.d.ts +54 -0
  261. package/dist/hooks/manager.d.ts.map +1 -0
  262. package/dist/hooks/manager.js +241 -0
  263. package/dist/hooks/manager.js.map +1 -0
  264. package/dist/hooks/types.d.ts +172 -0
  265. package/dist/hooks/types.d.ts.map +1 -0
  266. package/dist/hooks/types.js +8 -0
  267. package/dist/hooks/types.js.map +1 -0
  268. package/dist/index.d.ts +341 -0
  269. package/dist/index.d.ts.map +1 -0
  270. package/dist/index.js +919 -0
  271. package/dist/index.js.map +1 -0
  272. package/dist/ipc/ipc-reporter.d.ts +14 -0
  273. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  274. package/dist/ipc/ipc-reporter.js +21 -0
  275. package/dist/ipc/ipc-reporter.js.map +1 -0
  276. package/dist/knowledge-inspector.d.ts +119 -0
  277. package/dist/knowledge-inspector.d.ts.map +1 -0
  278. package/dist/knowledge-inspector.js +508 -0
  279. package/dist/knowledge-inspector.js.map +1 -0
  280. package/dist/knowledge-scope.d.ts +35 -0
  281. package/dist/knowledge-scope.d.ts.map +1 -0
  282. package/dist/knowledge-scope.js +47 -0
  283. package/dist/knowledge-scope.js.map +1 -0
  284. package/dist/lsp/client.d.ts +56 -0
  285. package/dist/lsp/client.d.ts.map +1 -0
  286. package/dist/lsp/client.js +251 -0
  287. package/dist/lsp/client.js.map +1 -0
  288. package/dist/lsp/index.d.ts +4 -0
  289. package/dist/lsp/index.d.ts.map +1 -0
  290. package/dist/lsp/index.js +4 -0
  291. package/dist/lsp/language.d.ts +9 -0
  292. package/dist/lsp/language.d.ts.map +1 -0
  293. package/dist/lsp/language.js +44 -0
  294. package/dist/lsp/language.js.map +1 -0
  295. package/dist/lsp/manager.d.ts +34 -0
  296. package/dist/lsp/manager.d.ts.map +1 -0
  297. package/dist/lsp/manager.js +82 -0
  298. package/dist/lsp/manager.js.map +1 -0
  299. package/dist/lsp/server.d.ts +27 -0
  300. package/dist/lsp/server.d.ts.map +1 -0
  301. package/dist/lsp/server.js +159 -0
  302. package/dist/lsp/server.js.map +1 -0
  303. package/dist/lsp/workspace.d.ts +9 -0
  304. package/dist/lsp/workspace.d.ts.map +1 -0
  305. package/dist/lsp/workspace.js +55 -0
  306. package/dist/lsp/workspace.js.map +1 -0
  307. package/dist/mcp/config.d.ts +62 -0
  308. package/dist/mcp/config.d.ts.map +1 -0
  309. package/dist/mcp/config.js +301 -0
  310. package/dist/mcp/config.js.map +1 -0
  311. package/dist/mcp/index.d.ts +6 -0
  312. package/dist/mcp/index.d.ts.map +1 -0
  313. package/dist/mcp/index.js +3 -0
  314. package/dist/mcp/manager.d.ts +101 -0
  315. package/dist/mcp/manager.d.ts.map +1 -0
  316. package/dist/mcp/manager.js +644 -0
  317. package/dist/mcp/manager.js.map +1 -0
  318. package/dist/mcp/state.d.ts +35 -0
  319. package/dist/mcp/state.d.ts.map +1 -0
  320. package/dist/mcp/state.js +97 -0
  321. package/dist/mcp/state.js.map +1 -0
  322. package/dist/mcp/types.d.ts +125 -0
  323. package/dist/mcp/types.d.ts.map +1 -0
  324. package/dist/mcp/types.js +1 -0
  325. package/dist/onboarding/custom-packs.d.ts +7 -0
  326. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  327. package/dist/onboarding/custom-packs.js +17 -0
  328. package/dist/onboarding/custom-packs.js.map +1 -0
  329. package/dist/onboarding/custom-providers.d.ts +4 -0
  330. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  331. package/dist/onboarding/custom-providers.js +30 -0
  332. package/dist/onboarding/custom-providers.js.map +1 -0
  333. package/dist/onboarding/index.d.ts +5 -0
  334. package/dist/onboarding/index.d.ts.map +1 -0
  335. package/dist/onboarding/index.js +3 -0
  336. package/dist/onboarding/om-settings.d.ts +25 -0
  337. package/dist/onboarding/om-settings.d.ts.map +1 -0
  338. package/dist/onboarding/om-settings.js +47 -0
  339. package/dist/onboarding/om-settings.js.map +1 -0
  340. package/dist/onboarding/packs.d.ts +49 -0
  341. package/dist/onboarding/packs.d.ts.map +1 -0
  342. package/dist/onboarding/packs.js +182 -0
  343. package/dist/onboarding/packs.js.map +1 -0
  344. package/dist/onboarding/settings.d.ts +438 -0
  345. package/dist/onboarding/settings.d.ts.map +1 -0
  346. package/dist/onboarding/settings.js +847 -0
  347. package/dist/onboarding/settings.js.map +1 -0
  348. package/dist/permissions.d.ts +55 -0
  349. package/dist/permissions.d.ts.map +1 -0
  350. package/dist/permissions.js +137 -0
  351. package/dist/permissions.js.map +1 -0
  352. package/dist/plugin.d.ts +144 -0
  353. package/dist/plugin.d.ts.map +1 -0
  354. package/dist/plugin.js +30 -0
  355. package/dist/plugin.js.map +1 -0
  356. package/dist/plugins/dependencies.d.ts +9 -0
  357. package/dist/plugins/dependencies.d.ts.map +1 -0
  358. package/dist/plugins/dependencies.js +88 -0
  359. package/dist/plugins/dependencies.js.map +1 -0
  360. package/dist/plugins/install.d.ts +21 -0
  361. package/dist/plugins/install.d.ts.map +1 -0
  362. package/dist/plugins/install.js +190 -0
  363. package/dist/plugins/install.js.map +1 -0
  364. package/dist/plugins/loader.d.ts +19 -0
  365. package/dist/plugins/loader.d.ts.map +1 -0
  366. package/dist/plugins/loader.js +258 -0
  367. package/dist/plugins/loader.js.map +1 -0
  368. package/dist/plugins/manager.d.ts +98 -0
  369. package/dist/plugins/manager.d.ts.map +1 -0
  370. package/dist/plugins/manager.js +456 -0
  371. package/dist/plugins/manager.js.map +1 -0
  372. package/dist/plugins/manifest.d.ts +14 -0
  373. package/dist/plugins/manifest.d.ts.map +1 -0
  374. package/dist/plugins/manifest.js +50 -0
  375. package/dist/plugins/manifest.js.map +1 -0
  376. package/dist/plugins/package-link.d.ts +3 -0
  377. package/dist/plugins/package-link.d.ts.map +1 -0
  378. package/dist/plugins/package-link.js +61 -0
  379. package/dist/plugins/package-link.js.map +1 -0
  380. package/dist/plugins/paths.d.ts +10 -0
  381. package/dist/plugins/paths.d.ts.map +1 -0
  382. package/dist/plugins/paths.js +25 -0
  383. package/dist/plugins/paths.js.map +1 -0
  384. package/dist/plugins/registry.d.ts +8 -0
  385. package/dist/plugins/registry.d.ts.map +1 -0
  386. package/dist/plugins/registry.js +112 -0
  387. package/dist/plugins/registry.js.map +1 -0
  388. package/dist/plugins/scaffold.d.ts +10 -0
  389. package/dist/plugins/scaffold.d.ts.map +1 -0
  390. package/dist/plugins/scaffold.js +116 -0
  391. package/dist/plugins/scaffold.js.map +1 -0
  392. package/dist/plugins/signal-lane.d.ts +58 -0
  393. package/dist/plugins/signal-lane.d.ts.map +1 -0
  394. package/dist/plugins/signal-lane.js +166 -0
  395. package/dist/plugins/signal-lane.js.map +1 -0
  396. package/dist/plugins/types.d.ts +81 -0
  397. package/dist/plugins/types.d.ts.map +1 -0
  398. package/dist/plugins/types.js +1 -0
  399. package/dist/process-memory-diagnostics.d.ts +135 -0
  400. package/dist/process-memory-diagnostics.d.ts.map +1 -0
  401. package/dist/process-memory-diagnostics.js +500 -0
  402. package/dist/process-memory-diagnostics.js.map +1 -0
  403. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  404. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  405. package/dist/processors/plan-rejection-abort.js +54 -0
  406. package/dist/processors/plan-rejection-abort.js.map +1 -0
  407. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  408. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  409. package/dist/providers/amazon-bedrock-gateway.js +153 -0
  410. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  411. package/dist/providers/amazon-bedrock.d.ts +28 -0
  412. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  413. package/dist/providers/amazon-bedrock.js +102 -0
  414. package/dist/providers/amazon-bedrock.js.map +1 -0
  415. package/dist/providers/claude-max.d.ts +65 -0
  416. package/dist/providers/claude-max.d.ts.map +1 -0
  417. package/dist/providers/claude-max.js +252 -0
  418. package/dist/providers/claude-max.js.map +1 -0
  419. package/dist/providers/github-copilot.d.ts +60 -0
  420. package/dist/providers/github-copilot.d.ts.map +1 -0
  421. package/dist/providers/github-copilot.js +266 -0
  422. package/dist/providers/github-copilot.js.map +1 -0
  423. package/dist/providers/kimi-coding.d.ts +15 -0
  424. package/dist/providers/kimi-coding.d.ts.map +1 -0
  425. package/dist/providers/kimi-coding.js +69 -0
  426. package/dist/providers/kimi-coding.js.map +1 -0
  427. package/dist/providers/openai-codex.d.ts +73 -0
  428. package/dist/providers/openai-codex.d.ts.map +1 -0
  429. package/dist/providers/openai-codex.js +306 -0
  430. package/dist/providers/openai-codex.js.map +1 -0
  431. package/dist/providers/xai.d.ts +33 -0
  432. package/dist/providers/xai.d.ts.map +1 -0
  433. package/dist/providers/xai.js +71 -0
  434. package/dist/providers/xai.js.map +1 -0
  435. package/dist/schema.d.ts +200 -0
  436. package/dist/schema.d.ts.map +1 -0
  437. package/dist/schema.js +92 -0
  438. package/dist/schema.js.map +1 -0
  439. package/dist/theme-palette.d.ts +17 -0
  440. package/dist/theme-palette.d.ts.map +1 -0
  441. package/dist/theme-palette.js +21 -0
  442. package/dist/theme-palette.js.map +1 -0
  443. package/dist/thinking.d.ts +33 -0
  444. package/dist/thinking.d.ts.map +1 -0
  445. package/dist/thinking.js +58 -0
  446. package/dist/thinking.js.map +1 -0
  447. package/dist/tool-names.d.ts +73 -0
  448. package/dist/tool-names.d.ts.map +1 -0
  449. package/dist/tool-names.js +52 -0
  450. package/dist/tool-names.js.map +1 -0
  451. package/dist/tools/index.d.ts +6 -0
  452. package/dist/tools/index.d.ts.map +1 -0
  453. package/dist/tools/index.js +3 -0
  454. package/dist/tools/request-sandbox-access.d.ts +6 -0
  455. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  456. package/dist/tools/request-sandbox-access.js +79 -0
  457. package/dist/tools/request-sandbox-access.js.map +1 -0
  458. package/dist/tools/utils.d.ts +20 -0
  459. package/dist/tools/utils.d.ts.map +1 -0
  460. package/dist/tools/utils.js +32 -0
  461. package/dist/tools/utils.js.map +1 -0
  462. package/dist/tools/web-search.d.ts +114 -0
  463. package/dist/tools/web-search.d.ts.map +1 -0
  464. package/dist/tools/web-search.js +155 -0
  465. package/dist/tools/web-search.js.map +1 -0
  466. package/dist/tools/workflows/create-workflow.d.ts +7 -0
  467. package/dist/tools/workflows/create-workflow.d.ts.map +1 -0
  468. package/dist/tools/workflows/create-workflow.js +81 -0
  469. package/dist/tools/workflows/create-workflow.js.map +1 -0
  470. package/dist/tools/workflows/delete-workflow.d.ts +7 -0
  471. package/dist/tools/workflows/delete-workflow.d.ts.map +1 -0
  472. package/dist/tools/workflows/delete-workflow.js +21 -0
  473. package/dist/tools/workflows/delete-workflow.js.map +1 -0
  474. package/dist/tools/workflows/ephemeral-memory.d.ts +7 -0
  475. package/dist/tools/workflows/ephemeral-memory.d.ts.map +1 -0
  476. package/dist/tools/workflows/ephemeral-memory.js +45 -0
  477. package/dist/tools/workflows/ephemeral-memory.js.map +1 -0
  478. package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
  479. package/dist/tools/workflows/extract-json-schema.d.ts.map +1 -0
  480. package/dist/tools/workflows/extract-json-schema.js +22 -0
  481. package/dist/tools/workflows/extract-json-schema.js.map +1 -0
  482. package/dist/tools/workflows/get-workflow.d.ts +11 -0
  483. package/dist/tools/workflows/get-workflow.d.ts.map +1 -0
  484. package/dist/tools/workflows/get-workflow.js +34 -0
  485. package/dist/tools/workflows/get-workflow.js.map +1 -0
  486. package/dist/tools/workflows/list-available-agents.d.ts +8 -0
  487. package/dist/tools/workflows/list-available-agents.d.ts.map +1 -0
  488. package/dist/tools/workflows/list-available-agents.js +32 -0
  489. package/dist/tools/workflows/list-available-agents.js.map +1 -0
  490. package/dist/tools/workflows/list-available-tools.d.ts +9 -0
  491. package/dist/tools/workflows/list-available-tools.d.ts.map +1 -0
  492. package/dist/tools/workflows/list-available-tools.js +40 -0
  493. package/dist/tools/workflows/list-available-tools.js.map +1 -0
  494. package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
  495. package/dist/tools/workflows/list-available-workflows.d.ts.map +1 -0
  496. package/dist/tools/workflows/list-available-workflows.js +32 -0
  497. package/dist/tools/workflows/list-available-workflows.js.map +1 -0
  498. package/dist/tools/workflows/list-workflows.d.ts +9 -0
  499. package/dist/tools/workflows/list-workflows.d.ts.map +1 -0
  500. package/dist/tools/workflows/list-workflows.js +33 -0
  501. package/dist/tools/workflows/list-workflows.js.map +1 -0
  502. package/dist/tools/workflows/run-workflow.d.ts +9 -0
  503. package/dist/tools/workflows/run-workflow.d.ts.map +1 -0
  504. package/dist/tools/workflows/run-workflow.js +52 -0
  505. package/dist/tools/workflows/run-workflow.js.map +1 -0
  506. package/dist/tools/workflows/save-workflow.d.ts +1015 -0
  507. package/dist/tools/workflows/save-workflow.d.ts.map +1 -0
  508. package/dist/tools/workflows/save-workflow.js +28 -0
  509. package/dist/tools/workflows/save-workflow.js.map +1 -0
  510. package/dist/tools/workflows/tool-ids.d.ts +15 -0
  511. package/dist/tools/workflows/tool-ids.d.ts.map +1 -0
  512. package/dist/tools/workflows/tool-ids.js +19 -0
  513. package/dist/tools/workflows/tool-ids.js.map +1 -0
  514. package/dist/utils/binaries.d.ts +7 -0
  515. package/dist/utils/binaries.d.ts.map +1 -0
  516. package/dist/utils/binaries.js +78 -0
  517. package/dist/utils/binaries.js.map +1 -0
  518. package/dist/utils/debug-log.d.ts +12 -0
  519. package/dist/utils/debug-log.d.ts.map +1 -0
  520. package/dist/utils/debug-log.js +59 -0
  521. package/dist/utils/debug-log.js.map +1 -0
  522. package/dist/utils/errors.d.ts +36 -0
  523. package/dist/utils/errors.d.ts.map +1 -0
  524. package/dist/utils/errors.js +196 -0
  525. package/dist/utils/errors.js.map +1 -0
  526. package/dist/utils/gateway-sync.d.ts +26 -0
  527. package/dist/utils/gateway-sync.d.ts.map +1 -0
  528. package/dist/utils/gateway-sync.js +61 -0
  529. package/dist/utils/gateway-sync.js.map +1 -0
  530. package/dist/utils/path-security.d.ts +2 -0
  531. package/dist/utils/path-security.d.ts.map +1 -0
  532. package/dist/utils/path-security.js +10 -0
  533. package/dist/utils/path-security.js.map +1 -0
  534. package/dist/utils/plan-diff.d.ts +25 -0
  535. package/dist/utils/plan-diff.d.ts.map +1 -0
  536. package/dist/utils/plan-diff.js +62 -0
  537. package/dist/utils/plan-diff.js.map +1 -0
  538. package/dist/utils/plans.d.ts +59 -0
  539. package/dist/utils/plans.d.ts.map +1 -0
  540. package/dist/utils/plans.js +117 -0
  541. package/dist/utils/plans.js.map +1 -0
  542. package/dist/utils/project.d.ts +160 -0
  543. package/dist/utils/project.d.ts.map +1 -0
  544. package/dist/utils/project.js +364 -0
  545. package/dist/utils/project.js.map +1 -0
  546. package/dist/utils/signals-pubsub.d.ts +41 -0
  547. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  548. package/dist/utils/signals-pubsub.js +122 -0
  549. package/dist/utils/signals-pubsub.js.map +1 -0
  550. package/dist/utils/slash-command-loader.d.ts +52 -0
  551. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  552. package/dist/utils/slash-command-loader.js +142 -0
  553. package/dist/utils/slash-command-loader.js.map +1 -0
  554. package/dist/utils/slash-command-processor.d.ts +14 -0
  555. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  556. package/dist/utils/slash-command-processor.js +109 -0
  557. package/dist/utils/slash-command-processor.js.map +1 -0
  558. package/dist/utils/stdin-pipe.d.ts +33 -0
  559. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  560. package/dist/utils/stdin-pipe.js +96 -0
  561. package/dist/utils/stdin-pipe.js.map +1 -0
  562. package/dist/utils/storage-factory.d.ts +50 -0
  563. package/dist/utils/storage-factory.d.ts.map +1 -0
  564. package/dist/utils/storage-factory.js +121 -0
  565. package/dist/utils/storage-factory.js.map +1 -0
  566. package/dist/utils/storage-maintenance.d.ts +103 -0
  567. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  568. package/dist/utils/storage-maintenance.js +274 -0
  569. package/dist/utils/storage-maintenance.js.map +1 -0
  570. package/dist/utils/thread-lock.d.ts +26 -0
  571. package/dist/utils/thread-lock.d.ts.map +1 -0
  572. package/dist/utils/thread-lock.js +112 -0
  573. package/dist/utils/thread-lock.js.map +1 -0
  574. package/dist/utils/token-estimator.d.ts +3 -0
  575. package/dist/utils/token-estimator.d.ts.map +1 -0
  576. package/dist/utils/token-estimator.js +21 -0
  577. package/dist/utils/token-estimator.js.map +1 -0
  578. package/dist/utils/update-check.d.ts +101 -0
  579. package/dist/utils/update-check.d.ts.map +1 -0
  580. package/dist/utils/update-check.js +383 -0
  581. package/dist/utils/update-check.js.map +1 -0
  582. package/dist/voice/stt-registry.d.ts +64 -0
  583. package/dist/voice/stt-registry.d.ts.map +1 -0
  584. package/dist/voice/stt-registry.js +144 -0
  585. package/dist/voice/stt-registry.js.map +1 -0
  586. package/dist/workflows/register-primitives.d.ts +52 -0
  587. package/dist/workflows/register-primitives.d.ts.map +1 -0
  588. package/dist/workflows/register-primitives.js +40 -0
  589. package/dist/workflows/register-primitives.js.map +1 -0
  590. package/dist/workflows/service.d.ts +64 -0
  591. package/dist/workflows/service.d.ts.map +1 -0
  592. package/dist/workflows/service.js +53 -0
  593. package/dist/workflows/service.js.map +1 -0
  594. package/package.json +97 -0
@@ -0,0 +1,30 @@
1
+ import type { RequestContext } from '@mastra/core/request-context';
2
+ import type { MastraCompositeStore } from '@mastra/core/storage';
3
+ import type { MastraVector } from '@mastra/core/vector';
4
+ import { Memory } from '@mastra/memory';
5
+ import { LOCAL_KNOWLEDGE_ORG_ID } from '../knowledge-scope.js';
6
+ import type { MastraCodeState } from '../schema.js';
7
+ export { LOCAL_KNOWLEDGE_ORG_ID };
8
+ /**
9
+ * Whether the experimental subconscious (knowledge graph + reminder sidekick)
10
+ * is switched on for this process: it needs a vector store and the opt-in flag.
11
+ */
12
+ export declare function isSubconsciousEnabled(vector: MastraVector | undefined): boolean;
13
+ /**
14
+ * Whether the subconscious tools (`knowledge_*`, `ask_memory`) are registered
15
+ * for a given session. Beyond the process-level switch, a Factory-owned
16
+ * session that cannot resolve its org refuses the subconscious entirely (see
17
+ * `getDynamicMemory`, which applies the same two checks inline because it also
18
+ * needs the resolved identity). The system prompt's tool guidance calls here so
19
+ * it never advertises tools that `getDynamicMemory` did not register.
20
+ */
21
+ export declare function hasSubconsciousTools(vector: MastraVector | undefined, state: MastraCodeState | undefined): boolean;
22
+ /**
23
+ * Dynamic memory factory function.
24
+ * Reads OM thresholds from controller state via requestContext.
25
+ * Model functions also read from requestContext (no mutable bridge needed).
26
+ */
27
+ export declare function getDynamicMemory(storage: MastraCompositeStore, vector?: MastraVector): ({ requestContext }: {
28
+ requestContext: RequestContext;
29
+ }) => Memory;
30
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/agents/memory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAiC,MAAM,uBAAuB,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAgEpD,OAAO,EAAE,sBAAsB,EAAE,CAAC;AA8BlC;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAE/E;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,EAAE,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAElH;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,CAAC,EAAE,YAAY,IAM3E,oBAAoB;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,YAkG/D"}
@@ -0,0 +1,171 @@
1
+ import { DEFAULT_OM_MODEL_ID } from "../constants.js";
2
+ import { getOmScope } from "../utils/project.js";
3
+ import { LOCAL_KNOWLEDGE_ORG_ID, resolveKnowledgeScopeIdentity } from "../knowledge-scope.js";
4
+ import { resolveModel } from "./model.js";
5
+ import { fastembed } from "@mastra/fastembed";
6
+ import { Memory, Subconscious } from "@mastra/memory";
7
+ //#region src/agents/memory.ts
8
+ /**
9
+ * Read controller state from requestContext.
10
+ * Used by both the memory factory and the OM model functions.
11
+ */
12
+ function getAgentControllerState(requestContext) {
13
+ return requestContext.get("controller")?.getState();
14
+ }
15
+ /**
16
+ * Observer model function — reads the current observer model ID from
17
+ * controller state via requestContext (now propagated by OM's agent.generate).
18
+ */
19
+ function getObserverModel({ requestContext }) {
20
+ return resolveModel(getAgentControllerState(requestContext)?.observerModelId ?? DEFAULT_OM_MODEL_ID, {
21
+ remapForCodexOAuth: true,
22
+ requestContext
23
+ });
24
+ }
25
+ /**
26
+ * Reflector model function — reads the current reflector model ID from
27
+ * controller state via requestContext (now propagated by OM's agent.generate).
28
+ */
29
+ function getReflectorModel({ requestContext }) {
30
+ return resolveModel(getAgentControllerState(requestContext)?.reflectorModelId ?? DEFAULT_OM_MODEL_ID, {
31
+ remapForCodexOAuth: true,
32
+ requestContext
33
+ });
34
+ }
35
+ const DYNAMIC_AGENTS_MD_INSTRUCTION = "Messages wrapped in <system-reminder type=\"dynamic-agents-md\" ...>...</system-reminder> are ephemeral project-context instructions injected from files on disk. Do NOT observe or extract information from these messages — they are reloaded automatically when needed and should not be stored in memory.";
36
+ const CAVEMAN_OM_INSTRUCTION = `Respond terse like smart caveman. All technical substance stay. Only fluff die.
37
+
38
+ Use full caveman compression style.
39
+
40
+ Drop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not "implement a solution for"). Technical terms exact. Code blocks unchanged. Errors quoted exact. Leave out the words "agent" and "assistant" at the start of each observation line, it is assumed each line is referring to the assistant unless it specifically says it was about the user. Leave out parenthesis and other text characters like * that would not contribute to understanding the observations.
41
+
42
+ Pattern: \`[thing] [action] [reason]. [next step]\`
43
+
44
+ Not: "Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by..."
45
+ Yes: "Bug in auth middleware. Token expiry check use < not <=. Fix:"
46
+
47
+ Example 1
48
+ 🔴 14:31 user asks why React component rerenders
49
+ 🟡 14:32 saw inline object prop create new ref each render, cause rerender
50
+ ✅ 14:34 fixed render issue by wrap object in useMemo
51
+
52
+ Example 2
53
+ 🟡 15:10 explained pool reuse DB connections, skip repeat handshake overhead
54
+
55
+ Don't say "Agent did x", say "did x". It will be assumed the agent did what was observed. The who should only be specified for the user or other third parties: "user asked x"
56
+
57
+ Drop caveman for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question, and anything that requires remembering verbatim content. Resume caveman after clear part done`;
58
+ const REPORTED_ORG_UNRESOLVED_LIMIT = 500;
59
+ const reportedOrgUnresolved = /* @__PURE__ */ new Set();
60
+ function reportOrgUnresolved(controller, factoryProjectId, reason) {
61
+ const sessionId = controller?.session?.id;
62
+ if (sessionId) {
63
+ if (reportedOrgUnresolved.has(sessionId)) return;
64
+ if (reportedOrgUnresolved.size >= REPORTED_ORG_UNRESOLVED_LIMIT) reportedOrgUnresolved.delete(reportedOrgUnresolved.values().next().value);
65
+ reportedOrgUnresolved.add(sessionId);
66
+ }
67
+ const session = controller?.session;
68
+ console.error(`[Subconscious] Knowledge curation disabled: no organization resolved for session ${session?.id ?? "unknown"} (project ${factoryProjectId ?? "none"})${reason ? `: ${reason}` : ""}. Knowledge is not written rather than written where it cannot be read.`);
69
+ }
70
+ /**
71
+ * Whether the experimental subconscious (knowledge graph + reminder sidekick)
72
+ * is switched on for this process: it needs a vector store and the opt-in flag.
73
+ */
74
+ function isSubconsciousEnabled(vector) {
75
+ return Boolean(vector) && process.env.MASTRACODE_EXPERIMENTAL_SUBCONSCIOUS === "1";
76
+ }
77
+ /**
78
+ * Whether the subconscious tools (`knowledge_*`, `ask_memory`) are registered
79
+ * for a given session. Beyond the process-level switch, a Factory-owned
80
+ * session that cannot resolve its org refuses the subconscious entirely (see
81
+ * `getDynamicMemory`, which applies the same two checks inline because it also
82
+ * needs the resolved identity). The system prompt's tool guidance calls here so
83
+ * it never advertises tools that `getDynamicMemory` did not register.
84
+ */
85
+ function hasSubconsciousTools(vector, state) {
86
+ return isSubconsciousEnabled(vector) && resolveKnowledgeScopeIdentity(state).resolved;
87
+ }
88
+ /**
89
+ * Dynamic memory factory function.
90
+ * Reads OM thresholds from controller state via requestContext.
91
+ * Model functions also read from requestContext (no mutable bridge needed).
92
+ */
93
+ function getDynamicMemory(storage, vector) {
94
+ let cachedMemory = null;
95
+ let cachedMemoryKey = null;
96
+ return ({ requestContext }) => {
97
+ const controller = requestContext.get("controller");
98
+ const state = controller?.getState();
99
+ const subconsciousEnabled = isSubconsciousEnabled(vector);
100
+ const factoryProjectId = state?.factoryProjectId;
101
+ const isFactory = typeof factoryProjectId === "string" && factoryProjectId.trim().length > 0;
102
+ let orgUnresolvedRefusal = false;
103
+ if (subconsciousEnabled) {
104
+ const identity = resolveKnowledgeScopeIdentity(state);
105
+ if (identity.resolved) requestContext.set("organizationId", identity.organizationId);
106
+ else {
107
+ orgUnresolvedRefusal = true;
108
+ reportOrgUnresolved(controller, identity.knowledgeResourceId, identity.reason);
109
+ }
110
+ if (identity.knowledgeResourceId) requestContext.set("knowledgeResourceId", identity.knowledgeResourceId);
111
+ }
112
+ const subconsciousAvailable = subconsciousEnabled && !orgUnresolvedRefusal;
113
+ const omScope = state?.omScope ?? getOmScope(state?.projectPath);
114
+ const obsThreshold = state?.observationThreshold ?? 3e4;
115
+ const refThreshold = state?.reflectionThreshold ?? 4e4;
116
+ const caveman = state?.cavemanObservations ?? false;
117
+ const observerPreviousObservationTokens = 1e3;
118
+ const observeAttachments = state?.observeAttachments;
119
+ const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}:${observeAttachments}:${isFactory ? 1 : 0}:${subconsciousAvailable ? 1 : 0}`;
120
+ if (cachedMemory && cachedMemoryKey === cacheKey) return cachedMemory;
121
+ const isResourceScope = omScope === "resource";
122
+ const observerInstruction = caveman ? `${DYNAMIC_AGENTS_MD_INSTRUCTION}\n\n${CAVEMAN_OM_INSTRUCTION}` : DYNAMIC_AGENTS_MD_INSTRUCTION;
123
+ const reflectionInstruction = caveman ? CAVEMAN_OM_INSTRUCTION : void 0;
124
+ cachedMemory = new Memory({
125
+ storage,
126
+ vector: vector || false,
127
+ embedder: vector ? fastembed.small : void 0,
128
+ options: {
129
+ generateTitle: { model: getObserverModel },
130
+ observationalMemory: {
131
+ enabled: true,
132
+ temporalMarkers: true,
133
+ retrieval: vector ? { vector: true } : true,
134
+ experimental_subconscious: subconsciousAvailable ? new Subconscious({
135
+ defaultScope: "resource",
136
+ maxScope: "resource",
137
+ pins: true,
138
+ ...isFactory ? { maxSteps: 25 } : {}
139
+ }) : void 0,
140
+ scope: omScope,
141
+ activateAfterIdle: "auto",
142
+ activateOnProviderChange: true,
143
+ observation: {
144
+ bufferTokens: isResourceScope ? false : 1 / 5,
145
+ bufferActivation: isResourceScope ? void 0 : 2e3,
146
+ model: getObserverModel,
147
+ messageTokens: obsThreshold,
148
+ blockAfter: 2,
149
+ previousObserverTokens: observerPreviousObservationTokens,
150
+ threadTitle: true,
151
+ instruction: observerInstruction,
152
+ observeAttachments
153
+ },
154
+ reflection: {
155
+ bufferActivation: isResourceScope ? void 0 : 1 / 2,
156
+ blockAfter: 1.1,
157
+ model: getReflectorModel,
158
+ observationTokens: refThreshold,
159
+ instruction: reflectionInstruction
160
+ }
161
+ }
162
+ }
163
+ });
164
+ cachedMemoryKey = cacheKey;
165
+ return cachedMemory;
166
+ };
167
+ }
168
+ //#endregion
169
+ export { LOCAL_KNOWLEDGE_ORG_ID, getDynamicMemory, hasSubconsciousTools, isSubconsciousEnabled };
170
+
171
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","names":[],"sources":["../../src/agents/memory.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\nimport type { MastraVector } from '@mastra/core/vector';\nimport { fastembed } from '@mastra/fastembed';\nimport { Memory, Subconscious } from '@mastra/memory';\nimport { DEFAULT_OM_MODEL_ID, DEFAULT_OBS_THRESHOLD, DEFAULT_REF_THRESHOLD } from '../constants.js';\nimport { LOCAL_KNOWLEDGE_ORG_ID, resolveKnowledgeScopeIdentity } from '../knowledge-scope.js';\nimport type { MastraCodeState } from '../schema.js';\nimport { getOmScope } from '../utils/project.js';\nimport { resolveModel } from './model.js';\n\n/**\n * Read controller state from requestContext.\n * Used by both the memory factory and the OM model functions.\n */\nfunction getAgentControllerState(requestContext: RequestContext): MastraCodeState | undefined {\n const ctx = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeState> | undefined;\n return ctx?.getState() as MastraCodeState | undefined;\n}\n\n/**\n * Observer model function — reads the current observer model ID from\n * controller state via requestContext (now propagated by OM's agent.generate).\n */\nfunction getObserverModel({ requestContext }: { requestContext: RequestContext }) {\n const state = getAgentControllerState(requestContext);\n return resolveModel(state?.observerModelId ?? DEFAULT_OM_MODEL_ID, {\n remapForCodexOAuth: true,\n requestContext,\n });\n}\n\n/**\n * Reflector model function — reads the current reflector model ID from\n * controller state via requestContext (now propagated by OM's agent.generate).\n */\nfunction getReflectorModel({ requestContext }: { requestContext: RequestContext }) {\n const state = getAgentControllerState(requestContext);\n return resolveModel(state?.reflectorModelId ?? DEFAULT_OM_MODEL_ID, {\n remapForCodexOAuth: true,\n requestContext,\n });\n}\n\nconst DYNAMIC_AGENTS_MD_INSTRUCTION =\n 'Messages wrapped in <system-reminder type=\"dynamic-agents-md\" ...>...</system-reminder> are ephemeral project-context instructions injected from files on disk. Do NOT observe or extract information from these messages — they are reloaded automatically when needed and should not be stored in memory.';\n\n// Derived from https://github.com/JuliusBrussee/caveman and adapted for OM use with fixed full-level compression.\nconst CAVEMAN_OM_INSTRUCTION = `Respond terse like smart caveman. All technical substance stay. Only fluff die.\n\nUse full caveman compression style.\n\nDrop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not \"implement a solution for\"). Technical terms exact. Code blocks unchanged. Errors quoted exact. Leave out the words \"agent\" and \"assistant\" at the start of each observation line, it is assumed each line is referring to the assistant unless it specifically says it was about the user. Leave out parenthesis and other text characters like * that would not contribute to understanding the observations.\n\nPattern: \\`[thing] [action] [reason]. [next step]\\`\n\nNot: \"Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by...\"\nYes: \"Bug in auth middleware. Token expiry check use < not <=. Fix:\"\n\nExample 1\n🔴 14:31 user asks why React component rerenders\n🟡 14:32 saw inline object prop create new ref each render, cause rerender\n✅ 14:34 fixed render issue by wrap object in useMemo\n\nExample 2\n🟡 15:10 explained pool reuse DB connections, skip repeat handshake overhead\n\nDon't say \"Agent did x\", say \"did x\". It will be assumed the agent did what was observed. The who should only be specified for the user or other third parties: \"user asked x\"\n\nDrop caveman for: security warnings, irreversible action confirmations, multi-step sequences where fragment order risks misread, user asks to clarify or repeats question, and anything that requires remembering verbatim content. Resume caveman after clear part done`;\n\nexport { LOCAL_KNOWLEDGE_ORG_ID };\n\n// One error per session, not per memory resolution. Keyed on the session id\n// rather than the controller object: the controller is read off the request\n// context on every resolution, so it is a fresh object per request and would\n// dedupe nothing. Bounded so a long-running Factory process cannot grow this\n// without limit — refusing sessions are rare, and losing the oldest ids only\n// costs one extra log line.\nconst REPORTED_ORG_UNRESOLVED_LIMIT = 500;\nconst reportedOrgUnresolved = new Set<string>();\n\nfunction reportOrgUnresolved(\n controller: AgentControllerRequestContext<MastraCodeState> | undefined,\n factoryProjectId: string | undefined,\n reason?: string,\n) {\n const sessionId = controller?.session?.id;\n if (sessionId) {\n if (reportedOrgUnresolved.has(sessionId)) return;\n if (reportedOrgUnresolved.size >= REPORTED_ORG_UNRESOLVED_LIMIT) {\n reportedOrgUnresolved.delete(reportedOrgUnresolved.values().next().value as string);\n }\n reportedOrgUnresolved.add(sessionId);\n }\n const session = controller?.session;\n console.error(\n `[Subconscious] Knowledge curation disabled: no organization resolved for session ${session?.id ?? 'unknown'} (project ${factoryProjectId ?? 'none'})${reason ? `: ${reason}` : ''}. Knowledge is not written rather than written where it cannot be read.`,\n );\n}\n\n/**\n * Whether the experimental subconscious (knowledge graph + reminder sidekick)\n * is switched on for this process: it needs a vector store and the opt-in flag.\n */\nexport function isSubconsciousEnabled(vector: MastraVector | undefined): boolean {\n return Boolean(vector) && process.env.MASTRACODE_EXPERIMENTAL_SUBCONSCIOUS === '1';\n}\n\n/**\n * Whether the subconscious tools (`knowledge_*`, `ask_memory`) are registered\n * for a given session. Beyond the process-level switch, a Factory-owned\n * session that cannot resolve its org refuses the subconscious entirely (see\n * `getDynamicMemory`, which applies the same two checks inline because it also\n * needs the resolved identity). The system prompt's tool guidance calls here so\n * it never advertises tools that `getDynamicMemory` did not register.\n */\nexport function hasSubconsciousTools(vector: MastraVector | undefined, state: MastraCodeState | undefined): boolean {\n return isSubconsciousEnabled(vector) && resolveKnowledgeScopeIdentity(state).resolved;\n}\n\n/**\n * Dynamic memory factory function.\n * Reads OM thresholds from controller state via requestContext.\n * Model functions also read from requestContext (no mutable bridge needed).\n */\nexport function getDynamicMemory(storage: MastraCompositeStore, vector?: MastraVector) {\n // Cache is scoped per storage instance (per getDynamicMemory call) so a\n // Memory bound to one storage is never reused after storage changes.\n let cachedMemory: Memory | null = null;\n let cachedMemoryKey: string | null = null;\n\n return ({ requestContext }: { requestContext: RequestContext }) => {\n const controller = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeState> | undefined;\n const state = controller?.getState() as MastraCodeState | undefined;\n const subconsciousEnabled = isSubconsciousEnabled(vector);\n const factoryProjectId = state?.factoryProjectId;\n const isFactory = typeof factoryProjectId === 'string' && factoryProjectId.trim().length > 0;\n\n // A Factory-owned session that could not resolve its org refuses to curate:\n // writing under a substituted identity produces knowledge the fail-closed\n // read path can never see.\n let orgUnresolvedRefusal = false;\n\n if (subconsciousEnabled) {\n const identity = resolveKnowledgeScopeIdentity(state);\n if (identity.resolved) {\n requestContext.set('organizationId', identity.organizationId);\n } else {\n orgUnresolvedRefusal = true;\n reportOrgUnresolved(controller, identity.knowledgeResourceId, identity.reason);\n }\n if (identity.knowledgeResourceId) {\n requestContext.set('knowledgeResourceId', identity.knowledgeResourceId);\n }\n }\n\n const subconsciousAvailable = subconsciousEnabled && !orgUnresolvedRefusal;\n\n const omScope = state?.omScope ?? getOmScope(state?.projectPath);\n\n const obsThreshold = state?.observationThreshold ?? DEFAULT_OBS_THRESHOLD;\n const refThreshold = state?.reflectionThreshold ?? DEFAULT_REF_THRESHOLD;\n const caveman = state?.cavemanObservations ?? false;\n\n const observerPreviousObservationTokens = 1000;\n const observeAttachments = state?.observeAttachments;\n // Factory sessions get a factory-only Subconscious config, so the cache key\n // carries a factory presence bit to keep the two configs from cross-serving.\n const cacheKey = `${obsThreshold}:${refThreshold}:${omScope}:${observerPreviousObservationTokens}:${caveman ? 1 : 0}:${observeAttachments}:${isFactory ? 1 : 0}:${subconsciousAvailable ? 1 : 0}`;\n if (cachedMemory && cachedMemoryKey === cacheKey) {\n return cachedMemory;\n }\n\n // Async buffering is not supported with resource scope — disable it\n const isResourceScope = omScope === 'resource';\n\n const observerInstruction = caveman\n ? `${DYNAMIC_AGENTS_MD_INSTRUCTION}\\n\\n${CAVEMAN_OM_INSTRUCTION}`\n : DYNAMIC_AGENTS_MD_INSTRUCTION;\n const reflectionInstruction = caveman ? CAVEMAN_OM_INSTRUCTION : undefined;\n\n cachedMemory = new Memory({\n storage,\n vector: vector || false,\n embedder: vector ? fastembed.small : undefined,\n options: {\n // Generate a durable title from the first user message. Every client uses\n // the same title in its thread list and active-session chrome.\n generateTitle: { model: getObserverModel },\n observationalMemory: {\n enabled: true,\n temporalMarkers: true,\n retrieval: vector ? { vector: true } : true,\n experimental_subconscious: subconsciousAvailable\n ? new Subconscious({\n defaultScope: 'resource',\n maxScope: 'resource',\n pins: true,\n ...(isFactory ? { maxSteps: 25 } : {}),\n })\n : undefined,\n scope: omScope,\n activateAfterIdle: 'auto',\n activateOnProviderChange: true,\n observation: {\n bufferTokens: isResourceScope ? false : 1 / 5,\n bufferActivation: isResourceScope ? undefined : 2000,\n model: getObserverModel,\n messageTokens: obsThreshold,\n blockAfter: 2,\n previousObserverTokens: observerPreviousObservationTokens,\n threadTitle: true,\n instruction: observerInstruction,\n observeAttachments,\n },\n reflection: {\n bufferActivation: isResourceScope ? undefined : 1 / 2,\n blockAfter: 1.1,\n model: getReflectorModel,\n observationTokens: refThreshold,\n instruction: reflectionInstruction,\n },\n },\n },\n });\n cachedMemoryKey = cacheKey;\n\n return cachedMemory;\n };\n}\n"],"mappings":"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"}
@@ -0,0 +1,81 @@
1
+ import type { GatewayLanguageModel, MastraModelGatewayInterface } from '@mastra/core/llm';
2
+ import type { RequestContext } from '@mastra/core/request-context';
3
+ import type { ThinkingLevelSetting } from '../thinking.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?: ThinkingLevelSetting;
32
+ remapForCodexOAuth?: boolean;
33
+ requestContext?: RequestContext;
34
+ }): GatewayLanguageModel;
35
+ export interface ThinkingRequestContext {
36
+ state?: {
37
+ thinkingLevel?: unknown;
38
+ };
39
+ session?: {
40
+ modeId?: string;
41
+ };
42
+ }
43
+ /**
44
+ * Resolve the effective thinking level for the current request.
45
+ *
46
+ * Precedence:
47
+ * 1. Session override (`state.thinkingLevel`, set via /think or the session
48
+ * settings panel).
49
+ * 2. Per-mode default from settings (`models.modeThinkingDefaults[mode]`).
50
+ * 3. Global default (`preferences.thinkingLevel`).
51
+ *
52
+ * Resolved per-request (not seeded at session start) so configuration changes
53
+ * apply to the next request of every session — including automated
54
+ * (rule-driven) Factory runs that nobody ever opens interactively.
55
+ */
56
+ export declare function resolveRequestThinkingLevel(agentControllerContext: ThinkingRequestContext | undefined, settingsPath?: string): ThinkingLevelSetting;
57
+ /**
58
+ * Dynamic model function that reads the current model from controller state.
59
+ * This allows runtime model switching via the /models picker.
60
+ */
61
+ export declare function getDynamicModel({ requestContext }: {
62
+ requestContext: RequestContext;
63
+ }, settingsPath?: string): ResolvedModel;
64
+ /**
65
+ * Goal judge model resolver for the agent's `goal.judge` config. Resolves the
66
+ * configured goal judge model through mastracode's gateway so provider
67
+ * credentials (stored in auth storage, not just env) are injected — a bare model
68
+ * id handed to core's default model router would fail to find the API key.
69
+ *
70
+ * Returns `undefined` when no judge model is configured, which keeps the goal
71
+ * step a complete no-op (the goal mechanism requires a judge to do anything).
72
+ *
73
+ * `settingsPath` must be the same source `createMastraCode()` reads from so the
74
+ * judge model and the goal budget (`goalMaxTurns`) come from one config — with a
75
+ * custom `settingsPath` a bare `loadSettings()` here could read a different file
76
+ * and silently turn the goal step into a no-op.
77
+ */
78
+ export declare function getGoalJudgeModel({ requestContext }: {
79
+ requestContext: RequestContext;
80
+ }, settingsPath?: string): ResolvedModel | undefined;
81
+ //# 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;AAQnE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAG3D,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,oBAAoB,CAAC;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,cAAc,CAAA;CAAE,GAChH,oBAAoB,CAqFtB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACpC,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/B;AACD;;;;;;;;;;;;GAYG;AAEH,wBAAgB,2BAA2B,CACzC,sBAAsB,EAAE,sBAAsB,GAAG,SAAS,EAC1D,YAAY,CAAC,EAAE,MAAM,GACpB,oBAAoB,CAKtB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,EAAE,cAAc,EAAE,EAAE;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,EACtD,YAAY,CAAC,EAAE,MAAM,GACpB,aAAa,CAoBf;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,155 @@
1
+ import { isThinkingLevelSetting } from "../thinking.js";
2
+ import { loadSettings, resolveDefaultThinkingLevel, stripMastraCodeCustomProviderPrefix } from "../onboarding/settings.js";
3
+ import { hasCredentialStoreProvider, resolveCredentialStore, resolveTenantFromRequestContext, setCredentialStoreProvider } from "./credential-resolver.js";
4
+ import { AMAZON_BEDROCK_GATEWAY_ID, createAmazonBedrockGateway } from "../providers/amazon-bedrock-gateway.js";
5
+ import { hasCustomProvidersSource, resolveCustomProviders, setCustomProvidersSource } from "./custom-provider-source.js";
6
+ import { MASTRACODE_GATEWAY_ID, MASTRA_GATEWAY_PREFIX, MastraCodeGateway, getAnthropicApiKey, getOpenAIApiKey, reloadAuthStorage, remapOpenAIModelForCodexOAuth, resolveAuth, stripMastraGatewayPrefix } from "./mastracode-gateway.js";
7
+ //#region src/agents/model.ts
8
+ function getAgentControllerHeaders(requestContext) {
9
+ const agentControllerContext = requestContext?.get("controller");
10
+ const headers = {
11
+ ...agentControllerContext?.threadId ? { "x-thread-id": agentControllerContext.threadId } : {},
12
+ ...agentControllerContext?.resourceId ? { "x-resource-id": agentControllerContext.resourceId } : {}
13
+ };
14
+ return Object.keys(headers).length > 0 ? headers : void 0;
15
+ }
16
+ function createMastraCodeGateway(options) {
17
+ return new MastraCodeGateway(options);
18
+ }
19
+ function createMastraCodeModelCatalogProvider(gateway) {
20
+ return gateway instanceof MastraCodeGateway ? gateway.createModelCatalogProvider() : MastraCodeGateway.createModelCatalogProvider(gateway);
21
+ }
22
+ /**
23
+ * Placeholder for future model ID normalization.
24
+ * Currently returns the input unchanged, but exists as a seam
25
+ * for aliasing, casing fixes, or validation in the future.
26
+ */
27
+ function resolveModelId(modelId) {
28
+ return modelId;
29
+ }
30
+ /**
31
+ * Resolve a model ID to the correct provider instance.
32
+ * Shared by the main agent, observer, and reflector.
33
+ *
34
+ * - For anthropic/* models: Uses stored OAuth credentials when present, otherwise direct API key
35
+ * - For openai/* models: Uses OAuth when configured, otherwise direct API key from AuthStorage
36
+ * - For moonshotai/* models: Uses Moonshot AI Anthropic-compatible endpoint
37
+ * - For all other providers: Uses Mastra's model router (models.dev gateway)
38
+ */
39
+ function resolveModel(modelId, options) {
40
+ reloadAuthStorage();
41
+ const headers = getAgentControllerHeaders(options?.requestContext);
42
+ const settings = loadSettings();
43
+ const bedrockLegacyPrefix = `${MASTRACODE_GATEWAY_ID}/amazon-bedrock/`;
44
+ const bedrockNormalizedInput = modelId.startsWith(bedrockLegacyPrefix) ? modelId.slice(MASTRACODE_GATEWAY_ID.length + 1) : modelId;
45
+ const customProviders = resolveCustomProviders(options?.requestContext) ?? settings.customProviders;
46
+ const normalizedInput = stripMastraCodeCustomProviderPrefix(bedrockNormalizedInput, customProviders);
47
+ const isMastraGatewayModel = normalizedInput.startsWith(MASTRA_GATEWAY_PREFIX);
48
+ const normalizedModelId = stripMastraGatewayPrefix(normalizedInput);
49
+ const [providerId, ...modelParts] = normalizedModelId.split("/");
50
+ const bareModelId = modelParts.join("/");
51
+ if (!providerId || !bareModelId) throw new Error(`Invalid model id: ${modelId}`);
52
+ if (providerId === "amazon-bedrock") {
53
+ const bedrockGateway = createAmazonBedrockGateway();
54
+ const routerId = `${AMAZON_BEDROCK_GATEWAY_ID}/${bareModelId}`;
55
+ const auth = bedrockGateway.resolveAuth({
56
+ gatewayId: AMAZON_BEDROCK_GATEWAY_ID,
57
+ providerId: AMAZON_BEDROCK_GATEWAY_ID,
58
+ modelId: bareModelId,
59
+ routerId
60
+ });
61
+ return bedrockGateway.resolveLanguageModel({
62
+ providerId: AMAZON_BEDROCK_GATEWAY_ID,
63
+ modelId: bareModelId,
64
+ apiKey: auth?.apiKey ?? "",
65
+ headers
66
+ });
67
+ }
68
+ const routerId = `${MASTRACODE_GATEWAY_ID}/${normalizedModelId}`;
69
+ const mgApiKey = MastraCodeGateway.getMastraGatewayApiKey();
70
+ const rawGatewayBase = settings.memoryGateway?.baseUrl ?? process.env["MASTRA_GATEWAY_URL"] ?? "https://gateway-api.mastra.ai";
71
+ const credentialStore = resolveCredentialStore(options?.requestContext);
72
+ const gateway = createMastraCodeGateway({
73
+ mastraGatewayBaseUrl: rawGatewayBase.replace(/\/+$/, "").replace(/\/v1$/, ""),
74
+ mastraGatewayApiKey: mgApiKey,
75
+ routeThroughMastraGateway: Boolean(mgApiKey && isMastraGatewayModel),
76
+ thinkingLevel: options?.thinkingLevel,
77
+ customProviders,
78
+ credentialStore
79
+ });
80
+ const auth = gateway.resolveAuth({
81
+ gatewayId: MASTRACODE_GATEWAY_ID,
82
+ providerId,
83
+ modelId: bareModelId,
84
+ routerId
85
+ });
86
+ if (!auth && credentialStore?.allowEnvironmentFallback === false) throw new Error(`No usable ${providerId} credential is configured for this signed-in Factory account. Connect the provider or add an organization credential, then try again.`);
87
+ return gateway.resolveLanguageModel({
88
+ providerId,
89
+ modelId: bareModelId,
90
+ apiKey: auth?.apiKey ?? "",
91
+ headers
92
+ });
93
+ }
94
+ /**
95
+ * Resolve the effective thinking level for the current request.
96
+ *
97
+ * Precedence:
98
+ * 1. Session override (`state.thinkingLevel`, set via /think or the session
99
+ * settings panel).
100
+ * 2. Per-mode default from settings (`models.modeThinkingDefaults[mode]`).
101
+ * 3. Global default (`preferences.thinkingLevel`).
102
+ *
103
+ * Resolved per-request (not seeded at session start) so configuration changes
104
+ * apply to the next request of every session — including automated
105
+ * (rule-driven) Factory runs that nobody ever opens interactively.
106
+ */
107
+ function resolveRequestThinkingLevel(agentControllerContext, settingsPath) {
108
+ const override = agentControllerContext?.state?.thinkingLevel;
109
+ if (isThinkingLevelSetting(override)) return override;
110
+ const modeId = agentControllerContext?.session?.modeId;
111
+ return resolveDefaultThinkingLevel(loadSettings(settingsPath), modeId).level;
112
+ }
113
+ /**
114
+ * Dynamic model function that reads the current model from controller state.
115
+ * This allows runtime model switching via the /models picker.
116
+ */
117
+ function getDynamicModel({ requestContext }, settingsPath) {
118
+ const agentControllerContext = requestContext.get("controller");
119
+ const modelId = agentControllerContext?.session?.modelId;
120
+ if (!modelId) {
121
+ if (!agentControllerContext) throw new Error("No model available: this run started without a controller session context, so no model selection could be resolved.");
122
+ throw new Error("No model selected. Use /models to select a model first.");
123
+ }
124
+ return resolveModel(modelId, {
125
+ thinkingLevel: resolveRequestThinkingLevel(agentControllerContext, settingsPath),
126
+ remapForCodexOAuth: true,
127
+ requestContext
128
+ });
129
+ }
130
+ /**
131
+ * Goal judge model resolver for the agent's `goal.judge` config. Resolves the
132
+ * configured goal judge model through mastracode's gateway so provider
133
+ * credentials (stored in auth storage, not just env) are injected — a bare model
134
+ * id handed to core's default model router would fail to find the API key.
135
+ *
136
+ * Returns `undefined` when no judge model is configured, which keeps the goal
137
+ * step a complete no-op (the goal mechanism requires a judge to do anything).
138
+ *
139
+ * `settingsPath` must be the same source `createMastraCode()` reads from so the
140
+ * judge model and the goal budget (`goalMaxTurns`) come from one config — with a
141
+ * custom `settingsPath` a bare `loadSettings()` here could read a different file
142
+ * and silently turn the goal step into a no-op.
143
+ */
144
+ function getGoalJudgeModel({ requestContext }, settingsPath) {
145
+ const judgeModelId = loadSettings(settingsPath).models.goalJudgeModel;
146
+ if (!judgeModelId) return void 0;
147
+ return resolveModel(judgeModelId, {
148
+ remapForCodexOAuth: true,
149
+ requestContext
150
+ });
151
+ }
152
+ //#endregion
153
+ export { MASTRACODE_GATEWAY_ID, MastraCodeGateway, createMastraCodeGateway, createMastraCodeModelCatalogProvider, getAnthropicApiKey, getDynamicModel, getGoalJudgeModel, getOpenAIApiKey, hasCredentialStoreProvider, hasCustomProvidersSource, remapOpenAIModelForCodexOAuth, resolveAuth, resolveCustomProviders, resolveModel, resolveModelId, resolveRequestThinkingLevel, resolveTenantFromRequestContext, setCredentialStoreProvider, setCustomProvidersSource };
154
+
155
+ //# 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 {\n loadSettings,\n resolveDefaultThinkingLevel,\n stripMastraCodeCustomProviderPrefix,\n} from '../onboarding/settings.js';\nimport { AMAZON_BEDROCK_GATEWAY_ID, createAmazonBedrockGateway } from '../providers/amazon-bedrock-gateway.js';\nimport { isThinkingLevelSetting } from '../thinking.js';\nimport type { ThinkingLevelSetting } from '../thinking.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?: ThinkingLevelSetting; 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 if (!auth && credentialStore?.allowEnvironmentFallback === false) {\n throw new Error(\n `No usable ${providerId} credential is configured for this signed-in Factory account. Connect the provider or add an organization credential, then try again.`,\n );\n }\n\n return gateway.resolveLanguageModel({\n providerId,\n modelId: bareModelId,\n apiKey: auth?.apiKey ?? '',\n headers,\n });\n}\n\nexport interface ThinkingRequestContext {\n state?: { thinkingLevel?: unknown };\n session?: { modeId?: string };\n}\n/**\n * Resolve the effective thinking level for the current request.\n *\n * Precedence:\n * 1. Session override (`state.thinkingLevel`, set via /think or the session\n * settings panel).\n * 2. Per-mode default from settings (`models.modeThinkingDefaults[mode]`).\n * 3. Global default (`preferences.thinkingLevel`).\n *\n * Resolved per-request (not seeded at session start) so configuration changes\n * apply to the next request of every session — including automated\n * (rule-driven) Factory runs that nobody ever opens interactively.\n */\n\nexport function resolveRequestThinkingLevel(\n agentControllerContext: ThinkingRequestContext | undefined,\n settingsPath?: string,\n): ThinkingLevelSetting {\n const override = agentControllerContext?.state?.thinkingLevel;\n if (isThinkingLevelSetting(override)) return override;\n const modeId = agentControllerContext?.session?.modeId;\n return resolveDefaultThinkingLevel(loadSettings(settingsPath), modeId).level;\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(\n { requestContext }: { requestContext: RequestContext },\n settingsPath?: string,\n): ResolvedModel {\n const agentControllerContext = requestContext.get('controller') as AgentControllerRequestContext<any> | undefined;\n\n const modelId = agentControllerContext?.session?.modelId;\n if (!modelId) {\n // A missing controller context means the run was started without session\n // request context at all (e.g. a signal delivered to an idle thread) —\n // \"use /models\" would mislead there, the user's selection was never the\n // problem.\n if (!agentControllerContext) {\n throw new Error(\n 'No model available: this run started without a controller session context, so no model selection could be resolved.',\n );\n }\n throw new Error('No model selected. Use /models to select a model first.');\n }\n\n const thinkingLevel = resolveRequestThinkingLevel(agentControllerContext, settingsPath);\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":"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"}
@@ -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,mBA8CvB,CAAC"}
@@ -0,0 +1,49 @@
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
+
39
+ ## Workflows
40
+ - To build a workflow: call \`create-workflow\` with the user's request verbatim. A focused sub-agent handles discovery, composition, and saving — don't try to do it inline.
41
+ - To run an existing workflow: call \`run-workflow\` with { workflowId, inputData }. Returns { status, result, error? }.
42
+ - To inspect or manage: \`list-workflows\`, \`get-workflow\`, \`delete-workflow\`.`,
43
+ defaultModelId: "openai/gpt-5.5",
44
+ metadata: { default: true }
45
+ };
46
+ //#endregion
47
+ export { buildMode };
48
+
49
+ //# 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\n## Workflows\n- To build a workflow: call \\`create-workflow\\` with the user's request verbatim. A focused sub-agent handles discovery, composition, and saving — don't try to do it inline.\n- To run an existing workflow: call \\`run-workflow\\` with { workflowId, inputData }. Returns { status, result, error? }.\n- To inspect or manage: \\`list-workflows\\`, \\`get-workflow\\`, \\`delete-workflow\\`.`,\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCd,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,mBAqCtB,CAAC"}