@mastra/server 0.0.0-vector-sources-20250516175436 → 0.0.0-vector-query-tool-provider-options-20250828222356

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 (234) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/{chunk-5SN4U5AC.cjs → chunk-3THIIWWW.cjs} +113 -137
  3. package/dist/chunk-3THIIWWW.cjs.map +1 -0
  4. package/dist/{chunk-57CJTIPW.cjs → chunk-4QSNRCOT.cjs} +4 -2
  5. package/dist/chunk-4QSNRCOT.cjs.map +1 -0
  6. package/dist/{chunk-P6SCPDYW.js → chunk-5QUKZCEF.js} +112 -136
  7. package/dist/chunk-5QUKZCEF.js.map +1 -0
  8. package/dist/{chunk-OCWPVYNI.cjs → chunk-7NADHFD2.cjs} +3 -0
  9. package/dist/chunk-7NADHFD2.cjs.map +1 -0
  10. package/dist/chunk-7QEJ5QG5.js +151 -0
  11. package/dist/chunk-7QEJ5QG5.js.map +1 -0
  12. package/dist/{chunk-ZE5AAC4I.cjs → chunk-A3FNPSBB.cjs} +36 -39
  13. package/dist/chunk-A3FNPSBB.cjs.map +1 -0
  14. package/dist/{chunk-MHKNLNAN.cjs → chunk-B2L53BNJ.cjs} +14 -9
  15. package/dist/chunk-B2L53BNJ.cjs.map +1 -0
  16. package/dist/{chunk-C7564HUT.js → chunk-B43YAQJR.js} +6 -4
  17. package/dist/chunk-B43YAQJR.js.map +1 -0
  18. package/dist/{chunk-TJKLBTFB.js → chunk-BUMPRH7R.js} +23 -26
  19. package/dist/chunk-BUMPRH7R.js.map +1 -0
  20. package/dist/chunk-CY4TP3FK.js +16 -0
  21. package/dist/chunk-CY4TP3FK.js.map +1 -0
  22. package/dist/chunk-D32MNBNS.js +17597 -0
  23. package/dist/chunk-D32MNBNS.js.map +1 -0
  24. package/dist/chunk-EMMSS5I5.cjs +37 -0
  25. package/dist/chunk-EMMSS5I5.cjs.map +1 -0
  26. package/dist/chunk-G3PMV62Z.js +33 -0
  27. package/dist/chunk-G3PMV62Z.js.map +1 -0
  28. package/dist/chunk-GU4EWMZB.cjs +769 -0
  29. package/dist/chunk-GU4EWMZB.cjs.map +1 -0
  30. package/dist/chunk-GUI3CROV.cjs +159 -0
  31. package/dist/chunk-GUI3CROV.cjs.map +1 -0
  32. package/dist/chunk-ID37OH5Z.js +517 -0
  33. package/dist/chunk-ID37OH5Z.js.map +1 -0
  34. package/dist/{chunk-VPNDC2DI.cjs → chunk-JGD42NME.cjs} +16 -14
  35. package/dist/chunk-JGD42NME.cjs.map +1 -0
  36. package/dist/chunk-JPY7GWFC.cjs +17614 -0
  37. package/dist/chunk-JPY7GWFC.cjs.map +1 -0
  38. package/dist/chunk-KLCYAQBL.cjs +120 -0
  39. package/dist/chunk-KLCYAQBL.cjs.map +1 -0
  40. package/dist/chunk-KNGXRN26.cjs +335 -0
  41. package/dist/chunk-KNGXRN26.cjs.map +1 -0
  42. package/dist/chunk-L265APUD.cjs +69 -0
  43. package/dist/chunk-L265APUD.cjs.map +1 -0
  44. package/dist/chunk-LF2ZLOFP.js +767 -0
  45. package/dist/chunk-LF2ZLOFP.js.map +1 -0
  46. package/dist/chunk-LUPY3MQY.js +571 -0
  47. package/dist/chunk-LUPY3MQY.js.map +1 -0
  48. package/dist/{chunk-NYN7KFXL.js → chunk-MMROOK5J.js} +3 -0
  49. package/dist/chunk-MMROOK5J.js.map +1 -0
  50. package/dist/chunk-NPE3X7FQ.cjs +88 -0
  51. package/dist/chunk-NPE3X7FQ.cjs.map +1 -0
  52. package/dist/{chunk-H5PTF3Y4.js → chunk-OW4FX5TS.js} +3 -1
  53. package/dist/chunk-OW4FX5TS.js.map +1 -0
  54. package/dist/{chunk-OR3CIE2H.js → chunk-PHZHWQZP.js} +10 -5
  55. package/dist/chunk-PHZHWQZP.js.map +1 -0
  56. package/dist/{chunk-HFWCEP5S.js → chunk-QBWF6U7Z.js} +36 -11
  57. package/dist/chunk-QBWF6U7Z.js.map +1 -0
  58. package/dist/chunk-R7NOGUZG.js +65 -0
  59. package/dist/chunk-R7NOGUZG.js.map +1 -0
  60. package/dist/chunk-RE4RPXT2.cjs +18 -0
  61. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  62. package/dist/chunk-ROA7BCHD.js +83 -0
  63. package/dist/chunk-ROA7BCHD.js.map +1 -0
  64. package/dist/{chunk-BNEY4P4P.cjs → chunk-T3TIA3O6.cjs} +20 -18
  65. package/dist/chunk-T3TIA3O6.cjs.map +1 -0
  66. package/dist/{chunk-EJO45KYT.js → chunk-TTHEEIZ3.js} +53 -50
  67. package/dist/chunk-TTHEEIZ3.js.map +1 -0
  68. package/dist/chunk-UVKXRPMV.cjs +588 -0
  69. package/dist/chunk-UVKXRPMV.cjs.map +1 -0
  70. package/dist/chunk-V5EWBGBF.cjs +534 -0
  71. package/dist/chunk-V5EWBGBF.cjs.map +1 -0
  72. package/dist/{chunk-55DOQLP6.js → chunk-WHN4VX55.js} +5 -3
  73. package/dist/chunk-WHN4VX55.js.map +1 -0
  74. package/dist/index.cjs +2 -0
  75. package/dist/index.cjs.map +1 -0
  76. package/dist/index.d.ts +1 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +2 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/server/a2a/protocol.d.ts +8 -0
  81. package/dist/server/a2a/protocol.d.ts.map +1 -0
  82. package/dist/server/a2a/store.cjs +25 -0
  83. package/dist/server/a2a/store.cjs.map +1 -0
  84. package/dist/server/a2a/store.d.ts +14 -0
  85. package/dist/server/a2a/store.d.ts.map +1 -0
  86. package/dist/server/a2a/store.js +23 -0
  87. package/dist/server/a2a/store.js.map +1 -0
  88. package/dist/server/a2a/tasks.d.ts +20 -0
  89. package/dist/server/a2a/tasks.d.ts.map +1 -0
  90. package/dist/server/handlers/a2a.cjs +13 -11
  91. package/dist/server/handlers/a2a.cjs.map +1 -0
  92. package/dist/server/handlers/a2a.d.ts +68 -6
  93. package/dist/server/handlers/a2a.d.ts.map +1 -0
  94. package/dist/server/handlers/a2a.js +3 -1
  95. package/dist/server/handlers/a2a.js.map +1 -0
  96. package/dist/server/handlers/agents.cjs +29 -7
  97. package/dist/server/handlers/agents.cjs.map +1 -0
  98. package/dist/server/handlers/agents.d.ts +111 -6
  99. package/dist/server/handlers/agents.d.ts.map +1 -0
  100. package/dist/server/handlers/agents.js +3 -1
  101. package/dist/server/handlers/agents.js.map +1 -0
  102. package/dist/server/handlers/error.cjs +4 -2
  103. package/dist/server/handlers/error.cjs.map +1 -0
  104. package/dist/server/handlers/error.d.ts +2 -1
  105. package/dist/server/handlers/error.d.ts.map +1 -0
  106. package/dist/server/handlers/error.js +3 -1
  107. package/dist/server/handlers/error.js.map +1 -0
  108. package/dist/server/handlers/legacyWorkflows.cjs +48 -0
  109. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  110. package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
  111. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  112. package/dist/server/handlers/legacyWorkflows.js +3 -0
  113. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  114. package/dist/server/handlers/logs.cjs +6 -4
  115. package/dist/server/handlers/logs.cjs.map +1 -0
  116. package/dist/server/handlers/logs.d.ts +34 -3
  117. package/dist/server/handlers/logs.d.ts.map +1 -0
  118. package/dist/server/handlers/logs.js +3 -1
  119. package/dist/server/handlers/logs.js.map +1 -0
  120. package/dist/server/handlers/memory.cjs +39 -9
  121. package/dist/server/handlers/memory.cjs.map +1 -0
  122. package/dist/server/handlers/memory.d.ts +118 -8
  123. package/dist/server/handlers/memory.d.ts.map +1 -0
  124. package/dist/server/handlers/memory.js +3 -1
  125. package/dist/server/handlers/memory.js.map +1 -0
  126. package/dist/server/handlers/network.cjs +7 -5
  127. package/dist/server/handlers/network.cjs.map +1 -0
  128. package/dist/server/handlers/network.d.ts +50 -4
  129. package/dist/server/handlers/network.d.ts.map +1 -0
  130. package/dist/server/handlers/network.js +3 -1
  131. package/dist/server/handlers/network.js.map +1 -0
  132. package/dist/server/handlers/observability.cjs +16 -0
  133. package/dist/server/handlers/observability.cjs.map +1 -0
  134. package/dist/server/handlers/observability.d.ts +23 -0
  135. package/dist/server/handlers/observability.d.ts.map +1 -0
  136. package/dist/server/handlers/observability.js +3 -0
  137. package/dist/server/handlers/observability.js.map +1 -0
  138. package/dist/server/handlers/scores.cjs +32 -0
  139. package/dist/server/handlers/scores.cjs.map +1 -0
  140. package/dist/server/handlers/scores.d.ts +49 -0
  141. package/dist/server/handlers/scores.d.ts.map +1 -0
  142. package/dist/server/handlers/scores.js +3 -0
  143. package/dist/server/handlers/scores.js.map +1 -0
  144. package/dist/server/handlers/telemetry.cjs +5 -3
  145. package/dist/server/handlers/telemetry.cjs.map +1 -0
  146. package/dist/server/handlers/telemetry.d.ts +32 -2
  147. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  148. package/dist/server/handlers/telemetry.js +3 -1
  149. package/dist/server/handlers/telemetry.js.map +1 -0
  150. package/dist/server/handlers/tools.cjs +7 -5
  151. package/dist/server/handlers/tools.cjs.map +1 -0
  152. package/dist/server/handlers/tools.d.ts +21 -4
  153. package/dist/server/handlers/tools.d.ts.map +1 -0
  154. package/dist/server/handlers/tools.js +3 -1
  155. package/dist/server/handlers/tools.js.map +1 -0
  156. package/dist/server/handlers/utils.cjs +4 -2
  157. package/dist/server/handlers/utils.cjs.map +1 -0
  158. package/dist/server/handlers/utils.d.ts +2 -1
  159. package/dist/server/handlers/utils.d.ts.map +1 -0
  160. package/dist/server/handlers/utils.js +3 -1
  161. package/dist/server/handlers/utils.js.map +1 -0
  162. package/dist/server/handlers/vNextNetwork.cjs +220 -0
  163. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  164. package/dist/server/handlers/vNextNetwork.d.ts +179 -0
  165. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  166. package/dist/server/handlers/vNextNetwork.js +213 -0
  167. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  168. package/dist/server/handlers/vector.cjs +9 -7
  169. package/dist/server/handlers/vector.cjs.map +1 -0
  170. package/dist/server/handlers/vector.d.ts +51 -6
  171. package/dist/server/handlers/vector.d.ts.map +1 -0
  172. package/dist/server/handlers/vector.js +3 -1
  173. package/dist/server/handlers/vector.js.map +1 -0
  174. package/dist/server/handlers/voice.cjs +10 -4
  175. package/dist/server/handlers/voice.cjs.map +1 -0
  176. package/dist/server/handlers/voice.d.ts +39 -3
  177. package/dist/server/handlers/voice.d.ts.map +1 -0
  178. package/dist/server/handlers/voice.js +3 -1
  179. package/dist/server/handlers/voice.js.map +1 -0
  180. package/dist/server/handlers/workflows.cjs +35 -13
  181. package/dist/server/handlers/workflows.cjs.map +1 -0
  182. package/dist/server/handlers/workflows.d.ts +72 -10
  183. package/dist/server/handlers/workflows.d.ts.map +1 -0
  184. package/dist/server/handlers/workflows.js +3 -1
  185. package/dist/server/handlers/workflows.js.map +1 -0
  186. package/dist/server/handlers.cjs +45 -33
  187. package/dist/server/handlers.cjs.map +1 -0
  188. package/dist/server/handlers.d.ts +14 -11
  189. package/dist/server/handlers.d.ts.map +1 -0
  190. package/dist/server/handlers.js +15 -11
  191. package/dist/server/handlers.js.map +1 -0
  192. package/dist/server/http-exception.d.ts +87 -0
  193. package/dist/server/http-exception.d.ts.map +1 -0
  194. package/dist/server/types.d.ts +10 -0
  195. package/dist/server/types.d.ts.map +1 -0
  196. package/dist/server/utils.d.ts +3 -0
  197. package/dist/server/utils.d.ts.map +1 -0
  198. package/package.json +39 -20
  199. package/dist/_tsup-dts-rollup.d.cts +0 -816
  200. package/dist/_tsup-dts-rollup.d.ts +0 -816
  201. package/dist/chunk-64U3UDTH.cjs +0 -13
  202. package/dist/chunk-75ZPJI57.cjs +0 -9
  203. package/dist/chunk-D4IRYCUI.cjs +0 -235
  204. package/dist/chunk-DJJIUEL2.js +0 -211
  205. package/dist/chunk-HWZVAG3H.js +0 -49
  206. package/dist/chunk-I2B73Y4I.cjs +0 -332
  207. package/dist/chunk-LIVAK2DM.js +0 -2001
  208. package/dist/chunk-M5ABIP7D.js +0 -11
  209. package/dist/chunk-MIQYDLLM.js +0 -329
  210. package/dist/chunk-MLKGABMK.js +0 -7
  211. package/dist/chunk-OGCNNUHF.cjs +0 -54
  212. package/dist/chunk-UCTEMO2Q.cjs +0 -341
  213. package/dist/chunk-WUC6LSTW.js +0 -227
  214. package/dist/chunk-Y7UWRW5X.cjs +0 -221
  215. package/dist/chunk-YBVOQN4M.cjs +0 -94
  216. package/dist/chunk-YWLUOY3D.cjs +0 -2004
  217. package/dist/index.d.cts +0 -1
  218. package/dist/server/handlers/a2a.d.cts +0 -6
  219. package/dist/server/handlers/agents.d.cts +0 -6
  220. package/dist/server/handlers/error.d.cts +0 -1
  221. package/dist/server/handlers/logs.d.cts +0 -3
  222. package/dist/server/handlers/memory.d.cts +0 -8
  223. package/dist/server/handlers/network.d.cts +0 -4
  224. package/dist/server/handlers/telemetry.d.cts +0 -2
  225. package/dist/server/handlers/tools.d.cts +0 -4
  226. package/dist/server/handlers/utils.d.cts +0 -1
  227. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  228. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  229. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  230. package/dist/server/handlers/vNextWorkflows.js +0 -1
  231. package/dist/server/handlers/vector.d.cts +0 -6
  232. package/dist/server/handlers/voice.d.cts +0 -3
  233. package/dist/server/handlers/workflows.d.cts +0 -10
  234. package/dist/server/handlers.d.cts +0 -11
