@mastra/server 0.0.0-remove-cloud-span-transform-20250425214156 → 0.0.0-scorers-api-v2-20250801171841

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 (217) hide show
  1. package/LICENSE.md +11 -42
  2. package/README.md +48 -135
  3. package/dist/chunk-2XIJW7SV.cjs +310 -0
  4. package/dist/chunk-2XIJW7SV.cjs.map +1 -0
  5. package/dist/chunk-4CEZIJWJ.cjs +150 -0
  6. package/dist/chunk-4CEZIJWJ.cjs.map +1 -0
  7. package/dist/chunk-4MQU6AJN.js +83 -0
  8. package/dist/chunk-4MQU6AJN.js.map +1 -0
  9. package/dist/{chunk-QN4KF3BH.cjs → chunk-4QSNRCOT.cjs} +4 -2
  10. package/dist/chunk-4QSNRCOT.cjs.map +1 -0
  11. package/dist/chunk-4US5W7PH.cjs +120 -0
  12. package/dist/chunk-4US5W7PH.cjs.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-4JINXASC.js → chunk-G7NVCO5M.js} +7 -4
  24. package/dist/chunk-G7NVCO5M.js.map +1 -0
  25. package/dist/chunk-GASWM5HJ.cjs +514 -0
  26. package/dist/chunk-GASWM5HJ.cjs.map +1 -0
  27. package/dist/{chunk-Q6SHQECN.js → chunk-HWHKM67I.js} +36 -10
  28. package/dist/chunk-HWHKM67I.js.map +1 -0
  29. package/dist/chunk-HXIOPAHT.js +541 -0
  30. package/dist/chunk-HXIOPAHT.js.map +1 -0
  31. package/dist/{chunk-7IWQE76Z.cjs → chunk-ILCWPBYQ.cjs} +18 -10
  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-LRUH33B4.cjs +2044 -0
  36. package/dist/chunk-LRUH33B4.cjs.map +1 -0
  37. package/dist/{chunk-TRDNDNGQ.js → chunk-MMROOK5J.js} +4 -7
  38. package/dist/chunk-MMROOK5J.js.map +1 -0
  39. package/dist/{chunk-M56ECCHK.cjs → chunk-NCS2OXX6.cjs} +22 -19
  40. package/dist/chunk-NCS2OXX6.cjs.map +1 -0
  41. package/dist/{chunk-D3G23FP3.cjs → chunk-O4I563YW.cjs} +26 -22
  42. package/dist/chunk-O4I563YW.cjs.map +1 -0
  43. package/dist/{chunk-L7XE5QTW.js → chunk-OW4FX5TS.js} +3 -1
  44. package/dist/chunk-OW4FX5TS.js.map +1 -0
  45. package/dist/chunk-PZ5AY32C.js +9 -0
  46. package/dist/chunk-PZ5AY32C.js.map +1 -0
  47. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  48. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  49. package/dist/chunk-RE4RPXT2.cjs +18 -0
  50. package/dist/chunk-RE4RPXT2.cjs.map +1 -0
  51. package/dist/chunk-S37KCGOR.cjs +546 -0
  52. package/dist/chunk-S37KCGOR.cjs.map +1 -0
  53. package/dist/{chunk-WTHDCRMY.js → chunk-SQ7KKIH3.js} +14 -6
  54. package/dist/chunk-SQ7KKIH3.js.map +1 -0
  55. package/dist/chunk-TRWPUPGD.js +506 -0
  56. package/dist/chunk-TRWPUPGD.js.map +1 -0
  57. package/dist/chunk-TXAQU2XN.js +151 -0
  58. package/dist/chunk-TXAQU2XN.js.map +1 -0
  59. package/dist/{chunk-LFOBHRFO.js → chunk-UVOSITKU.js} +76 -59
  60. package/dist/chunk-UVOSITKU.js.map +1 -0
  61. package/dist/chunk-VIGPWTDA.cjs +159 -0
  62. package/dist/chunk-VIGPWTDA.cjs.map +1 -0
  63. package/dist/chunk-VOY6MGKA.js +301 -0
  64. package/dist/chunk-VOY6MGKA.js.map +1 -0
  65. package/dist/chunk-X5SDJOY6.cjs +557 -0
  66. package/dist/chunk-X5SDJOY6.cjs.map +1 -0
  67. package/dist/{chunk-RE6YL32K.js → chunk-Y3J45CVZ.js} +54 -30
  68. package/dist/chunk-Y3J45CVZ.js.map +1 -0
  69. package/dist/{chunk-5JNVY6DU.js → chunk-YS66MFDY.js} +9 -5
  70. package/dist/chunk-YS66MFDY.js.map +1 -0
  71. package/dist/index.cjs +2 -0
  72. package/dist/index.cjs.map +1 -0
  73. package/dist/index.d.ts +1 -0
  74. package/dist/index.d.ts.map +1 -0
  75. package/dist/index.js +2 -0
  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.d.ts +14 -0
  80. package/dist/server/a2a/store.d.ts.map +1 -0
  81. package/dist/server/a2a/tasks.d.ts +20 -0
  82. package/dist/server/a2a/tasks.d.ts.map +1 -0
  83. package/dist/server/handlers/a2a.cjs +32 -0
  84. package/dist/server/handlers/a2a.cjs.map +1 -0
  85. package/dist/server/handlers/a2a.d.ts +66 -0
  86. package/dist/server/handlers/a2a.d.ts.map +1 -0
  87. package/dist/server/handlers/a2a.js +3 -0
  88. package/dist/server/handlers/a2a.js.map +1 -0
  89. package/dist/server/handlers/agents.cjs +13 -7
  90. package/dist/server/handlers/agents.cjs.map +1 -0
  91. package/dist/server/handlers/agents.d.ts +81 -6
  92. package/dist/server/handlers/agents.d.ts.map +1 -0
  93. package/dist/server/handlers/agents.js +3 -1
  94. package/dist/server/handlers/agents.js.map +1 -0
  95. package/dist/server/handlers/error.cjs +4 -2
  96. package/dist/server/handlers/error.cjs.map +1 -0
  97. package/dist/server/handlers/error.d.ts +2 -1
  98. package/dist/server/handlers/error.d.ts.map +1 -0
  99. package/dist/server/handlers/error.js +3 -1
  100. package/dist/server/handlers/error.js.map +1 -0
  101. package/dist/server/handlers/legacyWorkflows.cjs +48 -0
  102. package/dist/server/handlers/legacyWorkflows.cjs.map +1 -0
  103. package/dist/server/handlers/legacyWorkflows.d.ts +59 -0
  104. package/dist/server/handlers/legacyWorkflows.d.ts.map +1 -0
  105. package/dist/server/handlers/legacyWorkflows.js +3 -0
  106. package/dist/server/handlers/legacyWorkflows.js.map +1 -0
  107. package/dist/server/handlers/logs.cjs +6 -4
  108. package/dist/server/handlers/logs.cjs.map +1 -0
  109. package/dist/server/handlers/logs.d.ts +34 -3
  110. package/dist/server/handlers/logs.d.ts.map +1 -0
  111. package/dist/server/handlers/logs.js +3 -1
  112. package/dist/server/handlers/logs.js.map +1 -0
  113. package/dist/server/handlers/memory.cjs +35 -9
  114. package/dist/server/handlers/memory.cjs.map +1 -0
  115. package/dist/server/handlers/memory.d.ts +113 -8
  116. package/dist/server/handlers/memory.d.ts.map +1 -0
  117. package/dist/server/handlers/memory.js +3 -1
  118. package/dist/server/handlers/memory.js.map +1 -0
  119. package/dist/server/handlers/network.cjs +7 -5
  120. package/dist/server/handlers/network.cjs.map +1 -0
  121. package/dist/server/handlers/network.d.ts +50 -4
  122. package/dist/server/handlers/network.d.ts.map +1 -0
  123. package/dist/server/handlers/network.js +3 -1
  124. package/dist/server/handlers/network.js.map +1 -0
  125. package/dist/server/handlers/scores.cjs +32 -0
  126. package/dist/server/handlers/scores.cjs.map +1 -0
  127. package/dist/server/handlers/scores.d.ts +49 -0
  128. package/dist/server/handlers/scores.d.ts.map +1 -0
  129. package/dist/server/handlers/scores.js +3 -0
  130. package/dist/server/handlers/scores.js.map +1 -0
  131. package/dist/server/handlers/telemetry.cjs +5 -3
  132. package/dist/server/handlers/telemetry.cjs.map +1 -0
  133. package/dist/server/handlers/telemetry.d.ts +32 -2
  134. package/dist/server/handlers/telemetry.d.ts.map +1 -0
  135. package/dist/server/handlers/telemetry.js +3 -1
  136. package/dist/server/handlers/telemetry.js.map +1 -0
  137. package/dist/server/handlers/tools.cjs +7 -5
  138. package/dist/server/handlers/tools.cjs.map +1 -0
  139. package/dist/server/handlers/tools.d.ts +21 -4
  140. package/dist/server/handlers/tools.d.ts.map +1 -0
  141. package/dist/server/handlers/tools.js +3 -1
  142. package/dist/server/handlers/tools.js.map +1 -0
  143. package/dist/server/handlers/utils.cjs +4 -2
  144. package/dist/server/handlers/utils.cjs.map +1 -0
  145. package/dist/server/handlers/utils.d.ts +2 -1
  146. package/dist/server/handlers/utils.d.ts.map +1 -0
  147. package/dist/server/handlers/utils.js +3 -1
  148. package/dist/server/handlers/utils.js.map +1 -0
  149. package/dist/server/handlers/vNextNetwork.cjs +220 -0
  150. package/dist/server/handlers/vNextNetwork.cjs.map +1 -0
  151. package/dist/server/handlers/vNextNetwork.d.ts +179 -0
  152. package/dist/server/handlers/vNextNetwork.d.ts.map +1 -0
  153. package/dist/server/handlers/vNextNetwork.js +213 -0
  154. package/dist/server/handlers/vNextNetwork.js.map +1 -0
  155. package/dist/server/handlers/vector.cjs +9 -7
  156. package/dist/server/handlers/vector.cjs.map +1 -0
  157. package/dist/server/handlers/vector.d.ts +51 -6
  158. package/dist/server/handlers/vector.d.ts.map +1 -0
  159. package/dist/server/handlers/vector.js +3 -1
  160. package/dist/server/handlers/vector.js.map +1 -0
  161. package/dist/server/handlers/voice.cjs +10 -4
  162. package/dist/server/handlers/voice.cjs.map +1 -0
  163. package/dist/server/handlers/voice.d.ts +39 -3
  164. package/dist/server/handlers/voice.d.ts.map +1 -0
  165. package/dist/server/handlers/voice.js +3 -1
  166. package/dist/server/handlers/voice.js.map +1 -0
  167. package/dist/server/handlers/workflows.cjs +35 -13
  168. package/dist/server/handlers/workflows.cjs.map +1 -0
  169. package/dist/server/handlers/workflows.d.ts +88 -10
  170. package/dist/server/handlers/workflows.d.ts.map +1 -0
  171. package/dist/server/handlers/workflows.js +3 -1
  172. package/dist/server/handlers/workflows.js.map +1 -0
  173. package/dist/server/handlers.cjs +41 -29
  174. package/dist/server/handlers.cjs.map +1 -0
  175. package/dist/server/handlers.d.ts +13 -10
  176. package/dist/server/handlers.d.ts.map +1 -0
  177. package/dist/server/handlers.js +14 -10
  178. package/dist/server/handlers.js.map +1 -0
  179. package/dist/server/http-exception.d.ts +87 -0
  180. package/dist/server/http-exception.d.ts.map +1 -0
  181. package/dist/server/types.d.ts +10 -0
  182. package/dist/server/types.d.ts.map +1 -0
  183. package/package.json +17 -15
  184. package/dist/_tsup-dts-rollup.d.cts +0 -648
  185. package/dist/_tsup-dts-rollup.d.ts +0 -648
  186. package/dist/chunk-2FJURXCL.cjs +0 -213
  187. package/dist/chunk-3AHQ5RGN.js +0 -11
  188. package/dist/chunk-3EJZQ6TQ.js +0 -49
  189. package/dist/chunk-55HTWX4C.cjs +0 -93
  190. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  191. package/dist/chunk-B66WVPGJ.js +0 -297
  192. package/dist/chunk-FPIWDH5Y.cjs +0 -126
  193. package/dist/chunk-HCOPJZ4A.cjs +0 -164
  194. package/dist/chunk-OMN3UI6X.js +0 -5576
  195. package/dist/chunk-R4J7XQYU.js +0 -156
  196. package/dist/chunk-RBQASTUP.js +0 -203
  197. package/dist/chunk-SKBVVI24.cjs +0 -54
  198. package/dist/chunk-TZK63M5N.cjs +0 -317
  199. package/dist/chunk-ZHNKYTNS.cjs +0 -309
  200. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  201. package/dist/index.d.cts +0 -1
  202. package/dist/server/handlers/agents.d.cts +0 -6
  203. package/dist/server/handlers/error.d.cts +0 -1
  204. package/dist/server/handlers/logs.d.cts +0 -3
  205. package/dist/server/handlers/memory.d.cts +0 -8
  206. package/dist/server/handlers/network.d.cts +0 -4
  207. package/dist/server/handlers/telemetry.d.cts +0 -2
  208. package/dist/server/handlers/tools.d.cts +0 -4
  209. package/dist/server/handlers/utils.d.cts +0 -1
  210. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  211. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  212. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  213. package/dist/server/handlers/vNextWorkflows.js +0 -1
  214. package/dist/server/handlers/vector.d.cts +0 -6
  215. package/dist/server/handlers/voice.d.cts +0 -3
  216. package/dist/server/handlers/workflows.d.cts +0 -10
  217. package/dist/server/handlers.d.cts +0 -10
