@mastra/server 2.0.3 → 2.0.4-alpha.0

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 (69) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +152 -10
  2. package/dist/_tsup-dts-rollup.d.ts +152 -10
  3. package/dist/{chunk-2FJURXCL.cjs → chunk-24EGIVT7.cjs} +34 -33
  4. package/dist/{chunk-3XTEV33Q.js → chunk-2KIW6AJK.js} +4 -3
  5. package/dist/{chunk-6Q7UXAYJ.cjs → chunk-3HQNCTZ2.cjs} +21 -20
  6. package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
  7. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  8. package/dist/chunk-5SN4U5AC.cjs +508 -0
  9. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  10. package/dist/chunk-75ZPJI57.cjs +9 -0
  11. package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
  12. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  13. package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
  14. package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
  15. package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
  16. package/dist/chunk-LIVAK2DM.js +2001 -0
  17. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  18. package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
  19. package/dist/chunk-MLKGABMK.js +7 -0
  20. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  21. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  22. package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
  23. package/dist/{chunk-M2RXDCPV.cjs → chunk-OHKAN72U.cjs} +76 -57
  24. package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
  25. package/dist/chunk-P6SCPDYW.js +500 -0
  26. package/dist/{chunk-GVBJ5I2S.js → chunk-Q6KMBIAN.js} +5 -4
  27. package/dist/{chunk-CHFORQ7J.cjs → chunk-RYUN5DF4.cjs} +45 -44
  28. package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
  29. package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
  30. package/dist/{chunk-OWNA6I2H.js → chunk-WVDUW4GI.js} +28 -9
  31. package/dist/{chunk-RBQASTUP.js → chunk-X3ZDCS52.js} +4 -3
  32. package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
  33. package/dist/chunk-YWLUOY3D.cjs +2004 -0
  34. package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
  35. package/dist/server/handlers/a2a.cjs +30 -0
  36. package/dist/server/handlers/a2a.d.cts +6 -0
  37. package/dist/server/handlers/a2a.d.ts +6 -0
  38. package/dist/server/handlers/a2a.js +1 -0
  39. package/dist/server/handlers/agents.cjs +7 -7
  40. package/dist/server/handlers/agents.js +1 -1
  41. package/dist/server/handlers/error.cjs +2 -2
  42. package/dist/server/handlers/error.js +1 -1
  43. package/dist/server/handlers/logs.cjs +4 -4
  44. package/dist/server/handlers/logs.js +1 -1
  45. package/dist/server/handlers/memory.cjs +9 -9
  46. package/dist/server/handlers/memory.js +1 -1
  47. package/dist/server/handlers/network.cjs +5 -5
  48. package/dist/server/handlers/network.js +1 -1
  49. package/dist/server/handlers/telemetry.cjs +3 -3
  50. package/dist/server/handlers/telemetry.js +1 -1
  51. package/dist/server/handlers/tools.cjs +5 -5
  52. package/dist/server/handlers/tools.js +1 -1
  53. package/dist/server/handlers/utils.cjs +2 -2
  54. package/dist/server/handlers/utils.js +1 -1
  55. package/dist/server/handlers/vNextWorkflows.cjs +11 -11
  56. package/dist/server/handlers/vNextWorkflows.js +1 -1
  57. package/dist/server/handlers/vector.cjs +7 -7
  58. package/dist/server/handlers/vector.js +1 -1
  59. package/dist/server/handlers/voice.cjs +4 -4
  60. package/dist/server/handlers/voice.js +1 -1
  61. package/dist/server/handlers/workflows.cjs +11 -11
  62. package/dist/server/handlers/workflows.js +1 -1
  63. package/dist/server/handlers.cjs +28 -23
  64. package/dist/server/handlers.d.cts +1 -0
  65. package/dist/server/handlers.d.ts +1 -0
  66. package/dist/server/handlers.js +11 -10
  67. package/package.json +6 -4
  68. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  69. package/dist/chunk-OMN3UI6X.js +0 -5576
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
2
 
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunkYWLUOY3D_cjs = require('./chunk-YWLUOY3D.cjs');
4
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
7
  var web = require('stream/web');
7
8
 
8
9
  // src/server/handlers/workflows.ts
9
10
  var workflows_exports = {};