@@ -0,0 +1,534 @@
1
+ 'use strict';
2
+
3
+ var chunkGU4EWMZB_cjs = require('./chunk-GU4EWMZB.cjs');
4
+ var chunkRE4RPXT2_cjs = require('./chunk-RE4RPXT2.cjs');
5
+ var chunk7NADHFD2_cjs = require('./chunk-7NADHFD2.cjs');
6
+ var chunkEMMSS5I5_cjs = require('./chunk-EMMSS5I5.cjs');
7
+ var web = require('stream/web');
8
+ var zodToJson = require('@mastra/core/utils/zod-to-json');
9
+
10
+ // src/server/handlers/workflows.ts
11
+ var workflows_exports = {};
12
+ chunkEMMSS5I5_cjs.__export(workflows_exports, {
13
+ cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
14
+ createWorkflowRunHandler: () => createWorkflowRunHandler,
15
+ getWorkflowByIdHandler: () => getWorkflowByIdHandler,
16
+ getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
17
+ getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
18
+ getWorkflowRunsHandler: () => getWorkflowRunsHandler,
19
+ getWorkflowsHandler: () => getWorkflowsHandler,
20
+ resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
21
+ resumeWorkflowHandler: () => resumeWorkflowHandler,
22
+ sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
23
+ startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
24
+ startWorkflowRunHandler: () => startWorkflowRunHandler,
25
+ streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
26
+ streamWorkflowHandler: () => streamWorkflowHandler,
27
+ watchWorkflowHandler: () => watchWorkflowHandler
28
+ });
29
+ function getSteps(steps, path) {
30
+ return Object.entries(steps).reduce((acc, [key, step]) => {
31
+ const fullKey = path ? `${path}.${key}` : key;
32
+ acc[fullKey] = {
33
+ id: step.id,
34
+ description: step.description,
35
+ inputSchema: step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.inputSchema)) : void 0,
36
+ outputSchema: step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.outputSchema)) : void 0,
37
+ resumeSchema: step.resumeSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.resumeSchema)) : void 0,
38
+ suspendSchema: step.suspendSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.suspendSchema)) : void 0,
39
+ isWorkflow: step.component === "WORKFLOW"
40
+ };
41
+ if (step.component === "WORKFLOW" && step.steps) {
42
+ const nestedSteps = getSteps(step.steps, fullKey) || {};
43
+ acc = { ...acc, ...nestedSteps };
44
+ }
45
+ return acc;
46
+ }, {});
47
+ }
48
+ function getWorkflowInfo(workflow) {
49
+ return {
50
+ name: workflow.name,
51
+ description: workflow.description,
52
+ steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
53
+ acc[key] = {
54
+ id: step.id,
55
+ description: step.description,
56
+ inputSchema: step.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.inputSchema)) : void 0,
57
+ outputSchema: step.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.outputSchema)) : void 0,
58
+ resumeSchema: step.resumeSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.resumeSchema)) : void 0,
59
+ suspendSchema: step.suspendSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(step.suspendSchema)) : void 0
60
+ };
61
+ return acc;
62
+ }, {}),
63
+ allSteps: getSteps(workflow.steps) || {},
64
+ stepGraph: workflow.serializedStepGraph,
65
+ inputSchema: workflow.inputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.inputSchema)) : void 0,
66
+ outputSchema: workflow.outputSchema ? chunkGU4EWMZB_cjs.stringify(zodToJson.zodToJsonSchema(workflow.outputSchema)) : void 0
67
+ };
68
+ }
69
+
70
+ // src/server/handlers/workflows.ts
71
+ async function getWorkflowsHandler({ mastra }) {
72
+ try {
73
+ const workflows = mastra.getWorkflows({ serialized: false });
74
+ const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
75
+ acc[key] = getWorkflowInfo(workflow);
76
+ return acc;
77
+ }, {});
78
+ return _workflows;
79
+ } catch (error) {
80
+ return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflows");
81
+ }
82
+ }
83
+ async function getWorkflowsFromSystem({ mastra, workflowId }) {
84
+ const logger = mastra.getLogger();
85
+ if (!workflowId) {
86
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
87
+ }
88
+ let workflow;
89
+ try {
90
+ workflow = mastra.getWorkflow(workflowId);
91
+ } catch (error) {
92
+ logger.debug("Error getting workflow, searching agents for workflow", error);
93
+ }
94
+ if (!workflow) {
95
+ logger.debug("Workflow not found, searching agents for workflow", { workflowId });
96
+ const agents = mastra.getAgents();
97
+ if (Object.keys(agents || {}).length) {
98
+ for (const [_, agent] of Object.entries(agents)) {
99
+ try {
100
+ const workflows = await agent.getWorkflows();
101
+ if (workflows[workflowId]) {
102
+ workflow = workflows[workflowId];
103
+ break;
104
+ }
105
+ break;
106
+ } catch (error) {
107
+ logger.debug("Error getting workflow from agent", error);
108
+ }
109
+ }
110
+ }
111
+ }
112
+ if (!workflow) {
113
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
114
+ }
115
+ return { workflow };
116
+ }
117
+ async function getWorkflowByIdHandler({ mastra, workflowId }) {
118
+ try {
119
+ if (!workflowId) {
120
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
121
+ }
122
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
123
+ if (!workflow) {
124
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
125
+ }
126
+ return getWorkflowInfo(workflow);
127
+ } catch (error) {
128
+ return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow");
129
+ }
130
+ }
131
+ async function getWorkflowRunByIdHandler({
132
+ mastra,
133
+ workflowId,
134
+ runId
135
+ }) {
136
+ try {
137
+ if (!workflowId) {
138
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
139
+ }
140
+ if (!runId) {
141
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
142
+ }
143
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
144
+ if (!workflow) {
145
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
146
+ }
147
+ const run = await workflow.getWorkflowRunById(runId);
148
+ if (!run) {
149
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
150
+ }
151
+ return run;
152
+ } catch (error) {
153
+ return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow run");
154
+ }
155
+ }
156
+ async function getWorkflowRunExecutionResultHandler({
157
+ mastra,
158
+ workflowId,
159
+ runId
160
+ }) {
161
+ try {
162
+ if (!workflowId) {
163
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
164
+ }
165
+ if (!runId) {
166
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Run ID is required" });
167
+ }
168
+ const workflow = mastra.getWorkflow(workflowId);
169
+ if (!workflow) {
170
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
171
+ }
172
+ const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
173
+ if (!executionResult) {
174
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
175
+ }
176
+ return executionResult;
177
+ } catch (error) {
178
+ return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow run execution result");
179
+ }
180
+ }
181
+ async function createWorkflowRunHandler({
182
+ mastra,
183
+ workflowId,
184
+ runId: prevRunId
185
+ }) {
186
+ try {
187
+ if (!workflowId) {
188
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
189
+ }
190
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
191
+ if (!workflow) {
192
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
193
+ }
194
+ const run = await workflow.createRunAsync({ runId: prevRunId });
195
+ return { runId: run.runId };
196
+ } catch (error) {
197
+ return chunkRE4RPXT2_cjs.handleError(error, "Error creating workflow run");
198
+ }
199
+ }
200
+ async function startAsyncWorkflowHandler({
201
+ mastra,
202
+ runtimeContext,
203
+ workflowId,
204
+ runId,
205
+ inputData
206
+ }) {
207
+ try {
208
+ if (!workflowId) {
209
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
210
+ }
211
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
212
+ if (!workflow) {
213
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
214
+ }
215
+ const _run = await workflow.createRunAsync({ runId });
216
+ const result = await _run.start({
217
+ inputData,
218
+ runtimeContext
219
+ });
220
+ return result;
221
+ } catch (error) {
222
+ return chunkRE4RPXT2_cjs.handleError(error, "Error starting async workflow");
223
+ }
224
+ }
225
+ async function startWorkflowRunHandler({
226
+ mastra,
227
+ runtimeContext,
228
+ workflowId,
229
+ runId,
230
+ inputData
231
+ }) {
232
+ try {
233
+ if (!workflowId) {
234
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
235
+ }
236
+ if (!runId) {
237
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to start run" });
238
+ }
239
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
240
+ if (!workflow) {
241
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
242
+ }
243
+ const run = await workflow.getWorkflowRunById(runId);
244
+ if (!run) {
245
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
246
+ }
247
+ const _run = await workflow.createRunAsync({ runId });
248
+ void _run.start({
249
+ inputData,
250
+ runtimeContext
251
+ });
252
+ return { message: "Workflow run started" };
253
+ } catch (e) {
254
+ return chunkRE4RPXT2_cjs.handleError(e, "Error starting workflow run");
255
+ }
256
+ }
257
+ async function watchWorkflowHandler({
258
+ mastra,
259
+ workflowId,
260
+ runId
261
+ }) {
262
+ try {
263
+ if (!workflowId) {
264
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
265
+ }
266
+ if (!runId) {
267
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to watch workflow" });
268
+ }
269
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
270
+ if (!workflow) {
271
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
272
+ }
273
+ const run = await workflow.getWorkflowRunById(runId);
274
+ if (!run) {
275
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
276
+ }
277
+ const _run = await workflow.createRunAsync({ runId });
278
+ let unwatch;
279
+ let asyncRef = null;
280
+ const stream = new web.ReadableStream({
281
+ start(controller) {
282
+ unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
283
+ controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
284
+ if (asyncRef) {
285
+ clearImmediate(asyncRef);
286
+ asyncRef = null;
287
+ }
288
+ asyncRef = setImmediate(async () => {
289
+ const runDone = payload.workflowState.status !== "running";
290
+ if (runDone) {
291
+ controller.close();
292
+ unwatch?.();
293
+ }
294
+ });
295
+ });
296
+ },
297
+ cancel() {
298
+ unwatch?.();
299
+ }
300
+ });
301
+ return stream;
302
+ } catch (error) {
303
+ return chunkRE4RPXT2_cjs.handleError(error, "Error watching workflow");
304
+ }
305
+ }
306
+ async function streamWorkflowHandler({
307
+ mastra,
308
+ runtimeContext,
309
+ workflowId,
310
+ runId,
311
+ inputData
312
+ }) {
313
+ try {
314
+ if (!workflowId) {
315
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
316
+ }
317
+ if (!runId) {
318
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
319
+ }
320
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
321
+ if (!workflow) {
322
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
323
+ }
324
+ const run = await workflow.createRunAsync({ runId });
325
+ const result = run.stream({
326
+ inputData,
327
+ runtimeContext
328
+ });
329
+ return result;
330
+ } catch (error) {
331
+ return chunkRE4RPXT2_cjs.handleError(error, "Error executing workflow");
332
+ }
333
+ }
334
+ async function streamVNextWorkflowHandler({
335
+ mastra,
336
+ runtimeContext,
337
+ workflowId,
338
+ runId,
339
+ inputData
340
+ }) {
341
+ try {
342
+ if (!workflowId) {
343
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
344
+ }
345
+ if (!runId) {
346
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to stream workflow" });
347
+ }
348
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
349
+ if (!workflow) {
350
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
351
+ }
352
+ const run = await workflow.createRunAsync({ runId });
353
+ const result = run.streamVNext({
354
+ inputData,
355
+ runtimeContext
356
+ });
357
+ return result;
358
+ } catch (error) {
359
+ return chunkRE4RPXT2_cjs.handleError(error, "Error streaming workflow");
360
+ }
361
+ }
362
+ async function resumeAsyncWorkflowHandler({
363
+ mastra,
364
+ workflowId,
365
+ runId,
366
+ body,
367
+ runtimeContext
368
+ }) {
369
+ try {
370
+ if (!workflowId) {
371
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
372
+ }
373
+ if (!runId) {
374
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
375
+ }
376
+ if (!body.step) {
377
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
378
+ }
379
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
380
+ if (!workflow) {
381
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
382
+ }
383
+ const run = await workflow.getWorkflowRunById(runId);
384
+ if (!run) {
385
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
386
+ }
387
+ const _run = await workflow.createRunAsync({ runId });
388
+ const result = await _run.resume({
389
+ step: body.step,
390
+ resumeData: body.resumeData,
391
+ runtimeContext
392
+ });
393
+ return result;
394
+ } catch (error) {
395
+ return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow step");
396
+ }
397
+ }
398
+ async function resumeWorkflowHandler({
399
+ mastra,
400
+ workflowId,
401
+ runId,
402
+ body,
403
+ runtimeContext
404
+ }) {
405
+ try {
406
+ if (!workflowId) {
407
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
408
+ }
409
+ if (!runId) {
410
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to resume workflow" });
411
+ }
412
+ if (!body.step) {
413
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "step required to resume workflow" });
414
+ }
415
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
416
+ if (!workflow) {
417
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
418
+ }
419
+ const run = await workflow.getWorkflowRunById(runId);
420
+ if (!run) {
421
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
422
+ }
423
+ const _run = await workflow.createRunAsync({ runId });
424
+ void _run.resume({
425
+ step: body.step,
426
+ resumeData: body.resumeData,
427
+ runtimeContext
428
+ });
429
+ return { message: "Workflow run resumed" };
430
+ } catch (error) {
431
+ return chunkRE4RPXT2_cjs.handleError(error, "Error resuming workflow");
432
+ }
433
+ }
434
+ async function getWorkflowRunsHandler({
435
+ mastra,
436
+ workflowId,
437
+ fromDate,
438
+ toDate,
439
+ limit,
440
+ offset,
441
+ resourceId
442
+ }) {
443
+ try {
444
+ if (!workflowId) {
445
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
446
+ }
447
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
448
+ if (!workflow) {
449
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
450
+ }
451
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
452
+ runs: [],
453
+ total: 0
454
+ };
455
+ return workflowRuns;
456
+ } catch (error) {
457
+ return chunkRE4RPXT2_cjs.handleError(error, "Error getting workflow runs");
458
+ }
459
+ }
460
+ async function cancelWorkflowRunHandler({
461
+ mastra,
462
+ workflowId,
463
+ runId
464
+ }) {
465
+ try {
466
+ if (!workflowId) {
467
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
468
+ }
469
+ if (!runId) {
470
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
471
+ }
472
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
473
+ if (!workflow) {
474
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
475
+ }
476
+ const run = await workflow.getWorkflowRunById(runId);
477
+ if (!run) {
478
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
479
+ }
480
+ const _run = await workflow.createRunAsync({ runId });
481
+ await _run.cancel();
482
+ return { message: "Workflow run cancelled" };
483
+ } catch (error) {
484
+ return chunkRE4RPXT2_cjs.handleError(error, "Error canceling workflow run");
485
+ }
486
+ }
487
+ async function sendWorkflowRunEventHandler({
488
+ mastra,
489
+ workflowId,
490
+ runId,
491
+ event,
492
+ data
493
+ }) {
494
+ try {
495
+ if (!workflowId) {
496
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "Workflow ID is required" });
497
+ }
498
+ if (!runId) {
499
+ throw new chunk7NADHFD2_cjs.HTTPException(400, { message: "runId required to send workflow run event" });
500
+ }
501
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
502
+ if (!workflow) {
503
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow not found" });
504
+ }
505
+ const run = await workflow.getWorkflowRunById(runId);
506
+ if (!run) {
507
+ throw new chunk7NADHFD2_cjs.HTTPException(404, { message: "Workflow run not found" });
508
+ }
509
+ const _run = await workflow.createRunAsync({ runId });
510
+ await _run.sendEvent(event, data);
511
+ return { message: "Workflow run event sent" };
512
+ } catch (error) {
513
+ return chunkRE4RPXT2_cjs.handleError(error, "Error sending workflow run event");
514
+ }
515
+ }
516
+
517
+ exports.cancelWorkflowRunHandler = cancelWorkflowRunHandler;
518
+ exports.createWorkflowRunHandler = createWorkflowRunHandler;
519
+ exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
520
+ exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
521
+ exports.getWorkflowRunExecutionResultHandler = getWorkflowRunExecutionResultHandler;
522
+ exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
523
+ exports.getWorkflowsHandler = getWorkflowsHandler;
524
+ exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
525
+ exports.resumeWorkflowHandler = resumeWorkflowHandler;
526
+ exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
527
+ exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
528
+ exports.startWorkflowRunHandler = startWorkflowRunHandler;
529
+ exports.streamVNextWorkflowHandler = streamVNextWorkflowHandler;
530
+ exports.streamWorkflowHandler = streamWorkflowHandler;
531
+ exports.watchWorkflowHandler = watchWorkflowHandler;
532
+ exports.workflows_exports = workflows_exports;
533
+ //# sourceMappingURL=chunk-V5EWBGBF.cjs.map
534
+ //# sourceMappingURL=chunk-V5EWBGBF.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/workflows.ts","../src/server/utils.ts"],"names":["__export","stringify","zodToJsonSchema","handleError","HTTPException","ReadableStream"],"mappings":";;;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAAA;AAAA,EAAA,oCAA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BAA0B,CAAA;AAAA,IACpE;AAEA,IAAA,MAAM,OAAO,MAAM,QAAA,CAAS,cAAA,CAAe,EAAE,OAAO,CAAA;AAEpD,IAAA,MAAM,IAAA,CAAK,SAAA,CAAU,KAAA,EAAO,IAAI,CAAA;AAEhC,IAAA,OAAO,EAAE,SAAS,yBAAA,EAA0B;AAAA,EAC9C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOD,6BAAA,CAAY,OAAO,kCAAkC,CAAA;AAAA,EAC9D;AACF","file":"chunk-V5EWBGBF.cjs","sourcesContent":["import { ReadableStream } from 'node:stream/web';\nimport type { RuntimeContext } from '@mastra/core/di';\nimport type { WorkflowRuns } from '@mastra/core/storage';\nimport type { Workflow, WatchEvent, WorkflowInfo } from '@mastra/core/workflows';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\nimport { getWorkflowInfo } from '../utils';\nimport { handleError } from './error';\n\ninterface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nexport async function getWorkflowsHandler({ mastra }: WorkflowContext) {\n try {\n const workflows = mastra.getWorkflows({ serialized: false });\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow);\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n}\n\nasync function getWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n try {\n workflow = mastra.getWorkflow(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.getAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.getWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n break;\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\nexport async function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext): Promise<WorkflowInfo> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return getWorkflowInfo(workflow);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n}\n\nexport async function getWorkflowRunByIdHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n}\n\nexport async function getWorkflowRunExecutionResultHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const workflow = mastra.getWorkflow(workflowId);\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const executionResult = await workflow.getWorkflowRunExecutionResult(runId);\n\n if (!executionResult) {\n throw new HTTPException(404, { message: 'Workflow run execution result not found' });\n }\n\n return executionResult;\n } catch (error) {\n return handleError(error, 'Error getting workflow run execution result');\n }\n}\n\nexport async function createWorkflowRunHandler({\n mastra,\n workflowId,\n runId: prevRunId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId: prevRunId });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n}\n\nexport async function startAsyncWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.start({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n}\n\nexport async function startWorkflowRunHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n void _run.start({\n inputData,\n runtimeContext,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n}\n\nexport async function watchWorkflowHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream<string>> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to watch workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n let unwatch: () => void;\n let asyncRef: NodeJS.Immediate | null = null;\n const stream = new ReadableStream<string>({\n start(controller) {\n unwatch = _run.watch(({ type, payload, eventTimestamp }) => {\n controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));\n\n if (asyncRef) {\n clearImmediate(asyncRef);\n asyncRef = null;\n }\n\n // a run is finished if the status is not running\n asyncRef = setImmediate(async () => {\n const runDone = payload.workflowState.status !== 'running';\n if (runDone) {\n controller.close();\n unwatch?.();\n }\n });\n });\n },\n cancel() {\n unwatch?.();\n },\n });\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error watching workflow');\n }\n}\n\nexport async function streamWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.stream({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n}\n\nexport async function streamVNextWorkflowHandler({\n mastra,\n runtimeContext,\n workflowId,\n runId,\n inputData,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n inputData?: unknown;\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRunAsync({ runId });\n const result = run.streamVNext({\n inputData,\n runtimeContext,\n });\n return result;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n}\n\nexport async function resumeAsyncWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n const result = await _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n}\n\nexport async function resumeWorkflowHandler({\n mastra,\n workflowId,\n runId,\n body,\n runtimeContext,\n}: WorkflowContext & {\n body: { step: string | string[]; resumeData?: unknown };\n runtimeContext?: RuntimeContext;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n if (!body.step) {\n throw new HTTPException(400, { message: 'step required to resume workflow' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n void _run.resume({\n step: body.step,\n resumeData: body.resumeData,\n runtimeContext,\n });\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n}\n\nexport async function getWorkflowRunsHandler({\n mastra,\n workflowId,\n fromDate,\n toDate,\n limit,\n offset,\n resourceId,\n}: WorkflowContext & {\n fromDate?: Date;\n toDate?: Date;\n limit?: number;\n offset?: number;\n resourceId?: string;\n}): Promise<WorkflowRuns> {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const workflowRuns = (await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n}\n\nexport async function cancelWorkflowRunHandler({\n mastra,\n workflowId,\n runId,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n}\n\nexport async function sendWorkflowRunEventHandler({\n mastra,\n workflowId,\n runId,\n event,\n data,\n}: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {\n event: string;\n data: unknown;\n}) {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to send workflow run event' });\n }\n\n const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRunAsync({ runId });\n\n await _run.sendEvent(event, data);\n\n return { message: 'Workflow run event sent' };\n } catch (error) {\n return handleError(error, 'Error sending workflow run event');\n }\n}\n","import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';\nimport type { StepWithComponent, Workflow, WorkflowInfo } from '@mastra/core/workflows';\nimport { stringify } from 'superjson';\n\nfunction getSteps(steps: Record<string, StepWithComponent>, path?: string) {\n return Object.entries(steps).reduce<any>((acc, [key, step]) => {\n const fullKey = path ? `${path}.${key}` : key;\n acc[fullKey] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n isWorkflow: step.component === 'WORKFLOW',\n };\n\n if (step.component === 'WORKFLOW' && step.steps) {\n const nestedSteps = getSteps(step.steps, fullKey) || {};\n acc = { ...acc, ...nestedSteps };\n }\n\n return acc;\n }, {});\n}\n\nexport function getWorkflowInfo(workflow: Workflow): WorkflowInfo {\n return {\n name: workflow.name,\n description: workflow.description,\n steps: Object.entries(workflow.steps).reduce<any>((acc, [key, step]) => {\n acc[key] = {\n id: step.id,\n description: step.description,\n inputSchema: step.inputSchema ? stringify(zodToJsonSchema(step.inputSchema)) : undefined,\n outputSchema: step.outputSchema ? stringify(zodToJsonSchema(step.outputSchema)) : undefined,\n resumeSchema: step.resumeSchema ? stringify(zodToJsonSchema(step.resumeSchema)) : undefined,\n suspendSchema: step.suspendSchema ? stringify(zodToJsonSchema(step.suspendSchema)) : undefined,\n };\n return acc;\n }, {}),\n allSteps: getSteps(workflow.steps) || {},\n stepGraph: workflow.serializedStepGraph,\n inputSchema: workflow.inputSchema ? stringify(zodToJsonSchema(workflow.inputSchema)) : undefined,\n outputSchema: workflow.outputSchema ? stringify(zodToJsonSchema(workflow.outputSchema)) : undefined,\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { handleError } from './chunk-M5ABIP7D.js';
2
- import { HTTPException } from './chunk-NYN7KFXL.js';
3
- import { __export } from './chunk-MLKGABMK.js';
1
+ import { handleError } from './chunk-CY4TP3FK.js';
2
+ import { HTTPException } from './chunk-MMROOK5J.js';
3
+ import { __export } from './chunk-G3PMV62Z.js';
4
4
 
