@mastra/server 0.0.0-generate-message-id-20250512171942 → 0.0.0-http-transporter-20250702160118

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 (85) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +394 -128
  2. package/dist/_tsup-dts-rollup.d.ts +394 -128
  3. package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
  4. package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
  5. package/dist/chunk-4D66QEKC.js +81 -0
  6. package/dist/{chunk-EJO45KYT.js → chunk-5PQQ42EZ.js} +43 -43
  7. package/dist/{chunk-4YZ3U35L.cjs → chunk-7TP2LX5L.cjs} +18 -18
  8. package/dist/chunk-B2PAS2IB.cjs +514 -0
  9. package/dist/{chunk-Q6KMBIAN.js → chunk-BK4XT6EG.js} +93 -14
  10. package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  11. package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
  12. package/dist/{chunk-24EGIVT7.cjs → chunk-DN7K6FJK.cjs} +91 -54
  13. package/dist/{chunk-ZE5AAC4I.cjs → chunk-FRVBFMO2.cjs} +26 -36
  14. package/dist/{chunk-MHKNLNAN.cjs → chunk-G7KH752Y.cjs} +10 -7
  15. package/dist/{chunk-P6SCPDYW.js → chunk-GHC4YV6R.js} +5 -1
  16. package/dist/chunk-H7DMHBKY.js +498 -0
  17. package/dist/chunk-JMLYCXMK.cjs +332 -0
  18. package/dist/{chunk-HFWCEP5S.js → chunk-KHZKYUNR.js} +33 -10
  19. package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
  20. package/dist/chunk-LF7P5PLR.js +14 -0
  21. package/dist/{chunk-YWLUOY3D.cjs → chunk-LI436ITD.cjs} +107 -69
  22. package/dist/{chunk-TJKLBTFB.js → chunk-LRCAAFUA.js} +10 -20
  23. package/dist/{chunk-3HQNCTZ2.cjs → chunk-LZ3VJXSO.cjs} +107 -28
  24. package/dist/{chunk-LIVAK2DM.js → chunk-MEGCYGBU.js} +108 -70
  25. package/dist/{chunk-X3ZDCS52.js → chunk-MKLYEKEF.js} +62 -25
  26. package/dist/chunk-PZQDCRPV.cjs +16 -0
  27. package/dist/chunk-QGX47B5D.cjs +86 -0
  28. package/dist/{chunk-OR3CIE2H.js → chunk-RG473F6Y.js} +7 -4
  29. package/dist/chunk-RHSWAXKB.cjs +118 -0
  30. package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
  31. package/dist/{chunk-5SN4U5AC.cjs → chunk-SDPGVWQJ.cjs} +5 -1
  32. package/dist/{chunk-IU5VO2I2.js → chunk-WNVFNNWN.js} +4 -4
  33. package/dist/server/handlers/a2a.cjs +7 -7
  34. package/dist/server/handlers/a2a.js +1 -1
  35. package/dist/server/handlers/agents.cjs +7 -7
  36. package/dist/server/handlers/agents.js +1 -1
  37. package/dist/server/handlers/error.cjs +2 -2
  38. package/dist/server/handlers/error.js +1 -1
  39. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  40. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  41. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  42. package/dist/server/handlers/legacyWorkflows.js +1 -0
  43. package/dist/server/handlers/logs.cjs +4 -4
  44. package/dist/server/handlers/logs.js +1 -1
  45. package/dist/server/handlers/memory.cjs +9 -9
  46. package/dist/server/handlers/memory.js +1 -1
  47. package/dist/server/handlers/network.cjs +5 -5
  48. package/dist/server/handlers/network.js +1 -1
  49. package/dist/server/handlers/telemetry.cjs +3 -3
  50. package/dist/server/handlers/telemetry.js +1 -1
  51. package/dist/server/handlers/tools.cjs +5 -5
  52. package/dist/server/handlers/tools.js +1 -1
  53. package/dist/server/handlers/utils.cjs +2 -2
  54. package/dist/server/handlers/utils.js +1 -1
  55. package/dist/server/handlers/vNextNetwork.cjs +218 -0
  56. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  57. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  58. package/dist/server/handlers/vNextNetwork.js +211 -0
  59. package/dist/server/handlers/vector.cjs +7 -7
  60. package/dist/server/handlers/vector.js +1 -1
  61. package/dist/server/handlers/voice.cjs +8 -4
  62. package/dist/server/handlers/voice.d.cts +1 -0
  63. package/dist/server/handlers/voice.d.ts +1 -0
  64. package/dist/server/handlers/voice.js +1 -1
  65. package/dist/server/handlers/workflows.cjs +29 -13
  66. package/dist/server/handlers/workflows.d.cts +6 -2
  67. package/dist/server/handlers/workflows.d.ts +6 -2
  68. package/dist/server/handlers/workflows.js +1 -1
  69. package/dist/server/handlers.cjs +28 -28
  70. package/dist/server/handlers.d.cts +1 -1
  71. package/dist/server/handlers.d.ts +1 -1
  72. package/dist/server/handlers.js +11 -11
  73. package/package.json +12 -13
  74. package/dist/chunk-64U3UDTH.cjs +0 -13
  75. package/dist/chunk-HWZVAG3H.js +0 -49
  76. package/dist/chunk-I2B73Y4I.cjs +0 -332
  77. package/dist/chunk-M5ABIP7D.js +0 -11
  78. package/dist/chunk-MIQYDLLM.js +0 -329
  79. package/dist/chunk-OGCNNUHF.cjs +0 -54
  80. package/dist/chunk-UCTEMO2Q.cjs +0 -341
  81. package/dist/chunk-YBVOQN4M.cjs +0 -94
  82. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  83. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  84. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  85. package/dist/server/handlers/vNextWorkflows.js +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.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 chunkOCWPVYNI_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,6 @@
