@mastra/server 1.72.0-alpha.4 → 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.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/route-builder-2yrD15TL.cjs.map +1 -1
- package/dist/route-builder-lBil8Cvo.js.map +1 -1
- package/dist/server/handlers/agents.cjs +20 -2
- package/dist/server/handlers/agents.cjs.map +1 -1
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +20 -2
- package/dist/server/handlers/agents.js.map +1 -1
- package/package.json +6 -6
|
@@ -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
|
-
|
|
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
|