@mastra/server 0.0.0-fix-memory-xxhash-20250409202110 → 0.0.0-fix-generate-title-20250616171351
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/{LICENSE → LICENSE.md} +3 -1
- package/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +357 -57
- package/dist/_tsup-dts-rollup.d.ts +357 -57
- package/dist/{chunk-YNSGUC2O.js → chunk-2HXKRRNS.js} +14 -8
- package/dist/chunk-4O23XCE5.js +262 -0
- package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
- package/dist/{chunk-2FJURXCL.cjs → chunk-6TJSHFCJ.cjs} +44 -36
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/chunk-ASKESBJW.cjs +2004 -0
- package/dist/{chunk-CWSDZEZG.cjs → chunk-B4MQFJ7G.cjs} +18 -12
- package/dist/{chunk-DVPP5S6I.js → chunk-BFOA2QQY.js} +14 -8
- package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
- package/dist/{chunk-2YONKUWB.js → chunk-C7564HUT.js} +58 -33
- package/dist/chunk-C75ZRJKD.cjs +270 -0
- package/dist/{chunk-ILW7XYNJ.js → chunk-CLYX4KLH.js} +85 -61
- package/dist/chunk-CMMOIUFC.cjs +114 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-CP55EVBK.js} +26 -13
- package/dist/chunk-FRXZL32L.cjs +471 -0
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/{chunk-RBQASTUP.js → chunk-I7KJZNX5.js} +14 -6
- package/dist/chunk-IMBY5XUG.cjs +86 -0
- package/dist/chunk-JKTNRUKY.js +457 -0
- package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/{chunk-4C3EPMMF.cjs → chunk-NGURCFEJ.cjs} +31 -25
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/chunk-QLG2PFHE.js +81 -0
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/chunk-TGJMNUYJ.js +2001 -0
- package/dist/chunk-VPNDC2DI.cjs +148 -0
- package/dist/chunk-WE32JG64.cjs +332 -0
- 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/legacyWorkflows.cjs +46 -0
- package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
- package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
- package/dist/server/handlers/legacyWorkflows.js +1 -0
- 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/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -4
- package/dist/server/handlers/voice.d.cts +1 -0
- package/dist/server/handlers/voice.d.ts +1 -0
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +21 -13
- package/dist/server/handlers/workflows.d.cts +4 -2
- package/dist/server/handlers/workflows.d.ts +4 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +33 -23
- package/dist/server/handlers.d.cts +2 -0
- package/dist/server/handlers.d.ts +2 -0
- package/dist/server/handlers.js +11 -9
- package/package.json +14 -13
- package/dist/chunk-2JQC6JWP.js +0 -46
- package/dist/chunk-5JOF627H.cjs +0 -123
- package/dist/chunk-A7DF4ETD.cjs +0 -100
- package/dist/chunk-BMA2ORRT.js +0 -152
- package/dist/chunk-GV52BII2.cjs +0 -160
- package/dist/chunk-QH6XWSXP.cjs +0 -5579
- package/dist/chunk-VB7KH62D.cjs +0 -51
- package/dist/chunk-VK6FX47H.js +0 -5576
- package/dist/chunk-X37I6GZT.cjs +0 -308
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
2
|
-
import { handleError } from './chunk-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { stringify, esm_default } from './chunk-TGJMNUYJ.js';
|
|
2
|
+
import { handleError } from './chunk-M5ABIP7D.js';
|
|
3
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
5
|
+
import { ReadableStream } from 'stream/web';
|
|
5
6
|
|
|
6
|
-
// src/server/handlers/
|
|
7
|
-
var
|
|
8
|
-
__export(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
// src/server/handlers/legacyWorkflows.ts
|
|
8
|
+
var legacyWorkflows_exports = {};
|
|
9
|
+
__export(legacyWorkflows_exports, {
|
|
10
|
+
createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
|
|
11
|
+
getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
|
|
12
|
+
getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
|
|
13
|
+
getLegacyWorkflowRunsHandler: () => getLegacyWorkflowRunsHandler,
|
|
14
|
+
getLegacyWorkflowsHandler: () => getLegacyWorkflowsHandler,
|
|
15
|
+
resumeAsyncLegacyWorkflowHandler: () => resumeAsyncLegacyWorkflowHandler,
|
|
16
|
+
resumeLegacyWorkflowHandler: () => resumeLegacyWorkflowHandler,
|
|
17
|
+
startAsyncLegacyWorkflowHandler: () => startAsyncLegacyWorkflowHandler,
|
|
18
|
+
startLegacyWorkflowRunHandler: () => startLegacyWorkflowRunHandler,
|
|
19
|
+
watchLegacyWorkflowHandler: () => watchLegacyWorkflowHandler
|
|
19
20
|
});
|
|
20
|
-
async function
|
|
21
|
+
async function getLegacyWorkflowsHandler({ mastra }) {
|
|
21
22
|
try {
|
|
22
|
-
const workflows = mastra.
|
|
23
|
+
const workflows = mastra.legacy_getWorkflows({ serialized: false });
|
|
23
24
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
24
25
|
if (workflow.isNested) return acc;
|
|
25
26
|
acc[key] = {
|
|
@@ -32,7 +33,9 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
32
33
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
33
34
|
const _step = step;
|
|
34
35
|
acc2[key2] = {
|
|
35
|
-
|
|
36
|
+
id: _step.id,
|
|
37
|
+
description: _step.description,
|
|
38
|
+
workflowId: _step.workflowId,
|
|
36
39
|
inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
|
|
37
40
|
outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
|
|
38
41
|
};
|
|
@@ -46,12 +49,12 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
46
49
|
throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
async function
|
|
52
|
+
async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
|
|
50
53
|
try {
|
|
51
54
|
if (!workflowId) {
|
|
52
55
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
53
56
|
}
|
|
54
|
-
const workflow = mastra.
|
|
57
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
55
58
|
if (!workflow) {
|
|
56
59
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
57
60
|
}
|
|
@@ -65,7 +68,9 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
65
68
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
66
69
|
const _step = step;
|
|
67
70
|
acc[key] = {
|
|
68
|
-
|
|
71
|
+
id: _step.id,
|
|
72
|
+
description: _step.description,
|
|
73
|
+
workflowId: _step.workflowId,
|
|
69
74
|
inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
|
|
70
75
|
outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
|
|
71
76
|
};
|
|
@@ -76,8 +81,9 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
76
81
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
|
-
async function
|
|
84
|
+
async function startAsyncLegacyWorkflowHandler({
|
|
80
85
|
mastra,
|
|
86
|
+
runtimeContext,
|
|
81
87
|
workflowId,
|
|
82
88
|
runId,
|
|
83
89
|
triggerData
|
|
@@ -86,30 +92,32 @@ async function startAsyncWorkflowHandler({
|
|
|
86
92
|
if (!workflowId) {
|
|
87
93
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
88
94
|
}
|
|
89
|
-
const workflow = mastra.
|
|
95
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
90
96
|
if (!workflow) {
|
|
91
97
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
92
98
|
}
|
|
93
99
|
if (!runId) {
|
|
94
|
-
const
|
|
95
|
-
const result2 = await start({
|
|
96
|
-
triggerData
|
|
100
|
+
const newRun = workflow.createRun();
|
|
101
|
+
const result2 = await newRun.start({
|
|
102
|
+
triggerData,
|
|
103
|
+
runtimeContext
|
|
97
104
|
});
|
|
98
105
|
return result2;
|
|
99
106
|
}
|
|
100
|
-
const run = workflow.
|
|
107
|
+
const run = workflow.getMemoryRun(runId);
|
|
101
108
|
if (!run) {
|
|
102
109
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
103
110
|
}
|
|
104
111
|
const result = await run.start({
|
|
105
|
-
triggerData
|
|
112
|
+
triggerData,
|
|
113
|
+
runtimeContext
|
|
106
114
|
});
|
|
107
115
|
return result;
|
|
108
116
|
} catch (error) {
|
|
109
117
|
throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
|
-
async function
|
|
120
|
+
async function getLegacyWorkflowRunHandler({
|
|
113
121
|
mastra,
|
|
114
122
|
workflowId,
|
|
115
123
|
runId
|
|
@@ -121,11 +129,11 @@ async function getWorkflowRunHandler({
|
|
|
121
129
|
if (!runId) {
|
|
122
130
|
throw new HTTPException(400, { message: "Run ID is required" });
|
|
123
131
|
}
|
|
124
|
-
const workflow = mastra.
|
|
132
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
125
133
|
if (!workflow) {
|
|
126
134
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
127
135
|
}
|
|
128
|
-
const run = workflow.getRun(runId);
|
|
136
|
+
const run = await workflow.getRun(runId);
|
|
129
137
|
if (!run) {
|
|
130
138
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
131
139
|
}
|
|
@@ -134,7 +142,7 @@ async function getWorkflowRunHandler({
|
|
|
134
142
|
throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
|
-
async function
|
|
145
|
+
async function createLegacyWorkflowRunHandler({
|
|
138
146
|
mastra,
|
|
139
147
|
workflowId,
|
|
140
148
|
runId: prevRunId
|
|
@@ -143,18 +151,19 @@ async function createRunHandler({
|
|
|
143
151
|
if (!workflowId) {
|
|
144
152
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
145
153
|
}
|
|
146
|
-
const workflow = mastra.
|
|
154
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
147
155
|
if (!workflow) {
|
|
148
156
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
149
157
|
}
|
|
150
|
-
const
|
|
151
|
-
return { runId };
|
|
158
|
+
const newRun = workflow.createRun({ runId: prevRunId });
|
|
159
|
+
return { runId: newRun.runId };
|
|
152
160
|
} catch (error) {
|
|
153
161
|
throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
|
|
154
162
|
}
|
|
155
163
|
}
|
|
156
|
-
async function
|
|
164
|
+
async function startLegacyWorkflowRunHandler({
|
|
157
165
|
mastra,
|
|
166
|
+
runtimeContext,
|
|
158
167
|
workflowId,
|
|
159
168
|
runId,
|
|
160
169
|
triggerData
|
|
@@ -166,20 +175,21 @@ async function startWorkflowRunHandler({
|
|
|
166
175
|
if (!runId) {
|
|
167
176
|
throw new HTTPException(400, { message: "runId required to start run" });
|
|
168
177
|
}
|
|
169
|
-
const workflow = mastra.
|
|
170
|
-
const run = workflow.
|
|
178
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
179
|
+
const run = workflow.getMemoryRun(runId);
|
|
171
180
|
if (!run) {
|
|
172
181
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
173
182
|
}
|
|
174
|
-
|
|
175
|
-
triggerData
|
|
183
|
+
void run.start({
|
|
184
|
+
triggerData,
|
|
185
|
+
runtimeContext
|
|
176
186
|
});
|
|
177
187
|
return { message: "Workflow run started" };
|
|
178
188
|
} catch (e) {
|
|
179
189
|
return handleError(e, "Error starting workflow run");
|
|
180
190
|
}
|
|
181
191
|
}
|
|
182
|
-
async function
|
|
192
|
+
async function watchLegacyWorkflowHandler({
|
|
183
193
|
mastra,
|
|
184
194
|
workflowId,
|
|
185
195
|
runId
|
|
@@ -191,8 +201,8 @@ async function watchWorkflowHandler({
|
|
|
191
201
|
if (!runId) {
|
|
192
202
|
throw new HTTPException(400, { message: "runId required to watch workflow" });
|
|
193
203
|
}
|
|
194
|
-
const workflow = mastra.
|
|
195
|
-
const run = workflow.
|
|
204
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
205
|
+
const run = workflow.getMemoryRun(runId);
|
|
196
206
|
if (!run) {
|
|
197
207
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
198
208
|
}
|
|
@@ -208,8 +218,10 @@ async function watchWorkflowHandler({
|
|
|
208
218
|
asyncRef = null;
|
|
209
219
|
}
|
|
210
220
|
asyncRef = setImmediate(() => {
|
|
211
|
-
|
|
221
|
+
const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
|
|
222
|
+
if (runDone) {
|
|
212
223
|
controller.close();
|
|
224
|
+
unwatch?.();
|
|
213
225
|
}
|
|
214
226
|
});
|
|
215
227
|
});
|
|
@@ -223,11 +235,12 @@ async function watchWorkflowHandler({
|
|
|
223
235
|
return handleError(error, "Error watching workflow");
|
|
224
236
|
}
|
|
225
237
|
}
|
|
226
|
-
async function
|
|
238
|
+
async function resumeAsyncLegacyWorkflowHandler({
|
|
227
239
|
mastra,
|
|
228
240
|
workflowId,
|
|
229
241
|
runId,
|
|
230
|
-
body
|
|
242
|
+
body,
|
|
243
|
+
runtimeContext
|
|
231
244
|
}) {
|
|
232
245
|
try {
|
|
233
246
|
if (!workflowId) {
|
|
@@ -236,25 +249,27 @@ async function resumeAsyncWorkflowHandler({
|
|
|
236
249
|
if (!runId) {
|
|
237
250
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
238
251
|
}
|
|
239
|
-
const workflow = mastra.
|
|
240
|
-
const run = workflow.
|
|
252
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
253
|
+
const run = workflow.getMemoryRun(runId);
|
|
241
254
|
if (!run) {
|
|
242
255
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
243
256
|
}
|
|
244
257
|
const result = await run.resume({
|
|
245
258
|
stepId: body.stepId,
|
|
246
|
-
context: body.context
|
|
259
|
+
context: body.context,
|
|
260
|
+
runtimeContext
|
|
247
261
|
});
|
|
248
262
|
return result;
|
|
249
263
|
} catch (error) {
|
|
250
264
|
return handleError(error, "Error resuming workflow step");
|
|
251
265
|
}
|
|
252
266
|
}
|
|
253
|
-
async function
|
|
267
|
+
async function resumeLegacyWorkflowHandler({
|
|
254
268
|
mastra,
|
|
255
269
|
workflowId,
|
|
256
270
|
runId,
|
|
257
|
-
body
|
|
271
|
+
body,
|
|
272
|
+
runtimeContext
|
|
258
273
|
}) {
|
|
259
274
|
try {
|
|
260
275
|
if (!workflowId) {
|
|
@@ -263,27 +278,36 @@ async function resumeWorkflowHandler({
|
|
|
263
278
|
if (!runId) {
|
|
264
279
|
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
265
280
|
}
|
|
266
|
-
const workflow = mastra.
|
|
267
|
-
const run = workflow.
|
|
281
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
282
|
+
const run = workflow.getMemoryRun(runId);
|
|
268
283
|
if (!run) {
|
|
269
284
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
270
285
|
}
|
|
271
|
-
|
|
286
|
+
void run.resume({
|
|
272
287
|
stepId: body.stepId,
|
|
273
|
-
context: body.context
|
|
288
|
+
context: body.context,
|
|
289
|
+
runtimeContext
|
|
274
290
|
});
|
|
275
291
|
return { message: "Workflow run resumed" };
|
|
276
292
|
} catch (error) {
|
|
277
293
|
return handleError(error, "Error resuming workflow");
|
|
278
294
|
}
|
|
279
295
|
}
|
|
280
|
-
async function
|
|
296
|
+
async function getLegacyWorkflowRunsHandler({
|
|
297
|
+
mastra,
|
|
298
|
+
workflowId,
|
|
299
|
+
fromDate,
|
|
300
|
+
toDate,
|
|
301
|
+
limit,
|
|
302
|
+
offset,
|
|
303
|
+
resourceId
|
|
304
|
+
}) {
|
|
281
305
|
try {
|
|
282
306
|
if (!workflowId) {
|
|
283
307
|
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
284
308
|
}
|
|
285
|
-
const workflow = mastra.
|
|
286
|
-
const workflowRuns = await workflow.getWorkflowRuns() || {
|
|
309
|
+
const workflow = mastra.legacy_getWorkflow(workflowId);
|
|
310
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
287
311
|
runs: [],
|
|
288
312
|
total: 0
|
|
289
313
|
};
|
|
@@ -293,4 +317,4 @@ async function getWorkflowRunsHandler({ mastra, workflowId }) {
|
|
|
293
317
|
}
|
|
294
318
|
}
|
|
295
319
|
|
|
296
|
-
export {
|
|
320
|
+
export { createLegacyWorkflowRunHandler, getLegacyWorkflowByIdHandler, getLegacyWorkflowRunHandler, getLegacyWorkflowRunsHandler, getLegacyWorkflowsHandler, legacyWorkflows_exports, resumeAsyncLegacyWorkflowHandler, resumeLegacyWorkflowHandler, startAsyncLegacyWorkflowHandler, startLegacyWorkflowRunHandler, watchLegacyWorkflowHandler };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
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');
|
|
7
|
+
var stream = require('stream');
|
|
8
|
+
|
|
9
|
+
// src/server/handlers/voice.ts
|
|
10
|
+
var voice_exports = {};
|
|
11
|
+
chunk75ZPJI57_cjs.__export(voice_exports, {
|
|
12
|
+
generateSpeechHandler: () => generateSpeechHandler,
|
|
13
|
+
getListenerHandler: () => getListenerHandler,
|
|
14
|
+
getSpeakersHandler: () => getSpeakersHandler,
|
|
15
|
+
transcribeSpeechHandler: () => transcribeSpeechHandler
|
|
16
|
+
});
|
|
17
|
+
async function getSpeakersHandler({ mastra, agentId }) {
|
|
18
|
+
try {
|
|
19
|
+
if (!agentId) {
|
|
20
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
21
|
+
}
|
|
22
|
+
const agent = mastra.getAgent(agentId);
|
|
23
|
+
if (!agent) {
|
|
24
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
25
|
+
}
|
|
26
|
+
if (!agent.voice) {
|
|
27
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
28
|
+
}
|
|
29
|
+
const speakers = await agent.voice.getSpeakers();
|
|
30
|
+
return speakers;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting speakers");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function generateSpeechHandler({
|
|
36
|
+
mastra,
|
|
37
|
+
agentId,
|
|
38
|
+
body
|
|
39
|
+
}) {
|
|
40
|
+
try {
|
|
41
|
+
if (!agentId) {
|
|
42
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
43
|
+
}
|
|
44
|
+
chunk57CJTIPW_cjs.validateBody({
|
|
45
|
+
text: body?.text
|
|
46
|
+
});
|
|
47
|
+
const agent = mastra.getAgent(agentId);
|
|
48
|
+
if (!agent) {
|
|
49
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
50
|
+
}
|
|
51
|
+
if (!agent.voice) {
|
|
52
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
53
|
+
}
|
|
54
|
+
const audioStream = await agent.voice.speak(body.text, { speaker: body.speakerId });
|
|
55
|
+
if (!audioStream) {
|
|
56
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: "Failed to generate speech" });
|
|
57
|
+
}
|
|
58
|
+
return audioStream;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error generating speech");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function transcribeSpeechHandler({
|
|
64
|
+
mastra,
|
|
65
|
+
agentId,
|
|
66
|
+
body
|
|
67
|
+
}) {
|
|
68
|
+
try {
|
|
69
|
+
if (!agentId) {
|
|
70
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
71
|
+
}
|
|
72
|
+
if (!body?.audioData) {
|
|
73
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Audio data is required" });
|
|
74
|
+
}
|
|
75
|
+
const agent = mastra.getAgent(agentId);
|
|
76
|
+
if (!agent) {
|
|
77
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
78
|
+
}
|
|
79
|
+
if (!agent.voice) {
|
|
80
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
81
|
+
}
|
|
82
|
+
const audioStream = new stream.Readable();
|
|
83
|
+
audioStream.push(body.audioData);
|
|
84
|
+
audioStream.push(null);
|
|
85
|
+
const text = await agent.voice.listen(audioStream, body.options);
|
|
86
|
+
return { text };
|
|
87
|
+
} catch (error) {
|
|
88
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error transcribing speech");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function getListenerHandler({ mastra, agentId }) {
|
|
92
|
+
try {
|
|
93
|
+
if (!agentId) {
|
|
94
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
95
|
+
}
|
|
96
|
+
const agent = mastra.getAgent(agentId);
|
|
97
|
+
if (!agent) {
|
|
98
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
|
|
99
|
+
}
|
|
100
|
+
if (!agent.voice) {
|
|
101
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
102
|
+
}
|
|
103
|
+
const listeners = await agent.voice.getListener();
|
|
104
|
+
return listeners;
|
|
105
|
+
} catch (error) {
|
|
106
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error getting listeners");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
exports.generateSpeechHandler = generateSpeechHandler;
|
|
111
|
+
exports.getListenerHandler = getListenerHandler;
|
|
112
|
+
exports.getSpeakersHandler = getSpeakersHandler;
|
|
113
|
+
exports.transcribeSpeechHandler = transcribeSpeechHandler;
|
|
114
|
+
exports.voice_exports = voice_exports;
|
|
@@ -1,12 +1,14 @@
|
|
|
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
|
import { Readable } from 'stream';
|
|
5
6
|
|
|
6
7
|
// src/server/handlers/voice.ts
|
|
7
8
|
var voice_exports = {};
|
|
8
9
|
__export(voice_exports, {
|
|
9
10
|
generateSpeechHandler: () => generateSpeechHandler,
|
|
11
|
+
getListenerHandler: () => getListenerHandler,
|
|
10
12
|
getSpeakersHandler: () => getSpeakersHandler,
|
|
11
13
|
transcribeSpeechHandler: () => transcribeSpeechHandler
|
|
12
14
|
});
|
|
@@ -38,9 +40,7 @@ async function generateSpeechHandler({
|
|
|
38
40
|
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
39
41
|
}
|
|
40
42
|
validateBody({
|
|
41
|
-
text:
|
|
42
|
-
speakerId: void 0,
|
|
43
|
-
...body
|
|
43
|
+
text: body?.text
|
|
44
44
|
});
|
|
45
45
|
const agent = mastra.getAgent(agentId);
|
|
46
46
|
if (!agent) {
|
|
@@ -53,12 +53,7 @@ async function generateSpeechHandler({
|
|
|
53
53
|
if (!audioStream) {
|
|
54
54
|
throw new HTTPException(500, { message: "Failed to generate speech" });
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
for await (const chunk of audioStream) {
|
|
58
|
-
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
59
|
-
}
|
|
60
|
-
const audioData = Buffer.concat(chunks);
|
|
61
|
-
return { audioData };
|
|
56
|
+
return audioStream;
|
|
62
57
|
} catch (error) {
|
|
63
58
|
return handleError(error, "Error generating speech");
|
|
64
59
|
}
|
|
@@ -91,5 +86,23 @@ async function transcribeSpeechHandler({
|
|
|
91
86
|
return handleError(error, "Error transcribing speech");
|
|
92
87
|
}
|
|
93
88
|
}
|
|
89
|
+
async function getListenerHandler({ mastra, agentId }) {
|
|
90
|
+
try {
|
|
91
|
+
if (!agentId) {
|
|
92
|
+
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
93
|
+
}
|
|
94
|
+
const agent = mastra.getAgent(agentId);
|
|
95
|
+
if (!agent) {
|
|
96
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
97
|
+
}
|
|
98
|
+
if (!agent.voice) {
|
|
99
|
+
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
100
|
+
}
|
|
101
|
+
const listeners = await agent.voice.getListener();
|
|
102
|
+
return listeners;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
return handleError(error, "Error getting listeners");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
94
107
|
|
|
95
|
-
export { generateSpeechHandler, getSpeakersHandler, transcribeSpeechHandler, voice_exports };
|
|
108
|
+
export { generateSpeechHandler, getListenerHandler, getSpeakersHandler, transcribeSpeechHandler, voice_exports };
|