@mastra/server 0.0.0-separate-trace-data-from-component-20250501042644 → 0.0.0-support-d1-client-20250701191943
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 +517 -103
- package/dist/_tsup-dts-rollup.d.ts +517 -103
- package/dist/{chunk-2FJURXCL.cjs → chunk-3DKDT264.cjs} +93 -55
- package/dist/{chunk-Y3SV5XK4.js → chunk-4QBIUKVY.js} +105 -16
- package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
- package/dist/chunk-7524QH7G.cjs +483 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-M3YJLWTU.js → chunk-7GQJAMTA.js} +68 -57
- package/dist/chunk-BOXE6WSV.js +81 -0
- package/dist/{chunk-WTHDCRMY.js → chunk-BP24Z4WG.js} +12 -6
- package/dist/chunk-BWHGBV3K.cjs +278 -0
- package/dist/chunk-CNVDCLSY.cjs +86 -0
- package/dist/{chunk-5JNVY6DU.js → chunk-DFJUGWNU.js} +7 -5
- package/dist/{chunk-5YGDYMRB.cjs → chunk-DPRB3R7Y.cjs} +14 -13
- package/dist/{chunk-D3G23FP3.cjs → chunk-FGGMQCPP.cjs} +24 -22
- package/dist/{chunk-4JINXASC.js → chunk-FVMGZKFD.js} +5 -4
- package/dist/{chunk-Q6SHQECN.js → chunk-G37NVEDX.js} +34 -10
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
- package/dist/chunk-L3N7ST2Z.cjs +118 -0
- package/dist/chunk-LI436ITD.cjs +2042 -0
- package/dist/{chunk-RBQASTUP.js → chunk-LTJNMM2Y.js} +63 -25
- package/dist/chunk-MEGCYGBU.js +2039 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/{chunk-ZLBRQFDD.cjs → chunk-MTR2B27E.cjs} +3 -2
- package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
- package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
- package/dist/{chunk-3AHQ5RGN.js → chunk-QDOJJCS4.js} +3 -2
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/chunk-TGZIR6AK.cjs +332 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-TVBPFPTN.cjs} +20 -19
- package/dist/{chunk-7IWQE76Z.cjs → chunk-ULFULEW4.cjs} +16 -10
- package/dist/{chunk-QJ3AHN64.js → chunk-VMXLEF54.js} +4 -3
- package/dist/chunk-Z5TH5F35.js +468 -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/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 +25 -13
- package/dist/server/handlers/workflows.d.cts +5 -2
- package/dist/server/handlers/workflows.d.ts +5 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +32 -27
- 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-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-AELYAUEE.cjs +0 -316
- package/dist/chunk-EVCC233P.cjs +0 -321
- package/dist/chunk-JPB6RPGB.js +0 -304
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-SKBVVI24.cjs +0 -54
- 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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
4
|
+
var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.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
|
+
chunk57CJTIPW_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 chunkMTR2B27E_cjs.handleError(error, "Error getting logs");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function getLogsByRunIdHandler({
|
|
42
|
+
mastra,
|
|
43
|
+
runId,
|
|
44
|
+
transportId,
|
|
45
|
+
params
|
|
46
|
+
}) {
|
|
47
|
+
try {
|
|
48
|
+
chunk57CJTIPW_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 chunkMTR2B27E_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 chunkMTR2B27E_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,7 +1,8 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
2
|
-
import { validateBody } from './chunk-
|
|
3
|
-
import { handleError } from './chunk-
|
|
4
|
-
import {
|
|
1
|
+
import { stringify, esm_default } from './chunk-MEGCYGBU.js';
|
|
2
|
+
import { validateBody } from './chunk-H5PTF3Y4.js';
|
|
3
|
+
import { handleError } from './chunk-QDOJJCS4.js';
|
|
4
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
5
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
5
6
|
import { isVercelTool } from '@mastra/core/tools';
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/tools.ts
|
|
@@ -98,7 +99,8 @@ async function executeAgentToolHandler({
|
|
|
98
99
|
if (!agent) {
|
|
99
100
|
throw new HTTPException(404, { message: "Tool not found" });
|
|
100
101
|
}
|
|
101
|
-
const
|
|
102
|
+
const agentTools = await agent.getTools({ runtimeContext });
|
|
103
|
+
const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
|
|
102
104
|
if (!tool) {
|
|
103
105
|
throw new HTTPException(404, { message: "Tool not found" });
|
|
104
106
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
4
|
+
var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
|
|
5
|
+
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
6
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
7
|
|
|
7
8
|
// src/server/handlers/network.ts
|
|
8
9
|
var network_exports = {};
|
|
9
|
-
|
|
10
|
+
chunk75ZPJI57_cjs.__export(network_exports, {
|
|
10
11
|
generateHandler: () => generateHandler,
|
|
11
12
|
getNetworkByIdHandler: () => getNetworkByIdHandler,
|
|
12
13
|
getNetworksHandler: () => getNetworksHandler,
|
|
@@ -46,7 +47,7 @@ async function getNetworksHandler({
|
|
|
46
47
|
);
|
|
47
48
|
return serializedNetworks;
|
|
48
49
|
} catch (error) {
|
|
49
|
-
return
|
|
50
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error getting networks");
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
async function getNetworkByIdHandler({
|
|
@@ -61,7 +62,7 @@ async function getNetworkByIdHandler({
|
|
|
61
62
|
return network2.formatAgentId(routingAgent2.name) === networkId;
|
|
62
63
|
});
|
|
63
64
|
if (!network) {
|
|
64
|
-
throw new
|
|
65
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
65
66
|
}
|
|
66
67
|
const routingAgent = network.getRoutingAgent();
|
|
67
68
|
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
@@ -87,7 +88,7 @@ async function getNetworkByIdHandler({
|
|
|
87
88
|
};
|
|
88
89
|
return serializedNetwork;
|
|
89
90
|
} catch (error) {
|
|
90
|
-
return
|
|
91
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error getting network by ID");
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
async function generateHandler({
|
|
@@ -99,14 +100,14 @@ async function generateHandler({
|
|
|
99
100
|
try {
|
|
100
101
|
const network = mastra.getNetwork(networkId);
|
|
101
102
|
if (!network) {
|
|
102
|
-
throw new
|
|
103
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
103
104
|
}
|
|
104
|
-
|
|
105
|
+
chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
|
|
105
106
|
const { messages, ...rest } = body;
|
|
106
107
|
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
107
108
|
return result;
|
|
108
109
|
} catch (error) {
|
|
109
|
-
return
|
|
110
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error generating from network");
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
async function streamGenerateHandler({
|
|
@@ -118,9 +119,9 @@ async function streamGenerateHandler({
|
|
|
118
119
|
try {
|
|
119
120
|
const network = mastra.getNetwork(networkId);
|
|
120
121
|
if (!network) {
|
|
121
|
-
throw new
|
|
122
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Network not found" });
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
+
chunk57CJTIPW_cjs.validateBody({ messages: body.messages });
|
|
124
125
|
const { messages, output, ...rest } = body;
|
|
125
126
|
const streamResult = await network.stream(messages, {
|
|
126
127
|
output,
|
|
@@ -136,7 +137,7 @@ async function streamGenerateHandler({
|
|
|
136
137
|
});
|
|
137
138
|
return streamResponse;
|
|
138
139
|
} catch (error) {
|
|
139
|
-
return
|
|
140
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error streaming from network");
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
|
|
4
|
+
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
5
|
+
var chunkMTR2B27E_cjs = require('./chunk-MTR2B27E.cjs');
|
|
6
|
+
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
7
|
+
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
8
|
var tools = require('@mastra/core/tools');
|
|
8
9
|
|
|
9
10
|
// src/server/handlers/tools.ts
|
|
10
11
|
var tools_exports = {};
|
|
11
|
-
|
|
12
|
+
chunk75ZPJI57_cjs.__export(tools_exports, {
|
|
12
13
|
executeAgentToolHandler: () => executeAgentToolHandler,
|
|
13
14
|
executeToolHandler: () => executeToolHandler,
|
|
14
15
|
getToolByIdHandler: () => getToolByIdHandler,
|
|
@@ -24,8 +25,8 @@ async function getToolsHandler({ tools }) {
|
|
|
24
25
|
const tool = _tool;
|
|
25
26
|
acc[id] = {
|
|
26
27
|
...tool,
|
|
27
|
-
inputSchema: tool.inputSchema ?
|
|
28
|
-
outputSchema: tool.outputSchema ?
|
|
28
|
+
inputSchema: tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.inputSchema)) : void 0,
|
|
29
|
+
outputSchema: tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.outputSchema)) : void 0
|
|
29
30
|
};
|
|
30
31
|
return acc;
|
|
31
32
|
},
|
|
@@ -33,23 +34,23 @@ async function getToolsHandler({ tools }) {
|
|
|
33
34
|
);
|
|
34
35
|
return serializedTools;
|
|
35
36
|
} catch (error) {
|
|
36
|
-
return
|
|
37
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error getting tools");
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
async function getToolByIdHandler({ tools, toolId }) {
|
|
40
41
|
try {
|
|
41
42
|
const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
|
|
42
43
|
if (!tool) {
|
|
43
|
-
throw new
|
|
44
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
|
|
44
45
|
}
|
|
45
46
|
const serializedTool = {
|
|
46
47
|
...tool,
|
|
47
|
-
inputSchema: tool.inputSchema ?
|
|
48
|
-
outputSchema: tool.outputSchema ?
|
|
48
|
+
inputSchema: tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.inputSchema)) : void 0,
|
|
49
|
+
outputSchema: tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.outputSchema)) : void 0
|
|
49
50
|
};
|
|
50
51
|
return serializedTool;
|
|
51
52
|
} catch (error) {
|
|
52
|
-
return
|
|
53
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error getting tool");
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
function executeToolHandler(tools$1) {
|
|
@@ -62,16 +63,16 @@ function executeToolHandler(tools$1) {
|
|
|
62
63
|
}) => {
|
|
63
64
|
try {
|
|
64
65
|
if (!toolId) {
|
|
65
|
-
throw new
|
|
66
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool ID is required" });
|
|
66
67
|
}
|
|
67
68
|
const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
|
|
68
69
|
if (!tool) {
|
|
69
|
-
throw new
|
|
70
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
|
|
70
71
|
}
|
|
71
72
|
if (!tool?.execute) {
|
|
72
|
-
throw new
|
|
73
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
chunk57CJTIPW_cjs.validateBody({ data });
|
|
75
76
|
if (tools.isVercelTool(tool)) {
|
|
76
77
|
const result2 = await tool.execute(data);
|
|
77
78
|
return result2;
|
|
@@ -84,7 +85,7 @@ function executeToolHandler(tools$1) {
|
|
|
84
85
|
});
|
|
85
86
|
return result;
|
|
86
87
|
} catch (error) {
|
|
87
|
-
return
|
|
88
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error executing tool");
|
|
88
89
|
}
|
|
89
90
|
};
|
|
90
91
|
}
|
|
@@ -98,14 +99,15 @@ async function executeAgentToolHandler({
|
|
|
98
99
|
try {
|
|
99
100
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
100
101
|
if (!agent) {
|
|
101
|
-
throw new
|
|
102
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
|
|
102
103
|
}
|
|
103
|
-
const
|
|
104
|
+
const agentTools = await agent.getTools({ runtimeContext });
|
|
105
|
+
const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
|
|
104
106
|
if (!tool) {
|
|
105
|
-
throw new
|
|
107
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
|
|
106
108
|
}
|
|
107
109
|
if (!tool?.execute) {
|
|
108
|
-
throw new
|
|
110
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
|
|
109
111
|
}
|
|
110
112
|
const result = await tool.execute({
|
|
111
113
|
context: data,
|
|
@@ -115,7 +117,7 @@ async function executeAgentToolHandler({
|
|
|
115
117
|
});
|
|
116
118
|
return result;
|
|
117
119
|
} catch (error) {
|
|
118
|
-
return
|
|
120
|
+
return chunkMTR2B27E_cjs.handleError(error, "Error executing tool");
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { handleError } from './chunk-
|
|
2
|
-
import {
|
|
1
|
+
import { handleError } from './chunk-QDOJJCS4.js';
|
|
2
|
+
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
3
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
3
4
|
|
|
4
5
|
// src/server/handlers/vector.ts
|
|
5
6
|
var vector_exports = {};
|
|
@@ -90,7 +91,7 @@ async function describeIndex({
|
|
|
90
91
|
throw new HTTPException(400, { message: "Index name is required" });
|
|
91
92
|
}
|
|
92
93
|
const vector = getVector(mastra, vectorName);
|
|
93
|
-
const stats = await vector.describeIndex(indexName);
|
|
94
|
+
const stats = await vector.describeIndex({ indexName });
|
|
94
95
|
return {
|
|
95
96
|
dimension: stats.dimension,
|
|
96
97
|
count: stats.count,
|
|
@@ -110,7 +111,7 @@ async function deleteIndex({
|
|
|
110
111
|
throw new HTTPException(400, { message: "Index name is required" });
|
|
111
112
|
}
|
|
112
113
|
const vector = getVector(mastra, vectorName);
|
|
113
|
-
await vector.deleteIndex(indexName);
|
|
114
|
+
await vector.deleteIndex({ indexName });
|
|
114
115
|
return { success: true };
|
|
115
116
|
} catch (error) {
|
|
116
117
|
return handleError(error, "Error deleting index");
|
|
@@ -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-QDOJJCS4.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
|
});
|
|
@@ -19,10 +21,11 @@ async function getSpeakersHandler({ mastra, agentId }) {
|
|
|
19
21
|
if (!agent) {
|
|
20
22
|
throw new HTTPException(404, { message: "Agent not found" });
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
const voice = await agent.getVoice();
|
|
25
|
+
if (!voice) {
|
|
23
26
|
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
24
27
|
}
|
|
25
|
-
const speakers = await
|
|
28
|
+
const speakers = await voice.getSpeakers();
|
|
26
29
|
return speakers;
|
|
27
30
|
} catch (error) {
|
|
28
31
|
return handleError(error, "Error getting speakers");
|
|
@@ -44,10 +47,11 @@ async function generateSpeechHandler({
|
|
|
44
47
|
if (!agent) {
|
|
45
48
|
throw new HTTPException(404, { message: "Agent not found" });
|
|
46
49
|
}
|
|
47
|
-
|
|
50
|
+
const voice = await agent.getVoice();
|
|
51
|
+
if (!voice) {
|
|
48
52
|
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
49
53
|
}
|
|
50
|
-
const audioStream = await
|
|
54
|
+
const audioStream = await voice.speak(body.text, { speaker: body.speakerId });
|
|
51
55
|
if (!audioStream) {
|
|
52
56
|
throw new HTTPException(500, { message: "Failed to generate speech" });
|
|
53
57
|
}
|
|
@@ -72,17 +76,37 @@ async function transcribeSpeechHandler({
|
|
|
72
76
|
if (!agent) {
|
|
73
77
|
throw new HTTPException(404, { message: "Agent not found" });
|
|
74
78
|
}
|
|
75
|
-
|
|
79
|
+
const voice = await agent.getVoice();
|
|
80
|
+
if (!voice) {
|
|
76
81
|
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
77
82
|
}
|
|
78
83
|
const audioStream = new Readable();
|
|
79
84
|
audioStream.push(body.audioData);
|
|
80
85
|
audioStream.push(null);
|
|
81
|
-
const text = await
|
|
86
|
+
const text = await voice.listen(audioStream, body.options);
|
|
82
87
|
return { text };
|
|
83
88
|
} catch (error) {
|
|
84
89
|
return handleError(error, "Error transcribing speech");
|
|
85
90
|
}
|
|
86
91
|
}
|
|
92
|
+
async function getListenerHandler({ mastra, agentId }) {
|
|
93
|
+
try {
|
|
94
|
+
if (!agentId) {
|
|
95
|
+
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
96
|
+
}
|
|
97
|
+
const agent = mastra.getAgent(agentId);
|
|
98
|
+
if (!agent) {
|
|
99
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
100
|
+
}
|
|
101
|
+
const voice = await agent.getVoice();
|
|
102
|
+
if (!voice) {
|
|
103
|
+
throw new HTTPException(400, { message: "Agent does not have voice capabilities" });
|
|
104
|
+
}
|
|
105
|
+
const listeners = await voice.getListener();
|
|
106
|
+
return listeners;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return handleError(error, "Error getting listeners");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
87
111
|
|
|
88
|
-
export { generateSpeechHandler, getSpeakersHandler, transcribeSpeechHandler, voice_exports };
|
|
112
|
+
export { generateSpeechHandler, getListenerHandler, getSpeakersHandler, transcribeSpeechHandler, voice_exports };
|