@mastra/server 1.78.0-alpha.5 → 1.78.0-alpha.7
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/{agents-CKSEPpk1.cjs → agents-D9vpLghy.cjs} +8 -1
- package/dist/{agents-CKSEPpk1.cjs.map → agents-D9vpLghy.cjs.map} +1 -1
- package/dist/{agents-CW_JJZOf.js → agents-DNWDET4U.js} +3 -2
- package/dist/{agents-CW_JJZOf.js.map → agents-DNWDET4U.js.map} +1 -1
- package/dist/{api-schema-manifest-7Mkcahcz.cjs → api-schema-manifest-CmnpeFqd.cjs} +2 -2
- package/dist/{api-schema-manifest-7Mkcahcz.cjs.map → api-schema-manifest-CmnpeFqd.cjs.map} +1 -1
- package/dist/{api-schema-manifest-BSc3N7kx.js → api-schema-manifest-D8dn-tBo.js} +2 -2
- package/dist/{api-schema-manifest-BSc3N7kx.js.map → api-schema-manifest-D8dn-tBo.js.map} +1 -1
- package/dist/{background-tasks-Cu89GYC6.cjs → background-tasks-CP6TSFhc.cjs} +2 -2
- package/dist/{background-tasks-Cu89GYC6.cjs.map → background-tasks-CP6TSFhc.cjs.map} +1 -1
- package/dist/{background-tasks-_e2S8LLH.js → background-tasks-Clbud7G4.js} +2 -2
- package/dist/{background-tasks-_e2S8LLH.js.map → background-tasks-Clbud7G4.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-server-routes.md +3 -0
- package/dist/{editor-builder-CmUsqdZq.cjs → editor-builder-BOmAPurW.cjs} +2 -2
- package/dist/{editor-builder-CmUsqdZq.cjs.map → editor-builder-BOmAPurW.cjs.map} +1 -1
- package/dist/{editor-builder-DHXbVwxu.js → editor-builder-CeLVu_FT.js} +2 -2
- package/dist/{editor-builder-DHXbVwxu.js.map → editor-builder-CeLVu_FT.js.map} +1 -1
- package/dist/{editor-builder-CYkaYf6-.js → editor-builder-DHqCWGd2.js} +2 -2
- package/dist/{editor-builder-CYkaYf6-.js.map → editor-builder-DHqCWGd2.js.map} +1 -1
- package/dist/{editor-builder-BtcTQbAC.cjs → editor-builder-DqHKoEDx.cjs} +2 -2
- package/dist/{editor-builder-BtcTQbAC.cjs.map → editor-builder-DqHKoEDx.cjs.map} +1 -1
- package/dist/{routes-BOpfBZw5.cjs → routes-BwzE4nnm.cjs} +6 -5
- package/dist/routes-BwzE4nnm.cjs.map +1 -0
- package/dist/{routes-CccVLchZ.js → routes-DlbTsFpA.js} +7 -6
- package/dist/routes-DlbTsFpA.js.map +1 -0
- package/dist/{schedules-6XpznRPz.js → schedules-BRdVmFYi.js} +2 -2
- package/dist/{schedules-6XpznRPz.js.map → schedules-BRdVmFYi.js.map} +1 -1
- package/dist/{schedules-BiqVrJH7.cjs → schedules-DvLXX2nW.cjs} +2 -2
- package/dist/{schedules-BiqVrJH7.cjs.map → schedules-DvLXX2nW.cjs.map} +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 +1 -1
- package/dist/server/handlers/agent-controller.js +1 -1
- package/dist/server/handlers/agents.cjs +39 -10
- package/dist/server/handlers/agents.cjs.map +1 -1
- package/dist/server/handlers/agents.d.ts +2113 -0
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +39 -11
- package/dist/server/handlers/agents.js.map +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/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.js +1 -1
- package/dist/server/handlers/plans.cjs +2 -2
- package/dist/server/handlers/plans.js +2 -2
- 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/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 +2 -2
- package/dist/server/handlers/tools.js +2 -2
- package/dist/server/handlers/utils.cjs +1 -1
- package/dist/server/handlers/utils.d.ts +14 -3
- 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 +37 -20
- package/dist/server/handlers/workflows.cjs.map +1 -1
- package/dist/server/handlers/workflows.d.ts.map +1 -1
- package/dist/server/handlers/workflows.js +37 -20
- package/dist/server/handlers/workflows.js.map +1 -1
- package/dist/server/schemas/agents.d.ts +199 -0
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +3 -2
- package/dist/server/schemas/index.js +3 -3
- package/dist/server/server-adapter/index.cjs +1 -1
- package/dist/server/server-adapter/index.js +1 -1
- package/dist/server/server-adapter/routes/agents.d.ts +2 -1
- package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
- package/dist/{utils-BF2Kbju4.cjs → utils-DdGLbkOl.cjs} +21 -5
- package/dist/{utils-BF2Kbju4.cjs.map → utils-DdGLbkOl.cjs.map} +1 -1
- package/dist/{utils-GVYTDbr2.js → utils-mIFmRM_j.js} +21 -5
- package/dist/{utils-GVYTDbr2.js.map → utils-mIFmRM_j.js.map} +1 -1
- package/dist/{workflow-builder-UVflLOfv.cjs → workflow-builder-BM6Nen0q.cjs} +4 -4
- package/dist/{workflow-builder-UVflLOfv.cjs.map → workflow-builder-BM6Nen0q.cjs.map} +1 -1
- package/dist/{workflow-builder-U2jFH8o7.js → workflow-builder-BnKKH8iT.js} +4 -4
- package/dist/{workflow-builder-U2jFH8o7.js.map → workflow-builder-BnKKH8iT.js.map} +1 -1
- package/package.json +6 -6
- package/dist/routes-BOpfBZw5.cjs.map +0 -1
- package/dist/routes-CccVLchZ.js.map +0 -1
|
@@ -2,11 +2,11 @@ import { r as __exportAll } from "../../rolldown-runtime-maW3aOIk.js";
|
|
|
2
2
|
import { t as HTTPException } from "../../http-exception-CyfxZB6W.js";
|
|
3
3
|
import { o as optionalRunIdSchema, u as runIdSchema } from "../../common-Y30XtCyr.js";
|
|
4
4
|
import { _ as workflowRunCountsResponseSchema, a as observeWorkflowQuerySchema, b as workflowRunResultSchema, d as streamWorkflowBodySchema, f as timeTravelBodySchema, g as workflowInfoSchema, h as workflowIdPathParams, i as listWorkflowsResponseSchema, l as startAsyncWorkflowBodySchema, m as workflowExecutionResultSchema, n as createWorkflowRunResponseSchema, o as restartBodySchema, p as workflowControlResponseSchema, r as listWorkflowRunsQuerySchema, s as resumeBodySchema, t as createWorkflowRunBodySchema, v as workflowRunPathParams, x as workflowRunsResponseSchema, y as workflowRunResultQuerySchema } from "../../workflows-Dcx4Ib0t.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Y as streamResponseSchema } from "../../agents-DNWDET4U.js";
|
|
6
6
|
import { n as createRoute } from "../../route-builder-lBil8Cvo.js";
|
|
7
7
|
import { a as getWorkflowInfo, t as WorkflowRegistry } from "../../utils-BpQY-tBr.js";
|
|
8
8
|
import { handleError } from "./error.js";
|
|
9
|
-
import { a as getPublicWorkflowById, h as MastraFGAPermissions, p as validateRunOwnership, r as getEffectiveResourceId } from "../../utils-
|
|
9
|
+
import { a as getPublicWorkflowById, h as MastraFGAPermissions, p as validateRunOwnership, r as getEffectiveResourceId } from "../../utils-mIFmRM_j.js";
|
|
10
10
|
import { z } from "zod/v4";
|
|
11
11
|
import { createReplayStream } from "@mastra/core/stream";
|
|
12
12
|
//#region src/server/handlers/workflows.ts
|
|
@@ -338,7 +338,7 @@ const GET_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({
|
|
|
338
338
|
fields: fieldList
|
|
339
339
|
});
|
|
340
340
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
341
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
341
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
342
342
|
return run;
|
|
343
343
|
} catch (error) {
|
|
344
344
|
return handleError(error, "Error getting workflow run");
|
|
@@ -367,7 +367,7 @@ const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = createRoute({
|
|
|
367
367
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
368
368
|
const run = await workflow.getWorkflowRunById(runId);
|
|
369
369
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
370
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
370
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
371
371
|
await workflow.deleteWorkflowRunById(runId);
|
|
372
372
|
return { message: "Workflow run deleted" };
|
|
373
373
|
} catch (error) {
|
|
@@ -397,6 +397,7 @@ const CREATE_WORKFLOW_RUN_ROUTE = createRoute({
|
|
|
397
397
|
workflowId
|
|
398
398
|
});
|
|
399
399
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
400
|
+
if (runId) await validateRunOwnership(await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false }), getEffectiveResourceId(requestContext, void 0), mastra);
|
|
400
401
|
return { runId: (await workflow.createRun({
|
|
401
402
|
runId,
|
|
402
403
|
resourceId: effectiveResourceId,
|
|
@@ -429,6 +430,7 @@ const STREAM_WORKFLOW_ROUTE = createRoute({
|
|
|
429
430
|
});
|
|
430
431
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
431
432
|
const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
|
|
433
|
+
await validateRunOwnership(existingRun, getEffectiveResourceId(requestContext, void 0), mastra);
|
|
432
434
|
if (existingRun && TERMINAL_RUN_STATUSES.includes(existingRun.status)) throw new HTTPException(409, { message: `Workflow run ${runId} already finished with status "${existingRun.status}". Use /observe to read its stream back, or stream a new runId.` });
|
|
433
435
|
const serverCache = mastra.getServerCache();
|
|
434
436
|
const result = (await workflow.createRun({
|
|
@@ -473,7 +475,7 @@ const RESUME_STREAM_WORKFLOW_ROUTE = createRoute({
|
|
|
473
475
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
474
476
|
const run = await workflow.getWorkflowRunById(runId);
|
|
475
477
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
476
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
478
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
477
479
|
const _run = await workflow.createRun({
|
|
478
480
|
runId,
|
|
479
481
|
resourceId: run.resourceId
|
|
@@ -515,6 +517,7 @@ const START_ASYNC_WORKFLOW_ROUTE = createRoute({
|
|
|
515
517
|
workflowId
|
|
516
518
|
});
|
|
517
519
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
520
|
+
if (runId) await validateRunOwnership(await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false }), getEffectiveResourceId(requestContext, void 0), mastra);
|
|
518
521
|
return await (await workflow.createRun({
|
|
519
522
|
runId,
|
|
520
523
|
resourceId: effectiveResourceId
|
|
@@ -551,7 +554,7 @@ const START_WORKFLOW_RUN_ROUTE = createRoute({
|
|
|
551
554
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
552
555
|
const run = await workflow.getWorkflowRunById(runId);
|
|
553
556
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
554
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
557
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
555
558
|
(await workflow.createRun({
|
|
556
559
|
runId,
|
|
557
560
|
resourceId: run.resourceId
|
|
@@ -594,7 +597,7 @@ const OBSERVE_STREAM_WORKFLOW_ROUTE = createRoute({
|
|
|
594
597
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
595
598
|
const run = await workflow.getWorkflowRunById(runId);
|
|
596
599
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
597
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
600
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
598
601
|
const _run = await workflow.createRun({
|
|
599
602
|
runId,
|
|
600
603
|
resourceId: run.resourceId
|
|
@@ -635,7 +638,7 @@ const RESUME_ASYNC_WORKFLOW_ROUTE = createRoute({
|
|
|
635
638
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
636
639
|
const run = await workflow.getWorkflowRunById(runId);
|
|
637
640
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
638
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
641
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
639
642
|
return await (await workflow.createRun({
|
|
640
643
|
runId,
|
|
641
644
|
resourceId: run.resourceId
|
|
@@ -682,7 +685,7 @@ const RESUME_NO_WAIT_WORKFLOW_ROUTE = createRoute({
|
|
|
682
685
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
683
686
|
const run = await workflow.getWorkflowRunById(runId);
|
|
684
687
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
685
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
688
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
686
689
|
return await (await workflow.createRun({
|
|
687
690
|
runId,
|
|
688
691
|
resourceId: run.resourceId
|
|
@@ -719,7 +722,7 @@ const RESUME_WORKFLOW_ROUTE = createRoute({
|
|
|
719
722
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
720
723
|
const run = await workflow.getWorkflowRunById(runId);
|
|
721
724
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
722
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
725
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
723
726
|
(await workflow.createRun({
|
|
724
727
|
runId,
|
|
725
728
|
resourceId: run.resourceId
|
|
@@ -763,7 +766,7 @@ const RESTART_ASYNC_WORKFLOW_ROUTE = createRoute({
|
|
|
763
766
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
764
767
|
const run = await workflow.getWorkflowRunById(runId);
|
|
765
768
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
766
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
769
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
767
770
|
return await (await workflow.createRun({
|
|
768
771
|
runId,
|
|
769
772
|
resourceId: run.resourceId
|
|
@@ -800,7 +803,7 @@ const RESTART_WORKFLOW_ROUTE = createRoute({
|
|
|
800
803
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
801
804
|
const run = await workflow.getWorkflowRunById(runId);
|
|
802
805
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
803
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
806
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
804
807
|
(await workflow.createRun({
|
|
805
808
|
runId,
|
|
806
809
|
resourceId: run.resourceId
|
|
@@ -830,8 +833,9 @@ const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = createRoute({
|
|
|
830
833
|
description: "Restarts all active workflow runs asynchronously",
|
|
831
834
|
tags: ["Workflows"],
|
|
832
835
|
requiresAuth: true,
|
|
833
|
-
handler: async ({ mastra, workflowId }) => {
|
|
836
|
+
handler: async ({ mastra, workflowId, requestContext }) => {
|
|
834
837
|
try {
|
|
838
|
+
await validateRunOwnership({ resourceId: null }, getEffectiveResourceId(requestContext, void 0), mastra);
|
|
835
839
|
if (!workflowId) throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
836
840
|
const { workflow } = await listWorkflowsFromSystem({
|
|
837
841
|
mastra,
|
|
@@ -855,8 +859,9 @@ const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = createRoute({
|
|
|
855
859
|
description: "Restarts all active workflow runs",
|
|
856
860
|
tags: ["Workflows"],
|
|
857
861
|
requiresAuth: true,
|
|
858
|
-
handler: async ({ mastra, workflowId }) => {
|
|
862
|
+
handler: async ({ mastra, workflowId, requestContext }) => {
|
|
859
863
|
try {
|
|
864
|
+
await validateRunOwnership({ resourceId: null }, getEffectiveResourceId(requestContext, void 0), mastra);
|
|
860
865
|
if (!workflowId) throw new HTTPException(400, { message: "Workflow ID is required" });
|
|
861
866
|
const { workflow } = await listWorkflowsFromSystem({
|
|
862
867
|
mastra,
|
|
@@ -899,7 +904,7 @@ const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = createRoute({
|
|
|
899
904
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
900
905
|
const run = await workflow.getWorkflowRunById(runId);
|
|
901
906
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
902
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
907
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
903
908
|
return await (await workflow.createRun({
|
|
904
909
|
runId,
|
|
905
910
|
resourceId: run.resourceId
|
|
@@ -936,7 +941,7 @@ const TIME_TRAVEL_WORKFLOW_ROUTE = createRoute({
|
|
|
936
941
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
937
942
|
const run = await workflow.getWorkflowRunById(runId);
|
|
938
943
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
939
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
944
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
940
945
|
(await workflow.createRun({
|
|
941
946
|
runId,
|
|
942
947
|
resourceId: run.resourceId
|
|
@@ -979,7 +984,7 @@ const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = createRoute({
|
|
|
979
984
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
980
985
|
const existingRun = await workflow.getWorkflowRunById(runId);
|
|
981
986
|
if (!existingRun) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
982
|
-
await validateRunOwnership(existingRun, effectiveResourceId);
|
|
987
|
+
await validateRunOwnership(existingRun, effectiveResourceId, mastra);
|
|
983
988
|
const serverCache = mastra.getServerCache();
|
|
984
989
|
const result = (await workflow.createRun({
|
|
985
990
|
runId,
|
|
@@ -1021,7 +1026,7 @@ const CANCEL_WORKFLOW_RUN_ROUTE = createRoute({
|
|
|
1021
1026
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
1022
1027
|
const run = await workflow.getWorkflowRunById(runId);
|
|
1023
1028
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
1024
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
1029
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
1025
1030
|
await (await workflow.createRun({
|
|
1026
1031
|
runId,
|
|
1027
1032
|
resourceId: run.resourceId
|
|
@@ -1055,6 +1060,7 @@ const STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({
|
|
|
1055
1060
|
});
|
|
1056
1061
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
1057
1062
|
const serverCache = mastra.getServerCache();
|
|
1063
|
+
if (runId) await validateRunOwnership(await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false }), getEffectiveResourceId(requestContext, void 0), mastra);
|
|
1058
1064
|
return (await workflow.createRun({
|
|
1059
1065
|
runId,
|
|
1060
1066
|
resourceId: effectiveResourceId
|
|
@@ -1096,7 +1102,7 @@ const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = createRoute({
|
|
|
1096
1102
|
if (!workflow) throw new HTTPException(404, { message: "Workflow not found" });
|
|
1097
1103
|
const run = await workflow.getWorkflowRunById(runId);
|
|
1098
1104
|
if (!run) throw new HTTPException(404, { message: "Workflow run not found" });
|
|
1099
|
-
await validateRunOwnership(run, effectiveResourceId);
|
|
1105
|
+
await validateRunOwnership(run, effectiveResourceId, mastra);
|
|
1100
1106
|
const _run = await workflow.createRun({
|
|
1101
1107
|
runId,
|
|
1102
1108
|
resourceId: run.resourceId
|
|
@@ -1159,6 +1165,12 @@ const EXECUTE_WORKFLOW_STEP_ROUTE = createRoute({
|
|
|
1159
1165
|
requiresAuth: true,
|
|
1160
1166
|
handler: (async ({ mastra, workflowId, runId, ...body }) => {
|
|
1161
1167
|
try {
|
|
1168
|
+
const candidate = body.requestContext;
|
|
1169
|
+
const serverRequestContext = typeof candidate?.get === "function" ? candidate : void 0;
|
|
1170
|
+
await validateRunOwnership(await (await mastra.getStorage()?.getStore("workflows"))?.getWorkflowRunById({
|
|
1171
|
+
runId,
|
|
1172
|
+
workflowName: workflowId
|
|
1173
|
+
}), getEffectiveResourceId(serverRequestContext, void 0), mastra);
|
|
1162
1174
|
return await (await getStepStrategy(mastra)).executeStep({
|
|
1163
1175
|
workflowId,
|
|
1164
1176
|
runId,
|
|
@@ -1220,8 +1232,13 @@ const RECEIVE_WORKFLOW_EVENT_ROUTE = createRoute({
|
|
|
1220
1232
|
tags: ["Workflows", "Worker"],
|
|
1221
1233
|
requiresAuth: true,
|
|
1222
1234
|
requiresPermission: ["workflows:write", "workflows:execute"],
|
|
1223
|
-
handler: (async ({ mastra, event }) => {
|
|
1235
|
+
handler: (async ({ mastra, event, requestContext }) => {
|
|
1224
1236
|
try {
|
|
1237
|
+
const workflowName = event.data?.workflowId;
|
|
1238
|
+
await validateRunOwnership(await (await mastra.getStorage()?.getStore("workflows"))?.getWorkflowRunById({
|
|
1239
|
+
runId: event.runId,
|
|
1240
|
+
...typeof workflowName === "string" ? { workflowName } : {}
|
|
1241
|
+
}), getEffectiveResourceId(requestContext, void 0), mastra);
|
|
1225
1242
|
const rawCreatedAt = event.createdAt;
|
|
1226
1243
|
const createdAt = rawCreatedAt instanceof Date ? rawCreatedAt : new Date(rawCreatedAt);
|
|
1227
1244
|
if (Number.isNaN(createdAt.getTime())) throw new HTTPException(400, { message: "Invalid createdAt" });
|