10
- chunkFV45V6WC_cjs.__export(workflows_exports, {
11
+ chunk75ZPJI57_cjs.__export(workflows_exports, {
11
12
  createRunHandler: () => createRunHandler,
12
13
  getWorkflowByIdHandler: () => getWorkflowByIdHandler,
13
14
  getWorkflowRunHandler: () => getWorkflowRunHandler,
@@ -30,15 +31,15 @@ async function getWorkflowsHandler({ mastra }) {
30
31
  serializedStepGraph: workflow.serializedStepGraph,
31
32
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
32
33
  name: workflow.name,
33
- triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
34
+ triggerSchema: workflow.triggerSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.triggerSchema)) : void 0,
34
35
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
35
36
  const _step = step;
36
37
  acc2[key2] = {
37
38
  id: _step.id,
38
39
  description: _step.description,
39
40
  workflowId: _step.workflowId,
40
- inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
41
- outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
41
+ inputSchema: _step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.inputSchema)) : void 0,
42
+ outputSchema: _step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.outputSchema)) : void 0
42
43
  };
43
44
  return acc2;
44
45
  }, {})
@@ -47,17 +48,17 @@ async function getWorkflowsHandler({ mastra }) {
47
48
  }, {});
48
49
  return _workflows;
49
50
  } catch (error) {
50
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
51
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflows" });
51
52
  }
52
53
  }
53
54
  async function getWorkflowByIdHandler({ mastra, workflowId }) {
54
55
  try {
55
56
  if (!workflowId) {
56
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
57
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
57
58
  }
58
59
  const workflow = mastra.getWorkflow(workflowId);
59
60
  if (!workflow) {
60
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
61
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
61
62
  }
62
63
  return {
63
64
  stepGraph: workflow.stepGraph,
@@ -65,21 +66,21 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
65
66
  serializedStepGraph: workflow.serializedStepGraph,
66
67
  serializedStepSubscriberGraph: workflow.serializedStepSubscriberGraph,
67
68
  name: workflow.name,
68
- triggerSchema: workflow.triggerSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(workflow.triggerSchema)) : void 0,
69
+ triggerSchema: workflow.triggerSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(workflow.triggerSchema)) : void 0,
69
70
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
70
71
  const _step = step;
71
72
  acc[key] = {
72
73
  id: _step.id,
73
74
  description: _step.description,
74
75
  workflowId: _step.workflowId,
75
- inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
76
- outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
76
+ inputSchema: _step.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.inputSchema)) : void 0,
77
+ outputSchema: _step.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(_step.outputSchema)) : void 0
77
78
  };
78
79
  return acc;
79
80
  }, {})
80
81
  };
81
82
  } catch (error) {
82
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
83
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
83
84
  }
84
85
  }
