@mastra/server 0.0.0-mcp-schema-serializer-20250430202337 → 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.
Files changed (93) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +524 -100
  3. package/dist/_tsup-dts-rollup.d.ts +524 -100
  4. package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
  5. package/dist/{chunk-5YGDYMRB.cjs → chunk-2SLFAFTR.cjs} +14 -13
  6. package/dist/chunk-4D66QEKC.js +81 -0
  7. package/dist/{chunk-M3YJLWTU.js → chunk-5PQQ42EZ.js} +68 -57
  8. package/dist/chunk-75ZPJI57.cjs +9 -0
  9. package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
  10. package/dist/chunk-B2PAS2IB.cjs +514 -0
  11. package/dist/{chunk-Y3SV5XK4.js → chunk-BK4XT6EG.js} +105 -16
  12. package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  13. package/dist/{chunk-QJ3AHN64.js → chunk-CRCR3ZUK.js} +4 -3
  14. package/dist/{chunk-2FJURXCL.cjs → chunk-DN7K6FJK.cjs} +93 -55
  15. package/dist/{chunk-D3G23FP3.cjs → chunk-FRVBFMO2.cjs} +24 -22
  16. package/dist/{chunk-7IWQE76Z.cjs → chunk-G7KH752Y.cjs} +16 -10
  17. package/dist/chunk-GHC4YV6R.js +504 -0
  18. package/dist/chunk-H7DMHBKY.js +498 -0
  19. package/dist/chunk-JMLYCXMK.cjs +332 -0
  20. package/dist/{chunk-Q6SHQECN.js → chunk-KHZKYUNR.js} +34 -10
  21. package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
  22. package/dist/chunk-LF7P5PLR.js +14 -0
  23. package/dist/chunk-LI436ITD.cjs +2042 -0
  24. package/dist/{chunk-5JNVY6DU.js → chunk-LRCAAFUA.js} +7 -5
  25. package/dist/chunk-LZ3VJXSO.cjs +278 -0
  26. package/dist/chunk-MEGCYGBU.js +2039 -0
  27. package/dist/{chunk-RBQASTUP.js → chunk-MKLYEKEF.js} +63 -25
  28. package/dist/chunk-MLKGABMK.js +7 -0
  29. package/dist/chunk-PZQDCRPV.cjs +16 -0
  30. package/dist/chunk-QGX47B5D.cjs +86 -0
  31. package/dist/{chunk-WTHDCRMY.js → chunk-RG473F6Y.js} +12 -6
  32. package/dist/chunk-RHSWAXKB.cjs +118 -0
  33. package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
  34. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  35. package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
  36. package/dist/server/handlers/a2a.cjs +30 -0
  37. package/dist/server/handlers/a2a.d.cts +6 -0
  38. package/dist/server/handlers/a2a.d.ts +6 -0
  39. package/dist/server/handlers/a2a.js +1 -0
  40. package/dist/server/handlers/agents.cjs +7 -7
  41. package/dist/server/handlers/agents.js +1 -1
  42. package/dist/server/handlers/error.cjs +2 -2
  43. package/dist/server/handlers/error.js +1 -1
  44. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  45. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  46. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  47. package/dist/server/handlers/legacyWorkflows.js +1 -0
  48. package/dist/server/handlers/logs.cjs +4 -4
  49. package/dist/server/handlers/logs.js +1 -1
  50. package/dist/server/handlers/memory.cjs +9 -9
  51. package/dist/server/handlers/memory.js +1 -1
  52. package/dist/server/handlers/network.cjs +5 -5
  53. package/dist/server/handlers/network.js +1 -1
  54. package/dist/server/handlers/telemetry.cjs +3 -3
  55. package/dist/server/handlers/telemetry.js +1 -1
  56. package/dist/server/handlers/tools.cjs +5 -5
  57. package/dist/server/handlers/tools.js +1 -1
  58. package/dist/server/handlers/utils.cjs +2 -2
  59. package/dist/server/handlers/utils.js +1 -1
  60. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  61. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  62. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  63. package/dist/server/handlers/vNextNetwork.js +211 -0
  64. package/dist/server/handlers/vector.cjs +7 -7
  65. package/dist/server/handlers/vector.js +1 -1
  66. package/dist/server/handlers/voice.cjs +8 -4
  67. package/dist/server/handlers/voice.d.cts +1 -0
  68. package/dist/server/handlers/voice.d.ts +1 -0
  69. package/dist/server/handlers/voice.js +1 -1
  70. package/dist/server/handlers/workflows.cjs +29 -13
  71. package/dist/server/handlers/workflows.d.cts +6 -2
  72. package/dist/server/handlers/workflows.d.ts +6 -2
  73. package/dist/server/handlers/workflows.js +1 -1
  74. package/dist/server/handlers.cjs +32 -27
  75. package/dist/server/handlers.d.cts +2 -1
  76. package/dist/server/handlers.d.ts +2 -1
  77. package/dist/server/handlers.js +11 -10
  78. package/package.json +14 -13
  79. package/dist/chunk-3AHQ5RGN.js +0 -11
  80. package/dist/chunk-3EJZQ6TQ.js +0 -49
  81. package/dist/chunk-4BIX6GMY.cjs +0 -189
  82. package/dist/chunk-55HTWX4C.cjs +0 -93
  83. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  84. package/dist/chunk-AELYAUEE.cjs +0 -316
  85. package/dist/chunk-EVCC233P.cjs +0 -321
  86. package/dist/chunk-JPB6RPGB.js +0 -304
  87. package/dist/chunk-OMN3UI6X.js +0 -5576
  88. package/dist/chunk-SKBVVI24.cjs +0 -54
  89. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  90. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  91. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  92. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  93. package/dist/server/handlers/vNextWorkflows.js +0 -1
