@mastra/server 0.0.0-commonjs-20250414101718 → 0.0.0-custom-instrumentation-20250626084921

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 (87) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +544 -62
  3. package/dist/_tsup-dts-rollup.d.ts +544 -62
  4. package/dist/chunk-4DTDPTQC.cjs +332 -0
  5. package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
  6. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  7. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  8. package/dist/chunk-75ZPJI57.cjs +9 -0
  9. package/dist/{chunk-CWSDZEZG.cjs → chunk-B4MQFJ7G.cjs} +18 -12
  10. package/dist/{chunk-DVPP5S6I.js → chunk-BFOA2QQY.js} +14 -8
  11. package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  12. package/dist/{chunk-YANVFOYA.js → chunk-C7564HUT.js} +56 -34
  13. package/dist/{chunk-4C3EPMMF.cjs → chunk-CPPYMJX5.cjs} +31 -25
  14. package/dist/chunk-GHC4YV6R.js +504 -0
  15. package/dist/chunk-GKM45O24.cjs +278 -0
  16. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  17. package/dist/chunk-IMBY5XUG.cjs +86 -0
  18. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  19. package/dist/chunk-MLKGABMK.js +7 -0
  20. package/dist/chunk-MN6F4D5A.cjs +2004 -0
  21. package/dist/{chunk-OPP7H5TW.js → chunk-N2YBMSO2.js} +78 -63
  22. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  23. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  24. package/dist/chunk-OSZM4EAY.js +2001 -0
  25. package/dist/chunk-PMUATKV2.js +270 -0
  26. package/dist/chunk-QLG2PFHE.js +81 -0
  27. package/dist/{chunk-3RVHWGWO.js → chunk-R5VGYBV6.js} +36 -19
  28. package/dist/{chunk-2FJURXCL.cjs → chunk-RQ2Z56EC.cjs} +93 -55
  29. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  30. package/dist/chunk-SOBBILUG.js +421 -0
  31. package/dist/chunk-TO5U6HW3.cjs +435 -0
  32. package/dist/chunk-VPNDC2DI.cjs +148 -0
  33. package/dist/chunk-WJY57THV.cjs +118 -0
  34. package/dist/{chunk-YNSGUC2O.js → chunk-XR7VJOOP.js} +14 -8
  35. package/dist/{chunk-RBQASTUP.js → chunk-XUIJ7WRT.js} +63 -25
  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 +200 -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 +193 -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 +21 -13
  71. package/dist/server/handlers/workflows.d.cts +4 -2
  72. package/dist/server/handlers/workflows.d.ts +4 -2
  73. package/dist/server/handlers/workflows.js +1 -1
  74. package/dist/server/handlers.cjs +33 -23
  75. package/dist/server/handlers.d.cts +2 -0
  76. package/dist/server/handlers.d.ts +2 -0
  77. package/dist/server/handlers.js +11 -9
  78. package/package.json +13 -12
  79. package/dist/chunk-3EJZQ6TQ.js +0 -49
  80. package/dist/chunk-67WTHYAV.js +0 -156
  81. package/dist/chunk-A7DF4ETD.cjs +0 -100
  82. package/dist/chunk-B64YROKU.cjs +0 -317
  83. package/dist/chunk-JLDXUWK7.cjs +0 -126
  84. package/dist/chunk-QH6XWSXP.cjs +0 -5579
  85. package/dist/chunk-SKBVVI24.cjs +0 -54
  86. package/dist/chunk-VK6FX47H.js +0 -5576
  87. package/dist/chunk-Z46X3YCB.cjs +0 -164
@@ -1,50 +1,60 @@
1
1
  'use strict';
2
2
 
