@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.
- package/dist/_tsup-dts-rollup.d.cts +152 -10
- package/dist/_tsup-dts-rollup.d.ts +152 -10
- package/dist/{chunk-2FJURXCL.cjs → chunk-24EGIVT7.cjs} +34 -33
- package/dist/{chunk-6Q7UXAYJ.cjs → chunk-3HQNCTZ2.cjs} +21 -20
- package/dist/{chunk-M56ECCHK.cjs → chunk-4YZ3U35L.cjs} +18 -17
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/chunk-5SN4U5AC.cjs +508 -0
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
- package/dist/{chunk-3XTEV33Q.js → chunk-EJO45KYT.js} +19 -16
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/{chunk-Q6SHQECN.js → chunk-HFWCEP5S.js} +4 -3
- package/dist/{chunk-3EJZQ6TQ.js → chunk-HWZVAG3H.js} +3 -3
- package/dist/{chunk-CHFORQ7J.cjs → chunk-I2B73Y4I.cjs} +60 -57
- package/dist/{chunk-4JINXASC.js → chunk-IU5VO2I2.js} +3 -2
- package/dist/chunk-LIVAK2DM.js +2001 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/{chunk-M2RXDCPV.cjs → chunk-M6MC2QMH.cjs} +78 -59
- package/dist/{chunk-AMVOS7YB.cjs → chunk-MHKNLNAN.cjs} +9 -8
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/{chunk-SKBVVI24.cjs → chunk-OGCNNUHF.cjs} +9 -9
- package/dist/{chunk-BPL2CBLV.js → chunk-OR3CIE2H.js} +3 -2
- package/dist/chunk-P6SCPDYW.js +500 -0
- package/dist/{chunk-GVBJ5I2S.js → chunk-Q6KMBIAN.js} +5 -4
- package/dist/{chunk-5JNVY6DU.js → chunk-TJKLBTFB.js} +20 -8
- package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
- package/dist/{chunk-OWNA6I2H.js → chunk-WJU67W7F.js} +30 -11
- package/dist/{chunk-RBQASTUP.js → chunk-X3ZDCS52.js} +4 -3
- package/dist/{chunk-55HTWX4C.cjs → chunk-YBVOQN4M.cjs} +20 -19
- package/dist/chunk-YWLUOY3D.cjs +2004 -0
- package/dist/{chunk-D3G23FP3.cjs → chunk-ZE5AAC4I.cjs} +37 -25
- package/dist/server/handlers/a2a.cjs +30 -0
- package/dist/server/handlers/a2a.d.cts +6 -0
- package/dist/server/handlers/a2a.d.ts +6 -0
- package/dist/server/handlers/a2a.js +1 -0
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +9 -9
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vNextWorkflows.cjs +11 -11
- package/dist/server/handlers/vNextWorkflows.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +4 -4
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +11 -11
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +28 -23
- package/dist/server/handlers.d.cts +1 -0
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.js +11 -10
- package/package.json +5 -3
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-OMN3UI6X.js +0 -5576
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import {
|
|
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
|
+
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
|
-
|
|
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-
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import {
|
|
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
|
|
4
|
-
var
|
|
5
|
-
var
|
|
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
|
-
|
|
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
|
|
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
|
|
23
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
23
24
|
}
|
|
24
25
|
if (!agent.voice) {
|
|
25
|
-
throw new
|
|
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
|
|
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
|
|
41
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
41
42
|
}
|
|
42
|
-
|
|
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
|
|
48
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
48
49
|
}
|
|
49
50
|
if (!agent.voice) {
|
|
50
|
-
throw new
|
|
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
|
|
55
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: "Failed to generate speech" });
|
|
55
56
|
}
|
|
56
57
|
return audioStream;
|
|
57
58
|
} catch (error) {
|
|
58
|
-
return
|
|
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
|
|
69
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
69
70
|
}
|
|
70
71
|
if (!body?.audioData) {
|
|
71
|
-
throw new
|
|
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
|
|
76
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
76
77
|
}
|
|
77
78
|
if (!agent.voice) {
|
|
78
|
-
throw new
|
|
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
|
|
87
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error transcribing speech");
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
|