@mastra/server 0.0.0-message-ordering-20250415215612 → 0.0.0-message-list-update-20250715150321
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/LICENSE.md +11 -42
- package/README.md +48 -135
- package/dist/_tsup-dts-rollup.d.cts +604 -70
- package/dist/_tsup-dts-rollup.d.ts +604 -70
- package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
- package/dist/chunk-2SLFAFTR.cjs +148 -0
- package/dist/chunk-3CNDE7QY.cjs +308 -0
- package/dist/chunk-4D66QEKC.js +81 -0
- package/dist/{chunk-OPP7H5TW.js → chunk-5PQQ42EZ.js} +83 -68
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
- package/dist/chunk-B2PAS2IB.cjs +514 -0
- package/dist/chunk-BK4XT6EG.js +270 -0
- package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-YANVFOYA.js → chunk-CRCR3ZUK.js} +56 -34
- package/dist/{chunk-PDC4ZBQW.cjs → chunk-FRVBFMO2.cjs} +28 -26
- package/dist/{chunk-CWSDZEZG.cjs → chunk-G7KH752Y.cjs} +18 -12
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/chunk-H7DMHBKY.js +498 -0
- package/dist/chunk-JMLYCXMK.cjs +332 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-KHZKYUNR.js} +36 -19
- package/dist/{chunk-RBQASTUP.js → chunk-KOHWJYJT.js} +120 -27
- package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/chunk-LI436ITD.cjs +2042 -0
- package/dist/{chunk-UV4WTEH4.js → chunk-LRCAAFUA.js} +11 -9
- package/dist/chunk-LZ3VJXSO.cjs +278 -0
- package/dist/chunk-MEGCYGBU.js +2039 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/chunk-QGX47B5D.cjs +86 -0
- package/dist/{chunk-DVPP5S6I.js → chunk-RG473F6Y.js} +14 -8
- package/dist/chunk-RHSWAXKB.cjs +118 -0
- package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
- package/dist/chunk-SDPGVWQJ.cjs +512 -0
- package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
- package/dist/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 +17 -9
- package/dist/server/handlers/memory.d.cts +2 -0
- package/dist/server/handlers/memory.d.ts +2 -0
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vNextNetwork.cjs +218 -0
- package/dist/server/handlers/vNextNetwork.d.cts +6 -0
- package/dist/server/handlers/vNextNetwork.d.ts +6 -0
- package/dist/server/handlers/vNextNetwork.js +211 -0
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -4
- package/dist/server/handlers/voice.d.cts +1 -0
- package/dist/server/handlers/voice.d.ts +1 -0
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +29 -13
- package/dist/server/handlers/workflows.d.cts +6 -2
- package/dist/server/handlers/workflows.d.ts +6 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +33 -23
- package/dist/server/handlers.d.cts +2 -0
- package/dist/server/handlers.d.ts +2 -0
- package/dist/server/handlers.js +11 -9
- package/package.json +15 -14
- package/dist/chunk-2FJURXCL.cjs +0 -213
- package/dist/chunk-3AHQ5RGN.js +0 -11
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-67WTHYAV.js +0 -156
- package/dist/chunk-A7DF4ETD.cjs +0 -100
- package/dist/chunk-B64YROKU.cjs +0 -317
- package/dist/chunk-JLDXUWK7.cjs +0 -126
- package/dist/chunk-QH6XWSXP.cjs +0 -5579
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/chunk-VK6FX47H.js +0 -5576
- package/dist/chunk-Z46X3YCB.cjs +0 -164
- package/dist/chunk-ZLBRQFDD.cjs +0 -13
|
@@ -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-
|
|
2
|
-
import {
|
|
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,24 +16,26 @@ async function getTelemetryHandler({ mastra, body }) {
|
|
|
15
16
|
throw new HTTPException(400, { message: "Telemetry is not initialized" });
|
|
16
17
|
}
|
|
17
18
|
if (!storage) {
|
|
18
|
-
|
|
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(":");
|
|
27
28
|
return [key, value];
|
|
28
29
|
})
|
|
29
30
|
) : void 0;
|
|
30
|
-
const traces = await storage.
|
|
31
|
+
const traces = await storage.getTraces({
|
|
31
32
|
name,
|
|
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
|
-
|
|
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;
|
|
@@ -105,7 +111,7 @@ async function storeTelemetryHandler({ mastra, body }) {
|
|
|
105
111
|
}
|
|
106
112
|
return acc;
|
|
107
113
|
}, []);
|
|
108
|
-
return storage.
|
|
114
|
+
return storage.batchTraceInsert({
|
|
109
115
|
records: allSpans
|
|
110
116
|
}).then(() => {
|
|
111
117
|
return {
|
|
@@ -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;
|