@mastra/server 0.0.0-bundle-dynamic-imports-20250424001248 → 0.0.0-cli-debug-2-20250611100354

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 (81) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +331 -42
  3. package/dist/_tsup-dts-rollup.d.ts +331 -42
  4. package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
  5. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  6. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  7. package/dist/chunk-6F2H7Y45.js +255 -0
  8. package/dist/{chunk-2FJURXCL.cjs → chunk-6TJSHFCJ.cjs} +44 -36
  9. package/dist/chunk-75ZPJI57.cjs +9 -0
  10. package/dist/chunk-7IBZ4L35.js +344 -0
  11. package/dist/{chunk-7IWQE76Z.cjs → chunk-B4MQFJ7G.cjs} +16 -10
  12. package/dist/{chunk-WTHDCRMY.js → chunk-BFOA2QQY.js} +12 -6
  13. package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  14. package/dist/{chunk-RE6YL32K.js → chunk-C7564HUT.js} +52 -30
  15. package/dist/{chunk-55HTWX4C.cjs → chunk-CMMOIUFC.cjs} +40 -19
  16. package/dist/{chunk-Q6SHQECN.js → chunk-CP55EVBK.js} +24 -4
  17. package/dist/chunk-GHC4YV6R.js +504 -0
  18. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  19. package/dist/{chunk-5JNVY6DU.js → chunk-HYP7B2TL.js} +7 -5
  20. package/dist/{chunk-RBQASTUP.js → chunk-I7KJZNX5.js} +14 -6
  21. package/dist/chunk-IMBY5XUG.cjs +86 -0
  22. package/dist/chunk-JEWNMAYQ.cjs +263 -0
  23. package/dist/chunk-JKF6PRPU.cjs +357 -0
  24. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  25. package/dist/chunk-MLKGABMK.js +7 -0
  26. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  27. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  28. package/dist/chunk-QLG2PFHE.js +81 -0
  29. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  30. package/dist/{chunk-LFOBHRFO.js → chunk-TEZOEGR4.js} +69 -54
  31. package/dist/{chunk-D3G23FP3.cjs → chunk-TJO277H7.cjs} +24 -22
  32. package/dist/chunk-UZ7FJ66C.cjs +332 -0
  33. package/dist/{chunk-FPIWDH5Y.cjs → chunk-VPNDC2DI.cjs} +62 -40
  34. package/dist/chunk-WKWHYFX4.js +2001 -0
  35. package/dist/chunk-XUGQSVZ4.cjs +2004 -0
  36. package/dist/server/handlers/a2a.cjs +30 -0
  37. package/dist/server/handlers/a2a.d.cts +6 -0
  38. package/dist/server/handlers/a2a.d.ts +6 -0
  39. package/dist/server/handlers/a2a.js +1 -0
  40. package/dist/server/handlers/agents.cjs +7 -7
  41. package/dist/server/handlers/agents.js +1 -1
  42. package/dist/server/handlers/error.cjs +2 -2
  43. package/dist/server/handlers/error.js +1 -1
  44. package/dist/server/handlers/legacyWorkflows.cjs +46 -0
  45. package/dist/server/handlers/legacyWorkflows.d.cts +10 -0
  46. package/dist/server/handlers/legacyWorkflows.d.ts +10 -0
  47. package/dist/server/handlers/legacyWorkflows.js +1 -0
  48. package/dist/server/handlers/logs.cjs +4 -4
  49. package/dist/server/handlers/logs.js +1 -1
  50. package/dist/server/handlers/memory.cjs +9 -9
  51. package/dist/server/handlers/memory.js +1 -1
  52. package/dist/server/handlers/network.cjs +5 -5
  53. package/dist/server/handlers/network.js +1 -1
  54. package/dist/server/handlers/telemetry.cjs +3 -3
  55. package/dist/server/handlers/telemetry.js +1 -1
  56. package/dist/server/handlers/tools.cjs +5 -5
  57. package/dist/server/handlers/tools.js +1 -1
  58. package/dist/server/handlers/utils.cjs +2 -2
  59. package/dist/server/handlers/utils.js +1 -1
  60. package/dist/server/handlers/vector.cjs +7 -7
  61. package/dist/server/handlers/vector.js +1 -1
  62. package/dist/server/handlers/voice.cjs +8 -4
  63. package/dist/server/handlers/voice.d.cts +1 -0
  64. package/dist/server/handlers/voice.d.ts +1 -0
  65. package/dist/server/handlers/voice.js +1 -1
  66. package/dist/server/handlers/workflows.cjs +17 -13
  67. package/dist/server/handlers/workflows.d.cts +3 -2
  68. package/dist/server/handlers/workflows.d.ts +3 -2
  69. package/dist/server/handlers/workflows.js +1 -1
  70. package/dist/server/handlers.cjs +33 -23
  71. package/dist/server/handlers.d.cts +2 -0
  72. package/dist/server/handlers.d.ts +2 -0
  73. package/dist/server/handlers.js +11 -9
  74. package/package.json +12 -10
  75. package/dist/chunk-3EJZQ6TQ.js +0 -49
  76. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  77. package/dist/chunk-HCOPJZ4A.cjs +0 -164
  78. package/dist/chunk-OMN3UI6X.js +0 -5576
  79. package/dist/chunk-R4J7XQYU.js +0 -156
  80. package/dist/chunk-SKBVVI24.cjs +0 -54
  81. package/dist/chunk-TZK63M5N.cjs +0 -317
