@mastra/server 0.0.0-separate-trace-data-from-component-20250501042644 → 0.0.0-share-agent-metadata-with-cloud-20250718110128

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 (97) hide show
  1. package/LICENSE.md +11 -42
  2. package/README.md +48 -135
  3. package/dist/_tsup-dts-rollup.d.cts +556 -103
  4. package/dist/_tsup-dts-rollup.d.ts +556 -103
  5. package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
  6. package/dist/{chunk-5YGDYMRB.cjs → chunk-2SLFAFTR.cjs} +14 -13
  7. package/dist/chunk-3CNDE7QY.cjs +308 -0
  8. package/dist/chunk-4D66QEKC.js +81 -0
  9. package/dist/{chunk-M3YJLWTU.js → chunk-5PQQ42EZ.js} +68 -57
  10. package/dist/chunk-75ZPJI57.cjs +9 -0
  11. package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
  12. package/dist/chunk-B2PAS2IB.cjs +514 -0
  13. package/dist/{chunk-Y3SV5XK4.js → chunk-BK4XT6EG.js} +105 -16
  14. package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  15. package/dist/{chunk-QJ3AHN64.js → chunk-CRCR3ZUK.js} +4 -3
  16. package/dist/{chunk-D3G23FP3.cjs → chunk-FRVBFMO2.cjs} +24 -22
  17. package/dist/{chunk-7IWQE76Z.cjs → chunk-G7KH752Y.cjs} +16 -10
  18. package/dist/chunk-GHC4YV6R.js +504 -0
  19. package/dist/chunk-H7DMHBKY.js +498 -0
  20. package/dist/chunk-JMLYCXMK.cjs +332 -0
  21. package/dist/{chunk-Q6SHQECN.js → chunk-KHZKYUNR.js} +34 -10
  22. package/dist/{chunk-RBQASTUP.js → chunk-KOHWJYJT.js} +120 -27
  23. package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
  24. package/dist/chunk-LF7P5PLR.js +14 -0
  25. package/dist/chunk-LI436ITD.cjs +2042 -0
  26. package/dist/{chunk-5JNVY6DU.js → chunk-LRCAAFUA.js} +7 -5
  27. package/dist/chunk-LZ3VJXSO.cjs +278 -0
  28. package/dist/chunk-MEGCYGBU.js +2039 -0
  29. package/dist/chunk-MLKGABMK.js +7 -0
  30. package/dist/chunk-PZQDCRPV.cjs +16 -0
  31. package/dist/chunk-QGX47B5D.cjs +86 -0
  32. package/dist/{chunk-WTHDCRMY.js → chunk-RG473F6Y.js} +12 -6
  33. package/dist/chunk-RHSWAXKB.cjs +118 -0
  34. package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
  35. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  36. package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
  37. package/dist/server/handlers/a2a.cjs +30 -0
  38. package/dist/server/handlers/a2a.d.cts +6 -0
  39. package/dist/server/handlers/a2a.d.ts +6 -0
  40. package/dist/server/handlers/a2a.js +1 -0
  41. package/dist/server/handlers/agents.cjs +7 -7
  42. package/dist/server/handlers/agents.js +1 -1
  43. package/dist/server/handlers/error.cjs +2 -2
  44. package/dist/server/handlers/error.js +1 -1
  45. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  46. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  47. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  48. package/dist/server/handlers/legacyWorkflows.js +1 -0
  49. package/dist/server/handlers/logs.cjs +4 -4
  50. package/dist/server/handlers/logs.js +1 -1
  51. package/dist/server/handlers/memory.cjs +17 -9
  52. package/dist/server/handlers/memory.d.cts +2 -0
  53. package/dist/server/handlers/memory.d.ts +2 -0
  54. package/dist/server/handlers/memory.js +1 -1
  55. package/dist/server/handlers/network.cjs +5 -5
  56. package/dist/server/handlers/network.js +1 -1
  57. package/dist/server/handlers/telemetry.cjs +3 -3
  58. package/dist/server/handlers/telemetry.js +1 -1
  59. package/dist/server/handlers/tools.cjs +5 -5
  60. package/dist/server/handlers/tools.js +1 -1
  61. package/dist/server/handlers/utils.cjs +2 -2
  62. package/dist/server/handlers/utils.js +1 -1
  63. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  64. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  65. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  66. package/dist/server/handlers/vNextNetwork.js +211 -0
  67. package/dist/server/handlers/vector.cjs +7 -7
  68. package/dist/server/handlers/vector.js +1 -1
  69. package/dist/server/handlers/voice.cjs +8 -4
  70. package/dist/server/handlers/voice.d.cts +1 -0
  71. package/dist/server/handlers/voice.d.ts +1 -0
  72. package/dist/server/handlers/voice.js +1 -1
  73. package/dist/server/handlers/workflows.cjs +29 -13
  74. package/dist/server/handlers/workflows.d.cts +6 -2
  75. package/dist/server/handlers/workflows.d.ts +6 -2
  76. package/dist/server/handlers/workflows.js +1 -1
  77. package/dist/server/handlers.cjs +32 -27
  78. package/dist/server/handlers.d.cts +2 -1
  79. package/dist/server/handlers.d.ts +2 -1
  80. package/dist/server/handlers.js +11 -10
  81. package/package.json +15 -14
  82. package/dist/chunk-2FJURXCL.cjs +0 -213
  83. package/dist/chunk-3AHQ5RGN.js +0 -11
  84. package/dist/chunk-3EJZQ6TQ.js +0 -49
  85. package/dist/chunk-4BIX6GMY.cjs +0 -189
  86. package/dist/chunk-55HTWX4C.cjs +0 -93
  87. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  88. package/dist/chunk-AELYAUEE.cjs +0 -316
  89. package/dist/chunk-EVCC233P.cjs +0 -321
  90. package/dist/chunk-JPB6RPGB.js +0 -304
  91. package/dist/chunk-OMN3UI6X.js +0 -5576
  92. package/dist/chunk-SKBVVI24.cjs +0 -54
  93. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  94. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  95. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  96. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  97. package/dist/server/handlers/vNextWorkflows.js +0 -1
