@mastra/server 0.0.0-fix-prompt-enhance-route-20251210210827 → 0.0.0-fix-11329-windows-path-20251222155941
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/CHANGELOG.md +289 -37
- package/README.md +2 -2
- package/dist/{chunk-XKBWSWY5.js → chunk-253HVIIC.js} +22373 -18070
- package/dist/chunk-253HVIIC.js.map +1 -0
- package/dist/{chunk-LNCCLJQ6.js → chunk-2WMEM53H.js} +65 -17
- package/dist/chunk-2WMEM53H.js.map +1 -0
- package/dist/{chunk-PUSD37LD.cjs → chunk-3XI22UQR.cjs} +4 -3
- package/dist/chunk-3XI22UQR.cjs.map +1 -0
- package/dist/{chunk-IPXCJ2HO.cjs → chunk-564XV5EO.cjs} +68 -20
- package/dist/chunk-564XV5EO.cjs.map +1 -0
- package/dist/{chunk-W3QZMAHX.cjs → chunk-7KOS32XA.cjs} +103 -30
- package/dist/chunk-7KOS32XA.cjs.map +1 -0
- package/dist/chunk-AZIH2QEC.js +83 -0
- package/dist/chunk-AZIH2QEC.js.map +1 -0
- package/dist/{chunk-LPM6BBAX.cjs → chunk-BMLUV4BH.cjs} +2 -53
- package/dist/chunk-BMLUV4BH.cjs.map +1 -0
- package/dist/{chunk-YP34EWWK.js → chunk-DVSCJECS.js} +11 -14
- package/dist/chunk-DVSCJECS.js.map +1 -0
- package/dist/{chunk-4W2SM6CG.js → chunk-DW3WE4M4.js} +14 -58
- package/dist/chunk-DW3WE4M4.js.map +1 -0
- package/dist/{chunk-RQK4FQUD.js → chunk-E646Y4FQ.js} +3 -45
- package/dist/chunk-E646Y4FQ.js.map +1 -0
- package/dist/chunk-EUBTCHQC.js +83 -0
- package/dist/chunk-EUBTCHQC.js.map +1 -0
- package/dist/chunk-FWSKVWS7.cjs +88 -0
- package/dist/chunk-FWSKVWS7.cjs.map +1 -0
- package/dist/{chunk-C3D3X2L5.cjs → chunk-JUYWLFVT.cjs} +16 -7
- package/dist/chunk-JUYWLFVT.cjs.map +1 -0
- package/dist/{chunk-XO6UQB2N.cjs → chunk-K6GBS34H.cjs} +22108 -17805
- package/dist/chunk-K6GBS34H.cjs.map +1 -0
- package/dist/{chunk-2PLXW4ZX.cjs → chunk-K73YS7YB.cjs} +74 -74
- package/dist/{chunk-2PLXW4ZX.cjs.map → chunk-K73YS7YB.cjs.map} +1 -1
- package/dist/{chunk-V272B7RM.cjs → chunk-LKTCAPBD.cjs} +15 -18
- package/dist/chunk-LKTCAPBD.cjs.map +1 -0
- package/dist/{chunk-FPCGLPLJ.cjs → chunk-P3H4AZKI.cjs} +17 -62
- package/dist/chunk-P3H4AZKI.cjs.map +1 -0
- package/dist/chunk-Q7NPRJRV.cjs +88 -0
- package/dist/chunk-Q7NPRJRV.cjs.map +1 -0
- package/dist/{chunk-CT5VG7NT.js → chunk-S5XBFHJL.js} +14 -5
- package/dist/chunk-S5XBFHJL.js.map +1 -0
- package/dist/{chunk-ZULZ2752.js → chunk-SV4AUWGY.js} +3 -3
- package/dist/{chunk-ZULZ2752.js.map → chunk-SV4AUWGY.js.map} +1 -1
- package/dist/{chunk-ACZ2PUKX.js → chunk-UWRAKVAJ.js} +102 -29
- package/dist/chunk-UWRAKVAJ.js.map +1 -0
- package/dist/{chunk-6YWE7UPT.js → chunk-WBLT2HL3.js} +4 -3
- package/dist/chunk-WBLT2HL3.js.map +1 -0
- package/dist/dist-2J26LQO2.cjs +16 -0
- package/dist/{dist-P4MXBQ3U.cjs.map → dist-2J26LQO2.cjs.map} +1 -1
- package/dist/{dist-X7XR3M3Z.js → dist-4CMHRWC4.js} +3 -3
- package/dist/{dist-X7XR3M3Z.js.map → dist-4CMHRWC4.js.map} +1 -1
- package/dist/{dist-PQZUVLPC.js → dist-AEJONJSS.js} +3 -3
- package/dist/{dist-PQZUVLPC.js.map → dist-AEJONJSS.js.map} +1 -1
- package/dist/{dist-G2BYZJOC.cjs → dist-AF7EUPXA.cjs} +28 -28
- package/dist/{dist-G2BYZJOC.cjs.map → dist-AF7EUPXA.cjs.map} +1 -1
- package/dist/dist-MEN73GGI.js +3 -0
- package/dist/{dist-YREX2TJT.js.map → dist-MEN73GGI.js.map} +1 -1
- package/dist/{dist-FZYCV3VB.cjs → dist-NVXXJWBO.cjs} +26 -26
- package/dist/{dist-FZYCV3VB.cjs.map → dist-NVXXJWBO.cjs.map} +1 -1
- package/dist/{dist-RFMYFILX.cjs → dist-Q2ST4SUQ.cjs} +30 -30
- package/dist/{dist-RFMYFILX.cjs.map → dist-Q2ST4SUQ.cjs.map} +1 -1
- package/dist/{dist-XVBSOGFK.js → dist-TE7XRSWH.js} +3 -3
- package/dist/{dist-XVBSOGFK.js.map → dist-TE7XRSWH.js.map} +1 -1
- package/dist/{dist-R7WYX6LC.js → dist-VPYZNWNG.js} +3 -3
- package/dist/{dist-R7WYX6LC.js.map → dist-VPYZNWNG.js.map} +1 -1
- package/dist/{dist-4MVGNSRL.cjs → dist-Y5SYUVLY.cjs} +20 -20
- package/dist/{dist-4MVGNSRL.cjs.map → dist-Y5SYUVLY.cjs.map} +1 -1
- package/dist/server/handlers/a2a.cjs +9 -9
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +19 -19
- package/dist/server/handlers/agent-builder.d.ts +65 -6
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +24 -24
- package/dist/server/handlers/agents.d.ts +4 -3
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/workflows.cjs +27 -27
- package/dist/server/handlers/workflows.d.ts +115 -10
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +8 -8
- package/dist/server/handlers.js +4 -4
- package/dist/server/schemas/agent-builder.d.ts +21 -0
- package/dist/server/schemas/agent-builder.d.ts.map +1 -1
- package/dist/server/schemas/workflows.d.ts +88 -7
- package/dist/server/schemas/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +71 -71
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +3 -3
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +5 -5
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/routes/index.d.ts +2 -2
- package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/{token-VFONFWVS.cjs → token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs} +11 -12
- package/dist/token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs.map +1 -0
- package/dist/{token-JGA3ZWAN.js → token-6GSAFR2W-KVDFAJ2M-LNX5VF3I.js} +8 -8
- package/dist/token-6GSAFR2W-KVDFAJ2M-LNX5VF3I.js.map +1 -0
- package/dist/{token-ZOD6YIQ3.cjs → token-6GSAFR2W-KVDFAJ2M-SDYXODLX.cjs} +11 -11
- package/dist/token-6GSAFR2W-KVDFAJ2M-SDYXODLX.cjs.map +1 -0
- package/dist/{token-GVZ7HRD7.js → token-6GSAFR2W-KVDFAJ2M-VW443KIA.js} +8 -9
- package/dist/token-6GSAFR2W-KVDFAJ2M-VW443KIA.js.map +1 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs +10 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs.map +1 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-BSQMRUEW.js +8 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-BSQMRUEW.js.map +1 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js +8 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js.map +1 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-MFJRDVVF.cjs +10 -0
- package/dist/token-util-NEHG7TUY-DJYRKLRD-MFJRDVVF.cjs.map +1 -0
- package/package.json +6 -7
- package/dist/chunk-4W2SM6CG.js.map +0 -1
- package/dist/chunk-6YWE7UPT.js.map +0 -1
- package/dist/chunk-ACZ2PUKX.js.map +0 -1
- package/dist/chunk-C3D3X2L5.cjs.map +0 -1
- package/dist/chunk-CT5VG7NT.js.map +0 -1
- package/dist/chunk-ER3QM7DD.js +0 -46
- package/dist/chunk-ER3QM7DD.js.map +0 -1
- package/dist/chunk-FPCGLPLJ.cjs.map +0 -1
- package/dist/chunk-IPXCJ2HO.cjs.map +0 -1
- package/dist/chunk-LNCCLJQ6.js.map +0 -1
- package/dist/chunk-LPM6BBAX.cjs.map +0 -1
- package/dist/chunk-PUSD37LD.cjs.map +0 -1
- package/dist/chunk-RQK4FQUD.js.map +0 -1
- package/dist/chunk-V272B7RM.cjs.map +0 -1
- package/dist/chunk-W3QZMAHX.cjs.map +0 -1
- package/dist/chunk-XKBWSWY5.js.map +0 -1
- package/dist/chunk-XO6UQB2N.cjs.map +0 -1
- package/dist/chunk-XQPJ63ZD.cjs +0 -48
- package/dist/chunk-XQPJ63ZD.cjs.map +0 -1
- package/dist/chunk-YP34EWWK.js.map +0 -1
- package/dist/dist-P4MXBQ3U.cjs +0 -16
- package/dist/dist-YREX2TJT.js +0 -3
- package/dist/token-GVZ7HRD7.js.map +0 -1
- package/dist/token-JGA3ZWAN.js.map +0 -1
- package/dist/token-VFONFWVS.cjs.map +0 -1
- package/dist/token-ZOD6YIQ3.cjs.map +0 -1
- package/dist/token-util-7R2ZFIXO.js +0 -7
- package/dist/token-util-7R2ZFIXO.js.map +0 -1
- package/dist/token-util-BLJZJDBZ.cjs +0 -9
- package/dist/token-util-BLJZJDBZ.cjs.map +0 -1
- package/dist/token-util-VGZUWSNR.cjs +0 -9
- package/dist/token-util-VGZUWSNR.cjs.map +0 -1
- package/dist/token-util-VKTPZLSE.js +0 -7
- package/dist/token-util-VKTPZLSE.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk3XI22UQR_cjs = require('./chunk-3XI22UQR.cjs');
|
|
4
4
|
var chunkBMYZ4DO6_cjs = require('./chunk-BMYZ4DO6.cjs');
|
|
5
5
|
var chunkMCYD5LW7_cjs = require('./chunk-MCYD5LW7.cjs');
|
|
6
6
|
var chunkH2RMXG2Q_cjs = require('./chunk-H2RMXG2Q.cjs');
|
|
@@ -52,7 +52,9 @@ var workflowRunStatusSchema = z__default.default.enum([
|
|
|
52
52
|
"failed",
|
|
53
53
|
"canceled",
|
|
54
54
|
"pending",
|
|
55
|
-
"bailed"
|
|
55
|
+
"bailed",
|
|
56
|
+
"tripwire",
|
|
57
|
+
"paused"
|
|
56
58
|
]);
|
|
57
59
|
var workflowIdPathParams = z__default.default.object({
|
|
58
60
|
workflowId: z__default.default.string().describe("Unique identifier for the workflow")
|
|
@@ -75,7 +77,8 @@ var workflowInfoSchema = z__default.default.object({
|
|
|
75
77
|
stepGraph: z__default.default.array(serializedStepFlowEntrySchema),
|
|
76
78
|
inputSchema: z__default.default.string().optional(),
|
|
77
79
|
outputSchema: z__default.default.string().optional(),
|
|
78
|
-
options: z__default.default.object({}).optional()
|
|
80
|
+
options: z__default.default.object({}).optional(),
|
|
81
|
+
isProcessorWorkflow: z__default.default.boolean().optional()
|
|
79
82
|
});
|
|
80
83
|
var listWorkflowsResponseSchema = z__default.default.record(z__default.default.string(), workflowInfoSchema);
|
|
81
84
|
var workflowRunSchema = z__default.default.object({
|
|
@@ -98,10 +101,12 @@ var listWorkflowRunsQuerySchema = chunkMCYD5LW7_cjs.createCombinedPaginationSche
|
|
|
98
101
|
status: workflowRunStatusSchema.optional()
|
|
99
102
|
});
|
|
100
103
|
var workflowExecutionBodySchema = z__default.default.object({
|
|
104
|
+
resourceId: z__default.default.string().optional(),
|
|
101
105
|
inputData: z__default.default.unknown().optional(),
|
|
102
106
|
initialState: z__default.default.unknown().optional(),
|
|
103
107
|
requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
|
|
104
|
-
tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional()
|
|
108
|
+
tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional(),
|
|
109
|
+
perStep: z__default.default.boolean().optional()
|
|
105
110
|
});
|
|
106
111
|
var streamLegacyWorkflowBodySchema = workflowExecutionBodySchema;
|
|
107
112
|
var streamWorkflowBodySchema = workflowExecutionBodySchema.extend({
|
|
@@ -112,7 +117,8 @@ var resumeBodySchema = z__default.default.object({
|
|
|
112
117
|
// Optional - workflow can auto-resume all suspended steps
|
|
113
118
|
resumeData: z__default.default.unknown().optional(),
|
|
114
119
|
requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
|
|
115
|
-
tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional()
|
|
120
|
+
tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional(),
|
|
121
|
+
perStep: z__default.default.boolean().optional()
|
|
116
122
|
});
|
|
117
123
|
var restartBodySchema = z__default.default.object({
|
|
118
124
|
requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
|
|
@@ -126,22 +132,57 @@ var timeTravelBodySchema = z__default.default.object({
|
|
|
126
132
|
context: z__default.default.record(z__default.default.string(), z__default.default.any()).optional(),
|
|
127
133
|
nestedStepsContext: z__default.default.record(z__default.default.string(), z__default.default.record(z__default.default.string(), z__default.default.any())).optional(),
|
|
128
134
|
requestContext: z__default.default.record(z__default.default.string(), z__default.default.unknown()).optional(),
|
|
129
|
-
tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional()
|
|
135
|
+
tracingOptions: chunkMCYD5LW7_cjs.tracingOptionsSchema.optional(),
|
|
136
|
+
perStep: z__default.default.boolean().optional()
|
|
130
137
|
});
|
|
131
138
|
var startAsyncWorkflowBodySchema = workflowExecutionBodySchema;
|
|
132
139
|
z__default.default.object({
|
|
133
140
|
event: z__default.default.string(),
|
|
134
141
|
data: z__default.default.unknown()
|
|
135
142
|
});
|
|
143
|
+
var workflowExecutionResultQuerySchema = z__default.default.object({
|
|
144
|
+
fields: z__default.default.string().optional().refine(
|
|
145
|
+
(value) => {
|
|
146
|
+
if (!value) return true;
|
|
147
|
+
const validFields = /* @__PURE__ */ new Set([
|
|
148
|
+
"status",
|
|
149
|
+
"result",
|
|
150
|
+
"error",
|
|
151
|
+
"payload",
|
|
152
|
+
"steps",
|
|
153
|
+
"activeStepsPath",
|
|
154
|
+
"serializedStepGraph"
|
|
155
|
+
]);
|
|
156
|
+
const requestedFields = value.split(",").map((f) => f.trim());
|
|
157
|
+
return requestedFields.every((field) => validFields.has(field));
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
message: "Invalid field name. Available fields: status, result, error, payload, steps, activeStepsPath, serializedStepGraph"
|
|
161
|
+
}
|
|
162
|
+
).describe(
|
|
163
|
+
"Comma-separated list of fields to return. Available fields: status, result, error, payload, steps, activeStepsPath, serializedStepGraph. If not provided, returns all fields."
|
|
164
|
+
),
|
|
165
|
+
withNestedWorkflows: z__default.default.enum(["true", "false"]).optional().describe(
|
|
166
|
+
"Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance."
|
|
167
|
+
)
|
|
168
|
+
});
|
|
136
169
|
var workflowExecutionResultSchema = z__default.default.object({
|
|
137
|
-
status: workflowRunStatusSchema,
|
|
170
|
+
status: workflowRunStatusSchema.optional(),
|
|
138
171
|
result: z__default.default.unknown().optional(),
|
|
139
|
-
error: z__default.default.unknown().optional()
|
|
172
|
+
error: z__default.default.unknown().optional(),
|
|
173
|
+
payload: z__default.default.unknown().optional(),
|
|
174
|
+
steps: z__default.default.record(z__default.default.string(), z__default.default.any()).optional(),
|
|
175
|
+
activeStepsPath: z__default.default.record(z__default.default.string(), z__default.default.array(z__default.default.number())).optional(),
|
|
176
|
+
serializedStepGraph: z__default.default.array(serializedStepFlowEntrySchema).optional()
|
|
140
177
|
});
|
|
141
178
|
var workflowControlResponseSchema = chunkMCYD5LW7_cjs.messageResponseSchema;
|
|
142
179
|
var createWorkflowRunResponseSchema = z__default.default.object({
|
|
143
180
|
runId: z__default.default.string()
|
|
144
181
|
});
|
|
182
|
+
var createWorkflowRunBodySchema = z__default.default.object({
|
|
183
|
+
resourceId: z__default.default.string().optional(),
|
|
184
|
+
disableScorers: z__default.default.boolean().optional()
|
|
185
|
+
});
|
|
145
186
|
|
|
146
187
|
// src/server/handlers/workflows.ts
|
|
147
188
|
async function listWorkflowsFromSystem({ mastra, workflowId }) {
|
|
@@ -150,7 +191,7 @@ async function listWorkflowsFromSystem({ mastra, workflowId }) {
|
|
|
150
191
|
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
151
192
|
}
|
|
152
193
|
let workflow;
|
|
153
|
-
workflow =
|
|
194
|
+
workflow = chunk3XI22UQR_cjs.WorkflowRegistry.getWorkflow(workflowId);
|
|
154
195
|
if (!workflow) {
|
|
155
196
|
try {
|
|
156
197
|
workflow = mastra.getWorkflowById(workflowId);
|
|
@@ -197,7 +238,7 @@ var LIST_WORKFLOWS_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
197
238
|
const workflows = mastra.listWorkflows({ serialized: false });
|
|
198
239
|
const isPartial = partial === "true";
|
|
199
240
|
const _workflows = Object.entries(workflows).reduce((acc, [key, workflow]) => {
|
|
200
|
-
acc[key] =
|
|
241
|
+
acc[key] = chunk3XI22UQR_cjs.getWorkflowInfo(workflow, isPartial);
|
|
201
242
|
return acc;
|
|
202
243
|
}, {});
|
|
203
244
|
return _workflows;
|
|
@@ -221,7 +262,7 @@ var GET_WORKFLOW_BY_ID_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
221
262
|
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
222
263
|
}
|
|
223
264
|
const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });
|
|
224
|
-
return
|
|
265
|
+
return chunk3XI22UQR_cjs.getWorkflowInfo(workflow);
|
|
225
266
|
} catch (error) {
|
|
226
267
|
return chunkV5WWQN7P_cjs.handleError(error, "Error getting workflow");
|
|
227
268
|
}
|
|
@@ -342,11 +383,12 @@ var CREATE_WORKFLOW_RUN_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
342
383
|
responseType: "json",
|
|
343
384
|
pathParamSchema: workflowIdPathParams,
|
|
344
385
|
queryParamSchema: chunkMCYD5LW7_cjs.optionalRunIdSchema,
|
|
386
|
+
bodySchema: createWorkflowRunBodySchema,
|
|
345
387
|
responseSchema: createWorkflowRunResponseSchema,
|
|
346
388
|
summary: "Create workflow run",
|
|
347
389
|
description: "Creates a new workflow execution instance with an optional custom run ID",
|
|
348
390
|
tags: ["Workflows"],
|
|
349
|
-
handler: async ({ mastra, workflowId, runId }) => {
|
|
391
|
+
handler: async ({ mastra, workflowId, runId, resourceId, disableScorers }) => {
|
|
350
392
|
try {
|
|
351
393
|
if (!workflowId) {
|
|
352
394
|
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
@@ -355,7 +397,7 @@ var CREATE_WORKFLOW_RUN_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
355
397
|
if (!workflow) {
|
|
356
398
|
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
357
399
|
}
|
|
358
|
-
const run = await workflow.createRun({ runId });
|
|
400
|
+
const run = await workflow.createRun({ runId, resourceId, disableScorers });
|
|
359
401
|
return { runId: run.runId };
|
|
360
402
|
} catch (error) {
|
|
361
403
|
return chunkV5WWQN7P_cjs.handleError(error, "Error creating workflow run");
|
|
@@ -372,7 +414,7 @@ var STREAM_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
372
414
|
summary: "Stream workflow execution",
|
|
373
415
|
description: "Executes a workflow and streams the results in real-time",
|
|
374
416
|
tags: ["Workflows"],
|
|
375
|
-
handler: async ({ mastra, workflowId, runId, ...params }) => {
|
|
417
|
+
handler: async ({ mastra, workflowId, runId, resourceId, ...params }) => {
|
|
376
418
|
try {
|
|
377
419
|
if (!workflowId) {
|
|
378
420
|
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
@@ -385,7 +427,7 @@ var STREAM_WORKFLOW_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
385
427
|
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
386
428
|
}
|
|
387
429
|
const serverCache = mastra.getServerCache();
|
|
388
|
-
const run = await workflow.createRun({ runId });
|
|
430
|
+
const run = await workflow.createRun({ runId, resourceId });
|
|
389
431
|
const result = run.stream(params);
|
|
390
432
|
return result.fullStream.pipeThrough(
|
|
391
433
|
new web.TransformStream({
|
|
@@ -468,11 +510,12 @@ var GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
468
510
|
path: "/api/workflows/:workflowId/runs/:runId/execution-result",
|
|
469
511
|
responseType: "json",
|
|
470
512
|
pathParamSchema: workflowRunPathParams,
|
|
513
|
+
queryParamSchema: workflowExecutionResultQuerySchema,
|
|
471
514
|
responseSchema: workflowExecutionResultSchema,
|
|
472
515
|
summary: "Get workflow execution result",
|
|
473
|
-
description: "Returns the final execution result of a completed workflow run",
|
|
516
|
+
description: "Returns the final execution result of a completed workflow run. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=status,result)",
|
|
474
517
|
tags: ["Workflows"],
|
|
475
|
-
handler: async ({ mastra, workflowId, runId }) => {
|
|
518
|
+
handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows }) => {
|
|
476
519
|
try {
|
|
477
520
|
if (!workflowId) {
|
|
478
521
|
throw new chunk64ITUOXI_cjs.HTTPException(400, { message: "Workflow ID is required" });
|
|
@@ -484,7 +527,12 @@ var GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
484
527
|
if (!workflow) {
|
|
485
528
|
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
486
529
|
}
|
|
487
|
-
const
|
|
530
|
+
const fieldList = fields ? fields.split(",").map((f) => f.trim()) : void 0;
|
|
531
|
+
const executionResult = await workflow.getWorkflowRunExecutionResult(runId, {
|
|
532
|
+
withNestedWorkflows: withNestedWorkflows !== "false",
|
|
533
|
+
// Default to true unless explicitly 'false'
|
|
534
|
+
fields: fieldList
|
|
535
|
+
});
|
|
488
536
|
if (!executionResult) {
|
|
489
537
|
throw new chunk64ITUOXI_cjs.HTTPException(404, { message: "Workflow run execution result not found" });
|
|
490
538
|
}
|
|
@@ -1101,5 +1149,5 @@ exports.workflowInfoSchema = workflowInfoSchema;
|
|
|
1101
1149
|
exports.workflowRunResponseSchema = workflowRunResponseSchema;
|
|
1102
1150
|
exports.workflowRunsResponseSchema = workflowRunsResponseSchema;
|
|
1103
1151
|
exports.workflows_exports = workflows_exports;
|
|
1104
|
-
//# sourceMappingURL=chunk-
|
|
1105
|
-
//# sourceMappingURL=chunk-
|
|
1152
|
+
//# sourceMappingURL=chunk-564XV5EO.cjs.map
|
|
1153
|
+
//# sourceMappingURL=chunk-564XV5EO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/workflows.ts","../src/server/schemas/workflows.ts"],"names":["__export","z","createCombinedPaginationSchema","tracingOptionsSchema","messageResponseSchema","HTTPException","WorkflowRegistry","createRoute","getWorkflowInfo","handleError","optionalRunIdSchema","runIdSchema","TransformStream","streamResponseSchema","ReadableStream"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAA,iBAAA,GAAA;AAAAA,0BAAA,CAAA,iBAAA,EAAA;AAAA,EAAA,yBAAA,EAAA,MAAA,yBAA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,MAAA,MAAM,eAAA,GAAkB,MAAM,WAAA,CAAY,UAAA,CAAW,OAAO,CAAC,CAAA;AAE7D,MAAA,KAAA,MAAW,SAAS,eAAA,EAAiB;AACnC,QAAA,MAAM,MAAA,CAAO,MAAM,KAAY,CAAA;AAAA,MACjC;AAEA,MAAA,MAAA,CAAO,WAAA,EAAY;AAEnB,MAAA,MAAM,MAAA,GAAS,KAAK,mBAAA,EAAoB;AACxC,MAAA,OAAO,MAAA,CAAO,MAAA,EAAQ,WAAA,CAAY,eAAe,CAAA;AAAA,IACnD,SAAS,KAAA,EAAO;AACd,MAAA,OAAOH,6BAAA,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-564XV5EO.cjs","sourcesContent":["import { ReadableStream, TransformStream } from 'node:stream/web';\nimport type { WorkflowInfo, ChunkType, StreamEvent } from '@mastra/core/workflows';\nimport { z } from 'zod';\nimport { HTTPException } from '../http-exception';\nimport { streamResponseSchema } from '../schemas/agents';\nimport { optionalRunIdSchema, runIdSchema } from '../schemas/common';\nimport {\n createWorkflowRunBodySchema,\n createWorkflowRunResponseSchema,\n listWorkflowRunsQuerySchema,\n listWorkflowsResponseSchema,\n restartBodySchema,\n timeTravelBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamWorkflowBodySchema,\n workflowControlResponseSchema,\n workflowExecutionResultQuerySchema,\n workflowExecutionResultSchema,\n workflowIdPathParams,\n workflowInfoSchema,\n workflowRunPathParams,\n workflowRunResponseSchema,\n workflowRunsResponseSchema,\n} from '../schemas/workflows';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport type { Context } from '../types';\nimport { getWorkflowInfo, WorkflowRegistry } from '../utils';\nimport { handleError } from './error';\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n}\n\nasync function listWorkflowsFromSystem({ mastra, workflowId }: WorkflowContext) {\n const logger = mastra.getLogger();\n\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n let workflow;\n\n // First check registry for temporary workflows\n workflow = WorkflowRegistry.getWorkflow(workflowId);\n\n if (!workflow) {\n try {\n workflow = mastra.getWorkflowById(workflowId);\n } catch (error) {\n logger.debug('Error getting workflow, searching agents for workflow', error);\n }\n }\n\n if (!workflow) {\n logger.debug('Workflow not found, searching agents for workflow', { workflowId });\n const agents = mastra.listAgents();\n\n if (Object.keys(agents || {}).length) {\n for (const [_, agent] of Object.entries(agents)) {\n try {\n const workflows = await agent.listWorkflows();\n\n if (workflows[workflowId]) {\n workflow = workflows[workflowId];\n break;\n }\n break;\n } catch (error) {\n logger.debug('Error getting workflow from agent', error);\n }\n }\n }\n }\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n return { workflow };\n}\n\n// ============================================================================\n// Route Definitions (new pattern - handlers defined inline with createRoute)\n// ============================================================================\n\nexport const LIST_WORKFLOWS_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows',\n responseType: 'json',\n queryParamSchema: z.object({\n partial: z.string().optional(),\n }),\n responseSchema: listWorkflowsResponseSchema,\n summary: 'List all workflows',\n description: 'Returns a list of all available workflows in the system',\n tags: ['Workflows'],\n handler: async ({ mastra, partial }) => {\n try {\n const workflows = mastra.listWorkflows({ serialized: false });\n const isPartial = partial === 'true';\n const _workflows = Object.entries(workflows).reduce<Record<string, WorkflowInfo>>((acc, [key, workflow]) => {\n acc[key] = getWorkflowInfo(workflow, isPartial);\n return acc;\n }, {});\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n },\n});\n\nexport const GET_WORKFLOW_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows/:workflowId',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowInfoSchema,\n summary: 'Get workflow by ID',\n description: 'Returns details for a specific workflow',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n return getWorkflowInfo(workflow);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n },\n});\n\nexport const LIST_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows/:workflowId/runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: listWorkflowRunsQuerySchema,\n responseSchema: workflowRunsResponseSchema,\n summary: 'List workflow runs',\n description: 'Returns a paginated list of execution runs for the specified workflow',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, fromDate, toDate, page, perPage, limit, offset, resourceId, status }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n // Support both page/perPage and limit/offset for backwards compatibility\n // If page/perPage provided, use directly; otherwise convert from limit/offset\n let finalPage = page;\n let finalPerPage = perPage;\n\n if (finalPerPage === undefined && limit !== undefined) {\n finalPerPage = limit;\n }\n if (finalPage === undefined && offset !== undefined && finalPerPage !== undefined && finalPerPage > 0) {\n finalPage = Math.floor(offset / finalPerPage);\n }\n\n if (\n finalPerPage !== undefined &&\n (typeof finalPerPage !== 'number' || !Number.isInteger(finalPerPage) || finalPerPage <= 0)\n ) {\n throw new HTTPException(400, { message: 'perPage must be a positive integer' });\n }\n if (finalPage !== undefined && (!Number.isInteger(finalPage) || finalPage < 0)) {\n throw new HTTPException(400, { message: 'page must be a non-negative integer' });\n }\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const workflowRuns = (await workflow.listWorkflowRuns({\n fromDate: fromDate ? (typeof fromDate === 'string' ? new Date(fromDate) : fromDate) : undefined,\n toDate: toDate ? (typeof toDate === 'string' ? new Date(toDate) : toDate) : undefined,\n perPage: finalPerPage,\n page: finalPage,\n resourceId,\n status,\n })) || {\n runs: [],\n total: 0,\n };\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\n});\n\nexport const GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowRunResponseSchema,\n summary: 'Get workflow run by ID',\n description: 'Returns details for a specific workflow run',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n return run;\n } catch (error) {\n return handleError(error, 'Error getting workflow run');\n }\n },\n});\n\nexport const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'DELETE',\n path: '/api/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Delete workflow run by ID',\n description: 'Deletes a specific workflow run by ID',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n await workflow.deleteWorkflowRunById(runId);\n\n return { message: 'Workflow run deleted' };\n } catch (error) {\n return handleError(error, 'Error deleting workflow run');\n }\n },\n});\n\nexport const CREATE_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/create-run',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: createWorkflowRunBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Create workflow run',\n description: 'Creates a new workflow execution instance with an optional custom run ID',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, resourceId, disableScorers }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.createRun({ runId, resourceId, disableScorers });\n\n return { runId: run.runId };\n } catch (error) {\n return handleError(error, 'Error creating workflow run');\n }\n },\n});\n\nexport const STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n summary: 'Stream workflow execution',\n description: 'Executes a workflow and streams the results in real-time',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, resourceId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to stream workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId });\n const result = run.stream(params);\n return result.fullStream.pipeThrough(\n new TransformStream<ChunkType, ChunkType>({\n transform(chunk, controller) {\n if (serverCache) {\n const cacheKey = runId;\n serverCache.listPush(cacheKey, chunk).catch(() => {});\n }\n controller.enqueue(chunk);\n },\n }),\n );\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n },\n});\n\nexport const STREAM_VNEXT_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/streamVNext',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n summary: 'Stream workflow execution (v2)',\n description: 'Executes a workflow using the v2 streaming API and streams the results in real-time',\n tags: ['Workflows'],\n handler: STREAM_WORKFLOW_ROUTE.handler,\n});\n\nexport const RESUME_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/resume-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: streamResponseSchema,\n summary: 'Resume workflow stream',\n description: 'Resumes a suspended workflow execution and continues streaming results',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const stream = _run.resumeStream(params).fullStream.pipeThrough(\n new TransformStream<ChunkType, ChunkType>({\n transform(chunk, controller) {\n if (serverCache) {\n const cacheKey = runId;\n serverCache.listPush(cacheKey, chunk).catch(() => {});\n }\n\n controller.enqueue(chunk);\n },\n }),\n );\n\n return stream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const GET_WORKFLOW_RUN_EXECUTION_RESULT_ROUTE = createRoute({\n method: 'GET',\n path: '/api/workflows/:workflowId/runs/:runId/execution-result',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n queryParamSchema: workflowExecutionResultQuerySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Get workflow execution result',\n description:\n 'Returns the final execution result of a completed workflow run. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=status,result)',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'Run ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n // Parse fields parameter (comma-separated string)\n const fieldList = fields ? fields.split(',').map((f: string) => f.trim()) : undefined;\n\n const executionResult = await workflow.getWorkflowRunExecutionResult(runId, {\n withNestedWorkflows: withNestedWorkflows !== 'false', // Default to true unless explicitly 'false'\n fields: fieldList,\n });\n\n if (!executionResult) {\n throw new HTTPException(404, { message: 'Workflow run execution result not found' });\n }\n\n return executionResult;\n } catch (error) {\n return handleError(error, 'Error getting workflow run execution result');\n }\n },\n});\n\nexport const START_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/start-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: optionalRunIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Start workflow asynchronously',\n description: 'Starts a workflow execution asynchronously without streaming results',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const _run = await workflow.createRun({ runId });\n const result = await _run.start(params);\n return result;\n } catch (error) {\n return handleError(error, 'Error starting async workflow');\n }\n },\n});\n\nexport const START_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/start',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: startAsyncWorkflowBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Start specific workflow run',\n description: 'Starts execution of a specific workflow run by ID',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to start run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n void _run.start({\n ...params,\n });\n\n return { message: 'Workflow run started' };\n } catch (e) {\n return handleError(e, 'Error starting workflow run');\n }\n },\n});\n\nexport const OBSERVE_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/observe',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe workflow stream',\n description: 'Observes and streams updates from an already running workflow execution',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n // Get cached chunks first\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n // Create a readable stream that first emits cached chunks, then the live stream\n const combinedStream = new ReadableStream<ChunkType>({\n start(controller) {\n // First, emit all cached chunks\n const emitCachedChunks = async () => {\n for (const chunk of cachedRunChunks) {\n controller.enqueue(chunk as ChunkType);\n }\n };\n\n // Then, pipe the live stream\n const liveStream = _run.observeStream();\n const reader = liveStream.getReader();\n\n const pump = async () => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n break;\n }\n controller.enqueue(value);\n }\n } catch (error) {\n controller.error(error);\n } finally {\n reader.releaseLock();\n }\n };\n\n // Start with cached chunks, then live stream\n void emitCachedChunks()\n .then(() => {\n void pump();\n })\n .catch(error => {\n controller.error(error);\n });\n },\n });\n\n return combinedStream;\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\nexport const OBSERVE_STREAM_VNEXT_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/observe-streamVNext',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe workflow stream (v2)',\n description: 'Observes and streams updates from an already running workflow execution using v2 streaming API',\n tags: ['Workflows'],\n handler: OBSERVE_STREAM_WORKFLOW_ROUTE.handler,\n});\n\nexport const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/resume-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Resume workflow asynchronously',\n description: 'Resumes a suspended workflow execution asynchronously without streaming',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resume(params);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\nexport const RESUME_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/resume',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Resume workflow',\n description: 'Resumes a suspended workflow execution from a specific step',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.resume(params);\n\n return { message: 'Workflow run resumed' };\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const RESTART_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Restart workflow asynchronously',\n description: 'Restarts an active workflow execution asynchronously',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.restart(params);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: restartBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart workflow',\n description: 'Restarts an active workflow execution',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to restart workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart(params);\n\n return { message: 'Workflow run restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart-all-active-workflow-runs-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs asynchronously',\n description: 'Restarts all active workflow runs asynchronously',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n await workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/restart-all-active-workflow-runs',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Restart all active workflow runs',\n description: 'Restarts all active workflow runs',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n void workflow.restartAllActiveWorkflowRuns();\n\n return { message: 'All active workflow runs restarted' };\n } catch (error) {\n return handleError(error, 'Error restarting workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/time-travel-async',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowExecutionResultSchema,\n summary: 'Time travel workflow asynchronously',\n description: 'Time travels a workflow run asynchronously without streaming',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.timeTravel(params);\n\n return result;\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/time-travel',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n responseSchema: workflowControlResponseSchema,\n summary: 'Time travel workflow',\n description: 'Time travels a workflow run, starting from a specific step',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.timeTravel(params);\n\n return { message: 'Workflow run time travel started' };\n } catch (error) {\n return handleError(error, 'Error time traveling workflow');\n }\n },\n});\n\nexport const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/time-travel-stream',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: timeTravelBodySchema,\n summary: 'Time travel workflow stream',\n description: 'Time travels a workflow run, starting from a specific step, and streams the results in real-time',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to time travel workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId });\n const result = run.timeTravelStream(params);\n return result.fullStream.pipeThrough(\n new TransformStream<ChunkType, ChunkType>({\n transform(chunk, controller) {\n if (serverCache) {\n const cacheKey = runId;\n serverCache.listPush(cacheKey, chunk).catch(() => {});\n }\n controller.enqueue(chunk);\n },\n }),\n );\n } catch (error) {\n return handleError(error, 'Error time traveling workflow stream');\n }\n },\n});\n\nexport const CANCEL_WORKFLOW_RUN_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/runs/:runId/cancel',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n responseSchema: workflowControlResponseSchema,\n summary: 'Cancel workflow run',\n description: 'Cancels an in-progress workflow execution',\n tags: ['Workflows'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to cancel workflow run' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n await _run.cancel();\n\n return { message: 'Workflow run cancelled' };\n } catch (error) {\n return handleError(error, 'Error canceling workflow run');\n }\n },\n});\n\n// Legacy routes (deprecated)\nexport const STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: streamWorkflowBodySchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Stream workflow with legacy format',\n description: 'Legacy endpoint for streaming workflow execution. Use /api/workflows/:workflowId/stream instead.',\n tags: ['Workflows', 'Legacy'],\n handler: async ({ mastra, workflowId, runId, ...params }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to resume workflow' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId });\n const result = run.streamLegacy({\n ...params,\n onChunk: async chunk => {\n if (serverCache) {\n const cacheKey = runId;\n await serverCache.listPush(cacheKey, chunk);\n }\n },\n });\n\n return result.stream;\n } catch (error) {\n return handleError(error, 'Error executing workflow');\n }\n },\n});\n\nexport const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/api/workflows/:workflowId/observe-stream-legacy',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n responseSchema: streamResponseSchema,\n summary: '[DEPRECATED] Observe workflow stream with legacy format',\n description: 'Legacy endpoint for observing workflow stream. Use /api/workflows/:workflowId/observe instead.',\n tags: ['Workflows', 'Legacy'],\n handler: async ({ mastra, workflowId, runId }) => {\n try {\n if (!workflowId) {\n throw new HTTPException(400, { message: 'Workflow ID is required' });\n }\n\n if (!runId) {\n throw new HTTPException(400, { message: 'runId required to observe workflow stream' });\n }\n\n const { workflow } = await listWorkflowsFromSystem({ mastra, workflowId });\n\n if (!workflow) {\n throw new HTTPException(404, { message: 'Workflow not found' });\n }\n\n const run = await workflow.getWorkflowRunById(runId);\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n if (!serverCache) {\n throw new HTTPException(500, { message: 'Server cache not found' });\n }\n\n const transformStream = new TransformStream<StreamEvent, StreamEvent>();\n\n const writer = transformStream.writable.getWriter();\n\n const cachedRunChunks = await serverCache.listFromTo(runId, 0);\n\n for (const chunk of cachedRunChunks) {\n await writer.write(chunk as any);\n }\n\n writer.releaseLock();\n\n const result = _run.observeStreamLegacy();\n return result.stream?.pipeThrough(transformStream);\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n","import z from 'zod';\nimport { createCombinedPaginationSchema, tracingOptionsSchema, messageResponseSchema } from './common';\n\nexport const workflowRunStatusSchema = z.enum([\n 'running',\n 'waiting',\n 'suspended',\n 'success',\n 'failed',\n 'canceled',\n 'pending',\n 'bailed',\n 'tripwire',\n 'paused',\n]);\n\n// Path parameter schemas\nexport const workflowIdPathParams = z.object({\n workflowId: z.string().describe('Unique identifier for the workflow'),\n});\n\nexport const workflowRunPathParams = workflowIdPathParams.extend({\n runId: z.string().describe('Unique identifier for the workflow run'),\n});\n\n/**\n * Schema for serialized step\n * Uses passthrough() to allow step-specific fields\n */\nconst serializedStepSchema = z.object({\n id: z.string(),\n description: z.string().optional(),\n});\n\n/**\n * Schema for serialized step flow entry\n * Represents different step flow types in the workflow graph\n */\nconst serializedStepFlowEntrySchema = z.object({\n type: z.enum(['step', 'sleep', 'sleepUntil', 'waitForEvent', 'parallel', 'conditional', 'loop', 'foreach']),\n});\n\n/**\n * Schema for workflow information\n * Returned by getWorkflowByIdHandler and listWorkflowsHandler\n */\nexport const workflowInfoSchema = z.object({\n steps: z.record(z.string(), serializedStepSchema),\n allSteps: z.record(z.string(), serializedStepSchema),\n name: z.string().optional(),\n description: z.string().optional(),\n stepGraph: z.array(serializedStepFlowEntrySchema),\n inputSchema: z.string().optional(),\n outputSchema: z.string().optional(),\n options: z.object({}).optional(),\n isProcessorWorkflow: z.boolean().optional(),\n});\n\n/**\n * Schema for list workflows endpoint response\n * Returns a record of workflow ID to workflow info\n */\nexport const listWorkflowsResponseSchema = z.record(z.string(), workflowInfoSchema);\n\n/**\n * Schema for workflow run object\n */\nconst workflowRunSchema = z.object({\n workflowName: z.string(),\n runId: z.string(),\n snapshot: z.union([z.object({}), z.string()]),\n createdAt: z.date(),\n updatedAt: z.date(),\n resourceId: z.string().optional(),\n});\n\n/**\n * Schema for workflow runs response (paginated)\n * Includes runs array and total count\n */\nexport const workflowRunsResponseSchema = z.object({\n runs: z.array(workflowRunSchema),\n total: z.number(),\n});\n\n/**\n * Schema for single workflow run response\n */\nexport const workflowRunResponseSchema = workflowRunSchema;\n\n/**\n * Schema for query parameters when listing workflow runs\n * Supports both page/perPage and limit/offset for backwards compatibility\n * If page/perPage provided, use directly; otherwise convert from limit/offset\n */\nexport const listWorkflowRunsQuerySchema = createCombinedPaginationSchema().extend({\n fromDate: z.coerce.date().optional(),\n toDate: z.coerce.date().optional(),\n resourceId: z.string().optional(),\n status: workflowRunStatusSchema.optional(),\n});\n\n/**\n * Base schema for workflow execution with input data and tracing\n */\nconst workflowExecutionBodySchema = z.object({\n resourceId: z.string().optional(),\n inputData: z.unknown().optional(),\n initialState: z.unknown().optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n perStep: z.boolean().optional(),\n});\n\n/**\n * Schema for legacy stream workflow body (no closeOnSuspend support)\n * Used by /stream-legacy endpoints\n */\nexport const streamLegacyWorkflowBodySchema = workflowExecutionBodySchema;\n\n/**\n * Schema for stream workflow body\n * Used by both /stream and /streamVNext endpoints\n */\nexport const streamWorkflowBodySchema = workflowExecutionBodySchema.extend({\n closeOnSuspend: z.boolean().optional(),\n});\n\n/**\n * Schema for resume workflow body\n * Used by resume-stream, resume-async and resume endpoints\n */\nexport const resumeBodySchema = z.object({\n step: z.union([z.string(), z.array(z.string())]).optional(), // Optional - workflow can auto-resume all suspended steps\n resumeData: z.unknown().optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n perStep: z.boolean().optional(),\n});\n\n/**\n * Schema for restart workflow body\n * Used by restart-async and restart endpoints\n */\nexport const restartBodySchema = z.object({\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n});\n\n/**\n * Schema for time travel workflow body\n * Used by time-travel-stream, time-travel-async and time-travel endpoints\n */\nexport const timeTravelBodySchema = z.object({\n inputData: z.unknown().optional(),\n resumeData: z.unknown().optional(),\n initialState: z.unknown().optional(),\n step: z.union([z.string(), z.array(z.string())]),\n context: z.record(z.string(), z.any()).optional(),\n nestedStepsContext: z.record(z.string(), z.record(z.string(), z.any())).optional(),\n requestContext: z.record(z.string(), z.unknown()).optional(),\n tracingOptions: tracingOptionsSchema.optional(),\n perStep: z.boolean().optional(),\n});\n\n/**\n * Schema for start async workflow body\n */\nexport const startAsyncWorkflowBodySchema = workflowExecutionBodySchema;\n\n/**\n * Schema for send workflow run event body\n */\nexport const sendWorkflowRunEventBodySchema = z.object({\n event: z.string(),\n data: z.unknown(),\n});\n\n/**\n * Schema for workflow execution result query parameters\n * Allows filtering which fields to return to reduce payload size\n */\nexport const workflowExecutionResultQuerySchema = z.object({\n fields: z\n .string()\n .optional()\n .refine(\n value => {\n if (!value) return true;\n const validFields = new Set([\n 'status',\n 'result',\n 'error',\n 'payload',\n 'steps',\n 'activeStepsPath',\n 'serializedStepGraph',\n ]);\n const requestedFields = value.split(',').map(f => f.trim());\n return requestedFields.every(field => validFields.has(field));\n },\n {\n message:\n 'Invalid field name. Available fields: status, result, error, payload, steps, activeStepsPath, serializedStepGraph',\n },\n )\n .describe(\n 'Comma-separated list of fields to return. Available fields: status, result, error, payload, steps, activeStepsPath, serializedStepGraph. If not provided, returns all fields.',\n ),\n withNestedWorkflows: z\n .enum(['true', 'false'])\n .optional()\n .describe(\n 'Whether to include nested workflow data in steps. Defaults to true. Set to false for better performance.',\n ),\n});\n\n/**\n * Schema for workflow execution result\n * All fields are optional since field filtering allows requesting specific fields only\n */\nexport const workflowExecutionResultSchema = z.object({\n status: workflowRunStatusSchema.optional(),\n result: z.unknown().optional(),\n error: z.unknown().optional(),\n payload: z.unknown().optional(),\n steps: z.record(z.string(), z.any()).optional(),\n activeStepsPath: z.record(z.string(), z.array(z.number())).optional(),\n serializedStepGraph: z.array(serializedStepFlowEntrySchema).optional(),\n});\n\n/**\n * Response schema for workflow control operations\n */\nexport const workflowControlResponseSchema = messageResponseSchema;\n\n/**\n * Response schema for create workflow run operation\n * Returns only the runId after creating a run\n */\nexport const createWorkflowRunResponseSchema = z.object({\n runId: z.string(),\n});\n\n/**\n * Schema for create workflow run body\n * Used by /create-run endpoint\n */\nexport const createWorkflowRunBodySchema = z.object({\n resourceId: z.string().optional(),\n disableScorers: z.boolean().optional(),\n});\n"]}
|
|
@@ -7,6 +7,7 @@ var chunkH2RMXG2Q_cjs = require('./chunk-H2RMXG2Q.cjs');
|
|
|
7
7
|
var chunkV5WWQN7P_cjs = require('./chunk-V5WWQN7P.cjs');
|
|
8
8
|
var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
|
|
9
9
|
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
|
|
10
|
+
var agent = require('@mastra/core/agent');
|
|
10
11
|
var error = require('@mastra/core/error');
|
|
11
12
|
var llm = require('@mastra/core/llm');
|
|
12
13
|
var zodToJson = require('@mastra/core/utils/zod-to-json');
|
|
@@ -39,6 +40,13 @@ chunkO7I5CWRX_cjs.__export(agents_exports, {
|
|
|
39
40
|
getSerializedAgentTools: () => getSerializedAgentTools,
|
|
40
41
|
getSerializedProcessors: () => getSerializedProcessors
|
|
41
42
|
});
|
|
43
|
+
function isProviderConnected(providerId) {
|
|
44
|
+
const cleanId = providerId.includes(".") ? providerId.split(".")[0] : providerId;
|
|
45
|
+
const provider = llm.PROVIDER_REGISTRY[cleanId];
|
|
46
|
+
if (!provider) return false;
|
|
47
|
+
const envVars = Array.isArray(provider.apiKeyEnvVar) ? provider.apiKeyEnvVar : [provider.apiKeyEnvVar];
|
|
48
|
+
return envVars.every((envVar) => !!process.env[envVar]);
|
|
49
|
+
}
|
|
42
50
|
async function getSerializedAgentTools(tools, partial = false) {
|
|
43
51
|
return Object.entries(tools || {}).reduce((acc, [key, tool]) => {
|
|
44
52
|
const toolId = tool.id ?? `tool-${key}`;
|
|
@@ -468,15 +476,13 @@ var GET_PROVIDERS_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
468
476
|
handler: async () => {
|
|
469
477
|
try {
|
|
470
478
|
const providers = Object.entries(llm.PROVIDER_REGISTRY).map(([id, provider]) => {
|
|
471
|
-
const envVars = Array.isArray(provider.apiKeyEnvVar) ? provider.apiKeyEnvVar : [provider.apiKeyEnvVar];
|
|
472
|
-
const connected = envVars.every((envVar) => !!process.env[envVar]);
|
|
473
479
|
return {
|
|
474
480
|
id,
|
|
475
481
|
name: provider.name,
|
|
476
482
|
label: provider.label || provider.name,
|
|
477
483
|
description: provider.description || "",
|
|
478
484
|
envVar: provider.apiKeyEnvVar,
|
|
479
|
-
connected,
|
|
485
|
+
connected: isProviderConnected(id),
|
|
480
486
|
docUrl: provider.docUrl,
|
|
481
487
|
models: [...provider.models]
|
|
482
488
|
// Convert readonly array to regular array
|
|
@@ -731,6 +737,75 @@ var UPDATE_AGENT_MODEL_IN_MODEL_LIST_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
731
737
|
}
|
|
732
738
|
}
|
|
733
739
|
});
|
|
740
|
+
var ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS = `You are an expert system prompt engineer, specialized in analyzing and enhancing instructions to create clear, effective, and comprehensive system prompts. Your goal is to help users transform their basic instructions into well-structured system prompts that will guide AI behavior effectively.
|
|
741
|
+
|
|
742
|
+
Follow these steps to analyze and enhance the instructions:
|
|
743
|
+
|
|
744
|
+
1. ANALYSIS PHASE
|
|
745
|
+
- Identify the core purpose and goals
|
|
746
|
+
- Extract key constraints and requirements
|
|
747
|
+
- Recognize domain-specific terminology and concepts
|
|
748
|
+
- Note any implicit assumptions that should be made explicit
|
|
749
|
+
|
|
750
|
+
2. PROMPT STRUCTURE
|
|
751
|
+
Create a system prompt with these components:
|
|
752
|
+
a) ROLE DEFINITION
|
|
753
|
+
- Clear statement of the AI's role and purpose
|
|
754
|
+
- Key responsibilities and scope
|
|
755
|
+
- Primary stakeholders and users
|
|
756
|
+
b) CORE CAPABILITIES
|
|
757
|
+
- Main functions and abilities
|
|
758
|
+
- Specific domain knowledge required
|
|
759
|
+
- Tools and resources available
|
|
760
|
+
c) BEHAVIORAL GUIDELINES
|
|
761
|
+
- Communication style and tone
|
|
762
|
+
- Decision-making framework
|
|
763
|
+
- Error handling approach
|
|
764
|
+
- Ethical considerations
|
|
765
|
+
d) CONSTRAINTS & BOUNDARIES
|
|
766
|
+
- Explicit limitations
|
|
767
|
+
- Out-of-scope activities
|
|
768
|
+
- Security and privacy considerations
|
|
769
|
+
e) SUCCESS CRITERIA
|
|
770
|
+
- Quality standards
|
|
771
|
+
- Expected outcomes
|
|
772
|
+
- Performance metrics
|
|
773
|
+
|
|
774
|
+
3. QUALITY CHECKS
|
|
775
|
+
Ensure the prompt is:
|
|
776
|
+
- Clear and unambiguous
|
|
777
|
+
- Comprehensive yet concise
|
|
778
|
+
- Properly scoped
|
|
779
|
+
- Technically accurate
|
|
780
|
+
- Ethically sound
|
|
781
|
+
|
|
782
|
+
4. OUTPUT FORMAT
|
|
783
|
+
Return a structured response with:
|
|
784
|
+
- Enhanced system prompt
|
|
785
|
+
- Analysis of key components
|
|
786
|
+
- Identified goals and constraints
|
|
787
|
+
- Core domain concepts
|
|
788
|
+
|
|
789
|
+
Remember: A good system prompt should be specific enough to guide behavior but flexible enough to handle edge cases. Focus on creating prompts that are clear, actionable, and aligned with the intended use case.`;
|
|
790
|
+
async function findConnectedModel(agent) {
|
|
791
|
+
const modelList = await agent.getModelList();
|
|
792
|
+
if (modelList && modelList.length > 0) {
|
|
793
|
+
for (const modelConfig of modelList) {
|
|
794
|
+
if (modelConfig.enabled !== false) {
|
|
795
|
+
const model = modelConfig.model;
|
|
796
|
+
if (isProviderConnected(model.provider)) {
|
|
797
|
+
return model;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
return null;
|
|
802
|
+
}
|
|
803
|
+
const defaultModel = await agent.getModel();
|
|
804
|
+
if (isProviderConnected(defaultModel.provider)) {
|
|
805
|
+
return defaultModel;
|
|
806
|
+
}
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
734
809
|
var ENHANCE_INSTRUCTIONS_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
735
810
|
method: "POST",
|
|
736
811
|
path: "/api/agents/:agentId/instructions/enhance",
|
|
@@ -743,32 +818,30 @@ var ENHANCE_INSTRUCTIONS_ROUTE = chunkH2RMXG2Q_cjs.createRoute({
|
|
|
743
818
|
tags: ["Agents"],
|
|
744
819
|
handler: async ({ mastra, agentId, instructions, comment }) => {
|
|
745
820
|
try {
|
|
746
|
-
const agent = await getAgentFromSystem({ mastra, agentId });
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
1. An improved version of the instructions that incorporates the user's feedback
|
|
759
|
-
2. A brief explanation of what changes you made and why
|
|
760
|
-
|
|
761
|
-
Important:
|
|
762
|
-
- Maintain the overall structure and intent of the original instructions
|
|
763
|
-
- Make targeted improvements based on the user's feedback
|
|
764
|
-
- Keep the instructions clear, concise, and actionable
|
|
765
|
-
- Preserve any specific formatting or sections that are important`;
|
|
766
|
-
const result = await agent.generate(enhancementPrompt, {
|
|
767
|
-
structuredOutput: {
|
|
768
|
-
schema: chunkBMYZ4DO6_cjs.enhanceInstructionsResponseSchema
|
|
769
|
-
}
|
|
821
|
+
const agent$1 = await getAgentFromSystem({ mastra, agentId });
|
|
822
|
+
const model = await findConnectedModel(agent$1);
|
|
823
|
+
if (!model) {
|
|
824
|
+
throw new chunk64ITUOXI_cjs.HTTPException(400, {
|
|
825
|
+
message: "No model with a configured API key found. Please set the required environment variable for your model provider."
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
const systemPromptAgent = new agent.Agent({
|
|
829
|
+
id: "system-prompt-enhancer",
|
|
830
|
+
name: "system-prompt-enhancer",
|
|
831
|
+
instructions: ENHANCE_SYSTEM_PROMPT_INSTRUCTIONS,
|
|
832
|
+
model
|
|
770
833
|
});
|
|
771
|
-
|
|
834
|
+
const result = await systemPromptAgent.generate(
|
|
835
|
+
`We need to improve the system prompt.
|
|
836
|
+
Current: ${instructions}
|
|
837
|
+
${comment ? `User feedback: ${comment}` : ""}`,
|
|
838
|
+
{
|
|
839
|
+
structuredOutput: {
|
|
840
|
+
schema: chunkBMYZ4DO6_cjs.enhanceInstructionsResponseSchema
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
);
|
|
844
|
+
return await result.object;
|
|
772
845
|
} catch (error) {
|
|
773
846
|
return chunkV5WWQN7P_cjs.handleError(error, "Error enhancing instructions");
|
|
774
847
|
}
|
|
@@ -851,5 +924,5 @@ exports.agents_exports = agents_exports;
|
|
|
851
924
|
exports.getAgentFromSystem = getAgentFromSystem;
|
|
852
925
|
exports.getSerializedAgentTools = getSerializedAgentTools;
|
|
853
926
|
exports.getSerializedProcessors = getSerializedProcessors;
|
|
854
|
-
//# sourceMappingURL=chunk-
|
|
855
|
-
//# sourceMappingURL=chunk-
|
|
927
|
+
//# sourceMappingURL=chunk-7KOS32XA.cjs.map
|
|
928
|
+
//# sourceMappingURL=chunk-7KOS32XA.cjs.map
|