@mastra/server 0.0.0-fix-message-embedding-20250506021742 → 0.0.0-fix-generate-title-20250616171351

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/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +296 -100
  3. package/dist/_tsup-dts-rollup.d.ts +296 -100
  4. package/dist/{chunk-5JNVY6DU.js → chunk-2HXKRRNS.js} +7 -5
  5. package/dist/{chunk-Y3SV5XK4.js → chunk-4O23XCE5.js} +94 -13
  6. package/dist/{chunk-4JINXASC.js → chunk-55DOQLP6.js} +5 -4
  7. package/dist/{chunk-QN4KF3BH.cjs → chunk-57CJTIPW.cjs} +2 -2
  8. package/dist/{chunk-ZLBRQFDD.cjs → chunk-64U3UDTH.cjs} +2 -2
  9. package/dist/{chunk-2FJURXCL.cjs → chunk-6TJSHFCJ.cjs} +44 -36
  10. package/dist/chunk-75ZPJI57.cjs +9 -0
  11. package/dist/chunk-ASKESBJW.cjs +2004 -0
  12. package/dist/{chunk-AMVOS7YB.cjs → chunk-B4MQFJ7G.cjs} +12 -8
  13. package/dist/{chunk-BPL2CBLV.js → chunk-BFOA2QQY.js} +8 -4
  14. package/dist/{chunk-M56ECCHK.cjs → chunk-BNEY4P4P.cjs} +20 -19
  15. package/dist/{chunk-QJ3AHN64.js → chunk-C7564HUT.js} +4 -3
  16. package/dist/chunk-C75ZRJKD.cjs +270 -0
  17. package/dist/{chunk-3XTEV33Q.js → chunk-CLYX4KLH.js} +54 -51
  18. package/dist/{chunk-55HTWX4C.cjs → chunk-CMMOIUFC.cjs} +40 -19
  19. package/dist/{chunk-Q6SHQECN.js → chunk-CP55EVBK.js} +24 -4
  20. package/dist/chunk-FRXZL32L.cjs +471 -0
  21. package/dist/chunk-GHC4YV6R.js +504 -0
  22. package/dist/{chunk-L7XE5QTW.js → chunk-H5PTF3Y4.js} +1 -1
  23. package/dist/{chunk-RBQASTUP.js → chunk-I7KJZNX5.js} +14 -6
  24. package/dist/chunk-IMBY5XUG.cjs +86 -0
  25. package/dist/{chunk-IQTNZSFP.js → chunk-JKTNRUKY.js} +194 -49
  26. package/dist/{chunk-3AHQ5RGN.js → chunk-M5ABIP7D.js} +1 -1
  27. package/dist/chunk-MLKGABMK.js +7 -0
  28. package/dist/{chunk-D3G23FP3.cjs → chunk-NGURCFEJ.cjs} +24 -22
  29. package/dist/{chunk-TRDNDNGQ.js → chunk-NYN7KFXL.js} +1 -7
  30. package/dist/{chunk-FV45V6WC.cjs → chunk-OCWPVYNI.cjs} +0 -7
  31. package/dist/chunk-QLG2PFHE.js +81 -0
  32. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  33. package/dist/chunk-TGJMNUYJ.js +2001 -0
  34. package/dist/{chunk-5YGDYMRB.cjs → chunk-VPNDC2DI.cjs} +14 -13
  35. package/dist/chunk-WE32JG64.cjs +332 -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 +21 -13
  67. package/dist/server/handlers/workflows.d.cts +4 -2
  68. package/dist/server/handlers/workflows.d.ts +4 -2
  69. package/dist/server/handlers/workflows.js +1 -1
  70. package/dist/server/handlers.cjs +32 -27
  71. package/dist/server/handlers.d.cts +2 -1
  72. package/dist/server/handlers.d.ts +2 -1
  73. package/dist/server/handlers.js +11 -10
  74. package/package.json +13 -12
  75. package/dist/chunk-3EJZQ6TQ.js +0 -49
  76. package/dist/chunk-4BIX6GMY.cjs +0 -189
  77. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  78. package/dist/chunk-CHFORQ7J.cjs +0 -329
  79. package/dist/chunk-FOXHTOQZ.cjs +0 -324
  80. package/dist/chunk-OMN3UI6X.js +0 -5576
  81. package/dist/chunk-SKBVVI24.cjs +0 -54
  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,28 +1,33 @@
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-TGJMNUYJ.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';
6
+ import { RuntimeContext } from '@mastra/core/di';
5
7
 
