@mastra/server 0.0.0-error-handler-fix-20251020202607 → 0.0.0-export-agent-memory-from-local-studio-20251112153946
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/CHANGELOG.md +802 -3
- package/README.md +1 -1
- package/dist/{chunk-FWO7VQDC.js → chunk-2IS5WICF.js} +7079 -1524
- package/dist/chunk-2IS5WICF.js.map +1 -0
- package/dist/{chunk-SPRRK3P7.cjs → chunk-2YZH5PH6.cjs} +47 -47
- package/dist/chunk-2YZH5PH6.cjs.map +1 -0
- package/dist/{chunk-BATEJLED.js → chunk-3AMNUUZF.js} +20 -20
- package/dist/chunk-3AMNUUZF.js.map +1 -0
- package/dist/{chunk-AW5BU3RQ.js → chunk-3F52QCI4.js} +40 -40
- package/dist/chunk-3F52QCI4.js.map +1 -0
- package/dist/{chunk-OEOGYAQC.js → chunk-4JF5WXPL.js} +155 -206
- package/dist/chunk-4JF5WXPL.js.map +1 -0
- package/dist/{chunk-7NADHFD2.cjs → chunk-64ITUOXI.cjs} +2 -2
- package/dist/chunk-64ITUOXI.cjs.map +1 -0
- package/dist/{chunk-MMROOK5J.js → chunk-6QWQZI4Q.js} +2 -2
- package/dist/{chunk-7NADHFD2.cjs.map → chunk-6QWQZI4Q.js.map} +1 -1
- package/dist/{chunk-ABRFV4XP.js → chunk-73PAWDM5.js} +13 -13
- package/dist/chunk-73PAWDM5.js.map +1 -0
- package/dist/{chunk-2S4IMB6E.cjs → chunk-A24TSVEZ.cjs} +39 -39
- package/dist/chunk-A24TSVEZ.cjs.map +1 -0
- package/dist/chunk-A2NPD5N6.cjs +517 -0
- package/dist/chunk-A2NPD5N6.cjs.map +1 -0
- package/dist/{chunk-QQXMIP6C.js → chunk-B3Z6J745.js} +17 -17
- package/dist/chunk-B3Z6J745.js.map +1 -0
- package/dist/{chunk-G4PUALCE.cjs → chunk-BTWIR2B7.cjs} +4 -4
- package/dist/{chunk-G4PUALCE.cjs.map → chunk-BTWIR2B7.cjs.map} +1 -1
- package/dist/{chunk-YWOK4F5A.js → chunk-D7T74TVR.js} +4 -6
- package/dist/chunk-D7T74TVR.js.map +1 -0
- package/dist/{chunk-FHSOPERI.cjs → chunk-EHACNWDL.cjs} +221 -242
- package/dist/chunk-EHACNWDL.cjs.map +1 -0
- package/dist/{chunk-HPXAM2PG.js → chunk-FPBYKMIS.js} +13 -13
- package/dist/chunk-FPBYKMIS.js.map +1 -0
- package/dist/{chunk-3SNGNFUJ.cjs → chunk-GLAZTMX3.cjs} +37 -37
- package/dist/chunk-GLAZTMX3.cjs.map +1 -0
- package/dist/{chunk-7HDOBOGG.cjs → chunk-ID6JYDNL.cjs} +7102 -1544
- package/dist/chunk-ID6JYDNL.cjs.map +1 -0
- package/dist/{chunk-TRGAMKHX.cjs → chunk-KF3RI45U.cjs} +46 -41
- package/dist/chunk-KF3RI45U.cjs.map +1 -0
- package/dist/{chunk-TOP25AIO.cjs → chunk-KJIDZQRA.cjs} +14 -14
- package/dist/chunk-KJIDZQRA.cjs.map +1 -0
- package/dist/{chunk-MYR4PVGN.js → chunk-KWH5QBXP.js} +4 -4
- package/dist/{chunk-MYR4PVGN.js.map → chunk-KWH5QBXP.js.map} +1 -1
- package/dist/{chunk-AHB4JCIQ.js → chunk-ND5OKOMT.js} +31 -26
- package/dist/chunk-ND5OKOMT.js.map +1 -0
- package/dist/{chunk-XN74I6VW.cjs → chunk-PPMIB3FQ.cjs} +20 -20
- package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
- package/dist/{chunk-XVPBGW6Y.cjs → chunk-QU6N55W6.cjs} +9 -9
- package/dist/{chunk-XVPBGW6Y.cjs.map → chunk-QU6N55W6.cjs.map} +1 -1
- package/dist/{chunk-EP3JQDPD.cjs → chunk-S54HNARD.cjs} +18 -18
- package/dist/{chunk-EP3JQDPD.cjs.map → chunk-S54HNARD.cjs.map} +1 -1
- package/dist/{chunk-SIW6CYO3.js → chunk-SHWNNZBL.js} +7 -7
- package/dist/{chunk-SIW6CYO3.js.map → chunk-SHWNNZBL.js.map} +1 -1
- package/dist/{chunk-4QCXUEAT.js → chunk-SZIFSF4T.js} +3 -3
- package/dist/{chunk-4QCXUEAT.js.map → chunk-SZIFSF4T.js.map} +1 -1
- package/dist/{chunk-FZNS32WJ.js → chunk-TOCYBDP2.js} +4 -4
- package/dist/{chunk-FZNS32WJ.js.map → chunk-TOCYBDP2.js.map} +1 -1
- package/dist/{chunk-CY4TP3FK.js → chunk-UXGQZUYZ.js} +3 -3
- package/dist/{chunk-CY4TP3FK.js.map → chunk-UXGQZUYZ.js.map} +1 -1
- package/dist/{chunk-RE4RPXT2.cjs → chunk-V5WWQN7P.cjs} +4 -4
- package/dist/{chunk-RE4RPXT2.cjs.map → chunk-V5WWQN7P.cjs.map} +1 -1
- package/dist/{chunk-VY4ENABS.cjs → chunk-W2KMU354.cjs} +4 -6
- package/dist/chunk-W2KMU354.cjs.map +1 -0
- package/dist/chunk-X3MICMI2.cjs +620 -0
- package/dist/chunk-X3MICMI2.cjs.map +1 -0
- package/dist/{chunk-OYL5TBJW.cjs → chunk-X6C7BUWN.cjs} +4 -4
- package/dist/{chunk-OYL5TBJW.cjs.map → chunk-X6C7BUWN.cjs.map} +1 -1
- package/dist/{chunk-XDAYZS6N.js → chunk-Z2O5YVHY.js} +190 -211
- package/dist/chunk-Z2O5YVHY.js.map +1 -0
- package/dist/{chunk-DB63UMTV.js → chunk-ZJ6KEY6H.js} +110 -170
- package/dist/chunk-ZJ6KEY6H.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +7 -7
- package/dist/server/handlers/a2a.d.ts +10 -10
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +31 -19
- package/dist/server/handlers/agent-builder.d.ts +38 -47
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +26 -26
- package/dist/server/handlers/agents.d.ts +44 -54
- package/dist/server/handlers/agents.d.ts.map +1 -1
- 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/logs.cjs +7 -7
- package/dist/server/handlers/logs.d.ts +3 -3
- package/dist/server/handlers/logs.d.ts.map +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +17 -25
- package/dist/server/handlers/memory.d.ts +28 -34
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +8 -8
- package/dist/server/handlers/observability.d.ts +12 -12
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/scores.cjs +11 -11
- package/dist/server/handlers/scores.d.ts +24 -24
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/tools.cjs +7 -7
- package/dist/server/handlers/tools.d.ts +8 -8
- package/dist/server/handlers/tools.d.ts.map +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +3 -3
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.d.ts +6 -6
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +27 -27
- package/dist/server/handlers/workflows.d.ts +34 -37
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +26 -36
- package/dist/server/handlers.d.ts +0 -2
- package/dist/server/handlers.d.ts.map +1 -1
- package/dist/server/handlers.js +11 -13
- package/dist/server/http-exception.d.ts +0 -5
- package/dist/server/http-exception.d.ts.map +1 -1
- package/dist/server/utils.d.ts +3 -2
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/{token-53CFGXUO.cjs → token-375W3LEI.cjs} +10 -10
- package/dist/{token-53CFGXUO.cjs.map → token-375W3LEI.cjs.map} +1 -1
- package/dist/{token-WAEKDUVY.js → token-C3IMNCC4.js} +8 -8
- package/dist/{token-WAEKDUVY.js.map → token-C3IMNCC4.js.map} +1 -1
- package/dist/token-util-CV3RRG6K.cjs +9 -0
- package/dist/{token-util-S4A355II.cjs.map → token-util-CV3RRG6K.cjs.map} +1 -1
- package/dist/token-util-E5QO2RCL.js +7 -0
- package/dist/{token-util-LY37VCIN.js.map → token-util-E5QO2RCL.js.map} +1 -1
- package/package.json +11 -8
- package/dist/chunk-2S4IMB6E.cjs.map +0 -1
- package/dist/chunk-3LTO44EP.cjs +0 -570
- package/dist/chunk-3LTO44EP.cjs.map +0 -1
- package/dist/chunk-3SNGNFUJ.cjs.map +0 -1
- package/dist/chunk-67GYDFSB.js +0 -160
- package/dist/chunk-67GYDFSB.js.map +0 -1
- package/dist/chunk-6ZR275MD.cjs +0 -165
- package/dist/chunk-6ZR275MD.cjs.map +0 -1
- package/dist/chunk-7HDOBOGG.cjs.map +0 -1
- package/dist/chunk-ABRFV4XP.js.map +0 -1
- package/dist/chunk-AHB4JCIQ.js.map +0 -1
- package/dist/chunk-AW5BU3RQ.js.map +0 -1
- package/dist/chunk-BATEJLED.js.map +0 -1
- package/dist/chunk-DB63UMTV.js.map +0 -1
- package/dist/chunk-FHSOPERI.cjs.map +0 -1
- package/dist/chunk-FWO7VQDC.js.map +0 -1
- package/dist/chunk-HPXAM2PG.js.map +0 -1
- package/dist/chunk-I3C4ODGV.cjs +0 -335
- package/dist/chunk-I3C4ODGV.cjs.map +0 -1
- package/dist/chunk-LLUOPR3J.js +0 -323
- package/dist/chunk-LLUOPR3J.js.map +0 -1
- package/dist/chunk-MMROOK5J.js.map +0 -1
- package/dist/chunk-MQDBNHBT.cjs +0 -680
- package/dist/chunk-MQDBNHBT.cjs.map +0 -1
- package/dist/chunk-OEOGYAQC.js.map +0 -1
- package/dist/chunk-QQXMIP6C.js.map +0 -1
- package/dist/chunk-SPRRK3P7.cjs.map +0 -1
- package/dist/chunk-TOP25AIO.cjs.map +0 -1
- package/dist/chunk-TRGAMKHX.cjs.map +0 -1
- package/dist/chunk-VY4ENABS.cjs.map +0 -1
- package/dist/chunk-XDAYZS6N.js.map +0 -1
- package/dist/chunk-XN74I6VW.cjs.map +0 -1
- package/dist/chunk-YWOK4F5A.js.map +0 -1
- package/dist/server/handlers/legacyWorkflows.cjs +0 -48
- package/dist/server/handlers/legacyWorkflows.cjs.map +0 -1
- package/dist/server/handlers/legacyWorkflows.d.ts +0 -59
- package/dist/server/handlers/legacyWorkflows.d.ts.map +0 -1
- package/dist/server/handlers/legacyWorkflows.js +0 -3
- package/dist/server/handlers/legacyWorkflows.js.map +0 -1
- package/dist/server/handlers/telemetry.cjs +0 -20
- package/dist/server/handlers/telemetry.cjs.map +0 -1
- package/dist/server/handlers/telemetry.d.ts +0 -33
- package/dist/server/handlers/telemetry.d.ts.map +0 -1
- package/dist/server/handlers/telemetry.js +0 -3
- package/dist/server/handlers/telemetry.js.map +0 -1
- package/dist/token-util-LY37VCIN.js +0 -7
- package/dist/token-util-S4A355II.cjs +0 -9
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { sanitizeBody, validateBody } from './chunk-4QCXUEAT.js';
|
|
2
1
|
import { stringify } from './chunk-LF2ZLOFP.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { sanitizeBody, validateBody } from './chunk-SZIFSF4T.js';
|
|
3
|
+
import { handleError } from './chunk-UXGQZUYZ.js';
|
|
4
|
+
import { HTTPException } from './chunk-6QWQZI4Q.js';
|
|
5
5
|
import { __export } from './chunk-PR4QN5HX.js';
|
|
6
|
+
import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';
|
|
6
7
|
import { PROVIDER_REGISTRY } from '@mastra/core/llm';
|
|
7
|
-
import {
|
|
8
|
+
import { RequestContext } from '@mastra/core/request-context';
|
|
8
9
|
import { zodToJsonSchema } from '@mastra/core/utils/zod-to-json';
|
|
9
10
|
|
|
10
11
|
// src/server/handlers/agents.ts
|
|
@@ -15,13 +16,13 @@ __export(agents_exports, {
|
|
|
15
16
|
generateHandler: () => generateHandler,
|
|
16
17
|
generateLegacyHandler: () => generateLegacyHandler,
|
|
17
18
|
getAgentByIdHandler: () => getAgentByIdHandler,
|
|
18
|
-
|
|
19
|
-
getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
|
|
20
|
-
getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
|
|
19
|
+
getAgentFromSystem: () => getAgentFromSystem,
|
|
21
20
|
getProvidersHandler: () => getProvidersHandler,
|
|
22
21
|
getSerializedAgentTools: () => getSerializedAgentTools,
|
|
23
22
|
getSerializedProcessors: () => getSerializedProcessors,
|
|
23
|
+
listAgentsHandler: () => listAgentsHandler,
|
|
24
24
|
reorderAgentModelListHandler: () => reorderAgentModelListHandler,
|
|
25
|
+
resetAgentModelHandler: () => resetAgentModelHandler,
|
|
25
26
|
streamGenerateHandler: () => streamGenerateHandler,
|
|
26
27
|
streamGenerateLegacyHandler: () => streamGenerateLegacyHandler,
|
|
27
28
|
streamNetworkHandler: () => streamNetworkHandler,
|
|
@@ -80,17 +81,18 @@ async function getSerializedAgentTools(tools) {
|
|
|
80
81
|
function getSerializedProcessors(processors) {
|
|
81
82
|
return processors.map((processor) => {
|
|
82
83
|
return {
|
|
84
|
+
id: processor.id,
|
|
83
85
|
name: processor.name || processor.constructor.name
|
|
84
86
|
};
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
async function getSerializedAgentDefinition({
|
|
88
90
|
agent,
|
|
89
|
-
|
|
91
|
+
requestContext
|
|
90
92
|
}) {
|
|
91
93
|
let serializedAgentAgents = {};
|
|
92
94
|
if ("listAgents" in agent) {
|
|
93
|
-
const agents = await agent.listAgents({
|
|
95
|
+
const agents = await agent.listAgents({ requestContext });
|
|
94
96
|
serializedAgentAgents = Object.entries(agents || {}).reduce(
|
|
95
97
|
(acc, [key, agent2]) => {
|
|
96
98
|
return {
|
|
@@ -107,19 +109,21 @@ async function formatAgentList({
|
|
|
107
109
|
id,
|
|
108
110
|
mastra,
|
|
109
111
|
agent,
|
|
110
|
-
|
|
112
|
+
requestContext
|
|
111
113
|
}) {
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
114
|
+
const description = agent.getDescription();
|
|
115
|
+
const instructions = await agent.getInstructions({ requestContext });
|
|
116
|
+
const tools = await agent.listTools({ requestContext });
|
|
117
|
+
const llm = await agent.getLLM({ requestContext });
|
|
118
|
+
const defaultGenerateOptionsLegacy = await agent.getDefaultGenerateOptionsLegacy({ requestContext });
|
|
119
|
+
const defaultStreamOptionsLegacy = await agent.getDefaultStreamOptionsLegacy({ requestContext });
|
|
120
|
+
const defaultOptions = await agent.getDefaultOptions({ requestContext });
|
|
117
121
|
const serializedAgentTools = await getSerializedAgentTools(tools);
|
|
118
122
|
let serializedAgentWorkflows = {};
|
|
119
|
-
if ("
|
|
123
|
+
if ("listWorkflows" in agent) {
|
|
120
124
|
const logger = mastra.getLogger();
|
|
121
125
|
try {
|
|
122
|
-
const workflows = await agent.
|
|
126
|
+
const workflows = await agent.listWorkflows({ requestContext });
|
|
123
127
|
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
124
128
|
return {
|
|
125
129
|
...acc,
|
|
@@ -132,13 +136,13 @@ async function formatAgentList({
|
|
|
132
136
|
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
|
-
const serializedAgentAgents = await getSerializedAgentDefinition({ agent,
|
|
136
|
-
const inputProcessors = await agent.
|
|
137
|
-
const outputProcessors = await agent.
|
|
139
|
+
const serializedAgentAgents = await getSerializedAgentDefinition({ agent, requestContext });
|
|
140
|
+
const inputProcessors = await agent.listInputProcessors(requestContext);
|
|
141
|
+
const outputProcessors = await agent.listOutputProcessors(requestContext);
|
|
138
142
|
const serializedInputProcessors = getSerializedProcessors(inputProcessors);
|
|
139
143
|
const serializedOutputProcessors = getSerializedProcessors(outputProcessors);
|
|
140
144
|
const model = llm?.getModel();
|
|
141
|
-
const models = await agent.getModelList(
|
|
145
|
+
const models = await agent.getModelList(requestContext);
|
|
142
146
|
const modelList = models?.map((md) => ({
|
|
143
147
|
...md,
|
|
144
148
|
model: {
|
|
@@ -148,8 +152,9 @@ async function formatAgentList({
|
|
|
148
152
|
}
|
|
149
153
|
}));
|
|
150
154
|
return {
|
|
151
|
-
id,
|
|
155
|
+
id: agent.id || id,
|
|
152
156
|
name: agent.name,
|
|
157
|
+
description,
|
|
153
158
|
instructions,
|
|
154
159
|
agents: serializedAgentAgents,
|
|
155
160
|
tools: serializedAgentTools,
|
|
@@ -159,26 +164,63 @@ async function formatAgentList({
|
|
|
159
164
|
provider: llm?.getProvider(),
|
|
160
165
|
modelId: llm?.getModelId(),
|
|
161
166
|
modelVersion: model?.specificationVersion,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
167
|
+
defaultOptions,
|
|
168
|
+
modelList,
|
|
169
|
+
defaultGenerateOptionsLegacy,
|
|
170
|
+
defaultStreamOptionsLegacy
|
|
165
171
|
};
|
|
166
172
|
}
|
|
167
|
-
async function
|
|
173
|
+
async function getAgentFromSystem({ mastra, agentId }) {
|
|
174
|
+
const logger = mastra.getLogger();
|
|
175
|
+
if (!agentId) {
|
|
176
|
+
throw new HTTPException(400, { message: "Agent ID is required" });
|
|
177
|
+
}
|
|
178
|
+
let agent;
|
|
179
|
+
try {
|
|
180
|
+
agent = mastra.getAgentById(agentId);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
logger.debug("Error getting agent from mastra, searching agents for agent", error);
|
|
183
|
+
}
|
|
184
|
+
if (!agent) {
|
|
185
|
+
logger.debug(`Agent ${agentId} not found, looking through sub-agents`);
|
|
186
|
+
const agents = mastra.listAgents();
|
|
187
|
+
if (Object.keys(agents || {}).length) {
|
|
188
|
+
for (const [_, ag] of Object.entries(agents)) {
|
|
189
|
+
try {
|
|
190
|
+
const subAgents = await ag.listAgents();
|
|
191
|
+
if (subAgents[agentId]) {
|
|
192
|
+
agent = subAgents[agentId];
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
} catch (error) {
|
|
196
|
+
logger.debug("Error getting agent from agent", error);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (!agent) {
|
|
202
|
+
throw new HTTPException(404, { message: `Agent with id ${agentId} not found` });
|
|
203
|
+
}
|
|
204
|
+
return agent;
|
|
205
|
+
}
|
|
206
|
+
async function listAgentsHandler({
|
|
168
207
|
mastra,
|
|
169
|
-
|
|
208
|
+
requestContext
|
|
170
209
|
}) {
|
|
171
210
|
try {
|
|
172
|
-
const agents = mastra.
|
|
211
|
+
const agents = mastra.listAgents();
|
|
173
212
|
const serializedAgentsMap = await Promise.all(
|
|
174
213
|
Object.entries(agents).map(async ([id, agent]) => {
|
|
175
|
-
return formatAgentList({ id, mastra, agent,
|
|
214
|
+
return formatAgentList({ id, mastra, agent, requestContext });
|
|
176
215
|
})
|
|
177
216
|
);
|
|
178
|
-
const serializedAgents = serializedAgentsMap.reduce(
|
|
179
|
-
acc
|
|
180
|
-
|
|
181
|
-
|
|
217
|
+
const serializedAgents = serializedAgentsMap.reduce(
|
|
218
|
+
(acc, { id, ...rest }) => {
|
|
219
|
+
acc[id] = { id, ...rest };
|
|
220
|
+
return acc;
|
|
221
|
+
},
|
|
222
|
+
{}
|
|
223
|
+
);
|
|
182
224
|
return serializedAgents;
|
|
183
225
|
} catch (error) {
|
|
184
226
|
return handleError(error, "Error getting agents");
|
|
@@ -187,16 +229,17 @@ async function getAgentsHandler({
|
|
|
187
229
|
async function formatAgent({
|
|
188
230
|
mastra,
|
|
189
231
|
agent,
|
|
190
|
-
|
|
232
|
+
requestContext,
|
|
191
233
|
isPlayground
|
|
192
234
|
}) {
|
|
193
|
-
const
|
|
235
|
+
const description = agent.getDescription();
|
|
236
|
+
const tools = await agent.listTools({ requestContext });
|
|
194
237
|
const serializedAgentTools = await getSerializedAgentTools(tools);
|
|
195
238
|
let serializedAgentWorkflows = {};
|
|
196
|
-
if ("
|
|
239
|
+
if ("listWorkflows" in agent) {
|
|
197
240
|
const logger = mastra.getLogger();
|
|
198
241
|
try {
|
|
199
|
-
const workflows = await agent.
|
|
242
|
+
const workflows = await agent.listWorkflows({ requestContext });
|
|
200
243
|
serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
|
|
201
244
|
return {
|
|
202
245
|
...acc,
|
|
@@ -221,9 +264,9 @@ async function formatAgent({
|
|
|
221
264
|
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
222
265
|
}
|
|
223
266
|
}
|
|
224
|
-
let
|
|
267
|
+
let proxyRequestContext = requestContext;
|
|
225
268
|
if (isPlayground) {
|
|
226
|
-
|
|
269
|
+
proxyRequestContext = new Proxy(requestContext, {
|
|
227
270
|
get(target, prop) {
|
|
228
271
|
if (prop === "get") {
|
|
229
272
|
return function(key) {
|
|
@@ -235,12 +278,15 @@ async function formatAgent({
|
|
|
235
278
|
}
|
|
236
279
|
});
|
|
237
280
|
}
|
|
238
|
-
const instructions = await agent.getInstructions({
|
|
239
|
-
const llm = await agent.getLLM({
|
|
240
|
-
const
|
|
241
|
-
|
|
281
|
+
const instructions = await agent.getInstructions({ requestContext: proxyRequestContext });
|
|
282
|
+
const llm = await agent.getLLM({ requestContext });
|
|
283
|
+
const defaultGenerateOptionsLegacy = await agent.getDefaultGenerateOptionsLegacy({
|
|
284
|
+
requestContext: proxyRequestContext
|
|
285
|
+
});
|
|
286
|
+
const defaultStreamOptionsLegacy = await agent.getDefaultStreamOptionsLegacy({ requestContext: proxyRequestContext });
|
|
287
|
+
const defaultOptions = await agent.getDefaultOptions({ requestContext: proxyRequestContext });
|
|
242
288
|
const model = llm?.getModel();
|
|
243
|
-
const models = await agent.getModelList(
|
|
289
|
+
const models = await agent.getModelList(requestContext);
|
|
244
290
|
const modelList = models?.map((md) => ({
|
|
245
291
|
...md,
|
|
246
292
|
model: {
|
|
@@ -249,13 +295,14 @@ async function formatAgent({
|
|
|
249
295
|
modelVersion: md.model.specificationVersion
|
|
250
296
|
}
|
|
251
297
|
}));
|
|
252
|
-
const serializedAgentAgents = await getSerializedAgentDefinition({ agent,
|
|
253
|
-
const inputProcessors = await agent.
|
|
254
|
-
const outputProcessors = await agent.
|
|
298
|
+
const serializedAgentAgents = await getSerializedAgentDefinition({ agent, requestContext: proxyRequestContext });
|
|
299
|
+
const inputProcessors = await agent.listInputProcessors(proxyRequestContext);
|
|
300
|
+
const outputProcessors = await agent.listOutputProcessors(proxyRequestContext);
|
|
255
301
|
const serializedInputProcessors = getSerializedProcessors(inputProcessors);
|
|
256
302
|
const serializedOutputProcessors = getSerializedProcessors(outputProcessors);
|
|
257
303
|
return {
|
|
258
304
|
name: agent.name,
|
|
305
|
+
description,
|
|
259
306
|
instructions,
|
|
260
307
|
tools: serializedAgentTools,
|
|
261
308
|
agents: serializedAgentAgents,
|
|
@@ -266,82 +313,39 @@ async function formatAgent({
|
|
|
266
313
|
modelId: llm?.getModelId(),
|
|
267
314
|
modelVersion: model?.specificationVersion,
|
|
268
315
|
modelList,
|
|
269
|
-
|
|
270
|
-
|
|
316
|
+
defaultOptions,
|
|
317
|
+
defaultGenerateOptionsLegacy,
|
|
318
|
+
defaultStreamOptionsLegacy
|
|
271
319
|
};
|
|
272
320
|
}
|
|
273
321
|
async function getAgentByIdHandler({
|
|
274
322
|
mastra,
|
|
275
|
-
|
|
323
|
+
requestContext,
|
|
276
324
|
agentId,
|
|
277
325
|
isPlayground = false
|
|
278
326
|
}) {
|
|
279
327
|
try {
|
|
280
|
-
const agent = mastra
|
|
281
|
-
|
|
282
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
283
|
-
}
|
|
284
|
-
return formatAgent({ mastra, agent, runtimeContext, isPlayground });
|
|
328
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
329
|
+
return formatAgent({ mastra, agent, requestContext, isPlayground });
|
|
285
330
|
} catch (error) {
|
|
286
331
|
return handleError(error, "Error getting agent");
|
|
287
332
|
}
|
|
288
333
|
}
|
|
289
|
-
async function getEvalsByAgentIdHandler({
|
|
290
|
-
mastra,
|
|
291
|
-
runtimeContext,
|
|
292
|
-
agentId
|
|
293
|
-
}) {
|
|
294
|
-
try {
|
|
295
|
-
const agent = mastra.getAgent(agentId);
|
|
296
|
-
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
|
|
297
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
298
|
-
return {
|
|
299
|
-
id: agentId,
|
|
300
|
-
name: agent.name,
|
|
301
|
-
instructions,
|
|
302
|
-
evals
|
|
303
|
-
};
|
|
304
|
-
} catch (error) {
|
|
305
|
-
return handleError(error, "Error getting test evals");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
async function getLiveEvalsByAgentIdHandler({
|
|
309
|
-
mastra,
|
|
310
|
-
runtimeContext,
|
|
311
|
-
agentId
|
|
312
|
-
}) {
|
|
313
|
-
try {
|
|
314
|
-
const agent = mastra.getAgent(agentId);
|
|
315
|
-
const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
|
|
316
|
-
const instructions = await agent.getInstructions({ runtimeContext });
|
|
317
|
-
return {
|
|
318
|
-
id: agentId,
|
|
319
|
-
name: agent.name,
|
|
320
|
-
instructions,
|
|
321
|
-
evals
|
|
322
|
-
};
|
|
323
|
-
} catch (error) {
|
|
324
|
-
return handleError(error, "Error getting live evals");
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
334
|
async function generateLegacyHandler({
|
|
328
335
|
mastra,
|
|
329
|
-
|
|
336
|
+
requestContext,
|
|
330
337
|
agentId,
|
|
331
338
|
body,
|
|
332
339
|
abortSignal
|
|
333
340
|
}) {
|
|
334
341
|
try {
|
|
335
|
-
const agent = mastra
|
|
336
|
-
if (!agent) {
|
|
337
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
338
|
-
}
|
|
342
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
339
343
|
sanitizeBody(body, ["tools"]);
|
|
340
|
-
const { messages, resourceId, resourceid,
|
|
344
|
+
const { messages, resourceId, resourceid, requestContext: agentRequestContext, ...rest } = body;
|
|
341
345
|
const finalResourceId = resourceId ?? resourceid;
|
|
342
|
-
const
|
|
343
|
-
...Array.from(
|
|
344
|
-
...Array.from(Object.entries(
|
|
346
|
+
const finalRequestContext = new RequestContext([
|
|
347
|
+
...Array.from(requestContext.entries()),
|
|
348
|
+
...Array.from(Object.entries(agentRequestContext ?? {}))
|
|
345
349
|
]);
|
|
346
350
|
validateBody({ messages });
|
|
347
351
|
const result = await agent.generateLegacy(messages, {
|
|
@@ -349,7 +353,7 @@ async function generateLegacyHandler({
|
|
|
349
353
|
abortSignal,
|
|
350
354
|
// @ts-expect-error TODO fix types
|
|
351
355
|
resourceId: finalResourceId,
|
|
352
|
-
|
|
356
|
+
requestContext: finalRequestContext
|
|
353
357
|
});
|
|
354
358
|
return result;
|
|
355
359
|
} catch (error) {
|
|
@@ -358,27 +362,23 @@ async function generateLegacyHandler({
|
|
|
358
362
|
}
|
|
359
363
|
async function generateHandler({
|
|
360
364
|
mastra,
|
|
361
|
-
|
|
365
|
+
requestContext,
|
|
362
366
|
agentId,
|
|
363
367
|
body,
|
|
364
368
|
abortSignal
|
|
365
369
|
}) {
|
|
366
370
|
try {
|
|
367
|
-
const agent = mastra
|
|
368
|
-
if (!agent) {
|
|
369
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
370
|
-
}
|
|
371
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
371
372
|
sanitizeBody(body, ["tools"]);
|
|
372
|
-
const { messages,
|
|
373
|
-
const
|
|
374
|
-
...Array.from(
|
|
375
|
-
...Array.from(Object.entries(
|
|
373
|
+
const { messages, requestContext: agentRequestContext, ...rest } = body;
|
|
374
|
+
const finalRequestContext = new RequestContext([
|
|
375
|
+
...Array.from(requestContext.entries()),
|
|
376
|
+
...Array.from(Object.entries(agentRequestContext ?? {}))
|
|
376
377
|
]);
|
|
377
378
|
validateBody({ messages });
|
|
378
379
|
const result = await agent.generate(messages, {
|
|
379
380
|
...rest,
|
|
380
|
-
|
|
381
|
-
format: rest.format || "mastra",
|
|
381
|
+
requestContext: finalRequestContext,
|
|
382
382
|
abortSignal
|
|
383
383
|
});
|
|
384
384
|
return result;
|
|
@@ -388,21 +388,18 @@ async function generateHandler({
|
|
|
388
388
|
}
|
|
389
389
|
async function streamGenerateLegacyHandler({
|
|
390
390
|
mastra,
|
|
391
|
-
|
|
391
|
+
requestContext,
|
|
392
392
|
agentId,
|
|
393
393
|
body,
|
|
394
394
|
abortSignal
|
|
395
395
|
}) {
|
|
396
396
|
try {
|
|
397
|
-
const agent = mastra
|
|
398
|
-
|
|
399
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
400
|
-
}
|
|
401
|
-
const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
397
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
398
|
+
const { messages, resourceId, resourceid, requestContext: agentRequestContext, ...rest } = body;
|
|
402
399
|
const finalResourceId = resourceId ?? resourceid;
|
|
403
|
-
const
|
|
404
|
-
...Array.from(
|
|
405
|
-
...Array.from(Object.entries(
|
|
400
|
+
const finalRequestContext = new RequestContext([
|
|
401
|
+
...Array.from(requestContext.entries()),
|
|
402
|
+
...Array.from(Object.entries(agentRequestContext ?? {}))
|
|
406
403
|
]);
|
|
407
404
|
validateBody({ messages });
|
|
408
405
|
const streamResult = await agent.streamLegacy(messages, {
|
|
@@ -410,7 +407,7 @@ async function streamGenerateLegacyHandler({
|
|
|
410
407
|
abortSignal,
|
|
411
408
|
// @ts-expect-error TODO fix types
|
|
412
409
|
resourceId: finalResourceId,
|
|
413
|
-
|
|
410
|
+
requestContext: finalRequestContext
|
|
414
411
|
});
|
|
415
412
|
const streamResponse = rest.output ? streamResult.toTextStreamResponse({
|
|
416
413
|
headers: {
|
|
@@ -431,113 +428,110 @@ async function streamGenerateLegacyHandler({
|
|
|
431
428
|
return handleError(error, "error streaming agent response");
|
|
432
429
|
}
|
|
433
430
|
}
|
|
434
|
-
function streamGenerateHandler({
|
|
431
|
+
async function streamGenerateHandler({
|
|
435
432
|
mastra,
|
|
436
|
-
|
|
433
|
+
requestContext,
|
|
437
434
|
agentId,
|
|
438
435
|
body,
|
|
439
436
|
abortSignal
|
|
440
437
|
}) {
|
|
441
438
|
try {
|
|
442
|
-
const agent = mastra
|
|
443
|
-
if (!agent) {
|
|
444
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
445
|
-
}
|
|
439
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
446
440
|
sanitizeBody(body, ["tools"]);
|
|
447
|
-
const { messages,
|
|
448
|
-
const
|
|
449
|
-
...Array.from(
|
|
450
|
-
...Array.from(Object.entries(
|
|
441
|
+
const { messages, requestContext: agentRequestContext, ...rest } = body;
|
|
442
|
+
const finalRequestContext = new RequestContext([
|
|
443
|
+
...Array.from(requestContext.entries()),
|
|
444
|
+
...Array.from(Object.entries(agentRequestContext ?? {}))
|
|
451
445
|
]);
|
|
452
446
|
validateBody({ messages });
|
|
453
447
|
const streamResult = agent.stream(messages, {
|
|
454
448
|
...rest,
|
|
455
|
-
|
|
456
|
-
abortSignal
|
|
457
|
-
format: body.format ?? "mastra"
|
|
449
|
+
requestContext: finalRequestContext,
|
|
450
|
+
abortSignal
|
|
458
451
|
});
|
|
459
452
|
return streamResult;
|
|
460
453
|
} catch (error) {
|
|
461
454
|
return handleError(error, "error streaming agent response");
|
|
462
455
|
}
|
|
463
456
|
}
|
|
464
|
-
function approveToolCallHandler({
|
|
457
|
+
async function approveToolCallHandler({
|
|
465
458
|
mastra,
|
|
466
|
-
|
|
459
|
+
requestContext,
|
|
467
460
|
agentId,
|
|
468
461
|
body,
|
|
469
462
|
abortSignal
|
|
470
463
|
}) {
|
|
471
464
|
try {
|
|
472
|
-
const agent = mastra
|
|
473
|
-
if (!
|
|
474
|
-
throw new HTTPException(
|
|
465
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
466
|
+
if (!body.runId) {
|
|
467
|
+
throw new HTTPException(400, { message: "Run id is required" });
|
|
468
|
+
}
|
|
469
|
+
if (!body.toolCallId) {
|
|
470
|
+
throw new HTTPException(400, { message: "Tool call id is required" });
|
|
475
471
|
}
|
|
476
472
|
sanitizeBody(body, ["tools"]);
|
|
477
|
-
const { runId,
|
|
478
|
-
const
|
|
479
|
-
...Array.from(
|
|
480
|
-
...Array.from(Object.entries(
|
|
473
|
+
const { runId, requestContext: agentRequestContext, ...rest } = body;
|
|
474
|
+
const finalRequestContext = new RequestContext([
|
|
475
|
+
...Array.from(requestContext.entries()),
|
|
476
|
+
...Array.from(Object.entries(agentRequestContext ?? {}))
|
|
481
477
|
]);
|
|
482
478
|
const streamResult = agent.approveToolCall({
|
|
483
479
|
...rest,
|
|
484
480
|
runId,
|
|
485
|
-
|
|
486
|
-
abortSignal
|
|
487
|
-
format: body.format ?? "mastra"
|
|
481
|
+
requestContext: finalRequestContext,
|
|
482
|
+
abortSignal
|
|
488
483
|
});
|
|
489
484
|
return streamResult;
|
|
490
485
|
} catch (error) {
|
|
491
486
|
return handleError(error, "error streaming agent response");
|
|
492
487
|
}
|
|
493
488
|
}
|
|
494
|
-
function declineToolCallHandler({
|
|
489
|
+
async function declineToolCallHandler({
|
|
495
490
|
mastra,
|
|
496
|
-
|
|
491
|
+
requestContext,
|
|
497
492
|
agentId,
|
|
498
493
|
body,
|
|
499
494
|
abortSignal
|
|
500
495
|
}) {
|
|
501
496
|
try {
|
|
502
|
-
const agent = mastra
|
|
503
|
-
if (!
|
|
504
|
-
throw new HTTPException(
|
|
497
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
498
|
+
if (!body.runId) {
|
|
499
|
+
throw new HTTPException(400, { message: "Run id is required" });
|
|
500
|
+
}
|
|
501
|
+
if (!body.toolCallId) {
|
|
502
|
+
throw new HTTPException(400, { message: "Tool call id is required" });
|
|
505
503
|
}
|
|
506
504
|
sanitizeBody(body, ["tools"]);
|
|
507
|
-
const { runId,
|
|
508
|
-
const
|
|
509
|
-
...Array.from(
|
|
510
|
-
...Array.from(Object.entries(
|
|
505
|
+
const { runId, requestContext: agentRequestContext, ...rest } = body;
|
|
506
|
+
const finalRequestContext = new RequestContext([
|
|
507
|
+
...Array.from(requestContext.entries()),
|
|
508
|
+
...Array.from(Object.entries(agentRequestContext ?? {}))
|
|
511
509
|
]);
|
|
512
510
|
const streamResult = agent.declineToolCall({
|
|
513
511
|
...rest,
|
|
514
512
|
runId,
|
|
515
|
-
|
|
516
|
-
abortSignal
|
|
517
|
-
format: body.format ?? "mastra"
|
|
513
|
+
requestContext: finalRequestContext,
|
|
514
|
+
abortSignal
|
|
518
515
|
});
|
|
519
516
|
return streamResult;
|
|
520
517
|
} catch (error) {
|
|
521
518
|
return handleError(error, "error streaming agent response");
|
|
522
519
|
}
|
|
523
520
|
}
|
|
524
|
-
function streamNetworkHandler({
|
|
521
|
+
async function streamNetworkHandler({
|
|
525
522
|
mastra,
|
|
526
|
-
|
|
523
|
+
requestContext,
|
|
527
524
|
agentId,
|
|
528
525
|
body
|
|
529
526
|
// abortSignal,
|
|
530
527
|
}) {
|
|
531
528
|
try {
|
|
532
|
-
const agent = mastra
|
|
533
|
-
if (!agent) {
|
|
534
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
535
|
-
}
|
|
529
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
536
530
|
sanitizeBody(body, ["tools"]);
|
|
537
|
-
const { messages,
|
|
538
|
-
const
|
|
539
|
-
...Array.from(
|
|
540
|
-
...Array.from(Object.entries(
|
|
531
|
+
const { messages, requestContext: agentRequestContext, ...rest } = body;
|
|
532
|
+
const finalRequestContext = new RequestContext([
|
|
533
|
+
...Array.from(requestContext.entries()),
|
|
534
|
+
...Array.from(Object.entries(agentRequestContext ?? {}))
|
|
541
535
|
]);
|
|
542
536
|
validateBody({ messages });
|
|
543
537
|
const streamResult = agent.network(messages, {
|
|
@@ -547,39 +541,21 @@ function streamNetworkHandler({
|
|
|
547
541
|
resource: rest.resourceId ?? "",
|
|
548
542
|
options: rest.memory?.options ?? {}
|
|
549
543
|
},
|
|
550
|
-
|
|
544
|
+
requestContext: finalRequestContext
|
|
551
545
|
});
|
|
552
546
|
return streamResult;
|
|
553
547
|
} catch (error) {
|
|
554
548
|
return handleError(error, "error streaming agent loop response");
|
|
555
549
|
}
|
|
556
550
|
}
|
|
557
|
-
async function streamUIMessageHandler({
|
|
558
|
-
mastra,
|
|
559
|
-
runtimeContext,
|
|
560
|
-
agentId,
|
|
561
|
-
body,
|
|
562
|
-
abortSignal
|
|
563
|
-
}) {
|
|
551
|
+
async function streamUIMessageHandler(_params) {
|
|
564
552
|
try {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
|
|
571
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
572
|
-
...Array.from(runtimeContext.entries()),
|
|
573
|
-
...Array.from(Object.entries(agentRuntimeContext ?? {}))
|
|
574
|
-
]);
|
|
575
|
-
validateBody({ messages });
|
|
576
|
-
const streamResult = await agent.stream(messages, {
|
|
577
|
-
...rest,
|
|
578
|
-
runtimeContext: finalRuntimeContext,
|
|
579
|
-
abortSignal,
|
|
580
|
-
format: "aisdk"
|
|
553
|
+
throw new MastraError({
|
|
554
|
+
category: ErrorCategory.USER,
|
|
555
|
+
domain: ErrorDomain.MASTRA_SERVER,
|
|
556
|
+
id: "DEPRECATED_ENDPOINT",
|
|
557
|
+
text: "This endpoint is deprecated. Please use the @mastra/ai-sdk package to for uiMessage transformations"
|
|
581
558
|
});
|
|
582
|
-
return streamResult.toUIMessageStreamResponse();
|
|
583
559
|
} catch (error) {
|
|
584
560
|
return handleError(error, "error streaming agent response");
|
|
585
561
|
}
|
|
@@ -590,10 +566,7 @@ async function updateAgentModelHandler({
|
|
|
590
566
|
body
|
|
591
567
|
}) {
|
|
592
568
|
try {
|
|
593
|
-
const agent = mastra
|
|
594
|
-
if (!agent) {
|
|
595
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
596
|
-
}
|
|
569
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
597
570
|
const { modelId, provider } = body;
|
|
598
571
|
const newModel = `${provider}/${modelId}`;
|
|
599
572
|
agent.__updateModel({ model: newModel });
|
|
@@ -602,16 +575,25 @@ async function updateAgentModelHandler({
|
|
|
602
575
|
return handleError(error, "error updating agent model");
|
|
603
576
|
}
|
|
604
577
|
}
|
|
578
|
+
async function resetAgentModelHandler({
|
|
579
|
+
mastra,
|
|
580
|
+
agentId
|
|
581
|
+
}) {
|
|
582
|
+
try {
|
|
583
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
584
|
+
agent.__resetToOriginalModel();
|
|
585
|
+
return { message: "Agent model reset to original" };
|
|
586
|
+
} catch (error) {
|
|
587
|
+
return handleError(error, "error resetting agent model");
|
|
588
|
+
}
|
|
589
|
+
}
|
|
605
590
|
async function reorderAgentModelListHandler({
|
|
606
591
|
mastra,
|
|
607
592
|
agentId,
|
|
608
593
|
body
|
|
609
594
|
}) {
|
|
610
595
|
try {
|
|
611
|
-
const agent = mastra
|
|
612
|
-
if (!agent) {
|
|
613
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
614
|
-
}
|
|
596
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
615
597
|
const modelList = await agent.getModelList();
|
|
616
598
|
if (!modelList || modelList.length === 0) {
|
|
617
599
|
throw new HTTPException(400, { message: "Agent model list is not found or empty" });
|
|
@@ -629,10 +611,7 @@ async function updateAgentModelInModelListHandler({
|
|
|
629
611
|
body
|
|
630
612
|
}) {
|
|
631
613
|
try {
|
|
632
|
-
const agent = mastra
|
|
633
|
-
if (!agent) {
|
|
634
|
-
throw new HTTPException(404, { message: "Agent not found" });
|
|
635
|
-
}
|
|
614
|
+
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
636
615
|
const { model: bodyModel, maxRetries, enabled } = body;
|
|
637
616
|
if (!modelConfigId) {
|
|
638
617
|
throw new HTTPException(400, { message: "Model id is required" });
|
|
@@ -677,6 +656,6 @@ async function getProvidersHandler() {
|
|
|
677
656
|
}
|
|
678
657
|
}
|
|
679
658
|
|
|
680
|
-
export { agents_exports, approveToolCallHandler, declineToolCallHandler, generateHandler, generateLegacyHandler, getAgentByIdHandler,
|
|
681
|
-
//# sourceMappingURL=chunk-
|
|
682
|
-
//# sourceMappingURL=chunk-
|
|
659
|
+
export { agents_exports, approveToolCallHandler, declineToolCallHandler, generateHandler, generateLegacyHandler, getAgentByIdHandler, getAgentFromSystem, getProvidersHandler, getSerializedAgentTools, getSerializedProcessors, listAgentsHandler, reorderAgentModelListHandler, resetAgentModelHandler, streamGenerateHandler, streamGenerateLegacyHandler, streamNetworkHandler, streamUIMessageHandler, updateAgentModelHandler, updateAgentModelInModelListHandler };
|
|
660
|
+
//# sourceMappingURL=chunk-Z2O5YVHY.js.map
|
|
661
|
+
//# sourceMappingURL=chunk-Z2O5YVHY.js.map
|