@mastra/server 1.0.0-beta.0 → 1.0.0-beta.10

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 (302) hide show
  1. package/CHANGELOG.md +250 -0
  2. package/dist/chunk-3SFLFUKY.js +116 -0
  3. package/dist/chunk-3SFLFUKY.js.map +1 -0
  4. package/dist/chunk-4W2SM6CG.js +294 -0
  5. package/dist/chunk-4W2SM6CG.js.map +1 -0
  6. package/dist/chunk-5W4RPVTK.cjs +49 -0
  7. package/dist/chunk-5W4RPVTK.cjs.map +1 -0
  8. package/dist/{chunk-D7T74TVR.js → chunk-6YWE7UPT.js} +18 -4
  9. package/dist/chunk-6YWE7UPT.js.map +1 -0
  10. package/dist/chunk-7HX4V5Y6.cjs +23268 -0
  11. package/dist/chunk-7HX4V5Y6.cjs.map +1 -0
  12. package/dist/chunk-7N3PD4SV.js +196 -0
  13. package/dist/chunk-7N3PD4SV.js.map +1 -0
  14. package/dist/chunk-AWBBXA36.js +23226 -0
  15. package/dist/chunk-AWBBXA36.js.map +1 -0
  16. package/dist/{chunk-KJIDZQRA.cjs → chunk-C3D3X2L5.cjs} +219 -24
  17. package/dist/chunk-C3D3X2L5.cjs.map +1 -0
  18. package/dist/{chunk-FPBYKMIS.js → chunk-CT5VG7NT.js} +213 -24
  19. package/dist/chunk-CT5VG7NT.js.map +1 -0
  20. package/dist/chunk-DG3INBBQ.js +1061 -0
  21. package/dist/chunk-DG3INBBQ.js.map +1 -0
  22. package/dist/chunk-DHWPHLGF.cjs +211 -0
  23. package/dist/chunk-DHWPHLGF.cjs.map +1 -0
  24. package/dist/chunk-DRUNNM4C.js +328 -0
  25. package/dist/chunk-DRUNNM4C.js.map +1 -0
  26. package/dist/{chunk-TOCYBDP2.js → chunk-ER3QM7DD.js} +4 -4
  27. package/dist/{chunk-TOCYBDP2.js.map → chunk-ER3QM7DD.js.map} +1 -1
  28. package/dist/chunk-ESZ6V5WB.cjs +916 -0
  29. package/dist/chunk-ESZ6V5WB.cjs.map +1 -0
  30. package/dist/chunk-FPCGLPLJ.cjs +297 -0
  31. package/dist/chunk-FPCGLPLJ.cjs.map +1 -0
  32. package/dist/chunk-FYY54HZC.js +310 -0
  33. package/dist/chunk-FYY54HZC.js.map +1 -0
  34. package/dist/chunk-GFF2I6UD.js +354 -0
  35. package/dist/chunk-GFF2I6UD.js.map +1 -0
  36. package/dist/chunk-H2RMXG2Q.cjs +167 -0
  37. package/dist/chunk-H2RMXG2Q.cjs.map +1 -0
  38. package/dist/chunk-HAJOEDNB.js +274 -0
  39. package/dist/chunk-HAJOEDNB.js.map +1 -0
  40. package/dist/chunk-HT4LP3BO.js +75 -0
  41. package/dist/chunk-HT4LP3BO.js.map +1 -0
  42. package/dist/chunk-I6LR6CPC.cjs +125 -0
  43. package/dist/chunk-I6LR6CPC.cjs.map +1 -0
  44. package/dist/chunk-IEYXQTUW.cjs +284 -0
  45. package/dist/chunk-IEYXQTUW.cjs.map +1 -0
  46. package/dist/chunk-MCYD5LW7.cjs +90 -0
  47. package/dist/chunk-MCYD5LW7.cjs.map +1 -0
  48. package/dist/chunk-PUFCKXFW.cjs +312 -0
  49. package/dist/chunk-PUFCKXFW.cjs.map +1 -0
  50. package/dist/{chunk-W2KMU354.cjs → chunk-PUSD37LD.cjs} +18 -4
  51. package/dist/chunk-PUSD37LD.cjs.map +1 -0
  52. package/dist/chunk-Q6SVIZLX.js +786 -0
  53. package/dist/chunk-Q6SVIZLX.js.map +1 -0
  54. package/dist/chunk-QNVYGEJ4.js +204 -0
  55. package/dist/chunk-QNVYGEJ4.js.map +1 -0
  56. package/dist/chunk-R56K77E2.cjs +810 -0
  57. package/dist/chunk-R56K77E2.cjs.map +1 -0
  58. package/dist/chunk-S3TIWWQL.cjs +322 -0
  59. package/dist/chunk-S3TIWWQL.cjs.map +1 -0
  60. package/dist/chunk-SXVANU23.js +164 -0
  61. package/dist/chunk-SXVANU23.js.map +1 -0
  62. package/dist/chunk-TYZ6ZISQ.cjs +368 -0
  63. package/dist/chunk-TYZ6ZISQ.cjs.map +1 -0
  64. package/dist/chunk-US6Y5RLR.cjs +205 -0
  65. package/dist/chunk-US6Y5RLR.cjs.map +1 -0
  66. package/dist/chunk-UTIOKR5C.js +887 -0
  67. package/dist/chunk-UTIOKR5C.js.map +1 -0
  68. package/dist/{chunk-QU6N55W6.cjs → chunk-V272B7RM.cjs} +11 -12
  69. package/dist/chunk-V272B7RM.cjs.map +1 -0
  70. package/dist/chunk-WE4USCF3.js +226 -0
  71. package/dist/chunk-WE4USCF3.js.map +1 -0
  72. package/dist/chunk-WVAQXM6W.cjs +1105 -0
  73. package/dist/chunk-WVAQXM6W.cjs.map +1 -0
  74. package/dist/chunk-X43DWDXB.cjs +346 -0
  75. package/dist/chunk-X43DWDXB.cjs.map +1 -0
  76. package/dist/chunk-X4QMPCTP.cjs +259 -0
  77. package/dist/chunk-X4QMPCTP.cjs.map +1 -0
  78. package/dist/{chunk-X6C7BUWN.cjs → chunk-XQPJ63ZD.cjs} +4 -4
  79. package/dist/{chunk-X6C7BUWN.cjs.map → chunk-XQPJ63ZD.cjs.map} +1 -1
  80. package/dist/chunk-XW2HXQDO.js +302 -0
  81. package/dist/chunk-XW2HXQDO.js.map +1 -0
  82. package/dist/chunk-XWGAT2DA.js +44 -0
  83. package/dist/chunk-XWGAT2DA.js.map +1 -0
  84. package/dist/{chunk-SHWNNZBL.js → chunk-YP34EWWK.js} +9 -10
  85. package/dist/chunk-YP34EWWK.js.map +1 -0
  86. package/dist/server/auth/defaults.d.ts +3 -0
  87. package/dist/server/auth/defaults.d.ts.map +1 -0
  88. package/dist/server/auth/helpers.d.ts +14 -0
  89. package/dist/server/auth/helpers.d.ts.map +1 -0
  90. package/dist/server/auth/index.cjs +137 -0
  91. package/dist/server/auth/index.cjs.map +1 -0
  92. package/dist/server/auth/index.d.ts +3 -0
  93. package/dist/server/auth/index.d.ts.map +1 -0
  94. package/dist/server/auth/index.js +127 -0
  95. package/dist/server/auth/index.js.map +1 -0
  96. package/dist/server/handlers/a2a.cjs +15 -7
  97. package/dist/server/handlers/a2a.d.ts +482 -0
  98. package/dist/server/handlers/a2a.d.ts.map +1 -1
  99. package/dist/server/handlers/a2a.js +1 -1
  100. package/dist/server/handlers/agent-builder.cjs +37 -37
  101. package/dist/server/handlers/agent-builder.d.ts +599 -77
  102. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  103. package/dist/server/handlers/agent-builder.js +1 -1
  104. package/dist/server/handlers/agents.cjs +53 -37
  105. package/dist/server/handlers/agents.d.ts +3273 -128
  106. package/dist/server/handlers/agents.d.ts.map +1 -1
  107. package/dist/server/handlers/agents.js +1 -1
  108. package/dist/server/handlers/logs.cjs +7 -7
  109. package/dist/server/handlers/logs.d.ts +135 -27
  110. package/dist/server/handlers/logs.d.ts.map +1 -1
  111. package/dist/server/handlers/logs.js +1 -1
  112. package/dist/server/handlers/mcp.cjs +40 -0
  113. package/dist/server/handlers/mcp.cjs.map +1 -0
  114. package/dist/server/handlers/mcp.d.ts +110 -0
  115. package/dist/server/handlers/mcp.d.ts.map +1 -0
  116. package/dist/server/handlers/mcp.js +3 -0
  117. package/dist/server/handlers/mcp.js.map +1 -0
  118. package/dist/server/handlers/memory.cjs +67 -27
  119. package/dist/server/handlers/memory.d.ts +933 -96
  120. package/dist/server/handlers/memory.d.ts.map +1 -1
  121. package/dist/server/handlers/memory.js +1 -1
  122. package/dist/server/handlers/observability.cjs +21 -5
  123. package/dist/server/handlers/observability.d.ts +119 -12
  124. package/dist/server/handlers/observability.d.ts.map +1 -1
  125. package/dist/server/handlers/observability.js +1 -1
  126. package/dist/server/handlers/scores.cjs +13 -13
  127. package/dist/server/handlers/scores.d.ts +110 -141
  128. package/dist/server/handlers/scores.d.ts.map +1 -1
  129. package/dist/server/handlers/scores.js +1 -1
  130. package/dist/server/handlers/stored-agents.cjs +28 -0
  131. package/dist/server/handlers/stored-agents.cjs.map +1 -0
  132. package/dist/server/handlers/stored-agents.d.ts +289 -0
  133. package/dist/server/handlers/stored-agents.d.ts.map +1 -0
  134. package/dist/server/handlers/stored-agents.js +3 -0
  135. package/dist/server/handlers/stored-agents.js.map +1 -0
  136. package/dist/server/handlers/test-utils.cjs +15 -0
  137. package/dist/server/handlers/test-utils.cjs.map +1 -0
  138. package/dist/server/handlers/test-utils.d.ts +6 -0
  139. package/dist/server/handlers/test-utils.d.ts.map +1 -0
  140. package/dist/server/handlers/test-utils.js +13 -0
  141. package/dist/server/handlers/test-utils.js.map +1 -0
  142. package/dist/server/handlers/tools.cjs +11 -11
  143. package/dist/server/handlers/tools.d.ts +69 -23
  144. package/dist/server/handlers/tools.d.ts.map +1 -1
  145. package/dist/server/handlers/tools.js +1 -1
  146. package/dist/server/handlers/utils.cjs +11 -3
  147. package/dist/server/handlers/utils.d.ts +5 -0
  148. package/dist/server/handlers/utils.d.ts.map +1 -1
  149. package/dist/server/handlers/utils.js +1 -1
  150. package/dist/server/handlers/vector.cjs +31 -7
  151. package/dist/server/handlers/vector.d.ts +93 -9
  152. package/dist/server/handlers/vector.d.ts.map +1 -1
  153. package/dist/server/handlers/vector.js +1 -1
  154. package/dist/server/handlers/voice.cjs +21 -9
  155. package/dist/server/handlers/voice.d.ts +81 -40
  156. package/dist/server/handlers/voice.d.ts.map +1 -1
  157. package/dist/server/handlers/voice.js +1 -1
  158. package/dist/server/handlers/workflows.cjs +69 -37
  159. package/dist/server/handlers/workflows.d.ts +927 -79
  160. package/dist/server/handlers/workflows.d.ts.map +1 -1
  161. package/dist/server/handlers/workflows.js +1 -1
  162. package/dist/server/handlers.cjs +36 -31
  163. package/dist/server/handlers.d.ts +1 -0
  164. package/dist/server/handlers.d.ts.map +1 -1
  165. package/dist/server/handlers.js +12 -11
  166. package/dist/server/schemas/a2a.d.ts +786 -0
  167. package/dist/server/schemas/a2a.d.ts.map +1 -0
  168. package/dist/server/schemas/agent-builder.d.ts +204 -0
  169. package/dist/server/schemas/agent-builder.d.ts.map +1 -0
  170. package/dist/server/schemas/agents.d.ts +1375 -0
  171. package/dist/server/schemas/agents.d.ts.map +1 -0
  172. package/dist/server/schemas/common.d.ts +179 -0
  173. package/dist/server/schemas/common.d.ts.map +1 -0
  174. package/dist/server/schemas/logs.d.ts +124 -0
  175. package/dist/server/schemas/logs.d.ts.map +1 -0
  176. package/dist/server/schemas/mcp.d.ts +299 -0
  177. package/dist/server/schemas/mcp.d.ts.map +1 -0
  178. package/dist/server/schemas/memory.d.ts +998 -0
  179. package/dist/server/schemas/memory.d.ts.map +1 -0
  180. package/dist/server/schemas/observability.d.ts +402 -0
  181. package/dist/server/schemas/observability.d.ts.map +1 -0
  182. package/dist/server/schemas/scores.d.ts +259 -0
  183. package/dist/server/schemas/scores.d.ts.map +1 -0
  184. package/dist/server/schemas/stored-agents.d.ts +792 -0
  185. package/dist/server/schemas/stored-agents.d.ts.map +1 -0
  186. package/dist/server/schemas/vectors.d.ts +107 -0
  187. package/dist/server/schemas/vectors.d.ts.map +1 -0
  188. package/dist/server/schemas/workflows.d.ts +602 -0
  189. package/dist/server/schemas/workflows.d.ts.map +1 -0
  190. package/dist/server/server-adapter/index.cjs +481 -0
  191. package/dist/server/server-adapter/index.cjs.map +1 -0
  192. package/dist/server/server-adapter/index.d.ts +91 -0
  193. package/dist/server/server-adapter/index.d.ts.map +1 -0
  194. package/dist/server/server-adapter/index.js +466 -0
  195. package/dist/server/server-adapter/index.js.map +1 -0
  196. package/dist/server/server-adapter/openapi-utils.d.ts +59 -0
  197. package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -0
  198. package/dist/server/server-adapter/redact.d.ts +26 -0
  199. package/dist/server/server-adapter/redact.d.ts.map +1 -0
  200. package/dist/server/server-adapter/routes/a2a.d.ts +3 -0
  201. package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -0
  202. package/dist/server/server-adapter/routes/agent-builder.d.ts +3 -0
  203. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -0
  204. package/dist/server/server-adapter/routes/agents.d.ts +3 -0
  205. package/dist/server/server-adapter/routes/agents.d.ts.map +1 -0
  206. package/dist/server/server-adapter/routes/index.d.ts +50 -0
  207. package/dist/server/server-adapter/routes/index.d.ts.map +1 -0
  208. package/dist/server/server-adapter/routes/legacy.d.ts +7 -0
  209. package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -0
  210. package/dist/server/server-adapter/routes/logs.d.ts +3 -0
  211. package/dist/server/server-adapter/routes/logs.d.ts.map +1 -0
  212. package/dist/server/server-adapter/routes/mcp.d.ts +9 -0
  213. package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -0
  214. package/dist/server/server-adapter/routes/memory.d.ts +3 -0
  215. package/dist/server/server-adapter/routes/memory.d.ts.map +1 -0
  216. package/dist/server/server-adapter/routes/observability.d.ts +3 -0
  217. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -0
  218. package/dist/server/server-adapter/routes/route-builder.d.ts +52 -0
  219. package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -0
  220. package/dist/server/server-adapter/routes/scorers.d.ts +3 -0
  221. package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -0
  222. package/dist/server/server-adapter/routes/stored-agents.d.ts +8 -0
  223. package/dist/server/server-adapter/routes/stored-agents.d.ts.map +1 -0
  224. package/dist/server/server-adapter/routes/stream-types.d.ts +10 -0
  225. package/dist/server/server-adapter/routes/stream-types.d.ts.map +1 -0
  226. package/dist/server/server-adapter/routes/tools.d.ts +3 -0
  227. package/dist/server/server-adapter/routes/tools.d.ts.map +1 -0
  228. package/dist/server/server-adapter/routes/vectors.d.ts +3 -0
  229. package/dist/server/server-adapter/routes/vectors.d.ts.map +1 -0
  230. package/dist/server/server-adapter/routes/workflows.d.ts +3 -0
  231. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -0
  232. package/dist/server/utils.d.ts +1 -1
  233. package/dist/server/utils.d.ts.map +1 -1
  234. package/dist/token-GVZ7HRD7.js +62 -0
  235. package/dist/{token-C3IMNCC4.js.map → token-GVZ7HRD7.js.map} +1 -1
  236. package/dist/{token-C3IMNCC4.js → token-JGA3ZWAN.js} +5 -6
  237. package/dist/token-JGA3ZWAN.js.map +1 -0
  238. package/dist/token-VFONFWVS.cjs +64 -0
  239. package/dist/{token-375W3LEI.cjs.map → token-VFONFWVS.cjs.map} +1 -1
  240. package/dist/{token-375W3LEI.cjs → token-ZOD6YIQ3.cjs} +7 -8
  241. package/dist/token-ZOD6YIQ3.cjs.map +1 -0
  242. package/dist/token-util-7R2ZFIXO.js +7 -0
  243. package/dist/{token-util-E5QO2RCL.js.map → token-util-7R2ZFIXO.js.map} +1 -1
  244. package/dist/token-util-BLJZJDBZ.cjs +9 -0
  245. package/dist/{token-util-CV3RRG6K.cjs.map → token-util-BLJZJDBZ.cjs.map} +1 -1
  246. package/dist/token-util-VGZUWSNR.cjs +9 -0
  247. package/dist/token-util-VGZUWSNR.cjs.map +1 -0
  248. package/dist/token-util-VKTPZLSE.js +7 -0
  249. package/dist/token-util-VKTPZLSE.js.map +1 -0
  250. package/package.json +30 -5
  251. package/dist/chunk-2IS5WICF.js +0 -23036
  252. package/dist/chunk-2IS5WICF.js.map +0 -1
  253. package/dist/chunk-2YZH5PH6.cjs +0 -200
  254. package/dist/chunk-2YZH5PH6.cjs.map +0 -1
  255. package/dist/chunk-3AMNUUZF.js +0 -124
  256. package/dist/chunk-3AMNUUZF.js.map +0 -1
  257. package/dist/chunk-3F52QCI4.js +0 -192
  258. package/dist/chunk-3F52QCI4.js.map +0 -1
  259. package/dist/chunk-4JF5WXPL.js +0 -502
  260. package/dist/chunk-4JF5WXPL.js.map +0 -1
  261. package/dist/chunk-73PAWDM5.js +0 -83
  262. package/dist/chunk-73PAWDM5.js.map +0 -1
  263. package/dist/chunk-A24TSVEZ.cjs +0 -130
  264. package/dist/chunk-A24TSVEZ.cjs.map +0 -1
  265. package/dist/chunk-A2NPD5N6.cjs +0 -517
  266. package/dist/chunk-A2NPD5N6.cjs.map +0 -1
  267. package/dist/chunk-B3Z6J745.js +0 -122
  268. package/dist/chunk-B3Z6J745.js.map +0 -1
  269. package/dist/chunk-BTWIR2B7.cjs +0 -28
  270. package/dist/chunk-BTWIR2B7.cjs.map +0 -1
  271. package/dist/chunk-D7T74TVR.js.map +0 -1
  272. package/dist/chunk-EHACNWDL.cjs +0 -681
  273. package/dist/chunk-EHACNWDL.cjs.map +0 -1
  274. package/dist/chunk-FPBYKMIS.js.map +0 -1
  275. package/dist/chunk-GLAZTMX3.cjs +0 -128
  276. package/dist/chunk-GLAZTMX3.cjs.map +0 -1
  277. package/dist/chunk-ID6JYDNL.cjs +0 -23075
  278. package/dist/chunk-ID6JYDNL.cjs.map +0 -1
  279. package/dist/chunk-KF3RI45U.cjs +0 -172
  280. package/dist/chunk-KF3RI45U.cjs.map +0 -1
  281. package/dist/chunk-KJIDZQRA.cjs.map +0 -1
  282. package/dist/chunk-KWH5QBXP.js +0 -123
  283. package/dist/chunk-KWH5QBXP.js.map +0 -1
  284. package/dist/chunk-ND5OKOMT.js +0 -165
  285. package/dist/chunk-ND5OKOMT.js.map +0 -1
  286. package/dist/chunk-PPMIB3FQ.cjs +0 -88
  287. package/dist/chunk-PPMIB3FQ.cjs.map +0 -1
  288. package/dist/chunk-QU6N55W6.cjs.map +0 -1
  289. package/dist/chunk-S54HNARD.cjs +0 -131
  290. package/dist/chunk-S54HNARD.cjs.map +0 -1
  291. package/dist/chunk-SHWNNZBL.js.map +0 -1
  292. package/dist/chunk-SZIFSF4T.js +0 -25
  293. package/dist/chunk-SZIFSF4T.js.map +0 -1
  294. package/dist/chunk-W2KMU354.cjs.map +0 -1
  295. package/dist/chunk-X3MICMI2.cjs +0 -620
  296. package/dist/chunk-X3MICMI2.cjs.map +0 -1
  297. package/dist/chunk-Z2O5YVHY.js +0 -661
  298. package/dist/chunk-Z2O5YVHY.js.map +0 -1
  299. package/dist/chunk-ZJ6KEY6H.js +0 -600
  300. package/dist/chunk-ZJ6KEY6H.js.map +0 -1
  301. package/dist/token-util-CV3RRG6K.cjs +0 -9
  302. package/dist/token-util-E5QO2RCL.js +0 -7