@@ -1,7 +1,9 @@
1
- import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
- import { validateBody } from './chunk-L7XE5QTW.js';
3
- import { handleError } from './chunk-3AHQ5RGN.js';
4
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { stringify, esm_default } from './chunk-MEGCYGBU.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';
5
7
 
6
8
  // src/server/handlers/agents.ts
7
9
  var agents_exports = {};
@@ -21,6 +23,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
21
23
  const instructions = await agent.getInstructions({ runtimeContext });
22
24
  const tools = await agent.getTools({ runtimeContext });
23
25
  const llm = await agent.getLLM({ runtimeContext });
26
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext });
27
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext });
24
28
  const serializedAgentTools = Object.entries(tools || {}).reduce((acc, [key, tool]) => {
25
29
  const _tool = tool;
26
30
  acc[key] = {
@@ -30,13 +34,33 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
30
34
  };
31
35
  return acc;
32
36
  }, {});
37
+ let serializedAgentWorkflows = {};
38
+ if ("getWorkflows" in agent) {
39
+ const logger = mastra.getLogger();
40
+ try {
41
+ const workflows = await agent.getWorkflows({ runtimeContext });
42
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
43
+ return {
44
+ ...acc,
45
+ [key]: {
46
+ name: workflow.name
47
+ }
48
+ };
49
+ }, {});
50
+ } catch (error) {
51
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
52
+ }
53
+ }
33
54
  return {
34
55
  id,
35
56
  name: agent.name,
36
57
  instructions,
37
58
  tools: serializedAgentTools,
59
+ workflows: serializedAgentWorkflows,
38
60
  provider: llm?.getProvider(),
39
- modelId: llm?.getModelId()
61
+ modelId: llm?.getModelId(),
62
+ defaultGenerateOptions,
63
+ defaultStreamOptions
40
64
  };
41
65
  })
42
66
  );
