@mastra/server 1.82.0 → 1.83.0-alpha.1
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/_types/@internal_core@0.1.4/dist/storage/index.d.ts +24 -2
- package/dist/_types/@mastra_schema-compat@1.3.17/dist/_types/@internal_ai-v6@0.0.95/dist/index.d.ts +96 -15
- package/dist/{a2a-CoiG3TAj.js → a2a-CQlJ-SZr.js} +4 -4
- package/dist/{a2a-CoiG3TAj.js.map → a2a-CQlJ-SZr.js.map} +1 -1
- package/dist/{a2a-DvqRdny6.cjs → a2a-mDspNbWX.cjs} +4 -4
- package/dist/{a2a-DvqRdny6.cjs.map → a2a-mDspNbWX.cjs.map} +1 -1
- package/dist/{agent-builder-D0Up9Fw1.cjs → agent-builder-B9gEkbch.cjs} +8 -8
- package/dist/{agent-builder-D0Up9Fw1.cjs.map → agent-builder-B9gEkbch.cjs.map} +1 -1
- package/dist/{agent-builder-C_L1i2eE.js → agent-builder-BF7OAl_R.js} +8 -8
- package/dist/{agent-builder-C_L1i2eE.js.map → agent-builder-BF7OAl_R.js.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-DOHGWXDa.cjs → agents-CMEeZr5y.cjs} +223 -63
- package/dist/agents-CMEeZr5y.cjs.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-CgcW6lHt.js → agents-DXlVewzD.js} +223 -63
- package/dist/agents-DXlVewzD.js.map +1 -0
- package/dist/{api-schema-manifest-DCHOlOuJ.cjs → api-schema-manifest-BKnghL_k.cjs} +3 -3
- package/dist/{api-schema-manifest-DCHOlOuJ.cjs.map → api-schema-manifest-BKnghL_k.cjs.map} +1 -1
- package/dist/{api-schema-manifest-Ci2qUYHc.js → api-schema-manifest-DOuSq4rG.js} +3 -3
- package/dist/{api-schema-manifest-Ci2qUYHc.js.map → api-schema-manifest-DOuSq4rG.js.map} +1 -1
- package/dist/{background-tasks-BHhn4YZA.js → background-tasks-BIuEr2of.js} +3 -3
- package/dist/{background-tasks-BHhn4YZA.js.map → background-tasks-BIuEr2of.js.map} +1 -1
- package/dist/{background-tasks-Ci2tlxJC.cjs → background-tasks-BXTIp0QV.cjs} +3 -3
- package/dist/{background-tasks-Ci2tlxJC.cjs.map → background-tasks-BXTIp0QV.cjs.map} +1 -1
- package/dist/{builder-registry-m_gHCe12.js → builder-registry-Dd7pbJ5A.js} +4 -4
- package/dist/{builder-registry-m_gHCe12.js.map → builder-registry-Dd7pbJ5A.js.map} +1 -1
- package/dist/{builder-registry-D1_hGKCJ.cjs → builder-registry-DrBUA6EZ.cjs} +4 -4
- package/dist/{builder-registry-D1_hGKCJ.cjs.map → builder-registry-DrBUA6EZ.cjs.map} +1 -1
- package/dist/{channels-hhQ3vD30.js → channels-B6hwVMbV.js} +4 -4
- package/dist/{channels-hhQ3vD30.js.map → channels-B6hwVMbV.js.map} +1 -1
- package/dist/{channels-Bfkp5vYI.cjs → channels-DbfSH5O2.cjs} +4 -4
- package/dist/{channels-Bfkp5vYI.cjs.map → channels-DbfSH5O2.cjs.map} +1 -1
- package/dist/{conversations-Ch_VuVwY.cjs → conversations-CFj4BnNb.cjs} +5 -5
- package/dist/{conversations-Ch_VuVwY.cjs.map → conversations-CFj4BnNb.cjs.map} +1 -1
- package/dist/{conversations-xS7yHuG1.js → conversations-DjTKtaUi.js} +5 -5
- package/dist/{conversations-xS7yHuG1.js.map → conversations-DjTKtaUi.js.map} +1 -1
- package/dist/{dist-BKNKucT9.cjs → dist-Ctfk9X6u.cjs} +208 -247
- package/dist/dist-Ctfk9X6u.cjs.map +1 -0
- package/dist/dist-DJjVMQiv.js +1 -0
- package/dist/{dist-CIYZuix4.js → dist-OKFDPspq.js} +208 -247
- package/dist/dist-OKFDPspq.js.map +1 -0
- package/dist/{dist-DgKeISkr.cjs → dist-ZYvqJK9p.cjs} +1 -1
- package/dist/docs/SKILL.md +5 -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-knowledge-overview.md +106 -0
- package/dist/docs/references/docs-server-custom-adapters.md +4 -0
- package/dist/docs/references/docs-server-server-adapters.md +679 -0
- package/dist/docs/references/docs-studio-knowledge.md +45 -24
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +47 -58
- package/dist/docs/references/reference-server-invoke-route.md +86 -0
- package/dist/docs/references/reference-server-routes.md +63 -0
- package/dist/{dynamic-workflows-DDauBnDt.js → dynamic-workflows-CyaZLmHX.js} +2 -2
- package/dist/{dynamic-workflows-DDauBnDt.js.map → dynamic-workflows-CyaZLmHX.js.map} +1 -1
- package/dist/{dynamic-workflows-CpCkqM1g.cjs → dynamic-workflows-ZmzWJXxG.cjs} +2 -2
- package/dist/{dynamic-workflows-CpCkqM1g.cjs.map → dynamic-workflows-ZmzWJXxG.cjs.map} +1 -1
- package/dist/{editor-builder-CKfy5eZY.cjs → editor-builder-CBBZxQhO.cjs} +4 -4
- package/dist/{editor-builder-CKfy5eZY.cjs.map → editor-builder-CBBZxQhO.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-Ceen28s8.js → editor-builder-o9xJHa96.js} +4 -4
- package/dist/{editor-builder-Ceen28s8.js.map → editor-builder-o9xJHa96.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-DNq3LtLq.js → helpers-B29a1nM3.js} +51 -48
- package/dist/helpers-B29a1nM3.js.map +1 -0
- package/dist/{helpers-BKtUXhz2.cjs → helpers-CylvUIZm.cjs} +56 -47
- package/dist/helpers-CylvUIZm.cjs.map +1 -0
- package/dist/{knowledge-Ba74qr0v.js → knowledge-Cd2cCq-Y.js} +4 -4
- package/dist/{knowledge-Ba74qr0v.js.map → knowledge-Cd2cCq-Y.js.map} +1 -1
- package/dist/{knowledge-urR7FFG8.cjs → knowledge-Q_SCnD9m.cjs} +4 -4
- package/dist/{knowledge-urR7FFG8.cjs.map → knowledge-Q_SCnD9m.cjs.map} +1 -1
- package/dist/{logs-B57_NKDn.js → logs-C5L6gRGr.js} +4 -4
- package/dist/{logs-B57_NKDn.js.map → logs-C5L6gRGr.js.map} +1 -1
- package/dist/{logs-BJN3M88A.cjs → logs-DWIbFIw6.cjs} +4 -4
- package/dist/{logs-BJN3M88A.cjs.map → logs-DWIbFIw6.cjs.map} +1 -1
- package/dist/{mcp-B9BILfJP.cjs → mcp-CKvOVfHn.cjs} +3 -3
- package/dist/{mcp-B9BILfJP.cjs.map → mcp-CKvOVfHn.cjs.map} +1 -1
- package/dist/{mcp-BkmWZD6M.js → mcp-CntC59iU.js} +3 -3
- package/dist/{mcp-BkmWZD6M.js.map → mcp-CntC59iU.js.map} +1 -1
- package/dist/{memory-Dqod_AK9.cjs → memory-DIos0BE-.cjs} +57 -15
- package/dist/{memory-Dqod_AK9.cjs.map → memory-DIos0BE-.cjs.map} +1 -1
- package/dist/{memory-ipOCmg0C.js → memory-JzgWJevA.js} +57 -15
- package/dist/{memory-ipOCmg0C.js.map → memory-JzgWJevA.js.map} +1 -1
- package/dist/{observability-BtdW6mjq.cjs → observability-BB0DeGo4.cjs} +4 -3
- package/dist/{observability-BtdW6mjq.cjs.map → observability-BB0DeGo4.cjs.map} +1 -1
- package/dist/{observability-DBtyAJnb.js → observability-Cl3qZKTD.js} +4 -3
- package/dist/{observability-DBtyAJnb.js.map → observability-Cl3qZKTD.js.map} +1 -1
- package/dist/{observability-new-endpoints-jjCgXuTF.cjs → observability-new-endpoints-DugFsWBU.cjs} +154 -956
- package/dist/observability-new-endpoints-DugFsWBU.cjs.map +1 -0
- package/dist/{observability-new-endpoints-Di7m_-xc.js → observability-new-endpoints-qE2NutZ1.js} +72 -880
- package/dist/observability-new-endpoints-qE2NutZ1.js.map +1 -0
- package/dist/observability-signal-context-BYOFtbM_.cjs +1317 -0
- package/dist/observability-signal-context-BYOFtbM_.cjs.map +1 -0
- package/dist/observability-signal-context-CL5-rCWM.js +952 -0
- package/dist/observability-signal-context-CL5-rCWM.js.map +1 -0
- package/dist/{plans-Djcp3C0d.cjs → plans-CQijj_Am.cjs} +5 -5
- package/dist/{plans-Djcp3C0d.cjs.map → plans-CQijj_Am.cjs.map} +1 -1
- package/dist/{plans-nHOnlGzr.js → plans-DVx9N2re.js} +5 -5
- package/dist/{plans-nHOnlGzr.js.map → plans-DVx9N2re.js.map} +1 -1
- package/dist/{probe-image-size-DGTRKrgq.js → probe-image-size-Cxm5QtwO.js} +2 -2
- package/dist/{probe-image-size-DGTRKrgq.js.map → probe-image-size-Cxm5QtwO.js.map} +1 -1
- package/dist/{probe-image-size-BAwk1h6w.cjs → probe-image-size-bDuzMW0E.cjs} +2 -2
- package/dist/{probe-image-size-BAwk1h6w.cjs.map → probe-image-size-bDuzMW0E.cjs.map} +1 -1
- package/dist/{responses-BdOStKtX.cjs → responses-DYGS0aiI.cjs} +5 -5
- package/dist/{responses-BdOStKtX.cjs.map → responses-DYGS0aiI.cjs.map} +1 -1
- package/dist/{responses-CEet9y8G.js → responses-NM-kLq8b.js} +5 -5
- package/dist/{responses-CEet9y8G.js.map → responses-NM-kLq8b.js.map} +1 -1
- package/dist/{route-builder-BxPrwNog.js → route-builder-BKEzjw_M.js} +2 -2
- package/dist/{route-builder-BxPrwNog.js.map → route-builder-BKEzjw_M.js.map} +1 -1
- package/dist/{route-builder-CvARmqnA.cjs → route-builder-DHqDrSSy.cjs} +2 -2
- package/dist/{route-builder-CvARmqnA.cjs.map → route-builder-DHqDrSSy.cjs.map} +1 -1
- package/dist/{routes-5FpkkzND.js → routes-B2XGdvlv.js} +33 -32
- package/dist/routes-B2XGdvlv.js.map +1 -0
- package/dist/{routes-DU_FlwJP.cjs → routes-CWrdLnBc.cjs} +33 -32
- package/dist/routes-CWrdLnBc.cjs.map +1 -0
- package/dist/{schedules-D8ShgpY3.cjs → schedules-CvWX2yKR.cjs} +3 -3
- package/dist/{schedules-D8ShgpY3.cjs.map → schedules-CvWX2yKR.cjs.map} +1 -1
- package/dist/{schedules-CGViSLZC.js → schedules-D9CKB18-.js} +3 -3
- package/dist/{schedules-CGViSLZC.js.map → schedules-D9CKB18-.js.map} +1 -1
- package/dist/{schema-Bf12g7KC-DBc4NSds.js → schema-Bf12g7KC-5EUrrnSf.js} +96 -96
- package/dist/{schema-Bf12g7KC-DBc4NSds.js.map → schema-Bf12g7KC-5EUrrnSf.js.map} +1 -1
- package/dist/{schema-Bf12g7KC-plP4Ir6h.cjs → schema-Bf12g7KC-C5XzpQxe.cjs} +96 -96
- package/dist/{schema-Bf12g7KC-plP4Ir6h.cjs.map → schema-Bf12g7KC-C5XzpQxe.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-Bw6Tuga5.cjs → scores-CWx6H3Z8.cjs} +4 -4
- package/dist/{scores-Bw6Tuga5.cjs.map → scores-CWx6H3Z8.cjs.map} +1 -1
- package/dist/{scores-BaDFGpmr.js → scores-DTVV_OaX.js} +4 -4
- package/dist/{scores-BaDFGpmr.js.map → scores-DTVV_OaX.js.map} +1 -1
- package/dist/server/auth/helpers.d.ts +20 -0
- package/dist/server/auth/helpers.d.ts.map +1 -1
- package/dist/server/auth/index.cjs +2 -1
- package/dist/server/auth/index.js +2 -2
- 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 +17 -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 +17 -6
- package/dist/server/handlers/agent-controller.js.map +1 -1
- package/dist/server/handlers/agent-versions.cjs +4 -4
- package/dist/server/handlers/agent-versions.js +4 -4
- 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 +4 -4
- package/dist/server/handlers/auth.js +4 -4
- package/dist/server/handlers/authorship.cjs +1 -1
- package/dist/server/handlers/authorship.js +1 -1
- package/dist/server/handlers/background-tasks.cjs +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 +7 -5
- package/dist/server/handlers/datasets.cjs.map +1 -1
- package/dist/server/handlers/datasets.d.ts.map +1 -1
- package/dist/server/handlers/datasets.js +7 -5
- 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 +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/gateway-memory-client.cjs +4 -1
- package/dist/server/handlers/gateway-memory-client.cjs.map +1 -1
- package/dist/server/handlers/gateway-memory-client.d.ts.map +1 -1
- package/dist/server/handlers/gateway-memory-client.js +4 -1
- package/dist/server/handlers/gateway-memory-client.js.map +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 +3 -3
- package/dist/server/handlers/mcp-client-versions.js +3 -3
- 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-new-endpoints.cjs +2 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +328 -8
- 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 +7 -1
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +6 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +7 -1
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability-signal-context.cjs +4 -0
- package/dist/server/handlers/observability-signal-context.d.ts +42 -0
- package/dist/server/handlers/observability-signal-context.d.ts.map +1 -0
- package/dist/server/handlers/observability-signal-context.js +1 -0
- package/dist/server/handlers/observability.cjs +3 -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 +2 -2
- package/dist/server/handlers/processor-providers.js +2 -2
- package/dist/server/handlers/processors.cjs +2 -2
- package/dist/server/handlers/processors.js +2 -2
- package/dist/server/handlers/prompt-block-versions.cjs +3 -3
- package/dist/server/handlers/prompt-block-versions.js +3 -3
- package/dist/server/handlers/responses.cjs +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/responses.storage.cjs +1 -1
- package/dist/server/handlers/responses.storage.js +1 -1
- package/dist/server/handlers/schedules.cjs +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 +6 -6
- package/dist/server/handlers/stored-agent-favorites.js +6 -6
- package/dist/server/handlers/stored-agents.cjs +10 -9
- 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 +10 -9
- package/dist/server/handlers/stored-agents.js.map +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +3 -3
- package/dist/server/handlers/stored-mcp-clients.js +3 -3
- package/dist/server/handlers/stored-prompt-blocks.cjs +3 -3
- package/dist/server/handlers/stored-prompt-blocks.js +3 -3
- 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 +5 -5
- package/dist/server/handlers/stored-skill-favorites.js +5 -5
- package/dist/server/handlers/stored-skills.cjs +5 -5
- package/dist/server/handlers/stored-skills.js +5 -5
- package/dist/server/handlers/stored-workspaces.cjs +3 -3
- package/dist/server/handlers/stored-workspaces.js +3 -3
- package/dist/server/handlers/system.cjs +3 -3
- package/dist/server/handlers/system.js +3 -3
- package/dist/server/handlers/tool-providers.cjs +3 -3
- package/dist/server/handlers/tool-providers.js +3 -3
- package/dist/server/handlers/tools.cjs +1 -1
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +1 -1
- package/dist/server/handlers/utils.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.d.ts.map +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/feedback.d.ts +49 -0
- package/dist/server/schemas/feedback.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +23 -23
- package/dist/server/schemas/index.js +23 -23
- package/dist/server/schemas/stored-agents.d.ts +5 -10
- package/dist/server/schemas/stored-agents.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +231 -61
- package/dist/server/server-adapter/index.cjs.map +1 -1
- package/dist/server/server-adapter/index.d.ts +67 -1
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +226 -63
- package/dist/server/server-adapter/index.js.map +1 -1
- package/dist/server/server-adapter/mcp-auth.d.ts +16 -1
- package/dist/server/server-adapter/mcp-auth.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +162 -3
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- 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/{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/{tools-CI5oeJWT.cjs → tools-7O8cd_4u.cjs} +7 -7
- package/dist/{tools-CI5oeJWT.cjs.map → tools-7O8cd_4u.cjs.map} +1 -1
- package/dist/{tools-BAmCNGM5.js → tools-Bf3vq-HD.js} +7 -7
- package/dist/{tools-BAmCNGM5.js.map → tools-Bf3vq-HD.js.map} +1 -1
- package/dist/{utils-9PRHHTGC.cjs → utils-BXEJ6FZC.cjs} +2 -2
- package/dist/{utils-9PRHHTGC.cjs.map → utils-BXEJ6FZC.cjs.map} +1 -1
- package/dist/{utils-BhBJHsqX.cjs → utils-CL-m2SWZ.cjs} +3 -3
- package/dist/{utils-BhBJHsqX.cjs.map → utils-CL-m2SWZ.cjs.map} +1 -1
- package/dist/{utils-B15w-1hm.js → utils-CTYtskHa.js} +2 -2
- package/dist/{utils-B15w-1hm.js.map → utils-CTYtskHa.js.map} +1 -1
- package/dist/{utils-Dy_dQTlK.js → utils-y-cW3mQU.js} +3 -3
- package/dist/{utils-Dy_dQTlK.js.map → utils-y-cW3mQU.js.map} +1 -1
- package/dist/{vector-BZ1bKtwM.cjs → vector-6k7Ft7EX.cjs} +3 -3
- package/dist/{vector-BZ1bKtwM.cjs.map → vector-6k7Ft7EX.cjs.map} +1 -1
- package/dist/{vector-BAs5o6mH.js → vector-BWFSDXvg.js} +3 -3
- package/dist/{vector-BAs5o6mH.js.map → vector-BWFSDXvg.js.map} +1 -1
- package/dist/{workflow-builder-CaSfD6oL.js → workflow-builder-BUQfzD4L.js} +5 -5
- package/dist/{workflow-builder-CaSfD6oL.js.map → workflow-builder-BUQfzD4L.js.map} +1 -1
- package/dist/{workflow-builder-tr_D_ZDN.cjs → workflow-builder-C6J_1s56.cjs} +5 -5
- package/dist/{workflow-builder-tr_D_ZDN.cjs.map → workflow-builder-C6J_1s56.cjs.map} +1 -1
- package/dist/{workflows-BxXS5AfE.js → workflows-BkTNzH-i.js} +24 -13
- package/dist/workflows-BkTNzH-i.js.map +1 -0
- package/dist/{workflows-Cdi6w8JW.cjs → workflows-CHUG5jh4.cjs} +76 -65
- package/dist/workflows-CHUG5jh4.cjs.map +1 -0
- package/dist/{workspace-BU6sQpbV.cjs → workspace-C7PytFzz.cjs} +3 -3
- package/dist/{workspace-BU6sQpbV.cjs.map → workspace-C7PytFzz.cjs.map} +1 -1
- package/dist/{workspace-CS-GYTve.js → workspace-CYwDvH0G.js} +3 -3
- package/dist/{workspace-CS-GYTve.js.map → workspace-CYwDvH0G.js.map} +1 -1
- package/package.json +4 -4
- package/dist/agents-CgcW6lHt.js.map +0 -1
- package/dist/agents-DOHGWXDa.cjs.map +0 -1
- package/dist/dist-BKNKucT9.cjs.map +0 -1
- package/dist/dist-CIYZuix4.js.map +0 -1
- package/dist/dist-mNQb9_wX.js +0 -1
- package/dist/helpers-BKtUXhz2.cjs.map +0 -1
- package/dist/helpers-DNq3LtLq.js.map +0 -1
- package/dist/observability-new-endpoints-Di7m_-xc.js.map +0 -1
- package/dist/observability-new-endpoints-jjCgXuTF.cjs.map +0 -1
- package/dist/routes-5FpkkzND.js.map +0 -1
- package/dist/routes-DU_FlwJP.cjs.map +0 -1
- package/dist/stored-agents-DA8Zx6o9.js.map +0 -1
- package/dist/stored-agents-TQ2lIFbx.cjs.map +0 -1
- package/dist/workflows-BxXS5AfE.js.map +0 -1
- package/dist/workflows-Cdi6w8JW.cjs.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-10nMEhjP.cjs");
|
|
2
|
-
const
|
|
3
|
-
const require_agents = require("./agents-DbnPZXIN.cjs");
|
|
4
|
-
const require_schema_Bf12g7KC = require("./schema-Bf12g7KC-plP4Ir6h.cjs");
|
|
5
|
-
const require_route_builder = require("./route-builder-CvARmqnA.cjs");
|
|
6
|
-
const require_utils = require("./utils-BhBJHsqX.cjs");
|
|
2
|
+
const require_utils = require("./utils-CL-m2SWZ.cjs");
|
|
7
3
|
const require_constants = require("./constants-DMg8hUOR.cjs");
|
|
8
|
-
const
|
|
9
|
-
const require_utils$1 = require("./utils-
|
|
10
|
-
const
|
|
4
|
+
const require_schema_Bf12g7KC = require("./schema-Bf12g7KC-C5XzpQxe.cjs");
|
|
5
|
+
const require_utils$1 = require("./utils-BXEJ6FZC.cjs");
|
|
6
|
+
const require_http_exception = require("./http-exception-Co3MbFUf.cjs");
|
|
7
|
+
const require_agents = require("./agents-CjcvdF2e.cjs");
|
|
8
|
+
const require_stored_agents = require("./stored-agents-m0Knvv29.cjs");
|
|
11
9
|
const require_workspace = require("./workspace-C5BBUatQ.cjs");
|
|
10
|
+
const require_route_builder = require("./route-builder-DHqDrSSy.cjs");
|
|
12
11
|
const require_server_handlers_authorship = require("./server/handlers/authorship.cjs");
|
|
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");
|
|
14
14
|
let zod_v4 = require("zod/v4");
|
|
15
15
|
let _mastra_core_utils_zod_to_json = require("@mastra/core/utils/zod-to-json");
|
|
@@ -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) {
|
|
@@ -299,6 +323,50 @@ async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId,
|
|
|
299
323
|
*/
|
|
300
324
|
const ALIASED_API_KEY_ENV_VAR_PROVIDERS = /* @__PURE__ */ new Set(["google"]);
|
|
301
325
|
/**
|
|
326
|
+
* The shared ownership record of a plain agent run, readable from any server
|
|
327
|
+
* sharing the agent's record cache. Undefined when the run is unknown or
|
|
328
|
+
* expired. Falls back to the owner of a run executing in this process on a
|
|
329
|
+
* core without shared records. A record cache that cannot be read is a 503:
|
|
330
|
+
* the caller is refused, never let through.
|
|
331
|
+
*/
|
|
332
|
+
async function getPlainRunRecord(agent, runId) {
|
|
333
|
+
const resumable = agent;
|
|
334
|
+
if (typeof resumable.__getRunRecord === "function") try {
|
|
335
|
+
return await resumable.__getRunRecord.call(agent, runId);
|
|
336
|
+
} catch {
|
|
337
|
+
throw new require_http_exception.HTTPException(503, { message: "Run ownership is temporarily unavailable" });
|
|
338
|
+
}
|
|
339
|
+
const owner = resumable.__getPublishedRunOwner?.call(agent, runId);
|
|
340
|
+
return owner ? {
|
|
341
|
+
...owner,
|
|
342
|
+
status: "running"
|
|
343
|
+
} : void 0;
|
|
344
|
+
}
|
|
345
|
+
/** The caller must own the run and have `permission` on its thread. */
|
|
346
|
+
async function authorizeRunOwner({ mastra, agent, owner, requestContext, permission }) {
|
|
347
|
+
await require_utils$1.validateRunOwnership(owner, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
348
|
+
if (!owner.threadId) return;
|
|
349
|
+
const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId: owner.threadId });
|
|
350
|
+
await require_utils$1.enforceThreadAccess({
|
|
351
|
+
mastra,
|
|
352
|
+
requestContext,
|
|
353
|
+
threadId: owner.threadId,
|
|
354
|
+
thread,
|
|
355
|
+
effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
|
|
356
|
+
permission
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
/** Whether the agent publishes its runs, so a closed HTTP reader can detach instead of aborting. */
|
|
360
|
+
function hasResumableStreams(agent) {
|
|
361
|
+
if ((0, _mastra_core_agent.isDurableAgentLike)(agent)) return true;
|
|
362
|
+
const resumable = agent;
|
|
363
|
+
return typeof resumable.hasResumableStreams === "function" && resumable.hasResumableStreams();
|
|
364
|
+
}
|
|
365
|
+
/** The bus a plain Agent with resumable streams publishes its runs on. */
|
|
366
|
+
function getAgentStreamPubSub(agent) {
|
|
367
|
+
return agent.__getStreamBus?.()?.pubsub;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
302
370
|
* Checks if a provider has its required API key environment variable(s) configured.
|
|
303
371
|
* Handles provider IDs with suffixes (e.g., "openai.chat" -> "openai").
|
|
304
372
|
* Also handles custom gateway providers that are stored with gateway prefix (e.g., "acme/acme-openai").
|
|
@@ -1432,8 +1500,8 @@ const STREAM_GENERATE_ROUTE = require_route_builder.createRoute({
|
|
|
1432
1500
|
...restOptions,
|
|
1433
1501
|
requestContext: serverRequestContext,
|
|
1434
1502
|
memory: authorizedMemoryOption,
|
|
1435
|
-
abortSignal: (
|
|
1436
|
-
_detachObserverOnCancel: (
|
|
1503
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
1504
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
1437
1505
|
};
|
|
1438
1506
|
if (untilIdle) options.untilIdle = untilIdle;
|
|
1439
1507
|
return (structuredOutput ? await agent.stream(messages, {
|
|
@@ -1690,6 +1758,91 @@ const QUEUE_AGENT_SIGNAL_ROUTE = require_route_builder.createRoute({
|
|
|
1690
1758
|
}
|
|
1691
1759
|
}
|
|
1692
1760
|
});
|
|
1761
|
+
/**
|
|
1762
|
+
* Authorizes a request against a durable run through its workflow rows: the
|
|
1763
|
+
* caller must own the run, the run must belong to `agent`, and the caller must
|
|
1764
|
+
* have `permission` on its thread. Throws 403 when access is denied.
|
|
1765
|
+
* Returns 'missing' when no row exists and 'unverified' when the run has not
|
|
1766
|
+
* checkpointed its input yet, so ownership cannot be confirmed.
|
|
1767
|
+
*/
|
|
1768
|
+
async function authorizeDurableRun({ mastra, agent, runId, requestContext, permission }) {
|
|
1769
|
+
const workflows = await mastra.getStorage()?.getStore("workflows");
|
|
1770
|
+
const run = await workflows?.getWorkflowRunById({
|
|
1771
|
+
workflowName: getDurableLoopWorkflowName(agent),
|
|
1772
|
+
runId
|
|
1773
|
+
});
|
|
1774
|
+
if (!run) return "missing";
|
|
1775
|
+
await require_utils$1.validateRunOwnership(run, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
1776
|
+
const ownershipSchema = zod_v4.z.object({ context: zod_v4.z.object({ input: zod_v4.z.object({
|
|
1777
|
+
agentId: zod_v4.z.string(),
|
|
1778
|
+
state: zod_v4.z.object({ threadId: zod_v4.z.string().optional() }).optional()
|
|
1779
|
+
}) }) });
|
|
1780
|
+
let parsed = ownershipSchema.safeParse(typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot);
|
|
1781
|
+
if (!parsed.success) {
|
|
1782
|
+
const execution = await workflows?.getWorkflowRunById({
|
|
1783
|
+
workflowName: getDurableLoopWorkflowName(agent).replace(_mastra_core_agent_durable.DurableStepIds.AGENTIC_LOOP, _mastra_core_agent_durable.DurableStepIds.AGENTIC_EXECUTION),
|
|
1784
|
+
runId
|
|
1785
|
+
});
|
|
1786
|
+
await require_utils$1.validateRunOwnership(execution, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
|
|
1787
|
+
parsed = ownershipSchema.safeParse(typeof execution?.snapshot === "string" ? JSON.parse(execution.snapshot) : execution?.snapshot);
|
|
1788
|
+
}
|
|
1789
|
+
if (!parsed.success) return "unverified";
|
|
1790
|
+
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" });
|
|
1791
|
+
const threadId = parsed.data.context.input.state?.threadId;
|
|
1792
|
+
if (threadId) {
|
|
1793
|
+
const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId });
|
|
1794
|
+
await require_utils$1.enforceThreadAccess({
|
|
1795
|
+
mastra,
|
|
1796
|
+
requestContext,
|
|
1797
|
+
threadId,
|
|
1798
|
+
thread,
|
|
1799
|
+
effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
|
|
1800
|
+
permission
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
return "ok";
|
|
1804
|
+
}
|
|
1805
|
+
/**
|
|
1806
|
+
* Authorizes observing a run: the caller must own it and have read access to
|
|
1807
|
+
* its thread. Plain agent runs are checked against their shared run record,
|
|
1808
|
+
* so any server sharing the agent's record cache can authorize them. Durable
|
|
1809
|
+
* runs use the owner the agent tracks in this process, then their workflow
|
|
1810
|
+
* rows. Throws 404 when the run cannot be found or verified.
|
|
1811
|
+
*/
|
|
1812
|
+
async function authorizeRunObservation({ mastra, agent, runId, requestContext }) {
|
|
1813
|
+
const permission = require_utils$1.MastraFGAPermissions.MEMORY_READ;
|
|
1814
|
+
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
|
|
1815
|
+
const record = await getPlainRunRecord(agent, runId);
|
|
1816
|
+
if (!record) throw new require_http_exception.HTTPException(404, { message: "Run not found" });
|
|
1817
|
+
await authorizeRunOwner({
|
|
1818
|
+
mastra,
|
|
1819
|
+
agent,
|
|
1820
|
+
owner: record,
|
|
1821
|
+
requestContext,
|
|
1822
|
+
permission
|
|
1823
|
+
});
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
const getOwner = agent.__getRunOwner;
|
|
1827
|
+
const owner = typeof getOwner === "function" ? getOwner.call(agent, runId) : void 0;
|
|
1828
|
+
if (owner) {
|
|
1829
|
+
await authorizeRunOwner({
|
|
1830
|
+
mastra,
|
|
1831
|
+
agent,
|
|
1832
|
+
owner,
|
|
1833
|
+
requestContext,
|
|
1834
|
+
permission
|
|
1835
|
+
});
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
if (await authorizeDurableRun({
|
|
1839
|
+
mastra,
|
|
1840
|
+
agent,
|
|
1841
|
+
runId,
|
|
1842
|
+
requestContext,
|
|
1843
|
+
permission
|
|
1844
|
+
}) !== "ok") throw new require_http_exception.HTTPException(404, { message: "Run not found" });
|
|
1845
|
+
}
|
|
1693
1846
|
const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
1694
1847
|
method: "POST",
|
|
1695
1848
|
path: "/agents/:agentId/runs/:runId/abort",
|
|
@@ -1697,7 +1850,7 @@ const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
1697
1850
|
pathParamSchema: require_agents.agentRunPathParams,
|
|
1698
1851
|
responseSchema: require_agents.abortAgentThreadResponseSchema,
|
|
1699
1852
|
summary: "Abort an agent run",
|
|
1700
|
-
description: "Explicitly stop a durable run, including runs without a memory thread",
|
|
1853
|
+
description: "Explicitly stop a durable run or a run of an agent with resumable streams, including runs without a memory thread",
|
|
1701
1854
|
tags: ["Agents"],
|
|
1702
1855
|
requiresAuth: true,
|
|
1703
1856
|
requiresPermission: require_utils$1.MastraFGAPermissions.AGENTS_EXECUTE,
|
|
@@ -1708,41 +1861,29 @@ const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
|
|
|
1708
1861
|
agentId,
|
|
1709
1862
|
requestContext
|
|
1710
1863
|
});
|
|
1711
|
-
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent))
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
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);
|
|
1731
|
-
}
|
|
1732
|
-
if (!parsed.success) return { aborted: false };
|
|
1733
|
-
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" });
|
|
1734
|
-
const threadId = parsed.data.context.input.state?.threadId;
|
|
1735
|
-
if (threadId) {
|
|
1736
|
-
const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId });
|
|
1737
|
-
await require_utils$1.enforceThreadAccess({
|
|
1864
|
+
if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
|
|
1865
|
+
const resumable = agent;
|
|
1866
|
+
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({
|
|
1738
1870
|
mastra,
|
|
1871
|
+
agent,
|
|
1872
|
+
owner: record,
|
|
1739
1873
|
requestContext,
|
|
1740
|
-
threadId,
|
|
1741
|
-
thread,
|
|
1742
|
-
effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
|
|
1743
1874
|
permission: require_utils$1.MastraFGAPermissions.MEMORY_WRITE
|
|
1744
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) };
|
|
1745
1879
|
}
|
|
1880
|
+
if (await authorizeDurableRun({
|
|
1881
|
+
mastra,
|
|
1882
|
+
agent,
|
|
1883
|
+
runId,
|
|
1884
|
+
requestContext,
|
|
1885
|
+
permission: require_utils$1.MastraFGAPermissions.MEMORY_WRITE
|
|
1886
|
+
}) !== "ok") return { aborted: false };
|
|
1746
1887
|
if (typeof agent.__abortRunAcknowledged === "function") return { aborted: await agent.__abortRunAcknowledged(runId) };
|
|
1747
1888
|
return { aborted: await agent.abortRunStream(runId) };
|
|
1748
1889
|
} catch (error) {
|
|
@@ -2005,8 +2146,8 @@ const STREAM_UNTIL_IDLE_GENERATE_ROUTE = require_route_builder.createRoute({
|
|
|
2005
2146
|
context: restOptions.context,
|
|
2006
2147
|
requestContext: serverRequestContext,
|
|
2007
2148
|
memory: authorizedMemoryOption,
|
|
2008
|
-
abortSignal: (
|
|
2009
|
-
_detachObserverOnCancel: (
|
|
2149
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2150
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2010
2151
|
};
|
|
2011
2152
|
return (structuredOutput ? await agent.streamUntilIdle(messages, {
|
|
2012
2153
|
...options,
|
|
@@ -2040,24 +2181,43 @@ const OBSERVE_AGENT_STREAM_ROUTE = require_route_builder.createRoute({
|
|
|
2040
2181
|
bodySchema: require_agents.observeAgentBodySchema,
|
|
2041
2182
|
responseSchema: require_agents.observeAgentResponseSchema,
|
|
2042
2183
|
summary: "Observe agent stream",
|
|
2043
|
-
description: "Reconnect to an existing agent stream to receive missed events.
|
|
2184
|
+
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
2185
|
tags: ["Agents", "Streaming"],
|
|
2045
2186
|
requiresAuth: true,
|
|
2046
|
-
handler: async ({ mastra, agentId, runId, offset, abortSignal }) => {
|
|
2187
|
+
handler: async ({ mastra, agentId, runId, offset, abortSignal, requestContext }) => {
|
|
2047
2188
|
try {
|
|
2048
2189
|
const agent = await getAgentFromSystem({
|
|
2049
2190
|
mastra,
|
|
2050
|
-
agentId
|
|
2191
|
+
agentId,
|
|
2192
|
+
requestContext
|
|
2193
|
+
});
|
|
2194
|
+
await authorizeRunObservation({
|
|
2195
|
+
mastra,
|
|
2196
|
+
agent,
|
|
2197
|
+
runId,
|
|
2198
|
+
requestContext
|
|
2051
2199
|
});
|
|
2052
2200
|
const durableAgent = (0, _mastra_core_agent.isDurableAgentLike)(agent) ? agent : void 0;
|
|
2053
|
-
const pubsub = durableAgent?.pubsub ?? mastra.pubsub;
|
|
2201
|
+
const pubsub = durableAgent?.pubsub ?? getAgentStreamPubSub(agent) ?? mastra.pubsub;
|
|
2054
2202
|
const topic = (0, _mastra_core_agent_durable.AGENT_STREAM_TOPIC)(runId);
|
|
2055
2203
|
const subscribe = (onEvent, onComplete) => {
|
|
2056
2204
|
if (typeof durableAgent?.__subscribeToRunStream === "function") return durableAgent.__subscribeToRunStream(runId, {
|
|
2057
2205
|
offset,
|
|
2058
2206
|
onComplete
|
|
2059
2207
|
}, onEvent);
|
|
2060
|
-
|
|
2208
|
+
if (offset === void 0) return pubsub.subscribeWithReplay(topic, onEvent).then(() => () => pubsub.unsubscribe(topic, onEvent));
|
|
2209
|
+
return pubsub.subscribeFromOffset(topic, offset, onEvent).then(() => {
|
|
2210
|
+
if (offset > 0) {
|
|
2211
|
+
const readTail = async () => {
|
|
2212
|
+
const window = await pubsub.getHistory(topic, offset - 1);
|
|
2213
|
+
return window.length > 0 ? window.at(-1) : (await pubsub.getHistory(topic, 0)).at(-1);
|
|
2214
|
+
};
|
|
2215
|
+
readTail().catch(() => void 0).then((last) => {
|
|
2216
|
+
if (typeof last?.index === "number" && last.index < offset && isRunTerminalEvent(last)) onComplete();
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
return () => pubsub.unsubscribe(topic, onEvent);
|
|
2220
|
+
});
|
|
2061
2221
|
};
|
|
2062
2222
|
let closed = false;
|
|
2063
2223
|
let pendingRejection;
|
|
@@ -2186,8 +2346,8 @@ const APPROVE_TOOL_CALL_ROUTE = require_route_builder.createRoute({
|
|
|
2186
2346
|
return (await agent.approveToolCall({
|
|
2187
2347
|
...params,
|
|
2188
2348
|
requestContext,
|
|
2189
|
-
abortSignal: (
|
|
2190
|
-
_detachObserverOnCancel: (
|
|
2349
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2350
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2191
2351
|
})).fullStream;
|
|
2192
2352
|
} catch (error) {
|
|
2193
2353
|
return require_server_handlers_error.handleError(error, "error approving tool call");
|
|
@@ -2343,8 +2503,8 @@ const DECLINE_TOOL_CALL_ROUTE = require_route_builder.createRoute({
|
|
|
2343
2503
|
return (await agent.declineToolCall({
|
|
2344
2504
|
...params,
|
|
2345
2505
|
requestContext,
|
|
2346
|
-
abortSignal: (
|
|
2347
|
-
_detachObserverOnCancel: (
|
|
2506
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2507
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2348
2508
|
})).fullStream;
|
|
2349
2509
|
} catch (error) {
|
|
2350
2510
|
return require_server_handlers_error.handleError(error, "error declining tool call");
|
|
@@ -2428,8 +2588,8 @@ const RESUME_STREAM_ROUTE = require_route_builder.createRoute({
|
|
|
2428
2588
|
...restOptions,
|
|
2429
2589
|
requestContext: serverRequestContext,
|
|
2430
2590
|
memory: authorizedMemoryOption,
|
|
2431
|
-
abortSignal: (
|
|
2432
|
-
_detachObserverOnCancel: (
|
|
2591
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2592
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2433
2593
|
};
|
|
2434
2594
|
if (untilIdle) options.untilIdle = untilIdle;
|
|
2435
2595
|
return (structuredOutput ? await agent.resumeStream(resumeData, {
|
|
@@ -2558,8 +2718,8 @@ const RESUME_STREAM_UNTIL_IDLE_ROUTE = require_route_builder.createRoute({
|
|
|
2558
2718
|
context: restOptions.context,
|
|
2559
2719
|
requestContext: serverRequestContext,
|
|
2560
2720
|
memory: authorizedMemoryOption,
|
|
2561
|
-
abortSignal: (
|
|
2562
|
-
_detachObserverOnCancel: (
|
|
2721
|
+
abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
|
|
2722
|
+
_detachObserverOnCancel: hasResumableStreams(agent)
|
|
2563
2723
|
};
|
|
2564
2724
|
return (structuredOutput ? await agent.resumeStreamUntilIdle(resumeData, {
|
|
2565
2725
|
...options,
|
|
@@ -3381,4 +3541,4 @@ Object.defineProperty(exports, "isProviderConnected", {
|
|
|
3381
3541
|
}
|
|
3382
3542
|
});
|
|
3383
3543
|
|
|
3384
|
-
//# sourceMappingURL=agents-
|
|
3544
|
+
//# sourceMappingURL=agents-CMEeZr5y.cjs.map
|