@@ -0,0 +1,1105 @@
1
+ 'use strict';
2
+
3
+ var chunkPUSD37LD_cjs = require('./chunk-PUSD37LD.cjs');
4
+ var chunkX4QMPCTP_cjs = require('./chunk-X4QMPCTP.cjs');
5
+ var chunkMCYD5LW7_cjs = require('./chunk-MCYD5LW7.cjs');
6
+ var chunkH2RMXG2Q_cjs = require('./chunk-H2RMXG2Q.cjs');
7
+ var chunkV5WWQN7P_cjs = require('./chunk-V5WWQN7P.cjs');
8
+ var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
9
+ var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
10
+ var web = require('stream/web');
11
+ var z = require('zod');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var z__default = /*#__PURE__*/_interopDefault(z);
16
+
17
+ // src/server/handlers/workflows.ts
18
+ var workflows_exports = {};
19
+ chunkO7I5CWRX_cjs.__export(workflows_exports, {
20
+ CANCEL_WORKFLOW_RUN_ROUTE: () => CANCEL_WORKFLOW_RUN_ROUTE,
21
+ CREATE_WORKFLOW_RUN_ROUTE: () => CREATE_WORKFLOW_RUN_ROUTE,
22
+ DELETE_WORKFLOW_RUN_BY_ID_ROUTE: () => DELETE_WORKFLOW_RUN_BY_ID_ROUTE,
23
+ GET_WORKFLOW_BY_ID_ROUTE: () => GET_WORKFLOW_BY_ID_ROUTE,
24
+ GET_WORKFLOW_RUN_BY_ID_ROUTE: () => GET_WORKFLOW_RUN_BY_ID_ROUTE,
25
+ GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE: () => GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE,
26
+ LIST_WORKFLOWS_ROUTE: () => LIST_WORKFLOWS_ROUTE,
27
+ LIST_WORKFLOW_RUNS_ROUTE: () => LIST_WORKFLOW_RUNS_ROUTE,
28
+ OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE: () => OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE,
29
+ OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE: () => OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE,
30
+ OBSERVE_STREAM_WORKFLOW_ROUTE: () => OBSERVE_STREAM_WORKFLOW_ROUTE,
31
+ RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE: () => RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE,
32
+ RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE: () => RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE,
33
+ RESTART_ASYNC_WORKFLOW_ROUTE: () => RESTART_ASYNC_WORKFLOW_ROUTE,
34
+ RESTART_WORKFLOW_ROUTE: () => RESTART_WORKFLOW_ROUTE,
35
+ RESUME_ASYNC_WORKFLOW_ROUTE: () => RESUME_ASYNC_WORKFLOW_ROUTE,
36
+ RESUME_STREAM_WORKFLOW_ROUTE: () => RESUME_STREAM_WORKFLOW_ROUTE,
37
+ RESUME_WORKFLOW_ROUTE: () => RESUME_WORKFLOW_ROUTE,
38
+ START_ASYNC_WORKFLOW_ROUTE: () => START_ASYNC_WORKFLOW_ROUTE,
39
+ START_WORKFLOW_RUN_ROUTE: () => START_WORKFLOW_RUN_ROUTE,
40
+ STREAM_LEGACY_WORKFLOW_ROUTE: () => STREAM_LEGACY_WORKFLOW_ROUTE,
41
+ STREAM_VNEXT_WORKFLOW_ROUTE: () => STREAM_VNEXT_WORKFLOW_ROUTE,
42
+ STREAM_WORKFLOW_ROUTE: () => STREAM_WORKFLOW_ROUTE,
43
+ TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE: () => TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE,
44
+ TIME_TRAVEL_STREAM_WORKFLOW_ROUTE: () => TIME_TRAVEL_STREAM_WORKFLOW_ROUTE,
45
+ TIME_TRAVEL_WORKFLOW_ROUTE: () => TIME_TRAVEL_WORKFLOW_ROUTE
46
+ });
47
+ var workflowRunStatusSchema = z__default.default.enum([
48
+ "running",
49
+ "waiting",
50
+ "suspended",
51
+ "success",
52
+ "failed",
53
+ "canceled",
54
+ "pending",
55
+ "bailed"
56
+ ]);
57
+ var workflowIdPathParams = z__default.default.object({
58
+ workflowId: z__default.default.string().describe("Unique identifier for the workflow")
59
+ });
60
+ var workflowRunPathParams = workflowIdPathParams.extend({
61
+ runId: z__default.default.string().describe("Unique identifier for the workflow run")
62
+ });
63
+ var serializedStepSchema = z__default.default.object({
64
+ id: z__default.default.string(),
65
+ description: z__default.default.string().optional()
66
+ });
67
+ var serializedStepFlowEntrySchema = z__default.default.object({
68
+ type: z__default.default.enum(["step", "sleep", "sleepUntil", "waitForEvent", "parallel", "conditional", "loop", "foreach"])
69
+ });
70
+ var workflowInfoSchema = z__default.default.object({
71
+ steps: z__default.default.record(z__default.default.string(), serializedStepSchema),
72
+ allSteps: z__default.default.record(z__default.default.string(), serializedStepSchema),
73
+ name: z__default.default.string().optional(),
74
+ description: z__default.default.string().optional(),
75
+ stepGraph: z__default.default.array(serializedStepFlowEntrySchema),
76
+ inputSchema: z__default.default.string().optional(),
77
+ outputSchema: z__default.default.string().optional(),
78
+ options: z__default.default.object({}).optional()
79
+ });
80
+ var listWorkflowsResponseSchema = z__default.default.record(z__default.default.string(), workflowInfoSchema);
81
+ var workflowRunSchema = z__default.default.object({
82
+ workflowName: z__default.default.string(),
83
+ runId: z__default.default.string(),
84
+ snapshot: z__default.default.union([z__default.default.object({}), z__default.default.string()]),
85
+ createdAt: z__default.default.date(),
86
+ updatedAt: z__default.default.date(),
87
+ resourceId: z__default.default.string().optional()
88
+ });
89
+ var workflowRunsResponseSchema = z__default.default.object({
90
+ runs: z__default.default.array(workflowRunSchema),
91
+ total: z__default.default.number()
92
+ });
93
+ var workflowRunResponseSchema = workflowRunSchema;
94
+ var listWorkflowRunsQuerySchema = chunkMCYD5LW7_cjs.createCombinedPaginationSchema().extend({
95
+ fromDate: z__default.default.coerce.date().optional(),
96
+ toDate: z__default.default.coerce.date().optional(),
97
+ resourceId: z__default.default.string().optional(),
98
+ status: workflowRunStatusSchema.optional()
99
+ });
100
+ var workflowExecutionBodySchema = z__default.default.object({
101
+ inputData: z__default.default.unknown().optional(),
102
+ initialState: z__default.default.unknown().optional(),
103
+ requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
104
+ tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional()
105
+ });
106
+ var streamLegacyWorkflowBodySchema = workflowExecutionBodySchema;
107
+ var streamWorkflowBodySchema = workflowExecutionBodySchema.extend({
108
+ closeOnSuspend: z__default.default.boolean().optional()
109
+ });
110
+ var resumeBodySchema = z__default.default.object({
111
+ step: z__default.default.union([z__default.default.string(), z__default.default.array(z__default.default.string())]).optional(),
112
+ // Optional - workflow can auto-resume all suspended steps
113
+ resumeData: z__default.default.unknown().optional(),
114
+ requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
115
+ tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional()
116
+ });
117
+ var restartBodySchema = z__default.default.object({
118
+ requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
119
+ tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional()
120
+ });
121
+ var timeTravelBodySchema = z__default.default.object({
122
+ inputData: z__default.default.unknown().optional(),
123
+ resumeData: z__default.default.unknown().optional(),
124
+ initialState: z__default.default.unknown().optional(),
125
+ step: z__default.default.union([z__default.default.string(), z__default.default.array(z__default.default.string())]),
126
+ context: z__default.default.record(z__default.default.string(), z__default.default.any()).optional(),
127
+ nestedStepsContext: z__default.default.record(z__default.default.string(), z__default.default.record(z__default.default.string(), z__default.default.any())).optional(),
128
+ requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
129
+ tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional()
130
+ });
131
+ var startAsyncWorkflowBodySchema = workflowExecutionBodySchema;
132
+ z__default.default.object({
133
+ event: z__default.default.string(),
134
+ data: z__default.default.unknown()
135
+ });
136
+ var workflowExecutionResultSchema = z__default.default.object({
137
+ status: workflowRunStatusSchema,
138
+ result: z__default.default.unknown().optional(),
139
+ error: z__default.default.unknown().optional()
140
+ });
141
+ var workflowControlResponseSchema = chunkMCYD5LW7_cjs.messageResponseSchema;
142
+ var createWorkflowRunResponseSchema = z__default.default.object({
143
+ runId: z__default.default.string()
144
+ });
145
+
146
+ // src/server/handlers/workflows.ts
147
+ async function listWorkflowsFromSystem({ mastra, workflowId }) {
148
+ const logger = mastra.getLogger();
149
+ if (!workflowId) {
150
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
151
+ }
152
+ let workflow;
153
+ workflow = chunkPUSD37LD_cjs.WorkflowRegistry.getWorkflow(workflowId);
154
+ if (!workflow) {
155
+ try {
156
+ workflow = mastra.getWorkflowById(workflowId);
157
+ } catch (error) {
158
+ logger.debug("Error getting workflow, searching agents for workflow", error);
159
+ }
160
+ }
161
+ if (!workflow) {
162
+ logger.debug("Workflow not found, searching agents for workflow", { workflowId });
163
+ const agents = mastra.listAgents();
164
+ if (Object.keys(agents || {}).length) {
165
+ for (const [_, agent] of Object.entries(agents)) {
166
+ try {
167
+ const workflows = await agent.listWorkflows();
168
+ if (workflows[workflowId]) {
169
+ workflow = workflows[workflowId];
170
+ break;
171
+ }
172
+ break;
173
+ } catch (error) {
174
+ logger.debug("Error getting workflow from agent", error);
175
+ }
176
+ }
177
+ }
178
+ }
179
+ if (!workflow) {
180
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
181
+ }
182
+ return { workflow };
183
+ }
184
+ var LIST_WORKFLOWS_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
185
+ method: "GET",
186
+ path: "/api/workflows",
187
+ responseType: "json",
188
+ queryParamSchema: z.z.object({
189
+ partial: z.z.string().optional()
190
+ }),
191
+ responseSchema: listWorkflowsResponseSchema,
192
+ summary: "List all workflows",
193
+ description: "Returns a list of all available workflows in the system",
194
+ tags: ["Workflows"],
195
+ handler: async ({ mastra, partial }) => {
196
+ try {
197
+ const workflows = mastra.listWorkflows({ serialized: false });
198
+ const isPartial = partial === "true";
199
+ const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
200
+ acc[key] = chunkPUSD37LD_cjs.getWorkflowInfo(workflow, isPartial);
201
+ return acc;
202
+ }, {});
203
+ return _workflows;
204
+ } catch (error) {
205
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflows");
206
+ }
207
+ }
208
+ });
209
+ var GET_WORKFLOW_BY_ID_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
210
+ method: "GET",
211
+ path: "/api/workflows/:workflowId",
212
+ responseType: "json",
213
+ pathParamSchema: workflowIdPathParams,
214
+ responseSchema: workflowInfoSchema,
215
+ summary: "Get workflow by ID",
216
+ description: "Returns details for a specific workflow",
217
+ tags: ["Workflows"],
218
+ handler: async ({ mastra, workflowId }) => {
219
+ try {
220
+ if (!workflowId) {
221
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
222
+ }
223
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
224
+ return chunkPUSD37LD_cjs.getWorkflowInfo(workflow);
225
+ } catch (error) {
226
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow");
227
+ }
228
+ }
229
+ });
230
+ var LIST_WORKFLOW_RUNS_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
231
+ method: "GET",
232
+ path: "/api/workflows/:workflowId/runs",
233
+ responseType: "json",
234
+ pathParamSchema: workflowIdPathParams,
235
+ queryParamSchema: listWorkflowRunsQuerySchema,
236
+ responseSchema: workflowRunsResponseSchema,
237
+ summary: "List workflow runs",
238
+ description: "Returns a paginated list of execution runs for the specified workflow",
239
+ tags: ["Workflows"],
240
+ handler: async ({ mastra, workflowId, fromDate, toDate, page, perPage, limit, offset, resourceId, status }) => {
241
+ try {
242
+ if (!workflowId) {
243
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
244
+ }
245
+ let finalPage = page;
246
+ let finalPerPage = perPage;
247
+ if (finalPerPage === void 0 && limit !== void 0) {
248
+ finalPerPage = limit;
249
+ }
250
+ if (finalPage === void 0 && offset !== void 0 && finalPerPage !== void 0 && finalPerPage > 0) {
251
+ finalPage = Math.floor(offset / finalPerPage);
252
+ }
253
+ if (finalPerPage !== void 0 && (typeof finalPerPage !== "number" || !Number.isInteger(finalPerPage) || finalPerPage <= 0)) {
254
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "perPage must be a positive integer" });
255
+ }
256
+ if (finalPage !== void 0 && (!Number.isInteger(finalPage) || finalPage < 0)) {
257
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "page must be a non-negative integer" });
258
+ }
259
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
260
+ if (!workflow) {
261
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
262
+ }
263
+ const workflowRuns = await workflow.listWorkflowRuns({
264
+ fromDate: fromDate ? typeof fromDate === "string" ? new Date(fromDate) : fromDate : void 0,
265
+ toDate: toDate ? typeof toDate === "string" ? new Date(toDate) : toDate : void 0,
266
+ perPage: finalPerPage,
267
+ page: finalPage,
268
+ resourceId,
269
+ status
270
+ }) || {
271
+ runs: [],
272
+ total: 0
273
+ };
274
+ return workflowRuns;
275
+ } catch (error) {
276
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow runs");
277
+ }
278
+ }
279
+ });
280
+ var GET_WORKFLOW_RUN_BY_ID_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
281
+ method: "GET",
282
+ path: "/api/workflows/:workflowId/runs/:runId",
283
+ responseType: "json",
284
+ pathParamSchema: workflowRunPathParams,
285
+ responseSchema: workflowRunResponseSchema,
286
+ summary: "Get workflow run by ID",
287
+ description: "Returns details for a specific workflow run",
288
+ tags: ["Workflows"],
289
+ handler: async ({ mastra, workflowId, runId }) => {
290
+ try {
291
+ if (!workflowId) {
292
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
293
+ }
294
+ if (!runId) {
295
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Run ID is required" });
296
+ }
297
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
298
+ if (!workflow) {
299
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
300
+ }
301
+ const run = await workflow.getWorkflowRunById(runId);
302
+ if (!run) {
303
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
304
+ }
305
+ return run;
306
+ } catch (error) {
307
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow run");
308
+ }
309
+ }
310
+ });
311
+ var DELETE_WORKFLOW_RUN_BY_ID_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
312
+ method: "DELETE",
313
+ path: "/api/workflows/:workflowId/runs/:runId",
314
+ responseType: "json",
315
+ pathParamSchema: workflowRunPathParams,
316
+ responseSchema: workflowControlResponseSchema,
317
+ summary: "Delete workflow run by ID",
318
+ description: "Deletes a specific workflow run by ID",
319
+ tags: ["Workflows"],
320
+ handler: async ({ mastra, workflowId, runId }) => {
321
+ try {
322
+ if (!workflowId) {
323
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
324
+ }
325
+ if (!runId) {
326
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Run ID is required" });
327
+ }
328
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
329
+ if (!workflow) {
330
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
331
+ }
332
+ await workflow.deleteWorkflowRunById(runId);
333
+ return { message: "Workflow run deleted" };
334
+ } catch (error) {
335
+ return chunkV5WWQN7P_cjs.handleError(error, "Error deleting workflow run");
336
+ }
337
+ }
338
+ });
339
+ var CREATE_WORKFLOW_RUN_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
340
+ method: "POST",
341
+ path: "/api/workflows/:workflowId/create-run",
342
+ responseType: "json",
343
+ pathParamSchema: workflowIdPathParams,
344
+ queryParamSchema: chunkMCYD5LW7_cjs.optionalRunIdSchema,
345
+ responseSchema: createWorkflowRunResponseSchema,
346
+ summary: "Create workflow run",
347
+ description: "Creates a new workflow execution instance with an optional custom run ID",
348
+ tags: ["Workflows"],
349
+ handler: async ({ mastra, workflowId, runId }) => {
350
+ try {
351
+ if (!workflowId) {
352
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
353
+ }
354
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
355
+ if (!workflow) {
356
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
357
+ }
358
+ const run = await workflow.createRun({ runId });
359
+ return { runId: run.runId };
360
+ } catch (error) {
361
+ return chunkV5WWQN7P_cjs.handleError(error, "Error creating workflow run");
362
+ }
363
+ }
364
+ });
365
+ var STREAM_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
366
+ method: "POST",
367
+ path: "/api/workflows/:workflowId/stream",
368
+ responseType: "stream",
369
+ pathParamSchema: workflowIdPathParams,
370
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
371
+ bodySchema: streamWorkflowBodySchema,
372
+ summary: "Stream workflow execution",
373
+ description: "Executes a workflow and streams the results in real-time",
374
+ tags: ["Workflows"],
375
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
376
+ try {
377
+ if (!workflowId) {
378
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
379
+ }
380
+ if (!runId) {
381
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to stream workflow" });
382
+ }
383
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
384
+ if (!workflow) {
385
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
386
+ }
387
+ const serverCache = mastra.getServerCache();
388
+ const run = await workflow.createRun({ runId });
389
+ const result = run.stream(params);
390
+ return result.fullStream.pipeThrough(
391
+ new web.TransformStream({
392
+ transform(chunk, controller) {
393
+ if (serverCache) {
394
+ const cacheKey = runId;
395
+ serverCache.listPush(cacheKey, chunk).catch(() => {
396
+ });
397
+ }
398
+ controller.enqueue(chunk);
399
+ }
400
+ })
401
+ );
402
+ } catch (error) {
403
+ return chunkV5WWQN7P_cjs.handleError(error, "Error streaming workflow");
404
+ }
405
+ }
406
+ });
407
+ var STREAM_VNEXT_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
408
+ method: "POST",
409
+ path: "/api/workflows/:workflowId/streamVNext",
410
+ responseType: "stream",
411
+ pathParamSchema: workflowIdPathParams,
412
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
413
+ bodySchema: streamWorkflowBodySchema,
414
+ summary: "Stream workflow execution (v2)",
415
+ description: "Executes a workflow using the v2 streaming API and streams the results in real-time",
416
+ tags: ["Workflows"],
417
+ handler: STREAM_WORKFLOW_ROUTE.handler
418
+ });
419
+ var RESUME_STREAM_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
420
+ method: "POST",
421
+ path: "/api/workflows/:workflowId/resume-stream",
422
+ responseType: "stream",
423
+ pathParamSchema: workflowIdPathParams,
424
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
425
+ bodySchema: resumeBodySchema,
426
+ responseSchema: chunkX4QMPCTP_cjs.streamResponseSchema,
427
+ summary: "Resume workflow stream",
428
+ description: "Resumes a suspended workflow execution and continues streaming results",
429
+ tags: ["Workflows"],
430
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
431
+ try {
432
+ if (!workflowId) {
433
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
434
+ }
435
+ if (!runId) {
436
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
437
+ }
438
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
439
+ if (!workflow) {
440
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
441
+ }
442
+ const run = await workflow.getWorkflowRunById(runId);
443
+ if (!run) {
444
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
445
+ }
446
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
447
+ const serverCache = mastra.getServerCache();
448
+ const stream = _run.resumeStream(params).fullStream.pipeThrough(
449
+ new web.TransformStream({
450
+ transform(chunk, controller) {
451
+ if (serverCache) {
452
+ const cacheKey = runId;
453
+ serverCache.listPush(cacheKey, chunk).catch(() => {
454
+ });
455
+ }
456
+ controller.enqueue(chunk);
457
+ }
458
+ })
459
+ );
460
+ return stream;
461
+ } catch (error) {
462
+ return chunkV5WWQN7P_cjs.handleError(error, "Error resuming workflow");
463
+ }
464
+ }
465
+ });
466
+ var GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
467
+ method: "GET",
468
+ path: "/api/workflows/:workflowId/runs/:runId/execution-result",
469
+ responseType: "json",
470
+ pathParamSchema: workflowRunPathParams,
471
+ responseSchema: workflowExecutionResultSchema,
472
+ summary: "Get workflow execution result",
473
+ description: "Returns the final execution result of a completed workflow run",
474
+ tags: ["Workflows"],
475
+ handler: async ({ mastra, workflowId, runId }) => {
476
+ try {
477
+ if (!workflowId) {
478
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
479
+ }
480
+ if (!runId) {
481
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Run ID is required" });
482
+ }
483
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
484
+ if (!workflow) {
485
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
486
+ }
487
+ const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
488
+ if (!executionResult) {
489
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
490
+ }
491
+ return executionResult;
492
+ } catch (error) {
493
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow run execution result");
494
+ }
495
+ }
496
+ });
497
+ var START_ASYNC_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
498
+ method: "POST",
499
+ path: "/api/workflows/:workflowId/start-async",
500
+ responseType: "json",
501
+ pathParamSchema: workflowIdPathParams,
502
+ queryParamSchema: chunkMCYD5LW7_cjs.optionalRunIdSchema,
503
+ bodySchema: startAsyncWorkflowBodySchema,
504
+ responseSchema: workflowExecutionResultSchema,
505
+ summary: "Start workflow asynchronously",
506
+ description: "Starts a workflow execution asynchronously without streaming results",
507
+ tags: ["Workflows"],
508
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
509
+ try {
510
+ if (!workflowId) {
511
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
512
+ }
513
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
514
+ if (!workflow) {
515
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
516
+ }
517
+ const _run = await workflow.createRun({ runId });
518
+ const result = await _run.start(params);
519
+ return result;
520
+ } catch (error) {
521
+ return chunkV5WWQN7P_cjs.handleError(error, "Error starting async workflow");
522
+ }
523
+ }
524
+ });
525
+ var START_WORKFLOW_RUN_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
526
+ method: "POST",
527
+ path: "/api/workflows/:workflowId/start",
528
+ responseType: "json",
529
+ pathParamSchema: workflowIdPathParams,
530
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
531
+ bodySchema: startAsyncWorkflowBodySchema,
532
+ responseSchema: workflowControlResponseSchema,
533
+ summary: "Start specific workflow run",
534
+ description: "Starts execution of a specific workflow run by ID",
535
+ tags: ["Workflows"],
536
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
537
+ try {
538
+ if (!workflowId) {
539
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
540
+ }
541
+ if (!runId) {
542
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to start run" });
543
+ }
544
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
545
+ if (!workflow) {
546
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
547
+ }
548
+ const run = await workflow.getWorkflowRunById(runId);
549
+ if (!run) {
550
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
551
+ }
552
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
553
+ void _run.start({
554
+ ...params
555
+ });
556
+ return { message: "Workflow run started" };
557
+ } catch (e) {
558
+ return chunkV5WWQN7P_cjs.handleError(e, "Error starting workflow run");
559
+ }
560
+ }
561
+ });
562
+ var OBSERVE_STREAM_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
563
+ method: "POST",
564
+ path: "/api/workflows/:workflowId/observe",
565
+ responseType: "stream",
566
+ pathParamSchema: workflowIdPathParams,
567
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
568
+ responseSchema: chunkX4QMPCTP_cjs.streamResponseSchema,
569
+ summary: "Observe workflow stream",
570
+ description: "Observes and streams updates from an already running workflow execution",
571
+ tags: ["Workflows"],
572
+ handler: async ({ mastra, workflowId, runId }) => {
573
+ try {
574
+ if (!workflowId) {
575
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
576
+ }
577
+ if (!runId) {
578
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
579
+ }
580
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
581
+ if (!workflow) {
582
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
583
+ }
584
+ const run = await workflow.getWorkflowRunById(runId);
585
+ if (!run) {
586
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
587
+ }
588
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
589
+ const serverCache = mastra.getServerCache();
590
+ if (!serverCache) {
591
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Server cache not found" });
592
+ }
593
+ const cachedRunChunks = await serverCache.listFromTo(runId, 0);
594
+ const combinedStream = new web.ReadableStream({
595
+ start(controller) {
596
+ const emitCachedChunks = async () => {
597
+ for (const chunk of cachedRunChunks) {
598
+ controller.enqueue(chunk);
599
+ }
600
+ };
601
+ const liveStream = _run.observeStream();
602
+ const reader = liveStream.getReader();
603
+ const pump = async () => {
604
+ try {
605
+ while (true) {
606
+ const { done, value } = await reader.read();
607
+ if (done) {
608
+ controller.close();
609
+ break;
610
+ }
611
+ controller.enqueue(value);
612
+ }
613
+ } catch (error) {
614
+ controller.error(error);
615
+ } finally {
616
+ reader.releaseLock();
617
+ }
618
+ };
619
+ void emitCachedChunks().then(() => {
620
+ void pump();
621
+ }).catch((error) => {
622
+ controller.error(error);
623
+ });
624
+ }
625
+ });
626
+ return combinedStream;
627
+ } catch (error) {
628
+ return chunkV5WWQN7P_cjs.handleError(error, "Error observing workflow stream");
629
+ }
630
+ }
631
+ });
632
+ var OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
633
+ method: "POST",
634
+ path: "/api/workflows/:workflowId/observe-streamVNext",
635
+ responseType: "stream",
636
+ pathParamSchema: workflowIdPathParams,
637
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
638
+ responseSchema: chunkX4QMPCTP_cjs.streamResponseSchema,
639
+ summary: "Observe workflow stream (v2)",
640
+ description: "Observes and streams updates from an already running workflow execution using v2 streaming API",
641
+ tags: ["Workflows"],
642
+ handler: OBSERVE_STREAM_WORKFLOW_ROUTE.handler
643
+ });
644
+ var RESUME_ASYNC_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
645
+ method: "POST",
646
+ path: "/api/workflows/:workflowId/resume-async",
647
+ responseType: "json",
648
+ pathParamSchema: workflowIdPathParams,
649
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
650
+ bodySchema: resumeBodySchema,
651
+ responseSchema: workflowExecutionResultSchema,
652
+ summary: "Resume workflow asynchronously",
653
+ description: "Resumes a suspended workflow execution asynchronously without streaming",
654
+ tags: ["Workflows"],
655
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
656
+ try {
657
+ if (!workflowId) {
658
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
659
+ }
660
+ if (!runId) {
661
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
662
+ }
663
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
664
+ if (!workflow) {
665
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
666
+ }
667
+ const run = await workflow.getWorkflowRunById(runId);
668
+ if (!run) {
669
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
670
+ }
671
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
672
+ const result = await _run.resume(params);
673
+ return result;
674
+ } catch (error) {
675
+ return chunkV5WWQN7P_cjs.handleError(error, "Error resuming workflow step");
676
+ }
677
+ }
678
+ });
679
+ var RESUME_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
680
+ method: "POST",
681
+ path: "/api/workflows/:workflowId/resume",
682
+ responseType: "json",
683
+ pathParamSchema: workflowIdPathParams,
684
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
685
+ bodySchema: resumeBodySchema,
686
+ responseSchema: workflowControlResponseSchema,
687
+ summary: "Resume workflow",
688
+ description: "Resumes a suspended workflow execution from a specific step",
689
+ tags: ["Workflows"],
690
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
691
+ try {
692
+ if (!workflowId) {
693
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
694
+ }
695
+ if (!runId) {
696
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
697
+ }
698
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
699
+ if (!workflow) {
700
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
701
+ }
702
+ const run = await workflow.getWorkflowRunById(runId);
703
+ if (!run) {
704
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
705
+ }
706
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
707
+ void _run.resume(params);
708
+ return { message: "Workflow run resumed" };
709
+ } catch (error) {
710
+ return chunkV5WWQN7P_cjs.handleError(error, "Error resuming workflow");
711
+ }
712
+ }
713
+ });
714
+ var RESTART_ASYNC_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
715
+ method: "POST",
716
+ path: "/api/workflows/:workflowId/restart-async",
717
+ responseType: "json",
718
+ pathParamSchema: workflowIdPathParams,
719
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
720
+ bodySchema: restartBodySchema,
721
+ responseSchema: workflowExecutionResultSchema,
722
+ summary: "Restart workflow asynchronously",
723
+ description: "Restarts an active workflow execution asynchronously",
724
+ tags: ["Workflows"],
725
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
726
+ try {
727
+ if (!workflowId) {
728
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
729
+ }
730
+ if (!runId) {
731
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to restart workflow" });
732
+ }
733
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
734
+ if (!workflow) {
735
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
736
+ }
737
+ const run = await workflow.getWorkflowRunById(runId);
738
+ if (!run) {
739
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
740
+ }
741
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
742
+ const result = await _run.restart(params);
743
+ return result;
744
+ } catch (error) {
745
+ return chunkV5WWQN7P_cjs.handleError(error, "Error restarting workflow");
746
+ }
747
+ }
748
+ });
749
+ var RESTART_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
750
+ method: "POST",
751
+ path: "/api/workflows/:workflowId/restart",
752
+ responseType: "json",
753
+ pathParamSchema: workflowIdPathParams,
754
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
755
+ bodySchema: restartBodySchema,
756
+ responseSchema: workflowControlResponseSchema,
757
+ summary: "Restart workflow",
758
+ description: "Restarts an active workflow execution",
759
+ tags: ["Workflows"],
760
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
761
+ try {
762
+ if (!workflowId) {
763
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
764
+ }
765
+ if (!runId) {
766
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to restart workflow" });
767
+ }
768
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
769
+ if (!workflow) {
770
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
771
+ }
772
+ const run = await workflow.getWorkflowRunById(runId);
773
+ if (!run) {
774
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
775
+ }
776
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
777
+ void _run.restart(params);
778
+ return { message: "Workflow run restarted" };
779
+ } catch (error) {
780
+ return chunkV5WWQN7P_cjs.handleError(error, "Error restarting workflow");
781
+ }
782
+ }
783
+ });
784
+ var RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
785
+ method: "POST",
786
+ path: "/api/workflows/:workflowId/restart-all-active-workflow-runs-async",
787
+ responseType: "json",
788
+ pathParamSchema: workflowIdPathParams,
789
+ responseSchema: workflowControlResponseSchema,
790
+ summary: "Restart all active workflow runs asynchronously",
791
+ description: "Restarts all active workflow runs asynchronously",
792
+ tags: ["Workflows"],
793
+ handler: async ({ mastra, workflowId }) => {
794
+ try {
795
+ if (!workflowId) {
796
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
797
+ }
798
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
799
+ if (!workflow) {
800
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
801
+ }
802
+ await workflow.restartAllActiveWorkflowRuns();
803
+ return { message: "All active workflow runs restarted" };
804
+ } catch (error) {
805
+ return chunkV5WWQN7P_cjs.handleError(error, "Error restarting workflow");
806
+ }
807
+ }
808
+ });
809
+ var RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
810
+ method: "POST",
811
+ path: "/api/workflows/:workflowId/restart-all-active-workflow-runs",
812
+ responseType: "json",
813
+ pathParamSchema: workflowIdPathParams,
814
+ responseSchema: workflowControlResponseSchema,
815
+ summary: "Restart all active workflow runs",
816
+ description: "Restarts all active workflow runs",
817
+ tags: ["Workflows"],
818
+ handler: async ({ mastra, workflowId }) => {
819
+ try {
820
+ if (!workflowId) {
821
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
822
+ }
823
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
824
+ if (!workflow) {
825
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
826
+ }
827
+ void workflow.restartAllActiveWorkflowRuns();
828
+ return { message: "All active workflow runs restarted" };
829
+ } catch (error) {
830
+ return chunkV5WWQN7P_cjs.handleError(error, "Error restarting workflow");
831
+ }
832
+ }
833
+ });
834
+ var TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
835
+ method: "POST",
836
+ path: "/api/workflows/:workflowId/time-travel-async",
837
+ responseType: "json",
838
+ pathParamSchema: workflowIdPathParams,
839
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
840
+ bodySchema: timeTravelBodySchema,
841
+ responseSchema: workflowExecutionResultSchema,
842
+ summary: "Time travel workflow asynchronously",
843
+ description: "Time travels a workflow run asynchronously without streaming",
844
+ tags: ["Workflows"],
845
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
846
+ try {
847
+ if (!workflowId) {
848
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
849
+ }
850
+ if (!runId) {
851
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to time travel workflow" });
852
+ }
853
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
854
+ if (!workflow) {
855
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
856
+ }
857
+ const run = await workflow.getWorkflowRunById(runId);
858
+ if (!run) {
859
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
860
+ }
861
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
862
+ const result = await _run.timeTravel(params);
863
+ return result;
864
+ } catch (error) {
865
+ return chunkV5WWQN7P_cjs.handleError(error, "Error time traveling workflow");
866
+ }
867
+ }
868
+ });
869
+ var TIME_TRAVEL_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
870
+ method: "POST",
871
+ path: "/api/workflows/:workflowId/time-travel",
872
+ responseType: "json",
873
+ pathParamSchema: workflowIdPathParams,
874
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
875
+ bodySchema: timeTravelBodySchema,
876
+ responseSchema: workflowControlResponseSchema,
877
+ summary: "Time travel workflow",
878
+ description: "Time travels a workflow run, starting from a specific step",
879
+ tags: ["Workflows"],
880
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
881
+ try {
882
+ if (!workflowId) {
883
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
884
+ }
885
+ if (!runId) {
886
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to time travel workflow" });
887
+ }
888
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
889
+ if (!workflow) {
890
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
891
+ }
892
+ const run = await workflow.getWorkflowRunById(runId);
893
+ if (!run) {
894
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
895
+ }
896
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
897
+ void _run.timeTravel(params);
898
+ return { message: "Workflow run time travel started" };
899
+ } catch (error) {
900
+ return chunkV5WWQN7P_cjs.handleError(error, "Error time traveling workflow");
901
+ }
902
+ }
903
+ });
904
+ var TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
905
+ method: "POST",
906
+ path: "/api/workflows/:workflowId/time-travel-stream",
907
+ responseType: "stream",
908
+ pathParamSchema: workflowIdPathParams,
909
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
910
+ bodySchema: timeTravelBodySchema,
911
+ summary: "Time travel workflow stream",
912
+ description: "Time travels a workflow run, starting from a specific step, and streams the results in real-time",
913
+ tags: ["Workflows"],
914
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
915
+ try {
916
+ if (!workflowId) {
917
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
918
+ }
919
+ if (!runId) {
920
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to time travel workflow stream" });
921
+ }
922
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
923
+ if (!workflow) {
924
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
925
+ }
926
+ const serverCache = mastra.getServerCache();
927
+ const run = await workflow.createRun({ runId });
928
+ const result = run.timeTravelStream(params);
929
+ return result.fullStream.pipeThrough(
930
+ new web.TransformStream({
931
+ transform(chunk, controller) {
932
+ if (serverCache) {
933
+ const cacheKey = runId;
934
+ serverCache.listPush(cacheKey, chunk).catch(() => {
935
+ });
936
+ }
937
+ controller.enqueue(chunk);
938
+ }
939
+ })
940
+ );
941
+ } catch (error) {
942
+ return chunkV5WWQN7P_cjs.handleError(error, "Error time traveling workflow stream");
943
+ }
944
+ }
945
+ });
946
+ var CANCEL_WORKFLOW_RUN_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
947
+ method: "POST",
948
+ path: "/api/workflows/:workflowId/runs/:runId/cancel",
949
+ responseType: "json",
950
+ pathParamSchema: workflowRunPathParams,
951
+ responseSchema: workflowControlResponseSchema,
952
+ summary: "Cancel workflow run",
953
+ description: "Cancels an in-progress workflow execution",
954
+ tags: ["Workflows"],
955
+ handler: async ({ mastra, workflowId, runId }) => {
956
+ try {
957
+ if (!workflowId) {
958
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
959
+ }
960
+ if (!runId) {
961
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
962
+ }
963
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
964
+ if (!workflow) {
965
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
966
+ }
967
+ const run = await workflow.getWorkflowRunById(runId);
968
+ if (!run) {
969
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
970
+ }
971
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
972
+ await _run.cancel();
973
+ return { message: "Workflow run cancelled" };
974
+ } catch (error) {
975
+ return chunkV5WWQN7P_cjs.handleError(error, "Error canceling workflow run");
976
+ }
977
+ }
978
+ });
979
+ var STREAM_LEGACY_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
980
+ method: "POST",
981
+ path: "/api/workflows/:workflowId/stream-legacy",
982
+ responseType: "stream",
983
+ pathParamSchema: workflowIdPathParams,
984
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
985
+ bodySchema: streamWorkflowBodySchema,
986
+ responseSchema: chunkX4QMPCTP_cjs.streamResponseSchema,
987
+ summary: "[DEPRECATED] Stream workflow with legacy format",
988
+ description: "Legacy endpoint for streaming workflow execution. Use /api/workflows/:workflowId/stream instead.",
989
+ tags: ["Workflows", "Legacy"],
990
+ handler: async ({ mastra, workflowId, runId, ...params }) => {
991
+ try {
992
+ if (!workflowId) {
993
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
994
+ }
995
+ if (!runId) {
996
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
997
+ }
998
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
999
+ if (!workflow) {
1000
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
1001
+ }
1002
+ const serverCache = mastra.getServerCache();
1003
+ const run = await workflow.createRun({ runId });
1004
+ const result = run.streamLegacy({
1005
+ ...params,
1006
+ onChunk: async (chunk) => {
1007
+ if (serverCache) {
1008
+ const cacheKey = runId;
1009
+ await serverCache.listPush(cacheKey, chunk);
1010
+ }
1011
+ }
1012
+ });
1013
+ return result.stream;
1014
+ } catch (error) {
1015
+ return chunkV5WWQN7P_cjs.handleError(error, "Error executing workflow");
1016
+ }
1017
+ }
1018
+ });
1019
+ var OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
1020
+ method: "POST",
1021
+ path: "/api/workflows/:workflowId/observe-stream-legacy",
1022
+ responseType: "stream",
1023
+ pathParamSchema: workflowIdPathParams,
1024
+ queryParamSchema: chunkMCYD5LW7_cjs.runIdSchema,
1025
+ responseSchema: chunkX4QMPCTP_cjs.streamResponseSchema,
1026
+ summary: "[DEPRECATED] Observe workflow stream with legacy format",
1027
+ description: "Legacy endpoint for observing workflow stream. Use /api/workflows/:workflowId/observe instead.",
1028
+ tags: ["Workflows", "Legacy"],
1029
+ handler: async ({ mastra, workflowId, runId }) => {
1030
+ try {
1031
+ if (!workflowId) {
1032
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
1033
+ }
1034
+ if (!runId) {
1035
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
1036
+ }
1037
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
1038
+ if (!workflow) {
1039
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
1040
+ }
1041
+ const run = await workflow.getWorkflowRunById(runId);
1042
+ if (!run) {
1043
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
1044
+ }
1045
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
1046
+ const serverCache = mastra.getServerCache();
1047
+ if (!serverCache) {
1048
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Server cache not found" });
1049
+ }
1050
+ const transformStream = new web.TransformStream();
1051
+ const writer = transformStream.writable.getWriter();
1052
+ const cachedRunChunks = await serverCache.listFromTo(runId, 0);
1053
+ for (const chunk of cachedRunChunks) {
1054
+ await writer.write(chunk);
1055
+ }
1056
+ writer.releaseLock();
1057
+ const result = _run.observeStreamLegacy();
1058
+ return result.stream?.pipeThrough(transformStream);
1059
+ } catch (error) {
1060
+ return chunkV5WWQN7P_cjs.handleError(error, "Error observing workflow stream");
1061
+ }
1062
+ }
1063
+ });
1064
+
1065
+ exports.CANCEL_WORKFLOW_RUN_ROUTE = CANCEL_WORKFLOW_RUN_ROUTE;
1066
+ exports.CREATE_WORKFLOW_RUN_ROUTE = CREATE_WORKFLOW_RUN_ROUTE;
1067
+ exports.DELETE_WORKFLOW_RUN_BY_ID_ROUTE = DELETE_WORKFLOW_RUN_BY_ID_ROUTE;
1068
+ exports.GET_WORKFLOW_BY_ID_ROUTE = GET_WORKFLOW_BY_ID_ROUTE;
1069
+ exports.GET_WORKFLOW_RUN_BY_ID_ROUTE = GET_WORKFLOW_RUN_BY_ID_ROUTE;
1070
+ exports.GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE = GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE;
1071
+ exports.LIST_WORKFLOWS_ROUTE = LIST_WORKFLOWS_ROUTE;
1072
+ exports.LIST_WORKFLOW_RUNS_ROUTE = LIST_WORKFLOW_RUNS_ROUTE;
1073
+ exports.OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE;
1074
+ exports.OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE = OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE;
1075
+ exports.OBSERVE_STREAM_WORKFLOW_ROUTE = OBSERVE_STREAM_WORKFLOW_ROUTE;
1076
+ exports.RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE;
1077
+ exports.RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE;
1078
+ exports.RESTART_ASYNC_WORKFLOW_ROUTE = RESTART_ASYNC_WORKFLOW_ROUTE;
1079
+ exports.RESTART_WORKFLOW_ROUTE = RESTART_WORKFLOW_ROUTE;
1080
+ exports.RESUME_ASYNC_WORKFLOW_ROUTE = RESUME_ASYNC_WORKFLOW_ROUTE;
1081
+ exports.RESUME_STREAM_WORKFLOW_ROUTE = RESUME_STREAM_WORKFLOW_ROUTE;
1082
+ exports.RESUME_WORKFLOW_ROUTE = RESUME_WORKFLOW_ROUTE;
1083
+ exports.START_ASYNC_WORKFLOW_ROUTE = START_ASYNC_WORKFLOW_ROUTE;
1084
+ exports.START_WORKFLOW_RUN_ROUTE = START_WORKFLOW_RUN_ROUTE;
1085
+ exports.STREAM_LEGACY_WORKFLOW_ROUTE = STREAM_LEGACY_WORKFLOW_ROUTE;
1086
+ exports.STREAM_VNEXT_WORKFLOW_ROUTE = STREAM_VNEXT_WORKFLOW_ROUTE;
1087
+ exports.STREAM_WORKFLOW_ROUTE = STREAM_WORKFLOW_ROUTE;
1088
+ exports.TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE;
1089
+ exports.TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = TIME_TRAVEL_STREAM_WORKFLOW_ROUTE;
1090
+ exports.TIME_TRAVEL_WORKFLOW_ROUTE = TIME_TRAVEL_WORKFLOW_ROUTE;
1091
+ exports.createWorkflowRunResponseSchema = createWorkflowRunResponseSchema;
1092
+ exports.listWorkflowRunsQuerySchema = listWorkflowRunsQuerySchema;
1093
+ exports.listWorkflowsResponseSchema = listWorkflowsResponseSchema;
1094
+ exports.resumeBodySchema = resumeBodySchema;
1095
+ exports.startAsyncWorkflowBodySchema = startAsyncWorkflowBodySchema;
1096
+ exports.streamLegacyWorkflowBodySchema = streamLegacyWorkflowBodySchema;
1097
+ exports.streamWorkflowBodySchema = streamWorkflowBodySchema;
1098
+ exports.workflowControlResponseSchema = workflowControlResponseSchema;
1099
+ exports.workflowExecutionResultSchema = workflowExecutionResultSchema;
1100
+ exports.workflowInfoSchema = workflowInfoSchema;
1101
+ exports.workflowRunResponseSchema = workflowRunResponseSchema;
1102
+ exports.workflowRunsResponseSchema = workflowRunsResponseSchema;
1103
+ exports.workflows_exports = workflows_exports;
1104
+ //# sourceMappingURL=chunk-WVAQXM6W.cjs.map
1105
+ //# sourceMappingURL=chunk-WVAQXM6W.cjs.map