@mastra/server 2.0.4-alpha.0 → 2.0.4-alpha.1

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.
@@ -97,14 +97,14 @@ async function startAsyncWorkflowHandler({
97
97
  throw new HTTPException(404, { message: "Workflow not found" });
98
98
  }
99
99
  if (!runId) {
100
- const { start } = workflow.createRun();
101
- const result2 = await start({
100
+ const newRun = workflow.createRun();
101
+ const result2 = await newRun.start({
102
102
  triggerData,
103
103
  runtimeContext
104
104
  });
105
105
  return result2;
106
106
  }
107
- const run = workflow.getRun(runId);
107
+ const run = workflow.getMemoryRun(runId);
108
108
  if (!run) {
109
109
  throw new HTTPException(404, { message: "Workflow run not found" });
110
110
  }
@@ -133,7 +133,7 @@ async function getWorkflowRunHandler({
133
133
  if (!workflow) {
134
134
  throw new HTTPException(404, { message: "Workflow not found" });
135
135
  }
136
- const run = workflow.getRun(runId);
136
+ const run = await workflow.getRun(runId);
137
137
  if (!run) {
138
138
  throw new HTTPException(404, { message: "Workflow run not found" });
139
139
  }
@@ -155,8 +155,8 @@ async function createRunHandler({
155
155
  if (!workflow) {
156
156
  throw new HTTPException(404, { message: "Workflow not found" });
157
157
  }
158
- const { runId } = workflow.createRun({ runId: prevRunId });
159
- return { runId };
158
+ const newRun = workflow.createRun({ runId: prevRunId });
159
+ return { runId: newRun.runId };
160
160
  } catch (error) {
161
161
  throw new HTTPException(500, { message: error?.message || "Error creating workflow run" });
162
162
  }
@@ -176,11 +176,11 @@ async function startWorkflowRunHandler({
176
176
  throw new HTTPException(400, { message: "runId required to start run" });
177
177
  }
178
178
  const workflow = mastra.getWorkflow(workflowId);
179
- const run = workflow.getRun(runId);
179
+ const run = workflow.getMemoryRun(runId);
180
180
  if (!run) {
181
181
  throw new HTTPException(404, { message: "Workflow run not found" });
182
182
  }
183
- await run.start({
183
+ void run.start({
184
184
  triggerData,
185
185
  runtimeContext
186
186
  });
@@ -202,7 +202,7 @@ async function watchWorkflowHandler({
202
202
  throw new HTTPException(400, { message: "runId required to watch workflow" });
203
203
  }
204
204
  const workflow = mastra.getWorkflow(workflowId);
205
- const run = workflow.getRun(runId);
205
+ const run = workflow.getMemoryRun(runId);
206
206
  if (!run) {
207
207
  throw new HTTPException(404, { message: "Workflow run not found" });
208
208
  }
@@ -218,8 +218,10 @@ async function watchWorkflowHandler({
218
218
  asyncRef = null;
219
219
  }
220
220
  asyncRef = setImmediate(() => {
221
- if (!workflow.getRun(runId2)) {
221
+ const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
222
+ if (runDone) {
222
223
  controller.close();
224
+ unwatch?.();
223
225
  }
224
226
  });
225
227
  });
@@ -248,7 +250,7 @@ async function resumeAsyncWorkflowHandler({
248
250
  throw new HTTPException(400, { message: "runId required to resume workflow" });
249
251
  }
250
252
  const workflow = mastra.getWorkflow(workflowId);
251
- const run = workflow.getRun(runId);
253
+ const run = workflow.getMemoryRun(runId);
252
254
  if (!run) {
253
255
  throw new HTTPException(404, { message: "Workflow run not found" });
254
256
  }
@@ -277,11 +279,11 @@ async function resumeWorkflowHandler({
277
279
  throw new HTTPException(400, { message: "runId required to resume workflow" });
278
280
  }
279
281
  const workflow = mastra.getWorkflow(workflowId);
280
- const run = workflow.getRun(runId);
282
+ const run = workflow.getMemoryRun(runId);
281
283
  if (!run) {
282
284
  throw new HTTPException(404, { message: "Workflow run not found" });
283
285
  }
284
- await run.resume({
286
+ void run.resume({
285
287
  stepId: body.stepId,
286
288
  context: body.context,
287
289
  runtimeContext
@@ -99,14 +99,14 @@ async function startAsyncWorkflowHandler({
99
99
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
100
100
  }
101
101
  if (!runId) {
102
- const { start } = workflow.createRun();
103
- const result2 = await start({
102
+ const newRun = workflow.createRun();
103
+ const result2 = await newRun.start({
104
104
  triggerData,
105
105
  runtimeContext
106
106
  });
107
107
  return result2;
108
108
  }
109
- const run = workflow.getRun(runId);
109
+ const run = workflow.getMemoryRun(runId);
110
110
  if (!run) {
111
111
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
112
112
  }
@@ -135,7 +135,7 @@ async function getWorkflowRunHandler({
135
135
  if (!workflow) {
136
136
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
137
137
  }
138
- const run = workflow.getRun(runId);
138
+ const run = await workflow.getRun(runId);
139
139
  if (!run) {
140
140
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
141
141
  }
@@ -157,8 +157,8 @@ async function createRunHandler({
157
157
  if (!workflow) {
158
158
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
159
159
  }
160
- const { runId } = workflow.createRun({ runId: prevRunId });
161
- return { runId };
160
+ const newRun = workflow.createRun({ runId: prevRunId });
161
+ return { runId: newRun.runId };
162
162
  } catch (error) {
163
163
  throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error creating workflow run" });
164
164
  }
@@ -178,11 +178,11 @@ async function startWorkflowRunHandler({
178
178
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to start run" });
179
179
  }
180
180
  const workflow = mastra.getWorkflow(workflowId);
181
- const run = workflow.getRun(runId);
181
+ const run = workflow.getMemoryRun(runId);
182
182
  if (!run) {
183
183
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
184
184
  }
185
- await run.start({
185
+ void run.start({
186
186
  triggerData,
187
187
  runtimeContext
188
188
  });
@@ -204,7 +204,7 @@ async function watchWorkflowHandler({
204
204
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to watch workflow" });
205
205
  }
206
206
  const workflow = mastra.getWorkflow(workflowId);
207
- const run = workflow.getRun(runId);
207
+ const run = workflow.getMemoryRun(runId);
208
208
  if (!run) {
209
209
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
210
210
  }
@@ -220,8 +220,10 @@ async function watchWorkflowHandler({
220
220
  asyncRef = null;
221
221
  }
222
222
  asyncRef = setImmediate(() => {
223
- if (!workflow.getRun(runId2)) {
223
+ const runDone = Object.values(activePathsObj).every((value) => value.status !== "executing");
224
+ if (runDone) {
224
225
  controller.close();
226
+ unwatch?.();
225
227
  }
226
228
  });
227
229
  });
@@ -250,7 +252,7 @@ async function resumeAsyncWorkflowHandler({
250
252
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
251
253
  }
252
254
  const workflow = mastra.getWorkflow(workflowId);
253
- const run = workflow.getRun(runId);
255
+ const run = workflow.getMemoryRun(runId);
254
256
  if (!run) {
255
257
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
256
258
  }
@@ -279,11 +281,11 @@ async function resumeWorkflowHandler({
279
281
  throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
280
282
  }
281
283
  const workflow = mastra.getWorkflow(workflowId);
282
- const run = workflow.getRun(runId);
284
+ const run = workflow.getMemoryRun(runId);
283
285
  if (!run) {
284
286
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
285
287
  }
286
- await run.resume({
288
+ void run.resume({
287
289
  stepId: body.stepId,
288
290
  context: body.context,
289
291
  runtimeContext
@@ -180,7 +180,7 @@ async function startVNextWorkflowRunHandler({
180
180
  ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
181
181
  ]);
182
182
  const _run = workflow.createRun({ runId });
183
- await _run.start({
183
+ void _run.start({
184
184
  inputData,
185
185
  runtimeContext: finalRuntimeContext
186
186
  });
@@ -296,7 +296,7 @@ async function resumeVNextWorkflowHandler({
296
296
  throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
297
297
  }
298
298
  const _run = workflow.createRun({ runId });
299
- await _run.resume({
299
+ void _run.resume({
300
300
  step: body.step,
301
301
  resumeData: body.resumeData,
302
302
  runtimeContext
@@ -178,7 +178,7 @@ async function startVNextWorkflowRunHandler({
178
178
  ...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
179
179
  ]);
180
180
  const _run = workflow.createRun({ runId });
181
- await _run.start({
181
+ void _run.start({
182
182
  inputData,
183
183
  runtimeContext: finalRuntimeContext
184
184
  });
@@ -294,7 +294,7 @@ async function resumeVNextWorkflowHandler({
294
294
  throw new HTTPException(404, { message: "Workflow run not found" });
295
295
  }
296
296
  const _run = workflow.createRun({ runId });
297
- await _run.resume({
297
+ void _run.resume({
298
298
  step: body.step,
299
299
  resumeData: body.resumeData,
300
300
  runtimeContext
@@ -1,46 +1,46 @@
1
1
  'use strict';
2
2
 
3
- var chunkOHKAN72U_cjs = require('../../chunk-OHKAN72U.cjs');
3
+ var chunkM6MC2QMH_cjs = require('../../chunk-M6MC2QMH.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "createVNextWorkflowRunHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunkOHKAN72U_cjs.createVNextWorkflowRunHandler; }
9
+ get: function () { return chunkM6MC2QMH_cjs.createVNextWorkflowRunHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getVNextWorkflowByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkOHKAN72U_cjs.getVNextWorkflowByIdHandler; }
13
+ get: function () { return chunkM6MC2QMH_cjs.getVNextWorkflowByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getVNextWorkflowRunByIdHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkOHKAN72U_cjs.getVNextWorkflowRunByIdHandler; }
17
+ get: function () { return chunkM6MC2QMH_cjs.getVNextWorkflowRunByIdHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getVNextWorkflowRunsHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunkOHKAN72U_cjs.getVNextWorkflowRunsHandler; }
21
+ get: function () { return chunkM6MC2QMH_cjs.getVNextWorkflowRunsHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getVNextWorkflowsHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunkOHKAN72U_cjs.getVNextWorkflowsHandler; }
25
+ get: function () { return chunkM6MC2QMH_cjs.getVNextWorkflowsHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "resumeAsyncVNextWorkflowHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunkOHKAN72U_cjs.resumeAsyncVNextWorkflowHandler; }
29
+ get: function () { return chunkM6MC2QMH_cjs.resumeAsyncVNextWorkflowHandler; }
30
30
  });
31
31
  Object.defineProperty(exports, "resumeVNextWorkflowHandler", {
32
32
  enumerable: true,
33
- get: function () { return chunkOHKAN72U_cjs.resumeVNextWorkflowHandler; }
33
+ get: function () { return chunkM6MC2QMH_cjs.resumeVNextWorkflowHandler; }
34
34
  });
35
35
  Object.defineProperty(exports, "startAsyncVNextWorkflowHandler", {
36
36
  enumerable: true,
37
- get: function () { return chunkOHKAN72U_cjs.startAsyncVNextWorkflowHandler; }
37
+ get: function () { return chunkM6MC2QMH_cjs.startAsyncVNextWorkflowHandler; }
38
38
  });
39
39
  Object.defineProperty(exports, "startVNextWorkflowRunHandler", {
40
40
  enumerable: true,
41
- get: function () { return chunkOHKAN72U_cjs.startVNextWorkflowRunHandler; }
41
+ get: function () { return chunkM6MC2QMH_cjs.startVNextWorkflowRunHandler; }
42
42
  });
43
43
  Object.defineProperty(exports, "watchVNextWorkflowHandler", {
44
44
  enumerable: true,
45
- get: function () { return chunkOHKAN72U_cjs.watchVNextWorkflowHandler; }
45
+ get: function () { return chunkM6MC2QMH_cjs.watchVNextWorkflowHandler; }
46
46
  });
@@ -1 +1 @@
1
- export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunByIdHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, watchVNextWorkflowHandler } from '../../chunk-WVDUW4GI.js';
1
+ export { createVNextWorkflowRunHandler, getVNextWorkflowByIdHandler, getVNextWorkflowRunByIdHandler, getVNextWorkflowRunsHandler, getVNextWorkflowsHandler, resumeAsyncVNextWorkflowHandler, resumeVNextWorkflowHandler, startAsyncVNextWorkflowHandler, startVNextWorkflowRunHandler, watchVNextWorkflowHandler } from '../../chunk-WJU67W7F.js';
@@ -1,46 +1,46 @@
1
1
  'use strict';
2
2
 
3
- var chunkRYUN5DF4_cjs = require('../../chunk-RYUN5DF4.cjs');
3
+ var chunkI2B73Y4I_cjs = require('../../chunk-I2B73Y4I.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "createRunHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunkRYUN5DF4_cjs.createRunHandler; }
9
+ get: function () { return chunkI2B73Y4I_cjs.createRunHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getWorkflowByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkRYUN5DF4_cjs.getWorkflowByIdHandler; }
13
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getWorkflowRunHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkRYUN5DF4_cjs.getWorkflowRunHandler; }
17
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowRunHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getWorkflowRunsHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunkRYUN5DF4_cjs.getWorkflowRunsHandler; }
21
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowRunsHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getWorkflowsHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunkRYUN5DF4_cjs.getWorkflowsHandler; }
25
+ get: function () { return chunkI2B73Y4I_cjs.getWorkflowsHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "resumeAsyncWorkflowHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunkRYUN5DF4_cjs.resumeAsyncWorkflowHandler; }
29
+ get: function () { return chunkI2B73Y4I_cjs.resumeAsyncWorkflowHandler; }
30
30
  });
31
31
  Object.defineProperty(exports, "resumeWorkflowHandler", {
32
32
  enumerable: true,
33
- get: function () { return chunkRYUN5DF4_cjs.resumeWorkflowHandler; }
33
+ get: function () { return chunkI2B73Y4I_cjs.resumeWorkflowHandler; }
34
34
  });
35
35
  Object.defineProperty(exports, "startAsyncWorkflowHandler", {
36
36
  enumerable: true,
37
- get: function () { return chunkRYUN5DF4_cjs.startAsyncWorkflowHandler; }
37
+ get: function () { return chunkI2B73Y4I_cjs.startAsyncWorkflowHandler; }
38
38
  });
39
39
  Object.defineProperty(exports, "startWorkflowRunHandler", {
40
40
  enumerable: true,
41
- get: function () { return chunkRYUN5DF4_cjs.startWorkflowRunHandler; }
41
+ get: function () { return chunkI2B73Y4I_cjs.startWorkflowRunHandler; }
42
42
  });
43
43
  Object.defineProperty(exports, "watchWorkflowHandler", {
44
44
  enumerable: true,
45
- get: function () { return chunkRYUN5DF4_cjs.watchWorkflowHandler; }
45
+ get: function () { return chunkI2B73Y4I_cjs.watchWorkflowHandler; }
46
46
  });
@@ -1 +1 @@
1
- export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler } from '../../chunk-2KIW6AJK.js';
1
+ export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler } from '../../chunk-EJO45KYT.js';
@@ -2,10 +2,10 @@
2
2
 
3
3
  var chunkMHKNLNAN_cjs = require('../chunk-MHKNLNAN.cjs');
4
4
  var chunkZE5AAC4I_cjs = require('../chunk-ZE5AAC4I.cjs');
5
- var chunkOHKAN72U_cjs = require('../chunk-OHKAN72U.cjs');
5
+ var chunkM6MC2QMH_cjs = require('../chunk-M6MC2QMH.cjs');
6
6
  var chunk4YZ3U35L_cjs = require('../chunk-4YZ3U35L.cjs');
7
7
  var chunkYBVOQN4M_cjs = require('../chunk-YBVOQN4M.cjs');
8
- var chunkRYUN5DF4_cjs = require('../chunk-RYUN5DF4.cjs');
8
+ var chunkI2B73Y4I_cjs = require('../chunk-I2B73Y4I.cjs');
9
9
  var chunk5SN4U5AC_cjs = require('../chunk-5SN4U5AC.cjs');
10
10
  var chunk3HQNCTZ2_cjs = require('../chunk-3HQNCTZ2.cjs');
11
11
  var chunkOGCNNUHF_cjs = require('../chunk-OGCNNUHF.cjs');
@@ -24,7 +24,7 @@ Object.defineProperty(exports, "tools", {
24
24
  });
25
25
  Object.defineProperty(exports, "vNextWorkflows", {
26
26
  enumerable: true,
27
- get: function () { return chunkOHKAN72U_cjs.vNextWorkflows_exports; }
27
+ get: function () { return chunkM6MC2QMH_cjs.vNextWorkflows_exports; }
28
28
  });
29
29
  Object.defineProperty(exports, "vector", {
30
30
  enumerable: true,
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "voice", {
36
36
  });
37
37
  Object.defineProperty(exports, "workflows", {
38
38
  enumerable: true,
39
- get: function () { return chunkRYUN5DF4_cjs.workflows_exports; }
39
+ get: function () { return chunkI2B73Y4I_cjs.workflows_exports; }
40
40
  });
41
41
  Object.defineProperty(exports, "a2a", {
42
42
  enumerable: true,
@@ -1,9 +1,9 @@
1
1
  export { telemetry_exports as telemetry } from '../chunk-OR3CIE2H.js';
2
2
  export { tools_exports as tools } from '../chunk-TJKLBTFB.js';
3
- export { vNextWorkflows_exports as vNextWorkflows } from '../chunk-WVDUW4GI.js';
3
+ export { vNextWorkflows_exports as vNextWorkflows } from '../chunk-WJU67W7F.js';
4
4
  export { vector_exports as vector } from '../chunk-IU5VO2I2.js';
5
5
  export { voice_exports as voice } from '../chunk-HFWCEP5S.js';
6
- export { workflows_exports as workflows } from '../chunk-2KIW6AJK.js';
6
+ export { workflows_exports as workflows } from '../chunk-EJO45KYT.js';
7
7
  export { a2a_exports as a2a } from '../chunk-P6SCPDYW.js';
8
8
  export { agents_exports as agents } from '../chunk-Q6KMBIAN.js';
9
9
  export { logs_exports as logs } from '../chunk-HWZVAG3H.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "2.0.4-alpha.0",
3
+ "version": "2.0.4-alpha.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -46,8 +46,8 @@
46
46
  "license": "Elastic-2.0",
47
47
  "dependencies": {},
48
48
  "peerDependencies": {
49
- "zod": "^3.23.0",
50
- "@mastra/core": "^0.9.4-alpha.0"
49
+ "zod": "^3.0.0",
50
+ "@mastra/core": "^0.9.4-alpha.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@ai-sdk/openai": "^1.3.2",
@@ -58,10 +58,10 @@
58
58
  "tsup": "^8.4.0",
59
59
  "typescript": "^5.8.2",
60
60
  "vitest": "^2.1.9",
61
- "zod": "^3.24.4",
61
+ "zod": "^3.24.3",
62
62
  "zod-to-json-schema": "^3.24.5",
63
- "@mastra/core": "0.9.4-alpha.0",
64
- "@internal/lint": "0.0.4"
63
+ "@internal/lint": "0.0.4",
64
+ "@mastra/core": "0.9.4-alpha.1"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",