@mastra/server 0.10.0 → 0.10.1-alpha.0
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.
- package/dist/_tsup-dts-rollup.d.cts +11 -0
- package/dist/_tsup-dts-rollup.d.ts +11 -0
- package/dist/{chunk-QY36IPTP.js → chunk-KUNQFY2W.js} +35 -1
- package/dist/{chunk-6B4OMWT6.cjs → chunk-MMO2HDM6.cjs} +35 -0
- package/dist/server/handlers/workflows.cjs +15 -11
- package/dist/server/handlers/workflows.d.cts +1 -0
- package/dist/server/handlers/workflows.d.ts +1 -0
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +1 -1
- package/package.json +3 -3
|
@@ -38,6 +38,7 @@ import type { TaskSendParams } from '@mastra/core/a2a';
|
|
|
38
38
|
import type { TaskStatus } from '@mastra/core/a2a';
|
|
39
39
|
import type { ToolAction } from '@mastra/core/tools';
|
|
40
40
|
import type { VercelTool } from '@mastra/core/tools';
|
|
41
|
+
import { WatchEvent } from '@mastra/core/workflows';
|
|
41
42
|
import type { Workflow } from '@mastra/core/workflows';
|
|
42
43
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
|
|
43
44
|
import { WorkflowResult } from '@mastra/core/workflows';
|
|
@@ -673,6 +674,15 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
673
674
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
674
675
|
}): Promise<Response>;
|
|
675
676
|
|
|
677
|
+
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
678
|
+
inputData?: unknown;
|
|
679
|
+
runtimeContext?: RuntimeContext_2;
|
|
680
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
681
|
+
}): {
|
|
682
|
+
stream: globalThis.ReadableStream<WatchEvent>;
|
|
683
|
+
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
684
|
+
};
|
|
685
|
+
|
|
676
686
|
declare type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
|
|
677
687
|
|
|
678
688
|
export declare namespace telemetry {
|
|
@@ -808,6 +818,7 @@ export declare namespace workflows {
|
|
|
808
818
|
startAsyncWorkflowHandler,
|
|
809
819
|
startWorkflowRunHandler,
|
|
810
820
|
watchWorkflowHandler,
|
|
821
|
+
streamWorkflowHandler,
|
|
811
822
|
resumeAsyncWorkflowHandler,
|
|
812
823
|
resumeWorkflowHandler,
|
|
813
824
|
getWorkflowRunsHandler
|
|
@@ -38,6 +38,7 @@ import type { TaskSendParams } from '@mastra/core/a2a';
|
|
|
38
38
|
import type { TaskStatus } from '@mastra/core/a2a';
|
|
39
39
|
import type { ToolAction } from '@mastra/core/tools';
|
|
40
40
|
import type { VercelTool } from '@mastra/core/tools';
|
|
41
|
+
import { WatchEvent } from '@mastra/core/workflows';
|
|
41
42
|
import type { Workflow } from '@mastra/core/workflows';
|
|
42
43
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
|
|
43
44
|
import { WorkflowResult } from '@mastra/core/workflows';
|
|
@@ -673,6 +674,15 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
673
674
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
674
675
|
}): Promise<Response>;
|
|
675
676
|
|
|
677
|
+
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, runtimeContextFromRequest, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
678
|
+
inputData?: unknown;
|
|
679
|
+
runtimeContext?: RuntimeContext_2;
|
|
680
|
+
runtimeContextFromRequest?: Record<string, unknown>;
|
|
681
|
+
}): {
|
|
682
|
+
stream: globalThis.ReadableStream<WatchEvent>;
|
|
683
|
+
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
684
|
+
};
|
|
685
|
+
|
|
676
686
|
declare type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
|
|
677
687
|
|
|
678
688
|
export declare namespace telemetry {
|
|
@@ -808,6 +818,7 @@ export declare namespace workflows {
|
|
|
808
818
|
startAsyncWorkflowHandler,
|
|
809
819
|
startWorkflowRunHandler,
|
|
810
820
|
watchWorkflowHandler,
|
|
821
|
+
streamWorkflowHandler,
|
|
811
822
|
resumeAsyncWorkflowHandler,
|
|
812
823
|
resumeWorkflowHandler,
|
|
813
824
|
getWorkflowRunsHandler
|
|
@@ -17,6 +17,7 @@ __export(workflows_exports, {
|
|
|
17
17
|
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
18
18
|
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
19
19
|
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
20
|
+
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
20
21
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
21
22
|
});
|
|
22
23
|
async function getWorkflowsHandler({ mastra }) {
|
|
@@ -233,6 +234,39 @@ async function watchWorkflowHandler({
|
|
|
233
234
|
return handleError(error, "Error watching workflow");
|
|
234
235
|
}
|
|
235
236
|
}
|
|
237
|
+
function streamWorkflowHandler({
|
|
238
|
+
mastra,
|
|
239
|
+
runtimeContext,
|
|
240
|
+
workflowId,
|
|
241
|
+
runId,
|
|
242
|
+
inputData,
|
|
243
|
+
runtimeContextFromRequest
|
|
244
|
+
}) {
|
|
245
|
+
try {
|
|
246
|
+
if (!workflowId) {
|
|
247
|
+
throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
248
|
+
}
|
|
249
|
+
if (!runId) {
|
|
250
|
+
throw new HTTPException(400, { message: "runId required to resume workflow" });
|
|
251
|
+
}
|
|
252
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
253
|
+
if (!workflow) {
|
|
254
|
+
throw new HTTPException(404, { message: "Workflow not found" });
|
|
255
|
+
}
|
|
256
|
+
const finalRuntimeContext = new RuntimeContext([
|
|
257
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
258
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
259
|
+
]);
|
|
260
|
+
const run = workflow.createRun({ runId });
|
|
261
|
+
const result = run.stream({
|
|
262
|
+
inputData,
|
|
263
|
+
runtimeContext: finalRuntimeContext
|
|
264
|
+
});
|
|
265
|
+
return result;
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return handleError(error, "Error executing workflow");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
236
270
|
async function resumeAsyncWorkflowHandler({
|
|
237
271
|
mastra,
|
|
238
272
|
workflowId,
|
|
@@ -328,4 +362,4 @@ async function getWorkflowRunsHandler({
|
|
|
328
362
|
}
|
|
329
363
|
}
|
|
330
364
|
|
|
331
|
-
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, workflows_exports };
|
|
365
|
+
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler, workflows_exports };
|
|
@@ -19,6 +19,7 @@ chunk75ZPJI57_cjs.__export(workflows_exports, {
|
|
|
19
19
|
resumeWorkflowHandler: () => resumeWorkflowHandler,
|
|
20
20
|
startAsyncWorkflowHandler: () => startAsyncWorkflowHandler,
|
|
21
21
|
startWorkflowRunHandler: () => startWorkflowRunHandler,
|
|
22
|
+
streamWorkflowHandler: () => streamWorkflowHandler,
|
|
22
23
|
watchWorkflowHandler: () => watchWorkflowHandler
|
|
23
24
|
});
|
|
24
25
|
async function getWorkflowsHandler({ mastra }) {
|
|
@@ -235,6 +236,39 @@ async function watchWorkflowHandler({
|
|
|
235
236
|
return chunk64U3UDTH_cjs.handleError(error, "Error watching workflow");
|
|
236
237
|
}
|
|
237
238
|
}
|
|
239
|
+
function streamWorkflowHandler({
|
|
240
|
+
mastra,
|
|
241
|
+
runtimeContext,
|
|
242
|
+
workflowId,
|
|
243
|
+
runId,
|
|
244
|
+
inputData,
|
|
245
|
+
runtimeContextFromRequest
|
|
246
|
+
}) {
|
|
247
|
+
try {
|
|
248
|
+
if (!workflowId) {
|
|
249
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
250
|
+
}
|
|
251
|
+
if (!runId) {
|
|
252
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(400, { message: "runId required to resume workflow" });
|
|
253
|
+
}
|
|
254
|
+
const workflow = mastra.getWorkflow(workflowId);
|
|
255
|
+
if (!workflow) {
|
|
256
|
+
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
257
|
+
}
|
|
258
|
+
const finalRuntimeContext = new di.RuntimeContext([
|
|
259
|
+
...Array.from(runtimeContext?.entries() ?? []),
|
|
260
|
+
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
261
|
+
]);
|
|
262
|
+
const run = workflow.createRun({ runId });
|
|
263
|
+
const result = run.stream({
|
|
264
|
+
inputData,
|
|
265
|
+
runtimeContext: finalRuntimeContext
|
|
266
|
+
});
|
|
267
|
+
return result;
|
|
268
|
+
} catch (error) {
|
|
269
|
+
return chunk64U3UDTH_cjs.handleError(error, "Error executing workflow");
|
|
270
|
+
}
|
|
271
|
+
}
|
|
238
272
|
async function resumeAsyncWorkflowHandler({
|
|
239
273
|
mastra,
|
|
240
274
|
workflowId,
|
|
@@ -339,5 +373,6 @@ exports.resumeAsyncWorkflowHandler = resumeAsyncWorkflowHandler;
|
|
|
339
373
|
exports.resumeWorkflowHandler = resumeWorkflowHandler;
|
|
340
374
|
exports.startAsyncWorkflowHandler = startAsyncWorkflowHandler;
|
|
341
375
|
exports.startWorkflowRunHandler = startWorkflowRunHandler;
|
|
376
|
+
exports.streamWorkflowHandler = streamWorkflowHandler;
|
|
342
377
|
exports.watchWorkflowHandler = watchWorkflowHandler;
|
|
343
378
|
exports.workflows_exports = workflows_exports;
|
|
@@ -1,46 +1,50 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMMO2HDM6_cjs = require('../../chunk-MMO2HDM6.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "createWorkflowRunHandler", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkMMO2HDM6_cjs.createWorkflowRunHandler; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "getWorkflowByIdHandler", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkMMO2HDM6_cjs.getWorkflowByIdHandler; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "getWorkflowRunByIdHandler", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkMMO2HDM6_cjs.getWorkflowRunByIdHandler; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "getWorkflowRunsHandler", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkMMO2HDM6_cjs.getWorkflowRunsHandler; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "getWorkflowsHandler", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkMMO2HDM6_cjs.getWorkflowsHandler; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "resumeAsyncWorkflowHandler", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkMMO2HDM6_cjs.resumeAsyncWorkflowHandler; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "resumeWorkflowHandler", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkMMO2HDM6_cjs.resumeWorkflowHandler; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "startAsyncWorkflowHandler", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkMMO2HDM6_cjs.startAsyncWorkflowHandler; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "startWorkflowRunHandler", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkMMO2HDM6_cjs.startWorkflowRunHandler; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "streamWorkflowHandler", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunkMMO2HDM6_cjs.streamWorkflowHandler; }
|
|
42
46
|
});
|
|
43
47
|
Object.defineProperty(exports, "watchWorkflowHandler", {
|
|
44
48
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkMMO2HDM6_cjs.watchWorkflowHandler; }
|
|
46
50
|
});
|
|
@@ -5,6 +5,7 @@ export { createWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
|
|
|
5
5
|
export { startAsyncWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
6
6
|
export { startWorkflowRunHandler } from '../../_tsup-dts-rollup.cjs';
|
|
7
7
|
export { watchWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
8
|
+
export { streamWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
8
9
|
export { resumeAsyncWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
9
10
|
export { resumeWorkflowHandler } from '../../_tsup-dts-rollup.cjs';
|
|
10
11
|
export { getWorkflowRunsHandler } from '../../_tsup-dts-rollup.cjs';
|
|
@@ -5,6 +5,7 @@ export { createWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
|
|
|
5
5
|
export { startAsyncWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
6
6
|
export { startWorkflowRunHandler } from '../../_tsup-dts-rollup.js';
|
|
7
7
|
export { watchWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
8
|
+
export { streamWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
8
9
|
export { resumeAsyncWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
9
10
|
export { resumeWorkflowHandler } from '../../_tsup-dts-rollup.js';
|
|
10
11
|
export { getWorkflowRunsHandler } from '../../_tsup-dts-rollup.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler } from '../../chunk-
|
|
1
|
+
export { createWorkflowRunHandler, getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, streamWorkflowHandler, watchWorkflowHandler } from '../../chunk-KUNQFY2W.js';
|
package/dist/server/handlers.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var chunkMHKNLNAN_cjs = require('../chunk-MHKNLNAN.cjs');
|
|
|
5
5
|
var chunkZE5AAC4I_cjs = require('../chunk-ZE5AAC4I.cjs');
|
|
6
6
|
var chunkBNEY4P4P_cjs = require('../chunk-BNEY4P4P.cjs');
|
|
7
7
|
var chunkYBVOQN4M_cjs = require('../chunk-YBVOQN4M.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkMMO2HDM6_cjs = require('../chunk-MMO2HDM6.cjs');
|
|
9
9
|
var chunk5SN4U5AC_cjs = require('../chunk-5SN4U5AC.cjs');
|
|
10
10
|
var chunkD4IRYCUI_cjs = require('../chunk-D4IRYCUI.cjs');
|
|
11
11
|
var chunkYIOVBYZH_cjs = require('../chunk-YIOVBYZH.cjs');
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "voice", {
|
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "workflows", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkMMO2HDM6_cjs.workflows_exports; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "a2a", {
|
|
42
42
|
enumerable: true,
|
package/dist/server/handlers.js
CHANGED
|
@@ -3,7 +3,7 @@ export { telemetry_exports as telemetry } from '../chunk-OR3CIE2H.js';
|
|
|
3
3
|
export { tools_exports as tools } from '../chunk-TJKLBTFB.js';
|
|
4
4
|
export { vector_exports as vector } from '../chunk-55DOQLP6.js';
|
|
5
5
|
export { voice_exports as voice } from '../chunk-HFWCEP5S.js';
|
|
6
|
-
export { workflows_exports as workflows } from '../chunk-
|
|
6
|
+
export { workflows_exports as workflows } from '../chunk-KUNQFY2W.js';
|
|
7
7
|
export { a2a_exports as a2a } from '../chunk-P6SCPDYW.js';
|
|
8
8
|
export { agents_exports as agents } from '../chunk-WUC6LSTW.js';
|
|
9
9
|
export { legacyWorkflows_exports as legacyWorkflows } from '../chunk-W7VCKPAD.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/server",
|
|
3
|
-
"version": "0.10.0",
|
|
3
|
+
"version": "0.10.1-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"vitest": "^2.1.9",
|
|
61
61
|
"zod": "^3.24.3",
|
|
62
62
|
"zod-to-json-schema": "^3.24.5",
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
63
|
+
"@mastra/core": "0.10.1-alpha.1",
|
|
64
|
+
"@internal/lint": "0.0.6"
|
|
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",
|