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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (491) hide show
  1. package/CHANGELOG.md +1349 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +70 -0
  4. package/dist/acp/agent.d.ts +35 -0
  5. package/dist/acp/agent.d.ts.map +1 -0
  6. package/dist/acp/agent.js +161 -0
  7. package/dist/acp/agent.js.map +1 -0
  8. package/dist/acp/event-mapper.d.ts +22 -0
  9. package/dist/acp/event-mapper.d.ts.map +1 -0
  10. package/dist/acp/event-mapper.js +214 -0
  11. package/dist/acp/event-mapper.js.map +1 -0
  12. package/dist/acp/index.d.ts +8 -0
  13. package/dist/acp/index.d.ts.map +1 -0
  14. package/dist/acp/index.js +65 -0
  15. package/dist/acp/index.js.map +1 -0
  16. package/dist/acp/server.d.ts +7 -0
  17. package/dist/acp/server.d.ts.map +1 -0
  18. package/dist/acp/server.js +35 -0
  19. package/dist/acp/server.js.map +1 -0
  20. package/dist/acp.d.ts +2 -0
  21. package/dist/acp.d.ts.map +1 -0
  22. package/dist/acp.js +2 -0
  23. package/dist/agents/credential-resolver.d.ts +51 -0
  24. package/dist/agents/credential-resolver.d.ts.map +1 -0
  25. package/dist/agents/credential-resolver.js +52 -0
  26. package/dist/agents/credential-resolver.js.map +1 -0
  27. package/dist/agents/custom-provider-source.d.ts +35 -0
  28. package/dist/agents/custom-provider-source.d.ts.map +1 -0
  29. package/dist/agents/custom-provider-source.js +25 -0
  30. package/dist/agents/custom-provider-source.js.map +1 -0
  31. package/dist/agents/instructions.d.ts +6 -0
  32. package/dist/agents/instructions.d.ts.map +1 -0
  33. package/dist/agents/instructions.js +32 -0
  34. package/dist/agents/instructions.js.map +1 -0
  35. package/dist/agents/mastracode-gateway.d.ts +74 -0
  36. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  37. package/dist/agents/mastracode-gateway.js +400 -0
  38. package/dist/agents/mastracode-gateway.js.map +1 -0
  39. package/dist/agents/memory.d.ts +13 -0
  40. package/dist/agents/memory.d.ts.map +1 -0
  41. package/dist/agents/memory.js +116 -0
  42. package/dist/agents/memory.js.map +1 -0
  43. package/dist/agents/model.d.ts +59 -0
  44. package/dist/agents/model.d.ts.map +1 -0
  45. package/dist/agents/model.js +132 -0
  46. package/dist/agents/model.js.map +1 -0
  47. package/dist/agents/modes/build.d.ts +10 -0
  48. package/dist/agents/modes/build.d.ts.map +1 -0
  49. package/dist/agents/modes/build.js +44 -0
  50. package/dist/agents/modes/build.js.map +1 -0
  51. package/dist/agents/modes/explore.d.ts +10 -0
  52. package/dist/agents/modes/explore.d.ts.map +1 -0
  53. package/dist/agents/modes/explore.js +39 -0
  54. package/dist/agents/modes/explore.js.map +1 -0
  55. package/dist/agents/modes/plan.d.ts +6 -0
  56. package/dist/agents/modes/plan.d.ts.map +1 -0
  57. package/dist/agents/modes/plan.js +37 -0
  58. package/dist/agents/modes/plan.js.map +1 -0
  59. package/dist/agents/prompts/agent-instructions.d.ts +61 -0
  60. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  61. package/dist/agents/prompts/agent-instructions.js +201 -0
  62. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  63. package/dist/agents/prompts/build.d.ts +12 -0
  64. package/dist/agents/prompts/build.d.ts.map +1 -0
  65. package/dist/agents/prompts/build.js +76 -0
  66. package/dist/agents/prompts/build.js.map +1 -0
  67. package/dist/agents/prompts/fast.d.ts +5 -0
  68. package/dist/agents/prompts/fast.d.ts.map +1 -0
  69. package/dist/agents/prompts/fast.js +26 -0
  70. package/dist/agents/prompts/fast.js.map +1 -0
  71. package/dist/agents/prompts/index.d.ts +19 -0
  72. package/dist/agents/prompts/index.d.ts.map +1 -0
  73. package/dist/agents/prompts/index.js +65 -0
  74. package/dist/agents/prompts/index.js.map +1 -0
  75. package/dist/agents/prompts/model.d.ts +5 -0
  76. package/dist/agents/prompts/model.d.ts.map +1 -0
  77. package/dist/agents/prompts/model.js +23 -0
  78. package/dist/agents/prompts/model.js.map +1 -0
  79. package/dist/agents/prompts/plan.d.ts +6 -0
  80. package/dist/agents/prompts/plan.d.ts.map +1 -0
  81. package/dist/agents/prompts/plan.js +111 -0
  82. package/dist/agents/prompts/plan.js.map +1 -0
  83. package/dist/agents/prompts/tool-guidance.d.ts +13 -0
  84. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  85. package/dist/agents/prompts/tool-guidance.js +149 -0
  86. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  87. package/dist/agents/sandbox-filesystem.d.ts +99 -0
  88. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  89. package/dist/agents/sandbox-filesystem.js +328 -0
  90. package/dist/agents/sandbox-filesystem.js.map +1 -0
  91. package/dist/agents/sandbox-reattach.d.ts +19 -0
  92. package/dist/agents/sandbox-reattach.d.ts.map +1 -0
  93. package/dist/agents/sandbox-reattach.js +15 -0
  94. package/dist/agents/sandbox-reattach.js.map +1 -0
  95. package/dist/agents/thread-caveman-state.d.ts +17 -0
  96. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  97. package/dist/agents/thread-caveman-state.js +107 -0
  98. package/dist/agents/thread-caveman-state.js.map +1 -0
  99. package/dist/agents/tool-availability.d.ts +10 -0
  100. package/dist/agents/tool-availability.d.ts.map +1 -0
  101. package/dist/agents/tool-availability.js +87 -0
  102. package/dist/agents/tool-availability.js.map +1 -0
  103. package/dist/agents/tools.d.ts +19 -0
  104. package/dist/agents/tools.d.ts.map +1 -0
  105. package/dist/agents/tools.js +105 -0
  106. package/dist/agents/tools.js.map +1 -0
  107. package/dist/agents/workspace.d.ts +32 -0
  108. package/dist/agents/workspace.d.ts.map +1 -0
  109. package/dist/agents/workspace.js +251 -0
  110. package/dist/agents/workspace.js.map +1 -0
  111. package/dist/analytics.d.ts +18 -0
  112. package/dist/analytics.d.ts.map +1 -0
  113. package/dist/analytics.js +163 -0
  114. package/dist/analytics.js.map +1 -0
  115. package/dist/auth/authorization-input.d.ts +16 -0
  116. package/dist/auth/authorization-input.d.ts.map +1 -0
  117. package/dist/auth/authorization-input.js +42 -0
  118. package/dist/auth/authorization-input.js.map +1 -0
  119. package/dist/auth/device-code.d.ts +93 -0
  120. package/dist/auth/device-code.d.ts.map +1 -0
  121. package/dist/auth/device-code.js +129 -0
  122. package/dist/auth/device-code.js.map +1 -0
  123. package/dist/auth/index.d.ts +10 -0
  124. package/dist/auth/index.d.ts.map +1 -0
  125. package/dist/auth/index.js +6 -0
  126. package/dist/auth/pkce.d.ts +13 -0
  127. package/dist/auth/pkce.d.ts.map +1 -0
  128. package/dist/auth/pkce.js +32 -0
  129. package/dist/auth/pkce.js.map +1 -0
  130. package/dist/auth/providers/anthropic.d.ts +40 -0
  131. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  132. package/dist/auth/providers/anthropic.js +126 -0
  133. package/dist/auth/providers/anthropic.js.map +1 -0
  134. package/dist/auth/providers/github-copilot.d.ts +154 -0
  135. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  136. package/dist/auth/providers/github-copilot.js +340 -0
  137. package/dist/auth/providers/github-copilot.js.map +1 -0
  138. package/dist/auth/providers/openai-codex.d.ts +139 -0
  139. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  140. package/dist/auth/providers/openai-codex.js +519 -0
  141. package/dist/auth/providers/openai-codex.js.map +1 -0
  142. package/dist/auth/providers/xai.d.ts +64 -0
  143. package/dist/auth/providers/xai.d.ts.map +1 -0
  144. package/dist/auth/providers/xai.js +205 -0
  145. package/dist/auth/providers/xai.js.map +1 -0
  146. package/dist/auth/storage.d.ts +91 -0
  147. package/dist/auth/storage.d.ts.map +1 -0
  148. package/dist/auth/storage.js +197 -0
  149. package/dist/auth/storage.js.map +1 -0
  150. package/dist/auth/types.d.ts +89 -0
  151. package/dist/auth/types.d.ts.map +1 -0
  152. package/dist/auth/types.js +1 -0
  153. package/dist/clipboard/index.d.ts +26 -0
  154. package/dist/clipboard/index.d.ts.map +1 -0
  155. package/dist/clipboard/index.js +226 -0
  156. package/dist/clipboard/index.js.map +1 -0
  157. package/dist/constants.d.ts +10 -0
  158. package/dist/constants.d.ts.map +1 -0
  159. package/dist/constants.js +18 -0
  160. package/dist/constants.js.map +1 -0
  161. package/dist/error-classification.d.ts +10 -0
  162. package/dist/error-classification.d.ts.map +1 -0
  163. package/dist/error-classification.js +22 -0
  164. package/dist/error-classification.js.map +1 -0
  165. package/dist/evals/context-builder.d.ts +41 -0
  166. package/dist/evals/context-builder.d.ts.map +1 -0
  167. package/dist/evals/context-builder.js +161 -0
  168. package/dist/evals/context-builder.js.map +1 -0
  169. package/dist/evals/index.d.ts +4 -0
  170. package/dist/evals/index.d.ts.map +1 -0
  171. package/dist/evals/index.js +5 -0
  172. package/dist/evals/scorers/classify-command.d.ts +31 -0
  173. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  174. package/dist/evals/scorers/classify-command.js +73 -0
  175. package/dist/evals/scorers/classify-command.js.map +1 -0
  176. package/dist/evals/scorers/efficiency.d.ts +44 -0
  177. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  178. package/dist/evals/scorers/efficiency.js +259 -0
  179. package/dist/evals/scorers/efficiency.js.map +1 -0
  180. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  181. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  182. package/dist/evals/scorers/extract-tools.js +60 -0
  183. package/dist/evals/scorers/extract-tools.js.map +1 -0
  184. package/dist/evals/scorers/index.d.ts +3 -0
  185. package/dist/evals/scorers/index.d.ts.map +1 -0
  186. package/dist/evals/scorers/index.js +3 -0
  187. package/dist/evals/scorers/outcome.d.ts +49 -0
  188. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  189. package/dist/evals/scorers/outcome.js +347 -0
  190. package/dist/evals/scorers/outcome.js.map +1 -0
  191. package/dist/goal-manager.d.ts +78 -0
  192. package/dist/goal-manager.d.ts.map +1 -0
  193. package/dist/goal-manager.js +273 -0
  194. package/dist/goal-manager.js.map +1 -0
  195. package/dist/goal-signal.d.ts +14 -0
  196. package/dist/goal-signal.d.ts.map +1 -0
  197. package/dist/goal-signal.js +17 -0
  198. package/dist/goal-signal.js.map +1 -0
  199. package/dist/headless/cli.d.ts +42 -0
  200. package/dist/headless/cli.d.ts.map +1 -0
  201. package/dist/headless/cli.js +195 -0
  202. package/dist/headless/cli.js.map +1 -0
  203. package/dist/headless/flags.d.ts +33 -0
  204. package/dist/headless/flags.d.ts.map +1 -0
  205. package/dist/headless/flags.js +190 -0
  206. package/dist/headless/flags.js.map +1 -0
  207. package/dist/headless/format.d.ts +38 -0
  208. package/dist/headless/format.d.ts.map +1 -0
  209. package/dist/headless/format.js +89 -0
  210. package/dist/headless/format.js.map +1 -0
  211. package/dist/headless/index.d.ts +25 -0
  212. package/dist/headless/index.d.ts.map +1 -0
  213. package/dist/headless/index.js +6 -0
  214. package/dist/headless/policy.d.ts +17 -0
  215. package/dist/headless/policy.d.ts.map +1 -0
  216. package/dist/headless/policy.js +42 -0
  217. package/dist/headless/policy.js.map +1 -0
  218. package/dist/headless/run-mc.d.ts +7 -0
  219. package/dist/headless/run-mc.d.ts.map +1 -0
  220. package/dist/headless/run-mc.js +346 -0
  221. package/dist/headless/run-mc.js.map +1 -0
  222. package/dist/headless/types.d.ts +158 -0
  223. package/dist/headless/types.d.ts.map +1 -0
  224. package/dist/headless/types.js +18 -0
  225. package/dist/headless/types.js.map +1 -0
  226. package/dist/hooks/config.d.ts +11 -0
  227. package/dist/hooks/config.d.ts.map +1 -0
  228. package/dist/hooks/config.js +73 -0
  229. package/dist/hooks/config.js.map +1 -0
  230. package/dist/hooks/executor.d.ts +13 -0
  231. package/dist/hooks/executor.d.ts.map +1 -0
  232. package/dist/hooks/executor.js +128 -0
  233. package/dist/hooks/executor.js.map +1 -0
  234. package/dist/hooks/index.d.ts +6 -0
  235. package/dist/hooks/index.d.ts.map +1 -0
  236. package/dist/hooks/index.js +5 -0
  237. package/dist/hooks/manager.d.ts +47 -0
  238. package/dist/hooks/manager.d.ts.map +1 -0
  239. package/dist/hooks/manager.js +225 -0
  240. package/dist/hooks/manager.js.map +1 -0
  241. package/dist/hooks/types.d.ts +152 -0
  242. package/dist/hooks/types.d.ts.map +1 -0
  243. package/dist/hooks/types.js +8 -0
  244. package/dist/hooks/types.js.map +1 -0
  245. package/dist/index.d.ts +258 -0
  246. package/dist/index.d.ts.map +1 -0
  247. package/dist/index.js +740 -0
  248. package/dist/index.js.map +1 -0
  249. package/dist/ipc/ipc-reporter.d.ts +14 -0
  250. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  251. package/dist/ipc/ipc-reporter.js +21 -0
  252. package/dist/ipc/ipc-reporter.js.map +1 -0
  253. package/dist/lsp/client.d.ts +56 -0
  254. package/dist/lsp/client.d.ts.map +1 -0
  255. package/dist/lsp/client.js +251 -0
  256. package/dist/lsp/client.js.map +1 -0
  257. package/dist/lsp/index.d.ts +4 -0
  258. package/dist/lsp/index.d.ts.map +1 -0
  259. package/dist/lsp/index.js +4 -0
  260. package/dist/lsp/language.d.ts +9 -0
  261. package/dist/lsp/language.d.ts.map +1 -0
  262. package/dist/lsp/language.js +44 -0
  263. package/dist/lsp/language.js.map +1 -0
  264. package/dist/lsp/manager.d.ts +34 -0
  265. package/dist/lsp/manager.d.ts.map +1 -0
  266. package/dist/lsp/manager.js +82 -0
  267. package/dist/lsp/manager.js.map +1 -0
  268. package/dist/lsp/server.d.ts +27 -0
  269. package/dist/lsp/server.d.ts.map +1 -0
  270. package/dist/lsp/server.js +159 -0
  271. package/dist/lsp/server.js.map +1 -0
  272. package/dist/lsp/workspace.d.ts +9 -0
  273. package/dist/lsp/workspace.d.ts.map +1 -0
  274. package/dist/lsp/workspace.js +55 -0
  275. package/dist/lsp/workspace.js.map +1 -0
  276. package/dist/mcp/config.d.ts +54 -0
  277. package/dist/mcp/config.d.ts.map +1 -0
  278. package/dist/mcp/config.js +240 -0
  279. package/dist/mcp/config.js.map +1 -0
  280. package/dist/mcp/index.d.ts +5 -0
  281. package/dist/mcp/index.d.ts.map +1 -0
  282. package/dist/mcp/index.js +3 -0
  283. package/dist/mcp/manager.d.ts +98 -0
  284. package/dist/mcp/manager.d.ts.map +1 -0
  285. package/dist/mcp/manager.js +612 -0
  286. package/dist/mcp/manager.js.map +1 -0
  287. package/dist/mcp/state.d.ts +33 -0
  288. package/dist/mcp/state.d.ts.map +1 -0
  289. package/dist/mcp/state.js +88 -0
  290. package/dist/mcp/state.js.map +1 -0
  291. package/dist/mcp/types.d.ts +120 -0
  292. package/dist/mcp/types.d.ts.map +1 -0
  293. package/dist/mcp/types.js +1 -0
  294. package/dist/onboarding/custom-packs.d.ts +7 -0
  295. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  296. package/dist/onboarding/custom-packs.js +17 -0
  297. package/dist/onboarding/custom-packs.js.map +1 -0
  298. package/dist/onboarding/custom-providers.d.ts +4 -0
  299. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  300. package/dist/onboarding/custom-providers.js +30 -0
  301. package/dist/onboarding/custom-providers.js.map +1 -0
  302. package/dist/onboarding/index.d.ts +5 -0
  303. package/dist/onboarding/index.d.ts.map +1 -0
  304. package/dist/onboarding/index.js +3 -0
  305. package/dist/onboarding/om-settings.d.ts +25 -0
  306. package/dist/onboarding/om-settings.d.ts.map +1 -0
  307. package/dist/onboarding/om-settings.js +47 -0
  308. package/dist/onboarding/om-settings.js.map +1 -0
  309. package/dist/onboarding/packs.d.ts +46 -0
  310. package/dist/onboarding/packs.d.ts.map +1 -0
  311. package/dist/onboarding/packs.js +160 -0
  312. package/dist/onboarding/packs.js.map +1 -0
  313. package/dist/onboarding/settings.d.ts +338 -0
  314. package/dist/onboarding/settings.d.ts.map +1 -0
  315. package/dist/onboarding/settings.js +673 -0
  316. package/dist/onboarding/settings.js.map +1 -0
  317. package/dist/permissions.d.ts +55 -0
  318. package/dist/permissions.d.ts.map +1 -0
  319. package/dist/permissions.js +132 -0
  320. package/dist/permissions.js.map +1 -0
  321. package/dist/plugin.d.ts +81 -0
  322. package/dist/plugin.d.ts.map +1 -0
  323. package/dist/plugin.js +28 -0
  324. package/dist/plugin.js.map +1 -0
  325. package/dist/plugins/dependencies.d.ts +9 -0
  326. package/dist/plugins/dependencies.d.ts.map +1 -0
  327. package/dist/plugins/dependencies.js +88 -0
  328. package/dist/plugins/dependencies.js.map +1 -0
  329. package/dist/plugins/install.d.ts +21 -0
  330. package/dist/plugins/install.d.ts.map +1 -0
  331. package/dist/plugins/install.js +190 -0
  332. package/dist/plugins/install.js.map +1 -0
  333. package/dist/plugins/loader.d.ts +15 -0
  334. package/dist/plugins/loader.d.ts.map +1 -0
  335. package/dist/plugins/loader.js +206 -0
  336. package/dist/plugins/loader.js.map +1 -0
  337. package/dist/plugins/manager.d.ts +64 -0
  338. package/dist/plugins/manager.d.ts.map +1 -0
  339. package/dist/plugins/manager.js +384 -0
  340. package/dist/plugins/manager.js.map +1 -0
  341. package/dist/plugins/manifest.d.ts +14 -0
  342. package/dist/plugins/manifest.d.ts.map +1 -0
  343. package/dist/plugins/manifest.js +50 -0
  344. package/dist/plugins/manifest.js.map +1 -0
  345. package/dist/plugins/package-link.d.ts +3 -0
  346. package/dist/plugins/package-link.d.ts.map +1 -0
  347. package/dist/plugins/package-link.js +61 -0
  348. package/dist/plugins/package-link.js.map +1 -0
  349. package/dist/plugins/paths.d.ts +10 -0
  350. package/dist/plugins/paths.d.ts.map +1 -0
  351. package/dist/plugins/paths.js +25 -0
  352. package/dist/plugins/paths.js.map +1 -0
  353. package/dist/plugins/registry.d.ts +8 -0
  354. package/dist/plugins/registry.d.ts.map +1 -0
  355. package/dist/plugins/registry.js +112 -0
  356. package/dist/plugins/registry.js.map +1 -0
  357. package/dist/plugins/scaffold.d.ts +10 -0
  358. package/dist/plugins/scaffold.d.ts.map +1 -0
  359. package/dist/plugins/scaffold.js +116 -0
  360. package/dist/plugins/scaffold.js.map +1 -0
  361. package/dist/plugins/types.d.ts +45 -0
  362. package/dist/plugins/types.d.ts.map +1 -0
  363. package/dist/plugins/types.js +1 -0
  364. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  365. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  366. package/dist/processors/plan-rejection-abort.js +54 -0
  367. package/dist/processors/plan-rejection-abort.js.map +1 -0
  368. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  369. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  370. package/dist/providers/amazon-bedrock-gateway.js +152 -0
  371. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  372. package/dist/providers/amazon-bedrock.d.ts +28 -0
  373. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  374. package/dist/providers/amazon-bedrock.js +83 -0
  375. package/dist/providers/amazon-bedrock.js.map +1 -0
  376. package/dist/providers/claude-max.d.ts +52 -0
  377. package/dist/providers/claude-max.d.ts.map +1 -0
  378. package/dist/providers/claude-max.js +171 -0
  379. package/dist/providers/claude-max.js.map +1 -0
  380. package/dist/providers/github-copilot.d.ts +60 -0
  381. package/dist/providers/github-copilot.d.ts.map +1 -0
  382. package/dist/providers/github-copilot.js +265 -0
  383. package/dist/providers/github-copilot.js.map +1 -0
  384. package/dist/providers/openai-codex.d.ts +72 -0
  385. package/dist/providers/openai-codex.d.ts.map +1 -0
  386. package/dist/providers/openai-codex.js +302 -0
  387. package/dist/providers/openai-codex.js.map +1 -0
  388. package/dist/providers/xai.d.ts +33 -0
  389. package/dist/providers/xai.d.ts.map +1 -0
  390. package/dist/providers/xai.js +70 -0
  391. package/dist/providers/xai.js.map +1 -0
  392. package/dist/schema.d.ts +192 -0
  393. package/dist/schema.d.ts.map +1 -0
  394. package/dist/schema.js +98 -0
  395. package/dist/schema.js.map +1 -0
  396. package/dist/theme-palette.d.ts +17 -0
  397. package/dist/theme-palette.d.ts.map +1 -0
  398. package/dist/theme-palette.js +21 -0
  399. package/dist/theme-palette.js.map +1 -0
  400. package/dist/tool-names.d.ts +73 -0
  401. package/dist/tool-names.d.ts.map +1 -0
  402. package/dist/tool-names.js +52 -0
  403. package/dist/tool-names.js.map +1 -0
  404. package/dist/tools/index.d.ts +6 -0
  405. package/dist/tools/index.d.ts.map +1 -0
  406. package/dist/tools/index.js +3 -0
  407. package/dist/tools/request-sandbox-access.d.ts +6 -0
  408. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  409. package/dist/tools/request-sandbox-access.js +79 -0
  410. package/dist/tools/request-sandbox-access.js.map +1 -0
  411. package/dist/tools/utils.d.ts +20 -0
  412. package/dist/tools/utils.d.ts.map +1 -0
  413. package/dist/tools/utils.js +32 -0
  414. package/dist/tools/utils.js.map +1 -0
  415. package/dist/tools/web-search.d.ts +35 -0
  416. package/dist/tools/web-search.d.ts.map +1 -0
  417. package/dist/tools/web-search.js +61 -0
  418. package/dist/tools/web-search.js.map +1 -0
  419. package/dist/utils/binaries.d.ts +7 -0
  420. package/dist/utils/binaries.d.ts.map +1 -0
  421. package/dist/utils/binaries.js +78 -0
  422. package/dist/utils/binaries.js.map +1 -0
  423. package/dist/utils/debug-log.d.ts +12 -0
  424. package/dist/utils/debug-log.d.ts.map +1 -0
  425. package/dist/utils/debug-log.js +59 -0
  426. package/dist/utils/debug-log.js.map +1 -0
  427. package/dist/utils/errors.d.ts +36 -0
  428. package/dist/utils/errors.d.ts.map +1 -0
  429. package/dist/utils/errors.js +172 -0
  430. package/dist/utils/errors.js.map +1 -0
  431. package/dist/utils/gateway-sync.d.ts +26 -0
  432. package/dist/utils/gateway-sync.d.ts.map +1 -0
  433. package/dist/utils/gateway-sync.js +61 -0
  434. package/dist/utils/gateway-sync.js.map +1 -0
  435. package/dist/utils/path-security.d.ts +2 -0
  436. package/dist/utils/path-security.d.ts.map +1 -0
  437. package/dist/utils/path-security.js +10 -0
  438. package/dist/utils/path-security.js.map +1 -0
  439. package/dist/utils/plan-diff.d.ts +25 -0
  440. package/dist/utils/plan-diff.d.ts.map +1 -0
  441. package/dist/utils/plan-diff.js +62 -0
  442. package/dist/utils/plan-diff.js.map +1 -0
  443. package/dist/utils/plans.d.ts +56 -0
  444. package/dist/utils/plans.d.ts.map +1 -0
  445. package/dist/utils/plans.js +117 -0
  446. package/dist/utils/plans.js.map +1 -0
  447. package/dist/utils/project.d.ts +160 -0
  448. package/dist/utils/project.d.ts.map +1 -0
  449. package/dist/utils/project.js +364 -0
  450. package/dist/utils/project.js.map +1 -0
  451. package/dist/utils/signals-pubsub.d.ts +41 -0
  452. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  453. package/dist/utils/signals-pubsub.js +122 -0
  454. package/dist/utils/signals-pubsub.js.map +1 -0
  455. package/dist/utils/slash-command-loader.d.ts +52 -0
  456. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  457. package/dist/utils/slash-command-loader.js +141 -0
  458. package/dist/utils/slash-command-loader.js.map +1 -0
  459. package/dist/utils/slash-command-processor.d.ts +14 -0
  460. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  461. package/dist/utils/slash-command-processor.js +105 -0
  462. package/dist/utils/slash-command-processor.js.map +1 -0
  463. package/dist/utils/stdin-pipe.d.ts +33 -0
  464. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  465. package/dist/utils/stdin-pipe.js +96 -0
  466. package/dist/utils/stdin-pipe.js.map +1 -0
  467. package/dist/utils/storage-factory.d.ts +50 -0
  468. package/dist/utils/storage-factory.d.ts.map +1 -0
  469. package/dist/utils/storage-factory.js +121 -0
  470. package/dist/utils/storage-factory.js.map +1 -0
  471. package/dist/utils/storage-maintenance.d.ts +103 -0
  472. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  473. package/dist/utils/storage-maintenance.js +274 -0
  474. package/dist/utils/storage-maintenance.js.map +1 -0
  475. package/dist/utils/thread-lock.d.ts +26 -0
  476. package/dist/utils/thread-lock.d.ts.map +1 -0
  477. package/dist/utils/thread-lock.js +112 -0
  478. package/dist/utils/thread-lock.js.map +1 -0
  479. package/dist/utils/token-estimator.d.ts +3 -0
  480. package/dist/utils/token-estimator.d.ts.map +1 -0
  481. package/dist/utils/token-estimator.js +21 -0
  482. package/dist/utils/token-estimator.js.map +1 -0
  483. package/dist/utils/update-check.d.ts +101 -0
  484. package/dist/utils/update-check.d.ts.map +1 -0
  485. package/dist/utils/update-check.js +383 -0
  486. package/dist/utils/update-check.js.map +1 -0
  487. package/dist/voice/stt-registry.d.ts +64 -0
  488. package/dist/voice/stt-registry.d.ts.map +1 -0
  489. package/dist/voice/stt-registry.js +144 -0
  490. package/dist/voice/stt-registry.js.map +1 -0
  491. package/package.json +96 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clipboard/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAgChD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA+BtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAYzD"}
