@mastra/server 1.80.0-alpha.4 → 1.80.0-alpha.6
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/{a2a-BUOtgjP-.cjs → a2a-3ykajvdu.cjs} +2 -2
- package/dist/{a2a-BUOtgjP-.cjs.map → a2a-3ykajvdu.cjs.map} +1 -1
- package/dist/{a2a-B2K45wEY.js → a2a-D6ajBqAA.js} +2 -2
- package/dist/{a2a-B2K45wEY.js.map → a2a-D6ajBqAA.js.map} +1 -1
- package/dist/{agent-builder-BEhoRLS_.js → agent-builder-BDHi4NOZ.js} +4 -4
- package/dist/{agent-builder-BEhoRLS_.js.map → agent-builder-BDHi4NOZ.js.map} +1 -1
- package/dist/{agent-builder-CTHPsm8d.cjs → agent-builder-D3WRvBAH.cjs} +4 -4
- package/dist/{agent-builder-CTHPsm8d.cjs.map → agent-builder-D3WRvBAH.cjs.map} +1 -1
- package/dist/{agents-vFpMvK3w.cjs → agents-Bs1GFnXz.cjs} +5 -2
- package/dist/{agents-vFpMvK3w.cjs.map → agents-Bs1GFnXz.cjs.map} +1 -1
- package/dist/{agents-DSZgApzs.js → agents-CiUW6yvl.js} +105 -14
- package/dist/agents-CiUW6yvl.js.map +1 -0
- package/dist/{agents-A-ahR0eQ.js → agents-Cl3KTHU4.js} +5 -2
- package/dist/{agents-A-ahR0eQ.js.map → agents-Cl3KTHU4.js.map} +1 -1
- package/dist/{agents-I0TVb_TM.cjs → agents-DBsmIR4c.cjs} +105 -14
- package/dist/agents-DBsmIR4c.cjs.map +1 -0
- package/dist/{api-schema-manifest-j2xurBb0.js → api-schema-manifest-C6MbIQch.js} +2 -2
- package/dist/{api-schema-manifest-j2xurBb0.js.map → api-schema-manifest-C6MbIQch.js.map} +1 -1
- package/dist/{api-schema-manifest-DCuGBEO0.cjs → api-schema-manifest-COH6PAvQ.cjs} +2 -2
- package/dist/{api-schema-manifest-DCuGBEO0.cjs.map → api-schema-manifest-COH6PAvQ.cjs.map} +1 -1
- package/dist/{background-tasks-BMVUFtVh.cjs → background-tasks-BMp9Q6SB.cjs} +2 -2
- package/dist/{background-tasks-BMVUFtVh.cjs.map → background-tasks-BMp9Q6SB.cjs.map} +1 -1
- package/dist/{background-tasks-CFkXHgyQ.js → background-tasks-DIpPsqVy.js} +2 -2
- package/dist/{background-tasks-CFkXHgyQ.js.map → background-tasks-DIpPsqVy.js.map} +1 -1
- package/dist/{conversations-BfBS1UwQ.js → conversations-Ce0dCZ23.js} +3 -3
- package/dist/{conversations-BfBS1UwQ.js.map → conversations-Ce0dCZ23.js.map} +1 -1
- package/dist/{conversations-BSYZlASE.cjs → conversations-RVdtAQEv.cjs} +3 -3
- package/dist/{conversations-BSYZlASE.cjs.map → conversations-RVdtAQEv.cjs.map} +1 -1
- package/dist/dist-C-L2kyKZ.js +1 -0
- package/dist/{dist-Cci9RRWj.cjs → dist-Clj7hRKz.cjs} +47 -69
- package/dist/dist-Clj7hRKz.cjs.map +1 -0
- package/dist/{dist-DJ3281Ve.cjs → dist-D6oS7RF1.cjs} +1 -1
- package/dist/{dist-bAoX6ick.js → dist-PlsLrwz8.js} +48 -70
- package/dist/dist-PlsLrwz8.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{editor-builder-8li-nXor.cjs → editor-builder-9T1aGM2f.cjs} +2 -2
- package/dist/{editor-builder-8li-nXor.cjs.map → editor-builder-9T1aGM2f.cjs.map} +1 -1
- package/dist/{editor-builder-BXT6F3Hl.cjs → editor-builder-Bj_or9-c.cjs} +3 -3
- package/dist/{editor-builder-BXT6F3Hl.cjs.map → editor-builder-Bj_or9-c.cjs.map} +1 -1
- package/dist/{editor-builder-Bywazgj1.js → editor-builder-Cc0zrTC1.js} +3 -3
- package/dist/{editor-builder-Bywazgj1.js.map → editor-builder-Cc0zrTC1.js.map} +1 -1
- package/dist/{editor-builder-BCZy1ZH1.js → editor-builder-lzO2zecA.js} +2 -2
- package/dist/{editor-builder-BCZy1ZH1.js.map → editor-builder-lzO2zecA.js.map} +1 -1
- package/dist/{logs-Cbq2PiQG.js → logs-DIBh_xCk.js} +2 -2
- package/dist/{logs-Cbq2PiQG.js.map → logs-DIBh_xCk.js.map} +1 -1
- package/dist/{logs-BqHVVZBm.cjs → logs-NNur5jkf.cjs} +2 -2
- package/dist/{logs-BqHVVZBm.cjs.map → logs-NNur5jkf.cjs.map} +1 -1
- package/dist/{memory-CtSwODLV.js → memory-DeZ1je-b.js} +5 -6
- package/dist/memory-DeZ1je-b.js.map +1 -0
- package/dist/{memory-dujCippo.cjs → memory-Pj9P9vsl.cjs} +5 -6
- package/dist/memory-Pj9P9vsl.cjs.map +1 -0
- package/dist/{plans-CSLB_JKn.cjs → plans-Cu3zbWP_.cjs} +4 -4
- package/dist/{plans-CSLB_JKn.cjs.map → plans-Cu3zbWP_.cjs.map} +1 -1
- package/dist/{plans-DToC_H5z.js → plans-DVErlJoO.js} +4 -4
- package/dist/{plans-DToC_H5z.js.map → plans-DVErlJoO.js.map} +1 -1
- package/dist/{probe-image-size-CTKFNI9H.cjs → probe-image-size-C0psF6WM.cjs} +2 -2
- package/dist/{probe-image-size-CTKFNI9H.cjs.map → probe-image-size-C0psF6WM.cjs.map} +1 -1
- package/dist/{probe-image-size-DnRk0ecb.js → probe-image-size-CpV7slsd.js} +2 -2
- package/dist/{probe-image-size-DnRk0ecb.js.map → probe-image-size-CpV7slsd.js.map} +1 -1
- package/dist/{responses-w6B0iv_t.js → responses-DOqM_drh.js} +3 -3
- package/dist/{responses-w6B0iv_t.js.map → responses-DOqM_drh.js.map} +1 -1
- package/dist/{responses-OoIIZ1g6.cjs → responses-DniqbL1B.cjs} +3 -3
- package/dist/{responses-OoIIZ1g6.cjs.map → responses-DniqbL1B.cjs.map} +1 -1
- package/dist/{routes-KTxoRutQ.cjs → routes-B_-KRQOi.cjs} +16 -16
- package/dist/{routes-KTxoRutQ.cjs.map → routes-B_-KRQOi.cjs.map} +1 -1
- package/dist/{routes-CIjXlRu7.js → routes-BfQBQbwB.js} +16 -16
- package/dist/{routes-CIjXlRu7.js.map → routes-BfQBQbwB.js.map} +1 -1
- package/dist/{schedules-CSkQFQwy.cjs → schedules-CL4IU7kS.cjs} +2 -2
- package/dist/{schedules-CSkQFQwy.cjs.map → schedules-CL4IU7kS.cjs.map} +1 -1
- package/dist/{schedules-DfelziYe.js → schedules-CQPodXrR.js} +2 -2
- package/dist/{schedules-DfelziYe.js.map → schedules-CQPodXrR.js.map} +1 -1
- package/dist/{scores-FzL-bpCC.cjs → scores-BAZL_l3k.cjs} +2 -2
- package/dist/{scores-FzL-bpCC.cjs.map → scores-BAZL_l3k.cjs.map} +1 -1
- package/dist/{scores-PdRDQNaC.js → scores-BXrRHFvI.js} +2 -2
- package/dist/{scores-PdRDQNaC.js.map → scores-BXrRHFvI.js.map} +1 -1
- package/dist/server/handlers/a2a.cjs +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-controller.cjs +14 -11
- package/dist/server/handlers/agent-controller.cjs.map +1 -1
- package/dist/server/handlers/agent-controller.d.ts +2 -0
- package/dist/server/handlers/agent-controller.d.ts.map +1 -1
- package/dist/server/handlers/agent-controller.js +14 -11
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/agents.cjs +1 -1
- package/dist/server/handlers/agents.d.ts +2 -0
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/background-tasks.cjs +1 -1
- package/dist/server/handlers/background-tasks.js +1 -1
- package/dist/server/handlers/conversations.cjs +1 -1
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/editor-builder.cjs +1 -1
- package/dist/server/handlers/editor-builder.js +1 -1
- package/dist/server/handlers/error.cjs +1 -0
- package/dist/server/handlers/error.cjs.map +1 -1
- package/dist/server/handlers/error.d.ts.map +1 -1
- package/dist/server/handlers/error.js +1 -0
- package/dist/server/handlers/error.js.map +1 -1
- package/dist/server/handlers/favorites-enrichment.cjs +1 -1
- package/dist/server/handlers/favorites-enrichment.js +1 -1
- package/dist/server/handlers/logs.cjs +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/memory.cjs +1 -1
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +2 -10
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/responses.storage.cjs +1 -1
- package/dist/server/handlers/responses.storage.js +1 -1
- package/dist/server/handlers/schedules.cjs +1 -1
- package/dist/server/handlers/schedules.js +1 -1
- package/dist/server/handlers/scores.cjs +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
- package/dist/server/handlers/stored-agent-favorites.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +1 -1
- package/dist/server/handlers/stored-agents.js +1 -1
- package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
- package/dist/server/handlers/stored-skill-favorites.js +1 -1
- package/dist/server/handlers/stored-skills.cjs +1 -1
- package/dist/server/handlers/stored-skills.js +1 -1
- package/dist/server/handlers/system.cjs +1 -1
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -1
- package/dist/server/handlers/utils.d.ts +17 -2
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/workflow-builder.cjs +1 -1
- package/dist/server/handlers/workflow-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +1 -1
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers/workspace.d.ts +23 -23
- package/dist/server/handlers.cjs +11 -11
- package/dist/server/handlers.js +11 -11
- package/dist/server/schemas/agents.d.ts +1 -0
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +2 -2
- package/dist/server/schemas/index.js +2 -2
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +1 -5
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/server/utils/agent-stream-events.d.ts +23 -0
- package/dist/server/utils/agent-stream-events.d.ts.map +1 -0
- package/dist/{tools-tMPXGAUO.js → tools-Do1uV_07.js} +5 -5
- package/dist/tools-Do1uV_07.js.map +1 -0
- package/dist/{tools-CottqeCZ.cjs → tools-HYYytfMx.cjs} +5 -5
- package/dist/tools-HYYytfMx.cjs.map +1 -0
- package/dist/{utils-1UlUJRyC.cjs → utils-BbYUI6Yn.cjs} +32 -7
- package/dist/utils-BbYUI6Yn.cjs.map +1 -0
- package/dist/{utils-DEwjGOpJ.js → utils-DHxjw4Tn.js} +27 -8
- package/dist/utils-DHxjw4Tn.js.map +1 -0
- package/dist/{workflow-builder-CJEajbkw.cjs → workflow-builder-DJKziSOo.cjs} +4 -4
- package/dist/{workflow-builder-CJEajbkw.cjs.map → workflow-builder-DJKziSOo.cjs.map} +1 -1
- package/dist/{workflow-builder-BcVfkods.js → workflow-builder-ezo8ZG1K.js} +4 -4
- package/dist/{workflow-builder-BcVfkods.js.map → workflow-builder-ezo8ZG1K.js.map} +1 -1
- package/dist/{workflows-CxPsDCnW.cjs → workflows-BWLDlaL9.cjs} +28 -28
- package/dist/workflows-BWLDlaL9.cjs.map +1 -0
- package/dist/{workflows-BjLruwQB.js → workflows-Dm2iK1nq.js} +28 -28
- package/dist/workflows-Dm2iK1nq.js.map +1 -0
- package/package.json +6 -6
- package/dist/agents-DSZgApzs.js.map +0 -1
- package/dist/agents-I0TVb_TM.cjs.map +0 -1
- package/dist/dist-Cci9RRWj.cjs.map +0 -1
- package/dist/dist-bAoX6ick.js.map +0 -1
- package/dist/dist-t_05BTrR.js +0 -1
- package/dist/memory-CtSwODLV.js.map +0 -1
- package/dist/memory-dujCippo.cjs.map +0 -1
- package/dist/tools-CottqeCZ.cjs.map +0 -1
- package/dist/tools-tMPXGAUO.js.map +0 -1
- package/dist/utils-1UlUJRyC.cjs.map +0 -1
- package/dist/utils-DEwjGOpJ.js.map +0 -1
- package/dist/workflows-BjLruwQB.js.map +0 -1
- package/dist/workflows-CxPsDCnW.cjs.map +0 -1
|
@@ -2,11 +2,11 @@ const require_rolldown_runtime = require("./rolldown-runtime-10nMEhjP.cjs");
|
|
|
2
2
|
const require_http_exception = require("./http-exception-Co3MbFUf.cjs");
|
|
3
3
|
const require_common = require("./common-DVZqSEhZ.cjs");
|
|
4
4
|
const require_workflows = require("./workflows-SYBpQupF.cjs");
|
|
5
|
-
const require_agents = require("./agents-
|
|
5
|
+
const require_agents = require("./agents-Bs1GFnXz.cjs");
|
|
6
6
|
const require_route_builder = require("./route-builder-CvARmqnA.cjs");
|
|
7
7
|
const require_utils = require("./utils-BnH77wPf.cjs");
|
|
8
8
|
const require_server_handlers_error = require("./server/handlers/error.cjs");
|
|
9
|
-
const require_utils$1 = require("./utils-
|
|
9
|
+
const require_utils$1 = require("./utils-BbYUI6Yn.cjs");
|
|
10
10
|
let zod_v4 = require("zod/v4");
|
|
11
11
|
let _mastra_core_stream = require("@mastra/core/stream");
|
|
12
12
|
// src/server/handlers/workflows.ts
|
|
@@ -129,7 +129,7 @@ const LIST_WORKFLOWS_ROUTE = require_route_builder.createRoute({
|
|
|
129
129
|
acc[key] = require_utils.getWorkflowInfo(workflow, isPartial);
|
|
130
130
|
return acc;
|
|
131
131
|
}, {});
|
|
132
|
-
const fgaProvider =
|
|
132
|
+
const fgaProvider = require_utils$1.getHandlerFGAProvider(mastra, requestContext);
|
|
133
133
|
const user = requestContext?.get("user");
|
|
134
134
|
if (fgaProvider) {
|
|
135
135
|
if (!user) return {};
|
|
@@ -165,7 +165,7 @@ const LIST_WORKFLOW_RUN_COUNTS_ROUTE = require_route_builder.createRoute({
|
|
|
165
165
|
requiresAuth: true,
|
|
166
166
|
handler: (async ({ mastra, requestContext }) => {
|
|
167
167
|
try {
|
|
168
|
-
const fgaProvider =
|
|
168
|
+
const fgaProvider = require_utils$1.getHandlerFGAProvider(mastra, requestContext);
|
|
169
169
|
const user = requestContext?.get("user");
|
|
170
170
|
if (fgaProvider && !user) return {};
|
|
171
171
|
const workflows = mastra.listWorkflows({ serialized: false });
|
|
@@ -338,7 +338,7 @@ const GET_WORKFLOW_RUN_BY_ID_ROUTE = require_route_builder.createRoute({
|
|
|
338
338
|
fields: fieldList
|
|
339
339
|
});
|
|
340
340
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
341
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
341
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
342
342
|
return run;
|
|
343
343
|
} catch (error) {
|
|
344
344
|
return require_server_handlers_error.handleError(error, "Error getting workflow run");
|
|
@@ -367,7 +367,7 @@ const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = require_route_builder.createRoute({
|
|
|
367
367
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
368
368
|
const run = await workflow.getWorkflowRunById(runId);
|
|
369
369
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
370
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
370
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
371
371
|
await workflow.deleteWorkflowRunById(runId);
|
|
372
372
|
return { message: "Workflow run deleted" };
|
|
373
373
|
} catch (error) {
|
|
@@ -399,7 +399,7 @@ const CREATE_WORKFLOW_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
399
399
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
400
400
|
if (runId) {
|
|
401
401
|
const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
|
|
402
|
-
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
402
|
+
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra, requestContext);
|
|
403
403
|
}
|
|
404
404
|
return { runId: (await workflow.createRun({
|
|
405
405
|
runId,
|
|
@@ -433,7 +433,7 @@ const STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
433
433
|
});
|
|
434
434
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
435
435
|
const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
|
|
436
|
-
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
436
|
+
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra, requestContext);
|
|
437
437
|
if (existingRun && TERMINAL_RUN_STATUSES.includes(existingRun.status)) throw new require_http_exception.HTTPException(409, { message: `Workflow run ${runId} already finished with status "${existingRun.status}". Use /observe to read its stream back, or stream a new runId.` });
|
|
438
438
|
const serverCache = mastra.getServerCache();
|
|
439
439
|
const result = (await workflow.createRun({
|
|
@@ -478,7 +478,7 @@ const RESUME_STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
478
478
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
479
479
|
const run = await workflow.getWorkflowRunById(runId);
|
|
480
480
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
481
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
481
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
482
482
|
const _run = await workflow.createRun({
|
|
483
483
|
runId,
|
|
484
484
|
resourceId: run.resourceId
|
|
@@ -522,7 +522,7 @@ const START_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
522
522
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
523
523
|
if (runId) {
|
|
524
524
|
const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
|
|
525
|
-
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
525
|
+
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra, requestContext);
|
|
526
526
|
}
|
|
527
527
|
return await (await workflow.createRun({
|
|
528
528
|
runId,
|
|
@@ -560,7 +560,7 @@ const START_WORKFLOW_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
560
560
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
561
561
|
const run = await workflow.getWorkflowRunById(runId);
|
|
562
562
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
563
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
563
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
564
564
|
(await workflow.createRun({
|
|
565
565
|
runId,
|
|
566
566
|
resourceId: run.resourceId
|
|
@@ -603,7 +603,7 @@ const OBSERVE_STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
603
603
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
604
604
|
const run = await workflow.getWorkflowRunById(runId);
|
|
605
605
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
606
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
606
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
607
607
|
const _run = await workflow.createRun({
|
|
608
608
|
runId,
|
|
609
609
|
resourceId: run.resourceId
|
|
@@ -646,7 +646,7 @@ const RESUME_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
646
646
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
647
647
|
const run = await workflow.getWorkflowRunById(runId);
|
|
648
648
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
649
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
649
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
650
650
|
return await (await workflow.createRun({
|
|
651
651
|
runId,
|
|
652
652
|
resourceId: run.resourceId
|
|
@@ -693,7 +693,7 @@ const RESUME_NO_WAIT_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
693
693
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
694
694
|
const run = await workflow.getWorkflowRunById(runId);
|
|
695
695
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
696
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
696
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
697
697
|
return await (await workflow.createRun({
|
|
698
698
|
runId,
|
|
699
699
|
resourceId: run.resourceId
|
|
@@ -730,7 +730,7 @@ const RESUME_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
730
730
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
731
731
|
const run = await workflow.getWorkflowRunById(runId);
|
|
732
732
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
733
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
733
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
734
734
|
(await workflow.createRun({
|
|
735
735
|
runId,
|
|
736
736
|
resourceId: run.resourceId
|
|
@@ -774,7 +774,7 @@ const RESTART_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
774
774
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
775
775
|
const run = await workflow.getWorkflowRunById(runId);
|
|
776
776
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
777
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
777
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
778
778
|
return await (await workflow.createRun({
|
|
779
779
|
runId,
|
|
780
780
|
resourceId: run.resourceId
|
|
@@ -811,7 +811,7 @@ const RESTART_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
811
811
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
812
812
|
const run = await workflow.getWorkflowRunById(runId);
|
|
813
813
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
814
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
814
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
815
815
|
(await workflow.createRun({
|
|
816
816
|
runId,
|
|
817
817
|
resourceId: run.resourceId
|
|
@@ -843,7 +843,7 @@ const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = require_route_builder.creat
|
|
|
843
843
|
requiresAuth: true,
|
|
844
844
|
handler: async ({ mastra, workflowId, requestContext }) => {
|
|
845
845
|
try {
|
|
846
|
-
await require_utils$1.validateRunOwnership({ resourceId: null }, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
846
|
+
await require_utils$1.validateRunOwnership({ resourceId: null }, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra, requestContext);
|
|
847
847
|
if (!workflowId) throw new require_http_exception.HTTPException(400, { message: "Workflow ID is required" });
|
|
848
848
|
const { workflow } = await listWorkflowsFromSystem({
|
|
849
849
|
mastra,
|
|
@@ -869,7 +869,7 @@ const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = require_route_builder.createRoute
|
|
|
869
869
|
requiresAuth: true,
|
|
870
870
|
handler: async ({ mastra, workflowId, requestContext }) => {
|
|
871
871
|
try {
|
|
872
|
-
await require_utils$1.validateRunOwnership({ resourceId: null }, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
872
|
+
await require_utils$1.validateRunOwnership({ resourceId: null }, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra, requestContext);
|
|
873
873
|
if (!workflowId) throw new require_http_exception.HTTPException(400, { message: "Workflow ID is required" });
|
|
874
874
|
const { workflow } = await listWorkflowsFromSystem({
|
|
875
875
|
mastra,
|
|
@@ -912,7 +912,7 @@ const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
912
912
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
913
913
|
const run = await workflow.getWorkflowRunById(runId);
|
|
914
914
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
915
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
915
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
916
916
|
return await (await workflow.createRun({
|
|
917
917
|
runId,
|
|
918
918
|
resourceId: run.resourceId
|
|
@@ -949,7 +949,7 @@ const TIME_TRAVEL_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
949
949
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
950
950
|
const run = await workflow.getWorkflowRunById(runId);
|
|
951
951
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
952
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
952
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
953
953
|
(await workflow.createRun({
|
|
954
954
|
runId,
|
|
955
955
|
resourceId: run.resourceId
|
|
@@ -992,7 +992,7 @@ const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
992
992
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
993
993
|
const existingRun = await workflow.getWorkflowRunById(runId);
|
|
994
994
|
if (!existingRun) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
995
|
-
await require_utils$1.validateRunOwnership(existingRun, effectiveResourceId, mastra);
|
|
995
|
+
await require_utils$1.validateRunOwnership(existingRun, effectiveResourceId, mastra, requestContext);
|
|
996
996
|
const serverCache = mastra.getServerCache();
|
|
997
997
|
const result = (await workflow.createRun({
|
|
998
998
|
runId,
|
|
@@ -1034,7 +1034,7 @@ const CANCEL_WORKFLOW_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
1034
1034
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
1035
1035
|
const run = await workflow.getWorkflowRunById(runId);
|
|
1036
1036
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
1037
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
1037
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
1038
1038
|
await (await workflow.createRun({
|
|
1039
1039
|
runId,
|
|
1040
1040
|
resourceId: run.resourceId
|
|
@@ -1070,7 +1070,7 @@ const STREAM_LEGACY_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
1070
1070
|
const serverCache = mastra.getServerCache();
|
|
1071
1071
|
if (runId) {
|
|
1072
1072
|
const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
|
|
1073
|
-
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
1073
|
+
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra, requestContext);
|
|
1074
1074
|
}
|
|
1075
1075
|
return (await workflow.createRun({
|
|
1076
1076
|
runId,
|
|
@@ -1113,7 +1113,7 @@ const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
1113
1113
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
1114
1114
|
const run = await workflow.getWorkflowRunById(runId);
|
|
1115
1115
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
1116
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
1116
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra, requestContext);
|
|
1117
1117
|
const _run = await workflow.createRun({
|
|
1118
1118
|
runId,
|
|
1119
1119
|
resourceId: run.resourceId
|
|
@@ -1183,7 +1183,7 @@ const EXECUTE_WORKFLOW_STEP_ROUTE = require_route_builder.createRoute({
|
|
|
1183
1183
|
runId,
|
|
1184
1184
|
workflowName: workflowId
|
|
1185
1185
|
});
|
|
1186
|
-
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(serverRequestContext, void 0), mastra);
|
|
1186
|
+
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(serverRequestContext, void 0), mastra, serverRequestContext);
|
|
1187
1187
|
return await (await getStepStrategy(mastra)).executeStep({
|
|
1188
1188
|
workflowId,
|
|
1189
1189
|
runId,
|
|
@@ -1254,7 +1254,7 @@ const RECEIVE_WORKFLOW_EVENT_ROUTE = require_route_builder.createRoute({
|
|
|
1254
1254
|
runId: event.runId,
|
|
1255
1255
|
...typeof workflowName === "string" ? { workflowName } : {}
|
|
1256
1256
|
});
|
|
1257
|
-
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
1257
|
+
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra, requestContext);
|
|
1258
1258
|
const rawCreatedAt = event.createdAt;
|
|
1259
1259
|
const createdAt = rawCreatedAt instanceof Date ? rawCreatedAt : new Date(rawCreatedAt);
|
|
1260
1260
|
if (Number.isNaN(createdAt.getTime())) throw new require_http_exception.HTTPException(400, { message: "Invalid createdAt" });
|
|
@@ -1442,4 +1442,4 @@ Object.defineProperty(exports, "workflows_exports", {
|
|
|
1442
1442
|
}
|
|
1443
1443
|
});
|
|
1444
1444
|
|
|
1445
|
-
//# sourceMappingURL=workflows-
|
|
1445
|
+
//# sourceMappingURL=workflows-BWLDlaL9.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflows-BWLDlaL9.cjs","names":["HTTPException","WorkflowRegistry","getPublicWorkflowById","createRoute","z","listWorkflowsResponseSchema","getWorkflowInfo","getHandlerFGAProvider","MastraFGAPermissions","handleError","workflowRunCountsResponseSchema","getEffectiveResourceId","workflowIdPathParams","workflowInfoSchema","listWorkflowRunsQuerySchema","workflowRunsResponseSchema","workflowRunPathParams","workflowRunResultQuerySchema","workflowRunResultSchema","validateRunOwnership","workflowControlResponseSchema","optionalRunIdSchema","createWorkflowRunBodySchema","createWorkflowRunResponseSchema","runIdSchema","streamWorkflowBodySchema","resumeBodySchema","streamResponseSchema","startAsyncWorkflowBodySchema","workflowExecutionResultSchema","observeWorkflowQuerySchema","createReplayStream","restartBodySchema","timeTravelBodySchema"],"sources":["../src/server/handlers/workflows.ts"],"sourcesContent":["import type { Mastra } from '@mastra/core';\nimport type { MastraServerCache } from '@mastra/core/cache';\nimport type { RequestContext } from '@mastra/core/di';\nimport type { Event } from '@mastra/core/events';\nimport { createReplayStream } from '@mastra/core/stream';\nimport type {\n WorkflowInfo,\n ChunkType,\n StreamEvent,\n WorkflowStateField,\n WorkflowRunStatus,\n WorkflowRunState,\n} from '@mastra/core/workflows';\nimport { z } from 'zod/v4';\nimport { MastraFGAPermissions } from '../fga-permissions';\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 workflowRunCountsResponseSchema,\n restartBodySchema,\n timeTravelBodySchema,\n resumeBodySchema,\n startAsyncWorkflowBodySchema,\n streamWorkflowBodySchema,\n workflowControlResponseSchema,\n workflowExecutionResultSchema,\n workflowIdPathParams,\n workflowInfoSchema,\n workflowRunPathParams,\n workflowRunsResponseSchema,\n workflowRunResultQuerySchema,\n workflowRunResultSchema,\n observeWorkflowQuerySchema,\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';\nimport { getEffectiveResourceId, getHandlerFGAProvider, getPublicWorkflowById, validateRunOwnership } from './utils';\n\n/**\n * Statuses a run cannot come back from. Streaming one of these runIds again would\n * start a fresh execution under the same runId and overwrite its stored snapshot —\n * the in-memory de-dupe that protects concurrent streams only covers runs still held\n * in the workflow's run map, and a finished run has already been dropped from it.\n */\nconst TERMINAL_RUN_STATUSES: WorkflowRunStatus[] = ['success', 'failed', 'canceled', 'tripwire'];\n\n/**\n * Runs whose chunks are already being written to the cache in this process,\n * keyed by runId. A run has exactly one writer: without this, two concurrent\n * requests for the same runId each cache every chunk and the replayed history\n * comes back duplicated.\n */\nconst activeRunStreamCachers = new Set<string>();\n\n/**\n * Cache a run's chunks for later replay and return the stream to hand the client.\n *\n * The cached history belongs to the run, not to whoever happens to be watching,\n * so the caching side is driven by its own reader rather than by the client's\n * consumption. If the client disconnects mid-run its branch is cancelled while\n * this reader keeps draining, so `/observe` still replays a complete history —\n * the failure that makes reconnection necessary is exactly the one the cache has\n * to survive. Chunks buffer in the tee while a client lags, bounded by the run's\n * own length.\n */\nfunction cacheRunStream({\n cache,\n runId,\n source,\n}: {\n cache: MastraServerCache;\n runId: string;\n source: ReadableStream<ChunkType>;\n}): ReadableStream<ChunkType> {\n if (activeRunStreamCachers.has(runId)) {\n return source;\n }\n\n const [toCache, toClient] = source.tee();\n activeRunStreamCachers.add(runId);\n\n void (async () => {\n const reader = toCache.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n // Cache failures must not take down the run being streamed.\n await cache.listPush(runId, value).catch(() => {});\n }\n } catch {\n // The source errored; the client's branch surfaces it.\n } finally {\n reader.releaseLock();\n activeRunStreamCachers.delete(runId);\n }\n })();\n\n return toClient;\n}\n\nexport interface WorkflowContext extends Context {\n workflowId?: string;\n runId?: string;\n requestContext?: RequestContext;\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 workflow = getPublicWorkflowById(mastra, workflowId);\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 } 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: '/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 requiresAuth: true,\n handler: (async ({ mastra, partial, requestContext }: any) => {\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 as any, isPartial);\n return acc;\n }, {});\n\n // Filter workflows by FGA if configured\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n if (fgaProvider) {\n if (!user) {\n return {};\n }\n const workflowList = Object.entries(_workflows).map(([id, w]) => ({ id, ...w }));\n const accessible = await fgaProvider.filterAccessible(\n user,\n workflowList,\n 'workflow',\n MastraFGAPermissions.WORKFLOWS_READ,\n );\n const accessibleSet = new Set(accessible.map((w: any) => w.id));\n for (const id of Object.keys(_workflows)) {\n if (!accessibleSet.has(id)) {\n delete _workflows[id];\n }\n }\n }\n\n return _workflows;\n } catch (error) {\n return handleError(error, 'Error getting workflows');\n }\n }) as any,\n});\n\ntype WorkflowRunCounts = { running: number; suspended: number };\n\nconst RUN_COUNTS_CACHE_TTL_MS = 5_000;\n// Keyed by Mastra instance so multiple apps in one process never share counts.\nconst runCountsCache = new WeakMap<object, { at: number; value: Record<string, WorkflowRunCounts> }>();\nlet runCountsNow: () => number = () => Date.now();\n\n/** Test seam — lets TTL expiry be tested without wall-clock waits. */\nexport function __setWorkflowRunCountsNow(now?: () => number) {\n runCountsNow = now ?? (() => Date.now());\n}\n\nexport const LIST_WORKFLOW_RUN_COUNTS_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/run-counts',\n responseType: 'json',\n responseSchema: workflowRunCountsResponseSchema,\n summary: 'List workflow run counts',\n description:\n 'Returns per-workflow counts of currently running and suspended (awaiting resume) runs, keyed by the workflow registry key used in the Mastra config',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: (async ({ mastra, requestContext }: any) => {\n try {\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n // FGA with no user can never see anything — answer before touching storage.\n if (fgaProvider && !user) {\n return {};\n }\n\n const workflows = mastra.listWorkflows({ serialized: false });\n\n const counts: Record<string, WorkflowRunCounts> = {};\n const workflowIdToRegistryKey = new Map<string, string>();\n for (const [registryKey, workflow] of Object.entries(workflows)) {\n counts[registryKey] = { running: 0, suspended: 0 };\n workflowIdToRegistryKey.set((workflow as any).id, registryKey);\n }\n\n // Runs are scoped to the caller like the runs-listing endpoint: the\n // reserved request-context resource id takes precedence for security.\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\n // The shared cache holds the unscoped, unfiltered map — usable only when\n // neither per-user FGA filtering nor a resource scope applies.\n const cacheable = !fgaProvider && !effectiveResourceId;\n if (cacheable) {\n const cached = runCountsCache.get(mastra);\n if (cached && runCountsNow() - cached.at < RUN_COUNTS_CACHE_TTL_MS) {\n return cached.value;\n }\n }\n\n const storage = mastra.getStorage();\n const workflowsStore = storage ? await storage.getStore('workflows') : undefined;\n if (workflowsStore) {\n // Cross-workflow, engine-agnostic: both execution engines persist run\n // status into the same store. Deliberately not listActiveWorkflowRuns,\n // which means running+waiting and covers the default engine only.\n const [running, suspended] = await Promise.all([\n workflowsStore.listWorkflowRuns({ status: 'running', resourceId: effectiveResourceId }),\n workflowsStore.listWorkflowRuns({ status: 'suspended', resourceId: effectiveResourceId }),\n ]);\n for (const run of running.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.running++;\n }\n for (const run of suspended.runs) {\n const registryKey = workflowIdToRegistryKey.get(run.workflowName);\n const entry = registryKey ? counts[registryKey] : undefined;\n if (entry) entry.suspended++;\n }\n }\n\n if (fgaProvider) {\n const workflowList = Object.keys(counts).map(id => ({ id }));\n const accessible = await fgaProvider.filterAccessible(\n user,\n workflowList,\n 'workflow',\n MastraFGAPermissions.WORKFLOWS_READ,\n );\n const accessibleSet = new Set(accessible.map((w: any) => w.id));\n for (const id of Object.keys(counts)) {\n if (!accessibleSet.has(id)) {\n delete counts[id];\n }\n }\n return counts;\n }\n\n if (cacheable) {\n runCountsCache.set(mastra, { at: runCountsNow(), value: counts });\n }\n return counts;\n } catch (error) {\n return handleError(error, 'Error getting workflow run counts');\n }\n }) as any,\n});\n\nexport const GET_WORKFLOW_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/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 requiresAuth: true,\n handler: (async ({ mastra, workflowId }: any) => {\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, false);\n } catch (error) {\n return handleError(error, 'Error getting workflow');\n }\n }) as any,\n});\n\nexport const LIST_WORKFLOW_RUNS_ROUTE = createRoute({\n method: 'GET',\n path: '/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 requiresAuth: true,\n handler: async ({\n mastra,\n workflowId,\n fromDate,\n toDate,\n page,\n perPage,\n limit,\n offset,\n resourceId,\n status,\n summary,\n requestContext,\n }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\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: effectiveResourceId,\n status,\n ...(summary ? { summary: true } : {}),\n })) || {\n runs: [],\n total: 0,\n };\n if (summary) {\n // Adapters may ignore `summary`, so always trim here to keep the response small.\n return {\n ...workflowRuns,\n runs: workflowRuns.runs.map(run => ({ ...run, snapshot: toSummarySnapshot(run.snapshot) })),\n };\n }\n return workflowRuns;\n } catch (error) {\n return handleError(error, 'Error getting workflow runs');\n }\n },\n});\n\nfunction toSummarySnapshot(\n snapshot: WorkflowRunState | string,\n): Pick<WorkflowRunState, 'status' | 'timestamp'> | string {\n let parsed: unknown;\n if (typeof snapshot === 'string') {\n try {\n parsed = JSON.parse(snapshot);\n } catch {\n // Never echo an unparseable (possibly huge) snapshot back in summary mode.\n return '';\n }\n } else {\n parsed = snapshot;\n }\n if (!parsed || typeof parsed !== 'object') return '';\n const { status, timestamp } = parsed as WorkflowRunState;\n return { status, timestamp };\n}\n\nexport const GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({\n method: 'GET',\n path: '/workflows/:workflowId/runs/:runId',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n queryParamSchema: workflowRunResultQuerySchema,\n responseSchema: workflowRunResultSchema,\n summary: 'Get workflow run by ID',\n description:\n 'Returns a workflow run with metadata and processed execution state. Use the fields query parameter to reduce payload size by requesting only specific fields (e.g., ?fields=result,steps). Available fields: result, error, payload, steps, activeStepsPath, serializedStepGraph. Metadata fields (runId, workflowName, resourceId, createdAt, updatedAt) and status are always included.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, fields, withNestedWorkflows, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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()) as WorkflowStateField[]) : undefined;\n\n const run = await workflow.getWorkflowRunById(runId, {\n withNestedWorkflows: withNestedWorkflows !== 'false', // Default to true unless explicitly 'false'\n fields: fieldList,\n });\n\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 // Validate ownership before deletion\n const run = await workflow.getWorkflowRunById(runId);\n if (!run) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\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: '/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 requiresAuth: true,\n // Creating a run is part of the execute flow (Studio/UI calls this before\n // starting/streaming a workflow), so allow either permission. `write` is kept\n // for back-compat with roles that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: async ({ mastra, workflowId, runId, resourceId, disableScorers, requestContext }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\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 if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId, 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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\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\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n\n if (existingRun && TERMINAL_RUN_STATUSES.includes(existingRun.status)) {\n throw new HTTPException(409, {\n message:\n `Workflow run ${runId} already finished with status \"${existingRun.status}\". ` +\n `Use /observe to read its stream back, or stream a new runId.`,\n });\n }\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.stream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\n }\n\n return result.fullStream;\n } catch (error) {\n return handleError(error, 'Error streaming workflow');\n }\n },\n});\n\nexport const RESUME_STREAM_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const serverCache = mastra.getServerCache();\n\n const resumeResult = _run.resumeStream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: resumeResult.fullStream });\n }\n\n return resumeResult.fullStream;\n } catch (error) {\n return handleError(error, 'Error resuming workflow');\n }\n },\n});\n\nexport const START_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n // Use effective resourceId (context key takes precedence over client-provided value)\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\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 if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const _run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = await _run.start({ ...params, requestContext });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n // Fire-and-forget: attach .catch so a rejected start (e.g. invalid input\n // schema) cannot become an unhandledRejection and tear down the process.\n void _run\n .start({\n ...params,\n requestContext,\n })\n .catch(error => {\n mastra.getLogger().error('Failed to start workflow run', { error, workflowId, runId });\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: '/workflows/:workflowId/observe',\n responseType: 'stream',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: observeWorkflowQuerySchema,\n responseSchema: streamResponseSchema,\n summary: 'Observe workflow stream',\n description:\n 'Observes and streams updates from an already running workflow execution. Supports position-based resume with offset for efficient reconnection.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, offset, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\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 from the specified index (or 0 if not specified)\n const startIndex = offset ?? 0;\n const cachedRunChunks = (await serverCache.listFromTo(runId, startIndex)) as ChunkType[];\n const liveStream = _run.observeStream();\n\n return createReplayStream<ChunkType>({\n history: cachedRunChunks,\n liveSource: liveStream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\nexport const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resume({ ...params, requestContext });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error resuming workflow step');\n }\n },\n});\n\n/**\n * Fire-and-forget resume: dispatches the resume and returns immediately with the runId,\n * without waiting for the workflow to complete. For Inngest-backed workflows this avoids\n * the `getRunOutput()` polling race that the awaiting `resume-async` route can hit.\n *\n * TODO(v2): in Mastra v2 this fire-and-forget behavior should become the behavior of the\n * `resume-async` route (and `Run.resumeAsync()`), and this route should be removed. It is\n * kept separate in v1 to avoid a breaking change to the existing `resume-async` response\n * contract (which returns the full workflow result).\n */\nexport const RESUME_NO_WAIT_WORKFLOW_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/resume-no-wait',\n responseType: 'json',\n pathParamSchema: workflowIdPathParams,\n queryParamSchema: runIdSchema,\n bodySchema: resumeBodySchema,\n responseSchema: createWorkflowRunResponseSchema,\n summary: 'Resume workflow without waiting',\n description:\n 'Resumes a suspended workflow execution without waiting (fire-and-forget) and returns immediately with the runId. The workflow continues executing in the background.',\n tags: ['Workflows'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.resumeAsync({ ...params, requestContext });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n // Fire-and-forget: attach .catch so a rejected resume cannot become an\n // unhandledRejection and tear down the process.\n void _run.resume({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to resume workflow run', { error, workflowId, runId });\n });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.restart({ ...params, requestContext });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n void _run.restart({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to restart workflow run in background', { error, workflowId, runId });\n });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, requestContext }) => {\n try {\n // Restarting every active run spans all owners, so only a privileged caller may do it:\n // checked as access to a run with no owner.\n await validateRunOwnership(\n { resourceId: null },\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, requestContext }) => {\n try {\n // Restarting every active run spans all owners, so only a privileged caller may do it:\n // checked as access to a run with no owner.\n await validateRunOwnership(\n { resourceId: null },\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\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().catch(error => {\n mastra.getLogger().error('Failed to restart active workflow runs', { error, workflowId });\n });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n const result = await _run.timeTravel({ ...params, requestContext });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\n\n const _run = await workflow.createRun({ runId, resourceId: run.resourceId });\n\n // Fire-and-forget: attach .catch so a rejected time travel cannot become\n // an unhandledRejection and tear down the process.\n void _run.timeTravel({ ...params, requestContext }).catch(error => {\n mastra.getLogger().error('Failed to time travel workflow run', { error, workflowId, runId });\n });\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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\n // Validate ownership of existing run before time traveling\n const existingRun = await workflow.getWorkflowRunById(runId);\n if (!existingRun) {\n throw new HTTPException(404, { message: 'Workflow run not found' });\n }\n await validateRunOwnership(existingRun, effectiveResourceId, mastra, requestContext);\n\n const serverCache = mastra.getServerCache();\n\n const run = await workflow.createRun({ runId, resourceId: existingRun.resourceId });\n const result = run.timeTravelStream({ ...params, requestContext });\n\n if (serverCache) {\n return cacheRunStream({ cache: serverCache, runId, source: result.fullStream });\n }\n\n return result.fullStream;\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: '/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 requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\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: '/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 /workflows/:workflowId/stream instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, resourceId, requestContext, ...params }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, resourceId);\n\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 if (runId) {\n const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n }\n const run = await workflow.createRun({ runId, resourceId: effectiveResourceId });\n const result = run.streamLegacy({\n ...params,\n requestContext,\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: '/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 /workflows/:workflowId/observe instead.',\n tags: ['Workflows', 'Legacy'],\n requiresAuth: true,\n handler: async ({ mastra, workflowId, runId, requestContext }) => {\n try {\n const effectiveResourceId = getEffectiveResourceId(requestContext, undefined);\n\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 await validateRunOwnership(run, effectiveResourceId, mastra, requestContext);\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 and create replay stream\n const cachedRunChunks = (await serverCache.listFromTo(runId, 0)) as StreamEvent[];\n const result = _run.observeStreamLegacy();\n\n if (!result.stream) {\n throw new HTTPException(500, { message: 'Failed to create observe stream' });\n }\n\n return createReplayStream<StreamEvent>({\n history: cachedRunChunks,\n liveSource: result.stream,\n });\n } catch (error) {\n return handleError(error, 'Error observing workflow stream');\n }\n },\n});\n\n// ============================================================================\n// Worker Step Execution Endpoint\n// Used by standalone OrchestrationWorker instances with HttpRemoteStrategy.\n// ============================================================================\n\n// Identifies the workflow a nested step runs under, up to the top-level run.\n// Nested workflows are usually reachable only from their parent's step graph.\nexport type StepExecutionParentWorkflow = {\n workflowId: string;\n runId: string;\n executionPath: number[];\n parentWorkflow?: StepExecutionParentWorkflow;\n};\n\nconst stepExecutionParentWorkflowSchema: z.ZodType<StepExecutionParentWorkflow> = z.lazy(() =>\n z.object({\n workflowId: z.string(),\n runId: z.string(),\n executionPath: z.array(z.number().int().nonnegative()),\n parentWorkflow: stepExecutionParentWorkflowSchema.optional(),\n }),\n);\n\n// `workflowId` and `runId` are taken from path params (single source of\n// truth); they are intentionally omitted from the request body schema.\nconst stepExecutionBodySchema = z.object({\n stepId: z.string(),\n executionPath: z.array(z.number().int().nonnegative()),\n parentWorkflow: stepExecutionParentWorkflowSchema.optional(),\n stepResults: z.record(z.string(), z.unknown()),\n state: z.record(z.string(), z.unknown()),\n requestContext: z.record(z.string(), z.unknown()),\n input: z.unknown().optional(),\n resumeData: z.unknown().optional(),\n retryCount: z.number().int().nonnegative().optional(),\n foreachIdx: z.number().int().nonnegative().optional(),\n format: z.enum(['legacy', 'vnext']).optional(),\n perStep: z.boolean().optional(),\n validateInputs: z.boolean().optional(),\n});\n\ntype StepExecutionBody = z.infer<typeof stepExecutionBodySchema>;\n\ninterface StepExecutionHandlerArgs extends StepExecutionBody {\n mastra: Mastra;\n workflowId: string;\n runId: string;\n}\n\n// Reuse the InProcessStrategy across requests for a given Mastra instance.\n// The strategy is stateless beyond its mastra reference, but allocating it\n// per request triggers a dynamic import on the hot path.\n//\n// The dynamic import is required by `pnpm --filter ./packages/server\n// check:core-imports`: `@mastra/core/worker` is a new subpath that older\n// peer-dep floors don't expose, so a static import would fail the check.\n// Once the floor is bumped, this can become a static import.\ntype StepStrategy = { executeStep: (p: unknown) => Promise<unknown> };\nconst strategyByMastra = new WeakMap<Mastra, StepStrategy>();\n\nasync function getStepStrategy(mastra: Mastra): Promise<StepStrategy> {\n let cached = strategyByMastra.get(mastra);\n if (!cached) {\n const { InProcessStrategy } = await import('@mastra/core/worker');\n cached = new InProcessStrategy({ mastra }) as unknown as StepStrategy;\n strategyByMastra.set(mastra, cached);\n }\n return cached;\n}\n\n// Step execution returns the worker's StepResult. Its shape is dynamic\n// and depends on the step's output schema.\nconst stepExecutionResponseSchema = z.unknown();\n\nexport const EXECUTE_WORKFLOW_STEP_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/:workflowId/runs/:runId/steps/execute',\n responseType: 'json',\n pathParamSchema: workflowRunPathParams,\n bodySchema: stepExecutionBodySchema,\n responseSchema: stepExecutionResponseSchema,\n summary: 'Execute a workflow step',\n description:\n 'Internal endpoint used by standalone OrchestrationWorker instances to execute workflow steps remotely via HttpRemoteStrategy.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n handler: (async ({ mastra, workflowId, runId, ...body }: StepExecutionHandlerArgs) => {\n try {\n // The adapter replaces the body's requestContext with the server-built context.\n const candidate = body.requestContext as unknown as RequestContext | undefined;\n const serverRequestContext = typeof candidate?.get === 'function' ? candidate : undefined;\n const workflowsStore = await mastra.getStorage()?.getStore('workflows');\n const existingRun = await workflowsStore?.getWorkflowRunById({ runId, workflowName: workflowId });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(serverRequestContext, undefined),\n mastra,\n serverRequestContext,\n );\n // Auth is enforced by the framework via `requiresAuth: true` and the\n // deployer's `authenticateToken` provider. Note that when NO auth\n // provider is configured, the framework currently treats the route\n // as public (see ServerAdapter.checkRouteAuth). Operators deploying\n // standalone workers must configure an auth provider to gate this\n // endpoint — there is no implicit fail-closed.\n const strategy = await getStepStrategy(mastra);\n const result = await strategy.executeStep({\n workflowId,\n runId,\n stepId: body.stepId,\n executionPath: body.executionPath,\n parentWorkflow: body.parentWorkflow,\n stepResults: body.stepResults,\n state: body.state,\n requestContext: body.requestContext,\n input: body.input,\n resumeData: body.resumeData,\n retryCount: body.retryCount,\n foreachIdx: body.foreachIdx,\n format: body.format,\n perStep: body.perStep,\n validateInputs: body.validateInputs,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error executing workflow step');\n }\n }) as any,\n});\n\n// Wire shape of an Event delivered through a push-mode broker. Validates the\n// fields `WorkflowEventProcessor` depends on; broker envelopes routinely carry\n// extra metadata that isn't part of `Event` itself, so we passthrough the rest.\n// `createdAt` is an ISO timestamp on the wire — the handler converts it to a\n// `Date` before forwarding to `Mastra.handleWorkflowEvent`.\nconst workflowEventSchema = z.object({\n id: z.string(),\n type: z.string(),\n data: z.unknown(),\n runId: z.string(),\n createdAt: z.string(),\n index: z.number().optional(),\n deliveryAttempt: z.number().optional(),\n});\n\nconst receiveWorkflowEventBodySchema = z.object({\n event: workflowEventSchema.passthrough(),\n});\n\nconst receiveWorkflowEventResponseSchema = z.object({\n ok: z.boolean(),\n retry: z.boolean().optional(),\n});\n\ninterface ReceiveWorkflowEventHandlerArgs {\n mastra: Mastra;\n event: Event;\n requestContext?: RequestContext;\n}\n\n/**\n * Generic push receive endpoint for workflow events. A push-mode broker\n * (GCP Pub/Sub push subscription, SNS, EventBridge) — or a per-broker adapter\n * that decodes the broker's envelope first — POSTs each event here and the\n * response code tells the broker whether to retry:\n *\n * - 200/204 → ack\n * - 5xx → transient, retry with backoff\n * - 4xx → poison, drop / send to DLQ\n *\n * Auth is enforced through the framework's standard `requiresAuth` flow.\n * Operators MUST configure an `authenticateToken` provider that recognizes\n * whatever credential the broker attaches (e.g. a Google-signed OIDC token\n * for GCP Pub/Sub push). Without an auth provider the endpoint is effectively\n * public — same caveat as `EXECUTE_WORKFLOW_STEP_ROUTE`.\n */\nexport const RECEIVE_WORKFLOW_EVENT_ROUTE = createRoute({\n method: 'POST',\n path: '/workflows/events',\n responseType: 'json',\n bodySchema: receiveWorkflowEventBodySchema,\n responseSchema: receiveWorkflowEventResponseSchema,\n summary: 'Receive a workflow event from a push-mode broker',\n description:\n 'Push-mode entry point for workflow events. Brokers (GCP Pub/Sub push, SNS, EventBridge) POST each event here; Mastra processes it through the same pipeline as pull-mode workers.',\n tags: ['Workflows', 'Worker'],\n requiresAuth: true,\n // Broker push endpoint: it advances runtime state rather than editing\n // definitions, so `workflows:execute` is the more accurate fit. `write` is\n // kept for back-compat with service principals that already grant it.\n requiresPermission: ['workflows:write', 'workflows:execute'],\n handler: (async ({ mastra, event, requestContext }: ReceiveWorkflowEventHandlerArgs) => {\n try {\n const workflowName = (event.data as { workflowId?: unknown } | undefined)?.workflowId;\n const workflowsStore = await mastra.getStorage()?.getStore('workflows');\n const existingRun = await workflowsStore?.getWorkflowRunById({\n runId: event.runId,\n ...(typeof workflowName === 'string' ? { workflowName } : {}),\n });\n await validateRunOwnership(\n existingRun,\n getEffectiveResourceId(requestContext, undefined),\n mastra,\n requestContext,\n );\n // The wire schema carries `createdAt` as a string; coerce to Date here\n // before handing off to the in-process pipeline, which expects an `Event`.\n const rawCreatedAt = (event as unknown as { createdAt: unknown }).createdAt;\n const createdAt = rawCreatedAt instanceof Date ? rawCreatedAt : new Date(rawCreatedAt as string);\n if (Number.isNaN(createdAt.getTime())) {\n throw new HTTPException(400, { message: 'Invalid createdAt' });\n }\n return await mastra.handleWorkflowEvent({ ...event, createdAt });\n } catch (error) {\n return handleError(error, 'Error receiving workflow event');\n }\n }) as any,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,wBAA6C;CAAC;CAAW;CAAU;CAAY;AAAU;;;;;;;AAQ/F,MAAM,yCAAyB,IAAI,IAAY;;;;;;;;;;;;AAa/C,SAAS,eAAe,EACtB,OACA,OACA,UAK4B;CAC5B,IAAI,uBAAuB,IAAI,KAAK,GAClC,OAAO;CAGT,MAAM,CAAC,SAAS,YAAY,OAAO,IAAI;CACvC,uBAAuB,IAAI,KAAK;CAEhC,CAAM,YAAY;EAChB,MAAM,SAAS,QAAQ,UAAU;EACjC,IAAI;GACF,OAAO,MAAM;IACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,KAAK;IAC1C,IAAI,MAAM;IA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