@mastra/server 0.0.0-extend-clickhouse-20250418135620 → 0.0.0-feat-tool-input-validation-20250731232758
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 +763 -76
- package/dist/_tsup-dts-rollup.d.ts +763 -76
- package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
- package/dist/chunk-2SLFAFTR.cjs +148 -0
- package/dist/chunk-36BLNJHS.js +2039 -0
- package/dist/chunk-424T5F2J.cjs +157 -0
- package/dist/chunk-4D66QEKC.js +81 -0
- package/dist/chunk-6KP2OBYA.cjs +544 -0
- package/dist/chunk-6T5JUKOQ.js +149 -0
- package/dist/chunk-75ZPJI57.cjs +9 -0
- package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
- package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-YANVFOYA.js → chunk-CRCR3ZUK.js} +56 -34
- package/dist/{chunk-7IWQE76Z.cjs → chunk-G7KH752Y.cjs} +16 -10
- package/dist/chunk-GHC4YV6R.js +504 -0
- package/dist/chunk-HISYIDYH.cjs +2042 -0
- package/dist/{chunk-HABV7TZK.cjs → chunk-HRSAZUIK.cjs} +28 -26
- package/dist/chunk-I5JKUCGE.cjs +308 -0
- package/dist/{chunk-3RVHWGWO.js → chunk-KHZKYUNR.js} +36 -19
- package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/chunk-MLKGABMK.js +7 -0
- package/dist/chunk-PIAJQ75M.js +539 -0
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/chunk-QGX47B5D.cjs +86 -0
- package/dist/{chunk-WTHDCRMY.js → chunk-RG473F6Y.js} +12 -6
- 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-T7HAZC2E.js +527 -0
- package/dist/chunk-UCV4247U.cjs +332 -0
- package/dist/chunk-UEVYOKAH.cjs +555 -0
- package/dist/chunk-VTTN2FW3.js +299 -0
- package/dist/{chunk-XISBMH56.js → chunk-WBRFIHSF.js} +11 -9
- package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
- package/dist/{chunk-4B7OUZXW.js → chunk-ZYAFP2AV.js} +83 -68
- 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 +11 -7
- package/dist/server/handlers/agents.d.cts +1 -0
- package/dist/server/handlers/agents.d.ts +1 -0
- 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 +33 -9
- package/dist/server/handlers/memory.d.cts +6 -0
- package/dist/server/handlers/memory.d.ts +6 -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/scores.cjs +30 -0
- package/dist/server/handlers/scores.d.cts +6 -0
- package/dist/server/handlers/scores.d.ts +6 -0
- package/dist/server/handlers/scores.js +1 -0
- 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 +33 -13
- package/dist/server/handlers/workflows.d.cts +7 -2
- package/dist/server/handlers/workflows.d.ts +7 -2
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +40 -25
- package/dist/server/handlers.d.cts +4 -1
- package/dist/server/handlers.d.ts +4 -1
- package/dist/server/handlers.js +12 -9
- package/package.json +17 -15
- package/dist/chunk-2FJURXCL.cjs +0 -213
- package/dist/chunk-3AHQ5RGN.js +0 -11
- package/dist/chunk-3EJZQ6TQ.js +0 -49
- package/dist/chunk-4WJ5GHRG.cjs +0 -164
- package/dist/chunk-5SWCVTNL.cjs +0 -5579
- package/dist/chunk-A7DF4ETD.cjs +0 -100
- package/dist/chunk-JLDXUWK7.cjs +0 -126
- package/dist/chunk-OMN3UI6X.js +0 -5576
- package/dist/chunk-RBQASTUP.js +0 -203
- package/dist/chunk-RNU4JMLM.cjs +0 -317
- package/dist/chunk-SKBVVI24.cjs +0 -54
- package/dist/chunk-TFFNX7FI.js +0 -156
- package/dist/chunk-ZLBRQFDD.cjs +0 -13
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { stringify, esm_default } from './chunk-36BLNJHS.js';
|
|
2
|
+
import { validateBody } from './chunk-RSEO4XPX.js';
|
|
3
|
+
import { handleError } from './chunk-LF7P5PLR.js';
|
|
4
|
+
import { HTTPException } from './chunk-LCM566I4.js';
|
|
5
|
+
import { __export } from './chunk-MLKGABMK.js';
|
|
6
|
+
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
7
|
+
|
|
8
|
+
// src/server/handlers/agents.ts
|
|
9
|
+
var agents_exports = {};
|
|
10
|
+
__export(agents_exports, {
|
|
11
|
+
generateHandler: () => generateHandler,
|
|
12
|
+
getAgentByIdHandler: () => getAgentByIdHandler,
|
|
13
|
+
getAgentsHandler: () => getAgentsHandler,
|
|
14
|
+
getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
|
|
15
|
+
getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
|
|
16
|
+
streamGenerateHandler: () => streamGenerateHandler,
|
|
17
|
+
streamVNextGenerateHandler: () => streamVNextGenerateHandler
|
|
18
|
+
});
|
|
19
|
+
async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
20
|
+
try {
|
|
21
|
+
const agents = mastra.getAgents();
|
|
22
|
+
const serializedAgentsMap = await Promise.all(
|
|
23
|
+
Object.entries(agents).map(async ([id, agent]) => {
|
|
24
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
25
|
+
const tools = await agent.getTools({ runtimeContext });
|
|
26
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
27
|
+
const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
|
|
28
|
+
const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
|
|
29
|
+
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
30
|
+
const _tool = tool;
|
|
31
|
+
acc[key] = {
|
|
32
|
+
..._tool,
|
|
33
|
+
inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
|
|
34
|
+
outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
|
|
35
|
+
};
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
let serializedAgentWorkflows = {};
|
|
39
|
+
if ("getWorkflows" in agent) {
|
|
40
|
+
const logger = mastra.getLogger();
|
|
41
|
+
try {
|
|
42
|
+
const workflows = await agent.getWorkflows({ runtimeContext });
|
|
43
|
+
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
44
|
+
return {
|
|
45
|
+
...acc,
|
|
46
|
+
[key]: {
|
|
47
|
+
name: workflow.name
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}, {});
|
|
51
|
+
} catch (error) {
|
|
52
|
+
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
name: agent.name,
|
|
58
|
+
instructions,
|
|
59
|
+
tools: serializedAgentTools,
|
|
60
|
+
workflows: serializedAgentWorkflows,
|
|
61
|
+
provider: llm?.getProvider(),
|
|
62
|
+
modelId: llm?.getModelId(),
|
|
63
|
+
defaultGenerateOptions,
|
|
64
|
+
defaultStreamOptions
|
|
65
|
+
};
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
|
|
69
|
+
acc[id] = rest;
|
|
70
|
+
return acc;
|
|
71
|
+
}, {});
|
|
72
|
+
return serializedAgents;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
return handleError(error, "Error getting agents");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function getAgentByIdHandler({
|
|
78
|
+
mastra,
|
|
79
|
+
runtimeContext,
|
|
80
|
+
agentId,
|
|
81
|
+
isPlayground = false
|
|
82
|
+
}) {
|
|
83
|
+
try {
|
|
84
|
+
const agent = mastra.getAgent(agentId);
|
|
85
|
+
if (!agent) {
|
|
86
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
87
|
+
}
|
|
88
|
+
const tools = await agent.getTools({ runtimeContext });
|
|
89
|
+
const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
90
|
+
const _tool = tool;
|
|
91
|
+
acc[key] = {
|
|
92
|
+
..._tool,
|
|
93
|
+
inputSchema: _tool.inputSchema ? stringify(esm_default(_tool.inputSchema)) : void 0,
|
|
94
|
+
outputSchema: _tool.outputSchema ? stringify(esm_default(_tool.outputSchema)) : void 0
|
|
95
|
+
};
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
let serializedAgentWorkflows = {};
|
|
99
|
+
if ("getWorkflows" in agent) {
|
|
100
|
+
const logger = mastra.getLogger();
|
|
101
|
+
try {
|
|
102
|
+
const workflows = await agent.getWorkflows({ runtimeContext });
|
|
103
|
+
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
104
|
+
return {
|
|
105
|
+
...acc,
|
|
106
|
+
[key]: {
|
|
107
|
+
name: workflow.name,
|
|
108
|
+
steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
|
|
109
|
+
return {
|
|
110
|
+
...acc2,
|
|
111
|
+
[key2]: {
|
|
112
|
+
id: step.id,
|
|
113
|
+
description: step.description
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}, {})
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}, {});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
let proxyRuntimeContext = runtimeContext;
|
|
125
|
+
if (isPlayground) {
|
|
126
|
+
proxyRuntimeContext = new Proxy(runtimeContext, {
|
|
127
|
+
get(target, prop) {
|
|
128
|
+
if (prop === "get") {
|
|
129
|
+
return function(key) {
|
|
130
|
+
const value = target.get(key);
|
|
131
|
+
return value ?? `<${key}>`;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return Reflect.get(target, prop);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
|
|
139
|
+
const llm = await agent.getLLM({ runtimeContext });
|
|
140
|
+
const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
|
|
141
|
+
const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
|
|
142
|
+
return {
|
|
143
|
+
name: agent.name,
|
|
144
|
+
instructions,
|
|
145
|
+
tools: serializedAgentTools,
|
|
146
|
+
workflows: serializedAgentWorkflows,
|
|
147
|
+
provider: llm?.getProvider(),
|
|
148
|
+
modelId: llm?.getModelId(),
|
|
149
|
+
defaultGenerateOptions,
|
|
150
|
+
defaultStreamOptions
|
|
151
|
+
};
|
|
152
|
+
} catch (error) {
|
|
153
|
+
return handleError(error, "Error getting agent");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
async function getEvalsByAgentIdHandler({
|
|
157
|
+
mastra,
|
|
158
|
+
runtimeContext,
|
|
159
|
+
agentId
|
|
160
|
+
}) {
|
|
161
|
+
try {
|
|
162
|
+
const agent = mastra.getAgent(agentId);
|
|
163
|
+
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
|
|
164
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
165
|
+
return {
|
|
166
|
+
id: agentId,
|
|
167
|
+
name: agent.name,
|
|
168
|
+
instructions,
|
|
169
|
+
evals
|
|
170
|
+
};
|
|
171
|
+
} catch (error) {
|
|
172
|
+
return handleError(error, "Error getting test evals");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
async function getLiveEvalsByAgentIdHandler({
|
|
176
|
+
mastra,
|
|
177
|
+
runtimeContext,
|
|
178
|
+
agentId
|
|
179
|
+
}) {
|
|
180
|
+
try {
|
|
181
|
+
const agent = mastra.getAgent(agentId);
|
|
182
|
+
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
|
|
183
|
+
const instructions = await agent.getInstructions({ runtimeContext });
|
|
184
|
+
return {
|
|
185
|
+
id: agentId,
|
|
186
|
+
name: agent.name,
|
|
187
|
+
instructions,
|
|
188
|
+
evals
|
|
189
|
+
};
|
|
190
|
+
} catch (error) {
|
|
191
|
+
return handleError(error, "Error getting live evals");
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function generateHandler({
|
|
195
|
+
mastra,
|
|
196
|
+
runtimeContext,
|
|
197
|
+
agentId,
|
|
198
|
+
body,
|
|
199
|
+
abortSignal
|
|
200
|
+
}) {
|
|
201
|
+
try {
|
|
202
|
+
const agent = mastra.getAgent(agentId);
|
|
203
|
+
if (!agent) {
|
|
204
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
205
|
+
}
|
|
206
|
+
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
207
|
+
const finalResourceId = resourceId ?? resourceid;
|
|
208
|
+
const finalRuntimeContext = new RuntimeContext([
|
|
209
|
+
...Array.from(runtimeContext.entries()),
|
|
210
|
+
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
211
|
+
]);
|
|
212
|
+
validateBody({ messages });
|
|
213
|
+
const result = await agent.generate(messages, {
|
|
214
|
+
...rest,
|
|
215
|
+
// @ts-expect-error TODO fix types
|
|
216
|
+
resourceId: finalResourceId,
|
|
217
|
+
runtimeContext: finalRuntimeContext,
|
|
218
|
+
signal: abortSignal
|
|
219
|
+
});
|
|
220
|
+
return result;
|
|
221
|
+
} catch (error) {
|
|
222
|
+
return handleError(error, "Error generating from agent");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function streamGenerateHandler({
|
|
226
|
+
mastra,
|
|
227
|
+
runtimeContext,
|
|
228
|
+
agentId,
|
|
229
|
+
body,
|
|
230
|
+
abortSignal
|
|
231
|
+
}) {
|
|
232
|
+
try {
|
|
233
|
+
const agent = mastra.getAgent(agentId);
|
|
234
|
+
if (!agent) {
|
|
235
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
236
|
+
}
|
|
237
|
+
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
238
|
+
const finalResourceId = resourceId ?? resourceid;
|
|
239
|
+
const finalRuntimeContext = new RuntimeContext([
|
|
240
|
+
...Array.from(runtimeContext.entries()),
|
|
241
|
+
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
242
|
+
]);
|
|
243
|
+
validateBody({ messages });
|
|
244
|
+
const streamResult = await agent.stream(messages, {
|
|
245
|
+
...rest,
|
|
246
|
+
// @ts-expect-error TODO fix types
|
|
247
|
+
resourceId: finalResourceId,
|
|
248
|
+
runtimeContext: finalRuntimeContext,
|
|
249
|
+
signal: abortSignal
|
|
250
|
+
});
|
|
251
|
+
const streamResponse = rest.output ? streamResult.toTextStreamResponse({
|
|
252
|
+
headers: {
|
|
253
|
+
"Transfer-Encoding": "chunked"
|
|
254
|
+
}
|
|
255
|
+
}) : streamResult.toDataStreamResponse({
|
|
256
|
+
sendUsage: true,
|
|
257
|
+
sendReasoning: true,
|
|
258
|
+
getErrorMessage: (error) => {
|
|
259
|
+
return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
|
|
260
|
+
},
|
|
261
|
+
headers: {
|
|
262
|
+
"Transfer-Encoding": "chunked"
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
return streamResponse;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return handleError(error, "error streaming agent response");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function streamVNextGenerateHandler({
|
|
271
|
+
mastra,
|
|
272
|
+
runtimeContext,
|
|
273
|
+
agentId,
|
|
274
|
+
body,
|
|
275
|
+
abortSignal
|
|
276
|
+
}) {
|
|
277
|
+
try {
|
|
278
|
+
const agent = mastra.getAgent(agentId);
|
|
279
|
+
if (!agent) {
|
|
280
|
+
throw new HTTPException(404, { message: "Agent not found" });
|
|
281
|
+
}
|
|
282
|
+
const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
283
|
+
const finalRuntimeContext = new RuntimeContext([
|
|
284
|
+
...Array.from(runtimeContext.entries()),
|
|
285
|
+
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
286
|
+
]);
|
|
287
|
+
validateBody({ messages });
|
|
288
|
+
const streamResult = agent.streamVNext(messages, {
|
|
289
|
+
...rest,
|
|
290
|
+
runtimeContext: finalRuntimeContext,
|
|
291
|
+
abortSignal
|
|
292
|
+
});
|
|
293
|
+
return streamResult;
|
|
294
|
+
} catch (error) {
|
|
295
|
+
return handleError(error, "error streaming agent response");
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export { agents_exports, generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler, streamVNextGenerateHandler };
|
|
@@ -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-36BLNJHS.js';
|
|
2
|
+
import { validateBody } from './chunk-RSEO4XPX.js';
|
|
3
|
+
import { handleError } from './chunk-LF7P5PLR.js';
|
|
4
|
+
import { HTTPException } from './chunk-LCM566I4.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
|
|
@@ -56,7 +57,7 @@ function executeToolHandler(tools) {
|
|
|
56
57
|
runId,
|
|
57
58
|
toolId,
|
|
58
59
|
data,
|
|
59
|
-
|
|
60
|
+
runtimeContext
|
|
60
61
|
}) => {
|
|
61
62
|
try {
|
|
62
63
|
if (!toolId) {
|
|
@@ -78,7 +79,7 @@ function executeToolHandler(tools) {
|
|
|
78
79
|
context: data,
|
|
79
80
|
mastra,
|
|
80
81
|
runId,
|
|
81
|
-
|
|
82
|
+
runtimeContext
|
|
82
83
|
});
|
|
83
84
|
return result;
|
|
84
85
|
} catch (error) {
|
|
@@ -91,14 +92,15 @@ async function executeAgentToolHandler({
|
|
|
91
92
|
agentId,
|
|
92
93
|
toolId,
|
|
93
94
|
data,
|
|
94
|
-
|
|
95
|
+
runtimeContext
|
|
95
96
|
}) {
|
|
96
97
|
try {
|
|
97
98
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
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
|
}
|
|
@@ -107,7 +109,7 @@ async function executeAgentToolHandler({
|
|
|
107
109
|
}
|
|
108
110
|
const result = await tool.execute({
|
|
109
111
|
context: data,
|
|
110
|
-
|
|
112
|
+
runtimeContext,
|
|
111
113
|
mastra,
|
|
112
114
|
runId: agentId
|
|
113
115
|
});
|
|
@@ -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/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");
|