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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (491) hide show
  1. package/CHANGELOG.md +1349 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +70 -0
  4. package/dist/acp/agent.d.ts +35 -0
  5. package/dist/acp/agent.d.ts.map +1 -0
  6. package/dist/acp/agent.js +161 -0
  7. package/dist/acp/agent.js.map +1 -0
  8. package/dist/acp/event-mapper.d.ts +22 -0
  9. package/dist/acp/event-mapper.d.ts.map +1 -0
  10. package/dist/acp/event-mapper.js +214 -0
  11. package/dist/acp/event-mapper.js.map +1 -0
  12. package/dist/acp/index.d.ts +8 -0
  13. package/dist/acp/index.d.ts.map +1 -0
  14. package/dist/acp/index.js +65 -0
  15. package/dist/acp/index.js.map +1 -0
  16. package/dist/acp/server.d.ts +7 -0
  17. package/dist/acp/server.d.ts.map +1 -0
  18. package/dist/acp/server.js +35 -0
  19. package/dist/acp/server.js.map +1 -0
  20. package/dist/acp.d.ts +2 -0
  21. package/dist/acp.d.ts.map +1 -0
  22. package/dist/acp.js +2 -0
  23. package/dist/agents/credential-resolver.d.ts +51 -0
  24. package/dist/agents/credential-resolver.d.ts.map +1 -0
  25. package/dist/agents/credential-resolver.js +52 -0
  26. package/dist/agents/credential-resolver.js.map +1 -0
  27. package/dist/agents/custom-provider-source.d.ts +35 -0
  28. package/dist/agents/custom-provider-source.d.ts.map +1 -0
  29. package/dist/agents/custom-provider-source.js +25 -0
  30. package/dist/agents/custom-provider-source.js.map +1 -0
  31. package/dist/agents/instructions.d.ts +6 -0
  32. package/dist/agents/instructions.d.ts.map +1 -0
  33. package/dist/agents/instructions.js +32 -0
  34. package/dist/agents/instructions.js.map +1 -0
  35. package/dist/agents/mastracode-gateway.d.ts +74 -0
  36. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  37. package/dist/agents/mastracode-gateway.js +400 -0
  38. package/dist/agents/mastracode-gateway.js.map +1 -0
  39. package/dist/agents/memory.d.ts +13 -0
  40. package/dist/agents/memory.d.ts.map +1 -0
  41. package/dist/agents/memory.js +116 -0
  42. package/dist/agents/memory.js.map +1 -0
  43. package/dist/agents/model.d.ts +59 -0
  44. package/dist/agents/model.d.ts.map +1 -0
  45. package/dist/agents/model.js +132 -0
  46. package/dist/agents/model.js.map +1 -0
  47. package/dist/agents/modes/build.d.ts +10 -0
  48. package/dist/agents/modes/build.d.ts.map +1 -0
  49. package/dist/agents/modes/build.js +44 -0
  50. package/dist/agents/modes/build.js.map +1 -0
  51. package/dist/agents/modes/explore.d.ts +10 -0
  52. package/dist/agents/modes/explore.d.ts.map +1 -0
  53. package/dist/agents/modes/explore.js +39 -0
  54. package/dist/agents/modes/explore.js.map +1 -0
  55. package/dist/agents/modes/plan.d.ts +6 -0
  56. package/dist/agents/modes/plan.d.ts.map +1 -0
  57. package/dist/agents/modes/plan.js +37 -0
  58. package/dist/agents/modes/plan.js.map +1 -0
  59. package/dist/agents/prompts/agent-instructions.d.ts +61 -0
  60. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  61. package/dist/agents/prompts/agent-instructions.js +201 -0
  62. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  63. package/dist/agents/prompts/build.d.ts +12 -0
  64. package/dist/agents/prompts/build.d.ts.map +1 -0
  65. package/dist/agents/prompts/build.js +76 -0
  66. package/dist/agents/prompts/build.js.map +1 -0
  67. package/dist/agents/prompts/fast.d.ts +5 -0
  68. package/dist/agents/prompts/fast.d.ts.map +1 -0
  69. package/dist/agents/prompts/fast.js +26 -0
  70. package/dist/agents/prompts/fast.js.map +1 -0
  71. package/dist/agents/prompts/index.d.ts +19 -0
  72. package/dist/agents/prompts/index.d.ts.map +1 -0
  73. package/dist/agents/prompts/index.js +65 -0
  74. package/dist/agents/prompts/index.js.map +1 -0
  75. package/dist/agents/prompts/model.d.ts +5 -0
  76. package/dist/agents/prompts/model.d.ts.map +1 -0
  77. package/dist/agents/prompts/model.js +23 -0
  78. package/dist/agents/prompts/model.js.map +1 -0
  79. package/dist/agents/prompts/plan.d.ts +6 -0
  80. package/dist/agents/prompts/plan.d.ts.map +1 -0
  81. package/dist/agents/prompts/plan.js +111 -0
  82. package/dist/agents/prompts/plan.js.map +1 -0
  83. package/dist/agents/prompts/tool-guidance.d.ts +13 -0
  84. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  85. package/dist/agents/prompts/tool-guidance.js +149 -0
  86. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  87. package/dist/agents/sandbox-filesystem.d.ts +99 -0
  88. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  89. package/dist/agents/sandbox-filesystem.js +328 -0
  90. package/dist/agents/sandbox-filesystem.js.map +1 -0
  91. package/dist/agents/sandbox-reattach.d.ts +19 -0
  92. package/dist/agents/sandbox-reattach.d.ts.map +1 -0
  93. package/dist/agents/sandbox-reattach.js +15 -0
  94. package/dist/agents/sandbox-reattach.js.map +1 -0
  95. package/dist/agents/thread-caveman-state.d.ts +17 -0
  96. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  97. package/dist/agents/thread-caveman-state.js +107 -0
  98. package/dist/agents/thread-caveman-state.js.map +1 -0
  99. package/dist/agents/tool-availability.d.ts +10 -0
  100. package/dist/agents/tool-availability.d.ts.map +1 -0
  101. package/dist/agents/tool-availability.js +87 -0
  102. package/dist/agents/tool-availability.js.map +1 -0
  103. package/dist/agents/tools.d.ts +19 -0
  104. package/dist/agents/tools.d.ts.map +1 -0
  105. package/dist/agents/tools.js +105 -0
  106. package/dist/agents/tools.js.map +1 -0
  107. package/dist/agents/workspace.d.ts +32 -0
  108. package/dist/agents/workspace.d.ts.map +1 -0
  109. package/dist/agents/workspace.js +251 -0
  110. package/dist/agents/workspace.js.map +1 -0
  111. package/dist/analytics.d.ts +18 -0
  112. package/dist/analytics.d.ts.map +1 -0
  113. package/dist/analytics.js +163 -0
  114. package/dist/analytics.js.map +1 -0
  115. package/dist/auth/authorization-input.d.ts +16 -0
  116. package/dist/auth/authorization-input.d.ts.map +1 -0
  117. package/dist/auth/authorization-input.js +42 -0
  118. package/dist/auth/authorization-input.js.map +1 -0
  119. package/dist/auth/device-code.d.ts +93 -0
  120. package/dist/auth/device-code.d.ts.map +1 -0
  121. package/dist/auth/device-code.js +129 -0
  122. package/dist/auth/device-code.js.map +1 -0
  123. package/dist/auth/index.d.ts +10 -0
  124. package/dist/auth/index.d.ts.map +1 -0
  125. package/dist/auth/index.js +6 -0
  126. package/dist/auth/pkce.d.ts +13 -0
  127. package/dist/auth/pkce.d.ts.map +1 -0
  128. package/dist/auth/pkce.js +32 -0
  129. package/dist/auth/pkce.js.map +1 -0
  130. package/dist/auth/providers/anthropic.d.ts +40 -0
  131. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  132. package/dist/auth/providers/anthropic.js +126 -0
  133. package/dist/auth/providers/anthropic.js.map +1 -0
  134. package/dist/auth/providers/github-copilot.d.ts +154 -0
  135. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  136. package/dist/auth/providers/github-copilot.js +340 -0
  137. package/dist/auth/providers/github-copilot.js.map +1 -0
  138. package/dist/auth/providers/openai-codex.d.ts +139 -0
  139. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  140. package/dist/auth/providers/openai-codex.js +519 -0
  141. package/dist/auth/providers/openai-codex.js.map +1 -0
  142. package/dist/auth/providers/xai.d.ts +64 -0
  143. package/dist/auth/providers/xai.d.ts.map +1 -0
  144. package/dist/auth/providers/xai.js +205 -0
  145. package/dist/auth/providers/xai.js.map +1 -0
  146. package/dist/auth/storage.d.ts +91 -0
  147. package/dist/auth/storage.d.ts.map +1 -0
  148. package/dist/auth/storage.js +197 -0
  149. package/dist/auth/storage.js.map +1 -0
  150. package/dist/auth/types.d.ts +89 -0
  151. package/dist/auth/types.d.ts.map +1 -0
  152. package/dist/auth/types.js +1 -0
  153. package/dist/clipboard/index.d.ts +26 -0
  154. package/dist/clipboard/index.d.ts.map +1 -0
  155. package/dist/clipboard/index.js +226 -0
  156. package/dist/clipboard/index.js.map +1 -0
  157. package/dist/constants.d.ts +10 -0
  158. package/dist/constants.d.ts.map +1 -0
  159. package/dist/constants.js +18 -0
  160. package/dist/constants.js.map +1 -0
  161. package/dist/error-classification.d.ts +10 -0
  162. package/dist/error-classification.d.ts.map +1 -0
  163. package/dist/error-classification.js +22 -0
  164. package/dist/error-classification.js.map +1 -0
  165. package/dist/evals/context-builder.d.ts +41 -0
  166. package/dist/evals/context-builder.d.ts.map +1 -0
  167. package/dist/evals/context-builder.js +161 -0
  168. package/dist/evals/context-builder.js.map +1 -0
  169. package/dist/evals/index.d.ts +4 -0
  170. package/dist/evals/index.d.ts.map +1 -0
  171. package/dist/evals/index.js +5 -0
  172. package/dist/evals/scorers/classify-command.d.ts +31 -0
  173. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  174. package/dist/evals/scorers/classify-command.js +73 -0
  175. package/dist/evals/scorers/classify-command.js.map +1 -0
  176. package/dist/evals/scorers/efficiency.d.ts +44 -0
  177. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  178. package/dist/evals/scorers/efficiency.js +259 -0
  179. package/dist/evals/scorers/efficiency.js.map +1 -0
  180. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  181. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  182. package/dist/evals/scorers/extract-tools.js +60 -0
  183. package/dist/evals/scorers/extract-tools.js.map +1 -0
  184. package/dist/evals/scorers/index.d.ts +3 -0
  185. package/dist/evals/scorers/index.d.ts.map +1 -0
  186. package/dist/evals/scorers/index.js +3 -0
  187. package/dist/evals/scorers/outcome.d.ts +49 -0
  188. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  189. package/dist/evals/scorers/outcome.js +347 -0
  190. package/dist/evals/scorers/outcome.js.map +1 -0
  191. package/dist/goal-manager.d.ts +78 -0
  192. package/dist/goal-manager.d.ts.map +1 -0
  193. package/dist/goal-manager.js +273 -0
  194. package/dist/goal-manager.js.map +1 -0
  195. package/dist/goal-signal.d.ts +14 -0
  196. package/dist/goal-signal.d.ts.map +1 -0
  197. package/dist/goal-signal.js +17 -0
  198. package/dist/goal-signal.js.map +1 -0
  199. package/dist/headless/cli.d.ts +42 -0
  200. package/dist/headless/cli.d.ts.map +1 -0
  201. package/dist/headless/cli.js +195 -0
  202. package/dist/headless/cli.js.map +1 -0
  203. package/dist/headless/flags.d.ts +33 -0
  204. package/dist/headless/flags.d.ts.map +1 -0
  205. package/dist/headless/flags.js +190 -0
  206. package/dist/headless/flags.js.map +1 -0
  207. package/dist/headless/format.d.ts +38 -0
  208. package/dist/headless/format.d.ts.map +1 -0
  209. package/dist/headless/format.js +89 -0
  210. package/dist/headless/format.js.map +1 -0
  211. package/dist/headless/index.d.ts +25 -0
  212. package/dist/headless/index.d.ts.map +1 -0
  213. package/dist/headless/index.js +6 -0
  214. package/dist/headless/policy.d.ts +17 -0
  215. package/dist/headless/policy.d.ts.map +1 -0
  216. package/dist/headless/policy.js +42 -0
  217. package/dist/headless/policy.js.map +1 -0
  218. package/dist/headless/run-mc.d.ts +7 -0
  219. package/dist/headless/run-mc.d.ts.map +1 -0
  220. package/dist/headless/run-mc.js +346 -0
  221. package/dist/headless/run-mc.js.map +1 -0
  222. package/dist/headless/types.d.ts +158 -0
  223. package/dist/headless/types.d.ts.map +1 -0
  224. package/dist/headless/types.js +18 -0
  225. package/dist/headless/types.js.map +1 -0
  226. package/dist/hooks/config.d.ts +11 -0
  227. package/dist/hooks/config.d.ts.map +1 -0
  228. package/dist/hooks/config.js +73 -0
  229. package/dist/hooks/config.js.map +1 -0
  230. package/dist/hooks/executor.d.ts +13 -0
  231. package/dist/hooks/executor.d.ts.map +1 -0
  232. package/dist/hooks/executor.js +128 -0
  233. package/dist/hooks/executor.js.map +1 -0
  234. package/dist/hooks/index.d.ts +6 -0
  235. package/dist/hooks/index.d.ts.map +1 -0
  236. package/dist/hooks/index.js +5 -0
  237. package/dist/hooks/manager.d.ts +47 -0
  238. package/dist/hooks/manager.d.ts.map +1 -0
  239. package/dist/hooks/manager.js +225 -0
  240. package/dist/hooks/manager.js.map +1 -0
  241. package/dist/hooks/types.d.ts +152 -0
  242. package/dist/hooks/types.d.ts.map +1 -0
  243. package/dist/hooks/types.js +8 -0
  244. package/dist/hooks/types.js.map +1 -0
  245. package/dist/index.d.ts +258 -0
  246. package/dist/index.d.ts.map +1 -0
  247. package/dist/index.js +740 -0
  248. package/dist/index.js.map +1 -0
  249. package/dist/ipc/ipc-reporter.d.ts +14 -0
  250. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  251. package/dist/ipc/ipc-reporter.js +21 -0
  252. package/dist/ipc/ipc-reporter.js.map +1 -0
  253. package/dist/lsp/client.d.ts +56 -0
  254. package/dist/lsp/client.d.ts.map +1 -0
  255. package/dist/lsp/client.js +251 -0
  256. package/dist/lsp/client.js.map +1 -0
  257. package/dist/lsp/index.d.ts +4 -0
  258. package/dist/lsp/index.d.ts.map +1 -0
  259. package/dist/lsp/index.js +4 -0
  260. package/dist/lsp/language.d.ts +9 -0
  261. package/dist/lsp/language.d.ts.map +1 -0
  262. package/dist/lsp/language.js +44 -0
  263. package/dist/lsp/language.js.map +1 -0
  264. package/dist/lsp/manager.d.ts +34 -0
  265. package/dist/lsp/manager.d.ts.map +1 -0
  266. package/dist/lsp/manager.js +82 -0
  267. package/dist/lsp/manager.js.map +1 -0
  268. package/dist/lsp/server.d.ts +27 -0
  269. package/dist/lsp/server.d.ts.map +1 -0
  270. package/dist/lsp/server.js +159 -0
  271. package/dist/lsp/server.js.map +1 -0
  272. package/dist/lsp/workspace.d.ts +9 -0
  273. package/dist/lsp/workspace.d.ts.map +1 -0
  274. package/dist/lsp/workspace.js +55 -0
  275. package/dist/lsp/workspace.js.map +1 -0
  276. package/dist/mcp/config.d.ts +54 -0
  277. package/dist/mcp/config.d.ts.map +1 -0
  278. package/dist/mcp/config.js +240 -0
  279. package/dist/mcp/config.js.map +1 -0
  280. package/dist/mcp/index.d.ts +5 -0
  281. package/dist/mcp/index.d.ts.map +1 -0
  282. package/dist/mcp/index.js +3 -0
  283. package/dist/mcp/manager.d.ts +98 -0
  284. package/dist/mcp/manager.d.ts.map +1 -0
  285. package/dist/mcp/manager.js +612 -0
  286. package/dist/mcp/manager.js.map +1 -0
  287. package/dist/mcp/state.d.ts +33 -0
  288. package/dist/mcp/state.d.ts.map +1 -0
  289. package/dist/mcp/state.js +88 -0
  290. package/dist/mcp/state.js.map +1 -0
  291. package/dist/mcp/types.d.ts +120 -0
  292. package/dist/mcp/types.d.ts.map +1 -0
  293. package/dist/mcp/types.js +1 -0
  294. package/dist/onboarding/custom-packs.d.ts +7 -0
  295. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  296. package/dist/onboarding/custom-packs.js +17 -0
  297. package/dist/onboarding/custom-packs.js.map +1 -0
  298. package/dist/onboarding/custom-providers.d.ts +4 -0
  299. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  300. package/dist/onboarding/custom-providers.js +30 -0
  301. package/dist/onboarding/custom-providers.js.map +1 -0
  302. package/dist/onboarding/index.d.ts +5 -0
  303. package/dist/onboarding/index.d.ts.map +1 -0
  304. package/dist/onboarding/index.js +3 -0
  305. package/dist/onboarding/om-settings.d.ts +25 -0
  306. package/dist/onboarding/om-settings.d.ts.map +1 -0
  307. package/dist/onboarding/om-settings.js +47 -0
  308. package/dist/onboarding/om-settings.js.map +1 -0
  309. package/dist/onboarding/packs.d.ts +46 -0
  310. package/dist/onboarding/packs.d.ts.map +1 -0
  311. package/dist/onboarding/packs.js +160 -0
  312. package/dist/onboarding/packs.js.map +1 -0
  313. package/dist/onboarding/settings.d.ts +338 -0
  314. package/dist/onboarding/settings.d.ts.map +1 -0
  315. package/dist/onboarding/settings.js +673 -0
  316. package/dist/onboarding/settings.js.map +1 -0
  317. package/dist/permissions.d.ts +55 -0
  318. package/dist/permissions.d.ts.map +1 -0
  319. package/dist/permissions.js +132 -0
  320. package/dist/permissions.js.map +1 -0
  321. package/dist/plugin.d.ts +81 -0
  322. package/dist/plugin.d.ts.map +1 -0
  323. package/dist/plugin.js +28 -0
  324. package/dist/plugin.js.map +1 -0
  325. package/dist/plugins/dependencies.d.ts +9 -0
  326. package/dist/plugins/dependencies.d.ts.map +1 -0
  327. package/dist/plugins/dependencies.js +88 -0
  328. package/dist/plugins/dependencies.js.map +1 -0
  329. package/dist/plugins/install.d.ts +21 -0
  330. package/dist/plugins/install.d.ts.map +1 -0
  331. package/dist/plugins/install.js +190 -0
  332. package/dist/plugins/install.js.map +1 -0
  333. package/dist/plugins/loader.d.ts +15 -0
  334. package/dist/plugins/loader.d.ts.map +1 -0
  335. package/dist/plugins/loader.js +206 -0
  336. package/dist/plugins/loader.js.map +1 -0
  337. package/dist/plugins/manager.d.ts +64 -0
  338. package/dist/plugins/manager.d.ts.map +1 -0
  339. package/dist/plugins/manager.js +384 -0
  340. package/dist/plugins/manager.js.map +1 -0
  341. package/dist/plugins/manifest.d.ts +14 -0
  342. package/dist/plugins/manifest.d.ts.map +1 -0
  343. package/dist/plugins/manifest.js +50 -0
  344. package/dist/plugins/manifest.js.map +1 -0
  345. package/dist/plugins/package-link.d.ts +3 -0
  346. package/dist/plugins/package-link.d.ts.map +1 -0
  347. package/dist/plugins/package-link.js +61 -0
  348. package/dist/plugins/package-link.js.map +1 -0
  349. package/dist/plugins/paths.d.ts +10 -0
  350. package/dist/plugins/paths.d.ts.map +1 -0
  351. package/dist/plugins/paths.js +25 -0
  352. package/dist/plugins/paths.js.map +1 -0
  353. package/dist/plugins/registry.d.ts +8 -0
  354. package/dist/plugins/registry.d.ts.map +1 -0
  355. package/dist/plugins/registry.js +112 -0
  356. package/dist/plugins/registry.js.map +1 -0
  357. package/dist/plugins/scaffold.d.ts +10 -0
  358. package/dist/plugins/scaffold.d.ts.map +1 -0
  359. package/dist/plugins/scaffold.js +116 -0
  360. package/dist/plugins/scaffold.js.map +1 -0
  361. package/dist/plugins/types.d.ts +45 -0
  362. package/dist/plugins/types.d.ts.map +1 -0
  363. package/dist/plugins/types.js +1 -0
  364. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  365. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  366. package/dist/processors/plan-rejection-abort.js +54 -0
  367. package/dist/processors/plan-rejection-abort.js.map +1 -0
  368. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  369. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  370. package/dist/providers/amazon-bedrock-gateway.js +152 -0
  371. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  372. package/dist/providers/amazon-bedrock.d.ts +28 -0
  373. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  374. package/dist/providers/amazon-bedrock.js +83 -0
  375. package/dist/providers/amazon-bedrock.js.map +1 -0
  376. package/dist/providers/claude-max.d.ts +52 -0
  377. package/dist/providers/claude-max.d.ts.map +1 -0
  378. package/dist/providers/claude-max.js +171 -0
  379. package/dist/providers/claude-max.js.map +1 -0
  380. package/dist/providers/github-copilot.d.ts +60 -0
  381. package/dist/providers/github-copilot.d.ts.map +1 -0
  382. package/dist/providers/github-copilot.js +265 -0
  383. package/dist/providers/github-copilot.js.map +1 -0
  384. package/dist/providers/openai-codex.d.ts +72 -0
  385. package/dist/providers/openai-codex.d.ts.map +1 -0
  386. package/dist/providers/openai-codex.js +302 -0
  387. package/dist/providers/openai-codex.js.map +1 -0
  388. package/dist/providers/xai.d.ts +33 -0
  389. package/dist/providers/xai.d.ts.map +1 -0
  390. package/dist/providers/xai.js +70 -0
  391. package/dist/providers/xai.js.map +1 -0
  392. package/dist/schema.d.ts +192 -0
  393. package/dist/schema.d.ts.map +1 -0
  394. package/dist/schema.js +98 -0
  395. package/dist/schema.js.map +1 -0
  396. package/dist/theme-palette.d.ts +17 -0
  397. package/dist/theme-palette.d.ts.map +1 -0
  398. package/dist/theme-palette.js +21 -0
  399. package/dist/theme-palette.js.map +1 -0
  400. package/dist/tool-names.d.ts +73 -0
  401. package/dist/tool-names.d.ts.map +1 -0
  402. package/dist/tool-names.js +52 -0
  403. package/dist/tool-names.js.map +1 -0
  404. package/dist/tools/index.d.ts +6 -0
  405. package/dist/tools/index.d.ts.map +1 -0
  406. package/dist/tools/index.js +3 -0
  407. package/dist/tools/request-sandbox-access.d.ts +6 -0
  408. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  409. package/dist/tools/request-sandbox-access.js +79 -0
  410. package/dist/tools/request-sandbox-access.js.map +1 -0
  411. package/dist/tools/utils.d.ts +20 -0
  412. package/dist/tools/utils.d.ts.map +1 -0
  413. package/dist/tools/utils.js +32 -0
  414. package/dist/tools/utils.js.map +1 -0
  415. package/dist/tools/web-search.d.ts +35 -0
  416. package/dist/tools/web-search.d.ts.map +1 -0
  417. package/dist/tools/web-search.js +61 -0
  418. package/dist/tools/web-search.js.map +1 -0
  419. package/dist/utils/binaries.d.ts +7 -0
  420. package/dist/utils/binaries.d.ts.map +1 -0
  421. package/dist/utils/binaries.js +78 -0
  422. package/dist/utils/binaries.js.map +1 -0
  423. package/dist/utils/debug-log.d.ts +12 -0
  424. package/dist/utils/debug-log.d.ts.map +1 -0
  425. package/dist/utils/debug-log.js +59 -0
  426. package/dist/utils/debug-log.js.map +1 -0
  427. package/dist/utils/errors.d.ts +36 -0
  428. package/dist/utils/errors.d.ts.map +1 -0
  429. package/dist/utils/errors.js +172 -0
  430. package/dist/utils/errors.js.map +1 -0
  431. package/dist/utils/gateway-sync.d.ts +26 -0
  432. package/dist/utils/gateway-sync.d.ts.map +1 -0
  433. package/dist/utils/gateway-sync.js +61 -0
  434. package/dist/utils/gateway-sync.js.map +1 -0
  435. package/dist/utils/path-security.d.ts +2 -0
  436. package/dist/utils/path-security.d.ts.map +1 -0
  437. package/dist/utils/path-security.js +10 -0
  438. package/dist/utils/path-security.js.map +1 -0
  439. package/dist/utils/plan-diff.d.ts +25 -0
  440. package/dist/utils/plan-diff.d.ts.map +1 -0
  441. package/dist/utils/plan-diff.js +62 -0
  442. package/dist/utils/plan-diff.js.map +1 -0
  443. package/dist/utils/plans.d.ts +56 -0
  444. package/dist/utils/plans.d.ts.map +1 -0
  445. package/dist/utils/plans.js +117 -0
  446. package/dist/utils/plans.js.map +1 -0
  447. package/dist/utils/project.d.ts +160 -0
  448. package/dist/utils/project.d.ts.map +1 -0
  449. package/dist/utils/project.js +364 -0
  450. package/dist/utils/project.js.map +1 -0
  451. package/dist/utils/signals-pubsub.d.ts +41 -0
  452. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  453. package/dist/utils/signals-pubsub.js +122 -0
  454. package/dist/utils/signals-pubsub.js.map +1 -0
  455. package/dist/utils/slash-command-loader.d.ts +52 -0
  456. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  457. package/dist/utils/slash-command-loader.js +141 -0
  458. package/dist/utils/slash-command-loader.js.map +1 -0
  459. package/dist/utils/slash-command-processor.d.ts +14 -0
  460. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  461. package/dist/utils/slash-command-processor.js +105 -0
  462. package/dist/utils/slash-command-processor.js.map +1 -0
  463. package/dist/utils/stdin-pipe.d.ts +33 -0
  464. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  465. package/dist/utils/stdin-pipe.js +96 -0
  466. package/dist/utils/stdin-pipe.js.map +1 -0
  467. package/dist/utils/storage-factory.d.ts +50 -0
  468. package/dist/utils/storage-factory.d.ts.map +1 -0
  469. package/dist/utils/storage-factory.js +121 -0
  470. package/dist/utils/storage-factory.js.map +1 -0
  471. package/dist/utils/storage-maintenance.d.ts +103 -0
  472. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  473. package/dist/utils/storage-maintenance.js +274 -0
  474. package/dist/utils/storage-maintenance.js.map +1 -0
  475. package/dist/utils/thread-lock.d.ts +26 -0
  476. package/dist/utils/thread-lock.d.ts.map +1 -0
  477. package/dist/utils/thread-lock.js +112 -0
  478. package/dist/utils/thread-lock.js.map +1 -0
  479. package/dist/utils/token-estimator.d.ts +3 -0
  480. package/dist/utils/token-estimator.d.ts.map +1 -0
  481. package/dist/utils/token-estimator.js +21 -0
  482. package/dist/utils/token-estimator.js.map +1 -0
  483. package/dist/utils/update-check.d.ts +101 -0
  484. package/dist/utils/update-check.d.ts.map +1 -0
  485. package/dist/utils/update-check.js +383 -0
  486. package/dist/utils/update-check.js.map +1 -0
  487. package/dist/voice/stt-registry.d.ts +64 -0
  488. package/dist/voice/stt-registry.d.ts.map +1 -0
  489. package/dist/voice/stt-registry.js +144 -0
  490. package/dist/voice/stt-registry.js.map +1 -0
  491. package/package.json +96 -0
