@mastra/server 1.72.0-alpha.5 → 1.72.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.
@@ -3,7 +3,7 @@ name: mastra-server
3
3
  description: Documentation for @mastra/server. Use when working with @mastra/server APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/server"
6
- version: "1.72.0-alpha.5"
6
+ version: "1.72.0-alpha.6"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.72.0-alpha.5",
2
+ "version": "1.72.0-alpha.6",
3
3
  "package": "@mastra/server",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -128,7 +128,7 @@ function hasSuspendedToolCall(snapshot, toolCallId) {
128
128
  function getDurableLoopWorkflowName(agent) {
129
129
  return agent.durableLoopWorkflowName ?? _mastra_core_agent_durable.DurableStepIds.AGENTIC_LOOP;
130
130
  }
131
- async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId, requestContext }) {
131
+ async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId, requestContext, threadId }) {
132
132
  if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) return;
133
133
  const workflowRun = await (await mastra.getStorage()?.getStore("workflows"))?.getWorkflowRunById({
134
134
  workflowName: getDurableLoopWorkflowName(agent),
@@ -151,7 +151,9 @@ async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId,
151
151
  const effectiveResourceId = require_utils$1.getEffectiveResourceId(requestContext, void 0);
152
152
  const [persistedResourceId] = persistedResourceIds;
153
153
  if (persistedResourceIds.size > 1 || persistedResourceId && persistedResourceId !== effectiveResourceId) throw new require_http_exception.HTTPException(403, { message: "Access denied: durable run belongs to a different resource" });
154
- if (!snapshot || snapshot.status !== "suspended" || input?.agentId !== agent.id || !hasSuspendedToolCall(snapshot, toolCallId)) throw new require_http_exception.HTTPException(403, { message: "Access denied: tool call is not suspended on this durable run" });
154
+ const persistedThreadId = input?.state?.threadId ?? input?.messageListState?.memoryInfo?.threadId;
155
+ if (threadId && persistedThreadId !== threadId) throw new require_http_exception.HTTPException(403, { message: "Access denied: durable run belongs to a different thread" });
156
+ if (!snapshot || snapshot.status !== "suspended" || input?.agentId !== agent.id || toolCallId !== void 0 && !hasSuspendedToolCall(snapshot, toolCallId)) throw new require_http_exception.HTTPException(403, { message: "Access denied: tool call is not suspended on this durable run" });
155
157
  }
156
158
  /**
157
159
  * Providers whose apiKeyEnvVar entries are aliases for the same credential (any one
@@ -2019,6 +2021,14 @@ const RESUME_STREAM_ROUTE = require_route_builder.createRoute({
2019
2021
  ...effectiveResourceId ? { resource: effectiveResourceId } : {},
2020
2022
  ...effectiveThreadId ? { thread: effectiveThreadId } : {}
2021
2023
  };
2024
+ await validateDurableToolCallAccess({
2025
+ mastra,
2026
+ agent,
2027
+ runId,
2028
+ toolCallId,
2029
+ requestContext: serverRequestContext,
2030
+ threadId: effectiveThreadId
2031
+ });
2022
2032
  await require_utils$1.validateRunOwnership(await (await mastra.getStorage()?.getStore("workflows"))?.getWorkflowRunById({
2023
2033
  workflowName: "agentic-loop",
2024
2034
  runId
@@ -2131,6 +2141,14 @@ const RESUME_STREAM_UNTIL_IDLE_ROUTE = require_route_builder.createRoute({
2131
2141
  ...effectiveResourceId ? { resource: effectiveResourceId } : {},
2132
2142
  ...effectiveThreadId ? { thread: effectiveThreadId } : {}
2133
2143
  };
2144
+ await validateDurableToolCallAccess({
2145
+ mastra,
2146
+ agent,
2147
+ runId,
2148
+ toolCallId,
2149
+ requestContext: serverRequestContext,
2150
+ threadId: effectiveThreadId
2151
+ });
2134
2152
  await require_utils$1.validateRunOwnership(await (await mastra.getStorage()?.getStore("workflows"))?.getWorkflowRunById({
2135
2153
  workflowName: "agentic-loop",
2136
2154
  runId