@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
|
@@ -3,11 +3,11 @@ const require_rolldown_runtime = require("../../rolldown-runtime-Bd6kNlEP.cjs");
|
|
|
3
3
|
const require_http_exception = require("../../http-exception-CKDHupKw.cjs");
|
|
4
4
|
const require_common = require("../../common-DhKNoXGp.cjs");
|
|
5
5
|
const require_workflows = require("../../workflows-C8rDpHyY.cjs");
|
|
6
|
-
const require_agents = require("../../agents-
|
|
6
|
+
const require_agents = require("../../agents-D9vpLghy.cjs");
|
|
7
7
|
const require_route_builder = require("../../route-builder-2yrD15TL.cjs");
|
|
8
8
|
const require_utils = require("../../utils-CJxnYdr3.cjs");
|
|
9
9
|
const require_server_handlers_error = require("./error.cjs");
|
|
10
|
-
const require_utils$1 = require("../../utils-
|
|
10
|
+
const require_utils$1 = require("../../utils-DdGLbkOl.cjs");
|
|
11
11
|
let zod_v4 = require("zod/v4");
|
|
12
12
|
let _mastra_core_stream = require("@mastra/core/stream");
|
|
13
13
|
//#region src/server/handlers/workflows.ts
|
|
@@ -339,7 +339,7 @@ const GET_WORKFLOW_RUN_BY_ID_ROUTE = require_route_builder.createRoute({
|
|
|
339
339
|
fields: fieldList
|
|
340
340
|
});
|
|
341
341
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
342
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
342
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
343
343
|
return run;
|
|
344
344
|
} catch (error) {
|
|
345
345
|
return require_server_handlers_error.handleError(error, "Error getting workflow run");
|
|
@@ -368,7 +368,7 @@ const DELETE_WORKFLOW_RUN_BY_ID_ROUTE = require_route_builder.createRoute({
|
|
|
368
368
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
369
369
|
const run = await workflow.getWorkflowRunById(runId);
|
|
370
370
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
371
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
371
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
372
372
|
await workflow.deleteWorkflowRunById(runId);
|
|
373
373
|
return { message: "Workflow run deleted" };
|
|
374
374
|
} catch (error) {
|
|
@@ -398,6 +398,7 @@ const CREATE_WORKFLOW_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
398
398
|
workflowId
|
|
399
399
|
});
|
|
400
400
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
401
|
+
if (runId) await require_utils$1.validateRunOwnership(await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false }), require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
401
402
|
return { runId: (await workflow.createRun({
|
|
402
403
|
runId,
|
|
403
404
|
resourceId: effectiveResourceId,
|
|
@@ -430,6 +431,7 @@ const STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
430
431
|
});
|
|
431
432
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
432
433
|
const existingRun = await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false });
|
|
434
|
+
await require_utils$1.validateRunOwnership(existingRun, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
433
435
|
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.` });
|
|
434
436
|
const serverCache = mastra.getServerCache();
|
|
435
437
|
const result = (await workflow.createRun({
|
|
@@ -474,7 +476,7 @@ const RESUME_STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
474
476
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
475
477
|
const run = await workflow.getWorkflowRunById(runId);
|
|
476
478
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
477
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
479
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
478
480
|
const _run = await workflow.createRun({
|
|
479
481
|
runId,
|
|
480
482
|
resourceId: run.resourceId
|
|
@@ -516,6 +518,7 @@ const START_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
516
518
|
workflowId
|
|
517
519
|
});
|
|
518
520
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
521
|
+
if (runId) await require_utils$1.validateRunOwnership(await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false }), require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
519
522
|
return await (await workflow.createRun({
|
|
520
523
|
runId,
|
|
521
524
|
resourceId: effectiveResourceId
|
|
@@ -552,7 +555,7 @@ const START_WORKFLOW_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
552
555
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
553
556
|
const run = await workflow.getWorkflowRunById(runId);
|
|
554
557
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
555
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
558
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
556
559
|
(await workflow.createRun({
|
|
557
560
|
runId,
|
|
558
561
|
resourceId: run.resourceId
|
|
@@ -595,7 +598,7 @@ const OBSERVE_STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
595
598
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
596
599
|
const run = await workflow.getWorkflowRunById(runId);
|
|
597
600
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
598
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
601
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
599
602
|
const _run = await workflow.createRun({
|
|
600
603
|
runId,
|
|
601
604
|
resourceId: run.resourceId
|
|
@@ -636,7 +639,7 @@ const RESUME_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
636
639
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
637
640
|
const run = await workflow.getWorkflowRunById(runId);
|
|
638
641
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
639
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
642
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
640
643
|
return await (await workflow.createRun({
|
|
641
644
|
runId,
|
|
642
645
|
resourceId: run.resourceId
|
|
@@ -683,7 +686,7 @@ const RESUME_NO_WAIT_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
683
686
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
684
687
|
const run = await workflow.getWorkflowRunById(runId);
|
|
685
688
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
686
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
689
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
687
690
|
return await (await workflow.createRun({
|
|
688
691
|
runId,
|
|
689
692
|
resourceId: run.resourceId
|
|
@@ -720,7 +723,7 @@ const RESUME_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
720
723
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
721
724
|
const run = await workflow.getWorkflowRunById(runId);
|
|
722
725
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
723
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
726
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
724
727
|
(await workflow.createRun({
|
|
725
728
|
runId,
|
|
726
729
|
resourceId: run.resourceId
|
|
@@ -764,7 +767,7 @@ const RESTART_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
764
767
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
765
768
|
const run = await workflow.getWorkflowRunById(runId);
|
|
766
769
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
767
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
770
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
768
771
|
return await (await workflow.createRun({
|
|
769
772
|
runId,
|
|
770
773
|
resourceId: run.resourceId
|
|
@@ -801,7 +804,7 @@ const RESTART_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
801
804
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
802
805
|
const run = await workflow.getWorkflowRunById(runId);
|
|
803
806
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
804
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
807
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
805
808
|
(await workflow.createRun({
|
|
806
809
|
runId,
|
|
807
810
|
resourceId: run.resourceId
|
|
@@ -831,8 +834,9 @@ const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ASYNC_ROUTE = require_route_builder.creat
|
|
|
831
834
|
description: "Restarts all active workflow runs asynchronously",
|
|
832
835
|
tags: ["Workflows"],
|
|
833
836
|
requiresAuth: true,
|
|
834
|
-
handler: async ({ mastra, workflowId }) => {
|
|
837
|
+
handler: async ({ mastra, workflowId, requestContext }) => {
|
|
835
838
|
try {
|
|
839
|
+
await require_utils$1.validateRunOwnership({ resourceId: null }, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
836
840
|
if (!workflowId) throw new require_http_exception.HTTPException(400, { message: "Workflow ID is required" });
|
|
837
841
|
const { workflow } = await listWorkflowsFromSystem({
|
|
838
842
|
mastra,
|
|
@@ -856,8 +860,9 @@ const RESTART_ALL_ACTIVE_WORKFLOW_RUNS_ROUTE = require_route_builder.createRoute
|
|
|
856
860
|
description: "Restarts all active workflow runs",
|
|
857
861
|
tags: ["Workflows"],
|
|
858
862
|
requiresAuth: true,
|
|
859
|
-
handler: async ({ mastra, workflowId }) => {
|
|
863
|
+
handler: async ({ mastra, workflowId, requestContext }) => {
|
|
860
864
|
try {
|
|
865
|
+
await require_utils$1.validateRunOwnership({ resourceId: null }, require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
861
866
|
if (!workflowId) throw new require_http_exception.HTTPException(400, { message: "Workflow ID is required" });
|
|
862
867
|
const { workflow } = await listWorkflowsFromSystem({
|
|
863
868
|
mastra,
|
|
@@ -900,7 +905,7 @@ const TIME_TRAVEL_ASYNC_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
900
905
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
901
906
|
const run = await workflow.getWorkflowRunById(runId);
|
|
902
907
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
903
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
908
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
904
909
|
return await (await workflow.createRun({
|
|
905
910
|
runId,
|
|
906
911
|
resourceId: run.resourceId
|
|
@@ -937,7 +942,7 @@ const TIME_TRAVEL_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
937
942
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
938
943
|
const run = await workflow.getWorkflowRunById(runId);
|
|
939
944
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
940
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
945
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
941
946
|
(await workflow.createRun({
|
|
942
947
|
runId,
|
|
943
948
|
resourceId: run.resourceId
|
|
@@ -980,7 +985,7 @@ const TIME_TRAVEL_STREAM_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
980
985
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
981
986
|
const existingRun = await workflow.getWorkflowRunById(runId);
|
|
982
987
|
if (!existingRun) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
983
|
-
await require_utils$1.validateRunOwnership(existingRun, effectiveResourceId);
|
|
988
|
+
await require_utils$1.validateRunOwnership(existingRun, effectiveResourceId, mastra);
|
|
984
989
|
const serverCache = mastra.getServerCache();
|
|
985
990
|
const result = (await workflow.createRun({
|
|
986
991
|
runId,
|
|
@@ -1022,7 +1027,7 @@ const CANCEL_WORKFLOW_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
1022
1027
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
1023
1028
|
const run = await workflow.getWorkflowRunById(runId);
|
|
1024
1029
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
1025
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
1030
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
1026
1031
|
await (await workflow.createRun({
|
|
1027
1032
|
runId,
|
|
1028
1033
|
resourceId: run.resourceId
|
|
@@ -1056,6 +1061,7 @@ const STREAM_LEGACY_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
1056
1061
|
});
|
|
1057
1062
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
1058
1063
|
const serverCache = mastra.getServerCache();
|
|
1064
|
+
if (runId) await require_utils$1.validateRunOwnership(await workflow.getWorkflowRunById(runId, { withNestedWorkflows: false }), require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
1059
1065
|
return (await workflow.createRun({
|
|
1060
1066
|
runId,
|
|
1061
1067
|
resourceId: effectiveResourceId
|
|
@@ -1097,7 +1103,7 @@ const OBSERVE_STREAM_LEGACY_WORKFLOW_ROUTE = require_route_builder.createRoute({
|
|
|
1097
1103
|
if (!workflow) throw new require_http_exception.HTTPException(404, { message: "Workflow not found" });
|
|
1098
1104
|
const run = await workflow.getWorkflowRunById(runId);
|
|
1099
1105
|
if (!run) throw new require_http_exception.HTTPException(404, { message: "Workflow run not found" });
|
|
1100
|
-
await require_utils$1.validateRunOwnership(run, effectiveResourceId);
|
|
1106
|
+
await require_utils$1.validateRunOwnership(run, effectiveResourceId, mastra);
|
|
1101
1107
|
const _run = await workflow.createRun({
|
|
1102
1108
|
runId,
|
|
1103
1109
|
resourceId: run.resourceId
|
|
@@ -1161,6 +1167,12 @@ const EXECUTE_WORKFLOW_STEP_ROUTE = require_route_builder.createRoute({
|
|
|
1161
1167
|
requiresAuth: true,
|
|
1162
1168
|
handler: (async ({ mastra, workflowId, runId, ...body }) => {
|
|
1163
1169
|
try {
|
|
1170
|
+
const candidate = body.requestContext;
|
|
1171
|
+
const serverRequestContext = typeof candidate?.get === "function" ? candidate : void 0;
|
|
1172
|
+
await require_utils$1.validateRunOwnership(await (await mastra.getStorage()?.getStore("workflows"))?.getWorkflowRunById({
|
|
1173
|
+
runId,
|
|
1174
|
+
workflowName: workflowId
|
|
1175
|
+
}), require_utils$1.getEffectiveResourceId(serverRequestContext, void 0), mastra);
|
|
1164
1176
|
return await (await getStepStrategy(mastra)).executeStep({
|
|
1165
1177
|
workflowId,
|
|
1166
1178
|
runId,
|
|
@@ -1224,8 +1236,13 @@ const RECEIVE_WORKFLOW_EVENT_ROUTE = require_route_builder.createRoute({
|
|
|
1224
1236
|
tags: ["Workflows", "Worker"],
|
|
1225
1237
|
requiresAuth: true,
|
|
1226
1238
|
requiresPermission: ["workflows:write", "workflows:execute"],
|
|
1227
|
-
handler: (async ({ mastra, event }) => {
|
|
1239
|
+
handler: (async ({ mastra, event, requestContext }) => {
|
|
1228
1240
|
try {
|
|
1241
|
+
const workflowName = event.data?.workflowId;
|
|
1242
|
+
await require_utils$1.validateRunOwnership(await (await mastra.getStorage()?.getStore("workflows"))?.getWorkflowRunById({
|
|
1243
|
+
runId: event.runId,
|
|
1244
|
+
...typeof workflowName === "string" ? { workflowName } : {}
|
|
1245
|
+
}), require_utils$1.getEffectiveResourceId(requestContext, void 0), mastra);
|
|
1229
1246
|
const rawCreatedAt = event.createdAt;
|
|
1230
1247
|
const createdAt = rawCreatedAt instanceof Date ? rawCreatedAt : new Date(rawCreatedAt);
|
|
1231
1248
|
if (Number.isNaN(createdAt.getTime())) throw new require_http_exception.HTTPException(400, { message: "Invalid createdAt" });
|