@mastra/server 0.0.0-tool-call-parts-20250630193309 → 0.0.0-transpile-packages-20250724123433

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 (72) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/_tsup-dts-rollup.d.cts +142 -14
  3. package/dist/_tsup-dts-rollup.d.ts +142 -14
  4. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  5. package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
  6. package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
  7. package/dist/{chunk-E2LP4J6K.js → chunk-5PQQ42EZ.js} +7 -7
  8. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  9. package/dist/{chunk-L3VURYKY.cjs → chunk-B2PAS2IB.cjs} +134 -55
  10. package/dist/{chunk-2BCWG3EZ.js → chunk-BK4XT6EG.js} +4 -4
  11. package/dist/chunk-CBFTEHOO.cjs +157 -0
  12. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  13. package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
  14. package/dist/{chunk-Z3PTO2AK.cjs → chunk-FRVBFMO2.cjs} +15 -15
  15. package/dist/{chunk-XUIJ7WRT.js → chunk-G4L7OMCA.js} +84 -5
  16. package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  17. package/dist/{chunk-72LOJGUV.js → chunk-H7DMHBKY.js} +88 -11
  18. package/dist/{chunk-NGHSYB5B.cjs → chunk-JMLYCXMK.cjs} +36 -36
  19. package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
  20. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  21. package/dist/chunk-LF7P5PLR.js +14 -0
  22. package/dist/{chunk-EWLR2PNT.js → chunk-LRCAAFUA.js} +3 -3
  23. package/dist/{chunk-EP3XVEVC.cjs → chunk-LZ3VJXSO.cjs} +14 -14
  24. package/dist/chunk-PZQDCRPV.cjs +16 -0
  25. package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
  26. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  27. package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
  28. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  29. package/dist/chunk-VULESSU5.js +149 -0
  30. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  31. package/dist/{chunk-RQ2Z56EC.cjs → chunk-Z75RYULP.cjs} +117 -35
  32. package/dist/server/handlers/agents.cjs +7 -7
  33. package/dist/server/handlers/agents.js +1 -1
  34. package/dist/server/handlers/error.cjs +2 -2
  35. package/dist/server/handlers/error.js +1 -1
  36. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  37. package/dist/server/handlers/legacyWorkflows.js +1 -1
  38. package/dist/server/handlers/logs.cjs +4 -4
  39. package/dist/server/handlers/logs.js +1 -1
  40. package/dist/server/handlers/memory.cjs +21 -9
  41. package/dist/server/handlers/memory.d.cts +3 -0
  42. package/dist/server/handlers/memory.d.ts +3 -0
  43. package/dist/server/handlers/memory.js +1 -1
  44. package/dist/server/handlers/network.cjs +5 -5
  45. package/dist/server/handlers/network.js +1 -1
  46. package/dist/server/handlers/scores.cjs +30 -0
  47. package/dist/server/handlers/scores.d.cts +6 -0
  48. package/dist/server/handlers/scores.d.ts +6 -0
  49. package/dist/server/handlers/scores.js +1 -0
  50. package/dist/server/handlers/telemetry.cjs +3 -3
  51. package/dist/server/handlers/telemetry.js +1 -1
  52. package/dist/server/handlers/tools.cjs +5 -5
  53. package/dist/server/handlers/tools.js +1 -1
  54. package/dist/server/handlers/utils.cjs +2 -2
  55. package/dist/server/handlers/utils.js +1 -1
  56. package/dist/server/handlers/vNextNetwork.cjs +18 -18
  57. package/dist/server/handlers/vNextNetwork.js +3 -3
  58. package/dist/server/handlers/vector.cjs +7 -7
  59. package/dist/server/handlers/vector.js +1 -1
  60. package/dist/server/handlers/voice.cjs +5 -5
  61. package/dist/server/handlers/voice.js +1 -1
  62. package/dist/server/handlers/workflows.cjs +21 -13
  63. package/dist/server/handlers/workflows.d.cts +2 -0
  64. package/dist/server/handlers/workflows.d.ts +2 -0
  65. package/dist/server/handlers/workflows.js +1 -1
  66. package/dist/server/handlers.cjs +28 -23
  67. package/dist/server/handlers.d.cts +3 -2
  68. package/dist/server/handlers.d.ts +3 -2
  69. package/dist/server/handlers.js +11 -10
  70. package/package.json +8 -7
  71. package/dist/chunk-64U3UDTH.cjs +0 -13
  72. package/dist/chunk-M5ABIP7D.js +0 -11
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
6
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
  var web = require('stream/web');
