@mastra/server 2.0.3 → 2.0.4-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 (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-6Q7UXAYJ.cjs → chunk-3HQNCTZ2.cjs} +21 -20
  5. package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
  6. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  7. package/dist/chunk-5SN4U5AC.cjs +508 -0
  8. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  9. package/dist/chunk-75ZPJI57.cjs +9 -0
  10. package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
  11. package/dist/{chunk-3XTEV33Q.js → chunk-EJO45KYT.js} +19 -16
  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-CHFORQ7J.cjs → chunk-I2B73Y4I.cjs} +60 -57
  16. package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
  17. package/dist/chunk-LIVAK2DM.js +2001 -0
  18. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  19. package/dist/{chunk-M2RXDCPV.cjs → chunk-M6MC2QMH.cjs} +78 -59
  20. package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
  21. package/dist/chunk-MLKGABMK.js +7 -0
  22. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  23. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  24. package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
  25. package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
  26. package/dist/chunk-P6SCPDYW.js +500 -0
  27. package/dist/{chunk-GVBJ5I2S.js → chunk-Q6KMBIAN.js} +5 -4
  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-WJU67W7F.js} +30 -11
  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 +5 -3
  68. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  69. package/dist/chunk-OMN3UI6X.js +0 -5576
@@ -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
- await _run.start({
181
+ void _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) {
@@ -275,7 +294,7 @@ async function resumeVNextWorkflowHandler({
275
294
  throw new HTTPException(404, { message: "Workflow run not found" });
276
295
  }
277
296
  const _run = workflow.createRun({ runId });
278
- await _run.resume({
297
+ void _run.resume({
279
298
  step: body.step,
280
299
  resumeData: body.resumeData,
281
300
  runtimeContext
@@ -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