1
- import { validateBody } from './chunk-H5PTF3Y4.js';
2
- import { handleError } from './chunk-M5ABIP7D.js';
3
- import { HTTPException } from './chunk-NYN7KFXL.js';
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.js';
4
4
  import { __export } from './chunk-MLKGABMK.js';
5
5
 
6
6
  // src/server/handlers/network.ts
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
4
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
5
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
4
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
5
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
6
6
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
7
7
 
8
8
  // src/server/handlers/memory.ts
@@ -17,80 +17,102 @@ chunk75ZPJI57_cjs.__export(memory_exports, {
17
17
  saveMessagesHandler: () => saveMessagesHandler,
18
18
  updateThreadHandler: () => updateThreadHandler
19
19
  });
20
- function getMemoryFromContext({
20
+ async function getMemoryFromContext({
21
21
  mastra,
22
- agentId
22
+ agentId,
23
+ networkId,
24
+ runtimeContext
23
25
  }) {
24
26
  const agent = agentId ? mastra.getAgent(agentId) : null;
25
27
  if (agentId && !agent) {
26
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Agent not found" });
28
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Agent not found" });
29
+ }
30
+ const network = networkId ? mastra.vnext_getNetwork(networkId) : null;
31
+ if (networkId && !network) {
32
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
33
+ }
34
+ if (agent) {
35
+ return agent?.getMemory() || mastra.getMemory();
36
+ }
37
+ if (network) {
38
+ return await network?.getMemory({ runtimeContext }) || mastra.getMemory();
27
39
  }
28
- const memory = agent?.getMemory?.() || mastra.getMemory();
29
- return memory;
40
+ return mastra.getMemory();
30
41
  }
31
- async function getMemoryStatusHandler({ mastra, agentId }) {
42
+ async function getMemoryStatusHandler({
43
+ mastra,
44
+ agentId,
45
+ networkId,
46
+ runtimeContext
47
+ }) {
32
48
  try {
33
- const memory = getMemoryFromContext({ mastra, agentId });
49
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
34
50
  if (!memory) {
35
51
  return { result: false };
36
52
  }
37
53
  return { result: true };
38
54
  } catch (error) {
39
- return chunk64U3UDTH_cjs.handleError(error, "Error getting memory status");
55
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting memory status");
40
56
  }
41
57
  }
42
58
  async function getThreadsHandler({
43
59
  mastra,
44
60
  agentId,
45
- resourceId
61
+ resourceId,
62
+ networkId,
63
+ runtimeContext
46
64
  }) {
47
65
  try {
48
- const memory = getMemoryFromContext({ mastra, agentId });
66
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
49
67
  if (!memory) {
50
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
68
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
51
69
  }
52
- chunk57CJTIPW_cjs.validateBody({ resourceId });
70
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId });
53
71
  const threads = await memory.getThreadsByResourceId({ resourceId });
54
72
  return threads;
55
73
  } catch (error) {
56
- return chunk64U3UDTH_cjs.handleError(error, "Error getting threads");
74
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting threads");
57
75
  }
58
76
  }
59
77
  async function getThreadByIdHandler({
60
78
  mastra,
61
79
  agentId,
62
- threadId
80
+ threadId,
81
+ networkId,
82
+ runtimeContext
63
83
  }) {
64
84
  try {
65
- chunk57CJTIPW_cjs.validateBody({ threadId });
66
- const memory = getMemoryFromContext({ mastra, agentId });
85
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
86
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
67
87
  if (!memory) {
68
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
88
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
69
89
  }
70
90
  const thread = await memory.getThreadById({ threadId });
71
91
  if (!thread) {
72
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
92
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
73
93
  }
74
94
  return thread;
75
95
  } catch (error) {
76
- return chunk64U3UDTH_cjs.handleError(error, "Error getting thread");
96
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting thread");
77
97
  }
78
98
  }
79
99
  async function saveMessagesHandler({
80
100
  mastra,
81
101
  agentId,
82
- body
102
+ body,
103
+ networkId,
104
+ runtimeContext
83
105
  }) {
84
106
  try {
85
- const memory = getMemoryFromContext({ mastra, agentId });
107
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
86
108
  if (!memory) {
87
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
109
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
88
110
  }
89
111
  if (!body?.messages) {
90
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages are required" });
112
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages are required" });
91
113
  }
92
114
  if (!Array.isArray(body.messages)) {
93
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Messages should be an array" });
115
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Messages should be an array" });
94
116
  }
95
117
  const processedMessages = body.messages.map((message) => ({
96
118
  ...message,
@@ -100,20 +122,22 @@ async function saveMessagesHandler({
100
122
  const result = await memory.saveMessages({ messages: processedMessages, memoryConfig: {} });
101
123
  return result;
102
124
  } catch (error) {
103
- return chunk64U3UDTH_cjs.handleError(error, "Error saving messages");
125
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving messages");
104
126
  }
105
127
  }
106
128
  async function createThreadHandler({
107
129
  mastra,
108
130
  agentId,
109
- body
131
+ body,
132
+ networkId,
133
+ runtimeContext
110
134
  }) {
111
135
  try {
112
- const memory = getMemoryFromContext({ mastra, agentId });
136
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
113
137
  if (!memory) {
114
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
138
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
115
139
  }
116
- chunk57CJTIPW_cjs.validateBody({ resourceId: body?.resourceId });
140
+ chunkCCGRCYWJ_cjs.validateBody({ resourceId: body?.resourceId });
117
141
  const result = await memory.createThread({
118
142
  resourceId: body?.resourceId,
119
143
  title: body?.title,
@@ -122,29 +146,31 @@ async function createThreadHandler({
122
146
  });
123
147
  return result;
124
148
  } catch (error) {
125
- return chunk64U3UDTH_cjs.handleError(error, "Error saving thread to memory");
149
+ return chunkPZQDCRPV_cjs.handleError(error, "Error saving thread to memory");
126
150
  }
127
151
  }
128
152
  async function updateThreadHandler({
129
153
  mastra,
130
154
  agentId,
131
155
  threadId,
132
- body
156
+ body,
157
+ networkId,
158
+ runtimeContext
133
159
  }) {
134
160
  try {
135
- const memory = getMemoryFromContext({ mastra, agentId });
161
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
136
162
  if (!body) {
137
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
163
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
138
164
  }
139
165
  const { title, metadata, resourceId } = body;
140
166
  const updatedAt = /* @__PURE__ */ new Date();
141
- chunk57CJTIPW_cjs.validateBody({ threadId });
167
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
142
168
  if (!memory) {
143
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
169
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
144
170
  }
145
171
  const thread = await memory.getThreadById({ threadId });
146
172
  if (!thread) {
147
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
173
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
148
174
  }
149
175
  const updatedThread = {
150
176
  ...thread,
@@ -157,49 +183,60 @@ async function updateThreadHandler({
157
183
  const result = await memory.saveThread({ thread: updatedThread });
158
184
  return result;
159
185
  } catch (error) {
160
- return chunk64U3UDTH_cjs.handleError(error, "Error updating thread");
186
+ return chunkPZQDCRPV_cjs.handleError(error, "Error updating thread");
161
187
  }
162
188
  }
163
189
  async function deleteThreadHandler({
164
190
  mastra,
165
191
  agentId,
166
- threadId
192
+ threadId,
193
+ networkId,
194
+ runtimeContext
167
195
  }) {
168
196
  try {
169
- chunk57CJTIPW_cjs.validateBody({ threadId });
170
- const memory = getMemoryFromContext({ mastra, agentId });
197
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
198
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
171
199
  if (!memory) {
172
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
200
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
173
201
  }
174
202
  const thread = await memory.getThreadById({ threadId });
175
203
  if (!thread) {
176
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
204
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
177
205
  }
178
206
  await memory.deleteThread(threadId);
179
207
  return { result: "Thread deleted" };
180
208
  } catch (error) {
181
- return chunk64U3UDTH_cjs.handleError(error, "Error deleting thread");
209
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting thread");
182
210
  }
183
211
  }
184
212
  async function getMessagesHandler({
185
213
  mastra,
186
214
  agentId,
187
- threadId
215
+ threadId,
216
+ limit,
217
+ networkId,
218
+ runtimeContext
188
219
  }) {
220
+ if (limit !== void 0 && (!Number.isInteger(limit) || limit <= 0)) {
221
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid limit: must be a positive integer" });
222
+ }
189
223
  try {
190
- chunk57CJTIPW_cjs.validateBody({ threadId });
191
- const memory = getMemoryFromContext({ mastra, agentId });
224
+ chunkCCGRCYWJ_cjs.validateBody({ threadId });
225
+ const memory = await getMemoryFromContext({ mastra, agentId, networkId, runtimeContext });
192
226
  if (!memory) {
193
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Memory is not initialized" });
227
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Memory is not initialized" });
194
228
  }
195
229
  const thread = await memory.getThreadById({ threadId });
196
230
  if (!thread) {
197
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Thread not found" });
231
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Thread not found" });
198
232
  }
199
- const result = await memory.query({ threadId });
200
- return result;
233
+ const result = await memory.query({
234
+ threadId,
235
+ ...limit && { selectBy: { last: limit } }
236
+ });
237
+ return { messages: result.messages, uiMessages: result.uiMessages };
201
238
  } catch (error) {
202
- return chunk64U3UDTH_cjs.handleError(error, "Error getting messages");
239
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting messages");
203
240
  }
204
241
  }
205
242
 
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkYWLUOY3D_cjs = require('./chunk-YWLUOY3D.cjs');
4
- var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
5
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
6
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.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
7
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
8
- var di = require('@mastra/core/di');
9
8
  var tools = require('@mastra/core/tools');
10
9
 
11
10
  // src/server/handlers/tools.ts
@@ -26,8 +25,8 @@ async function getToolsHandler({ tools }) {
26
25
  const tool = _tool;
27
26
  acc[id] = {
28
27
  ...tool,
29
- inputSchema: tool.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(tool.inputSchema)) : void 0,
30
- outputSchema: tool.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_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
31
30
  };
32
31
  return acc;
33
32
  },
@@ -35,23 +34,23 @@ async function getToolsHandler({ tools }) {
35
34
  );
36
35
  return serializedTools;
37
36
  } catch (error) {
38
- return chunk64U3UDTH_cjs.handleError(error, "Error getting tools");
37
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting tools");
39
38
  }
40
39
  }
41
40
  async function getToolByIdHandler({ tools, toolId }) {
42
41
  try {
43
42
  const tool = Object.values(tools || {}).find((tool2) => tool2.id === toolId);
44
43
  if (!tool) {
45
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
44
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
46
45
  }
47
46
  const serializedTool = {
48
47
  ...tool,
49
- inputSchema: tool.inputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_cjs.esm_default(tool.inputSchema)) : void 0,
50
- outputSchema: tool.outputSchema ? chunkYWLUOY3D_cjs.stringify(chunkYWLUOY3D_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
51
50
  };
52
51
  return serializedTool;
53
52
  } catch (error) {
54
- return chunk64U3UDTH_cjs.handleError(error, "Error getting tool");
53
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting tool");
55
54
  }
56
55
  }
57
56
  function executeToolHandler(tools$1) {
@@ -60,38 +59,33 @@ function executeToolHandler(tools$1) {
60
59
  runId,
61
60
  toolId,
62
61
  data,
63
- runtimeContext,
64
- runtimeContextFromRequest
62
+ runtimeContext
65
63
  }) => {
66
64
  try {
67
65
  if (!toolId) {
68
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool ID is required" });
66
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool ID is required" });
69
67
  }
70
68
  const tool = Object.values(tools$1 || {}).find((tool2) => tool2.id === toolId);
71
69
  if (!tool) {
72
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
70
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
73
71
  }
74
72
  if (!tool?.execute) {
75
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
73
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
76
74
  }
77
- chunk57CJTIPW_cjs.validateBody({ data });
75
+ chunkCCGRCYWJ_cjs.validateBody({ data });
78
76
  if (tools.isVercelTool(tool)) {
79
77
  const result2 = await tool.execute(data);
80
78
  return result2;
81
79
  }
82
- const finalRuntimeContext = new di.RuntimeContext([
83
- ...Array.from(runtimeContext.entries()),
84
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
85
- ]);
86
80
  const result = await tool.execute({
87
81
  context: data,
88
82
  mastra,
89
83
  runId,
90
- runtimeContext: finalRuntimeContext
84
+ runtimeContext
91
85
  });
92
86
  return result;
93
87
  } catch (error) {
94
- return chunk64U3UDTH_cjs.handleError(error, "Error executing tool");
88
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
95
89
  }
96
90
  };
97
91
  }
@@ -100,34 +94,30 @@ async function executeAgentToolHandler({
100
94
  agentId,
101
95
  toolId,
102
96
  data,
103
- runtimeContext,
104
- runtimeContextFromRequest
97
+ runtimeContext
105
98
  }) {
106
99
  try {
107
100
  const agent = agentId ? mastra.getAgent(agentId) : null;
108
101
  if (!agent) {
109
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
102
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
110
103
  }
111
- 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);
112
106
  if (!tool) {
113
- throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Tool not found" });
107
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Tool not found" });
114
108
  }
115
109
  if (!tool?.execute) {
116
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
110
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Tool is not executable" });
117
111
  }
118
- const finalRuntimeContext = new di.RuntimeContext([
119
- ...Array.from(runtimeContext.entries()),
120
- ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
121
- ]);
122
112
  const result = await tool.execute({
123
113
  context: data,
124
- runtimeContext: finalRuntimeContext,
114
+ runtimeContext,
125
115
  mastra,
126
116
  runId: agentId
127
117
  });
128
118
  return result;
129
119
  } catch (error) {
130
- return chunk64U3UDTH_cjs.handleError(error, "Error executing tool");
120
+ return chunkPZQDCRPV_cjs.handleError(error, "Error executing tool");
131
121
  }
132
122
  }
133
123
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
4
- var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
3
+ var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
4
+ var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
5
5
  var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
6
 
7
7
  // src/server/handlers/telemetry.ts
@@ -15,13 +15,13 @@ async function getTelemetryHandler({ mastra, body }) {
15
15
  const telemetry = mastra.getTelemetry();
16
16
  const storage = mastra.getStorage();
17
17
  if (!telemetry) {
18
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
18
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Telemetry is not initialized" });
19
19
  }
20
20
  if (!storage) {
21
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Storage is not initialized" });
21
+ return [];
22
22
  }
23
23
  if (!body) {
24
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Body is required" });
24
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Body is required" });
25
25
  }
26
26
  const { name, scope, page, perPage, attribute, fromDate, toDate } = body;
27
27
  const attributes = attribute ? Object.fromEntries(
@@ -41,7 +41,7 @@ async function getTelemetryHandler({ mastra, body }) {
41
41
  });
42
42
  return traces;
43
43
  } catch (error2) {
44
- return chunk64U3UDTH_cjs.handleError(error2, "Error getting telemetry");
44
+ return chunkPZQDCRPV_cjs.handleError(error2, "Error getting telemetry");
45
45
  }
46
46
  }
47
47
  async function storeTelemetryHandler({ mastra, body }) {
@@ -49,7 +49,10 @@ async function storeTelemetryHandler({ mastra, body }) {
49
49
  const storage = mastra.getStorage();
50
50
  const logger = mastra.getLogger();
51
51
  if (!storage) {
52
- throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Storage is not initialized" });
52
+ return {
53
+ status: "error",
54
+ message: "Storage is not initialized"
55
+ };
53
56
  }
54
57
  const now = /* @__PURE__ */ new Date();
55
58
  const items = body?.resourceSpans?.[0]?.scopeSpans;
@@ -296,11 +296,11 @@ async function handleTaskSend({
296
296
  params,
297
297
  taskStore,
298
298
  agent,
299
+ agentId,
299
300
  logger,
300
301
  runtimeContext
301
302
  }) {
302
303
  validateTaskSendParams(params);
303
- const agentId = agent.id;
304
304
  const { id: taskId, message, sessionId, metadata } = params;
305
305
  let currentData = await loadOrCreateTaskAndHistory({
306
306
  taskId,
@@ -374,6 +374,7 @@ async function* handleTaskSendSubscribe({
374
374
  params,
375
375
  taskStore,
376
376
  agent,
377
+ agentId,
377
378
  logger,
378
379
  runtimeContext
379
380
  }) {
@@ -391,6 +392,7 @@ async function* handleTaskSendSubscribe({
391
392
  params,
392
393
  taskStore,
393
394
  agent,
395
+ agentId,
394
396
  runtimeContext,
395
397
  logger
396
398
  });
@@ -455,6 +457,7 @@ async function getAgentExecutionHandler({
455
457
  params,
456
458
  taskStore,
457
459
  agent,
460
+ agentId,
458
461
  runtimeContext
459
462
  });
460
463
  return result2;
@@ -465,6 +468,7 @@ async function getAgentExecutionHandler({
465
468
  taskStore,
466
469
  params,
467
470
  agent,
471
+ agentId,
468
472
  runtimeContext
469
473
  });
470
474
  return result;