3
- var chunk4C3EPMMF_cjs = require('../chunk-4C3EPMMF.cjs');
4
- var chunkM56ECCHK_cjs = require('../chunk-M56ECCHK.cjs');
5
- var chunkA7DF4ETD_cjs = require('../chunk-A7DF4ETD.cjs');
6
- var chunkB64YROKU_cjs = require('../chunk-B64YROKU.cjs');
7
- var chunkZ46X3YCB_cjs = require('../chunk-Z46X3YCB.cjs');
8
- var chunkSKBVVI24_cjs = require('../chunk-SKBVVI24.cjs');
9
- var chunk2FJURXCL_cjs = require('../chunk-2FJURXCL.cjs');
10
- var chunkJLDXUWK7_cjs = require('../chunk-JLDXUWK7.cjs');
11
- var chunkCWSDZEZG_cjs = require('../chunk-CWSDZEZG.cjs');
3
+ var chunkVPNDC2DI_cjs = require('../chunk-VPNDC2DI.cjs');
4
+ var chunkB4MQFJ7G_cjs = require('../chunk-B4MQFJ7G.cjs');
5
+ var chunkCPPYMJX5_cjs = require('../chunk-CPPYMJX5.cjs');
6
+ var chunkBNEY4P4P_cjs = require('../chunk-BNEY4P4P.cjs');
7
+ var chunkWJY57THV_cjs = require('../chunk-WJY57THV.cjs');
8
+ var chunkTO5U6HW3_cjs = require('../chunk-TO5U6HW3.cjs');
9
+ var chunkSDPGVWQJ_cjs = require('../chunk-SDPGVWQJ.cjs');
10
+ var chunkGKM45O24_cjs = require('../chunk-GKM45O24.cjs');
11
+ var chunk4DTDPTQC_cjs = require('../chunk-4DTDPTQC.cjs');
12
+ var chunkIMBY5XUG_cjs = require('../chunk-IMBY5XUG.cjs');
13
+ var chunkRQ2Z56EC_cjs = require('../chunk-RQ2Z56EC.cjs');
12
14
 
13
15
 
14
16
 
17
+ Object.defineProperty(exports, "network", {
18
+ enumerable: true,
19
+ get: function () { return chunkVPNDC2DI_cjs.network_exports; }
20
+ });
21
+ Object.defineProperty(exports, "telemetry", {
22
+ enumerable: true,
23
+ get: function () { return chunkB4MQFJ7G_cjs.telemetry_exports; }
24
+ });
15
25
  Object.defineProperty(exports, "tools", {
16
26
  enumerable: true,
17
- get: function () { return chunk4C3EPMMF_cjs.tools_exports; }
27
+ get: function () { return chunkCPPYMJX5_cjs.tools_exports; }
18
28
  });
19
29
  Object.defineProperty(exports, "vector", {
20
30
  enumerable: true,
21
- get: function () { return chunkM56ECCHK_cjs.vector_exports; }
31
+ get: function () { return chunkBNEY4P4P_cjs.vector_exports; }
22
32
  });
23
33
  Object.defineProperty(exports, "voice", {
24
34
  enumerable: true,
25
- get: function () { return chunkA7DF4ETD_cjs.voice_exports; }
35
+ get: function () { return chunkWJY57THV_cjs.voice_exports; }
26
36
  });
27
37
  Object.defineProperty(exports, "workflows", {
28
38
  enumerable: true,
29
- get: function () { return chunkB64YROKU_cjs.workflows_exports; }
39
+ get: function () { return chunkTO5U6HW3_cjs.workflows_exports; }
30
40
  });
