@mastra/code-sdk 1.21.0-alpha.6 → 1.21.0-alpha.7

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 (580) hide show
  1. package/dist/acp/agent.js +0 -2
  2. package/dist/acp/errors.js +0 -2
  3. package/dist/acp/event-mapper.js +0 -2
  4. package/dist/acp/index.js +0 -2
  5. package/dist/acp/runtime.js +0 -2
  6. package/dist/acp/server.js +0 -2
  7. package/dist/acp/skills.js +0 -2
  8. package/dist/agent-connections/messaging-processor.js +0 -2
  9. package/dist/agent-connections/ownership.js +0 -2
  10. package/dist/agent-connections/registry.js +0 -2
  11. package/dist/agent-connections/session-advertisement.js +0 -2
  12. package/dist/agent-connections/signal-provider.js +0 -2
  13. package/dist/agent-connections/state-processor.js +0 -2
  14. package/dist/agent-connections/thread-state.js +0 -2
  15. package/dist/agent-connections/tools.js +0 -2
  16. package/dist/agent-connections/types.js +0 -2
  17. package/dist/agent-connections/untrusted-text.js +0 -2
  18. package/dist/agents/background-completion-events.js +0 -2
  19. package/dist/agents/background-completion.js +0 -2
  20. package/dist/agents/context-audit.js +0 -2
  21. package/dist/agents/credential-resolver.js +0 -2
  22. package/dist/agents/custom-provider-source.js +0 -2
  23. package/dist/agents/fastembed-subprocess.d.ts +21 -0
  24. package/dist/agents/fastembed-subprocess.js +88 -8
  25. package/dist/agents/instructions.js +0 -2
  26. package/dist/agents/mastracode-gateway.js +0 -2
  27. package/dist/agents/memory.js +0 -2
  28. package/dist/agents/model.js +0 -2
  29. package/dist/agents/modes/build.js +0 -2
  30. package/dist/agents/modes/explore.js +0 -2
  31. package/dist/agents/modes/plan.js +0 -2
  32. package/dist/agents/prompts/agent-instructions.js +0 -2
  33. package/dist/agents/prompts/build.js +0 -2
  34. package/dist/agents/prompts/fast.js +0 -2
  35. package/dist/agents/prompts/index.js +0 -2
  36. package/dist/agents/prompts/model.js +0 -2
  37. package/dist/agents/prompts/plan.js +0 -2
  38. package/dist/agents/prompts/tool-guidance.js +0 -2
  39. package/dist/agents/sandbox-filesystem.js +0 -2
  40. package/dist/agents/subagents/execute.js +0 -2
  41. package/dist/agents/subagents/explore.js +0 -2
  42. package/dist/agents/subagents/index.js +0 -2
  43. package/dist/agents/subagents/plan.js +0 -2
  44. package/dist/agents/thread-caveman-state.js +0 -2
  45. package/dist/agents/tool-availability.js +0 -2
  46. package/dist/agents/tools.js +0 -2
  47. package/dist/agents/workflow-builder-agent.js +0 -2
  48. package/dist/agents/workspace.js +0 -2
  49. package/dist/analytics.js +0 -2
  50. package/dist/auth/account-rotation-processor.js +0 -2
  51. package/dist/auth/account-routing-context.js +0 -2
  52. package/dist/auth/authorization-input.js +0 -2
  53. package/dist/auth/device-code.js +0 -2
  54. package/dist/auth/pkce.js +0 -2
  55. package/dist/auth/provider-auth-error.js +0 -2
  56. package/dist/auth/providers/anthropic.js +0 -2
  57. package/dist/auth/providers/github-copilot.js +0 -2
  58. package/dist/auth/providers/kimi-coding.js +0 -2
  59. package/dist/auth/providers/openai-codex.js +0 -2
  60. package/dist/auth/providers/xai.js +0 -2
  61. package/dist/auth/storage.js +0 -2
  62. package/dist/clipboard/index.js +0 -2
  63. package/dist/constants.js +0 -2
  64. package/dist/error-classification.js +0 -2
  65. package/dist/evals/context-builder.js +0 -2
  66. package/dist/evals/scorers/classify-command.js +0 -2
  67. package/dist/evals/scorers/efficiency.js +0 -2
  68. package/dist/evals/scorers/extract-tools.js +0 -2
  69. package/dist/evals/scorers/outcome.js +0 -2
  70. package/dist/experimental-agent.js +0 -2
  71. package/dist/factory/client.js +0 -2
  72. package/dist/factory/remote-controller.js +0 -2
  73. package/dist/factory/remote-session.js +0 -2
  74. package/dist/goal-manager.js +0 -2
  75. package/dist/goal-signal.js +0 -2
  76. package/dist/headless/cli.js +5 -2
  77. package/dist/headless/flags.js +0 -2
  78. package/dist/headless/format.js +0 -2
  79. package/dist/headless/policy.js +0 -2
  80. package/dist/headless/run-mc.js +0 -2
  81. package/dist/headless/types.js +0 -2
  82. package/dist/hooks/config.js +0 -2
  83. package/dist/hooks/executor.js +0 -2
  84. package/dist/hooks/manager.js +0 -2
  85. package/dist/hooks/types.js +0 -2
  86. package/dist/index.js +0 -2
  87. package/dist/ipc/ipc-reporter.js +0 -2
  88. package/dist/knowledge-inspector.js +0 -2
  89. package/dist/knowledge-scope-id.js +0 -2
  90. package/dist/knowledge-scope.js +0 -2
  91. package/dist/lsp/client.js +0 -2
  92. package/dist/lsp/language.js +0 -2
  93. package/dist/lsp/manager.js +0 -2
  94. package/dist/lsp/server.js +0 -2
  95. package/dist/lsp/workspace.js +0 -2
  96. package/dist/mcp/config.js +0 -2
  97. package/dist/mcp/manager.js +0 -2
  98. package/dist/mcp/state.js +0 -2
  99. package/dist/onboarding/custom-packs.js +0 -2
  100. package/dist/onboarding/custom-providers.js +0 -2
  101. package/dist/onboarding/om-settings.js +0 -2
  102. package/dist/onboarding/pack-activation.js +0 -2
  103. package/dist/onboarding/packs.js +0 -2
  104. package/dist/onboarding/settings.js +0 -2
  105. package/dist/permissions.js +0 -2
  106. package/dist/platform/index.js +0 -2
  107. package/dist/plugin.js +0 -2
  108. package/dist/plugins/dependencies.js +0 -2
  109. package/dist/plugins/install.js +0 -2
  110. package/dist/plugins/loader.js +0 -2
  111. package/dist/plugins/manager.js +0 -2
  112. package/dist/plugins/manifest.js +0 -2
  113. package/dist/plugins/package-link.js +0 -2
  114. package/dist/plugins/paths.js +0 -2
  115. package/dist/plugins/registry.js +0 -2
  116. package/dist/plugins/scaffold.js +0 -2
  117. package/dist/plugins/signal-lane.js +0 -2
  118. package/dist/process-memory-diagnostics.js +0 -2
  119. package/dist/processors/plan-rejection-abort.js +0 -2
  120. package/dist/providers/amazon-bedrock-gateway.js +0 -2
  121. package/dist/providers/amazon-bedrock.js +0 -2
  122. package/dist/providers/anthropic-prompt-cache.js +0 -2
  123. package/dist/providers/anthropic-thinking.js +0 -2
  124. package/dist/providers/claude-max.js +0 -2
  125. package/dist/providers/github-copilot-gateway.js +0 -2
  126. package/dist/providers/github-copilot.js +0 -2
  127. package/dist/providers/google-thinking.js +0 -2
  128. package/dist/providers/google-vertex-gateway.js +0 -2
  129. package/dist/providers/google-vertex.js +0 -2
  130. package/dist/providers/kimi-coding.js +0 -2
  131. package/dist/providers/model-ids.js +0 -2
  132. package/dist/providers/openai-codex.js +0 -2
  133. package/dist/providers/provider-thinking.js +0 -2
  134. package/dist/providers/thinking-request.js +0 -2
  135. package/dist/providers/xai.js +0 -2
  136. package/dist/schedules/interval.js +0 -2
  137. package/dist/schedules/prompt.js +0 -2
  138. package/dist/schedules/run-script.js +0 -2
  139. package/dist/schedules/scheduler.js +0 -2
  140. package/dist/schedules/tools.js +0 -2
  141. package/dist/schema.js +0 -2
  142. package/dist/theme-palette.js +0 -2
  143. package/dist/thinking-catalog.js +0 -2
  144. package/dist/thinking.js +0 -2
  145. package/dist/tool-names.js +0 -2
  146. package/dist/tools/request-sandbox-access.js +0 -2
  147. package/dist/tools/utils.js +0 -2
  148. package/dist/tools/web-search.js +0 -2
  149. package/dist/tools/workflows/create-workflow.js +0 -2
  150. package/dist/tools/workflows/delete-workflow.js +0 -2
  151. package/dist/tools/workflows/ephemeral-memory.js +0 -2
  152. package/dist/tools/workflows/extract-json-schema.js +0 -2
  153. package/dist/tools/workflows/get-workflow.js +0 -2
  154. package/dist/tools/workflows/list-available-agents.js +0 -2
  155. package/dist/tools/workflows/list-available-classifiers.js +0 -2
  156. package/dist/tools/workflows/list-available-tools.js +0 -2
  157. package/dist/tools/workflows/list-available-workflows.js +0 -2
  158. package/dist/tools/workflows/list-workflows.js +0 -2
  159. package/dist/tools/workflows/run-workflow.js +0 -2
  160. package/dist/tools/workflows/save-workflow.js +0 -2
  161. package/dist/tools/workflows/tool-ids.js +0 -2
  162. package/dist/utils/binaries.js +0 -2
  163. package/dist/utils/debug-log.js +0 -2
  164. package/dist/utils/discarding-scores-storage.js +0 -2
  165. package/dist/utils/errors.js +0 -2
  166. package/dist/utils/gateway-sync.js +0 -2
  167. package/dist/utils/local-observability.js +0 -2
  168. package/dist/utils/maintenance-lock.js +0 -2
  169. package/dist/utils/notification-dispatch.js +0 -2
  170. package/dist/utils/open-url.js +0 -2
  171. package/dist/utils/path-security.js +0 -2
  172. package/dist/utils/plan-diff.js +0 -2
  173. package/dist/utils/plans.js +0 -2
  174. package/dist/utils/project.js +0 -2
  175. package/dist/utils/prune-cli.js +0 -2
  176. package/dist/utils/signals-pubsub.js +0 -2
  177. package/dist/utils/slash-command-loader.js +0 -2
  178. package/dist/utils/slash-command-processor.js +0 -2
  179. package/dist/utils/stdin-pipe.js +0 -2
  180. package/dist/utils/storage-factory.js +0 -2
  181. package/dist/utils/storage-maintenance.js +0 -2
  182. package/dist/utils/thread-lock.js +0 -2
  183. package/dist/utils/token-estimator.js +0 -2
  184. package/dist/utils/update-check.js +0 -2
  185. package/dist/utils/wake-session.js +0 -2
  186. package/dist/voice/stt-registry.js +0 -2
  187. package/dist/voice/transcribe.js +0 -2
  188. package/dist/workflows/register-primitives.js +0 -2
  189. package/dist/workflows/service.js +0 -2
  190. package/package.json +23 -22
  191. package/dist/acp/agent.d.ts.map +0 -1
  192. package/dist/acp/agent.js.map +0 -1
  193. package/dist/acp/errors.d.ts.map +0 -1
  194. package/dist/acp/errors.js.map +0 -1
  195. package/dist/acp/event-mapper.d.ts.map +0 -1
  196. package/dist/acp/event-mapper.js.map +0 -1
  197. package/dist/acp/index.d.ts.map +0 -1
  198. package/dist/acp/index.js.map +0 -1
  199. package/dist/acp/runtime.d.ts.map +0 -1
  200. package/dist/acp/runtime.js.map +0 -1
  201. package/dist/acp/server.d.ts.map +0 -1
  202. package/dist/acp/server.js.map +0 -1
  203. package/dist/acp/skills.d.ts.map +0 -1
  204. package/dist/acp/skills.js.map +0 -1
  205. package/dist/acp.d.ts.map +0 -1
  206. package/dist/agent-connections/messaging-processor.d.ts.map +0 -1
  207. package/dist/agent-connections/messaging-processor.js.map +0 -1
  208. package/dist/agent-connections/ownership.d.ts.map +0 -1
  209. package/dist/agent-connections/ownership.js.map +0 -1
  210. package/dist/agent-connections/registry.d.ts.map +0 -1
  211. package/dist/agent-connections/registry.js.map +0 -1
  212. package/dist/agent-connections/session-advertisement.d.ts.map +0 -1
  213. package/dist/agent-connections/session-advertisement.js.map +0 -1
  214. package/dist/agent-connections/signal-provider.d.ts.map +0 -1
  215. package/dist/agent-connections/signal-provider.js.map +0 -1
  216. package/dist/agent-connections/state-processor.d.ts.map +0 -1
  217. package/dist/agent-connections/state-processor.js.map +0 -1
  218. package/dist/agent-connections/thread-state.d.ts.map +0 -1
  219. package/dist/agent-connections/thread-state.js.map +0 -1
  220. package/dist/agent-connections/tools.d.ts.map +0 -1
  221. package/dist/agent-connections/tools.js.map +0 -1
  222. package/dist/agent-connections/types.d.ts.map +0 -1
  223. package/dist/agent-connections/types.js.map +0 -1
  224. package/dist/agent-connections/untrusted-text.d.ts.map +0 -1
  225. package/dist/agent-connections/untrusted-text.js.map +0 -1
  226. package/dist/agents/background-completion-events.d.ts.map +0 -1
  227. package/dist/agents/background-completion-events.js.map +0 -1
  228. package/dist/agents/background-completion.d.ts.map +0 -1
  229. package/dist/agents/background-completion.js.map +0 -1
  230. package/dist/agents/context-audit.d.ts.map +0 -1
  231. package/dist/agents/context-audit.js.map +0 -1
  232. package/dist/agents/credential-resolver.d.ts.map +0 -1
  233. package/dist/agents/credential-resolver.js.map +0 -1
  234. package/dist/agents/custom-provider-source.d.ts.map +0 -1
  235. package/dist/agents/custom-provider-source.js.map +0 -1
  236. package/dist/agents/fastembed-subprocess.d.ts.map +0 -1
  237. package/dist/agents/fastembed-subprocess.js.map +0 -1
  238. package/dist/agents/instructions.d.ts.map +0 -1
  239. package/dist/agents/instructions.js.map +0 -1
  240. package/dist/agents/mastracode-gateway.d.ts.map +0 -1
  241. package/dist/agents/mastracode-gateway.js.map +0 -1
  242. package/dist/agents/memory.d.ts.map +0 -1
  243. package/dist/agents/memory.js.map +0 -1
  244. package/dist/agents/model.d.ts.map +0 -1
  245. package/dist/agents/model.js.map +0 -1
  246. package/dist/agents/modes/build.d.ts.map +0 -1
  247. package/dist/agents/modes/build.js.map +0 -1
  248. package/dist/agents/modes/explore.d.ts.map +0 -1
  249. package/dist/agents/modes/explore.js.map +0 -1
  250. package/dist/agents/modes/plan.d.ts.map +0 -1
  251. package/dist/agents/modes/plan.js.map +0 -1
  252. package/dist/agents/prompts/agent-instructions.d.ts.map +0 -1
  253. package/dist/agents/prompts/agent-instructions.js.map +0 -1
  254. package/dist/agents/prompts/build.d.ts.map +0 -1
  255. package/dist/agents/prompts/build.js.map +0 -1
  256. package/dist/agents/prompts/fast.d.ts.map +0 -1
  257. package/dist/agents/prompts/fast.js.map +0 -1
  258. package/dist/agents/prompts/index.d.ts.map +0 -1
  259. package/dist/agents/prompts/index.js.map +0 -1
  260. package/dist/agents/prompts/model.d.ts.map +0 -1
  261. package/dist/agents/prompts/model.js.map +0 -1
  262. package/dist/agents/prompts/plan.d.ts.map +0 -1
  263. package/dist/agents/prompts/plan.js.map +0 -1
  264. package/dist/agents/prompts/tool-guidance.d.ts.map +0 -1
  265. package/dist/agents/prompts/tool-guidance.js.map +0 -1
  266. package/dist/agents/sandbox-filesystem.d.ts.map +0 -1
  267. package/dist/agents/sandbox-filesystem.js.map +0 -1
  268. package/dist/agents/subagents/execute.d.ts.map +0 -1
  269. package/dist/agents/subagents/execute.js.map +0 -1
  270. package/dist/agents/subagents/explore.d.ts.map +0 -1
  271. package/dist/agents/subagents/explore.js.map +0 -1
  272. package/dist/agents/subagents/index.d.ts.map +0 -1
  273. package/dist/agents/subagents/index.js.map +0 -1
  274. package/dist/agents/subagents/plan.d.ts.map +0 -1
  275. package/dist/agents/subagents/plan.js.map +0 -1
  276. package/dist/agents/thread-caveman-state.d.ts.map +0 -1
  277. package/dist/agents/thread-caveman-state.js.map +0 -1
  278. package/dist/agents/tool-availability.d.ts.map +0 -1
  279. package/dist/agents/tool-availability.js.map +0 -1
  280. package/dist/agents/tools.d.ts.map +0 -1
  281. package/dist/agents/tools.js.map +0 -1
  282. package/dist/agents/workflow-builder-agent.d.ts.map +0 -1
  283. package/dist/agents/workflow-builder-agent.js.map +0 -1
  284. package/dist/agents/workspace.d.ts.map +0 -1
  285. package/dist/agents/workspace.js.map +0 -1
  286. package/dist/analytics.d.ts.map +0 -1
  287. package/dist/analytics.js.map +0 -1
  288. package/dist/auth/account-rotation-processor.d.ts.map +0 -1
  289. package/dist/auth/account-rotation-processor.js.map +0 -1
  290. package/dist/auth/account-routing-context.d.ts.map +0 -1
  291. package/dist/auth/account-routing-context.js.map +0 -1
  292. package/dist/auth/authorization-input.d.ts.map +0 -1
  293. package/dist/auth/authorization-input.js.map +0 -1
  294. package/dist/auth/device-code.d.ts.map +0 -1
  295. package/dist/auth/device-code.js.map +0 -1
  296. package/dist/auth/index.d.ts.map +0 -1
  297. package/dist/auth/pkce.d.ts.map +0 -1
  298. package/dist/auth/pkce.js.map +0 -1
  299. package/dist/auth/provider-auth-error.d.ts.map +0 -1
  300. package/dist/auth/provider-auth-error.js.map +0 -1
  301. package/dist/auth/providers/anthropic.d.ts.map +0 -1
  302. package/dist/auth/providers/anthropic.js.map +0 -1
  303. package/dist/auth/providers/github-copilot.d.ts.map +0 -1
  304. package/dist/auth/providers/github-copilot.js.map +0 -1
  305. package/dist/auth/providers/kimi-coding.d.ts.map +0 -1
  306. package/dist/auth/providers/kimi-coding.js.map +0 -1
  307. package/dist/auth/providers/openai-codex.d.ts.map +0 -1
  308. package/dist/auth/providers/openai-codex.js.map +0 -1
  309. package/dist/auth/providers/xai.d.ts.map +0 -1
  310. package/dist/auth/providers/xai.js.map +0 -1
  311. package/dist/auth/storage.d.ts.map +0 -1
  312. package/dist/auth/storage.js.map +0 -1
  313. package/dist/auth/types.d.ts.map +0 -1
  314. package/dist/clipboard/index.d.ts.map +0 -1
  315. package/dist/clipboard/index.js.map +0 -1
  316. package/dist/constants.d.ts.map +0 -1
  317. package/dist/constants.js.map +0 -1
  318. package/dist/error-classification.d.ts.map +0 -1
  319. package/dist/error-classification.js.map +0 -1
  320. package/dist/evals/context-builder.d.ts.map +0 -1
  321. package/dist/evals/context-builder.js.map +0 -1
  322. package/dist/evals/index.d.ts.map +0 -1
  323. package/dist/evals/scorers/classify-command.d.ts.map +0 -1
  324. package/dist/evals/scorers/classify-command.js.map +0 -1
  325. package/dist/evals/scorers/efficiency.d.ts.map +0 -1
  326. package/dist/evals/scorers/efficiency.js.map +0 -1
  327. package/dist/evals/scorers/extract-tools.d.ts.map +0 -1
  328. package/dist/evals/scorers/extract-tools.js.map +0 -1
  329. package/dist/evals/scorers/index.d.ts.map +0 -1
  330. package/dist/evals/scorers/outcome.d.ts.map +0 -1
  331. package/dist/evals/scorers/outcome.js.map +0 -1
  332. package/dist/experimental-agent.d.ts.map +0 -1
  333. package/dist/experimental-agent.js.map +0 -1
  334. package/dist/factory/client.d.ts.map +0 -1
  335. package/dist/factory/client.js.map +0 -1
  336. package/dist/factory/remote-controller.d.ts.map +0 -1
  337. package/dist/factory/remote-controller.js.map +0 -1
  338. package/dist/factory/remote-session.d.ts.map +0 -1
  339. package/dist/factory/remote-session.js.map +0 -1
  340. package/dist/goal-manager.d.ts.map +0 -1
  341. package/dist/goal-manager.js.map +0 -1
  342. package/dist/goal-signal.d.ts.map +0 -1
  343. package/dist/goal-signal.js.map +0 -1
  344. package/dist/headless/cli.d.ts.map +0 -1
  345. package/dist/headless/cli.js.map +0 -1
  346. package/dist/headless/flags.d.ts.map +0 -1
  347. package/dist/headless/flags.js.map +0 -1
  348. package/dist/headless/format.d.ts.map +0 -1
  349. package/dist/headless/format.js.map +0 -1
  350. package/dist/headless/index.d.ts.map +0 -1
  351. package/dist/headless/policy.d.ts.map +0 -1
  352. package/dist/headless/policy.js.map +0 -1
  353. package/dist/headless/run-mc.d.ts.map +0 -1
  354. package/dist/headless/run-mc.js.map +0 -1
  355. package/dist/headless/types.d.ts.map +0 -1
  356. package/dist/headless/types.js.map +0 -1
  357. package/dist/hooks/config.d.ts.map +0 -1
  358. package/dist/hooks/config.js.map +0 -1
  359. package/dist/hooks/executor.d.ts.map +0 -1
  360. package/dist/hooks/executor.js.map +0 -1
  361. package/dist/hooks/index.d.ts.map +0 -1
  362. package/dist/hooks/manager.d.ts.map +0 -1
  363. package/dist/hooks/manager.js.map +0 -1
  364. package/dist/hooks/types.d.ts.map +0 -1
  365. package/dist/hooks/types.js.map +0 -1
  366. package/dist/index.d.ts.map +0 -1
  367. package/dist/index.js.map +0 -1
  368. package/dist/ipc/ipc-reporter.d.ts.map +0 -1
  369. package/dist/ipc/ipc-reporter.js.map +0 -1
  370. package/dist/knowledge-inspector.d.ts.map +0 -1
  371. package/dist/knowledge-inspector.js.map +0 -1
  372. package/dist/knowledge-scope-id.d.ts.map +0 -1
  373. package/dist/knowledge-scope-id.js.map +0 -1
  374. package/dist/knowledge-scope.d.ts.map +0 -1
  375. package/dist/knowledge-scope.js.map +0 -1
  376. package/dist/lsp/client.d.ts.map +0 -1
  377. package/dist/lsp/client.js.map +0 -1
  378. package/dist/lsp/index.d.ts.map +0 -1
  379. package/dist/lsp/language.d.ts.map +0 -1
  380. package/dist/lsp/language.js.map +0 -1
  381. package/dist/lsp/manager.d.ts.map +0 -1
  382. package/dist/lsp/manager.js.map +0 -1
  383. package/dist/lsp/server.d.ts.map +0 -1
  384. package/dist/lsp/server.js.map +0 -1
  385. package/dist/lsp/workspace.d.ts.map +0 -1
  386. package/dist/lsp/workspace.js.map +0 -1
  387. package/dist/mcp/config.d.ts.map +0 -1
  388. package/dist/mcp/config.js.map +0 -1
  389. package/dist/mcp/index.d.ts.map +0 -1
  390. package/dist/mcp/manager.d.ts.map +0 -1
  391. package/dist/mcp/manager.js.map +0 -1
  392. package/dist/mcp/state.d.ts.map +0 -1
  393. package/dist/mcp/state.js.map +0 -1
  394. package/dist/mcp/types.d.ts.map +0 -1
  395. package/dist/onboarding/custom-packs.d.ts.map +0 -1
  396. package/dist/onboarding/custom-packs.js.map +0 -1
  397. package/dist/onboarding/custom-providers.d.ts.map +0 -1
  398. package/dist/onboarding/custom-providers.js.map +0 -1
  399. package/dist/onboarding/index.d.ts.map +0 -1
  400. package/dist/onboarding/om-settings.d.ts.map +0 -1
  401. package/dist/onboarding/om-settings.js.map +0 -1
  402. package/dist/onboarding/pack-activation.d.ts.map +0 -1
  403. package/dist/onboarding/pack-activation.js.map +0 -1
  404. package/dist/onboarding/packs.d.ts.map +0 -1
  405. package/dist/onboarding/packs.js.map +0 -1
  406. package/dist/onboarding/settings.d.ts.map +0 -1
  407. package/dist/onboarding/settings.js.map +0 -1
  408. package/dist/permissions.d.ts.map +0 -1
  409. package/dist/permissions.js.map +0 -1
  410. package/dist/platform/index.d.ts.map +0 -1
  411. package/dist/platform/index.js.map +0 -1
  412. package/dist/plugin.d.ts.map +0 -1
  413. package/dist/plugin.js.map +0 -1
  414. package/dist/plugins/dependencies.d.ts.map +0 -1
  415. package/dist/plugins/dependencies.js.map +0 -1
  416. package/dist/plugins/install.d.ts.map +0 -1
  417. package/dist/plugins/install.js.map +0 -1
  418. package/dist/plugins/loader.d.ts.map +0 -1
  419. package/dist/plugins/loader.js.map +0 -1
  420. package/dist/plugins/manager.d.ts.map +0 -1
  421. package/dist/plugins/manager.js.map +0 -1
  422. package/dist/plugins/manifest.d.ts.map +0 -1
  423. package/dist/plugins/manifest.js.map +0 -1
  424. package/dist/plugins/package-link.d.ts.map +0 -1
  425. package/dist/plugins/package-link.js.map +0 -1
  426. package/dist/plugins/paths.d.ts.map +0 -1
  427. package/dist/plugins/paths.js.map +0 -1
  428. package/dist/plugins/registry.d.ts.map +0 -1
  429. package/dist/plugins/registry.js.map +0 -1
  430. package/dist/plugins/scaffold.d.ts.map +0 -1
  431. package/dist/plugins/scaffold.js.map +0 -1
  432. package/dist/plugins/signal-lane.d.ts.map +0 -1
  433. package/dist/plugins/signal-lane.js.map +0 -1
  434. package/dist/plugins/types.d.ts.map +0 -1
  435. package/dist/process-memory-diagnostics.d.ts.map +0 -1
  436. package/dist/process-memory-diagnostics.js.map +0 -1
  437. package/dist/processors/plan-rejection-abort.d.ts.map +0 -1
  438. package/dist/processors/plan-rejection-abort.js.map +0 -1
  439. package/dist/providers/amazon-bedrock-gateway.d.ts.map +0 -1
  440. package/dist/providers/amazon-bedrock-gateway.js.map +0 -1
  441. package/dist/providers/amazon-bedrock.d.ts.map +0 -1
  442. package/dist/providers/amazon-bedrock.js.map +0 -1
  443. package/dist/providers/anthropic-prompt-cache.d.ts.map +0 -1
  444. package/dist/providers/anthropic-prompt-cache.js.map +0 -1
  445. package/dist/providers/anthropic-thinking.d.ts.map +0 -1
  446. package/dist/providers/anthropic-thinking.js.map +0 -1
  447. package/dist/providers/claude-max.d.ts.map +0 -1
  448. package/dist/providers/claude-max.js.map +0 -1
  449. package/dist/providers/github-copilot-gateway.d.ts.map +0 -1
  450. package/dist/providers/github-copilot-gateway.js.map +0 -1
  451. package/dist/providers/github-copilot.d.ts.map +0 -1
  452. package/dist/providers/github-copilot.js.map +0 -1
  453. package/dist/providers/google-thinking.d.ts.map +0 -1
  454. package/dist/providers/google-thinking.js.map +0 -1
  455. package/dist/providers/google-vertex-gateway.d.ts.map +0 -1
  456. package/dist/providers/google-vertex-gateway.js.map +0 -1
  457. package/dist/providers/google-vertex.d.ts.map +0 -1
  458. package/dist/providers/google-vertex.js.map +0 -1
  459. package/dist/providers/kimi-coding.d.ts.map +0 -1
  460. package/dist/providers/kimi-coding.js.map +0 -1
  461. package/dist/providers/model-ids.d.ts.map +0 -1
  462. package/dist/providers/model-ids.js.map +0 -1
  463. package/dist/providers/openai-codex.d.ts.map +0 -1
  464. package/dist/providers/openai-codex.js.map +0 -1
  465. package/dist/providers/provider-thinking.d.ts.map +0 -1
  466. package/dist/providers/provider-thinking.js.map +0 -1
  467. package/dist/providers/thinking-request.d.ts.map +0 -1
  468. package/dist/providers/thinking-request.js.map +0 -1
  469. package/dist/providers/xai.d.ts.map +0 -1
  470. package/dist/providers/xai.js.map +0 -1
  471. package/dist/schedules/index.d.ts.map +0 -1
  472. package/dist/schedules/interval.d.ts.map +0 -1
  473. package/dist/schedules/interval.js.map +0 -1
  474. package/dist/schedules/prompt.d.ts.map +0 -1
  475. package/dist/schedules/prompt.js.map +0 -1
  476. package/dist/schedules/run-script.d.ts.map +0 -1
  477. package/dist/schedules/run-script.js.map +0 -1
  478. package/dist/schedules/scheduler.d.ts.map +0 -1
  479. package/dist/schedules/scheduler.js.map +0 -1
  480. package/dist/schedules/tools.d.ts.map +0 -1
  481. package/dist/schedules/tools.js.map +0 -1
  482. package/dist/schema.d.ts.map +0 -1
  483. package/dist/schema.js.map +0 -1
  484. package/dist/theme-palette.d.ts.map +0 -1
  485. package/dist/theme-palette.js.map +0 -1
  486. package/dist/thinking-catalog.d.ts.map +0 -1
  487. package/dist/thinking-catalog.js.map +0 -1
  488. package/dist/thinking.d.ts.map +0 -1
  489. package/dist/thinking.js.map +0 -1
  490. package/dist/tool-names.d.ts.map +0 -1
  491. package/dist/tool-names.js.map +0 -1
  492. package/dist/tools/index.d.ts.map +0 -1
  493. package/dist/tools/request-sandbox-access.d.ts.map +0 -1
  494. package/dist/tools/request-sandbox-access.js.map +0 -1
  495. package/dist/tools/utils.d.ts.map +0 -1
  496. package/dist/tools/utils.js.map +0 -1
  497. package/dist/tools/web-search.d.ts.map +0 -1
  498. package/dist/tools/web-search.js.map +0 -1
  499. package/dist/tools/workflows/create-workflow.d.ts.map +0 -1
  500. package/dist/tools/workflows/create-workflow.js.map +0 -1
  501. package/dist/tools/workflows/delete-workflow.d.ts.map +0 -1
  502. package/dist/tools/workflows/delete-workflow.js.map +0 -1
  503. package/dist/tools/workflows/ephemeral-memory.d.ts.map +0 -1
  504. package/dist/tools/workflows/ephemeral-memory.js.map +0 -1
  505. package/dist/tools/workflows/extract-json-schema.d.ts.map +0 -1
  506. package/dist/tools/workflows/extract-json-schema.js.map +0 -1
  507. package/dist/tools/workflows/get-workflow.d.ts.map +0 -1
  508. package/dist/tools/workflows/get-workflow.js.map +0 -1
  509. package/dist/tools/workflows/list-available-agents.d.ts.map +0 -1
  510. package/dist/tools/workflows/list-available-agents.js.map +0 -1
  511. package/dist/tools/workflows/list-available-classifiers.d.ts.map +0 -1
  512. package/dist/tools/workflows/list-available-classifiers.js.map +0 -1
  513. package/dist/tools/workflows/list-available-tools.d.ts.map +0 -1
  514. package/dist/tools/workflows/list-available-tools.js.map +0 -1
  515. package/dist/tools/workflows/list-available-workflows.d.ts.map +0 -1
  516. package/dist/tools/workflows/list-available-workflows.js.map +0 -1
  517. package/dist/tools/workflows/list-workflows.d.ts.map +0 -1
  518. package/dist/tools/workflows/list-workflows.js.map +0 -1
  519. package/dist/tools/workflows/run-workflow.d.ts.map +0 -1
  520. package/dist/tools/workflows/run-workflow.js.map +0 -1
  521. package/dist/tools/workflows/save-workflow.d.ts.map +0 -1
  522. package/dist/tools/workflows/save-workflow.js.map +0 -1
  523. package/dist/tools/workflows/tool-ids.d.ts.map +0 -1
  524. package/dist/tools/workflows/tool-ids.js.map +0 -1
  525. package/dist/utils/binaries.d.ts.map +0 -1
  526. package/dist/utils/binaries.js.map +0 -1
  527. package/dist/utils/debug-log.d.ts.map +0 -1
  528. package/dist/utils/debug-log.js.map +0 -1
  529. package/dist/utils/discarding-scores-storage.d.ts.map +0 -1
  530. package/dist/utils/discarding-scores-storage.js.map +0 -1
  531. package/dist/utils/errors.d.ts.map +0 -1
  532. package/dist/utils/errors.js.map +0 -1
  533. package/dist/utils/gateway-sync.d.ts.map +0 -1
  534. package/dist/utils/gateway-sync.js.map +0 -1
  535. package/dist/utils/local-observability.d.ts.map +0 -1
  536. package/dist/utils/local-observability.js.map +0 -1
  537. package/dist/utils/maintenance-lock.d.ts.map +0 -1
  538. package/dist/utils/maintenance-lock.js.map +0 -1
  539. package/dist/utils/notification-dispatch.d.ts.map +0 -1
  540. package/dist/utils/notification-dispatch.js.map +0 -1
  541. package/dist/utils/open-url.d.ts.map +0 -1
  542. package/dist/utils/open-url.js.map +0 -1
  543. package/dist/utils/path-security.d.ts.map +0 -1
  544. package/dist/utils/path-security.js.map +0 -1
  545. package/dist/utils/plan-diff.d.ts.map +0 -1
  546. package/dist/utils/plan-diff.js.map +0 -1
  547. package/dist/utils/plans.d.ts.map +0 -1
  548. package/dist/utils/plans.js.map +0 -1
  549. package/dist/utils/project.d.ts.map +0 -1
  550. package/dist/utils/project.js.map +0 -1
  551. package/dist/utils/prune-cli.d.ts.map +0 -1
  552. package/dist/utils/prune-cli.js.map +0 -1
  553. package/dist/utils/signals-pubsub.d.ts.map +0 -1
  554. package/dist/utils/signals-pubsub.js.map +0 -1
  555. package/dist/utils/slash-command-loader.d.ts.map +0 -1
  556. package/dist/utils/slash-command-loader.js.map +0 -1
  557. package/dist/utils/slash-command-processor.d.ts.map +0 -1
  558. package/dist/utils/slash-command-processor.js.map +0 -1
  559. package/dist/utils/stdin-pipe.d.ts.map +0 -1
  560. package/dist/utils/stdin-pipe.js.map +0 -1
  561. package/dist/utils/storage-factory.d.ts.map +0 -1
  562. package/dist/utils/storage-factory.js.map +0 -1
  563. package/dist/utils/storage-maintenance.d.ts.map +0 -1
  564. package/dist/utils/storage-maintenance.js.map +0 -1
  565. package/dist/utils/thread-lock.d.ts.map +0 -1
  566. package/dist/utils/thread-lock.js.map +0 -1
  567. package/dist/utils/token-estimator.d.ts.map +0 -1
  568. package/dist/utils/token-estimator.js.map +0 -1
  569. package/dist/utils/update-check.d.ts.map +0 -1
  570. package/dist/utils/update-check.js.map +0 -1
  571. package/dist/utils/wake-session.d.ts.map +0 -1
  572. package/dist/utils/wake-session.js.map +0 -1
  573. package/dist/voice/stt-registry.d.ts.map +0 -1
  574. package/dist/voice/stt-registry.js.map +0 -1
  575. package/dist/voice/transcribe.d.ts.map +0 -1
  576. package/dist/voice/transcribe.js.map +0 -1
  577. package/dist/workflows/register-primitives.d.ts.map +0 -1
  578. package/dist/workflows/register-primitives.js.map +0 -1
  579. package/dist/workflows/service.d.ts.map +0 -1
  580. package/dist/workflows/service.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"sandbox-filesystem.d.ts","sourceRoot":"","sources":["../../src/agents/sandbox-filesystem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,QAAQ,EAER,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,cAAc,EACd,WAAW,EACX,aAAa,EACb,SAAS,EACT,WAAW,EACX,mBAAmB,EACnB,YAAY,EACb,MAAM,wBAAwB,CAAC;AAqBhC,iDAAiD;AACjD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,mBAAmB,CAAC;IAC1C,cAAc,CACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,uCAAuC;IACvC,OAAO,EAAE,WAAW,CAAC;IACrB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IACnD,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B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CAAmC;IAErD,OAAO,CAAC,WAAW;YAoBL,eAAe;IAgC7B,OAAO,CAAC,gBAAgB;IA4BxB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAA+C;IAEtF;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAyC;IAEjF,wGAAwG;IACxG,OAAO,CAAC,MAAM,CAAC,SAAS;IAkBxB;;;;;;;;;OASG;YACW,eAAe;YAqFf,iBAAiB;IAoD/B,OAAO,CAAC,aAAa;IAgBf,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAM3C;IAEK,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6C1C;IAIK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1B;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAE7B;IAEK,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAGhC;IAED,OAAO,IAAI,cAAc,CAQxB;IAED,eAAe,IAAI,MAAM,CAExB;CACF"}
