@mastra/server 0.0.0-vnext-inngest-20250508131921 → 0.0.0-vnext-20251104230439

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 (269) hide show
  1. package/CHANGELOG.md +4403 -0
  2. package/LICENSE.md +11 -42
  3. package/README.md +1 -6
  4. package/dist/chunk-2PLXW4ZX.cjs +2777 -0
  5. package/dist/chunk-2PLXW4ZX.cjs.map +1 -0
  6. package/dist/chunk-46Z2KDQL.js +124 -0
  7. package/dist/chunk-46Z2KDQL.js.map +1 -0
  8. package/dist/{chunk-FV45V6WC.cjs → chunk-64ITUOXI.cjs} +3 -7
  9. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  10. package/dist/{chunk-TRDNDNGQ.js → chunk-6QWQZI4Q.js} +4 -7
  11. package/dist/chunk-6QWQZI4Q.js.map +1 -0
  12. package/dist/chunk-73PAWDM5.js +83 -0
  13. package/dist/chunk-73PAWDM5.js.map +1 -0
  14. package/dist/chunk-AEVI2HIU.cjs +651 -0
  15. package/dist/chunk-AEVI2HIU.cjs.map +1 -0
  16. package/dist/chunk-ALOLTNSO.js +477 -0
  17. package/dist/chunk-ALOLTNSO.js.map +1 -0
  18. package/dist/chunk-B6NK4KI5.cjs +128 -0
  19. package/dist/chunk-B6NK4KI5.cjs.map +1 -0
  20. package/dist/chunk-BANGX6SC.cjs +200 -0
  21. package/dist/chunk-BANGX6SC.cjs.map +1 -0
  22. package/dist/chunk-BHQH5QXD.cjs +172 -0
  23. package/dist/chunk-BHQH5QXD.cjs.map +1 -0
  24. package/dist/chunk-BTWIR2B7.cjs +28 -0
  25. package/dist/chunk-BTWIR2B7.cjs.map +1 -0
  26. package/dist/chunk-DNUO33HF.js +129 -0
  27. package/dist/chunk-DNUO33HF.js.map +1 -0
  28. package/dist/chunk-FKZVCLOY.js +527 -0
  29. package/dist/chunk-FKZVCLOY.js.map +1 -0
  30. package/dist/chunk-GTZOYEAU.cjs +130 -0
  31. package/dist/chunk-GTZOYEAU.cjs.map +1 -0
  32. package/dist/chunk-GU4EWMZB.cjs +769 -0
  33. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  34. package/dist/chunk-IGOWG5V5.js +192 -0
  35. package/dist/chunk-IGOWG5V5.js.map +1 -0
  36. package/dist/chunk-JIIVA4BA.cjs +23087 -0
  37. package/dist/chunk-JIIVA4BA.cjs.map +1 -0
  38. package/dist/chunk-JO2AZFJN.js +165 -0
  39. package/dist/chunk-JO2AZFJN.js.map +1 -0
  40. package/dist/chunk-JZ65BJ6H.cjs +678 -0
  41. package/dist/chunk-JZ65BJ6H.cjs.map +1 -0
  42. package/dist/chunk-KCP6I5F3.js +23047 -0
  43. package/dist/chunk-KCP6I5F3.js.map +1 -0
  44. package/dist/{chunk-4JINXASC.js → chunk-KWH5QBXP.js} +7 -4
  45. package/dist/chunk-KWH5QBXP.js.map +1 -0
  46. package/dist/chunk-LF2ZLOFP.js +767 -0
  47. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  48. package/dist/{chunk-Q6SHQECN.js → chunk-LPCK5MAF.js} +47 -13
  49. package/dist/chunk-LPCK5MAF.js.map +1 -0
  50. package/dist/chunk-LPM6BBAX.cjs +1043 -0
  51. package/dist/chunk-LPM6BBAX.cjs.map +1 -0
  52. package/dist/chunk-LWLSQ2W4.cjs +133 -0
  53. package/dist/chunk-LWLSQ2W4.cjs.map +1 -0
  54. package/dist/chunk-O7I5CWRX.cjs +44 -0
  55. package/dist/chunk-O7I5CWRX.cjs.map +1 -0
  56. package/dist/chunk-PPMIB3FQ.cjs +88 -0
  57. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  58. package/dist/chunk-PR4QN5HX.js +39 -0
  59. package/dist/chunk-PR4QN5HX.js.map +1 -0
  60. package/dist/chunk-QFGNUBOA.cjs +543 -0
  61. package/dist/chunk-QFGNUBOA.cjs.map +1 -0
  62. package/dist/chunk-QU6N55W6.cjs +256 -0
  63. package/dist/chunk-QU6N55W6.cjs.map +1 -0
  64. package/dist/chunk-R6OQFR47.js +630 -0
  65. package/dist/chunk-R6OQFR47.js.map +1 -0
  66. package/dist/chunk-RQK4FQUD.js +1012 -0
  67. package/dist/chunk-RQK4FQUD.js.map +1 -0
  68. package/dist/{chunk-M56ECCHK.cjs → chunk-S54HNARD.cjs} +22 -19
  69. package/dist/chunk-S54HNARD.cjs.map +1 -0
  70. package/dist/chunk-SHWNNZBL.js +254 -0
  71. package/dist/chunk-SHWNNZBL.js.map +1 -0
  72. package/dist/{chunk-L7XE5QTW.js → chunk-SZIFSF4T.js} +11 -2
  73. package/dist/chunk-SZIFSF4T.js.map +1 -0
  74. package/dist/chunk-TOCYBDP2.js +46 -0
  75. package/dist/chunk-TOCYBDP2.js.map +1 -0
  76. package/dist/chunk-UXGQZUYZ.js +16 -0
  77. package/dist/chunk-UXGQZUYZ.js.map +1 -0
  78. package/dist/chunk-V5WWQN7P.cjs +18 -0
  79. package/dist/chunk-V5WWQN7P.cjs.map +1 -0
  80. package/dist/chunk-VYR3SAFM.js +658 -0
  81. package/dist/chunk-VYR3SAFM.js.map +1 -0
  82. package/dist/chunk-X6C7BUWN.cjs +48 -0
  83. package/dist/chunk-X6C7BUWN.cjs.map +1 -0
  84. package/dist/chunk-XXGID4PQ.cjs +485 -0
  85. package/dist/chunk-XXGID4PQ.cjs.map +1 -0
  86. package/dist/chunk-ZULZ2752.js +2774 -0
  87. package/dist/chunk-ZULZ2752.js.map +1 -0
  88. package/dist/dist-4MVGNSRL.cjs +1150 -0
  89. package/dist/dist-4MVGNSRL.cjs.map +1 -0
  90. package/dist/dist-FZYCV3VB.cjs +940 -0
  91. package/dist/dist-FZYCV3VB.cjs.map +1 -0
  92. package/dist/dist-G2BYZJOC.cjs +928 -0
  93. package/dist/dist-G2BYZJOC.cjs.map +1 -0
  94. package/dist/dist-P4MXBQ3U.cjs +16 -0
  95. package/dist/dist-P4MXBQ3U.cjs.map +1 -0
  96. package/dist/dist-PQZUVLPC.js +937 -0
  97. package/dist/dist-PQZUVLPC.js.map +1 -0
  98. package/dist/dist-R7WYX6LC.js +925 -0
  99. package/dist/dist-R7WYX6LC.js.map +1 -0
  100. package/dist/dist-RFMYFILX.cjs +764 -0
  101. package/dist/dist-RFMYFILX.cjs.map +1 -0
  102. package/dist/dist-X7XR3M3Z.js +1147 -0
  103. package/dist/dist-X7XR3M3Z.js.map +1 -0
  104. package/dist/dist-XVBSOGFK.js +761 -0
  105. package/dist/dist-XVBSOGFK.js.map +1 -0
  106. package/dist/dist-YREX2TJT.js +3 -0
  107. package/dist/dist-YREX2TJT.js.map +1 -0
  108. package/dist/index.cjs +6 -0
  109. package/dist/index.cjs.map +1 -0
  110. package/dist/index.d.ts +1 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +5 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/server/a2a/protocol.d.ts +8 -0
  115. package/dist/server/a2a/protocol.d.ts.map +1 -0
  116. package/dist/server/a2a/store.cjs +25 -0
  117. package/dist/server/a2a/store.cjs.map +1 -0
  118. package/dist/server/a2a/store.d.ts +14 -0
  119. package/dist/server/a2a/store.d.ts.map +1 -0
  120. package/dist/server/a2a/store.js +23 -0
  121. package/dist/server/a2a/store.js.map +1 -0
  122. package/dist/server/a2a/tasks.d.ts +20 -0
  123. package/dist/server/a2a/tasks.d.ts.map +1 -0
  124. package/dist/server/handlers/a2a.cjs +32 -0
  125. package/dist/server/handlers/a2a.cjs.map +1 -0
  126. package/dist/server/handlers/a2a.d.ts +68 -0
  127. package/dist/server/handlers/a2a.d.ts.map +1 -0
  128. package/dist/server/handlers/a2a.js +3 -0
  129. package/dist/server/handlers/a2a.js.map +1 -0
  130. package/dist/server/handlers/agent-builder.cjs +84 -0
  131. package/dist/server/handlers/agent-builder.cjs.map +1 -0
  132. package/dist/server/handlers/agent-builder.d.ts +91 -0
  133. package/dist/server/handlers/agent-builder.d.ts.map +1 -0
  134. package/dist/server/handlers/agent-builder.js +3 -0
  135. package/dist/server/handlers/agent-builder.js.map +1 -0
  136. package/dist/server/handlers/agents.cjs +60 -10
  137. package/dist/server/handlers/agents.cjs.map +1 -0
  138. package/dist/server/handlers/agents.d.ts +194 -6
  139. package/dist/server/handlers/agents.d.ts.map +1 -0
  140. package/dist/server/handlers/agents.js +3 -1
  141. package/dist/server/handlers/agents.js.map +1 -0
  142. package/dist/server/handlers/error.cjs +4 -2
  143. package/dist/server/handlers/error.cjs.map +1 -0
  144. package/dist/server/handlers/error.d.ts +2 -1
  145. package/dist/server/handlers/error.d.ts.map +1 -0
  146. package/dist/server/handlers/error.js +3 -1
  147. package/dist/server/handlers/error.js.map +1 -0
  148. package/dist/server/handlers/logs.cjs +9 -7
  149. package/dist/server/handlers/logs.cjs.map +1 -0
  150. package/dist/server/handlers/logs.d.ts +34 -3
  151. package/dist/server/handlers/logs.d.ts.map +1 -0
  152. package/dist/server/handlers/logs.js +3 -1
  153. package/dist/server/handlers/logs.js.map +1 -0
  154. package/dist/server/handlers/memory.cjs +36 -10
  155. package/dist/server/handlers/memory.cjs.map +1 -0
  156. package/dist/server/handlers/memory.d.ts +116 -8
  157. package/dist/server/handlers/memory.d.ts.map +1 -0
  158. package/dist/server/handlers/memory.js +3 -1
  159. package/dist/server/handlers/memory.js.map +1 -0
  160. package/dist/server/handlers/observability.cjs +24 -0
  161. package/dist/server/handlers/observability.cjs.map +1 -0
  162. package/dist/server/handlers/observability.d.ts +49 -0
  163. package/dist/server/handlers/observability.d.ts.map +1 -0
  164. package/dist/server/handlers/observability.js +3 -0
  165. package/dist/server/handlers/observability.js.map +1 -0
  166. package/dist/server/handlers/scores.cjs +32 -0
  167. package/dist/server/handlers/scores.cjs.map +1 -0
  168. package/dist/server/handlers/scores.d.ts +152 -0
  169. package/dist/server/handlers/scores.d.ts.map +1 -0
  170. package/dist/server/handlers/scores.js +3 -0
  171. package/dist/server/handlers/scores.js.map +1 -0
  172. package/dist/server/handlers/tools.cjs +12 -6
  173. package/dist/server/handlers/tools.cjs.map +1 -0
  174. package/dist/server/handlers/tools.d.ts +25 -4
  175. package/dist/server/handlers/tools.d.ts.map +1 -0
  176. package/dist/server/handlers/tools.js +3 -1
  177. package/dist/server/handlers/tools.js.map +1 -0
  178. package/dist/server/handlers/utils.cjs +8 -2
  179. package/dist/server/handlers/utils.cjs.map +1 -0
  180. package/dist/server/handlers/utils.d.ts +8 -1
  181. package/dist/server/handlers/utils.d.ts.map +1 -0
  182. package/dist/server/handlers/utils.js +3 -1
  183. package/dist/server/handlers/utils.js.map +1 -0
  184. package/dist/server/handlers/vector.cjs +9 -7
  185. package/dist/server/handlers/vector.cjs.map +1 -0
  186. package/dist/server/handlers/vector.d.ts +51 -6
  187. package/dist/server/handlers/vector.d.ts.map +1 -0
  188. package/dist/server/handlers/vector.js +3 -1
  189. package/dist/server/handlers/vector.js.map +1 -0
  190. package/dist/server/handlers/voice.cjs +10 -4
  191. package/dist/server/handlers/voice.cjs.map +1 -0
  192. package/dist/server/handlers/voice.d.ts +41 -3
  193. package/dist/server/handlers/voice.d.ts.map +1 -0
  194. package/dist/server/handlers/voice.js +3 -1
  195. package/dist/server/handlers/voice.js.map +1 -0
  196. package/dist/server/handlers/workflows.cjs +54 -16
  197. package/dist/server/handlers/workflows.cjs.map +1 -0
  198. package/dist/server/handlers/workflows.d.ts +94 -10
  199. package/dist/server/handlers/workflows.d.ts.map +1 -0
  200. package/dist/server/handlers/workflows.js +3 -1
  201. package/dist/server/handlers/workflows.js.map +1 -0
  202. package/dist/server/handlers.cjs +37 -30
  203. package/dist/server/handlers.cjs.map +1 -0
  204. package/dist/server/handlers.d.ts +12 -10
  205. package/dist/server/handlers.d.ts.map +1 -0
  206. package/dist/server/handlers.js +13 -10
  207. package/dist/server/handlers.js.map +1 -0
  208. package/dist/server/http-exception.d.ts +82 -0
  209. package/dist/server/http-exception.d.ts.map +1 -0
  210. package/dist/server/types.d.ts +10 -0
  211. package/dist/server/types.d.ts.map +1 -0
  212. package/dist/server/utils.d.ts +44 -0
  213. package/dist/server/utils.d.ts.map +1 -0
  214. package/dist/token-375W3LEI.cjs +64 -0
  215. package/dist/token-375W3LEI.cjs.map +1 -0
  216. package/dist/token-C3IMNCC4.js +62 -0
  217. package/dist/token-C3IMNCC4.js.map +1 -0
  218. package/dist/token-util-CV3RRG6K.cjs +9 -0
  219. package/dist/token-util-CV3RRG6K.cjs.map +1 -0
  220. package/dist/token-util-E5QO2RCL.js +7 -0
  221. package/dist/token-util-E5QO2RCL.js.map +1 -0
  222. package/package.json +43 -19
  223. package/dist/_tsup-dts-rollup.d.cts +0 -670
  224. package/dist/_tsup-dts-rollup.d.ts +0 -670
  225. package/dist/chunk-2FJURXCL.cjs +0 -213
  226. package/dist/chunk-3AHQ5RGN.js +0 -11
  227. package/dist/chunk-3EJZQ6TQ.js +0 -49
  228. package/dist/chunk-3XTEV33Q.js +0 -317
  229. package/dist/chunk-55HTWX4C.cjs +0 -93
  230. package/dist/chunk-5JNVY6DU.js +0 -120
  231. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  232. package/dist/chunk-5YGDYMRB.cjs +0 -147
  233. package/dist/chunk-6Q7UXAYJ.cjs +0 -198
  234. package/dist/chunk-AMVOS7YB.cjs +0 -141
  235. package/dist/chunk-BPL2CBLV.js +0 -137
  236. package/dist/chunk-CHFORQ7J.cjs +0 -329
  237. package/dist/chunk-D3G23FP3.cjs +0 -126
  238. package/dist/chunk-GVBJ5I2S.js +0 -190
  239. package/dist/chunk-M2RXDCPV.cjs +0 -324
  240. package/dist/chunk-OMN3UI6X.js +0 -5576
  241. package/dist/chunk-OWNA6I2H.js +0 -312
  242. package/dist/chunk-QJ3AHN64.js +0 -141
  243. package/dist/chunk-QN4KF3BH.cjs +0 -18
  244. package/dist/chunk-RBQASTUP.js +0 -203
  245. package/dist/chunk-SKBVVI24.cjs +0 -54
  246. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  247. package/dist/index.d.cts +0 -1
  248. package/dist/server/handlers/agents.d.cts +0 -6
  249. package/dist/server/handlers/error.d.cts +0 -1
  250. package/dist/server/handlers/logs.d.cts +0 -3
  251. package/dist/server/handlers/memory.d.cts +0 -8
  252. package/dist/server/handlers/network.cjs +0 -22
  253. package/dist/server/handlers/network.d.cts +0 -4
  254. package/dist/server/handlers/network.d.ts +0 -4
  255. package/dist/server/handlers/network.js +0 -1
  256. package/dist/server/handlers/telemetry.cjs +0 -14
  257. package/dist/server/handlers/telemetry.d.cts +0 -2
  258. package/dist/server/handlers/telemetry.d.ts +0 -2
  259. package/dist/server/handlers/telemetry.js +0 -1
  260. package/dist/server/handlers/tools.d.cts +0 -4
  261. package/dist/server/handlers/utils.d.cts +0 -1
  262. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  263. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  264. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  265. package/dist/server/handlers/vNextWorkflows.js +0 -1
  266. package/dist/server/handlers/vector.d.cts +0 -6
  267. package/dist/server/handlers/voice.d.cts +0 -3
  268. package/dist/server/handlers/workflows.d.cts +0 -10
  269. package/dist/server/handlers.d.cts +0 -10
