@mastra/server 0.0.0-cli-debug-2-20250611100354 → 0.0.0-cloud-deployer-for-core-0.19.1-20251001164939

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 (295) hide show
  1. package/CHANGELOG.md +3867 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +0 -5
  4. package/dist/{chunk-H5PTF3Y4.js → chunk-4QCXUEAT.js} +11 -2
  5. package/dist/chunk-4QCXUEAT.js.map +1 -0
  6. package/dist/chunk-4RRMWXQ2.js +3522 -0
  7. package/dist/chunk-4RRMWXQ2.js.map +1 -0
  8. package/dist/chunk-4VJG7FZK.cjs +18023 -0
  9. package/dist/chunk-4VJG7FZK.cjs.map +1 -0
  10. package/dist/chunk-52UP7DFT.cjs +130 -0
  11. package/dist/chunk-52UP7DFT.cjs.map +1 -0
  12. package/dist/chunk-6GMFZ5LK.js +2774 -0
  13. package/dist/chunk-6GMFZ5LK.js.map +1 -0
  14. package/dist/{chunk-GHC4YV6R.js → chunk-6IJWRJZE.js} +109 -136
  15. package/dist/chunk-6IJWRJZE.js.map +1 -0
  16. package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
  17. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  18. package/dist/{chunk-QLG2PFHE.js → chunk-A3AL7EWJ.js} +5 -3
  19. package/dist/chunk-A3AL7EWJ.js.map +1 -0
  20. package/dist/chunk-BKCWZLEL.cjs +197 -0
  21. package/dist/chunk-BKCWZLEL.cjs.map +1 -0
  22. package/dist/chunk-BX5XPVO2.cjs +676 -0
  23. package/dist/chunk-BX5XPVO2.cjs.map +1 -0
  24. package/dist/chunk-CY4TP3FK.js +16 -0
  25. package/dist/chunk-CY4TP3FK.js.map +1 -0
  26. package/dist/chunk-EMMSS5I5.cjs +37 -0
  27. package/dist/chunk-EMMSS5I5.cjs.map +1 -0
  28. package/dist/chunk-FALVL2VV.cjs +3525 -0
  29. package/dist/chunk-FALVL2VV.cjs.map +1 -0
  30. package/dist/chunk-G3PMV62Z.js +33 -0
  31. package/dist/chunk-G3PMV62Z.js.map +1 -0
  32. package/dist/chunk-G4PUALCE.cjs +28 -0
  33. package/dist/chunk-G4PUALCE.cjs.map +1 -0
  34. package/dist/chunk-GU4EWMZB.cjs +769 -0
  35. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  36. package/dist/chunk-HCFCPUTA.cjs +601 -0
  37. package/dist/chunk-HCFCPUTA.cjs.map +1 -0
  38. package/dist/chunk-HFEPCQAR.js +655 -0
  39. package/dist/chunk-HFEPCQAR.js.map +1 -0
  40. package/dist/{chunk-XUGQSVZ4.cjs → chunk-HVBBFCDH.cjs} +1110 -793
  41. package/dist/chunk-HVBBFCDH.cjs.map +1 -0
  42. package/dist/chunk-JLPZWKPR.js +582 -0
  43. package/dist/chunk-JLPZWKPR.js.map +1 -0
  44. package/dist/{chunk-CP55EVBK.js → chunk-JRDEOHAJ.js} +30 -16
  45. package/dist/chunk-JRDEOHAJ.js.map +1 -0
  46. package/dist/{chunk-HYP7B2TL.js → chunk-KM7EJKXV.js} +50 -12
  47. package/dist/chunk-KM7EJKXV.js.map +1 -0
  48. package/dist/{chunk-UZ7FJ66C.cjs → chunk-KNGXRN26.cjs} +48 -45
  49. package/dist/chunk-KNGXRN26.cjs.map +1 -0
  50. package/dist/{chunk-BFOA2QQY.js → chunk-KV6VHX4V.js} +24 -5
  51. package/dist/chunk-KV6VHX4V.js.map +1 -0
  52. package/dist/chunk-LF2ZLOFP.js +767 -0
  53. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  54. package/dist/chunk-LJFAAEU7.cjs +167 -0
  55. package/dist/chunk-LJFAAEU7.cjs.map +1 -0
  56. package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
  57. package/dist/chunk-MMROOK5J.js.map +1 -0
  58. package/dist/{chunk-WKWHYFX4.js → chunk-N7F33WAD.js} +1083 -794
  59. package/dist/chunk-N7F33WAD.js.map +1 -0
  60. package/dist/chunk-NG5IVLEZ.js +1012 -0
  61. package/dist/chunk-NG5IVLEZ.js.map +1 -0
  62. package/dist/chunk-NLWACBE7.cjs +128 -0
  63. package/dist/chunk-NLWACBE7.cjs.map +1 -0
  64. package/dist/{chunk-SDPGVWQJ.cjs → chunk-OPI3FZYH.cjs} +110 -137
  65. package/dist/chunk-OPI3FZYH.cjs.map +1 -0
  66. package/dist/chunk-OZLRIVC4.cjs +588 -0
  67. package/dist/chunk-OZLRIVC4.cjs.map +1 -0
  68. package/dist/chunk-PPYGWINI.cjs +2777 -0
  69. package/dist/chunk-PPYGWINI.cjs.map +1 -0
  70. package/dist/{chunk-B4MQFJ7G.cjs → chunk-PWTXZZTR.cjs} +28 -8
  71. package/dist/chunk-PWTXZZTR.cjs.map +1 -0
  72. package/dist/chunk-RE4RPXT2.cjs +18 -0
  73. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  74. package/dist/chunk-SIGXR3JT.cjs +1043 -0
  75. package/dist/chunk-SIGXR3JT.cjs.map +1 -0
  76. package/dist/{chunk-IMBY5XUG.cjs → chunk-SPLSYTYW.cjs} +11 -9
  77. package/dist/chunk-SPLSYTYW.cjs.map +1 -0
  78. package/dist/chunk-SQY4T6EJ.js +571 -0
  79. package/dist/chunk-SQY4T6EJ.js.map +1 -0
  80. package/dist/{chunk-BNEY4P4P.cjs → chunk-T3TIA3O6.cjs} +20 -18
  81. package/dist/chunk-T3TIA3O6.cjs.map +1 -0
  82. package/dist/{chunk-TEZOEGR4.js → chunk-TTHEEIZ3.js} +18 -15
  83. package/dist/chunk-TTHEEIZ3.js.map +1 -0
  84. package/dist/chunk-VY4ENABS.cjs +135 -0
  85. package/dist/chunk-VY4ENABS.cjs.map +1 -0
  86. package/dist/{chunk-55DOQLP6.js → chunk-WHN4VX55.js} +5 -3
  87. package/dist/chunk-WHN4VX55.js.map +1 -0
  88. package/dist/chunk-WUJLVNLU.js +124 -0
  89. package/dist/chunk-WUJLVNLU.js.map +1 -0
  90. package/dist/chunk-XJOYGRTN.js +189 -0
  91. package/dist/chunk-XJOYGRTN.js.map +1 -0
  92. package/dist/chunk-YGQ5F6E6.js +17987 -0
  93. package/dist/chunk-YGQ5F6E6.js.map +1 -0
  94. package/dist/chunk-YWOK4F5A.js +131 -0
  95. package/dist/chunk-YWOK4F5A.js.map +1 -0
  96. package/dist/dist-26HWEQY6.js +3 -0
  97. package/dist/dist-26HWEQY6.js.map +1 -0
  98. package/dist/dist-3DRD6USP.cjs +1411 -0
  99. package/dist/dist-3DRD6USP.cjs.map +1 -0
  100. package/dist/dist-7GVM5ZCS.js +845 -0
  101. package/dist/dist-7GVM5ZCS.js.map +1 -0
  102. package/dist/dist-CCDXEZDR.js +1408 -0
  103. package/dist/dist-CCDXEZDR.js.map +1 -0
  104. package/dist/dist-COC6WFAX.js +761 -0
  105. package/dist/dist-COC6WFAX.js.map +1 -0
  106. package/dist/dist-EZZMMMNT.cjs +16 -0
  107. package/dist/dist-EZZMMMNT.cjs.map +1 -0
  108. package/dist/dist-H64VX6DE.js +3 -0
  109. package/dist/dist-H64VX6DE.js.map +1 -0
  110. package/dist/dist-H7RR3EXL.js +2006 -0
  111. package/dist/dist-H7RR3EXL.js.map +1 -0
  112. package/dist/dist-JNIWWFE5.js +1147 -0
  113. package/dist/dist-JNIWWFE5.js.map +1 -0
  114. package/dist/dist-L76NFIWM.cjs +934 -0
  115. package/dist/dist-L76NFIWM.cjs.map +1 -0
  116. package/dist/dist-LKU3RRT2.js +937 -0
  117. package/dist/dist-LKU3RRT2.js.map +1 -0
  118. package/dist/dist-MQUZENT7.js +931 -0
  119. package/dist/dist-MQUZENT7.js.map +1 -0
  120. package/dist/dist-N6P7NYGX.cjs +928 -0
  121. package/dist/dist-N6P7NYGX.cjs.map +1 -0
  122. package/dist/dist-OC4J73ML.cjs +940 -0
  123. package/dist/dist-OC4J73ML.cjs.map +1 -0
  124. package/dist/dist-QI7RYOYQ.cjs +764 -0
  125. package/dist/dist-QI7RYOYQ.cjs.map +1 -0
  126. package/dist/dist-R3L5J3LL.cjs +1150 -0
  127. package/dist/dist-R3L5J3LL.cjs.map +1 -0
  128. package/dist/dist-S3ILRJUH.cjs +2013 -0
  129. package/dist/dist-S3ILRJUH.cjs.map +1 -0
  130. package/dist/dist-WKYB3LTJ.cjs +16 -0
  131. package/dist/dist-WKYB3LTJ.cjs.map +1 -0
  132. package/dist/dist-WY4WSW7C.cjs +849 -0
  133. package/dist/dist-WY4WSW7C.cjs.map +1 -0
  134. package/dist/dist-ZHCN47XA.js +925 -0
  135. package/dist/dist-ZHCN47XA.js.map +1 -0
  136. package/dist/index.cjs +6 -0
  137. package/dist/index.cjs.map +1 -0
  138. package/dist/index.d.ts +1 -0
  139. package/dist/index.d.ts.map +1 -0
  140. package/dist/index.js +5 -0
  141. package/dist/index.js.map +1 -0
  142. package/dist/server/a2a/protocol.d.ts +8 -0
  143. package/dist/server/a2a/protocol.d.ts.map +1 -0
  144. package/dist/server/a2a/store.cjs +25 -0
  145. package/dist/server/a2a/store.cjs.map +1 -0
  146. package/dist/server/a2a/store.d.ts +14 -0
  147. package/dist/server/a2a/store.d.ts.map +1 -0
  148. package/dist/server/a2a/store.js +23 -0
  149. package/dist/server/a2a/store.js.map +1 -0
  150. package/dist/server/a2a/tasks.d.ts +20 -0
  151. package/dist/server/a2a/tasks.d.ts.map +1 -0
  152. package/dist/server/handlers/a2a.cjs +13 -11
  153. package/dist/server/handlers/a2a.cjs.map +1 -0
  154. package/dist/server/handlers/a2a.d.ts +68 -6
  155. package/dist/server/handlers/a2a.d.ts.map +1 -0
  156. package/dist/server/handlers/a2a.js +3 -1
  157. package/dist/server/handlers/a2a.js.map +1 -0
  158. package/dist/server/handlers/agent-builder.cjs +68 -0
  159. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  160. package/dist/server/handlers/agent-builder.d.ts +94 -0
  161. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  162. package/dist/server/handlers/agent-builder.js +3 -0
  163. package/dist/server/handlers/agent-builder.js.map +1 -0
  164. package/dist/server/handlers/agents.cjs +61 -7
  165. package/dist/server/handlers/agents.cjs.map +1 -0
  166. package/dist/server/handlers/agents.d.ts +216 -6
  167. package/dist/server/handlers/agents.d.ts.map +1 -0
  168. package/dist/server/handlers/agents.js +3 -1
  169. package/dist/server/handlers/agents.js.map +1 -0
  170. package/dist/server/handlers/error.cjs +4 -2
  171. package/dist/server/handlers/error.cjs.map +1 -0
  172. package/dist/server/handlers/error.d.ts +2 -1
  173. package/dist/server/handlers/error.d.ts.map +1 -0
  174. package/dist/server/handlers/error.js +3 -1
  175. package/dist/server/handlers/error.js.map +1 -0
  176. package/dist/server/handlers/legacyWorkflows.cjs +13 -11
  177. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  178. package/dist/server/handlers/legacyWorkflows.d.ts +59 -10
  179. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  180. package/dist/server/handlers/legacyWorkflows.js +3 -1
  181. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  182. package/dist/server/handlers/logs.cjs +6 -4
  183. package/dist/server/handlers/logs.cjs.map +1 -0
  184. package/dist/server/handlers/logs.d.ts +34 -3
  185. package/dist/server/handlers/logs.d.ts.map +1 -0
  186. package/dist/server/handlers/logs.js +3 -1
  187. package/dist/server/handlers/logs.js.map +1 -0
  188. package/dist/server/handlers/memory.cjs +39 -9
  189. package/dist/server/handlers/memory.cjs.map +1 -0
  190. package/dist/server/handlers/memory.d.ts +118 -8
  191. package/dist/server/handlers/memory.d.ts.map +1 -0
  192. package/dist/server/handlers/memory.js +3 -1
  193. package/dist/server/handlers/memory.js.map +1 -0
  194. package/dist/server/handlers/observability.cjs +24 -0
  195. package/dist/server/handlers/observability.cjs.map +1 -0
  196. package/dist/server/handlers/observability.d.ts +49 -0
  197. package/dist/server/handlers/observability.d.ts.map +1 -0
  198. package/dist/server/handlers/observability.js +3 -0
  199. package/dist/server/handlers/observability.js.map +1 -0
  200. package/dist/server/handlers/scores.cjs +32 -0
  201. package/dist/server/handlers/scores.cjs.map +1 -0
  202. package/dist/server/handlers/scores.d.ts +251 -0
  203. package/dist/server/handlers/scores.d.ts.map +1 -0
  204. package/dist/server/handlers/scores.js +3 -0
  205. package/dist/server/handlers/scores.js.map +1 -0
  206. package/dist/server/handlers/telemetry.cjs +9 -3
  207. package/dist/server/handlers/telemetry.cjs.map +1 -0
  208. package/dist/server/handlers/telemetry.d.ts +33 -2
  209. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  210. package/dist/server/handlers/telemetry.js +3 -1
  211. package/dist/server/handlers/telemetry.js.map +1 -0
  212. package/dist/server/handlers/tools.cjs +11 -5
  213. package/dist/server/handlers/tools.cjs.map +1 -0
  214. package/dist/server/handlers/tools.d.ts +25 -4
  215. package/dist/server/handlers/tools.d.ts.map +1 -0
  216. package/dist/server/handlers/tools.js +3 -1
  217. package/dist/server/handlers/tools.js.map +1 -0
  218. package/dist/server/handlers/utils.cjs +8 -2
  219. package/dist/server/handlers/utils.cjs.map +1 -0
  220. package/dist/server/handlers/utils.d.ts +8 -1
  221. package/dist/server/handlers/utils.d.ts.map +1 -0
  222. package/dist/server/handlers/utils.js +3 -1
  223. package/dist/server/handlers/utils.js.map +1 -0
  224. package/dist/server/handlers/vNextNetwork.cjs +220 -0
  225. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  226. package/dist/server/handlers/vNextNetwork.d.ts +246 -0
  227. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  228. package/dist/server/handlers/vNextNetwork.js +213 -0
  229. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  230. package/dist/server/handlers/vector.cjs +9 -7
  231. package/dist/server/handlers/vector.cjs.map +1 -0
  232. package/dist/server/handlers/vector.d.ts +51 -6
  233. package/dist/server/handlers/vector.d.ts.map +1 -0
  234. package/dist/server/handlers/vector.js +3 -1
  235. package/dist/server/handlers/vector.js.map +1 -0
  236. package/dist/server/handlers/voice.cjs +7 -5
  237. package/dist/server/handlers/voice.cjs.map +1 -0
  238. package/dist/server/handlers/voice.d.ts +41 -4
  239. package/dist/server/handlers/voice.d.ts.map +1 -0
  240. package/dist/server/handlers/voice.js +3 -1
  241. package/dist/server/handlers/voice.js.map +1 -0
  242. package/dist/server/handlers/workflows.cjs +38 -12
  243. package/dist/server/handlers/workflows.cjs.map +1 -0
  244. package/dist/server/handlers/workflows.d.ts +90 -11
  245. package/dist/server/handlers/workflows.d.ts.map +1 -0
  246. package/dist/server/handlers/workflows.js +3 -1
  247. package/dist/server/handlers/workflows.js.map +1 -0
  248. package/dist/server/handlers.cjs +44 -32
  249. package/dist/server/handlers.cjs.map +1 -0
  250. package/dist/server/handlers.d.ts +14 -11
  251. package/dist/server/handlers.d.ts.map +1 -0
  252. package/dist/server/handlers.js +15 -11
  253. package/dist/server/handlers.js.map +1 -0
  254. package/dist/server/http-exception.d.ts +87 -0
  255. package/dist/server/http-exception.d.ts.map +1 -0
  256. package/dist/server/types.d.ts +10 -0
  257. package/dist/server/types.d.ts.map +1 -0
  258. package/dist/server/utils.d.ts +44 -0
  259. package/dist/server/utils.d.ts.map +1 -0
  260. package/package.json +41 -19
  261. package/dist/_tsup-dts-rollup.d.cts +0 -860
  262. package/dist/_tsup-dts-rollup.d.ts +0 -860
  263. package/dist/chunk-57CJTIPW.cjs +0 -18
  264. package/dist/chunk-64U3UDTH.cjs +0 -13
  265. package/dist/chunk-6F2H7Y45.js +0 -255
  266. package/dist/chunk-6TJSHFCJ.cjs +0 -221
  267. package/dist/chunk-75ZPJI57.cjs +0 -9
  268. package/dist/chunk-7IBZ4L35.js +0 -344
  269. package/dist/chunk-C7564HUT.js +0 -142
  270. package/dist/chunk-CMMOIUFC.cjs +0 -114
  271. package/dist/chunk-I7KJZNX5.js +0 -211
  272. package/dist/chunk-JEWNMAYQ.cjs +0 -263
  273. package/dist/chunk-JKF6PRPU.cjs +0 -357
  274. package/dist/chunk-M5ABIP7D.js +0 -11
  275. package/dist/chunk-MLKGABMK.js +0 -7
  276. package/dist/chunk-TJO277H7.cjs +0 -128
  277. package/dist/chunk-VPNDC2DI.cjs +0 -148
  278. package/dist/index.d.cts +0 -1
  279. package/dist/server/handlers/a2a.d.cts +0 -6
  280. package/dist/server/handlers/agents.d.cts +0 -6
  281. package/dist/server/handlers/error.d.cts +0 -1
  282. package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
  283. package/dist/server/handlers/logs.d.cts +0 -3
  284. package/dist/server/handlers/memory.d.cts +0 -8
  285. package/dist/server/handlers/network.cjs +0 -22
  286. package/dist/server/handlers/network.d.cts +0 -4
  287. package/dist/server/handlers/network.d.ts +0 -4
  288. package/dist/server/handlers/network.js +0 -1
  289. package/dist/server/handlers/telemetry.d.cts +0 -2
  290. package/dist/server/handlers/tools.d.cts +0 -4
  291. package/dist/server/handlers/utils.d.cts +0 -1
  292. package/dist/server/handlers/vector.d.cts +0 -6
  293. package/dist/server/handlers/voice.d.cts +0 -4
  294. package/dist/server/handlers/workflows.d.cts +0 -11
  295. package/dist/server/handlers.d.cts +0 -11