@@ -52,7 +76,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
52
76
  async function getAgentByIdHandler({
53
77
  mastra,
54
78
  runtimeContext,
55
- agentId
79
+ agentId,
80
+ isPlayground = false
56
81
  }) {
57
82
  try {
58
83
  const agent = mastra.getAgent(agentId);
@@ -69,14 +94,59 @@ async function getAgentByIdHandler({
69
94
  };
70
95
  return acc;
71
96
  }, {});
72
- const instructions = await agent.getInstructions({ runtimeContext });
97
+ let serializedAgentWorkflows = {};
98
+ if ("getWorkflows" in agent) {
99
+ const logger = mastra.getLogger();
100
+ try {
101
+ const workflows = await agent.getWorkflows({ runtimeContext });
102
+ serializedAgentWorkflows = Object.entries(workflows || {}).reduce((acc, [key, workflow]) => {
103
+ return {
104
+ ...acc,
105
+ [key]: {
106
+ name: workflow.name,
107
+ steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
108
+ return {
109
+ ...acc2,
110
+ [key2]: {
111
+ id: step.id,
112
+ description: step.description
113
+ }
114
+ };
115
+ }, {})
116
+ }
117
+ };
118
+ }, {});
119
+ } catch (error) {
120
+ logger.error("Error getting workflows for agent", { agentName: agent.name, error });
121
+ }
122
+ }
123
+ let proxyRuntimeContext = runtimeContext;
124
+ if (isPlayground) {
125
+ proxyRuntimeContext = new Proxy(runtimeContext, {
126
+ get(target, prop) {
127
+ if (prop === "get") {
128
+ return function(key) {
129
+ const value = target.get(key);
130
+ return value ?? `<${key}>`;
131
+ };
132
+ }
133
+ return Reflect.get(target, prop);
134
+ }
135
+ });
136
+ }
137
+ const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
73
138
  const llm = await agent.getLLM({ runtimeContext });
139
+ const defaultGenerateOptions = await agent.getDefaultGenerateOptions({ runtimeContext: proxyRuntimeContext });
140
+ const defaultStreamOptions = await agent.getDefaultStreamOptions({ runtimeContext: proxyRuntimeContext });
74
141
  return {
75
142
  name: agent.name,
76
143
  instructions,
77
144
  tools: serializedAgentTools,
145
+ workflows: serializedAgentWorkflows,
78
146
  provider: llm?.getProvider(),
79
- modelId: llm?.getModelId()
147
+ modelId: llm?.getModelId(),
148
+ defaultGenerateOptions,
149
+ defaultStreamOptions
80
150
  };
81
151
  } catch (error) {
82
152
  return handleError(error, "Error getting agent");
@@ -124,21 +194,27 @@ async function generateHandler({
124
194
  mastra,
125
195
  runtimeContext,
126
196
  agentId,
127
- body
197
+ body,
198
+ abortSignal
128
199
  }) {
129
200
  try {
130
201
  const agent = mastra.getAgent(agentId);
131
202
  if (!agent) {
132
203
  throw new HTTPException(404, { message: "Agent not found" });
133
204
  }
134
- const { messages, resourceId, resourceid, ...rest } = body;
205
+ const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
135
206
  const finalResourceId = resourceId ?? resourceid;
207
+ const finalRuntimeContext = new RuntimeContext([
208
+ ...Array.from(runtimeContext.entries()),
209
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
210
+ ]);
136
211
  validateBody({ messages });
137
212
  const result = await agent.generate(messages, {
138
213
  ...rest,
139
214
  // @ts-expect-error TODO fix types
140
215
  resourceId: finalResourceId,
141
- runtimeContext
216
+ runtimeContext: finalRuntimeContext,
217
+ signal: abortSignal
142
218
  });
143
219
  return result;
144
220
  } catch (error) {
@@ -149,32 +225,45 @@ async function streamGenerateHandler({
149
225
  mastra,
150
226
  runtimeContext,
151
227
  agentId,
152
- body
228
+ body,
229
+ abortSignal
153
230
  }) {
154
231
  try {
155
232
  const agent = mastra.getAgent(agentId);
156
233
  if (!agent) {
157
234
  throw new HTTPException(404, { message: "Agent not found" });
158
235
  }
159
- const { messages, resourceId, resourceid, ...rest } = body;
236
+ const { messages, resourceId, resourceid, runtimeContext: agentRuntimeContext, ...rest } = body;
160
237
  const finalResourceId = resourceId ?? resourceid;
238
+ const finalRuntimeContext = new RuntimeContext([
239
+ ...Array.from(runtimeContext.entries()),
240
+ ...Array.from(Object.entries(agentRuntimeContext ?? {}))
241
+ ]);
161
242
  validateBody({ messages });
162
243
  const streamResult = await agent.stream(messages, {
163
244
  ...rest,
164
245
  // @ts-expect-error TODO fix types
165
246
  resourceId: finalResourceId,
166
- runtimeContext
247
+ runtimeContext: finalRuntimeContext,
248
+ signal: abortSignal
167
249
  });
168
- const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
250
+ const streamResponse = rest.output ? streamResult.toTextStreamResponse({
251
+ headers: {
252
+ "Transfer-Encoding": "chunked"
253
+ }
254
+ }) : streamResult.toDataStreamResponse({
169
255
  sendUsage: true,
170
256
  sendReasoning: true,
171
257
  getErrorMessage: (error) => {
172
258
  return `An error occurred while processing your request. ${error instanceof Error ? error.message : JSON.stringify(error)}`;
259
+ },
260
+ headers: {
261
+ "Transfer-Encoding": "chunked"
173
262
  }
174
263
  });
175
264
  return streamResponse;
176
265
  } catch (error) {
177
- throw new HTTPException(error?.status ?? 500, { message: error?.message ?? "Error streaming from agent" });
266
+ return handleError(error, "error streaming agent response");
178
267
  }
179
268
  }
180
269
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
4
4
 
5
5
  // src/server/handlers/utils.ts
6
6
  function validateBody(body) {
@@ -11,7 +11,7 @@ function validateBody(body) {
11
11
  return acc;
12
12
  }, {});
13
13
  if (Object.keys(errorResponse).length > 0) {
14
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
14
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: Object.values(errorResponse)[0] });
15
15
  }
16
16
  }
