@mastra/server 0.0.0-mcp-server-deploy-20250507160341 → 0.0.0-memory-system-message-error-20250813233316

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 (226) hide show
  1. package/LICENSE.md +11 -42
  2. package/README.md +48 -135
  3. package/dist/{chunk-5YGDYMRB.cjs → chunk-4CEZIJWJ.cjs} +16 -13
  4. package/dist/chunk-4CEZIJWJ.cjs.map +1 -0
  5. package/dist/chunk-4MQU6AJN.js +83 -0
  6. package/dist/chunk-4MQU6AJN.js.map +1 -0
  7. package/dist/{chunk-QN4KF3BH.cjs → chunk-4QSNRCOT.cjs} +4 -2
  8. package/dist/chunk-4QSNRCOT.cjs.map +1 -0
  9. package/dist/chunk-4US5W7PH.cjs +120 -0
  10. package/dist/chunk-4US5W7PH.cjs.map +1 -0
  11. package/dist/chunk-5AKR33BI.js +333 -0
  12. package/dist/chunk-5AKR33BI.js.map +1 -0
  13. package/dist/chunk-7FHF55WA.js +2041 -0
  14. package/dist/chunk-7FHF55WA.js.map +1 -0
  15. package/dist/{chunk-FV45V6WC.cjs → chunk-7NADHFD2.cjs} +3 -7
  16. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  17. package/dist/chunk-BED2O446.cjs +88 -0
  18. package/dist/chunk-BED2O446.cjs.map +1 -0
  19. package/dist/chunk-BUOJL3MN.js +529 -0
  20. package/dist/chunk-BUOJL3MN.js.map +1 -0
  21. package/dist/chunk-CY4TP3FK.js +16 -0
  22. package/dist/chunk-CY4TP3FK.js.map +1 -0
  23. package/dist/chunk-EBNIUZRY.cjs +344 -0
  24. package/dist/chunk-EBNIUZRY.cjs.map +1 -0
  25. package/dist/{chunk-4JINXASC.js → chunk-G7NVCO5M.js} +7 -4
  26. package/dist/chunk-G7NVCO5M.js.map +1 -0
  27. package/dist/chunk-GX25CWC7.cjs +588 -0
  28. package/dist/chunk-GX25CWC7.cjs.map +1 -0
  29. package/dist/{chunk-Q6SHQECN.js → chunk-HWHKM67I.js} +36 -10
  30. package/dist/chunk-HWHKM67I.js.map +1 -0
  31. package/dist/{chunk-AMVOS7YB.cjs → chunk-ILCWPBYQ.cjs} +14 -8
  32. package/dist/chunk-ILCWPBYQ.cjs.map +1 -0
  33. package/dist/chunk-JGVY3KWV.cjs +334 -0
  34. package/dist/chunk-JGVY3KWV.cjs.map +1 -0
  35. package/dist/chunk-JNWFG7JP.js +476 -0
  36. package/dist/chunk-JNWFG7JP.js.map +1 -0
  37. package/dist/chunk-KXNFZXLG.cjs +484 -0
  38. package/dist/chunk-KXNFZXLG.cjs.map +1 -0
  39. package/dist/chunk-L7YG7WQH.js +151 -0
  40. package/dist/chunk-L7YG7WQH.js.map +1 -0
  41. package/dist/chunk-LRUH33B4.cjs +2044 -0
  42. package/dist/chunk-LRUH33B4.cjs.map +1 -0
  43. package/dist/{chunk-TRDNDNGQ.js → chunk-MMROOK5J.js} +4 -7
  44. package/dist/chunk-MMROOK5J.js.map +1 -0
  45. package/dist/{chunk-M56ECCHK.cjs → chunk-NCS2OXX6.cjs} +22 -19
  46. package/dist/chunk-NCS2OXX6.cjs.map +1 -0
  47. package/dist/{chunk-D3G23FP3.cjs → chunk-O4I563YW.cjs} +26 -22
  48. package/dist/chunk-O4I563YW.cjs.map +1 -0
  49. package/dist/{chunk-L7XE5QTW.js → chunk-OW4FX5TS.js} +3 -1
  50. package/dist/chunk-OW4FX5TS.js.map +1 -0
  51. package/dist/chunk-PZ5AY32C.js +9 -0
  52. package/dist/chunk-PZ5AY32C.js.map +1 -0
  53. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  54. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  55. package/dist/chunk-RE4RPXT2.cjs +18 -0
  56. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  57. package/dist/chunk-RQQNZZAI.cjs +159 -0
  58. package/dist/chunk-RQQNZZAI.cjs.map +1 -0
  59. package/dist/chunk-S37KCGOR.cjs +546 -0
  60. package/dist/chunk-S37KCGOR.cjs.map +1 -0
  61. package/dist/{chunk-BPL2CBLV.js → chunk-SQ7KKIH3.js} +10 -4
  62. package/dist/chunk-SQ7KKIH3.js.map +1 -0
  63. package/dist/{chunk-3XTEV33Q.js → chunk-UVOSITKU.js} +61 -56
  64. package/dist/chunk-UVOSITKU.js.map +1 -0
  65. package/dist/{chunk-QJ3AHN64.js → chunk-Y3J45CVZ.js} +6 -3
  66. package/dist/chunk-Y3J45CVZ.js.map +1 -0
  67. package/dist/{chunk-5JNVY6DU.js → chunk-YS66MFDY.js} +9 -5
  68. package/dist/chunk-YS66MFDY.js.map +1 -0
  69. package/dist/chunk-ZKJZQN24.js +571 -0
  70. package/dist/chunk-ZKJZQN24.js.map +1 -0
  71. package/dist/index.cjs +2 -12
  72. package/dist/index.cjs.map +1 -0
  73. package/dist/index.d.ts +2 -2
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +3 -1
  76. package/dist/index.js.map +1 -0
  77. package/dist/server/a2a/protocol.d.ts +8 -0
  78. package/dist/server/a2a/protocol.d.ts.map +1 -0
  79. package/dist/server/a2a/store.cjs +25 -0
  80. package/dist/server/a2a/store.cjs.map +1 -0
  81. package/dist/server/a2a/store.d.ts +14 -0
  82. package/dist/server/a2a/store.d.ts.map +1 -0
  83. package/dist/server/a2a/store.js +23 -0
  84. package/dist/server/a2a/store.js.map +1 -0
  85. package/dist/server/a2a/tasks.d.ts +20 -0
  86. package/dist/server/a2a/tasks.d.ts.map +1 -0
  87. package/dist/server/handlers/a2a.cjs +32 -0
  88. package/dist/server/handlers/a2a.cjs.map +1 -0
  89. package/dist/server/handlers/a2a.d.ts +68 -0
  90. package/dist/server/handlers/a2a.d.ts.map +1 -0
  91. package/dist/server/handlers/a2a.js +3 -0
  92. package/dist/server/handlers/a2a.js.map +1 -0
  93. package/dist/server/handlers/agents.cjs +21 -7
  94. package/dist/server/handlers/agents.cjs.map +1 -0
  95. package/dist/server/handlers/agents.d.ts +90 -6
  96. package/dist/server/handlers/agents.d.ts.map +1 -0
  97. package/dist/server/handlers/agents.js +3 -1
  98. package/dist/server/handlers/agents.js.map +1 -0
  99. package/dist/server/handlers/error.cjs +4 -2
  100. package/dist/server/handlers/error.cjs.map +1 -0
  101. package/dist/server/handlers/error.d.ts +2 -1
  102. package/dist/server/handlers/error.d.ts.map +1 -0
  103. package/dist/server/handlers/error.js +3 -1
  104. package/dist/server/handlers/error.js.map +1 -0
  105. package/dist/server/handlers/legacyWorkflows.cjs +48 -0
  106. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  107. package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
  108. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  109. package/dist/server/handlers/legacyWorkflows.js +3 -0
  110. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  111. package/dist/server/handlers/logs.cjs +6 -4
  112. package/dist/server/handlers/logs.cjs.map +1 -0
  113. package/dist/server/handlers/logs.d.ts +34 -3
  114. package/dist/server/handlers/logs.d.ts.map +1 -0
  115. package/dist/server/handlers/logs.js +3 -1
  116. package/dist/server/handlers/logs.js.map +1 -0
  117. package/dist/server/handlers/memory.cjs +39 -9
  118. package/dist/server/handlers/memory.cjs.map +1 -0
  119. package/dist/server/handlers/memory.d.ts +119 -8
  120. package/dist/server/handlers/memory.d.ts.map +1 -0
  121. package/dist/server/handlers/memory.js +3 -1
  122. package/dist/server/handlers/memory.js.map +1 -0
  123. package/dist/server/handlers/network.cjs +7 -5
  124. package/dist/server/handlers/network.cjs.map +1 -0
  125. package/dist/server/handlers/network.d.ts +50 -4
  126. package/dist/server/handlers/network.d.ts.map +1 -0
  127. package/dist/server/handlers/network.js +3 -1
  128. package/dist/server/handlers/network.js.map +1 -0
  129. package/dist/server/handlers/scores.cjs +32 -0
  130. package/dist/server/handlers/scores.cjs.map +1 -0
  131. package/dist/server/handlers/scores.d.ts +49 -0
  132. package/dist/server/handlers/scores.d.ts.map +1 -0
  133. package/dist/server/handlers/scores.js +3 -0
  134. package/dist/server/handlers/scores.js.map +1 -0
  135. package/dist/server/handlers/telemetry.cjs +5 -3
  136. package/dist/server/handlers/telemetry.cjs.map +1 -0
  137. package/dist/server/handlers/telemetry.d.ts +32 -2
  138. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  139. package/dist/server/handlers/telemetry.js +3 -1
  140. package/dist/server/handlers/telemetry.js.map +1 -0
  141. package/dist/server/handlers/tools.cjs +7 -5
  142. package/dist/server/handlers/tools.cjs.map +1 -0
  143. package/dist/server/handlers/tools.d.ts +21 -4
  144. package/dist/server/handlers/tools.d.ts.map +1 -0
  145. package/dist/server/handlers/tools.js +3 -1
  146. package/dist/server/handlers/tools.js.map +1 -0
  147. package/dist/server/handlers/utils.cjs +4 -2
  148. package/dist/server/handlers/utils.cjs.map +1 -0
  149. package/dist/server/handlers/utils.d.ts +2 -1
  150. package/dist/server/handlers/utils.d.ts.map +1 -0
  151. package/dist/server/handlers/utils.js +3 -1
  152. package/dist/server/handlers/utils.js.map +1 -0
  153. package/dist/server/handlers/vNextNetwork.cjs +220 -0
  154. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  155. package/dist/server/handlers/vNextNetwork.d.ts +179 -0
  156. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  157. package/dist/server/handlers/vNextNetwork.js +213 -0
  158. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  159. package/dist/server/handlers/vector.cjs +9 -7
  160. package/dist/server/handlers/vector.cjs.map +1 -0
  161. package/dist/server/handlers/vector.d.ts +51 -6
  162. package/dist/server/handlers/vector.d.ts.map +1 -0
  163. package/dist/server/handlers/vector.js +3 -1
  164. package/dist/server/handlers/vector.js.map +1 -0
  165. package/dist/server/handlers/voice.cjs +10 -4
  166. package/dist/server/handlers/voice.cjs.map +1 -0
  167. package/dist/server/handlers/voice.d.ts +39 -3
  168. package/dist/server/handlers/voice.d.ts.map +1 -0
  169. package/dist/server/handlers/voice.js +3 -1
  170. package/dist/server/handlers/voice.js.map +1 -0
  171. package/dist/server/handlers/workflows.cjs +35 -13
  172. package/dist/server/handlers/workflows.cjs.map +1 -0
  173. package/dist/server/handlers/workflows.d.ts +88 -10
  174. package/dist/server/handlers/workflows.d.ts.map +1 -0
  175. package/dist/server/handlers/workflows.js +3 -1
  176. package/dist/server/handlers/workflows.js.map +1 -0
  177. package/dist/server/handlers.cjs +42 -30
  178. package/dist/server/handlers.cjs.map +1 -0
  179. package/dist/server/handlers.d.ts +13 -10
  180. package/dist/server/handlers.d.ts.map +1 -0
  181. package/dist/server/handlers.js +14 -10
  182. package/dist/server/handlers.js.map +1 -0
  183. package/dist/server/http-exception.d.ts +87 -0
  184. package/dist/server/http-exception.d.ts.map +1 -0
  185. package/dist/server/types.d.ts +10 -0
  186. package/dist/server/types.d.ts.map +1 -0
  187. package/package.json +31 -18
  188. package/dist/_tsup-dts-rollup.d.cts +0 -748
  189. package/dist/_tsup-dts-rollup.d.ts +0 -748
  190. package/dist/chunk-2FJURXCL.cjs +0 -213
  191. package/dist/chunk-3AHQ5RGN.js +0 -11
  192. package/dist/chunk-3EJZQ6TQ.js +0 -49
  193. package/dist/chunk-4BIX6GMY.cjs +0 -189
  194. package/dist/chunk-55HTWX4C.cjs +0 -93
  195. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  196. package/dist/chunk-74DLDQTQ.cjs +0 -36
  197. package/dist/chunk-CHFORQ7J.cjs +0 -329
  198. package/dist/chunk-FOXHTOQZ.cjs +0 -324
  199. package/dist/chunk-HAA5T7JL.js +0 -33
  200. package/dist/chunk-IQTNZSFP.js +0 -312
  201. package/dist/chunk-OMN3UI6X.js +0 -5576
  202. package/dist/chunk-RBQASTUP.js +0 -203
  203. package/dist/chunk-SKBVVI24.cjs +0 -54
  204. package/dist/chunk-Y3SV5XK4.js +0 -181
  205. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  206. package/dist/index.d.cts +0 -2
  207. package/dist/server/handlers/agents.d.cts +0 -6
  208. package/dist/server/handlers/error.d.cts +0 -1
  209. package/dist/server/handlers/logs.d.cts +0 -3
  210. package/dist/server/handlers/mcp.cjs +0 -14
  211. package/dist/server/handlers/mcp.d.cts +0 -2
  212. package/dist/server/handlers/mcp.d.ts +0 -2
  213. package/dist/server/handlers/mcp.js +0 -1
  214. package/dist/server/handlers/memory.d.cts +0 -8
  215. package/dist/server/handlers/network.d.cts +0 -4
  216. package/dist/server/handlers/telemetry.d.cts +0 -2
  217. package/dist/server/handlers/tools.d.cts +0 -4
  218. package/dist/server/handlers/utils.d.cts +0 -1
  219. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  220. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  221. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  222. package/dist/server/handlers/vNextWorkflows.js +0 -1
  223. package/dist/server/handlers/vector.d.cts +0 -6
  224. package/dist/server/handlers/voice.d.cts +0 -3
  225. package/dist/server/handlers/workflows.d.cts +0 -10
  226. package/dist/server/handlers.d.cts +0 -10
