@mastra/server 0.0.0-tool-call-parts-20250630193309 → 0.0.0-transpile-packages-20250724123433

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 (72) hide show
  1. package/LICENSE.md +11 -42
  2. package/dist/_tsup-dts-rollup.d.cts +142 -14
  3. package/dist/_tsup-dts-rollup.d.ts +142 -14
  4. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  5. package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
  6. package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
  7. package/dist/{chunk-E2LP4J6K.js → chunk-5PQQ42EZ.js} +7 -7
  8. package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
  9. package/dist/{chunk-L3VURYKY.cjs → chunk-B2PAS2IB.cjs} +134 -55
  10. package/dist/{chunk-2BCWG3EZ.js → chunk-BK4XT6EG.js} +4 -4
  11. package/dist/chunk-CBFTEHOO.cjs +157 -0
  12. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  13. package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
  14. package/dist/{chunk-Z3PTO2AK.cjs → chunk-FRVBFMO2.cjs} +15 -15
  15. package/dist/{chunk-XUIJ7WRT.js → chunk-G4L7OMCA.js} +84 -5
  16. package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
  17. package/dist/{chunk-72LOJGUV.js → chunk-H7DMHBKY.js} +88 -11
  18. package/dist/{chunk-NGHSYB5B.cjs → chunk-JMLYCXMK.cjs} +36 -36
  19. package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
  20. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  21. package/dist/chunk-LF7P5PLR.js +14 -0
  22. package/dist/{chunk-EWLR2PNT.js → chunk-LRCAAFUA.js} +3 -3
  23. package/dist/{chunk-EP3XVEVC.cjs → chunk-LZ3VJXSO.cjs} +14 -14
  24. package/dist/chunk-PZQDCRPV.cjs +16 -0
  25. package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
  26. package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
  27. package/dist/{chunk-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
  28. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  29. package/dist/chunk-VULESSU5.js +149 -0
  30. package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
  31. package/dist/{chunk-RQ2Z56EC.cjs → chunk-Z75RYULP.cjs} +117 -35
  32. package/dist/server/handlers/agents.cjs +7 -7
  33. package/dist/server/handlers/agents.js +1 -1
  34. package/dist/server/handlers/error.cjs +2 -2
  35. package/dist/server/handlers/error.js +1 -1
  36. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  37. package/dist/server/handlers/legacyWorkflows.js +1 -1
  38. package/dist/server/handlers/logs.cjs +4 -4
  39. package/dist/server/handlers/logs.js +1 -1
  40. package/dist/server/handlers/memory.cjs +21 -9
  41. package/dist/server/handlers/memory.d.cts +3 -0
  42. package/dist/server/handlers/memory.d.ts +3 -0
  43. package/dist/server/handlers/memory.js +1 -1
  44. package/dist/server/handlers/network.cjs +5 -5
  45. package/dist/server/handlers/network.js +1 -1
  46. package/dist/server/handlers/scores.cjs +30 -0
  47. package/dist/server/handlers/scores.d.cts +6 -0
  48. package/dist/server/handlers/scores.d.ts +6 -0
  49. package/dist/server/handlers/scores.js +1 -0
  50. package/dist/server/handlers/telemetry.cjs +3 -3
  51. package/dist/server/handlers/telemetry.js +1 -1
  52. package/dist/server/handlers/tools.cjs +5 -5
  53. package/dist/server/handlers/tools.js +1 -1
  54. package/dist/server/handlers/utils.cjs +2 -2
  55. package/dist/server/handlers/utils.js +1 -1
  56. package/dist/server/handlers/vNextNetwork.cjs +18 -18
  57. package/dist/server/handlers/vNextNetwork.js +3 -3
  58. package/dist/server/handlers/vector.cjs +7 -7
  59. package/dist/server/handlers/vector.js +1 -1
  60. package/dist/server/handlers/voice.cjs +5 -5
  61. package/dist/server/handlers/voice.js +1 -1
  62. package/dist/server/handlers/workflows.cjs +21 -13
  63. package/dist/server/handlers/workflows.d.cts +2 -0
  64. package/dist/server/handlers/workflows.d.ts +2 -0
  65. package/dist/server/handlers/workflows.js +1 -1
  66. package/dist/server/handlers.cjs +28 -23
  67. package/dist/server/handlers.d.cts +3 -2
  68. package/dist/server/handlers.d.ts +3 -2
  69. package/dist/server/handlers.js +11 -10
  70. package/package.json +8 -7
  71. package/dist/chunk-64U3UDTH.cjs +0 -13
  72. package/dist/chunk-M5ABIP7D.js +0 -11
@@ -1,6 +1,6 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
  import { Readable } from 'stream';
6
6
 
@@ -11,6 +11,7 @@ var HTTPException = class extends Error {
11
11
  super(options?.message, { cause: options?.cause });
12
12
  this.res = options?.res;
13
13
  this.status = status;
14
+ this.stack = options?.stack || this.stack;
14
15
  }
15
16
  /**
16
17
  * Returns the response object associated with the exception.
@@ -0,0 +1,14 @@
1
+ import { HTTPException } from './chunk-LCM566I4.js';
2
+
3
+ // src/server/handlers/error.ts
4
+ function handleError(error, defaultMessage) {
5
+ const apiError = error;
6
+ const apiErrorStatus = apiError.status || apiError.details?.status || 500;
7
+ throw new HTTPException(apiErrorStatus, {
8
+ message: apiError.message || defaultMessage,
9
+ stack: apiError.stack,
10
+ cause: apiError.cause
11
+ });
12
+ }
13
+
14
+ export { handleError };
@@ -1,7 +1,7 @@
1
1
  import { stringify, esm_default } from './chunk-MEGCYGBU.js';
2
- import { validateBody } from './chunk-H5PTF3Y4.js';
3
- import { handleError } from './chunk-M5ABIP7D.js';
4
- import { HTTPException } from './chunk-NYN7KFXL.js';
2
+ import { validateBody } from './chunk-RSEO4XPX.js';
3
+ import { handleError } from './chunk-LF7P5PLR.js';
4
+ import { HTTPException } from './chunk-LCM566I4.js';
5
5
  import { __export } from './chunk-MLKGABMK.js';
6
6
  import { isVercelTool } from '@mastra/core/tools';
7
7
 
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
4
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
5
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
6
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
4
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
5
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
6
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
7
7
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
8
8
  var runtimeContext = require('@mastra/core/runtime-context');
9
9
 
@@ -72,7 +72,7 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
72
72
  }, {});
73
73
  return serializedAgents;
74
74
  } catch (error) {
75
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agents");
75
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting agents");
76
76
  }
77
77
  }
78
78
  async function getAgentByIdHandler({
@@ -84,7 +84,7 @@ async function getAgentByIdHandler({
84
84
  try {
85
85
  const agent = mastra.getAgent(agentId);
86
86
  if (!agent) {
87
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
87
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
88
88
  }
89
89
  const tools = await agent.getTools({ runtimeContext });
90
90
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
@@ -151,7 +151,7 @@ async function getAgentByIdHandler({
151
151
  defaultStreamOptions
152
152
  };
153
153
  } catch (error) {
154
- return chunk64U3UDTH_cjs.handleError(error, "Error getting agent");
154
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting agent");
155
155
  }
156
156
  }
157
157
  async function getEvalsByAgentIdHandler({
@@ -170,7 +170,7 @@ async function getEvalsByAgentIdHandler({
170
170
  evals
171
171
  };
172
172
  } catch (error) {
173
- return chunk64U3UDTH_cjs.handleError(error, "Error getting test evals");
173
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting test evals");
174
174
  }
175
175
  }
176
176
  async function getLiveEvalsByAgentIdHandler({
@@ -189,7 +189,7 @@ async function getLiveEvalsByAgentIdHandler({
189
189
  evals
190
190
  };
191
191
  } catch (error) {
192
- return chunk64U3UDTH_cjs.handleError(error, "Error getting live evals");
192
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting live evals");
193
193
  }
194
194
  }
195
195
  async function generateHandler({
@@ -202,7 +202,7 @@ async function generateHandler({
202
202
  try {
203
203
  const agent = mastra.getAgent(agentId);
204
204
  if (!agent) {
205
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
205
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
206
206
  }
207
207
  const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
208
208
  const finalResourceId = resourceId ?? resourceid;
@@ -210,7 +210,7 @@ async function generateHandler({
210
210
  ...Array.from(runtimeContext$1.entries()),
211
211
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
212
212
  ]);
213
- chunk57CJTIPW_cjs.validateBody({ messages });
213
+ chunkCCGRCYWJ_cjs.validateBody({ messages });
214
214
  const result = await agent.generate(messages, {
215
215
  ...rest,
216
216
  // @ts-expect-error TODO fix types
@@ -220,7 +220,7 @@ async function generateHandler({
220
220
  });
221
221
  return result;
222
222
  } catch (error) {
223
- return chunk64U3UDTH_cjs.handleError(error, "Error generating from agent");
223
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating from agent");
224
224
  }
225
225
  }
226
226
  async function streamGenerateHandler({
@@ -233,7 +233,7 @@ async function streamGenerateHandler({
233
233
  try {
234
234
  const agent = mastra.getAgent(agentId);
235
235
  if (!agent) {
236
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
236
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
237
237
  }
238
238
  const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
239
239
  const finalResourceId = resourceId ?? resourceid;
@@ -241,7 +241,7 @@ async function streamGenerateHandler({
241
241
  ...Array.from(runtimeContext$1.entries()),
242
242
  ...Array.from(Object.entries(agentRuntimeContext ?? {}))
243
243
  ]);
244
- chunk57CJTIPW_cjs.validateBody({ messages });
244
+ chunkCCGRCYWJ_cjs.validateBody({ messages });
245
245
  const streamResult = await agent.stream(messages, {
246
246
  ...rest,
247
247
  // @ts-expect-error TODO fix types
@@ -265,7 +265,7 @@ async function streamGenerateHandler({
265
265
  });
266
266
  return streamResponse;
267
267
  } catch (error) {
268
- throw new chunkOCWPVYNI_cjs.HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
268
+ return chunkPZQDCRPV_cjs.handleError(error, "error streaming agent response");
269
269
  }
270
270
  }
271
271
 
@@ -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;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
5
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
6
 
7
7
  // src/server/handlers/logs.ts
@@ -17,7 +17,7 @@ async function getLogsHandler({
17
17
  params
18
18
  }) {
19
19
  try {
20
- chunk57CJTIPW_cjs.validateBody({ transportId });
20
+ chunkCCGRCYWJ_cjs.validateBody({ transportId });
21
21
  const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
22
22
  const filters = _filters ? Object.fromEntries(
23
23
  (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
@@ -35,7 +35,7 @@ async function getLogsHandler({
35
35
  });
36
36
  return logs;
37
37
  } catch (error) {
38
- return chunk64U3UDTH_cjs.handleError(error, "Error getting logs");
38
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting logs");
39
39
  }
40
40
  }
41
41
  async function getLogsByRunIdHandler({
@@ -45,7 +45,7 @@ async function getLogsByRunIdHandler({
45
45
  params
46
46
  }) {
47
47
  try {
48
- chunk57CJTIPW_cjs.validateBody({ runId, transportId });
48
+ chunkCCGRCYWJ_cjs.validateBody({ runId, transportId });
49
49
  const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
50
50
  const filters = _filters ? Object.fromEntries(
51
51
  (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
@@ -65,7 +65,7 @@ async function getLogsByRunIdHandler({
65
65
  });
66
66
  return logs;
67
67
  } catch (error) {
68
- return chunk64U3UDTH_cjs.handleError(error, "Error getting logs by run ID");
68
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting logs by run ID");
69
69
  }
70
70
  }
71
71
  async function getLogTransports({ mastra }) {
@@ -76,7 +76,7 @@ async function getLogTransports({ mastra }) {
76
76
  transports: transports ? [...transports.keys()] : []
77
77
  };
78
78
  } catch (error) {
79
- return chunk64U3UDTH_cjs.handleError(error, "Error getting log Transports");
79
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting log Transports");
80
80
  }
81
81
  }
82
82
 
@@ -1,5 +1,5 @@
1
- import { handleError } from './chunk-M5ABIP7D.js';
2
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { handleError } from './chunk-LF7P5PLR.js';
2
+ import { HTTPException } from './chunk-LCM566I4.js';
3
3
  import { __export } from './chunk-MLKGABMK.js';
4
4
 
5
5
  // src/server/handlers/telemetry.ts
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
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');
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
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
  var stream = require('stream');
8
8
 
@@ -17,20 +17,20 @@ chunk75ZPJI57_cjs.__export(voice_exports, {
17
17
  async function getSpeakersHandler({ mastra, agentId }) {
18
18
  try {
19
19
  if (!agentId) {
20
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
20
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
21
21
  }
22
22
  const agent = mastra.getAgent(agentId);
23
23
  if (!agent) {
24
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
24
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
25
25
  }
26
26
  const voice = await agent.getVoice();
27
27
  if (!voice) {
28
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
28
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
29
29
  }
30
30
  const speakers = await voice.getSpeakers();
31
31
  return speakers;
32
32
  } catch (error) {
33
- return chunk64U3UDTH_cjs.handleError(error, "Error getting speakers");
33
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting speakers");
34
34
  }
35
35
  }
36
36
  async function generateSpeechHandler({
@@ -40,26 +40,26 @@ async function generateSpeechHandler({
40
40
  }) {
41
41
  try {
42
42
  if (!agentId) {
43
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
43
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
44
44
  }
45
- chunk57CJTIPW_cjs.validateBody({
45
+ chunkCCGRCYWJ_cjs.validateBody({
46
46
  text: body?.text
47
47
  });
48
48
  const agent = mastra.getAgent(agentId);
49
49
  if (!agent) {
50
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
50
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
51
51
  }
52
52
  const voice = await agent.getVoice();
53
53
  if (!voice) {
54
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
54
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
55
55
  }
56
56
  const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
57
57
  if (!audioStream) {
58
- throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: "Failed to generate speech" });
58
+ throw new chunk2KZFMI6P_cjs.HTTPException(500, { message: "Failed to generate speech" });
59
59
  }
60
60
  return audioStream;
61
61
  } catch (error) {
62
- return chunk64U3UDTH_cjs.handleError(error, "Error generating speech");
62
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating speech");
63
63
  }
64
64
  }
65
65
  async function transcribeSpeechHandler({
@@ -69,18 +69,18 @@ async function transcribeSpeechHandler({
69
69
  }) {
70
70
  try {
71
71
  if (!agentId) {
72
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
72
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
73
73
  }
74
74
  if (!body?.audioData) {
75
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Audio data is required" });
75
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Audio data is required" });
76
76
  }
77
77
  const agent = mastra.getAgent(agentId);
78
78
  if (!agent) {
79
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
79
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
80
80
  }
81
81
  const voice = await agent.getVoice();
82
82
  if (!voice) {
83
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
83
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
84
84
  }
85
85
  const audioStream = new stream.Readable();
86
86
  audioStream.push(body.audioData);
@@ -88,26 +88,26 @@ async function transcribeSpeechHandler({
88
88
  const text = await voice.listen(audioStream, body.options);
89
89
  return { text };
90
90
  } catch (error) {
91
- return chunk64U3UDTH_cjs.handleError(error, "Error transcribing speech");
91
+ return chunkPZQDCRPV_cjs.handleError(error, "Error transcribing speech");
92
92
  }
93
93
  }
94
94
  async function getListenerHandler({ mastra, agentId }) {
95
95
  try {
96
96
  if (!agentId) {
97
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent ID is required" });
97
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent ID is required" });
98
98
  }
99
99
  const agent = mastra.getAgent(agentId);
100
100
  if (!agent) {
101
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
101
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
102
102
  }
103
103
  const voice = await agent.getVoice();
104
104
  if (!voice) {
105
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
105
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
106
106
  }
107
107
  const listeners = await voice.getListener();
108
108
  return listeners;
109
109
  } catch (error) {
110
- return chunk64U3UDTH_cjs.handleError(error, "Error getting listeners");
110
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting listeners");
111
111
  }
112
112
  }
113
113
 
@@ -1,4 +1,4 @@
1
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { HTTPException } from './chunk-LCM566I4.js';
2
2
 
3
3
  // src/server/handlers/utils.ts
4
4
  function validateBody(body) {
@@ -0,0 +1,149 @@
1
+ import { handleError } from './chunk-LF7P5PLR.js';
2
+ import { __export } from './chunk-MLKGABMK.js';
3
+
4
+ // src/server/handlers/scores.ts
5
+ var scores_exports = {};
6
+ __export(scores_exports, {
7
+ getScorerHandler: () => getScorerHandler,
8
+ getScorersHandler: () => getScorersHandler,
9
+ getScoresByEntityIdHandler: () => getScoresByEntityIdHandler,
10
+ getScoresByRunIdHandler: () => getScoresByRunIdHandler,
11
+ getScoresByScorerIdHandler: () => getScoresByScorerIdHandler,
12
+ saveScoreHandler: () => saveScoreHandler
13
+ });
14
+ async function getScorersFromSystem({
15
+ mastra,
16
+ runtimeContext
17
+ }) {
18
+ const agents = mastra.getAgents();
19
+ const workflows = mastra.getWorkflows();
20
+ const scorersMap = /* @__PURE__ */ new Map();
21
+ for (const [agentId, agent] of Object.entries(agents)) {
22
+ const scorers = await agent.getScorers({
23
+ runtimeContext
24
+ }) || {};
25
+ if (Object.keys(scorers).length > 0) {
26
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
27
+ if (scorersMap.has(scorerId)) {
28
+ scorersMap.get(scorerId)?.agentIds.push(agentId);
29
+ } else {
30
+ scorersMap.set(scorerId, {
31
+ workflowIds: [],
32
+ ...scorer,
33
+ agentIds: [agentId]
34
+ });
35
+ }
36
+ }
37
+ }
38
+ }
39
+ for (const [workflowId, workflow] of Object.entries(workflows)) {
40
+ const scorers = await workflow.getScorers({
41
+ runtimeContext
42
+ }) || {};
43
+ if (Object.keys(scorers).length > 0) {
44
+ for (const [scorerId, scorer] of Object.entries(scorers)) {
45
+ if (scorersMap.has(scorerId)) {
46
+ scorersMap.get(scorerId)?.workflowIds.push(workflowId);
47
+ } else {
48
+ scorersMap.set(scorerId, {
49
+ agentIds: [],
50
+ ...scorer,
51
+ workflowIds: [workflowId]
52
+ });
53
+ }
54
+ }
55
+ }
56
+ }
57
+ return Object.fromEntries(scorersMap.entries());
58
+ }
59
+ async function getScorersHandler({ mastra, runtimeContext }) {
60
+ const scorers = await getScorersFromSystem({
61
+ mastra,
62
+ runtimeContext
63
+ });
64
+ return scorers;
65
+ }
66
+ async function getScorerHandler({
67
+ mastra,
68
+ scorerId,
69
+ runtimeContext
70
+ }) {
71
+ const scorers = await getScorersFromSystem({
72
+ mastra,
73
+ runtimeContext
74
+ });
75
+ const scorer = scorers[scorerId];
76
+ if (!scorer) {
77
+ return null;
78
+ }
79
+ return scorer;
80
+ }
81
+ async function getScoresByRunIdHandler({
82
+ mastra,
83
+ runId,
84
+ pagination
85
+ }) {
86
+ try {
87
+ const scores = await mastra.getStorage()?.getScoresByRunId?.({
88
+ runId,
89
+ pagination
90
+ }) || [];
91
+ return scores;
92
+ } catch (error) {
93
+ return handleError(error, "Error getting scores by run id");
94
+ }
95
+ }
96
+ async function getScoresByScorerIdHandler({
97
+ mastra,
98
+ scorerId,
99
+ pagination,
100
+ entityId,
101
+ entityType
102
+ }) {
103
+ try {
104
+ const scores = await mastra.getStorage()?.getScoresByScorerId?.({
105
+ scorerId,
106
+ pagination,
107
+ entityId,
108
+ entityType
109
+ }) || [];
110
+ return scores;
111
+ } catch (error) {
112
+ return handleError(error, "Error getting scores by scorer id");
113
+ }
114
+ }
115
+ async function getScoresByEntityIdHandler({
116
+ mastra,
117
+ entityId,
118
+ entityType,
119
+ pagination
120
+ }) {
121
+ try {
122
+ let entityIdToUse = entityId;
123
+ if (entityType === "AGENT") {
124
+ const agent = mastra.getAgentById(entityId);
125
+ entityIdToUse = agent.id;
126
+ } else if (entityType === "WORKFLOW") {
127
+ const workflow = mastra.getWorkflowById(entityId);
128
+ entityIdToUse = workflow.id;
129
+ }
130
+ const scores = await mastra.getStorage()?.getScoresByEntityId?.({
131
+ entityId: entityIdToUse,
132
+ entityType,
133
+ pagination
134
+ }) || [];
135
+ return scores;
136
+ } catch (error) {
137
+ return handleError(error, "Error getting scores by entity id");
138
+ }
139
+ }
140
+ async function saveScoreHandler({ mastra, score }) {
141
+ try {
142
+ const scores = await mastra.getStorage()?.saveScore?.(score) || [];
143
+ return scores;
144
+ } catch (error) {
145
+ return handleError(error, "Error saving score");
146
+ }
147
+ }
148
+
149
+ export { getScorerHandler, getScorersHandler, getScoresByEntityIdHandler, getScoresByRunIdHandler, getScoresByScorerIdHandler, saveScoreHandler, scores_exports };
@@ -1,5 +1,5 @@
1
- import { handleError } from './chunk-M5ABIP7D.js';
2
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { handleError } from './chunk-LF7P5PLR.js';
2
+ import { HTTPException } from './chunk-LCM566I4.js';
3
3
  import { __export } from './chunk-MLKGABMK.js';
4
4
 
5
5
  // src/server/handlers/vector.ts