17
17
 
@@ -1,6 +1,7 @@
1
- import { validateBody } from './chunk-L7XE5QTW.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
4
5
 
5
6
  // src/server/handlers/network.ts
6
7
  var network_exports = {};
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
- var chunk5SWCVTNL_cjs = require('./chunk-5SWCVTNL.cjs');
4
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
5
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
6
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunkLI436ITD_cjs = require('./chunk-LI436ITD.cjs');
4
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
5
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
6
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
7
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
8
  var tools = require('@mastra/core/tools');
8
9
 
9
10
  // src/server/handlers/tools.ts
10
11
  var tools_exports = {};
11
- chunkFV45V6WC_cjs.__export(tools_exports, {
12
+ chunk75ZPJI57_cjs.__export(tools_exports, {
12
13
  executeAgentToolHandler: () => executeAgentToolHandler,
13
14
  executeToolHandler: () => executeToolHandler,
14
15
  getToolByIdHandler: () => getToolByIdHandler,
@@ -24,8 +25,8 @@ async function getToolsHandler({ tools }) {
24
25
  const tool = _tool;
25
26
  acc[id] = {
26
27
  ...tool,
27
- inputSchema: tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.inputSchema)) : void 0,
28
- outputSchema: tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.outputSchema)) : void 0
28
+ inputSchema: tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.inputSchema)) : void 0,
29
+ outputSchema: tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.outputSchema)) : void 0
29
30
  };
30
31
  return acc;
31
32
  },
@@ -33,23 +34,23 @@ async function getToolsHandler({ tools }) {
33
34
  );
34
35
  return serializedTools;
35
36
  } catch (error) {
36
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting tools");
37
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting tools");
37
38
  }
38
39
  }
39
40
  async function getToolByIdHandler({ tools, toolId }) {
40
41
  try {
41
42
  const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
42
43
  if (!tool) {
43
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
44
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
44
45
  }
45
46
  const serializedTool = {
46
47
  ...tool,
47
- inputSchema: tool.inputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.inputSchema)) : void 0,
48
- outputSchema: tool.outputSchema ? chunk5SWCVTNL_cjs.stringify(chunk5SWCVTNL_cjs.esm_default(tool.outputSchema)) : void 0
48
+ inputSchema: tool.inputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.inputSchema)) : void 0,
49
+ outputSchema: tool.outputSchema ? chunkLI436ITD_cjs.stringify(chunkLI436ITD_cjs.esm_default(tool.outputSchema)) : void 0
49
50
  };
50
51
  return serializedTool;
51
52
  } catch (error) {
52
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting tool");
53
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting tool");
53
54
  }
54
55
  }
