@mastra/server 0.0.0-mcp-schema-serializer-20250430202337 → 0.0.0-mcp-changeset-20250707162621

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 (93) hide show
  1. package/README.md +48 -135
  2. package/dist/_tsup-dts-rollup.d.cts +524 -100
  3. package/dist/_tsup-dts-rollup.d.ts +524 -100
  4. package/dist/{chunk-FV45V6WC.cjs → chunk-2KZFMI6P.cjs} +1 -7
  5. package/dist/{chunk-5YGDYMRB.cjs → chunk-2SLFAFTR.cjs} +14 -13
  6. package/dist/chunk-4D66QEKC.js +81 -0
  7. package/dist/{chunk-M3YJLWTU.js → chunk-5PQQ42EZ.js} +68 -57
  8. package/dist/chunk-75ZPJI57.cjs +9 -0
  9. package/dist/{chunk-M56ECCHK.cjs → chunk-7TP2LX5L.cjs} +20 -19
  10. package/dist/chunk-B2PAS2IB.cjs +514 -0
  11. package/dist/{chunk-Y3SV5XK4.js → chunk-BK4XT6EG.js} +105 -16
  12. package/dist/{chunk-QN4KF3BH.cjs → chunk-CCGRCYWJ.cjs} +2 -2
  13. package/dist/{chunk-QJ3AHN64.js → chunk-CRCR3ZUK.js} +4 -3
  14. package/dist/{chunk-2FJURXCL.cjs → chunk-DN7K6FJK.cjs} +93 -55
  15. package/dist/{chunk-D3G23FP3.cjs → chunk-FRVBFMO2.cjs} +24 -22
  16. package/dist/{chunk-7IWQE76Z.cjs → chunk-G7KH752Y.cjs} +16 -10
  17. package/dist/chunk-GHC4YV6R.js +504 -0
  18. package/dist/chunk-H7DMHBKY.js +498 -0
  19. package/dist/chunk-JMLYCXMK.cjs +332 -0
  20. package/dist/{chunk-Q6SHQECN.js → chunk-KHZKYUNR.js} +34 -10
  21. package/dist/{chunk-TRDNDNGQ.js → chunk-LCM566I4.js} +2 -7
  22. package/dist/chunk-LF7P5PLR.js +14 -0
  23. package/dist/chunk-LI436ITD.cjs +2042 -0
  24. package/dist/{chunk-5JNVY6DU.js → chunk-LRCAAFUA.js} +7 -5
  25. package/dist/chunk-LZ3VJXSO.cjs +278 -0
  26. package/dist/chunk-MEGCYGBU.js +2039 -0
  27. package/dist/{chunk-RBQASTUP.js → chunk-MKLYEKEF.js} +63 -25
  28. package/dist/chunk-MLKGABMK.js +7 -0
  29. package/dist/chunk-PZQDCRPV.cjs +16 -0
  30. package/dist/chunk-QGX47B5D.cjs +86 -0
  31. package/dist/{chunk-WTHDCRMY.js → chunk-RG473F6Y.js} +12 -6
  32. package/dist/chunk-RHSWAXKB.cjs +118 -0
  33. package/dist/{chunk-L7XE5QTW.js → chunk-RSEO4XPX.js} +1 -1
  34. package/dist/chunk-SDPGVWQJ.cjs +512 -0
  35. package/dist/{chunk-4JINXASC.js → chunk-WNVFNNWN.js} +5 -4
  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/vNextNetwork.cjs +218 -0
  61. package/dist/server/handlers/vNextNetwork.d.cts +6 -0
  62. package/dist/server/handlers/vNextNetwork.d.ts +6 -0
  63. package/dist/server/handlers/vNextNetwork.js +211 -0
  64. package/dist/server/handlers/vector.cjs +7 -7
  65. package/dist/server/handlers/vector.js +1 -1
  66. package/dist/server/handlers/voice.cjs +8 -4
  67. package/dist/server/handlers/voice.d.cts +1 -0
  68. package/dist/server/handlers/voice.d.ts +1 -0
  69. package/dist/server/handlers/voice.js +1 -1
  70. package/dist/server/handlers/workflows.cjs +29 -13
  71. package/dist/server/handlers/workflows.d.cts +6 -2
  72. package/dist/server/handlers/workflows.d.ts +6 -2
  73. package/dist/server/handlers/workflows.js +1 -1
  74. package/dist/server/handlers.cjs +32 -27
  75. package/dist/server/handlers.d.cts +2 -1
  76. package/dist/server/handlers.d.ts +2 -1
  77. package/dist/server/handlers.js +11 -10
  78. package/package.json +14 -13
  79. package/dist/chunk-3AHQ5RGN.js +0 -11
  80. package/dist/chunk-3EJZQ6TQ.js +0 -49
  81. package/dist/chunk-4BIX6GMY.cjs +0 -189
  82. package/dist/chunk-55HTWX4C.cjs +0 -93
  83. package/dist/chunk-5SWCVTNL.cjs +0 -5579
  84. package/dist/chunk-AELYAUEE.cjs +0 -316
  85. package/dist/chunk-EVCC233P.cjs +0 -321
  86. package/dist/chunk-JPB6RPGB.js +0 -304
  87. package/dist/chunk-OMN3UI6X.js +0 -5576
  88. package/dist/chunk-SKBVVI24.cjs +0 -54
  89. package/dist/chunk-ZLBRQFDD.cjs +0 -13
  90. package/dist/server/handlers/vNextWorkflows.cjs +0 -46
  91. package/dist/server/handlers/vNextWorkflows.d.cts +0 -10
  92. package/dist/server/handlers/vNextWorkflows.d.ts +0 -10
  93. package/dist/server/handlers/vNextWorkflows.js +0 -1
