@mastra/server 1.0.4-alpha.2 → 1.1.0-alpha.0

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 (487) hide show
  1. package/CHANGELOG.md +6765 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +45 -137
  4. package/a2a/store.d.ts +1 -0
  5. package/auth.d.ts +1 -0
  6. package/dist/chunk-24SISJRB.js +250 -0
  7. package/dist/chunk-24SISJRB.js.map +1 -0
  8. package/dist/chunk-2HAVULC2.cjs +204 -0
  9. package/dist/chunk-2HAVULC2.cjs.map +1 -0
  10. package/dist/chunk-2HOMKKY4.cjs +352 -0
  11. package/dist/chunk-2HOMKKY4.cjs.map +1 -0
  12. package/dist/chunk-37DO73XV.cjs +33207 -0
  13. package/dist/chunk-37DO73XV.cjs.map +1 -0
  14. package/dist/chunk-3AZY5AWI.js +689 -0
  15. package/dist/chunk-3AZY5AWI.js.map +1 -0
  16. package/dist/chunk-3OIJLD3O.js +333 -0
  17. package/dist/chunk-3OIJLD3O.js.map +1 -0
  18. package/dist/chunk-3QUACCLU.js +1372 -0
  19. package/dist/chunk-3QUACCLU.js.map +1 -0
  20. package/dist/chunk-3W67K7YE.js +13 -0
  21. package/dist/chunk-3W67K7YE.js.map +1 -0
  22. package/dist/chunk-4HFYR562.cjs +82 -0
  23. package/dist/chunk-4HFYR562.cjs.map +1 -0
  24. package/dist/chunk-4JAEBN6N.js +1201 -0
  25. package/dist/chunk-4JAEBN6N.js.map +1 -0
  26. package/dist/chunk-4LVJBXI2.cjs +324 -0
  27. package/dist/chunk-4LVJBXI2.cjs.map +1 -0
  28. package/dist/{chunk-FV45V6WC.cjs → chunk-64ITUOXI.cjs} +3 -7
  29. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  30. package/dist/chunk-6G2RQWKA.cjs +252 -0
  31. package/dist/chunk-6G2RQWKA.cjs.map +1 -0
  32. package/dist/chunk-6KC345IN.cjs +708 -0
  33. package/dist/chunk-6KC345IN.cjs.map +1 -0
  34. package/dist/{chunk-TRDNDNGQ.js → chunk-6QWQZI4Q.js} +4 -7
  35. package/dist/chunk-6QWQZI4Q.js.map +1 -0
  36. package/dist/chunk-7D3UAMQM.cjs +82 -0
  37. package/dist/chunk-7D3UAMQM.cjs.map +1 -0
  38. package/dist/chunk-7XIMPDJV.js +442 -0
  39. package/dist/chunk-7XIMPDJV.js.map +1 -0
  40. package/dist/chunk-A2K5ZL47.cjs +195 -0
  41. package/dist/chunk-A2K5ZL47.cjs.map +1 -0
  42. package/dist/chunk-AAHPYUEC.cjs +211 -0
  43. package/dist/chunk-AAHPYUEC.cjs.map +1 -0
  44. package/dist/chunk-AN42MFD5.cjs +1231 -0
  45. package/dist/chunk-AN42MFD5.cjs.map +1 -0
  46. package/dist/chunk-AQI6GLTN.cjs +2777 -0
  47. package/dist/chunk-AQI6GLTN.cjs.map +1 -0
  48. package/dist/chunk-AV3VZ6S3.cjs +190 -0
  49. package/dist/chunk-AV3VZ6S3.cjs.map +1 -0
  50. package/dist/chunk-C4NZAUUW.js +33168 -0
  51. package/dist/chunk-C4NZAUUW.js.map +1 -0
  52. package/dist/chunk-D5VCL56B.js +317 -0
  53. package/dist/chunk-D5VCL56B.js.map +1 -0
  54. package/dist/chunk-DD7LYNHB.js +596 -0
  55. package/dist/chunk-DD7LYNHB.js.map +1 -0
  56. package/dist/chunk-DHDVJ5II.js +334 -0
  57. package/dist/chunk-DHDVJ5II.js.map +1 -0
  58. package/dist/chunk-ED6NQBHF.js +190 -0
  59. package/dist/chunk-ED6NQBHF.js.map +1 -0
  60. package/dist/chunk-EKFYZUPC.cjs +1404 -0
  61. package/dist/chunk-EKFYZUPC.cjs.map +1 -0
  62. package/dist/chunk-EV5H2JQU.js +45 -0
  63. package/dist/chunk-EV5H2JQU.js.map +1 -0
  64. package/dist/chunk-F2WTCJ5C.js +1153 -0
  65. package/dist/chunk-F2WTCJ5C.js.map +1 -0
  66. package/dist/chunk-FCPLBTHB.js +195 -0
  67. package/dist/chunk-FCPLBTHB.js.map +1 -0
  68. package/dist/chunk-FQX5SQO7.js +212 -0
  69. package/dist/chunk-FQX5SQO7.js.map +1 -0
  70. package/dist/chunk-FRRHYZR6.cjs +88 -0
  71. package/dist/chunk-FRRHYZR6.cjs.map +1 -0
  72. package/dist/chunk-GUG6KRAJ.js +666 -0
  73. package/dist/chunk-GUG6KRAJ.js.map +1 -0
  74. package/dist/chunk-GXUBQJ74.js +184 -0
  75. package/dist/chunk-GXUBQJ74.js.map +1 -0
  76. package/dist/chunk-H66LLFDL.js +970 -0
  77. package/dist/chunk-H66LLFDL.js.map +1 -0
  78. package/dist/chunk-HDGF45K7.cjs +128 -0
  79. package/dist/chunk-HDGF45K7.cjs.map +1 -0
  80. package/dist/chunk-HT4LP3BO.js +75 -0
  81. package/dist/chunk-HT4LP3BO.js.map +1 -0
  82. package/dist/chunk-HZINLMHL.cjs +252 -0
  83. package/dist/chunk-HZINLMHL.cjs.map +1 -0
  84. package/dist/chunk-IS3HHGL4.js +250 -0
  85. package/dist/chunk-IS3HHGL4.js.map +1 -0
  86. package/dist/chunk-JLFFAYTC.cjs +252 -0
  87. package/dist/chunk-JLFFAYTC.cjs.map +1 -0
  88. package/dist/chunk-JRM3DWRM.cjs +322 -0
  89. package/dist/chunk-JRM3DWRM.cjs.map +1 -0
  90. package/dist/chunk-K2SXZLA3.cjs +1049 -0
  91. package/dist/chunk-K2SXZLA3.cjs.map +1 -0
  92. package/dist/chunk-K4HSW5ZF.js +77 -0
  93. package/dist/chunk-K4HSW5ZF.js.map +1 -0
  94. package/dist/chunk-LFNP3ACE.js +1009 -0
  95. package/dist/chunk-LFNP3ACE.js.map +1 -0
  96. package/dist/chunk-LFTVDHOD.js +200 -0
  97. package/dist/chunk-LFTVDHOD.js.map +1 -0
  98. package/dist/chunk-LJ6YRVDI.cjs +15 -0
  99. package/dist/chunk-LJ6YRVDI.cjs.map +1 -0
  100. package/dist/chunk-LOA7RQYO.js +2774 -0
  101. package/dist/chunk-LOA7RQYO.js.map +1 -0
  102. package/dist/chunk-MCYD5LW7.cjs +90 -0
  103. package/dist/chunk-MCYD5LW7.cjs.map +1 -0
  104. package/dist/chunk-MZRJNOYJ.cjs +1195 -0
  105. package/dist/chunk-MZRJNOYJ.cjs.map +1 -0
  106. package/dist/chunk-O7I5CWRX.cjs +44 -0
  107. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  108. package/dist/chunk-ONN5EA7E.js +26 -0
  109. package/dist/chunk-ONN5EA7E.js.map +1 -0
  110. package/dist/chunk-OS7SAIRA.js +250 -0
  111. package/dist/chunk-OS7SAIRA.js.map +1 -0
  112. package/dist/chunk-PR4QN5HX.js +39 -0
  113. package/dist/chunk-PR4QN5HX.js.map +1 -0
  114. package/dist/chunk-PWXUI3OG.cjs +252 -0
  115. package/dist/chunk-PWXUI3OG.cjs.map +1 -0
  116. package/dist/chunk-QOVLJFLX.cjs +680 -0
  117. package/dist/chunk-QOVLJFLX.cjs.map +1 -0
  118. package/dist/chunk-QXDNFBJQ.js +220 -0
  119. package/dist/chunk-QXDNFBJQ.js.map +1 -0
  120. package/dist/chunk-RIX6WEJ2.js +83 -0
  121. package/dist/chunk-RIX6WEJ2.js.map +1 -0
  122. package/dist/chunk-RW66MHXI.js +246 -0
  123. package/dist/chunk-RW66MHXI.js.map +1 -0
  124. package/dist/chunk-S4SLHUJ7.cjs +253 -0
  125. package/dist/chunk-S4SLHUJ7.cjs.map +1 -0
  126. package/dist/chunk-SONAXR2M.cjs +450 -0
  127. package/dist/chunk-SONAXR2M.cjs.map +1 -0
  128. package/dist/chunk-SUKFO7UM.cjs +29 -0
  129. package/dist/chunk-SUKFO7UM.cjs.map +1 -0
  130. package/dist/chunk-T5KH32UA.cjs +47 -0
  131. package/dist/chunk-T5KH32UA.cjs.map +1 -0
  132. package/dist/chunk-TCWPL26W.js +119 -0
  133. package/dist/chunk-TCWPL26W.js.map +1 -0
  134. package/dist/chunk-TGDBGIDA.cjs +623 -0
  135. package/dist/chunk-TGDBGIDA.cjs.map +1 -0
  136. package/dist/chunk-USR6JK77.js +62 -0
  137. package/dist/chunk-USR6JK77.js.map +1 -0
  138. package/dist/chunk-VNHOYZ56.cjs +219 -0
  139. package/dist/chunk-VNHOYZ56.cjs.map +1 -0
  140. package/dist/chunk-VX3VN7FN.cjs +992 -0
  141. package/dist/chunk-VX3VN7FN.cjs.map +1 -0
  142. package/dist/chunk-WHC6S3VY.cjs +345 -0
  143. package/dist/chunk-WHC6S3VY.cjs.map +1 -0
  144. package/dist/chunk-XKLJYRAA.js +77 -0
  145. package/dist/chunk-XKLJYRAA.js.map +1 -0
  146. package/dist/chunk-XUSAKRLX.js +312 -0
  147. package/dist/chunk-XUSAKRLX.js.map +1 -0
  148. package/dist/chunk-ZKMVCV4G.cjs +71 -0
  149. package/dist/chunk-ZKMVCV4G.cjs.map +1 -0
  150. package/dist/dist-7NTDEVLP.cjs +928 -0
  151. package/dist/dist-7NTDEVLP.cjs.map +1 -0
  152. package/dist/dist-B5GMANA6.js +1147 -0
  153. package/dist/dist-B5GMANA6.js.map +1 -0
  154. package/dist/dist-EDO7GEGI.js +3 -0
  155. package/dist/dist-EDO7GEGI.js.map +1 -0
  156. package/dist/dist-OF24ZMHH.cjs +764 -0
  157. package/dist/dist-OF24ZMHH.cjs.map +1 -0
  158. package/dist/dist-P6YSNLL3.cjs +1150 -0
  159. package/dist/dist-P6YSNLL3.cjs.map +1 -0
  160. package/dist/dist-SMBO5KVB.js +937 -0
  161. package/dist/dist-SMBO5KVB.js.map +1 -0
  162. package/dist/dist-THPMW5QR.js +761 -0
  163. package/dist/dist-THPMW5QR.js.map +1 -0
  164. package/dist/dist-VZTG56X2.cjs +940 -0
  165. package/dist/dist-VZTG56X2.cjs.map +1 -0
  166. package/dist/dist-ZLC23RVC.cjs +16 -0
  167. package/dist/dist-ZLC23RVC.cjs.map +1 -0
  168. package/dist/dist-ZOZ6MHJH.js +925 -0
  169. package/dist/dist-ZOZ6MHJH.js.map +1 -0
  170. package/dist/docs/README.md +31 -0
  171. package/dist/docs/SKILL.md +32 -0
  172. package/dist/docs/SOURCE_MAP.json +6 -0
  173. package/dist/docs/server/01-custom-adapters.md +380 -0
  174. package/dist/docs/server/02-reference.md +833 -0
  175. package/dist/index.cjs +6 -0
  176. package/dist/index.cjs.map +1 -0
  177. package/dist/index.d.ts +1 -0
  178. package/dist/index.d.ts.map +1 -0
  179. package/dist/index.js +5 -0
  180. package/dist/index.js.map +1 -0
  181. package/dist/server/a2a/protocol.d.ts +8 -0
  182. package/dist/server/a2a/protocol.d.ts.map +1 -0
  183. package/dist/server/a2a/store.cjs +25 -0
  184. package/dist/server/a2a/store.cjs.map +1 -0
  185. package/dist/server/a2a/store.d.ts +14 -0
  186. package/dist/server/a2a/store.d.ts.map +1 -0
  187. package/dist/server/a2a/store.js +23 -0
  188. package/dist/server/a2a/store.js.map +1 -0
  189. package/dist/server/a2a/tasks.d.ts +20 -0
  190. package/dist/server/a2a/tasks.d.ts.map +1 -0
  191. package/dist/server/auth/defaults.d.ts +3 -0
  192. package/dist/server/auth/defaults.d.ts.map +1 -0
  193. package/dist/server/auth/helpers.d.ts +21 -0
  194. package/dist/server/auth/helpers.d.ts.map +1 -0
  195. package/dist/server/auth/index.cjs +48 -0
  196. package/dist/server/auth/index.cjs.map +1 -0
  197. package/dist/server/auth/index.d.ts +3 -0
  198. package/dist/server/auth/index.d.ts.map +1 -0
  199. package/dist/server/auth/index.js +3 -0
  200. package/dist/server/auth/index.js.map +1 -0
  201. package/dist/server/auth/path-pattern.d.ts +43 -0
  202. package/dist/server/auth/path-pattern.d.ts.map +1 -0
  203. package/dist/server/constants.d.ts +51 -0
  204. package/dist/server/constants.d.ts.map +1 -0
  205. package/dist/server/handlers/a2a.cjs +40 -0
  206. package/dist/server/handlers/a2a.cjs.map +1 -0
  207. package/dist/server/handlers/a2a.d.ts +550 -0
  208. package/dist/server/handlers/a2a.d.ts.map +1 -0
  209. package/dist/server/handlers/a2a.js +3 -0
  210. package/dist/server/handlers/a2a.js.map +1 -0
  211. package/dist/server/handlers/agent-builder.cjs +68 -0
  212. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  213. package/dist/server/handlers/agent-builder.d.ts +632 -0
  214. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  215. package/dist/server/handlers/agent-builder.js +3 -0
  216. package/dist/server/handlers/agent-builder.js.map +1 -0
  217. package/dist/server/handlers/agent-versions.cjs +60 -0
  218. package/dist/server/handlers/agent-versions.cjs.map +1 -0
  219. package/dist/server/handlers/agent-versions.d.ts +479 -0
  220. package/dist/server/handlers/agent-versions.d.ts.map +1 -0
  221. package/dist/server/handlers/agent-versions.js +3 -0
  222. package/dist/server/handlers/agent-versions.js.map +1 -0
  223. package/dist/server/handlers/agents.cjs +111 -13
  224. package/dist/server/handlers/agents.cjs.map +1 -0
  225. package/dist/server/handlers/agents.d.ts +3440 -6
  226. package/dist/server/handlers/agents.d.ts.map +1 -0
  227. package/dist/server/handlers/agents.js +3 -1
  228. package/dist/server/handlers/agents.js.map +1 -0
  229. package/dist/server/handlers/error.cjs +8 -2
  230. package/dist/server/handlers/error.cjs.map +1 -0
  231. package/dist/server/handlers/error.d.ts +14 -1
  232. package/dist/server/handlers/error.d.ts.map +1 -0
  233. package/dist/server/handlers/error.js +3 -1
  234. package/dist/server/handlers/error.js.map +1 -0
  235. package/dist/server/handlers/logs.cjs +9 -7
  236. package/dist/server/handlers/logs.cjs.map +1 -0
  237. package/dist/server/handlers/logs.d.ts +142 -3
  238. package/dist/server/handlers/logs.d.ts.map +1 -0
  239. package/dist/server/handlers/logs.js +3 -1
  240. package/dist/server/handlers/logs.js.map +1 -0
  241. package/dist/server/handlers/mcp.cjs +40 -0
  242. package/dist/server/handlers/mcp.cjs.map +1 -0
  243. package/dist/server/handlers/mcp.d.ts +132 -0
  244. package/dist/server/handlers/mcp.d.ts.map +1 -0
  245. package/dist/server/handlers/mcp.js +3 -0
  246. package/dist/server/handlers/mcp.js.map +1 -0
  247. package/dist/server/handlers/memory.cjs +83 -17
  248. package/dist/server/handlers/memory.cjs.map +1 -0
  249. package/dist/server/handlers/memory.d.ts +1089 -8
  250. package/dist/server/handlers/memory.d.ts.map +1 -0
  251. package/dist/server/handlers/memory.js +3 -1
  252. package/dist/server/handlers/memory.js.map +1 -0
  253. package/dist/server/handlers/observability.cjs +24 -0
  254. package/dist/server/handlers/observability.cjs.map +1 -0
  255. package/dist/server/handlers/observability.d.ts +154 -0
  256. package/dist/server/handlers/observability.d.ts.map +1 -0
  257. package/dist/server/handlers/observability.js +3 -0
  258. package/dist/server/handlers/observability.js.map +1 -0
  259. package/dist/server/handlers/processors.cjs +20 -0
  260. package/dist/server/handlers/processors.cjs.map +1 -0
  261. package/dist/server/handlers/processors.d.ts +181 -0
  262. package/dist/server/handlers/processors.d.ts.map +1 -0
  263. package/dist/server/handlers/processors.js +3 -0
  264. package/dist/server/handlers/processors.js.map +1 -0
  265. package/dist/server/handlers/scores.cjs +32 -0
  266. package/dist/server/handlers/scores.cjs.map +1 -0
  267. package/dist/server/handlers/scores.d.ts +121 -0
  268. package/dist/server/handlers/scores.d.ts.map +1 -0
  269. package/dist/server/handlers/scores.js +3 -0
  270. package/dist/server/handlers/scores.js.map +1 -0
  271. package/dist/server/handlers/stored-agents.cjs +28 -0
  272. package/dist/server/handlers/stored-agents.cjs.map +1 -0
  273. package/dist/server/handlers/stored-agents.d.ts +317 -0
  274. package/dist/server/handlers/stored-agents.d.ts.map +1 -0
  275. package/dist/server/handlers/stored-agents.js +3 -0
  276. package/dist/server/handlers/stored-agents.js.map +1 -0
  277. package/dist/server/handlers/system.cjs +12 -0
  278. package/dist/server/handlers/system.cjs.map +1 -0
  279. package/dist/server/handlers/system.d.ts +7 -0
  280. package/dist/server/handlers/system.d.ts.map +1 -0
  281. package/dist/server/handlers/system.js +3 -0
  282. package/dist/server/handlers/system.js.map +1 -0
  283. package/dist/server/handlers/test-utils.cjs +15 -0
  284. package/dist/server/handlers/test-utils.cjs.map +1 -0
  285. package/dist/server/handlers/test-utils.d.ts +6 -0
  286. package/dist/server/handlers/test-utils.d.ts.map +1 -0
  287. package/dist/server/handlers/test-utils.js +13 -0
  288. package/dist/server/handlers/test-utils.js.map +1 -0
  289. package/dist/server/handlers/tools.cjs +15 -9
  290. package/dist/server/handlers/tools.cjs.map +1 -0
  291. package/dist/server/handlers/tools.d.ts +71 -4
  292. package/dist/server/handlers/tools.d.ts.map +1 -0
  293. package/dist/server/handlers/tools.js +3 -1
  294. package/dist/server/handlers/tools.js.map +1 -0
  295. package/dist/server/handlers/utils.cjs +32 -2
  296. package/dist/server/handlers/utils.cjs.map +1 -0
  297. package/dist/server/handlers/utils.d.ts +39 -1
  298. package/dist/server/handlers/utils.d.ts.map +1 -0
  299. package/dist/server/handlers/utils.js +3 -1
  300. package/dist/server/handlers/utils.js.map +1 -0
  301. package/dist/server/handlers/vector.cjs +33 -7
  302. package/dist/server/handlers/vector.cjs.map +1 -0
  303. package/dist/server/handlers/vector.d.ts +135 -6
  304. package/dist/server/handlers/vector.d.ts.map +1 -0
  305. package/dist/server/handlers/vector.js +3 -1
  306. package/dist/server/handlers/vector.js.map +1 -0
  307. package/dist/server/handlers/voice.cjs +25 -7
  308. package/dist/server/handlers/voice.cjs.map +1 -0
  309. package/dist/server/handlers/voice.d.ts +82 -3
  310. package/dist/server/handlers/voice.d.ts.map +1 -0
  311. package/dist/server/handlers/voice.js +3 -1
  312. package/dist/server/handlers/voice.js.map +1 -0
  313. package/dist/server/handlers/workflows.cjs +75 -21
  314. package/dist/server/handlers/workflows.cjs.map +1 -0
  315. package/dist/server/handlers/workflows.d.ts +996 -10
  316. package/dist/server/handlers/workflows.d.ts.map +1 -0
  317. package/dist/server/handlers/workflows.js +3 -1
  318. package/dist/server/handlers/workflows.js.map +1 -0
  319. package/dist/server/handlers/workspace.cjs +80 -0
  320. package/dist/server/handlers/workspace.cjs.map +1 -0
  321. package/dist/server/handlers/workspace.d.ts +591 -0
  322. package/dist/server/handlers/workspace.d.ts.map +1 -0
  323. package/dist/server/handlers/workspace.js +3 -0
  324. package/dist/server/handlers/workspace.js.map +1 -0
  325. package/dist/server/handlers.cjs +41 -24
  326. package/dist/server/handlers.cjs.map +1 -0
  327. package/dist/server/handlers.d.ts +13 -9
  328. package/dist/server/handlers.d.ts.map +1 -0
  329. package/dist/server/handlers.js +14 -9
  330. package/dist/server/handlers.js.map +1 -0
  331. package/dist/server/http-exception.d.ts +82 -0
  332. package/dist/server/http-exception.d.ts.map +1 -0
  333. package/dist/server/schemas/a2a.d.ts +786 -0
  334. package/dist/server/schemas/a2a.d.ts.map +1 -0
  335. package/dist/server/schemas/agent-builder.d.ts +225 -0
  336. package/dist/server/schemas/agent-builder.d.ts.map +1 -0
  337. package/dist/server/schemas/agent-versions.d.ts +1646 -0
  338. package/dist/server/schemas/agent-versions.d.ts.map +1 -0
  339. package/dist/server/schemas/agents.d.ts +1815 -0
  340. package/dist/server/schemas/agents.d.ts.map +1 -0
  341. package/dist/server/schemas/common.d.ts +179 -0
  342. package/dist/server/schemas/common.d.ts.map +1 -0
  343. package/dist/server/schemas/logs.d.ts +124 -0
  344. package/dist/server/schemas/logs.d.ts.map +1 -0
  345. package/dist/server/schemas/mcp.d.ts +299 -0
  346. package/dist/server/schemas/mcp.d.ts.map +1 -0
  347. package/dist/server/schemas/memory.d.ts +1216 -0
  348. package/dist/server/schemas/memory.d.ts.map +1 -0
  349. package/dist/server/schemas/processors.d.ts +519 -0
  350. package/dist/server/schemas/processors.d.ts.map +1 -0
  351. package/dist/server/schemas/scores.d.ts +259 -0
  352. package/dist/server/schemas/scores.d.ts.map +1 -0
  353. package/dist/server/schemas/stored-agents.d.ts +850 -0
  354. package/dist/server/schemas/stored-agents.d.ts.map +1 -0
  355. package/dist/server/schemas/system.d.ts +36 -0
  356. package/dist/server/schemas/system.d.ts.map +1 -0
  357. package/dist/server/schemas/vectors.d.ts +107 -0
  358. package/dist/server/schemas/vectors.d.ts.map +1 -0
  359. package/dist/server/schemas/workflows.d.ts +863 -0
  360. package/dist/server/schemas/workflows.d.ts.map +1 -0
  361. package/dist/server/schemas/workspace.d.ts +1107 -0
  362. package/dist/server/schemas/workspace.d.ts.map +1 -0
  363. package/dist/server/server-adapter/index.cjs +661 -0
  364. package/dist/server/server-adapter/index.cjs.map +1 -0
  365. package/dist/server/server-adapter/index.d.ts +163 -0
  366. package/dist/server/server-adapter/index.d.ts.map +1 -0
  367. package/dist/server/server-adapter/index.js +630 -0
  368. package/dist/server/server-adapter/index.js.map +1 -0
  369. package/dist/server/server-adapter/openapi-utils.d.ts +69 -0
  370. package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -0
  371. package/dist/server/server-adapter/redact.d.ts +26 -0
  372. package/dist/server/server-adapter/redact.d.ts.map +1 -0
  373. package/dist/server/server-adapter/routes/a2a.d.ts +3 -0
  374. package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -0
  375. package/dist/server/server-adapter/routes/agent-builder.d.ts +3 -0
  376. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -0
  377. package/dist/server/server-adapter/routes/agents.d.ts +3 -0
  378. package/dist/server/server-adapter/routes/agents.d.ts.map +1 -0
  379. package/dist/server/server-adapter/routes/index.d.ts +52 -0
  380. package/dist/server/server-adapter/routes/index.d.ts.map +1 -0
  381. package/dist/server/server-adapter/routes/legacy.d.ts +7 -0
  382. package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -0
  383. package/dist/server/server-adapter/routes/logs.d.ts +3 -0
  384. package/dist/server/server-adapter/routes/logs.d.ts.map +1 -0
  385. package/dist/server/server-adapter/routes/mcp.d.ts +9 -0
  386. package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -0
  387. package/dist/server/server-adapter/routes/memory.d.ts +3 -0
  388. package/dist/server/server-adapter/routes/memory.d.ts.map +1 -0
  389. package/dist/server/server-adapter/routes/observability.d.ts +3 -0
  390. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -0
  391. package/dist/server/server-adapter/routes/processors.d.ts +3 -0
  392. package/dist/server/server-adapter/routes/processors.d.ts.map +1 -0
  393. package/dist/server/server-adapter/routes/route-builder.d.ts +112 -0
  394. package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -0
  395. package/dist/server/server-adapter/routes/scorers.d.ts +3 -0
  396. package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -0
  397. package/dist/server/server-adapter/routes/stored-agents.d.ts +8 -0
  398. package/dist/server/server-adapter/routes/stored-agents.d.ts.map +1 -0
  399. package/dist/server/server-adapter/routes/stream-types.d.ts +10 -0
  400. package/dist/server/server-adapter/routes/stream-types.d.ts.map +1 -0
  401. package/dist/server/server-adapter/routes/system.d.ts +12 -0
  402. package/dist/server/server-adapter/routes/system.d.ts.map +1 -0
  403. package/dist/server/server-adapter/routes/tools.d.ts +3 -0
  404. package/dist/server/server-adapter/routes/tools.d.ts.map +1 -0
  405. package/dist/server/server-adapter/routes/vectors.d.ts +3 -0
  406. package/dist/server/server-adapter/routes/vectors.d.ts.map +1 -0
  407. package/dist/server/server-adapter/routes/workflows.d.ts +3 -0
  408. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -0
  409. package/dist/server/server-adapter/routes/workspace.d.ts +8 -0
  410. package/dist/server/server-adapter/routes/workspace.d.ts.map +1 -0
  411. package/dist/server/types.d.ts +10 -0
  412. package/dist/server/types.d.ts.map +1 -0
  413. package/dist/server/utils.d.ts +58 -0
  414. package/dist/server/utils.d.ts.map +1 -0
  415. package/dist/token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs +63 -0
  416. package/dist/token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs.map +1 -0
  417. package/dist/token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js +61 -0
  418. package/dist/token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js.map +1 -0
  419. package/dist/token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs +63 -0
  420. package/dist/token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs.map +1 -0
  421. package/dist/token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js +61 -0
  422. package/dist/token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js.map +1 -0
  423. package/dist/token-6GSAFR2W-WGTMOPEU-6HSZQUFZ.cjs +63 -0
  424. package/dist/token-6GSAFR2W-WGTMOPEU-6HSZQUFZ.cjs.map +1 -0
  425. package/dist/token-6GSAFR2W-WGTMOPEU-JKP67ZX4.js +61 -0
  426. package/dist/token-6GSAFR2W-WGTMOPEU-JKP67ZX4.js.map +1 -0
  427. package/dist/token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js +8 -0
  428. package/dist/token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js.map +1 -0
  429. package/dist/token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs +10 -0
  430. package/dist/token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs.map +1 -0
  431. package/dist/token-util-NEHG7TUY-TV2H7N56-GGCGMPDG.js +8 -0
  432. package/dist/token-util-NEHG7TUY-TV2H7N56-GGCGMPDG.js.map +1 -0
  433. package/dist/token-util-NEHG7TUY-TV2H7N56-R7OENTCJ.cjs +10 -0
  434. package/dist/token-util-NEHG7TUY-TV2H7N56-R7OENTCJ.cjs.map +1 -0
  435. package/dist/token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs +10 -0
  436. package/dist/token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs.map +1 -0
  437. package/dist/token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js +8 -0
  438. package/dist/token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js.map +1 -0
  439. package/handlers/server/handlers.d.ts +1 -0
  440. package/handlers.d.ts +1 -0
  441. package/package.json +74 -20
  442. package/server-adapter.d.ts +1 -0
  443. package/dist/_tsup-dts-rollup.d.cts +0 -573
  444. package/dist/_tsup-dts-rollup.d.ts +0 -573
  445. package/dist/chunk-2FJURXCL.cjs +0 -213
  446. package/dist/chunk-3AHQ5RGN.js +0 -11
  447. package/dist/chunk-3EJZQ6TQ.js +0 -49
  448. package/dist/chunk-3RVHWGWO.js +0 -95
  449. package/dist/chunk-4JINXASC.js +0 -120
  450. package/dist/chunk-67WTHYAV.js +0 -156
  451. package/dist/chunk-A7DF4ETD.cjs +0 -100
  452. package/dist/chunk-B64YROKU.cjs +0 -317
  453. package/dist/chunk-CWSDZEZG.cjs +0 -139
  454. package/dist/chunk-DVPP5S6I.js +0 -135
  455. package/dist/chunk-JLDXUWK7.cjs +0 -126
  456. package/dist/chunk-L7XE5QTW.js +0 -16
  457. package/dist/chunk-M56ECCHK.cjs +0 -128
  458. package/dist/chunk-OPP7H5TW.js +0 -305
  459. package/dist/chunk-PDC4ZBQW.cjs +0 -126
  460. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  461. package/dist/chunk-QN4KF3BH.cjs +0 -18
  462. package/dist/chunk-RBQASTUP.js +0 -203
  463. package/dist/chunk-SKBVVI24.cjs +0 -54
  464. package/dist/chunk-UV4WTEH4.js +0 -120
  465. package/dist/chunk-VK6FX47H.js +0 -5576
  466. package/dist/chunk-YANVFOYA.js +0 -120
  467. package/dist/chunk-Z46X3YCB.cjs +0 -164
  468. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  469. package/dist/index.d.cts +0 -1
  470. package/dist/server/handlers/agents.d.cts +0 -6
  471. package/dist/server/handlers/error.d.cts +0 -1
  472. package/dist/server/handlers/logs.d.cts +0 -3
  473. package/dist/server/handlers/memory.d.cts +0 -8
  474. package/dist/server/handlers/network.cjs +0 -22
  475. package/dist/server/handlers/network.d.cts +0 -4
  476. package/dist/server/handlers/network.d.ts +0 -4
  477. package/dist/server/handlers/network.js +0 -1
  478. package/dist/server/handlers/telemetry.cjs +0 -14
  479. package/dist/server/handlers/telemetry.d.cts +0 -2
  480. package/dist/server/handlers/telemetry.d.ts +0 -2
  481. package/dist/server/handlers/telemetry.js +0 -1
  482. package/dist/server/handlers/tools.d.cts +0 -4
  483. package/dist/server/handlers/utils.d.cts +0 -1
  484. package/dist/server/handlers/vector.d.cts +0 -6
  485. package/dist/server/handlers/voice.d.cts +0 -3
  486. package/dist/server/handlers/workflows.d.cts +0 -10
  487. package/dist/server/handlers.d.cts +0 -9
