@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
@@ -1,341 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkYWLUOY3D_cjs = require('./chunk-YWLUOY3D.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
- var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
- var web = require('stream/web');
8
- var di = require('@mastra/core/di');
9
-
10
- // src/server/handlers/vNextWorkflows.ts
11
- var vNextWorkflows_exports = {};
12
- chunk75ZPJI57_cjs.__export(vNextWorkflows_exports, {
13
- createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
14
- getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
15
- getVNextWorkflowRunByIdHandler: () => getVNextWorkflowRunByIdHandler,
16
- getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
17
- getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
18
- resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
19
- resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
20
- startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
21
- startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
22
- watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
23
- });
24
- async function getVNextWorkflowsHandler({ mastra }) {
25
- try {
26
- const workflows = mastra.vnext_getWorkflows({ serialized: false });
27
- const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
28
- acc[key] = {
29
- name: workflow.name,
30
- steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
31
- acc2[key2] = {
32
- id: step.id,
33
- description: step.description,
34
- inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
35
- outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
36
- resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
37
- suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
38
- };
39
- return acc2;
40
- }, {}),
41
- stepGraph: workflow.serializedStepGraph,
42
- inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
43
- outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
44
- };
45
- return acc;
46
- }, {});
47
- return _workflows;
48
- } catch (error) {
49
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
50
- }
51
- }
52
- async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
53
- try {
54
- if (!workflowId) {
55
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
56
- }
57
- const workflow = mastra.vnext_getWorkflow(workflowId);
58
- if (!workflow) {
59
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
60
- }
61
- return {
62
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
63
- acc[key] = {
64
- id: step.id,
65
- description: step.description,
66
- inputSchema: step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.inputSchema)) : void 0,
67
- outputSchema: step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.outputSchema)) : void 0,
68
- resumeSchema: step.resumeSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.resumeSchema)) : void 0,
69
- suspendSchema: step.suspendSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(step.suspendSchema)) : void 0
70
- };
71
- return acc;
72
- }, {}),
73
- name: workflow.name,
74
- stepGraph: workflow.serializedStepGraph,
75
- inputSchema: workflow.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.inputSchema)) : void 0,
76
- outputSchema: workflow.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.outputSchema)) : void 0
77
- };
78
- } catch (error) {
79
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
80
- }
81
- }
82
- async function getVNextWorkflowRunByIdHandler({
83
- mastra,
84
- workflowId,
85
- runId
86
- }) {
87
- try {
88
- if (!workflowId) {
89
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
90
- }
91
- if (!runId) {
92
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
93
- }
94
- const workflow = mastra.vnext_getWorkflow(workflowId);
95
- if (!workflow) {
96
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
97
- }
98
- const run = await workflow.getWorkflowRunById(runId);
99
- if (!run) {
100
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
101
- }
102
- return run;
103
- } catch (error) {
104
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
105
- }
106
- }
107
- async function createVNextWorkflowRunHandler({
108
- mastra,
109
- workflowId,
110
- runId: prevRunId
111
- }) {
112
- try {
113
- if (!workflowId) {
114
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
115
- }
116
- const workflow = mastra.vnext_getWorkflow(workflowId);
117
- if (!workflow) {
118
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
119
- }
120
- const run = workflow.createRun({ runId: prevRunId });
121
- return { runId: run.runId };
122
- } catch (error) {
123
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
124
- }
125
- }
126
- async function startAsyncVNextWorkflowHandler({
127
- mastra,
128
- runtimeContext,
129
- workflowId,
130
- runId,
131
- inputData,
132
- runtimeContextFromRequest
133
- }) {
134
- try {
135
- if (!workflowId) {
136
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
137
- }
138
- const workflow = mastra.vnext_getWorkflow(workflowId);
139
- if (!workflow) {
140
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
141
- }
142
- const finalRuntimeContext = new di.RuntimeContext([
143
- ...Array.from(runtimeContext?.entries() ?? []),
144
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
145
- ]);
146
- const _run = workflow.createRun({ runId });
147
- const result = await _run.start({
148
- inputData,
149
- runtimeContext: finalRuntimeContext
150
- });
151
- return result;
152
- } catch (error) {
153
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
154
- }
155
- }
156
- async function startVNextWorkflowRunHandler({
157
- mastra,
158
- runtimeContext,
159
- workflowId,
160
- runId,
161
- inputData,
162
- runtimeContextFromRequest
163
- }) {
164
- try {
165
- if (!workflowId) {
166
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
167
- }
168
- if (!runId) {
169
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
170
- }
171
- const workflow = mastra.vnext_getWorkflow(workflowId);
172
- const run = await workflow.getWorkflowRunById(runId);
173
- if (!run) {
174
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
175
- }
176
- const finalRuntimeContext = new di.RuntimeContext([
177
- ...Array.from(runtimeContext?.entries() ?? []),
178
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
179
- ]);
180
- const _run = workflow.createRun({ runId });
181
- void _run.start({
182
- inputData,
183
- runtimeContext: finalRuntimeContext
184
- });
185
- return { message: "Workflow run started" };
186
- } catch (e) {
187
- return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
188
- }
189
- }
190
- async function watchVNextWorkflowHandler({
191
- mastra,
192
- workflowId,
193
- runId
194
- }) {
195
- try {
196
- if (!workflowId) {
197
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
198
- }
199
- if (!runId) {
200
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
201
- }
202
- const workflow = mastra.vnext_getWorkflow(workflowId);
203
- const run = await workflow.getWorkflowRunById(runId);
204
- if (!run) {
205
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
206
- }
207
- const _run = workflow.createRun({ runId });
208
- let unwatch;
209
- let asyncRef = null;
210
- const stream = new web.ReadableStream({
211
- start(controller) {
212
- unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
213
- controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
214
- if (asyncRef) {
215
- clearImmediate(asyncRef);
216
- asyncRef = null;
217
- }
218
- asyncRef = setImmediate(async () => {
219
- const runDone = payload.workflowState.status !== "running";
220
- if (runDone) {
221
- controller.close();
222
- unwatch?.();
223
- }
224
- });
225
- });
226
- },
227
- cancel() {
228
- unwatch?.();
229
- }
230
- });
231
- return stream;
232
- } catch (error) {
233
- return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
234
- }
235
- }
236
- async function resumeAsyncVNextWorkflowHandler({
237
- mastra,
238
- workflowId,
239
- runId,
240
- body,
241
- runtimeContext,
242
- runtimeContextFromRequest
243
- }) {
244
- try {
245
- if (!workflowId) {
246
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
247
- }
248
- if (!runId) {
249
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
250
- }
251
- if (!body.step) {
252
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
253
- }
254
- const workflow = mastra.vnext_getWorkflow(workflowId);
255
- const run = await workflow.getWorkflowRunById(runId);
256
- if (!run) {
257
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
258
- }
259
- const finalRuntimeContext = new di.RuntimeContext([
260
- ...Array.from(runtimeContext?.entries() ?? []),
261
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
262
- ]);
263
- const _run = workflow.createRun({ runId });
264
- const result = await _run.resume({
265
- step: body.step,
266
- resumeData: body.resumeData,
267
- runtimeContext: finalRuntimeContext
268
- });
269
- return result;
270
- } catch (error) {
271
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
272
- }
273
- }
274
- async function resumeVNextWorkflowHandler({
275
- mastra,
276
- workflowId,
277
- runId,
278
- body,
279
- runtimeContext
280
- }) {
281
- try {
282
- if (!workflowId) {
283
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
284
- }
285
- if (!runId) {
286
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
287
- }
288
- if (!body.step) {
289
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
290
- }
291
- const workflow = mastra.vnext_getWorkflow(workflowId);
292
- const run = await workflow.getWorkflowRunById(runId);
293
- if (!run) {
294
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
295
- }
296
- const _run = workflow.createRun({ runId });
297
- void _run.resume({
298
- step: body.step,
299
- resumeData: body.resumeData,
300
- runtimeContext
301
- });
302
- return { message: "Workflow run resumed" };
303
- } catch (error) {
304
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
305
- }
306
- }
307
- async function getVNextWorkflowRunsHandler({
308
- mastra,
309
- workflowId,
310
- fromDate,
311
- toDate,
312
- limit,
313
- offset,
314
- resourceId
315
- }) {
316
- try {
317
- if (!workflowId) {
318
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
319
- }
320
- const workflow = mastra.vnext_getWorkflow(workflowId);
321
- const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
322
- runs: [],
323
- total: 0
324
- };
325
- return workflowRuns;
326
- } catch (error) {
327
- return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
328
- }
329
- }
330
-
331
- exports.createVNextWorkflowRunHandler = createVNextWorkflowRunHandler;
332
- exports.getVNextWorkflowByIdHandler = getVNextWorkflowByIdHandler;
333
- exports.getVNextWorkflowRunByIdHandler = getVNextWorkflowRunByIdHandler;
334
- exports.getVNextWorkflowRunsHandler = getVNextWorkflowRunsHandler;
335
- exports.getVNextWorkflowsHandler = getVNextWorkflowsHandler;
336
- exports.resumeAsyncVNextWorkflowHandler = resumeAsyncVNextWorkflowHandler;
337
- exports.resumeVNextWorkflowHandler = resumeVNextWorkflowHandler;
338
- exports.startAsyncVNextWorkflowHandler = startAsyncVNextWorkflowHandler;
339
- exports.startVNextWorkflowRunHandler = startVNextWorkflowRunHandler;
340
- exports.vNextWorkflows_exports = vNextWorkflows_exports;
341
- exports.watchVNextWorkflowHandler = watchVNextWorkflowHandler;
@@ -1,227 +0,0 @@
1
- import { stringify, esm_default } from './chunk-LIVAK2DM.js';
2
- import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-M5ABIP7D.js';
4
- import { HTTPException } from './chunk-NYN7KFXL.js';
5
- import { __export } from './chunk-MLKGABMK.js';
6
- import { RuntimeContext } from '@mastra/core/runtime-context';
7
-
8
- // src/server/handlers/agents.ts
9
- var agents_exports = {};
10
- __export(agents_exports, {
11
- generateHandler: () => generateHandler,
12
- getAgentByIdHandler: () => getAgentByIdHandler,
13
- getAgentsHandler: () => getAgentsHandler,
14
- getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
15
- getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
16
- streamGenerateHandler: () => streamGenerateHandler
17
- });
18
- async function getAgentsHandler({ mastra, runtimeContext }) {
19
- try {
20
- const agents = mastra.getAgents();
21
- const serializedAgentsMap = await Promise.all(
22
- Object.entries(agents).map(async ([id, agent]) => {
23
- const instructions = await agent.getInstructions({ runtimeContext });
24
- const tools = await agent.getTools({ runtimeContext });
25
- const llm = await agent.getLLM({ runtimeContext });
26
- const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
27
- const _tool = tool;
28
- acc[key] = {
29
- ..._tool,
30
- inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
31
- outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
32
- };
33
- return acc;
34
- }, {});
35
- let serializedAgentWorkflows = {};
36
- if ("getWorkflows" in agent) {
37
- const logger = mastra.getLogger();
38
- try {
39
- const workflows = await agent.getWorkflows({ runtimeContext });
40
- serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
41
- return {
42
- ...acc,
43
- [key]: {
44
- name: workflow.name
45
- }
46
- };
47
- }, {});
48
- } catch (error) {
49
- logger.error("Error getting workflows for agent", { agentName: agent.name, error });
50
- }
51
- }
52
- return {
53
- id,
54
- name: agent.name,
55
- instructions,
56
- tools: serializedAgentTools,
57
- workflows: serializedAgentWorkflows,
58
- provider: llm?.getProvider(),
59
- modelId: llm?.getModelId()
60
- };
61
- })
62
- );
63
- const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
64
- acc[id] = rest;
65
- return acc;
66
- }, {});
67
- return serializedAgents;
68
- } catch (error) {
69
- return handleError(error, "Error getting agents");
70
- }
71
- }
72
- async function getAgentByIdHandler({
73
- mastra,
74
- runtimeContext,
75
- agentId
76
- }) {
77
- try {
78
- const agent = mastra.getAgent(agentId);
79
- if (!agent) {
80
- throw new HTTPException(404, { message: "Agent not found" });
81
- }
82
- const tools = await agent.getTools({ runtimeContext });
83
- const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
84
- const _tool = tool;
85
- acc[key] = {
86
- ..._tool,
87
- inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
88
- outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
89
- };
90
- return acc;
91
- }, {});
92
- let serializedAgentWorkflows = {};
93
- if ("getWorkflows" in agent) {
94
- const logger = mastra.getLogger();
95
- try {
96
- const workflows = await agent.getWorkflows({ runtimeContext });
97
- serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
98
- return {
99
- ...acc,
100
- [key]: {
101
- name: workflow.name
102
- }
103
- };
104
- }, {});
105
- } catch (error) {
106
- logger.error("Error getting workflows for agent", { agentName: agent.name, error });
107
- }
108
- }
109
- const instructions = await agent.getInstructions({ runtimeContext });
110
- const llm = await agent.getLLM({ runtimeContext });
111
- return {
112
- name: agent.name,
113
- instructions,
114
- tools: serializedAgentTools,
115
- workflows: serializedAgentWorkflows,
116
- provider: llm?.getProvider(),
117
- modelId: llm?.getModelId()
118
- };
119
- } catch (error) {
120
- return handleError(error, "Error getting agent");
121
- }
122
- }
123
- async function getEvalsByAgentIdHandler({
124
- mastra,
125
- runtimeContext,
126
- agentId
127
- }) {
128
- try {
129
- const agent = mastra.getAgent(agentId);
130
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
131
- const instructions = await agent.getInstructions({ runtimeContext });
132
- return {
133
- id: agentId,
134
- name: agent.name,
135
- instructions,
136
- evals
137
- };
138
- } catch (error) {
139
- return handleError(error, "Error getting test evals");
140
- }
141
- }
142
- async function getLiveEvalsByAgentIdHandler({
143
- mastra,
144
- runtimeContext,
145
- agentId
146
- }) {
147
- try {
148
- const agent = mastra.getAgent(agentId);
149
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
150
- const instructions = await agent.getInstructions({ runtimeContext });
151
- return {
152
- id: agentId,
153
- name: agent.name,
154
- instructions,
155
- evals
156
- };
157
- } catch (error) {
158
- return handleError(error, "Error getting live evals");
159
- }
160
- }
161
- async function generateHandler({
162
- mastra,
163
- runtimeContext,
164
- agentId,
165
- body
166
- }) {
167
- try {
168
- const agent = mastra.getAgent(agentId);
169
- if (!agent) {
170
- throw new HTTPException(404, { message: "Agent not found" });
171
- }
172
- const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
173
- const finalResourceId = resourceId ?? resourceid;
174
- const finalRuntimeContext = new RuntimeContext([
175
- ...Array.from(runtimeContext.entries()),
176
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
177
- ]);
178
- validateBody({ messages });
179
- const result = await agent.generate(messages, {
180
- ...rest,
181
- // @ts-expect-error TODO fix types
182
- resourceId: finalResourceId,
183
- runtimeContext: finalRuntimeContext
184
- });
185
- return result;
186
- } catch (error) {
187
- return handleError(error, "Error generating from agent");
188
- }
189
- }
190
- async function streamGenerateHandler({
191
- mastra,
192
- runtimeContext,
193
- agentId,
194
- body
195
- }) {
196
- try {
197
- const agent = mastra.getAgent(agentId);
198
- if (!agent) {
199
- throw new HTTPException(404, { message: "Agent not found" });
200
- }
201
- const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
202
- const finalResourceId = resourceId ?? resourceid;
203
- const finalRuntimeContext = new RuntimeContext([
204
- ...Array.from(runtimeContext.entries()),
205
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
206
- ]);
207
- validateBody({ messages });
208
- const streamResult = await agent.stream(messages, {
209
- ...rest,
210
- // @ts-expect-error TODO fix types
211
- resourceId: finalResourceId,
212
- runtimeContext: finalRuntimeContext
213
- });
214
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
215
- sendUsage: true,
216
- sendReasoning: true,
217
- getErrorMessage: (error) => {
218
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
219
- }
220
- });
221
- return streamResponse;
222
- } catch (error) {
223
- throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
224
- }
225
- }
226
-
227
- export { agents_exports, generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler };