@mastra/server 0.0.0-mcp-server-update-parse-20250421171139 → 0.0.0-mcp-server-deploy-20250507160341
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/dist/_tsup-dts-rollup.d.cts +217 -42
- package/dist/_tsup-dts-rollup.d.ts +217 -42
- package/dist/{chunk-4B7OUZXW.js → chunk-3XTEV33Q.js} +25 -13
- package/dist/{chunk-4WJ5GHRG.cjs → chunk-4BIX6GMY.cjs} +56 -31
- package/dist/{chunk-A7DF4ETD.cjs → chunk-55HTWX4C.cjs} +2 -9
- package/dist/{chunk-XISBMH56.js → chunk-5JNVY6DU.js} +4 -4
- package/dist/{chunk-JLDXUWK7.cjs → chunk-5YGDYMRB.cjs} +52 -31
- package/dist/chunk-74DLDQTQ.cjs +36 -0
- package/dist/{chunk-7IWQE76Z.cjs → chunk-AMVOS7YB.cjs} +4 -2
- package/dist/{chunk-WTHDCRMY.js → chunk-BPL2CBLV.js} +4 -2
- package/dist/{chunk-RNU4JMLM.cjs → chunk-CHFORQ7J.cjs} +25 -13
- package/dist/{chunk-HABV7TZK.cjs → chunk-D3G23FP3.cjs} +4 -4
- package/dist/chunk-FOXHTOQZ.cjs +324 -0
- package/dist/chunk-HAA5T7JL.js +33 -0
- package/dist/chunk-IQTNZSFP.js +312 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-Q6SHQECN.js} +2 -9
- package/dist/{chunk-YANVFOYA.js → chunk-QJ3AHN64.js} +52 -31
- package/dist/{chunk-TFFNX7FI.js → chunk-Y3SV5XK4.js} +56 -31
- package/dist/index.cjs +12 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/mcp.cjs +14 -0
- package/dist/server/handlers/mcp.d.cts +2 -0
- package/dist/server/handlers/mcp.d.ts +2 -0
- package/dist/server/handlers/mcp.js +1 -0
- 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/vNextWorkflows.cjs +46 -0
- package/dist/server/handlers/vNextWorkflows.d.cts +10 -0
- package/dist/server/handlers/vNextWorkflows.d.ts +10 -0
- package/dist/server/handlers/vNextWorkflows.js +1 -0
- package/dist/server/handlers/voice.cjs +4 -4
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +11 -11
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +20 -15
- package/dist/server/handlers.d.cts +1 -0
- package/dist/server/handlers.d.ts +1 -0
- package/dist/server/handlers.js +7 -6
- package/package.json +5 -5
|
@@ -15,27 +15,35 @@ chunkFV45V6WC_cjs.__export(agents_exports, {
|
|
|
15
15
|
getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
|
|
16
16
|
streamGenerateHandler: () => streamGenerateHandler
|
|
17
17
|
});
|
|
18
|
-
async function getAgentsHandler({ mastra }) {
|
|
18
|
+
async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
19
19
|
try {
|
|
20
20
|
const agents = mastra.getAgents();
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const serializedAgentsMap = await Promise.all(
|
|
22
|
+
Object.entries(agents).map(async ([id, agent]) => {
|
|
23
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
24
|
+
const tools = await agent.getTools({ runtimeContext });
|
|
25
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
26
|
+
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
27
|
+
const _tool = tool;
|
|
28
|
+
acc[key] = {
|
|
29
|
+
..._tool,
|
|
30
|
+
inputSchema: _tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
31
|
+
outputSchema: _tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
32
|
+
};
|
|
33
|
+
return acc;
|
|
34
|
+
}, {});
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
name: agent.name,
|
|
38
|
+
instructions,
|
|
39
|
+
tools: serializedAgentTools,
|
|
40
|
+
provider: llm?.getProvider(),
|
|
41
|
+
modelId: llm?.getModelId()
|
|
29
42
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
instructions: agent.instructions,
|
|
35
|
-
tools: serializedAgentTools,
|
|
36
|
-
provider: agent.llm?.getProvider(),
|
|
37
|
-
modelId: agent.llm?.getModelId()
|
|
38
|
-
};
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
|
|
46
|
+
acc[id] = rest;
|
|
39
47
|
return acc;
|
|
40
48
|
}, {});
|
|
41
49
|
return serializedAgents;
|
|
@@ -43,13 +51,18 @@ async function getAgentsHandler({ mastra }) {
|
|
|
43
51
|
return chunkZLBRQFDD_cjs.handleError(error, "Error getting agents");
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
|
-
async function getAgentByIdHandler({
|
|
54
|
+
async function getAgentByIdHandler({
|
|
55
|
+
mastra,
|
|
56
|
+
runtimeContext,
|
|
57
|
+
agentId
|
|
58
|
+
}) {
|
|
47
59
|
try {
|
|
48
60
|
const agent = mastra.getAgent(agentId);
|
|
49
61
|
if (!agent) {
|
|
50
62
|
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Agent not found" });
|
|
51
63
|
}
|
|
52
|
-
const
|
|
64
|
+
const tools = await agent.getTools({ runtimeContext });
|
|
65
|
+
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
53
66
|
const _tool = tool;
|
|
54
67
|
acc[key] = {
|
|
55
68
|
..._tool,
|
|
@@ -58,39 +71,51 @@ async function getAgentByIdHandler({ mastra, agentId }) {
|
|
|
58
71
|
};
|
|
59
72
|
return acc;
|
|
60
73
|
}, {});
|
|
74
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
75
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
61
76
|
return {
|
|
62
77
|
name: agent.name,
|
|
63
|
-
instructions
|
|
78
|
+
instructions,
|
|
64
79
|
tools: serializedAgentTools,
|
|
65
|
-
provider:
|
|
66
|
-
modelId:
|
|
80
|
+
provider: llm?.getProvider(),
|
|
81
|
+
modelId: llm?.getModelId()
|
|
67
82
|
};
|
|
68
83
|
} catch (error) {
|
|
69
84
|
return chunkZLBRQFDD_cjs.handleError(error, "Error getting agent");
|
|
70
85
|
}
|
|
71
86
|
}
|
|
72
|
-
async function getEvalsByAgentIdHandler({
|
|
87
|
+
async function getEvalsByAgentIdHandler({
|
|
88
|
+
mastra,
|
|
89
|
+
runtimeContext,
|
|
90
|
+
agentId
|
|
91
|
+
}) {
|
|
73
92
|
try {
|
|
74
93
|
const agent = mastra.getAgent(agentId);
|
|
75
94
|
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
|
|
95
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
76
96
|
return {
|
|
77
97
|
id: agentId,
|
|
78
98
|
name: agent.name,
|
|
79
|
-
instructions
|
|
99
|
+
instructions,
|
|
80
100
|
evals
|
|
81
101
|
};
|
|
82
102
|
} catch (error) {
|
|
83
103
|
return chunkZLBRQFDD_cjs.handleError(error, "Error getting test evals");
|
|
84
104
|
}
|
|
85
105
|
}
|
|
86
|
-
async function getLiveEvalsByAgentIdHandler({
|
|
106
|
+
async function getLiveEvalsByAgentIdHandler({
|
|
107
|
+
mastra,
|
|
108
|
+
runtimeContext,
|
|
109
|
+
agentId
|
|
110
|
+
}) {
|
|
87
111
|
try {
|
|
88
112
|
const agent = mastra.getAgent(agentId);
|
|
89
113
|
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
|
|
114
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
90
115
|
return {
|
|
91
116
|
id: agentId,
|
|
92
117
|
name: agent.name,
|
|
93
|
-
instructions
|
|
118
|
+
instructions,
|
|
94
119
|
evals
|
|
95
120
|
};
|
|
96
121
|
} catch (error) {
|
|
@@ -99,7 +124,7 @@ async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
|
|
|
99
124
|
}
|
|
100
125
|
async function generateHandler({
|
|
101
126
|
mastra,
|
|
102
|
-
|
|
127
|
+
runtimeContext,
|
|
103
128
|
agentId,
|
|
104
129
|
body
|
|
105
130
|
}) {
|
|
@@ -115,7 +140,7 @@ async function generateHandler({
|
|
|
115
140
|
...rest,
|
|
116
141
|
// @ts-expect-error TODO fix types
|
|
117
142
|
resourceId: finalResourceId,
|
|
118
|
-
|
|
143
|
+
runtimeContext
|
|
119
144
|
});
|
|
120
145
|
return result;
|
|
121
146
|
} catch (error) {
|
|
@@ -124,7 +149,7 @@ async function generateHandler({
|
|
|
124
149
|
}
|
|
125
150
|
async function streamGenerateHandler({
|
|
126
151
|
mastra,
|
|
127
|
-
|
|
152
|
+
runtimeContext,
|
|
128
153
|
agentId,
|
|
129
154
|
body
|
|
130
155
|
}) {
|
|
@@ -140,7 +165,7 @@ async function streamGenerateHandler({
|
|
|
140
165
|
...rest,
|
|
141
166
|
// @ts-expect-error TODO fix types
|
|
142
167
|
resourceId: finalResourceId,
|
|
143
|
-
|
|
168
|
+
runtimeContext
|
|
144
169
|
});
|
|
145
170
|
const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
146
171
|
sendUsage: true,
|
|
@@ -40,9 +40,7 @@ async function generateSpeechHandler({
|
|
|
40
40
|
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Agent ID is required" });
|
|
41
41
|
}
|
|
42
42
|
chunkQN4KF3BH_cjs.validateBody({
|
|
43
|
-
text:
|
|
44
|
-
speakerId: void 0,
|
|
45
|
-
...body
|
|
43
|
+
text: body?.text
|
|
46
44
|
});
|
|
47
45
|
const agent = mastra.getAgent(agentId);
|
|
48
46
|
if (!agent) {
|
|
@@ -55,12 +53,7 @@ async function generateSpeechHandler({
|
|
|
55
53
|
if (!audioStream) {
|
|
56
54
|
throw new chunkFV45V6WC_cjs.HTTPException(500, { message: "Failed to generate speech" });
|
|
57
55
|
}
|
|
58
|
-
|
|
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 };
|
|
56
|
+
return audioStream;
|
|
64
57
|
} catch (error) {
|
|
65
58
|
return chunkZLBRQFDD_cjs.handleError(error, "Error generating speech");
|
|
66
59
|
}
|
|
@@ -56,7 +56,7 @@ function executeToolHandler(tools) {
|
|
|
56
56
|
runId,
|
|
57
57
|
toolId,
|
|
58
58
|
data,
|
|
59
|
-
|
|
59
|
+
runtimeContext
|
|
60
60
|
}) => {
|
|
61
61
|
try {
|
|
62
62
|
if (!toolId) {
|
|
@@ -78,7 +78,7 @@ function executeToolHandler(tools) {
|
|
|
78
78
|
context: data,
|
|
79
79
|
mastra,
|
|
80
80
|
runId,
|
|
81
|
-
|
|
81
|
+
runtimeContext
|
|
82
82
|
});
|
|
83
83
|
return result;
|
|
84
84
|
} catch (error) {
|
|
@@ -91,7 +91,7 @@ async function executeAgentToolHandler({
|
|
|
91
91
|
agentId,
|
|
92
92
|
toolId,
|
|
93
93
|
data,
|
|
94
|
-
|
|
94
|
+
runtimeContext
|
|
95
95
|
}) {
|
|
96
96
|
try {
|
|
97
97
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
@@ -107,7 +107,7 @@ async function executeAgentToolHandler({
|
|
|
107
107
|
}
|
|
108
108
|
const result = await tool.execute({
|
|
109
109
|
context: data,
|
|
110
|
-
|
|
110
|
+
runtimeContext,
|
|
111
111
|
mastra,
|
|
112
112
|
runId: agentId
|
|
113
113
|
});
|
|
@@ -12,33 +12,48 @@ chunkFV45V6WC_cjs.__export(network_exports, {
|
|
|
12
12
|
getNetworksHandler: () => getNetworksHandler,
|
|
13
13
|
streamGenerateHandler: () => streamGenerateHandler
|
|
14
14
|
});
|
|
15
|
-
async function getNetworksHandler({
|
|
15
|
+
async function getNetworksHandler({
|
|
16
|
+
mastra,
|
|
17
|
+
runtimeContext
|
|
18
|
+
}) {
|
|
16
19
|
try {
|
|
17
20
|
const networks = mastra.getNetworks();
|
|
18
|
-
const serializedNetworks =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
const serializedNetworks = await Promise.all(
|
|
22
|
+
networks.map(async (network) => {
|
|
23
|
+
const routingAgent = network.getRoutingAgent();
|
|
24
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
25
|
+
const agents = network.getAgents();
|
|
26
|
+
return {
|
|
27
|
+
id: network.formatAgentId(routingAgent.name),
|
|
28
|
+
name: routingAgent.name,
|
|
29
|
+
instructions: routingAgent.instructions,
|
|
30
|
+
agents: await Promise.all(
|
|
31
|
+
agents.map(async (agent) => {
|
|
32
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
33
|
+
return {
|
|
34
|
+
name: agent.name,
|
|
35
|
+
provider: llm?.getProvider(),
|
|
36
|
+
modelId: llm?.getModelId()
|
|
37
|
+
};
|
|
38
|
+
})
|
|
39
|
+
),
|
|
40
|
+
routingModel: {
|
|
41
|
+
provider: routingLLM?.getProvider(),
|
|
42
|
+
modelId: routingLLM?.getModelId()
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
);
|
|
36
47
|
return serializedNetworks;
|
|
37
48
|
} catch (error) {
|
|
38
49
|
return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
|
-
async function getNetworkByIdHandler({
|
|
52
|
+
async function getNetworkByIdHandler({
|
|
53
|
+
mastra,
|
|
54
|
+
networkId,
|
|
55
|
+
runtimeContext
|
|
56
|
+
}) {
|
|
42
57
|
try {
|
|
43
58
|
const networks = mastra.getNetworks();
|
|
44
59
|
const network = networks.find((network2) => {
|
|
@@ -49,19 +64,25 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
49
64
|
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
|
|
50
65
|
}
|
|
51
66
|
const routingAgent = network.getRoutingAgent();
|
|
67
|
+
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
52
68
|
const agents = network.getAgents();
|
|
53
69
|
const serializedNetwork = {
|
|
54
70
|
id: network.formatAgentId(routingAgent.name),
|
|
55
71
|
name: routingAgent.name,
|
|
56
72
|
instructions: routingAgent.instructions,
|
|
57
|
-
agents:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
73
|
+
agents: await Promise.all(
|
|
74
|
+
agents.map(async (agent) => {
|
|
75
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
76
|
+
return {
|
|
77
|
+
name: agent.name,
|
|
78
|
+
provider: llm?.getProvider(),
|
|
79
|
+
modelId: llm?.getModelId()
|
|
80
|
+
};
|
|
81
|
+
})
|
|
82
|
+
),
|
|
62
83
|
routingModel: {
|
|
63
|
-
provider:
|
|
64
|
-
modelId:
|
|
84
|
+
provider: routingLLM?.getProvider(),
|
|
85
|
+
modelId: routingLLM?.getModelId()
|
|
65
86
|
}
|
|
66
87
|
};
|
|
67
88
|
return serializedNetwork;
|
|
@@ -71,7 +92,7 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
|
|
|
71
92
|
}
|
|
72
93
|
async function generateHandler({
|
|
73
94
|
mastra,
|
|
74
|
-
|
|
95
|
+
runtimeContext,
|
|
75
96
|
networkId,
|
|
76
97
|
body
|
|
77
98
|
}) {
|
|
@@ -82,7 +103,7 @@ async function generateHandler({
|
|
|
82
103
|
}
|
|
83
104
|
chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
|
|
84
105
|
const { messages, ...rest } = body;
|
|
85
|
-
const result = await network.generate(messages, { ...rest,
|
|
106
|
+
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
86
107
|
return result;
|
|
87
108
|
} catch (error) {
|
|
88
109
|
return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
|
|
@@ -92,7 +113,7 @@ async function streamGenerateHandler({
|
|
|
92
113
|
mastra,
|
|
93
114
|
networkId,
|
|
94
115
|
body,
|
|
95
|
-
|
|
116
|
+
runtimeContext
|
|
96
117
|
}) {
|
|
97
118
|
try {
|
|
98
119
|
const network = mastra.getNetwork(networkId);
|
|
@@ -104,7 +125,7 @@ async function streamGenerateHandler({
|
|
|
104
125
|
const streamResult = await network.stream(messages, {
|
|
105
126
|
output,
|
|
106
127
|
...rest,
|
|
107
|
-
|
|
128
|
+
runtimeContext
|
|
108
129
|
});
|
|
109
130
|
const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
|
|
110
131
|
sendUsage: true,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
|
|
4
|
+
|
|
5
|
+
// src/server/handlers/mcp.ts
|
|
6
|
+
var getMcpServersHandler = async ({ mastra }) => {
|
|
7
|
+
const servers = mastra.getMCPServers();
|
|
8
|
+
return {
|
|
9
|
+
servers: servers.map((server) => ({
|
|
10
|
+
id: server.name,
|
|
11
|
+
name: server.name,
|
|
12
|
+
version: server.version,
|
|
13
|
+
tools: Object.keys(server.tools()).length
|
|
14
|
+
}))
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var getMcpServerHandler = async ({ mastra, serverId }) => {
|
|
18
|
+
const server = mastra.getMCPServer(serverId);
|
|
19
|
+
if (!server) {
|
|
20
|
+
throw new chunkFV45V6WC_cjs.HTTPException(404, { message: `MCP server '${serverId}' not found` });
|
|
21
|
+
}
|
|
22
|
+
const tools = server.tools();
|
|
23
|
+
return {
|
|
24
|
+
id: server.name,
|
|
25
|
+
name: server.name,
|
|
26
|
+
version: server.version,
|
|
27
|
+
tools: Object.entries(tools).map(([name, tool]) => ({
|
|
28
|
+
name,
|
|
29
|
+
description: tool.description,
|
|
30
|
+
parameters: tool.parameters
|
|
31
|
+
}))
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.getMcpServerHandler = getMcpServerHandler;
|
|
36
|
+
exports.getMcpServersHandler = getMcpServersHandler;
|
|
@@ -22,7 +22,7 @@ async function getTelemetryHandler({ mastra, body }) {
|
|
|
22
22
|
if (!body) {
|
|
23
23
|
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Body is required" });
|
|
24
24
|
}
|
|
25
|
-
const { name, scope, page, perPage, attribute } = body;
|
|
25
|
+
const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
|
|
26
26
|
const attributes = attribute ? Object.fromEntries(
|
|
27
27
|
(Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
|
|
28
28
|
const [key, value] = attr.split(":");
|
|
@@ -34,7 +34,9 @@ async function getTelemetryHandler({ mastra, body }) {
|
|
|
34
34
|
scope,
|
|
35
35
|
page: Number(page ?? 0),
|
|
36
36
|
perPage: Number(perPage ?? 100),
|
|
37
|
-
attributes
|
|
37
|
+
attributes,
|
|
38
|
+
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
39
|
+
toDate: toDate ? new Date(toDate) : void 0
|
|
38
40
|
});
|
|
39
41
|
return traces;
|
|
40
42
|
} catch (error2) {
|
|
@@ -20,7 +20,7 @@ async function getTelemetryHandler({ mastra, body }) {
|
|
|
20
20
|
if (!body) {
|
|
21
21
|
throw new HTTPException(400, { message: "Body is required" });
|
|
22
22
|
}
|
|
23
|
-
const { name, scope, page, perPage, attribute } = body;
|
|
23
|
+
const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
|
|
24
24
|
const attributes = attribute ? Object.fromEntries(
|
|
25
25
|
(Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
|
|
26
26
|
const [key, value] = attr.split(":");
|
|
@@ -32,7 +32,9 @@ async function getTelemetryHandler({ mastra, body }) {
|
|
|
32
32
|
scope,
|
|
33
33
|
page: Number(page ?? 0),
|
|
34
34
|
perPage: Number(perPage ?? 100),
|
|
35
|
-
attributes
|
|
35
|
+
attributes,
|
|
36
|
+
fromDate: fromDate ? new Date(fromDate) : void 0,
|
|
37
|
+
toDate: toDate ? new Date(toDate) : void 0
|
|
36
38
|
});
|
|
37
39
|
return traces;
|
|
38
40
|
} catch (error2) {
|
|
@@ -34,7 +34,9 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
34
34
|
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
35
35
|
const _step = step;
|
|
36
36
|
acc2[key2] = {
|
|
37
|
-
|
|
37
|
+
id: _step.id,
|
|
38
|
+
description: _step.description,
|
|
39
|
+
workflowId: _step.workflowId,
|
|
38
40
|
inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
39
41
|
outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
|
|
40
42
|
};
|
|
@@ -67,7 +69,9 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
67
69
|
steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
|
|
68
70
|
const _step = step;
|
|
69
71
|
acc[key] = {
|
|
70
|
-
|
|
72
|
+
id: _step.id,
|
|
73
|
+
description: _step.description,
|
|
74
|
+
workflowId: _step.workflowId,
|
|
71
75
|
inputSchema: _step.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.inputSchema)) : void 0,
|
|
72
76
|
outputSchema: _step.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(_step.outputSchema)) : void 0
|
|
73
77
|
};
|
|
@@ -80,7 +84,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
80
84
|
}
|
|
81
85
|
async function startAsyncWorkflowHandler({
|
|
82
86
|
mastra,
|
|
83
|
-
|
|
87
|
+
runtimeContext,
|
|
84
88
|
workflowId,
|
|
85
89
|
runId,
|
|
86
90
|
triggerData
|
|
@@ -97,7 +101,7 @@ async function startAsyncWorkflowHandler({
|
|
|
97
101
|
const { start } = workflow.createRun();
|
|
98
102
|
const result2 = await start({
|
|
99
103
|
triggerData,
|
|
100
|
-
|
|
104
|
+
runtimeContext
|
|
101
105
|
});
|
|
102
106
|
return result2;
|
|
103
107
|
}
|
|
@@ -107,7 +111,7 @@ async function startAsyncWorkflowHandler({
|
|
|
107
111
|
}
|
|
108
112
|
const result = await run.start({
|
|
109
113
|
triggerData,
|
|
110
|
-
|
|
114
|
+
runtimeContext
|
|
111
115
|
});
|
|
112
116
|
return result;
|
|
113
117
|
} catch (error) {
|
|
@@ -160,7 +164,7 @@ async function createRunHandler({
|
|
|
160
164
|
}
|
|
161
165
|
async function startWorkflowRunHandler({
|
|
162
166
|
mastra,
|
|
163
|
-
|
|
167
|
+
runtimeContext,
|
|
164
168
|
workflowId,
|
|
165
169
|
runId,
|
|
166
170
|
triggerData
|
|
@@ -179,7 +183,7 @@ async function startWorkflowRunHandler({
|
|
|
179
183
|
}
|
|
180
184
|
await run.start({
|
|
181
185
|
triggerData,
|
|
182
|
-
|
|
186
|
+
runtimeContext
|
|
183
187
|
});
|
|
184
188
|
return { message: "Workflow run started" };
|
|
185
189
|
} catch (e) {
|
|
@@ -235,7 +239,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
235
239
|
workflowId,
|
|
236
240
|
runId,
|
|
237
241
|
body,
|
|
238
|
-
|
|
242
|
+
runtimeContext
|
|
239
243
|
}) {
|
|
240
244
|
try {
|
|
241
245
|
if (!workflowId) {
|
|
@@ -252,7 +256,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
252
256
|
const result = await run.resume({
|
|
253
257
|
stepId: body.stepId,
|
|
254
258
|
context: body.context,
|
|
255
|
-
|
|
259
|
+
runtimeContext
|
|
256
260
|
});
|
|
257
261
|
return result;
|
|
258
262
|
} catch (error) {
|
|
@@ -264,7 +268,7 @@ async function resumeWorkflowHandler({
|
|
|
264
268
|
workflowId,
|
|
265
269
|
runId,
|
|
266
270
|
body,
|
|
267
|
-
|
|
271
|
+
runtimeContext
|
|
268
272
|
}) {
|
|
269
273
|
try {
|
|
270
274
|
if (!workflowId) {
|
|
@@ -281,20 +285,28 @@ async function resumeWorkflowHandler({
|
|
|
281
285
|
await run.resume({
|
|
282
286
|
stepId: body.stepId,
|
|
283
287
|
context: body.context,
|
|
284
|
-
|
|
288
|
+
runtimeContext
|
|
285
289
|
});
|
|
286
290
|
return { message: "Workflow run resumed" };
|
|
287
291
|
} catch (error) {
|
|
288
292
|
return chunkZLBRQFDD_cjs.handleError(error, "Error resuming workflow");
|
|
289
293
|
}
|
|
290
294
|
}
|
|
291
|
-
async function getWorkflowRunsHandler({
|
|
295
|
+
async function getWorkflowRunsHandler({
|
|
296
|
+
mastra,
|
|
297
|
+
workflowId,
|
|
298
|
+
fromDate,
|
|
299
|
+
toDate,
|
|
300
|
+
limit,
|
|
301
|
+
offset,
|
|
302
|
+
resourceId
|
|
303
|
+
}) {
|
|
292
304
|
try {
|
|
293
305
|
if (!workflowId) {
|
|
294
306
|
throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
295
307
|
}
|
|
296
308
|
const workflow = mastra.getWorkflow(workflowId);
|
|
297
|
-
const workflowRuns = await workflow.getWorkflowRuns() || {
|
|
309
|
+
const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
|
|
298
310
|
runs: [],
|
|
299
311
|
total: 0
|
|
300
312
|
};
|
|
@@ -58,7 +58,7 @@ function executeToolHandler(tools$1) {
|
|
|
58
58
|
runId,
|
|
59
59
|
toolId,
|
|
60
60
|
data,
|
|
61
|
-
|
|
61
|
+
runtimeContext
|
|
62
62
|
}) => {
|
|
63
63
|
try {
|
|
64
64
|
if (!toolId) {
|
|
@@ -80,7 +80,7 @@ function executeToolHandler(tools$1) {
|
|
|
80
80
|
context: data,
|
|
81
81
|
mastra,
|
|
82
82
|
runId,
|
|
83
|
-
|
|
83
|
+
runtimeContext
|
|
84
84
|
});
|
|
85
85
|
return result;
|
|
86
86
|
} catch (error) {
|
|
@@ -93,7 +93,7 @@ async function executeAgentToolHandler({
|
|
|
93
93
|
agentId,
|
|
94
94
|
toolId,
|
|
95
95
|
data,
|
|
96
|
-
|
|
96
|
+
runtimeContext
|
|
97
97
|
}) {
|
|
98
98
|
try {
|
|
99
99
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
@@ -109,7 +109,7 @@ async function executeAgentToolHandler({
|
|
|
109
109
|
}
|
|
110
110
|
const result = await tool.execute({
|
|
111
111
|
context: data,
|
|
112
|
-
|
|
112
|
+
runtimeContext,
|
|
113
113
|
mastra,
|
|
114
114
|
runId: agentId
|
|
115
115
|
});
|