@@ -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;
@@ -19,6 +13,7 @@ var HTTPException = class extends Error {
19
13
  super(options?.message, { cause: options?.cause });
20
14
  this.res = options?.res;
21
15
  this.status = status;
16
+ this.stack = options?.stack || this.stack;
22
17
  }
23
18
  /**
24
19
  * Returns the response object associated with the exception.
@@ -40,4 +35,3 @@ var HTTPException = class extends Error {
40
35
  };
41
36
 
42
37
  exports.HTTPException = HTTPException;
43
- exports.__export = __export;
@@ -1,12 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkQN4KF3BH_cjs = require('./chunk-QN4KF3BH.cjs');
4
- var chunkZLBRQFDD_cjs = require('./chunk-ZLBRQFDD.cjs');
5
- var chunkFV45V6WC_cjs = require('./chunk-FV45V6WC.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
+ var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
6
7
 
7
8
  // src/server/handlers/network.ts
8
9
  var network_exports = {};
9
- chunkFV45V6WC_cjs.__export(network_exports, {
10
+ chunk75ZPJI57_cjs.__export(network_exports, {
10
11
  generateHandler: () => generateHandler,
11
12
  getNetworkByIdHandler: () => getNetworkByIdHandler,
12
13
  getNetworksHandler: () => getNetworksHandler,
@@ -46,7 +47,7 @@ async function getNetworksHandler({
46
47
  );
47
48
  return serializedNetworks;
48
49
  } catch (error) {
49
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
50
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting networks");
50
51
  }
51
52
  }
52
53
  async function getNetworkByIdHandler({
@@ -61,7 +62,7 @@ async function getNetworkByIdHandler({
61
62
  return network2.formatAgentId(routingAgent2.name) === networkId;
62
63
  });
63
64
  if (!network) {
64
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
65
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
65
66
  }
66
67
  const routingAgent = network.getRoutingAgent();
67
68
  const routingLLM = await routingAgent.getLLM({ runtimeContext });
@@ -87,7 +88,7 @@ async function getNetworkByIdHandler({
87
88
  };
88
89
  return serializedNetwork;
89
90
  } catch (error) {
90
- return chunkZLBRQFDD_cjs.handleError(error, "Error getting network by ID");
91
+ return chunkPZQDCRPV_cjs.handleError(error, "Error getting network by ID");
91
92
  }
92
93
  }
93
94
  async function generateHandler({
@@ -99,14 +100,14 @@ async function generateHandler({
99
100
  try {
100
101
  const network = mastra.getNetwork(networkId);
101
102
  if (!network) {
102
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
103
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
103
104
  }
104
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
105
+ chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
105
106
  const { messages, ...rest } = body;
106
107
  const result = await network.generate(messages, { ...rest, runtimeContext });
107
108
  return result;
108
109
  } catch (error) {
109
- return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
110
+ return chunkPZQDCRPV_cjs.handleError(error, "Error generating from network");
110
111
  }
111
112
  }
112
113
  async function streamGenerateHandler({
@@ -118,9 +119,9 @@ async function streamGenerateHandler({
118
119
  try {
119
120
  const network = mastra.getNetwork(networkId);
120
121
  if (!network) {
121
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
122
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
122
123
  }
123
- chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
124
+ chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
124
125
  const { messages, output, ...rest } = body;
125
126
  const streamResult = await network.stream(messages, {
126
127
  output,
@@ -136,7 +137,7 @@ async function streamGenerateHandler({
136
137
  });
137
138
  return streamResponse;
138
139
  } catch (error) {
139
- return chunkZLBRQFDD_cjs.handleError(error, "Error streaming from network");
140
+ return chunkPZQDCRPV_cjs.handleError(error, "Error streaming from network");
140
141
  }
141
142
  }
142
143
 
@@ -0,0 +1,81 @@
1
+ import { validateBody } from './chunk-RSEO4XPX.js';
2
+ import { handleError } from './chunk-LF7P5PLR.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 };
@@ -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-MEGCYGBU.js';
2
+ import { handleError } from './chunk-LF7P5PLR.js';
3
+ import { HTTPException } from './chunk-LCM566I4.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] = {
@@ -45,15 +46,15 @@ async function getWorkflowsHandler({ mastra }) {
45
46
  }, {});
46
47
  return _workflows;
47
48
  } catch (error) {
48
- throw new HTTPException(500, { message: error?.message || "Error getting workflows" });
49
+ return handleError(error, "error getting workflows");
49
50
  }
50
51
  }
51
- async function getWorkflowByIdHandler({ mastra, workflowId }) {
52
+ async function getLegacyWorkflowByIdHandler({ mastra, workflowId }) {
52
53
  try {
53
54
  if (!workflowId) {
54
55
  throw new HTTPException(400, { message: "Workflow ID is required" });
55
56
  }
56
- const workflow = mastra.getWorkflow(workflowId);
57
+ const workflow = mastra.legacy_getWorkflow(workflowId);
57
58
  if (!workflow) {
58
59
  throw new HTTPException(404, { message: "Workflow not found" });
59
60
  }
@@ -77,10 +78,10 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
77
78
  }, {})
78
79
  };
79
80
  } catch (error) {
80
- throw new HTTPException(500, { message: error?.message || "Error getting workflow" });
81
+ return handleError(error, "error getting workflow by id");
81
82
  }
82
83
  }
83
- async function startAsyncWorkflowHandler({
84
+ async function startAsyncLegacyWorkflowHandler({
84
85
  mastra,
85
86
  runtimeContext,
86
87
  workflowId,
@@ -91,19 +92,19 @@ async function startAsyncWorkflowHandler({
91
92
  if (!workflowId) {
92
93
  throw new HTTPException(400, { message: "Workflow ID is required" });
93
94
  }
94
- const workflow = mastra.getWorkflow(workflowId);
95
+ const workflow = mastra.legacy_getWorkflow(workflowId);
95
96
  if (!workflow) {
96
97
  throw new HTTPException(404, { message: "Workflow not found" });
97
98
  }
98
99
  if (!runId) {
99
- const { start } = workflow.createRun();
100
- const result2 = await start({
100
+ const newRun = workflow.createRun();
101
+ const result2 = await newRun.start({
101
102
  triggerData,
102
103
  runtimeContext
103
104
  });
104
105
  return result2;
105
106
  }
106
- const run = workflow.getRun(runId);
107
+ const run = workflow.getMemoryRun(runId);
107
108
  if (!run) {
108
109
  throw new HTTPException(404, { message: "Workflow run not found" });
109
110
  }
@@ -113,10 +114,10 @@ async function startAsyncWorkflowHandler({
113
114
  });
114
115
  return result;
115
116
  } catch (error) {
116
- throw new HTTPException(500, { message: error?.message || "Error executing workflow" });
117
+ return handleError(error, "error starting workflow");
117
118
  }
118
119
  }
119
- async function getWorkflowRunHandler({
120
+ async function getLegacyWorkflowRunHandler({
120
121
  mastra,
121
122
  workflowId,
122
123
  runId
@@ -128,20 +129,20 @@ async function getWorkflowRunHandler({
128
129
  if (!runId) {
129
130
  throw new HTTPException(400, { message: "Run ID is required" });
130
131
  }
131
- const workflow = mastra.getWorkflow(workflowId);
132
+ const workflow = mastra.legacy_getWorkflow(workflowId);
132
133
  if (!workflow) {
133
134
  throw new HTTPException(404, { message: "Workflow not found" });
134
135
  }
135
- const run = workflow.getRun(runId);
136
+ const run = await workflow.getRun(runId);
136
137
  if (!run) {
137
138
  throw new HTTPException(404, { message: "Workflow run not found" });
138
139
  }
139
140
  return run;
140
141
  } catch (error) {
141
- throw new HTTPException(500, { message: error?.message || "Error getting workflow run" });
142
+ return handleError(error, "error getting workflow run");
142
143
  }
143
144
  }
144
- async function createRunHandler({
145
+ async function createLegacyWorkflowRunHandler({
145
146
  mastra,
146
147
  workflowId,
147
148
  runId: prevRunId
@@ -150,17 +151,17 @@ async function createRunHandler({
150
151
  if (!workflowId) {
151
152
  throw new HTTPException(400, { message: "Workflow ID is required" });
152
153
  }
153
- const workflow = mastra.getWorkflow(workflowId);
154
+ const workflow = mastra.legacy_getWorkflow(workflowId);
154
155
  if (!workflow) {
155
156
  throw new HTTPException(404, { message: "Workflow not found" });
156
157
  }
157
- const { runId } = workflow.createRun({ runId: prevRunId });
158
- return { runId };
158
+ const newRun = workflow.createRun({ runId: prevRunId });
159
+ return { runId: newRun.runId };
159
160
  } catch (error) {
160
- throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
161
+ return handleError(error, "error creating workflow run");
161
162
  }
162
163
  }
163
- async function startWorkflowRunHandler({
164
+ async function startLegacyWorkflowRunHandler({
164
165
  mastra,
165
166
  runtimeContext,
166
167
  workflowId,
@@ -174,12 +175,12 @@ async function startWorkflowRunHandler({
174
175
  if (!runId) {
175
176
  throw new HTTPException(400, { message: "runId required to start run" });
176
177
  }
177
- const workflow = mastra.getWorkflow(workflowId);
178
- const run = workflow.getRun(runId);
178
+ const workflow = mastra.legacy_getWorkflow(workflowId);
179
+ const run = workflow.getMemoryRun(runId);
179
180
  if (!run) {
180
181
  throw new HTTPException(404, { message: "Workflow run not found" });
181
182
  }
182
- await run.start({
183
+ void run.start({
183
184
  triggerData,
184
185
  runtimeContext
185
186
  });
@@ -188,7 +189,7 @@ async function startWorkflowRunHandler({
188
189
  return handleError(e, "Error starting workflow run");
189
190
  }
190
191
  }
191
- async function watchWorkflowHandler({
192
+ async function watchLegacyWorkflowHandler({
192
193
  mastra,
193
194
  workflowId,
194
195
  runId
@@ -200,8 +201,8 @@ async function watchWorkflowHandler({
200
201
  if (!runId) {
201
202
  throw new HTTPException(400, { message: "runId required to watch workflow" });
202
203
  }
203
- const workflow = mastra.getWorkflow(workflowId);
204
- const run = workflow.getRun(runId);
204
+ const workflow = mastra.legacy_getWorkflow(workflowId);
205
+ const run = workflow.getMemoryRun(runId);
205
206
  if (!run) {
206
207
  throw new HTTPException(404, { message: "Workflow run not found" });
207
208
  }
@@ -217,8 +218,10 @@ async function watchWorkflowHandler({
217
218
  asyncRef = null;
218
219
  }
219
220
  asyncRef = setImmediate(() => {
220
- if (!workflow.getRun(runId2)) {
221
+ const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
222
+ if (runDone) {
221
223
  controller.close();
224
+ unwatch?.();
222
225
  }
223
226
  });
224
227
  });
@@ -232,7 +235,7 @@ async function watchWorkflowHandler({
232
235
  return handleError(error, "Error watching workflow");
233
236
  }
234
237
  }
235
- async function resumeAsyncWorkflowHandler({
238
+ async function resumeAsyncLegacyWorkflowHandler({
236
239
  mastra,
237
240
  workflowId,
238
241
  runId,
@@ -246,8 +249,8 @@ async function resumeAsyncWorkflowHandler({
246
249
  if (!runId) {
247
250
  throw new HTTPException(400, { message: "runId required to resume workflow" });
248
251
  }
249
- const workflow = mastra.getWorkflow(workflowId);
250
- const run = workflow.getRun(runId);
252
+ const workflow = mastra.legacy_getWorkflow(workflowId);
253
+ const run = workflow.getMemoryRun(runId);
251
254
  if (!run) {
252
255
  throw new HTTPException(404, { message: "Workflow run not found" });
253
256
  }
@@ -261,7 +264,7 @@ async function resumeAsyncWorkflowHandler({
261
264
  return handleError(error, "Error resuming workflow step");
262
265
  }
263
266
  }
264
- async function resumeWorkflowHandler({
267
+ async function resumeLegacyWorkflowHandler({
265
268
  mastra,
266
269
  workflowId,
267
270
  runId,
@@ -275,12 +278,12 @@ async function resumeWorkflowHandler({
275
278
  if (!runId) {
276
279
  throw new HTTPException(400, { message: "runId required to resume workflow" });
277
280
  }
278
- const workflow = mastra.getWorkflow(workflowId);
279
- const run = workflow.getRun(runId);
281
+ const workflow = mastra.legacy_getWorkflow(workflowId);
282
+ const run = workflow.getMemoryRun(runId);
280
283
  if (!run) {
281
284
  throw new HTTPException(404, { message: "Workflow run not found" });
282
285
  }
283
- await run.resume({
286
+ void run.resume({
284
287
  stepId: body.stepId,
285
288
  context: body.context,
286
289
  runtimeContext
@@ -290,13 +293,21 @@ async function resumeWorkflowHandler({
290
293
  return handleError(error, "Error resuming workflow");
291
294
  }
292
295
  }
293
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
296
+ async function getLegacyWorkflowRunsHandler({
297
+ mastra,
298
+ workflowId,
299
+ fromDate,
300
+ toDate,
301
+ limit,
302
+ offset,
303
+ resourceId
304
+ }) {
294
305
  try {
295
306
  if (!workflowId) {
296
307
  throw new HTTPException(400, { message: "Workflow ID is required" });
297
308
  }
298
- const workflow = mastra.getWorkflow(workflowId);
299
- const workflowRuns = await workflow.getWorkflowRuns() || {
309
+ const workflow = mastra.legacy_getWorkflow(workflowId);
310
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
300
311
  runs: [],
301
312
  total: 0
302
313
  };
@@ -306,4 +317,4 @@ async function getWorkflowRunsHandler({ mastra, workflowId }) {
306
317
  }
307
318
  }
308
319
 
309
- 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 };
@@ -0,0 +1,9 @@
1
+ 'use strict';
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
+ exports.__export = __export;
@@ -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/vector.ts
7
8
  var vector_exports = {};
8
- chunkFV45V6WC_cjs.__export(vector_exports, {
9
+ chunk75ZPJI57_cjs.__export(vector_exports, {
9
10
  createIndex: () => createIndex,
10
11
  deleteIndex: () => deleteIndex,
11
12
  describeIndex: () => describeIndex,
@@ -15,24 +16,24 @@ chunkFV45V6WC_cjs.__export(vector_exports, {
15
16
  });
16
17
  function getVector(mastra, vectorName) {
17
18
  if (!vectorName) {
18
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Vector name is required" });
19
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Vector name is required" });
19
20
  }
20
21
  const vector = mastra.getVector(vectorName);
21
22
  if (!vector) {
22
- throw new chunkFV45V6WC_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
23
+ throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: `Vector store ${vectorName} not found` });
23
24
  }
24
25
  return vector;
25
26
  }
26
27
  async function upsertVectors({ mastra, vectorName, index }) {
27
28
  try {
28
29
  if (!index?.indexName || !index?.vectors || !Array.isArray(index.vectors)) {
29
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
30
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request index. indexName and vectors array are required." });
30
31
  }
31
32
  const vector = getVector(mastra, vectorName);
32
33
  const result = await vector.upsert(index);
33
34
  return { ids: result };
34
35
  } catch (error) {
35
- return chunkZLBRQFDD_cjs.handleError(error, "Error upserting vectors");
36
+ return chunkPZQDCRPV_cjs.handleError(error, "Error upserting vectors");
36
37
  }
37
38
  }
38
39
  async function createIndex({
@@ -43,18 +44,18 @@ async function createIndex({
43
44
  try {
44
45
  const { indexName, dimension, metric } = index;
45
46
  if (!indexName || typeof dimension !== "number" || dimension <= 0) {
46
- throw new chunkFV45V6WC_cjs.HTTPException(400, {
47
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, {
47
48
  message: "Invalid request index, indexName and positive dimension number are required."
48
49
  });
49
50
  }
50
51
  if (metric && !["cosine", "euclidean", "dotproduct"].includes(metric)) {
51
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
52
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid metric. Must be one of: cosine, euclidean, dotproduct" });
52
53
  }
53
54
  const vector = getVector(mastra, vectorName);
54
55
  await vector.createIndex({ indexName, dimension, metric });
55
56
  return { success: true };
56
57
  } catch (error) {
57
- return chunkZLBRQFDD_cjs.handleError(error, "Error creating index");
58
+ return chunkPZQDCRPV_cjs.handleError(error, "Error creating index");
58
59
  }
59
60
  }
60
61
  async function queryVectors({
@@ -64,13 +65,13 @@ async function queryVectors({
64
65
  }) {
65
66
  try {
66
67
  if (!query?.indexName || !query?.queryVector || !Array.isArray(query.queryVector)) {
67
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
68
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Invalid request query. indexName and queryVector array are required." });
68
69
  }
69
70
  const vector = getVector(mastra, vectorName);
70
71
  const results = await vector.query(query);
71
72
  return results;
72
73
  } catch (error) {
73
- return chunkZLBRQFDD_cjs.handleError(error, "Error querying vectors");
74
+ return chunkPZQDCRPV_cjs.handleError(error, "Error querying vectors");
74
75
  }
75
76
  }
76
77
  async function listIndexes({ mastra, vectorName }) {
@@ -79,7 +80,7 @@ async function listIndexes({ mastra, vectorName }) {
79
80
  const indexes = await vector.listIndexes();
80
81
  return indexes.filter(Boolean);
81
82
  } catch (error) {
82
- return chunkZLBRQFDD_cjs.handleError(error, "Error listing indexes");
83
+ return chunkPZQDCRPV_cjs.handleError(error, "Error listing indexes");
83
84
  }
84
85
  }
85
86
  async function describeIndex({
@@ -89,17 +90,17 @@ async function describeIndex({
89
90
  }) {
90
91
  try {
91
92
  if (!indexName) {
92
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Index name is required" });
93
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
93
94
  }
94
95
  const vector = getVector(mastra, vectorName);
95
- const stats = await vector.describeIndex(indexName);
96
+ const stats = await vector.describeIndex({ indexName });
96
97
  return {
97
98
  dimension: stats.dimension,
98
99
  count: stats.count,
99
100
  metric: stats.metric?.toLowerCase()
100
101
  };
101
102
  } catch (error) {
102
- return chunkZLBRQFDD_cjs.handleError(error, "Error describing index");
103
+ return chunkPZQDCRPV_cjs.handleError(error, "Error describing index");
103
104
  }
104
105
  }
105
106
  async function deleteIndex({
@@ -109,13 +110,13 @@ async function deleteIndex({
109
110
  }) {
110
111
  try {
111
112
  if (!indexName) {
112
- throw new chunkFV45V6WC_cjs.HTTPException(400, { message: "Index name is required" });
113
+ throw new chunk2KZFMI6P_cjs.HTTPException(400, { message: "Index name is required" });
113
114
  }
114
115
  const vector = getVector(mastra, vectorName);
115
- await vector.deleteIndex(indexName);
116
+ await vector.deleteIndex({ indexName });
116
117
  return { success: true };
117
118
  } catch (error) {
118
- return chunkZLBRQFDD_cjs.handleError(error, "Error deleting index");
119
+ return chunkPZQDCRPV_cjs.handleError(error, "Error deleting index");
119
120
  }
120
121
  }
121
122