@mastra/server 0.0.0-playground-studio-cloud-20251031080052 → 0.0.0-playground-studio-again-20251114102707

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +685 -3
  2. package/README.md +1 -1
  3. package/dist/{chunk-7HCPO76Z.js → chunk-2IS5WICF.js} +4505 -1017
  4. package/dist/chunk-2IS5WICF.js.map +1 -0
  5. package/dist/{chunk-SPRRK3P7.cjs → chunk-2YZH5PH6.cjs} +47 -47
  6. package/dist/chunk-2YZH5PH6.cjs.map +1 -0
  7. package/dist/{chunk-BATEJLED.js → chunk-3AMNUUZF.js} +20 -20
  8. package/dist/chunk-3AMNUUZF.js.map +1 -0
  9. package/dist/{chunk-AW5BU3RQ.js → chunk-3F52QCI4.js} +40 -40
  10. package/dist/chunk-3F52QCI4.js.map +1 -0
  11. package/dist/{chunk-7NADHFD2.cjs → chunk-64ITUOXI.cjs} +2 -2
  12. package/dist/chunk-64ITUOXI.cjs.map +1 -0
  13. package/dist/{chunk-MMROOK5J.js → chunk-6QWQZI4Q.js} +2 -2
  14. package/dist/{chunk-7NADHFD2.cjs.map → chunk-6QWQZI4Q.js.map} +1 -1
  15. package/dist/{chunk-ABRFV4XP.js → chunk-73PAWDM5.js} +13 -13
  16. package/dist/chunk-73PAWDM5.js.map +1 -0
  17. package/dist/{chunk-2S4IMB6E.cjs → chunk-A24TSVEZ.cjs} +39 -39
  18. package/dist/chunk-A24TSVEZ.cjs.map +1 -0
  19. package/dist/{chunk-QQXMIP6C.js → chunk-B3Z6J745.js} +17 -17
  20. package/dist/chunk-B3Z6J745.js.map +1 -0
  21. package/dist/{chunk-G4PUALCE.cjs → chunk-BTWIR2B7.cjs} +4 -4
  22. package/dist/{chunk-G4PUALCE.cjs.map → chunk-BTWIR2B7.cjs.map} +1 -1
  23. package/dist/{chunk-KSFLUEWV.js → chunk-D7T74TVR.js} +4 -5
  24. package/dist/chunk-D7T74TVR.js.map +1 -0
  25. package/dist/{chunk-YSHNCC6F.cjs → chunk-EHACNWDL.cjs} +169 -201
  26. package/dist/chunk-EHACNWDL.cjs.map +1 -0
  27. package/dist/{chunk-MN2TZQ7I.js → chunk-FPBYKMIS.js} +13 -13
  28. package/dist/chunk-FPBYKMIS.js.map +1 -0
  29. package/dist/{chunk-3SNGNFUJ.cjs → chunk-GLAZTMX3.cjs} +37 -37
  30. package/dist/chunk-GLAZTMX3.cjs.map +1 -0
  31. package/dist/{chunk-KDUHLUK4.cjs → chunk-ID6JYDNL.cjs} +4387 -896
  32. package/dist/chunk-ID6JYDNL.cjs.map +1 -0
  33. package/dist/{chunk-TRGAMKHX.cjs → chunk-KF3RI45U.cjs} +46 -41
  34. package/dist/chunk-KF3RI45U.cjs.map +1 -0
  35. package/dist/{chunk-K5T5A3AL.cjs → chunk-KJIDZQRA.cjs} +14 -14
  36. package/dist/chunk-KJIDZQRA.cjs.map +1 -0
  37. package/dist/{chunk-MYR4PVGN.js → chunk-KWH5QBXP.js} +4 -4
  38. package/dist/{chunk-MYR4PVGN.js.map → chunk-KWH5QBXP.js.map} +1 -1
  39. package/dist/{chunk-AHB4JCIQ.js → chunk-ND5OKOMT.js} +31 -26
  40. package/dist/chunk-ND5OKOMT.js.map +1 -0
  41. package/dist/{chunk-XN74I6VW.cjs → chunk-PPMIB3FQ.cjs} +20 -20
  42. package/dist/chunk-PPMIB3FQ.cjs.map +1 -0
  43. package/dist/{chunk-EP3JQDPD.cjs → chunk-S54HNARD.cjs} +18 -18
  44. package/dist/{chunk-EP3JQDPD.cjs.map → chunk-S54HNARD.cjs.map} +1 -1
  45. package/dist/{chunk-4QCXUEAT.js → chunk-SZIFSF4T.js} +3 -3
  46. package/dist/{chunk-4QCXUEAT.js.map → chunk-SZIFSF4T.js.map} +1 -1
  47. package/dist/{chunk-Y7SH5ZKM.cjs → chunk-U7GLIXYO.cjs} +157 -172
  48. package/dist/chunk-U7GLIXYO.cjs.map +1 -0
  49. package/dist/{chunk-CY4TP3FK.js → chunk-UXGQZUYZ.js} +3 -3
  50. package/dist/{chunk-CY4TP3FK.js.map → chunk-UXGQZUYZ.js.map} +1 -1
  51. package/dist/{chunk-RE4RPXT2.cjs → chunk-V5WWQN7P.cjs} +4 -4
  52. package/dist/{chunk-RE4RPXT2.cjs.map → chunk-V5WWQN7P.cjs.map} +1 -1
  53. package/dist/{chunk-OGK26QPW.js → chunk-V6JYJS7O.js} +109 -123
  54. package/dist/chunk-V6JYJS7O.js.map +1 -0
  55. package/dist/{chunk-CJFKRVED.cjs → chunk-W2KMU354.cjs} +4 -5
  56. package/dist/chunk-W2KMU354.cjs.map +1 -0
  57. package/dist/{chunk-B7QWVGQQ.cjs → chunk-X3MICMI2.cjs} +140 -249
  58. package/dist/chunk-X3MICMI2.cjs.map +1 -0
  59. package/dist/{chunk-6VPAV4ZV.js → chunk-Z2O5YVHY.js} +134 -165
  60. package/dist/chunk-Z2O5YVHY.js.map +1 -0
  61. package/dist/{chunk-ZLBL4NQC.js → chunk-ZJ6KEY6H.js} +67 -174
  62. package/dist/chunk-ZJ6KEY6H.js.map +1 -0
  63. package/dist/server/handlers/a2a.cjs +7 -7
  64. package/dist/server/handlers/a2a.d.ts +10 -10
  65. package/dist/server/handlers/a2a.d.ts.map +1 -1
  66. package/dist/server/handlers/a2a.js +1 -1
  67. package/dist/server/handlers/agent-builder.cjs +31 -19
  68. package/dist/server/handlers/agent-builder.d.ts +38 -47
  69. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  70. package/dist/server/handlers/agent-builder.js +1 -1
  71. package/dist/server/handlers/agents.cjs +25 -29
  72. package/dist/server/handlers/agents.d.ts +41 -55
  73. package/dist/server/handlers/agents.d.ts.map +1 -1
  74. package/dist/server/handlers/agents.js +1 -1
  75. package/dist/server/handlers/error.cjs +2 -2
  76. package/dist/server/handlers/error.js +1 -1
  77. package/dist/server/handlers/logs.cjs +7 -7
  78. package/dist/server/handlers/logs.d.ts +3 -3
  79. package/dist/server/handlers/logs.d.ts.map +1 -1
  80. package/dist/server/handlers/logs.js +1 -1
  81. package/dist/server/handlers/memory.cjs +19 -23
  82. package/dist/server/handlers/memory.d.ts +30 -35
  83. package/dist/server/handlers/memory.d.ts.map +1 -1
  84. package/dist/server/handlers/memory.js +1 -1
  85. package/dist/server/handlers/observability.cjs +8 -8
  86. package/dist/server/handlers/observability.d.ts +12 -12
  87. package/dist/server/handlers/observability.d.ts.map +1 -1
  88. package/dist/server/handlers/observability.js +1 -1
  89. package/dist/server/handlers/scores.cjs +11 -11
  90. package/dist/server/handlers/scores.d.ts +24 -24
  91. package/dist/server/handlers/scores.d.ts.map +1 -1
  92. package/dist/server/handlers/scores.js +1 -1
  93. package/dist/server/handlers/tools.cjs +7 -7
  94. package/dist/server/handlers/tools.d.ts +8 -8
  95. package/dist/server/handlers/tools.d.ts.map +1 -1
  96. package/dist/server/handlers/tools.js +1 -1
  97. package/dist/server/handlers/utils.cjs +3 -3
  98. package/dist/server/handlers/utils.js +1 -1
  99. package/dist/server/handlers/vector.cjs +7 -7
  100. package/dist/server/handlers/vector.js +1 -1
  101. package/dist/server/handlers/voice.cjs +5 -5
  102. package/dist/server/handlers/voice.d.ts +6 -6
  103. package/dist/server/handlers/voice.js +1 -1
  104. package/dist/server/handlers/workflows.cjs +21 -29
  105. package/dist/server/handlers/workflows.d.ts +27 -36
  106. package/dist/server/handlers/workflows.d.ts.map +1 -1
  107. package/dist/server/handlers/workflows.js +1 -1
  108. package/dist/server/handlers.cjs +23 -28
  109. package/dist/server/handlers.d.ts +0 -1
  110. package/dist/server/handlers.d.ts.map +1 -1
  111. package/dist/server/handlers.js +11 -12
  112. package/dist/server/http-exception.d.ts +0 -5
  113. package/dist/server/http-exception.d.ts.map +1 -1
  114. package/dist/server/utils.d.ts +3 -2
  115. package/dist/server/utils.d.ts.map +1 -1
  116. package/package.json +13 -8
  117. package/dist/chunk-2S4IMB6E.cjs.map +0 -1
  118. package/dist/chunk-3SNGNFUJ.cjs.map +0 -1
  119. package/dist/chunk-6VPAV4ZV.js.map +0 -1
  120. package/dist/chunk-7HCPO76Z.js.map +0 -1
  121. package/dist/chunk-ABRFV4XP.js.map +0 -1
  122. package/dist/chunk-AHB4JCIQ.js.map +0 -1
  123. package/dist/chunk-AW5BU3RQ.js.map +0 -1
  124. package/dist/chunk-B7QWVGQQ.cjs.map +0 -1
  125. package/dist/chunk-BATEJLED.js.map +0 -1
  126. package/dist/chunk-CJFKRVED.cjs.map +0 -1
  127. package/dist/chunk-I3C4ODGV.cjs +0 -335
  128. package/dist/chunk-I3C4ODGV.cjs.map +0 -1
  129. package/dist/chunk-K5T5A3AL.cjs.map +0 -1
  130. package/dist/chunk-KDUHLUK4.cjs.map +0 -1
  131. package/dist/chunk-KSFLUEWV.js.map +0 -1
  132. package/dist/chunk-LLUOPR3J.js +0 -323
  133. package/dist/chunk-LLUOPR3J.js.map +0 -1
  134. package/dist/chunk-MMROOK5J.js.map +0 -1
  135. package/dist/chunk-MN2TZQ7I.js.map +0 -1
  136. package/dist/chunk-OGK26QPW.js.map +0 -1
  137. package/dist/chunk-QQXMIP6C.js.map +0 -1
  138. package/dist/chunk-SPRRK3P7.cjs.map +0 -1
  139. package/dist/chunk-TRGAMKHX.cjs.map +0 -1
  140. package/dist/chunk-XN74I6VW.cjs.map +0 -1
  141. package/dist/chunk-Y7SH5ZKM.cjs.map +0 -1
  142. package/dist/chunk-YSHNCC6F.cjs.map +0 -1
  143. package/dist/chunk-ZLBL4NQC.js.map +0 -1
  144. package/dist/server/handlers/legacyWorkflows.cjs +0 -48
  145. package/dist/server/handlers/legacyWorkflows.cjs.map +0 -1
  146. package/dist/server/handlers/legacyWorkflows.d.ts +0 -59
  147. package/dist/server/handlers/legacyWorkflows.d.ts.map +0 -1
  148. package/dist/server/handlers/legacyWorkflows.js +0 -3
  149. package/dist/server/handlers/legacyWorkflows.js.map +0 -1