31
- Object.defineProperty(exports, "agents", {
41
+ Object.defineProperty(exports, "a2a", {
32
42
  enumerable: true,
33
- get: function () { return chunkZ46X3YCB_cjs.agents_exports; }
43
+ get: function () { return chunkSDPGVWQJ_cjs.a2a_exports; }
34
44
  });
35
- Object.defineProperty(exports, "logs", {
45
+ Object.defineProperty(exports, "agents", {
36
46
  enumerable: true,
37
- get: function () { return chunkSKBVVI24_cjs.logs_exports; }
47
+ get: function () { return chunkGKM45O24_cjs.agents_exports; }
38
48
  });
39
- Object.defineProperty(exports, "memory", {
49
+ Object.defineProperty(exports, "legacyWorkflows", {
40
50
  enumerable: true,
41
- get: function () { return chunk2FJURXCL_cjs.memory_exports; }
51
+ get: function () { return chunk4DTDPTQC_cjs.legacyWorkflows_exports; }
42
52
  });
43
- Object.defineProperty(exports, "network", {
53
+ Object.defineProperty(exports, "logs", {
44
54
  enumerable: true,
45
- get: function () { return chunkJLDXUWK7_cjs.network_exports; }
55
+ get: function () { return chunkIMBY5XUG_cjs.logs_exports; }
46
56
  });
47
- Object.defineProperty(exports, "telemetry", {
57
+ Object.defineProperty(exports, "memory", {
48
58
  enumerable: true,
49
- get: function () { return chunkCWSDZEZG_cjs.telemetry_exports; }
59
+ get: function () { return chunkRQ2Z56EC_cjs.memory_exports; }
50
60
  });
@@ -1,9 +1,11 @@
1
1
  export { agents } from '../_tsup-dts-rollup.cjs';
2
+ export { a2a } from '../_tsup-dts-rollup.cjs';
2
3
  export { logs } from '../_tsup-dts-rollup.cjs';
3
4
  export { memory } from '../_tsup-dts-rollup.cjs';
4
5
  export { network } from '../_tsup-dts-rollup.cjs';
5
6
  export { telemetry } from '../_tsup-dts-rollup.cjs';
6
7
  export { tools } from '../_tsup-dts-rollup.cjs';
8
+ export { legacyWorkflows } from '../_tsup-dts-rollup.cjs';
7
9
  export { workflows } from '../_tsup-dts-rollup.cjs';
8
10
  export { vector } from '../_tsup-dts-rollup.cjs';
9
11
  export { voice } from '../_tsup-dts-rollup.cjs';
@@ -1,9 +1,11 @@
1
1
  export { agents } from '../_tsup-dts-rollup.js';
2
+ export { a2a } from '../_tsup-dts-rollup.js';
2
3
  export { logs } from '../_tsup-dts-rollup.js';
3
4
  export { memory } from '../_tsup-dts-rollup.js';
4
5
  export { network } from '../_tsup-dts-rollup.js';
5
6
  export { telemetry } from '../_tsup-dts-rollup.js';
6
7
  export { tools } from '../_tsup-dts-rollup.js';
8
+ export { legacyWorkflows } from '../_tsup-dts-rollup.js';
7
9
  export { workflows } from '../_tsup-dts-rollup.js';
8
10
  export { vector } from '../_tsup-dts-rollup.js';
9
11
  export { voice } from '../_tsup-dts-rollup.js';
@@ -1,9 +1,11 @@
1
- export { tools_exports as tools } from '../chunk-YNSGUC2O.js';
2
- export { vector_exports as vector } from '../chunk-4JINXASC.js';
3
- export { voice_exports as voice } from '../chunk-3RVHWGWO.js';
4
- export { workflows_exports as workflows } from '../chunk-OPP7H5TW.js';
5
- export { agents_exports as agents } from '../chunk-67WTHYAV.js';
6
- export { logs_exports as logs } from '../chunk-3EJZQ6TQ.js';
7
- export { memory_exports as memory } from '../chunk-RBQASTUP.js';
8
- export { network_exports as network } from '../chunk-YANVFOYA.js';
9
- export { telemetry_exports as telemetry } from '../chunk-DVPP5S6I.js';
1
+ export { network_exports as network } from '../chunk-C7564HUT.js';
2
+ export { telemetry_exports as telemetry } from '../chunk-BFOA2QQY.js';
3
+ export { tools_exports as tools } from '../chunk-XR7VJOOP.js';
4
+ export { vector_exports as vector } from '../chunk-55DOQLP6.js';
5
+ export { voice_exports as voice } from '../chunk-R5VGYBV6.js';
6
+ export { workflows_exports as workflows } from '../chunk-SOBBILUG.js';
7
+ export { a2a_exports as a2a } from '../chunk-GHC4YV6R.js';
8
+ export { agents_exports as agents } from '../chunk-PMUATKV2.js';
9
+ export { legacyWorkflows_exports as legacyWorkflows } from '../chunk-N2YBMSO2.js';
10
+ export { logs_exports as logs } from '../chunk-QLG2PFHE.js';
11
+ export { memory_exports as memory } from '../chunk-XUIJ7WRT.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "0.0.0-commonjs-20250414101718",
3
+ "version": "0.0.0-custom-instrumentation-20250626084921",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -44,22 +44,23 @@
44
44
  "keywords": [],
45
45
  "author": "",
46
46
  "license": "Elastic-2.0",
47
- "dependencies": {},
48
47
  "peerDependencies": {
49
- "@mastra/core": "0.0.0-commonjs-20250414101718"
48
+ "zod": "^3.0.0",
49
+ "@mastra/core": "0.0.0-custom-instrumentation-20250626084921"
50
50
  },
51
51
  "devDependencies": {
52
- "@ai-sdk/openai": "^1.3.2",
53
- "@microsoft/api-extractor": "^7.52.1",
54
- "@types/node": "^20.17.27",
55
- "eslint": "^9.23.0",
52
+ "@ai-sdk/openai": "^1.3.22",
53
+ "@microsoft/api-extractor": "^7.52.8",
54
+ "@types/node": "^20.19.0",
55
+ "eslint": "^9.29.0",
56
56
  "superjson": "^2.2.2",
57
- "tsup": "^8.4.0",
58
- "typescript": "^5.8.2",
57
+ "tsup": "^8.5.0",
58
+ "typescript": "^5.8.3",
59
59
  "vitest": "^2.1.9",
60
- "zod-to-json-schema": "^3.24.3",
61
- "@internal/lint": "0.0.0-commonjs-20250414101718",
62
- "@mastra/core": "0.0.0-commonjs-20250414101718"
60
+ "zod": "^3.25.67",
61
+ "zod-to-json-schema": "^3.24.5",
62
+ "@internal/lint": "0.0.0-custom-instrumentation-20250626084921",
63
+ "@mastra/core": "0.0.0-custom-instrumentation-20250626084921"
63
64
  },
64
65
  "scripts": {
65
66
  "build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",
@@ -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 };
@@ -1,156 +0,0 @@
1
- import { stringify, esm_default } from './chunk-VK6FX47H.js';
2
- import { validateBody } from './chunk-L7XE5QTW.js';
3
- import { handleError } from './chunk-3AHQ5RGN.js';
4
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
5
-
6
- // src/server/handlers/agents.ts
7
- var agents_exports = {};
8
- __export(agents_exports, {
9
- generateHandler: () => generateHandler,
10
- getAgentByIdHandler: () => getAgentByIdHandler,
11
- getAgentsHandler: () => getAgentsHandler,
12
- getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
13
- getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
14
- streamGenerateHandler: () => streamGenerateHandler
15
- });
16
- async function getAgentsHandler({ mastra }) {
17
- try {
18
- const agents = mastra.getAgents();
19
- const serializedAgents = Object.entries(agents).reduce((acc, [_id, _agent]) => {
20
- const agent = _agent;
21
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc2, [key, tool]) => {
22
- const _tool = tool;
23
- acc2[key] = {
24
- ..._tool,
25
- inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
26
- outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
27
- };
28
- return acc2;
29
- }, {});
30
- acc[_id] = {
31
- name: agent.name,
32
- instructions: agent.instructions,
33
- tools: serializedAgentTools,
34
- provider: agent.llm?.getProvider(),
35
- modelId: agent.llm?.getModelId()
36
- };
37
- return acc;
38
- }, {});
39
- return serializedAgents;
40
- } catch (error) {
41
- return handleError(error, "Error getting agents");
42
- }
43
- }
44
- async function getAgentByIdHandler({ mastra, agentId }) {
45
- try {
46
- const agent = mastra.getAgent(agentId);
47
- if (!agent) {
48
- throw new HTTPException(404, { message: "Agent not found" });
49
- }
50
- const serializedAgentTools = Object.entries(agent?.tools || {}).reduce((acc, [key, tool]) => {
51
- const _tool = tool;
52
- acc[key] = {
53
- ..._tool,
54
- inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
55
- outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
56
- };
57
- return acc;
58
- }, {});
59
- return {
60
- name: agent.name,
61
- instructions: agent.instructions,
62
- tools: serializedAgentTools,
63
- provider: agent.llm?.getProvider(),
64
- modelId: agent.llm?.getModelId()
65
- };
66
- } catch (error) {
67
- return handleError(error, "Error getting agent");
68
- }
69
- }
70
- async function getEvalsByAgentIdHandler({ mastra, agentId }) {
71
- try {
72
- const agent = mastra.getAgent(agentId);
73
- const evals = await mastra.getStorage()?.__getEvalsByAgentName?.(agent.name, "test") || [];
74
- return {
75
- id: agentId,
76
- name: agent.name,
77
- instructions: agent.instructions,
78
- evals
79
- };
80
- } catch (error) {
81
- return handleError(error, "Error getting test evals");
82
- }
83
- }
84
- async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
85
- try {
86
- const agent = mastra.getAgent(agentId);
87
- const evals = await mastra.getStorage()?.__getEvalsByAgentName?.(agent.name, "live") || [];
88
- return {
89
- id: agentId,
90
- name: agent.name,
91
- instructions: agent.instructions,
92
- evals
93
- };
94
- } catch (error) {
95
- return handleError(error, "Error getting live evals");
96
- }
97
- }
98
- async function generateHandler({
99
- mastra,
100
- container,
101
- agentId,
102
- body
103
- }) {
104
- try {
105
- const agent = mastra.getAgent(agentId);
106
- if (!agent) {
107
- throw new HTTPException(404, { message: "Agent not found" });
108
- }
109
- const { messages, resourceId, resourceid, ...rest } = body;
110
- const finalResourceId = resourceId ?? resourceid;
111
- validateBody({ messages });
112
- const result = await agent.generate(messages, {
113
- ...rest,
114
- // @ts-expect-error TODO fix types
115
- resourceId: finalResourceId,
116
- container
117
- });
118
- return result;
119
- } catch (error) {
120
- return handleError(error, "Error generating from agent");
121
- }
122
- }
123
- async function streamGenerateHandler({
124
- mastra,
125
- container,
126
- agentId,
127
- body
128
- }) {
129
- try {
130
- const agent = mastra.getAgent(agentId);
131
- if (!agent) {
132
- throw new HTTPException(404, { message: "Agent not found" });
133
- }
134
- const { messages, resourceId, resourceid, ...rest } = body;
135
- const finalResourceId = resourceId ?? resourceid;
136
- validateBody({ messages });
137
- const streamResult = await agent.stream(messages, {
138
- ...rest,
139
- // @ts-expect-error TODO fix types
140
- resourceId: finalResourceId,
141
- container
142
- });
143
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
144
- sendUsage: true,
145
- sendReasoning: true,
146
- getErrorMessage: (error) => {
147
- return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
148
- }
149
- });
150
- return streamResponse;
151
- } catch (error) {
152
- throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
153
- }
154
- }
155
-
156
- export { agents_exports, generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler };
@@ -1,100 +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: void 0,
44
- speakerId: void 0,
45
- ...body
46
- });
47
- const agent = mastra.getAgent(agentId);
48
- if (!agent) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
50
- }
51
- if (!agent.voice) {
52
- throw new chunkFV45V6WC_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 chunkFV45V6WC_cjs.HTTPException(500, { message: "Failed to generate speech" });
57
- }
58
- const chunks = [];
59
- for await (const chunk of audioStream) {
60
- chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
61
- }
62
- const audioData = Buffer.concat(chunks);
63
- return { audioData };
64
- } catch (error) {
65
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating speech");
66
- }
67
- }
68
- async function transcribeSpeechHandler({
69
- mastra,
70
- agentId,
71
- body
72
- }) {
73
- try {
74
- if (!agentId) {
75
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
76
- }
77
- if (!body?.audioData) {
78
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Audio data is required" });
79
- }
80
- const agent = mastra.getAgent(agentId);
81
- if (!agent) {
82
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
83
- }
84
- if (!agent.voice) {
85
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent does not have voice capabilities" });
86
- }
87
- const audioStream = new stream.Readable();
88
- audioStream.push(body.audioData);
89
- audioStream.push(null);
90
- const text = await agent.voice.listen(audioStream, body.options);
91
- return { text };
92
- } catch (error) {
93
- return chunkZLBRQFDD_cjs.handleError(error, "Error transcribing speech");
94
- }
95
- }
96
-
97
- exports.generateSpeechHandler = generateSpeechHandler;
98
- exports.getSpeakersHandler = getSpeakersHandler;
99
- exports.transcribeSpeechHandler = transcribeSpeechHandler;
100
- exports.voice_exports = voice_exports;