@@ -0,0 +1,226 @@
1
+ import { readFileSync, unlinkSync } from "fs";
2
+ import { tmpdir } from "os";
3
+ import { join } from "path";
4
+ import { execSync } from "child_process";
5
+ //#region src/clipboard/index.ts
6
+ /**
7
+ * Platform-specific clipboard image extraction.
8
+ *
9
+ * Checks the system clipboard for image data and returns it as base64.
10
+ * Uses synchronous execution (execSync) since this only runs on paste events.
11
+ */
12
+ /**
13
+ * Read plain text from the system clipboard.
14
+ * Returns null if clipboard is empty or reading fails.
15
+ */
16
+ function getClipboardText() {
17
+ try {
18
+ if (process.platform === "darwin") {
19
+ const text = execSync("pbpaste", {
20
+ encoding: "utf-8",
21
+ timeout: 3e3,
22
+ stdio: [
23
+ "pipe",
24
+ "pipe",
25
+ "pipe"
26
+ ]
27
+ });
28
+ return text.length > 0 ? text : null;
29
+ }
30
+ if (process.platform === "linux") try {
31
+ const text = execSync("xclip -selection clipboard -o", {
32
+ encoding: "utf-8",
33
+ timeout: 3e3,
34
+ stdio: [
35
+ "pipe",
36
+ "pipe",
37
+ "pipe"
38
+ ]
39
+ });
40
+ return text.length > 0 ? text : null;
41
+ } catch {
42
+ const text = execSync("wl-paste", {
43
+ encoding: "utf-8",
44
+ timeout: 3e3,
45
+ stdio: [
46
+ "pipe",
47
+ "pipe",
48
+ "pipe"
49
+ ]
50
+ });
51
+ return text.length > 0 ? text : null;
52
+ }
53
+ return null;
54
+ } catch {
55
+ return null;
56
+ }
57
+ }
58
+ /**
59
+ * Write plain text to the system clipboard.
60
+ * Returns true on success, false on failure.
61
+ */
62
+ function setClipboardText(text) {
63
+ try {
64
+ if (process.platform === "darwin") {
65
+ execSync("pbcopy", {
66
+ input: text,
67
+ timeout: 3e3,
68
+ stdio: [
69
+ "pipe",
70
+ "pipe",
71
+ "pipe"
72
+ ]
73
+ });
74
+ return true;
75
+ }
76
+ if (process.platform === "linux") try {
77
+ execSync("xclip -selection clipboard", {
78
+ input: text,
79
+ timeout: 3e3,
80
+ stdio: [
81
+ "pipe",
82
+ "pipe",
83
+ "pipe"
84
+ ]
85
+ });
86
+ return true;
87
+ } catch {
88
+ execSync("wl-copy", {
89
+ input: text,
90
+ timeout: 3e3,
91
+ stdio: [
92
+ "pipe",
93
+ "pipe",
94
+ "pipe"
95
+ ]
96
+ });
97
+ return true;
98
+ }
99
+ return false;
100
+ } catch {
101
+ return false;
102
+ }
103
+ }
104
+ /**
105
+ * Check the system clipboard for image data and return it as base64.
106
+ * Returns null if no image data is found or extraction fails.
107
+ */
108
+ function getClipboardImage() {
109
+ try {
110
+ if (process.platform === "darwin") return getMacClipboardImage();
111
+ if (process.platform === "linux") return getLinuxClipboardImage();
112
+ return null;
113
+ } catch {
114
+ return null;
115
+ }
116
+ }
117
+ function getMacClipboardImage() {
118
+ return tryReadMacClipboardImage({
119
+ coercion: "«class PNGf»",
120
+ extension: "png",
121
+ mimeType: "image/png"
122
+ }) ?? tryReadMacClipboardImage({
123
+ coercion: "TIFF picture",
124
+ extension: "tiff",
125
+ mimeType: "image/tiff"
126
+ }) ?? tryReadMacClipboardImage({
127
+ coercion: "«class TIFF»",
128
+ extension: "tiff",
129
+ mimeType: "image/tiff"
130
+ });
131
+ }
132
+ function tryReadMacClipboardImage({ coercion, extension, mimeType }) {
133
+ const tmpFile = join(tmpdir(), `mastra-clipboard-${Date.now()}.${extension}`);
134
+ try {
135
+ execSync(`osascript -e '${`
136
+ set theImage to the clipboard as ${coercion}
137
+ set theFile to open for access POSIX file "${tmpFile}" with write permission
138
+ write theImage to theFile
139
+ close access theFile
140
+ `.replace(/'/g, "'\\''")}'`, {
141
+ timeout: 5e3,
142
+ stdio: [
143
+ "pipe",
144
+ "pipe",
145
+ "pipe"
146
+ ]
147
+ });
148
+ const buffer = readFileSync(tmpFile);
149
+ if (!Buffer.isBuffer(buffer) || buffer.length === 0) return null;
150
+ return {
151
+ data: buffer.toString("base64"),
152
+ mimeType
153
+ };
154
+ } catch {
155
+ return null;
156
+ } finally {
157
+ try {
158
+ unlinkSync(tmpFile);
159
+ } catch {}
160
+ }
161
+ }
162
+ function getLinuxClipboardImage() {
163
+ return getLinuxClipboardImageXclip() ?? getLinuxClipboardImageWlPaste();
164
+ }
165
+ function getLinuxClipboardImageXclip() {
166
+ try {
167
+ if (!execSync("xclip -selection clipboard -target TARGETS -o", {
168
+ encoding: "utf-8",
169
+ timeout: 3e3,
170
+ stdio: [
171
+ "pipe",
172
+ "pipe",
173
+ "pipe"
174
+ ]
175
+ }).includes("image/png")) return null;
176
+ const buffer = execSync("xclip -selection clipboard -target image/png -o", {
177
+ timeout: 5e3,
178
+ stdio: [
179
+ "pipe",
180
+ "pipe",
181
+ "pipe"
182
+ ],
183
+ maxBuffer: 50 * 1024 * 1024
184
+ });
185
+ if (!Buffer.isBuffer(buffer) || buffer.length === 0) return null;
186
+ return {
187
+ data: buffer.toString("base64"),
188
+ mimeType: "image/png"
189
+ };
190
+ } catch {
191
+ return null;
192
+ }
193
+ }
194
+ function getLinuxClipboardImageWlPaste() {
195
+ try {
196
+ if (!execSync("wl-paste --list-types", {
197
+ encoding: "utf-8",
198
+ timeout: 3e3,
199
+ stdio: [
200
+ "pipe",
201
+ "pipe",
202
+ "pipe"
203
+ ]
204
+ }).includes("image/png")) return null;
205
+ const buffer = execSync("wl-paste --type image/png", {
206
+ timeout: 5e3,
207
+ stdio: [
208
+ "pipe",
209
+ "pipe",
210
+ "pipe"
211
+ ],
212
+ maxBuffer: 50 * 1024 * 1024
213
+ });
214
+ if (!Buffer.isBuffer(buffer) || buffer.length === 0) return null;
215
+ return {
216
+ data: buffer.toString("base64"),
217
+ mimeType: "image/png"
218
+ };
219
+ } catch {
220
+ return null;
221
+ }
222
+ }
223
+ //#endregion
224
+ export { getClipboardImage, getClipboardText, setClipboardText };
225
+
226
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/clipboard/index.ts"],"sourcesContent":["/**\n * Platform-specific clipboard image extraction.\n *\n * Checks the system clipboard for image data and returns it as base64.\n * Uses synchronous execution (execSync) since this only runs on paste events.\n */\n\nimport { execSync } from 'node:child_process';\nimport { readFileSync, unlinkSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\n\nexport interface ClipboardImage {\n data: string; // base64-encoded image data or a remote image URL\n mimeType: string;\n}\n\n/**\n * Read plain text from the system clipboard.\n * Returns null if clipboard is empty or reading fails.\n */\nexport function getClipboardText(): string | null {\n try {\n if (process.platform === 'darwin') {\n const text = execSync('pbpaste', {\n encoding: 'utf-8',\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n return text.length > 0 ? text : null;\n }\n if (process.platform === 'linux') {\n // Try xclip first, then wl-paste\n try {\n const text = execSync('xclip -selection clipboard -o', {\n encoding: 'utf-8',\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n return text.length > 0 ? text : null;\n } catch {\n const text = execSync('wl-paste', {\n encoding: 'utf-8',\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n return text.length > 0 ? text : null;\n }\n }\n return null;\n } catch {\n return null;\n }\n}\n\n/**\n * Write plain text to the system clipboard.\n * Returns true on success, false on failure.\n */\nexport function setClipboardText(text: string): boolean {\n try {\n if (process.platform === 'darwin') {\n execSync('pbcopy', {\n input: text,\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n return true;\n }\n if (process.platform === 'linux') {\n try {\n execSync('xclip -selection clipboard', {\n input: text,\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n return true;\n } catch {\n execSync('wl-copy', {\n input: text,\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n return true;\n }\n }\n return false;\n } catch {\n return false;\n }\n}\n\n/**\n * Check the system clipboard for image data and return it as base64.\n * Returns null if no image data is found or extraction fails.\n */\nexport function getClipboardImage(): ClipboardImage | null {\n try {\n if (process.platform === 'darwin') {\n return getMacClipboardImage();\n }\n if (process.platform === 'linux') {\n return getLinuxClipboardImage();\n }\n return null;\n } catch {\n return null;\n }\n}\n\n// =============================================================================\n// macOS\n// =============================================================================\n\nfunction getMacClipboardImage(): ClipboardImage | null {\n return (\n tryReadMacClipboardImage({\n coercion: '«class PNGf»',\n extension: 'png',\n mimeType: 'image/png',\n }) ??\n tryReadMacClipboardImage({\n coercion: 'TIFF picture',\n extension: 'tiff',\n mimeType: 'image/tiff',\n }) ??\n tryReadMacClipboardImage({\n coercion: '«class TIFF»',\n extension: 'tiff',\n mimeType: 'image/tiff',\n })\n );\n}\n\nfunction tryReadMacClipboardImage({\n coercion,\n extension,\n mimeType,\n}: {\n coercion: string;\n extension: string;\n mimeType: string;\n}): ClipboardImage | null {\n const tmpFile = join(tmpdir(), `mastra-clipboard-${Date.now()}.${extension}`);\n\n try {\n const script = `\n\t\t\tset theImage to the clipboard as ${coercion}\n\t\t\tset theFile to open for access POSIX file \"${tmpFile}\" with write permission\n\t\t\twrite theImage to theFile\n\t\t\tclose access theFile\n\t\t`;\n execSync(`osascript -e '${script.replace(/'/g, \"'\\\\''\")}'`, {\n timeout: 5000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n const buffer = readFileSync(tmpFile);\n if (!Buffer.isBuffer(buffer) || buffer.length === 0) {\n return null;\n }\n\n return {\n data: buffer.toString('base64'),\n mimeType,\n };\n } catch {\n return null;\n } finally {\n try {\n unlinkSync(tmpFile);\n } catch {\n // ignore cleanup errors\n }\n }\n}\n\n// =============================================================================\n// Linux\n// =============================================================================\n\nfunction getLinuxClipboardImage(): ClipboardImage | null {\n // Try xclip first, then wl-paste (Wayland)\n return getLinuxClipboardImageXclip() ?? getLinuxClipboardImageWlPaste();\n}\n\nfunction getLinuxClipboardImageXclip(): ClipboardImage | null {\n try {\n // Check available targets\n const targets = execSync('xclip -selection clipboard -target TARGETS -o', {\n encoding: 'utf-8',\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n if (!targets.includes('image/png')) {\n return null;\n }\n\n // Extract PNG data\n const buffer = execSync('xclip -selection clipboard -target image/png -o', {\n timeout: 5000,\n stdio: ['pipe', 'pipe', 'pipe'],\n maxBuffer: 50 * 1024 * 1024, // 50MB max\n });\n\n if (!Buffer.isBuffer(buffer) || buffer.length === 0) {\n return null;\n }\n\n return {\n data: buffer.toString('base64'),\n mimeType: 'image/png',\n };\n } catch {\n return null;\n }\n}\n\nfunction getLinuxClipboardImageWlPaste(): ClipboardImage | null {\n try {\n // Check if wl-paste is available and clipboard has image\n const types = execSync('wl-paste --list-types', {\n encoding: 'utf-8',\n timeout: 3000,\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n\n if (!types.includes('image/png')) {\n return null;\n }\n\n // Extract PNG data\n const buffer = execSync('wl-paste --type image/png', {\n timeout: 5000,\n stdio: ['pipe', 'pipe', 'pipe'],\n maxBuffer: 50 * 1024 * 1024,\n });\n\n if (!Buffer.isBuffer(buffer) || buffer.length === 0) {\n return null;\n }\n\n return {\n data: buffer.toString('base64'),\n mimeType: 'image/png',\n };\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,mBAAkC;CAChD,IAAI;EACF,IAAI,QAAQ,aAAa,UAAU;GACjC,MAAM,OAAO,SAAS,WAAW;IAC/B,UAAU;IACV,SAAS;IACT,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;GACD,OAAO,KAAK,SAAS,IAAI,OAAO;EAClC;EACA,IAAI,QAAQ,aAAa,SAEvB,IAAI;GACF,MAAM,OAAO,SAAS,iCAAiC;IACrD,UAAU;IACV,SAAS;IACT,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;GACD,OAAO,KAAK,SAAS,IAAI,OAAO;EAClC,QAAQ;GACN,MAAM,OAAO,SAAS,YAAY;IAChC,UAAU;IACV,SAAS;IACT,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;GACD,OAAO,KAAK,SAAS,IAAI,OAAO;EAClC;EAEF,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,iBAAiB,MAAuB;CACtD,IAAI;EACF,IAAI,QAAQ,aAAa,UAAU;GACjC,SAAS,UAAU;IACjB,OAAO;IACP,SAAS;IACT,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;GACD,OAAO;EACT;EACA,IAAI,QAAQ,aAAa,SACvB,IAAI;GACF,SAAS,8BAA8B;IACrC,OAAO;IACP,SAAS;IACT,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;GACD,OAAO;EACT,QAAQ;GACN,SAAS,WAAW;IAClB,OAAO;IACP,SAAS;IACT,OAAO;KAAC;KAAQ;KAAQ;IAAM;GAChC,CAAC;GACD,OAAO;EACT;EAEF,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,oBAA2C;CACzD,IAAI;EACF,IAAI,QAAQ,aAAa,UACvB,OAAO,qBAAqB;EAE9B,IAAI,QAAQ,aAAa,SACvB,OAAO,uBAAuB;EAEhC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AAMA,SAAS,uBAA8C;CACrD,OACE,yBAAyB;EACvB,UAAU;EACV,WAAW;EACX,UAAU;CACZ,CAAC,KACD,yBAAyB;EACvB,UAAU;EACV,WAAW;EACX,UAAU;CACZ,CAAC,KACD,yBAAyB;EACvB,UAAU;EACV,WAAW;EACX,UAAU;CACZ,CAAC;AAEL;AAEA,SAAS,yBAAyB,EAChC,UACA,WACA,YAKwB;CACxB,MAAM,UAAU,KAAK,OAAO,GAAG,oBAAoB,KAAK,IAAI,EAAE,GAAG,WAAW;CAE5E,IAAI;EAOF,SAAS,iBAAiB;sCALQ,SAAS;gDACC,QAAQ;;;IAInB,QAAQ,MAAM,OAAO,EAAE,IAAI;GAC1D,SAAS;GACT,OAAO;IAAC;IAAQ;IAAQ;GAAM;EAChC,CAAC;EAED,MAAM,SAAS,aAAa,OAAO;EACnC,IAAI,CAAC,OAAO,SAAS,MAAM,KAAK,OAAO,WAAW,GAChD,OAAO;EAGT,OAAO;GACL,MAAM,OAAO,SAAS,QAAQ;GAC9B;EACF;CACF,QAAQ;EACN,OAAO;CACT,UAAU;EACR,IAAI;GACF,WAAW,OAAO;EACpB,QAAQ,CAER;CACF;AACF;AAMA,SAAS,yBAAgD;CAEvD,OAAO,4BAA4B,KAAK,8BAA8B;AACxE;AAEA,SAAS,8BAAqD;CAC5D,IAAI;EAQF,IAAI,CANY,SAAS,iDAAiD;GACxE,UAAU;GACV,SAAS;GACT,OAAO;IAAC;IAAQ;IAAQ;GAAM;EAChC,CAEW,CAAC,CAAC,SAAS,WAAW,GAC/B,OAAO;EAIT,MAAM,SAAS,SAAS,mDAAmD;GACzE,SAAS;GACT,OAAO;IAAC;IAAQ;IAAQ;GAAM;GAC9B,WAAW,KAAK,OAAO;EACzB,CAAC;EAED,IAAI,CAAC,OAAO,SAAS,MAAM,KAAK,OAAO,WAAW,GAChD,OAAO;EAGT,OAAO;GACL,MAAM,OAAO,SAAS,QAAQ;GAC9B,UAAU;EACZ;CACF,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,gCAAuD;CAC9D,IAAI;EAQF,IAAI,CANU,SAAS,yBAAyB;GAC9C,UAAU;GACV,SAAS;GACT,OAAO;IAAC;IAAQ;IAAQ;GAAM;EAChC,CAES,CAAC,CAAC,SAAS,WAAW,GAC7B,OAAO;EAIT,MAAM,SAAS,SAAS,6BAA6B;GACnD,SAAS;GACT,OAAO;IAAC;IAAQ;IAAQ;GAAM;GAC9B,WAAW,KAAK,OAAO;EACzB,CAAC;EAED,IAAI,CAAC,OAAO,SAAS,MAAM,KAAK,OAAO,WAAW,GAChD,OAAO;EAGT,OAAO;GACL,MAAM,OAAO,SAAS,QAAQ;GAC9B,UAAU;EACZ;CACF,QAAQ;EACN,OAAO;CACT;AACF"}
@@ -0,0 +1,10 @@
1
+ export declare const DEFAULT_CONFIG_DIR = ".mastracode";
2
+ /**
3
+ * Validate that a configDirName is a safe single directory name.
4
+ * Rejects absolute paths, path separators, and traversal components.
5
+ */
6
+ export declare function validateConfigDirName(configDirName: string): void;
7
+ export declare const DEFAULT_OM_MODEL_ID: string;
8
+ export declare const DEFAULT_OBS_THRESHOLD = 30000;
9
+ export declare const DEFAULT_REF_THRESHOLD = 40000;
10
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAgBjE;AAGD,eAAO,MAAM,mBAAmB,QAA+D,CAAC;AAGhG,eAAO,MAAM,qBAAqB,QAAS,CAAC;AAC5C,eAAO,MAAM,qBAAqB,QAAS,CAAC"}
@@ -0,0 +1,18 @@
1
+ import * as path$1 from "path";
2
+ //#region src/constants.ts
3
+ const DEFAULT_CONFIG_DIR = ".mastracode";
4
+ /**
5
+ * Validate that a configDirName is a safe single directory name.
6
+ * Rejects absolute paths, path separators, and traversal components.
7
+ */
8
+ function validateConfigDirName(configDirName) {
9
+ if (configDirName.trim().length === 0) throw new Error("configDirName must be a non-empty directory name");
10
+ if (path$1.isAbsolute(configDirName) || configDirName.includes("/") || configDirName.includes("\\") || configDirName === ".." || configDirName === ".") throw new Error(`configDirName must be a single directory name without path separators or traversal components, got: "${configDirName}"`);
11
+ }
12
+ const DEFAULT_OM_MODEL_ID = process.env.DEFAULT_OM_MODEL_ID ?? "google/gemini-3.5-flash";
13
+ const DEFAULT_OBS_THRESHOLD = 3e4;
14
+ const DEFAULT_REF_THRESHOLD = 4e4;
15
+ //#endregion
16
+ export { DEFAULT_CONFIG_DIR, DEFAULT_OBS_THRESHOLD, DEFAULT_OM_MODEL_ID, DEFAULT_REF_THRESHOLD, validateConfigDirName };
17
+
18
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["path"],"sources":["../src/constants.ts"],"sourcesContent":["import * as path from 'node:path';\n\n// Default config directory name used for all project-level and global config paths.\nexport const DEFAULT_CONFIG_DIR = '.mastracode';\n\n/**\n * Validate that a configDirName is a safe single directory name.\n * Rejects absolute paths, path separators, and traversal components.\n */\nexport function validateConfigDirName(configDirName: string): void {\n if (configDirName.trim().length === 0) {\n throw new Error('configDirName must be a non-empty directory name');\n }\n\n if (\n path.isAbsolute(configDirName) ||\n configDirName.includes('/') ||\n configDirName.includes('\\\\') ||\n configDirName === '..' ||\n configDirName === '.'\n ) {\n throw new Error(\n `configDirName must be a single directory name without path separators or traversal components, got: \"${configDirName}\"`,\n );\n }\n}\n\n// Default OM model - using gemini-3.5-flash for efficiency\nexport const DEFAULT_OM_MODEL_ID = process.env.DEFAULT_OM_MODEL_ID ?? 'google/gemini-3.5-flash';\n\n// Default OM thresholds — per-thread overrides are loaded from thread metadata\nexport const DEFAULT_OBS_THRESHOLD = 30_000;\nexport const DEFAULT_REF_THRESHOLD = 40_000;\n"],"mappings":";;AAGA,MAAa,qBAAqB;;;;;AAMlC,SAAgB,sBAAsB,eAA6B;CACjE,IAAI,cAAc,KAAK,CAAC,CAAC,WAAW,GAClC,MAAM,IAAI,MAAM,kDAAkD;CAGpE,IACEA,OAAK,WAAW,aAAa,KAC7B,cAAc,SAAS,GAAG,KAC1B,cAAc,SAAS,IAAI,KAC3B,kBAAkB,QAClB,kBAAkB,KAElB,MAAM,IAAI,MACR,wGAAwG,cAAc,EACxH;AAEJ;AAGA,MAAa,sBAAsB,QAAQ,IAAI,uBAAuB;AAGtE,MAAa,wBAAwB;AACrC,MAAa,wBAAwB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Checks whether an error is an ERR_STREAM_DESTROYED error, which is a
3
+ * non-fatal condition that occurs when code writes to a stream after it
4
+ * has been closed (e.g., client disconnect, cancelled LLM stream, LSP
5
+ * shutdown, killed subprocess).
6
+ *
7
+ * Walks the `.cause` chain up to a depth limit.
8
+ */
9
+ export declare function isStreamDestroyedError(err: unknown, depth?: number): boolean;
10
+ //# sourceMappingURL=error-classification.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-classification.d.ts","sourceRoot":"","sources":["../src/error-classification.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CASvE"}
@@ -0,0 +1,22 @@
1
+ //#region src/error-classification.ts
2
+ /**
3
+ * Checks whether an error is an ERR_STREAM_DESTROYED error, which is a
4
+ * non-fatal condition that occurs when code writes to a stream after it
5
+ * has been closed (e.g., client disconnect, cancelled LLM stream, LSP
6
+ * shutdown, killed subprocess).
7
+ *
8
+ * Walks the `.cause` chain up to a depth limit.
9
+ */
10
+ function isStreamDestroyedError(err, depth = 0) {
11
+ if (!err || depth > 5) return false;
12
+ const e = err;
13
+ if (e.code === "ERR_STREAM_DESTROYED") return true;
14
+ if (typeof e.message === "string" && e.message.includes("stream was destroyed")) return true;
15
+ if (e.cause && isStreamDestroyedError(e.cause, depth + 1)) return true;
16
+ if (Array.isArray(e.errors) && e.errors.some((inner) => isStreamDestroyedError(inner, depth + 1))) return true;
17
+ return false;
18
+ }
19
+ //#endregion
20
+ export { isStreamDestroyedError };
21
+
22
+ //# sourceMappingURL=error-classification.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-classification.js","names":[],"sources":["../src/error-classification.ts"],"sourcesContent":["/**\n * Checks whether an error is an ERR_STREAM_DESTROYED error, which is a\n * non-fatal condition that occurs when code writes to a stream after it\n * has been closed (e.g., client disconnect, cancelled LLM stream, LSP\n * shutdown, killed subprocess).\n *\n * Walks the `.cause` chain up to a depth limit.\n */\nexport function isStreamDestroyedError(err: unknown, depth = 0): boolean {\n if (!err || depth > 5) return false;\n const e = err as any;\n if (e.code === 'ERR_STREAM_DESTROYED') return true;\n if (typeof e.message === 'string' && e.message.includes('stream was destroyed')) return true;\n if (e.cause && isStreamDestroyedError(e.cause, depth + 1)) return true;\n if (Array.isArray(e.errors) && e.errors.some((inner: unknown) => isStreamDestroyedError(inner, depth + 1)))\n return true;\n return false;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,uBAAuB,KAAc,QAAQ,GAAY;CACvE,IAAI,CAAC,OAAO,QAAQ,GAAG,OAAO;CAC9B,MAAM,IAAI;CACV,IAAI,EAAE,SAAS,wBAAwB,OAAO;CAC9C,IAAI,OAAO,EAAE,YAAY,YAAY,EAAE,QAAQ,SAAS,sBAAsB,GAAG,OAAO;CACxF,IAAI,EAAE,SAAS,uBAAuB,EAAE,OAAO,QAAQ,CAAC,GAAG,OAAO;CAClE,IAAI,MAAM,QAAQ,EAAE,MAAM,KAAK,EAAE,OAAO,MAAM,UAAmB,uBAAuB,OAAO,QAAQ,CAAC,CAAC,GACvG,OAAO;CACT,OAAO;AACT"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Eval Context Builder for MastraCode
3
+ *
4
+ * Converts AgentController session data into scorer-compatible format.
5
+ * Supports both agent-type scorers (ScorerRunInputForAgent) and
6
+ * trajectory scorers (Trajectory).
7
+ */
8
+ import type { AgentController, Session } from '@mastra/core/agent-controller';
9
+ import type { ScorerRunInputForAgent, ScorerRunOutputForAgent, Trajectory } from '@mastra/core/evals';
10
+ export type MastraCodeEvalContext = {
11
+ /** Scorer-compatible agent input (messages, system prompt, etc.) */
12
+ agentInput: ScorerRunInputForAgent;
13
+ /** Scorer-compatible agent output (response messages) */
14
+ agentOutput: ScorerRunOutputForAgent;
15
+ /** Execution trajectory extracted from trace spans */
16
+ trajectory: Trajectory | undefined;
17
+ /** Request context with session metadata */
18
+ requestContext: Record<string, unknown>;
19
+ /** The thread ID this context was built from */
20
+ threadId: string;
21
+ /** The trace ID for observability linkage */
22
+ traceId: string | undefined;
23
+ };
24
+ export type BuildContextOptions = {
25
+ /** AgentController instance to extract data from */
26
+ controller: AgentController<any>;
27
+ /** Session whose state/model/thread is being evaluated */
28
+ session: Session<any>;
29
+ /** Thread ID to build context for (defaults to current thread) */
30
+ threadId?: string;
31
+ /** Limit messages to the last N turns (user+assistant pairs). Undefined = all messages */
32
+ lastNTurns?: number;
33
+ };
34
+ /**
35
+ * Build an evaluation context from a AgentController session.
36
+ *
37
+ * This extracts messages from storage, builds trajectory from trace spans,
38
+ * and packages everything into the format scorers expect.
39
+ */
40
+ export declare function buildEvalContext(options: BuildContextOptions): Promise<MastraCodeEvalContext>;
41
+ //# sourceMappingURL=context-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../../src/evals/context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAItG,MAAM,MAAM,qBAAqB,GAAG;IAClC,oEAAoE;IACpE,UAAU,EAAE,sBAAsB,CAAC;IACnC,yDAAyD;IACzD,WAAW,EAAE,uBAAuB,CAAC;IACrC,sDAAsD;IACtD,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;IACnC,4CAA4C;IAC5C,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,oDAAoD;IACpD,UAAU,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;IACjC,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAoCnG"}
@@ -0,0 +1,161 @@
1
+ import { extractTrajectoryFromTrace } from "@mastra/core/evals";
2
+ //#region src/evals/context-builder.ts
3
+ /**
4
+ * Build an evaluation context from a AgentController session.
5
+ *
6
+ * This extracts messages from storage, builds trajectory from trace spans,
7
+ * and packages everything into the format scorers expect.
8
+ */
9
+ async function buildEvalContext(options) {
10
+ const { controller, session, lastNTurns } = options;
11
+ const threadId = options.threadId ?? session.thread.getId();
12
+ if (!threadId) throw new Error("No thread ID available. Start a session before building eval context.");
13
+ const storage = controller.getMastra()?.getStorage();
14
+ const { inputMessages, systemMessages, outputMessages } = categorizeMessages(await getRawMessages(storage, threadId, lastNTurns));
15
+ const { trajectory, traceId } = await extractSessionTrajectory(storage, threadId);
16
+ const requestContext = buildRequestContext(session, threadId);
17
+ return {
18
+ agentInput: {
19
+ inputMessages,
20
+ rememberedMessages: [],
21
+ systemMessages,
22
+ taggedSystemMessages: {}
23
+ },
24
+ agentOutput: outputMessages,
25
+ trajectory,
26
+ requestContext,
27
+ threadId,
28
+ traceId
29
+ };
30
+ }
31
+ /**
32
+ * Fetch raw MastraDBMessage[] from memory storage for a thread.
33
+ */
34
+ async function getRawMessages(storage, threadId, lastNTurns) {
35
+ if (!storage) return [];
36
+ const memoryStore = await storage.getStore("memory");
37
+ if (!memoryStore) return [];
38
+ let messages = (await memoryStore.listMessages({
39
+ threadId,
40
+ perPage: false
41
+ })).messages;
42
+ if (lastNTurns !== void 0 && lastNTurns > 0) messages = trimToLastNTurns(messages, lastNTurns);
43
+ return messages;
44
+ }
45
+ /**
46
+ * Trim messages to the last N user-assistant turn pairs.
47
+ */
48
+ function trimToLastNTurns(messages, turns) {
49
+ let turnCount = 0;
50
+ let cutoffIndex = 0;
51
+ for (let i = messages.length - 1; i >= 0; i--) if (messages[i].role === "user") {
52
+ turnCount++;
53
+ if (turnCount === turns) {
54
+ cutoffIndex = i;
55
+ break;
56
+ }
57
+ }
58
+ return messages.slice(cutoffIndex);
59
+ }
60
+ /**
61
+ * Categorize messages into input (user), system, and output (assistant) groups.
62
+ */
63
+ function categorizeMessages(messages) {
64
+ const inputMessages = [];
65
+ const systemMessages = [];
66
+ const outputMessages = [];
67
+ for (const msg of messages) switch (msg.role) {
68
+ case "user":
69
+ inputMessages.push(msg);
70
+ break;
71
+ case "system":
72
+ systemMessages.push({
73
+ role: "system",
74
+ content: extractTextContent(msg)
75
+ });
76
+ break;
77
+ case "assistant":
78
+ outputMessages.push(msg);
79
+ break;
80
+ }
81
+ return {
82
+ inputMessages,
83
+ systemMessages,
84
+ outputMessages
85
+ };
86
+ }
87
+ /**
88
+ * Extract plain text content from a MastraDBMessage.
89
+ */
90
+ function extractTextContent(msg) {
91
+ if (!msg.content?.parts) return "";
92
+ return msg.content.parts.filter((p) => p.type === "text" && "text" in p).map((p) => p.text).join("\n");
93
+ }
94
+ /**
95
+ * Extract trajectory from trace spans in observability storage.
96
+ * Looks up traces by threadId metadata.
97
+ */
98
+ async function extractSessionTrajectory(storage, threadId) {
99
+ if (!storage) return {
100
+ trajectory: void 0,
101
+ traceId: void 0
102
+ };
103
+ try {
104
+ const observabilityStore = await storage.getStore("observability");
105
+ if (!observabilityStore) return {
106
+ trajectory: void 0,
107
+ traceId: void 0
108
+ };
109
+ const result = await observabilityStore.listTraces({
110
+ filters: { threadId },
111
+ pagination: {
112
+ page: 0,
113
+ perPage: 1
114
+ },
115
+ orderBy: {
116
+ field: "startedAt",
117
+ direction: "DESC"
118
+ }
119
+ });
120
+ if (!result?.spans?.length) return {
121
+ trajectory: void 0,
122
+ traceId: void 0
123
+ };
124
+ const traceId = result.spans[0].traceId;
125
+ const trace = await observabilityStore.getTrace({ traceId });
126
+ if (!trace?.spans?.length) return {
127
+ trajectory: void 0,
128
+ traceId
129
+ };
130
+ return {
131
+ trajectory: extractTrajectoryFromTrace(trace.spans),
132
+ traceId
133
+ };
134
+ } catch {
135
+ return {
136
+ trajectory: void 0,
137
+ traceId: void 0
138
+ };
139
+ }
140
+ }
141
+ /**
142
+ * Build request context from AgentController state for scorer evaluation.
143
+ */
144
+ function buildRequestContext(session, threadId) {
145
+ const state = session.state.get();
146
+ return {
147
+ threadId,
148
+ mode: state.currentMode ?? state.mode,
149
+ modelId: session.model.get(),
150
+ projectPath: state.projectPath,
151
+ projectName: state.projectName,
152
+ gitBranch: state.gitBranch,
153
+ thinkingLevel: state.thinkingLevel,
154
+ yolo: state.yolo,
155
+ smartEditing: state.smartEditing
156
+ };
157
+ }
158
+ //#endregion
159
+ export { buildEvalContext };
160
+
161
+ //# sourceMappingURL=context-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-builder.js","names":[],"sources":["../../src/evals/context-builder.ts"],"sourcesContent":["/**\n * Eval Context Builder for MastraCode\n *\n * Converts AgentController session data into scorer-compatible format.\n * Supports both agent-type scorers (ScorerRunInputForAgent) and\n * trajectory scorers (Trajectory).\n */\n\nimport type { MastraDBMessage } from '@mastra/core/agent';\nimport type { AgentController, Session } from '@mastra/core/agent-controller';\nimport { extractTrajectoryFromTrace } from '@mastra/core/evals';\nimport type { ScorerRunInputForAgent, ScorerRunOutputForAgent, Trajectory } from '@mastra/core/evals';\nimport type { CoreMessage, CoreSystemMessage } from '@mastra/core/llm';\nimport type { MastraCompositeStore } from '@mastra/core/storage';\n\nexport type MastraCodeEvalContext = {\n /** Scorer-compatible agent input (messages, system prompt, etc.) */\n agentInput: ScorerRunInputForAgent;\n /** Scorer-compatible agent output (response messages) */\n agentOutput: ScorerRunOutputForAgent;\n /** Execution trajectory extracted from trace spans */\n trajectory: Trajectory | undefined;\n /** Request context with session metadata */\n requestContext: Record<string, unknown>;\n /** The thread ID this context was built from */\n threadId: string;\n /** The trace ID for observability linkage */\n traceId: string | undefined;\n};\n\nexport type BuildContextOptions = {\n /** AgentController instance to extract data from */\n controller: AgentController<any>;\n /** Session whose state/model/thread is being evaluated */\n session: Session<any>;\n /** Thread ID to build context for (defaults to current thread) */\n threadId?: string;\n /** Limit messages to the last N turns (user+assistant pairs). Undefined = all messages */\n lastNTurns?: number;\n};\n\n/**\n * Build an evaluation context from a AgentController session.\n *\n * This extracts messages from storage, builds trajectory from trace spans,\n * and packages everything into the format scorers expect.\n */\nexport async function buildEvalContext(options: BuildContextOptions): Promise<MastraCodeEvalContext> {\n const { controller, session, lastNTurns } = options;\n const threadId = options.threadId ?? session.thread.getId();\n\n if (!threadId) {\n throw new Error('No thread ID available. Start a session before building eval context.');\n }\n\n const mastra = controller.getMastra();\n const storage = mastra?.getStorage();\n\n // 1. Get raw MastraDB messages from memory storage\n const rawMessages = await getRawMessages(storage, threadId, lastNTurns);\n\n // 2. Split messages into input/output categories\n const { inputMessages, systemMessages, outputMessages } = categorizeMessages(rawMessages);\n\n // 3. Extract trajectory from observability traces\n const { trajectory, traceId } = await extractSessionTrajectory(storage, threadId);\n\n // 4. Build request context from AgentController state\n const requestContext = buildRequestContext(session, threadId);\n\n return {\n agentInput: {\n inputMessages,\n rememberedMessages: [], // AgentController doesn't separate these; memory recall is transparent\n systemMessages,\n taggedSystemMessages: {},\n },\n agentOutput: outputMessages,\n trajectory,\n requestContext,\n threadId,\n traceId,\n };\n}\n\n/**\n * Fetch raw MastraDBMessage[] from memory storage for a thread.\n */\nasync function getRawMessages(\n storage: MastraCompositeStore | undefined,\n threadId: string,\n lastNTurns?: number,\n): Promise<MastraDBMessage[]> {\n if (!storage) return [];\n\n const memoryStore = await storage.getStore('memory');\n if (!memoryStore) return [];\n\n const result = await memoryStore.listMessages({\n threadId,\n perPage: false,\n });\n\n let messages = result.messages;\n\n if (lastNTurns !== undefined && lastNTurns > 0) {\n messages = trimToLastNTurns(messages, lastNTurns);\n }\n\n return messages;\n}\n\n/**\n * Trim messages to the last N user-assistant turn pairs.\n */\nfunction trimToLastNTurns(messages: MastraDBMessage[], turns: number): MastraDBMessage[] {\n // Walk backward, counting user messages as turn boundaries.\n // When we find the Nth user message, slice from there to include\n // that turn and everything after it.\n let turnCount = 0;\n let cutoffIndex = 0;\n\n for (let i = messages.length - 1; i >= 0; i--) {\n if (messages[i]!.role === 'user') {\n turnCount++;\n if (turnCount === turns) {\n cutoffIndex = i;\n break;\n }\n }\n }\n\n return messages.slice(cutoffIndex);\n}\n\n/**\n * Categorize messages into input (user), system, and output (assistant) groups.\n */\nfunction categorizeMessages(messages: MastraDBMessage[]): {\n inputMessages: MastraDBMessage[];\n systemMessages: CoreMessage[];\n outputMessages: MastraDBMessage[];\n} {\n const inputMessages: MastraDBMessage[] = [];\n const systemMessages: CoreSystemMessage[] = [];\n const outputMessages: MastraDBMessage[] = [];\n\n for (const msg of messages) {\n switch (msg.role) {\n case 'user':\n inputMessages.push(msg);\n break;\n case 'system':\n systemMessages.push({\n role: 'system',\n content: extractTextContent(msg),\n });\n break;\n case 'assistant':\n outputMessages.push(msg);\n break;\n }\n }\n\n return { inputMessages, systemMessages, outputMessages };\n}\n\n/**\n * Extract plain text content from a MastraDBMessage.\n */\nfunction extractTextContent(msg: MastraDBMessage): string {\n if (!msg.content?.parts) return '';\n\n return msg.content.parts\n .filter((p): p is { type: 'text'; text: string } => p.type === 'text' && 'text' in p)\n .map(p => p.text)\n .join('\\n');\n}\n\n/**\n * Extract trajectory from trace spans in observability storage.\n * Looks up traces by threadId metadata.\n */\nasync function extractSessionTrajectory(\n storage: MastraCompositeStore | undefined,\n threadId: string,\n): Promise<{ trajectory: Trajectory | undefined; traceId: string | undefined }> {\n if (!storage) return { trajectory: undefined, traceId: undefined };\n\n try {\n const observabilityStore = await storage.getStore('observability');\n if (!observabilityStore) return { trajectory: undefined, traceId: undefined };\n\n // Find traces associated with this thread\n const result = await observabilityStore.listTraces({\n filters: { threadId },\n pagination: { page: 0, perPage: 1 },\n orderBy: { field: 'startedAt', direction: 'DESC' },\n });\n\n if (!result?.spans?.length) return { trajectory: undefined, traceId: undefined };\n\n const traceId = result.spans[0]!.traceId;\n const trace = await observabilityStore.getTrace({ traceId });\n\n if (!trace?.spans?.length) return { trajectory: undefined, traceId };\n\n const trajectory = extractTrajectoryFromTrace(trace.spans);\n return { trajectory, traceId };\n } catch {\n // Trace extraction is best-effort\n return { trajectory: undefined, traceId: undefined };\n }\n}\n\n/**\n * Build request context from AgentController state for scorer evaluation.\n */\nfunction buildRequestContext(session: Session<any>, threadId: string): Record<string, unknown> {\n const state = session.state.get() as Record<string, unknown>;\n\n return {\n threadId,\n mode: state.currentMode ?? state.mode,\n modelId: session.model.get(),\n projectPath: state.projectPath,\n projectName: state.projectName,\n gitBranch: state.gitBranch,\n thinkingLevel: state.thinkingLevel,\n yolo: state.yolo,\n smartEditing: state.smartEditing,\n };\n}\n"],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ export { buildEvalContext } from './context-builder.js';
2
+ export type { MastraCodeEvalContext, BuildContextOptions } from './context-builder.js';
3
+ export { createOutcomeScorer, createEfficiencyScorer } from './scorers/index.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evals/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { createOutcomeScorer } from "./scorers/outcome.js";
2
+ import { createEfficiencyScorer } from "./scorers/efficiency.js";
3
+ import "./scorers/index.js";
4
+ import { buildEvalContext } from "./context-builder.js";
5
+ export { buildEvalContext, createEfficiencyScorer, createOutcomeScorer };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shared command classification utilities for scoring.
3
+ *
4
+ * Used by both live scorers (outcome.ts) and offline scorers (outcome-match.ts)
5
+ * to consistently identify build, test, and other command types.
6
+ */
7
+ /**
8
+ * Check if a command string is a build/typecheck command.
9
+ * Handles compound commands (e.g. `pnpm build && pnpm test`) by checking each segment.
10
+ */
11
+ export declare function isBuildCommand(command: string): boolean;
12
+ /**
13
+ * Check if a command string is a test command.
14
+ */
15
+ export declare function isTestCommand(command: string): boolean;
16
+ /**
17
+ * Extract exit code from an `execute_command` result.
18
+ * Only trusts explicit exitCode/code fields — no heuristic fallbacks.
19
+ */
20
+ export declare function getExitCode(result: unknown): number | null;
21
+ /**
22
+ * Determine if a tool call result indicates success (exit code 0, no explicit error).
23
+ * Works with both structured result objects and string results.
24
+ */
25
+ export declare function isSuccessResult(result: unknown, error?: unknown): boolean;
26
+ /**
27
+ * Match a file path from tool output against an expected path.
28
+ * Supports exact match and suffix match (e.g. "src/foo.ts" matches "/abs/path/src/foo.ts").
29
+ */
30
+ export declare function matchFilePath(actual: string, expected: string): boolean;
31
+ //# sourceMappingURL=classify-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify-command.d.ts","sourceRoot":"","sources":["../../../src/evals/scorers/classify-command.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAUvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAgB1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAiBzE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvE"}