8
8
 
9
9
  // src/server/handlers/workflows.ts
10
10
  var workflows_exports = {};
11
11
  chunk75ZPJI57_cjs.__export(workflows_exports, {
12
+ cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
12
13
  createWorkflowRunHandler: () => createWorkflowRunHandler,
13
14
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
14
15
  getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
@@ -17,11 +18,31 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
17
18
  getWorkflowsHandler: () => getWorkflowsHandler,
18
19
  resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
19
20
  resumeWorkflowHandler: () => resumeWorkflowHandler,
21
+ sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
20
22
  startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
21
23
  startWorkflowRunHandler: () => startWorkflowRunHandler,
22
24
  streamWorkflowHandler: () => streamWorkflowHandler,
23
25
  watchWorkflowHandler: () => watchWorkflowHandler
24
26
  });
27
+ function getSteps(steps, path) {
28
+ return Object.entries(steps).reduce((acc, [key, step]) => {
29
+ const fullKey = path ? `${path}.${key}` : key;
30
+ acc[fullKey] = {
31
+ id: step.id,
32
+ description: step.description,
33
+ inputSchema: step.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.inputSchema)) : void 0,
34
+ outputSchema: step.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.outputSchema)) : void 0,
35
+ resumeSchema: step.resumeSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.resumeSchema)) : void 0,
36
+ suspendSchema: step.suspendSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(step.suspendSchema)) : void 0,
37
+ isWorkflow: step.component === "WORKFLOW"
38
+ };
39
+ if (step.component === "WORKFLOW" && step.steps) {
40
+ const nestedSteps = getSteps(step.steps, fullKey) || {};
41
+ acc = { ...acc, ...nestedSteps };
42
+ }
43
+ return acc;
44
+ }, {});
45
+ }
25
46
  async function getWorkflowsHandler({ mastra }) {
26
47
  try {
27
48
  const workflows = mastra.getWorkflows({ serialized: false });
@@ -40,6 +61,7 @@ async function getWorkflowsHandler({ mastra }) {
40
61
  };
41
62
  return acc2;
42
63
  }, {}),
64
+ allSteps: getSteps(workflow.steps) || {},
43
65
  stepGraph: workflow.serializedStepGraph,
44
66
  inputSchema: workflow.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.inputSchema)) : void 0,
45
67
  outputSchema: workflow.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.outputSchema)) : void 0
@@ -48,13 +70,13 @@ async function getWorkflowsHandler({ mastra }) {
48
70
  }, {});
49
71
  return _workflows;
50
72
  } catch (error) {
51
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
73
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflows");
52
74
  }
53
75
  }
54
76
  async function getWorkflowsFromSystem({ mastra, workflowId }) {
55
77
  const logger = mastra.getLogger();
56
78
  if (!workflowId) {
57
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
79
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
58
80
  }
59
81
  let workflow;
60
82
  try {
@@ -81,18 +103,18 @@ async function getWorkflowsFromSystem({ mastra, workflowId }) {
81
103
  }
82
104
  }
83
105
  if (!workflow) {
84
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
106
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
85
107
  }
86
108
  return { workflow };
87
109
  }
88
110
  async function getWorkflowByIdHandler({ mastra, workflowId }) {
89
111
  try {
90
112
  if (!workflowId) {
91
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
113
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
92
114
  }
93
115
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
94
116
  if (!workflow) {
95
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
117
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
96
118
  }
97
119
  return {
98
120
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
@@ -106,6 +128,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
106
128
  };
107
129
  return acc;
108
130
  }, {}),
131
+ allSteps: getSteps(workflow.steps) || {},
109
132
  name: workflow.name,
110
133
  description: workflow.description,
111
134
  stepGraph: workflow.serializedStepGraph,
@@ -113,7 +136,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
113
136
  outputSchema: workflow.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.outputSchema)) : void 0
114
137
  };
115
138
  } catch (error) {
116
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
139
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow");
117
140
  }
118
141
  }
