@mastra/server 0.10.12-alpha.1 → 0.10.13
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/package.json +3 -3
- package/dist/_tsup-dts-rollup.d.cts +0 -1078
- package/dist/_tsup-dts-rollup.d.ts +0 -1078
- package/dist/chunk-2KZFMI6P.cjs +0 -37
- package/dist/chunk-2SLFAFTR.cjs +0 -148
- package/dist/chunk-4D66QEKC.js +0 -81
- package/dist/chunk-5PQQ42EZ.js +0 -320
- package/dist/chunk-75ZPJI57.cjs +0 -9
- package/dist/chunk-7TP2LX5L.cjs +0 -129
- package/dist/chunk-B2PAS2IB.cjs +0 -514
- package/dist/chunk-BK4XT6EG.js +0 -270
- package/dist/chunk-CCGRCYWJ.cjs +0 -18
- package/dist/chunk-CRCR3ZUK.js +0 -142
- package/dist/chunk-DN7K6FJK.cjs +0 -251
- package/dist/chunk-FRVBFMO2.cjs +0 -128
- package/dist/chunk-G7KH752Y.cjs +0 -145
- package/dist/chunk-GHC4YV6R.js +0 -504
- package/dist/chunk-H7DMHBKY.js +0 -498
- package/dist/chunk-JMLYCXMK.cjs +0 -332
- package/dist/chunk-KHZKYUNR.js +0 -112
- package/dist/chunk-LCM566I4.js +0 -35
- package/dist/chunk-LF7P5PLR.js +0 -14
- package/dist/chunk-LI436ITD.cjs +0 -2042
- package/dist/chunk-LRCAAFUA.js +0 -122
- package/dist/chunk-LZ3VJXSO.cjs +0 -278
- package/dist/chunk-MEGCYGBU.js +0 -2039
- package/dist/chunk-MKLYEKEF.js +0 -241
- package/dist/chunk-MLKGABMK.js +0 -7
- package/dist/chunk-PZQDCRPV.cjs +0 -16
- package/dist/chunk-QGX47B5D.cjs +0 -86
- package/dist/chunk-RG473F6Y.js +0 -141
- package/dist/chunk-RHSWAXKB.cjs +0 -118
- package/dist/chunk-RSEO4XPX.js +0 -16
- package/dist/chunk-SDPGVWQJ.cjs +0 -512
- package/dist/chunk-WNVFNNWN.js +0 -121
- package/dist/index.cjs +0 -2
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/server/handlers/a2a.cjs +0 -30
- package/dist/server/handlers/a2a.d.cts +0 -6
- package/dist/server/handlers/a2a.d.ts +0 -6
- package/dist/server/handlers/a2a.js +0 -1
- package/dist/server/handlers/agents.cjs +0 -30
- package/dist/server/handlers/agents.d.cts +0 -6
- package/dist/server/handlers/agents.d.ts +0 -6
- package/dist/server/handlers/agents.js +0 -1
- package/dist/server/handlers/error.cjs +0 -10
- package/dist/server/handlers/error.d.cts +0 -1
- package/dist/server/handlers/error.d.ts +0 -1
- package/dist/server/handlers/error.js +0 -1
- package/dist/server/handlers/legacyWorkflows.cjs +0 -46
- package/dist/server/handlers/legacyWorkflows.d.cts +0 -10
- package/dist/server/handlers/legacyWorkflows.d.ts +0 -10
- package/dist/server/handlers/legacyWorkflows.js +0 -1
- package/dist/server/handlers/logs.cjs +0 -18
- package/dist/server/handlers/logs.d.cts +0 -3
- package/dist/server/handlers/logs.d.ts +0 -3
- package/dist/server/handlers/logs.js +0 -1
- package/dist/server/handlers/memory.cjs +0 -38
- package/dist/server/handlers/memory.d.cts +0 -8
- package/dist/server/handlers/memory.d.ts +0 -8
- package/dist/server/handlers/memory.js +0 -1
- package/dist/server/handlers/network.cjs +0 -22
- package/dist/server/handlers/network.d.cts +0 -4
- package/dist/server/handlers/network.d.ts +0 -4
- package/dist/server/handlers/network.js +0 -1
- package/dist/server/handlers/telemetry.cjs +0 -14
- package/dist/server/handlers/telemetry.d.cts +0 -2
- package/dist/server/handlers/telemetry.d.ts +0 -2
- package/dist/server/handlers/telemetry.js +0 -1
- package/dist/server/handlers/tools.cjs +0 -22
- package/dist/server/handlers/tools.d.cts +0 -4
- package/dist/server/handlers/tools.d.ts +0 -4
- package/dist/server/handlers/tools.js +0 -1
- package/dist/server/handlers/utils.cjs +0 -10
- package/dist/server/handlers/utils.d.cts +0 -1
- package/dist/server/handlers/utils.d.ts +0 -1
- package/dist/server/handlers/utils.js +0 -1
- package/dist/server/handlers/vNextNetwork.cjs +0 -218
- package/dist/server/handlers/vNextNetwork.d.cts +0 -6
- package/dist/server/handlers/vNextNetwork.d.ts +0 -6
- package/dist/server/handlers/vNextNetwork.js +0 -211
- package/dist/server/handlers/vector.cjs +0 -30
- package/dist/server/handlers/vector.d.cts +0 -6
- package/dist/server/handlers/vector.d.ts +0 -6
- package/dist/server/handlers/vector.js +0 -1
- package/dist/server/handlers/voice.cjs +0 -22
- package/dist/server/handlers/voice.d.cts +0 -4
- package/dist/server/handlers/voice.d.ts +0 -4
- package/dist/server/handlers/voice.js +0 -1
- package/dist/server/handlers/workflows.cjs +0 -62
- package/dist/server/handlers/workflows.d.cts +0 -14
- package/dist/server/handlers/workflows.d.ts +0 -14
- package/dist/server/handlers/workflows.js +0 -1
- package/dist/server/handlers.cjs +0 -60
- package/dist/server/handlers.d.cts +0 -11
- package/dist/server/handlers.d.ts +0 -11
- package/dist/server/handlers.js +0 -11
package/dist/chunk-FRVBFMO2.cjs
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkLI436ITD_cjs = require('./chunk-LI436ITD.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
|
-
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
8
|
-
var tools = require('@mastra/core/tools');
|
|
9
|
-
|
|
10
|
-
// src/server/handlers/tools.ts
|
|
11
|
-
var tools_exports = {};
|
|
12
|
-
chunk75ZPJI57_cjs.__export(tools_exports, {
|
|
13
|
-
executeAgentToolHandler: () => executeAgentToolHandler,
|
|
14
|
-
executeToolHandler: () => executeToolHandler,
|
|
15
|
-
getToolByIdHandler: () => getToolByIdHandler,
|
|
16
|
-
getToolsHandler: () => getToolsHandler
|
|
17
|
-
});
|
|
18
|
-
async function getToolsHandler({ tools }) {
|
|
19
|
-
try {
|
|
20
|
-
if (!tools) {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
const serializedTools = Object.entries(tools).reduce(
|
|
24
|
-
(acc, [id, _tool]) => {
|
|
25
|
-
const tool = _tool;
|
|
26
|
-
acc[id] = {
|
|
27
|
-
...tool,
|
|
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
|
|
30
|
-
};
|
|
31
|
-
return acc;
|
|
32
|
-
},
|
|
33
|
-
{}
|
|
34
|
-
);
|
|
35
|
-
return serializedTools;
|
|
36
|
-
} catch (error) {
|
|
37
|
-
return chunkPZQDCRPV_cjs.handleError(error, "Error getting tools");
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async function getToolByIdHandler({ tools, toolId }) {
|
|
41
|
-
try {
|
|
42
|
-
const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
|
|
43
|
-
if (!tool) {
|
|
44
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
|
|
45
|
-
}
|
|
46
|
-
const serializedTool = {
|
|
47
|
-
...tool,
|
|
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
|
|
50
|
-
};
|
|
51
|
-
return serializedTool;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
return chunkPZQDCRPV_cjs.handleError(error, "Error getting tool");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function executeToolHandler(tools$1) {
|
|
57
|
-
return async ({
|
|
58
|
-
mastra,
|
|
59
|
-
runId,
|
|
60
|
-
toolId,
|
|
61
|
-
data,
|
|
62
|
-
runtimeContext
|
|
63
|
-
}) => {
|
|
64
|
-
try {
|
|
65
|
-
if (!toolId) {
|
|
66
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool ID is required" });
|
|
67
|
-
}
|
|
68
|
-
const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
|
|
69
|
-
if (!tool) {
|
|
70
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
|
|
71
|
-
}
|
|
72
|
-
if (!tool?.execute) {
|
|
73
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
|
|
74
|
-
}
|
|
75
|
-
chunkCCGRCYWJ_cjs.validateBody({ data });
|
|
76
|
-
if (tools.isVercelTool(tool)) {
|
|
77
|
-
const result2 = await tool.execute(data);
|
|
78
|
-
return result2;
|
|
79
|
-
}
|
|
80
|
-
const result = await tool.execute({
|
|
81
|
-
context: data,
|
|
82
|
-
mastra,
|
|
83
|
-
runId,
|
|
84
|
-
runtimeContext
|
|
85
|
-
});
|
|
86
|
-
return result;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
async function executeAgentToolHandler({
|
|
93
|
-
mastra,
|
|
94
|
-
agentId,
|
|
95
|
-
toolId,
|
|
96
|
-
data,
|
|
97
|
-
runtimeContext
|
|
98
|
-
}) {
|
|
99
|
-
try {
|
|
100
|
-
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
101
|
-
if (!agent) {
|
|
102
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
|
|
103
|
-
}
|
|
104
|
-
const agentTools = await agent.getTools({ runtimeContext });
|
|
105
|
-
const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
|
|
106
|
-
if (!tool) {
|
|
107
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
|
|
108
|
-
}
|
|
109
|
-
if (!tool?.execute) {
|
|
110
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
|
|
111
|
-
}
|
|
112
|
-
const result = await tool.execute({
|
|
113
|
-
context: data,
|
|
114
|
-
runtimeContext,
|
|
115
|
-
mastra,
|
|
116
|
-
runId: agentId
|
|
117
|
-
});
|
|
118
|
-
return result;
|
|
119
|
-
} catch (error) {
|
|
120
|
-
return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
exports.executeAgentToolHandler = executeAgentToolHandler;
|
|
125
|
-
exports.executeToolHandler = executeToolHandler;
|
|
126
|
-
exports.getToolByIdHandler = getToolByIdHandler;
|
|
127
|
-
exports.getToolsHandler = getToolsHandler;
|
|
128
|
-
exports.tools_exports = tools_exports;
|
package/dist/chunk-G7KH752Y.cjs
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
|
|
4
|
-
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
5
|
-
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
6
|
-
|
|
7
|
-
// src/server/handlers/telemetry.ts
|
|
8
|
-
var telemetry_exports = {};
|
|
9
|
-
chunk75ZPJI57_cjs.__export(telemetry_exports, {
|
|
10
|
-
getTelemetryHandler: () => getTelemetryHandler,
|
|
11
|
-
storeTelemetryHandler: () => storeTelemetryHandler
|
|
12
|
-
});
|
|
13
|
-
async function getTelemetryHandler({ mastra, body }) {
|
|
14
|
-
try {
|
|
15
|
-
const telemetry = mastra.getTelemetry();
|
|
16
|
-
const storage = mastra.getStorage();
|
|
17
|
-
if (!telemetry) {
|
|
18
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
|
|
19
|
-
}
|
|
20
|
-
if (!storage) {
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
if (!body) {
|
|
24
|
-
throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
|
|
25
|
-
}
|
|
26
|
-
const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
|
|
27
|
-
const attributes = attribute ? Object.fromEntries(
|
|
28
|
-
(Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
|
|
29
|
-
const [key, value] = attr.split(":");
|
|
30
|
-
return [key, value];
|
|
31
|
-
})
|
|
32
|
-
) : void 0;
|
|
33
|
-
const traces = await storage.getTraces({
|
|
34
|
-
name,
|
|
35
|
-
scope,
|
|
36
|
-
page: Number(page ?? 0),
|
|
37
|
-
perPage: Number(perPage ?? 100),
|
|
38
|
-
attributes,
|
|
39
|
-
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
40
|
-
toDate: toDate ? new Date(toDate) : void 0
|
|
41
|
-
});
|
|
42
|
-
return traces;
|
|
43
|
-
} catch (error2) {
|
|
44
|
-
return chunkPZQDCRPV_cjs.handleError(error2, "Error getting telemetry");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function storeTelemetryHandler({ mastra, body }) {
|
|
48
|
-
try {
|
|
49
|
-
const storage = mastra.getStorage();
|
|
50
|
-
const logger = mastra.getLogger();
|
|
51
|
-
if (!storage) {
|
|
52
|
-
return {
|
|
53
|
-
status: "error",
|
|
54
|
-
message: "Storage is not initialized"
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const now = /* @__PURE__ */ new Date();
|
|
58
|
-
const items = body?.resourceSpans?.[0]?.scopeSpans;
|
|
59
|
-
logger.debug("[Telemetry Handler] Received spans:", {
|
|
60
|
-
totalSpans: items?.reduce((acc, scope) => acc + scope.spans.length, 0) || 0,
|
|
61
|
-
timestamp: now.toISOString()
|
|
62
|
-
});
|
|
63
|
-
if (!items?.length) {
|
|
64
|
-
return {
|
|
65
|
-
status: "success",
|
|
66
|
-
message: "No spans to process",
|
|
67
|
-
traceCount: 0
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const allSpans = items.reduce((acc, scopedSpans) => {
|
|
71
|
-
const { scope, spans } = scopedSpans;
|
|
72
|
-
for (const span of spans) {
|
|
73
|
-
const {
|
|
74
|
-
spanId,
|
|
75
|
-
parentSpanId,
|
|
76
|
-
traceId,
|
|
77
|
-
name,
|
|
78
|
-
kind,
|
|
79
|
-
attributes,
|
|
80
|
-
status,
|
|
81
|
-
events,
|
|
82
|
-
links,
|
|
83
|
-
startTimeUnixNano,
|
|
84
|
-
endTimeUnixNano,
|
|
85
|
-
...rest
|
|
86
|
-
} = span;
|
|
87
|
-
const startTime = Number(BigInt(startTimeUnixNano) / 1000n);
|
|
88
|
-
const endTime = Number(BigInt(endTimeUnixNano) / 1000n);
|
|
89
|
-
acc.push({
|
|
90
|
-
id: spanId,
|
|
91
|
-
parentSpanId,
|
|
92
|
-
traceId,
|
|
93
|
-
name,
|
|
94
|
-
scope: scope.name,
|
|
95
|
-
kind,
|
|
96
|
-
status: JSON.stringify(status),
|
|
97
|
-
events: JSON.stringify(events),
|
|
98
|
-
links: JSON.stringify(links),
|
|
99
|
-
attributes: JSON.stringify(
|
|
100
|
-
attributes.reduce((acc2, attr) => {
|
|
101
|
-
const valueKey = Object.keys(attr.value)[0];
|
|
102
|
-
if (valueKey) {
|
|
103
|
-
acc2[attr.key] = attr.value[valueKey];
|
|
104
|
-
}
|
|
105
|
-
return acc2;
|
|
106
|
-
}, {})
|
|
107
|
-
),
|
|
108
|
-
startTime,
|
|
109
|
-
endTime,
|
|
110
|
-
other: JSON.stringify(rest),
|
|
111
|
-
createdAt: now
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return acc;
|
|
115
|
-
}, []);
|
|
116
|
-
return storage.batchTraceInsert({
|
|
117
|
-
records: allSpans
|
|
118
|
-
}).then(() => {
|
|
119
|
-
return {
|
|
120
|
-
status: "success",
|
|
121
|
-
message: "Traces received and processed successfully",
|
|
122
|
-
traceCount: body.resourceSpans?.length || 0
|
|
123
|
-
};
|
|
124
|
-
}).catch(() => {
|
|
125
|
-
return {
|
|
126
|
-
status: "error",
|
|
127
|
-
message: "Failed to process traces",
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
error: error.message
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
} catch (error2) {
|
|
133
|
-
console.error("Error processing traces:", error2);
|
|
134
|
-
return {
|
|
135
|
-
status: "error",
|
|
136
|
-
message: "Failed to process traces",
|
|
137
|
-
// @ts-ignore
|
|
138
|
-
error: error2.message
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
exports.getTelemetryHandler = getTelemetryHandler;
|
|
144
|
-
exports.storeTelemetryHandler = storeTelemetryHandler;
|
|
145
|
-
exports.telemetry_exports = telemetry_exports;
|