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

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 (78) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/_tsup-dts-rollup.d.cts +212 -23
  3. package/dist/_tsup-dts-rollup.d.ts +212 -23
  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-MEGCYGBU.js → chunk-36BLNJHS.js} +37 -37
  7. package/dist/chunk-424T5F2J.cjs +157 -0
  8. package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
  9. package/dist/{chunk-L3VURYKY.cjs → chunk-6KP2OBYA.cjs} +177 -68
  10. package/dist/chunk-6T5JUKOQ.js +149 -0
  11. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  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-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  15. package/dist/{chunk-LI436ITD.cjs → chunk-HISYIDYH.cjs} +37 -37
  16. package/dist/{chunk-Z3PTO2AK.cjs → chunk-HRSAZUIK.cjs} +20 -20
  17. package/dist/{chunk-EP3XVEVC.cjs → chunk-I5JKUCGE.cjs} +50 -20
  18. package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
  19. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  20. package/dist/chunk-LF7P5PLR.js +14 -0
  21. package/dist/chunk-PZQDCRPV.cjs +16 -0
  22. package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
  23. package/dist/chunk-R3I7AJVL.js +507 -0
  24. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  25. package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
  26. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  27. package/dist/{chunk-72LOJGUV.js → chunk-T7HAZC2E.js} +118 -12
  28. package/dist/chunk-TTPJHP42.cjs +522 -0
  29. package/dist/{chunk-NGHSYB5B.cjs → chunk-UCV4247U.cjs} +43 -43
  30. package/dist/{chunk-2BCWG3EZ.js → chunk-VTTN2FW3.js} +36 -7
  31. package/dist/{chunk-EWLR2PNT.js → chunk-WBRFIHSF.js} +4 -4
  32. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  33. package/dist/{chunk-E2LP4J6K.js → chunk-ZYAFP2AV.js} +8 -8
  34. package/dist/server/handlers/agents.cjs +11 -7
  35. package/dist/server/handlers/agents.d.cts +1 -0
  36. package/dist/server/handlers/agents.d.ts +1 -0
  37. package/dist/server/handlers/agents.js +1 -1
  38. package/dist/server/handlers/error.cjs +2 -2
  39. package/dist/server/handlers/error.js +1 -1
  40. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  41. package/dist/server/handlers/legacyWorkflows.js +1 -1
  42. package/dist/server/handlers/logs.cjs +4 -4
  43. package/dist/server/handlers/logs.js +1 -1
  44. package/dist/server/handlers/memory.cjs +29 -9
  45. package/dist/server/handlers/memory.d.cts +5 -0
  46. package/dist/server/handlers/memory.d.ts +5 -0
  47. package/dist/server/handlers/memory.js +1 -1
  48. package/dist/server/handlers/network.cjs +5 -5
  49. package/dist/server/handlers/network.js +1 -1
  50. package/dist/server/handlers/scores.cjs +30 -0
  51. package/dist/server/handlers/scores.d.cts +6 -0
  52. package/dist/server/handlers/scores.d.ts +6 -0
  53. package/dist/server/handlers/scores.js +1 -0
  54. package/dist/server/handlers/telemetry.cjs +3 -3
  55. package/dist/server/handlers/telemetry.js +1 -1
  56. package/dist/server/handlers/tools.cjs +5 -5
  57. package/dist/server/handlers/tools.js +1 -1
  58. package/dist/server/handlers/utils.cjs +2 -2
  59. package/dist/server/handlers/utils.js +1 -1
  60. package/dist/server/handlers/vNextNetwork.cjs +23 -23
  61. package/dist/server/handlers/vNextNetwork.js +4 -4
  62. package/dist/server/handlers/vector.cjs +7 -7
  63. package/dist/server/handlers/vector.js +1 -1
  64. package/dist/server/handlers/voice.cjs +5 -5
  65. package/dist/server/handlers/voice.js +1 -1
  66. package/dist/server/handlers/workflows.cjs +25 -13
  67. package/dist/server/handlers/workflows.d.cts +3 -0
  68. package/dist/server/handlers/workflows.d.ts +3 -0
  69. package/dist/server/handlers/workflows.js +1 -1
  70. package/dist/server/handlers.cjs +28 -23
  71. package/dist/server/handlers.d.cts +3 -2
  72. package/dist/server/handlers.d.ts +3 -2
  73. package/dist/server/handlers.js +11 -10
  74. package/package.json +8 -7
  75. package/dist/chunk-64U3UDTH.cjs +0 -13
  76. package/dist/chunk-M5ABIP7D.js +0 -11
  77. package/dist/chunk-RQ2Z56EC.cjs +0 -251
  78. package/dist/chunk-XUIJ7WRT.js +0 -241