119
142
  async function getWorkflowRunByIdHandler({
@@ -123,22 +146,22 @@ async function getWorkflowRunByIdHandler({
123
146
  }) {
124
147
  try {
125
148
  if (!workflowId) {
126
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
149
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
127
150
  }
128
151
  if (!runId) {
129
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
152
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
130
153
  }
131
154
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
132
155
  if (!workflow) {
133
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
156
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
134
157
  }
135
158
  const run = await workflow.getWorkflowRunById(runId);
136
159
  if (!run) {
137
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
160
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
138
161
  }
139
162
  return run;
140
163
  } catch (error) {
141
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
164
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow run");
142
165
  }
143
166
  }
144
167
  async function getWorkflowRunExecutionResultHandler({
@@ -148,24 +171,22 @@ async function getWorkflowRunExecutionResultHandler({
148
171
  }) {
149
172
  try {
150
173
  if (!workflowId) {
151
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
174
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
152
175
  }
153
176
  if (!runId) {
154
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
177
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
155
178
  }
156
179
  const workflow = mastra.getWorkflow(workflowId);
157
180
  if (!workflow) {
158
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
181
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
159
182
  }
160
183
  const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
161
184
  if (!executionResult) {
162
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
185
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
163
186
  }
164
187
  return executionResult;
165
188
  } catch (error) {
166
- throw new chunkOCWPVYNI_cjs.HTTPException(500, {
167
- message: error?.message || "Error getting workflow run execution result"
168
- });
189
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow run execution result");
169
190
  }
170
191
  }
171
192
  async function createWorkflowRunHandler({
@@ -175,16 +196,16 @@ async function createWorkflowRunHandler({
175
196
  }) {
176
197
  try {
177
198
  if (!workflowId) {
178
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
199
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
179
200
  }
180
201
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
181
202
  if (!workflow) {
182
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
203
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
183
204
  }
184
205
  const run = await workflow.createRunAsync({ runId: prevRunId });
185
206
  return { runId: run.runId };
186
207
  } catch (error) {
187
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
208
+ return chunkPZQDCRPV_cjs.handleError(error, "Error creating workflow run");
188
209
  }
189
210
  }
190
211
  async function startAsyncWorkflowHandler({
@@ -196,11 +217,11 @@ async function startAsyncWorkflowHandler({
196
217
  }) {
197
218
  try {
198
219
  if (!workflowId) {
199
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
220
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
200
221
  }
201
222
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
202
223
  if (!workflow) {
203
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
224
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
204
225
  }
205
226
  const _run = await workflow.createRunAsync({ runId });
206
227
  const result = await _run.start({
@@ -209,7 +230,7 @@ async function startAsyncWorkflowHandler({
209
230
  });
210
231
  return result;
211
232
  } catch (error) {
212
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
233
+ return chunkPZQDCRPV_cjs.handleError(error, "Error starting async workflow");
213
234
  }
214
235
  }
215
236
  async function startWorkflowRunHandler({
@@ -221,18 +242,18 @@ async function startWorkflowRunHandler({
221
242
  }) {
222
243
  try {
223
244
  if (!workflowId) {
224
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
245
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
225
246
  }
226
247
  if (!runId) {
227
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
248
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to start run" });
228
249
  }
229
250
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
230
251
  if (!workflow) {
231
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
252
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
232
253
  }
233
254
  const run = await workflow.getWorkflowRunById(runId);
234
255
  if (!run) {
235
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
256
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
236
257
  }
237
258
  const _run = await workflow.createRunAsync({ runId });
238
259
  void _run.start({
@@ -241,7 +262,7 @@ async function startWorkflowRunHandler({
241
262
  });
242
263
  return { message: "Workflow run started" };
243
264
  } catch (e) {
244
- return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
265
+ return chunkPZQDCRPV_cjs.handleError(e, "Error starting workflow run");
245
266
  }
246
267
  }
247
268
  async function watchWorkflowHandler({
@@ -251,18 +272,18 @@ async function watchWorkflowHandler({
251
272
  }) {
252
273
  try {
253
274
  if (!workflowId) {
254
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
275
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
255
276
  }
256
277
  if (!runId) {
257
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
278
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to watch workflow" });
258
279
  }
259
280
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
260
281
  if (!workflow) {
261
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
282
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
262
283
  }
263
284
  const run = await workflow.getWorkflowRunById(runId);
264
285
  if (!run) {
265
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
286
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
266
287
  }
267
288
  const _run = await workflow.createRunAsync({ runId });
268
289
  let unwatch;
@@ -290,7 +311,7 @@ async function watchWorkflowHandler({
290
311
  });
291
312
  return stream;
292
313
  } catch (error) {
293
- return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
314
+ return chunkPZQDCRPV_cjs.handleError(error, "Error watching workflow");
294
315
  }
295
316
  }
296
317
  async function streamWorkflowHandler({
@@ -302,14 +323,14 @@ async function streamWorkflowHandler({
302
323
  }) {
303
324
  try {
304
325
  if (!workflowId) {
305
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
326
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
306
327
  }
307
328
  if (!runId) {
308
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
329
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
309
330
  }
310
331
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
311
332
  if (!workflow) {
312
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
333
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
313
334
  }
314
335
  const run = await workflow.createRunAsync({ runId });
315
336
  const result = run.stream({
@@ -318,7 +339,7 @@ async function streamWorkflowHandler({
318
339
  });
319
340
  return result;
320
341
  } catch (error) {
321
- return chunk64U3UDTH_cjs.handleError(error, "Error executing workflow");
342
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing workflow");
322
343
  }
323
344
  }
324
345
  async function resumeAsyncWorkflowHandler({
@@ -330,21 +351,21 @@ async function resumeAsyncWorkflowHandler({
330
351
  }) {
331
352
  try {
332
353
  if (!workflowId) {
333
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
354
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
334
355
  }
335
356
  if (!runId) {
336
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
357
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
337
358
  }
338
359
  if (!body.step) {
339
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
360
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "step required to resume workflow" });
340
361
  }
341
362
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
342
363
  if (!workflow) {
343
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
364
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
344
365
  }
345
366
  const run = await workflow.getWorkflowRunById(runId);
346
367
  if (!run) {
347
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
368
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
348
369
  }
349
370
  const _run = await workflow.createRunAsync({ runId });
350
371
  const result = await _run.resume({
@@ -354,7 +375,7 @@ async function resumeAsyncWorkflowHandler({
354
375
  });
355
376
  return result;
356
377
  } catch (error) {
357
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
378
+ return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow step");
358
379
  }
359
380
  }
360
381
  async function resumeWorkflowHandler({
@@ -366,21 +387,21 @@ async function resumeWorkflowHandler({
366
387
  }) {
367
388
  try {
368
389
  if (!workflowId) {
369
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
390
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
370
391
  }
371
392
  if (!runId) {
372
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
393
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to resume workflow" });
373
394
  }
374
395
  if (!body.step) {
375
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "step required to resume workflow" });
396
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "step required to resume workflow" });
376
397
  }
377
398
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
378
399
  if (!workflow) {
379
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
400
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
380
401
  }
381
402
  const run = await workflow.getWorkflowRunById(runId);
382
403
  if (!run) {
383
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
404
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
384
405
  }
385
406
  const _run = await workflow.createRunAsync({ runId });
386
407
  void _run.resume({
@@ -390,7 +411,7 @@ async function resumeWorkflowHandler({
390
411
  });
391
412
  return { message: "Workflow run resumed" };
392
413
  } catch (error) {
393
- return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
414
+ return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow");
394
415
  }
395
416
  }
396
417
  async function getWorkflowRunsHandler({
@@ -404,11 +425,11 @@ async function getWorkflowRunsHandler({
404
425
  }) {
405
426
  try {
406
427
  if (!workflowId) {
407
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
428
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
408
429
  }
409
430
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
410
431
  if (!workflow) {
411
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
432
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
412
433
  }
413
434
  const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
414
435
  runs: [],
@@ -416,10 +437,67 @@ async function getWorkflowRunsHandler({
416
437
  };
417
438
  return workflowRuns;
418
439
  } catch (error) {
419
- return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
440
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow runs");
441
+ }
442
+ }
443
+ async function cancelWorkflowRunHandler({
444
+ mastra,
445
+ workflowId,
446
+ runId
447
+ }) {
448
+ try {
449
+ if (!workflowId) {
450
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
451
+ }
452
+ if (!runId) {
453
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
454
+ }
455
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
456
+ if (!workflow) {
457
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
458
+ }
459
+ const run = await workflow.getWorkflowRunById(runId);
460
+ if (!run) {
461
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
462
+ }
463
+ const _run = await workflow.createRunAsync({ runId });
464
+ await _run.cancel();
465
+ return { message: "Workflow run cancelled" };
466
+ } catch (error) {
467
+ return chunkPZQDCRPV_cjs.handleError(error, "Error canceling workflow run");
468
+ }
469
+ }
470
+ async function sendWorkflowRunEventHandler({
471
+ mastra,
472
+ workflowId,
473
+ runId,
474
+ event,
475
+ data
476
+ }) {
477
+ try {
478
+ if (!workflowId) {
479
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
480
+ }
481
+ if (!runId) {
482
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to send workflow run event" });
483
+ }
484
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
485
+ if (!workflow) {
486
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
487
+ }
488
+ const run = await workflow.getWorkflowRunById(runId);
489
+ if (!run) {
490
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
491
+ }
492
+ const _run = await workflow.createRunAsync({ runId });
493
+ await _run.sendEvent(event, data);
494
+ return { message: "Workflow run event sent" };
495
+ } catch (error) {
496
+ return chunkPZQDCRPV_cjs.handleError(error, "Error sending workflow run event");
420
497
  }
421
498
  }
422
499
 
500
+ exports.cancelWorkflowRunHandler = cancelWorkflowRunHandler;
423
501
  exports.createWorkflowRunHandler = createWorkflowRunHandler;
424
502
  exports.getWorkflowByIdHandler = getWorkflowByIdHandler;
425
503
  exports.getWorkflowRunByIdHandler = getWorkflowRunByIdHandler;
@@ -428,6 +506,7 @@ exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
428
506
  exports.getWorkflowsHandler = getWorkflowsHandler;
429
507
  exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
430
508
  exports.resumeWorkflowHandler = resumeWorkflowHandler;
509
+ exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
431
510
  exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
432
511
  exports.startWorkflowRunHandler = startWorkflowRunHandler;
433
512
  exports.streamWorkflowHandler = streamWorkflowHandler;
@@ -1,7 +1,7 @@
1
1
  import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
- import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-M5ABIP7D.js';
4
- import { HTTPException } from './chunk-NYN7KFXL.js';
2
+ import { validateBody } from './chunk-RSEO4XPX.js';
3
+ import { handleError } from './chunk-LF7P5PLR.js';
4
+ import { HTTPException } from './chunk-LCM566I4.js';
5
5
  import { __export } from './chunk-MLKGABMK.js';
6
6
  import { RuntimeContext } from '@mastra/core/runtime-context';
7
7
 
@@ -263,7 +263,7 @@ async function streamGenerateHandler({
263
263
  });
264
264
  return streamResponse;
265
265
  } catch (error) {
266
- throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
266
+ return handleError(error, "error streaming agent response");
267
267
  }
268
268
  }
269
269
 
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
5
+
6
+ // src/server/handlers/scores.ts
7
+ var scores_exports = {};
8
+ chunk75ZPJI57_cjs.__export(scores_exports, {
9
+ getScorerHandler: () => getScorerHandler,
10
+ getScorersHandler: () => getScorersHandler,
11
+ getScoresByEntityIdHandler: () => getScoresByEntityIdHandler,
12
+ getScoresByRunIdHandler: () => getScoresByRunIdHandler,
13
+ getScoresByScorerIdHandler: () => getScoresByScorerIdHandler,
14
+ saveScoreHandler: () => saveScoreHandler
15
+ });
16
+ async function getScorersFromSystem({
17
+ mastra,
18
+ runtimeContext
19
+ }) {
20
+ const agents = mastra.getAgents();
21
+ const workflows = mastra.getWorkflows();
22
+ const scorersMap = /* @__PURE__ */ new Map();
23
+ for (const [agentId, agent] of Object.entries(agents)) {
24
+ const scorers = await agent.getScorers({
25
+ runtimeContext
26
+ }) || {};
27
+ if (Object.keys(scorers).length > 0) {
28
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
29
+ if (scorersMap.has(scorerId)) {
30
+ scorersMap.get(scorerId)?.agentIds.push(agentId);
31
+ } else {
32
+ scorersMap.set(scorerId, {
33
+ workflowIds: [],
34
+ ...scorer,
35
+ agentIds: [agentId]
36
+ });
37
+ }
38
+ }
39
+ }
40
+ }
41
+ for (const [workflowId, workflow] of Object.entries(workflows)) {
42
+ const scorers = await workflow.getScorers({
43
+ runtimeContext
44
+ }) || {};
45
+ if (Object.keys(scorers).length > 0) {
46
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
47
+ if (scorersMap.has(scorerId)) {
48
+ scorersMap.get(scorerId)?.workflowIds.push(workflowId);
49
+ } else {
50
+ scorersMap.set(scorerId, {
51
+ agentIds: [],
52
+ ...scorer,
53
+ workflowIds: [workflowId]
54
+ });
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return Object.fromEntries(scorersMap.entries());
60
+ }
61
+ async function getScorersHandler({ mastra, runtimeContext }) {
62
+ const scorers = await getScorersFromSystem({
63
+ mastra,
64
+ runtimeContext
65
+ });
66
+ return scorers;
67
+ }
68
+ async function getScorerHandler({
69
+ mastra,
70
+ scorerId,
71
+ runtimeContext
72
+ }) {
73
+ const scorers = await getScorersFromSystem({
74
+ mastra,
75
+ runtimeContext
76
+ });
77
+ const scorer = scorers[scorerId];
78
+ if (!scorer) {
79
+ return null;
80
+ }
81
+ return scorer;
82
+ }
83
+ async function getScoresByRunIdHandler({
84
+ mastra,
85
+ runId,
86
+ pagination
87
+ }) {
88
+ try {
89
+ const scores = await mastra.getStorage()?.getScoresByRunId?.({
90
+ runId,
91
+ pagination
92
+ }) || [];
93
+ return scores;
94
+ } catch (error) {
95
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by run id");
96
+ }
97
+ }
98
+ async function getScoresByScorerIdHandler({
99
+ mastra,
100
+ scorerId,
101
+ pagination,
102
+ entityId,
103
+ entityType
104
+ }) {
105
+ try {
106
+ const scores = await mastra.getStorage()?.getScoresByScorerId?.({
107
+ scorerId,
108
+ pagination,
109
+ entityId,
110
+ entityType
111
+ }) || [];
112
+ return scores;
113
+ } catch (error) {
114
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by scorer id");
115
+ }
116
+ }
117
+ async function getScoresByEntityIdHandler({
118
+ mastra,
119
+ entityId,
120
+ entityType,
121
+ pagination
122
+ }) {
123
+ try {
124
+ let entityIdToUse = entityId;
125
+ if (entityType === "AGENT") {
126
+ const agent = mastra.getAgentById(entityId);
127
+ entityIdToUse = agent.id;
128
+ } else if (entityType === "WORKFLOW") {
129
+ const workflow = mastra.getWorkflowById(entityId);
130
+ entityIdToUse = workflow.id;
131
+ }
132
+ const scores = await mastra.getStorage()?.getScoresByEntityId?.({
133
+ entityId: entityIdToUse,
134
+ entityType,
135
+ pagination
136
+ }) || [];
137
+ return scores;
138
+ } catch (error) {
139
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting scores by entity id");
140
+ }
141
+ }
142
+ async function saveScoreHandler({ mastra, score }) {
143
+ try {
144
+ const scores = await mastra.getStorage()?.saveScore?.(score) || [];
145
+ return scores;
146
+ } catch (error) {
147
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving score");
148
+ }
149
+ }
150
+
151
+ exports.getScorerHandler = getScorerHandler;
152
+ exports.getScorersHandler = getScorersHandler;
153
+ exports.getScoresByEntityIdHandler = getScoresByEntityIdHandler;
154
+ exports.getScoresByRunIdHandler = getScoresByRunIdHandler;
155
+ exports.getScoresByScorerIdHandler = getScoresByScorerIdHandler;
156
+ exports.saveScoreHandler = saveScoreHandler;
157
+ exports.scores_exports = scores_exports;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
4
4
 
5
5
  // src/server/handlers/utils.ts
6
6
  function validateBody(body) {
@@ -11,7 +11,7 @@ function validateBody(body) {
11
11
  return acc;
12
12
  }, {});
13
13
  if (Object.keys(errorResponse).length > 0) {
14
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
14
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
15
15
  }
16
16
  }
17
17
 
@@ -1,6 +1,6 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
 
6
6
  // src/server/handlers/network.ts