@mastra/server 1.78.0-alpha.4 → 1.78.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.
Files changed (105) hide show
  1. package/dist/{agents-CKSEPpk1.cjs → agents-D9vpLghy.cjs} +8 -1
  2. package/dist/{agents-CKSEPpk1.cjs.map → agents-D9vpLghy.cjs.map} +1 -1
  3. package/dist/{agents-CW_JJZOf.js → agents-DNWDET4U.js} +3 -2
  4. package/dist/{agents-CW_JJZOf.js.map → agents-DNWDET4U.js.map} +1 -1
  5. package/dist/{api-schema-manifest-7Mkcahcz.cjs → api-schema-manifest-CmnpeFqd.cjs} +2 -2
  6. package/dist/{api-schema-manifest-7Mkcahcz.cjs.map → api-schema-manifest-CmnpeFqd.cjs.map} +1 -1
  7. package/dist/{api-schema-manifest-BSc3N7kx.js → api-schema-manifest-D8dn-tBo.js} +2 -2
  8. package/dist/{api-schema-manifest-BSc3N7kx.js.map → api-schema-manifest-D8dn-tBo.js.map} +1 -1
  9. package/dist/{background-tasks-Cu89GYC6.cjs → background-tasks-CP6TSFhc.cjs} +2 -2
  10. package/dist/{background-tasks-Cu89GYC6.cjs.map → background-tasks-CP6TSFhc.cjs.map} +1 -1
  11. package/dist/{background-tasks-_e2S8LLH.js → background-tasks-Clbud7G4.js} +2 -2
  12. package/dist/{background-tasks-_e2S8LLH.js.map → background-tasks-Clbud7G4.js.map} +1 -1
  13. package/dist/docs/SKILL.md +1 -1
  14. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  15. package/dist/docs/references/docs-guides-mcp-authentication-authorization.md +10 -1
  16. package/dist/docs/references/docs-server-middleware.md +4 -0
  17. package/dist/docs/references/reference-server-routes.md +17 -6
  18. package/dist/{editor-builder-CmUsqdZq.cjs → editor-builder-BOmAPurW.cjs} +2 -2
  19. package/dist/{editor-builder-CmUsqdZq.cjs.map → editor-builder-BOmAPurW.cjs.map} +1 -1
  20. package/dist/{editor-builder-DHXbVwxu.js → editor-builder-CeLVu_FT.js} +2 -2
  21. package/dist/{editor-builder-DHXbVwxu.js.map → editor-builder-CeLVu_FT.js.map} +1 -1
  22. package/dist/{editor-builder-CYkaYf6-.js → editor-builder-DHqCWGd2.js} +2 -2
  23. package/dist/{editor-builder-CYkaYf6-.js.map → editor-builder-DHqCWGd2.js.map} +1 -1
  24. package/dist/{editor-builder-BtcTQbAC.cjs → editor-builder-DqHKoEDx.cjs} +2 -2
  25. package/dist/{editor-builder-BtcTQbAC.cjs.map → editor-builder-DqHKoEDx.cjs.map} +1 -1
  26. package/dist/{routes-BOpfBZw5.cjs → routes-BwzE4nnm.cjs} +6 -5
  27. package/dist/routes-BwzE4nnm.cjs.map +1 -0
  28. package/dist/{routes-CccVLchZ.js → routes-DlbTsFpA.js} +7 -6
  29. package/dist/routes-DlbTsFpA.js.map +1 -0
  30. package/dist/{schedules-6XpznRPz.js → schedules-BRdVmFYi.js} +2 -2
  31. package/dist/{schedules-6XpznRPz.js.map → schedules-BRdVmFYi.js.map} +1 -1
  32. package/dist/{schedules-BiqVrJH7.cjs → schedules-DvLXX2nW.cjs} +2 -2
  33. package/dist/{schedules-BiqVrJH7.cjs.map → schedules-DvLXX2nW.cjs.map} +1 -1
  34. package/dist/server/handlers/agent-builder.cjs +1 -1
  35. package/dist/server/handlers/agent-builder.js +1 -1
  36. package/dist/server/handlers/agent-controller.cjs +1 -1
  37. package/dist/server/handlers/agent-controller.js +1 -1
  38. package/dist/server/handlers/agents.cjs +39 -10
  39. package/dist/server/handlers/agents.cjs.map +1 -1
  40. package/dist/server/handlers/agents.d.ts +2113 -0
  41. package/dist/server/handlers/agents.d.ts.map +1 -1
  42. package/dist/server/handlers/agents.js +39 -11
  43. package/dist/server/handlers/agents.js.map +1 -1
  44. package/dist/server/handlers/background-tasks.cjs +1 -1
  45. package/dist/server/handlers/background-tasks.js +1 -1
  46. package/dist/server/handlers/conversations.cjs +1 -1
  47. package/dist/server/handlers/conversations.js +1 -1
  48. package/dist/server/handlers/editor-builder.cjs +1 -1
  49. package/dist/server/handlers/editor-builder.js +1 -1
  50. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  51. package/dist/server/handlers/favorites-enrichment.js +1 -1
  52. package/dist/server/handlers/logs.cjs +1 -1
  53. package/dist/server/handlers/logs.js +1 -1
  54. package/dist/server/handlers/memory.cjs +1 -1
  55. package/dist/server/handlers/memory.js +1 -1
  56. package/dist/server/handlers/plans.cjs +2 -2
  57. package/dist/server/handlers/plans.js +2 -2
  58. package/dist/server/handlers/responses.cjs +1 -1
  59. package/dist/server/handlers/responses.js +1 -1
  60. package/dist/server/handlers/responses.storage.cjs +1 -1
  61. package/dist/server/handlers/responses.storage.js +1 -1
  62. package/dist/server/handlers/schedules.cjs +1 -1
  63. package/dist/server/handlers/schedules.js +1 -1
  64. package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
  65. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  66. package/dist/server/handlers/stored-agents.cjs +1 -1
  67. package/dist/server/handlers/stored-agents.js +1 -1
  68. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  69. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  70. package/dist/server/handlers/stored-skills.cjs +1 -1
  71. package/dist/server/handlers/stored-skills.js +1 -1
  72. package/dist/server/handlers/system.cjs +1 -1
  73. package/dist/server/handlers/system.js +1 -1
  74. package/dist/server/handlers/tools.cjs +2 -2
  75. package/dist/server/handlers/tools.js +2 -2
  76. package/dist/server/handlers/utils.cjs +1 -1
  77. package/dist/server/handlers/utils.d.ts +14 -3
  78. package/dist/server/handlers/utils.d.ts.map +1 -1
  79. package/dist/server/handlers/utils.js +1 -1
  80. package/dist/server/handlers/workflow-builder.cjs +1 -1
  81. package/dist/server/handlers/workflow-builder.js +1 -1
  82. package/dist/server/handlers/workflows.cjs +37 -20
  83. package/dist/server/handlers/workflows.cjs.map +1 -1
  84. package/dist/server/handlers/workflows.d.ts.map +1 -1
  85. package/dist/server/handlers/workflows.js +37 -20
  86. package/dist/server/handlers/workflows.js.map +1 -1
  87. package/dist/server/schemas/agents.d.ts +199 -0
  88. package/dist/server/schemas/agents.d.ts.map +1 -1
  89. package/dist/server/schemas/index.cjs +3 -2
  90. package/dist/server/schemas/index.js +3 -3
  91. package/dist/server/server-adapter/index.cjs +1 -1
  92. package/dist/server/server-adapter/index.js +1 -1
  93. package/dist/server/server-adapter/routes/agents.d.ts +2 -1
  94. package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
  95. package/dist/{utils-BF2Kbju4.cjs → utils-DdGLbkOl.cjs} +21 -5
  96. package/dist/{utils-BF2Kbju4.cjs.map → utils-DdGLbkOl.cjs.map} +1 -1
  97. package/dist/{utils-GVYTDbr2.js → utils-mIFmRM_j.js} +21 -5
  98. package/dist/{utils-GVYTDbr2.js.map → utils-mIFmRM_j.js.map} +1 -1
  99. package/dist/{workflow-builder-UVflLOfv.cjs → workflow-builder-BM6Nen0q.cjs} +4 -4
  100. package/dist/{workflow-builder-UVflLOfv.cjs.map → workflow-builder-BM6Nen0q.cjs.map} +1 -1
  101. package/dist/{workflow-builder-U2jFH8o7.js → workflow-builder-BnKKH8iT.js} +4 -4
  102. package/dist/{workflow-builder-U2jFH8o7.js.map → workflow-builder-BnKKH8iT.js.map} +1 -1
  103. package/package.json +6 -6
  104. package/dist/routes-BOpfBZw5.cjs.map +0 -1
  105. 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-CKSEPpk1.cjs");
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-BF2Kbju4.cjs");
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" });