55
56
  function executeToolHandler(tools$1) {
@@ -62,16 +63,16 @@ function executeToolHandler(tools$1) {
62
63
  }) => {
63
64
  try {
64
65
  if (!toolId) {
65
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool ID is required" });
66
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool ID is required" });
66
67
  }
67
68
  const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
68
69
  if (!tool) {
69
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
70
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
70
71
  }
71
72
  if (!tool?.execute) {
72
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool is not executable" });
73
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
73
74
  }
74
- chunkQN4KF3BH_cjs.validateBody({ data });
75
+ chunkCCGRCYWJ_cjs.validateBody({ data });
75
76
  if (tools.isVercelTool(tool)) {
76
77
  const result2 = await tool.execute(data);
77
78
  return result2;
@@ -84,7 +85,7 @@ function executeToolHandler(tools$1) {
84
85
  });
85
86
  return result;
86
87
  } catch (error) {
87
- return chunkZLBRQFDD_cjs.handleError(error, "Error executing tool");
88
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
88
89
  }
89
90
  };
90
91
  }
@@ -98,14 +99,15 @@ async function executeAgentToolHandler({
98
99
  try {
99
100
  const agent = agentId ? mastra.getAgent(agentId) : null;
100
101
  if (!agent) {
101
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
102
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
102
103
  }
103
- const tool = Object.values(agent?.tools || {}).find((tool2) => tool2.id === toolId);
104
+ const agentTools = await agent.getTools({ runtimeContext });
105
+ const tool = Object.values(agentTools || {}).find((tool2) => tool2.id === toolId);
104
106
  if (!tool) {
105
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Tool not found" });
107
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
106
108
  }
107
109
  if (!tool?.execute) {
108
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Tool is not executable" });
110
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
109
111
  }
110
112
  const result = await tool.execute({
111
113
  context: data,
@@ -115,7 +117,7 @@ async function executeAgentToolHandler({
115
117
  });
116
118
  return result;
117
119
  } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error executing tool");
120
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
119
121
  }
120
122
  }
121
123
 
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
4
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.cjs');
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
5
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
5
6
 
6
7
  // src/server/handlers/telemetry.ts
7
8
  var telemetry_exports = {};
8
- chunkFV45V6WC_cjs.__export(telemetry_exports, {
9
+ chunk75ZPJI57_cjs.__export(telemetry_exports, {
9
10
  getTelemetryHandler: () => getTelemetryHandler,
10
11
  storeTelemetryHandler: () => storeTelemetryHandler
11
12
  });
@@ -14,15 +15,15 @@ async function getTelemetryHandler({ mastra, body }) {
14
15
  const telemetry = mastra.getTelemetry();
15
16
  const storage = mastra.getStorage();
16
17
  if (!telemetry) {
17
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
18
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
18
19
  }
19
20
  if (!storage) {
20
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Storage is not initialized" });
21
+ return [];
21
22
  }
22
23
  if (!body) {
23
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Body is required" });
24
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
24
25
  }
25
- const { name, scope, page, perPage, attribute } = body;
26
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
26
27
  const attributes = attribute ? Object.fromEntries(
27
28
  (Array.isArray(attribute) ? attribute : [attribute]).map((attr) => {
28
29
  const [key, value] = attr.split(":");
@@ -34,11 +35,13 @@ async function getTelemetryHandler({ mastra, body }) {
34
35
  scope,
35
36
  page: Number(page ?? 0),
36
37
  perPage: Number(perPage ?? 100),
37
- attributes
38
+ attributes,
39
+ fromDate: fromDate ? new Date(fromDate) : void 0,
40
+ toDate: toDate ? new Date(toDate) : void 0
38
41
  });
39
42
  return traces;
40
43
  } catch (error2) {
41
- return chunkZLBRQFDD_cjs.handleError(error2, "Error getting telemetry");
44
+ return chunkPZQDCRPV_cjs.handleError(error2, "Error getting telemetry");
42
45
  }
43
46
  }
44
47
  async function storeTelemetryHandler({ mastra, body }) {
@@ -46,7 +49,10 @@ async function storeTelemetryHandler({ mastra, body }) {
46
49
  const storage = mastra.getStorage();
47
50
  const logger = mastra.getLogger();
48
51
  if (!storage) {
49
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Storage is not initialized" });
52
+ return {
53
+ status: "error",
54
+ message: "Storage is not initialized"
55
+ };
50
56
  }
51
57
  const now = /* @__PURE__ */ new Date();
52
58
  const items = body?.resourceSpans?.[0]?.scopeSpans;