@@ -0,0 +1,1153 @@
1
+ import { getWorkflowInfo, WorkflowRegistry } from './chunk-ED6NQBHF.js';
2
+ import { streamResponseSchema } from './chunk-LFNP3ACE.js';
3
+ import { getEffectiveResourceId, validateRunOwnership } from './chunk-USR6JK77.js';
4
+ import { createCombinedPaginationSchema, tracingOptionsSchema, messageResponseSchema, optionalRunIdSchema, runIdSchema } from './chunk-HT4LP3BO.js';
5
+ import { handleError } from './chunk-ONN5EA7E.js';
6
+ import { createRoute } from './chunk-D5VCL56B.js';
7
+ import { HTTPException } from './chunk-6QWQZI4Q.js';
8
+ import { __export } from './chunk-PR4QN5HX.js';
9
+ import { TransformStream, ReadableStream } from 'stream/web';
10
+ import z, { z as z$1 } from 'zod';
11
+
12
+ // src/server/handlers/workflows.ts
13
+ var workflows_exports = {};
14
+ __export(workflows_exports, {
15
+ CANCEL_WORKFLOW_RUN_ROUTE: () => CANCEL_WORKFLOW_RUN_ROUTE,
16
+ CREATE_WORKFLOW_RUN_ROUTE: () => CREATE_WORKFLOW_RUN_ROUTE,
17
+ DELETE_WORKFLOW_RUN_BY_ID_ROUTE: () => DELETE_WORKFLOW_RUN_BY_ID_ROUTE,
18
+ GET_WORKFLOW_BY_ID_ROUTE: () => GET_WORKFLOW_BY_ID_ROUTE,
19
+ GET_WORKFLOW_RUN_BY_ID_ROUTE: () => GET_WORKFLOW_RUN_BY_ID_ROUTE,
20
+ LIST_WORKFLOWS_ROUTE: () => LIST_WORKFLOWS_ROUTE,
21
+ LIST_WORKFLOW_RUNS_ROUTE: () => LIST_WORKFLOW_RUNS_ROUTE,
22
+ OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE: () => OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE,
23
+ OBSERVE_STREAM_WORKFLOW_ROUTE: () => OBSERVE_STREAM_WORKFLOW_ROUTE,
24
+ RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE: () => RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE,
25
+ RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE: () => RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE,
26
+ RESTART_ASYNC_WORKFLOW_ROUTE: () => RESTART_ASYNC_WORKFLOW_ROUTE,
27
+ RESTART_WORKFLOW_ROUTE: () => RESTART_WORKFLOW_ROUTE,
28
+ RESUME_ASYNC_WORKFLOW_ROUTE: () => RESUME_ASYNC_WORKFLOW_ROUTE,
29
+ RESUME_STREAM_WORKFLOW_ROUTE: () => RESUME_STREAM_WORKFLOW_ROUTE,
30
+ RESUME_WORKFLOW_ROUTE: () => RESUME_WORKFLOW_ROUTE,
31
+ START_ASYNC_WORKFLOW_ROUTE: () => START_ASYNC_WORKFLOW_ROUTE,
32
+ START_WORKFLOW_RUN_ROUTE: () => START_WORKFLOW_RUN_ROUTE,
33
+ STREAM_LEGACY_WORKFLOW_ROUTE: () => STREAM_LEGACY_WORKFLOW_ROUTE,
34
+ STREAM_WORKFLOW_ROUTE: () => STREAM_WORKFLOW_ROUTE,
35
+ TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE: () => TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE,
36
+ TIME_TRAVEL_STREAM_WORKFLOW_ROUTE: () => TIME_TRAVEL_STREAM_WORKFLOW_ROUTE,
37
+ TIME_TRAVEL_WORKFLOW_ROUTE: () => TIME_TRAVEL_WORKFLOW_ROUTE
38
+ });
39
+ var workflowRunStatusSchema = z.enum([
40
+ "running",
41
+ "waiting",
42
+ "suspended",
43
+ "success",
44
+ "failed",
45
+ "canceled",
46
+ "pending",
47
+ "bailed",
48
+ "tripwire",
49
+ "paused"
50
+ ]);
51
+ var workflowIdPathParams = z.object({
52
+ workflowId: z.string().describe("Unique identifier for the workflow")
53
+ });
54
+ var workflowRunPathParams = workflowIdPathParams.extend({
55
+ runId: z.string().describe("Unique identifier for the workflow run")
56
+ });
57
+ var serializedStepSchema = z.object({
58
+ id: z.string(),
59
+ description: z.string().optional(),
60
+ stateSchema: z.string().optional(),
61
+ inputSchema: z.string().optional(),
62
+ outputSchema: z.string().optional(),
63
+ resumeSchema: z.string().optional(),
64
+ suspendSchema: z.string().optional(),
65
+ component: z.string().optional(),
66
+ isWorkflow: z.boolean().optional()
67
+ });
68
+ var serializedStepFlowEntrySchema = z.object({
69
+ type: z.enum(["step", "sleep", "sleepUntil", "waitForEvent", "parallel", "conditional", "loop", "foreach"])
70
+ });
71
+ var workflowInfoSchema = z.object({
72
+ steps: z.record(z.string(), serializedStepSchema),
73
+ allSteps: z.record(z.string(), serializedStepSchema),
74
+ name: z.string().optional(),
75
+ description: z.string().optional(),
76
+ stepGraph: z.array(serializedStepFlowEntrySchema),
77
+ inputSchema: z.string().optional(),
78
+ outputSchema: z.string().optional(),
79
+ stateSchema: z.string().optional(),
80
+ options: z.object({}).optional(),
81
+ isProcessorWorkflow: z.boolean().optional()
82
+ });
83
+ var listWorkflowsResponseSchema = z.record(z.string(), workflowInfoSchema);
84
+ var workflowRunSchema = z.object({
85
+ workflowName: z.string(),
86
+ runId: z.string(),
87
+ snapshot: z.union([z.object({}), z.string()]),
88
+ createdAt: z.date(),
89
+ updatedAt: z.date(),
90
+ resourceId: z.string().optional()
91
+ });
92
+ var workflowRunsResponseSchema = z.object({
93
+ runs: z.array(workflowRunSchema),
94
+ total: z.number()
95
+ });
96
+ var listWorkflowRunsQuerySchema = createCombinedPaginationSchema().extend({
97
+ fromDate: z.coerce.date().optional(),
98
+ toDate: z.coerce.date().optional(),
99
+ resourceId: z.string().optional(),
100
+ status: workflowRunStatusSchema.optional()
101
+ });
102
+ var workflowExecutionBodySchema = z.object({
103
+ resourceId: z.string().optional(),
104
+ inputData: z.unknown().optional(),
105
+ initialState: z.unknown().optional(),
106
+ requestContext: z.record(z.string(), z.unknown()).optional(),
107
+ tracingOptions: tracingOptionsSchema.optional(),
108
+ perStep: z.boolean().optional()
109
+ });
110
+ var streamLegacyWorkflowBodySchema = workflowExecutionBodySchema;
111
+ var streamWorkflowBodySchema = workflowExecutionBodySchema.extend({
112
+ closeOnSuspend: z.boolean().optional()
113
+ });
114
+ var resumeBodySchema = z.object({
115
+ step: z.union([z.string(), z.array(z.string())]).optional(),
116
+ // Optional - workflow can auto-resume all suspended steps
117
+ resumeData: z.unknown().optional(),
118
+ requestContext: z.record(z.string(), z.unknown()).optional(),
119
+ tracingOptions: tracingOptionsSchema.optional(),
120
+ perStep: z.boolean().optional()
121
+ });
122
+ var restartBodySchema = z.object({
123
+ requestContext: z.record(z.string(), z.unknown()).optional(),
124
+ tracingOptions: tracingOptionsSchema.optional()
125
+ });
126
+ var timeTravelBodySchema = z.object({
127
+ inputData: z.unknown().optional(),
128
+ resumeData: z.unknown().optional(),
129
+ initialState: z.unknown().optional(),
130
+ step: z.union([z.string(), z.array(z.string())]),
131
+ context: z.record(z.string(), z.any()).optional(),
132
+ nestedStepsContext: z.record(z.string(), z.record(z.string(), z.any())).optional(),
133
+ requestContext: z.record(z.string(), z.unknown()).optional(),
134
+ tracingOptions: tracingOptionsSchema.optional(),
135
+ perStep: z.boolean().optional()
136
+ });
137
+ var startAsyncWorkflowBodySchema = workflowExecutionBodySchema;
138
+ z.object({
139
+ event: z.string(),
140
+ data: z.unknown()
141
+ });
142
+ var VALID_WORKFLOW_RESULT_FIELDS = /* @__PURE__ */ new Set([
143
+ "result",
144
+ "error",
145
+ "payload",
146
+ "steps",
147
+ "activeStepsPath",
148
+ "serializedStepGraph"
149
+ ]);
150
+ var WORKFLOW_RESULT_FIELDS_ERROR = "Invalid field name. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph";
151
+ var createFieldsValidator = (description) => z.string().optional().refine(
152
+ (value) => {
153
+ if (!value) return true;
154
+ const requestedFields = value.split(",").map((f) => f.trim());
155
+ return requestedFields.every((field) => VALID_WORKFLOW_RESULT_FIELDS.has(field));
156
+ },
157
+ { message: WORKFLOW_RESULT_FIELDS_ERROR }
158
+ ).describe(description);
159
+ var withNestedWorkflowsField = z.enum(["true", "false"]).optional().describe("Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance.");
160
+ var workflowExecutionResultSchema = z.object({
161
+ status: workflowRunStatusSchema.optional(),
162
+ result: z.unknown().optional(),
163
+ error: z.unknown().optional(),
164
+ payload: z.unknown().optional(),
165
+ initialState: z.unknown().optional(),
166
+ steps: z.record(z.string(), z.any()).optional(),
167
+ activeStepsPath: z.record(z.string(), z.array(z.number())).optional(),
168
+ serializedStepGraph: z.array(serializedStepFlowEntrySchema).optional()
169
+ });
170
+ var workflowRunResultQuerySchema = z.object({
171
+ fields: createFieldsValidator(
172
+ "Comma-separated list of fields to return. Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included."
173
+ ),
174
+ withNestedWorkflows: withNestedWorkflowsField
175
+ });
176
+ var workflowRunResultSchema = z.object({
177
+ // Metadata - always present
178
+ runId: z.string(),
179
+ workflowName: z.string(),
180
+ resourceId: z.string().optional(),
181
+ createdAt: z.date(),
182
+ updatedAt: z.date(),
183
+ // Execution state
184
+ status: workflowRunStatusSchema,
185
+ initialState: z.record(z.string(), z.any()).optional(),
186
+ result: z.unknown().optional(),
187
+ error: z.unknown().optional(),
188
+ payload: z.unknown().optional(),
189
+ steps: z.record(z.string(), z.any()).optional(),
190
+ // Optional detailed fields
191
+ activeStepsPath: z.record(z.string(), z.array(z.number())).optional(),
192
+ serializedStepGraph: z.array(serializedStepFlowEntrySchema).optional()
193
+ });
194
+ var workflowControlResponseSchema = messageResponseSchema;
195
+ var createWorkflowRunResponseSchema = z.object({
196
+ runId: z.string()
197
+ });
198
+ var createWorkflowRunBodySchema = z.object({
199
+ resourceId: z.string().optional(),
200
+ disableScorers: z.boolean().optional()
201
+ });
202
+
203
+ // src/server/handlers/workflows.ts
204
+ async function listWorkflowsFromSystem({ mastra, workflowId }) {
205
+ const logger = mastra.getLogger();
206
+ if (!workflowId) {
207
+ throw new HTTPException(400, { message: "Workflow ID is required" });
208
+ }
209
+ let workflow;
210
+ workflow = WorkflowRegistry.getWorkflow(workflowId);
211
+ if (!workflow) {
212
+ try {
213
+ workflow = mastra.getWorkflowById(workflowId);
214
+ } catch (error) {
215
+ logger.debug("Error getting workflow, searching agents for workflow", error);
216
+ }
217
+ }
218
+ if (!workflow) {
219
+ logger.debug("Workflow not found, searching agents for workflow", { workflowId });
220
+ const agents = mastra.listAgents();
221
+ if (Object.keys(agents || {}).length) {
222
+ for (const [_, agent] of Object.entries(agents)) {
223
+ try {
224
+ const workflows = await agent.listWorkflows();
225
+ if (workflows[workflowId]) {
226
+ workflow = workflows[workflowId];
227
+ break;
228
+ }
229
+ } catch (error) {
230
+ logger.debug("Error getting workflow from agent", error);
231
+ }
232
+ }
233
+ }
234
+ }
235
+ if (!workflow) {
236
+ throw new HTTPException(404, { message: "Workflow not found" });
237
+ }
238
+ return { workflow };
239
+ }
240
+ var LIST_WORKFLOWS_ROUTE = createRoute({
241
+ method: "GET",
242
+ path: "/workflows",
243
+ responseType: "json",
244
+ queryParamSchema: z$1.object({
245
+ partial: z$1.string().optional()
246
+ }),
247
+ responseSchema: listWorkflowsResponseSchema,
248
+ summary: "List all workflows",
249
+ description: "Returns a list of all available workflows in the system",
250
+ tags: ["Workflows"],
251
+ requiresAuth: true,
252
+ handler: async ({ mastra, partial }) => {
253
+ try {
254
+ const workflows = mastra.listWorkflows({ serialized: false });
255
+ const isPartial = partial === "true";
256
+ const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
257
+ acc[key] = getWorkflowInfo(workflow, isPartial);
258
+ return acc;
259
+ }, {});
260
+ return _workflows;
261
+ } catch (error) {
262
+ return handleError(error, "Error getting workflows");
263
+ }
264
+ }
265
+ });
266
+ var GET_WORKFLOW_BY_ID_ROUTE = createRoute({
267
+ method: "GET",
268
+ path: "/workflows/:workflowId",
269
+ responseType: "json",
270
+ pathParamSchema: workflowIdPathParams,
271
+ responseSchema: workflowInfoSchema,
272
+ summary: "Get workflow by ID",
273
+ description: "Returns details for a specific workflow",
274
+ tags: ["Workflows"],
275
+ requiresAuth: true,
276
+ handler: async ({ mastra, workflowId }) => {
277
+ try {
278
+ if (!workflowId) {
279
+ throw new HTTPException(400, { message: "Workflow ID is required" });
280
+ }
281
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
282
+ return getWorkflowInfo(workflow);
283
+ } catch (error) {
284
+ return handleError(error, "Error getting workflow");
285
+ }
286
+ }
287
+ });
288
+ var LIST_WORKFLOW_RUNS_ROUTE = createRoute({
289
+ method: "GET",
290
+ path: "/workflows/:workflowId/runs",
291
+ responseType: "json",
292
+ pathParamSchema: workflowIdPathParams,
293
+ queryParamSchema: listWorkflowRunsQuerySchema,
294
+ responseSchema: workflowRunsResponseSchema,
295
+ summary: "List workflow runs",
296
+ description: "Returns a paginated list of execution runs for the specified workflow",
297
+ tags: ["Workflows"],
298
+ requiresAuth: true,
299
+ handler: async ({
300
+ mastra,
301
+ workflowId,
302
+ fromDate,
303
+ toDate,
304
+ page,
305
+ perPage,
306
+ limit,
307
+ offset,
308
+ resourceId,
309
+ status,
310
+ requestContext
311
+ }) => {
312
+ try {
313
+ const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);
314
+ if (!workflowId) {
315
+ throw new HTTPException(400, { message: "Workflow ID is required" });
316
+ }
317
+ let finalPage = page;
318
+ let finalPerPage = perPage;
319
+ if (finalPerPage === void 0 && limit !== void 0) {
320
+ finalPerPage = limit;
321
+ }
322
+ if (finalPage === void 0 && offset !== void 0 && finalPerPage !== void 0 && finalPerPage > 0) {
323
+ finalPage = Math.floor(offset / finalPerPage);
324
+ }
325
+ if (finalPerPage !== void 0 && (typeof finalPerPage !== "number" || !Number.isInteger(finalPerPage) || finalPerPage <= 0)) {
326
+ throw new HTTPException(400, { message: "perPage must be a positive integer" });
327
+ }
328
+ if (finalPage !== void 0 && (!Number.isInteger(finalPage) || finalPage < 0)) {
329
+ throw new HTTPException(400, { message: "page must be a non-negative integer" });
330
+ }
331
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
332
+ if (!workflow) {
333
+ throw new HTTPException(404, { message: "Workflow not found" });
334
+ }
335
+ const workflowRuns = await workflow.listWorkflowRuns({
336
+ fromDate: fromDate ? typeof fromDate === "string" ? new Date(fromDate) : fromDate : void 0,
337
+ toDate: toDate ? typeof toDate === "string" ? new Date(toDate) : toDate : void 0,
338
+ perPage: finalPerPage,
339
+ page: finalPage,
340
+ resourceId: effectiveResourceId,
341
+ status
342
+ }) || {
343
+ runs: [],
344
+ total: 0
345
+ };
346
+ return workflowRuns;
347
+ } catch (error) {
348
+ return handleError(error, "Error getting workflow runs");
349
+ }
350
+ }
351
+ });
352
+ var GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({
353
+ method: "GET",
354
+ path: "/workflows/:workflowId/runs/:runId",
355
+ responseType: "json",
356
+ pathParamSchema: workflowRunPathParams,
357
+ queryParamSchema: workflowRunResultQuerySchema,
358
+ responseSchema: workflowRunResultSchema,
359
+ summary: "Get workflow run by ID",
360
+ description: "Returns a workflow run with metadata and processed execution state. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=status,result,metadata)",
361
+ tags: ["Workflows"],
362
+ requiresAuth: true,
363
+ handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows, requestContext }) => {
364
+ try {
365
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
366
+ if (!workflowId) {
367
+ throw new HTTPException(400, { message: "Workflow ID is required" });
368
+ }
369
+ if (!runId) {
370
+ throw new HTTPException(400, { message: "Run ID is required" });
371
+ }
372
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
373
+ if (!workflow) {
374
+ throw new HTTPException(404, { message: "Workflow not found" });
375
+ }
376
+ const fieldList = fields ? fields.split(",").map((f) => f.trim()) : void 0;
377
+ const run = await workflow.getWorkflowRunById(runId, {
378
+ withNestedWorkflows: withNestedWorkflows !== "false",
379
+ // Default to true unless explicitly 'false'
380
+ fields: fieldList
381
+ });
382
+ if (!run) {
383
+ throw new HTTPException(404, { message: "Workflow run not found" });
384
+ }
385
+ await validateRunOwnership(run, effectiveResourceId);
386
+ return run;
387
+ } catch (error) {
388
+ return handleError(error, "Error getting workflow run");
389
+ }
390
+ }
391
+ });
392
+ var DELETE_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({
393
+ method: "DELETE",
394
+ path: "/workflows/:workflowId/runs/:runId",
395
+ responseType: "json",
396
+ pathParamSchema: workflowRunPathParams,
397
+ responseSchema: workflowControlResponseSchema,
398
+ summary: "Delete workflow run by ID",
399
+ description: "Deletes a specific workflow run by ID",
400
+ tags: ["Workflows"],
401
+ requiresAuth: true,
402
+ handler: async ({ mastra, workflowId, runId, requestContext }) => {
403
+ try {
404
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
405
+ if (!workflowId) {
406
+ throw new HTTPException(400, { message: "Workflow ID is required" });
407
+ }
408
+ if (!runId) {
409
+ throw new HTTPException(400, { message: "Run ID is required" });
410
+ }
411
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
412
+ if (!workflow) {
413
+ throw new HTTPException(404, { message: "Workflow not found" });
414
+ }
415
+ const run = await workflow.getWorkflowRunById(runId);
416
+ if (!run) {
417
+ throw new HTTPException(404, { message: "Workflow run not found" });
418
+ }
419
+ await validateRunOwnership(run, effectiveResourceId);
420
+ await workflow.deleteWorkflowRunById(runId);
421
+ return { message: "Workflow run deleted" };
422
+ } catch (error) {
423
+ return handleError(error, "Error deleting workflow run");
424
+ }
425
+ }
426
+ });
427
+ var CREATE_WORKFLOW_RUN_ROUTE = createRoute({
428
+ method: "POST",
429
+ path: "/workflows/:workflowId/create-run",
430
+ responseType: "json",
431
+ pathParamSchema: workflowIdPathParams,
432
+ queryParamSchema: optionalRunIdSchema,
433
+ bodySchema: createWorkflowRunBodySchema,
434
+ responseSchema: createWorkflowRunResponseSchema,
435
+ summary: "Create workflow run",
436
+ description: "Creates a new workflow execution instance with an optional custom run ID",
437
+ tags: ["Workflows"],
438
+ requiresAuth: true,
439
+ handler: async ({ mastra, workflowId, runId, resourceId, disableScorers, requestContext }) => {
440
+ try {
441
+ const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);
442
+ if (!workflowId) {
443
+ throw new HTTPException(400, { message: "Workflow ID is required" });
444
+ }
445
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
446
+ if (!workflow) {
447
+ throw new HTTPException(404, { message: "Workflow not found" });
448
+ }
449
+ const run = await workflow.createRun({ runId, resourceId: effectiveResourceId, disableScorers });
450
+ return { runId: run.runId };
451
+ } catch (error) {
452
+ return handleError(error, "Error creating workflow run");
453
+ }
454
+ }
455
+ });
456
+ var STREAM_WORKFLOW_ROUTE = createRoute({
457
+ method: "POST",
458
+ path: "/workflows/:workflowId/stream",
459
+ responseType: "stream",
460
+ pathParamSchema: workflowIdPathParams,
461
+ queryParamSchema: runIdSchema,
462
+ bodySchema: streamWorkflowBodySchema,
463
+ summary: "Stream workflow execution",
464
+ description: "Executes a workflow and streams the results in real-time",
465
+ tags: ["Workflows"],
466
+ requiresAuth: true,
467
+ handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {
468
+ try {
469
+ const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);
470
+ if (!workflowId) {
471
+ throw new HTTPException(400, { message: "Workflow ID is required" });
472
+ }
473
+ if (!runId) {
474
+ throw new HTTPException(400, { message: "runId required to stream workflow" });
475
+ }
476
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
477
+ if (!workflow) {
478
+ throw new HTTPException(404, { message: "Workflow not found" });
479
+ }
480
+ const serverCache = mastra.getServerCache();
481
+ const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });
482
+ const result = run.stream({ ...params, requestContext });
483
+ return result.fullStream.pipeThrough(
484
+ new TransformStream({
485
+ transform(chunk, controller) {
486
+ if (serverCache) {
487
+ const cacheKey = runId;
488
+ serverCache.listPush(cacheKey, chunk).catch(() => {
489
+ });
490
+ }
491
+ controller.enqueue(chunk);
492
+ }
493
+ })
494
+ );
495
+ } catch (error) {
496
+ return handleError(error, "Error streaming workflow");
497
+ }
498
+ }
499
+ });
500
+ var RESUME_STREAM_WORKFLOW_ROUTE = createRoute({
501
+ method: "POST",
502
+ path: "/workflows/:workflowId/resume-stream",
503
+ responseType: "stream",
504
+ pathParamSchema: workflowIdPathParams,
505
+ queryParamSchema: runIdSchema,
506
+ bodySchema: resumeBodySchema,
507
+ responseSchema: streamResponseSchema,
508
+ summary: "Resume workflow stream",
509
+ description: "Resumes a suspended workflow execution and continues streaming results",
510
+ tags: ["Workflows"],
511
+ requiresAuth: true,
512
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
513
+ try {
514
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
515
+ if (!workflowId) {
516
+ throw new HTTPException(400, { message: "Workflow ID is required" });
517
+ }
518
+ if (!runId) {
519
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
520
+ }
521
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
522
+ if (!workflow) {
523
+ throw new HTTPException(404, { message: "Workflow not found" });
524
+ }
525
+ const run = await workflow.getWorkflowRunById(runId);
526
+ if (!run) {
527
+ throw new HTTPException(404, { message: "Workflow run not found" });
528
+ }
529
+ await validateRunOwnership(run, effectiveResourceId);
530
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
531
+ const serverCache = mastra.getServerCache();
532
+ const stream = _run.resumeStream({ ...params, requestContext }).fullStream.pipeThrough(
533
+ new TransformStream({
534
+ transform(chunk, controller) {
535
+ if (serverCache) {
536
+ const cacheKey = runId;
537
+ serverCache.listPush(cacheKey, chunk).catch(() => {
538
+ });
539
+ }
540
+ controller.enqueue(chunk);
541
+ }
542
+ })
543
+ );
544
+ return stream;
545
+ } catch (error) {
546
+ return handleError(error, "Error resuming workflow");
547
+ }
548
+ }
549
+ });
550
+ var START_ASYNC_WORKFLOW_ROUTE = createRoute({
551
+ method: "POST",
552
+ path: "/workflows/:workflowId/start-async",
553
+ responseType: "json",
554
+ pathParamSchema: workflowIdPathParams,
555
+ queryParamSchema: optionalRunIdSchema,
556
+ bodySchema: startAsyncWorkflowBodySchema,
557
+ responseSchema: workflowExecutionResultSchema,
558
+ summary: "Start workflow asynchronously",
559
+ description: "Starts a workflow execution asynchronously without streaming results",
560
+ tags: ["Workflows"],
561
+ requiresAuth: true,
562
+ handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {
563
+ try {
564
+ const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);
565
+ if (!workflowId) {
566
+ throw new HTTPException(400, { message: "Workflow ID is required" });
567
+ }
568
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
569
+ if (!workflow) {
570
+ throw new HTTPException(404, { message: "Workflow not found" });
571
+ }
572
+ const _run = await workflow.createRun({ runId, resourceId: effectiveResourceId });
573
+ const result = await _run.start({ ...params, requestContext });
574
+ return result;
575
+ } catch (error) {
576
+ return handleError(error, "Error starting async workflow");
577
+ }
578
+ }
579
+ });
580
+ var START_WORKFLOW_RUN_ROUTE = createRoute({
581
+ method: "POST",
582
+ path: "/workflows/:workflowId/start",
583
+ responseType: "json",
584
+ pathParamSchema: workflowIdPathParams,
585
+ queryParamSchema: runIdSchema,
586
+ bodySchema: startAsyncWorkflowBodySchema,
587
+ responseSchema: workflowControlResponseSchema,
588
+ summary: "Start specific workflow run",
589
+ description: "Starts execution of a specific workflow run by ID",
590
+ tags: ["Workflows"],
591
+ requiresAuth: true,
592
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
593
+ try {
594
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
595
+ if (!workflowId) {
596
+ throw new HTTPException(400, { message: "Workflow ID is required" });
597
+ }
598
+ if (!runId) {
599
+ throw new HTTPException(400, { message: "runId required to start run" });
600
+ }
601
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
602
+ if (!workflow) {
603
+ throw new HTTPException(404, { message: "Workflow not found" });
604
+ }
605
+ const run = await workflow.getWorkflowRunById(runId);
606
+ if (!run) {
607
+ throw new HTTPException(404, { message: "Workflow run not found" });
608
+ }
609
+ await validateRunOwnership(run, effectiveResourceId);
610
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
611
+ void _run.start({
612
+ ...params,
613
+ requestContext
614
+ });
615
+ return { message: "Workflow run started" };
616
+ } catch (e) {
617
+ return handleError(e, "Error starting workflow run");
618
+ }
619
+ }
620
+ });
621
+ var OBSERVE_STREAM_WORKFLOW_ROUTE = createRoute({
622
+ method: "POST",
623
+ path: "/workflows/:workflowId/observe",
624
+ responseType: "stream",
625
+ pathParamSchema: workflowIdPathParams,
626
+ queryParamSchema: runIdSchema,
627
+ responseSchema: streamResponseSchema,
628
+ summary: "Observe workflow stream",
629
+ description: "Observes and streams updates from an already running workflow execution",
630
+ tags: ["Workflows"],
631
+ requiresAuth: true,
632
+ handler: async ({ mastra, workflowId, runId, requestContext }) => {
633
+ try {
634
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
635
+ if (!workflowId) {
636
+ throw new HTTPException(400, { message: "Workflow ID is required" });
637
+ }
638
+ if (!runId) {
639
+ throw new HTTPException(400, { message: "runId required to observe workflow stream" });
640
+ }
641
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
642
+ if (!workflow) {
643
+ throw new HTTPException(404, { message: "Workflow not found" });
644
+ }
645
+ const run = await workflow.getWorkflowRunById(runId);
646
+ if (!run) {
647
+ throw new HTTPException(404, { message: "Workflow run not found" });
648
+ }
649
+ await validateRunOwnership(run, effectiveResourceId);
650
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
651
+ const serverCache = mastra.getServerCache();
652
+ if (!serverCache) {
653
+ throw new HTTPException(500, { message: "Server cache not found" });
654
+ }
655
+ const cachedRunChunks = await serverCache.listFromTo(runId, 0);
656
+ const combinedStream = new ReadableStream({
657
+ start(controller) {
658
+ const emitCachedChunks = async () => {
659
+ for (const chunk of cachedRunChunks) {
660
+ controller.enqueue(chunk);
661
+ }
662
+ };
663
+ const liveStream = _run.observeStream();
664
+ const reader = liveStream.getReader();
665
+ const pump = async () => {
666
+ try {
667
+ while (true) {
668
+ const { done, value } = await reader.read();
669
+ if (done) {
670
+ controller.close();
671
+ break;
672
+ }
673
+ controller.enqueue(value);
674
+ }
675
+ } catch (error) {
676
+ controller.error(error);
677
+ } finally {
678
+ reader.releaseLock();
679
+ }
680
+ };
681
+ void emitCachedChunks().then(() => {
682
+ void pump();
683
+ }).catch((error) => {
684
+ controller.error(error);
685
+ });
686
+ }
687
+ });
688
+ return combinedStream;
689
+ } catch (error) {
690
+ return handleError(error, "Error observing workflow stream");
691
+ }
692
+ }
693
+ });
694
+ var RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({
695
+ method: "POST",
696
+ path: "/workflows/:workflowId/resume-async",
697
+ responseType: "json",
698
+ pathParamSchema: workflowIdPathParams,
699
+ queryParamSchema: runIdSchema,
700
+ bodySchema: resumeBodySchema,
701
+ responseSchema: workflowExecutionResultSchema,
702
+ summary: "Resume workflow asynchronously",
703
+ description: "Resumes a suspended workflow execution asynchronously without streaming",
704
+ tags: ["Workflows"],
705
+ requiresAuth: true,
706
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
707
+ try {
708
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
709
+ if (!workflowId) {
710
+ throw new HTTPException(400, { message: "Workflow ID is required" });
711
+ }
712
+ if (!runId) {
713
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
714
+ }
715
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
716
+ if (!workflow) {
717
+ throw new HTTPException(404, { message: "Workflow not found" });
718
+ }
719
+ const run = await workflow.getWorkflowRunById(runId);
720
+ if (!run) {
721
+ throw new HTTPException(404, { message: "Workflow run not found" });
722
+ }
723
+ await validateRunOwnership(run, effectiveResourceId);
724
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
725
+ const result = await _run.resume({ ...params, requestContext });
726
+ return result;
727
+ } catch (error) {
728
+ return handleError(error, "Error resuming workflow step");
729
+ }
730
+ }
731
+ });
732
+ var RESUME_WORKFLOW_ROUTE = createRoute({
733
+ method: "POST",
734
+ path: "/workflows/:workflowId/resume",
735
+ responseType: "json",
736
+ pathParamSchema: workflowIdPathParams,
737
+ queryParamSchema: runIdSchema,
738
+ bodySchema: resumeBodySchema,
739
+ responseSchema: workflowControlResponseSchema,
740
+ summary: "Resume workflow",
741
+ description: "Resumes a suspended workflow execution from a specific step",
742
+ tags: ["Workflows"],
743
+ requiresAuth: true,
744
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
745
+ try {
746
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
747
+ if (!workflowId) {
748
+ throw new HTTPException(400, { message: "Workflow ID is required" });
749
+ }
750
+ if (!runId) {
751
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
752
+ }
753
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
754
+ if (!workflow) {
755
+ throw new HTTPException(404, { message: "Workflow not found" });
756
+ }
757
+ const run = await workflow.getWorkflowRunById(runId);
758
+ if (!run) {
759
+ throw new HTTPException(404, { message: "Workflow run not found" });
760
+ }
761
+ await validateRunOwnership(run, effectiveResourceId);
762
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
763
+ void _run.resume({ ...params, requestContext });
764
+ return { message: "Workflow run resumed" };
765
+ } catch (error) {
766
+ return handleError(error, "Error resuming workflow");
767
+ }
768
+ }
769
+ });
770
+ var RESTART_ASYNC_WORKFLOW_ROUTE = createRoute({
771
+ method: "POST",
772
+ path: "/workflows/:workflowId/restart-async",
773
+ responseType: "json",
774
+ pathParamSchema: workflowIdPathParams,
775
+ queryParamSchema: runIdSchema,
776
+ bodySchema: restartBodySchema,
777
+ responseSchema: workflowExecutionResultSchema,
778
+ summary: "Restart workflow asynchronously",
779
+ description: "Restarts an active workflow execution asynchronously",
780
+ tags: ["Workflows"],
781
+ requiresAuth: true,
782
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
783
+ try {
784
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
785
+ if (!workflowId) {
786
+ throw new HTTPException(400, { message: "Workflow ID is required" });
787
+ }
788
+ if (!runId) {
789
+ throw new HTTPException(400, { message: "runId required to restart workflow" });
790
+ }
791
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
792
+ if (!workflow) {
793
+ throw new HTTPException(404, { message: "Workflow not found" });
794
+ }
795
+ const run = await workflow.getWorkflowRunById(runId);
796
+ if (!run) {
797
+ throw new HTTPException(404, { message: "Workflow run not found" });
798
+ }
799
+ await validateRunOwnership(run, effectiveResourceId);
800
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
801
+ const result = await _run.restart({ ...params, requestContext });
802
+ return result;
803
+ } catch (error) {
804
+ return handleError(error, "Error restarting workflow");
805
+ }
806
+ }
807
+ });
808
+ var RESTART_WORKFLOW_ROUTE = createRoute({
809
+ method: "POST",
810
+ path: "/workflows/:workflowId/restart",
811
+ responseType: "json",
812
+ pathParamSchema: workflowIdPathParams,
813
+ queryParamSchema: runIdSchema,
814
+ bodySchema: restartBodySchema,
815
+ responseSchema: workflowControlResponseSchema,
816
+ summary: "Restart workflow",
817
+ description: "Restarts an active workflow execution",
818
+ tags: ["Workflows"],
819
+ requiresAuth: true,
820
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
821
+ try {
822
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
823
+ if (!workflowId) {
824
+ throw new HTTPException(400, { message: "Workflow ID is required" });
825
+ }
826
+ if (!runId) {
827
+ throw new HTTPException(400, { message: "runId required to restart workflow" });
828
+ }
829
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
830
+ if (!workflow) {
831
+ throw new HTTPException(404, { message: "Workflow not found" });
832
+ }
833
+ const run = await workflow.getWorkflowRunById(runId);
834
+ if (!run) {
835
+ throw new HTTPException(404, { message: "Workflow run not found" });
836
+ }
837
+ await validateRunOwnership(run, effectiveResourceId);
838
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
839
+ void _run.restart({ ...params, requestContext });
840
+ return { message: "Workflow run restarted" };
841
+ } catch (error) {
842
+ return handleError(error, "Error restarting workflow");
843
+ }
844
+ }
845
+ });
846
+ var RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = createRoute({
847
+ method: "POST",
848
+ path: "/workflows/:workflowId/restart-all-active-workflow-runs-async",
849
+ responseType: "json",
850
+ pathParamSchema: workflowIdPathParams,
851
+ responseSchema: workflowControlResponseSchema,
852
+ summary: "Restart all active workflow runs asynchronously",
853
+ description: "Restarts all active workflow runs asynchronously",
854
+ tags: ["Workflows"],
855
+ requiresAuth: true,
856
+ handler: async ({ mastra, workflowId }) => {
857
+ try {
858
+ if (!workflowId) {
859
+ throw new HTTPException(400, { message: "Workflow ID is required" });
860
+ }
861
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
862
+ if (!workflow) {
863
+ throw new HTTPException(404, { message: "Workflow not found" });
864
+ }
865
+ await workflow.restartAllActiveWorkflowRuns();
866
+ return { message: "All active workflow runs restarted" };
867
+ } catch (error) {
868
+ return handleError(error, "Error restarting workflow");
869
+ }
870
+ }
871
+ });
872
+ var RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = createRoute({
873
+ method: "POST",
874
+ path: "/workflows/:workflowId/restart-all-active-workflow-runs",
875
+ responseType: "json",
876
+ pathParamSchema: workflowIdPathParams,
877
+ responseSchema: workflowControlResponseSchema,
878
+ summary: "Restart all active workflow runs",
879
+ description: "Restarts all active workflow runs",
880
+ tags: ["Workflows"],
881
+ requiresAuth: true,
882
+ handler: async ({ mastra, workflowId }) => {
883
+ try {
884
+ if (!workflowId) {
885
+ throw new HTTPException(400, { message: "Workflow ID is required" });
886
+ }
887
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
888
+ if (!workflow) {
889
+ throw new HTTPException(404, { message: "Workflow not found" });
890
+ }
891
+ void workflow.restartAllActiveWorkflowRuns();
892
+ return { message: "All active workflow runs restarted" };
893
+ } catch (error) {
894
+ return handleError(error, "Error restarting workflow");
895
+ }
896
+ }
897
+ });
898
+ var TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = createRoute({
899
+ method: "POST",
900
+ path: "/workflows/:workflowId/time-travel-async",
901
+ responseType: "json",
902
+ pathParamSchema: workflowIdPathParams,
903
+ queryParamSchema: runIdSchema,
904
+ bodySchema: timeTravelBodySchema,
905
+ responseSchema: workflowExecutionResultSchema,
906
+ summary: "Time travel workflow asynchronously",
907
+ description: "Time travels a workflow run asynchronously without streaming",
908
+ tags: ["Workflows"],
909
+ requiresAuth: true,
910
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
911
+ try {
912
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
913
+ if (!workflowId) {
914
+ throw new HTTPException(400, { message: "Workflow ID is required" });
915
+ }
916
+ if (!runId) {
917
+ throw new HTTPException(400, { message: "runId required to time travel workflow" });
918
+ }
919
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
920
+ if (!workflow) {
921
+ throw new HTTPException(404, { message: "Workflow not found" });
922
+ }
923
+ const run = await workflow.getWorkflowRunById(runId);
924
+ if (!run) {
925
+ throw new HTTPException(404, { message: "Workflow run not found" });
926
+ }
927
+ await validateRunOwnership(run, effectiveResourceId);
928
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
929
+ const result = await _run.timeTravel({ ...params, requestContext });
930
+ return result;
931
+ } catch (error) {
932
+ return handleError(error, "Error time traveling workflow");
933
+ }
934
+ }
935
+ });
936
+ var TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({
937
+ method: "POST",
938
+ path: "/workflows/:workflowId/time-travel",
939
+ responseType: "json",
940
+ pathParamSchema: workflowIdPathParams,
941
+ queryParamSchema: runIdSchema,
942
+ bodySchema: timeTravelBodySchema,
943
+ responseSchema: workflowControlResponseSchema,
944
+ summary: "Time travel workflow",
945
+ description: "Time travels a workflow run, starting from a specific step",
946
+ tags: ["Workflows"],
947
+ requiresAuth: true,
948
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
949
+ try {
950
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
951
+ if (!workflowId) {
952
+ throw new HTTPException(400, { message: "Workflow ID is required" });
953
+ }
954
+ if (!runId) {
955
+ throw new HTTPException(400, { message: "runId required to time travel workflow" });
956
+ }
957
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
958
+ if (!workflow) {
959
+ throw new HTTPException(404, { message: "Workflow not found" });
960
+ }
961
+ const run = await workflow.getWorkflowRunById(runId);
962
+ if (!run) {
963
+ throw new HTTPException(404, { message: "Workflow run not found" });
964
+ }
965
+ await validateRunOwnership(run, effectiveResourceId);
966
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
967
+ void _run.timeTravel({ ...params, requestContext });
968
+ return { message: "Workflow run time travel started" };
969
+ } catch (error) {
970
+ return handleError(error, "Error time traveling workflow");
971
+ }
972
+ }
973
+ });
974
+ var TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = createRoute({
975
+ method: "POST",
976
+ path: "/workflows/:workflowId/time-travel-stream",
977
+ responseType: "stream",
978
+ pathParamSchema: workflowIdPathParams,
979
+ queryParamSchema: runIdSchema,
980
+ bodySchema: timeTravelBodySchema,
981
+ summary: "Time travel workflow stream",
982
+ description: "Time travels a workflow run, starting from a specific step, and streams the results in real-time",
983
+ tags: ["Workflows"],
984
+ requiresAuth: true,
985
+ handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {
986
+ try {
987
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
988
+ if (!workflowId) {
989
+ throw new HTTPException(400, { message: "Workflow ID is required" });
990
+ }
991
+ if (!runId) {
992
+ throw new HTTPException(400, { message: "runId required to time travel workflow stream" });
993
+ }
994
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
995
+ if (!workflow) {
996
+ throw new HTTPException(404, { message: "Workflow not found" });
997
+ }
998
+ const existingRun = await workflow.getWorkflowRunById(runId);
999
+ if (!existingRun) {
1000
+ throw new HTTPException(404, { message: "Workflow run not found" });
1001
+ }
1002
+ await validateRunOwnership(existingRun, effectiveResourceId);
1003
+ const serverCache = mastra.getServerCache();
1004
+ const run = await workflow.createRun({ runId, resourceId: existingRun.resourceId });
1005
+ const result = run.timeTravelStream({ ...params, requestContext });
1006
+ return result.fullStream.pipeThrough(
1007
+ new TransformStream({
1008
+ transform(chunk, controller) {
1009
+ if (serverCache) {
1010
+ const cacheKey = runId;
1011
+ serverCache.listPush(cacheKey, chunk).catch(() => {
1012
+ });
1013
+ }
1014
+ controller.enqueue(chunk);
1015
+ }
1016
+ })
1017
+ );
1018
+ } catch (error) {
1019
+ return handleError(error, "Error time traveling workflow stream");
1020
+ }
1021
+ }
1022
+ });
1023
+ var CANCEL_WORKFLOW_RUN_ROUTE = createRoute({
1024
+ method: "POST",
1025
+ path: "/workflows/:workflowId/runs/:runId/cancel",
1026
+ responseType: "json",
1027
+ pathParamSchema: workflowRunPathParams,
1028
+ responseSchema: workflowControlResponseSchema,
1029
+ summary: "Cancel workflow run",
1030
+ description: "Cancels an in-progress workflow execution",
1031
+ tags: ["Workflows"],
1032
+ requiresAuth: true,
1033
+ handler: async ({ mastra, workflowId, runId, requestContext }) => {
1034
+ try {
1035
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
1036
+ if (!workflowId) {
1037
+ throw new HTTPException(400, { message: "Workflow ID is required" });
1038
+ }
1039
+ if (!runId) {
1040
+ throw new HTTPException(400, { message: "runId required to cancel workflow run" });
1041
+ }
1042
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
1043
+ if (!workflow) {
1044
+ throw new HTTPException(404, { message: "Workflow not found" });
1045
+ }
1046
+ const run = await workflow.getWorkflowRunById(runId);
1047
+ if (!run) {
1048
+ throw new HTTPException(404, { message: "Workflow run not found" });
1049
+ }
1050
+ await validateRunOwnership(run, effectiveResourceId);
1051
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
1052
+ await _run.cancel();
1053
+ return { message: "Workflow run cancelled" };
1054
+ } catch (error) {
1055
+ return handleError(error, "Error canceling workflow run");
1056
+ }
1057
+ }
1058
+ });
1059
+ var STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({
1060
+ method: "POST",
1061
+ path: "/workflows/:workflowId/stream-legacy",
1062
+ responseType: "stream",
1063
+ pathParamSchema: workflowIdPathParams,
1064
+ queryParamSchema: runIdSchema,
1065
+ bodySchema: streamWorkflowBodySchema,
1066
+ responseSchema: streamResponseSchema,
1067
+ summary: "[DEPRECATED] Stream workflow with legacy format",
1068
+ description: "Legacy endpoint for streaming workflow execution. Use /workflows/:workflowId/stream instead.",
1069
+ tags: ["Workflows", "Legacy"],
1070
+ requiresAuth: true,
1071
+ handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {
1072
+ try {
1073
+ const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);
1074
+ if (!workflowId) {
1075
+ throw new HTTPException(400, { message: "Workflow ID is required" });
1076
+ }
1077
+ if (!runId) {
1078
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
1079
+ }
1080
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
1081
+ if (!workflow) {
1082
+ throw new HTTPException(404, { message: "Workflow not found" });
1083
+ }
1084
+ const serverCache = mastra.getServerCache();
1085
+ const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });
1086
+ const result = run.streamLegacy({
1087
+ ...params,
1088
+ requestContext,
1089
+ onChunk: async (chunk) => {
1090
+ if (serverCache) {
1091
+ const cacheKey = runId;
1092
+ await serverCache.listPush(cacheKey, chunk);
1093
+ }
1094
+ }
1095
+ });
1096
+ return result.stream;
1097
+ } catch (error) {
1098
+ return handleError(error, "Error executing workflow");
1099
+ }
1100
+ }
1101
+ });
1102
+ var OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({
1103
+ method: "POST",
1104
+ path: "/workflows/:workflowId/observe-stream-legacy",
1105
+ responseType: "stream",
1106
+ pathParamSchema: workflowIdPathParams,
1107
+ queryParamSchema: runIdSchema,
1108
+ responseSchema: streamResponseSchema,
1109
+ summary: "[DEPRECATED] Observe workflow stream with legacy format",
1110
+ description: "Legacy endpoint for observing workflow stream. Use /workflows/:workflowId/observe instead.",
1111
+ tags: ["Workflows", "Legacy"],
1112
+ requiresAuth: true,
1113
+ handler: async ({ mastra, workflowId, runId, requestContext }) => {
1114
+ try {
1115
+ const effectiveResourceId = getEffectiveResourceId(requestContext, void 0);
1116
+ if (!workflowId) {
1117
+ throw new HTTPException(400, { message: "Workflow ID is required" });
1118
+ }
1119
+ if (!runId) {
1120
+ throw new HTTPException(400, { message: "runId required to observe workflow stream" });
1121
+ }
1122
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
1123
+ if (!workflow) {
1124
+ throw new HTTPException(404, { message: "Workflow not found" });
1125
+ }
1126
+ const run = await workflow.getWorkflowRunById(runId);
1127
+ if (!run) {
1128
+ throw new HTTPException(404, { message: "Workflow run not found" });
1129
+ }
1130
+ await validateRunOwnership(run, effectiveResourceId);
1131
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
1132
+ const serverCache = mastra.getServerCache();
1133
+ if (!serverCache) {
1134
+ throw new HTTPException(500, { message: "Server cache not found" });
1135
+ }
1136
+ const transformStream = new TransformStream();
1137
+ const writer = transformStream.writable.getWriter();
1138
+ const cachedRunChunks = await serverCache.listFromTo(runId, 0);
1139
+ for (const chunk of cachedRunChunks) {
1140
+ await writer.write(chunk);
1141
+ }
1142
+ writer.releaseLock();
1143
+ const result = _run.observeStreamLegacy();
1144
+ return result.stream?.pipeThrough(transformStream);
1145
+ } catch (error) {
1146
+ return handleError(error, "Error observing workflow stream");
1147
+ }
1148
+ }
1149
+ });
1150
+
1151
+ export { CANCEL_WORKFLOW_RUN_ROUTE, CREATE_WORKFLOW_RUN_ROUTE, DELETE_WORKFLOW_RUN_BY_ID_ROUTE, GET_WORKFLOW_BY_ID_ROUTE, GET_WORKFLOW_RUN_BY_ID_ROUTE, LIST_WORKFLOWS_ROUTE, LIST_WORKFLOW_RUNS_ROUTE, OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE, OBSERVE_STREAM_WORKFLOW_ROUTE, RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE, RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE, RESTART_ASYNC_WORKFLOW_ROUTE, RESTART_WORKFLOW_ROUTE, RESUME_ASYNC_WORKFLOW_ROUTE, RESUME_STREAM_WORKFLOW_ROUTE, RESUME_WORKFLOW_ROUTE, START_ASYNC_WORKFLOW_ROUTE, START_WORKFLOW_RUN_ROUTE, STREAM_LEGACY_WORKFLOW_ROUTE, STREAM_WORKFLOW_ROUTE, TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE, TIME_TRAVEL_STREAM_WORKFLOW_ROUTE, TIME_TRAVEL_WORKFLOW_ROUTE, createWorkflowRunResponseSchema, listWorkflowRunsQuerySchema, listWorkflowsResponseSchema, resumeBodySchema, startAsyncWorkflowBodySchema, streamLegacyWorkflowBodySchema, streamWorkflowBodySchema, workflowControlResponseSchema, workflowExecutionResultSchema, workflowInfoSchema, workflowRunResultQuerySchema, workflowRunResultSchema, workflowRunsResponseSchema, workflows_exports };
1152
+ //# sourceMappingURL=chunk-F2WTCJ5C.js.map
1153
+ //# sourceMappingURL=chunk-F2WTCJ5C.js.map