@mastra/server 1.83.0-alpha.0 → 1.83.0-alpha.10
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/README.md +0 -6
- package/dist/_types/@internal_core@0.1.4/dist/storage/index.d.ts +59 -0
- package/dist/{a2a-kz7NjjCg.cjs → a2a-DIcMx6x-.cjs} +4 -4
- package/dist/{a2a-kz7NjjCg.cjs.map → a2a-DIcMx6x-.cjs.map} +1 -1
- package/dist/{a2a-DCpd3CTv.js → a2a-DTTGA2Xg.js} +4 -4
- package/dist/{a2a-DCpd3CTv.js.map → a2a-DTTGA2Xg.js.map} +1 -1
- package/dist/{agent-builder-CocfOSi8.js → agent-builder-BNfBksTT.js} +6 -6
- package/dist/{agent-builder-CocfOSi8.js.map → agent-builder-BNfBksTT.js.map} +1 -1
- package/dist/{agent-builder-uDstZROq.cjs → agent-builder-CopkMfWF.cjs} +6 -6
- package/dist/{agent-builder-uDstZROq.cjs.map → agent-builder-CopkMfWF.cjs.map} +1 -1
- package/dist/{agent-versions-BccL4mEW.cjs → agent-versions-CwWhEoU5.cjs} +2 -2
- package/dist/{agent-versions-BccL4mEW.cjs.map → agent-versions-CwWhEoU5.cjs.map} +1 -1
- package/dist/{agent-versions-DFJyxWY1.js → agent-versions-DfcKpYNW.js} +2 -2
- package/dist/{agent-versions-DFJyxWY1.js.map → agent-versions-DfcKpYNW.js.map} +1 -1
- package/dist/{agents-BXqMKoOz.js → agents-BCgiMlDq.js} +2 -2
- package/dist/{agents-BXqMKoOz.js.map → agents-BCgiMlDq.js.map} +1 -1
- package/dist/{agents-BI8ez-FT.js → agents-CTgjTASj.js} +248 -65
- package/dist/agents-CTgjTASj.js.map +1 -0
- package/dist/{agents-DbnPZXIN.cjs → agents-CjcvdF2e.cjs} +2 -2
- package/dist/{agents-DbnPZXIN.cjs.map → agents-CjcvdF2e.cjs.map} +1 -1
- package/dist/{agents-DsfsDhIT.cjs → agents-DjpBmwhv.cjs} +249 -66
- package/dist/agents-DjpBmwhv.cjs.map +1 -0
- package/dist/{api-schema-manifest-ChxbN16M.js → api-schema-manifest-LHpJSi-Y.js} +3 -3
- package/dist/{api-schema-manifest-ChxbN16M.js.map → api-schema-manifest-LHpJSi-Y.js.map} +1 -1
- package/dist/{api-schema-manifest-DtYTPvh9.cjs → api-schema-manifest-hPT7_FSw.cjs} +3 -3
- package/dist/{api-schema-manifest-DtYTPvh9.cjs.map → api-schema-manifest-hPT7_FSw.cjs.map} +1 -1
- package/dist/{background-tasks-BIuEr2of.js → background-tasks-CYvlxFz3.js} +6 -2
- package/dist/background-tasks-CYvlxFz3.js.map +1 -0
- package/dist/{background-tasks-BXTIp0QV.cjs → background-tasks-Dv9o8cR7.cjs} +6 -2
- package/dist/background-tasks-Dv9o8cR7.cjs.map +1 -0
- package/dist/{builder-registry-Dd7pbJ5A.js → builder-registry-BmrttdGj.js} +3 -3
- package/dist/{builder-registry-Dd7pbJ5A.js.map → builder-registry-BmrttdGj.js.map} +1 -1
- package/dist/{builder-registry-DrBUA6EZ.cjs → builder-registry-CmbtZzbE.cjs} +3 -3
- package/dist/{builder-registry-DrBUA6EZ.cjs.map → builder-registry-CmbtZzbE.cjs.map} +1 -1
- package/dist/{channels-DbfSH5O2.cjs → channels-CXwFVxi2.cjs} +2 -2
- package/dist/{channels-DbfSH5O2.cjs.map → channels-CXwFVxi2.cjs.map} +1 -1
- package/dist/{channels-B6hwVMbV.js → channels-KHhb7hAm.js} +2 -2
- package/dist/{channels-B6hwVMbV.js.map → channels-KHhb7hAm.js.map} +1 -1
- package/dist/{conversations-QuKJVEFe.cjs → conversations-BFqmDglO.cjs} +3 -3
- package/dist/{conversations-QuKJVEFe.cjs.map → conversations-BFqmDglO.cjs.map} +1 -1
- package/dist/{conversations-BbZYXKIa.js → conversations-BkX00xDs.js} +3 -3
- package/dist/{conversations-BbZYXKIa.js.map → conversations-BkX00xDs.js.map} +1 -1
- package/dist/{datasets--F0QkdGX.js → datasets-C1XJLHN8.js} +6 -1
- package/dist/datasets-C1XJLHN8.js.map +1 -0
- package/dist/{datasets-BiEAIm0s.cjs → datasets-hqDd4IUN.cjs} +6 -1
- package/dist/datasets-hqDd4IUN.cjs.map +1 -0
- package/dist/{dist-ZYvqJK9p.cjs → dist-3WMLkPSs.cjs} +1 -1
- package/dist/dist-4NnakSte.js +1 -0
- package/dist/{dist-Ctfk9X6u.cjs → dist-COfASzWw.cjs} +206 -304
- package/dist/dist-COfASzWw.cjs.map +1 -0
- package/dist/{dist-OKFDPspq.js → dist-G8g-Cg67.js} +202 -300
- package/dist/dist-G8g-Cg67.js.map +1 -0
- package/dist/docs/SKILL.md +3 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-resumable-streams.md +140 -0
- package/dist/docs/references/docs-server-custom-adapters.md +40 -11
- package/dist/docs/references/docs-server-middleware.md +1 -1
- package/dist/docs/references/docs-server-server-adapters.md +679 -0
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +49 -59
- package/dist/{dynamic-workflows-CyaZLmHX.js → dynamic-workflows-CYtakeIQ.js} +2 -2
- package/dist/{dynamic-workflows-CyaZLmHX.js.map → dynamic-workflows-CYtakeIQ.js.map} +1 -1
- package/dist/{dynamic-workflows-ZmzWJXxG.cjs → dynamic-workflows-QgKLYkiC.cjs} +2 -2
- package/dist/{dynamic-workflows-ZmzWJXxG.cjs.map → dynamic-workflows-QgKLYkiC.cjs.map} +1 -1
- package/dist/{editor-builder-CbfX5bvL.js → editor-builder-C4H2l6tz.js} +4 -4
- package/dist/{editor-builder-CbfX5bvL.js.map → editor-builder-C4H2l6tz.js.map} +1 -1
- package/dist/{editor-builder-CjJlqR9a.cjs → editor-builder-Cqw1npOK.cjs} +4 -4
- package/dist/{editor-builder-CjJlqR9a.cjs.map → editor-builder-Cqw1npOK.cjs.map} +1 -1
- package/dist/{editor-builder-Bln4Pg1U.js → editor-builder-fe70YP8g.js} +2 -2
- package/dist/{editor-builder-Bln4Pg1U.js.map → editor-builder-fe70YP8g.js.map} +1 -1
- package/dist/{editor-builder-BaI8pttR.cjs → editor-builder-xQmDgVgJ.cjs} +2 -2
- package/dist/{editor-builder-BaI8pttR.cjs.map → editor-builder-xQmDgVgJ.cjs.map} +1 -1
- package/dist/{helpers-CylvUIZm.cjs → helpers-0LJI4DxR.cjs} +190 -55
- package/dist/helpers-0LJI4DxR.cjs.map +1 -0
- package/dist/{helpers-B29a1nM3.js → helpers-C9QZKOhz.js} +185 -56
- package/dist/helpers-C9QZKOhz.js.map +1 -0
- package/dist/{knowledge-Q_SCnD9m.cjs → knowledge-CRkWkTBC.cjs} +2 -2
- package/dist/{knowledge-Q_SCnD9m.cjs.map → knowledge-CRkWkTBC.cjs.map} +1 -1
- package/dist/{knowledge-Cd2cCq-Y.js → knowledge-Dfe_CFtt.js} +2 -2
- package/dist/{knowledge-Cd2cCq-Y.js.map → knowledge-Dfe_CFtt.js.map} +1 -1
- package/dist/{logs-DWIbFIw6.cjs → logs-B2ov1yZQ.cjs} +2 -2
- package/dist/{logs-DWIbFIw6.cjs.map → logs-B2ov1yZQ.cjs.map} +1 -1
- package/dist/{logs-C5L6gRGr.js → logs-Dg2AWexF.js} +2 -2
- package/dist/{logs-C5L6gRGr.js.map → logs-Dg2AWexF.js.map} +1 -1
- package/dist/{mcp-CKvOVfHn.cjs → mcp-Bon4eIV1.cjs} +2 -2
- package/dist/{mcp-CKvOVfHn.cjs.map → mcp-Bon4eIV1.cjs.map} +1 -1
- package/dist/{mcp-CntC59iU.js → mcp-bsPRIGFX.js} +2 -2
- package/dist/{mcp-CntC59iU.js.map → mcp-bsPRIGFX.js.map} +1 -1
- package/dist/{memory-DIos0BE-.cjs → memory-BRE3ofvI.cjs} +109 -45
- package/dist/memory-BRE3ofvI.cjs.map +1 -0
- package/dist/{memory-JzgWJevA.js → memory-Dw7xG5nn.js} +109 -45
- package/dist/memory-Dw7xG5nn.js.map +1 -0
- package/dist/{observability-BCTkIhJT.js → observability-BYIy4kPf.js} +5 -3
- package/dist/{observability-BCTkIhJT.js.map → observability-BYIy4kPf.js.map} +1 -1
- package/dist/{observability-mnHHbnoc.cjs → observability-DHJ7mzoE.cjs} +5 -3
- package/dist/{observability-mnHHbnoc.cjs.map → observability-DHJ7mzoE.cjs.map} +1 -1
- package/dist/{observability-new-endpoints-B6fo20v5.cjs → observability-new-endpoints-BOe3wej1.cjs} +229 -99
- package/dist/observability-new-endpoints-BOe3wej1.cjs.map +1 -0
- package/dist/{observability-new-endpoints-DHn8uKyr.js → observability-new-endpoints-COy7lpeR.js} +136 -18
- package/dist/observability-new-endpoints-COy7lpeR.js.map +1 -0
- package/dist/{plans-9hdkc-t8.js → plans-D_GKFz2x.js} +4 -4
- package/dist/{plans-9hdkc-t8.js.map → plans-D_GKFz2x.js.map} +1 -1
- package/dist/{plans-DMs8SVBG.cjs → plans-_nR8lqgD.cjs} +4 -4
- package/dist/{plans-DMs8SVBG.cjs.map → plans-_nR8lqgD.cjs.map} +1 -1
- package/dist/{probe-image-size-Cxm5QtwO.js → probe-image-size-C2b8QfA7.js} +2 -2
- package/dist/{probe-image-size-Cxm5QtwO.js.map → probe-image-size-C2b8QfA7.js.map} +1 -1
- package/dist/{probe-image-size-bDuzMW0E.cjs → probe-image-size-DLuC8QsM.cjs} +2 -2
- package/dist/{probe-image-size-bDuzMW0E.cjs.map → probe-image-size-DLuC8QsM.cjs.map} +1 -1
- package/dist/{responses-B5_syoSo.js → responses-C_OEJoxU.js} +3 -3
- package/dist/{responses-B5_syoSo.js.map → responses-C_OEJoxU.js.map} +1 -1
- package/dist/{responses-CNKJoC5a.cjs → responses-CdWbS4jA.cjs} +3 -3
- package/dist/{responses-CNKJoC5a.cjs.map → responses-CdWbS4jA.cjs.map} +1 -1
- package/dist/{route-builder-DHqDrSSy.cjs → route-builder-B9C5vT54.cjs} +4 -4
- package/dist/{route-builder-DHqDrSSy.cjs.map → route-builder-B9C5vT54.cjs.map} +1 -1
- package/dist/{route-builder-BKEzjw_M.js → route-builder-DfDT1g4L.js} +2 -2
- package/dist/{route-builder-BKEzjw_M.js.map → route-builder-DfDT1g4L.js.map} +1 -1
- package/dist/{routes-C0pgNcG-.js → routes-BR7W0b_u.js} +28 -26
- package/dist/routes-BR7W0b_u.js.map +1 -0
- package/dist/{routes-BYQ38dFx.cjs → routes-Brf5Qfbu.cjs} +28 -26
- package/dist/routes-Brf5Qfbu.cjs.map +1 -0
- package/dist/{schedules-CvWX2yKR.cjs → schedules-BQvnAe1j.cjs} +50 -12
- package/dist/schedules-BQvnAe1j.cjs.map +1 -0
- package/dist/{schedules-D9CKB18-.js → schedules-BcAIELfB.js} +50 -12
- package/dist/schedules-BcAIELfB.js.map +1 -0
- package/dist/{schema-Bf12g7KC-5EUrrnSf.js → schema-xsUy1mlm-CAPin6jE.js} +303 -6
- package/dist/{schema-Bf12g7KC-5EUrrnSf.js.map → schema-xsUy1mlm-CAPin6jE.js.map} +1 -1
- package/dist/{schema-Bf12g7KC-C5XzpQxe.cjs → schema-xsUy1mlm-pvZI8YC0.cjs} +303 -6
- package/dist/{schema-Bf12g7KC-C5XzpQxe.cjs.map → schema-xsUy1mlm-pvZI8YC0.cjs.map} +1 -1
- package/dist/{scorer-versions-vQVWyYWA.cjs → scorer-versions-Bhdvt-cX.cjs} +2 -2
- package/dist/{scorer-versions-vQVWyYWA.cjs.map → scorer-versions-Bhdvt-cX.cjs.map} +1 -1
- package/dist/{scorer-versions-BZ58s09W.js → scorer-versions-DhT7Lj33.js} +2 -2
- package/dist/{scorer-versions-BZ58s09W.js.map → scorer-versions-DhT7Lj33.js.map} +1 -1
- package/dist/{scores-Dxa8dDfV.cjs → scores-DEvPN0kz.cjs} +3 -3
- package/dist/{scores-Dxa8dDfV.cjs.map → scores-DEvPN0kz.cjs.map} +1 -1
- package/dist/{scores-B3mS6vqB.js → scores-Dm0yu1Pt.js} +3 -3
- package/dist/{scores-B3mS6vqB.js.map → scores-Dm0yu1Pt.js.map} +1 -1
- package/dist/server/auth/custom-route-matcher.d.ts +54 -0
- package/dist/server/auth/custom-route-matcher.d.ts.map +1 -0
- package/dist/server/auth/helpers.d.ts +14 -5
- package/dist/server/auth/helpers.d.ts.map +1 -1
- package/dist/server/auth/index.cjs +1 -1
- package/dist/server/auth/index.js +1 -1
- package/dist/server/auth/path-pattern.d.ts.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 +30 -6
- 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 +30 -6
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/agent-versions.cjs +3 -3
- package/dist/server/handlers/agent-versions.js +3 -3
- 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/auth.cjs +2 -2
- package/dist/server/handlers/auth.js +2 -2
- 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/builder-registry.cjs +1 -1
- package/dist/server/handlers/builder-registry.js +1 -1
- package/dist/server/handlers/channels.cjs +1 -1
- package/dist/server/handlers/channels.js +1 -1
- package/dist/server/handlers/conversations.cjs +1 -1
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/datasets.cjs +30 -8
- package/dist/server/handlers/datasets.cjs.map +1 -1
- package/dist/server/handlers/datasets.d.ts +28 -2
- package/dist/server/handlers/datasets.d.ts.map +1 -1
- package/dist/server/handlers/datasets.js +30 -8
- package/dist/server/handlers/datasets.js.map +1 -1
- package/dist/server/handlers/dynamic-workflows.cjs +1 -1
- package/dist/server/handlers/dynamic-workflows.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 +2 -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 +2 -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/knowledge.cjs +1 -1
- package/dist/server/handlers/knowledge.js +1 -1
- package/dist/server/handlers/logs.cjs +1 -1
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/mcp-client-versions.cjs +2 -2
- package/dist/server/handlers/mcp-client-versions.js +2 -2
- package/dist/server/handlers/mcp.cjs +1 -1
- package/dist/server/handlers/mcp.js +1 -1
- package/dist/server/handlers/memory.cjs +1 -1
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability-export.cjs +66 -0
- package/dist/server/handlers/observability-export.cjs.map +1 -0
- package/dist/server/handlers/observability-export.d.ts +12 -0
- package/dist/server/handlers/observability-export.d.ts.map +1 -0
- package/dist/server/handlers/observability-export.js +62 -0
- package/dist/server/handlers/observability-export.js.map +1 -0
- package/dist/server/handlers/observability-new-endpoints.cjs +3 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +602 -2
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +35 -3
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +23 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +34 -4
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability-signal-context.cjs +69 -2
- package/dist/server/handlers/observability-signal-context.cjs.map +1 -0
- package/dist/server/handlers/observability-signal-context.js +70 -1
- package/dist/server/handlers/observability-signal-context.js.map +1 -0
- package/dist/server/handlers/observability.cjs +4 -2
- package/dist/server/handlers/observability.js +3 -3
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.js +1 -1
- package/dist/server/handlers/processor-providers.cjs +1 -1
- package/dist/server/handlers/processor-providers.js +1 -1
- package/dist/server/handlers/processors.cjs +1 -1
- package/dist/server/handlers/processors.js +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +2 -2
- package/dist/server/handlers/prompt-block-versions.js +2 -2
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.d.ts +11 -11
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/schedules.cjs +1 -1
- package/dist/server/handlers/schedules.d.ts +88 -28
- package/dist/server/handlers/schedules.d.ts.map +1 -1
- package/dist/server/handlers/schedules.js +1 -1
- package/dist/server/handlers/scorer-versions.cjs +3 -3
- package/dist/server/handlers/scorer-versions.js +3 -3
- package/dist/server/handlers/scores.cjs +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +4 -4
- package/dist/server/handlers/stored-agent-favorites.js +4 -4
- package/dist/server/handlers/stored-agents.cjs +6 -5
- package/dist/server/handlers/stored-agents.cjs.map +1 -1
- package/dist/server/handlers/stored-agents.d.ts +2 -6
- package/dist/server/handlers/stored-agents.d.ts.map +1 -1
- package/dist/server/handlers/stored-agents.js +6 -5
- package/dist/server/handlers/stored-agents.js.map +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +2 -2
- package/dist/server/handlers/stored-mcp-clients.js +2 -2
- package/dist/server/handlers/stored-prompt-blocks.cjs +2 -2
- package/dist/server/handlers/stored-prompt-blocks.js +2 -2
- package/dist/server/handlers/stored-scorers.cjs +3 -3
- package/dist/server/handlers/stored-scorers.js +3 -3
- package/dist/server/handlers/stored-skill-favorites.cjs +3 -3
- package/dist/server/handlers/stored-skill-favorites.js +3 -3
- package/dist/server/handlers/stored-skills.cjs +3 -3
- package/dist/server/handlers/stored-skills.js +3 -3
- package/dist/server/handlers/stored-workspaces.cjs +2 -2
- package/dist/server/handlers/stored-workspaces.js +2 -2
- package/dist/server/handlers/system.cjs +3 -3
- package/dist/server/handlers/system.d.ts +10 -0
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +3 -3
- package/dist/server/handlers/tool-providers.cjs +1 -1
- package/dist/server/handlers/tool-providers.js +1 -1
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/validate-agent-instructions.cjs +1 -1
- package/dist/server/handlers/validate-agent-instructions.js +1 -1
- package/dist/server/handlers/vector.cjs +1 -1
- package/dist/server/handlers/vector.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 +1 -1
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers/workspace.cjs +1 -1
- package/dist/server/handlers/workspace.d.ts +23 -23
- package/dist/server/handlers/workspace.js +1 -1
- package/dist/server/handlers.cjs +16 -16
- package/dist/server/handlers.js +16 -16
- package/dist/server/schemas/agents.d.ts.map +1 -1
- package/dist/server/schemas/datasets.d.ts +10 -0
- package/dist/server/schemas/datasets.d.ts.map +1 -1
- package/dist/server/schemas/feedback.d.ts +49 -0
- package/dist/server/schemas/feedback.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +8 -8
- package/dist/server/schemas/index.js +8 -8
- package/dist/server/schemas/schedules.d.ts +26 -8
- package/dist/server/schemas/schedules.d.ts.map +1 -1
- package/dist/server/schemas/stored-agents.d.ts +5 -10
- package/dist/server/schemas/stored-agents.d.ts.map +1 -1
- package/dist/server/schemas/system.d.ts +10 -0
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/server-adapter/api-schema-manifest.d.ts +1 -1
- package/dist/server/server-adapter/index.cjs +167 -7
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +35 -0
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +166 -8
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/openapi-utils.d.ts +1 -1
- package/dist/server/server-adapter/routes/conversations.d.ts +3 -3
- package/dist/server/server-adapter/routes/datasets.d.ts +28 -2
- package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +299 -1
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/system.d.ts +10 -0
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- 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/server/utils/agent-stream-events.d.ts +2 -0
- package/dist/server/utils/agent-stream-events.d.ts.map +1 -1
- package/dist/{observability-signal-context-CL5-rCWM.js → storage-CVkNJ5eB.js} +15 -69
- package/dist/storage-CVkNJ5eB.js.map +1 -0
- package/dist/{observability-signal-context-BYOFtbM_.cjs → storage-mEqRYYDg.cjs} +22 -70
- package/dist/storage-mEqRYYDg.cjs.map +1 -0
- package/dist/{stored-agents-DA8Zx6o9.js → stored-agents-DmN_pIIl.js} +10 -10
- package/dist/stored-agents-DmN_pIIl.js.map +1 -0
- package/dist/{stored-agents-TQ2lIFbx.cjs → stored-agents-m0Knvv29.cjs} +10 -10
- package/dist/stored-agents-m0Knvv29.cjs.map +1 -0
- package/dist/{stored-scorers-DhOq8ZQC.js → stored-scorers-2F2k6XSx.js} +2 -2
- package/dist/{stored-scorers-DhOq8ZQC.js.map → stored-scorers-2F2k6XSx.js.map} +1 -1
- package/dist/{stored-scorers-FJOs5774.cjs → stored-scorers-iM2Qq9Nh.cjs} +2 -2
- package/dist/{stored-scorers-FJOs5774.cjs.map → stored-scorers-iM2Qq9Nh.cjs.map} +1 -1
- package/dist/{system-DT0pqJSk.js → system-DlW760k2.js} +6 -1
- package/dist/system-DlW760k2.js.map +1 -0
- package/dist/{system-eeBLPCu1.cjs → system-zL047vEq.cjs} +6 -1
- package/dist/system-zL047vEq.cjs.map +1 -0
- package/dist/{tools-Ce7SFoT1.js → tools-BJFq9JKF.js} +6 -6
- package/dist/{tools-Ce7SFoT1.js.map → tools-BJFq9JKF.js.map} +1 -1
- package/dist/{tools-C9W7WvyI.cjs → tools-Daot5Zgz.cjs} +7 -7
- package/dist/{tools-C9W7WvyI.cjs.map → tools-Daot5Zgz.cjs.map} +1 -1
- package/dist/{utils-CL-m2SWZ.cjs → utils-DptI_ERr.cjs} +5 -5
- package/dist/{utils-CL-m2SWZ.cjs.map → utils-DptI_ERr.cjs.map} +1 -1
- package/dist/{utils-y-cW3mQU.js → utils-yedETkNk.js} +2 -2
- package/dist/{utils-y-cW3mQU.js.map → utils-yedETkNk.js.map} +1 -1
- package/dist/{vector-BWFSDXvg.js → vector-CZ26vo6u.js} +2 -2
- package/dist/{vector-BWFSDXvg.js.map → vector-CZ26vo6u.js.map} +1 -1
- package/dist/{vector-6k7Ft7EX.cjs → vector-DBe45tnv.cjs} +2 -2
- package/dist/{vector-6k7Ft7EX.cjs.map → vector-DBe45tnv.cjs.map} +1 -1
- package/dist/{workflow-builder-BNk301jl.js → workflow-builder-C5ufahUw.js} +4 -4
- package/dist/{workflow-builder-BNk301jl.js.map → workflow-builder-C5ufahUw.js.map} +1 -1
- package/dist/{workflow-builder-CsOEskDo.cjs → workflow-builder-CkrdTcoM.cjs} +4 -4
- package/dist/{workflow-builder-CsOEskDo.cjs.map → workflow-builder-CkrdTcoM.cjs.map} +1 -1
- package/dist/{workflows-CJz5Eh0B.cjs → workflows-B5uWFrJ1.cjs} +4 -4
- package/dist/{workflows-CJz5Eh0B.cjs.map → workflows-B5uWFrJ1.cjs.map} +1 -1
- package/dist/{workflows-BAFGmHCW.js → workflows-C_Mqj_80.js} +4 -4
- package/dist/{workflows-BAFGmHCW.js.map → workflows-C_Mqj_80.js.map} +1 -1
- package/dist/{workspace-CYwDvH0G.js → workspace-BwlPQO3M.js} +2 -2
- package/dist/{workspace-CYwDvH0G.js.map → workspace-BwlPQO3M.js.map} +1 -1
- package/dist/{workspace-C7PytFzz.cjs → workspace-CD9pQ61P.cjs} +2 -2
- package/dist/{workspace-C7PytFzz.cjs.map → workspace-CD9pQ61P.cjs.map} +1 -1
- package/package.json +6 -7
- package/dist/agents-BI8ez-FT.js.map +0 -1
- package/dist/agents-DsfsDhIT.cjs.map +0 -1
- package/dist/background-tasks-BIuEr2of.js.map +0 -1
- package/dist/background-tasks-BXTIp0QV.cjs.map +0 -1
- package/dist/datasets--F0QkdGX.js.map +0 -1
- package/dist/datasets-BiEAIm0s.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
- package/dist/helpers-B29a1nM3.js.map +0 -1
- package/dist/helpers-CylvUIZm.cjs.map +0 -1
- package/dist/memory-DIos0BE-.cjs.map +0 -1
- package/dist/memory-JzgWJevA.js.map +0 -1
- package/dist/observability-new-endpoints-B6fo20v5.cjs.map +0 -1
- package/dist/observability-new-endpoints-DHn8uKyr.js.map +0 -1
- package/dist/observability-signal-context-BYOFtbM_.cjs.map +0 -1
- package/dist/observability-signal-context-CL5-rCWM.js.map +0 -1
- package/dist/routes-BYQ38dFx.cjs.map +0 -1
- package/dist/routes-C0pgNcG-.js.map +0 -1
- package/dist/schedules-CvWX2yKR.cjs.map +0 -1
- package/dist/schedules-D9CKB18-.js.map +0 -1
- package/dist/stored-agents-DA8Zx6o9.js.map +0 -1
- package/dist/stored-agents-TQ2lIFbx.cjs.map +0 -1
- package/dist/system-DT0pqJSk.js.map +0 -1
- package/dist/system-eeBLPCu1.cjs.map +0 -1
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/_types/@internal_ai-sdk-v4@0.0.95/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/_types/@internal_ai-sdk-v5@0.0.95/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/_types/@internal_ai-v6@0.0.95/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/_types/@standard-schema_spec@1.1.0/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/_types/@types_json-schema@7.0.15/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/null-to-undefined.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/provider-compats/anthropic.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/provider-compats/deepseek.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/provider-compats/google.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/provider-compats/meta.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/provider-compats/openai-reasoning.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/provider-compats/openai.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/schema-compatibility-v3.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/schema-compatibility-v4.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/schema-compatibility.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/schema.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/schema.types.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/standard-schema/standard-schema.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/standard-schema/standard-schema.types.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/standard-schema-compat.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/types.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/utils.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/dist/zod-to-json.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.3.17 → @mastra_schema-compat@1.4.0-alpha.1}/package.json +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-10nMEhjP.cjs");
|
|
2
|
-
const require_utils = require("./utils-
|
|
2
|
+
const require_utils = require("./utils-DptI_ERr.cjs");
|
|
3
3
|
const require_constants = require("./constants-DMg8hUOR.cjs");
|
|
4
|
-
const
|
|
4
|
+
const require_schema_xsUy1mlm = require("./schema-xsUy1mlm-pvZI8YC0.cjs");
|
|
5
5
|
const require_utils$1 = require("./utils-BXEJ6FZC.cjs");
|
|
6
6
|
const require_http_exception = require("./http-exception-Co3MbFUf.cjs");
|
|
7
|
-
const require_agents = require("./agents-
|
|
8
|
-
const require_stored_agents = require("./stored-agents-
|
|
7
|
+
const require_agents = require("./agents-CjcvdF2e.cjs");
|
|
8
|
+
const require_stored_agents = require("./stored-agents-m0Knvv29.cjs");
|
|
9
9
|
const require_workspace = require("./workspace-C5BBUatQ.cjs");
|
|
10
|
-
const require_route_builder = require("./route-builder-
|
|
10
|
+
const require_route_builder = require("./route-builder-B9C5vT54.cjs");
|
|
11
11
|
const require_server_handlers_authorship = require("./server/handlers/authorship.cjs");
|
|
12
12
|
const require_server_handlers_error = require("./server/handlers/error.cjs");
|
|
13
13
|
const require_server_handlers_tool_schema_overrides = require("./server/handlers/tool-schema-overrides.cjs");
|
|
@@ -23,6 +23,7 @@ let _mastra_core_llm = require("@mastra/core/llm");
|
|
|
23
23
|
// src/server/utils/agent-stream-events.ts
|
|
24
24
|
function toAgentStreamChunks(event) {
|
|
25
25
|
const { runId } = event;
|
|
26
|
+
const logIndex = typeof event.index === "number" ? { index: event.index } : void 0;
|
|
26
27
|
const abort = {
|
|
27
28
|
type: "abort",
|
|
28
29
|
runId,
|
|
@@ -30,10 +31,21 @@ function toAgentStreamChunks(event) {
|
|
|
30
31
|
payload: {}
|
|
31
32
|
};
|
|
32
33
|
switch (event.type) {
|
|
33
|
-
case "chunk":
|
|
34
|
+
case "chunk": {
|
|
35
|
+
const { index: _nestedIndex, ...data } = event.data;
|
|
36
|
+
return [{
|
|
37
|
+
...data,
|
|
38
|
+
...logIndex
|
|
39
|
+
}];
|
|
40
|
+
}
|
|
34
41
|
case "step-start": {
|
|
35
42
|
const chunk = event.data;
|
|
36
|
-
|
|
43
|
+
if (!chunk || !("type" in chunk)) return [];
|
|
44
|
+
const { index: _nestedIndex, ...data } = chunk;
|
|
45
|
+
return [{
|
|
46
|
+
...data,
|
|
47
|
+
...logIndex
|
|
48
|
+
}];
|
|
37
49
|
}
|
|
38
50
|
case "finish": {
|
|
39
51
|
const data = event.data;
|
|
@@ -49,6 +61,7 @@ function toAgentStreamChunks(event) {
|
|
|
49
61
|
type: "finish",
|
|
50
62
|
runId,
|
|
51
63
|
from: _mastra_core_stream.ChunkFrom.AGENT,
|
|
64
|
+
...logIndex,
|
|
52
65
|
payload: {
|
|
53
66
|
output: raw === void 0 ? data.output : {
|
|
54
67
|
...data.output,
|
|
@@ -69,6 +82,7 @@ function toAgentStreamChunks(event) {
|
|
|
69
82
|
type: "finish",
|
|
70
83
|
runId,
|
|
71
84
|
from: _mastra_core_stream.ChunkFrom.AGENT,
|
|
85
|
+
...logIndex,
|
|
72
86
|
payload: {
|
|
73
87
|
output: {
|
|
74
88
|
text: data.text,
|
|
@@ -87,10 +101,14 @@ function toAgentStreamChunks(event) {
|
|
|
87
101
|
}
|
|
88
102
|
}];
|
|
89
103
|
}
|
|
90
|
-
case "error":
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
104
|
+
case "error": {
|
|
105
|
+
const data = event.data;
|
|
106
|
+
return [{
|
|
107
|
+
type: "error",
|
|
108
|
+
...logIndex,
|
|
109
|
+
payload: { error: { ...data.error } }
|
|
110
|
+
}];
|
|
111
|
+
}
|
|
94
112
|
default: return [];
|
|
95
113
|
}
|
|
96
114
|
}
|
|
@@ -247,6 +265,12 @@ function hasSuspendedToolCall(snapshot, toolCallId) {
|
|
|
247
265
|
};
|
|
248
266
|
return visit(snapshot.context);
|
|
249
267
|
}
|
|
268
|
+
/** A run-log entry that ends the run. An error *chunk* can precede the finish, so it does not count. */
|
|
269
|
+
const isRunTerminalEvent = (event) => {
|
|
270
|
+
if (event?.type === "error") return true;
|
|
271
|
+
const type = event?.type === "chunk" ? event.data?.type : event?.type;
|
|
272
|
+
return type === "finish" || type === "abort";
|
|
273
|
+
};
|
|
250
274
|
const DURABLE_SNAPSHOT_WAIT_TIMEOUT_MS = 1e4;
|
|
251
275
|
const DURABLE_SNAPSHOT_WAIT_INTERVAL_MS = 25;
|
|
252
276
|
function getDurableLoopWorkflowName(agent) {
|
|
@@ -280,11 +304,12 @@ async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId,
|
|
|
280
304
|
const [persistedResourceId] = persistedResourceIds;
|
|
281
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" });
|
|
282
306
|
const ready = !!workflowRun && !!snapshot && snapshot.status === "suspended" && (toolCallId === void 0 || hasSuspendedToolCall(snapshot, toolCallId));
|
|
283
|
-
|
|
307
|
+
const aborted = !!workflowRun && snapshot?.status === "canceled";
|
|
308
|
+
if (ready || aborted || Date.now() >= deadline || abortSignal?.aborted) {
|
|
284
309
|
if (!workflowRun) throw new require_http_exception.HTTPException(403, { message: "Access denied: durable run belongs to a different resource" });
|
|
285
310
|
const persistedThreadId = input?.state?.threadId ?? input?.messageListState?.memoryInfo?.threadId;
|
|
286
311
|
if (threadId && persistedThreadId !== threadId) throw new require_http_exception.HTTPException(403, { message: "Access denied: durable run belongs to a different thread" });
|
|
287
|
-
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" });
|
|
288
313
|
await require_utils$1.validateRunOwnership({ resourceId: persistedResourceId }, contextResourceId, mastra, requestContext);
|
|
289
314
|
return;
|
|
290
315
|
}
|
|
@@ -299,6 +324,50 @@ async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId,
|
|
|
299
324
|
*/
|
|
300
325
|
const ALIASED_API_KEY_ENV_VAR_PROVIDERS = /* @__PURE__ */ new Set(["google"]);
|
|
301
326
|
/**
|
|
327
|
+
* The shared ownership record of a plain agent run, readable from any server
|
|
328
|
+
* sharing the agent's record cache. Undefined when the run is unknown or
|
|
329
|
+
* expired. Falls back to the owner of a run executing in this process on a
|
|
330
|
+
* core without shared records. A record cache that cannot be read is a 503:
|
|
331
|
+
* the caller is refused, never let through.
|
|
332
|
+
*/
|
|
333
|
+
async function getPlainRunRecord(agent, runId) {
|
|
334
|
+
const resumable = agent;
|
|
335
|
+
if (typeof resumable.__getRunRecord === "function") try {
|
|
336
|
+
return await resumable.__getRunRecord.call(agent, runId);
|
|
337
|
+
} catch {
|
|
338
|
+
throw new require_http_exception.HTTPException(503, { message: "Run ownership is temporarily unavailable" });
|
|
339
|
+
}
|
|
340
|
+
const owner = resumable.__getPublishedRunOwner?.call(agent, runId);
|
|
341
|
+
return owner ? {
|
|
342
|
+
...owner,
|
|
343
|
+
status: "running"
|
|
344
|
+
} : void 0;
|
|
345
|
+
}
|
|
346
|
+
/** The caller must own the run and have `permission` on its thread. */
|
|
347
|
+
async function authorizeRunOwner({ mastra, agent, owner, requestContext, permission }) {
|
|
348
|
+
await require_utils$1.validateRunOwnership(owner, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
349
|
+
if (!owner.threadId) return;
|
|
350
|
+
const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId: owner.threadId });
|
|
351
|
+
await require_utils$1.enforceThreadAccess({
|
|
352
|
+
mastra,
|
|
353
|
+
requestContext,
|
|
354
|
+
threadId: owner.threadId,
|
|
355
|
+
thread,
|
|
356
|
+
effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
|
|
357
|
+
permission
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
/** Whether the agent publishes its runs, so a closed HTTP reader can detach instead of aborting. */
|
|
361
|
+
function hasResumableStreams(agent) {
|
|
362
|
+
if ((0, _mastra_core_agent.isDurableAgentLike)(agent)) return true;
|
|
363
|
+
const resumable = agent;
|
|
364
|
+
return typeof resumable.hasResumableStreams === "function" && resumable.hasResumableStreams();
|
|
365
|
+
}
|
|
366
|
+
/** The bus a plain Agent with resumable streams publishes its runs on. */
|
|
367
|
+
function getAgentStreamPubSub(agent) {
|
|
368
|
+
return agent.__getStreamBus?.()?.pubsub;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
302
371
|
* Checks if a provider has its required API key environment variable(s) configured.
|
|
303
372
|
* Handles provider IDs with suffixes (e.g., "openai.chat" -> "openai").
|
|
304
373
|
* Also handles custom gateway providers that are stored with gateway prefix (e.g., "acme/acme-openai").
|
|
@@ -336,7 +405,7 @@ function resolveLazySchema(schema) {
|
|
|
336
405
|
}
|
|
337
406
|
function schemaToJsonSchema(schema) {
|
|
338
407
|
if (!schema) return;
|
|
339
|
-
return
|
|
408
|
+
return require_schema_xsUy1mlm.standardSchemaToJSONSchema(require_schema_xsUy1mlm.toStandardSchema(schema), { target: "draft-2020-12" });
|
|
340
409
|
}
|
|
341
410
|
function getAgentModelRef(agentModel, llm) {
|
|
342
411
|
if (typeof agentModel === "string") {
|
|
@@ -1432,8 +1501,8 @@ const STREAM_GENERATE_ROUTE = require_route_builder.createRoute({
|
|
|
1432
1501
|
...restOptions,
|
|
1433
1502
|
requestContext: serverRequestContext,
|
|
1434
1503
|
memory: authorizedMemoryOption,
|
|
1435
|
-
abortSignal: (
|
|
1436
|
-
_detachObserverOnCancel: (
|
|
1504
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
1505
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
1437
1506
|
};
|
|
1438
1507
|
if (untilIdle) options.untilIdle = untilIdle;
|
|
1439
1508
|
return (structuredOutput ? await agent.stream(messages, {
|
|
@@ -1690,6 +1759,116 @@ const QUEUE_AGENT_SIGNAL_ROUTE = require_route_builder.createRoute({
|
|
|
1690
1759
|
}
|
|
1691
1760
|
}
|
|
1692
1761
|
});
|
|
1762
|
+
/**
|
|
1763
|
+
* Authorizes a request against a durable run through its workflow rows: the
|
|
1764
|
+
* caller must own the run, the run must belong to `agent`, and the caller must
|
|
1765
|
+
* have `permission` on its thread. Throws 403 when access is denied.
|
|
1766
|
+
* Returns 'missing' when no row exists and 'unverified' when the run has not
|
|
1767
|
+
* checkpointed its input yet, so ownership cannot be confirmed.
|
|
1768
|
+
*/
|
|
1769
|
+
async function authorizeDurableRun({ mastra, agent, runId, requestContext, permission }) {
|
|
1770
|
+
const workflows = await mastra.getStorage()?.getStore("workflows");
|
|
1771
|
+
const run = await workflows?.getWorkflowRunById({
|
|
1772
|
+
workflowName: getDurableLoopWorkflowName(agent),
|
|
1773
|
+
runId
|
|
1774
|
+
});
|
|
1775
|
+
if (!run) return "missing";
|
|
1776
|
+
await require_utils$1.validateRunOwnership(run, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
1777
|
+
const ownershipSchema = zod_v4.z.object({ context: zod_v4.z.object({ input: zod_v4.z.object({
|
|
1778
|
+
agentId: zod_v4.z.string(),
|
|
1779
|
+
state: zod_v4.z.object({ threadId: zod_v4.z.string().optional() }).optional()
|
|
1780
|
+
}) }) });
|
|
1781
|
+
let parsed = ownershipSchema.safeParse(typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot);
|
|
1782
|
+
if (!parsed.success) {
|
|
1783
|
+
const execution = await workflows?.getWorkflowRunById({
|
|
1784
|
+
workflowName: getDurableLoopWorkflowName(agent).replace(_mastra_core_agent_durable.DurableStepIds.AGENTIC_LOOP, _mastra_core_agent_durable.DurableStepIds.AGENTIC_EXECUTION),
|
|
1785
|
+
runId
|
|
1786
|
+
});
|
|
1787
|
+
await require_utils$1.validateRunOwnership(execution, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
1788
|
+
parsed = ownershipSchema.safeParse(typeof execution?.snapshot === "string" ? JSON.parse(execution.snapshot) : execution?.snapshot);
|
|
1789
|
+
}
|
|
1790
|
+
if (!parsed.success) return "unverified";
|
|
1791
|
+
if (parsed.data.context.input.agentId !== agent.id) throw new require_http_exception.HTTPException(403, { message: "Access denied: run does not belong to this agent" });
|
|
1792
|
+
const threadId = parsed.data.context.input.state?.threadId;
|
|
1793
|
+
if (threadId) {
|
|
1794
|
+
const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId });
|
|
1795
|
+
await require_utils$1.enforceThreadAccess({
|
|
1796
|
+
mastra,
|
|
1797
|
+
requestContext,
|
|
1798
|
+
threadId,
|
|
1799
|
+
thread,
|
|
1800
|
+
effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
|
|
1801
|
+
permission
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
return "ok";
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
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.
|
|
1819
|
+
*/
|
|
1820
|
+
async function authorizeRunAccess({ mastra, agent, runId, requestContext, permission }) {
|
|
1821
|
+
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
|
|
1822
|
+
const record = await getPlainRunRecord(agent, runId);
|
|
1823
|
+
if (!record) return void 0;
|
|
1824
|
+
await authorizeRunOwner({
|
|
1825
|
+
mastra,
|
|
1826
|
+
agent,
|
|
1827
|
+
owner: record,
|
|
1828
|
+
requestContext,
|
|
1829
|
+
permission
|
|
1830
|
+
});
|
|
1831
|
+
return record;
|
|
1832
|
+
}
|
|
1833
|
+
const getOwner = agent.__getRunOwner;
|
|
1834
|
+
const owner = permission === require_utils$1.MastraFGAPermissions.MEMORY_READ && typeof getOwner === "function" ? getOwner.call(agent, runId) : void 0;
|
|
1835
|
+
if (owner) {
|
|
1836
|
+
await authorizeRunOwner({
|
|
1837
|
+
mastra,
|
|
1838
|
+
agent,
|
|
1839
|
+
owner,
|
|
1840
|
+
requestContext,
|
|
1841
|
+
permission
|
|
1842
|
+
});
|
|
1843
|
+
return {};
|
|
1844
|
+
}
|
|
1845
|
+
const access = await authorizeDurableRun({
|
|
1846
|
+
mastra,
|
|
1847
|
+
agent,
|
|
1848
|
+
runId,
|
|
1849
|
+
requestContext,
|
|
1850
|
+
permission
|
|
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 {};
|
|
1871
|
+
}
|
|
1693
1872
|
const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
1694
1873
|
method: "POST",
|
|
1695
1874
|
path: "/agents/:agentId/runs/:runId/abort",
|
|
@@ -1697,7 +1876,7 @@ const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
1697
1876
|
pathParamSchema: require_agents.agentRunPathParams,
|
|
1698
1877
|
responseSchema: require_agents.abortAgentThreadResponseSchema,
|
|
1699
1878
|
summary: "Abort an agent run",
|
|
1700
|
-
description: "Explicitly stop a durable run, including runs without a memory thread",
|
|
1879
|
+
description: "Explicitly stop a durable run or a run of an agent with resumable streams, including runs without a memory thread",
|
|
1701
1880
|
tags: ["Agents"],
|
|
1702
1881
|
requiresAuth: true,
|
|
1703
1882
|
requiresPermission: require_utils$1.MastraFGAPermissions.AGENTS_EXECUTE,
|
|
@@ -1708,41 +1887,25 @@ const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
1708
1887
|
agentId,
|
|
1709
1888
|
requestContext
|
|
1710
1889
|
});
|
|
1711
|
-
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent))
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
workflowName: getDurableLoopWorkflowName(agent),
|
|
1715
|
-
runId
|
|
1716
|
-
});
|
|
1717
|
-
if (!run) return { aborted: false };
|
|
1718
|
-
await require_utils$1.validateRunOwnership(run, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
1719
|
-
const ownershipSchema = zod_v4.z.object({ context: zod_v4.z.object({ input: zod_v4.z.object({
|
|
1720
|
-
agentId: zod_v4.z.string(),
|
|
1721
|
-
state: zod_v4.z.object({ threadId: zod_v4.z.string().optional() }).optional()
|
|
1722
|
-
}) }) });
|
|
1723
|
-
let parsed = ownershipSchema.safeParse(typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot);
|
|
1724
|
-
if (!parsed.success) {
|
|
1725
|
-
const execution = await workflows?.getWorkflowRunById({
|
|
1726
|
-
workflowName: getDurableLoopWorkflowName(agent).replace(_mastra_core_agent_durable.DurableStepIds.AGENTIC_LOOP, _mastra_core_agent_durable.DurableStepIds.AGENTIC_EXECUTION),
|
|
1727
|
-
runId
|
|
1728
|
-
});
|
|
1729
|
-
await require_utils$1.validateRunOwnership(execution, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
1730
|
-
parsed = ownershipSchema.safeParse(typeof execution?.snapshot === "string" ? JSON.parse(execution.snapshot) : execution?.snapshot);
|
|
1890
|
+
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
|
|
1891
|
+
const resumable = agent;
|
|
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" });
|
|
1731
1893
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
}
|
|
1894
|
+
const run = await authorizeRunAccess({
|
|
1895
|
+
mastra,
|
|
1896
|
+
agent,
|
|
1897
|
+
runId,
|
|
1898
|
+
requestContext,
|
|
1899
|
+
permission: require_utils$1.MastraFGAPermissions.MEMORY_WRITE
|
|
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) };
|
|
1745
1907
|
}
|
|
1908
|
+
if (!run) return { aborted: false };
|
|
1746
1909
|
if (typeof agent.__abortRunAcknowledged === "function") return { aborted: await agent.__abortRunAcknowledged(runId) };
|
|
1747
1910
|
return { aborted: await agent.abortRunStream(runId) };
|
|
1748
1911
|
} catch (error) {
|
|
@@ -2005,8 +2168,8 @@ const STREAM_UNTIL_IDLE_GENERATE_ROUTE = require_route_builder.createRoute({
|
|
|
2005
2168
|
context: restOptions.context,
|
|
2006
2169
|
requestContext: serverRequestContext,
|
|
2007
2170
|
memory: authorizedMemoryOption,
|
|
2008
|
-
abortSignal: (
|
|
2009
|
-
_detachObserverOnCancel: (
|
|
2171
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2172
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2010
2173
|
};
|
|
2011
2174
|
return (structuredOutput ? await agent.streamUntilIdle(messages, {
|
|
2012
2175
|
...options,
|
|
@@ -2040,24 +2203,44 @@ const OBSERVE_AGENT_STREAM_ROUTE = require_route_builder.createRoute({
|
|
|
2040
2203
|
bodySchema: require_agents.observeAgentBodySchema,
|
|
2041
2204
|
responseSchema: require_agents.observeAgentResponseSchema,
|
|
2042
2205
|
summary: "Observe agent stream",
|
|
2043
|
-
description: "Reconnect to an existing agent stream to receive missed events.
|
|
2206
|
+
description: "Reconnect to an existing agent stream to receive missed events. Every frame except abort carries the run-log `index` it came from; pass `offset` as the index + 1 of the last frame that has one to resume without repeating indexed frames. Frames whose replay-cache write failed, or all frames when caching is off, carry no index, so no offset can resume at them; omitting `offset` replays whatever the transport itself retains, which can repeat frames already received.",
|
|
2044
2207
|
tags: ["Agents", "Streaming"],
|
|
2045
2208
|
requiresAuth: true,
|
|
2046
|
-
handler: async ({ mastra, agentId, runId, offset, abortSignal }) => {
|
|
2209
|
+
handler: async ({ mastra, agentId, runId, offset, abortSignal, requestContext }) => {
|
|
2047
2210
|
try {
|
|
2048
2211
|
const agent = await getAgentFromSystem({
|
|
2049
2212
|
mastra,
|
|
2050
|
-
agentId
|
|
2213
|
+
agentId,
|
|
2214
|
+
requestContext
|
|
2051
2215
|
});
|
|
2216
|
+
if (!await authorizeRunAccess({
|
|
2217
|
+
mastra,
|
|
2218
|
+
agent,
|
|
2219
|
+
runId,
|
|
2220
|
+
requestContext,
|
|
2221
|
+
permission: require_utils$1.MastraFGAPermissions.MEMORY_READ
|
|
2222
|
+
})) throw new require_http_exception.HTTPException(404, { message: "Run not found" });
|
|
2052
2223
|
const durableAgent = (0, _mastra_core_agent.isDurableAgentLike)(agent) ? agent : void 0;
|
|
2053
|
-
const pubsub = durableAgent?.pubsub ?? mastra.pubsub;
|
|
2224
|
+
const pubsub = durableAgent?.pubsub ?? getAgentStreamPubSub(agent) ?? mastra.pubsub;
|
|
2054
2225
|
const topic = (0, _mastra_core_agent_durable.AGENT_STREAM_TOPIC)(runId);
|
|
2055
2226
|
const subscribe = (onEvent, onComplete) => {
|
|
2056
2227
|
if (typeof durableAgent?.__subscribeToRunStream === "function") return durableAgent.__subscribeToRunStream(runId, {
|
|
2057
2228
|
offset,
|
|
2058
2229
|
onComplete
|
|
2059
2230
|
}, onEvent);
|
|
2060
|
-
|
|
2231
|
+
if (offset === void 0) return pubsub.subscribeWithReplay(topic, onEvent).then(() => () => pubsub.unsubscribe(topic, onEvent));
|
|
2232
|
+
return pubsub.subscribeFromOffset(topic, offset, onEvent).then(() => {
|
|
2233
|
+
if (offset > 0) {
|
|
2234
|
+
const readTail = async () => {
|
|
2235
|
+
const window = await pubsub.getHistory(topic, offset - 1);
|
|
2236
|
+
return window.length > 0 ? window.at(-1) : (await pubsub.getHistory(topic, 0)).at(-1);
|
|
2237
|
+
};
|
|
2238
|
+
readTail().catch(() => void 0).then((last) => {
|
|
2239
|
+
if (typeof last?.index === "number" && last.index < offset && isRunTerminalEvent(last)) onComplete();
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
return () => pubsub.unsubscribe(topic, onEvent);
|
|
2243
|
+
});
|
|
2061
2244
|
};
|
|
2062
2245
|
let closed = false;
|
|
2063
2246
|
let pendingRejection;
|
|
@@ -2186,8 +2369,8 @@ const APPROVE_TOOL_CALL_ROUTE = require_route_builder.createRoute({
|
|
|
2186
2369
|
return (await agent.approveToolCall({
|
|
2187
2370
|
...params,
|
|
2188
2371
|
requestContext,
|
|
2189
|
-
abortSignal: (
|
|
2190
|
-
_detachObserverOnCancel: (
|
|
2372
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2373
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2191
2374
|
})).fullStream;
|
|
2192
2375
|
} catch (error) {
|
|
2193
2376
|
return require_server_handlers_error.handleError(error, "error approving tool call");
|
|
@@ -2343,8 +2526,8 @@ const DECLINE_TOOL_CALL_ROUTE = require_route_builder.createRoute({
|
|
|
2343
2526
|
return (await agent.declineToolCall({
|
|
2344
2527
|
...params,
|
|
2345
2528
|
requestContext,
|
|
2346
|
-
abortSignal: (
|
|
2347
|
-
_detachObserverOnCancel: (
|
|
2529
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2530
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2348
2531
|
})).fullStream;
|
|
2349
2532
|
} catch (error) {
|
|
2350
2533
|
return require_server_handlers_error.handleError(error, "error declining tool call");
|
|
@@ -2428,8 +2611,8 @@ const RESUME_STREAM_ROUTE = require_route_builder.createRoute({
|
|
|
2428
2611
|
...restOptions,
|
|
2429
2612
|
requestContext: serverRequestContext,
|
|
2430
2613
|
memory: authorizedMemoryOption,
|
|
2431
|
-
abortSignal: (
|
|
2432
|
-
_detachObserverOnCancel: (
|
|
2614
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2615
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2433
2616
|
};
|
|
2434
2617
|
if (untilIdle) options.untilIdle = untilIdle;
|
|
2435
2618
|
return (structuredOutput ? await agent.resumeStream(resumeData, {
|
|
@@ -2558,8 +2741,8 @@ const RESUME_STREAM_UNTIL_IDLE_ROUTE = require_route_builder.createRoute({
|
|
|
2558
2741
|
context: restOptions.context,
|
|
2559
2742
|
requestContext: serverRequestContext,
|
|
2560
2743
|
memory: authorizedMemoryOption,
|
|
2561
|
-
abortSignal: (
|
|
2562
|
-
_detachObserverOnCancel: (
|
|
2744
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2745
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2563
2746
|
};
|
|
2564
2747
|
return (structuredOutput ? await agent.resumeStreamUntilIdle(resumeData, {
|
|
2565
2748
|
...options,
|
|
@@ -3381,4 +3564,4 @@ Object.defineProperty(exports, "isProviderConnected", {
|
|
|
3381
3564
|
}
|
|
3382
3565
|
});
|
|
3383
3566
|
|
|
3384
|
-
//# sourceMappingURL=agents-
|
|
3567
|
+
//# sourceMappingURL=agents-DjpBmwhv.cjs.map
|