@@ -1,10 +1,11 @@
1
- import { sanitizeBody, validateBody } from './chunk-4QCXUEAT.js';
2
1
  import { stringify } from './chunk-LF2ZLOFP.js';
3
- import { handleError } from './chunk-CY4TP3FK.js';
4
- import { HTTPException } from './chunk-MMROOK5J.js';
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 { RuntimeContext } from '@mastra/core/runtime-context';
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
@@ -16,13 +17,12 @@ __export(agents_exports, {
16
17
  generateLegacyHandler: () => generateLegacyHandler,
17
18
  getAgentByIdHandler: () => getAgentByIdHandler,
18
19
  getAgentFromSystem: () => getAgentFromSystem,
19
- getAgentsHandler: () => getAgentsHandler,
20
- getEvalsByAgentIdHandler: () => getEvalsByAgentIdHandler,
21
- getLiveEvalsByAgentIdHandler: () => getLiveEvalsByAgentIdHandler,
22
20
  getProvidersHandler: () => getProvidersHandler,
23
21
  getSerializedAgentTools: () => getSerializedAgentTools,
24
22
  getSerializedProcessors: () => getSerializedProcessors,
23
+ listAgentsHandler: () => listAgentsHandler,
25
24
  reorderAgentModelListHandler: () => reorderAgentModelListHandler,
25
+ resetAgentModelHandler: () => resetAgentModelHandler,
26
26
  streamGenerateHandler: () => streamGenerateHandler,
27
27
  streamGenerateLegacyHandler: () => streamGenerateLegacyHandler,
28
28
  streamNetworkHandler: () => streamNetworkHandler,
@@ -81,17 +81,18 @@ async function getSerializedAgentTools(tools) {
81
81
  function getSerializedProcessors(processors) {
82
82
  return processors.map((processor) => {
83
83
  return {
84
+ id: processor.id,
84
85
  name: processor.name || processor.constructor.name
85
86
  };
86
87
  });
87
88
  }
88
89
  async function getSerializedAgentDefinition({
89
90
  agent,
90
- runtimeContext
91
+ requestContext
91
92
  }) {
92
93
  let serializedAgentAgents = {};
93
94
  if ("listAgents" in agent) {
94
- const agents = await agent.listAgents({ runtimeContext });
95
+ const agents = await agent.listAgents({ requestContext });
95
96
  serializedAgentAgents = Object.entries(agents || {}).reduce(
96
97
  (acc, [key, agent2]) => {
97
98
  return {
@@ -108,19 +109,21 @@ async function formatAgentList({
108
109
  id,
109
110
  mastra,
110
111
  agent,
111
- runtimeContext
112
+ requestContext
112
113
  }) {
113
- const instructions = await agent.getInstructions({ runtimeContext });
114
- const tools = await agent.getTools({ runtimeContext });
115
- const llm = await agent.getLLM({ runtimeContext });
116
- const defaultGenerateOptions = await agent.getDefaultGenerateOptionsLegacy({ runtimeContext });
117
- const defaultStreamOptions = await agent.getDefaultStreamOptionsLegacy({ runtimeContext });
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 });
118
121
  const serializedAgentTools = await getSerializedAgentTools(tools);
119
122
  let serializedAgentWorkflows = {};
120
- if ("getWorkflows" in agent) {
123
+ if ("listWorkflows" in agent) {
121
124
  const logger = mastra.getLogger();
122
125
  try {
123
- const workflows = await agent.getWorkflows({ runtimeContext });
126
+ const workflows = await agent.listWorkflows({ requestContext });
124
127
  serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
125
128
  return {
126
129
  ...acc,
@@ -133,13 +136,13 @@ async function formatAgentList({
133
136
  logger.error("Error getting workflows for agent", { agentName: agent.name, error });
134
137
  }
135
138
  }
136
- const serializedAgentAgents = await getSerializedAgentDefinition({ agent, runtimeContext });
137
- const inputProcessors = await agent.getInputProcessors(runtimeContext);
138
- const outputProcessors = await agent.getOutputProcessors(runtimeContext);
139
+ const serializedAgentAgents = await getSerializedAgentDefinition({ agent, requestContext });
140
+ const inputProcessors = await agent.listInputProcessors(requestContext);
141
+ const outputProcessors = await agent.listOutputProcessors(requestContext);
139
142
  const serializedInputProcessors = getSerializedProcessors(inputProcessors);
140
143
  const serializedOutputProcessors = getSerializedProcessors(outputProcessors);
141
144
  const model = llm?.getModel();
142
- const models = await agent.getModelList(runtimeContext);
145
+ const models = await agent.getModelList(requestContext);
143
146
  const modelList = models?.map((md) => ({
144
147
  ...md,
145
148
  model: {
@@ -149,8 +152,9 @@ async function formatAgentList({
149
152
  }
150
153
  }));
151
154
  return {
152
- id,
155
+ id: agent.id || id,
153
156
  name: agent.name,
157
+ description,
154
158
  instructions,
155
159
  agents: serializedAgentAgents,
156
160
  tools: serializedAgentTools,
@@ -160,9 +164,10 @@ async function formatAgentList({
160
164
  provider: llm?.getProvider(),
161
165
  modelId: llm?.getModelId(),
162
166
  modelVersion: model?.specificationVersion,
163
- defaultGenerateOptions,
164
- defaultStreamOptions,
165
- modelList
167
+ defaultOptions,
168
+ modelList,
169
+ defaultGenerateOptionsLegacy,
170
+ defaultStreamOptionsLegacy
166
171
  };
167
172
  }
168
173
  async function getAgentFromSystem({ mastra, agentId }) {
@@ -172,13 +177,13 @@ async function getAgentFromSystem({ mastra, agentId }) {
172
177
  }
173
178
  let agent;
174
179
  try {
175
- agent = mastra.getAgent(agentId);
180
+ agent = mastra.getAgentById(agentId);
176
181
  } catch (error) {
177
182
  logger.debug("Error getting agent from mastra, searching agents for agent", error);
178
183
  }
179
184
  if (!agent) {
180
185
  logger.debug(`Agent ${agentId} not found, looking through sub-agents`);
181
- const agents = mastra.getAgents();
186
+ const agents = mastra.listAgents();
182
187
  if (Object.keys(agents || {}).length) {
183
188
  for (const [_, ag] of Object.entries(agents)) {
184
189
  try {
@@ -194,25 +199,28 @@ async function getAgentFromSystem({ mastra, agentId }) {
194
199
  }
195
200
  }
196
201
  if (!agent) {
197
- throw new HTTPException(404, { message: `Agent with name ${agentId} not found` });
202
+ throw new HTTPException(404, { message: `Agent with id ${agentId} not found` });
198
203
  }
199
204
  return agent;
200
205
  }
201
- async function getAgentsHandler({
206
+ async function listAgentsHandler({
202
207
  mastra,
203
- runtimeContext
208
+ requestContext
204
209
  }) {
205
210
  try {
206
- const agents = mastra.getAgents();
211
+ const agents = mastra.listAgents();
207
212
  const serializedAgentsMap = await Promise.all(
208
213
  Object.entries(agents).map(async ([id, agent]) => {
209
- return formatAgentList({ id, mastra, agent, runtimeContext });
214
+ return formatAgentList({ id, mastra, agent, requestContext });
210
215
  })
211
216
  );
212
- const serializedAgents = serializedAgentsMap.reduce((acc, { id, ...rest }) => {
213
- acc[id] = rest;
214
- return acc;
215
- }, {});
217
+ const serializedAgents = serializedAgentsMap.reduce(
218
+ (acc, { id, ...rest }) => {
219
+ acc[id] = { id, ...rest };
220
+ return acc;
221
+ },
222
+ {}
223
+ );
216
224
  return serializedAgents;
217
225
  } catch (error) {
218
226
  return handleError(error, "Error getting agents");
@@ -221,16 +229,17 @@ async function getAgentsHandler({
221
229
  async function formatAgent({
222
230
  mastra,
223
231
  agent,
224
- runtimeContext,
232
+ requestContext,
225
233
  isPlayground
226
234
  }) {
227
- const tools = await agent.getTools({ runtimeContext });
235
+ const description = agent.getDescription();
236
+ const tools = await agent.listTools({ requestContext });
228
237
  const serializedAgentTools = await getSerializedAgentTools(tools);
229
238
  let serializedAgentWorkflows = {};
230
- if ("getWorkflows" in agent) {
239
+ if ("listWorkflows" in agent) {
231
240
  const logger = mastra.getLogger();
232
241
  try {
233
- const workflows = await agent.getWorkflows({ runtimeContext });
242
+ const workflows = await agent.listWorkflows({ requestContext });
234
243
  serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
235
244
  return {
236
245
  ...acc,
@@ -255,9 +264,9 @@ async function formatAgent({
255
264
  logger.error("Error getting workflows for agent", { agentName: agent.name, error });
256
265
  }
257
266
  }
258
- let proxyRuntimeContext = runtimeContext;
267
+ let proxyRequestContext = requestContext;
259
268
  if (isPlayground) {
260
- proxyRuntimeContext = new Proxy(runtimeContext, {
269
+ proxyRequestContext = new Proxy(requestContext, {
261
270
  get(target, prop) {
262
271
  if (prop === "get") {
263
272
  return function(key) {
@@ -269,12 +278,15 @@ async function formatAgent({
269
278
  }
270
279
  });
271
280
  }
272
- const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
273
- const llm = await agent.getLLM({ runtimeContext });
274
- const defaultGenerateOptions = await agent.getDefaultGenerateOptionsLegacy({ runtimeContext: proxyRuntimeContext });
275
- const defaultStreamOptions = await agent.getDefaultStreamOptionsLegacy({ runtimeContext: proxyRuntimeContext });
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 });
276
288
  const model = llm?.getModel();
277
- const models = await agent.getModelList(runtimeContext);
289
+ const models = await agent.getModelList(requestContext);
278
290
  const modelList = models?.map((md) => ({
279
291
  ...md,
280
292
  model: {
@@ -283,13 +295,14 @@ async function formatAgent({
283
295
  modelVersion: md.model.specificationVersion
284
296
  }
285
297
  }));
286
- const serializedAgentAgents = await getSerializedAgentDefinition({ agent, runtimeContext: proxyRuntimeContext });
287
- const inputProcessors = await agent.getInputProcessors(proxyRuntimeContext);
288
- const outputProcessors = await agent.getOutputProcessors(proxyRuntimeContext);
298
+ const serializedAgentAgents = await getSerializedAgentDefinition({ agent, requestContext: proxyRequestContext });
299
+ const inputProcessors = await agent.listInputProcessors(proxyRequestContext);
300
+ const outputProcessors = await agent.listOutputProcessors(proxyRequestContext);
289
301
  const serializedInputProcessors = getSerializedProcessors(inputProcessors);
290
302
  const serializedOutputProcessors = getSerializedProcessors(outputProcessors);
291
303
  return {
292
304
  name: agent.name,
305
+ description,
293
306
  instructions,
294
307
  tools: serializedAgentTools,
295
308
  agents: serializedAgentAgents,
@@ -300,64 +313,27 @@ async function formatAgent({
300
313
  modelId: llm?.getModelId(),
301
314
  modelVersion: model?.specificationVersion,
302
315
  modelList,
303
- defaultGenerateOptions,
304
- defaultStreamOptions
316
+ defaultOptions,
317
+ defaultGenerateOptionsLegacy,
318
+ defaultStreamOptionsLegacy
305
319
  };
306
320
  }
307
321
  async function getAgentByIdHandler({
308
322
  mastra,
309
- runtimeContext,
323
+ requestContext,
310
324
  agentId,
311
325
  isPlayground = false
312
326
  }) {
313
327
  try {
314
328
  const agent = await getAgentFromSystem({ mastra, agentId });
315
- return formatAgent({ mastra, agent, runtimeContext, isPlayground });
329
+ return formatAgent({ mastra, agent, requestContext, isPlayground });
316
330
  } catch (error) {
317
331
  return handleError(error, "Error getting agent");
318
332
  }
319
333
  }
320
- async function getEvalsByAgentIdHandler({
321
- mastra,
322
- runtimeContext,
323
- agentId
324
- }) {
325
- try {
326
- const agent = await getAgentFromSystem({ mastra, agentId });
327
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "test") || [];
328
- const instructions = await agent.getInstructions({ runtimeContext });
329
- return {
330
- id: agentId,
331
- name: agent.name,
332
- instructions,
333
- evals
334
- };
335
- } catch (error) {
336
- return handleError(error, "Error getting test evals");
337
- }
338
- }
339
- async function getLiveEvalsByAgentIdHandler({
340
- mastra,
341
- runtimeContext,
342
- agentId
343
- }) {
344
- try {
345
- const agent = await getAgentFromSystem({ mastra, agentId });
346
- const evals = await mastra.getStorage()?.getEvalsByAgentName?.(agent.name, "live") || [];
347
- const instructions = await agent.getInstructions({ runtimeContext });
348
- return {
349
- id: agentId,
350
- name: agent.name,
351
- instructions,
352
- evals
353
- };
354
- } catch (error) {
355
- return handleError(error, "Error getting live evals");
356
- }
357
- }
358
334
  async function generateLegacyHandler({
359
335
  mastra,
360
- runtimeContext,
336
+ requestContext,
361
337
  agentId,
362
338
  body,
363
339
  abortSignal
@@ -365,11 +341,11 @@ async function generateLegacyHandler({
365
341
  try {
366
342
  const agent = await getAgentFromSystem({ mastra, agentId });
367
343
  sanitizeBody(body, ["tools"]);
368
- const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
344
+ const { messages, resourceId, resourceid, requestContext: agentRequestContext, ...rest } = body;
369
345
  const finalResourceId = resourceId ?? resourceid;
370
- const finalRuntimeContext = new RuntimeContext([
371
- ...Array.from(runtimeContext.entries()),
372
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
346
+ const finalRequestContext = new RequestContext([
347
+ ...Array.from(requestContext.entries()),
348
+ ...Array.from(Object.entries(agentRequestContext ?? {}))
373
349
  ]);
374
350
  validateBody({ messages });
375
351
  const result = await agent.generateLegacy(messages, {
@@ -377,7 +353,7 @@ async function generateLegacyHandler({
377
353
  abortSignal,
378
354
  // @ts-expect-error TODO fix types
379
355
  resourceId: finalResourceId,
380
- runtimeContext: finalRuntimeContext
356
+ requestContext: finalRequestContext
381
357
  });
382
358
  return result;
383
359
  } catch (error) {
@@ -386,7 +362,7 @@ async function generateLegacyHandler({
386
362
  }
387
363
  async function generateHandler({
388
364
  mastra,
389
- runtimeContext,
365
+ requestContext,
390
366
  agentId,
391
367
  body,
392
368
  abortSignal
@@ -394,16 +370,15 @@ async function generateHandler({
394
370
  try {
395
371
  const agent = await getAgentFromSystem({ mastra, agentId });
396
372
  sanitizeBody(body, ["tools"]);
397
- const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
398
- const finalRuntimeContext = new RuntimeContext([
399
- ...Array.from(runtimeContext.entries()),
400
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
373
+ const { messages, requestContext: agentRequestContext, ...rest } = body;
374
+ const finalRequestContext = new RequestContext([
375
+ ...Array.from(requestContext.entries()),
376
+ ...Array.from(Object.entries(agentRequestContext ?? {}))
401
377
  ]);
402
378
  validateBody({ messages });
403
379
  const result = await agent.generate(messages, {
404
380
  ...rest,
405
- runtimeContext: finalRuntimeContext,
406
- format: rest.format || "mastra",
381
+ requestContext: finalRequestContext,
407
382
  abortSignal
408
383
  });
409
384
  return result;
@@ -413,18 +388,18 @@ async function generateHandler({
413
388
  }
414
389
  async function streamGenerateLegacyHandler({
415
390
  mastra,
416
- runtimeContext,
391
+ requestContext,
417
392
  agentId,
418
393
  body,
419
394
  abortSignal
420
395
  }) {
421
396
  try {
422
397
  const agent = await getAgentFromSystem({ mastra, agentId });
423
- const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
398
+ const { messages, resourceId, resourceid, requestContext: agentRequestContext, ...rest } = body;
424
399
  const finalResourceId = resourceId ?? resourceid;
425
- const finalRuntimeContext = new RuntimeContext([
426
- ...Array.from(runtimeContext.entries()),
427
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
400
+ const finalRequestContext = new RequestContext([
401
+ ...Array.from(requestContext.entries()),
402
+ ...Array.from(Object.entries(agentRequestContext ?? {}))
428
403
  ]);
429
404
  validateBody({ messages });
430
405
  const streamResult = await agent.streamLegacy(messages, {
@@ -432,7 +407,7 @@ async function streamGenerateLegacyHandler({
432
407
  abortSignal,
433
408
  // @ts-expect-error TODO fix types
434
409
  resourceId: finalResourceId,
435
- runtimeContext: finalRuntimeContext
410
+ requestContext: finalRequestContext
436
411
  });
437
412
  const streamResponse = rest.output ? streamResult.toTextStreamResponse({
438
413
  headers: {
@@ -455,7 +430,7 @@ async function streamGenerateLegacyHandler({
455
430
  }
456
431
  async function streamGenerateHandler({
457
432
  mastra,
458
- runtimeContext,
433
+ requestContext,
459
434
  agentId,
460
435
  body,
461
436
  abortSignal
@@ -463,17 +438,16 @@ async function streamGenerateHandler({
463
438
  try {
464
439
  const agent = await getAgentFromSystem({ mastra, agentId });
465
440
  sanitizeBody(body, ["tools"]);
466
- const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
467
- const finalRuntimeContext = new RuntimeContext([
468
- ...Array.from(runtimeContext.entries()),
469
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
441
+ const { messages, requestContext: agentRequestContext, ...rest } = body;
442
+ const finalRequestContext = new RequestContext([
443
+ ...Array.from(requestContext.entries()),
444
+ ...Array.from(Object.entries(agentRequestContext ?? {}))
470
445
  ]);
471
446
  validateBody({ messages });
472
447
  const streamResult = agent.stream(messages, {
473
448
  ...rest,
474
- runtimeContext: finalRuntimeContext,
475
- abortSignal,
476
- format: body.format ?? "mastra"
449
+ requestContext: finalRequestContext,
450
+ abortSignal
477
451
  });
478
452
  return streamResult;
479
453
  } catch (error) {
@@ -482,7 +456,7 @@ async function streamGenerateHandler({
482
456
  }
483
457
  async function approveToolCallHandler({
484
458
  mastra,
485
- runtimeContext,
459
+ requestContext,
486
460
  agentId,
487
461
  body,
488
462
  abortSignal
@@ -496,17 +470,16 @@ async function approveToolCallHandler({
496
470
  throw new HTTPException(400, { message: "Tool call id is required" });
497
471
  }
498
472
  sanitizeBody(body, ["tools"]);
499
- const { runId, runtimeContext: agentRuntimeContext, ...rest } = body;
500
- const finalRuntimeContext = new RuntimeContext([
501
- ...Array.from(runtimeContext.entries()),
502
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
473
+ const { runId, requestContext: agentRequestContext, ...rest } = body;
474
+ const finalRequestContext = new RequestContext([
475
+ ...Array.from(requestContext.entries()),
476
+ ...Array.from(Object.entries(agentRequestContext ?? {}))
503
477
  ]);
504
478
  const streamResult = agent.approveToolCall({
505
479
  ...rest,
506
480
  runId,
507
- runtimeContext: finalRuntimeContext,
508
- abortSignal,
509
- format: body.format ?? "mastra"
481
+ requestContext: finalRequestContext,
482
+ abortSignal
510
483
  });
511
484
  return streamResult;
512
485
  } catch (error) {
@@ -515,7 +488,7 @@ async function approveToolCallHandler({
515
488
  }
516
489
  async function declineToolCallHandler({
517
490
  mastra,
518
- runtimeContext,
491
+ requestContext,
519
492
  agentId,
520
493
  body,
521
494
  abortSignal
@@ -529,17 +502,16 @@ async function declineToolCallHandler({
529
502
  throw new HTTPException(400, { message: "Tool call id is required" });
530
503
  }
531
504
  sanitizeBody(body, ["tools"]);
532
- const { runId, runtimeContext: agentRuntimeContext, ...rest } = body;
533
- const finalRuntimeContext = new RuntimeContext([
534
- ...Array.from(runtimeContext.entries()),
535
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
505
+ const { runId, requestContext: agentRequestContext, ...rest } = body;
506
+ const finalRequestContext = new RequestContext([
507
+ ...Array.from(requestContext.entries()),
508
+ ...Array.from(Object.entries(agentRequestContext ?? {}))
536
509
  ]);
537
510
  const streamResult = agent.declineToolCall({
538
511
  ...rest,
539
512
  runId,
540
- runtimeContext: finalRuntimeContext,
541
- abortSignal,
542
- format: body.format ?? "mastra"
513
+ requestContext: finalRequestContext,
514
+ abortSignal
543
515
  });
544
516
  return streamResult;
545
517
  } catch (error) {
@@ -548,7 +520,7 @@ async function declineToolCallHandler({
548
520
  }
549
521
  async function streamNetworkHandler({
550
522
  mastra,
551
- runtimeContext,
523
+ requestContext,
552
524
  agentId,
553
525
  body
554
526
  // abortSignal,
@@ -556,10 +528,10 @@ async function streamNetworkHandler({
556
528
  try {
557
529
  const agent = await getAgentFromSystem({ mastra, agentId });
558
530
  sanitizeBody(body, ["tools"]);
559
- const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
560
- const finalRuntimeContext = new RuntimeContext([
561
- ...Array.from(runtimeContext.entries()),
562
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
531
+ const { messages, requestContext: agentRequestContext, ...rest } = body;
532
+ const finalRequestContext = new RequestContext([
533
+ ...Array.from(requestContext.entries()),
534
+ ...Array.from(Object.entries(agentRequestContext ?? {}))
563
535
  ]);
564
536
  validateBody({ messages });
565
537
  const streamResult = agent.network(messages, {
@@ -569,36 +541,21 @@ async function streamNetworkHandler({
569
541
  resource: rest.resourceId ?? "",
570
542
  options: rest.memory?.options ?? {}
571
543
  },
572
- runtimeContext: finalRuntimeContext
544
+ requestContext: finalRequestContext
573
545
  });
574
546
  return streamResult;
575
547
  } catch (error) {
576
548
  return handleError(error, "error streaming agent loop response");
577
549
  }
578
550
  }
579
- async function streamUIMessageHandler({
580
- mastra,
581
- runtimeContext,
582
- agentId,
583
- body,
584
- abortSignal
585
- }) {
551
+ async function streamUIMessageHandler(_params) {
586
552
  try {
587
- const agent = await getAgentFromSystem({ mastra, agentId });
588
- sanitizeBody(body, ["tools"]);
589
- const { messages, runtimeContext: agentRuntimeContext, ...rest } = body;
590
- const finalRuntimeContext = new RuntimeContext([
591
- ...Array.from(runtimeContext.entries()),
592
- ...Array.from(Object.entries(agentRuntimeContext ?? {}))
593
- ]);
594
- validateBody({ messages });
595
- const streamResult = await agent.stream(messages, {
596
- ...rest,
597
- runtimeContext: finalRuntimeContext,
598
- abortSignal,
599
- 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"
600
558
  });
601
- return streamResult.toUIMessageStreamResponse();
602
559
  } catch (error) {
603
560
  return handleError(error, "error streaming agent response");
604
561
  }
@@ -618,6 +575,18 @@ async function updateAgentModelHandler({
618
575
  return handleError(error, "error updating agent model");
619
576
  }
620
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
+ }
621
590
  async function reorderAgentModelListHandler({
622
591
  mastra,
623
592
  agentId,
@@ -687,6 +656,6 @@ async function getProvidersHandler() {
687
656
  }
688
657
  }
689
658
 
690
- export { agents_exports, approveToolCallHandler, declineToolCallHandler, generateHandler, generateLegacyHandler, getAgentByIdHandler, getAgentFromSystem, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, getProvidersHandler, getSerializedAgentTools, getSerializedProcessors, reorderAgentModelListHandler, streamGenerateHandler, streamGenerateLegacyHandler, streamNetworkHandler, streamUIMessageHandler, updateAgentModelHandler, updateAgentModelInModelListHandler };
691
- //# sourceMappingURL=chunk-6VPAV4ZV.js.map
692
- //# sourceMappingURL=chunk-6VPAV4ZV.js.map
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