85
86
  async function startAsyncWorkflowHandler({
@@ -91,11 +92,11 @@ async function startAsyncWorkflowHandler({
91
92
  }) {
92
93
  try {
93
94
  if (!workflowId) {
94
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
95
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
95
96
  }
96
97
  const workflow = mastra.getWorkflow(workflowId);
97
98
  if (!workflow) {
98
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
99
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
99
100
  }
100
101
  if (!runId) {
101
102
  const { start } = workflow.createRun();
@@ -107,7 +108,7 @@ async function startAsyncWorkflowHandler({
107
108
  }
108
109
  const run = workflow.getRun(runId);
109
110
  if (!run) {
110
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
111
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
111
112
  }
112
113
  const result = await run.start({
113
114
  triggerData,
@@ -115,7 +116,7 @@ async function startAsyncWorkflowHandler({
115
116
  });
116
117
  return result;
117
118
  } catch (error) {
118
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
119
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error executing workflow" });
119
120
  }
120
121
  }
121
122
  async function getWorkflowRunHandler({
@@ -125,22 +126,22 @@ async function getWorkflowRunHandler({
125
126
  }) {
126
127
  try {
127
128
  if (!workflowId) {
128
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
129
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
129
130
  }
130
131
  if (!runId) {
131
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Run ID is required" });
132
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Run ID is required" });
132
133
  }
133
134
  const workflow = mastra.getWorkflow(workflowId);
134
135
  if (!workflow) {
135
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
136
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
136
137
  }
137
138
  const run = workflow.getRun(runId);
138
139
  if (!run) {
139
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
140
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
140
141
  }
141
142
  return run;
142
143
  } catch (error) {
143
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
144
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow run" });
144
145
  }
145
146
  }
146
147
  async function createRunHandler({
@@ -150,16 +151,16 @@ async function createRunHandler({
150
151
  }) {
151
152
  try {
152
153
  if (!workflowId) {
153
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
154
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
154
155
  }
155
156
  const workflow = mastra.getWorkflow(workflowId);
156
157
  if (!workflow) {
157
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow not found" });
158
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
158
159
  }
159
160
  const { runId } = workflow.createRun({ runId: prevRunId });
160
161
  return { runId };
161
162
  } catch (error) {
162
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
163
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
163
164
  }
164
165
  }
165
166
  async function startWorkflowRunHandler({
@@ -171,15 +172,15 @@ async function startWorkflowRunHandler({
171
172
  }) {
172
173
  try {
173
174
  if (!workflowId) {
174
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
175
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
175
176
  }
176
177
  if (!runId) {
177
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to start run" });
178
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
178
179
  }
179
180
  const workflow = mastra.getWorkflow(workflowId);
180
181
  const run = workflow.getRun(runId);
181
182
  if (!run) {
182
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
183
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
183
184
  }
184
185
  await run.start({
185
186
  triggerData,
@@ -187,7 +188,7 @@ async function startWorkflowRunHandler({
187
188
  });
188
189
  return { message: "Workflow run started" };
189
190
  } catch (e) {
190
- return chunkZLBRQFDD_cjs.handleError(e, "Error starting workflow run");
191
+ return chunk64U3UDTH_cjs.handleError(e, "Error starting workflow run");
191
192
  }
192
193
  }
193
194
  async function watchWorkflowHandler({
@@ -197,15 +198,15 @@ async function watchWorkflowHandler({
197
198
  }) {
198
199
  try {
199
200
  if (!workflowId) {
200
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
201
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
201
202
  }
202
203
  if (!runId) {
203
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to watch workflow" });
204
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
204
205
  }
205
206
  const workflow = mastra.getWorkflow(workflowId);
206
207
  const run = workflow.getRun(runId);
207
208
  if (!run) {
208
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
209
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
209
210
  }
210
211
  let unwatch;
211
212
  let asyncRef = null;
@@ -231,7 +232,7 @@ async function watchWorkflowHandler({
231
232
  });
232
233
  return stream;
233
234
  } catch (error) {
234
- return chunkZLBRQFDD_cjs.handleError(error, "Error watching workflow");
235
+ return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
235
236
  }
236
237
  }
237
238
  async function resumeAsyncWorkflowHandler({
@@ -243,15 +244,15 @@ async function resumeAsyncWorkflowHandler({
243
244
  }) {
244
245
  try {
245
246
  if (!workflowId) {
246
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
247
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
247
248
  }
248
249
  if (!runId) {
249
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
250
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
250
251
  }
251
252
  const workflow = mastra.getWorkflow(workflowId);
252
253
  const run = workflow.getRun(runId);
253
254
  if (!run) {
254
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
255
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
255
256
  }
256
257
  const result = await run.resume({
257
258
  stepId: body.stepId,
@@ -260,7 +261,7 @@ async function resumeAsyncWorkflowHandler({
260
261
  });
261
262
  return result;
262
263
  } catch (error) {
263
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow step");
264
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow step");
264
265
  }
265
266
  }
266
267
  async function resumeWorkflowHandler({
@@ -272,15 +273,15 @@ async function resumeWorkflowHandler({
272
273
  }) {
273
274
  try {
274
275
  if (!workflowId) {
275
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
276
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
276
277
  }
277
278
  if (!runId) {
278
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "runId required to resume workflow" });
279
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
279
280
  }
280
281
  const workflow = mastra.getWorkflow(workflowId);
281
282
  const run = workflow.getRun(runId);
282
283
  if (!run) {
283
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
284
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
284
285
  }
285
286
  await run.resume({
286
287
  stepId: body.stepId,
@@ -289,7 +290,7 @@ async function resumeWorkflowHandler({
289
290
  });
290
291
  return { message: "Workflow run resumed" };
291
292
  } catch (error) {
292
- return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
293
+ return chunk64U3UDTH_cjs.handleError(error, "Error resuming workflow");
293
294
  }
294
295
  }
295
296
  async function getWorkflowRunsHandler({
@@ -303,7 +304,7 @@ async function getWorkflowRunsHandler({
303
304
  }) {
304
305
  try {
305
306
  if (!workflowId) {
306
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
307
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
307
308
  }
308
309
  const workflow = mastra.getWorkflow(workflowId);
309
310
  const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
@@ -312,7 +313,7 @@ async function getWorkflowRunsHandler({
312
313
  };
313
314
  return workflowRuns;
314
315
  } catch (error) {
315
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting workflow runs");
316
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting workflow runs");
316
317
  }
317
318
  }
318
319
 
@@ -1,7 +1,9 @@
1
- import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
- import { validateBody } from './chunk-L7XE5QTW.js';
3
- import { handleError } from './chunk-3AHQ5RGN.js';
4
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { stringify, esm_default } from './chunk-LIVAK2DM.js';
2
+ import { validateBody } from './chunk-H5PTF3Y4.js';
3
+ import { handleError } from './chunk-M5ABIP7D.js';
4
+ import { HTTPException } from './chunk-NYN7KFXL.js';
5
+ import { __export } from './chunk-MLKGABMK.js';
6
+ import { RuntimeContext } from '@mastra/core/di';
5
7
  import { isVercelTool } from '@mastra/core/tools';
6
8
 
7
9
  // src/server/handlers/tools.ts
@@ -56,7 +58,8 @@ function executeToolHandler(tools) {
56
58
  runId,
57
59
  toolId,
58
60
  data,
59
- runtimeContext
61
+ runtimeContext,
62
+ runtimeContextFromRequest
60
63
  }) => {
61
64
  try {
62
65
  if (!toolId) {
@@ -74,11 +77,15 @@ function executeToolHandler(tools) {
74
77
  const result2 = await tool.execute(data);
75
78
  return result2;
76
79
  }
80
+ const finalRuntimeContext = new RuntimeContext([
81
+ ...Array.from(runtimeContext.entries()),
82
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
83
+ ]);
77
84
  const result = await tool.execute({
78
85
  context: data,
79
86
  mastra,
80
87
  runId,
81
- runtimeContext
88
+ runtimeContext: finalRuntimeContext
82
89
  });
83
90
  return result;
84
91
  } catch (error) {
@@ -91,7 +98,8 @@ async function executeAgentToolHandler({
91
98
  agentId,
92
99
  toolId,
93
100
  data,
94
- runtimeContext
101
+ runtimeContext,
102
+ runtimeContextFromRequest
95
103
  }) {
96
104
  try {
97
105
  const agent = agentId ? mastra.getAgent(agentId) : null;
@@ -105,9 +113,13 @@ async function executeAgentToolHandler({
105
113
  if (!tool?.execute) {
106
114
  throw new HTTPException(400, { message: "Tool is not executable" });
107
115
  }
116
+ const finalRuntimeContext = new RuntimeContext([
117
+ ...Array.from(runtimeContext.entries()),
118
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
119
+ ]);
108
120
  const result = await tool.execute({
109
121
  context: data,
110
- runtimeContext,
122
+ runtimeContext: finalRuntimeContext,
111
123
  mastra,
112
124
  runId: agentId
113
125
  });
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
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');
3
+ var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
7
 
7
8
  // src/server/handlers/network.ts
8
9
  var network_exports = {};
9
- chunkFV45V6WC_cjs.__export(network_exports, {
10
+ chunk75ZPJI57_cjs.__export(network_exports, {
10
11
  generateHandler: () => generateHandler,
11
12
  getNetworkByIdHandler: () => getNetworkByIdHandler,
12
13
  getNetworksHandler: () => getNetworksHandler,
@@ -46,7 +47,7 @@ async function getNetworksHandler({
46
47
  );
47
48
  return serializedNetworks;
48
49
  } catch (error) {
49
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
50
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting networks");
50
51
  }
51
52
  }
52
53
  async function getNetworkByIdHandler({
@@ -61,7 +62,7 @@ async function getNetworkByIdHandler({
61
62
  return network2.formatAgentId(routingAgent2.name) === networkId;
62
63
  });
63
64
  if (!network) {
64
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
65
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
65
66
  }
66
67
  const routingAgent = network.getRoutingAgent();
67
68
  const routingLLM = await routingAgent.getLLM({ runtimeContext });
@@ -87,7 +88,7 @@ async function getNetworkByIdHandler({
87
88
  };
88
89
  return serializedNetwork;
89
90
  } catch (error) {
90
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting network by ID");
91
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting network by ID");
91
92
  }
92
93
  }
93
94
  async function generateHandler({
@@ -99,14 +100,14 @@ async function generateHandler({
99
100
  try {
100
101
  const network = mastra.getNetwork(networkId);
101
102
  if (!network) {
102
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
103
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
103
104
  }
104
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
105
+ chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
105
106
  const { messages, ...rest } = body;
106
107
  const result = await network.generate(messages, { ...rest, runtimeContext });
107
108
  return result;
108
109
  } catch (error) {
109
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
110
+ return chunk64U3UDTH_cjs.handleError(error, "Error generating from network");
110
111
  }
111
112
  }
112
113
  async function streamGenerateHandler({
@@ -118,9 +119,9 @@ async function streamGenerateHandler({
118
119
  try {
119
120
  const network = mastra.getNetwork(networkId);
120
121
  if (!network) {
121
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
122
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
122
123
  }
123
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
124
+ chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
124
125
  const { messages, output, ...rest } = body;
125
126
  const streamResult = await network.stream(messages, {
126
127
  output,
@@ -136,7 +137,7 @@ async function streamGenerateHandler({
136
137
  });
137
138
  return streamResponse;
138
139
  } catch (error) {
139
- return chunkZLBRQFDD_cjs.handleError(error, "Error streaming from network");
140
+ return chunk64U3UDTH_cjs.handleError(error, "Error streaming from network");
140
141
  }
141
142
  }
142
143
 
@@ -1,7 +1,9 @@
1
- import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { stringify, esm_default } from './chunk-LIVAK2DM.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { HTTPException } from './chunk-NYN7KFXL.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
4
5
  import { ReadableStream } from 'node:stream/web';
6
+ import { RuntimeContext } from '@mastra/core/di';
5
7
 
6
8
  // src/server/handlers/vNextWorkflows.ts
7
9
  var vNextWorkflows_exports = {};
@@ -68,7 +70,9 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
68
70
  }, {}),
69
71
  name: workflow.name,
70
72
  stepGraph: workflow.serializedStepGraph,
73
+ // @ts-ignore - ignore infinite recursion
71
74
  inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
75
+ // @ts-ignore - ignore infinite recursion
72
76
  outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
73
77
  };
74
78
  } catch (error) {
@@ -124,7 +128,8 @@ async function startAsyncVNextWorkflowHandler({
124
128
  runtimeContext,
125
129
  workflowId,
126
130
  runId,
127
- inputData
131
+ inputData,
132
+ runtimeContextFromRequest
128
133
  }) {
129
134
  try {
130
135
  if (!workflowId) {
@@ -134,10 +139,14 @@ async function startAsyncVNextWorkflowHandler({
134
139
  if (!workflow) {
135
140
  throw new HTTPException(404, { message: "Workflow not found" });
136
141
  }
142
+ const finalRuntimeContext = new RuntimeContext([
143
+ ...Array.from(runtimeContext?.entries() ?? []),
144
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
145
+ ]);
137
146
  const _run = workflow.createRun({ runId });
138
147
  const result = await _run.start({
139
148
  inputData,
140
- runtimeContext
149
+ runtimeContext: finalRuntimeContext
141
150
  });
142
151
  return result;
143
152
  } catch (error) {
@@ -149,7 +158,8 @@ async function startVNextWorkflowRunHandler({
149
158
  runtimeContext,
150
159
  workflowId,
151
160
  runId,
152
- inputData
161
+ inputData,
162
+ runtimeContextFromRequest
153
163
  }) {
154
164
  try {
155
165
  if (!workflowId) {
@@ -163,10 +173,14 @@ async function startVNextWorkflowRunHandler({
163
173
  if (!run) {
164
174
  throw new HTTPException(404, { message: "Workflow run not found" });
165
175
  }
176
+ const finalRuntimeContext = new RuntimeContext([
177
+ ...Array.from(runtimeContext?.entries() ?? []),
178
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
179
+ ]);
166
180
  const _run = workflow.createRun({ runId });
167
181
  await _run.start({
168
182
  inputData,
169
- runtimeContext
183
+ runtimeContext: finalRuntimeContext
170
184
  });
171
185
  return { message: "Workflow run started" };
172
186
  } catch (e) {
@@ -224,7 +238,8 @@ async function resumeAsyncVNextWorkflowHandler({
224
238
  workflowId,
225
239
  runId,
226
240
  body,
227
- runtimeContext
241
+ runtimeContext,
242
+ runtimeContextFromRequest
228
243
  }) {
229
244
  try {
230
245
  if (!workflowId) {
@@ -241,11 +256,15 @@ async function resumeAsyncVNextWorkflowHandler({
241
256
  if (!run) {
242
257
  throw new HTTPException(404, { message: "Workflow run not found" });
243
258
  }
259
+ const finalRuntimeContext = new RuntimeContext([
260
+ ...Array.from(runtimeContext?.entries() ?? []),
261
+ ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
262
+ ]);
244
263
  const _run = workflow.createRun({ runId });
245
264
  const result = await _run.resume({
246
265
  step: body.step,
247
266
  resumeData: body.resumeData,
248
- runtimeContext
267
+ runtimeContext: finalRuntimeContext
249
268
  });
250
269
  return result;
251
270
  } catch (error) {
@@ -1,6 +1,7 @@
1
- import { validateBody } from './chunk-L7XE5QTW.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { validateBody } from './chunk-H5PTF3Y4.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { HTTPException } from './chunk-NYN7KFXL.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
4
5
 
5
6
  // src/server/handlers/memory.ts
6
7
  var memory_exports = {};
@@ -1,13 +1,14 @@
1
1
  'use strict';
2
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');
3
+ var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
+ var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
+ var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
6
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
7
  var stream = require('stream');
7
8
 
8
9
  // src/server/handlers/voice.ts
9
10
  var voice_exports = {};
10
- chunkFV45V6WC_cjs.__export(voice_exports, {
11
+ chunk75ZPJI57_cjs.__export(voice_exports, {
11
12
  generateSpeechHandler: () => generateSpeechHandler,
12
13
  getSpeakersHandler: () => getSpeakersHandler,
13
14
  transcribeSpeechHandler: () => transcribeSpeechHandler
@@ -15,19 +16,19 @@ chunkFV45V6WC_cjs.__export(voice_exports, {
15
16
  async function getSpeakersHandler({ mastra, agentId }) {
16
17
  try {
17
18
  if (!agentId) {
18
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
19
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
19
20
  }
20
21
  const agent = mastra.getAgent(agentId);
21
22
  if (!agent) {
22
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
23
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
23
24
  }
24
25
  if (!agent.voice) {
25
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
26
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
26
27
  }
27
28
  const speakers = await agent.voice.getSpeakers();
28
29
  return speakers;
29
30
  } catch (error) {
30
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting speakers");
31
+ return chunk64U3UDTH_cjs.handleError(error, "Error getting speakers");
31
32
  }
32
33
  }
33
34
  async function generateSpeechHandler({
@@ -37,25 +38,25 @@ async function generateSpeechHandler({
37
38
  }) {
38
39
  try {
39
40
  if (!agentId) {
40
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
41
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
41
42
  }
42
- chunkQN4KF3BH_cjs.validateBody({
43
+ chunk57CJTIPW_cjs.validateBody({
43
44
  text: body?.text
44
45
  });
45
46
  const agent = mastra.getAgent(agentId);
46
47
  if (!agent) {
47
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
48
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
48
49
  }
49
50
  if (!agent.voice) {
50
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
51
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
51
52
  }
52
53
  const audioStream = await agent.voice.speak(body.text, { speaker: body.speakerId });
53
54
  if (!audioStream) {
54
- throw new chunkFV45V6WC_cjs.HTTPException(500, { message: "Failed to generate speech" });
55
+ throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: "Failed to generate speech" });
55
56
  }
56
57
  return audioStream;
57
58
  } catch (error) {
58
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating speech");
59
+ return chunk64U3UDTH_cjs.handleError(error, "Error generating speech");
59
60
  }
60
61
  }
61
62
  async function transcribeSpeechHandler({
@@ -65,17 +66,17 @@ async function transcribeSpeechHandler({
65
66
  }) {
66
67
  try {
67
68
  if (!agentId) {
68
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
69
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
69
70
  }
70
71
  if (!body?.audioData) {
71
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Audio data is required" });
72
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Audio data is required" });
72
73
  }
73
74
  const agent = mastra.getAgent(agentId);
74
75
  if (!agent) {
75
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
76
+ throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
76
77
  }
77
78
  if (!agent.voice) {
78
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
79
+ throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
79
80
  }
80
81
  const audioStream = new stream.Readable();
81
82
  audioStream.push(body.audioData);
@@ -83,7 +84,7 @@ async function transcribeSpeechHandler({
83
84
  const text = await agent.voice.listen(audioStream, body.options);
84
85
  return { text };
85
86
  } catch (error) {
86
- return chunkZLBRQFDD_cjs.handleError(error, "Error transcribing speech");
87
+ return chunk64U3UDTH_cjs.handleError(error, "Error transcribing speech");
87
88
  }
88
89
  }
89
90