@@ -1,25 +1,26 @@
1
- import { stringify, esm_default } from './chunk-OMN3UI6X.js';
2
- import { handleError } from './chunk-3AHQ5RGN.js';
3
- import { __export, HTTPException } from './chunk-TRDNDNGQ.js';
4
- import { ReadableStream } from 'node:stream/web';
1
+ import { stringify, esm_default } from './chunk-WKWHYFX4.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { HTTPException } from './chunk-NYN7KFXL.js';
4
+ import { __export } from './chunk-MLKGABMK.js';
5
+ import { ReadableStream } from 'stream/web';
5
6
 
6
- // src/server/handlers/workflows.ts
7
- var workflows_exports = {};
8
- __export(workflows_exports, {
9
- createRunHandler: () => createRunHandler,
10
- getWorkflowByIdHandler: () => getWorkflowByIdHandler,
11
- getWorkflowRunHandler: () => getWorkflowRunHandler,
12
- getWorkflowRunsHandler: () => getWorkflowRunsHandler,
13
- getWorkflowsHandler: () => getWorkflowsHandler,
14
- resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
15
- resumeWorkflowHandler: () => resumeWorkflowHandler,
16
- startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
17
- startWorkflowRunHandler: () => startWorkflowRunHandler,
18
- watchWorkflowHandler: () => watchWorkflowHandler
7
+ // src/server/handlers/legacyWorkflows.ts
8
+ var legacyWorkflows_exports = {};
9
+ __export(legacyWorkflows_exports, {
10
+ createLegacyWorkflowRunHandler: () => createLegacyWorkflowRunHandler,
11
+ getLegacyWorkflowByIdHandler: () => getLegacyWorkflowByIdHandler,
12
+ getLegacyWorkflowRunHandler: () => getLegacyWorkflowRunHandler,
13
+ getLegacyWorkflowRunsHandler: () => getLegacyWorkflowRunsHandler,
14
+ getLegacyWorkflowsHandler: () => getLegacyWorkflowsHandler,
15
+ resumeAsyncLegacyWorkflowHandler: () => resumeAsyncLegacyWorkflowHandler,
16
+ resumeLegacyWorkflowHandler: () => resumeLegacyWorkflowHandler,
17
+ startAsyncLegacyWorkflowHandler: () => startAsyncLegacyWorkflowHandler,
18
+ startLegacyWorkflowRunHandler: () => startLegacyWorkflowRunHandler,
19
+ watchLegacyWorkflowHandler: () => watchLegacyWorkflowHandler
19
20
  });
20
- async function getWorkflowsHandler({ mastra }) {
21
+ async function getLegacyWorkflowsHandler({ mastra }) {
21
22
  try {
22
- const workflows = mastra.getWorkflows({ serialized: false });
23
+ const workflows = mastra.legacy_getWorkflows({ serialized: false });
23
24
  const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
24
25
  if (workflow.isNested) return acc;
25
26
  acc[key] = {
@@ -32,7 +33,9 @@ async function getWorkflowsHandler({ mastra }) {
32
33
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
33
34
  const _step = step;
34
35
  acc2[key2] = {
35
- ..._step,
36
+ id: _step.id,
37
+ description: _step.description,
38
+ workflowId: _step.workflowId,
36
39
  inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
37
40
  outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
38
41
  };
@@ -46,12 +49,12 @@ async function getWorkflowsHandler({ mastra }) {
46
49
  throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
47
50
  }
48
51
  }
49
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
52
+ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
50
53
  try {
51
54
  if (!workflowId) {
52
55
  throw new HTTPException(400, { message: "Workflow ID is required" });
53
56
  }
54
- const workflow = mastra.getWorkflow(workflowId);
57
+ const workflow = mastra.legacy_getWorkflow(workflowId);
55
58
  if (!workflow) {
56
59
  throw new HTTPException(404, { message: "Workflow not found" });
57
60
  }
@@ -65,7 +68,9 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
65
68
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
66
69
  const _step = step;
67
70
  acc[key] = {
68
- ..._step,
71
+ id: _step.id,
72
+ description: _step.description,
73
+ workflowId: _step.workflowId,
69
74
  inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
70
75
  outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
71
76
  };
@@ -76,7 +81,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
76
81
  throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
77
82
  }
78
83
  }
79
- async function startAsyncWorkflowHandler({
84
+ async function startAsyncLegacyWorkflowHandler({
80
85
  mastra,
81
86
  runtimeContext,
82
87
  workflowId,
@@ -87,19 +92,19 @@ async function startAsyncWorkflowHandler({
87
92
  if (!workflowId) {
88
93
  throw new HTTPException(400, { message: "Workflow ID is required" });
89
94
  }
90
- const workflow = mastra.getWorkflow(workflowId);
95
+ const workflow = mastra.legacy_getWorkflow(workflowId);
91
96
  if (!workflow) {
92
97
  throw new HTTPException(404, { message: "Workflow not found" });
93
98
  }
94
99
  if (!runId) {
95
- const { start } = workflow.createRun();
96
- const result2 = await start({
100
+ const newRun = workflow.createRun();
101
+ const result2 = await newRun.start({
97
102
  triggerData,
98
103
  runtimeContext
99
104
  });
100
105
  return result2;
101
106
  }
102
- const run = workflow.getRun(runId);
107
+ const run = workflow.getMemoryRun(runId);
103
108
  if (!run) {
104
109
  throw new HTTPException(404, { message: "Workflow run not found" });
105
110
  }
@@ -112,7 +117,7 @@ async function startAsyncWorkflowHandler({
112
117
  throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
113
118
  }
114
119
  }
115
- async function getWorkflowRunHandler({
120
+ async function getLegacyWorkflowRunHandler({
116
121
  mastra,
117
122
  workflowId,
118
123
  runId
@@ -124,11 +129,11 @@ async function getWorkflowRunHandler({
124
129
  if (!runId) {
125
130
  throw new HTTPException(400, { message: "Run ID is required" });
126
131
  }
127
- const workflow = mastra.getWorkflow(workflowId);
132
+ const workflow = mastra.legacy_getWorkflow(workflowId);
128
133
  if (!workflow) {
129
134
  throw new HTTPException(404, { message: "Workflow not found" });
130
135
  }
131
- const run = workflow.getRun(runId);
136
+ const run = await workflow.getRun(runId);
132
137
  if (!run) {
133
138
  throw new HTTPException(404, { message: "Workflow run not found" });
134
139
  }
@@ -137,7 +142,7 @@ async function getWorkflowRunHandler({
137
142
  throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
138
143
  }
139
144
  }
140
- async function createRunHandler({
145
+ async function createLegacyWorkflowRunHandler({
141
146
  mastra,
142
147
  workflowId,
143
148
  runId: prevRunId
@@ -146,17 +151,17 @@ async function createRunHandler({
146
151
  if (!workflowId) {
147
152
  throw new HTTPException(400, { message: "Workflow ID is required" });
148
153
  }
149
- const workflow = mastra.getWorkflow(workflowId);
154
+ const workflow = mastra.legacy_getWorkflow(workflowId);
150
155
  if (!workflow) {
151
156
  throw new HTTPException(404, { message: "Workflow not found" });
152
157
  }
153
- const { runId } = workflow.createRun({ runId: prevRunId });
154
- return { runId };
158
+ const newRun = workflow.createRun({ runId: prevRunId });
159
+ return { runId: newRun.runId };
155
160
  } catch (error) {
156
161
  throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
157
162
  }
158
163
  }
159
- async function startWorkflowRunHandler({
164
+ async function startLegacyWorkflowRunHandler({
160
165
  mastra,
161
166
  runtimeContext,
162
167
  workflowId,
@@ -170,12 +175,12 @@ async function startWorkflowRunHandler({
170
175
  if (!runId) {
171
176
  throw new HTTPException(400, { message: "runId required to start run" });
172
177
  }
173
- const workflow = mastra.getWorkflow(workflowId);
174
- const run = workflow.getRun(runId);
178
+ const workflow = mastra.legacy_getWorkflow(workflowId);
179
+ const run = workflow.getMemoryRun(runId);
175
180
  if (!run) {
176
181
  throw new HTTPException(404, { message: "Workflow run not found" });
177
182
  }
178
- await run.start({
183
+ void run.start({
179
184
  triggerData,
180
185
  runtimeContext
181
186
  });
@@ -184,7 +189,7 @@ async function startWorkflowRunHandler({
184
189
  return handleError(e, "Error starting workflow run");
185
190
  }
186
191
  }
187
- async function watchWorkflowHandler({
192
+ async function watchLegacyWorkflowHandler({
188
193
  mastra,
189
194
  workflowId,
190
195
  runId
@@ -196,8 +201,8 @@ async function watchWorkflowHandler({
196
201
  if (!runId) {
197
202
  throw new HTTPException(400, { message: "runId required to watch workflow" });
198
203
  }
199
- const workflow = mastra.getWorkflow(workflowId);
200
- const run = workflow.getRun(runId);
204
+ const workflow = mastra.legacy_getWorkflow(workflowId);
205
+ const run = workflow.getMemoryRun(runId);
201
206
  if (!run) {
202
207
  throw new HTTPException(404, { message: "Workflow run not found" });
203
208
  }
@@ -213,8 +218,10 @@ async function watchWorkflowHandler({
213
218
  asyncRef = null;
214
219
  }
215
220
  asyncRef = setImmediate(() => {
216
- if (!workflow.getRun(runId2)) {
221
+ const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
222
+ if (runDone) {
217
223
  controller.close();
224
+ unwatch?.();
218
225
  }
219
226
  });
220
227
  });
@@ -228,7 +235,7 @@ async function watchWorkflowHandler({
228
235
  return handleError(error, "Error watching workflow");
229
236
  }
230
237
  }
231
- async function resumeAsyncWorkflowHandler({
238
+ async function resumeAsyncLegacyWorkflowHandler({
232
239
  mastra,
233
240
  workflowId,
234
241
  runId,
@@ -242,8 +249,8 @@ async function resumeAsyncWorkflowHandler({
242
249
  if (!runId) {
243
250
  throw new HTTPException(400, { message: "runId required to resume workflow" });
244
251
  }
245
- const workflow = mastra.getWorkflow(workflowId);
246
- const run = workflow.getRun(runId);
252
+ const workflow = mastra.legacy_getWorkflow(workflowId);
253
+ const run = workflow.getMemoryRun(runId);
247
254
  if (!run) {
248
255
  throw new HTTPException(404, { message: "Workflow run not found" });
249
256
  }
@@ -257,7 +264,7 @@ async function resumeAsyncWorkflowHandler({
257
264
  return handleError(error, "Error resuming workflow step");
258
265
  }
259
266
  }
260
- async function resumeWorkflowHandler({
267
+ async function resumeLegacyWorkflowHandler({
261
268
  mastra,
262
269
  workflowId,
263
270
  runId,
@@ -271,12 +278,12 @@ async function resumeWorkflowHandler({
271
278
  if (!runId) {
272
279
  throw new HTTPException(400, { message: "runId required to resume workflow" });
273
280
  }
274
- const workflow = mastra.getWorkflow(workflowId);
275
- const run = workflow.getRun(runId);
281
+ const workflow = mastra.legacy_getWorkflow(workflowId);
282
+ const run = workflow.getMemoryRun(runId);
276
283
  if (!run) {
277
284
  throw new HTTPException(404, { message: "Workflow run not found" });
278
285
  }
279
- await run.resume({
286
+ void run.resume({
280
287
  stepId: body.stepId,
281
288
  context: body.context,
282
289
  runtimeContext
@@ -286,13 +293,21 @@ async function resumeWorkflowHandler({
286
293
  return handleError(error, "Error resuming workflow");
287
294
  }
288
295
  }
289
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
296
+ async function getLegacyWorkflowRunsHandler({
297
+ mastra,
298
+ workflowId,
299
+ fromDate,
300
+ toDate,
301
+ limit,
302
+ offset,
303
+ resourceId
304
+ }) {
290
305
  try {
291
306
  if (!workflowId) {
292
307
  throw new HTTPException(400, { message: "Workflow ID is required" });
293
308
  }
294
- const workflow = mastra.getWorkflow(workflowId);
295
- const workflowRuns = await workflow.getWorkflowRuns() || {
309
+ const workflow = mastra.legacy_getWorkflow(workflowId);
310
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
296
311
  runs: [],
297
312
  total: 0
298
313
  };
@@ -302,4 +317,4 @@ async function getWorkflowRunsHandler({ mastra, workflowId }) {
302
317
  }
303
318
  }
304
319
 
305
- export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, workflows_exports };
320
+ export { createLegacyWorkflowRunHandler, getLegacyWorkflowByIdHandler, getLegacyWorkflowRunHandler, getLegacyWorkflowRunsHandler, getLegacyWorkflowsHandler, legacyWorkflows_exports, resumeAsyncLegacyWorkflowHandler, resumeLegacyWorkflowHandler, startAsyncLegacyWorkflowHandler, startLegacyWorkflowRunHandler, watchLegacyWorkflowHandler };
@@ -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 chunkXUGQSVZ4_cjs = require('./chunk-XUGQSVZ4.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');
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 ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(tool.inputSchema)) : void 0,
29
+ outputSchema: tool.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_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 chunk64U3UDTH_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 chunkOCWPVYNI_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 ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(tool.inputSchema)) : void 0,
49
+ outputSchema: tool.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_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 chunk64U3UDTH_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 chunkOCWPVYNI_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 chunkOCWPVYNI_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 chunkOCWPVYNI_cjs.HTTPException(400, { message: "Tool is not executable" });
73
74
  }
74
- chunkQN4KF3BH_cjs.validateBody({ data });
75
+ chunk57CJTIPW_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 chunk64U3UDTH_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 chunkOCWPVYNI_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 chunkOCWPVYNI_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 chunkOCWPVYNI_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 chunk64U3UDTH_cjs.handleError(error, "Error executing tool");
119
121
  }
120
122
  }
121
123