@mastra/server 1.83.0-alpha.1 → 1.83.0-alpha.3
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/{a2a-CQlJ-SZr.js → a2a-BnWFvgiU.js} +2 -2
- package/dist/{a2a-CQlJ-SZr.js.map → a2a-BnWFvgiU.js.map} +1 -1
- package/dist/{a2a-mDspNbWX.cjs → a2a-Cu87JDM2.cjs} +2 -2
- package/dist/{a2a-mDspNbWX.cjs.map → a2a-Cu87JDM2.cjs.map} +1 -1
- package/dist/{agent-builder-B9gEkbch.cjs → agent-builder-73cAYGts.cjs} +2 -2
- package/dist/{agent-builder-B9gEkbch.cjs.map → agent-builder-73cAYGts.cjs.map} +1 -1
- package/dist/{agent-builder-BF7OAl_R.js → agent-builder-pQaGXyFz.js} +2 -2
- package/dist/{agent-builder-BF7OAl_R.js.map → agent-builder-pQaGXyFz.js.map} +1 -1
- package/dist/{agents-DXlVewzD.js → agents-BA-MmcJN.js} +56 -33
- package/dist/agents-BA-MmcJN.js.map +1 -0
- package/dist/{agents-CMEeZr5y.cjs → agents-BMxHcsO7.cjs} +56 -33
- package/dist/agents-BMxHcsO7.cjs.map +1 -0
- package/dist/{api-schema-manifest-BKnghL_k.cjs → api-schema-manifest-CDJEhBm9.cjs} +2 -2
- package/dist/{api-schema-manifest-BKnghL_k.cjs.map → api-schema-manifest-CDJEhBm9.cjs.map} +1 -1
- package/dist/{api-schema-manifest-DOuSq4rG.js → api-schema-manifest-DvyXrvvK.js} +2 -2
- package/dist/{api-schema-manifest-DOuSq4rG.js.map → api-schema-manifest-DvyXrvvK.js.map} +1 -1
- package/dist/{background-tasks-BXTIp0QV.cjs → background-tasks-CIXrANYT.cjs} +5 -1
- package/dist/background-tasks-CIXrANYT.cjs.map +1 -0
- package/dist/{background-tasks-BIuEr2of.js → background-tasks-S__xU_pa.js} +5 -1
- package/dist/background-tasks-S__xU_pa.js.map +1 -0
- package/dist/{conversations-CFj4BnNb.cjs → conversations-CsyE18Yj.cjs} +2 -2
- package/dist/{conversations-CFj4BnNb.cjs.map → conversations-CsyE18Yj.cjs.map} +1 -1
- package/dist/{conversations-DjTKtaUi.js → conversations-DtbEa1l_.js} +2 -2
- package/dist/{conversations-DjTKtaUi.js.map → conversations-DtbEa1l_.js.map} +1 -1
- package/dist/dist-CQGBYe6U.js +1 -0
- package/dist/{dist-OKFDPspq.js → dist-CXxA_Jnu.js} +122 -281
- package/dist/dist-CXxA_Jnu.js.map +1 -0
- package/dist/{dist-Ctfk9X6u.cjs → dist-DIeKEdwH.cjs} +121 -280
- package/dist/dist-DIeKEdwH.cjs.map +1 -0
- package/dist/{dist-ZYvqJK9p.cjs → dist-Dhi6UZwv.cjs} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-resumable-streams.md +3 -3
- package/dist/docs/references/docs-server-custom-adapters.md +40 -11
- package/dist/docs/references/docs-server-middleware.md +1 -1
- package/dist/{editor-builder-o9xJHa96.js → editor-builder-B4-g7fu_.js} +2 -2
- package/dist/{editor-builder-o9xJHa96.js.map → editor-builder-B4-g7fu_.js.map} +1 -1
- package/dist/{editor-builder-CBBZxQhO.cjs → editor-builder-BTi2EIB1.cjs} +2 -2
- package/dist/{editor-builder-CBBZxQhO.cjs.map → editor-builder-BTi2EIB1.cjs.map} +1 -1
- package/dist/{plans-DVx9N2re.js → plans-BLqnqqE0.js} +2 -2
- package/dist/{plans-DVx9N2re.js.map → plans-BLqnqqE0.js.map} +1 -1
- package/dist/{plans-CQijj_Am.cjs → plans-LbsK1Bj0.cjs} +2 -2
- package/dist/{plans-CQijj_Am.cjs.map → plans-LbsK1Bj0.cjs.map} +1 -1
- package/dist/{probe-image-size-bDuzMW0E.cjs → probe-image-size-C2efNs3R.cjs} +2 -2
- package/dist/{probe-image-size-bDuzMW0E.cjs.map → probe-image-size-C2efNs3R.cjs.map} +1 -1
- package/dist/{probe-image-size-Cxm5QtwO.js → probe-image-size-CO02-278.js} +2 -2
- package/dist/{probe-image-size-Cxm5QtwO.js.map → probe-image-size-CO02-278.js.map} +1 -1
- package/dist/{responses-DYGS0aiI.cjs → responses-7obXjZaq.cjs} +2 -2
- package/dist/{responses-DYGS0aiI.cjs.map → responses-7obXjZaq.cjs.map} +1 -1
- package/dist/{responses-NM-kLq8b.js → responses-DYPwRZ7Z.js} +2 -2
- package/dist/{responses-NM-kLq8b.js.map → responses-DYPwRZ7Z.js.map} +1 -1
- package/dist/{routes-CWrdLnBc.cjs → routes-B9pnPvQx.cjs} +11 -11
- package/dist/{routes-CWrdLnBc.cjs.map → routes-B9pnPvQx.cjs.map} +1 -1
- package/dist/{routes-B2XGdvlv.js → routes-CHctVPfy.js} +11 -11
- package/dist/{routes-B2XGdvlv.js.map → routes-CHctVPfy.js.map} +1 -1
- package/dist/{scores-CWx6H3Z8.cjs → scores-DxLiiwPT.cjs} +2 -2
- package/dist/{scores-CWx6H3Z8.cjs.map → scores-DxLiiwPT.cjs.map} +1 -1
- package/dist/{scores-DTVV_OaX.js → scores-qTduRPeX.js} +2 -2
- package/dist/{scores-DTVV_OaX.js.map → scores-qTduRPeX.js.map} +1 -1
- package/dist/server/handlers/a2a.cjs +1 -1
- package/dist/server/handlers/a2a.js +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 +4 -0
- package/dist/server/handlers/agent-controller.cjs.map +1 -1
- package/dist/server/handlers/agent-controller.d.ts.map +1 -1
- package/dist/server/handlers/agent-controller.js +4 -0
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/agents.cjs +1 -1
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/background-tasks.cjs +1 -1
- package/dist/server/handlers/background-tasks.d.ts.map +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/error.cjs +1 -0
- package/dist/server/handlers/error.cjs.map +1 -1
- package/dist/server/handlers/error.d.ts.map +1 -1
- package/dist/server/handlers/error.js +1 -0
- package/dist/server/handlers/error.js.map +1 -1
- package/dist/server/handlers/favorites-enrichment.cjs +1 -1
- package/dist/server/handlers/favorites-enrichment.js +1 -1
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/scores.cjs +1 -1
- package/dist/server/handlers/scores.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 +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers.cjs +8 -8
- package/dist/server/handlers.js +8 -8
- package/dist/server/server-adapter/index.cjs +47 -1
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +1 -0
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +46 -2
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/routes/responses.d.ts +11 -11
- package/dist/server/server-adapter/stream-disconnect.d.ts +24 -0
- package/dist/server/server-adapter/stream-disconnect.d.ts.map +1 -0
- package/dist/{tools-Bf3vq-HD.js → tools-DeHsVuWZ.js} +2 -2
- package/dist/{tools-Bf3vq-HD.js.map → tools-DeHsVuWZ.js.map} +1 -1
- package/dist/{tools-7O8cd_4u.cjs → tools-DszNVjKC.cjs} +2 -2
- package/dist/{tools-7O8cd_4u.cjs.map → tools-DszNVjKC.cjs.map} +1 -1
- package/package.json +3 -3
- package/dist/agents-CMEeZr5y.cjs.map +0 -1
- package/dist/agents-DXlVewzD.js.map +0 -1
- package/dist/background-tasks-BIuEr2of.js.map +0 -1
- package/dist/background-tasks-BXTIp0QV.cjs.map +0 -1
- package/dist/dist-Ctfk9X6u.cjs.map +0 -1
- package/dist/dist-DJjVMQiv.js +0 -1
- package/dist/dist-OKFDPspq.js.map +0 -1
|
@@ -304,11 +304,12 @@ async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId,
|
|
|
304
304
|
const [persistedResourceId] = persistedResourceIds;
|
|
305
305
|
if (persistedResourceIds.size > 1 || contextResourceId && persistedResourceId && persistedResourceId !== contextResourceId) throw new require_http_exception.HTTPException(403, { message: "Access denied: durable run belongs to a different resource" });
|
|
306
306
|
const ready = !!workflowRun && !!snapshot && snapshot.status === "suspended" && (toolCallId === void 0 || hasSuspendedToolCall(snapshot, toolCallId));
|
|
307
|
-
|
|
307
|
+
const aborted = !!workflowRun && snapshot?.status === "canceled";
|
|
308
|
+
if (ready || aborted || Date.now() >= deadline || abortSignal?.aborted) {
|
|
308
309
|
if (!workflowRun) throw new require_http_exception.HTTPException(403, { message: "Access denied: durable run belongs to a different resource" });
|
|
309
310
|
const persistedThreadId = input?.state?.threadId ?? input?.messageListState?.memoryInfo?.threadId;
|
|
310
311
|
if (threadId && persistedThreadId !== threadId) throw new require_http_exception.HTTPException(403, { message: "Access denied: durable run belongs to a different thread" });
|
|
311
|
-
if (!ready || input?.agentId !== agent.id) throw new require_http_exception.HTTPException(403, { message: "Access denied: tool call is not suspended on this durable run" });
|
|
312
|
+
if (!ready && !aborted || input?.agentId !== agent.id) throw new require_http_exception.HTTPException(403, { message: "Access denied: tool call is not suspended on this durable run" });
|
|
312
313
|
await require_utils$1.validateRunOwnership({ resourceId: persistedResourceId }, contextResourceId, mastra, requestContext);
|
|
313
314
|
return;
|
|
314
315
|
}
|
|
@@ -1803,17 +1804,23 @@ async function authorizeDurableRun({ mastra, agent, runId, requestContext, permi
|
|
|
1803
1804
|
return "ok";
|
|
1804
1805
|
}
|
|
1805
1806
|
/**
|
|
1806
|
-
*
|
|
1807
|
-
*
|
|
1808
|
-
*
|
|
1809
|
-
*
|
|
1810
|
-
*
|
|
1807
|
+
* The ownership policy for observing (`MEMORY_READ`) and aborting
|
|
1808
|
+
* (`MEMORY_WRITE`) a run: the caller must own the run and have `permission` on
|
|
1809
|
+
* its thread. Throws 403 when access is denied and 503 when ownership cannot be
|
|
1810
|
+
* read. Returns undefined when the run is unknown, expired, or its owner cannot
|
|
1811
|
+
* be verified; the caller decides how to report that.
|
|
1812
|
+
*
|
|
1813
|
+
* Plain runs are checked against their shared run record. Durable runs are
|
|
1814
|
+
* checked against their workflow rows; observers may also use the owner the
|
|
1815
|
+
* agent tracks in this process, or, once the rows are gone, the replay owner
|
|
1816
|
+
* the executing process shared. Both outlive the run so finished runs can be
|
|
1817
|
+
* replayed from any server, and both go when the replay history is cleared.
|
|
1818
|
+
* Aborts never use them, so a finished run is not reported stopped.
|
|
1811
1819
|
*/
|
|
1812
|
-
async function
|
|
1813
|
-
const permission = require_utils$1.MastraFGAPermissions.MEMORY_READ;
|
|
1820
|
+
async function authorizeRunAccess({ mastra, agent, runId, requestContext, permission }) {
|
|
1814
1821
|
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
|
|
1815
1822
|
const record = await getPlainRunRecord(agent, runId);
|
|
1816
|
-
if (!record)
|
|
1823
|
+
if (!record) return void 0;
|
|
1817
1824
|
await authorizeRunOwner({
|
|
1818
1825
|
mastra,
|
|
1819
1826
|
agent,
|
|
@@ -1821,10 +1828,10 @@ async function authorizeRunObservation({ mastra, agent, runId, requestContext })
|
|
|
1821
1828
|
requestContext,
|
|
1822
1829
|
permission
|
|
1823
1830
|
});
|
|
1824
|
-
return;
|
|
1831
|
+
return record;
|
|
1825
1832
|
}
|
|
1826
1833
|
const getOwner = agent.__getRunOwner;
|
|
1827
|
-
const owner = typeof getOwner === "function" ? getOwner.call(agent, runId) : void 0;
|
|
1834
|
+
const owner = permission === require_utils$1.MastraFGAPermissions.MEMORY_READ && typeof getOwner === "function" ? getOwner.call(agent, runId) : void 0;
|
|
1828
1835
|
if (owner) {
|
|
1829
1836
|
await authorizeRunOwner({
|
|
1830
1837
|
mastra,
|
|
@@ -1833,15 +1840,34 @@ async function authorizeRunObservation({ mastra, agent, runId, requestContext })
|
|
|
1833
1840
|
requestContext,
|
|
1834
1841
|
permission
|
|
1835
1842
|
});
|
|
1836
|
-
return;
|
|
1843
|
+
return {};
|
|
1837
1844
|
}
|
|
1838
|
-
|
|
1845
|
+
const access = await authorizeDurableRun({
|
|
1839
1846
|
mastra,
|
|
1840
1847
|
agent,
|
|
1841
1848
|
runId,
|
|
1842
1849
|
requestContext,
|
|
1843
1850
|
permission
|
|
1844
|
-
})
|
|
1851
|
+
});
|
|
1852
|
+
if (access === "ok") return {};
|
|
1853
|
+
if (access !== "missing") return void 0;
|
|
1854
|
+
const getReplayOwner = agent.__getReplayOwner;
|
|
1855
|
+
if (permission !== require_utils$1.MastraFGAPermissions.MEMORY_READ || typeof getReplayOwner !== "function") return void 0;
|
|
1856
|
+
let replayOwner;
|
|
1857
|
+
try {
|
|
1858
|
+
replayOwner = await getReplayOwner.call(agent, runId);
|
|
1859
|
+
} catch {
|
|
1860
|
+
throw new require_http_exception.HTTPException(503, { message: "Run ownership is temporarily unavailable" });
|
|
1861
|
+
}
|
|
1862
|
+
if (!replayOwner) return void 0;
|
|
1863
|
+
await authorizeRunOwner({
|
|
1864
|
+
mastra,
|
|
1865
|
+
agent,
|
|
1866
|
+
owner: replayOwner,
|
|
1867
|
+
requestContext,
|
|
1868
|
+
permission
|
|
1869
|
+
});
|
|
1870
|
+
return {};
|
|
1845
1871
|
}
|
|
1846
1872
|
const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
1847
1873
|
method: "POST",
|
|
@@ -1864,26 +1890,22 @@ const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
1864
1890
|
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
|
|
1865
1891
|
const resumable = agent;
|
|
1866
1892
|
if (typeof resumable.__getRunRecord !== "function" && typeof resumable.__getPublishedRunOwner !== "function" || !hasResumableStreams(agent)) throw new require_http_exception.HTTPException(501, { message: "Run-scoped cancellation requires a durable agent or an agent with resumable streams" });
|
|
1867
|
-
const record = await getPlainRunRecord(agent, runId);
|
|
1868
|
-
if (!record) throw new require_http_exception.HTTPException(404, { message: "Run not found" });
|
|
1869
|
-
await authorizeRunOwner({
|
|
1870
|
-
mastra,
|
|
1871
|
-
agent,
|
|
1872
|
-
owner: record,
|
|
1873
|
-
requestContext,
|
|
1874
|
-
permission: require_utils$1.MastraFGAPermissions.MEMORY_WRITE
|
|
1875
|
-
});
|
|
1876
|
-
if (record.status === "finished") return { aborted: false };
|
|
1877
|
-
if (typeof resumable.__abortRunAcknowledged === "function") return { aborted: await resumable.__abortRunAcknowledged.call(agent, runId) };
|
|
1878
|
-
return { aborted: agent.abortRunStream(runId) };
|
|
1879
1893
|
}
|
|
1880
|
-
|
|
1894
|
+
const run = await authorizeRunAccess({
|
|
1881
1895
|
mastra,
|
|
1882
1896
|
agent,
|
|
1883
1897
|
runId,
|
|
1884
1898
|
requestContext,
|
|
1885
1899
|
permission: require_utils$1.MastraFGAPermissions.MEMORY_WRITE
|
|
1886
|
-
})
|
|
1900
|
+
});
|
|
1901
|
+
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
|
|
1902
|
+
if (!run) throw new require_http_exception.HTTPException(404, { message: "Run not found" });
|
|
1903
|
+
if (run.status === "finished") return { aborted: false };
|
|
1904
|
+
const resumable = agent;
|
|
1905
|
+
if (typeof resumable.__abortRunAcknowledged === "function") return { aborted: await resumable.__abortRunAcknowledged.call(agent, runId) };
|
|
1906
|
+
return { aborted: agent.abortRunStream(runId) };
|
|
1907
|
+
}
|
|
1908
|
+
if (!run) return { aborted: false };
|
|
1887
1909
|
if (typeof agent.__abortRunAcknowledged === "function") return { aborted: await agent.__abortRunAcknowledged(runId) };
|
|
1888
1910
|
return { aborted: await agent.abortRunStream(runId) };
|
|
1889
1911
|
} catch (error) {
|
|
@@ -2191,12 +2213,13 @@ const OBSERVE_AGENT_STREAM_ROUTE = require_route_builder.createRoute({
|
|
|
2191
2213
|
agentId,
|
|
2192
2214
|
requestContext
|
|
2193
2215
|
});
|
|
2194
|
-
await
|
|
2216
|
+
if (!await authorizeRunAccess({
|
|
2195
2217
|
mastra,
|
|
2196
2218
|
agent,
|
|
2197
2219
|
runId,
|
|
2198
|
-
requestContext
|
|
2199
|
-
|
|
2220
|
+
requestContext,
|
|
2221
|
+
permission: require_utils$1.MastraFGAPermissions.MEMORY_READ
|
|
2222
|
+
})) throw new require_http_exception.HTTPException(404, { message: "Run not found" });
|
|
2200
2223
|
const durableAgent = (0, _mastra_core_agent.isDurableAgentLike)(agent) ? agent : void 0;
|
|
2201
2224
|
const pubsub = durableAgent?.pubsub ?? getAgentStreamPubSub(agent) ?? mastra.pubsub;
|
|
2202
2225
|
const topic = (0, _mastra_core_agent_durable.AGENT_STREAM_TOPIC)(runId);
|
|
@@ -3541,4 +3564,4 @@ Object.defineProperty(exports, "isProviderConnected", {
|
|
|
3541
3564
|
}
|
|
3542
3565
|
});
|
|
3543
3566
|
|
|
3544
|
-
//# sourceMappingURL=agents-
|
|
3567
|
+
//# sourceMappingURL=agents-BMxHcsO7.cjs.map
|