@@ -1,297 +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
- ...step,
29
- inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
30
- outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0
31
- };
32
- return acc2;
33
- }, {}),
34
- stepGraph: workflow.stepGraph,
35
- inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
36
- outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
37
- };
38
- return acc;
39
- }, {});
40
- return _workflows;
41
- } catch (error) {
42
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
43
- }
44
- }
45
- async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
46
- try {
47
- if (!workflowId) {
48
- throw new HTTPException(400, { message: "Workflow ID is required" });
49
- }
50
- const workflow = mastra.vnext_getWorkflow(workflowId);
51
- if (!workflow) {
52
- throw new HTTPException(404, { message: "Workflow not found" });
53
- }
54
- return {
55
- steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
56
- acc[key] = {
57
- ...step,
58
- inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
59
- outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0
60
- };
61
- return acc;
62
- }, {}),
63
- name: workflow.name,
64
- stepGraph: workflow.stepGraph,
65
- inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
66
- outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
67
- };
68
- } catch (error) {
69
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
70
- }
71
- }
72
- async function getVNextWorkflowRunHandler({
73
- mastra,
74
- workflowId,
75
- runId
76
- }) {
77
- try {
78
- if (!workflowId) {
79
- throw new HTTPException(400, { message: "Workflow ID is required" });
80
- }
81
- if (!runId) {
82
- throw new HTTPException(400, { message: "Run ID is required" });
83
- }
84
- const workflow = mastra.vnext_getWorkflow(workflowId);
85
- if (!workflow) {
86
- throw new HTTPException(404, { message: "Workflow not found" });
87
- }
88
- const run = await workflow.getWorkflowRun(runId);
89
- if (!run) {
90
- throw new HTTPException(404, { message: "Workflow run not found" });
91
- }
92
- return run;
93
- } catch (error) {
94
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
95
- }
96
- }
97
- async function createVNextWorkflowRunHandler({
98
- mastra,
99
- workflowId,
100
- runId: prevRunId
101
- }) {
102
- try {
103
- if (!workflowId) {
104
- throw new HTTPException(400, { message: "Workflow ID is required" });
105
- }
106
- const workflow = mastra.vnext_getWorkflow(workflowId);
107
- if (!workflow) {
108
- throw new HTTPException(404, { message: "Workflow not found" });
109
- }
110
- const run = workflow.createRun({ runId: prevRunId });
111
- return { runId: run.runId };
112
- } catch (error) {
113
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
114
- }
115
- }
116
- async function startAsyncVNextWorkflowHandler({
117
- mastra,
118
- runtimeContext,
119
- workflowId,
120
- runId,
121
- inputData
122
- }) {
123
- try {
124
- if (!workflowId) {
125
- throw new HTTPException(400, { message: "Workflow ID is required" });
126
- }
127
- const workflow = mastra.vnext_getWorkflow(workflowId);
128
- if (!workflow) {
129
- throw new HTTPException(404, { message: "Workflow not found" });
130
- }
131
- const _run = workflow.createRun({ runId });
132
- const result = await _run.start({
133
- inputData,
134
- runtimeContext
135
- });
136
- return result;
137
- } catch (error) {
138
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
139
- }
140
- }
141
- async function startVNextWorkflowRunHandler({
142
- mastra,
143
- runtimeContext,
144
- workflowId,
145
- runId,
146
- inputData
147
- }) {
148
- try {
149
- if (!workflowId) {
150
- throw new HTTPException(400, { message: "Workflow ID is required" });
151
- }
152
- if (!runId) {
153
- throw new HTTPException(400, { message: "runId required to start run" });
154
- }
155
- const workflow = mastra.vnext_getWorkflow(workflowId);
156
- const run = await workflow.getWorkflowRun(runId);
157
- if (!run) {
158
- throw new HTTPException(404, { message: "Workflow run not found" });
159
- }
160
- const _run = workflow.createRun({ runId });
161
- await _run.start({
162
- inputData,
163
- runtimeContext
164
- });
165
- return { message: "Workflow run started" };
166
- } catch (e) {
167
- return handleError(e, "Error starting workflow run");
168
- }
169
- }
170
- async function watchVNextWorkflowHandler({
171
- mastra,
172
- workflowId,
173
- runId
174
- }) {
175
- try {
176
- if (!workflowId) {
177
- throw new HTTPException(400, { message: "Workflow ID is required" });
178
- }
179
- if (!runId) {
180
- throw new HTTPException(400, { message: "runId required to watch workflow" });
181
- }
182
- const workflow = mastra.vnext_getWorkflow(workflowId);
183
- const run = await workflow.getWorkflowRun(runId);
184
- if (!run) {
185
- throw new HTTPException(404, { message: "Workflow run not found" });
186
- }
187
- const _run = workflow.createRun({ runId });
188
- let unwatch;
189
- let asyncRef = null;
190
- const stream = new ReadableStream({
191
- start(controller) {
192
- unwatch = _run.watch(({ type, payload, eventTimestamp }) => {
193
- controller.enqueue(JSON.stringify({ type, payload, eventTimestamp, runId }));
194
- if (asyncRef) {
195
- clearImmediate(asyncRef);
196
- asyncRef = null;
197
- }
198
- asyncRef = setImmediate(async () => {
199
- const runDone = payload.workflowState.status !== "running";
200
- if (runDone) {
201
- controller.close();
202
- }
203
- });
204
- });
205
- },
206
- cancel() {
207
- unwatch?.();
208
- }
209
- });
210
- return stream;
211
- } catch (error) {
212
- return handleError(error, "Error watching workflow");
213
- }
214
- }
215
- async function resumeAsyncVNextWorkflowHandler({
216
- mastra,
217
- workflowId,
218
- runId,
219
- body,
220
- runtimeContext
221
- }) {
222
- try {
223
- if (!workflowId) {
224
- throw new HTTPException(400, { message: "Workflow ID is required" });
225
- }
226
- if (!runId) {
227
- throw new HTTPException(400, { message: "runId required to resume workflow" });
228
- }
229
- if (!body.step) {
230
- throw new HTTPException(400, { message: "step required to resume workflow" });
231
- }
232
- const workflow = mastra.vnext_getWorkflow(workflowId);
233
- const run = await workflow.getWorkflowRun(runId);
234
- if (!run) {
235
- throw new HTTPException(404, { message: "Workflow run not found" });
236
- }
237
- const _run = workflow.createRun({ runId });
238
- const result = await _run.resume({
239
- step: body.step,
240
- resumeData: body.resumeData,
241
- runtimeContext
242
- });
243
- return result;
244
- } catch (error) {
245
- return handleError(error, "Error resuming workflow step");
246
- }
247
- }
248
- async function resumeVNextWorkflowHandler({
249
- mastra,
250
- workflowId,
251
- runId,
252
- body,
253
- runtimeContext
254
- }) {
255
- try {
256
- if (!workflowId) {
257
- throw new HTTPException(400, { message: "Workflow ID is required" });
258
- }
259
- if (!runId) {
260
- throw new HTTPException(400, { message: "runId required to resume workflow" });
261
- }
262
- if (!body.step) {
263
- throw new HTTPException(400, { message: "step required to resume workflow" });
264
- }
265
- const workflow = mastra.vnext_getWorkflow(workflowId);
266
- const run = await workflow.getWorkflowRun(runId);
267
- if (!run) {
268
- throw new HTTPException(404, { message: "Workflow run not found" });
269
- }
270
- const _run = workflow.createRun({ runId });
271
- await _run.resume({
272
- step: body.step,
273
- resumeData: body.resumeData,
274
- runtimeContext
275
- });
276
- return { message: "Workflow run resumed" };
277
- } catch (error) {
278
- return handleError(error, "Error resuming workflow");
279
- }
280
- }
281
- async function getVNextWorkflowRunsHandler({ mastra, workflowId }) {
282
- try {
283
- if (!workflowId) {
284
- throw new HTTPException(400, { message: "Workflow ID is required" });
285
- }
286
- const workflow = mastra.vnext_getWorkflow(workflowId);
287
- const workflowRuns = await workflow.getWorkflowRuns() || {
288
- runs: [],
289
- total: 0
290
- };
291
- return workflowRuns;
292
- } catch (error) {
293
- return handleError(error, "Error getting workflow runs");
294
- }
295
- }
296
-
297
- export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, vNextWorkflows_exports, watchVNextWorkflowHandler };
@@ -1,126 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
6
-
7
- // src/server/handlers/network.ts
8
- var network_exports = {};
9
- chunkFV45V6WC_cjs.__export(network_exports, {
10
- generateHandler: () => generateHandler,
11
- getNetworkByIdHandler: () => getNetworkByIdHandler,
12
- getNetworksHandler: () => getNetworksHandler,
13
- streamGenerateHandler: () => streamGenerateHandler
14
- });
15
- async function getNetworksHandler({ mastra }) {
16
- try {
17
- const networks = mastra.getNetworks();
18
- const serializedNetworks = networks.map((network) => {
19
- const routingAgent = network.getRoutingAgent();
20
- const agents = network.getAgents();
21
- return {
22
- id: network.formatAgentId(routingAgent.name),
23
- name: routingAgent.name,
24
- instructions: routingAgent.instructions,
25
- agents: agents.map((agent) => ({
26
- name: agent.name,
27
- provider: agent.llm?.getProvider(),
28
- modelId: agent.llm?.getModelId()
29
- })),
30
- routingModel: {
31
- provider: routingAgent.llm?.getProvider(),
32
- modelId: routingAgent.llm?.getModelId()
33
- }
34
- };
35
- });
36
- return serializedNetworks;
37
- } catch (error) {
38
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
39
- }
40
- }
41
- async function getNetworkByIdHandler({ mastra, networkId }) {
42
- try {
43
- const networks = mastra.getNetworks();
44
- const network = networks.find((network2) => {
45
- const routingAgent2 = network2.getRoutingAgent();
46
- return network2.formatAgentId(routingAgent2.name) === networkId;
47
- });
48
- if (!network) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
50
- }
51
- const routingAgent = network.getRoutingAgent();
52
- const agents = network.getAgents();
53
- const serializedNetwork = {
54
- id: network.formatAgentId(routingAgent.name),
55
- name: routingAgent.name,
56
- instructions: routingAgent.instructions,
57
- agents: agents.map((agent) => ({
58
- name: agent.name,
59
- provider: agent.llm?.getProvider(),
60
- modelId: agent.llm?.getModelId()
61
- })),
62
- routingModel: {
63
- provider: routingAgent.llm?.getProvider(),
64
- modelId: routingAgent.llm?.getModelId()
65
- }
66
- };
67
- return serializedNetwork;
68
- } catch (error) {
69
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting network by ID");
70
- }
71
- }
72
- async function generateHandler({
73
- mastra,
74
- runtimeContext,
75
- networkId,
76
- body
77
- }) {
78
- try {
79
- const network = mastra.getNetwork(networkId);
80
- if (!network) {
81
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
82
- }
83
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
84
- const { messages, ...rest } = body;
85
- const result = await network.generate(messages, { ...rest, runtimeContext });
86
- return result;
87
- } catch (error) {
88
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
89
- }
90
- }
91
- async function streamGenerateHandler({
92
- mastra,
93
- networkId,
94
- body,
95
- runtimeContext
96
- }) {
97
- try {
98
- const network = mastra.getNetwork(networkId);
99
- if (!network) {
100
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
101
- }
102
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
103
- const { messages, output, ...rest } = body;
104
- const streamResult = await network.stream(messages, {
105
- output,
106
- ...rest,
107
- runtimeContext
108
- });
109
- const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
110
- sendUsage: true,
111
- sendReasoning: true,
112
- getErrorMessage: (error) => {
113
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
114
- }
115
- });
116
- return streamResponse;
117
- } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error streaming from network");
119
- }
120
- }
121
-
122
- exports.generateHandler = generateHandler;
123
- exports.getNetworkByIdHandler = getNetworkByIdHandler;
124
- exports.getNetworksHandler = getNetworksHandler;
125
- exports.network_exports = network_exports;
126
- exports.streamGenerateHandler = streamGenerateHandler;
@@ -1,164 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
4
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
5
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
6
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
7
-
8
- // src/server/handlers/agents.ts
9
- var agents_exports = {};
10
- chunkFV45V6WC_cjs.__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 }) {
19
- try {
20
- const agents = mastra.getAgents();
21
- const serializedAgents = Object.entries(agents).reduce((acc, [_id, _agent]) => {
22
- const agent = _agent;
23
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc2, [key, tool]) => {
24
- const _tool = tool;
25
- acc2[key] = {
26
- ..._tool,
27
- inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
28
- outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
29
- };
30
- return acc2;
31
- }, {});
32
- acc[_id] = {
33
- name: agent.name,
34
- instructions: agent.instructions,
35
- tools: serializedAgentTools,
36
- provider: agent.llm?.getProvider(),
37
- modelId: agent.llm?.getModelId()
38
- };
39
- return acc;
40
- }, {});
41
- return serializedAgents;
42
- } catch (error) {
43
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agents");
44
- }
45
- }
46
- async function getAgentByIdHandler({ mastra, agentId }) {
47
- try {
48
- const agent = mastra.getAgent(agentId);
49
- if (!agent) {
50
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
51
- }
52
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc, [key, tool]) => {
53
- const _tool = tool;
54
- acc[key] = {
55
- ..._tool,
56
- inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
57
- outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
58
- };
59
- return acc;
60
- }, {});
61
- return {
62
- name: agent.name,
63
- instructions: agent.instructions,
64
- tools: serializedAgentTools,
65
- provider: agent.llm?.getProvider(),
66
- modelId: agent.llm?.getModelId()
67
- };
68
- } catch (error) {
69
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting agent");
70
- }
71
- }
72
- async function getEvalsByAgentIdHandler({ mastra, agentId }) {
73
- try {
74
- const agent = mastra.getAgent(agentId);
75
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
76
- return {
77
- id: agentId,
78
- name: agent.name,
79
- instructions: agent.instructions,
80
- evals
81
- };
82
- } catch (error) {
83
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting test evals");
84
- }
85
- }
86
- async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
87
- try {
88
- const agent = mastra.getAgent(agentId);
89
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
90
- return {
91
- id: agentId,
92
- name: agent.name,
93
- instructions: agent.instructions,
94
- evals
95
- };
96
- } catch (error) {
97
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting live evals");
98
- }
99
- }
100
- async function generateHandler({
101
- mastra,
102
- runtimeContext,
103
- agentId,
104
- body
105
- }) {
106
- try {
107
- const agent = mastra.getAgent(agentId);
108
- if (!agent) {
109
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
110
- }
111
- const { messages, resourceId, resourceid, ...rest } = body;
112
- const finalResourceId = resourceId ?? resourceid;
113
- chunkQN4KF3BH_cjs.validateBody({ messages });
114
- const result = await agent.generate(messages, {
115
- ...rest,
116
- // @ts-expect-error TODO fix types
117
- resourceId: finalResourceId,
118
- runtimeContext
119
- });
120
- return result;
121
- } catch (error) {
122
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from agent");
123
- }
124
- }
125
- async function streamGenerateHandler({
126
- mastra,
127
- runtimeContext,
128
- agentId,
129
- body
130
- }) {
131
- try {
132
- const agent = mastra.getAgent(agentId);
133
- if (!agent) {
134
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
135
- }
136
- const { messages, resourceId, resourceid, ...rest } = body;
137
- const finalResourceId = resourceId ?? resourceid;
138
- chunkQN4KF3BH_cjs.validateBody({ messages });
139
- const streamResult = await agent.stream(messages, {
140
- ...rest,
141
- // @ts-expect-error TODO fix types
142
- resourceId: finalResourceId,
143
- runtimeContext
144
- });
145
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
146
- sendUsage: true,
147
- sendReasoning: true,
148
- getErrorMessage: (error) => {
149
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
150
- }
151
- });
152
- return streamResponse;
153
- } catch (error) {
154
- throw new chunkFV45V6WC_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
155
- }
156
- }
157
-
158
- exports.agents_exports = agents_exports;
159
- exports.generateHandler = generateHandler;
160
- exports.getAgentByIdHandler = getAgentByIdHandler;
161
- exports.getAgentsHandler = getAgentsHandler;
162
- exports.getEvalsByAgentIdHandler = getEvalsByAgentIdHandler;
163
- exports.getLiveEvalsByAgentIdHandler = getLiveEvalsByAgentIdHandler;
164
- exports.streamGenerateHandler = streamGenerateHandler;