@@ -1,12 +1,13 @@
1
- import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { stringify, esm_default } from './chunk-36BLNJHS.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
  import { ReadableStream } from 'stream/web';
6
6
 
7
7
  // src/server/handlers/workflows.ts
8
8
  var workflows_exports = {};
9
9
  __export(workflows_exports, {
10
+ cancelWorkflowRunHandler: () => cancelWorkflowRunHandler,
10
11
  createWorkflowRunHandler: () => createWorkflowRunHandler,
11
12
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
12
13
  getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
@@ -15,11 +16,32 @@ __export(workflows_exports, {
15
16
  getWorkflowsHandler: () => getWorkflowsHandler,
16
17
  resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
17
18
  resumeWorkflowHandler: () => resumeWorkflowHandler,
19
+ sendWorkflowRunEventHandler: () => sendWorkflowRunEventHandler,
18
20
  startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
19
21
  startWorkflowRunHandler: () => startWorkflowRunHandler,
22
+ streamVNextWorkflowHandler: () => streamVNextWorkflowHandler,
20
23
  streamWorkflowHandler: () => streamWorkflowHandler,
21
24
  watchWorkflowHandler: () => watchWorkflowHandler
22
25
  });
26
+ function getSteps(steps, path) {
27
+ return Object.entries(steps).reduce((acc, [key, step]) => {
28
+ const fullKey = path ? `${path}.${key}` : key;
29
+ acc[fullKey] = {
30
+ id: step.id,
31
+ description: step.description,
32
+ inputSchema: step.inputSchema ? stringify(esm_default(step.inputSchema)) : void 0,
33
+ outputSchema: step.outputSchema ? stringify(esm_default(step.outputSchema)) : void 0,
34
+ resumeSchema: step.resumeSchema ? stringify(esm_default(step.resumeSchema)) : void 0,
35
+ suspendSchema: step.suspendSchema ? stringify(esm_default(step.suspendSchema)) : void 0,
36
+ isWorkflow: step.component === "WORKFLOW"
37
+ };
38
+ if (step.component === "WORKFLOW" && step.steps) {
39
+ const nestedSteps = getSteps(step.steps, fullKey) || {};
40
+ acc = { ...acc, ...nestedSteps };
41
+ }
42
+ return acc;
43
+ }, {});
44
+ }
23
45
  async function getWorkflowsHandler({ mastra }) {
24
46
  try {
25
47
  const workflows = mastra.getWorkflows({ serialized: false });
@@ -38,6 +60,7 @@ async function getWorkflowsHandler({ mastra }) {
38
60
  };
39
61
  return acc2;
40
62
  }, {}),
63
+ allSteps: getSteps(workflow.steps) || {},
41
64
  stepGraph: workflow.serializedStepGraph,
42
65
  inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
43
66
  outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
@@ -46,7 +69,7 @@ async function getWorkflowsHandler({ mastra }) {
46
69
  }, {});
47
70
  return _workflows;
48
71
  } catch (error) {
49
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
72
+ return handleError(error, "Error getting workflows");
50
73
  }
51
74
  }
52
75
  async function getWorkflowsFromSystem({ mastra, workflowId }) {
@@ -104,6 +127,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
104
127
  };
105
128
  return acc;
106
129
  }, {}),
130
+ allSteps: getSteps(workflow.steps) || {},
107
131
  name: workflow.name,
108
132
  description: workflow.description,
109
133
  stepGraph: workflow.serializedStepGraph,
@@ -111,7 +135,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
111
135
  outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
112
136
  };
113
137
  } catch (error) {
114
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
138
+ return handleError(error, "Error getting workflow");
115
139
  }
116
140
  }