@@ -1,8 +1,9 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
4
- import { __export } from './chunk-MLKGABMK.js';
1
+ import { validateBody } from './chunk-4QCXUEAT.js';
2
+ import { handleError } from './chunk-CY4TP3FK.js';
3
+ import { HTTPException } from './chunk-MMROOK5J.js';
4
+ import { __export } from './chunk-G3PMV62Z.js';
5
5
  import { Readable } from 'stream';
6
+ import { MastraError } from '@mastra/core/error';
6
7
 
7
8
  // src/server/handlers/voice.ts
8
9
  var voice_exports = {};
@@ -12,7 +13,7 @@ __export(voice_exports, {
12
13
  getSpeakersHandler: () => getSpeakersHandler,
13
14
  transcribeSpeechHandler: () => transcribeSpeechHandler
14
15
  });
15
- async function getSpeakersHandler({ mastra, agentId }) {
16
+ async function getSpeakersHandler({ mastra, agentId, runtimeContext }) {
16
17
  try {
17
18
  if (!agentId) {
18
19
  throw new HTTPException(400, { message: "Agent ID is required" });
@@ -21,10 +22,11 @@ async function getSpeakersHandler({ mastra, agentId }) {
21
22
  if (!agent) {
22
23
  throw new HTTPException(404, { message: "Agent not found" });
23
24
  }
24
- if (!agent.voice) {
25
+ const voice = await agent.getVoice({ runtimeContext });
26
+ if (!voice) {
25
27
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
26
28
  }
27
- const speakers = await agent.voice.getSpeakers();
29
+ const speakers = await voice.getSpeakers();
28
30
  return speakers;
29
31
  } catch (error) {
30
32
  return handleError(error, "Error getting speakers");
@@ -33,7 +35,8 @@ async function getSpeakersHandler({ mastra, agentId }) {
33
35
  async function generateSpeechHandler({
34
36
  mastra,
35
37
  agentId,
36
- body
38
+ body,
39
+ runtimeContext
37
40
  }) {
38
41
  try {
39
42
  if (!agentId) {
@@ -46,10 +49,16 @@ async function generateSpeechHandler({
46
49
  if (!agent) {
47
50
  throw new HTTPException(404, { message: "Agent not found" });
48
51
  }
49
- if (!agent.voice) {
52
+ const voice = await agent.getVoice({ runtimeContext });
53
+ if (!voice) {
50
54
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
51
55
  }
52
- const audioStream = await agent.voice.speak(body.text, { speaker: body.speakerId });
56
+ const audioStream = await Promise.resolve().then(() => voice.speak(body.text, { speaker: body.speakerId })).catch((err) => {
57
+ if (err instanceof MastraError) {
58
+ throw new HTTPException(400, { message: err.message });
59
+ }
60
+ throw err;
61
+ });
53
62
  if (!audioStream) {
54
63
  throw new HTTPException(500, { message: "Failed to generate speech" });
55
64
  }
@@ -61,7 +70,8 @@ async function generateSpeechHandler({
61
70
  async function transcribeSpeechHandler({
62
71
  mastra,
63
72
  agentId,
64
- body
73
+ body,
74
+ runtimeContext
65
75
  }) {
66
76
  try {
67
77
  if (!agentId) {
@@ -74,19 +84,20 @@ async function transcribeSpeechHandler({
74
84
  if (!agent) {
75
85
  throw new HTTPException(404, { message: "Agent not found" });
76
86
  }
77
- if (!agent.voice) {
87
+ const voice = await agent.getVoice({ runtimeContext });
88
+ if (!voice) {
78
89
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
79
90
  }
80
91
  const audioStream = new Readable();
81
92
  audioStream.push(body.audioData);
82
93
  audioStream.push(null);
83
- const text = await agent.voice.listen(audioStream, body.options);
94
+ const text = await voice.listen(audioStream, body.options);
84
95
  return { text };
85
96
  } catch (error) {
86
97
  return handleError(error, "Error transcribing speech");
87
98
  }
88
99
  }
89
- async function getListenerHandler({ mastra, agentId }) {
100
+ async function getListenerHandler({ mastra, agentId, runtimeContext }) {
90
101
  try {
91
102
  if (!agentId) {
92
103
  throw new HTTPException(400, { message: "Agent ID is required" });
@@ -95,10 +106,11 @@ async function getListenerHandler({ mastra, agentId }) {
95
106
  if (!agent) {
96
107
  throw new HTTPException(404, { message: "Agent not found" });
97
108
  }
98
- if (!agent.voice) {
109
+ const voice = await agent.getVoice({ runtimeContext });
110
+ if (!voice) {
99
111
  throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
100
112
  }
101
- const listeners = await agent.voice.getListener();
113
+ const listeners = await voice.getListener();
102
114
  return listeners;
103
115
  } catch (error) {
104
116
  return handleError(error, "Error getting listeners");
@@ -106,3 +118,5 @@ async function getListenerHandler({ mastra, agentId }) {
106
118
  }
107
119
 
108
120
  export { generateSpeechHandler, getListenerHandler, getSpeakersHandler, transcribeSpeechHandler, voice_exports };
121
+ //# sourceMappingURL=chunk-JRDEOHAJ.js.map
122
+ //# sourceMappingURL=chunk-JRDEOHAJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/voice.ts"],"names":[],"mappings":";;;;;;;;AAAA,IAAA,aAAA,GAAA;AAAA,QAAA,CAAA,aAAA,EAAA;AAAA,EAAA,qBAAA,EAAA,MAAA,qBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EA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c,GAAA,EAAK,EAAE,OAAA,EAAS,mBAAmB,CAAA;AAAA,IAC7D;AAEA,IAAA,MAAM,QAAQ,MAAM,KAAA,CAAM,QAAA,CAAS,EAAE,gBAAgB,CAAA;AAErD,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0CAA0C,CAAA;AAAA,IACpF;AAEA,IAAA,MAAM,SAAA,GAAY,MAAM,KAAA,CAAM,WAAA,EAAY;AAC1C,IAAA,OAAO,SAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,yBAAyB,CAAA;AAAA,EACrD;AACF","file":"chunk-JRDEOHAJ.js","sourcesContent":["import { Readable } from 'stream';\nimport type { Agent } from '@mastra/core/agent';\nimport { MastraError } from '@mastra/core/error';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface VoiceContext extends Context {\n agentId?: string;\n runtimeContext?: RuntimeContext;\n}\n\n/**\n * Get available speakers for an agent\n */\nexport async function getSpeakersHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const speakers = await voice.getSpeakers();\n return speakers;\n } catch (error) {\n return handleError(error, 'Error getting speakers');\n }\n}\n\n/**\n * Generate speech from text\n */\nexport async function generateSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n text?: string;\n speakerId?: string;\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n validateBody({\n text: body?.text,\n });\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = await Promise.resolve()\n .then(() => voice.speak(body!.text!, { speaker: body!.speakerId! }))\n .catch(err => {\n if (err instanceof MastraError) {\n throw new HTTPException(400, { message: err.message });\n }\n\n throw err;\n });\n\n if (!audioStream) {\n throw new HTTPException(500, { message: 'Failed to generate speech' });\n }\n\n return audioStream;\n } catch (error) {\n return handleError(error, 'Error generating speech');\n }\n}\n\n/**\n * Transcribe speech to text\n */\nexport async function transcribeSpeechHandler({\n mastra,\n agentId,\n body,\n runtimeContext,\n}: VoiceContext & {\n body?: {\n audioData?: Buffer;\n options?: Parameters<NonNullable<Agent['voice']>['listen']>[1];\n };\n}) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n if (!body?.audioData) {\n throw new HTTPException(400, { message: 'Audio data is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const audioStream = new Readable();\n audioStream.push(body.audioData);\n audioStream.push(null);\n\n const text = await voice.listen(audioStream, body.options);\n return { text };\n } catch (error) {\n return handleError(error, 'Error transcribing speech');\n }\n}\n\n/**\n * Get available listeners for an agent\n */\nexport async function getListenerHandler({ mastra, agentId, runtimeContext }: VoiceContext) {\n try {\n if (!agentId) {\n throw new HTTPException(400, { message: 'Agent ID is required' });\n }\n\n const agent = mastra.getAgent(agentId);\n\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const voice = await agent.getVoice({ runtimeContext });\n\n if (!voice) {\n throw new HTTPException(400, { message: 'Agent does not have voice capabilities' });\n }\n\n const listeners = await voice.getListener();\n return listeners;\n } catch (error) {\n return handleError(error, 'Error getting listeners');\n }\n}\n"]}
@@ -1,15 +1,17 @@
1
- import { stringify, esm_default } from './chunk-WKWHYFX4.js';
2
- import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-M5ABIP7D.js';
4
- import { HTTPException } from './chunk-NYN7KFXL.js';
5
- import { __export } from './chunk-MLKGABMK.js';
1
+ import { validateBody } from './chunk-4QCXUEAT.js';
2
+ import { stringify } from './chunk-LF2ZLOFP.js';
3
+ import { handleError } from './chunk-CY4TP3FK.js';
4
+ import { HTTPException } from './chunk-MMROOK5J.js';
5
+ import { __export } from './chunk-G3PMV62Z.js';
6
6
  import { isVercelTool } from '@mastra/core/tools';
7
+ import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';
7
8
 
8
9
  // src/server/handlers/tools.ts
9
10
  var tools_exports = {};
10
11
  __export(tools_exports, {
11
12
  executeAgentToolHandler: () => executeAgentToolHandler,
12
13
  executeToolHandler: () => executeToolHandler,
14
+ getAgentToolHandler: () => getAgentToolHandler,
13
15
  getToolByIdHandler: () => getToolByIdHandler,
14
16
  getToolsHandler: () => getToolsHandler
15
17
  });
@@ -23,8 +25,8 @@ async function getToolsHandler({ tools }) {
23
25
  const tool = _tool;
24
26
  acc[id] = {
25
27
  ...tool,
26
- inputSchema: tool.inputSchema ? stringify(esm_default(tool.inputSchema)) : void 0,
27
- outputSchema: tool.outputSchema ? stringify(esm_default(tool.outputSchema)) : void 0
28
+ inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : void 0,
29
+ outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : void 0
28
30
  };
29
31
  return acc;
30
32
  },
@@ -43,8 +45,8 @@ async function getToolByIdHandler({ tools, toolId }) {
43
45
  }
44
46
  const serializedTool = {
45
47
  ...tool,
46
- inputSchema: tool.inputSchema ? stringify(esm_default(tool.inputSchema)) : void 0,
47
- outputSchema: tool.outputSchema ? stringify(esm_default(tool.outputSchema)) : void 0
48
+ inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : void 0,
49
+ outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : void 0
48
50
  };
49
51
  return serializedTool;
50
52
  } catch (error) {
@@ -79,7 +81,11 @@ function executeToolHandler(tools) {
79
81
  context: data,
80
82
  mastra,
81
83
  runId,
82
- runtimeContext
84
+ runtimeContext,
85
+ // TODO: Pass proper tracing context when server API supports tracing
86
+ tracingContext: { currentSpan: void 0 },
87
+ suspend: async () => {
88
+ }
83
89
  });
84
90
  return result;
85
91
  } catch (error) {
@@ -87,6 +93,32 @@ function executeToolHandler(tools) {
87
93
  }
88
94
  };
89
95
  }
96
+ async function getAgentToolHandler({
97
+ mastra,
98
+ agentId,
99
+ toolId,
100
+ runtimeContext
101
+ }) {
102
+ try {
103
+ const agent = agentId ? mastra.getAgent(agentId) : null;
104
+ if (!agent) {
105
+ throw new HTTPException(404, { message: "Agent not found" });
106
+ }
107
+ const agentTools = await agent.getTools({ runtimeContext });
108
+ const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
109
+ if (!tool) {
110
+ throw new HTTPException(404, { message: "Tool not found" });
111
+ }
112
+ const serializedTool = {
113
+ ...tool,
114
+ inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : void 0,
115
+ outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : void 0
116
+ };
117
+ return serializedTool;
118
+ } catch (error) {
119
+ return handleError(error, "Error getting agent tool");
120
+ }
121
+ }
90
122
  async function executeAgentToolHandler({
91
123
  mastra,
92
124
  agentId,
@@ -111,7 +143,11 @@ async function executeAgentToolHandler({
111
143
  context: data,
112
144
  runtimeContext,
113
145
  mastra,
114
- runId: agentId
146
+ runId: agentId,
147
+ // TODO: Pass proper tracing context when server API supports tracing
148
+ tracingContext: { currentSpan: void 0 },
149
+ suspend: async () => {
150
+ }
115
151
  });
116
152
  return result;
117
153
  } catch (error) {
@@ -119,4 +155,6 @@ async function executeAgentToolHandler({
119
155
  }
120
156
  }
121
157
 
122
- export { executeAgentToolHandler, executeToolHandler, getToolByIdHandler, getToolsHandler, tools_exports };
158
+ export { executeAgentToolHandler, executeToolHandler, getAgentToolHandler, getToolByIdHandler, getToolsHandler, tools_exports };
159
+ //# sourceMappingURL=chunk-KM7EJKXV.js.map
160
+ //# sourceMappingURL=chunk-KM7EJKXV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/tools.ts"],"names":["tool","result"],"mappings":";;;;;;;;;AAAA,IAAA,aAAA,GAAA;AAAA,QAAA,CAAA,aAAA,EAAA;AAAA,EAAA,uBAAA,EAAA,MAAA,uBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,mBAAA,EAAA,MAAA,mBAAA;AAAA,EAAA,kBAAA,EAAA,MAAA,kBAAA;AAAA,EAAA,eAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAkBA,eAAsB,eAAA,CAAgB,EAAE,KAAA,EAAM,EAAgC;AAC5E,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,KAAA,EAAO;AACV,MAAA,OAAO,EAAC;AAAA,IACV;AAEA,IAAA,MAAM,eAAA,GAAkB,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,CAAE,MAAA;AAAA,MAC5C,CAAC,GAAA,EAAK,CAAC,EAAA,EAAI,KAAK,CAAA,KAAM;AACpB,QAAA,MAAM,IAAA,GAAO,KAAA;AACb,QAAA,GAAA,CAAI,EAAE,CAAA,GAAI;AAAA,UACR,GAAG,IAAA;AAAA,UACH,WAAA,EAAa,KAAK,WAAA,GAAc,SAAA,CAAU,gBAAgB,IAAA,CAAK,WAAW,CAAC,CAAA,GAAI,MAAA;AAAA,UAC/E,YAAA,EAAc,KAAK,YAAA,GAAe,S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,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,kBAAkB,CAAA;AAAA,IAC5D;AAEA,IAAA,MAAM,aAAa,MAAM,KAAA,CAAM,QAAA,CAAS,EAAE,gBAAgB,CAAA;AAE1D,IAAA,MAAM,IAAA,GAAO,MAAA,CAAO,MAAA,CAAO,UAAA,IAAc,EAAE,CAAA,CAAE,IAAA,CAAK,CAACA,KAAAA,KAAcA,KAAAA,CAAK,EAAA,KAAO,MAAM,CAAA;AAEnF,IAAA,IAAI,CAAC,IAAA,EAAM;AACT,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,kBAAkB,CAAA;AAAA,IAC5D;AAEA,IAAA,IAAI,CAAC,MAAM,OAAA,EAAS;AAClB,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,IACpE;AAOA,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,OAAA,CAAQ;AAAA,MAChC,OAAA,EAAS,IAAA;AAAA,MACT,cAAA;AAAA,MACA,MAAA;AAAA,MACA,KAAA,EAAO,OAAA;AAAA;AAAA,MAEP,cAAA,EAAgB,EAAE,WAAA,EAAa,MAAA,EAAU;AAAA,MACzC,SAAS,YAAY;AAAA,MAAC;AAAA,KACvB,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,sBAAsB,CAAA;AAAA,EAClD;AACF","file":"chunk-KM7EJKXV.js","sourcesContent":["import type { RuntimeContext } from '@mastra/core/di';\nimport type { ToolAction, VercelTool } from '@mastra/core/tools';\nimport { isVercelTool } from '@mastra/core/tools';\nimport { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\nimport { stringify } from 'superjson';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\nimport { validateBody } from './utils';\n\ninterface ToolsContext extends Context {\n tools?: Record<string, ToolAction | VercelTool>;\n toolId?: string;\n runId?: string;\n}\n\n// Tool handlers\nexport async function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>) {\n try {\n if (!tools) {\n return {};\n }\n\n const serializedTools = Object.entries(tools).reduce(\n (acc, [id, _tool]) => {\n const tool = _tool as any;\n acc[id] = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n return acc;\n },\n {} as Record<string, any>,\n );\n\n return serializedTools;\n } catch (error) {\n return handleError(error, 'Error getting tools');\n }\n}\n\nexport async function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>) {\n try {\n const tool = Object.values(tools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const serializedTool = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n\n return serializedTool;\n } catch (error) {\n return handleError(error, 'Error getting tool');\n }\n}\n\nexport function executeToolHandler(tools: ToolsContext['tools']) {\n return async ({\n mastra,\n runId,\n toolId,\n data,\n runtimeContext,\n }: Pick<ToolsContext, 'mastra' | 'toolId' | 'runId'> & {\n data?: unknown;\n runtimeContext: RuntimeContext;\n }) => {\n try {\n if (!toolId) {\n throw new HTTPException(400, { message: 'Tool ID is required' });\n }\n\n const tool = Object.values(tools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n if (!tool?.execute) {\n throw new HTTPException(400, { message: 'Tool is not executable' });\n }\n\n validateBody({ data });\n\n if (isVercelTool(tool)) {\n const result = await (tool as any).execute(data);\n return result;\n }\n\n const result = await tool.execute({\n context: data!,\n mastra,\n runId,\n runtimeContext,\n // TODO: Pass proper tracing context when server API supports tracing\n tracingContext: { currentSpan: undefined },\n suspend: async () => {},\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error executing tool');\n }\n };\n}\n\nexport async function getAgentToolHandler({\n mastra,\n agentId,\n toolId,\n runtimeContext,\n}: Pick<ToolsContext, 'mastra' | 'toolId'> & {\n agentId?: string;\n runtimeContext: RuntimeContext;\n}) {\n try {\n const agent = agentId ? mastra.getAgent(agentId) : null;\n if (!agent) {\n throw new HTTPException(404, { message: 'Agent not found' });\n }\n\n const agentTools = await agent.getTools({ runtimeContext });\n\n const tool = Object.values(agentTools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const serializedTool = {\n ...tool,\n inputSchema: tool.inputSchema ? stringify(zodToJsonSchema(tool.inputSchema)) : undefined,\n outputSchema: tool.outputSchema ? stringify(zodToJsonSchema(tool.outputSchema)) : undefined,\n };\n\n return serializedTool;\n } catch (error) {\n return handleError(error, 'Error getting agent tool');\n }\n}\n\nexport async function executeAgentToolHandler({\n mastra,\n agentId,\n toolId,\n data,\n runtimeContext,\n}: Pick<ToolsContext, 'mastra' | 'toolId'> & {\n agentId?: string;\n data: any;\n runtimeContext: RuntimeContext;\n}) {\n try {\n const agent = agentId ? mastra.getAgent(agentId) : null;\n if (!agent) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n const agentTools = await agent.getTools({ runtimeContext });\n\n const tool = Object.values(agentTools || {}).find((tool: any) => tool.id === toolId) as any;\n\n if (!tool) {\n throw new HTTPException(404, { message: 'Tool not found' });\n }\n\n if (!tool?.execute) {\n throw new HTTPException(400, { message: 'Tool is not executable' });\n }\n\n // if (isVercelTool(tool)) {\n // const result = await (tool as any).execute(data);\n // return result;\n // }\n\n const result = await tool.execute({\n context: data,\n runtimeContext,\n mastra,\n runId: agentId,\n // TODO: Pass proper tracing context when server API supports tracing\n tracingContext: { currentSpan: undefined },\n suspend: async () => {},\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing tool');\n }\n}\n"]}
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunkXUGQSVZ4_cjs = require('./chunk-XUGQSVZ4.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
3
+ var chunkGU4EWMZB_cjs = require('./chunk-GU4EWMZB.cjs');
4
+ var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
5
+ var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
6
+ var chunkEMMSS5I5_cjs = require('./chunk-EMMSS5I5.cjs');
7
7
  var web = require('stream/web');
8
+ var zodToJson = require('@mastra/core/utils/zod-to-json');
8
9
 
9
10
  // src/server/handlers/legacyWorkflows.ts
10
11
  var legacyWorkflows_exports = {};
11
- chunk75ZPJI57_cjs.__export(legacyWorkflows_exports, {
12
+ chunkEMMSS5I5_cjs.__export(legacyWorkflows_exports, {
12
13
  createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
13
14
  getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
14
15
  getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
@@ -31,15 +32,15 @@ async function getLegacyWorkflowsHandler({ mastra }) {
31
32
  serializedStepGraph: workflow.serializedStepGraph,
32
33
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
33
34
  name: workflow.name,
34
- triggerSchema: workflow.triggerSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(workflow.triggerSchema)) : void 0,
35
+ triggerSchema: workflow.triggerSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.triggerSchema)) : void 0,
35
36
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
36
37
  const _step = step;
37
38
  acc2[key2] = {
38
39
  id: _step.id,
39
40
  description: _step.description,
40
41
  workflowId: _step.workflowId,
41
- inputSchema: _step.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_step.inputSchema)) : void 0,
42
- outputSchema: _step.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_step.outputSchema)) : void 0
42
+ inputSchema: _step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(_step.inputSchema)) : void 0,
43
+ outputSchema: _step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(_step.outputSchema)) : void 0
43
44
  };
44
45
  return acc2;
45
46
  }, {})
@@ -48,17 +49,17 @@ async function getLegacyWorkflowsHandler({ mastra }) {
48
49
  }, {});
49
50
  return _workflows;
50
51
  } catch (error) {
51
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
52
+ return chunkRE4RPXT2_cjs.handleError(error, "error getting workflows");
52
53
  }
53
54
  }
54
55
  async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
55
56
  try {
56
57
  if (!workflowId) {
57
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
58
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
58
59
  }
59
60
  const workflow = mastra.legacy_getWorkflow(workflowId);
60
61
  if (!workflow) {
61
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
62
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
62
63
  }
63
64
  return {
64
65
  stepGraph: workflow.stepGraph,
@@ -66,21 +67,21 @@ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
66
67
  serializedStepGraph: workflow.serializedStepGraph,
67
68
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
68
69
  name: workflow.name,
69
- triggerSchema: workflow.triggerSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(workflow.triggerSchema)) : void 0,
70
+ triggerSchema: workflow.triggerSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.triggerSchema)) : void 0,
70
71
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
71
72
  const _step = step;
72
73
  acc[key] = {
73
74
  id: _step.id,
74
75
  description: _step.description,
75
76
  workflowId: _step.workflowId,
76
- inputSchema: _step.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_step.inputSchema)) : void 0,
77
- outputSchema: _step.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_step.outputSchema)) : void 0
77
+ inputSchema: _step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(_step.inputSchema)) : void 0,
78
+ outputSchema: _step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(_step.outputSchema)) : void 0
78
79
  };
79
80
  return acc;
80
81
  }, {})
81
82
  };
82
83
  } catch (error) {
83
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
84
+ return chunkRE4RPXT2_cjs.handleError(error, "error getting workflow by id");
84
85
  }
85
86
  }
86
87
  async function startAsyncLegacyWorkflowHandler({
@@ -92,11 +93,11 @@ async function startAsyncLegacyWorkflowHandler({
92
93
  }) {
93
94
  try {
94
95
  if (!workflowId) {
95
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
96
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
96
97
  }
97
98
  const workflow = mastra.legacy_getWorkflow(workflowId);
98
99
  if (!workflow) {
99
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
100
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
100
101
  }
101
102
  if (!runId) {
102
103
  const newRun = workflow.createRun();
@@ -108,7 +109,7 @@ async function startAsyncLegacyWorkflowHandler({
108
109
  }
109
110
  const run = workflow.getMemoryRun(runId);
110
111
  if (!run) {
111
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
112
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
112
113
  }
113
114
  const result = await run.start({
114
115
  triggerData,
@@ -116,7 +117,7 @@ async function startAsyncLegacyWorkflowHandler({
116
117
  });
117
118
  return result;
118
119
  } catch (error) {
119
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
120
+ return chunkRE4RPXT2_cjs.handleError(error, "error starting workflow");
120
121
  }
121
122
  }
122
123
  async function getLegacyWorkflowRunHandler({
@@ -126,22 +127,22 @@ async function getLegacyWorkflowRunHandler({
126
127
  }) {
127
128
  try {
128
129
  if (!workflowId) {
129
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
130
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
130
131
  }
131
132
  if (!runId) {
132
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
133
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
133
134
  }
134
135
  const workflow = mastra.legacy_getWorkflow(workflowId);
135
136
  if (!workflow) {
136
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
137
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
137
138
  }
138
139
  const run = await workflow.getRun(runId);
139
140
  if (!run) {
140
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
141
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
141
142
  }
142
143
  return run;
143
144
  } catch (error) {
144
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
145
+ return chunkRE4RPXT2_cjs.handleError(error, "error getting workflow run");
145
146
  }
146
147
  }
147
148
  async function createLegacyWorkflowRunHandler({
@@ -151,16 +152,16 @@ async function createLegacyWorkflowRunHandler({
151
152
  }) {
152
153
  try {
153
154
  if (!workflowId) {
154
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
155
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
155
156
  }
156
157
  const workflow = mastra.legacy_getWorkflow(workflowId);
157
158
  if (!workflow) {
158
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
159
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
159
160
  }
160
161
  const newRun = workflow.createRun({ runId: prevRunId });
161
162
  return { runId: newRun.runId };
162
163
  } catch (error) {
163
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
164
+ return chunkRE4RPXT2_cjs.handleError(error, "error creating workflow run");
164
165
  }
165
166
  }
166
167
  async function startLegacyWorkflowRunHandler({
@@ -172,15 +173,15 @@ async function startLegacyWorkflowRunHandler({
172
173
  }) {
173
174
  try {
174
175
  if (!workflowId) {
175
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
176
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
176
177
  }
177
178
  if (!runId) {
178
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
179
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to start run" });
179
180
  }
180
181
  const workflow = mastra.legacy_getWorkflow(workflowId);
181
182
  const run = workflow.getMemoryRun(runId);
182
183
  if (!run) {
183
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
184
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
184
185
  }
185
186
  void run.start({
186
187
  triggerData,
@@ -188,7 +189,7 @@ async function startLegacyWorkflowRunHandler({
188
189
  });
189
190
  return { message: "Workflow run started" };
190
191
  } catch (e) {
191
- return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
192
+ return chunkRE4RPXT2_cjs.handleError(e, "Error starting workflow run");
192
193
  }
193
194
  }
194
195
  async function watchLegacyWorkflowHandler({
@@ -198,15 +199,15 @@ async function watchLegacyWorkflowHandler({
198
199
  }) {
199
200
  try {
200
201
  if (!workflowId) {
201
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
202
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
202
203
  }
203
204
  if (!runId) {
204
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
205
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to watch workflow" });
205
206
  }
206
207
  const workflow = mastra.legacy_getWorkflow(workflowId);
207
208
  const run = workflow.getMemoryRun(runId);
208
209
  if (!run) {
209
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
210
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
210
211
  }
211
212
  let unwatch;
212
213
  let asyncRef = null;
@@ -234,7 +235,7 @@ async function watchLegacyWorkflowHandler({
234
235
  });
235
236
  return stream;
236
237
  } catch (error) {
237
- return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
238
+ return chunkRE4RPXT2_cjs.handleError(error, "Error watching workflow");
238
239
  }
239
240
  }
240
241
  async function resumeAsyncLegacyWorkflowHandler({
@@ -246,15 +247,15 @@ async function resumeAsyncLegacyWorkflowHandler({
246
247
  }) {
247
248
  try {
248
249
  if (!workflowId) {
249
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
250
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
250
251
  }
251
252
  if (!runId) {
252
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
253
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
253
254
  }
254
255
  const workflow = mastra.legacy_getWorkflow(workflowId);
255
256
  const run = workflow.getMemoryRun(runId);
256
257
  if (!run) {
257
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
258
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
258
259
  }
259
260
  const result = await run.resume({
260
261
  stepId: body.stepId,
@@ -263,7 +264,7 @@ async function resumeAsyncLegacyWorkflowHandler({
263
264
  });
264
265
  return result;
265
266
  } catch (error) {
266
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
267
+ return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow step");
267
268
  }
268
269
  }
269
270
  async function resumeLegacyWorkflowHandler({
@@ -275,15 +276,15 @@ async function resumeLegacyWorkflowHandler({
275
276
  }) {
276
277
  try {
277
278
  if (!workflowId) {
278
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
279
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
279
280
  }
280
281
  if (!runId) {
281
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
282
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
282
283
  }
283
284
  const workflow = mastra.legacy_getWorkflow(workflowId);
284
285
  const run = workflow.getMemoryRun(runId);
285
286
  if (!run) {
286
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
287
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
287
288
  }
288
289
  void run.resume({
289
290
  stepId: body.stepId,
@@ -292,7 +293,7 @@ async function resumeLegacyWorkflowHandler({
292
293
  });
293
294
  return { message: "Workflow run resumed" };
294
295
  } catch (error) {
295
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
296
+ return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
296
297
  }
297
298
  }
298
299
  async function getLegacyWorkflowRunsHandler({
@@ -306,7 +307,7 @@ async function getLegacyWorkflowRunsHandler({
306
307
  }) {
307
308
  try {
308
309
  if (!workflowId) {
309
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
310
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
310
311
  }
311
312
  const workflow = mastra.legacy_getWorkflow(workflowId);
312
313
  const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
@@ -315,7 +316,7 @@ async function getLegacyWorkflowRunsHandler({
315
316
  };
316
317
  return workflowRuns;
317
318
  } catch (error) {
318
- return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
319
+ return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow runs");
319
320
  }
320
321
  }
321
322
 
@@ -330,3 +331,5 @@ exports.resumeLegacyWorkflowHandler = resumeLegacyWorkflowHandler;
330
331
  exports.startAsyncLegacyWorkflowHandler = startAsyncLegacyWorkflowHandler;
331
332
  exports.startLegacyWorkflowRunHandler = startLegacyWorkflowRunHandler;
332
333
  exports.watchLegacyWorkflowHandler = watchLegacyWorkflowHandler;
334
+ //# sourceMappingURL=chunk-KNGXRN26.cjs.map
335
+ //# sourceMappingURL=chunk-KNGXRN26.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/legacyWorkflows.ts"],"names":["__export","stringify","zodToJsonSchema","acc","key","handleError","HTTPException","result","ReadableStream","runId"],"mappings":";;;;;;;;;;AAAA,IAAA,uBAAA,GAAA;AAAAA,0BAAA,CAAA,uBAAA,EAAA;AAAA,EAAA,8BAAA,EAAA,MAAA,8BAAA;AAAA,EAAA,4BAAA,EAAA,MAAA,4BAAA;AAAA,EAAA,2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,EACT,SAAS,KAAA,EAAO;AACd,IAAA,OAAOD,6BAAA,CAAY,OAAO,6BAA6B,CAAA;AAAA,EACzD;AACF","file":"chunk-KNGXRN26.cjs","sourcesContent":["import { ReadableStream } from 'node:stream/web';\nimport type { RuntimeContext } from '@mastra/core/runtime-context';\nimport type { LegacyWorkflowRuns } from '@mastra/core/storage';\nimport { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\nimport type { LegacyWorkflow } from '@mastra/core/workflows/legacy';\nimport { stringify } from 'superjson';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { handleError } from './error';\n\ninterface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nexport async function getLegacyWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.legacy_getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<any>((acc, [key, workflow]) => {\n if (workflow.isNested) return acc;\n acc[key] = {\n stepGraph: workflow.stepGraph,\n stepSubscriberGraph: workflow.stepSubscriberGraph,\n serializedStepGraph: workflow.serializedStepGraph,\n serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,\n name: workflow.name,\n triggerSchema: workflow.triggerSchema ? stringify(zodToJsonSchema(workflow.triggerSchema)) : undefined,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n const _step = step as any;\n acc[key] = {\n id: _step.id,\n description: _step.description,\n workflowId: _step.workflowId,\n inputSchema: _step.inputSchema ? stringify(zodToJsonSchema(_step.inputSchema)) : undefined,\n outputSchema: _step.outputSchema ? stringify(zodToJsonSchema(_step.outputSchema)) : undefined,\n };\n return acc;\n }, {}),\n };\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'error getting workflows');\n }\n}\n\nexport async function getLegacyWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return {\n stepGraph: workflow.stepGraph,\n stepSubscriberGraph: workflow.stepSubscriberGraph,\n serializedStepGraph: workflow.serializedStepGraph,\n serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,\n name: workflow.name,\n triggerSchema: workflow.triggerSchema ? stringify(zodToJsonSchema(workflow.triggerSchema)) : undefined,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n const _step = step as any;\n acc[key] = {\n id: _step.id,\n description: _step.description,\n workflowId: _step.workflowId,\n inputSchema: _step.inputSchema ? stringify(zodToJsonSchema(_step.inputSchema)) : undefined,\n outputSchema: _step.outputSchema ? stringify(zodToJsonSchema(_step.outputSchema)) : undefined,\n };\n return acc;\n }, {}),\n };\n } catch (error) {\n return handleError(error, 'error getting workflow by id');\n }\n}\n\nexport async function startAsyncLegacyWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n triggerData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n triggerData?: unknown;\n runtimeContext: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n if (!runId) {\n const newRun = workflow.createRun();\n const result = await newRun.start({\n triggerData,\n runtimeContext,\n });\n return result;\n }\n\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n // const newRun = workflow.createRun({ runId });\n\n const result = await run.start({\n triggerData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'error starting workflow');\n }\n}\n\nexport async function getLegacyWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<LegacyWorkflow['getRun']>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'error getting workflow run');\n }\n}\n\nexport async function createLegacyWorkflowRunHandler({\n mastra,\n workflowId,\n runId: prevRunId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const newRun = workflow.createRun({ runId: prevRunId });\n\n return { runId: newRun.runId };\n } catch (error) {\n return handleError(error, 'error creating workflow run');\n }\n}\n\nexport async function startLegacyWorkflowRunHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n triggerData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n triggerData?: unknown;\n runtimeContext: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n void run.start({\n triggerData,\n runtimeContext,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n}\n\nexport async function watchLegacyWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream<string>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to watch workflow' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = run.watch(({ activePaths, runId, timestamp, results }) => {\n const activePathsObj = Object.fromEntries(activePaths);\n controller.enqueue(JSON.stringify({ activePaths: activePathsObj, runId, timestamp, results }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if none of the active paths is currently being executed\n asyncRef = setImmediate(() => {\n const runDone = Object.values(activePathsObj).every(value => value.status !== 'executing');\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n });\n },\n cancel() {\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function resumeAsyncLegacyWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & { body: { stepId: string; context: any }; runtimeContext: RuntimeContext }) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n // const newRun = workflow.createRun({ runId });\n\n const result = await run.resume({\n stepId: body.stepId,\n context: body.context,\n runtimeContext,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeLegacyWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & { body: { stepId: string; context: any }; runtimeContext: RuntimeContext }) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const run = workflow.getMemoryRun(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n void run.resume({\n stepId: body.stepId,\n context: body.context,\n runtimeContext,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function getLegacyWorkflowRunsHandler({\n mastra,\n workflowId,\n fromDate,\n toDate,\n limit,\n offset,\n resourceId,\n}: WorkflowContext & {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n offset?: number;\n resourceId?: string;\n}): Promise<LegacyWorkflowRuns> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const workflow = mastra.legacy_getWorkflow(workflowId);\n const workflowRuns = (await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n}\n"]}