@@ -1,33 +0,0 @@
1
- import { HTTPException } from './chunk-TRDNDNGQ.js';
2
-
3
- // src/server/handlers/mcp.ts
4
- var getMcpServersHandler = async ({ mastra }) => {
5
- const servers = mastra.getMCPServers();
6
- return {
7
- servers: servers.map((server) => ({
8
- id: server.name,
9
- name: server.name,
10
- version: server.version,
11
- tools: Object.keys(server.tools()).length
12
- }))
13
- };
14
- };
15
- var getMcpServerHandler = async ({ mastra, serverId }) => {
16
- const server = mastra.getMCPServer(serverId);
17
- if (!server) {
18
- throw new HTTPException(404, { message: `MCP server '${serverId}' not found` });
19
- }
20
- const tools = server.tools();
21
- return {
22
- id: server.name,
23
- name: server.name,
24
- version: server.version,
25
- tools: Object.entries(tools).map(([name, tool]) => ({
26
- name,
27
- description: tool.description,
28
- parameters: tool.parameters
29
- }))
30
- };
31
- };
32
-
33
- export { getMcpServerHandler, getMcpServersHandler };
@@ -1,312 +0,0 @@
1
- import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
4
- import { ReadableStream } from 'node:stream/web';
5
-
6
- // src/server/handlers/vNextWorkflows.ts
7
- var vNextWorkflows_exports = {};
8
- __export(vNextWorkflows_exports, {
9
- createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
10
- getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
11
- getVNextWorkflowRunHandler: () => getVNextWorkflowRunHandler,
12
- getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
13
- getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
14
- resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
15
- resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
16
- startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
17
- startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
18
- watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
19
- });
20
- async function getVNextWorkflowsHandler({ mastra }) {
21
- try {
22
- const workflows = mastra.vnext_getWorkflows({ serialized: false });
23
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
24
- acc[key] = {
25
- name: workflow.name,
26
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
27
- acc2[key2] = {
28
- id: step.id,
29
- description: step.description,
30
- inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
31
- outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
32
- resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
33
- suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
34
- };
35
- return acc2;
36
- }, {}),
37
- stepGraph: workflow.serializedStepGraph,
38
- inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
39
- outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
40
- };
41
- return acc;
42
- }, {});
43
- return _workflows;
44
- } catch (error) {
45
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
46
- }
47
- }
48
- async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
49
- try {
50
- if (!workflowId) {
51
- throw new HTTPException(400, { message: "Workflow ID is required" });
52
- }
53
- const workflow = mastra.vnext_getWorkflow(workflowId);
54
- if (!workflow) {
55
- throw new HTTPException(404, { message: "Workflow not found" });
56
- }
57
- return {
58
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
59
- acc[key] = {
60
- id: step.id,
61
- description: step.description,
62
- inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
63
- outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
64
- resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
65
- suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0
66
- };
67
- return acc;
68
- }, {}),
69
- name: workflow.name,
70
- stepGraph: workflow.serializedStepGraph,
71
- inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
72
- outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
73
- };
74
- } catch (error) {
75
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
76
- }
77
- }
78
- async function getVNextWorkflowRunHandler({
79
- mastra,
80
- workflowId,
81
- runId
82
- }) {
83
- try {
84
- if (!workflowId) {
85
- throw new HTTPException(400, { message: "Workflow ID is required" });
86
- }
87
- if (!runId) {
88
- throw new HTTPException(400, { message: "Run ID is required" });
89
- }
90
- const workflow = mastra.vnext_getWorkflow(workflowId);
91
- if (!workflow) {
92
- throw new HTTPException(404, { message: "Workflow not found" });
93
- }
94
- const run = await workflow.getWorkflowRun(runId);
95
- if (!run) {
96
- throw new HTTPException(404, { message: "Workflow run not found" });
97
- }
98
- return run;
99
- } catch (error) {
100
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
101
- }
102
- }
103
- async function createVNextWorkflowRunHandler({
104
- mastra,
105
- workflowId,
106
- runId: prevRunId
107
- }) {
108
- try {
109
- if (!workflowId) {
110
- throw new HTTPException(400, { message: "Workflow ID is required" });
111
- }
112
- const workflow = mastra.vnext_getWorkflow(workflowId);
113
- if (!workflow) {
114
- throw new HTTPException(404, { message: "Workflow not found" });
115
- }
116
- const run = workflow.createRun({ runId: prevRunId });
117
- return { runId: run.runId };
118
- } catch (error) {
119
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
120
- }
121
- }
122
- async function startAsyncVNextWorkflowHandler({
123
- mastra,
124
- runtimeContext,
125
- workflowId,
126
- runId,
127
- inputData
128
- }) {
129
- try {
130
- if (!workflowId) {
131
- throw new HTTPException(400, { message: "Workflow ID is required" });
132
- }
133
- const workflow = mastra.vnext_getWorkflow(workflowId);
134
- if (!workflow) {
135
- throw new HTTPException(404, { message: "Workflow not found" });
136
- }
137
- const _run = workflow.createRun({ runId });
138
- const result = await _run.start({
139
- inputData,
140
- runtimeContext
141
- });
142
- return result;
143
- } catch (error) {
144
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
145
- }
146
- }
147
- async function startVNextWorkflowRunHandler({
148
- mastra,
149
- runtimeContext,
150
- workflowId,
151
- runId,
152
- inputData
153
- }) {
154
- try {
155
- if (!workflowId) {
156
- throw new HTTPException(400, { message: "Workflow ID is required" });
157
- }
158
- if (!runId) {
159
- throw new HTTPException(400, { message: "runId required to start run" });
160
- }
161
- const workflow = mastra.vnext_getWorkflow(workflowId);
162
- const run = await workflow.getWorkflowRun(runId);
163
- if (!run) {
164
- throw new HTTPException(404, { message: "Workflow run not found" });
165
- }
166
- const _run = workflow.createRun({ runId });
167
- await _run.start({
168
- inputData,
169
- runtimeContext
170
- });
171
- return { message: "Workflow run started" };
172
- } catch (e) {
173
- return handleError(e, "Error starting workflow run");
174
- }
175
- }
176
- async function watchVNextWorkflowHandler({
177
- mastra,
178
- workflowId,
179
- runId
180
- }) {
181
- try {
182
- if (!workflowId) {
183
- throw new HTTPException(400, { message: "Workflow ID is required" });
184
- }
185
- if (!runId) {
186
- throw new HTTPException(400, { message: "runId required to watch workflow" });
187
- }
188
- const workflow = mastra.vnext_getWorkflow(workflowId);
189
- const run = await workflow.getWorkflowRun(runId);
190
- if (!run) {
191
- throw new HTTPException(404, { message: "Workflow run not found" });
192
- }
193
- const _run = workflow.createRun({ runId });
194
- let unwatch;
195
- let asyncRef = null;
196
- const stream = new ReadableStream({
197
- start(controller) {
198
- unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
199
- controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
200
- if (asyncRef) {
201
- clearImmediate(asyncRef);
202
- asyncRef = null;
203
- }
204
- asyncRef = setImmediate(async () => {
205
- const runDone = payload.workflowState.status !== "running";
206
- if (runDone) {
207
- controller.close();
208
- unwatch?.();
209
- }
210
- });
211
- });
212
- },
213
- cancel() {
214
- unwatch?.();
215
- }
216
- });
217
- return stream;
218
- } catch (error) {
219
- return handleError(error, "Error watching workflow");
220
- }
221
- }
222
- async function resumeAsyncVNextWorkflowHandler({
223
- mastra,
224
- workflowId,
225
- runId,
226
- body,
227
- runtimeContext
228
- }) {
229
- try {
230
- if (!workflowId) {
231
- throw new HTTPException(400, { message: "Workflow ID is required" });
232
- }
233
- if (!runId) {
234
- throw new HTTPException(400, { message: "runId required to resume workflow" });
235
- }
236
- if (!body.step) {
237
- throw new HTTPException(400, { message: "step required to resume workflow" });
238
- }
239
- const workflow = mastra.vnext_getWorkflow(workflowId);
240
- const run = await workflow.getWorkflowRun(runId);
241
- if (!run) {
242
- throw new HTTPException(404, { message: "Workflow run not found" });
243
- }
244
- const _run = workflow.createRun({ runId });
245
- const result = await _run.resume({
246
- step: body.step,
247
- resumeData: body.resumeData,
248
- runtimeContext
249
- });
250
- return result;
251
- } catch (error) {
252
- return handleError(error, "Error resuming workflow step");
253
- }
254
- }
255
- async function resumeVNextWorkflowHandler({
256
- mastra,
257
- workflowId,
258
- runId,
259
- body,
260
- runtimeContext
261
- }) {
262
- try {
263
- if (!workflowId) {
264
- throw new HTTPException(400, { message: "Workflow ID is required" });
265
- }
266
- if (!runId) {
267
- throw new HTTPException(400, { message: "runId required to resume workflow" });
268
- }
269
- if (!body.step) {
270
- throw new HTTPException(400, { message: "step required to resume workflow" });
271
- }
272
- const workflow = mastra.vnext_getWorkflow(workflowId);
273
- const run = await workflow.getWorkflowRun(runId);
274
- if (!run) {
275
- throw new HTTPException(404, { message: "Workflow run not found" });
276
- }
277
- const _run = workflow.createRun({ runId });
278
- await _run.resume({
279
- step: body.step,
280
- resumeData: body.resumeData,
281
- runtimeContext
282
- });
283
- return { message: "Workflow run resumed" };
284
- } catch (error) {
285
- return handleError(error, "Error resuming workflow");
286
- }
287
- }
288
- async function getVNextWorkflowRunsHandler({
289
- mastra,
290
- workflowId,
291
- fromDate,
292
- toDate,
293
- limit,
294
- offset,
295
- resourceId
296
- }) {
297
- try {
298
- if (!workflowId) {
299
- throw new HTTPException(400, { message: "Workflow ID is required" });
300
- }
301
- const workflow = mastra.vnext_getWorkflow(workflowId);
302
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
303
- runs: [],
304
- total: 0
305
- };
306
- return workflowRuns;
307
- } catch (error) {
308
- return handleError(error, "Error getting workflow runs");
309
- }
310
- }
311
-
312
- export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, vNextWorkflows_exports, watchVNextWorkflowHandler };