5
5
  // src/server/handlers/vector.ts
6
6
  var vector_exports = {};
@@ -119,3 +119,5 @@ async function deleteIndex({
119
119
  }
120
120
 
121
121
  export { createIndex, deleteIndex, describeIndex, listIndexes, queryVectors, upsertVectors, vector_exports };
122
+ //# sourceMappingURL=chunk-WHN4VX55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AQ,KAAA,CAAM,MAAA,EAAQ,WAAA;AAAY,KACpC;AAAA,EACF,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,wBAAwB,CAAA;AAAA,EACpD;AACF;AAGA,eAAsB,WAAA,CAAY;AAAA,EAChC,MAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAA,EAA0E;AACxE,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0BAA0B,CAAA;AAAA,IACpE;AAEA,IAAA,MAAM,MAAA,GAAS,SAAA,CAAU,MAAA,EAAQ,UAAU,CAAA;AAC3C,IAAA,MAAM,MAAA,CAAO,WAAA,CAAY,EAAE,SAAA,EAAW,CAAA;AACtC,IAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAAA,EACzB,SAAS,KAAA,EAAO;AACd,IAAA,OAAO,WAAA,CAAY,OAAO,sBAAsB,CAAA;AAAA,EAClD;AACF","file":"chunk-WHN4VX55.js","sourcesContent":["import type { MastraVector, QueryResult, IndexStats } from '@mastra/core/vector';\nimport { HTTPException } from '../http-exception';\nimport type { Context } from '../types';\n\nimport { handleError } from './error';\n\ninterface VectorContext extends Context {\n vectorName?: string;\n}\n\ninterface UpsertRequest {\n indexName: string;\n vectors: number[][];\n metadata?: Record<string, any>[];\n ids?: string[];\n}\n\ninterface CreateIndexRequest {\n indexName: string;\n dimension: number;\n metric?: 'cosine' | 'euclidean' | 'dotproduct';\n}\n\ninterface QueryRequest {\n indexName: string;\n queryVector: number[];\n topK?: number;\n filter?: Record<string, any>;\n includeVector?: boolean;\n}\n\nfunction getVector(mastra: Context['mastra'], vectorName?: string): MastraVector {\n if (!vectorName) {\n throw new HTTPException(400, { message: 'Vector name is required' });\n }\n\n const vector = mastra.getVector(vectorName);\n if (!vector) {\n throw new HTTPException(404, { message: `Vector store ${vectorName} not found` });\n }\n\n return vector;\n}\n\n// Upsert vectors\nexport async function upsertVectors({ mastra, vectorName, index }: VectorContext & { index: UpsertRequest }) {\n try {\n if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {\n throw new HTTPException(400, { message: 'Invalid request index. indexName and vectors array are required.' });\n }\n\n const vector = getVector(mastra, vectorName);\n const result = await vector.upsert(index);\n return { ids: result };\n } catch (error) {\n return handleError(error, 'Error upserting vectors');\n }\n}\n\n// Create index\nexport async function createIndex({\n mastra,\n vectorName,\n index,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { index: CreateIndexRequest }) {\n try {\n const { indexName, dimension, metric } = index;\n\n if (!indexName || typeof dimension !== 'number' || dimension <= 0) {\n throw new HTTPException(400, {\n message: 'Invalid request index, indexName and positive dimension number are required.',\n });\n }\n\n if (metric && !['cosine', 'euclidean', 'dotproduct'].includes(metric)) {\n throw new HTTPException(400, { message: 'Invalid metric. Must be one of: cosine, euclidean, dotproduct' });\n }\n\n const vector = getVector(mastra, vectorName);\n await vector.createIndex({ indexName, dimension, metric });\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error creating index');\n }\n}\n\n// Query vectors\nexport async function queryVectors({\n mastra,\n vectorName,\n query,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { query: QueryRequest }) {\n try {\n if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {\n throw new HTTPException(400, { message: 'Invalid request query. indexName and queryVector array are required.' });\n }\n\n const vector = getVector(mastra, vectorName);\n const results: QueryResult[] = await vector.query(query);\n return results;\n } catch (error) {\n return handleError(error, 'Error querying vectors');\n }\n}\n\n// List indexes\nexport async function listIndexes({ mastra, vectorName }: Pick<VectorContext, 'mastra' | 'vectorName'>) {\n try {\n const vector = getVector(mastra, vectorName);\n\n const indexes = await vector.listIndexes();\n return indexes.filter(Boolean);\n } catch (error) {\n return handleError(error, 'Error listing indexes');\n }\n}\n\n// Describe index\nexport async function describeIndex({\n mastra,\n vectorName,\n indexName,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { indexName?: string }) {\n try {\n if (!indexName) {\n throw new HTTPException(400, { message: 'Index name is required' });\n }\n\n const vector = getVector(mastra, vectorName);\n const stats: IndexStats = await vector.describeIndex({ indexName });\n\n return {\n dimension: stats.dimension,\n count: stats.count,\n metric: stats.metric?.toLowerCase(),\n };\n } catch (error) {\n return handleError(error, 'Error describing index');\n }\n}\n\n// Delete index\nexport async function deleteIndex({\n mastra,\n vectorName,\n indexName,\n}: Pick<VectorContext, 'mastra' | 'vectorName'> & { indexName?: string }) {\n try {\n if (!indexName) {\n throw new HTTPException(400, { message: 'Index name is required' });\n }\n\n const vector = getVector(mastra, vectorName);\n await vector.deleteIndex({ indexName });\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error deleting index');\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,2 +1,4 @@
1
1
  'use strict';
2
2
 
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js CHANGED
@@ -1 +1,3 @@
1
1
 
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map