@mastra/server 0.0.0-sidebar-window-undefined-fix-20251029233656 → 0.0.0-span-scorring-test-20251124132129

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 (252) hide show
  1. package/CHANGELOG.md +713 -3
  2. package/README.md +1 -1
  3. package/dist/chunk-2NW6POYK.cjs +89 -0
  4. package/dist/chunk-2NW6POYK.cjs.map +1 -0
  5. package/dist/chunk-35NT4TMQ.cjs +201 -0
  6. package/dist/chunk-35NT4TMQ.cjs.map +1 -0
  7. package/dist/{chunk-MN2TZQ7I.js → chunk-3R5EV3HV.js} +218 -31
  8. package/dist/chunk-3R5EV3HV.js.map +1 -0
  9. package/dist/{chunk-K5T5A3AL.cjs → chunk-4ECGVOJZ.cjs} +224 -31
  10. package/dist/chunk-4ECGVOJZ.cjs.map +1 -0
  11. package/dist/chunk-5PONYNYP.cjs +125 -0
  12. package/dist/chunk-5PONYNYP.cjs.map +1 -0
  13. package/dist/chunk-5W4RPVTK.cjs +49 -0
  14. package/dist/chunk-5W4RPVTK.cjs.map +1 -0
  15. package/dist/{chunk-7NADHFD2.cjs → chunk-64ITUOXI.cjs} +2 -2
  16. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  17. package/dist/{chunk-7HCPO76Z.js → chunk-6BISSAIF.js} +5096 -1150
  18. package/dist/chunk-6BISSAIF.js.map +1 -0
  19. package/dist/chunk-6DTV6NEW.js +116 -0
  20. package/dist/chunk-6DTV6NEW.js.map +1 -0
  21. package/dist/{chunk-MMROOK5J.js → chunk-6QWQZI4Q.js} +2 -2
  22. package/dist/{chunk-7NADHFD2.cjs.map → chunk-6QWQZI4Q.js.map} +1 -1
  23. package/dist/chunk-AEO6IHLK.cjs +368 -0
  24. package/dist/chunk-AEO6IHLK.cjs.map +1 -0
  25. package/dist/chunk-ASZUOBKV.js +310 -0
  26. package/dist/chunk-ASZUOBKV.js.map +1 -0
  27. package/dist/chunk-ECIVTQ4E.js +354 -0
  28. package/dist/chunk-ECIVTQ4E.js.map +1 -0
  29. package/dist/chunk-FAQICBMH.js +164 -0
  30. package/dist/chunk-FAQICBMH.js.map +1 -0
  31. package/dist/chunk-FXDZLX2Y.js +192 -0
  32. package/dist/chunk-FXDZLX2Y.js.map +1 -0
  33. package/dist/{chunk-KSFLUEWV.js → chunk-G7BPNX2V.js} +6 -6
  34. package/dist/chunk-G7BPNX2V.js.map +1 -0
  35. package/dist/chunk-I5VZ5SKG.js +328 -0
  36. package/dist/chunk-I5VZ5SKG.js.map +1 -0
  37. package/dist/chunk-ICANWSEW.js +204 -0
  38. package/dist/chunk-ICANWSEW.js.map +1 -0
  39. package/dist/chunk-KB5NSROG.cjs +211 -0
  40. package/dist/chunk-KB5NSROG.cjs.map +1 -0
  41. package/dist/chunk-MWQQRVQC.cjs +259 -0
  42. package/dist/chunk-MWQQRVQC.cjs.map +1 -0
  43. package/dist/chunk-NDFAQBQD.cjs +792 -0
  44. package/dist/chunk-NDFAQBQD.cjs.map +1 -0
  45. package/dist/chunk-PKRHEXX7.js +74 -0
  46. package/dist/chunk-PKRHEXX7.js.map +1 -0
  47. package/dist/chunk-QGWCNTG6.cjs +797 -0
  48. package/dist/chunk-QGWCNTG6.cjs.map +1 -0
  49. package/dist/chunk-R4M3BSUG.js +226 -0
  50. package/dist/chunk-R4M3BSUG.js.map +1 -0
  51. package/dist/{chunk-KDUHLUK4.cjs → chunk-TBVUN4XN.cjs} +5944 -1992
  52. package/dist/chunk-TBVUN4XN.cjs.map +1 -0
  53. package/dist/chunk-UJNHKFBR.cjs +167 -0
  54. package/dist/chunk-UJNHKFBR.cjs.map +1 -0
  55. package/dist/chunk-UOFV2ZCI.js +878 -0
  56. package/dist/chunk-UOFV2ZCI.js.map +1 -0
  57. package/dist/{chunk-CY4TP3FK.js → chunk-UXGQZUYZ.js} +3 -3
  58. package/dist/{chunk-CY4TP3FK.js.map → chunk-UXGQZUYZ.js.map} +1 -1
  59. package/dist/{chunk-CJFKRVED.cjs → chunk-UZ6CYAOG.cjs} +6 -6
  60. package/dist/chunk-UZ6CYAOG.cjs.map +1 -0
  61. package/dist/{chunk-RE4RPXT2.cjs → chunk-V5WWQN7P.cjs} +4 -4
  62. package/dist/{chunk-RE4RPXT2.cjs.map → chunk-V5WWQN7P.cjs.map} +1 -1
  63. package/dist/chunk-VQAT5HX6.js +756 -0
  64. package/dist/chunk-VQAT5HX6.js.map +1 -0
  65. package/dist/chunk-XWGAT2DA.js +44 -0
  66. package/dist/chunk-XWGAT2DA.js.map +1 -0
  67. package/dist/chunk-YJ3VDL3Z.cjs +346 -0
  68. package/dist/chunk-YJ3VDL3Z.cjs.map +1 -0
  69. package/dist/chunk-Z36N2OQA.cjs +907 -0
  70. package/dist/chunk-Z36N2OQA.cjs.map +1 -0
  71. package/dist/chunk-ZLRTFRL4.js +773 -0
  72. package/dist/chunk-ZLRTFRL4.js.map +1 -0
  73. package/dist/chunk-ZODCSH2W.cjs +322 -0
  74. package/dist/chunk-ZODCSH2W.cjs.map +1 -0
  75. package/dist/server/handlers/a2a.cjs +15 -7
  76. package/dist/server/handlers/a2a.d.ts +492 -10
  77. package/dist/server/handlers/a2a.d.ts.map +1 -1
  78. package/dist/server/handlers/a2a.js +1 -1
  79. package/dist/server/handlers/agent-builder.cjs +43 -31
  80. package/dist/server/handlers/agent-builder.d.ts +592 -84
  81. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  82. package/dist/server/handlers/agent-builder.js +1 -1
  83. package/dist/server/handlers/agents.cjs +51 -39
  84. package/dist/server/handlers/agents.d.ts +3277 -148
  85. package/dist/server/handlers/agents.d.ts.map +1 -1
  86. package/dist/server/handlers/agents.js +1 -1
  87. package/dist/server/handlers/error.cjs +2 -2
  88. package/dist/server/handlers/error.js +1 -1
  89. package/dist/server/handlers/logs.cjs +7 -7
  90. package/dist/server/handlers/logs.d.ts +135 -27
  91. package/dist/server/handlers/logs.d.ts.map +1 -1
  92. package/dist/server/handlers/logs.js +1 -1
  93. package/dist/server/handlers/memory.cjs +63 -31
  94. package/dist/server/handlers/memory.d.ts +934 -103
  95. package/dist/server/handlers/memory.d.ts.map +1 -1
  96. package/dist/server/handlers/memory.js +1 -1
  97. package/dist/server/handlers/observability.cjs +24 -8
  98. package/dist/server/handlers/observability.d.ts +128 -21
  99. package/dist/server/handlers/observability.d.ts.map +1 -1
  100. package/dist/server/handlers/observability.js +1 -1
  101. package/dist/server/handlers/scores.cjs +13 -13
  102. package/dist/server/handlers/scores.d.ts +110 -141
  103. package/dist/server/handlers/scores.d.ts.map +1 -1
  104. package/dist/server/handlers/scores.js +1 -1
  105. package/dist/server/handlers/test-utils.cjs +15 -0
  106. package/dist/server/handlers/test-utils.cjs.map +1 -0
  107. package/dist/server/handlers/test-utils.d.ts +6 -0
  108. package/dist/server/handlers/test-utils.d.ts.map +1 -0
  109. package/dist/server/handlers/test-utils.js +13 -0
  110. package/dist/server/handlers/test-utils.js.map +1 -0
  111. package/dist/server/handlers/tools.cjs +11 -11
  112. package/dist/server/handlers/tools.d.ts +69 -23
  113. package/dist/server/handlers/tools.d.ts.map +1 -1
  114. package/dist/server/handlers/tools.js +1 -1
  115. package/dist/server/handlers/utils.cjs +11 -3
  116. package/dist/server/handlers/utils.d.ts +5 -0
  117. package/dist/server/handlers/utils.d.ts.map +1 -1
  118. package/dist/server/handlers/utils.js +1 -1
  119. package/dist/server/handlers/vector.cjs +31 -7
  120. package/dist/server/handlers/vector.d.ts +93 -9
  121. package/dist/server/handlers/vector.d.ts.map +1 -1
  122. package/dist/server/handlers/vector.js +1 -1
  123. package/dist/server/handlers/voice.cjs +21 -9
  124. package/dist/server/handlers/voice.d.ts +81 -40
  125. package/dist/server/handlers/voice.d.ts.map +1 -1
  126. package/dist/server/handlers/voice.js +1 -1
  127. package/dist/server/handlers/workflows.cjs +37 -45
  128. package/dist/server/handlers/workflows.d.ts +597 -83
  129. package/dist/server/handlers/workflows.d.ts.map +1 -1
  130. package/dist/server/handlers/workflows.js +1 -1
  131. package/dist/server/handlers.cjs +23 -28
  132. package/dist/server/handlers.d.ts +0 -1
  133. package/dist/server/handlers.d.ts.map +1 -1
  134. package/dist/server/handlers.js +11 -12
  135. package/dist/server/http-exception.d.ts +0 -5
  136. package/dist/server/http-exception.d.ts.map +1 -1
  137. package/dist/server/schemas/a2a.d.ts +786 -0
  138. package/dist/server/schemas/a2a.d.ts.map +1 -0
  139. package/dist/server/schemas/agent-builder.d.ts +195 -0
  140. package/dist/server/schemas/agent-builder.d.ts.map +1 -0
  141. package/dist/server/schemas/agents.d.ts +1375 -0
  142. package/dist/server/schemas/agents.d.ts.map +1 -0
  143. package/dist/server/schemas/common.d.ts +165 -0
  144. package/dist/server/schemas/common.d.ts.map +1 -0
  145. package/dist/server/schemas/logs.d.ts +124 -0
  146. package/dist/server/schemas/logs.d.ts.map +1 -0
  147. package/dist/server/schemas/memory.d.ts +998 -0
  148. package/dist/server/schemas/memory.d.ts.map +1 -0
  149. package/dist/server/schemas/observability.d.ts +402 -0
  150. package/dist/server/schemas/observability.d.ts.map +1 -0
  151. package/dist/server/schemas/scores.d.ts +259 -0
  152. package/dist/server/schemas/scores.d.ts.map +1 -0
  153. package/dist/server/schemas/vectors.d.ts +107 -0
  154. package/dist/server/schemas/vectors.d.ts.map +1 -0
  155. package/dist/server/schemas/workflows.d.ts +505 -0
  156. package/dist/server/schemas/workflows.d.ts.map +1 -0
  157. package/dist/server/server-adapter/index.cjs +323 -0
  158. package/dist/server/server-adapter/index.cjs.map +1 -0
  159. package/dist/server/server-adapter/index.d.ts +52 -0
  160. package/dist/server/server-adapter/index.d.ts.map +1 -0
  161. package/dist/server/server-adapter/index.js +309 -0
  162. package/dist/server/server-adapter/index.js.map +1 -0
  163. package/dist/server/server-adapter/openapi-utils.d.ts +59 -0
  164. package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -0
  165. package/dist/server/server-adapter/routes/a2a.d.ts +3 -0
  166. package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -0
  167. package/dist/server/server-adapter/routes/agent-builder.d.ts +3 -0
  168. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -0
  169. package/dist/server/server-adapter/routes/agents.d.ts +3 -0
  170. package/dist/server/server-adapter/routes/agents.d.ts.map +1 -0
  171. package/dist/server/server-adapter/routes/index.d.ts +41 -0
  172. package/dist/server/server-adapter/routes/index.d.ts.map +1 -0
  173. package/dist/server/server-adapter/routes/legacy.d.ts +7 -0
  174. package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -0
  175. package/dist/server/server-adapter/routes/logs.d.ts +3 -0
  176. package/dist/server/server-adapter/routes/logs.d.ts.map +1 -0
  177. package/dist/server/server-adapter/routes/memory.d.ts +3 -0
  178. package/dist/server/server-adapter/routes/memory.d.ts.map +1 -0
  179. package/dist/server/server-adapter/routes/observability.d.ts +3 -0
  180. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -0
  181. package/dist/server/server-adapter/routes/route-builder.d.ts +52 -0
  182. package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -0
  183. package/dist/server/server-adapter/routes/scorers.d.ts +3 -0
  184. package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -0
  185. package/dist/server/server-adapter/routes/stream-types.d.ts +10 -0
  186. package/dist/server/server-adapter/routes/stream-types.d.ts.map +1 -0
  187. package/dist/server/server-adapter/routes/tools.d.ts +3 -0
  188. package/dist/server/server-adapter/routes/tools.d.ts.map +1 -0
  189. package/dist/server/server-adapter/routes/vectors.d.ts +3 -0
  190. package/dist/server/server-adapter/routes/vectors.d.ts.map +1 -0
  191. package/dist/server/server-adapter/routes/workflows.d.ts +3 -0
  192. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -0
  193. package/dist/server/utils.d.ts +3 -2
  194. package/dist/server/utils.d.ts.map +1 -1
  195. package/package.json +26 -8
  196. package/dist/chunk-2P4VRXBT.js +0 -533
  197. package/dist/chunk-2P4VRXBT.js.map +0 -1
  198. package/dist/chunk-2S4IMB6E.cjs +0 -130
  199. package/dist/chunk-2S4IMB6E.cjs.map +0 -1
  200. package/dist/chunk-3SNGNFUJ.cjs +0 -128
  201. package/dist/chunk-3SNGNFUJ.cjs.map +0 -1
  202. package/dist/chunk-4QCXUEAT.js +0 -25
  203. package/dist/chunk-4QCXUEAT.js.map +0 -1
  204. package/dist/chunk-6VPAV4ZV.js +0 -692
  205. package/dist/chunk-6VPAV4ZV.js.map +0 -1
  206. package/dist/chunk-7HCPO76Z.js.map +0 -1
  207. package/dist/chunk-ABRFV4XP.js +0 -83
  208. package/dist/chunk-ABRFV4XP.js.map +0 -1
  209. package/dist/chunk-AHB4JCIQ.js +0 -160
  210. package/dist/chunk-AHB4JCIQ.js.map +0 -1
  211. package/dist/chunk-AW5BU3RQ.js +0 -192
  212. package/dist/chunk-AW5BU3RQ.js.map +0 -1
  213. package/dist/chunk-B7QWVGQQ.cjs +0 -729
  214. package/dist/chunk-B7QWVGQQ.cjs.map +0 -1
  215. package/dist/chunk-BATEJLED.js +0 -124
  216. package/dist/chunk-BATEJLED.js.map +0 -1
  217. package/dist/chunk-CJFKRVED.cjs.map +0 -1
  218. package/dist/chunk-EP3JQDPD.cjs +0 -131
  219. package/dist/chunk-EP3JQDPD.cjs.map +0 -1
  220. package/dist/chunk-G4PUALCE.cjs +0 -28
  221. package/dist/chunk-G4PUALCE.cjs.map +0 -1
  222. package/dist/chunk-GDUKGVFI.cjs +0 -550
  223. package/dist/chunk-GDUKGVFI.cjs.map +0 -1
  224. package/dist/chunk-I3C4ODGV.cjs +0 -335
  225. package/dist/chunk-I3C4ODGV.cjs.map +0 -1
  226. package/dist/chunk-K5T5A3AL.cjs.map +0 -1
  227. package/dist/chunk-KDUHLUK4.cjs.map +0 -1
  228. package/dist/chunk-KSFLUEWV.js.map +0 -1
  229. package/dist/chunk-LLUOPR3J.js +0 -323
  230. package/dist/chunk-LLUOPR3J.js.map +0 -1
  231. package/dist/chunk-MMROOK5J.js.map +0 -1
  232. package/dist/chunk-MN2TZQ7I.js.map +0 -1
  233. package/dist/chunk-MYR4PVGN.js +0 -123
  234. package/dist/chunk-MYR4PVGN.js.map +0 -1
  235. package/dist/chunk-QQXMIP6C.js +0 -122
  236. package/dist/chunk-QQXMIP6C.js.map +0 -1
  237. package/dist/chunk-SPRRK3P7.cjs +0 -200
  238. package/dist/chunk-SPRRK3P7.cjs.map +0 -1
  239. package/dist/chunk-TRGAMKHX.cjs +0 -167
  240. package/dist/chunk-TRGAMKHX.cjs.map +0 -1
  241. package/dist/chunk-XN74I6VW.cjs +0 -88
  242. package/dist/chunk-XN74I6VW.cjs.map +0 -1
  243. package/dist/chunk-YSHNCC6F.cjs +0 -713
  244. package/dist/chunk-YSHNCC6F.cjs.map +0 -1
  245. package/dist/chunk-ZLBL4NQC.js +0 -707
  246. package/dist/chunk-ZLBL4NQC.js.map +0 -1
  247. package/dist/server/handlers/legacyWorkflows.cjs +0 -48
  248. package/dist/server/handlers/legacyWorkflows.cjs.map +0 -1
  249. package/dist/server/handlers/legacyWorkflows.d.ts +0 -59
  250. package/dist/server/handlers/legacyWorkflows.d.ts.map +0 -1
  251. package/dist/server/handlers/legacyWorkflows.js +0 -3
  252. package/dist/server/handlers/legacyWorkflows.js.map +0 -1