117
141
  async function getWorkflowRunByIdHandler({
@@ -136,7 +160,7 @@ async function getWorkflowRunByIdHandler({
136
160
  }
137
161
  return run;
138
162
  } catch (error) {
139
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
163
+ return handleError(error, "Error getting workflow run");
140
164
  }
141
165
  }
142
166
  async function getWorkflowRunExecutionResultHandler({
@@ -161,9 +185,7 @@ async function getWorkflowRunExecutionResultHandler({
161
185
  }
162
186
  return executionResult;
163
187
  } catch (error) {
164
- throw new HTTPException(500, {
165
- message: error?.message || "Error getting workflow run execution result"
166
- });
188
+ return handleError(error, "Error getting workflow run execution result");
167
189
  }
168
190
  }
169
191
  async function createWorkflowRunHandler({
@@ -182,7 +204,7 @@ async function createWorkflowRunHandler({
182
204
  const run = await workflow.createRunAsync({ runId: prevRunId });
183
205
  return { runId: run.runId };
184
206
  } catch (error) {
185
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
207
+ return handleError(error, "Error creating workflow run");
186
208
  }
187
209
  }
188
210
  async function startAsyncWorkflowHandler({
@@ -207,7 +229,7 @@ async function startAsyncWorkflowHandler({
207
229
  });
208
230
  return result;
209
231
  } catch (error) {
210
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
232
+ return handleError(error, "Error starting async workflow");
211
233
  }
212
234
  }
213
235
  async function startWorkflowRunHandler({
@@ -319,6 +341,34 @@ async function streamWorkflowHandler({
319
341
  return handleError(error, "Error executing workflow");
320
342
  }
321
343
  }
344
+ async function streamVNextWorkflowHandler({
345
+ mastra,
346
+ runtimeContext,
347
+ workflowId,
348
+ runId,
349
+ inputData
350
+ }) {
351
+ try {
352
+ if (!workflowId) {
353
+ throw new HTTPException(400, { message: "Workflow ID is required" });
354
+ }
355
+ if (!runId) {
356
+ throw new HTTPException(400, { message: "runId required to stream workflow" });
357
+ }
358
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
359
+ if (!workflow) {
360
+ throw new HTTPException(404, { message: "Workflow not found" });
361
+ }
362
+ const run = await workflow.createRunAsync({ runId });
363
+ const result = run.streamVNext({
364
+ inputData,
365
+ runtimeContext
366
+ });
367
+ return result;
368
+ } catch (error) {
369
+ return handleError(error, "Error streaming workflow");
370
+ }
371
+ }
322
372
  async function resumeAsyncWorkflowHandler({
323
373
  mastra,
324
374
  workflowId,
@@ -417,5 +467,61 @@ async function getWorkflowRunsHandler({
417
467
  return handleError(error, "Error getting workflow runs");
418
468
  }
419
469
  }
470
+ async function cancelWorkflowRunHandler({
471
+ mastra,
472
+ workflowId,
473
+ runId
474
+ }) {
475
+ try {
476
+ if (!workflowId) {
477
+ throw new HTTPException(400, { message: "Workflow ID is required" });
478
+ }
479
+ if (!runId) {
480
+ throw new HTTPException(400, { message: "runId required to cancel workflow run" });
481
+ }
482
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
483
+ if (!workflow) {
484
+ throw new HTTPException(404, { message: "Workflow not found" });
485
+ }
486
+ const run = await workflow.getWorkflowRunById(runId);
487
+ if (!run) {
488
+ throw new HTTPException(404, { message: "Workflow run not found" });
489
+ }
490
+ const _run = await workflow.createRunAsync({ runId });
491
+ await _run.cancel();
492
+ return { message: "Workflow run cancelled" };
493
+ } catch (error) {
494
+ return handleError(error, "Error canceling workflow run");
495
+ }
496
+ }
497
+ async function sendWorkflowRunEventHandler({
498
+ mastra,
499
+ workflowId,
500
+ runId,
501
+ event,
502
+ data
503
+ }) {
504
+ try {
505
+ if (!workflowId) {
506
+ throw new HTTPException(400, { message: "Workflow ID is required" });
507
+ }
508
+ if (!runId) {
509
+ throw new HTTPException(400, { message: "runId required to send workflow run event" });
510
+ }
511
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
512
+ if (!workflow) {
513
+ throw new HTTPException(404, { message: "Workflow not found" });
514
+ }
515
+ const run = await workflow.getWorkflowRunById(runId);
516
+ if (!run) {
517
+ throw new HTTPException(404, { message: "Workflow run not found" });
518
+ }
519
+ const _run = await workflow.createRunAsync({ runId });
520
+ await _run.sendEvent(event, data);
521
+ return { message: "Workflow run event sent" };
522
+ } catch (error) {
523
+ return handleError(error, "Error sending workflow run event");
524
+ }
525
+ }
420
526
 
421
- export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
527
+ export { cancelWorkflowRunHandler, createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, sendWorkflowRunEventHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamVNextWorkflowHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };