@mastra/server 0.10.9 → 0.10.10-alpha.1

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 (59) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +11 -1
  2. package/dist/_tsup-dts-rollup.d.ts +11 -1
  3. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  4. package/dist/{chunk-DPRB3R7Y.cjs → chunk-2SLFAFTR.cjs} +12 -12
  5. package/dist/{chunk-BOXE6WSV.js → chunk-4D66QEKC.js} +2 -2
  6. package/dist/{chunk-7GQJAMTA.js → chunk-5PQQ42EZ.js} +2 -2
  7. package/dist/{chunk-TVBPFPTN.cjs → chunk-7TP2LX5L.cjs} +16 -16
  8. package/dist/{chunk-7524QH7G.cjs → chunk-B2PAS2IB.cjs} +89 -58
  9. package/dist/{chunk-4QBIUKVY.js → chunk-BK4XT6EG.js} +3 -3
  10. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  11. package/dist/{chunk-VMXLEF54.js → chunk-CRCR3ZUK.js} +3 -3
  12. package/dist/{chunk-3DKDT264.cjs → chunk-DN7K6FJK.cjs} +34 -34
  13. package/dist/{chunk-FGGMQCPP.cjs → chunk-FRVBFMO2.cjs} +15 -15
  14. package/dist/{chunk-ULFULEW4.cjs → chunk-G7KH752Y.cjs} +5 -5
  15. package/dist/{chunk-Z5TH5F35.js → chunk-H7DMHBKY.js} +33 -3
  16. package/dist/{chunk-TGZIR6AK.cjs → chunk-JMLYCXMK.cjs} +36 -36
  17. package/dist/{chunk-G37NVEDX.js → chunk-KHZKYUNR.js} +3 -3
  18. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  19. package/dist/{chunk-QDOJJCS4.js → chunk-LF7P5PLR.js} +4 -2
  20. package/dist/{chunk-DFJUGWNU.js → chunk-LRCAAFUA.js} +3 -3
  21. package/dist/{chunk-BWHGBV3K.cjs → chunk-LZ3VJXSO.cjs} +14 -14
  22. package/dist/{chunk-LTJNMM2Y.js → chunk-MKLYEKEF.js} +3 -3
  23. package/dist/{chunk-MTR2B27E.cjs → chunk-PZQDCRPV.cjs} +5 -3
  24. package/dist/{chunk-CNVDCLSY.cjs → chunk-QGX47B5D.cjs} +7 -7
  25. package/dist/{chunk-BP24Z4WG.js → chunk-RG473F6Y.js} +2 -2
  26. package/dist/{chunk-L3N7ST2Z.cjs → chunk-RHSWAXKB.cjs} +22 -22
  27. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  28. package/dist/{chunk-FVMGZKFD.js → chunk-WNVFNNWN.js} +2 -2
  29. package/dist/server/handlers/agents.cjs +7 -7
  30. package/dist/server/handlers/agents.js +1 -1
  31. package/dist/server/handlers/error.cjs +2 -2
  32. package/dist/server/handlers/error.js +1 -1
  33. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  34. package/dist/server/handlers/legacyWorkflows.js +1 -1
  35. package/dist/server/handlers/logs.cjs +4 -4
  36. package/dist/server/handlers/logs.js +1 -1
  37. package/dist/server/handlers/memory.cjs +9 -9
  38. package/dist/server/handlers/memory.js +1 -1
  39. package/dist/server/handlers/network.cjs +5 -5
  40. package/dist/server/handlers/network.js +1 -1
  41. package/dist/server/handlers/telemetry.cjs +3 -3
  42. package/dist/server/handlers/telemetry.js +1 -1
  43. package/dist/server/handlers/tools.cjs +5 -5
  44. package/dist/server/handlers/tools.js +1 -1
  45. package/dist/server/handlers/utils.cjs +2 -2
  46. package/dist/server/handlers/utils.js +1 -1
  47. package/dist/server/handlers/vNextNetwork.cjs +18 -18
  48. package/dist/server/handlers/vNextNetwork.js +3 -3
  49. package/dist/server/handlers/vector.cjs +7 -7
  50. package/dist/server/handlers/vector.js +1 -1
  51. package/dist/server/handlers/voice.cjs +5 -5
  52. package/dist/server/handlers/voice.js +1 -1
  53. package/dist/server/handlers/workflows.cjs +18 -14
  54. package/dist/server/handlers/workflows.d.cts +1 -0
  55. package/dist/server/handlers/workflows.d.ts +1 -0
  56. package/dist/server/handlers/workflows.js +1 -1
  57. package/dist/server/handlers.cjs +20 -20
  58. package/dist/server/handlers.js +10 -10
  59. package/package.json +2 -2
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
4
- var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.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
 
@@ -18,6 +18,7 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
18
18
  getWorkflowsHandler: () => getWorkflowsHandler,
19
19
  resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
20
20
  resumeWorkflowHandler: () => resumeWorkflowHandler,
21
+ sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
21
22
  startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
22
23
  startWorkflowRunHandler: () => startWorkflowRunHandler,
23
24
  streamWorkflowHandler: () => streamWorkflowHandler,
@@ -69,13 +70,13 @@ async function getWorkflowsHandler({ mastra }) {
69
70
  }, {});
70
71
  return _workflows;
71
72
  } catch (error) {
72
- return chunkMTR2B27E_cjs.handleError(error, "Error getting workflows");
73
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflows");
73
74
  }
74
75
  }
75
76
  async function getWorkflowsFromSystem({ mastra, workflowId }) {
76
77
  const logger = mastra.getLogger();
77
78
  if (!workflowId) {
78
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
79
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
79
80
  }
80
81
  let workflow;
81
82
  try {
@@ -102,18 +103,18 @@ async function getWorkflowsFromSystem({ mastra, workflowId }) {
102
103
  }
103
104
  }
104
105
  if (!workflow) {
105
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
106
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
106
107
  }
107
108
  return { workflow };
108
109
  }
109
110
  async function getWorkflowByIdHandler({ mastra, workflowId }) {
110
111
  try {
111
112
  if (!workflowId) {
112
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
113
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
113
114
  }
114
115
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
115
116
  if (!workflow) {
116
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
117
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
117
118
  }
118
119
  return {
119
120
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
@@ -135,7 +136,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
135
136
  outputSchema: workflow.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(workflow.outputSchema)) : void 0
136
137
  };
137
138
  } catch (error) {
138
- return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow");
139
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow");
139
140
  }
140
141
  }
141
142
  async function getWorkflowRunByIdHandler({
@@ -145,22 +146,22 @@ async function getWorkflowRunByIdHandler({
145
146
  }) {
146
147
  try {
147
148
  if (!workflowId) {
148
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
149
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
149
150
  }
150
151
  if (!runId) {
151
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
152
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
152
153
  }
153
154
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
154
155
  if (!workflow) {
155
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
156
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
156
157
  }
157
158
  const run = await workflow.getWorkflowRunById(runId);
158
159
  if (!run) {
159
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
160
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
160
161
  }
161
162
  return run;
162
163
  } catch (error) {
163
- return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow run");
164
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow run");
164
165
  }
165
166
  }
166
167
  async function getWorkflowRunExecutionResultHandler({
@@ -170,22 +171,22 @@ async function getWorkflowRunExecutionResultHandler({
170
171
  }) {
171
172
  try {
172
173
  if (!workflowId) {
173
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
174
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
174
175
  }
175
176
  if (!runId) {
176
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
177
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Run ID is required" });
177
178
  }
178
179
  const workflow = mastra.getWorkflow(workflowId);
179
180
  if (!workflow) {
180
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
181
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
181
182
  }
182
183
  const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
183
184
  if (!executionResult) {
184
- 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" });
185
186
  }
186
187
  return executionResult;
187
188
  } catch (error) {
188
- return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow run execution result");
189
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow run execution result");
189
190
  }
190
191
  }
191
192
  async function createWorkflowRunHandler({
@@ -195,16 +196,16 @@ async function createWorkflowRunHandler({
195
196
  }) {
196
197
  try {
197
198
  if (!workflowId) {
198
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
199
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
199
200
  }
200
201
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
201
202
  if (!workflow) {
202
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
203
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
203
204
  }
204
205
  const run = await workflow.createRunAsync({ runId: prevRunId });
205
206
  return { runId: run.runId };
206
207
  } catch (error) {
207
- return chunkMTR2B27E_cjs.handleError(error, "Error creating workflow run");
208
+ return chunkPZQDCRPV_cjs.handleError(error, "Error creating workflow run");
208
209
  }
209
210
  }
210
211
  async function startAsyncWorkflowHandler({
@@ -216,11 +217,11 @@ async function startAsyncWorkflowHandler({
216
217
  }) {
217
218
  try {
218
219
  if (!workflowId) {
219
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
220
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
220
221
  }
221
222
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
222
223
  if (!workflow) {
223
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
224
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
224
225
  }
225
226
  const _run = await workflow.createRunAsync({ runId });
226
227
  const result = await _run.start({
@@ -229,7 +230,7 @@ async function startAsyncWorkflowHandler({
229
230
  });
230
231
  return result;
231
232
  } catch (error) {
232
- return chunkMTR2B27E_cjs.handleError(error, "Error starting async workflow");
233
+ return chunkPZQDCRPV_cjs.handleError(error, "Error starting async workflow");
233
234
  }
234
235
  }
235
236
  async function startWorkflowRunHandler({
@@ -241,18 +242,18 @@ async function startWorkflowRunHandler({
241
242
  }) {
242
243
  try {
243
244
  if (!workflowId) {
244
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
245
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
245
246
  }
246
247
  if (!runId) {
247
- 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" });
248
249
  }
249
250
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
250
251
  if (!workflow) {
251
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
252
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
252
253
  }
253
254
  const run = await workflow.getWorkflowRunById(runId);
254
255
  if (!run) {
255
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
256
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
256
257
  }
257
258
  const _run = await workflow.createRunAsync({ runId });
258
259
  void _run.start({
@@ -261,7 +262,7 @@ async function startWorkflowRunHandler({
261
262
  });
262
263
  return { message: "Workflow run started" };
263
264
  } catch (e) {
264
- return chunkMTR2B27E_cjs.handleError(e, "Error starting workflow run");
265
+ return chunkPZQDCRPV_cjs.handleError(e, "Error starting workflow run");
265
266
  }
266
267
  }
267
268
  async function watchWorkflowHandler({
@@ -271,18 +272,18 @@ async function watchWorkflowHandler({
271
272
  }) {
272
273
  try {
273
274
  if (!workflowId) {
274
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
275
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
275
276
  }
276
277
  if (!runId) {
277
- 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" });
278
279
  }
279
280
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
280
281
  if (!workflow) {
281
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
282
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
282
283
  }
283
284
  const run = await workflow.getWorkflowRunById(runId);
284
285
  if (!run) {
285
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
286
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
286
287
  }
287
288
  const _run = await workflow.createRunAsync({ runId });
288
289
  let unwatch;
@@ -310,7 +311,7 @@ async function watchWorkflowHandler({
310
311
  });
311
312
  return stream;
312
313
  } catch (error) {
313
- return chunkMTR2B27E_cjs.handleError(error, "Error watching workflow");
314
+ return chunkPZQDCRPV_cjs.handleError(error, "Error watching workflow");
314
315
  }
315
316
  }
316
317
  async function streamWorkflowHandler({
@@ -322,14 +323,14 @@ async function streamWorkflowHandler({
322
323
  }) {
323
324
  try {
324
325
  if (!workflowId) {
325
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
326
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
326
327
  }
327
328
  if (!runId) {
328
- 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" });
329
330
  }
330
331
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
331
332
  if (!workflow) {
332
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
333
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
333
334
  }
334
335
  const run = await workflow.createRunAsync({ runId });
335
336
  const result = run.stream({
@@ -338,7 +339,7 @@ async function streamWorkflowHandler({
338
339
  });
339
340
  return result;
340
341
  } catch (error) {
341
- return chunkMTR2B27E_cjs.handleError(error, "Error executing workflow");
342
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing workflow");
342
343
  }
343
344
  }
344
345
  async function resumeAsyncWorkflowHandler({
@@ -350,21 +351,21 @@ async function resumeAsyncWorkflowHandler({
350
351
  }) {
351
352
  try {
352
353
  if (!workflowId) {
353
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
354
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
354
355
  }
355
356
  if (!runId) {
356
- 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" });
357
358
  }
358
359
  if (!body.step) {
359
- 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" });
360
361
  }
361
362
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
362
363
  if (!workflow) {
363
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
364
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
364
365
  }
365
366
  const run = await workflow.getWorkflowRunById(runId);
366
367
  if (!run) {
367
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
368
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
368
369
  }
369
370
  const _run = await workflow.createRunAsync({ runId });
370
371
  const result = await _run.resume({
@@ -374,7 +375,7 @@ async function resumeAsyncWorkflowHandler({
374
375
  });
375
376
  return result;
376
377
  } catch (error) {
377
- return chunkMTR2B27E_cjs.handleError(error, "Error resuming workflow step");
378
+ return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow step");
378
379
  }
379
380
  }
380
381
  async function resumeWorkflowHandler({
@@ -386,21 +387,21 @@ async function resumeWorkflowHandler({
386
387
  }) {
387
388
  try {
388
389
  if (!workflowId) {
389
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
390
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
390
391
  }
391
392
  if (!runId) {
392
- 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" });
393
394
  }
394
395
  if (!body.step) {
395
- 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" });
396
397
  }
397
398
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
398
399
  if (!workflow) {
399
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
400
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
400
401
  }
401
402
  const run = await workflow.getWorkflowRunById(runId);
402
403
  if (!run) {
403
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
404
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
404
405
  }
405
406
  const _run = await workflow.createRunAsync({ runId });
406
407
  void _run.resume({
@@ -410,7 +411,7 @@ async function resumeWorkflowHandler({
410
411
  });
411
412
  return { message: "Workflow run resumed" };
412
413
  } catch (error) {
413
- return chunkMTR2B27E_cjs.handleError(error, "Error resuming workflow");
414
+ return chunkPZQDCRPV_cjs.handleError(error, "Error resuming workflow");
414
415
  }
415
416
  }
416
417
  async function getWorkflowRunsHandler({
@@ -424,11 +425,11 @@ async function getWorkflowRunsHandler({
424
425
  }) {
425
426
  try {
426
427
  if (!workflowId) {
427
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
428
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
428
429
  }
429
430
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
430
431
  if (!workflow) {
431
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
432
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
432
433
  }
433
434
  const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
434
435
  runs: [],
@@ -436,7 +437,7 @@ async function getWorkflowRunsHandler({
436
437
  };
437
438
  return workflowRuns;
438
439
  } catch (error) {
439
- return chunkMTR2B27E_cjs.handleError(error, "Error getting workflow runs");
440
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting workflow runs");
440
441
  }
441
442
  }
442
443
  async function cancelWorkflowRunHandler({
@@ -446,24 +447,53 @@ async function cancelWorkflowRunHandler({
446
447
  }) {
447
448
  try {
448
449
  if (!workflowId) {
449
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
450
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Workflow ID is required" });
450
451
  }
451
452
  if (!runId) {
452
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
453
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "runId required to cancel workflow run" });
453
454
  }
454
455
  const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
455
456
  if (!workflow) {
456
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
457
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow not found" });
457
458
  }
458
459
  const run = await workflow.getWorkflowRunById(runId);
459
460
  if (!run) {
460
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
461
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Workflow run not found" });
461
462
  }
462
463
  const _run = await workflow.createRunAsync({ runId });
463
464
  await _run.cancel();
464
465
  return { message: "Workflow run cancelled" };
465
466
  } catch (error) {
466
- return chunkMTR2B27E_cjs.handleError(error, "Error canceling workflow run");
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");
467
497
  }
468
498
  }
469
499
 
@@ -476,6 +506,7 @@ exports.getWorkflowRunsHandler = getWorkflowRunsHandler;
476
506
  exports.getWorkflowsHandler = getWorkflowsHandler;
477
507
  exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
478
508
  exports.resumeWorkflowHandler = resumeWorkflowHandler;
509
+ exports.sendWorkflowRunEventHandler = sendWorkflowRunEventHandler;
479
510
  exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
480
511
  exports.startWorkflowRunHandler = startWorkflowRunHandler;
481
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-QDOJJCS4.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
 
@@ -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-QDOJJCS4.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
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.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
 
8
8
  // src/server/handlers/memory.ts
@@ -25,11 +25,11 @@ async function getMemoryFromContext({
25
25
  }) {
26
26
  const agent = agentId ? mastra.getAgent(agentId) : null;
27
27
  if (agentId && !agent) {
28
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
28
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
29
29
  }
30
30
  const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
31
31
  if (networkId && !network) {
32
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
32
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
33
33
  }
34
34
  if (agent) {
35
35
  return agent?.getMemory() || mastra.getMemory();
@@ -52,7 +52,7 @@ async function getMemoryStatusHandler({
52
52
  }
53
53
  return { result: true };
54
54
  } catch (error) {
55
- return chunkMTR2B27E_cjs.handleError(error, "Error getting memory status");
55
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting memory status");
56
56
  }
57
57
  }
58
58
  async function getThreadsHandler({
@@ -65,13 +65,13 @@ async function getThreadsHandler({
65
65
  try {
66
66
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
67
67
  if (!memory) {
68
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
68
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
69
69
  }
70
- chunk57CJTIPW_cjs.validateBody({ resourceId });
70
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId });
71
71
  const threads = await memory.getThreadsByResourceId({ resourceId });
72
72
  return threads;
73
73
  } catch (error) {
74
- return chunkMTR2B27E_cjs.handleError(error, "Error getting threads");
74
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting threads");
75
75
  }
76
76
  }
77
77
  async function getThreadByIdHandler({
@@ -82,18 +82,18 @@ async function getThreadByIdHandler({
82
82
  runtimeContext
83
83
  }) {
84
84
  try {
85
- chunk57CJTIPW_cjs.validateBody({ threadId });
85
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
86
86
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
87
87
  if (!memory) {
88
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
88
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
89
89
  }
90
90
  const thread = await memory.getThreadById({ threadId });
91
91
  if (!thread) {
92
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
92
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
93
93
  }
94
94
  return thread;
95
95
  } catch (error) {
96
- return chunkMTR2B27E_cjs.handleError(error, "Error getting thread");
96
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting thread");
97
97
  }
98
98
  }
99
99
  async function saveMessagesHandler({
@@ -106,13 +106,13 @@ async function saveMessagesHandler({
106
106
  try {
107
107
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
108
108
  if (!memory) {
109
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
109
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
110
110
  }
111
111
  if (!body?.messages) {
112
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
112
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages are required" });
113
113
  }
114
114
  if (!Array.isArray(body.messages)) {
115
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
115
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages should be an array" });
116
116
  }
117
117
  const processedMessages = body.messages.map((message) => ({
118
118
  ...message,
@@ -122,7 +122,7 @@ async function saveMessagesHandler({
122
122
  const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
123
123
  return result;
124
124
  } catch (error) {
125
- return chunkMTR2B27E_cjs.handleError(error, "Error saving messages");
125
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving messages");
126
126
  }
127
127
  }
128
128
  async function createThreadHandler({
@@ -135,9 +135,9 @@ async function createThreadHandler({
135
135
  try {
136
136
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
137
137
  if (!memory) {
138
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
138
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
139
139
  }
140
- chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
140
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId: body?.resourceId });
141
141
  const result = await memory.createThread({
142
142
  resourceId: body?.resourceId,
143
143
  title: body?.title,
@@ -146,7 +146,7 @@ async function createThreadHandler({
146
146
  });
147
147
  return result;
148
148
  } catch (error) {
149
- return chunkMTR2B27E_cjs.handleError(error, "Error saving thread to memory");
149
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving thread to memory");
150
150
  }
151
151
  }
152
152
  async function updateThreadHandler({
@@ -160,17 +160,17 @@ async function updateThreadHandler({
160
160
  try {
161
161
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
162
162
  if (!body) {
163
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
163
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
164
164
  }
165
165
  const { title, metadata, resourceId } = body;
166
166
  const updatedAt = /* @__PURE__ */ new Date();
167
- chunk57CJTIPW_cjs.validateBody({ threadId });
167
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
168
168
  if (!memory) {
169
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
169
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
170
170
  }
171
171
  const thread = await memory.getThreadById({ threadId });
172
172
  if (!thread) {
173
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
173
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
174
174
  }
175
175
  const updatedThread = {
176
176
  ...thread,
@@ -183,7 +183,7 @@ async function updateThreadHandler({
183
183
  const result = await memory.saveThread({ thread: updatedThread });
184
184
  return result;
185
185
  } catch (error) {
186
- return chunkMTR2B27E_cjs.handleError(error, "Error updating thread");
186
+ return chunkPZQDCRPV_cjs.handleError(error, "Error updating thread");
187
187
  }
188
188
  }
189
189
  async function deleteThreadHandler({
@@ -194,19 +194,19 @@ async function deleteThreadHandler({
194
194
  runtimeContext
195
195
  }) {
196
196
  try {
197
- chunk57CJTIPW_cjs.validateBody({ threadId });
197
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
198
198
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
199
199
  if (!memory) {
200
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
200
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
201
201
  }
202
202
  const thread = await memory.getThreadById({ threadId });
203
203
  if (!thread) {
204
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
204
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
205
205
  }
206
206
  await memory.deleteThread(threadId);
207
207
  return { result: "Thread deleted" };
208
208
  } catch (error) {
209
- return chunkMTR2B27E_cjs.handleError(error, "Error deleting thread");
209
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting thread");
210
210
  }
211
211
  }
212
212
  async function getMessagesHandler({
@@ -218,17 +218,17 @@ async function getMessagesHandler({
218
218
  runtimeContext
219
219
  }) {
220
220
  if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
221
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
221
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
222
222
  }
223
223
  try {
224
- chunk57CJTIPW_cjs.validateBody({ threadId });
224
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
225
225
  const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
226
226
  if (!memory) {
227
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
227
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
228
228
  }
229
229
  const thread = await memory.getThreadById({ threadId });
230
230
  if (!thread) {
231
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
231
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
232
232
  }
233
233
  const result = await memory.query({
234
234
  threadId,
@@ -236,7 +236,7 @@ async function getMessagesHandler({
236
236
  });
237
237
  return { messages: result.messages, uiMessages: result.uiMessages };
238
238
  } catch (error) {
239
- return chunkMTR2B27E_cjs.handleError(error, "Error getting messages");
239
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting messages");
240
240
  }
241
241
  }
242
242