@@ -1,707 +0,0 @@
1
- import { getWorkflowInfo, WorkflowRegistry } from './chunk-KSFLUEWV.js';
2
- import { handleError } from './chunk-CY4TP3FK.js';
3
- import { HTTPException } from './chunk-MMROOK5J.js';
4
- import { __export } from './chunk-PR4QN5HX.js';
5
- import { ReadableStream, TransformStream } from 'stream/web';
6
-
7
- // src/server/handlers/workflows.ts
8
- var workflows_exports = {};
9
- __export(workflows_exports, {
10
- cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
11
- createWorkflowRunHandler: () => createWorkflowRunHandler,
12
- getWorkflowByIdHandler: () => getWorkflowByIdHandler,
13
- getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
14
- getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
15
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
16
- getWorkflowsHandler: () => getWorkflowsHandler,
17
- observeStreamLegacyWorkflowHandler: () => observeStreamLegacyWorkflowHandler,
18
- observeStreamVNextWorkflowHandler: () => observeStreamVNextWorkflowHandler,
19
- observeStreamWorkflowHandler: () => observeStreamWorkflowHandler,
20
- resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
21
- resumeStreamWorkflowHandler: () => resumeStreamWorkflowHandler,
22
- resumeWorkflowHandler: () => resumeWorkflowHandler,
23
- sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
24
- startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
25
- startWorkflowRunHandler: () => startWorkflowRunHandler,
26
- streamLegacyWorkflowHandler: () => streamLegacyWorkflowHandler,
27
- streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
28
- streamWorkflowHandler: () => streamWorkflowHandler,
29
- watchWorkflowHandler: () => watchWorkflowHandler
30
- });
31
- async function getWorkflowsHandler({ mastra }) {
32
- try {
33
- const workflows = mastra.getWorkflows({ serialized: false });
34
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
35
- acc[key] = getWorkflowInfo(workflow);
36
- return acc;
37
- }, {});
38
- return _workflows;
39
- } catch (error) {
40
- return handleError(error, "Error getting workflows");
41
- }
42
- }
43
- async function getWorkflowsFromSystem({ mastra, workflowId }) {
44
- const logger = mastra.getLogger();
45
- if (!workflowId) {
46
- throw new HTTPException(400, { message: "Workflow ID is required" });
47
- }
48
- let workflow;
49
- workflow = WorkflowRegistry.getWorkflow(workflowId);
50
- if (!workflow) {
51
- try {
52
- workflow = mastra.getWorkflow(workflowId);
53
- } catch (error) {
54
- logger.debug("Error getting workflow, searching agents for workflow", error);
55
- }
56
- }
57
- if (!workflow) {
58
- logger.debug("Workflow not found, searching agents for workflow", { workflowId });
59
- const agents = mastra.getAgents();
60
- if (Object.keys(agents || {}).length) {
61
- for (const [_, agent] of Object.entries(agents)) {
62
- try {
63
- const workflows = await agent.getWorkflows();
64
- if (workflows[workflowId]) {
65
- workflow = workflows[workflowId];
66
- break;
67
- }
68
- break;
69
- } catch (error) {
70
- logger.debug("Error getting workflow from agent", error);
71
- }
72
- }
73
- }
74
- }
75
- if (!workflow) {
76
- throw new HTTPException(404, { message: "Workflow not found" });
77
- }
78
- return { workflow };
79
- }
80
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
81
- try {
82
- if (!workflowId) {
83
- throw new HTTPException(400, { message: "Workflow ID is required" });
84
- }
85
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
86
- if (!workflow) {
87
- throw new HTTPException(404, { message: "Workflow not found" });
88
- }
89
- return getWorkflowInfo(workflow);
90
- } catch (error) {
91
- return handleError(error, "Error getting workflow");
92
- }
93
- }
94
- async function getWorkflowRunByIdHandler({
95
- mastra,
96
- workflowId,
97
- runId
98
- }) {
99
- try {
100
- if (!workflowId) {
101
- throw new HTTPException(400, { message: "Workflow ID is required" });
102
- }
103
- if (!runId) {
104
- throw new HTTPException(400, { message: "Run ID is required" });
105
- }
106
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
107
- if (!workflow) {
108
- throw new HTTPException(404, { message: "Workflow not found" });
109
- }
110
- const run = await workflow.getWorkflowRunById(runId);
111
- if (!run) {
112
- throw new HTTPException(404, { message: "Workflow run not found" });
113
- }
114
- return run;
115
- } catch (error) {
116
- return handleError(error, "Error getting workflow run");
117
- }
118
- }
119
- async function getWorkflowRunExecutionResultHandler({
120
- mastra,
121
- workflowId,
122
- runId
123
- }) {
124
- try {
125
- if (!workflowId) {
126
- throw new HTTPException(400, { message: "Workflow ID is required" });
127
- }
128
- if (!runId) {
129
- throw new HTTPException(400, { message: "Run ID is required" });
130
- }
131
- const workflow = mastra.getWorkflow(workflowId);
132
- if (!workflow) {
133
- throw new HTTPException(404, { message: "Workflow not found" });
134
- }
135
- const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
136
- if (!executionResult) {
137
- throw new HTTPException(404, { message: "Workflow run execution result not found" });
138
- }
139
- return executionResult;
140
- } catch (error) {
141
- return handleError(error, "Error getting workflow run execution result");
142
- }
143
- }
144
- async function createWorkflowRunHandler({
145
- mastra,
146
- workflowId,
147
- runId: prevRunId
148
- }) {
149
- try {
150
- if (!workflowId) {
151
- throw new HTTPException(400, { message: "Workflow ID is required" });
152
- }
153
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
154
- if (!workflow) {
155
- throw new HTTPException(404, { message: "Workflow not found" });
156
- }
157
- const run = await workflow.createRunAsync({ runId: prevRunId });
158
- return { runId: run.runId };
159
- } catch (error) {
160
- return handleError(error, "Error creating workflow run");
161
- }
162
- }
163
- async function startAsyncWorkflowHandler({
164
- mastra,
165
- runtimeContext,
166
- workflowId,
167
- runId,
168
- inputData,
169
- tracingOptions
170
- }) {
171
- try {
172
- if (!workflowId) {
173
- throw new HTTPException(400, { message: "Workflow ID is required" });
174
- }
175
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
176
- if (!workflow) {
177
- throw new HTTPException(404, { message: "Workflow not found" });
178
- }
179
- const _run = await workflow.createRunAsync({ runId });
180
- const result = await _run.start({
181
- inputData,
182
- runtimeContext,
183
- tracingOptions
184
- });
185
- return result;
186
- } catch (error) {
187
- return handleError(error, "Error starting async workflow");
188
- }
189
- }
190
- async function startWorkflowRunHandler({
191
- mastra,
192
- runtimeContext,
193
- workflowId,
194
- runId,
195
- inputData,
196
- tracingOptions
197
- }) {
198
- try {
199
- if (!workflowId) {
200
- throw new HTTPException(400, { message: "Workflow ID is required" });
201
- }
202
- if (!runId) {
203
- throw new HTTPException(400, { message: "runId required to start run" });
204
- }
205
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
206
- if (!workflow) {
207
- throw new HTTPException(404, { message: "Workflow not found" });
208
- }
209
- const run = await workflow.getWorkflowRunById(runId);
210
- if (!run) {
211
- throw new HTTPException(404, { message: "Workflow run not found" });
212
- }
213
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
214
- void _run.start({
215
- inputData,
216
- runtimeContext,
217
- tracingOptions
218
- });
219
- return { message: "Workflow run started" };
220
- } catch (e) {
221
- return handleError(e, "Error starting workflow run");
222
- }
223
- }
224
- async function watchWorkflowHandler({
225
- mastra,
226
- workflowId,
227
- runId,
228
- eventType = "watch"
229
- }) {
230
- try {
231
- if (!workflowId) {
232
- throw new HTTPException(400, { message: "Workflow ID is required" });
233
- }
234
- if (!runId) {
235
- throw new HTTPException(400, { message: "runId required to watch workflow" });
236
- }
237
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
238
- if (!workflow) {
239
- throw new HTTPException(404, { message: "Workflow not found" });
240
- }
241
- const run = await workflow.getWorkflowRunById(runId);
242
- if (!run) {
243
- throw new HTTPException(404, { message: "Workflow run not found" });
244
- }
245
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
246
- let unwatch;
247
- let asyncRef = null;
248
- const stream = new ReadableStream({
249
- start(controller) {
250
- if (eventType === "watch") {
251
- unwatch = _run.watch((event) => {
252
- const { type, payload, eventTimestamp } = event;
253
- controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
254
- if (asyncRef) {
255
- clearImmediate(asyncRef);
256
- asyncRef = null;
257
- }
258
- asyncRef = setImmediate(async () => {
259
- const runDone = payload.workflowState?.status !== "running";
260
- if (runDone) {
261
- controller.close();
262
- unwatch?.();
263
- }
264
- });
265
- }, eventType);
266
- } else {
267
- unwatch = _run.watch((event) => {
268
- const { type, payload } = event;
269
- controller.enqueue(JSON.stringify({ type, payload, runId }));
270
- if (asyncRef) {
271
- clearImmediate(asyncRef);
272
- asyncRef = null;
273
- }
274
- asyncRef = setImmediate(async () => {
275
- const runDone = type === "workflow-finish";
276
- if (runDone) {
277
- controller.close();
278
- unwatch?.();
279
- }
280
- });
281
- }, eventType);
282
- }
283
- },
284
- cancel() {
285
- if (asyncRef) {
286
- clearImmediate(asyncRef);
287
- asyncRef = null;
288
- }
289
- unwatch?.();
290
- }
291
- });
292
- return stream;
293
- } catch (error) {
294
- return handleError(error, "Error watching workflow");
295
- }
296
- }
297
- async function streamWorkflowHandler({
298
- mastra,
299
- runtimeContext,
300
- workflowId,
301
- runId,
302
- inputData,
303
- tracingOptions
304
- }) {
305
- return streamVNextWorkflowHandler({ mastra, workflowId, runId, inputData, runtimeContext, tracingOptions });
306
- }
307
- async function streamLegacyWorkflowHandler({
308
- mastra,
309
- runtimeContext,
310
- workflowId,
311
- runId,
312
- inputData,
313
- tracingOptions
314
- }) {
315
- try {
316
- if (!workflowId) {
317
- throw new HTTPException(400, { message: "Workflow ID is required" });
318
- }
319
- if (!runId) {
320
- throw new HTTPException(400, { message: "runId required to resume workflow" });
321
- }
322
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
323
- if (!workflow) {
324
- throw new HTTPException(404, { message: "Workflow not found" });
325
- }
326
- const serverCache = mastra.getServerCache();
327
- const run = await workflow.createRunAsync({ runId });
328
- const result = run.streamLegacy({
329
- inputData,
330
- runtimeContext,
331
- onChunk: async (chunk) => {
332
- if (serverCache) {
333
- const cacheKey = runId;
334
- await serverCache.listPush(cacheKey, chunk);
335
- }
336
- },
337
- tracingOptions
338
- });
339
- return result;
340
- } catch (error) {
341
- return handleError(error, "Error executing workflow");
342
- }
343
- }
344
- async function observeStreamLegacyWorkflowHandler({
345
- mastra,
346
- workflowId,
347
- runId
348
- }) {
349
- try {
350
- if (!workflowId) {
351
- throw new HTTPException(400, { message: "Workflow ID is required" });
352
- }
353
- if (!runId) {
354
- throw new HTTPException(400, { message: "runId required to observe workflow stream" });
355
- }
356
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
357
- if (!workflow) {
358
- throw new HTTPException(404, { message: "Workflow not found" });
359
- }
360
- const run = await workflow.getWorkflowRunById(runId);
361
- if (!run) {
362
- throw new HTTPException(404, { message: "Workflow run not found" });
363
- }
364
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
365
- const serverCache = mastra.getServerCache();
366
- if (!serverCache) {
367
- throw new HTTPException(500, { message: "Server cache not found" });
368
- }
369
- const transformStream = new TransformStream();
370
- const writer = transformStream.writable.getWriter();
371
- const cachedRunChunks = await serverCache.listFromTo(runId, 0);
372
- for (const chunk of cachedRunChunks) {
373
- await writer.write(chunk);
374
- }
375
- writer.releaseLock();
376
- const result = _run.observeStreamLegacy();
377
- return result.stream?.pipeThrough(transformStream);
378
- } catch (error) {
379
- return handleError(error, "Error observing workflow stream");
380
- }
381
- }
382
- async function observeStreamWorkflowHandler({
383
- mastra,
384
- workflowId,
385
- runId
386
- }) {
387
- return observeStreamVNextWorkflowHandler({ mastra, workflowId, runId });
388
- }
389
- async function streamVNextWorkflowHandler({
390
- mastra,
391
- runtimeContext,
392
- workflowId,
393
- runId,
394
- inputData,
395
- closeOnSuspend,
396
- tracingOptions
397
- }) {
398
- try {
399
- if (!workflowId) {
400
- throw new HTTPException(400, { message: "Workflow ID is required" });
401
- }
402
- if (!runId) {
403
- throw new HTTPException(400, { message: "runId required to stream workflow" });
404
- }
405
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
406
- if (!workflow) {
407
- throw new HTTPException(404, { message: "Workflow not found" });
408
- }
409
- const serverCache = mastra.getServerCache();
410
- const run = await workflow.createRunAsync({ runId });
411
- const result = run.stream({
412
- inputData,
413
- runtimeContext,
414
- closeOnSuspend,
415
- tracingOptions
416
- });
417
- return result.fullStream.pipeThrough(
418
- new TransformStream({
419
- transform(chunk, controller) {
420
- if (serverCache) {
421
- const cacheKey = runId;
422
- serverCache.listPush(cacheKey, chunk).catch(() => {
423
- });
424
- }
425
- controller.enqueue(chunk);
426
- }
427
- })
428
- );
429
- } catch (error) {
430
- return handleError(error, "Error streaming workflow");
431
- }
432
- }
433
- async function observeStreamVNextWorkflowHandler({
434
- mastra,
435
- workflowId,
436
- runId
437
- }) {
438
- try {
439
- if (!workflowId) {
440
- throw new HTTPException(400, { message: "Workflow ID is required" });
441
- }
442
- if (!runId) {
443
- throw new HTTPException(400, { message: "runId required to observe workflow stream" });
444
- }
445
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
446
- if (!workflow) {
447
- throw new HTTPException(404, { message: "Workflow not found" });
448
- }
449
- const run = await workflow.getWorkflowRunById(runId);
450
- if (!run) {
451
- throw new HTTPException(404, { message: "Workflow run not found" });
452
- }
453
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
454
- const serverCache = mastra.getServerCache();
455
- if (!serverCache) {
456
- throw new HTTPException(500, { message: "Server cache not found" });
457
- }
458
- const cachedRunChunks = await serverCache.listFromTo(runId, 0);
459
- const combinedStream = new ReadableStream({
460
- start(controller) {
461
- const emitCachedChunks = async () => {
462
- for (const chunk of cachedRunChunks) {
463
- controller.enqueue(chunk);
464
- }
465
- };
466
- const liveStream = _run.observeStream();
467
- const reader = liveStream.getReader();
468
- const pump = async () => {
469
- try {
470
- while (true) {
471
- const { done, value } = await reader.read();
472
- if (done) {
473
- controller.close();
474
- break;
475
- }
476
- controller.enqueue(value);
477
- }
478
- } catch (error) {
479
- controller.error(error);
480
- } finally {
481
- reader.releaseLock();
482
- }
483
- };
484
- void emitCachedChunks().then(() => {
485
- void pump();
486
- }).catch((error) => {
487
- controller.error(error);
488
- });
489
- }
490
- });
491
- return combinedStream;
492
- } catch (error) {
493
- return handleError(error, "Error observing workflow stream");
494
- }
495
- }
496
- async function resumeAsyncWorkflowHandler({
497
- mastra,
498
- workflowId,
499
- runId,
500
- body,
501
- runtimeContext,
502
- tracingOptions
503
- }) {
504
- try {
505
- if (!workflowId) {
506
- throw new HTTPException(400, { message: "Workflow ID is required" });
507
- }
508
- if (!runId) {
509
- throw new HTTPException(400, { message: "runId required to resume workflow" });
510
- }
511
- if (!body.step) {
512
- throw new HTTPException(400, { message: "step required to resume workflow" });
513
- }
514
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
515
- if (!workflow) {
516
- throw new HTTPException(404, { message: "Workflow not found" });
517
- }
518
- const run = await workflow.getWorkflowRunById(runId);
519
- if (!run) {
520
- throw new HTTPException(404, { message: "Workflow run not found" });
521
- }
522
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
523
- const result = await _run.resume({
524
- step: body.step,
525
- resumeData: body.resumeData,
526
- runtimeContext,
527
- tracingOptions
528
- });
529
- return result;
530
- } catch (error) {
531
- return handleError(error, "Error resuming workflow step");
532
- }
533
- }
534
- async function resumeWorkflowHandler({
535
- mastra,
536
- workflowId,
537
- runId,
538
- body,
539
- runtimeContext,
540
- tracingOptions
541
- }) {
542
- try {
543
- if (!workflowId) {
544
- throw new HTTPException(400, { message: "Workflow ID is required" });
545
- }
546
- if (!runId) {
547
- throw new HTTPException(400, { message: "runId required to resume workflow" });
548
- }
549
- if (!body.step) {
550
- throw new HTTPException(400, { message: "step required to resume workflow" });
551
- }
552
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
553
- if (!workflow) {
554
- throw new HTTPException(404, { message: "Workflow not found" });
555
- }
556
- const run = await workflow.getWorkflowRunById(runId);
557
- if (!run) {
558
- throw new HTTPException(404, { message: "Workflow run not found" });
559
- }
560
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
561
- void _run.resume({
562
- step: body.step,
563
- resumeData: body.resumeData,
564
- runtimeContext,
565
- tracingOptions
566
- });
567
- return { message: "Workflow run resumed" };
568
- } catch (error) {
569
- return handleError(error, "Error resuming workflow");
570
- }
571
- }
572
- async function resumeStreamWorkflowHandler({
573
- mastra,
574
- workflowId,
575
- runId,
576
- body,
577
- runtimeContext,
578
- tracingOptions
579
- }) {
580
- try {
581
- if (!workflowId) {
582
- throw new HTTPException(400, { message: "Workflow ID is required" });
583
- }
584
- if (!runId) {
585
- throw new HTTPException(400, { message: "runId required to resume workflow" });
586
- }
587
- if (!body.step) {
588
- throw new HTTPException(400, { message: "step required to resume workflow" });
589
- }
590
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
591
- if (!workflow) {
592
- throw new HTTPException(404, { message: "Workflow not found" });
593
- }
594
- const run = await workflow.getWorkflowRunById(runId);
595
- if (!run) {
596
- throw new HTTPException(404, { message: "Workflow run not found" });
597
- }
598
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
599
- const serverCache = mastra.getServerCache();
600
- const stream = _run.resumeStream({
601
- step: body.step,
602
- resumeData: body.resumeData,
603
- runtimeContext,
604
- tracingOptions
605
- }).fullStream.pipeThrough(
606
- new TransformStream({
607
- transform(chunk, controller) {
608
- if (serverCache) {
609
- const cacheKey = runId;
610
- serverCache.listPush(cacheKey, chunk).catch(() => {
611
- });
612
- }
613
- controller.enqueue(chunk);
614
- }
615
- })
616
- );
617
- return stream;
618
- } catch (error) {
619
- return handleError(error, "Error resuming workflow");
620
- }
621
- }
622
- async function getWorkflowRunsHandler({
623
- mastra,
624
- workflowId,
625
- fromDate,
626
- toDate,
627
- limit,
628
- offset,
629
- resourceId
630
- }) {
631
- try {
632
- if (!workflowId) {
633
- throw new HTTPException(400, { message: "Workflow ID is required" });
634
- }
635
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
636
- if (!workflow) {
637
- throw new HTTPException(404, { message: "Workflow not found" });
638
- }
639
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
640
- runs: [],
641
- total: 0
642
- };
643
- return workflowRuns;
644
- } catch (error) {
645
- return handleError(error, "Error getting workflow runs");
646
- }
647
- }
648
- async function cancelWorkflowRunHandler({
649
- mastra,
650
- workflowId,
651
- runId
652
- }) {
653
- try {
654
- if (!workflowId) {
655
- throw new HTTPException(400, { message: "Workflow ID is required" });
656
- }
657
- if (!runId) {
658
- throw new HTTPException(400, { message: "runId required to cancel workflow run" });
659
- }
660
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
661
- if (!workflow) {
662
- throw new HTTPException(404, { message: "Workflow not found" });
663
- }
664
- const run = await workflow.getWorkflowRunById(runId);
665
- if (!run) {
666
- throw new HTTPException(404, { message: "Workflow run not found" });
667
- }
668
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
669
- await _run.cancel();
670
- return { message: "Workflow run cancelled" };
671
- } catch (error) {
672
- return handleError(error, "Error canceling workflow run");
673
- }
674
- }
675
- async function sendWorkflowRunEventHandler({
676
- mastra,
677
- workflowId,
678
- runId,
679
- event,
680
- data
681
- }) {
682
- try {
683
- if (!workflowId) {
684
- throw new HTTPException(400, { message: "Workflow ID is required" });
685
- }
686
- if (!runId) {
687
- throw new HTTPException(400, { message: "runId required to send workflow run event" });
688
- }
689
- const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
690
- if (!workflow) {
691
- throw new HTTPException(404, { message: "Workflow not found" });
692
- }
693
- const run = await workflow.getWorkflowRunById(runId);
694
- if (!run) {
695
- throw new HTTPException(404, { message: "Workflow run not found" });
696
- }
697
- const _run = await workflow.createRunAsync({ runId, resourceId: run.resourceId });
698
- await _run.sendEvent(event, data);
699
- return { message: "Workflow run event sent" };
700
- } catch (error) {
701
- return handleError(error, "Error sending workflow run event");
702
- }
703
- }
704
-
705
- export { cancelWorkflowRunHandler, createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, observeStreamLegacyWorkflowHandler, observeStreamVNextWorkflowHandler, observeStreamWorkflowHandler, resumeAsyncWorkflowHandler, resumeStreamWorkflowHandler, resumeWorkflowHandler, sendWorkflowRunEventHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamLegacyWorkflowHandler, streamVNextWorkflowHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
706
- //# sourceMappingURL=chunk-ZLBL4NQC.js.map
707
- //# sourceMappingURL=chunk-ZLBL4NQC.js.map