@@ -1 +0,0 @@
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 * When the sandbox exposes its own `filesystem`, file operations use it\n * instead, which takes one round trip rather than several commands; grep and\n * walks still run as shell commands.\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 FilesystemGrepMatch,\n FilesystemGrepOptions,\n FilesystemGrepResult,\n FilesystemInfo,\n ListOptions,\n ProviderStatus,\n ReadOptions,\n RemoveOptions,\n WalkEntry,\n WalkOptions,\n WorkspaceFilesystem,\n WriteOptions,\n} from '@mastra/core/workspace';\nimport {\n DirectoryNotFoundError,\n FileExistsError,\n FileNotFoundError,\n getMimeType,\n IsDirectoryError,\n LocalFilesystem,\n NotDirectoryError,\n UnsupportedGrepPatternError,\n} 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;\nconst EXIT_NOT_DIRECTORY = 23;\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 /**\n * The sandbox's own file API, when it has one (`WorkspaceSandbox.filesystem`).\n * File operations go through it instead of shell commands.\n */\n readonly filesystem?: WorkspaceFilesystem;\n executeCommand(\n command: string,\n args?: string[],\n options?: { timeout?: number; maxRetainedBytes?: number },\n ): Promise<SandboxCommandResult>;\n}\n\nexport interface SandboxFilesystemOptions {\n /** Live sandbox to run commands in. */\n sandbox: SandboxExec;\n /**\n * Absolute path inside the sandbox that is the workspace root — or a lazy\n * resolver for it. The resolver form exists for sandboxes whose workspace\n * root is only knowable once the VM is running (e.g. `$HOME/<repo>` under\n * a provider-chosen home dir): it is awaited on the first file operation\n * (which itself may lazily start the VM) and the result is memoized.\n */\n workdir: string | (() => Promise<string> | string);\n /** Optional stable id; defaults to a sandbox-derived id. */\n id?: string;\n /**\n * Check that symlinks don't lead outside the workdir when using the\n * sandbox's native filesystem. Off by default: native file APIs follow\n * symlinks, and inside a sandbox the agent can read anything with a command\n * anyway. Turn it on when files are served to someone other than the agent.\n *\n * Each path is checked once per instance, so keep such instances\n * short-lived. Without a native filesystem the shell path always checks.\n */\n verifySymlinks?: boolean;\n /**\n * Additional file extensions to treat as text, extending (not replacing) the\n * built-in set. Affects which files tools like `grep` will search. Values are\n * normalized like `LocalFilesystem`'s option, so `'sas'`, `'.sas'` and\n * `'.SAS'` are equivalent.\n */\n textExtensions?: string[];\n}\n\ntype ContainmentCheck = 'target' | 'dest' | 'parent';\n\n/** Default per-command deadline so a hung sandbox can't block file tools forever. */\nconst COMMAND_TIMEOUT_MS = 30_000;\n\n/**\n * Explain why a native grep command failed so callers can tell a timeout or\n * broken toolchain apart from a pattern the engine cannot express.\n */\nfunction describeGrepFailure(result: SandboxCommandResult): string {\n if (result.exitCode === 124) return `timed out after ${COMMAND_TIMEOUT_MS / 1000}s`;\n const stderrLine = result.stderr\n .split('\\n')\n .map(line => line.trim())\n .find(Boolean);\n const detail = stderrLine ? `: ${stderrLine.length > 200 ? `${stderrLine.slice(0, 200)}…` : stderrLine}` : '';\n return `exit code ${result.exitCode}${detail}`;\n}\n\n/** Single-quote a string for safe POSIX shell interpolation. */\nfunction shellQuote(value: string): string {\n return `'${value.replace(/'/g, `'\\\\''`)}'`;\n}\n\ninterface SearchTools {\n rg: boolean;\n gnuGrep: boolean;\n git: boolean;\n /** `grep -P` works, and so does `git grep -P` when git is present. */\n pcre: boolean;\n}\n\n/** One command that reports which search tools the sandbox has, one name per line. */\nconst SEARCH_TOOLS_PROBE =\n 'command -v rg >/dev/null 2>&1 && echo rg; ' +\n \"grep --version 2>/dev/null | head -n 1 | grep -q 'GNU grep' && echo gnu-grep; \" +\n \"printf 'a1\\\\n' | grep -qP '\\\\d(?=)' 2>/dev/null && echo grep-pcre; \" +\n 'if command -v git >/dev/null 2>&1; then echo git; ' +\n // git can be built without PCRE; check it on a throwaway repository.\n 'd=$(mktemp -d 2>/dev/null) && { ' +\n \"(cd \\\"$d\\\" && git init -q && printf 'a1\\\\n' >f && git grep -q --untracked -P -e '\\\\d(?=)') >/dev/null 2>&1 && echo git-pcre; \" +\n 'rm -rf \"$d\"; }; fi; true';\n\nfunction isInsideNodeModules(path: string): boolean {\n return path.split('/').includes('node_modules');\n}\n\n/** Lines a grep engine printed for one file: matches plus surrounding context. */\ninterface GrepFileLines {\n matches: FilesystemGrepMatch[];\n linesByNumber: Map<number, string>;\n}\n\nfunction fileLines(files: Map<string, GrepFileLines>, filePath: string): GrepFileLines {\n let state = files.get(filePath);\n if (!state) {\n state = { matches: [], linesByNumber: new Map() };\n files.set(filePath, state);\n }\n return state;\n}\n\n/** Turn per-file lines into results relative to `abs`, attaching before/after context. */\nfunction toGrepResults(files: Map<string, GrepFileLines>, abs: string, contextLines: number): FilesystemGrepResult[] {\n const results: FilesystemGrepResult[] = [];\n for (const [filePath, state] of files) {\n if (state.matches.length === 0) continue;\n const rel = posixPath.relative(abs, filePath) || posixPath.basename(filePath);\n const matches = state.matches.map(match => {\n if (contextLines <= 0) return match;\n const before: string[] = [];\n for (let n = match.line - 1; n >= Math.max(1, match.line - contextLines); n--) {\n const text = state.linesByNumber.get(n);\n if (text === undefined) break;\n before.unshift(text);\n }\n const after: string[] = [];\n for (let n = match.line + 1; n <= match.line + contextLines; n++) {\n const text = state.linesByNumber.get(n);\n if (text === undefined) break;\n after.push(text);\n }\n return { ...match, before, after };\n });\n results.push({ path: rel, matches });\n }\n return results;\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 status: ProviderStatus = 'ready';\n\n private readonly sandbox: SandboxExec;\n private readonly workdirSource: string | (() => Promise<string> | string);\n private resolvedBase?: string;\n private resolvingBase?: Promise<string>;\n private readonly verifySymlinks: boolean;\n /**\n * Classifies file names as text: the built-in extensions plus\n * `textExtensions`, normalized exactly as `LocalFilesystem` does. Only its\n * `isTextFile` is ever called; it never touches a file.\n */\n private readonly textClassifier: LocalFilesystem;\n /** `check:absolutePath` keys that passed while the entry existed. */\n private readonly verified = new Set<string>();\n\n constructor(options: SandboxFilesystemOptions) {\n this.sandbox = options.sandbox;\n this.workdirSource = options.workdir;\n this.verifySymlinks = options.verifySymlinks ?? false;\n this.textClassifier = new LocalFilesystem({ basePath: '/', textExtensions: options.textExtensions });\n if (typeof options.workdir === 'string') this.resolvedBase = options.workdir;\n // Include the workdir when known: one sandbox can back several\n // filesystems rooted at different checkouts, and each needs a distinct\n // id. Lazy-workdir callers pass an explicit id.\n this.id =\n options.id ??\n (typeof options.workdir === 'string'\n ? `sandbox-fs:${options.sandbox.id}:${options.workdir}`\n : `sandbox-fs:${options.sandbox.id}`);\n }\n\n /** The resolved workspace root; empty until a lazy workdir first resolves. */\n get basePath(): string {\n return this.resolvedBase ?? '';\n }\n\n /**\n * The sandbox directory shell commands default to: the same root file paths\n * resolve against, so a relative path means the same thing to a shell command\n * and to a file tool. Non-empty whenever the workspace root is known.\n */\n async getCommandCwd(): Promise<string | undefined> {\n return (await this.base()) || undefined;\n }\n\n /**\n * Whether tools like `grep` should treat a file as text: the built-in text\n * extensions plus any `textExtensions` passed to the constructor.\n */\n isTextFile(filename: string): boolean {\n return this.textClassifier.isTextFile(filename);\n }\n\n /** Await (and memoize) the workspace root, resolving a lazy workdir once. */\n private async base(): Promise<string> {\n if (this.resolvedBase) return this.resolvedBase;\n const source = this.workdirSource;\n if (typeof source === 'string') return (this.resolvedBase = source);\n this.resolvingBase ??= Promise.resolve()\n .then(source)\n .then(resolved => {\n if (!resolved) throw new Error('Sandbox workspace root resolution returned an empty path');\n return (this.resolvedBase = resolved);\n })\n .finally(() => {\n this.resolvingBase = undefined;\n });\n return this.resolvingBase;\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. Awaits the workspace root first, which\n * for a lazy workdir may start the VM.\n */\n private async resolveAsync(inputPath: string): Promise<string> {\n return this.resolveAgainst(await this.base(), inputPath);\n }\n\n /**\n * Resolve a workspace path against a known base, enforcing that it stays\n * 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 resolveAgainst(basePath: string, inputPath: string): string {\n const base = posixPath.normalize(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(base, rel));\n if (resolved !== base && !resolved.startsWith(`${base}/`)) {\n throw new Error(`Path escapes workspace root: ${inputPath}`);\n }\n return resolved;\n }\n\n /**\n * A miss on an absolute path outside the workdir (e.g. `/tmp/x/a.ts`) that\n * does exist at that real sandbox path: the agent meant the sandbox path,\n * but it was remapped under the workdir. Explain that instead of a bare\n * not-found. Undefined when the path is inside the workdir or doesn't exist.\n */\n private async outsideWorkdirNotFound(inputPath: string, abs: string): Promise<FileNotFoundError | undefined> {\n const base = posixPath.normalize(this.basePath);\n const normalized = posixPath.normalize(inputPath);\n if (!inputPath.startsWith('/') || normalized === base || normalized.startsWith(`${base}/`)) return undefined;\n const probe = await this.exec(`test -e ${shellQuote(normalized)}`).catch(() => undefined);\n if (probe?.exitCode !== 0) return undefined;\n const error = new FileNotFoundError(inputPath);\n error.message = `File not found: ${inputPath} (resolved to ${abs}). File tools only reach files under ${base}; absolute paths are workspace-relative. Put scratch worktrees under ${base}/.worktrees/.`;\n return error;\n }\n\n resolveAbsolutePath(inputPath: string): string | undefined {\n // Sync interface: a lazy workdir that has not resolved yet has no\n // absolute form to offer.\n if (!this.resolvedBase) return undefined;\n return this.resolveAgainst(this.resolvedBase, inputPath);\n }\n\n // ── Command helper ─────────────────────────────────────────────────────\n\n private async exec(script: string): Promise<SandboxCommandResult> {\n // File reads come back as base64 on stdout and listings/grep are parsed\n // line by line, so dropping the oldest output would corrupt results.\n return this.sandbox.executeCommand('sh', ['-c', script], {\n timeout: COMMAND_TIMEOUT_MS,\n maxRetainedBytes: Infinity,\n });\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<boolean> {\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 false;\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 return true;\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<boolean> {\n // First check the target itself (covers overwriting an existing symlink).\n const exists = 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 return exists;\n }\n\n /**\n * Before a native filesystem call, run the containment check the shell path\n * runs for that operation, when `verifySymlinks` is on. A pass is remembered\n * only for an entry that exists: a missing path may later appear as a\n * symlink that leads outside the workdir.\n */\n private async verifyNative(check: ContainmentCheck, abs: string, inputPath: string): Promise<void> {\n if (!this.verifySymlinks) return;\n const key = `${check}:${abs}`;\n if (this.verified.has(key)) return;\n const existed =\n check === 'dest'\n ? await this.assertContainedDest(abs, inputPath)\n : await this.assertContainedRealpath(check === 'parent' ? posixPath.dirname(abs) : abs, inputPath);\n if (existed) this.verified.add(key);\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('target', abs, path);\n try {\n return await native.readFile(abs, options);\n } catch (error) {\n const isNotFound = error instanceof FileNotFoundError || (error as { code?: unknown })?.code === 'ENOENT';\n throw (isNotFound && (await this.outsideWorkdirNotFound(path, abs))) || error;\n }\n }\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) {\n throw (await this.outsideWorkdirNotFound(path, abs)) ?? new FileNotFoundError(path);\n }\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('dest', abs, path);\n return native.writeFile(abs, content, options);\n }\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('dest', abs, path);\n return native.appendFile(abs, content);\n }\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('parent', abs, path);\n return native.deleteFile(abs, options);\n }\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 = await this.resolveAsync(src);\n const destAbs = await this.resolveAsync(dest);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('target', srcAbs, src);\n await this.verifyNative('dest', destAbs, dest);\n return native.copyFile(srcAbs, destAbs, options);\n }\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 = await this.resolveAsync(src);\n const destAbs = await this.resolveAsync(dest);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('target', srcAbs, src);\n await this.verifyNative('dest', destAbs, dest);\n return native.moveFile(srcAbs, destAbs, options);\n }\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('dest', abs, path);\n return native.mkdir(abs, options);\n }\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('parent', abs, path);\n return native.rmdir(abs, options);\n }\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('target', abs, path);\n return native.readdir(abs, options);\n }\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 // ── Native walk / grep capabilities ────────────────────────────────────\n\n /**\n * Walk the tree in a single sandbox command instead of one readdir round\n * trip per directory. Uses `find` with a portable classification loop\n * (`find -printf` is GNU-only and fails on macOS/BSD hosts). `find` does\n * not follow symlinked directories by default, matching the host-side\n * walker's no-recursion-into-symlinks behavior.\n */\n async walk(path: string, options?: WalkOptions): Promise<WalkEntry[]> {\n const abs = await this.resolveAsync(path);\n await this.assertContainedRealpath(abs, path);\n const maxDepth =\n options?.maxDepth !== undefined && Number.isFinite(options.maxDepth)\n ? `-maxdepth ${Math.max(0, Math.floor(options.maxDepth))} `\n : '';\n // Prune hidden entries in-sandbox when not requested, so a huge hidden\n // tree (e.g. `.git`) doesn't inflate the response. `.gitignore` files\n // still come back when the caller applies them.\n const keepGitignore = options?.includeGitignoreFiles ? `! \\\\( -type f -name .gitignore \\\\) ` : '';\n const hiddenPrune = options?.includeHidden ? '' : `\\\\( -name '.*' ${keepGitignore}\\\\) -prune -o `;\n // Skip directories like node_modules entirely instead of listing them\n // only for the caller to filter them out.\n const skipNames = options?.skipDirectoryNames?.filter(Boolean) ?? [];\n const skipPrune = skipNames.length\n ? `\\\\( -type d \\\\( ${skipNames.map(name => `-name ${shellQuote(name)}`).join(' -o ')} \\\\) \\\\) -prune -o `\n : '';\n // Emit \"flag\\tpath[\\ttarget]\" — flag is d/f for regular entries, D/F for\n // symlinks (with the link target as a third field).\n const script =\n `root=${shellQuote(abs)}\\n` +\n `[ -e \"$root\" ] || [ -L \"$root\" ] || exit ${EXIT_NOT_FOUND}\\n` +\n `[ -d \"$root\" ] || exit ${EXIT_NOT_DIRECTORY}\\n` +\n `find \"$root\" -mindepth 1 ${maxDepth}${hiddenPrune}${skipPrune}-print 2>/dev/null | while IFS= read -r f; do ` +\n `if [ -L \"$f\" ]; then if [ -d \"$f\" ]; then t=D; else t=F; fi; printf '%s\\\\t%s\\\\t%s\\\\n' \"$t\" \"$f\" \"$(readlink \"$f\")\"; ` +\n `elif [ -d \"$f\" ]; then printf 'd\\\\t%s\\\\n' \"$f\"; else printf 'f\\\\t%s\\\\n' \"$f\"; fi; done`;\n const result = await this.exec(script);\n if (result.exitCode === EXIT_NOT_FOUND) throw new DirectoryNotFoundError(path);\n if (result.exitCode === EXIT_NOT_DIRECTORY) throw new NotDirectoryError(path);\n if (result.exitCode !== 0) {\n throw new Error(`walk ${path} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);\n }\n const entries: WalkEntry[] = [];\n for (const line of result.stdout.split('\\n')) {\n if (!line) continue;\n const tab = line.indexOf('\\t');\n if (tab < 0) continue;\n const flag = line.slice(0, tab);\n const isSymlink = flag === 'D' || flag === 'F';\n let fullPath = line.slice(tab + 1);\n let symlinkTarget: string | undefined;\n if (isSymlink) {\n const tab2 = fullPath.lastIndexOf('\\t');\n if (tab2 >= 0) {\n symlinkTarget = fullPath.slice(tab2 + 1) || undefined;\n fullPath = fullPath.slice(0, tab2);\n }\n }\n const rel = posixPath.relative(abs, fullPath);\n if (!rel || rel.startsWith('..')) continue;\n entries.push({\n name: posixPath.basename(rel),\n type: flag === 'd' || flag === 'D' ? 'directory' : 'file',\n ...(isSymlink ? { isSymlink: true, ...(symlinkTarget ? { symlinkTarget } : {}) } : {}),\n path: rel,\n });\n }\n return entries;\n }\n\n /**\n * Content search executed inside the sandbox in one command, using the best\n * engine the sandbox has: ripgrep, then GNU grep (with git choosing files\n * inside repositories), then POSIX `grep -rnE`. Patterns the grep engines\n * can't express (PCRE-style classes, word boundaries, lookarounds,\n * non-greedy quantifiers) throw {@link UnsupportedGrepPatternError} so\n * callers use their host-side walk.\n *\n * ripgrep and GNU grep apply every `.gitignore` in the tree, relative to the\n * directory that holds it, and skip `node_modules` unless the search path\n * is inside one. Callers still apply their own hidden/glob filtering.\n */\n async grep(options: FilesystemGrepOptions): Promise<FilesystemGrepResult[]> {\n const abs = await this.resolveAsync(options.path);\n await this.assertContainedRealpath(abs, options.path);\n const tools = await this.searchTools();\n if (tools.rg) return this.grepWithRipgrep(abs, options);\n if (tools.gnuGrep) return this.grepWithGnuGrep(abs, options, tools);\n return this.grepWithPosixGrep(abs, options);\n }\n\n private toolsCheck: Promise<SearchTools> | undefined;\n\n private searchTools(): Promise<SearchTools> {\n const check = (this.toolsCheck ??= this.exec(SEARCH_TOOLS_PROBE).then(result => {\n if (result.exitCode !== 0) throw new Error(`search tool probe exited with ${result.exitCode}`);\n const found = new Set(result.stdout.split('\\n').map(line => line.trim()));\n const git = found.has('git');\n return {\n rg: found.has('rg'),\n gnuGrep: found.has('gnu-grep'),\n git,\n pcre: found.has('grep-pcre') && (!git || found.has('git-pcre')),\n };\n }));\n // Only a successful probe is cached; a failed one (e.g. the sandbox wasn't\n // ready) is retried on the next search instead of pinning the slow path.\n return check.catch(() => {\n if (this.toolsCheck === check) this.toolsCheck = undefined;\n return { rg: false, gnuGrep: false, git: false, pcre: false };\n });\n }\n\n private async grepWithRipgrep(abs: string, options: FilesystemGrepOptions): Promise<FilesystemGrepResult[]> {\n const args = [\n // --no-require-git applies .gitignore files outside a git checkout too\n // (e.g. a multi-repo root). A path passed explicitly is searched even\n // when ignored, so targeting `dist/` or `node_modules/x` still works.\n 'rg --json --hidden --no-require-git',\n // .git is filtered host-side too; exclude it here so its object files\n // don't inflate the response.\n `-g ${shellQuote('!.git/**')}`,\n isInsideNodeModules(abs) ? '' : `-g ${shellQuote('!**/node_modules/**')}`,\n options.caseSensitive ? '' : '-i',\n options.maxCountPerFile !== undefined ? `-m ${Math.max(1, Math.floor(options.maxCountPerFile))}` : '',\n options.contextLines ? `-C ${Math.max(0, Math.floor(options.contextLines))}` : '',\n `-e ${shellQuote(options.pattern)}`,\n shellQuote(abs),\n ]\n .filter(Boolean)\n .join(' ');\n const result = await this.exec(args);\n // rg exits 1 when there are no matches, 2 on any error. A bad pattern\n // produces no output at all, but a per-file error (e.g. an unreadable\n // file) also yields exit 2 while still emitting matches for every other\n // file. Keep those partial results; only treat \"error with no matches\"\n // as an unsupported pattern so the caller falls back to the host walk.\n if (result.exitCode === 1) return [];\n const results = this.parseRipgrepJson(result.stdout, abs, options);\n if (result.exitCode !== 0 && results.length === 0) {\n throw new UnsupportedGrepPatternError(options.pattern, describeGrepFailure(result));\n }\n return results;\n }\n\n private parseRipgrepJson(stdout: string, abs: string, options: FilesystemGrepOptions): FilesystemGrepResult[] {\n const files = new Map<string, GrepFileLines>();\n for (const line of stdout.split('\\n')) {\n if (!line) continue;\n let event: any;\n try {\n event = JSON.parse(line);\n } catch {\n continue;\n }\n if (event.type !== 'match' && event.type !== 'context') continue;\n const filePath: string | undefined = event.data?.path?.text;\n const lineNumber: number | undefined = event.data?.line_number;\n if (!filePath || !lineNumber) continue;\n const state = fileLines(files, filePath);\n const text: string = (event.data?.lines?.text ?? '').replace(/\\r?\\n$/, '');\n state.linesByNumber.set(lineNumber, text);\n if (event.type === 'match') {\n // rg submatch offsets are byte offsets into the line; convert to a\n // UTF-16 (JS string) index for the capability contract.\n const byteStart: number = event.data?.submatches?.[0]?.start ?? 0;\n const column = Buffer.from(text, 'utf8').subarray(0, byteStart).toString('utf8').length;\n state.matches.push({ line: lineNumber, column, text });\n }\n }\n return this.applyTotalCap(toGrepResults(files, abs, options.contextLines ?? 0), options.maxTotalMatches);\n }\n\n /**\n * Patterns whose meaning differs between POSIX ERE and JS RegExp. The grep\n * runs with ERE but match columns are recomputed with JS, so anything that\n * only one side understands (PCRE classes, lookarounds, lazy quantifiers,\n * POSIX bracket classes, GNU word anchors) must fall back to the host walk.\n */\n private static readonly ERE_UNSUPPORTED = /\\\\[dDwWsSbB<>]|\\(\\?|[*+?}]\\?|\\[:[a-z]+:\\]/;\n\n /**\n * Escapes that `grep -P` (PCRE) and JS RegExp (without the `u` flag) both\n * accept but read differently, e.g. `\\A` is \"start of subject\" in PCRE and\n * a literal `A` in JS, plus POSIX bracket classes. PCRE-only syntax that JS\n * rejects (inline flags, possessive quantifiers, atomic groups) already\n * fails the JS compile below.\n */\n private static readonly PCRE_UNSUPPORTED = /\\\\[AzZGKQEhHvVRXNCpPe]|\\[:[a-z]+:\\]/;\n\n /** Reject patterns grep can't run with the same meaning as JS; return the JS regex used for columns. */\n private static grepRegex(options: FilesystemGrepOptions, pcre = false): RegExp {\n if (\n pcre\n ? SandboxFilesystem.PCRE_UNSUPPORTED.test(options.pattern)\n : SandboxFilesystem.ERE_UNSUPPORTED.test(options.pattern)\n ) {\n throw new UnsupportedGrepPatternError(\n options.pattern,\n pcre ? 'grep -P reads this syntax differently from JavaScript' : 'POSIX ERE cannot express this syntax',\n );\n }\n try {\n return new RegExp(options.pattern, options.caseSensitive ? '' : 'i');\n } catch {\n throw new UnsupportedGrepPatternError(options.pattern, 'invalid regular expression');\n }\n }\n\n /**\n * GNU grep without ripgrep. Inside a git checkout, `git grep` picks the\n * files (tracked plus untracked, every `.gitignore` applied) and GNU grep\n * prints them with context. Outside a checkout (e.g. a multi-repo root),\n * each child repository is searched the same way and plain grep covers the\n * remaining files, skipping `node_modules`. `--null` ends each file name\n * with NUL, so match (`N:`) and context (`N-`) lines parse unambiguously.\n * When grep and git support it, patterns run as PCRE (`-P`), so `\\d`,\n * `\\w`, `\\s`, `\\b`, and lookarounds don't need the host walk.\n */\n private async grepWithGnuGrep(\n abs: string,\n options: FilesystemGrepOptions,\n tools: SearchTools,\n ): Promise<FilesystemGrepResult[]> {\n const hasGit = tools.git;\n const mode = tools.pcre ? '-P' : '-E';\n const jsRegex = SandboxFilesystem.grepRegex(options, tools.pcre);\n const contextLines = Math.max(0, Math.floor(options.contextLines ?? 0));\n const grepFlags = [\n `-HnI${mode.slice(1)} --null`,\n options.caseSensitive ? '' : '-i',\n options.maxCountPerFile !== undefined ? `-m ${Math.max(1, Math.floor(options.maxCountPerFile))}` : '',\n contextLines > 0 ? `-C ${contextLines}` : '',\n ]\n .filter(Boolean)\n .join(' ');\n const skipNodeModules = !isInsideNodeModules(abs);\n const nodeModulesPathspec = skipNodeModules ? ` ${shellQuote(':(exclude,glob)**/node_modules/**')}` : '';\n const pruneNames = skipNodeModules ? '-name .git -o -name node_modules' : '-name .git';\n const script = [\n `pat=${shellQuote(options.pattern)}`,\n `root=${shellQuote(abs)}`,\n // xargs exit codes can't tell \"no match\" from \"bad pattern\"; check first.\n `grep ${mode} -e \"$pat\" </dev/null >/dev/null 2>&1`,\n 'if [ $? -eq 2 ]; then echo \"grep: invalid regular expression\" >&2; exit 2; fi',\n 'tmp=$(mktemp -d) || exit 1',\n `trap 'rm -rf \"$tmp\"' EXIT`,\n `search_files() { xargs -0 -r grep ${grepFlags} -e \"$pat\" -- 2>/dev/null; }`,\n // A line starting with NUL names the directory later paths are relative to.\n 'search_repo() {',\n ` git -C \"$1\" grep -l -z -I --untracked ${options.caseSensitive ? '' : '-i '}${mode} -e \"$pat\" -- .${nodeModulesPathspec} >\"$tmp/files\" 2>/dev/null`,\n ' [ $? -gt 1 ] && return 1',\n ` printf '\\\\0%s\\\\n' \"$1\"`,\n ' (cd \"$1\" && search_files) <\"$tmp/files\"',\n '}',\n ...(hasGit\n ? [\n 'if git -C \"$root\" rev-parse --is-inside-work-tree >/dev/null 2>&1 && ! git -C \"$root\" check-ignore -q . 2>/dev/null; then',\n ' search_repo \"$root\" && exit 0',\n 'fi',\n `find \"$root\" -mindepth 1 -maxdepth 3 \\\\( ${skipNodeModules ? '-name node_modules -prune' : '-false'} \\\\) -o \\\\( -name .git -prune -print \\\\) >\"$tmp/repos\" 2>/dev/null`,\n ': >\"$tmp/done\"',\n 'while IFS= read -r g; do',\n ' d=${g%/.git}',\n ' search_repo \"$d\" && printf \\'%s\\\\n\\' \"$d\" >>\"$tmp/done\"',\n 'done <\"$tmp/repos\"',\n 'set --',\n 'while IFS= read -r d; do set -- \"$@\" -o -path \"$d\"; done <\"$tmp/done\"',\n ]\n : ['set --']),\n `printf '\\\\0%s\\\\n' \"$root\"`,\n `find \"$root\" -mindepth 1 \\\\( ${pruneNames} \"$@\" \\\\) -prune -o -type f -print0 2>/dev/null | search_files`,\n 'exit 0',\n ].join('\\n');\n const result = await this.exec(script);\n if (result.exitCode !== 0) {\n throw new UnsupportedGrepPatternError(options.pattern, describeGrepFailure(result));\n }\n const files = new Map<string, GrepFileLines>();\n let base = abs;\n for (const line of result.stdout.split('\\n')) {\n if (!line || line === '--') continue;\n if (line.startsWith('\\0')) {\n base = line.slice(1);\n continue;\n }\n const nul = line.indexOf('\\0');\n if (nul <= 0) continue;\n const parsed = /^(\\d+)([:-])(.*)$/s.exec(line.slice(nul + 1));\n if (!parsed) continue;\n const lineNumber = Number(parsed[1]);\n const text = parsed[3]!;\n const state = fileLines(files, posixPath.resolve(base, line.slice(0, nul)));\n state.linesByNumber.set(lineNumber, text);\n if (parsed[2] !== ':') continue;\n const column = jsRegex.exec(text)?.index;\n if (column === undefined) {\n throw new UnsupportedGrepPatternError(options.pattern, 'POSIX ERE and JS RegExp disagree on this pattern');\n }\n state.matches.push({ line: lineNumber, column, text });\n }\n return this.applyTotalCap(toGrepResults(files, abs, contextLines), options.maxTotalMatches);\n }\n\n private async grepWithPosixGrep(abs: string, options: FilesystemGrepOptions): Promise<FilesystemGrepResult[]> {\n const jsRegex = SandboxFilesystem.grepRegex(options);\n // Reconstructing per-match context from `grep -C` text output is not\n // reliable (separator lines are ambiguous); let the host walk handle it.\n if (options.contextLines) {\n throw new UnsupportedGrepPatternError(options.pattern, 'context lines are not supported by POSIX grep');\n }\n const args = [\n 'grep -rnIE',\n // .git is filtered host-side too; skip it so object files are not scanned.\n '--exclude-dir=.git',\n options.caseSensitive ? '' : '-i',\n options.maxCountPerFile !== undefined ? `-m ${Math.max(1, Math.floor(options.maxCountPerFile))}` : '',\n '--',\n shellQuote(options.pattern),\n shellQuote(abs),\n ]\n .filter(Boolean)\n .join(' ');\n const result = await this.exec(args);\n if (result.exitCode === 1) return [];\n // Like rg, grep exits 2 on per-file errors (e.g. an unreadable file) while\n // still printing matches for the rest; keep those partial results.\n if (result.exitCode !== 0 && !(result.exitCode === 2 && result.stdout.trim())) {\n throw new UnsupportedGrepPatternError(options.pattern, describeGrepFailure(result));\n }\n // grep -n has no column output; recompute with the JS regex host-side so\n // columns are UTF-16 indices, consistent with the fallback implementation.\n const byFile = new Map<string, FilesystemGrepMatch[]>();\n for (const line of result.stdout.split('\\n')) {\n if (!line) continue;\n const parsed = /^(.*?):(\\d+):(.*)$/.exec(line);\n if (!parsed) continue;\n const rel = posixPath.relative(abs, parsed[1]!) || posixPath.basename(parsed[1]!);\n const text = parsed[3]!;\n const column = jsRegex.exec(text)?.index;\n // grep matched this line but the JS regex did not: the two dialects\n // disagree on this pattern, so the columns would be wrong. Fall back.\n if (column === undefined) {\n throw new UnsupportedGrepPatternError(options.pattern, 'POSIX ERE and JS RegExp disagree on this pattern');\n }\n let matches = byFile.get(rel);\n if (!matches) {\n matches = [];\n byFile.set(rel, matches);\n }\n matches.push({ line: Number(parsed[2]), column, text });\n }\n const results = [...byFile.entries()].map(([path, matches]) => ({ path, matches }));\n return this.applyTotalCap(results, options.maxTotalMatches);\n }\n\n private applyTotalCap(results: FilesystemGrepResult[], maxTotal?: number): FilesystemGrepResult[] {\n if (maxTotal === undefined) return results;\n const capped: FilesystemGrepResult[] = [];\n let total = 0;\n for (const file of results) {\n if (total >= maxTotal) break;\n const remaining = maxTotal - total;\n const matches = file.matches.slice(0, remaining);\n total += matches.length;\n capped.push({ path: file.path, matches });\n }\n return capped;\n }\n\n // ── Path / metadata ────────────────────────────────────────────────────\n\n async exists(path: string): Promise<boolean> {\n const abs = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) return native.exists(abs);\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 = await this.resolveAsync(path);\n const native = this.sandbox.filesystem;\n if (native) {\n await this.verifyNative('target', abs, path);\n let info: Awaited<ReturnType<typeof native.stat>>;\n try {\n info = await native.stat(abs);\n } catch (error) {\n const isNotFound = error instanceof FileNotFoundError || (error as { code?: unknown })?.code === 'ENOENT';\n throw (isNotFound && (await this.outsideWorkdirNotFound(path, abs))) || error;\n }\n return {\n ...info,\n name: posixPath.basename(abs),\n path: `/${posixPath.relative(this.basePath, abs)}`,\n mimeType: info.type === 'file' ? (info.mimeType ?? getMimeType(abs)) : info.mimeType,\n };\n }\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. `-L` reports the symlink target, like LocalFilesystem.\n const result = await this.exec(\n `stat -L -c '%F|%s|%Y|%W' ${shellQuote(abs)} 2>/dev/null || stat -L -f '%HT|%z|%m|%B' ${shellQuote(abs)}`,\n );\n if (result.exitCode !== 0) {\n throw (await this.outsideWorkdirNotFound(path, abs)) ?? 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 mimeType: type === 'file' ? getMimeType(abs) : undefined,\n };\n }\n\n // ── Lifecycle ──────────────────────────────────────────────────────────\n\n async init(): Promise<void> {\n await this.execOk(`mkdir -p ${shellQuote(await this.base())}`, '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(await this.base())}`);\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. Absolute paths are workspace-relative (/tmp/x resolves to ${this.basePath}/tmp/x), so file tools cannot reach files outside ${this.basePath}. Create scratch git worktrees under ${this.basePath}/.worktrees/, then, in a pnpm monorepo, run \\`pnpm install --prefer-offline --frozen-lockfile\\` in the worktree and build the workspace packages you test against (with Turborepo: \\`pnpm turbo build --filter=\"<package>^...\"\\`, which reuses the build cache).`;\n }\n}\n"],"mappings":";;;;;;;;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AAO,OAAO,KAAK;EAChC,MAAM,QAAQ,OAAO,QAAQ,KAAK;EAClC,MAAM,QAAQ,OAAO,QAAQ;EAC7B,OAAO;GACL,MAAMA,MAAU,SAAS,GAAG;GAC5B,MAAM,IAAIA,MAAU,SAAS,KAAK,UAAU,GAAG;GAC/C;GACA,MAAM,SAAS,cAAc,IAAI;GACjC,4BAAY,IAAI,KAAK,QAAQ,GAAI;GACjC,2BAAW,IAAI,MAAM,QAAQ,IAAI,QAAQ,SAAS,GAAI;GACtD,UAAU,SAAS,SAAS,YAAY,GAAG,IAAI,KAAA;EACjD;CACF;CAIA,MAAM,OAAsB;EAC1B,MAAM,KAAK,OAAO,YAAY,WAAW,MAAM,KAAK,KAAK,CAAC,KAAK,cAAc;CAC/E;CAEA,MAAM,UAAyB,CAE/B;CAEA,MAAM,UAA4B;EAEhC,QAAO,MADc,KAAK,KAAK,WAAW,WAAW,MAAM,KAAK,KAAK,CAAC,GAAG,EAAA,CAC3D,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,2KAA2K,KAAK,SAAS,oDAAoD,KAAK,SAAS,uCAAuC,KAAK,SAAS;CAClX;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,eAAe,EAAE,uBAoB7B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute.js","names":[],"sources":["../../../src/agents/subagents/execute.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { MC_TOOLS } from '../../tool-names.js';\n\nexport const executeSubagent: AgentControllerSubagent = {\n id: 'execute',\n name: 'Execute',\n description: 'Implement a focused task, run relevant checks, and report the result.',\n instructions: `You are a focused execution agent. Understand relevant code before editing it and follow existing conventions. Stay within the assigned task; do not make unrelated changes. Use workspace tools to edit files and execute commands to verify your changes. Do not delegate work or modify the parent task list. Return a concise summary of changed files, verification results, and any blockers. Never claim checks passed unless you ran them successfully.`,\n allowedWorkspaceTools: [\n MC_TOOLS.VIEW,\n MC_TOOLS.FIND_FILES,\n MC_TOOLS.SEARCH_CONTENT,\n MC_TOOLS.FILE_STAT,\n MC_TOOLS.WRITE_FILE,\n MC_TOOLS.STRING_REPLACE_LSP,\n MC_TOOLS.DELETE_FILE,\n MC_TOOLS.MKDIR,\n MC_TOOLS.AST_SMART_EDIT,\n MC_TOOLS.EXECUTE_COMMAND,\n MC_TOOLS.GET_PROCESS_OUTPUT,\n MC_TOOLS.KILL_PROCESS,\n MC_TOOLS.LSP_INSPECT,\n ],\n};\n"],"mappings":";;AAGA,MAAa,kBAA2C;CACtD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;CACd,uBAAuB;EACrB,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;CACX;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"explore.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/explore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,eAAe,EAAE,uBAM7B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"explore.js","names":[],"sources":["../../../src/agents/subagents/explore.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { MC_TOOLS } from '../../tool-names.js';\n\nexport const exploreSubagent: AgentControllerSubagent = {\n id: 'explore',\n name: 'Explore',\n description: 'Explore the codebase and answer focused questions without modifying files.',\n instructions: `You are a read-only codebase exploration agent. Read relevant files before drawing conclusions. Use view, find_files, search_content, and file_stat to investigate. Do not modify files or run shell commands. Return concise findings with file paths and line numbers, and clearly distinguish verified facts from assumptions.`,\n allowedWorkspaceTools: [MC_TOOLS.VIEW, MC_TOOLS.FIND_FILES, MC_TOOLS.SEARCH_CONTENT, MC_TOOLS.FILE_STAT],\n};\n"],"mappings":";;AAGA,MAAa,kBAA2C;CACtD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;CACd,uBAAuB;EAAC,SAAS;EAAM,SAAS;EAAY,SAAS;EAAgB,SAAS;CAAS;AACzG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAK7E,uFAAuF;AACvF,eAAO,MAAM,gBAAgB,EAAE,SAAS,uBAAuB,EAAqD,CAAC;AAErH,sGAAsG;AACtG,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,uBAAuB,EAAE,CAEnF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/agents/subagents/index.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { executeSubagent } from './execute.js';\nimport { exploreSubagent } from './explore.js';\nimport { planSubagent } from './plan.js';\n\n/** The explore/plan/execute subagents. Not registered unless passed as `subagents`. */\nexport const builtinSubagents: readonly AgentControllerSubagent[] = [exploreSubagent, planSubagent, executeSubagent];\n\n/** Subagents for the `preferences.subagentsEnabled` setting: the built-ins when on, none when off. */\nexport function resolveSubagentsSetting(enabled: boolean): AgentControllerSubagent[] {\n return enabled ? [...builtinSubagents] : [];\n}\n"],"mappings":";;;;;AAMA,MAAa,mBAAuD;CAAC;CAAiB;CAAc;AAAe;;AAGnH,SAAgB,wBAAwB,SAA6C;CACnF,OAAO,UAAU,CAAC,GAAG,gBAAgB,IAAI,CAAC;AAC5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/subagents/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAG7E,eAAO,MAAM,YAAY,EAAE,uBAM1B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"plan.js","names":[],"sources":["../../../src/agents/subagents/plan.ts"],"sourcesContent":["import type { AgentControllerSubagent } from '@mastra/core/agent-controller';\nimport { MC_TOOLS } from '../../tool-names.js';\n\nexport const planSubagent: AgentControllerSubagent = {\n id: 'plan',\n name: 'Plan',\n description: 'Investigate a task and propose an implementation plan without modifying files.',\n instructions: `You are a read-only planning agent. Inspect the relevant code using view, find_files, search_content, and file_stat before proposing changes. Do not modify files or run shell commands. Return a concise implementation plan with file paths, ordered steps, risks, and concrete verification criteria. State assumptions and unresolved questions.`,\n allowedWorkspaceTools: [MC_TOOLS.VIEW, MC_TOOLS.FIND_FILES, MC_TOOLS.SEARCH_CONTENT, MC_TOOLS.FILE_STAT],\n};\n"],"mappings":";;AAGA,MAAa,eAAwC;CACnD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,cAAc;CACd,uBAAuB;EAAC,SAAS;EAAM,SAAS;EAAY,SAAS;EAAgB,SAAS;CAAS;AACzG"}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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"],"mappings":";AASA,MAAM,wBAA8C;CAClD;EACE,KAAK;EACL,UAAU,UAAqC,OAAO,UAAU;EAChE,6BAA6B;CAC/B;CACA;EACE,KAAK;EACL,UAAU,UAA8C,UAAU,UAAU,OAAO,UAAU;EAC7F,6BAA6B;CAC/B;CACA;EACE,KAAK;EACL,UAAU,UACR,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAM,SAAQ,OAAO,SAAS,QAAQ;EACtE,uBAAuB,CAAC;CAC1B;AACF;AAEA,SAAS,cAAc,SAA2C,SAAsC;CACtG,MAAM,QAAQ,QAAQ,MAAM,IAAI,CAAC,CAAC,QAAQ;CAC1C,OAAO,QAAQ,QAAQ,KAAK,IAAI,QAAQ,KAAA;AAC1C;AAEA,SAAS,iBAAiB,MAAe,OAAyB;CAChE,IAAI,MAAM,QAAQ,IAAI,KAAK,MAAM,QAAQ,KAAK,GAC5C,OAAO,KAAK,WAAW,MAAM,UAAU,KAAK,OAAO,MAAM,UAAU,SAAS,MAAM,MAAM;CAE1F,OAAO,SAAS;AAClB;AAEA,eAAe,WACb,SACA,UAC4C;CAE5C,QAAO,MADe,QAAQ,OAAO,KAAK,EAAE,cAAc,KAAK,CAAC,EAAA,CACjD,MAAK,MAAK,EAAE,OAAO,QAAQ;AAC5C;;;;;;;AAQA,eAAe,yBAAyB,SAA2C,UAAiC;CAClH,MAAM,SAAS,MAAM,WAAW,SAAS,QAAQ;CACjD,IAAI,QAAQ,OAAO,MAAM,MAAM,UAAU;CAEzC,MAAM,UAAmC,CAAC;CAC1C,MAAM,iBAAyD,CAAC;CAEhE,KAAK,MAAM,WAAW,uBAAuB;EAC3C,MAAM,YAAY,QAAQ,WAAW,QAAQ;EA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,YAAY,CAExE,CAAC;EACH;CAEJ,CAAC;AACH;;;;;;AAOA,eAAsB,qCAAqC,SAA0D;CACnH,MAAM,WAAW,QAAQ,OAAO,MAAM;CACtC,IAAI,CAAC,UAAU;CACf,MAAM,yBAAyB,SAAS,QAAQ;AAClD"}
@@ -1 +0,0 @@
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;AA4D7F,wFAAwF;AACxF,wBAAgB,gCAAgC,CAAC,QAAQ,CAAC,EAAE,MAAM,iBAC3C,wBAAwB;;;cAC9C;AAED,eAAO,MAAM,2BAA2B,gBAHjB,wBAAwB;;;aAG8B,CAAC;AAgC9E,wBAAgB,8BAA8B,CAC5C,sBAAsB,UAAQ,EAC9B,QAAQ,CAAC,EAAE,MAAM,GAChB,oBAAoB,CAiCtB;AAED,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,sBAAmC,CAAC;AAE3E,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAwBtD,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAUzD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAMtD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-availability.js","names":[],"sources":["../../src/agents/tool-availability.ts"],"sourcesContent":["import { WORKSPACE_TOOLS } from '@mastra/core/workspace';\nimport type { WorkspaceToolHookContext, WorkspaceToolsConfig } from '@mastra/core/workspace';\nimport { MC_TOOLS, TOOL_NAME_OVERRIDES } from '../tool-names.js';\nimport { getLocalPlansRelativeDir, isPlanFilePath } from '../utils/plans.js';\n\nconst PLAN_MODE_WRITE_TOOL_NAMES = new Set<string>([\n WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE,\n WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE,\n]);\n\nfunction getRequestContextValue(requestContext: unknown, key: string): unknown {\n if (!requestContext) return undefined;\n if (typeof (requestContext as { get?: unknown }).get === 'function') {\n return (requestContext as { get: (key: string) => unknown }).get(key);\n }\n return (requestContext as Record<string, unknown>)[key];\n}\n\n/**\n * Subset of the `AgentControllerRequestContext` the controller sets under the\n * `controller` request-context key. The mode is a string property\n * (`session.modeId`) and live state is read via `session.state.get()`.\n */\ninterface PlanModeGuardHarness {\n session?: {\n modeId?: unknown;\n state?: { get?: () => unknown };\n };\n}\n\nfunction getHarnessContext(context: unknown): PlanModeGuardHarness | undefined {\n const requestContext = (context as { requestContext?: unknown } | undefined)?.requestContext;\n const harness = getRequestContextValue(requestContext, 'controller');\n return harness && typeof harness === 'object' ? (harness as PlanModeGuardHarness) : undefined;\n}\n\nfunction getHarnessState(harness: PlanModeGuardHarness | undefined): Record<string, unknown> | undefined {\n const state = harness?.session?.state?.get?.();\n return state && typeof state === 'object' ? (state as Record<string, unknown>) : undefined;\n}\n\nfunction getHarnessModeId(harness: PlanModeGuardHarness | undefined): string | undefined {\n const modeId = harness?.session?.modeId ?? getHarnessState(harness)?.modeId;\n return typeof modeId === 'string' ? modeId : undefined;\n}\n\nfunction getHarnessProjectPath(harness: PlanModeGuardHarness | undefined): string | undefined {\n const projectPath = getHarnessState(harness)?.projectPath;\n return typeof projectPath === 'string' ? projectPath : undefined;\n}\n\nfunction getHarnessFactoryProjectId(harness: PlanModeGuardHarness | undefined): string | undefined {\n const factoryProjectId = getHarnessState(harness)?.factoryProjectId;\n return typeof factoryProjectId === 'string' ? factoryProjectId : undefined;\n}\n\nfunction getToolInputPath(input: unknown): string | undefined {\n const toolPath = (input as { path?: unknown } | undefined)?.path;\n return typeof toolPath === 'string' ? toolPath : undefined;\n}\n\n/** Plan-mode write guard; `plansDir` is the host-configured plans directory, if any. */\nexport function createPlanModePlanFileWriteGuard(plansDir?: string) {\n return (hookContext: WorkspaceToolHookContext) => guardPlanFileWrite(hookContext, plansDir);\n}\n\nexport const guardPlanModePlanFileWrites = createPlanModePlanFileWriteGuard();\n\nfunction guardPlanFileWrite({ workspaceToolName, input, context }: WorkspaceToolHookContext, plansDir?: string) {\n if (!PLAN_MODE_WRITE_TOOL_NAMES.has(workspaceToolName)) return;\n\n const harness = getHarnessContext(context);\n if (getHarnessModeId(harness) !== 'plan') return;\n\n const factoryProjectId = getHarnessFactoryProjectId(harness);\n const planOptions = { factoryProjectId, plansDir };\n const planDirHint = `${getLocalPlansRelativeDir(planOptions)}/`;\n const projectPath = getHarnessProjectPath(harness);\n const inputPath = getToolInputPath(input);\n if (!projectPath || !inputPath) {\n return {\n proceed: false as const,\n output: `Plan mode can only write plan files inside ${planDirHint}.`,\n };\n }\n\n // Plan mode may write any `.md` file directly inside the configured plan directory,\n // but nothing else in the project.\n if (isPlanFilePath(projectPath, inputPath, planOptions)) return;\n\n return {\n proceed: false as const,\n output: `Plan mode can only write plan files inside ${planDirHint}. Refusing to edit ${inputPath}.`,\n };\n}\n\nconst BACKGROUND_TOOL_CONFIG = { enabled: true, defaultDisposition: 'foreground' } as const;\n\nexport function createMastraCodeWorkspaceTools(\n backgroundToolsEnabled = false,\n plansDir?: string,\n): WorkspaceToolsConfig {\n const background = backgroundToolsEnabled ? BACKGROUND_TOOL_CONFIG : undefined;\n return {\n ...TOOL_NAME_OVERRIDES,\n // The TUI shows this description in place of the raw command.\n [WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND]: {\n ...TOOL_NAME_OVERRIDES[WORKSPACE_TOOLS.SANDBOX.EXECUTE_COMMAND],\n requireDescription: true,\n },\n [WORKSPACE_TOOLS.FILESYSTEM.READ_FILE]: {\n ...TOOL_NAME_OVERRIDES[WORKSPACE_TOOLS.FILESYSTEM.READ_FILE],\n ...(background ? { background } : {}),\n },\n [WORKSPACE_TOOLS.FILESYSTEM.LIST_FILES]: {\n ...TOOL_NAME_OVERRIDES[WORKSPACE_TOOLS.FILESYSTEM.LIST_FILES],\n ...(background ? { background } : {}),\n },\n [WORKSPACE_TOOLS.FILESYSTEM.FILE_STAT]: {\n ...TOOL_NAME_OVERRIDES[WORKSPACE_TOOLS.FILESYSTEM.FILE_STAT],\n ...(background ? { background } : {}),\n },\n [WORKSPACE_TOOLS.FILESYSTEM.GREP]: {\n ...TOOL_NAME_OVERRIDES[WORKSPACE_TOOLS.FILESYSTEM.GREP],\n ...(background ? { background } : {}),\n },\n [WORKSPACE_TOOLS.LSP.LSP_INSPECT]: {\n ...TOOL_NAME_OVERRIDES[WORKSPACE_TOOLS.LSP.LSP_INSPECT],\n ...(background ? { background } : {}),\n },\n hooks: {\n beforeToolCall: createPlanModePlanFileWriteGuard(plansDir),\n },\n };\n}\n\n/** Default foreground-only configuration for consumers without Mastra Code settings. */\nexport const MASTRACODE_WORKSPACE_TOOLS = createMastraCodeWorkspaceTools();\n\nexport const PLAN_MODE_AVAILABLE_TOOLS: readonly string[] = [\n // Read-only exploration tools\n MC_TOOLS.VIEW,\n MC_TOOLS.FIND_FILES,\n MC_TOOLS.SEARCH_CONTENT,\n MC_TOOLS.FILE_STAT,\n MC_TOOLS.LSP_INSPECT,\n // Plan file writing. Tool hooks enforce that these can only write `.md`\n // files inside the session's configured plan directory while in plan mode.\n MC_TOOLS.WRITE_FILE,\n MC_TOOLS.STRING_REPLACE_LSP,\n // Plan delivery tools\n 'ask_user',\n 'submit_plan',\n // Task tools for plan-stage tracking\n 'task_write',\n 'task_update',\n 'task_complete',\n 'task_check',\n // Notification access\n MC_TOOLS.NOTIFICATION_INBOX,\n // Read-only workflow inspection (no create/run/delete in plan mode).\n 'list-workflows',\n 'get-workflow',\n];\n\nexport const EXPLORE_MODE_AVAILABLE_TOOLS: readonly string[] = [\n MC_TOOLS.VIEW,\n MC_TOOLS.FIND_FILES,\n MC_TOOLS.SEARCH_CONTENT,\n MC_TOOLS.FILE_STAT,\n MC_TOOLS.LSP_INSPECT,\n 'ask_user',\n // Read-only workflow inspection (no create/run/delete in fast mode either).\n 'list-workflows',\n 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AAC,CAAC,CAAC;AAwBhG,wBAAgB,kBAAkB,CAChC,UAAU,CAAC,EAAE,UAAU,EACvB,UAAU,CAAC,EAAE,mBAAmB,EAChC,aAAa,CAAC,EAAE,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACtC,sBAAsB,UAAQ,EAC9B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,yBAIpC;IACD,cAAc,EAAE,cAAc,CAAC;CAChC,KAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAqGrC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.js","names":[],"sources":["../../src/agents/tools.ts"],"sourcesContent":["import { createAnthropic } from '@ai-sdk/anthropic';\nimport { createOpenAI } from '@ai-sdk/openai';\nimport type { ToolsInput } from '@mastra/core/agent';\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport { createNotificationInboxTool, NotificationsStorage } from '@mastra/core/notifications';\nimport type {\n CreateNotificationInput,\n ListDueNotificationsInput,\n ListNotificationsInput,\n UpdateNotificationInput,\n UpdateNotificationsStatusInput,\n} from '@mastra/core/notifications';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\nimport type { ToolAfterHookContext, ToolHooks } from '@mastra/core/tools';\nimport { jsonSchema } from 'ai';\nimport type { HookManager } from '../hooks/index.js';\nimport type { McpManager } from '../mcp/index.js';\nimport type { MastraCodeComposedState } from '../schema.js';\nimport { MC_TOOLS } from '../tool-names.js';\nimport { createConfiguredWebTools, requestSandboxAccessTool } from '../tools/index.js';\nimport { createWorkflowTool } from '../tools/workflows/create-workflow.js';\nimport { deleteWorkflowTool } from '../tools/workflows/delete-workflow.js';\nimport { getWorkflowTool } from '../tools/workflows/get-workflow.js';\nimport { listWorkflowsTool } from '../tools/workflows/list-workflows.js';\nimport { runWorkflowTool } from '../tools/workflows/run-workflow.js';\nimport { WORKFLOW_MANAGEMENT_TOOL_IDS } from '../tools/workflows/tool-ids.js';\nimport { prepareProviderWebSearchRoute, resolveProviderWebSearchRoute } from './model.js';\nimport type { ProviderWebSearchRoute } from './model.js';\n\n/** Minimal shape for tools passed to createDynamicTools. */\nexport type ToolLike = {\n execute?: (...args: any[]) => Promise<unknown> | unknown;\n} & Record<string, any>;\n\nfunction configurePluginTool(tool: ToolLike, backgroundToolsEnabled: boolean): ToolLike {\n if (backgroundToolsEnabled || !tool.background) return tool;\n return { ...tool, background: { ...tool.background, enabled: false } };\n}\n\nexport class LazyNotificationsStorage extends NotificationsStorage {\n constructor(private readonly storage: MastraCompositeStore) {\n super();\n }\n\n private async getNotificationsStorage(): Promise<NotificationsStorage> {\n const notifications = await this.storage.getStore('notifications');\n if (!notifications) {\n throw new Error('notification_inbox requires a notifications storage domain');\n }\n return notifications;\n }\n\n async createNotification(input: CreateNotificationInput) {\n return (await this.getNotificationsStorage()).createNotification(input);\n }\n\n async listNotifications(input: ListNotificationsInput) {\n return (await this.getNotificationsStorage()).listNotifications(input);\n }\n\n async listDueNotifications(input: ListDueNotificationsInput) {\n return (await this.getNotificationsStorage()).listDueNotifications(input);\n }\n\n async getNotification(input: { threadId: string; id: string }) {\n return (await this.getNotificationsStorage()).getNotification(input);\n }\n\n async updateNotification(input: UpdateNotificationInput) {\n return (await this.getNotificationsStorage()).updateNotification(input);\n }\n\n override async updateNotificationsStatus(input: UpdateNotificationsStatusInput) {\n return (await this.getNotificationsStorage()).updateNotificationsStatus(input);\n }\n\n async dangerouslyClearAll() {\n return (await this.getNotificationsStorage()).dangerouslyClearAll();\n }\n}\n\nexport type PostToolObserver = (context: ToolAfterHookContext) => void | Promise<void>;\n\nexport function createToolHooks(hookManager?: HookManager, postToolObserver?: PostToolObserver): ToolHooks | undefined {\n if (!hookManager && !postToolObserver) return undefined;\n\n return {\n beforeToolCall: async ({ toolName, input }) => {\n if (!hookManager) return;\n const preResult = await hookManager.runPreToolUse(toolName, input);\n if (!preResult.allowed) {\n return {\n proceed: false as const,\n output: {\n error: preResult.blockReason ?? `Blocked by PreToolUse hook for tool \"${toolName}\"`,\n },\n };\n }\n },\n afterToolCall: async context => {\n const { toolName, input, output, error } = context;\n if (hookManager) {\n const failed = error !== undefined;\n await hookManager\n .runPostToolUse(\n toolName,\n input,\n failed ? { error: error instanceof Error ? error.message : String(error) } : output,\n failed,\n )\n .catch(() => undefined);\n }\n await Promise.resolve()\n .then(() => postToolObserver?.(context))\n .catch(error => {\n console.warn(`[MastraCode] Post-tool observer failed for ${toolName}.`, error);\n });\n },\n };\n}\n\ntype DynamicToolProvider =\n | Record<string, ToolLike | undefined>\n | ((ctx: {\n requestContext: RequestContext;\n }) => Record<string, ToolLike | undefined> | Promise<Record<string, ToolLike | undefined>>);\n\n/**\n * The provider-executed search tool for a route. The Mastra gateway's OpenRouter\n * chat endpoint takes `openrouter:web_search` (the OpenRouter provider sends a\n * provider tool `openrouter.web_search` with that type), as Mastra's own\n * templates use against the gateway.\n */\nfunction createProviderWebSearchTool(route: ProviderWebSearchRoute): ToolLike {\n switch (route) {\n case 'anthropic':\n return createAnthropic({}).tools.webSearch_20250305();\n case 'openai':\n return createOpenAI({}).tools.webSearch();\n case 'mastra-gateway':\n return {\n type: 'provider',\n id: 'openrouter.web_search',\n args: {},\n inputSchema: jsonSchema({ type: 'object', properties: {} }),\n } as unknown as ToolLike;\n }\n}\n\nexport function createDynamicTools(\n mcpManager?: McpManager,\n extraTools?: DynamicToolProvider,\n disabledTools?: string[],\n storage?: MastraCompositeStore,\n pluginTools?: Record<string, ToolLike>,\n backgroundToolsEnabled = false,\n builtinTools?: Record<string, ToolLike>,\n) {\n return function getDynamicTools({\n requestContext,\n }: {\n requestContext: RequestContext;\n }): ToolsInput | Promise<ToolsInput> {\n const ctx = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeComposedState> | undefined;\n const state = ctx?.getState();\n\n // In deployed Factory, the search route reads tenant credentials; prepare them first if needed.\n const preparing = prepareProviderWebSearchRoute(ctx?.session?.modelId, { requestContext });\n if (preparing) return preparing.then(() => getDynamicTools({ requestContext }));\n const webSearchRoute = resolveProviderWebSearchRoute(ctx?.session?.modelId, { requestContext });\n\n // Filesystem, grep, glob, edit, write, execute_command, and process\n // management tools are now provided by the workspace (see workspace.ts).\n // Only tools without a workspace equivalent remain here.\n const tools: Record<string, ToolLike> = {\n request_access: requestSandboxAccessTool,\n // Workflow surface. `create-workflow` delegates to the workflow-builder\n // sub-agent; the other four are Dynamic Workflow management operations.\n // Permission categories live in permissions.ts (TOOL_CATEGORY_MAP).\n [WORKFLOW_MANAGEMENT_TOOL_IDS.createWorkflow]: createWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.listWorkflows]: listWorkflowsTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.getWorkflow]: getWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.runWorkflow]: runWorkflowTool,\n [WORKFLOW_MANAGEMENT_TOOL_IDS.deleteWorkflow]: deleteWorkflowTool,\n };\n\n // Opt-in built-ins (e.g. the experimental schedule tools).\n if (builtinTools) Object.assign(tools, builtinTools);\n\n if (storage) {\n tools[MC_TOOLS.NOTIFICATION_INBOX] = createNotificationInboxTool({\n storage: new LazyNotificationsStorage(storage),\n });\n }\n\n // Async only when a Tavily/Parallel key is set; otherwise the tool list stays synchronous.\n const configuredWebTools = createConfiguredWebTools();\n if (!configuredWebTools && webSearchRoute) {\n tools.web_search = createProviderWebSearchTool(webSearchRoute);\n }\n\n const mcpTools = mcpManager?.getTools();\n if (mcpTools) Object.assign(tools, mcpTools);\n\n const finish = (resolvedExtra: Record<string, ToolLike | undefined> | undefined) => {\n if (resolvedExtra) {\n for (const [name, tool] of Object.entries(resolvedExtra)) {\n if (tool && !(name in tools)) {\n tools[name] = tool;\n }\n }\n }\n\n if (pluginTools) {\n for (const [name, tool] of Object.entries(pluginTools)) {\n if (!(name in tools)) {\n tools[name] = configurePluginTool(tool, backgroundToolsEnabled);\n }\n }\n }\n\n // Remove tools explicitly disabled via config so the model never sees them.\n if (disabledTools?.length) {\n for (const toolName of disabledTools) {\n delete tools[toolName];\n }\n }\n\n // Remove tools that have a per-tool 'deny' policy so the model never sees them.\n const permissionRules = state?.permissionRules;\n if (permissionRules?.tools) {\n for (const [name, policy] of Object.entries(permissionRules.tools)) {\n if (policy === 'deny') {\n delete tools[name];\n }\n }\n }\n\n return tools as ToolsInput;\n };\n\n const resolveExtra = (): ToolsInput | Promise<ToolsInput> => {\n if (typeof extraTools === 'function') {\n const resolved = extraTools({ requestContext });\n // Stay synchronous for sync providers; only go async when the provider does.\n if (resolved && typeof (resolved as PromiseLike<unknown>).then === 'function') {\n return Promise.resolve(resolved).then(finish);\n }\n return finish(resolved as Record<string, ToolLike | undefined>);\n }\n return finish(extraTools);\n };\n\n if (configuredWebTools) {\n return configuredWebTools.then(webTools => {\n // MCP tools keep precedence over the web tools, as when both were assigned in order.\n Object.assign(tools, webTools, mcpTools);\n return resolveExtra();\n });\n }\n\n return resolveExtra();\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmCA,SAAS,oBAAoB,MAAgB,wBAA2C;CACtF,IAAI,0BAA0B,CAAC,KAAK,YAAY,OAAO;CACvD,OAAO;EAAE,GAAG;EAAM,YAAY;GAAE,GAAG,KAAK;GAAY,SAAS;EAAM;CAAE;AACvE;AAEA,IAAa,2BAAb,cAA8C,qBAAqB;CACpC;CAA7B,YAAY,SAAgD;EAC1D,MAAM;EADqB,KAAA,UAAA;CAE7B;CAEA,MAAc,0BAAyD;EACrE,MAAM,gBAAgB,MAAM,KAAK,QAAQ,SAAS,eAAe;EACjE,IAAI,CAAC,eACH,MAAM,IAAI,MAAM,4DAA4D;EAE9E,OAAO;CACT;CAEA,MAAM,mBAAmB,OAAgC;EACvD,QAAQ,MAAM,KAAK,wBAAwB,EAAA,CAAG,mBAAmB,KAAK;CACxE;CAEA,MAAM,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AAM,UAAU,kBAAoE;GAClF,IAAI,eACG;SAAA,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,aAAa,GACrD,IAAI,QAAQ,EAAE,QAAQ,QACpB,MAAM,QAAQ;GAAA;GAKpB,IAAI,aACG;SAAA,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,WAAW,GACnD,IAAI,EAAE,QAAQ,QACZ,MAAM,QAAQ,oBAAoB,MAAM,sBAAsB;GAAA;GAMpE,IAAI,eAAe,QACjB,KAAK,MAAM,YAAY,eACrB,OAAO,MAAM;GAKjB,MAAM,kBAAkB,OAAO;GAC/B,IAAI,iBAAiB,OACd;SAAA,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,gBAAgB,KAAK,GAC/D,IAAI,WAAW,QACb,OAAO,MAAM;GAAA;GAKnB,OAAO;EACT;EAEA,MAAM,qBAAuD;GAC3D,IAAI,OAAO,eAAe,YAAY;IACpC,MAAM,WAAW,WAAW,EAAE,eAAe,CAAC;IAE9C,IAAI,YAAY,OAAQ,SAAkC,SAAS,YACjE,OAAO,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KAAK,MAAM;IAE9C,OAAO,OAAO,QAAgD;GAChE;GACA,OAAO,OAAO,UAAU;EAC1B;EAEA,IAAI,oBACF,OAAO,mBAAmB,MAAK,aAAY;GAEzC,OAAO,OAAO,OAAO,UAAU,QAAQ;GACvC,OAAO,aAAa;EACtB,CAAC;EAGH,OAAO,aAAa;CACtB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-builder-agent.d.ts","sourceRoot":"","sources":["../../src/agents/workflow-builder-agent.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,oBAAoB,6KA4D/B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-builder-agent.js","names":[],"sources":["../../src/agents/workflow-builder-agent.ts"],"sourcesContent":["/**\n * Workflow Builder sub-agent.\n *\n * The parent code-agent (build/plan/explore modes) delegates to this agent\n * via the `create-workflow` tool. Keeping the long workflow-authoring system\n * prompt here — instead of inlining it into every parent mode — keeps the\n * parent modes lean and lets the same author logic ship to Studio later.\n *\n * The sub-agent's tool set is intentionally tiny: discover what's available,\n * construct the entire definition in one thought, save it. No setter loop,\n * no per-step mutations.\n */\nimport { createWorkflowBuilderAgent } from '@mastra/core/workflows/builder';\nimport { listAvailableAgentsTool } from '../tools/workflows/list-available-agents.js';\nimport { listAvailableClassifiersTool } from '../tools/workflows/list-available-classifiers.js';\nimport { listAvailableToolsTool } from '../tools/workflows/list-available-tools.js';\nimport { listAvailableWorkflowsTool } from '../tools/workflows/list-available-workflows.js';\nimport { saveWorkflowTool } from '../tools/workflows/save-workflow.js';\nimport { WORKFLOW_AUTHORING_TOOL_IDS } from '../tools/workflows/tool-ids.js';\nimport { getDynamicModel } from './model.js';\n\nexport const workflowBuilderAgent = createWorkflowBuilderAgent({\n id: 'workflow-builder',\n name: 'Workflow Builder',\n description: 'Turns plain-language workflow descriptions into runnable, persisted workflow definitions.',\n tools: {\n [WORKFLOW_AUTHORING_TOOL_IDS.listAgents]: listAvailableAgentsTool,\n [WORKFLOW_AUTHORING_TOOL_IDS.listClassifiers]: listAvailableClassifiersTool,\n [WORKFLOW_AUTHORING_TOOL_IDS.listTools]: listAvailableToolsTool,\n [WORKFLOW_AUTHORING_TOOL_IDS.listWorkflows]: listAvailableWorkflowsTool,\n [WORKFLOW_AUTHORING_TOOL_IDS.saveWorkflow]: saveWorkflowTool,\n },\n surfaceInstructions: `# Mastra Code authoring policy\n\nYour job: turn the user's verbatim plain-language request into a complete Dynamic Workflow definition and persist it with save-workflow. Success means save-workflow returned \\`{ ok: true, id }\\` for the workflow the user asked for; do not claim success before that result.\n\nSave each definition successfully **exactly once**: after \\`save-workflow\\` returns \\`{ ok: true, id }\\`, never save that workflow again. The workflow the user asked for is always saved LAST. You may save other workflows before it **only** when they are helper workflows the requested workflow references as \\`{ type: \"workflow\" }\\` entries — never to probe the schema or split one workflow into pieces the user did not ask for. A rejected save is not a successful save; correct the reported issues and make the one sequential corrected attempt permitted by the protocol below.\n\n# \\`code-agent\\` — when to use it as an agent step\n\nThe Mastra instance registers \\`code-agent\\` (mastracode's coding agent) alongside the workflow-builder. When discovery surfaces it in \\`list-available-agents\\`, know that under the hood it has full access to workspace tools (view / edit / run commands), MCP tools, and web search — and it *reasons* over a prompt to pick the right ones.\n\nUse it as an \\`agent\\` step when the workflow needs judgment or open-ended tool orchestration you can't hardcode — e.g. \"read these files and figure out what changed\", \"review these logs and summarise the failures\", \"call the right MCP tool to open a Linear issue based on this content\".\n\nWhen the workflow needs a **specific, deterministic** operation (like \\`execute_command wc -l file.ts\\` or a single fixed web-search call), prefer a plain \\`tool\\` step — cheaper, no LLM in the middle, and reproducible.\n\n# Workspace tool output shapes — read this before wiring a file-oriented workflow\n\nThe workspace tools you are most likely to compose with return **strings, not objects**, and the shared bridge-agent and \\`initData\\` re-threading guidance applies to them directly:\n\n- \\`find_files\\` returns a formatted \\`string\\` listing, and the entries are **bare basenames with no path prefix** (e.g. \\`app-tools.ts\\\\nserver.ts\\`). A downstream step told only \"summarise each file\" therefore has no idea which folder they live in.\n- \\`find_files\\` — inputSchema \\`{ path?: string, ... }\\`, outputSchema tree-formatted text (string).\n- \\`view\\` — inputSchema \\`{ path: string, ... }\\`, outputSchema \\`string | { __workspaceMedia: true, text: string, mediaType: string, data: string }\\`.\n\nTwo consequences, both covered by the shared playbook's worked examples:\n\n1. A string listing is not iterable, so \\`foreach\\` needs a bridge \\`agent\\` step with a top-level array \\`outputSchema\\` between the listing tool and the loop.\n2. Because the listing strips the folder path, the mapping that builds the bridge agent's prompt MUST re-thread the original path with \\`\\${initData.<pathField>}\\` alongside \\`\\${stepResults.<listing-step>}\\`. Skipping this is the most common cause of downstream \"file not found\" failures.\n\nAlways confirm these shapes against \\`list-available-tools\\` rather than trusting the summary above.\n\n# Mastra Code discovery notes\n\nThe four shared listing tools behave here exactly as the shared playbook describes; each row's \\`id\\` is the value you copy into \\`agentId\\` / \\`classifierId\\` / \\`toolId\\` / \\`workflowId\\`. \\`list-available-classifiers\\` includes configured question metadata and stable \\`values.<question>\\` paths for conditional routing. \\`list-available-workflows\\` includes both code-defined and Dynamic Workflows, and its catalog is always available on this surface.\n\nYour fifth tool is \\`save-workflow\\`, which persists and live-registers a definition. Make one sequential complete call per attempt, only after composition and the shared pre-action check.\n\n# Mastra Code execution and response protocol\n\n1. Complete discovery, composition, and the shared pre-action check before calling \\`save-workflow\\`.\n2. If the design needs helper workflows (for example, per-branch wrappers so \\`parallel\\` branches can consume different fields — see the shared nested-workflow guidance), save each helper FIRST, one complete definition per call, in dependency order. Each \\`save-workflow\\` success live-registers that helper, which makes it a valid \\`workflowId\\` for the next definition. Confirm with \\`list-available-workflows\\` before referencing it, and give each helper a real \\`id\\` and \\`description\\` — helpers are permanent, user-visible registry entries, not scratch space.\n3. Call \\`save-workflow\\` with one complete \\`{ id, description, inputSchema, outputSchema, graph }\\` definition for the requested workflow. There are no incremental setter tools and no parallel save attempts.\n4. Wait for the tool result. Success means exactly that \\`save-workflow\\` returned \\`{ ok: true, id }\\`; at that point the workflow is persisted and live-registered.\n5. If the tool rejects the definition, do not claim success. Use the returned diagnostics and authoritative discovery to correct every named issue, rerun the shared pre-action check, and make one sequential corrected complete save attempt. Do not rationalize a registry mismatch as a missing engine feature.\n6. After success, follow the shared summary rules and end with the concrete run command \\`/workflows run <id> {…}\\` for the requested workflow. If you saved helper workflows, name them so the user knows they now exist in the registry.\n`,\n // Same dynamic model resolver mastracode's main code-agent uses — picks up\n // the user's configured provider/model from session state. When the parent\n // code-agent delegates to this sub-agent (via `create-workflow`), the\n // request context propagates so the same model resolves.\n model: getDynamicModel,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,uBAAuB,2BAA2B;CAC7D,IAAI;CACJ,MAAM;CACN,aAAa;CACb,OAAO;GACJ,4BAA4B,aAAa;GACzC,4BAA4B,kBAAkB;GAC9C,4BAA4B,YAAY;GACx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;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAclC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace.js","names":[],"sources":["../../src/agents/workspace.ts"],"sourcesContent":["import fs, { existsSync } from 'node:fs';\nimport os from 'node:os';\nimport path, { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { ToolsInput } from '@mastra/core/agent';\nimport type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { Workspace, LocalFilesystem, LocalSandbox, createWorkspaceTools } from '@mastra/core/workspace';\nimport type { LSPConfig, SkillSource } from '@mastra/core/workspace';\nimport { DEFAULT_CONFIG_DIR } from '../constants.js';\nimport { loadSettings, resolveLspSetting } from '../onboarding/settings.js';\nimport type { MastraCodeState } from '../schema.js';\nimport { isPathWithinRoot } from '../utils/path-security.js';\nimport { getPlansDir } from '../utils/plans.js';\n\nimport { createMastraCodeWorkspaceTools, GOAL_JUDGE_READONLY_TOOLS } from './tool-availability.js';\n\n// =============================================================================\n// Sandbox Environment\n// =============================================================================\n\nfunction buildSandboxEnv(): NodeJS.ProcessEnv {\n return {\n ...process.env,\n // Explicit overrides for non-interactive subprocess execution\n FORCE_COLOR: '1',\n CLICOLOR_FORCE: '1',\n TERM: process.env.TERM || 'xterm-256color',\n CI: 'true',\n NONINTERACTIVE: '1',\n DEBIAN_FRONTEND: 'noninteractive',\n };\n}\n\n// =============================================================================\n// Create Workspace with Skills\n// =============================================================================\n\n// We support multiple skill locations for compatibility:\n// 1. Project-local: <configDir>/skills (project-specific mastracode skills)\n// 2. Project-local: .claude/skills (Claude Code compatible skills)\n// 3. Project-local: .agents/skills (Agent Skills spec compatible)\n// 4. Global: ~/<configDir>/skills (user-wide mastracode skills)\n// 5. Global: ~/.claude/skills (user-wide Claude Code skills)\n// 6. Global: ~/.agents/skills (user-wide Agent Skills spec compatible)\n\n// Mastra's LocalSkillSource.readdir uses Node's Dirent.isDirectory() which\n// returns false for symlinks. Tools like `npx skills add` install skills as\n// symlinks, so we need to resolve them. For each symlinked skill directory,\n// we add the real (resolved) parent path as an additional skill scan path.\nfunction collectSkillPaths(skillsDirs: string[], allowedRoot?: string): string[] {\n const paths: string[] = [];\n const seen = new Set<string>();\n let realAllowedRoot: string | undefined;\n\n if (allowedRoot) {\n try {\n realAllowedRoot = fs.realpathSync(allowedRoot);\n } catch {\n return [];\n }\n }\n\n for (const skillsDir of skillsDirs) {\n const skillsDirExists = fs.existsSync(skillsDir);\n if (skillsDirExists && realAllowedRoot) {\n try {\n const realSkillsDir = fs.realpathSync(skillsDir);\n if (!isPathWithinRoot(realSkillsDir, realAllowedRoot)) continue;\n } catch {\n continue;\n }\n }\n\n const resolved = path.resolve(skillsDir);\n if (!seen.has(resolved)) {\n seen.add(resolved);\n paths.push(skillsDir);\n }\n\n if (!skillsDirExists) continue;\n\n try {\n const entries = fs.readdirSync(skillsDir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.isSymbolicLink()) {\n try {\n const linkPath = path.join(skillsDir, entry.name);\n const realPath = fs.realpathSync(linkPath);\n if (realAllowedRoot && !isPathWithinRoot(realPath, realAllowedRoot)) continue;\n const stat = fs.statSync(realPath);\n if (stat.isDirectory()) {\n const realParent = path.dirname(realPath);\n if (realAllowedRoot && !isPathWithinRoot(realParent, realAllowedRoot)) continue;\n if (!seen.has(realParent)) {\n seen.add(realParent);\n paths.push(realParent);\n }\n }\n } catch {\n continue;\n }\n }\n }\n } catch {\n // Ignore errors during symlink resolution\n }\n }\n\n return paths;\n}\n\n// Build skill paths dynamically based on configDir and projectPath\nexport function buildSkillPaths(\n projectPath: string,\n configDir: string,\n homeDir = os.homedir(),\n pluginSkillPaths: string[] = [],\n): string[] {\n const mastraCodeLocalSkillsPath = path.join(projectPath, configDir, 'skills');\n const claudeLocalSkillsPath = path.join(projectPath, '.claude', 'skills');\n const agentSkillsLocalPath = path.join(projectPath, '.agents', 'skills');\n const mastraCodeGlobalSkillsPath = path.join(homeDir, configDir, 'skills');\n const claudeGlobalSkillsPath = path.join(homeDir, '.claude', 'skills');\n const agentSkillsGlobalPath = path.join(homeDir, '.agents', 'skills');\n\n const paths = [\n ...collectSkillPaths([mastraCodeLocalSkillsPath, claudeLocalSkillsPath, agentSkillsLocalPath], projectPath),\n ...collectSkillPaths([mastraCodeGlobalSkillsPath, claudeGlobalSkillsPath, agentSkillsGlobalPath]),\n ...pluginSkillPaths.flatMap(pluginSkillPath => collectSkillPaths([pluginSkillPath], pluginSkillPath)),\n ];\n\n const seenPaths = new Set<string>();\n return paths.filter(skillPath => {\n let resolved: string;\n try {\n resolved = fs.realpathSync(skillPath);\n } catch {\n resolved = path.resolve(skillPath);\n }\n if (seenPaths.has(resolved)) return false;\n seenPaths.add(resolved);\n return true;\n });\n}\n\nexport interface WorkspaceSkillExtension {\n /** Distinguishes extended workspaces from the default resolver cache. */\n id: string;\n /** Additional read-only skill roots prepended to normal project/global skill roots. */\n paths: string[];\n /** Compose the additional roots with the workspace's normal skill source. */\n createSource: (fallback: SkillSource, fallbackSkillRoots: string[]) => SkillSource;\n}\n\n/**\n * Paths the agent is always allowed to access (in addition to the project root\n * and any per-thread sandboxAllowedPaths). The OS temp directory is included\n * so the agent can use it as a scratchpad without requesting access every time.\n */\nconst DEFAULT_ALLOWED_PATHS: string[] = [os.tmpdir(), '/tmp', getPlansDir()].reduce<string[]>((acc, p) => {\n const resolved = path.resolve(p);\n if (!acc.includes(resolved)) acc.push(resolved);\n return acc;\n}, []);\n\nconst WORKSPACE_ID_PREFIX = 'mastra-code-workspace';\n\n/**\n * Detect the project's package runner from lock files.\n * Used as a fallback packageRunner for LSP when no binary is found locally or on PATH.\n */\nfunction detectPackageRunner(projectPath: string): string | undefined {\n if (existsSync(join(projectPath, 'pnpm-lock.yaml'))) return 'pnpm dlx';\n if (existsSync(join(projectPath, 'bun.lockb')) || existsSync(join(projectPath, 'bun.lock'))) return 'bunx';\n if (existsSync(join(projectPath, 'yarn.lock'))) return 'yarn dlx';\n if (existsSync(join(projectPath, 'package-lock.json'))) return 'npx --yes';\n return 'npx --yes';\n}\n\nexport async function getDynamicWorkspace({\n requestContext,\n mastra,\n skillExtension,\n backgroundToolsEnabled = false,\n plansDir,\n}: {\n requestContext: RequestContext;\n mastra?: Mastra;\n skillExtension?: WorkspaceSkillExtension;\n backgroundToolsEnabled?: boolean;\n /** Host-configured plans directory the plan-mode write guard allows. */\n plansDir?: string;\n}) {\n const ctx = requestContext.get('controller') as AgentControllerRequestContext<MastraCodeState> | undefined;\n const state = ctx?.getState();\n\n const rawProjectPath = state?.projectPath;\n\n if (!rawProjectPath) {\n throw new Error('Project path is required');\n }\n\n const projectPath = path.resolve(rawProjectPath);\n const configDir = state?.configDir ?? DEFAULT_CONFIG_DIR;\n const projectSkillPaths = buildSkillPaths(projectPath, configDir, state?.homeDir, state?.pluginSkillPaths ?? []);\n const skillPaths = [...(skillExtension?.paths ?? []), ...projectSkillPaths];\n const extensionId = skillExtension ? `-${skillExtension.id}` : '';\n const workspaceId = `${WORKSPACE_ID_PREFIX}-${projectPath}${extensionId}`;\n const sandboxPaths = state?.sandboxAllowedPaths ?? [];\n const allowedPaths = [\n ...projectSkillPaths,\n ...DEFAULT_ALLOWED_PATHS,\n ...sandboxPaths.map((p: string) => path.resolve(p)),\n ];\n\n // All modes share the same workspace tool configuration. Per-mode tool\n // visibility is enforced at LLM-call time via `availableTools` /\n // `activeTools` on the AgentController, not by mutating workspace capabilities.\n const workspaceTools = createMastraCodeWorkspaceTools(backgroundToolsEnabled, plansDir);\n\n // Reuse existing workspace if already registered (preserves ProcessManager state).\n // `optional` skips the error log on a miss; older cores ignore it and throw instead.\n let existing: Workspace<LocalFilesystem, LocalSandbox> | undefined;\n try {\n existing = mastra?.getWorkspaceById(workspaceId, { optional: true }) as\n | Workspace<LocalFilesystem, LocalSandbox>\n | undefined;\n } catch {\n // Not registered yet\n }\n\n if (existing) {\n existing.filesystem.setAllowedPaths(allowedPaths);\n existing.setToolsConfig(workspaceTools);\n return existing;\n }\n\n // LSP is opt-in. When disabled we pass `false` so core skips the dependency\n // check, the LSP manager, and the `lsp_inspect` tool entirely.\n const userLsp = resolveLspSetting(loadSettings().lsp);\n let lspConfig: LSPConfig | false = false;\n if (userLsp !== false) {\n const mcModulePath = join(dirname(fileURLToPath(import.meta.url)), '..');\n lspConfig = {\n maxOpenClients: 4,\n ...userLsp,\n packageRunner: userLsp.packageRunner || detectPackageRunner(projectPath), // Detected runner is the fallback — user's packageRunner always wins\n searchPaths: [mcModulePath, ...(userLsp.searchPaths ?? [])],\n };\n }\n\n // First call for this project — create the workspace\n const filesystem = new LocalFilesystem({\n basePath: projectPath,\n allowedPaths,\n });\n return new Workspace({\n id: workspaceId,\n name: 'Mastra Code Workspace',\n filesystem,\n sandbox: new LocalSandbox({\n timeout: 30_000,\n workingDirectory: projectPath,\n env: buildSandboxEnv(),\n }),\n tools: workspaceTools,\n skills: skillPaths,\n ...(skillExtension ? { skillSource: skillExtension.createSource(filesystem, projectSkillPaths) } : {}),\n lsp: lspConfig,\n });\n}\n\n/**\n * Resolver for the agent's `goal.tools` config. Builds the request's workspace\n * (same per-request resolution as the agent's own tools) and returns only the\n * read-only verification subset, remapped to mastracode's tool names (`view`,\n * `search_content`, etc.). Returns `undefined` when no workspace can be resolved\n * (e.g. no project path), keeping the default judge text-only rather than\n * throwing inside the goal step.\n */\nexport async function getGoalJudgeTools({\n requestContext,\n mastra,\n}: {\n requestContext: RequestContext;\n mastra?: Mastra;\n}): Promise<ToolsInput | undefined> {\n let workspace: Workspace;\n try {\n workspace = await getDynamicWorkspace({ requestContext, mastra });\n } catch {\n return undefined;\n }\n\n const allTools = await createWorkspaceTools(workspace, { requestContext, workspace });\n const readonly: ToolsInput = {};\n for (const name of GOAL_JUDGE_READONLY_TOOLS) {\n if (allTools[name]) readonly[name] = allTools[name];\n }\n return Object.keys(readonly).length > 0 ? readonly : undefined;\n}\n"],"mappings":";;;;;;;;;;;AAsBA,SAAS,kBAAqC;CAC5C,OAAO;EACL,GAAG,QAAQ;EAEX,aAAa;EACb,gBAAgB;EAChB,MAAM,QAAQ,IAAI,QAAQ;EAC1B,IAAI;EACJ,gBAAgB;EAChB,iBAAiB;CACnB;AACF;AAkBA,SAAS,kBAAkB,YAAsB,aAAgC;CAC/E,MAAM,QAAkB,CAAC;CACzB,MAAM,uBAAO,IAAI,IAAY;CAC7B,IAAI;CAEJ,IAAI,aACF,IAAI;EACF,kBAAkB,GAAG,aAAa,WAAW;CAC/C,QAAQ;EACN,OAAO,CAAC;CACV;CAGF,KAAK,MAAM,aAAa,YAAY;EAClC,MAAM,kBAAkB,GAAG,WAAW,SAAS;EAC/C,IAAI,mBAAmB,iBACrB,IAAI;GACF,MAAM,gBAAgB,GAAG,aAAa,SAAS;GAC/C,IAAI,CAAC,iBAAiB,eAAe,eAAe,GAAG;EACzD,QAAQ;GACN;EACF;EAGF,MAAM,WAAW,KAAK,QAAQ,SAAS;EACvC,IAAI,CAAC,KAAK,IAAI,QAAQ,GAAG;GACvB,KAAK,IAAI,QAAQ;GACjB,MAAM,KAAK,SAAS;EACtB;EAEA,IAAI,CAAC,iBAAiB;EAEtB,IAAI;GACF,MAAM,UAAU,GAAG,YAAY,WAAW,EAAE,eAAe,KAAK,CAAC;GACjE,KAAK,MAAM,SAAS,SAClB,IAAI,MAAM,eAAe,GACvB,IAAI;IACF,MAAM,WAAW,KAAK,KAAK,WAAW,MAAM,IAAI;IAChD,MAAM,WAAW,GAAG,aAAa,QAAQ;IACzC,IAAI,mBAAmB,CAAC,iBAAiB,UAAU,eAAe,GAAG;IAErE,IADa,GAAG,SAAS,QAClB,CAAC,CAAC,YAAY,GAAG;KACtB,MAAM,aAAa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AeD,MAAM,MAAM,wBAAwB,GAChC,4BAA4B,GAC5B,6BAA6B,GAC7B,2BAA2B,GAC3B,0BAA0B,GAC1B,yBAAyB,GACzB,qCAAqC,CAAC;AAE1C,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,KAAK,EAAE,wBAAwB,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrF,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC1E,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACvF,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC;CACtB;AAED,UAAU,0BAA0B;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA8FD,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAOjF;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,0BAA0B,GAAG,mBAAmB,CAOlG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"analytics.js","names":[],"sources":["../src/analytics.ts"],"sourcesContent":["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport { PostHog } from 'posthog-node';\n\nconst POSTHOG_API_KEY = 'phc_SBLpZVAB6jmHOct9CABq3PF0Yn5FU3G2FgT4xUr2XrT';\nconst POSTHOG_HOST = 'https://us.posthog.com';\nconst MASTRA_SOURCE = 'mastracode';\nconst TRUTHY_DISABLED_VALUES = new Set(['1', 'true', 'yes', 'on']);\nconst ANALYTICS_CONFIG_PATH = path.join(os.homedir(), '.mastracode', 'analytics.json');\n\ninterface AnalyticsConfig {\n distinctId?: string;\n}\n\nfunction createMastraAnalyticsDistinctId(): string {\n return `mastra-${globalThis.crypto.randomUUID()}`;\n}\n\nfunction isHostnameDerivedDistinctId(distinctId: string, hostname = os.hostname()): boolean {\n return distinctId === `mastra-${hostname}`;\n}\n\nfunction isValidMastraAnalyticsDistinctId(distinctId: string): boolean {\n return /^mastra-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(distinctId);\n}\n\nfunction writeAnalyticsConfig(distinctId: string, configPath = ANALYTICS_CONFIG_PATH): void {\n try {\n mkdirSync(path.dirname(configPath), { recursive: true });\n writeFileSync(configPath, JSON.stringify({ distinctId }));\n } catch {\n // swallow analytics persistence errors\n }\n}\n\nexport function getMastraAnalyticsDistinctId(configPath = ANALYTICS_CONFIG_PATH): string {\n try {\n if (existsSync(configPath)) {\n const config = JSON.parse(readFileSync(configPath, 'utf-8')) as AnalyticsConfig;\n if (\n config.distinctId &&\n isValidMastraAnalyticsDistinctId(config.distinctId) &&\n !isHostnameDerivedDistinctId(config.distinctId)\n ) {\n return config.distinctId;\n }\n }\n } catch {\n // regenerate below\n }\n\n const distinctId = createMastraAnalyticsDistinctId();\n writeAnalyticsConfig(distinctId, configPath);\n return distinctId;\n}\n\nfunction isAnalyticsDebugEnabled(): boolean {\n return TRUTHY_DISABLED_VALUES.has(process.env.MASTRACODE_ANALYTICS_DEBUG?.trim().toLowerCase() ?? '');\n}\n\nfunction debugAnalytics(message: string, properties?: Record<string, unknown>): void {\n if (!isAnalyticsDebugEnabled()) {\n return;\n }\n\n const suffix = properties ? ` ${JSON.stringify(properties)}` : '';\n process.stderr.write(`[mastracode analytics] ${message}${suffix}\\n`);\n}\n\nexport type MastraCodeAnalyticsEvent =\n | 'mastracode_session_started'\n | 'mastracode_prompt_submitted'\n | 'mastracode_thread_changed'\n | 'mastracode_model_changed'\n | 'mastracode_command_used'\n | 'mastracode_interactive_prompt_shown';\n\nexport interface MastraCodeAnalytics {\n capture(event: MastraCodeAnalyticsEvent, properties?: Record<string, unknown>): void;\n trackCommand(command: string, properties?: Record<string, unknown>): void;\n trackInteractivePrompt(promptType: string, properties?: Record<string, unknown>): void;\n shutdown(): Promise<void>;\n isEnabled(): boolean;\n}\n\ninterface MastraCodeAnalyticsOptions {\n version: string;\n host?: string;\n apiKey?: string;\n}\n\nclass NoopMastraCodeAnalytics implements MastraCodeAnalytics {\n capture(event: MastraCodeAnalyticsEvent): void {\n debugAnalytics('capture skipped: telemetry disabled', { event });\n }\n trackCommand(command: string): void {\n debugAnalytics('command skipped: telemetry disabled', { command });\n }\n trackInteractivePrompt(promptType: string): void {\n debugAnalytics('interactive prompt skipped: telemetry disabled', { promptType });\n }\n async shutdown(): Promise<void> {\n debugAnalytics('shutdown skipped: telemetry disabled');\n }\n isEnabled(): boolean {\n return false;\n }\n}\n\nclass PostHogMastraCodeAnalytics implements MastraCodeAnalytics {\n private readonly client: PostHog;\n private readonly distinctId: string;\n private readonly sessionId = globalThis.crypto.randomUUID();\n private readonly version: string;\n\n constructor({ version, apiKey = POSTHOG_API_KEY, host = POSTHOG_HOST }: MastraCodeAnalyticsOptions) {\n this.version = version;\n this.distinctId = getMastraAnalyticsDistinctId();\n this.client = new PostHog(apiKey, {\n host,\n flushAt: 1,\n flushInterval: 0,\n disableGeoip: false,\n });\n this.client.register({ mastraSource: MASTRA_SOURCE });\n debugAnalytics('enabled', { host, distinctId: this.distinctId, version });\n }\n\n capture(event: MastraCodeAnalyticsEvent, properties?: Record<string, unknown>): void {\n try {\n const eventProperties = {\n ...this.getBaseProperties(),\n ...properties,\n };\n debugAnalytics('capture', { event, properties: eventProperties });\n this.client.capture({\n distinctId: this.distinctId,\n event,\n properties: eventProperties,\n });\n } catch (error) {\n debugAnalytics('capture failed', { event, error: error instanceof Error ? error.message : String(error) });\n // swallow analytics errors\n }\n }\n\n trackCommand(command: string, properties?: Record<string, unknown>): void {\n this.capture('mastracode_command_used', { command, ...properties });\n }\n\n trackInteractivePrompt(promptType: string, properties?: Record<string, unknown>): void {\n this.capture('mastracode_interactive_prompt_shown', { promptType, ...properties });\n }\n\n async shutdown(): Promise<void> {\n try {\n debugAnalytics('shutdown start');\n await this.client.shutdown();\n debugAnalytics('shutdown complete');\n } catch (error) {\n debugAnalytics('shutdown failed', { error: error instanceof Error ? error.message : String(error) });\n // swallow analytics errors\n }\n }\n\n isEnabled(): boolean {\n return true;\n }\n\n private getBaseProperties(): Record<string, unknown> {\n return {\n mastraSource: MASTRA_SOURCE,\n sessionId: this.sessionId,\n version: this.version,\n os: process.platform,\n osVersion: os.release(),\n nodeVersion: process.version,\n platform: process.arch,\n machineId: os.hostname(),\n };\n }\n}\n\nexport function isTelemetryDisabled(env: NodeJS.ProcessEnv = process.env): boolean {\n const value = env.MASTRA_TELEMETRY_DISABLED;\n if (!value) {\n return false;\n }\n\n return TRUTHY_DISABLED_VALUES.has(value.trim().toLowerCase());\n}\n\nexport function createMastraCodeAnalytics(options: MastraCodeAnalyticsOptions): MastraCodeAnalytics {\n if (isTelemetryDisabled()) {\n debugAnalytics('disabled by MASTRA_TELEMETRY_DISABLED', { value: process.env.MASTRA_TELEMETRY_DISABLED });\n return new NoopMastraCodeAnalytics();\n }\n\n return new PostHogMastraCodeAnalytics(options);\n}\n"],"mappings":";;;;;AAMA,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,yCAAyB,IAAI,IAAI;CAAC;CAAK;CAAQ;CAAO;AAAI,CAAC;AACjE,MAAM,wBAAwB,KAAK,KAAK,GAAG,QAAQ,GAAG,eAAe,gBAAgB;AAMrF,SAAS,kCAA0C;CACjD,OAAO,UAAU,WAAW,OAAO,WAAW;AAChD;AAEA,SAAS,4BAA4B,YAAoB,WAAW,GAAG,SAAS,GAAY;CAC1F,OAAO,eAAe,UAAU;AAClC;A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