@@ -0,0 +1,651 @@
1
+ 'use strict';
2
+
3
+ var chunkLWLSQ2W4_cjs = require('./chunk-LWLSQ2W4.cjs');
4
+ var chunkV5WWQN7P_cjs = require('./chunk-V5WWQN7P.cjs');
5
+ var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
6
+ var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
7
+ var web = require('stream/web');
8
+
9
+ // src/server/handlers/workflows.ts
10
+ var workflows_exports = {};
11
+ chunkO7I5CWRX_cjs.__export(workflows_exports, {
12
+ cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
13
+ createWorkflowRunHandler: () => createWorkflowRunHandler,
14
+ getWorkflowByIdHandler: () => getWorkflowByIdHandler,
15
+ getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
16
+ getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
17
+ listWorkflowRunsHandler: () => listWorkflowRunsHandler,
18
+ listWorkflowsHandler: () => listWorkflowsHandler,
19
+ observeStreamLegacyWorkflowHandler: () => observeStreamLegacyWorkflowHandler,
20
+ observeStreamVNextWorkflowHandler: () => observeStreamVNextWorkflowHandler,
21
+ observeStreamWorkflowHandler: () => observeStreamWorkflowHandler,
22
+ resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
23
+ resumeStreamWorkflowHandler: () => resumeStreamWorkflowHandler,
24
+ resumeWorkflowHandler: () => resumeWorkflowHandler,
25
+ sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
26
+ startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
27
+ startWorkflowRunHandler: () => startWorkflowRunHandler,
28
+ streamLegacyWorkflowHandler: () => streamLegacyWorkflowHandler,
29
+ streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
30
+ streamWorkflowHandler: () => streamWorkflowHandler
31
+ });
32
+ async function listWorkflowsHandler({ mastra }) {
33
+ try {
34
+ const workflows = mastra.listWorkflows({ serialized: false });
35
+ const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
36
+ acc[key] = chunkLWLSQ2W4_cjs.getWorkflowInfo(workflow);
37
+ return acc;
38
+ }, {});
39
+ return _workflows;
40
+ } catch (error) {
41
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflows");
42
+ }
43
+ }
44
+ async function listWorkflowsFromSystem({ mastra, workflowId }) {
45
+ const logger = mastra.getLogger();
46
+ if (!workflowId) {
47
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
48
+ }
49
+ let workflow;
50
+ workflow = chunkLWLSQ2W4_cjs.WorkflowRegistry.getWorkflow(workflowId);
51
+ if (!workflow) {
52
+ try {
53
+ workflow = mastra.getWorkflow(workflowId);
54
+ } catch (error) {
55
+ logger.debug("Error getting workflow, searching agents for workflow", error);
56
+ }
57
+ }
58
+ if (!workflow) {
59
+ logger.debug("Workflow not found, searching agents for workflow", { workflowId });
60
+ const agents = mastra.listAgents();
61
+ if (Object.keys(agents || {}).length) {
62
+ for (const [_, agent] of Object.entries(agents)) {
63
+ try {
64
+ const workflows = await agent.listWorkflows();
65
+ if (workflows[workflowId]) {
66
+ workflow = workflows[workflowId];
67
+ break;
68
+ }
69
+ break;
70
+ } catch (error) {
71
+ logger.debug("Error getting workflow from agent", error);
72
+ }
73
+ }
74
+ }
75
+ }
76
+ if (!workflow) {
77
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
78
+ }
79
+ return { workflow };
80
+ }
81
+ async function getWorkflowByIdHandler({ mastra, workflowId }) {
82
+ try {
83
+ if (!workflowId) {
84
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
85
+ }
86
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
87
+ if (!workflow) {
88
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
89
+ }
90
+ return chunkLWLSQ2W4_cjs.getWorkflowInfo(workflow);
91
+ } catch (error) {
92
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow");
93
+ }
94
+ }
95
+ async function getWorkflowRunByIdHandler({
96
+ mastra,
97
+ workflowId,
98
+ runId
99
+ }) {
100
+ try {
101
+ if (!workflowId) {
102
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
103
+ }
104
+ if (!runId) {
105
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Run ID is required" });
106
+ }
107
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
108
+ if (!workflow) {
109
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
110
+ }
111
+ const run = await workflow.getWorkflowRunById(runId);
112
+ if (!run) {
113
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
114
+ }
115
+ return run;
116
+ } catch (error) {
117
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow run");
118
+ }
119
+ }
120
+ async function getWorkflowRunExecutionResultHandler({
121
+ mastra,
122
+ workflowId,
123
+ runId
124
+ }) {
125
+ try {
126
+ if (!workflowId) {
127
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
128
+ }
129
+ if (!runId) {
130
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Run ID is required" });
131
+ }
132
+ const workflow = mastra.getWorkflow(workflowId);
133
+ if (!workflow) {
134
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
135
+ }
136
+ const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
137
+ if (!executionResult) {
138
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
139
+ }
140
+ return executionResult;
141
+ } catch (error) {
142
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow run execution result");
143
+ }
144
+ }
145
+ async function createWorkflowRunHandler({
146
+ mastra,
147
+ workflowId,
148
+ runId: prevRunId
149
+ }) {
150
+ try {
151
+ if (!workflowId) {
152
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
153
+ }
154
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
155
+ if (!workflow) {
156
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
157
+ }
158
+ const run = await workflow.createRun({ runId: prevRunId });
159
+ return { runId: run.runId };
160
+ } catch (error) {
161
+ return chunkV5WWQN7P_cjs.handleError(error, "Error creating workflow run");
162
+ }
163
+ }
164
+ async function startAsyncWorkflowHandler({
165
+ mastra,
166
+ requestContext,
167
+ workflowId,
168
+ runId,
169
+ inputData,
170
+ tracingOptions
171
+ }) {
172
+ try {
173
+ if (!workflowId) {
174
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
175
+ }
176
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
177
+ if (!workflow) {
178
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
179
+ }
180
+ const _run = await workflow.createRun({ runId });
181
+ const result = await _run.start({
182
+ inputData,
183
+ requestContext,
184
+ tracingOptions
185
+ });
186
+ return result;
187
+ } catch (error) {
188
+ return chunkV5WWQN7P_cjs.handleError(error, "Error starting async workflow");
189
+ }
190
+ }
191
+ async function startWorkflowRunHandler({
192
+ mastra,
193
+ requestContext,
194
+ workflowId,
195
+ runId,
196
+ inputData,
197
+ tracingOptions
198
+ }) {
199
+ try {
200
+ if (!workflowId) {
201
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
202
+ }
203
+ if (!runId) {
204
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to start run" });
205
+ }
206
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
207
+ if (!workflow) {
208
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
209
+ }
210
+ const run = await workflow.getWorkflowRunById(runId);
211
+ if (!run) {
212
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
213
+ }
214
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
215
+ void _run.start({
216
+ inputData,
217
+ requestContext,
218
+ tracingOptions
219
+ });
220
+ return { message: "Workflow run started" };
221
+ } catch (e) {
222
+ return chunkV5WWQN7P_cjs.handleError(e, "Error starting workflow run");
223
+ }
224
+ }
225
+ async function streamWorkflowHandler({
226
+ mastra,
227
+ requestContext,
228
+ workflowId,
229
+ runId,
230
+ inputData,
231
+ tracingOptions
232
+ }) {
233
+ return streamVNextWorkflowHandler({ mastra, workflowId, runId, inputData, requestContext, tracingOptions });
234
+ }
235
+ async function streamLegacyWorkflowHandler({
236
+ mastra,
237
+ requestContext,
238
+ workflowId,
239
+ runId,
240
+ inputData,
241
+ tracingOptions
242
+ }) {
243
+ try {
244
+ if (!workflowId) {
245
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
246
+ }
247
+ if (!runId) {
248
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
249
+ }
250
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
251
+ if (!workflow) {
252
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
253
+ }
254
+ const serverCache = mastra.getServerCache();
255
+ const run = await workflow.createRun({ runId });
256
+ const result = run.streamLegacy({
257
+ inputData,
258
+ requestContext,
259
+ onChunk: async (chunk) => {
260
+ if (serverCache) {
261
+ const cacheKey = runId;
262
+ await serverCache.listPush(cacheKey, chunk);
263
+ }
264
+ },
265
+ tracingOptions
266
+ });
267
+ return result;
268
+ } catch (error) {
269
+ return chunkV5WWQN7P_cjs.handleError(error, "Error executing workflow");
270
+ }
271
+ }
272
+ async function observeStreamLegacyWorkflowHandler({
273
+ mastra,
274
+ workflowId,
275
+ runId
276
+ }) {
277
+ try {
278
+ if (!workflowId) {
279
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
280
+ }
281
+ if (!runId) {
282
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
283
+ }
284
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
285
+ if (!workflow) {
286
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
287
+ }
288
+ const run = await workflow.getWorkflowRunById(runId);
289
+ if (!run) {
290
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
291
+ }
292
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
293
+ const serverCache = mastra.getServerCache();
294
+ if (!serverCache) {
295
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Server cache not found" });
296
+ }
297
+ const transformStream = new web.TransformStream();
298
+ const writer = transformStream.writable.getWriter();
299
+ const cachedRunChunks = await serverCache.listFromTo(runId, 0);
300
+ for (const chunk of cachedRunChunks) {
301
+ await writer.write(chunk);
302
+ }
303
+ writer.releaseLock();
304
+ const result = _run.observeStreamLegacy();
305
+ return result.stream?.pipeThrough(transformStream);
306
+ } catch (error) {
307
+ return chunkV5WWQN7P_cjs.handleError(error, "Error observing workflow stream");
308
+ }
309
+ }
310
+ async function observeStreamWorkflowHandler({
311
+ mastra,
312
+ workflowId,
313
+ runId
314
+ }) {
315
+ return observeStreamVNextWorkflowHandler({ mastra, workflowId, runId });
316
+ }
317
+ async function streamVNextWorkflowHandler({
318
+ mastra,
319
+ requestContext,
320
+ workflowId,
321
+ runId,
322
+ inputData,
323
+ closeOnSuspend,
324
+ tracingOptions
325
+ }) {
326
+ try {
327
+ if (!workflowId) {
328
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
329
+ }
330
+ if (!runId) {
331
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to stream workflow" });
332
+ }
333
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
334
+ if (!workflow) {
335
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
336
+ }
337
+ const serverCache = mastra.getServerCache();
338
+ const run = await workflow.createRun({ runId });
339
+ const result = run.stream({
340
+ inputData,
341
+ requestContext,
342
+ closeOnSuspend,
343
+ tracingOptions
344
+ });
345
+ return result.fullStream.pipeThrough(
346
+ new web.TransformStream({
347
+ transform(chunk, controller) {
348
+ if (serverCache) {
349
+ const cacheKey = runId;
350
+ serverCache.listPush(cacheKey, chunk).catch(() => {
351
+ });
352
+ }
353
+ controller.enqueue(chunk);
354
+ }
355
+ })
356
+ );
357
+ } catch (error) {
358
+ return chunkV5WWQN7P_cjs.handleError(error, "Error streaming workflow");
359
+ }
360
+ }
361
+ async function observeStreamVNextWorkflowHandler({
362
+ mastra,
363
+ workflowId,
364
+ runId
365
+ }) {
366
+ try {
367
+ if (!workflowId) {
368
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
369
+ }
370
+ if (!runId) {
371
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to observe workflow stream" });
372
+ }
373
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
374
+ if (!workflow) {
375
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
376
+ }
377
+ const run = await workflow.getWorkflowRunById(runId);
378
+ if (!run) {
379
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
380
+ }
381
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
382
+ const serverCache = mastra.getServerCache();
383
+ if (!serverCache) {
384
+ throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Server cache not found" });
385
+ }
386
+ const cachedRunChunks = await serverCache.listFromTo(runId, 0);
387
+ const combinedStream = new web.ReadableStream({
388
+ start(controller) {
389
+ const emitCachedChunks = async () => {
390
+ for (const chunk of cachedRunChunks) {
391
+ controller.enqueue(chunk);
392
+ }
393
+ };
394
+ const liveStream = _run.observeStream();
395
+ const reader = liveStream.getReader();
396
+ const pump = async () => {
397
+ try {
398
+ while (true) {
399
+ const { done, value } = await reader.read();
400
+ if (done) {
401
+ controller.close();
402
+ break;
403
+ }
404
+ controller.enqueue(value);
405
+ }
406
+ } catch (error) {
407
+ controller.error(error);
408
+ } finally {
409
+ reader.releaseLock();
410
+ }
411
+ };
412
+ void emitCachedChunks().then(() => {
413
+ void pump();
414
+ }).catch((error) => {
415
+ controller.error(error);
416
+ });
417
+ }
418
+ });
419
+ return combinedStream;
420
+ } catch (error) {
421
+ return chunkV5WWQN7P_cjs.handleError(error, "Error observing workflow stream");
422
+ }
423
+ }
424
+ async function resumeAsyncWorkflowHandler({
425
+ mastra,
426
+ workflowId,
427
+ runId,
428
+ body,
429
+ requestContext,
430
+ tracingOptions
431
+ }) {
432
+ try {
433
+ if (!workflowId) {
434
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
435
+ }
436
+ if (!runId) {
437
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
438
+ }
439
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
440
+ if (!workflow) {
441
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
442
+ }
443
+ const run = await workflow.getWorkflowRunById(runId);
444
+ if (!run) {
445
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
446
+ }
447
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
448
+ const result = await _run.resume({
449
+ step: body.step,
450
+ resumeData: body.resumeData,
451
+ requestContext,
452
+ tracingOptions
453
+ });
454
+ return result;
455
+ } catch (error) {
456
+ return chunkV5WWQN7P_cjs.handleError(error, "Error resuming workflow step");
457
+ }
458
+ }
459
+ async function resumeWorkflowHandler({
460
+ mastra,
461
+ workflowId,
462
+ runId,
463
+ body,
464
+ requestContext,
465
+ tracingOptions
466
+ }) {
467
+ try {
468
+ if (!workflowId) {
469
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
470
+ }
471
+ if (!runId) {
472
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
473
+ }
474
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
475
+ if (!workflow) {
476
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
477
+ }
478
+ const run = await workflow.getWorkflowRunById(runId);
479
+ if (!run) {
480
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
481
+ }
482
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
483
+ void _run.resume({
484
+ step: body.step,
485
+ resumeData: body.resumeData,
486
+ requestContext,
487
+ tracingOptions
488
+ });
489
+ return { message: "Workflow run resumed" };
490
+ } catch (error) {
491
+ return chunkV5WWQN7P_cjs.handleError(error, "Error resuming workflow");
492
+ }
493
+ }
494
+ async function resumeStreamWorkflowHandler({
495
+ mastra,
496
+ workflowId,
497
+ runId,
498
+ body,
499
+ requestContext,
500
+ tracingOptions
501
+ }) {
502
+ try {
503
+ if (!workflowId) {
504
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
505
+ }
506
+ if (!runId) {
507
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
508
+ }
509
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
510
+ if (!workflow) {
511
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
512
+ }
513
+ const run = await workflow.getWorkflowRunById(runId);
514
+ if (!run) {
515
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
516
+ }
517
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
518
+ const serverCache = mastra.getServerCache();
519
+ const stream = _run.resumeStream({
520
+ step: body.step,
521
+ resumeData: body.resumeData,
522
+ requestContext,
523
+ tracingOptions
524
+ }).fullStream.pipeThrough(
525
+ new web.TransformStream({
526
+ transform(chunk, controller) {
527
+ if (serverCache) {
528
+ const cacheKey = runId;
529
+ serverCache.listPush(cacheKey, chunk).catch(() => {
530
+ });
531
+ }
532
+ controller.enqueue(chunk);
533
+ }
534
+ })
535
+ );
536
+ return stream;
537
+ } catch (error) {
538
+ return chunkV5WWQN7P_cjs.handleError(error, "Error resuming workflow");
539
+ }
540
+ }
541
+ async function listWorkflowRunsHandler({
542
+ mastra,
543
+ workflowId,
544
+ fromDate,
545
+ toDate,
546
+ perPage,
547
+ page,
548
+ resourceId
549
+ }) {
550
+ try {
551
+ if (!workflowId) {
552
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
553
+ }
554
+ if (perPage !== void 0 && perPage !== false && (!Number.isInteger(perPage) || perPage <= 0)) {
555
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "perPage must be a positive integer or false" });
556
+ }
557
+ if (page !== void 0 && (!Number.isInteger(page) || page < 0)) {
558
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "page must be a non-negative integer" });
559
+ }
560
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
561
+ if (!workflow) {
562
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
563
+ }
564
+ const workflowRuns = await workflow.listWorkflowRuns({ fromDate, toDate, perPage, page, resourceId }) || {
565
+ runs: [],
566
+ total: 0
567
+ };
568
+ return workflowRuns;
569
+ } catch (error) {
570
+ return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow runs");
571
+ }
572
+ }
573
+ async function cancelWorkflowRunHandler({
574
+ mastra,
575
+ workflowId,
576
+ runId
577
+ }) {
578
+ try {
579
+ if (!workflowId) {
580
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
581
+ }
582
+ if (!runId) {
583
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
584
+ }
585
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
586
+ if (!workflow) {
587
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
588
+ }
589
+ const run = await workflow.getWorkflowRunById(runId);
590
+ if (!run) {
591
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
592
+ }
593
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
594
+ await _run.cancel();
595
+ return { message: "Workflow run cancelled" };
596
+ } catch (error) {
597
+ return chunkV5WWQN7P_cjs.handleError(error, "Error canceling workflow run");
598
+ }
599
+ }
600
+ async function sendWorkflowRunEventHandler({
601
+ mastra,
602
+ workflowId,
603
+ runId,
604
+ event,
605
+ data
606
+ }) {
607
+ try {
608
+ if (!workflowId) {
609
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
610
+ }
611
+ if (!runId) {
612
+ throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "runId required to send workflow run event" });
613
+ }
614
+ const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
615
+ if (!workflow) {
616
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
617
+ }
618
+ const run = await workflow.getWorkflowRunById(runId);
619
+ if (!run) {
620
+ throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run not found" });
621
+ }
622
+ const _run = await workflow.createRun({ runId, resourceId: run.resourceId });
623
+ await _run.sendEvent(event, data);
624
+ return { message: "Workflow run event sent" };
625
+ } catch (error) {
626
+ return chunkV5WWQN7P_cjs.handleError(error, "Error sending workflow run event");
627
+ }
628
+ }
629
+
630
+ exports.cancelWorkflowRunHandler = cancelWorkflowRunHandler;
631
+ exports.createWorkflowRunHandler = createWorkflowRunHandler;
632
+ exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
633
+ exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
634
+ exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
635
+ exports.listWorkflowRunsHandler = listWorkflowRunsHandler;
636
+ exports.listWorkflowsHandler = listWorkflowsHandler;
637
+ exports.observeStreamLegacyWorkflowHandler = observeStreamLegacyWorkflowHandler;
638
+ exports.observeStreamVNextWorkflowHandler = observeStreamVNextWorkflowHandler;
639
+ exports.observeStreamWorkflowHandler = observeStreamWorkflowHandler;
640
+ exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
641
+ exports.resumeStreamWorkflowHandler = resumeStreamWorkflowHandler;
642
+ exports.resumeWorkflowHandler = resumeWorkflowHandler;
643
+ exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
644
+ exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
645
+ exports.startWorkflowRunHandler = startWorkflowRunHandler;
646
+ exports.streamLegacyWorkflowHandler = streamLegacyWorkflowHandler;
647
+ exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
648
+ exports.streamWorkflowHandler = streamWorkflowHandler;
649
+ exports.workflows_exports = workflows_exports;
650
+ //# sourceMappingURL=chunk-AEVI2HIU.cjs.map
651
+ //# sourceMappingURL=chunk-AEVI2HIU.cjs.map