6
- // src/server/handlers/vNextWorkflows.ts
7
- var vNextWorkflows_exports = {};
8
- __export(vNextWorkflows_exports, {
9
- createVNextWorkflowRunHandler: () => createVNextWorkflowRunHandler,
10
- getVNextWorkflowByIdHandler: () => getVNextWorkflowByIdHandler,
11
- getVNextWorkflowRunHandler: () => getVNextWorkflowRunHandler,
12
- getVNextWorkflowRunsHandler: () => getVNextWorkflowRunsHandler,
13
- getVNextWorkflowsHandler: () => getVNextWorkflowsHandler,
14
- resumeAsyncVNextWorkflowHandler: () => resumeAsyncVNextWorkflowHandler,
15
- resumeVNextWorkflowHandler: () => resumeVNextWorkflowHandler,
16
- startAsyncVNextWorkflowHandler: () => startAsyncVNextWorkflowHandler,
17
- startVNextWorkflowRunHandler: () => startVNextWorkflowRunHandler,
18
- watchVNextWorkflowHandler: () => watchVNextWorkflowHandler
8
+ // src/server/handlers/workflows.ts
9
+ var workflows_exports = {};
10
+ __export(workflows_exports, {
11
+ createWorkflowRunHandler: () => createWorkflowRunHandler,
12
+ getWorkflowByIdHandler: () => getWorkflowByIdHandler,
13
+ getWorkflowRunByIdHandler: () => getWorkflowRunByIdHandler,
14
+ getWorkflowRunExecutionResultHandler: () => getWorkflowRunExecutionResultHandler,
15
+ getWorkflowRunsHandler: () => getWorkflowRunsHandler,
16
+ getWorkflowsHandler: () => getWorkflowsHandler,
17
+ resumeAsyncWorkflowHandler: () => resumeAsyncWorkflowHandler,
18
+ resumeWorkflowHandler: () => resumeWorkflowHandler,
19
+ startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
20
+ startWorkflowRunHandler: () => startWorkflowRunHandler,
21
+ streamWorkflowHandler: () => streamWorkflowHandler,
22
+ watchWorkflowHandler: () => watchWorkflowHandler
19
23
  });
20
- async function getVNextWorkflowsHandler({ mastra }) {
24
+ async function getWorkflowsHandler({ mastra }) {
21
25
  try {
22
- const workflows = mastra.vnext_getWorkflows({ serialized: false });
26
+ const workflows = mastra.getWorkflows({ serialized: false });
23
27
  const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
24
28
  acc[key] = {
25
29
  name: workflow.name,
30
+ description: workflow.description,
26
31
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
27
32
  acc2[key2] = {
28
33
  id: step.id,
@@ -45,12 +50,46 @@ async function getVNextWorkflowsHandler({ mastra }) {
45
50
  throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
46
51
  }
47
52
  }
48
- async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
53
+ async function getWorkflowsFromSystem({ mastra, workflowId }) {
54
+ const logger = mastra.getLogger();
55
+ if (!workflowId) {
56
+ throw new HTTPException(400, { message: "Workflow ID is required" });
57
+ }
58
+ let workflow;
59
+ try {
60
+ workflow = mastra.getWorkflow(workflowId);
61
+ } catch (error) {
62
+ logger.debug("Error getting workflow, searching agents for workflow", error);
63
+ }
64
+ if (!workflow) {
65
+ logger.debug("Workflow not found, searching agents for workflow", { workflowId });
66
+ const agents = mastra.getAgents();
67
+ if (Object.keys(agents || {}).length) {
68
+ for (const [_, agent] of Object.entries(agents)) {
69
+ try {
70
+ const workflows = await agent.getWorkflows();
71
+ if (workflows[workflowId]) {
72
+ workflow = workflows[workflowId];
73
+ break;
74
+ }
75
+ break;
76
+ } catch (error) {
77
+ logger.debug("Error getting workflow from agent", error);
78
+ }
79
+ }
80
+ }
81
+ }
82
+ if (!workflow) {
83
+ throw new HTTPException(404, { message: "Workflow not found" });
84
+ }
85
+ return { workflow };
86
+ }
87
+ async function getWorkflowByIdHandler({ mastra, workflowId }) {
49
88
  try {
50
89
  if (!workflowId) {
51
90
  throw new HTTPException(400, { message: "Workflow ID is required" });
52
91
  }
53
- const workflow = mastra.vnext_getWorkflow(workflowId);
92
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
54
93
  if (!workflow) {
55
94
  throw new HTTPException(404, { message: "Workflow not found" });
56
95
  }
@@ -67,6 +106,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
67
106
  return acc;
68
107
  }, {}),
69
108
  name: workflow.name,
109
+ description: workflow.description,
70
110
  stepGraph: workflow.serializedStepGraph,
71
111
  inputSchema: workflow.inputSchema ? stringify(esm_default(workflow.inputSchema)) : void 0,
72
112
  outputSchema: workflow.outputSchema ? stringify(esm_default(workflow.outputSchema)) : void 0
@@ -75,7 +115,7 @@ async function getVNextWorkflowByIdHandler({ mastra, workflowId }) {
75
115
  throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
76
116
  }
77
117
  }
78
- async function getVNextWorkflowRunHandler({
118
+ async function getWorkflowRunByIdHandler({
79
119
  mastra,
80
120
  workflowId,
81
121
  runId
@@ -87,11 +127,11 @@ async function getVNextWorkflowRunHandler({
87
127
  if (!runId) {
88
128
  throw new HTTPException(400, { message: "Run ID is required" });
89
129
  }
90
- const workflow = mastra.vnext_getWorkflow(workflowId);
130
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
91
131
  if (!workflow) {
92
132
  throw new HTTPException(404, { message: "Workflow not found" });
93
133
  }
94
- const run = await workflow.getWorkflowRun(runId);
134
+ const run = await workflow.getWorkflowRunById(runId);
95
135
  if (!run) {
96
136
  throw new HTTPException(404, { message: "Workflow run not found" });
97
137
  }
@@ -100,7 +140,34 @@ async function getVNextWorkflowRunHandler({
100
140
  throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
101
141
  }
102
142
  }
103
- async function createVNextWorkflowRunHandler({
143
+ async function getWorkflowRunExecutionResultHandler({
144
+ mastra,
145
+ workflowId,
146
+ runId
147
+ }) {
148
+ try {
149
+ if (!workflowId) {
150
+ throw new HTTPException(400, { message: "Workflow ID is required" });
151
+ }
152
+ if (!runId) {
153
+ throw new HTTPException(400, { message: "Run ID is required" });
154
+ }
155
+ const workflow = mastra.getWorkflow(workflowId);
156
+ if (!workflow) {
157
+ throw new HTTPException(404, { message: "Workflow not found" });
158
+ }
159
+ const executionResult = await workflow.getWorkflowRunExecutionResult(runId);
160
+ if (!executionResult) {
161
+ throw new HTTPException(404, { message: "Workflow run execution result not found" });
162
+ }
163
+ return executionResult;
164
+ } catch (error) {
165
+ throw new HTTPException(500, {
166
+ message: error?.message || "Error getting workflow run execution result"
167
+ });
168
+ }
169
+ }
170
+ async function createWorkflowRunHandler({
104
171
  mastra,
105
172
  workflowId,
106
173
  runId: prevRunId
@@ -109,7 +176,7 @@ async function createVNextWorkflowRunHandler({
109
176
  if (!workflowId) {
110
177
  throw new HTTPException(400, { message: "Workflow ID is required" });
111
178
  }
112
- const workflow = mastra.vnext_getWorkflow(workflowId);
179
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
113
180
  if (!workflow) {
114
181
  throw new HTTPException(404, { message: "Workflow not found" });
115
182
  }
@@ -119,9 +186,9 @@ async function createVNextWorkflowRunHandler({
119
186
  throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
120
187
  }
121
188
  }
122
- async function startAsyncVNextWorkflowHandler({
189
+ async function startAsyncWorkflowHandler({
123
190
  mastra,
124
- runtimeContext,
191
+ runtimeContext: payloadRuntimeContext,
125
192
  workflowId,
126
193
  runId,
127
194
  inputData
@@ -130,10 +197,17 @@ async function startAsyncVNextWorkflowHandler({
130
197
  if (!workflowId) {
131
198
  throw new HTTPException(400, { message: "Workflow ID is required" });
132
199
  }
133
- const workflow = mastra.vnext_getWorkflow(workflowId);
200
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
134
201
  if (!workflow) {
135
202
  throw new HTTPException(404, { message: "Workflow not found" });
136
203
  }
204
+ let runtimeContext;
205
+ if (payloadRuntimeContext) {
206
+ runtimeContext = new RuntimeContext();
207
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
208
+ runtimeContext.set(key, value);
209
+ });
210
+ }
137
211
  const _run = workflow.createRun({ runId });
138
212
  const result = await _run.start({
139
213
  inputData,
@@ -144,9 +218,9 @@ async function startAsyncVNextWorkflowHandler({
144
218
  throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
145
219
  }
146
220
  }
147
- async function startVNextWorkflowRunHandler({
221
+ async function startWorkflowRunHandler({
148
222
  mastra,
149
- runtimeContext,
223
+ runtimeContext: payloadRuntimeContext,
150
224
  workflowId,
151
225
  runId,
152
226
  inputData
@@ -158,13 +232,23 @@ async function startVNextWorkflowRunHandler({
158
232
  if (!runId) {
159
233
  throw new HTTPException(400, { message: "runId required to start run" });
160
234
  }
161
- const workflow = mastra.vnext_getWorkflow(workflowId);
162
- const run = await workflow.getWorkflowRun(runId);
235
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
236
+ if (!workflow) {
237
+ throw new HTTPException(404, { message: "Workflow not found" });
238
+ }
239
+ const run = await workflow.getWorkflowRunById(runId);
163
240
  if (!run) {
164
241
  throw new HTTPException(404, { message: "Workflow run not found" });
165
242
  }
243
+ let runtimeContext;
244
+ if (payloadRuntimeContext) {
245
+ runtimeContext = new RuntimeContext();
246
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
247
+ runtimeContext.set(key, value);
248
+ });
249
+ }
166
250
  const _run = workflow.createRun({ runId });
167
- await _run.start({
251
+ void _run.start({
168
252
  inputData,
169
253
  runtimeContext
170
254
  });
@@ -173,7 +257,7 @@ async function startVNextWorkflowRunHandler({
173
257
  return handleError(e, "Error starting workflow run");
174
258
  }
175
259
  }
176
- async function watchVNextWorkflowHandler({
260
+ async function watchWorkflowHandler({
177
261
  mastra,
178
262
  workflowId,
179
263
  runId
@@ -185,8 +269,11 @@ async function watchVNextWorkflowHandler({
185
269
  if (!runId) {
186
270
  throw new HTTPException(400, { message: "runId required to watch workflow" });
187
271
  }
188
- const workflow = mastra.vnext_getWorkflow(workflowId);
189
- const run = await workflow.getWorkflowRun(runId);
272
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
273
+ if (!workflow) {
274
+ throw new HTTPException(404, { message: "Workflow not found" });
275
+ }
276
+ const run = await workflow.getWorkflowRunById(runId);
190
277
  if (!run) {
191
278
  throw new HTTPException(404, { message: "Workflow run not found" });
192
279
  }
@@ -219,12 +306,47 @@ async function watchVNextWorkflowHandler({
219
306
  return handleError(error, "Error watching workflow");
220
307
  }
221
308
  }
222
- async function resumeAsyncVNextWorkflowHandler({
309
+ async function streamWorkflowHandler({
310
+ mastra,
311
+ runtimeContext: payloadRuntimeContext,
312
+ workflowId,
313
+ runId,
314
+ inputData
315
+ }) {
316
+ try {
317
+ if (!workflowId) {
318
+ throw new HTTPException(400, { message: "Workflow ID is required" });
319
+ }
320
+ if (!runId) {
321
+ throw new HTTPException(400, { message: "runId required to resume workflow" });
322
+ }
323
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
324
+ if (!workflow) {
325
+ throw new HTTPException(404, { message: "Workflow not found" });
326
+ }
327
+ let runtimeContext;
328
+ if (payloadRuntimeContext) {
329
+ runtimeContext = new RuntimeContext();
330
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
331
+ runtimeContext.set(key, value);
332
+ });
333
+ }
334
+ const run = workflow.createRun({ runId });
335
+ const result = run.stream({
336
+ inputData,
337
+ runtimeContext
338
+ });
339
+ return result;
340
+ } catch (error) {
341
+ return handleError(error, "Error executing workflow");
342
+ }
343
+ }
344
+ async function resumeAsyncWorkflowHandler({
223
345
  mastra,
224
346
  workflowId,
225
347
  runId,
226
348
  body,
227
- runtimeContext
349
+ runtimeContext: payloadRuntimeContext
228
350
  }) {
229
351
  try {
230
352
  if (!workflowId) {
@@ -236,11 +358,21 @@ async function resumeAsyncVNextWorkflowHandler({
236
358
  if (!body.step) {
237
359
  throw new HTTPException(400, { message: "step required to resume workflow" });
238
360
  }
239
- const workflow = mastra.vnext_getWorkflow(workflowId);
240
- const run = await workflow.getWorkflowRun(runId);
361
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
362
+ if (!workflow) {
363
+ throw new HTTPException(404, { message: "Workflow not found" });
364
+ }
365
+ const run = await workflow.getWorkflowRunById(runId);
241
366
  if (!run) {
242
367
  throw new HTTPException(404, { message: "Workflow run not found" });
243
368
  }
369
+ let runtimeContext;
370
+ if (payloadRuntimeContext) {
371
+ runtimeContext = new RuntimeContext();
372
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
373
+ runtimeContext.set(key, value);
374
+ });
375
+ }
244
376
  const _run = workflow.createRun({ runId });
245
377
  const result = await _run.resume({
246
378
  step: body.step,
@@ -252,12 +384,12 @@ async function resumeAsyncVNextWorkflowHandler({
252
384
  return handleError(error, "Error resuming workflow step");
253
385
  }
254
386
  }
255
- async function resumeVNextWorkflowHandler({
387
+ async function resumeWorkflowHandler({
256
388
  mastra,
257
389
  workflowId,
258
390
  runId,
259
391
  body,
260
- runtimeContext
392
+ runtimeContext: payloadRuntimeContext
261
393
  }) {
262
394
  try {
263
395
  if (!workflowId) {
@@ -269,13 +401,23 @@ async function resumeVNextWorkflowHandler({
269
401
  if (!body.step) {
270
402
  throw new HTTPException(400, { message: "step required to resume workflow" });
271
403
  }
272
- const workflow = mastra.vnext_getWorkflow(workflowId);
273
- const run = await workflow.getWorkflowRun(runId);
404
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
405
+ if (!workflow) {
406
+ throw new HTTPException(404, { message: "Workflow not found" });
407
+ }
408
+ const run = await workflow.getWorkflowRunById(runId);
274
409
  if (!run) {
275
410
  throw new HTTPException(404, { message: "Workflow run not found" });
276
411
  }
412
+ let runtimeContext;
413
+ if (payloadRuntimeContext) {
414
+ runtimeContext = new RuntimeContext();
415
+ Object.entries(payloadRuntimeContext || {}).forEach(([key, value]) => {
416
+ runtimeContext.set(key, value);
417
+ });
418
+ }
277
419
  const _run = workflow.createRun({ runId });
278
- await _run.resume({
420
+ void _run.resume({
279
421
  step: body.step,
280
422
  resumeData: body.resumeData,
281
423
  runtimeContext
@@ -285,7 +427,7 @@ async function resumeVNextWorkflowHandler({
285
427
  return handleError(error, "Error resuming workflow");
286
428
  }
287
429
  }
288
- async function getVNextWorkflowRunsHandler({
430
+ async function getWorkflowRunsHandler({
289
431
  mastra,
290
432
  workflowId,
291
433
  fromDate,
@@ -298,7 +440,10 @@ async function getVNextWorkflowRunsHandler({
298
440
  if (!workflowId) {
299
441
  throw new HTTPException(400, { message: "Workflow ID is required" });
300
442
  }
301
- const workflow = mastra.vnext_getWorkflow(workflowId);
443
+ const { workflow } = await getWorkflowsFromSystem({ mastra, workflowId });
444
+ if (!workflow) {
445
+ throw new HTTPException(404, { message: "Workflow not found" });
446
+ }
302
447
  const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
303
448
  runs: [],
304
449
  total: 0
@@ -309,4 +454,4 @@ async function getVNextWorkflowRunsHandler({
309
454
  }
310
455
  }
311
456
 
312
- export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, vNextWorkflows_exports, watchVNextWorkflowHandler };
457
+ export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
@@ -1,4 +1,4 @@
1
- import { HTTPException } from './chunk-TRDNDNGQ.js';
1
+ import { HTTPException } from './chunk-NYN7KFXL.js';
2
2
 
3
3
  // src/server/handlers/error.ts
4
4
  function handleError(error, defaultMessage) {
@@ -0,0 +1,7 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ export { __export };
@@ -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 chunkASKESBJW_cjs = require('./chunk-ASKESBJW.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 ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(tool.inputSchema)) : void 0,
29
+ outputSchema: tool.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_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 ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_cjs.esm_default(tool.inputSchema)) : void 0,
49
+ outputSchema: tool.outputSchema ? chunkASKESBJW_cjs.stringify(chunkASKESBJW_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
 
@@ -1,9 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
6
-
7
1
  // src/server/http-exception.ts
8
2
  var HTTPException = class extends Error {
9
3
  res;
@@ -37,4 +31,4 @@ var HTTPException = class extends Error {
37
31
  }
38
32
  };
39
33
 
40
- export { HTTPException, __export };
34
+ export { HTTPException };
@@ -1,11 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var __defProp = Object.defineProperty;
4
- var __export = (target, all) => {
5
- for (var name in all)
6
- __defProp(target, name, { get: all[name], enumerable: true });
7
- };
8
-
9
3
  // src/server/http-exception.ts
10
4
  var HTTPException = class extends Error {
11
5
  res;
@@ -40,4 +34,3 @@ var HTTPException = class extends Error {
40
34
  };
41
35
 
42
36
  exports.HTTPException = HTTPException;
43
- exports.__export = __export;
@@ -0,0 +1,81 @@
1
+ import { validateBody } from './chunk-H5PTF3Y4.js';
2
+ import { handleError } from './chunk-M5ABIP7D.js';
3
+ import { __export } from './chunk-MLKGABMK.js';
4
+
5
+ // src/server/handlers/logs.ts
6
+ var logs_exports = {};
7
+ __export(logs_exports, {
8
+ getLogTransports: () => getLogTransports,
9
+ getLogsByRunIdHandler: () => getLogsByRunIdHandler,
10
+ getLogsHandler: () => getLogsHandler
11
+ });
12
+ async function getLogsHandler({
13
+ mastra,
14
+ transportId,
15
+ params
16
+ }) {
17
+ try {
18
+ validateBody({ transportId });
19
+ const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
20
+ const filters = _filters ? Object.fromEntries(
21
+ (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
22
+ const [key, value] = attr.split(":");
23
+ return [key, value];
24
+ })
25
+ ) : void 0;
26
+ const logs = await mastra.getLogs(transportId, {
27
+ fromDate,
28
+ toDate,
29
+ logLevel,
30
+ filters,
31
+ page: page ? Number(page) : void 0,
32
+ perPage: perPage ? Number(perPage) : void 0
33
+ });
34
+ return logs;
35
+ } catch (error) {
36
+ return handleError(error, "Error getting logs");
37
+ }
38
+ }
39
+ async function getLogsByRunIdHandler({
40
+ mastra,
41
+ runId,
42
+ transportId,
43
+ params
44
+ }) {
45
+ try {
46
+ validateBody({ runId, transportId });
47
+ const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
48
+ const filters = _filters ? Object.fromEntries(
49
+ (Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
50
+ const [key, value] = attr.split(":");
51
+ return [key, value];
52
+ })
53
+ ) : void 0;
54
+ const logs = await mastra.getLogsByRunId({
55
+ runId,
56
+ transportId,
57
+ fromDate,
58
+ toDate,
59
+ logLevel,
60
+ filters,
61
+ page: page ? Number(page) : void 0,
62
+ perPage: perPage ? Number(perPage) : void 0
63
+ });
64
+ return logs;
65
+ } catch (error) {
66
+ return handleError(error, "Error getting logs by run ID");
67
+ }
68
+ }
69
+ async function getLogTransports({ mastra }) {
70
+ try {
71
+ const logger = mastra.getLogger();
72
+ const transports = logger.getTransports();
73
+ return {
74
+ transports: transports ? [...transports.keys()] : []
75
+ };
76
+ } catch (error) {
77
+ return handleError(error, "Error getting log Transports");
78
+ }
79
+ }
80
+
81
+ export { getLogTransports, getLogsByRunIdHandler, getLogsHandler, logs_exports };