@mastra/server 0.0.0-mcp-server-deploy-20250507160341 → 0.0.0-mcp-changeset-20250707162621
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/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +523 -193
- package/dist/_tsup-dts-rollup.d.ts +523 -193
- package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
- package/dist/{chunk-5YGDYMRB.cjs → chunk-2SLFAFTR.cjs} +14 -13
- package/dist/chunk-4D66QEKC.js +81 -0
- package/dist/{chunk-3XTEV33Q.js → chunk-5PQQ42EZ.js} +59 -56
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
- package/dist/chunk-B2PAS2IB.cjs +514 -0
- package/dist/{chunk-Y3SV5XK4.js → chunk-BK4XT6EG.js} +105 -16
- package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-QJ3AHN64.js → chunk-CRCR3ZUK.js} +4 -3
- package/dist/{chunk-2FJURXCL.cjs → chunk-DN7K6FJK.cjs} +93 -55
- package/dist/{chunk-D3G23FP3.cjs → chunk-FRVBFMO2.cjs} +24 -22
- package/dist/{chunk-AMVOS7YB.cjs → chunk-G7KH752Y.cjs} +12 -8
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/chunk-H7DMHBKY.js +498 -0
- package/dist/chunk-JMLYCXMK.cjs +332 -0
- package/dist/{chunk-Q6SHQECN.js → chunk-KHZKYUNR.js} +34 -10
- package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/chunk-LI436ITD.cjs +2042 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-LRCAAFUA.js} +7 -5
- package/dist/chunk-LZ3VJXSO.cjs +278 -0
- package/dist/chunk-MEGCYGBU.js +2039 -0
- package/dist/{chunk-RBQASTUP.js → chunk-MKLYEKEF.js} +63 -25
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/chunk-QGX47B5D.cjs +86 -0
- package/dist/{chunk-BPL2CBLV.js → chunk-RG473F6Y.js} +8 -4
- package/dist/chunk-RHSWAXKB.cjs +118 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
- package/dist/index.cjs +0 -12
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- 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/vNextNetwork.cjs +218 -0
- package/dist/server/handlers/vNextNetwork.d.cts +6 -0
- package/dist/server/handlers/vNextNetwork.d.ts +6 -0
- package/dist/server/handlers/vNextNetwork.js +211 -0
- 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 +29 -13
- package/dist/server/handlers/workflows.d.cts +6 -2
- package/dist/server/handlers/workflows.d.ts +6 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +31 -26
- package/dist/server/handlers.d.cts +2 -1
- package/dist/server/handlers.d.ts +2 -1
- package/dist/server/handlers.js +11 -10
- package/package.json +14 -13
- package/dist/chunk-3AHQ5RGN.js +0 -11
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-4BIX6GMY.cjs +0 -189
- package/dist/chunk-55HTWX4C.cjs +0 -93
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-74DLDQTQ.cjs +0 -36
- package/dist/chunk-CHFORQ7J.cjs +0 -329
- package/dist/chunk-FOXHTOQZ.cjs +0 -324
- package/dist/chunk-HAA5T7JL.js +0 -33
- package/dist/chunk-IQTNZSFP.js +0 -312
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/chunk-ZLBRQFDD.cjs +0 -13
- package/dist/server/handlers/mcp.cjs +0 -14
- package/dist/server/handlers/mcp.d.cts +0 -2
- package/dist/server/handlers/mcp.d.ts +0 -2
- package/dist/server/handlers/mcp.js +0 -1
- package/dist/server/handlers/vNextWorkflows.cjs +0 -46
- package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
- package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
- package/dist/server/handlers/vNextWorkflows.js +0 -1
package/dist/chunk-3EJZQ6TQ.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { validateBody } from './chunk-L7XE5QTW.js';
|
|
2
|
-
import { handleError } from './chunk-3AHQ5RGN.js';
|
|
3
|
-
import { __export } from './chunk-TRDNDNGQ.js';
|
|
4
|
-
|
|
5
|
-
// src/server/handlers/logs.ts
|
|
6
|
-
var logs_exports = {};
|
|
7
|
-
__export(logs_exports, {
|
|
8
|
-
getLogTransports: () => getLogTransports,
|
|
9
|
-
getLogsByRunIdHandler: () => getLogsByRunIdHandler,
|
|
10
|
-
getLogsHandler: () => getLogsHandler
|
|
11
|
-
});
|
|
12
|
-
async function getLogsHandler({
|
|
13
|
-
mastra,
|
|
14
|
-
transportId
|
|
15
|
-
}) {
|
|
16
|
-
try {
|
|
17
|
-
validateBody({ transportId });
|
|
18
|
-
const logs = await mastra.getLogs(transportId);
|
|
19
|
-
return logs;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
return handleError(error, "Error getting logs");
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
async function getLogsByRunIdHandler({
|
|
25
|
-
mastra,
|
|
26
|
-
runId,
|
|
27
|
-
transportId
|
|
28
|
-
}) {
|
|
29
|
-
try {
|
|
30
|
-
validateBody({ runId, transportId });
|
|
31
|
-
const logs = await mastra.getLogsByRunId({ runId, transportId });
|
|
32
|
-
return logs;
|
|
33
|
-
} catch (error) {
|
|
34
|
-
return handleError(error, "Error getting logs by run ID");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async function getLogTransports({ mastra }) {
|
|
38
|
-
try {
|
|
39
|
-
const logger = mastra.getLogger();
|
|
40
|
-
const transports = logger.transports;
|
|
41
|
-
return {
|
|
42
|
-
transports: transports ? Object.keys(transports) : []
|
|
43
|
-
};
|
|
44
|
-
} catch (error) {
|
|
45
|
-
return handleError(error, "Error getting log Transports");
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { getLogTransports, getLogsByRunIdHandler, getLogsHandler, logs_exports };
|
package/dist/chunk-4BIX6GMY.cjs
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
|
|
4
|
-
var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
|
|
5
|
-
var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
|
|
6
|
-
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/agents.ts
|
|
9
|
-
var agents_exports = {};
|
|
10
|
-
chunkFV45V6WC_cjs.__export(agents_exports, {
|
|
11
|
-
generateHandler: () => generateHandler,
|
|
12
|
-
getAgentByIdHandler: () => getAgentByIdHandler,
|
|
13
|
-
getAgentsHandler: () => getAgentsHandler,
|
|
14
|
-
getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
|
|
15
|
-
getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
|
|
16
|
-
streamGenerateHandler: () => streamGenerateHandler
|
|
17
|
-
});
|
|
18
|
-
async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
19
|
-
try {
|
|
20
|
-
const agents = mastra.getAgents();
|
|
21
|
-
const serializedAgentsMap = await Promise.all(
|
|
22
|
-
Object.entries(agents).map(async ([id, agent]) => {
|
|
23
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
24
|
-
const tools = await agent.getTools({ runtimeContext });
|
|
25
|
-
const llm = await agent.getLLM({ runtimeContext });
|
|
26
|
-
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
27
|
-
const _tool = tool;
|
|
28
|
-
acc[key] = {
|
|
29
|
-
..._tool,
|
|
30
|
-
inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
31
|
-
outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
32
|
-
};
|
|
33
|
-
return acc;
|
|
34
|
-
}, {});
|
|
35
|
-
return {
|
|
36
|
-
id,
|
|
37
|
-
name: agent.name,
|
|
38
|
-
instructions,
|
|
39
|
-
tools: serializedAgentTools,
|
|
40
|
-
provider: llm?.getProvider(),
|
|
41
|
-
modelId: llm?.getModelId()
|
|
42
|
-
};
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
|
|
46
|
-
acc[id] = rest;
|
|
47
|
-
return acc;
|
|
48
|
-
}, {});
|
|
49
|
-
return serializedAgents;
|
|
50
|
-
} catch (error) {
|
|
51
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error getting agents");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async function getAgentByIdHandler({
|
|
55
|
-
mastra,
|
|
56
|
-
runtimeContext,
|
|
57
|
-
agentId
|
|
58
|
-
}) {
|
|
59
|
-
try {
|
|
60
|
-
const agent = mastra.getAgent(agentId);
|
|
61
|
-
if (!agent) {
|
|
62
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
|
|
63
|
-
}
|
|
64
|
-
const tools = await agent.getTools({ runtimeContext });
|
|
65
|
-
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
66
|
-
const _tool = tool;
|
|
67
|
-
acc[key] = {
|
|
68
|
-
..._tool,
|
|
69
|
-
inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
70
|
-
outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
71
|
-
};
|
|
72
|
-
return acc;
|
|
73
|
-
}, {});
|
|
74
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
75
|
-
const llm = await agent.getLLM({ runtimeContext });
|
|
76
|
-
return {
|
|
77
|
-
name: agent.name,
|
|
78
|
-
instructions,
|
|
79
|
-
tools: serializedAgentTools,
|
|
80
|
-
provider: llm?.getProvider(),
|
|
81
|
-
modelId: llm?.getModelId()
|
|
82
|
-
};
|
|
83
|
-
} catch (error) {
|
|
84
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error getting agent");
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async function getEvalsByAgentIdHandler({
|
|
88
|
-
mastra,
|
|
89
|
-
runtimeContext,
|
|
90
|
-
agentId
|
|
91
|
-
}) {
|
|
92
|
-
try {
|
|
93
|
-
const agent = mastra.getAgent(agentId);
|
|
94
|
-
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
|
|
95
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
96
|
-
return {
|
|
97
|
-
id: agentId,
|
|
98
|
-
name: agent.name,
|
|
99
|
-
instructions,
|
|
100
|
-
evals
|
|
101
|
-
};
|
|
102
|
-
} catch (error) {
|
|
103
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error getting test evals");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async function getLiveEvalsByAgentIdHandler({
|
|
107
|
-
mastra,
|
|
108
|
-
runtimeContext,
|
|
109
|
-
agentId
|
|
110
|
-
}) {
|
|
111
|
-
try {
|
|
112
|
-
const agent = mastra.getAgent(agentId);
|
|
113
|
-
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
|
|
114
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
115
|
-
return {
|
|
116
|
-
id: agentId,
|
|
117
|
-
name: agent.name,
|
|
118
|
-
instructions,
|
|
119
|
-
evals
|
|
120
|
-
};
|
|
121
|
-
} catch (error) {
|
|
122
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error getting live evals");
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
async function generateHandler({
|
|
126
|
-
mastra,
|
|
127
|
-
runtimeContext,
|
|
128
|
-
agentId,
|
|
129
|
-
body
|
|
130
|
-
}) {
|
|
131
|
-
try {
|
|
132
|
-
const agent = mastra.getAgent(agentId);
|
|
133
|
-
if (!agent) {
|
|
134
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
|
|
135
|
-
}
|
|
136
|
-
const { messages, resourceId, resourceid, ...rest } = body;
|
|
137
|
-
const finalResourceId = resourceId ?? resourceid;
|
|
138
|
-
chunkQN4KF3BH_cjs.validateBody({ messages });
|
|
139
|
-
const result = await agent.generate(messages, {
|
|
140
|
-
...rest,
|
|
141
|
-
// @ts-expect-error TODO fix types
|
|
142
|
-
resourceId: finalResourceId,
|
|
143
|
-
runtimeContext
|
|
144
|
-
});
|
|
145
|
-
return result;
|
|
146
|
-
} catch (error) {
|
|
147
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error generating from agent");
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async function streamGenerateHandler({
|
|
151
|
-
mastra,
|
|
152
|
-
runtimeContext,
|
|
153
|
-
agentId,
|
|
154
|
-
body
|
|
155
|
-
}) {
|
|
156
|
-
try {
|
|
157
|
-
const agent = mastra.getAgent(agentId);
|
|
158
|
-
if (!agent) {
|
|
159
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
|
|
160
|
-
}
|
|
161
|
-
const { messages, resourceId, resourceid, ...rest } = body;
|
|
162
|
-
const finalResourceId = resourceId ?? resourceid;
|
|
163
|
-
chunkQN4KF3BH_cjs.validateBody({ messages });
|
|
164
|
-
const streamResult = await agent.stream(messages, {
|
|
165
|
-
...rest,
|
|
166
|
-
// @ts-expect-error TODO fix types
|
|
167
|
-
resourceId: finalResourceId,
|
|
168
|
-
runtimeContext
|
|
169
|
-
});
|
|
170
|
-
const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
171
|
-
sendUsage: true,
|
|
172
|
-
sendReasoning: true,
|
|
173
|
-
getErrorMessage: (error) => {
|
|
174
|
-
return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
return streamResponse;
|
|
178
|
-
} catch (error) {
|
|
179
|
-
throw new chunkFV45V6WC_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
exports.agents_exports = agents_exports;
|
|
184
|
-
exports.generateHandler = generateHandler;
|
|
185
|
-
exports.getAgentByIdHandler = getAgentByIdHandler;
|
|
186
|
-
exports.getAgentsHandler = getAgentsHandler;
|
|
187
|
-
exports.getEvalsByAgentIdHandler = getEvalsByAgentIdHandler;
|
|
188
|
-
exports.getLiveEvalsByAgentIdHandler = getLiveEvalsByAgentIdHandler;
|
|
189
|
-
exports.streamGenerateHandler = streamGenerateHandler;
|
package/dist/chunk-55HTWX4C.cjs
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
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');
|
|
6
|
-
var stream = require('stream');
|
|
7
|
-
|
|
8
|
-
// src/server/handlers/voice.ts
|
|
9
|
-
var voice_exports = {};
|
|
10
|
-
chunkFV45V6WC_cjs.__export(voice_exports, {
|
|
11
|
-
generateSpeechHandler: () => generateSpeechHandler,
|
|
12
|
-
getSpeakersHandler: () => getSpeakersHandler,
|
|
13
|
-
transcribeSpeechHandler: () => transcribeSpeechHandler
|
|
14
|
-
});
|
|
15
|
-
async function getSpeakersHandler({ mastra, agentId }) {
|
|
16
|
-
try {
|
|
17
|
-
if (!agentId) {
|
|
18
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
19
|
-
}
|
|
20
|
-
const agent = mastra.getAgent(agentId);
|
|
21
|
-
if (!agent) {
|
|
22
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
|
|
23
|
-
}
|
|
24
|
-
if (!agent.voice) {
|
|
25
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
26
|
-
}
|
|
27
|
-
const speakers = await agent.voice.getSpeakers();
|
|
28
|
-
return speakers;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error getting speakers");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function generateSpeechHandler({
|
|
34
|
-
mastra,
|
|
35
|
-
agentId,
|
|
36
|
-
body
|
|
37
|
-
}) {
|
|
38
|
-
try {
|
|
39
|
-
if (!agentId) {
|
|
40
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
41
|
-
}
|
|
42
|
-
chunkQN4KF3BH_cjs.validateBody({
|
|
43
|
-
text: body?.text
|
|
44
|
-
});
|
|
45
|
-
const agent = mastra.getAgent(agentId);
|
|
46
|
-
if (!agent) {
|
|
47
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
|
|
48
|
-
}
|
|
49
|
-
if (!agent.voice) {
|
|
50
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
51
|
-
}
|
|
52
|
-
const audioStream = await agent.voice.speak(body.text, { speaker: body.speakerId });
|
|
53
|
-
if (!audioStream) {
|
|
54
|
-
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: "Failed to generate speech" });
|
|
55
|
-
}
|
|
56
|
-
return audioStream;
|
|
57
|
-
} catch (error) {
|
|
58
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error generating speech");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function transcribeSpeechHandler({
|
|
62
|
-
mastra,
|
|
63
|
-
agentId,
|
|
64
|
-
body
|
|
65
|
-
}) {
|
|
66
|
-
try {
|
|
67
|
-
if (!agentId) {
|
|
68
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
69
|
-
}
|
|
70
|
-
if (!body?.audioData) {
|
|
71
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Audio data is required" });
|
|
72
|
-
}
|
|
73
|
-
const agent = mastra.getAgent(agentId);
|
|
74
|
-
if (!agent) {
|
|
75
|
-
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
|
|
76
|
-
}
|
|
77
|
-
if (!agent.voice) {
|
|
78
|
-
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
79
|
-
}
|
|
80
|
-
const audioStream = new stream.Readable();
|
|
81
|
-
audioStream.push(body.audioData);
|
|
82
|
-
audioStream.push(null);
|
|
83
|
-
const text = await agent.voice.listen(audioStream, body.options);
|
|
84
|
-
return { text };
|
|
85
|
-
} catch (error) {
|
|
86
|
-
return chunkZLBRQFDD_cjs.handleError(error, "Error transcribing speech");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
exports.generateSpeechHandler = generateSpeechHandler;
|
|
91
|
-
exports.getSpeakersHandler = getSpeakersHandler;
|
|
92
|
-
exports.transcribeSpeechHandler = transcribeSpeechHandler;
|
|
93
|
-
exports.voice_exports = voice_exports;
|