@@ -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-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
4
5
 
5
6
  // src/server/handlers/memory.ts
6
7
  var memory_exports = {};
@@ -14,20 +15,36 @@ __export(memory_exports, {
14
15
  saveMessagesHandler: () => saveMessagesHandler,
15
16
  updateThreadHandler: () => updateThreadHandler
16
17
  });
17
- function getMemoryFromContext({
18
+ async function getMemoryFromContext({
18
19
  mastra,
19
- agentId
20
+ agentId,
21
+ networkId,
22
+ runtimeContext
20
23
  }) {
21
24
  const agent = agentId ? mastra.getAgent(agentId) : null;
22
25
  if (agentId && !agent) {
23
26
  throw new HTTPException(404, { message: "Agent not found" });
24
27
  }
25
- const memory = agent?.getMemory?.() || mastra.getMemory();
26
- return memory;
28
+ const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
29
+ if (networkId && !network) {
30
+ throw new HTTPException(404, { message: "Network not found" });
31
+ }
32
+ if (agent) {
33
+ return agent?.getMemory() || mastra.getMemory();
34
+ }
35
+ if (network) {
36
+ return await network?.getMemory({ runtimeContext }) || mastra.getMemory();
37
+ }
38
+ return mastra.getMemory();
27
39
  }
28
- async function getMemoryStatusHandler({ mastra, agentId }) {
40
+ async function getMemoryStatusHandler({
41
+ mastra,
42
+ agentId,
43
+ networkId,
44
+ runtimeContext
45
+ }) {
29
46
  try {
30
- const memory = getMemoryFromContext({ mastra, agentId });
47
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
31
48
  if (!memory) {
32
49
  return { result: false };
33
50
  }
@@ -39,10 +56,12 @@ async function getMemoryStatusHandler({ mastra, agentId }) {
39
56
  async function getThreadsHandler({
40
57
  mastra,
41
58
  agentId,
42
- resourceId
59
+ resourceId,
60
+ networkId,
61
+ runtimeContext
43
62
  }) {
44
63
  try {
45
- const memory = getMemoryFromContext({ mastra, agentId });
64
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
46
65
  if (!memory) {
47
66
  throw new HTTPException(400, { message: "Memory is not initialized" });
48
67
  }
@@ -56,11 +75,13 @@ async function getThreadsHandler({
56
75
  async function getThreadByIdHandler({
57
76
  mastra,
58
77
  agentId,
59
- threadId
78
+ threadId,
79
+ networkId,
80
+ runtimeContext
60
81
  }) {
61
82
  try {
62
83
  validateBody({ threadId });
63
- const memory = getMemoryFromContext({ mastra, agentId });
84
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
64
85
  if (!memory) {
65
86
  throw new HTTPException(400, { message: "Memory is not initialized" });
66
87
  }
@@ -76,10 +97,12 @@ async function getThreadByIdHandler({
76
97
  async function saveMessagesHandler({
77
98
  mastra,
78
99
  agentId,
79
- body
100
+ body,
101
+ networkId,
102
+ runtimeContext
80
103
  }) {
81
104
  try {
82
- const memory = getMemoryFromContext({ mastra, agentId });
105
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
83
106
  if (!memory) {
84
107
  throw new HTTPException(400, { message: "Memory is not initialized" });
85
108
  }
@@ -103,10 +126,12 @@ async function saveMessagesHandler({
103
126
  async function createThreadHandler({
104
127
  mastra,
105
128
  agentId,
106
- body
129
+ body,
130
+ networkId,
131
+ runtimeContext
107
132
  }) {
108
133
  try {
109
- const memory = getMemoryFromContext({ mastra, agentId });
134
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
110
135
  if (!memory) {
111
136
  throw new HTTPException(400, { message: "Memory is not initialized" });
112
137
  }
@@ -126,10 +151,12 @@ async function updateThreadHandler({
126
151
  mastra,
127
152
  agentId,
128
153
  threadId,
129
- body
154
+ body,
155
+ networkId,
156
+ runtimeContext
130
157
  }) {
131
158
  try {
132
- const memory = getMemoryFromContext({ mastra, agentId });
159
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
133
160
  if (!body) {
134
161
  throw new HTTPException(400, { message: "Body is required" });
135
162
  }
@@ -160,11 +187,13 @@ async function updateThreadHandler({
160
187
  async function deleteThreadHandler({
161
188
  mastra,
162
189
  agentId,
163
- threadId
190
+ threadId,
191
+ networkId,
192
+ runtimeContext
164
193
  }) {
165
194
  try {
166
195
  validateBody({ threadId });
167
- const memory = getMemoryFromContext({ mastra, agentId });
196
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
168
197
  if (!memory) {
169
198
  throw new HTTPException(400, { message: "Memory is not initialized" });
170
199
  }
@@ -181,11 +210,17 @@ async function deleteThreadHandler({
181
210
  async function getMessagesHandler({
182
211
  mastra,
183
212
  agentId,
184
- threadId
213
+ threadId,
214
+ limit,
215
+ networkId,
216
+ runtimeContext
185
217
  }) {
218
+ if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
219
+ throw new HTTPException(400, { message: "Invalid limit: must be a positive integer" });
220
+ }
186
221
  try {
187
222
  validateBody({ threadId });
188
- const memory = getMemoryFromContext({ mastra, agentId });
223
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
189
224
  if (!memory) {
190
225
  throw new HTTPException(400, { message: "Memory is not initialized" });
191
226
  }
@@ -193,8 +228,11 @@ async function getMessagesHandler({
193
228
  if (!thread) {
194
229
  throw new HTTPException(404, { message: "Thread not found" });
195
230
  }
196
- const result = await memory.query({ threadId });
197
- return result;
231
+ const result = await memory.query({
232
+ threadId,
233
+ ...limit && { selectBy: { last: limit } }
234
+ });
235
+ return { messages: result.messages, uiMessages: result.uiMessages };
198
236
  } catch (error) {
199
237
  return handleError(error, "Error getting messages");
200
238
  }
@@ -0,0 +1,7 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export { __export };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
4
+
5
+ // src/server/handlers/error.ts
6
+ function handleError(error, defaultMessage) {
7
+ const apiError = error;
8
+ const apiErrorStatus = apiError.status || apiError.details?.status || 500;
9
+ throw new chunk2KZFMI6P_cjs.HTTPException(apiErrorStatus, {
10
+ message: apiError.message || defaultMessage,
11
+ stack: apiError.stack,
12
+ cause: apiError.cause
13
+ });
14
+ }
15
+
16
+ exports.handleError = handleError;
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
+
7
+ // src/server/handlers/logs.ts
8
+ var logs_exports = {};
9
+ chunk75ZPJI57_cjs.__export(logs_exports, {
10
+ getLogTransports: () => getLogTransports,
11
+ getLogsByRunIdHandler: () => getLogsByRunIdHandler,
12
+ getLogsHandler: () => getLogsHandler
13
+ });
14
+ async function getLogsHandler({
15
+ mastra,
16
+ transportId,
17
+ params
18
+ }) {
19
+ try {
20
+ chunkCCGRCYWJ_cjs.validateBody({ transportId });
21
+ const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
22
+ const filters = _filters ? Object.fromEntries(
23
+ (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
24
+ const [key, value] = attr.split(":");
25
+ return [key, value];
26
+ })
27
+ ) : void 0;
28
+ const logs = await mastra.getLogs(transportId, {
29
+ fromDate,
30
+ toDate,
31
+ logLevel,
32
+ filters,
33
+ page: page ? Number(page) : void 0,
34
+ perPage: perPage ? Number(perPage) : void 0
35
+ });
36
+ return logs;
37
+ } catch (error) {
38
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting logs");
39
+ }
40
+ }
41
+ async function getLogsByRunIdHandler({
42
+ mastra,
43
+ runId,
44
+ transportId,
45
+ params
46
+ }) {
47
+ try {
48
+ chunkCCGRCYWJ_cjs.validateBody({ runId, transportId });
49
+ const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
50
+ const filters = _filters ? Object.fromEntries(
51
+ (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
52
+ const [key, value] = attr.split(":");
53
+ return [key, value];
54
+ })
55
+ ) : void 0;
56
+ const logs = await mastra.getLogsByRunId({
57
+ runId,
58
+ transportId,
59
+ fromDate,
60
+ toDate,
61
+ logLevel,
62
+ filters,
63
+ page: page ? Number(page) : void 0,
64
+ perPage: perPage ? Number(perPage) : void 0
65
+ });
66
+ return logs;
67
+ } catch (error) {
68
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting logs by run ID");
69
+ }
70
+ }
71
+ async function getLogTransports({ mastra }) {
72
+ try {
73
+ const logger = mastra.getLogger();
74
+ const transports = logger.getTransports();
75
+ return {
76
+ transports: transports ? [...transports.keys()] : []
77
+ };
78
+ } catch (error) {
79
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting log Transports");
80
+ }
81
+ }
82
+
83
+ exports.getLogTransports = getLogTransports;
84
+ exports.getLogsByRunIdHandler = getLogsByRunIdHandler;
85
+ exports.getLogsHandler = getLogsHandler;
86
+ exports.logs_exports = logs_exports;
@@ -1,5 +1,6 @@
1
- import { handleError } from './chunk-3AHQ5RGN.js';
2
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { handleError } from './chunk-LF7P5PLR.js';
2
+ import { HTTPException } from './chunk-LCM566I4.js';
3
+ import { __export } from './chunk-MLKGABMK.js';
3
4
 
4
5
  // src/server/handlers/telemetry.ts
5
6
  var telemetry_exports = {};
@@ -15,12 +16,12 @@ async function getTelemetryHandler({ mastra, body }) {
15
16
  throw new HTTPException(400, { message: "Telemetry is not initialized" });
16
17
  }
17
18
  if (!storage) {
18
- throw new HTTPException(400, { message: "Storage is not initialized" });
19
+ return [];
19
20
  }
20
21
  if (!body) {
21
22
  throw new HTTPException(400, { message: "Body is required" });
22
23
  }
23
- const { name, scope, page, perPage, attribute } = body;
24
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
24
25
  const attributes = attribute ? Object.fromEntries(
25
26
  (Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
26
27
  const [key, value] = attr.split(":");
@@ -32,7 +33,9 @@ async function getTelemetryHandler({ mastra, body }) {
32
33
  scope,
33
34
  page: Number(page ?? 0),
34
35
  perPage: Number(perPage ?? 100),
35
- attributes
36
+ attributes,
37
+ fromDate: fromDate ? new Date(fromDate) : void 0,
38
+ toDate: toDate ? new Date(toDate) : void 0
36
39
  });
37
40
  return traces;
38
41
  } catch (error2) {
@@ -44,7 +47,10 @@ async function storeTelemetryHandler({ mastra, body }) {
44
47
  const storage = mastra.getStorage();
45
48
  const logger = mastra.getLogger();
46
49
  if (!storage) {
47
- throw new HTTPException(400, { message: "Storage is not initialized" });
50
+ return {
51
+ status: "error",
52
+ message: "Storage is not initialized"
53
+ };
48
54
  }
49
55
  const now = /* @__PURE__ */ new Date();
50
56
  const items = body?.resourceSpans?.[0]?.scopeSpans;
@@ -0,0 +1,118 @@
1
+ 'use strict';
2
+
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.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 chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
21
+ }
22
+ const agent = mastra.getAgent(agentId);
23
+ if (!agent) {
24
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
25
+ }
26
+ const voice = await agent.getVoice();
27
+ if (!voice) {
28
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
29
+ }
30
+ const speakers = await voice.getSpeakers();
31
+ return speakers;
32
+ } catch (error) {
33
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting speakers");
34
+ }
35
+ }
36
+ async function generateSpeechHandler({
37
+ mastra,
38
+ agentId,
39
+ body
40
+ }) {
41
+ try {
42
+ if (!agentId) {
43
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
44
+ }
45
+ chunkCCGRCYWJ_cjs.validateBody({
46
+ text: body?.text
47
+ });
48
+ const agent = mastra.getAgent(agentId);
49
+ if (!agent) {
50
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
51
+ }
52
+ const voice = await agent.getVoice();
53
+ if (!voice) {
54
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
55
+ }
56
+ const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
57
+ if (!audioStream) {
58
+ throw new chunk2KZFMI6P_cjs.HTTPException(500, { message: "Failed to generate speech" });
59
+ }
60
+ return audioStream;
61
+ } catch (error) {
62
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating speech");
63
+ }
64
+ }
65
+ async function transcribeSpeechHandler({
66
+ mastra,
67
+ agentId,
68
+ body
69
+ }) {
70
+ try {
71
+ if (!agentId) {
72
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
73
+ }
74
+ if (!body?.audioData) {
75
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Audio data is required" });
76
+ }
77
+ const agent = mastra.getAgent(agentId);
78
+ if (!agent) {
79
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
80
+ }
81
+ const voice = await agent.getVoice();
82
+ if (!voice) {
83
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
84
+ }
85
+ const audioStream = new stream.Readable();
86
+ audioStream.push(body.audioData);
87
+ audioStream.push(null);
88
+ const text = await voice.listen(audioStream, body.options);
89
+ return { text };
90
+ } catch (error) {
91
+ return chunkPZQDCRPV_cjs.handleError(error, "Error transcribing speech");
92
+ }
93
+ }
94
+ async function getListenerHandler({ mastra, agentId }) {
95
+ try {
96
+ if (!agentId) {
97
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
98
+ }
99
+ const agent = mastra.getAgent(agentId);
100
+ if (!agent) {
101
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
102
+ }
103
+ const voice = await agent.getVoice();
104
+ if (!voice) {
105
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
106
+ }
107
+ const listeners = await voice.getListener();
108
+ return listeners;
109
+ } catch (error) {
110
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting listeners");
111
+ }
112
+ }
113
+
114
+ exports.generateSpeechHandler = generateSpeechHandler;
115
+ exports.getListenerHandler = getListenerHandler;
116
+ exports.getSpeakersHandler = getSpeakersHandler;
117
+ exports.transcribeSpeechHandler = transcribeSpeechHandler;
118
+ exports.voice_exports = voice_exports;
@@ -1,4 +1,4 @@
1
- import { HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { HTTPException } from './chunk-LCM566I4.js';
2
2
 
3
3
  // src/server/handlers/utils.ts
4
4
  function validateBody(body) {