@@ -0,0 +1,328 @@
1
+ import { posix } from "path";
2
+ import { FileExistsError, FileNotFoundError, IsDirectoryError } from "@mastra/core/workspace";
3
+ //#region src/agents/sandbox-filesystem.ts
4
+ /**
5
+ * SandboxFilesystem
6
+ *
7
+ * A `WorkspaceFilesystem` that stores files inside a remote `MastraSandbox`
8
+ * (e.g. a Railway VM) rather than on the server host. File operations are
9
+ * implemented by shelling out through the sandbox's `executeCommand`, so the
10
+ * agent's file tools and command tools share one VM and one view of the repo.
11
+ *
12
+ * Paths are workspace-relative (`/src/foo.ts`) and resolve under the sandbox
13
+ * working directory (`basePath`). A traversal guard rejects any path that
14
+ * escapes the workdir, mirroring `LocalFilesystem`'s contained mode.
15
+ *
16
+ * Reads/writes use base64 over the wire so binary content survives the shell.
17
+ */
18
+ /**
19
+ * Sentinel exit codes used by guard clauses that run before the real command,
20
+ * so shell failures can be mapped to typed filesystem errors.
21
+ */
22
+ const EXIT_NOT_FOUND = 20;
23
+ const EXIT_IS_DIRECTORY = 21;
24
+ const EXIT_EXISTS = 22;
25
+ /** Default per-command deadline so a hung sandbox can't block file tools forever. */
26
+ const COMMAND_TIMEOUT_MS = 3e4;
27
+ /** Single-quote a string for safe POSIX shell interpolation. */
28
+ function shellQuote(value) {
29
+ return `'${value.replace(/'/g, `'\\''`)}'`;
30
+ }
31
+ function isFileContentString(content) {
32
+ return typeof content === "string";
33
+ }
34
+ function toBuffer(content) {
35
+ if (isFileContentString(content)) return Buffer.from(content, "utf8");
36
+ return Buffer.from(content);
37
+ }
38
+ var SandboxFilesystem = class {
39
+ id;
40
+ name = "SandboxFilesystem";
41
+ provider = "sandbox";
42
+ basePath;
43
+ status = "ready";
44
+ sandbox;
45
+ constructor(options) {
46
+ this.sandbox = options.sandbox;
47
+ this.basePath = options.workdir;
48
+ this.id = options.id ?? `sandbox-fs:${options.sandbox.id}:${options.workdir}`;
49
+ }
50
+ /**
51
+ * Resolve a workspace path to an absolute path inside the sandbox, enforcing
52
+ * that it stays within the workdir.
53
+ *
54
+ * Accepts both workspace-relative paths (`src/foo.ts`, `/src/foo.ts`) and
55
+ * absolute sandbox paths that already live under the workdir — the agent's
56
+ * prompt advertises the workdir as its working directory, so tools are
57
+ * routinely called with fully-qualified paths like `<workdir>/src/foo.ts`.
58
+ */
59
+ resolve(inputPath) {
60
+ const base = posix.normalize(this.basePath);
61
+ const normalizedInput = posix.normalize(inputPath);
62
+ const rel = normalizedInput === base ? "" : normalizedInput.startsWith(`${base}/`) ? normalizedInput.slice(base.length + 1) : inputPath.startsWith("/") ? inputPath.slice(1) : inputPath;
63
+ const resolved = posix.normalize(posix.join(this.basePath, rel));
64
+ const root = posix.normalize(this.basePath);
65
+ if (resolved !== root && !resolved.startsWith(`${root}/`)) throw new Error(`Path escapes workspace root: ${inputPath}`);
66
+ return resolved;
67
+ }
68
+ resolveAbsolutePath(inputPath) {
69
+ return this.resolve(inputPath);
70
+ }
71
+ async exec(script) {
72
+ return this.sandbox.executeCommand("sh", ["-c", script], { timeout: COMMAND_TIMEOUT_MS });
73
+ }
74
+ /**
75
+ * Lexical guard catches `..` traversal, but a symlink inside the workdir can
76
+ * still point outside it. After resolving a path that refers to an existing
77
+ * entry, verify its realpath is still contained in the workdir.
78
+ *
79
+ * Canonicalization tries `realpath`, then `readlink -f` (GNU/busybox), then
80
+ * `cd && pwd -P` for directories — covering GNU hosts, macOS/BSD, and
81
+ * busybox. If the path exists but cannot be canonicalized we fail CLOSED:
82
+ * returning without a check would let a symlink bypass containment.
83
+ */
84
+ async assertContainedRealpath(abs, inputPath) {
85
+ const result = await this.exec([
86
+ `p=${shellQuote(abs)}`,
87
+ `if [ ! -e "$p" ] && [ ! -L "$p" ]; then exit ${EXIT_NOT_FOUND}; fi`,
88
+ `root=$(cd ${shellQuote(this.basePath)} 2>/dev/null && pwd -P)`,
89
+ `[ -n "$root" ] || exit 1`,
90
+ `rp=$(realpath "$p" 2>/dev/null) || rp=$(readlink -f "$p" 2>/dev/null) || { [ -d "$p" ] && rp=$(cd "$p" 2>/dev/null && pwd -P); }`,
91
+ `[ -n "$rp" ] || exit 1`,
92
+ `printf '%s\\n%s' "$root" "$rp"`
93
+ ].join("\n"));
94
+ if (result.exitCode === EXIT_NOT_FOUND) return;
95
+ const [root, real] = result.stdout.split("\n").map((s) => s.trim());
96
+ if (result.exitCode !== 0 || !root || !real) throw new Error(`Unable to verify path stays within workspace root: ${inputPath}`);
97
+ if (real !== root && !real.startsWith(`${root}/`)) throw new Error(`Path escapes workspace root (symlink): ${inputPath}`);
98
+ }
99
+ /**
100
+ * Guard for write destinations. The lexical guard catches `..`, but a symlink
101
+ * inside the workdir can redirect a write outside it. For an existing target
102
+ * we check its realpath; for a not-yet-existing target we check the realpath
103
+ * of its nearest existing ancestor directory, since a symlinked parent is the
104
+ * escape vector (e.g. `link -> /etc` then writing `link/passwd`).
105
+ */
106
+ async assertContainedDest(abs, inputPath) {
107
+ await this.assertContainedRealpath(abs, inputPath);
108
+ const parent = posix.dirname(abs);
109
+ if (parent && parent !== abs) await this.assertContainedRealpath(parent, inputPath);
110
+ }
111
+ async execOk(script, context) {
112
+ const result = await this.exec(script);
113
+ if (result.exitCode !== 0) throw new Error(`${context} failed (exit ${result.exitCode}): ${result.stderr.trim() || result.stdout.trim()}`);
114
+ return result;
115
+ }
116
+ async readFile(path, options) {
117
+ const abs = this.resolve(path);
118
+ await this.assertContainedRealpath(abs, path);
119
+ const result = await this.exec(`if [ -d ${shellQuote(abs)} ]; then exit ${EXIT_IS_DIRECTORY}; elif [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; base64 < ${shellQuote(abs)}`);
120
+ if (result.exitCode === EXIT_IS_DIRECTORY) throw new IsDirectoryError(path);
121
+ if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);
122
+ if (result.exitCode !== 0) throw new Error(`readFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
123
+ const buffer = Buffer.from(result.stdout.replace(/\s/g, ""), "base64");
124
+ if (options?.encoding) return buffer.toString(options.encoding);
125
+ return buffer;
126
+ }
127
+ async writeFile(path, content, options) {
128
+ const abs = this.resolve(path);
129
+ await this.assertContainedDest(abs, path);
130
+ const b64 = toBuffer(content).toString("base64");
131
+ const dir = posix.dirname(abs);
132
+ const mkdir = options?.recursive === false ? "" : `mkdir -p ${shellQuote(dir)} && `;
133
+ if (options?.overwrite === false) {
134
+ const result = await this.exec(`${mkdir}{ (set -C; printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}) 2>/dev/null || { [ -e ${shellQuote(abs)} ] && exit ${EXIT_EXISTS} || exit 1; }; }`);
135
+ if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(path);
136
+ if (result.exitCode !== 0) throw new Error(`writeFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
137
+ return;
138
+ }
139
+ await this.execOk(`${mkdir}printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}`, `writeFile ${path}`);
140
+ }
141
+ async appendFile(path, content) {
142
+ const abs = this.resolve(path);
143
+ await this.assertContainedDest(abs, path);
144
+ const b64 = toBuffer(content).toString("base64");
145
+ await this.execOk(`mkdir -p ${shellQuote(posix.dirname(abs))} && printf %s ${shellQuote(b64)} | base64 -d >> ${shellQuote(abs)}`, `appendFile ${path}`);
146
+ }
147
+ async deleteFile(path, options) {
148
+ const abs = this.resolve(path);
149
+ await this.assertContainedRealpath(posix.dirname(abs), path);
150
+ if (options?.force) {
151
+ await this.execOk(`rm -f ${shellQuote(abs)}`, `deleteFile ${path}`);
152
+ return;
153
+ }
154
+ const result = await this.exec(`if [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; rm ${shellQuote(abs)}`);
155
+ if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);
156
+ if (result.exitCode !== 0) throw new Error(`deleteFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
157
+ }
158
+ async copyFile(src, dest, options) {
159
+ const srcAbs = this.resolve(src);
160
+ const destAbs = this.resolve(dest);
161
+ await this.assertContainedRealpath(srcAbs, src);
162
+ await this.assertContainedDest(destAbs, dest);
163
+ const recursive = options?.recursive ? "-r " : "";
164
+ if (options?.overwrite === false) {
165
+ const result = await this.exec([
166
+ `src=${shellQuote(srcAbs)}`,
167
+ `dest=${shellQuote(destAbs)}`,
168
+ `if [ ! -e "$src" ] && [ ! -L "$src" ]; then exit ${EXIT_NOT_FOUND}; fi`,
169
+ `mkdir -p ${shellQuote(posix.dirname(destAbs))} || exit 1`,
170
+ `if [ -d "$src" ]; then`,
171
+ ` mkdir "$dest" 2>/dev/null || exit ${EXIT_EXISTS}`,
172
+ ` cp -R "$src"/. "$dest"/`,
173
+ `else`,
174
+ ` tmp="$dest.__cptmp$$"`,
175
+ ` cp "$src" "$tmp" || exit 1`,
176
+ ` ln "$tmp" "$dest" 2>/dev/null || { rm -f "$tmp"; [ -e "$dest" ] && exit ${EXIT_EXISTS} || exit 1; }`,
177
+ ` rm -f "$tmp"`,
178
+ `fi`
179
+ ].join("\n"));
180
+ if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
181
+ if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);
182
+ if (result.exitCode !== 0) throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
183
+ return;
184
+ }
185
+ const result = await this.exec(`if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posix.dirname(destAbs))} && cp ${recursive}${shellQuote(srcAbs)} ${shellQuote(destAbs)}`);
186
+ if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
187
+ if (result.exitCode !== 0) throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
188
+ }
189
+ async moveFile(src, dest, options) {
190
+ const srcAbs = this.resolve(src);
191
+ const destAbs = this.resolve(dest);
192
+ await this.assertContainedRealpath(srcAbs, src);
193
+ await this.assertContainedDest(destAbs, dest);
194
+ if (options?.overwrite === false) {
195
+ const result = await this.exec([
196
+ `src=${shellQuote(srcAbs)}`,
197
+ `dest=${shellQuote(destAbs)}`,
198
+ `if [ ! -e "$src" ] && [ ! -L "$src" ]; then exit ${EXIT_NOT_FOUND}; fi`,
199
+ `mkdir -p ${shellQuote(posix.dirname(destAbs))} || exit 1`,
200
+ `mv -n "$src" "$dest" 2>/dev/null || exit 1`,
201
+ `if [ -e "$src" ] || [ -L "$src" ]; then exit ${EXIT_EXISTS}; fi`
202
+ ].join("\n"));
203
+ if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
204
+ if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);
205
+ if (result.exitCode !== 0) throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
206
+ return;
207
+ }
208
+ const result = await this.exec(`if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posix.dirname(destAbs))} && mv ${shellQuote(srcAbs)} ${shellQuote(destAbs)}`);
209
+ if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);
210
+ if (result.exitCode !== 0) throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
211
+ }
212
+ async mkdir(path, options) {
213
+ const abs = this.resolve(path);
214
+ await this.assertContainedDest(abs, path);
215
+ const flag = options?.recursive === false ? "" : "-p ";
216
+ await this.execOk(`mkdir ${flag}${shellQuote(abs)}`, `mkdir ${path}`);
217
+ }
218
+ async rmdir(path, options) {
219
+ const abs = this.resolve(path);
220
+ await this.assertContainedRealpath(posix.dirname(abs), path);
221
+ if (options?.recursive) {
222
+ const force = options?.force ? "-f " : "";
223
+ await this.execOk(`rm -r ${force}${shellQuote(abs)}`, `rmdir ${path}`);
224
+ return;
225
+ }
226
+ if ((await this.exec(`rmdir ${shellQuote(abs)}`)).exitCode !== 0 && !options?.force) throw new Error(`Directory not empty or not found: ${path}`);
227
+ }
228
+ async readdir(path, options) {
229
+ const abs = this.resolve(path);
230
+ await this.assertContainedRealpath(abs, path);
231
+ if (options?.recursive) {
232
+ const result = await this.exec(`test -d ${shellQuote(abs)} && find ${shellQuote(abs)} -mindepth 1 ${options.maxDepth ? `-maxdepth ${Number(options.maxDepth)} ` : ""}2>/dev/null | while IFS= read -r f; do if [ -d "$f" ]; then printf 'd\\t%s\\n' "$f"; else printf 'f\\t%s\\n' "$f"; fi; done`);
233
+ if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);
234
+ return this.parseFindOutput(result.stdout, abs, options);
235
+ }
236
+ const result = await this.exec(`cd ${shellQuote(abs)} 2>/dev/null && for f in * .[!.]*; do [ -e "$f" ] || continue; if [ -d "$f" ]; then printf 'd\\t%s\\n' "$f"; else printf 'f\\t%s\\n' "$f"; fi; done`);
237
+ if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);
238
+ return this.parseListOutput(result.stdout, options);
239
+ }
240
+ parseListOutput(stdout, options) {
241
+ const entries = [];
242
+ for (const line of stdout.split("\n")) {
243
+ if (!line) continue;
244
+ const tab = line.indexOf(" ");
245
+ if (tab < 0) continue;
246
+ const type = line.slice(0, tab) === "d" ? "directory" : "file";
247
+ const name = line.slice(tab + 1);
248
+ if (!name || name === "." || name === "..") continue;
249
+ if (type === "file" && !this.matchesExtension(name, options?.extension)) continue;
250
+ entries.push({
251
+ name,
252
+ type
253
+ });
254
+ }
255
+ return entries;
256
+ }
257
+ parseFindOutput(stdout, base, options) {
258
+ const entries = [];
259
+ for (const line of stdout.split("\n")) {
260
+ if (!line) continue;
261
+ const tab = line.indexOf(" ");
262
+ if (tab < 0) continue;
263
+ const type = line.slice(0, tab) === "d" ? "directory" : "file";
264
+ const fullPath = line.slice(tab + 1);
265
+ const name = posix.relative(base, fullPath);
266
+ if (!name) continue;
267
+ if (type === "file" && !this.matchesExtension(name, options?.extension)) continue;
268
+ entries.push({
269
+ name,
270
+ type
271
+ });
272
+ }
273
+ return entries;
274
+ }
275
+ matchesExtension(name, extension) {
276
+ if (!extension) return true;
277
+ return (Array.isArray(extension) ? extension : [extension]).some((ext) => name.endsWith(ext));
278
+ }
279
+ async exists(path) {
280
+ const abs = this.resolve(path);
281
+ return (await this.exec(`test -e ${shellQuote(abs)}`)).exitCode === 0;
282
+ }
283
+ async stat(path) {
284
+ const abs = this.resolve(path);
285
+ await this.assertContainedRealpath(abs, path);
286
+ const result = await this.exec(`stat -c '%F|%s|%Y|%W' ${shellQuote(abs)} 2>/dev/null || stat -f '%HT|%z|%m|%B' ${shellQuote(abs)}`);
287
+ if (result.exitCode !== 0) throw new FileNotFoundError(path);
288
+ const [kind, sizeStr, mtimeStr, ctimeStr] = result.stdout.trim().split("|");
289
+ const type = kind && kind.toLowerCase().includes("directory") ? "directory" : "file";
290
+ const size = Number(sizeStr) || 0;
291
+ const mtime = Number(mtimeStr) || 0;
292
+ const ctime = Number(ctimeStr);
293
+ return {
294
+ name: posix.basename(abs),
295
+ path: `/${posix.relative(this.basePath, abs)}`,
296
+ type,
297
+ size: type === "directory" ? 0 : size,
298
+ modifiedAt: /* @__PURE__ */ new Date(mtime * 1e3),
299
+ createdAt: /* @__PURE__ */ new Date((ctime > 0 ? ctime : mtime) * 1e3)
300
+ };
301
+ }
302
+ async init() {
303
+ await this.execOk(`mkdir -p ${shellQuote(this.basePath)}`, "init workdir");
304
+ }
305
+ async destroy() {}
306
+ async isReady() {
307
+ return (await this.exec(`test -d ${shellQuote(this.basePath)}`)).exitCode === 0;
308
+ }
309
+ getInfo() {
310
+ return {
311
+ id: this.id,
312
+ name: this.name,
313
+ provider: this.provider,
314
+ status: this.status,
315
+ metadata: {
316
+ basePath: this.basePath,
317
+ sandboxId: this.sandbox.id
318
+ }
319
+ };
320
+ }
321
+ getInstructions() {
322
+ return `Files are stored in a remote sandbox at ${this.basePath}. Use absolute workspace paths like /src/index.ts. All reads, writes and commands run inside the same sandbox.`;
323
+ }
324
+ };
325
+ //#endregion
326
+ export { SandboxFilesystem };
327
+
328
+ //# sourceMappingURL=sandbox-filesystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-filesystem.js","names":["posixPath"],"sources":["../../src/agents/sandbox-filesystem.ts"],"sourcesContent":["/**\n * SandboxFilesystem\n *\n * A `WorkspaceFilesystem` that stores files inside a remote `MastraSandbox`\n * (e.g. a Railway VM) rather than on the server host. File operations are\n * implemented by shelling out through the sandbox's `executeCommand`, so the\n * agent's file tools and command tools share one VM and one view of the repo.\n *\n * Paths are workspace-relative (`/src/foo.ts`) and resolve under the sandbox\n * working directory (`basePath`). A traversal guard rejects any path that\n * escapes the workdir, mirroring `LocalFilesystem`'s contained mode.\n *\n * Reads/writes use base64 over the wire so binary content survives the shell.\n */\n\nimport { posix as posixPath } from 'node:path';\nimport type {\n CopyOptions,\n FileContent,\n FileEntry,\n FileStat,\n FilesystemInfo,\n ListOptions,\n ProviderStatus,\n ReadOptions,\n RemoveOptions,\n WorkspaceFilesystem,\n WriteOptions,\n} from '@mastra/core/workspace';\nimport { FileExistsError, FileNotFoundError, IsDirectoryError } from '@mastra/core/workspace';\n\n/**\n * Sentinel exit codes used by guard clauses that run before the real command,\n * so shell failures can be mapped to typed filesystem errors.\n */\nconst EXIT_NOT_FOUND = 20;\nconst EXIT_IS_DIRECTORY = 21;\nconst EXIT_EXISTS = 22;\n\n/** Minimal command result shape we depend on. */\nexport interface SandboxCommandResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\n/** Minimal sandbox surface the filesystem needs. */\nexport interface SandboxExec {\n readonly id: string;\n executeCommand(command: string, args?: string[], options?: { timeout?: number }): Promise<SandboxCommandResult>;\n}\n\nexport interface SandboxFilesystemOptions {\n /** Live sandbox to run commands in. */\n sandbox: SandboxExec;\n /** Absolute path inside the sandbox that is the workspace root. */\n workdir: string;\n /** Optional stable id; defaults to a sandbox-derived id. */\n id?: string;\n}\n\n/** Default per-command deadline so a hung sandbox can't block file tools forever. */\nconst COMMAND_TIMEOUT_MS = 30_000;\n\n/** Single-quote a string for safe POSIX shell interpolation. */\nfunction shellQuote(value: string): string {\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\nfunction isFileContentString(content: FileContent): content is string {\n return typeof content === 'string';\n}\n\nfunction toBuffer(content: FileContent): Buffer {\n if (isFileContentString(content)) return Buffer.from(content, 'utf8');\n return Buffer.from(content);\n}\n\nexport class SandboxFilesystem implements WorkspaceFilesystem {\n readonly id: string;\n readonly name = 'SandboxFilesystem';\n readonly provider = 'sandbox';\n readonly basePath: string;\n status: ProviderStatus = 'ready';\n\n private readonly sandbox: SandboxExec;\n\n constructor(options: SandboxFilesystemOptions) {\n this.sandbox = options.sandbox;\n this.basePath = options.workdir;\n // Include the workdir: one sandbox can back several filesystems rooted at\n // different worktrees, and each needs a distinct id.\n this.id = options.id ?? `sandbox-fs:${options.sandbox.id}:${options.workdir}`;\n }\n\n // ── Path handling ──────────────────────────────────────────────────────\n\n /**\n * Resolve a workspace path to an absolute path inside the sandbox, enforcing\n * that it stays within the workdir.\n *\n * Accepts both workspace-relative paths (`src/foo.ts`, `/src/foo.ts`) and\n * absolute sandbox paths that already live under the workdir — the agent's\n * prompt advertises the workdir as its working directory, so tools are\n * routinely called with fully-qualified paths like `<workdir>/src/foo.ts`.\n */\n private resolve(inputPath: string): string {\n const base = posixPath.normalize(this.basePath);\n const normalizedInput = posixPath.normalize(inputPath);\n const rel =\n normalizedInput === base\n ? ''\n : normalizedInput.startsWith(`${base}/`)\n ? normalizedInput.slice(base.length + 1)\n : inputPath.startsWith('/')\n ? inputPath.slice(1)\n : inputPath;\n const resolved = posixPath.normalize(posixPath.join(this.basePath, rel));\n const root = posixPath.normalize(this.basePath);\n if (resolved !== root && !resolved.startsWith(`${root}/`)) {\n throw new Error(`Path escapes workspace root: ${inputPath}`);\n }\n return resolved;\n }\n\n resolveAbsolutePath(inputPath: string): string | undefined {\n return this.resolve(inputPath);\n }\n\n // ── Command helper ─────────────────────────────────────────────────────\n\n private async exec(script: string): Promise<SandboxCommandResult> {\n return this.sandbox.executeCommand('sh', ['-c', script], { timeout: COMMAND_TIMEOUT_MS });\n }\n\n /**\n * Lexical guard catches `..` traversal, but a symlink inside the workdir can\n * still point outside it. After resolving a path that refers to an existing\n * entry, verify its realpath is still contained in the workdir.\n *\n * Canonicalization tries `realpath`, then `readlink -f` (GNU/busybox), then\n * `cd && pwd -P` for directories — covering GNU hosts, macOS/BSD, and\n * busybox. If the path exists but cannot be canonicalized we fail CLOSED:\n * returning without a check would let a symlink bypass containment.\n */\n private async assertContainedRealpath(abs: string, inputPath: string): Promise<void> {\n const result = await this.exec(\n [\n `p=${shellQuote(abs)}`,\n `if [ ! -e \"$p\" ] && [ ! -L \"$p\" ]; then exit ${EXIT_NOT_FOUND}; fi`,\n // The workdir itself may contain symlinked components (/tmp on macOS),\n // so canonicalize it as the comparison root.\n `root=$(cd ${shellQuote(this.basePath)} 2>/dev/null && pwd -P)`,\n `[ -n \"$root\" ] || exit 1`,\n `rp=$(realpath \"$p\" 2>/dev/null) || rp=$(readlink -f \"$p\" 2>/dev/null) || { [ -d \"$p\" ] && rp=$(cd \"$p\" 2>/dev/null && pwd -P); }`,\n `[ -n \"$rp\" ] || exit 1`,\n `printf '%s\\\\n%s' \"$root\" \"$rp\"`,\n ].join('\\n'),\n );\n // Path doesn't exist yet: nothing to canonicalize (writes to a fresh leaf\n // are covered by assertContainedDest checking the parent directory).\n if (result.exitCode === EXIT_NOT_FOUND) return;\n const [root, real] = result.stdout.split('\\n').map(s => s.trim());\n if (result.exitCode !== 0 || !root || !real) {\n throw new Error(`Unable to verify path stays within workspace root: ${inputPath}`);\n }\n if (real !== root && !real.startsWith(`${root}/`)) {\n throw new Error(`Path escapes workspace root (symlink): ${inputPath}`);\n }\n }\n\n /**\n * Guard for write destinations. The lexical guard catches `..`, but a symlink\n * inside the workdir can redirect a write outside it. For an existing target\n * we check its realpath; for a not-yet-existing target we check the realpath\n * of its nearest existing ancestor directory, since a symlinked parent is the\n * escape vector (e.g. `link -> /etc` then writing `link/passwd`).\n */\n private async assertContainedDest(abs: string, inputPath: string): Promise<void> {\n // First check the target itself (covers overwriting an existing symlink).\n await this.assertContainedRealpath(abs, inputPath);\n // Then check the parent directory's realpath; readlink -f resolves the\n // nearest existing ancestor when the leaf doesn't exist yet.\n const parent = posixPath.dirname(abs);\n if (parent && parent !== abs) {\n await this.assertContainedRealpath(parent, inputPath);\n }\n }\n\n private async execOk(script: string, context: string): Promise<SandboxCommandResult> {\n const result = await this.exec(script);\n if (result.exitCode !== 0) {\n throw new Error(`${context} failed (exit ${result.exitCode}): ${result.stderr.trim() || result.stdout.trim()}`);\n }\n return result;\n }\n\n // ── File operations ────────────────────────────────────────────────────\n\n async readFile(path: string, options?: ReadOptions): Promise<string | Buffer> {\n const abs = this.resolve(path);\n await this.assertContainedRealpath(abs, path);\n // Guard clauses first: redirecting from a directory \"succeeds\" with empty\n // output on some shells, so classify before reading.\n const result = await this.exec(\n `if [ -d ${shellQuote(abs)} ]; then exit ${EXIT_IS_DIRECTORY}; elif [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; base64 < ${shellQuote(abs)}`,\n );\n if (result.exitCode === EXIT_IS_DIRECTORY) throw new IsDirectoryError(path);\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);\n if (result.exitCode !== 0) {\n throw new Error(`readFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n const buffer = Buffer.from(result.stdout.replace(/\\s/g, ''), 'base64');\n if (options?.encoding) {\n return buffer.toString(options.encoding);\n }\n return buffer;\n }\n\n async writeFile(path: string, content: FileContent, options?: WriteOptions): Promise<void> {\n const abs = this.resolve(path);\n await this.assertContainedDest(abs, path);\n const b64 = toBuffer(content).toString('base64');\n const dir = posixPath.dirname(abs);\n const mkdir = options?.recursive === false ? '' : `mkdir -p ${shellQuote(dir)} && `;\n if (options?.overwrite === false) {\n // `set -C` (noclobber) makes the redirect itself the exclusivity check —\n // no exists() pre-check that could race with a concurrent writer.\n const result = await this.exec(\n `${mkdir}{ (set -C; printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}) 2>/dev/null || { [ -e ${shellQuote(abs)} ] && exit ${EXIT_EXISTS} || exit 1; }; }`,\n );\n if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(path);\n if (result.exitCode !== 0) {\n throw new Error(`writeFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n return;\n }\n await this.execOk(`${mkdir}printf %s ${shellQuote(b64)} | base64 -d > ${shellQuote(abs)}`, `writeFile ${path}`);\n }\n\n async appendFile(path: string, content: FileContent): Promise<void> {\n const abs = this.resolve(path);\n await this.assertContainedDest(abs, path);\n const b64 = toBuffer(content).toString('base64');\n await this.execOk(\n `mkdir -p ${shellQuote(posixPath.dirname(abs))} && printf %s ${shellQuote(b64)} | base64 -d >> ${shellQuote(abs)}`,\n `appendFile ${path}`,\n );\n }\n\n async deleteFile(path: string, options?: RemoveOptions): Promise<void> {\n const abs = this.resolve(path);\n // Contain the parent's realpath: deleting `link/file` where `link` points\n // outside the workdir must fail, while deleting a symlink entry itself\n // (which lives inside the workdir) stays allowed.\n await this.assertContainedRealpath(posixPath.dirname(abs), path);\n if (options?.force) {\n // `rm -f` already succeeds for a missing file, but still fails for\n // directories and permission errors — surface those.\n await this.execOk(`rm -f ${shellQuote(abs)}`, `deleteFile ${path}`);\n return;\n }\n const result = await this.exec(\n `if [ ! -e ${shellQuote(abs)} ]; then exit ${EXIT_NOT_FOUND}; fi; rm ${shellQuote(abs)}`,\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(path);\n if (result.exitCode !== 0) {\n throw new Error(`deleteFile ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n }\n\n async copyFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n const srcAbs = this.resolve(src);\n const destAbs = this.resolve(dest);\n await this.assertContainedRealpath(srcAbs, src);\n await this.assertContainedDest(destAbs, dest);\n const recursive = options?.recursive ? '-r ' : '';\n if (options?.overwrite === false) {\n // Atomic no-clobber: directories claim the destination with an exclusive\n // mkdir; files copy to a temp name then hardlink into place (link(2)\n // fails if the destination exists). No racy exists() pre-check.\n const result = await this.exec(\n [\n `src=${shellQuote(srcAbs)}`,\n `dest=${shellQuote(destAbs)}`,\n `if [ ! -e \"$src\" ] && [ ! -L \"$src\" ]; then exit ${EXIT_NOT_FOUND}; fi`,\n `mkdir -p ${shellQuote(posixPath.dirname(destAbs))} || exit 1`,\n `if [ -d \"$src\" ]; then`,\n ` mkdir \"$dest\" 2>/dev/null || exit ${EXIT_EXISTS}`,\n ` cp -R \"$src\"/. \"$dest\"/`,\n `else`,\n ` tmp=\"$dest.__cptmp$$\"`,\n ` cp \"$src\" \"$tmp\" || exit 1`,\n ` ln \"$tmp\" \"$dest\" 2>/dev/null || { rm -f \"$tmp\"; [ -e \"$dest\" ] && exit ${EXIT_EXISTS} || exit 1; }`,\n ` rm -f \"$tmp\"`,\n `fi`,\n ].join('\\n'),\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);\n if (result.exitCode !== 0) {\n throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n return;\n }\n const result = await this.exec(\n `if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posixPath.dirname(destAbs))} && cp ${recursive}${shellQuote(srcAbs)} ${shellQuote(destAbs)}`,\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode !== 0) {\n throw new Error(`copyFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n }\n\n async moveFile(src: string, dest: string, options?: CopyOptions): Promise<void> {\n const srcAbs = this.resolve(src);\n const destAbs = this.resolve(dest);\n await this.assertContainedRealpath(srcAbs, src);\n await this.assertContainedDest(destAbs, dest);\n if (options?.overwrite === false) {\n // `mv -n` exits 0 even when it skips, so detect a skipped move by the\n // source surviving. The no-clobber rename itself is atomic; no racy\n // exists() pre-check.\n const result = await this.exec(\n [\n `src=${shellQuote(srcAbs)}`,\n `dest=${shellQuote(destAbs)}`,\n `if [ ! -e \"$src\" ] && [ ! -L \"$src\" ]; then exit ${EXIT_NOT_FOUND}; fi`,\n `mkdir -p ${shellQuote(posixPath.dirname(destAbs))} || exit 1`,\n `mv -n \"$src\" \"$dest\" 2>/dev/null || exit 1`,\n `if [ -e \"$src\" ] || [ -L \"$src\" ]; then exit ${EXIT_EXISTS}; fi`,\n ].join('\\n'),\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode === EXIT_EXISTS) throw new FileExistsError(dest);\n if (result.exitCode !== 0) {\n throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n return;\n }\n const result = await this.exec(\n `if [ ! -e ${shellQuote(srcAbs)} ]; then exit ${EXIT_NOT_FOUND}; fi; mkdir -p ${shellQuote(posixPath.dirname(destAbs))} && mv ${shellQuote(srcAbs)} ${shellQuote(destAbs)}`,\n );\n if (result.exitCode === EXIT_NOT_FOUND) throw new FileNotFoundError(src);\n if (result.exitCode !== 0) {\n throw new Error(`moveFile ${src} -> ${dest} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n }\n\n // ── Directory operations ───────────────────────────────────────────────\n\n async mkdir(path: string, options?: { recursive?: boolean }): Promise<void> {\n const abs = this.resolve(path);\n await this.assertContainedDest(abs, path);\n const flag = options?.recursive === false ? '' : '-p ';\n await this.execOk(`mkdir ${flag}${shellQuote(abs)}`, `mkdir ${path}`);\n }\n\n async rmdir(path: string, options?: RemoveOptions): Promise<void> {\n const abs = this.resolve(path);\n // Same parent containment as deleteFile — `rm -r` through a symlinked\n // parent would otherwise delete outside the workspace.\n await this.assertContainedRealpath(posixPath.dirname(abs), path);\n if (options?.recursive) {\n const force = options?.force ? '-f ' : '';\n await this.execOk(`rm -r ${force}${shellQuote(abs)}`, `rmdir ${path}`);\n return;\n }\n const result = await this.exec(`rmdir ${shellQuote(abs)}`);\n if (result.exitCode !== 0 && !options?.force) {\n throw new Error(`Directory not empty or not found: ${path}`);\n }\n }\n\n async readdir(path: string, options?: ListOptions): Promise<FileEntry[]> {\n const abs = this.resolve(path);\n await this.assertContainedRealpath(abs, path);\n if (options?.recursive) {\n // Recursive listing emitting \"type\\tpath\". `find -printf` is GNU-only\n // (fails on macOS/BSD hosts backing a local sandbox), so classify each\n // entry with a portable shell loop instead.\n const result = await this.exec(\n `test -d ${shellQuote(abs)} && find ${shellQuote(abs)} -mindepth 1 ${options.maxDepth ? `-maxdepth ${Number(options.maxDepth)} ` : ''}2>/dev/null | while IFS= read -r f; do if [ -d \"$f\" ]; then printf 'd\\\\t%s\\\\n' \"$f\"; else printf 'f\\\\t%s\\\\n' \"$f\"; fi; done`,\n );\n if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);\n return this.parseFindOutput(result.stdout, abs, options);\n }\n // Non-recursive: list with name + type via a portable loop. Use printf,\n // not echo — bash-as-/bin/sh (macOS local sandboxes) does not expand \\t\n // in echo arguments.\n const result = await this.exec(\n `cd ${shellQuote(abs)} 2>/dev/null && for f in * .[!.]*; do [ -e \"$f\" ] || continue; if [ -d \"$f\" ]; then printf 'd\\\\t%s\\\\n' \"$f\"; else printf 'f\\\\t%s\\\\n' \"$f\"; fi; done`,\n );\n if (result.exitCode !== 0) throw new Error(`Directory not found: ${path}`);\n return this.parseListOutput(result.stdout, options);\n }\n\n private parseListOutput(stdout: string, options?: ListOptions): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split('\\n')) {\n if (!line) continue;\n const tab = line.indexOf('\\t');\n if (tab < 0) continue;\n const type = line.slice(0, tab) === 'd' ? 'directory' : 'file';\n const name = line.slice(tab + 1);\n if (!name || name === '.' || name === '..') continue;\n if (type === 'file' && !this.matchesExtension(name, options?.extension)) continue;\n entries.push({ name, type });\n }\n return entries;\n }\n\n private parseFindOutput(stdout: string, base: string, options?: ListOptions): FileEntry[] {\n const entries: FileEntry[] = [];\n for (const line of stdout.split('\\n')) {\n if (!line) continue;\n const tab = line.indexOf('\\t');\n if (tab < 0) continue;\n const type = line.slice(0, tab) === 'd' ? 'directory' : 'file';\n const fullPath = line.slice(tab + 1);\n const name = posixPath.relative(base, fullPath);\n if (!name) continue;\n if (type === 'file' && !this.matchesExtension(name, options?.extension)) continue;\n entries.push({ name, type });\n }\n return entries;\n }\n\n private matchesExtension(name: string, extension?: string | string[]): boolean {\n if (!extension) return true;\n const exts = Array.isArray(extension) ? extension : [extension];\n return exts.some(ext => name.endsWith(ext));\n }\n\n // ── Path / metadata ────────────────────────────────────────────────────\n\n async exists(path: string): Promise<boolean> {\n const abs = this.resolve(path);\n const result = await this.exec(`test -e ${shellQuote(abs)}`);\n return result.exitCode === 0;\n }\n\n async stat(path: string): Promise<FileStat> {\n const abs = this.resolve(path);\n await this.assertContainedRealpath(abs, path);\n // GNU stat: %F=type, %s=size, %Y=mtime (epoch seconds), %W=birth (or -1).\n // BSD/macOS stat (local sandbox hosts) rejects `-c`; fall back to its\n // `-f` format with the same field order (%HT=type, %z=size, %m=mtime,\n // %B=birth). Delimit with `|` — neither stat interprets `\\t` escapes in\n // its format string.\n const result = await this.exec(\n `stat -c '%F|%s|%Y|%W' ${shellQuote(abs)} 2>/dev/null || stat -f '%HT|%z|%m|%B' ${shellQuote(abs)}`,\n );\n if (result.exitCode !== 0) {\n throw new FileNotFoundError(path);\n }\n const [kind, sizeStr, mtimeStr, ctimeStr] = result.stdout.trim().split('|');\n const type = kind && kind.toLowerCase().includes('directory') ? 'directory' : 'file';\n const size = Number(sizeStr) || 0;\n const mtime = Number(mtimeStr) || 0;\n const ctime = Number(ctimeStr);\n return {\n name: posixPath.basename(abs),\n path: `/${posixPath.relative(this.basePath, abs)}`,\n type,\n size: type === 'directory' ? 0 : size,\n modifiedAt: new Date(mtime * 1000),\n createdAt: new Date((ctime > 0 ? ctime : mtime) * 1000),\n };\n }\n\n // ── Lifecycle ──────────────────────────────────────────────────────────\n\n async init(): Promise<void> {\n await this.execOk(`mkdir -p ${shellQuote(this.basePath)}`, 'init workdir');\n }\n\n async destroy(): Promise<void> {\n // The sandbox lifecycle is owned by the caller; nothing to tear down here.\n }\n\n async isReady(): Promise<boolean> {\n const result = await this.exec(`test -d ${shellQuote(this.basePath)}`);\n return result.exitCode === 0;\n }\n\n getInfo(): FilesystemInfo {\n return {\n id: this.id,\n name: this.name,\n provider: this.provider,\n status: this.status,\n metadata: { basePath: this.basePath, sandboxId: this.sandbox.id },\n };\n }\n\n getInstructions(): string {\n return `Files are stored in a remote sandbox at ${this.basePath}. Use absolute workspace paths like /src/index.ts. All reads, writes and commands run inside the same sandbox.`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,iBAAiB;AACvB,MAAM,oBAAoB;AAC1B,MAAM,cAAc;;AAyBpB,MAAM,qBAAqB;;AAG3B,SAAS,WAAW,OAAuB;CACzC,OAAO,IAAI,MAAM,QAAQ,MAAM,OAAO,E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QAAO,MADc,KAAK,KAAK,WAAW,WAAW,KAAK,QAAQ,GAAG,EAAA,CACvD,aAAa;CAC7B;CAEA,UAA0B;EACxB,OAAO;GACL,IAAI,KAAK;GACT,MAAM,KAAK;GACX,UAAU,KAAK;GACf,QAAQ,KAAK;GACb,UAAU;IAAE,UAAU,KAAK;IAAU,WAAW,KAAK,QAAQ;GAAG;EAClE;CACF;CAEA,kBAA0B;EACxB,OAAO,2CAA2C,KAAK,SAAS;CAClE;AACF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Seam between the core workspace wiring and the web surface's sandbox
3
+ * provisioning. GitHub/cloud-sandbox projects are only reachable through the
4
+ * web tenant server, which owns the sandbox provider factory and its DB-backed
5
+ * bookkeeping. The web package registers its `reattachProjectSandbox`
6
+ * implementation here at startup so `getDynamicWorkspace` can reattach
7
+ * sandboxes without core depending on the web stack.
8
+ */
9
+ import type { SandboxExec } from './sandbox-filesystem.js';
10
+ /** Minimal sandbox surface the workspace seam needs after reattach. */
11
+ export interface ReattachedSandbox extends SandboxExec {
12
+ start(): Promise<void>;
13
+ }
14
+ export type SandboxReattachFn = (providerSandboxId: string) => Promise<ReattachedSandbox>;
15
+ /** Register the sandbox reattach implementation (called by the web surface at startup). */
16
+ export declare function registerSandboxReattach(fn: SandboxReattachFn): void;
17
+ /** Reattach to an already-provisioned sandbox by provider id. */
18
+ export declare function reattachProjectSandbox(providerSandboxId: string): Promise<ReattachedSandbox>;
19
+ //# sourceMappingURL=sandbox-reattach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-reattach.d.ts","sourceRoot":"","sources":["../../src/agents/sandbox-reattach.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,uEAAuE;AACvE,MAAM,WAAW,iBAAkB,SAAQ,WAAW;IACpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,iBAAiB,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAI1F,2FAA2F;AAC3F,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAEnE;AAED,iEAAiE;AACjE,wBAAsB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAOlG"}
@@ -0,0 +1,15 @@
1
+ //#region src/agents/sandbox-reattach.ts
2
+ let reattachFn;
3
+ /** Register the sandbox reattach implementation (called by the web surface at startup). */
4
+ function registerSandboxReattach(fn) {
5
+ reattachFn = fn;
6
+ }
7
+ /** Reattach to an already-provisioned sandbox by provider id. */
8
+ async function reattachProjectSandbox(providerSandboxId) {
9
+ if (!reattachFn) throw new Error("No sandbox reattach implementation registered. Sandbox-backed workspaces are only available when the web surface has called registerSandboxReattach().");
10
+ return reattachFn(providerSandboxId);
11
+ }
12
+ //#endregion
13
+ export { reattachProjectSandbox, registerSandboxReattach };
14
+
15
+ //# sourceMappingURL=sandbox-reattach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-reattach.js","names":[],"sources":["../../src/agents/sandbox-reattach.ts"],"sourcesContent":["/**\n * Seam between the core workspace wiring and the web surface's sandbox\n * provisioning. GitHub/cloud-sandbox projects are only reachable through the\n * web tenant server, which owns the sandbox provider factory and its DB-backed\n * bookkeeping. The web package registers its `reattachProjectSandbox`\n * implementation here at startup so `getDynamicWorkspace` can reattach\n * sandboxes without core depending on the web stack.\n */\nimport type { SandboxExec } from './sandbox-filesystem.js';\n\n/** Minimal sandbox surface the workspace seam needs after reattach. */\nexport interface ReattachedSandbox extends SandboxExec {\n start(): Promise<void>;\n}\n\nexport type SandboxReattachFn = (providerSandboxId: string) => Promise<ReattachedSandbox>;\n\nlet reattachFn: SandboxReattachFn | undefined;\n\n/** Register the sandbox reattach implementation (called by the web surface at startup). */\nexport function registerSandboxReattach(fn: SandboxReattachFn): void {\n reattachFn = fn;\n}\n\n/** Reattach to an already-provisioned sandbox by provider id. */\nexport async function reattachProjectSandbox(providerSandboxId: string): Promise<ReattachedSandbox> {\n if (!reattachFn) {\n throw new Error(\n 'No sandbox reattach implementation registered. Sandbox-backed workspaces are only available when the web surface has called registerSandboxReattach().',\n );\n }\n return reattachFn(providerSandboxId);\n}\n"],"mappings":";AAiBA,IAAI;;AAGJ,SAAgB,wBAAwB,IAA6B;CACnE,aAAa;AACf;;AAGA,eAAsB,uBAAuB,mBAAuD;CAClG,IAAI,CAAC,YACH,MAAM,IAAI,MACR,wJACF;CAEF,OAAO,WAAW,iBAAiB;AACrC"}
@@ -0,0 +1,17 @@
1
+ import type { Session } from '@mastra/core/agent-controller';
2
+ /**
3
+ * Wires MastraCode-owned state into controller thread events so it persists
4
+ * per-thread and new threads inherit the most recent value.
5
+ *
6
+ * This is intentionally implemented in mastracode rather than core: these
7
+ * settings are mastracode-specific concepts, so persistence stays scoped to
8
+ * the host.
9
+ */
10
+ export declare function attachOMThreadStatePersistence(session: Session<Record<string, unknown>>): void;
11
+ /**
12
+ * Eagerly restores MastraCode-owned OM settings for the currently-selected
13
+ * thread. Called once at TUI startup after the initial thread is selected,
14
+ * since the subscription set up later misses the startup `thread_changed` event.
15
+ */
16
+ export declare function restoreOMThreadStateForCurrentThread(session: Session<Record<string, unknown>>): Promise<void>;
17
+ //# sourceMappingURL=thread-caveman-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-caveman-state.d.ts","sourceRoot":"","sources":["../../src/agents/thread-caveman-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAkGpF;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAqB9F;AAED;;;;GAIG;AACH,wBAAsB,oCAAoC,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAInH"}
@@ -0,0 +1,107 @@
1
+ //#region src/agents/thread-caveman-state.ts
2
+ const THREAD_STATE_SETTINGS = [
3
+ {
4
+ key: "cavemanObservations",
5
+ isValid: (value) => typeof value === "boolean",
6
+ seedMissingFromCurrentState: true
7
+ },
8
+ {
9
+ key: "observeAttachments",
10
+ isValid: (value) => value === "auto" || typeof value === "boolean",
11
+ seedMissingFromCurrentState: true
12
+ },
13
+ {
14
+ key: "sandboxAllowedPaths",
15
+ isValid: (value) => Array.isArray(value) && value.every((item) => typeof item === "string"),
16
+ clearValueWhenMissing: []
17
+ }
18
+ ];
19
+ function getStateValue(session, setting) {
20
+ const value = session.state.get()[setting.key];
21
+ return setting.isValid(value) ? value : void 0;
22
+ }
23
+ function stateValuesEqual(left, right) {
24
+ if (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((item, index) => item === right[index]);
25
+ return left === right;
26
+ }
27
+ async function findThread(session, threadId) {
28
+ return (await session.thread.list({ allResources: true })).find((t) => t.id === threadId);
29
+ }
30
+ /**
31
+ * Restores MastraCode-owned per-thread state for the given thread:
32
+ * - If the thread already has a valid value in metadata, mirror it into controller state.
33
+ * - Otherwise, persist the current session.state value to the thread so future
34
+ * sessions see the user's last-selected setting.
35
+ */
36
+ async function restoreSettingsForThread(session, threadId) {
37
+ const thread = await findThread(session, threadId);
38
+ if (session.thread.getId() !== threadId) return;
39
+ const updates = {};
40
+ const settingsToSeed = [];
41
+ for (const setting of THREAD_STATE_SETTINGS) {
42
+ const persisted = thread?.metadata?.[setting.key];
43
+ if (setting.isValid(persisted)) {
44
+ if (getStateValue(session, setting) !== persisted) updates[setting.key] = persisted;
45
+ continue;
46
+ }
47
+ if (setting.clearValueWhenMissing !== void 0) {
48
+ const current = getStateValue(session, setting);
49
+ if (current !== void 0 && !stateValuesEqual(current, setting.clearValueWhenMissing)) updates[setting.key] = setting.clearValueWhenMissing;
50
+ continue;
51
+ }
52
+ if (setting.seedMissingFromCurrentState) {
53
+ const current = getStateValue(session, setting);
54
+ if (current !== void 0) settingsToSeed.push({
55
+ key: setting.key,
56
+ value: current
57
+ });
58
+ }
59
+ }
60
+ if (Object.keys(updates).length > 0) {
61
+ if (session.thread.getId() !== threadId) return;
62
+ await session.state.set(updates);
63
+ }
64
+ for (const setting of settingsToSeed) {
65
+ if (session.thread.getId() !== threadId) return;
66
+ await session.thread.setSetting(setting);
67
+ }
68
+ }
69
+ /**
70
+ * Wires MastraCode-owned state into controller thread events so it persists
71
+ * per-thread and new threads inherit the most recent value.
72
+ *
73
+ * This is intentionally implemented in mastracode rather than core: these
74
+ * settings are mastracode-specific concepts, so persistence stays scoped to
75
+ * the host.
76
+ */
77
+ function attachOMThreadStatePersistence(session) {
78
+ session.subscribe((event) => {
79
+ if (event.type === "thread_changed" || event.type === "thread_created") {
80
+ restoreSettingsForThread(session, event.type === "thread_changed" ? event.threadId : event.thread.id).catch(() => {});
81
+ return;
82
+ }
83
+ if (event.type === "state_changed") for (const setting of THREAD_STATE_SETTINGS) {
84
+ if (!event.changedKeys.includes(setting.key)) continue;
85
+ const value = event.state[setting.key];
86
+ if (!setting.isValid(value)) continue;
87
+ session.thread.setSetting({
88
+ key: setting.key,
89
+ value
90
+ }).catch(() => {});
91
+ }
92
+ });
93
+ }
94
+ /**
95
+ * Eagerly restores MastraCode-owned OM settings for the currently-selected
96
+ * thread. Called once at TUI startup after the initial thread is selected,
97
+ * since the subscription set up later misses the startup `thread_changed` event.
98
+ */
99
+ async function restoreOMThreadStateForCurrentThread(session) {
100
+ const threadId = session.thread.getId();
101
+ if (!threadId) return;
102
+ await restoreSettingsForThread(session, threadId);
103
+ }
104
+ //#endregion
105
+ export { attachOMThreadStatePersistence, restoreOMThreadStateForCurrentThread };
106
+
107
+ //# sourceMappingURL=thread-caveman-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thread-caveman-state.js","names":[],"sources":["../../src/agents/thread-caveman-state.ts"],"sourcesContent":["import type { AgentControllerThread, Session } from '@mastra/core/agent-controller';\n\ninterface ThreadStateSetting {\n key: string;\n isValid(value: unknown): boolean;\n seedMissingFromCurrentState?: boolean;\n clearValueWhenMissing?: unknown;\n}\n\nconst THREAD_STATE_SETTINGS: ThreadStateSetting[] = [\n {\n key: 'cavemanObservations',\n isValid: (value: unknown): value is boolean => typeof value === 'boolean',\n seedMissingFromCurrentState: true,\n },\n {\n key: 'observeAttachments',\n isValid: (value: unknown): value is 'auto' | boolean => value === 'auto' || typeof value === 'boolean',\n seedMissingFromCurrentState: true,\n },\n {\n key: 'sandboxAllowedPaths',\n isValid: (value: unknown): value is string[] =>\n Array.isArray(value) && value.every(item => typeof item === 'string'),\n clearValueWhenMissing: [],\n },\n];\n\nfunction getStateValue(session: Session<Record<string, unknown>>, setting: ThreadStateSetting): unknown {\n const value = session.state.get()[setting.key];\n return setting.isValid(value) ? value : undefined;\n}\n\nfunction stateValuesEqual(left: unknown, right: unknown): boolean {\n if (Array.isArray(left) && Array.isArray(right)) {\n return left.length === right.length && left.every((item, index) => item === right[index]);\n }\n return left === right;\n}\n\nasync function findThread(\n session: Session<Record<string, unknown>>,\n threadId: string,\n): Promise<AgentControllerThread | undefined> {\n const threads = await session.thread.list({ allResources: true });\n return threads.find(t => t.id === threadId);\n}\n\n/**\n * Restores MastraCode-owned per-thread state for the given thread:\n * - If the thread already has a valid value in metadata, mirror it into controller state.\n * - Otherwise, persist the current session.state value to the thread so future\n * sessions see the user's last-selected setting.\n */\nasync function restoreSettingsForThread(session: Session<Record<string, unknown>>, threadId: string): Promise<void> {\n const thread = await findThread(session, threadId);\n if (session.thread.getId() !== threadId) return;\n\n const updates: Record<string, unknown> = {};\n const settingsToSeed: Array<{ key: string; value: unknown }> = [];\n\n for (const setting of THREAD_STATE_SETTINGS) {\n const persisted = thread?.metadata?.[setting.key];\n\n if (setting.isValid(persisted)) {\n if (getStateValue(session, setting) !== persisted) {\n updates[setting.key] = persisted;\n }\n continue;\n }\n\n if (setting.clearValueWhenMissing !== undefined) {\n const current = getStateValue(session, setting);\n if (current !== undefined && !stateValuesEqual(current, setting.clearValueWhenMissing)) {\n updates[setting.key] = setting.clearValueWhenMissing;\n }\n continue;\n }\n\n if (setting.seedMissingFromCurrentState) {\n const current = getStateValue(session, setting);\n if (current !== undefined) {\n settingsToSeed.push({ key: setting.key, value: current });\n }\n }\n }\n\n if (Object.keys(updates).length > 0) {\n if (session.thread.getId() !== threadId) return;\n await session.state.set(updates);\n }\n\n for (const setting of settingsToSeed) {\n if (session.thread.getId() !== threadId) return;\n await session.thread.setSetting(setting);\n }\n}\n\n/**\n * Wires MastraCode-owned state into controller thread events so it persists\n * per-thread and new threads inherit the most recent value.\n *\n * This is intentionally implemented in mastracode rather than core: these\n * settings are mastracode-specific concepts, so persistence stays scoped to\n * the host.\n */\nexport function attachOMThreadStatePersistence(session: Session<Record<string, unknown>>): void {\n session.subscribe(event => {\n if (event.type === 'thread_changed' || event.type === 'thread_created') {\n const threadId = event.type === 'thread_changed' ? event.threadId : event.thread.id;\n void restoreSettingsForThread(session, threadId).catch(() => {\n // Persistence is best-effort; don't crash the TUI if storage hiccups.\n });\n return;\n }\n\n if (event.type === 'state_changed') {\n for (const setting of THREAD_STATE_SETTINGS) {\n if (!event.changedKeys.includes(setting.key)) continue;\n const value = event.state[setting.key];\n if (!setting.isValid(value)) continue;\n void session.thread.setSetting({ key: setting.key, value }).catch(() => {\n // Persistence is best-effort; don't crash the TUI if storage hiccups.\n });\n }\n }\n });\n}\n\n/**\n * Eagerly restores MastraCode-owned OM settings for the currently-selected\n * thread. Called once at TUI startup after the initial thread is selected,\n * since the subscription set up later misses the startup `thread_changed` event.\n */\nexport async function restoreOMThreadStateForCurrentThread(session: Session<Record<string, unknown>>): Promise<void> {\n const threadId = session.thread.getId();\n if (!threadId) return;\n await restoreSettingsForThread(session, threadId);\n}\n"],"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,0 +1,10 @@
1
+ import type { WorkspaceToolHookContext, WorkspaceToolsConfig } from '@mastra/core/workspace';
2
+ export declare function guardPlanModePlanFileWrites({ workspaceToolName, input, context }: WorkspaceToolHookContext): {
3
+ proceed: false;
4
+ output: string;
5
+ } | undefined;
6
+ export declare const MASTRACODE_WORKSPACE_TOOLS: WorkspaceToolsConfig;
7
+ export declare const PLAN_MODE_AVAILABLE_TOOLS: readonly string[];
8
+ export declare const EXPLORE_MODE_AVAILABLE_TOOLS: readonly string[];
9
+ export declare const GOAL_JUDGE_READONLY_TOOLS: readonly string[];
10
+ //# sourceMappingURL=tool-availability.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-availability.d.ts","sourceRoot":"","sources":["../../src/agents/tool-availability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAyD7F,wBAAgB,2BAA2B,CAAC,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,wBAAwB;;;cAuB1G;AAED,eAAO,MAAM,0BAA0B,EAAE,oBAKxC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAqBtD,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAOzD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAMtD,CAAC"}