@mastra/server 1.83.0-alpha.11 → 1.83.0-alpha.13
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_voice@0.0.44/dist/_types/@internal_core@0.1.4/dist/request-context/index.d.ts +19 -0
- package/dist/{a2a-DIcMx6x-.cjs → a2a-Bz7vRGfF.cjs} +9 -6
- package/dist/a2a-Bz7vRGfF.cjs.map +1 -0
- package/dist/{a2a-DTTGA2Xg.js → a2a-CY85JalK.js} +9 -6
- package/dist/a2a-CY85JalK.js.map +1 -0
- package/dist/{agent-builder-BNfBksTT.js → agent-builder-Ce1pjSjg.js} +6 -6
- package/dist/{agent-builder-BNfBksTT.js.map → agent-builder-Ce1pjSjg.js.map} +1 -1
- package/dist/{agent-builder-CopkMfWF.cjs → agent-builder-DWtgp1cb.cjs} +6 -6
- package/dist/{agent-builder-CopkMfWF.cjs.map → agent-builder-DWtgp1cb.cjs.map} +1 -1
- package/dist/{agents-BCgiMlDq.js → agents-B0OpLdbp.js} +444 -3
- package/dist/agents-B0OpLdbp.js.map +1 -0
- package/dist/{agents-DjpBmwhv.cjs → agents-BgaBbcwb.cjs} +136 -53
- package/dist/agents-BgaBbcwb.cjs.map +1 -0
- package/dist/{agents-CTgjTASj.js → agents-BjlUjmb1.js} +136 -53
- package/dist/agents-BjlUjmb1.js.map +1 -0
- package/dist/{agents-CjcvdF2e.cjs → agents-CH_G37hG.cjs} +521 -2
- package/dist/agents-CH_G37hG.cjs.map +1 -0
- package/dist/{api-schema-manifest-LHpJSi-Y.js → api-schema-manifest-CsTpd03O.js} +9 -9
- package/dist/api-schema-manifest-CsTpd03O.js.map +1 -0
- package/dist/{api-schema-manifest-hPT7_FSw.cjs → api-schema-manifest-DT9X0fAm.cjs} +9 -9
- package/dist/api-schema-manifest-DT9X0fAm.cjs.map +1 -0
- package/dist/{background-tasks-CYvlxFz3.js → background-tasks-BKnoXtUN.js} +3 -3
- package/dist/{background-tasks-CYvlxFz3.js.map → background-tasks-BKnoXtUN.js.map} +1 -1
- package/dist/{background-tasks-Dv9o8cR7.cjs → background-tasks-BqW1_VmH.cjs} +3 -3
- package/dist/{background-tasks-Dv9o8cR7.cjs.map → background-tasks-BqW1_VmH.cjs.map} +1 -1
- package/dist/{builder-registry-BmrttdGj.js → builder-registry-ByghMyfA.js} +3 -3
- package/dist/{builder-registry-BmrttdGj.js.map → builder-registry-ByghMyfA.js.map} +1 -1
- package/dist/{builder-registry-CmbtZzbE.cjs → builder-registry-DPsdmtZG.cjs} +3 -3
- package/dist/{builder-registry-CmbtZzbE.cjs.map → builder-registry-DPsdmtZG.cjs.map} +1 -1
- package/dist/catalogue-CGQdyojN.cjs +1378 -0
- package/dist/catalogue-CGQdyojN.cjs.map +1 -0
- package/dist/catalogue-CUJevxy3.js +1376 -0
- package/dist/catalogue-CUJevxy3.js.map +1 -0
- package/dist/{channels-KHhb7hAm.js → channels-DIE-lJkq.js} +3 -3
- package/dist/{channels-KHhb7hAm.js.map → channels-DIE-lJkq.js.map} +1 -1
- package/dist/{channels-CXwFVxi2.cjs → channels-k5dF1IBc.cjs} +3 -3
- package/dist/{channels-CXwFVxi2.cjs.map → channels-k5dF1IBc.cjs.map} +1 -1
- package/dist/{constants-CXAvBYcz.js → constants-0xZU_h4R.js} +10 -2
- package/dist/constants-0xZU_h4R.js.map +1 -0
- package/dist/{constants-DMg8hUOR.cjs → constants-1yTmKUZD.cjs} +15 -1
- package/dist/constants-1yTmKUZD.cjs.map +1 -0
- package/dist/{conversations-BFqmDglO.cjs → conversations-Bvk5VVVJ.cjs} +6 -5
- package/dist/conversations-Bvk5VVVJ.cjs.map +1 -0
- package/dist/{conversations-BkX00xDs.js → conversations-DYqwqCWH.js} +6 -5
- package/dist/conversations-DYqwqCWH.js.map +1 -0
- package/dist/dist-BVw6-hMs.js +1 -0
- package/dist/{dist-G8g-Cg67.js → dist-C-Hmkkat.js} +6 -6
- package/dist/{dist-G8g-Cg67.js.map → dist-C-Hmkkat.js.map} +1 -1
- package/dist/{dist-COfASzWw.cjs → dist-Clh3uSOV.cjs} +11 -11
- package/dist/{dist-COfASzWw.cjs.map → dist-Clh3uSOV.cjs.map} +1 -1
- package/dist/{dist-3WMLkPSs.cjs → dist-DPgpEz_7.cjs} +1 -1
- package/dist/docs/SKILL.md +3 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-mcp.md +315 -0
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +2 -1
- package/dist/docs/references/reference-server-dispatch-route.md +124 -0
- package/dist/docs/references/reference-server-invoke-route.md +10 -0
- package/dist/{dynamic-workflows-QgKLYkiC.cjs → dynamic-workflows-DPgV6qtS.cjs} +2 -2
- package/dist/{dynamic-workflows-QgKLYkiC.cjs.map → dynamic-workflows-DPgV6qtS.cjs.map} +1 -1
- package/dist/{dynamic-workflows-CYtakeIQ.js → dynamic-workflows-DmkCJ4Lp.js} +2 -2
- package/dist/{dynamic-workflows-CYtakeIQ.js.map → dynamic-workflows-DmkCJ4Lp.js.map} +1 -1
- package/dist/{editor-builder-C4H2l6tz.js → editor-builder-CGM0scw2.js} +10 -4
- package/dist/editor-builder-CGM0scw2.js.map +1 -0
- package/dist/{editor-builder-fe70YP8g.js → editor-builder-CXLdplIj.js} +2 -2
- package/dist/{editor-builder-fe70YP8g.js.map → editor-builder-CXLdplIj.js.map} +1 -1
- package/dist/{editor-builder-Cqw1npOK.cjs → editor-builder-SP_ledm3.cjs} +10 -4
- package/dist/editor-builder-SP_ledm3.cjs.map +1 -0
- package/dist/{editor-builder-xQmDgVgJ.cjs → editor-builder-eF2IetF2.cjs} +2 -2
- package/dist/{editor-builder-xQmDgVgJ.cjs.map → editor-builder-eF2IetF2.cjs.map} +1 -1
- package/dist/{helpers-C9QZKOhz.js → helpers-B56oH6qp.js} +27 -8
- package/dist/helpers-B56oH6qp.js.map +1 -0
- package/dist/{helpers-0LJI4DxR.cjs → helpers-Dpdta8ai.cjs} +31 -6
- package/dist/helpers-Dpdta8ai.cjs.map +1 -0
- package/dist/{knowledge-CRkWkTBC.cjs → knowledge-2fms70NN.cjs} +4 -4
- package/dist/{knowledge-CRkWkTBC.cjs.map → knowledge-2fms70NN.cjs.map} +1 -1
- package/dist/{knowledge-Dfe_CFtt.js → knowledge-BblTTH3z.js} +4 -4
- package/dist/{knowledge-Dfe_CFtt.js.map → knowledge-BblTTH3z.js.map} +1 -1
- package/dist/{logs-Dg2AWexF.js → logs-D_hKQuvQ.js} +3 -3
- package/dist/{logs-Dg2AWexF.js.map → logs-D_hKQuvQ.js.map} +1 -1
- package/dist/{logs-B2ov1yZQ.cjs → logs-Deoh0l4I.cjs} +3 -3
- package/dist/{logs-B2ov1yZQ.cjs.map → logs-Deoh0l4I.cjs.map} +1 -1
- package/dist/{mcp-bsPRIGFX.js → mcp-CSRuYaWN.js} +3 -3
- package/dist/{mcp-bsPRIGFX.js.map → mcp-CSRuYaWN.js.map} +1 -1
- package/dist/{mcp-Bon4eIV1.cjs → mcp-oWjcmsQb.cjs} +3 -3
- package/dist/{mcp-Bon4eIV1.cjs.map → mcp-oWjcmsQb.cjs.map} +1 -1
- package/dist/{memory-Dw7xG5nn.js → memory-CGlo-6_V.js} +105 -12
- package/dist/memory-CGlo-6_V.js.map +1 -0
- package/dist/{memory-BRE3ofvI.cjs → memory-CzSke9Em.cjs} +105 -12
- package/dist/memory-CzSke9Em.cjs.map +1 -0
- package/dist/{observability-DHJ7mzoE.cjs → observability-BCJsmSH0.cjs} +27 -3
- package/dist/observability-BCJsmSH0.cjs.map +1 -0
- package/dist/{observability-BYIy4kPf.js → observability-Z2tDxHS1.js} +27 -3
- package/dist/observability-Z2tDxHS1.js.map +1 -0
- package/dist/{observability-new-endpoints-BOe3wej1.cjs → observability-new-endpoints-C_HEkpZ1.cjs} +157 -5
- package/dist/observability-new-endpoints-C_HEkpZ1.cjs.map +1 -0
- package/dist/{observability-new-endpoints-COy7lpeR.js → observability-new-endpoints-dr0XcNkP.js} +158 -6
- package/dist/observability-new-endpoints-dr0XcNkP.js.map +1 -0
- package/dist/{plans-D_GKFz2x.js → plans-BemJO4-7.js} +7 -6
- package/dist/plans-BemJO4-7.js.map +1 -0
- package/dist/{plans-_nR8lqgD.cjs → plans-CffjV2_6.cjs} +7 -6
- package/dist/plans-CffjV2_6.cjs.map +1 -0
- package/dist/{probe-image-size-C2b8QfA7.js → probe-image-size-jA5gozO6.js} +2 -2
- package/dist/{probe-image-size-C2b8QfA7.js.map → probe-image-size-jA5gozO6.js.map} +1 -1
- package/dist/{probe-image-size-DLuC8QsM.cjs → probe-image-size-qOT5Pn0l.cjs} +2 -2
- package/dist/{probe-image-size-DLuC8QsM.cjs.map → probe-image-size-qOT5Pn0l.cjs.map} +1 -1
- package/dist/{responses-C_OEJoxU.js → responses-BofWEQYg.js} +11 -8
- package/dist/responses-BofWEQYg.js.map +1 -0
- package/dist/{responses-CdWbS4jA.cjs → responses-D0mb5ubj.cjs} +11 -8
- package/dist/responses-D0mb5ubj.cjs.map +1 -0
- package/dist/{route-builder-B9C5vT54.cjs → route-builder-DjTBxSZN.cjs} +10 -10
- package/dist/{route-builder-B9C5vT54.cjs.map → route-builder-DjTBxSZN.cjs.map} +1 -1
- package/dist/{route-builder-DfDT1g4L.js → route-builder-Dz18c3qm.js} +9 -9
- package/dist/{route-builder-DfDT1g4L.js.map → route-builder-Dz18c3qm.js.map} +1 -1
- package/dist/{routes-Brf5Qfbu.cjs → routes-01JAJiMe.cjs} +646 -27
- package/dist/routes-01JAJiMe.cjs.map +1 -0
- package/dist/{routes-BR7W0b_u.js → routes-CmkPohqd.js} +593 -28
- package/dist/routes-CmkPohqd.js.map +1 -0
- package/dist/{schedules-BQvnAe1j.cjs → schedules-BRwhbppl.cjs} +77 -22
- package/dist/schedules-BRwhbppl.cjs.map +1 -0
- package/dist/{schedules-BcAIELfB.js → schedules-Zct_0ZwE.js} +77 -22
- package/dist/schedules-Zct_0ZwE.js.map +1 -0
- package/dist/{schema-xsUy1mlm-CAPin6jE.js → schema-TQPB_dl2-CCzMcdDx.js} +9 -6
- package/dist/{schema-xsUy1mlm-CAPin6jE.js.map → schema-TQPB_dl2-CCzMcdDx.js.map} +1 -1
- package/dist/{schema-xsUy1mlm-pvZI8YC0.cjs → schema-TQPB_dl2-CJX1q58F.cjs} +9 -6
- package/dist/{schema-xsUy1mlm-pvZI8YC0.cjs.map → schema-TQPB_dl2-CJX1q58F.cjs.map} +1 -1
- package/dist/{scores-DEvPN0kz.cjs → scores-0MyV08tL.cjs} +26 -11
- package/dist/scores-0MyV08tL.cjs.map +1 -0
- package/dist/{scores-Dm0yu1Pt.js → scores-CVssMyoQ.js} +26 -11
- package/dist/scores-CVssMyoQ.js.map +1 -0
- package/dist/server/auth/helpers.d.ts +7 -1
- package/dist/server/auth/helpers.d.ts.map +1 -1
- package/dist/server/auth/index.cjs +4 -2
- package/dist/server/auth/index.js +3 -3
- package/dist/server/constants.d.ts +8 -1
- package/dist/server/constants.d.ts.map +1 -1
- package/dist/server/handlers/a2a.cjs +1 -1
- package/dist/server/handlers/a2a.d.ts +4 -0
- package/dist/server/handlers/a2a.d.ts.map +1 -1
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-access.cjs +42 -0
- package/dist/server/handlers/agent-access.cjs.map +1 -0
- package/dist/server/handlers/agent-access.d.ts +19 -0
- package/dist/server/handlers/agent-access.d.ts.map +1 -0
- package/dist/server/handlers/agent-access.js +39 -0
- package/dist/server/handlers/agent-access.js.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +1 -1
- package/dist/server/handlers/agent-builder.d.ts +32 -0
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-controller.cjs +3 -3
- package/dist/server/handlers/agent-controller.d.ts +72 -0
- package/dist/server/handlers/agent-controller.d.ts.map +1 -1
- package/dist/server/handlers/agent-controller.js +3 -3
- package/dist/server/handlers/agent-versions.cjs +30 -2
- package/dist/server/handlers/agent-versions.cjs.map +1 -1
- package/dist/server/handlers/agent-versions.d.ts +12 -0
- package/dist/server/handlers/agent-versions.d.ts.map +1 -1
- package/dist/server/handlers/agent-versions.js +30 -2
- package/dist/server/handlers/agent-versions.js.map +1 -1
- package/dist/server/handlers/agents.cjs +1 -1
- package/dist/server/handlers/agents.d.ts +91 -2
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/auth.cjs +3 -3
- package/dist/server/handlers/auth.d.ts +40 -0
- package/dist/server/handlers/auth.d.ts.map +1 -1
- package/dist/server/handlers/auth.js +3 -3
- 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.d.ts +8 -0
- 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.d.ts +10 -0
- package/dist/server/handlers/builder-registry.d.ts.map +1 -1
- package/dist/server/handlers/builder-registry.js +1 -1
- package/dist/server/handlers/channels.cjs +1 -1
- package/dist/server/handlers/channels.d.ts +10 -0
- package/dist/server/handlers/channels.d.ts.map +1 -1
- package/dist/server/handlers/channels.js +1 -1
- package/dist/server/handlers/conversations.cjs +1 -1
- package/dist/server/handlers/conversations.d.ts +8 -0
- package/dist/server/handlers/conversations.d.ts.map +1 -1
- package/dist/server/handlers/conversations.js +1 -1
- package/dist/server/handlers/datasets.cjs +2 -2
- package/dist/server/handlers/datasets.d.ts +66 -0
- package/dist/server/handlers/datasets.d.ts.map +1 -1
- package/dist/server/handlers/datasets.js +2 -2
- package/dist/server/handlers/dynamic-workflows.cjs +1 -1
- package/dist/server/handlers/dynamic-workflows.d.ts +8 -0
- package/dist/server/handlers/dynamic-workflows.d.ts.map +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.d.ts +6 -0
- package/dist/server/handlers/editor-builder.d.ts.map +1 -1
- package/dist/server/handlers/editor-builder.js +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.d.ts +18 -0
- package/dist/server/handlers/knowledge.d.ts.map +1 -1
- package/dist/server/handlers/knowledge.js +1 -1
- package/dist/server/handlers/logs.cjs +1 -1
- package/dist/server/handlers/logs.d.ts +6 -0
- package/dist/server/handlers/logs.d.ts.map +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.d.ts +14 -0
- package/dist/server/handlers/mcp-client-versions.d.ts.map +1 -1
- package/dist/server/handlers/mcp-client-versions.js +2 -2
- package/dist/server/handlers/mcp.cjs +1 -1
- package/dist/server/handlers/mcp.d.ts +42 -0
- package/dist/server/handlers/mcp.d.ts.map +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 +52 -0
- 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 +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +163 -3
- 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 +8 -1
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +13 -0
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +7 -2
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability-signal-context.cjs +1 -1
- package/dist/server/handlers/observability-signal-context.js +1 -1
- package/dist/server/handlers/observability.cjs +2 -2
- package/dist/server/handlers/observability.d.ts +12 -0
- package/dist/server/handlers/observability.d.ts.map +1 -1
- package/dist/server/handlers/observability.js +2 -2
- package/dist/server/handlers/plans.cjs +1 -1
- package/dist/server/handlers/plans.d.ts +2 -0
- package/dist/server/handlers/plans.d.ts.map +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.d.ts +4 -0
- package/dist/server/handlers/processor-providers.d.ts.map +1 -1
- package/dist/server/handlers/processor-providers.js +1 -1
- package/dist/server/handlers/processors.cjs +57 -6
- package/dist/server/handlers/processors.cjs.map +1 -1
- package/dist/server/handlers/processors.d.ts +6 -0
- package/dist/server/handlers/processors.d.ts.map +1 -1
- package/dist/server/handlers/processors.js +57 -6
- package/dist/server/handlers/processors.js.map +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +2 -2
- package/dist/server/handlers/prompt-block-versions.d.ts +14 -0
- package/dist/server/handlers/prompt-block-versions.d.ts.map +1 -1
- 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 +17 -11
- package/dist/server/handlers/responses.d.ts.map +1 -1
- package/dist/server/handlers/responses.js +1 -1
- package/dist/server/handlers/responses.storage.cjs +4 -3
- package/dist/server/handlers/responses.storage.cjs.map +1 -1
- package/dist/server/handlers/responses.storage.d.ts.map +1 -1
- package/dist/server/handlers/responses.storage.js +4 -3
- package/dist/server/handlers/responses.storage.js.map +1 -1
- package/dist/server/handlers/schedules.cjs +1 -1
- package/dist/server/handlers/schedules.d.ts +18 -0
- 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 +2 -2
- package/dist/server/handlers/scorer-versions.d.ts +14 -0
- package/dist/server/handlers/scorer-versions.d.ts.map +1 -1
- package/dist/server/handlers/scorer-versions.js +2 -2
- package/dist/server/handlers/scores.cjs +1 -1
- package/dist/server/handlers/scores.d.ts +12 -0
- package/dist/server/handlers/scores.d.ts.map +1 -1
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agent-favorites.cjs +3 -3
- package/dist/server/handlers/stored-agent-favorites.d.ts +4 -0
- package/dist/server/handlers/stored-agent-favorites.d.ts.map +1 -1
- package/dist/server/handlers/stored-agent-favorites.js +3 -3
- package/dist/server/handlers/stored-agents.cjs +41 -3
- package/dist/server/handlers/stored-agents.cjs.map +1 -1
- package/dist/server/handlers/stored-agents.d.ts +14 -0
- package/dist/server/handlers/stored-agents.d.ts.map +1 -1
- package/dist/server/handlers/stored-agents.js +41 -3
- 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.d.ts +10 -0
- package/dist/server/handlers/stored-mcp-clients.d.ts.map +1 -1
- 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.d.ts +10 -0
- package/dist/server/handlers/stored-prompt-blocks.d.ts.map +1 -1
- package/dist/server/handlers/stored-prompt-blocks.js +2 -2
- package/dist/server/handlers/stored-scorers.cjs +2 -2
- package/dist/server/handlers/stored-scorers.d.ts +10 -0
- package/dist/server/handlers/stored-scorers.d.ts.map +1 -1
- package/dist/server/handlers/stored-scorers.js +2 -2
- package/dist/server/handlers/stored-skill-favorites.cjs +3 -3
- package/dist/server/handlers/stored-skill-favorites.d.ts +4 -0
- package/dist/server/handlers/stored-skill-favorites.d.ts.map +1 -1
- 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.d.ts +12 -0
- package/dist/server/handlers/stored-skills.d.ts.map +1 -1
- package/dist/server/handlers/stored-skills.js +3 -3
- package/dist/server/handlers/stored-workspaces.cjs +2 -2
- package/dist/server/handlers/stored-workspaces.d.ts +10 -0
- package/dist/server/handlers/stored-workspaces.d.ts.map +1 -1
- package/dist/server/handlers/stored-workspaces.js +2 -2
- package/dist/server/handlers/system.cjs +3 -3
- package/dist/server/handlers/system.d.ts +6 -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 +2 -2
- package/dist/server/handlers/tool-providers.d.ts +26 -0
- package/dist/server/handlers/tool-providers.d.ts.map +1 -1
- package/dist/server/handlers/tool-providers.js +2 -2
- package/dist/server/handlers/tools.cjs +2 -1
- package/dist/server/handlers/tools.d.ts +20 -0
- package/dist/server/handlers/tools.d.ts.map +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.d.ts +16 -0
- package/dist/server/handlers/vector.d.ts.map +1 -1
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +1 -1
- package/dist/server/handlers/voice.d.ts.map +1 -1
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflow-builder.cjs +1 -1
- package/dist/server/handlers/workflow-builder.d.ts +4 -0
- package/dist/server/handlers/workflow-builder.d.ts.map +1 -1
- package/dist/server/handlers/workflow-builder.js +1 -1
- package/dist/server/handlers/workflows.cjs +2 -1
- package/dist/server/handlers/workflows.d.ts +57 -0
- 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 +103 -23
- package/dist/server/handlers/workspace.d.ts.map +1 -1
- package/dist/server/handlers/workspace.js +1 -1
- package/dist/server/handlers.cjs +17 -17
- package/dist/server/handlers.js +17 -17
- package/dist/server/mcp/capabilities.d.ts +25 -0
- package/dist/server/mcp/capabilities.d.ts.map +1 -0
- package/dist/server/mcp/catalogue.d.ts +76 -0
- package/dist/server/mcp/catalogue.d.ts.map +1 -0
- package/dist/server/mcp/config.d.ts +49 -0
- package/dist/server/mcp/config.d.ts.map +1 -0
- package/dist/server/mcp/descriptor.d.ts +40 -0
- package/dist/server/mcp/descriptor.d.ts.map +1 -0
- package/dist/server/mcp/oauth.d.ts +46 -0
- package/dist/server/mcp/oauth.d.ts.map +1 -0
- package/dist/server/mcp/result-size.d.ts +26 -0
- package/dist/server/mcp/result-size.d.ts.map +1 -0
- package/dist/server/mcp/route.d.ts +21 -0
- package/dist/server/mcp/route.d.ts.map +1 -0
- package/dist/server/mcp/schema.d.ts +13 -0
- package/dist/server/mcp/schema.d.ts.map +1 -0
- package/dist/server/mcp/toolsets/memory.d.ts +8 -0
- package/dist/server/mcp/toolsets/memory.d.ts.map +1 -0
- package/dist/server/mcp/toolsets/observability.d.ts +4 -0
- package/dist/server/mcp/toolsets/observability.d.ts.map +1 -0
- package/dist/server/mcp/toolsets/stored-agents.d.ts +8 -0
- package/dist/server/mcp/toolsets/stored-agents.d.ts.map +1 -0
- package/dist/server/schemas/index.cjs +9 -10
- package/dist/server/schemas/index.js +3 -4
- package/dist/server/schemas/system.d.ts +2 -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 +45 -1831
- package/dist/server/server-adapter/index.d.ts +126 -3
- package/dist/server/server-adapter/index.d.ts.map +1 -1
- package/dist/server/server-adapter/index.js +7 -1805
- package/dist/server/server-adapter/openapi-utils.d.ts +2 -2
- package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/a2a.d.ts +4 -0
- package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/agent-builder.d.ts +32 -0
- package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/channels.d.ts +10 -0
- package/dist/server/server-adapter/routes/channels.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/conversations.d.ts +11 -3
- package/dist/server/server-adapter/routes/conversations.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/datasets.d.ts +66 -0
- package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/editor-builder.d.ts +20 -0
- package/dist/server/server-adapter/routes/editor-builder.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/index.d.ts +26 -1
- package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/knowledge.d.ts +18 -0
- package/dist/server/server-adapter/routes/knowledge.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/legacy.d.ts +8 -0
- package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/logs.d.ts +6 -0
- package/dist/server/server-adapter/routes/logs.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/mcp.d.ts +37 -1
- package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/memory.d.ts +52 -0
- package/dist/server/server-adapter/routes/memory.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/observability.d.ts +97 -1
- package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/processor-providers.d.ts +4 -0
- package/dist/server/server-adapter/routes/processor-providers.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/processors.d.ts +6 -0
- package/dist/server/server-adapter/routes/processors.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/responses.d.ts +6 -0
- package/dist/server/server-adapter/routes/responses.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/route-builder.d.ts +5 -1
- package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/scorers.d.ts +12 -0
- package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/stored-mcp-clients.d.ts +24 -0
- package/dist/server/server-adapter/routes/stored-mcp-clients.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/stored-prompt-blocks.d.ts +24 -0
- package/dist/server/server-adapter/routes/stored-prompt-blocks.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/stored-scorers.d.ts +24 -0
- package/dist/server/server-adapter/routes/stored-scorers.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/stored-skills.d.ts +16 -0
- package/dist/server/server-adapter/routes/stored-skills.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/stored-workspaces.d.ts +10 -0
- package/dist/server/server-adapter/routes/stored-workspaces.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/system.d.ts +6 -0
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/tool-providers.d.ts +26 -0
- package/dist/server/server-adapter/routes/tool-providers.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/tools.d.ts +6 -0
- package/dist/server/server-adapter/routes/tools.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/vectors.d.ts +16 -0
- package/dist/server/server-adapter/routes/vectors.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workflows.d.ts +50 -0
- package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
- package/dist/server/server-adapter/routes/workspace.d.ts +42 -0
- package/dist/server/server-adapter/routes/workspace.d.ts.map +1 -1
- package/dist/server-adapter-B7dLE5si.cjs +2386 -0
- package/dist/server-adapter-B7dLE5si.cjs.map +1 -0
- package/dist/server-adapter-BywLWVKp.js +2189 -0
- package/dist/server-adapter-BywLWVKp.js.map +1 -0
- package/dist/{system-zL047vEq.cjs → system-DdMSBAOY.cjs} +2 -1
- package/dist/system-DdMSBAOY.cjs.map +1 -0
- package/dist/{system-DlW760k2.js → system-FnU7vyxd.js} +2 -1
- package/dist/system-FnU7vyxd.js.map +1 -0
- package/dist/{tools-Daot5Zgz.cjs → tools-CawMeeZg.cjs} +71 -29
- package/dist/tools-CawMeeZg.cjs.map +1 -0
- package/dist/{tools-BJFq9JKF.js → tools-oHRh4msa.js} +65 -29
- package/dist/tools-oHRh4msa.js.map +1 -0
- package/dist/{utils-yedETkNk.js → utils-BfySxdfF.js} +3 -3
- package/dist/{utils-yedETkNk.js.map → utils-BfySxdfF.js.map} +1 -1
- package/dist/{utils-BXEJ6FZC.cjs → utils-DFhesFfA.cjs} +2 -2
- package/dist/{utils-BXEJ6FZC.cjs.map → utils-DFhesFfA.cjs.map} +1 -1
- package/dist/{utils-DptI_ERr.cjs → utils-Dn_OA_6N.cjs} +6 -6
- package/dist/{utils-DptI_ERr.cjs.map → utils-Dn_OA_6N.cjs.map} +1 -1
- package/dist/{utils-CTYtskHa.js → utils-Dv1D6ob-.js} +2 -2
- package/dist/{utils-CTYtskHa.js.map → utils-Dv1D6ob-.js.map} +1 -1
- package/dist/{vector-CZ26vo6u.js → vector-Bz-glead.js} +2 -2
- package/dist/{vector-CZ26vo6u.js.map → vector-Bz-glead.js.map} +1 -1
- package/dist/{vector-DBe45tnv.cjs → vector-DIFU_fwU.cjs} +2 -2
- package/dist/{vector-DBe45tnv.cjs.map → vector-DIFU_fwU.cjs.map} +1 -1
- package/dist/voice-C6bAqs79.js +42 -0
- package/dist/voice-C6bAqs79.js.map +1 -0
- package/dist/{voice-CBbxcsCM.cjs → voice-Dk0O5mVD.cjs} +29 -9
- package/dist/voice-Dk0O5mVD.cjs.map +1 -0
- package/dist/{workflow-builder-CkrdTcoM.cjs → workflow-builder-BPUjAdaC.cjs} +5 -5
- package/dist/{workflow-builder-CkrdTcoM.cjs.map → workflow-builder-BPUjAdaC.cjs.map} +1 -1
- package/dist/{workflow-builder-C5ufahUw.js → workflow-builder-D2fwGsLw.js} +5 -5
- package/dist/{workflow-builder-C5ufahUw.js.map → workflow-builder-D2fwGsLw.js.map} +1 -1
- package/dist/{workflows-C_Mqj_80.js → workflows-B-QJ0Tnv.js} +38 -7
- package/dist/workflows-B-QJ0Tnv.js.map +1 -0
- package/dist/{workflows-B5uWFrJ1.cjs → workflows-CwkEHIKW.cjs} +43 -6
- package/dist/workflows-CwkEHIKW.cjs.map +1 -0
- package/dist/{workspace-BwlPQO3M.js → workspace-CbTB2svI.js} +99 -41
- package/dist/workspace-CbTB2svI.js.map +1 -0
- package/dist/{workspace-CD9pQ61P.cjs → workspace-CsPtSXQd.cjs} +99 -41
- package/dist/workspace-CsPtSXQd.cjs.map +1 -0
- package/package.json +13 -6
- package/dist/a2a-DIcMx6x-.cjs.map +0 -1
- package/dist/a2a-DTTGA2Xg.js.map +0 -1
- package/dist/agents-BCgiMlDq.js.map +0 -1
- package/dist/agents-CTgjTASj.js.map +0 -1
- package/dist/agents-CjcvdF2e.cjs.map +0 -1
- package/dist/agents-DjpBmwhv.cjs.map +0 -1
- package/dist/api-schema-manifest-LHpJSi-Y.js.map +0 -1
- package/dist/api-schema-manifest-hPT7_FSw.cjs.map +0 -1
- package/dist/constants-CXAvBYcz.js.map +0 -1
- package/dist/constants-DMg8hUOR.cjs.map +0 -1
- package/dist/conversations-BFqmDglO.cjs.map +0 -1
- package/dist/conversations-BkX00xDs.js.map +0 -1
- package/dist/dist-4NnakSte.js +0 -1
- package/dist/editor-builder-C4H2l6tz.js.map +0 -1
- package/dist/editor-builder-Cqw1npOK.cjs.map +0 -1
- package/dist/helpers-0LJI4DxR.cjs.map +0 -1
- package/dist/helpers-C9QZKOhz.js.map +0 -1
- package/dist/memory-BRE3ofvI.cjs.map +0 -1
- package/dist/memory-Dw7xG5nn.js.map +0 -1
- package/dist/observability-BYIy4kPf.js.map +0 -1
- package/dist/observability-DHJ7mzoE.cjs.map +0 -1
- package/dist/observability-new-endpoints-BOe3wej1.cjs.map +0 -1
- package/dist/observability-new-endpoints-COy7lpeR.js.map +0 -1
- package/dist/plans-D_GKFz2x.js.map +0 -1
- package/dist/plans-_nR8lqgD.cjs.map +0 -1
- package/dist/responses-C_OEJoxU.js.map +0 -1
- package/dist/responses-CdWbS4jA.cjs.map +0 -1
- package/dist/routes-BR7W0b_u.js.map +0 -1
- package/dist/routes-Brf5Qfbu.cjs.map +0 -1
- package/dist/routes-CtGp_lBn.cjs +0 -523
- package/dist/routes-CtGp_lBn.cjs.map +0 -1
- package/dist/routes-MRZFTKei.js +0 -446
- package/dist/routes-MRZFTKei.js.map +0 -1
- package/dist/schedules-BQvnAe1j.cjs.map +0 -1
- package/dist/schedules-BcAIELfB.js.map +0 -1
- package/dist/scores-DEvPN0kz.cjs.map +0 -1
- package/dist/scores-Dm0yu1Pt.js.map +0 -1
- package/dist/server/server-adapter/index.cjs.map +0 -1
- package/dist/server/server-adapter/index.js.map +0 -1
- package/dist/system-DlW760k2.js.map +0 -1
- package/dist/system-zL047vEq.cjs.map +0 -1
- package/dist/tools-BJFq9JKF.js.map +0 -1
- package/dist/tools-Daot5Zgz.cjs.map +0 -1
- package/dist/voice-CBbxcsCM.cjs.map +0 -1
- package/dist/voice-CzFWhWPJ.js +0 -22
- package/dist/voice-CzFWhWPJ.js.map +0 -1
- package/dist/workflows-B5uWFrJ1.cjs.map +0 -1
- package/dist/workflows-C_Mqj_80.js.map +0 -1
- package/dist/workspace-BwlPQO3M.js.map +0 -1
- package/dist/workspace-CD9pQ61P.cjs.map +0 -1
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/_types/@internal_ai-sdk-v4@0.0.95/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/_types/@internal_ai-sdk-v5@0.0.95/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/_types/@internal_ai-v6@0.0.95/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/_types/@standard-schema_spec@1.1.0/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/_types/@types_json-schema@7.0.15/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/index.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/null-to-undefined.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/provider-compats/anthropic.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/provider-compats/deepseek.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/provider-compats/google.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/provider-compats/meta.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/provider-compats/openai-reasoning.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/provider-compats/openai.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/schema-compatibility-v3.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/schema-compatibility-v4.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/schema-compatibility.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/schema.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/schema.types.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/standard-schema/standard-schema.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/standard-schema/standard-schema.types.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/standard-schema-compat.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/types.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/utils.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/dist/zod-to-json.d.ts +0 -0
- /package/dist/_types/{@mastra_schema-compat@1.4.0-alpha.1 → @mastra_schema-compat@1.4.0-alpha.2}/package.json +0 -0
|
@@ -0,0 +1,1376 @@
|
|
|
1
|
+
import { n as standardSchemaToJSONSchema, r as toStandardSchema } from "./schema-TQPB_dl2-CCzMcdDx.js";
|
|
2
|
+
import "./constants-0xZU_h4R.js";
|
|
3
|
+
import { G as getAgentFromSystem, f as GENERATE_AGENT_ROUTE, h as GET_AGENT_BY_ID_ROUTE, v as LIST_AGENTS_ROUTE } from "./agents-BjlUjmb1.js";
|
|
4
|
+
import { a as LIST_TOOLS_ROUTE, i as GET_TOOL_BY_ID_ROUTE, n as EXECUTE_TOOL_ROUTE, o as findTool } from "./tools-oHRh4msa.js";
|
|
5
|
+
import { _ as RESUME_ASYNC_WORKFLOW_ROUTE, a as GET_WORKFLOW_BY_ID_ROUTE, k as listWorkflowsFromSystem, o as GET_WORKFLOW_RUN_BY_ID_ROUTE, s as LIST_WORKFLOWS_ROUTE, t as CANCEL_WORKFLOW_RUN_ROUTE, x as START_ASYNC_WORKFLOW_ROUTE } from "./workflows-B-QJ0Tnv.js";
|
|
6
|
+
import { o as checkRouteRBAC, r as authorizeRoute, s as dispatchRoute } from "./server-adapter-BywLWVKp.js";
|
|
7
|
+
import { c as getBuiltinMCPCapabilities, s as getEffectivePermission } from "./routes-CmkPohqd.js";
|
|
8
|
+
import "./utils-BfySxdfF.js";
|
|
9
|
+
import { S as SEARCH_MEMORY_ROUTE, T as UPDATE_THREAD_ROUTE, _ as LIST_MESSAGES_ROUTE, d as GET_MEMORY_STATUS_ROUTE, f as GET_OBSERVATIONAL_MEMORY_ROUTE, i as CREATE_THREAD_ROUTE, l as GET_MEMORY_CONFIG_ROUTE, m as GET_THREAD_BY_ID_ROUTE, n as CLONE_THREAD_ROUTE, t as AWAIT_BUFFER_STATUS_ROUTE, x as SAVE_MESSAGES_ROUTE, y as LIST_THREADS_ROUTE } from "./memory-CGlo-6_V.js";
|
|
10
|
+
import { L as saveMessagesBodySchema } from "./memory-CCEjoCF6.js";
|
|
11
|
+
import { a as GET_TRACE_ROUTE, i as GET_TRACE_LIGHT_ROUTE, o as GET_TRACE_TRAJECTORY_ROUTE, r as GET_SPAN_ROUTE, u as LIST_TRACES_ROUTE } from "./observability-Z2tDxHS1.js";
|
|
12
|
+
import { A as GET_TRACE_QUERY_FIELDS, D as GET_SCORE_TIME_SERIES, E as GET_SCORE_PERCENTILES, F as LIST_SCORES, L as QUERY_SPANS, M as LIST_FEEDBACK, N as LIST_LOGS, R as QUERY_THREADS, S as GET_METRIC_TIME_SERIES, T as GET_SCORE_BREAKDOWN, _ as GET_METRIC_BREAKDOWN, b as GET_METRIC_NAMES, f as GET_FEEDBACK_AGGREGATE, g as GET_METRIC_AGGREGATE, h as GET_FEEDBACK_TIME_SERIES, j as GET_TRACE_QUERY_VALUES, m as GET_FEEDBACK_PERCENTILES, n as AGGREGATE_TRACES, p as GET_FEEDBACK_BREAKDOWN, t as AGGREGATE_SPANS, v as GET_METRIC_LABEL_KEYS, w as GET_SCORE_AGGREGATE, x as GET_METRIC_PERCENTILES, y as GET_METRIC_LABEL_VALUES, z as QUERY_TRACES } from "./observability-new-endpoints-dr0XcNkP.js";
|
|
13
|
+
import { t as GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE } from "./editor-builder-CGM0scw2.js";
|
|
14
|
+
import { CREATE_STORED_AGENT_ROUTE, GET_STORED_AGENT_ROUTE, LIST_STORED_AGENTS_ROUTE, UPDATE_STORED_AGENT_ROUTE } from "./server/handlers/stored-agents.js";
|
|
15
|
+
import { O as updateStoredAgentBodySchema, n as createStoredAgentBodySchema } from "./stored-agents-DmN_pIIl.js";
|
|
16
|
+
import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
17
|
+
import { createTool } from "@mastra/core/tools";
|
|
18
|
+
import * as coreStorage from "@mastra/core/storage";
|
|
19
|
+
// src/server/mcp/schema.ts
|
|
20
|
+
const object = (properties, required = []) => ({
|
|
21
|
+
type: "object",
|
|
22
|
+
properties,
|
|
23
|
+
required,
|
|
24
|
+
additionalProperties: false
|
|
25
|
+
});
|
|
26
|
+
const str = (description) => ({
|
|
27
|
+
type: "string",
|
|
28
|
+
description
|
|
29
|
+
});
|
|
30
|
+
/** MCP tool schemas default to JSON Schema 2020-12 (e.g. tuples are `prefixItems`, not array-valued `items`). */
|
|
31
|
+
function toJSONSchema(schema) {
|
|
32
|
+
if (!schema) return void 0;
|
|
33
|
+
try {
|
|
34
|
+
const { $schema: _dialect, ...json } = standardSchemaToJSONSchema(toStandardSchema(schema), {
|
|
35
|
+
io: "input",
|
|
36
|
+
target: "draft-2020-12"
|
|
37
|
+
});
|
|
38
|
+
return json;
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Shrinks a tool schema without changing what it accepts, and keeps it portable:
|
|
45
|
+
* - drops regex `pattern`s that only restate `format: date-time` (most of a time-range schema's size);
|
|
46
|
+
* - spells a closed tuple (`prefixItems` + `items: false`) as `maxItems`, since some clients reject bare `false`.
|
|
47
|
+
*/
|
|
48
|
+
function compact(node) {
|
|
49
|
+
if (Array.isArray(node)) return node.map(compact);
|
|
50
|
+
if (!node || typeof node !== "object") return node;
|
|
51
|
+
const { pattern, ...rest } = node;
|
|
52
|
+
const kept = rest.format === "date-time" || pattern === void 0 ? rest : {
|
|
53
|
+
...rest,
|
|
54
|
+
pattern
|
|
55
|
+
};
|
|
56
|
+
if (kept.items === false && Array.isArray(kept.prefixItems)) {
|
|
57
|
+
delete kept.items;
|
|
58
|
+
kept.maxItems ??= kept.prefixItems.length;
|
|
59
|
+
}
|
|
60
|
+
return Object.fromEntries(Object.entries(kept).map(([key, value]) => [key, compact(value)]));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Moves sub-schemas repeated within one tool schema (e.g. predicate operands) into `$defs`. The schema
|
|
64
|
+
* accepts exactly the same input; it is just shorter. Schemas here already use `$defs`/`$ref`.
|
|
65
|
+
*/
|
|
66
|
+
const MAPS = /* @__PURE__ */ new Set([
|
|
67
|
+
"properties",
|
|
68
|
+
"patternProperties",
|
|
69
|
+
"$defs",
|
|
70
|
+
"definitions"
|
|
71
|
+
]);
|
|
72
|
+
const SCHEMA_KEYS = /* @__PURE__ */ new Set([
|
|
73
|
+
"items",
|
|
74
|
+
"additionalProperties",
|
|
75
|
+
"anyOf",
|
|
76
|
+
"oneOf",
|
|
77
|
+
"allOf",
|
|
78
|
+
"not",
|
|
79
|
+
"prefixItems",
|
|
80
|
+
"contains"
|
|
81
|
+
]);
|
|
82
|
+
function hoistRepeated(schema) {
|
|
83
|
+
const root = schema;
|
|
84
|
+
const defs = { ...root.$defs };
|
|
85
|
+
let body = {
|
|
86
|
+
...root,
|
|
87
|
+
$defs: void 0
|
|
88
|
+
};
|
|
89
|
+
for (let n = 0;; n++) {
|
|
90
|
+
const counts = /* @__PURE__ */ new Map();
|
|
91
|
+
const visit = (node, isSchema) => {
|
|
92
|
+
if (!node || typeof node !== "object") return;
|
|
93
|
+
const json = JSON.stringify(node);
|
|
94
|
+
if (isSchema && !Array.isArray(node) && json.length > 150) counts.set(json, (counts.get(json) ?? 0) + 1);
|
|
95
|
+
for (const [key, child] of Object.entries(node)) if (MAPS.has(key) && !Array.isArray(node)) for (const value of Object.values(child ?? {})) visit(value, true);
|
|
96
|
+
else visit(child, Array.isArray(node) || SCHEMA_KEYS.has(key));
|
|
97
|
+
};
|
|
98
|
+
for (const [key, value] of Object.entries(body)) if (MAPS.has(key)) for (const child of Object.values(value ?? {})) visit(child, true);
|
|
99
|
+
else visit(value, SCHEMA_KEYS.has(key));
|
|
100
|
+
for (const value of Object.values(defs)) visit(value, false);
|
|
101
|
+
const [repeated] = [...counts].filter(([, count]) => count > 1).sort(([a], [b]) => b.length - a.length);
|
|
102
|
+
if (!repeated) break;
|
|
103
|
+
const name = `mcp${n}`;
|
|
104
|
+
const target = repeated[0];
|
|
105
|
+
defs[name] = JSON.parse(target);
|
|
106
|
+
const replace = (node, isSchema = true) => {
|
|
107
|
+
if (!node || typeof node !== "object") return node;
|
|
108
|
+
if (isSchema && !Array.isArray(node) && JSON.stringify(node) === target) return { $ref: `#/$defs/${name}` };
|
|
109
|
+
if (Array.isArray(node)) return node.map((item) => replace(item));
|
|
110
|
+
return Object.fromEntries(Object.entries(node).map(([key, value]) => [key, MAPS.has(key) ? Object.fromEntries(Object.entries(value ?? {}).map(([k, v]) => [k, replace(v)])) : replace(value, SCHEMA_KEYS.has(key))]));
|
|
111
|
+
};
|
|
112
|
+
body = replace(body, false);
|
|
113
|
+
for (const key of Object.keys(defs)) if (key !== name) defs[key] = replace(defs[key], false);
|
|
114
|
+
}
|
|
115
|
+
const { $defs: _unused, ...rest } = body;
|
|
116
|
+
return Object.keys(defs).length ? {
|
|
117
|
+
...rest,
|
|
118
|
+
$defs: defs
|
|
119
|
+
} : rest;
|
|
120
|
+
}
|
|
121
|
+
// src/server/mcp/result-size.ts
|
|
122
|
+
/**
|
|
123
|
+
* Most MCP clients cap a tool result at roughly 25k tokens (Claude Code drops larger results). Tools that
|
|
124
|
+
* return lists keep their serialized result under this many characters.
|
|
125
|
+
*/
|
|
126
|
+
const MAX_RESULT_CHARS = 4e4;
|
|
127
|
+
/** String lengths tried, longest first, when clipping a value that doesn't fit. */
|
|
128
|
+
const CLIP_LENGTHS = [
|
|
129
|
+
1e4,
|
|
130
|
+
2e3,
|
|
131
|
+
500,
|
|
132
|
+
100
|
|
133
|
+
];
|
|
134
|
+
/** Ids stay whole so the caller can still look the full item up (`id`, `spanId`, `trace_id`, ...). */
|
|
135
|
+
const isIdKey = (key) => key === "id" || /(Id|_id)$/.test(key);
|
|
136
|
+
const isObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
137
|
+
const isPlainObject = (value) => isObject$1(value) && [Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
138
|
+
const fits = (value) => JSON.stringify(value).length <= MAX_RESULT_CHARS;
|
|
139
|
+
/** Cuts every string longer than `max` to `max` characters plus a marker; keys, ids and other values stay. */
|
|
140
|
+
function clipStrings(value, max, detail) {
|
|
141
|
+
if (typeof value === "string") {
|
|
142
|
+
if (value.length <= max) return value;
|
|
143
|
+
const how = detail ? `, use ${detail} for the full value` : "";
|
|
144
|
+
return `${value.slice(0, max)}[truncated ${value.length - max} chars${how}]`;
|
|
145
|
+
}
|
|
146
|
+
if (Array.isArray(value)) return value.map((item) => clipStrings(item, max, detail));
|
|
147
|
+
if (isPlainObject(value)) return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, isIdKey(key) ? item : clipStrings(item, max, detail)]));
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
/** `build` with its long strings clipped as little as it takes to fit (or down to 100 characters). */
|
|
151
|
+
function clipToFit(build, detail) {
|
|
152
|
+
let clipped;
|
|
153
|
+
for (const max of CLIP_LENGTHS) {
|
|
154
|
+
clipped = build((value) => clipStrings(value, max, detail));
|
|
155
|
+
if (fits(clipped)) break;
|
|
156
|
+
}
|
|
157
|
+
return clipped;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Keeps a single-record result under {@link MAX_RESULT_CHARS} by clipping its long strings. `detail` names the
|
|
161
|
+
* tool that returns full values, if there is one. Results that already fit pass through unchanged.
|
|
162
|
+
*/
|
|
163
|
+
function fitValue(result, detail) {
|
|
164
|
+
return fits(result) ? result : clipToFit((clip) => clip(result), detail);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Keeps a list result under {@link MAX_RESULT_CHARS} by dropping trailing rows of `key` and says how to page.
|
|
168
|
+
* It always keeps at least one row: when the first row alone is too big, its long strings are clipped. Results
|
|
169
|
+
* that already fit, or aren't a list, pass through unchanged.
|
|
170
|
+
*/
|
|
171
|
+
function fitRows(result, key, hint, { cursors = [], views = [], detail } = {}) {
|
|
172
|
+
if (!isObject$1(result) || !Array.isArray(result[key]) || fits(result)) return result;
|
|
173
|
+
const rows = result[key];
|
|
174
|
+
const without = (fields) => Object.fromEntries(Object.entries(result).filter(([field]) => field !== key && !fields.includes(field)));
|
|
175
|
+
const allRows = {
|
|
176
|
+
...without(views),
|
|
177
|
+
[key]: rows
|
|
178
|
+
};
|
|
179
|
+
if (views.length > 0 && fits(allRows)) return allRows;
|
|
180
|
+
const rest = without([...cursors, ...views]);
|
|
181
|
+
const build = (count) => ({
|
|
182
|
+
...rest,
|
|
183
|
+
[key]: rows.slice(0, count),
|
|
184
|
+
truncated: `Only the first ${count} of ${rows.length} ${key} fit in one result. ${hint}`
|
|
185
|
+
});
|
|
186
|
+
let low = 0;
|
|
187
|
+
let high = rows.length - 1;
|
|
188
|
+
while (low < high) {
|
|
189
|
+
const mid = Math.ceil((low + high) / 2);
|
|
190
|
+
if (fits(build(mid))) low = mid;
|
|
191
|
+
else high = mid - 1;
|
|
192
|
+
}
|
|
193
|
+
if (low > 0 || rows.length === 0) return build(low);
|
|
194
|
+
const kept = rows.length > 1 ? rest : without(views);
|
|
195
|
+
return clipToFit((clip) => ({
|
|
196
|
+
...kept,
|
|
197
|
+
[key]: [clip(rows[0])],
|
|
198
|
+
truncated: rows.length > 1 ? `Only the first of ${rows.length} ${key} fits in one result, with its long values cut. ${hint}` : `Long values in the ${key} were cut to fit in one result.`
|
|
199
|
+
}), detail);
|
|
200
|
+
}
|
|
201
|
+
// src/server/mcp/toolsets/memory.ts
|
|
202
|
+
const PER_PAGE_HINT$1 = "Call again with a smaller perPage to page through every item.";
|
|
203
|
+
const PAGINATION = ["hasMore"];
|
|
204
|
+
const int = (description) => ({
|
|
205
|
+
type: "integer",
|
|
206
|
+
minimum: 0,
|
|
207
|
+
description
|
|
208
|
+
});
|
|
209
|
+
const metadata = {
|
|
210
|
+
type: "object",
|
|
211
|
+
description: "Arbitrary metadata."
|
|
212
|
+
};
|
|
213
|
+
/** Drops undefined values so optional arguments are not sent as empty query params. */
|
|
214
|
+
const defined = (values) => Object.fromEntries(Object.entries(values).filter(([, value]) => value !== void 0));
|
|
215
|
+
/**
|
|
216
|
+
* Memory: Observational Memory, threads, and messages. Every route enforces thread/resource ownership itself.
|
|
217
|
+
* A tool given an `agentId` left out by include/exclude returns "not found", as in the agents toolset; threads
|
|
218
|
+
* read by `threadId` or listed without an `agentId` aren't filtered by agent, as on the HTTP routes.
|
|
219
|
+
*/
|
|
220
|
+
async function addMemoryTools(kit) {
|
|
221
|
+
const { addOperation, addCombined, requestContext } = kit;
|
|
222
|
+
const call = async (route, input, signal) => {
|
|
223
|
+
const agentId = input.query?.agentId ?? input.body?.agentId;
|
|
224
|
+
if (typeof agentId === "string") await kit.requireSelected("agents", agentId, "Agent");
|
|
225
|
+
return kit.call(route, input, signal);
|
|
226
|
+
};
|
|
227
|
+
const agentIds = await kit.visibleAgentIds();
|
|
228
|
+
const agentId = kit.idParam("Agent", agentIds, "list_agents");
|
|
229
|
+
const resourceId = str("Owner of the memory, for example a user id. Defaults to you when the server maps users to resources.");
|
|
230
|
+
const threadId = str("Thread id.");
|
|
231
|
+
const contextResource = (args) => args.resourceId ?? requestContext.get("mastra__resourceId");
|
|
232
|
+
const omScope = {
|
|
233
|
+
agentId,
|
|
234
|
+
threadId: str("Thread id. Omit for resource-scoped Observational Memory."),
|
|
235
|
+
resourceId
|
|
236
|
+
};
|
|
237
|
+
const canWait = kit.permitted(AWAIT_BUFFER_STATUS_ROUTE);
|
|
238
|
+
const waitForPending = {
|
|
239
|
+
type: "boolean",
|
|
240
|
+
description: "Set true right after call_agent to wait (up to 30s) for Observational Memory to finish processing recent messages before reading. Returns an error if the agent has no Observational Memory."
|
|
241
|
+
};
|
|
242
|
+
addOperation(GET_OBSERVATIONAL_MEMORY_ROUTE, object(canWait ? {
|
|
243
|
+
...omScope,
|
|
244
|
+
waitForPending
|
|
245
|
+
} : omScope, ["agentId"]), async (args, signal) => {
|
|
246
|
+
const scope = defined({
|
|
247
|
+
agentId: args.agentId,
|
|
248
|
+
threadId: args.threadId,
|
|
249
|
+
resourceId: args.resourceId
|
|
250
|
+
});
|
|
251
|
+
if (canWait && args.waitForPending === true) return fitValue(await call(AWAIT_BUFFER_STATUS_ROUTE, { body: scope }, signal));
|
|
252
|
+
return fitValue({ record: (await call(GET_OBSERVATIONAL_MEMORY_ROUTE, { query: {
|
|
253
|
+
...scope,
|
|
254
|
+
limit: 1
|
|
255
|
+
} }, signal))?.record ?? null });
|
|
256
|
+
});
|
|
257
|
+
const page = {
|
|
258
|
+
page: int("Page number, from 0."),
|
|
259
|
+
perPage: int("Items per page.")
|
|
260
|
+
};
|
|
261
|
+
addOperation(LIST_THREADS_ROUTE, object({
|
|
262
|
+
agentId: {
|
|
263
|
+
...agentId,
|
|
264
|
+
description: "Agent whose memory to list. Optional."
|
|
265
|
+
},
|
|
266
|
+
resourceId,
|
|
267
|
+
...page
|
|
268
|
+
}), async (args, signal) => fitRows(await call(LIST_THREADS_ROUTE, { query: defined(args) }, signal), "threads", PER_PAGE_HINT$1, { cursors: PAGINATION }));
|
|
269
|
+
addOperation(GET_THREAD_BY_ID_ROUTE, object({
|
|
270
|
+
threadId,
|
|
271
|
+
agentId: {
|
|
272
|
+
...agentId,
|
|
273
|
+
description: "Agent whose memory holds the thread. Optional."
|
|
274
|
+
}
|
|
275
|
+
}, ["threadId"]), (args, signal) => call(GET_THREAD_BY_ID_ROUTE, {
|
|
276
|
+
pathParams: { threadId: args.threadId },
|
|
277
|
+
query: defined({ agentId: args.agentId })
|
|
278
|
+
}, signal));
|
|
279
|
+
addOperation(LIST_MESSAGES_ROUTE, object({
|
|
280
|
+
threadId,
|
|
281
|
+
agentId: {
|
|
282
|
+
...agentId,
|
|
283
|
+
description: "Agent whose memory holds the thread. Optional."
|
|
284
|
+
},
|
|
285
|
+
...page
|
|
286
|
+
}, ["threadId"]), async (args, signal) => {
|
|
287
|
+
const { threadId: id, ...query } = args;
|
|
288
|
+
return fitRows(await call(LIST_MESSAGES_ROUTE, {
|
|
289
|
+
pathParams: { threadId: id },
|
|
290
|
+
query: defined(query)
|
|
291
|
+
}, signal), "messages", PER_PAGE_HINT$1, {
|
|
292
|
+
cursors: PAGINATION,
|
|
293
|
+
views: ["uiMessages"]
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
addOperation(SEARCH_MEMORY_ROUTE, object({
|
|
297
|
+
agentId,
|
|
298
|
+
searchQuery: str("What to search for."),
|
|
299
|
+
resourceId,
|
|
300
|
+
threadId: str("Only search this thread."),
|
|
301
|
+
limit: int("Maximum results. Defaults to 20.")
|
|
302
|
+
}, ["agentId", "searchQuery"]), (args, signal) => call(SEARCH_MEMORY_ROUTE, { query: defined({
|
|
303
|
+
...args,
|
|
304
|
+
resourceId: contextResource(args)
|
|
305
|
+
}) }, signal));
|
|
306
|
+
addCombined([GET_MEMORY_STATUS_ROUTE, GET_MEMORY_CONFIG_ROUTE], object({
|
|
307
|
+
agentId,
|
|
308
|
+
resourceId,
|
|
309
|
+
threadId
|
|
310
|
+
}, ["agentId"]), async (args, signal) => {
|
|
311
|
+
const status = await call(GET_MEMORY_STATUS_ROUTE, { query: defined(args) }, signal);
|
|
312
|
+
const config = await call(GET_MEMORY_CONFIG_ROUTE, { query: { agentId: args.agentId } }, signal);
|
|
313
|
+
return {
|
|
314
|
+
status,
|
|
315
|
+
config: config?.config ?? config
|
|
316
|
+
};
|
|
317
|
+
});
|
|
318
|
+
addOperation(CREATE_THREAD_ROUTE, object({
|
|
319
|
+
agentId,
|
|
320
|
+
resourceId,
|
|
321
|
+
title: str("Thread title."),
|
|
322
|
+
metadata,
|
|
323
|
+
threadId: str("Id for the new thread. Generated if omitted.")
|
|
324
|
+
}, ["agentId"]), (args, signal) => {
|
|
325
|
+
const { agentId: id, ...body } = args;
|
|
326
|
+
return call(CREATE_THREAD_ROUTE, {
|
|
327
|
+
query: { agentId: id },
|
|
328
|
+
body: defined({
|
|
329
|
+
...body,
|
|
330
|
+
resourceId: contextResource(args)
|
|
331
|
+
})
|
|
332
|
+
}, signal);
|
|
333
|
+
});
|
|
334
|
+
addOperation(UPDATE_THREAD_ROUTE, object({
|
|
335
|
+
threadId,
|
|
336
|
+
agentId,
|
|
337
|
+
title: str("New title."),
|
|
338
|
+
metadata
|
|
339
|
+
}, ["threadId", "agentId"]), (args, signal) => call(UPDATE_THREAD_ROUTE, {
|
|
340
|
+
pathParams: { threadId: args.threadId },
|
|
341
|
+
query: { agentId: args.agentId },
|
|
342
|
+
body: defined({
|
|
343
|
+
title: args.title,
|
|
344
|
+
metadata: args.metadata
|
|
345
|
+
})
|
|
346
|
+
}, signal));
|
|
347
|
+
addOperation(CLONE_THREAD_ROUTE, object({
|
|
348
|
+
threadId: str("Thread to copy."),
|
|
349
|
+
agentId,
|
|
350
|
+
newThreadId: str("Id for the copy. Generated if omitted."),
|
|
351
|
+
title: str("Title for the copy."),
|
|
352
|
+
metadata,
|
|
353
|
+
messageLimit: int("Only copy the most recent N messages.")
|
|
354
|
+
}, ["threadId", "agentId"]), (args, signal) => call(CLONE_THREAD_ROUTE, {
|
|
355
|
+
pathParams: { threadId: args.threadId },
|
|
356
|
+
query: { agentId: args.agentId },
|
|
357
|
+
body: defined({
|
|
358
|
+
newThreadId: args.newThreadId,
|
|
359
|
+
title: args.title,
|
|
360
|
+
metadata: args.metadata,
|
|
361
|
+
options: args.messageLimit === void 0 ? void 0 : { messageLimit: args.messageLimit }
|
|
362
|
+
})
|
|
363
|
+
}, signal));
|
|
364
|
+
const messages = toJSONSchema(saveMessagesBodySchema)?.properties?.messages;
|
|
365
|
+
addOperation(SAVE_MESSAGES_ROUTE, object({
|
|
366
|
+
agentId,
|
|
367
|
+
messages: typeof messages === "object" ? messages : {
|
|
368
|
+
type: "array",
|
|
369
|
+
items: { type: "object" }
|
|
370
|
+
}
|
|
371
|
+
}, ["agentId", "messages"]), (args, signal) => call(SAVE_MESSAGES_ROUTE, {
|
|
372
|
+
query: { agentId: args.agentId },
|
|
373
|
+
body: { messages: args.messages }
|
|
374
|
+
}, signal));
|
|
375
|
+
}
|
|
376
|
+
// src/server/mcp/toolsets/observability.ts
|
|
377
|
+
const COMBINATORS = [
|
|
378
|
+
"anyOf",
|
|
379
|
+
"oneOf",
|
|
380
|
+
"allOf",
|
|
381
|
+
"not"
|
|
382
|
+
];
|
|
383
|
+
const DELTA_POLLING = [
|
|
384
|
+
"mode",
|
|
385
|
+
"after",
|
|
386
|
+
"limit"
|
|
387
|
+
];
|
|
388
|
+
/**
|
|
389
|
+
* Every way an observability list says where to continue: keyset `page`, offset `pagination`, and delta polling's
|
|
390
|
+
* `delta` / `deltaCursor` (the tool schemas don't offer delta polling, but the routes still accept it). All of them
|
|
391
|
+
* would skip rows that were cut, so a cut page drops whichever it has.
|
|
392
|
+
*/
|
|
393
|
+
const CURSORS = [
|
|
394
|
+
"page",
|
|
395
|
+
"pagination",
|
|
396
|
+
"delta",
|
|
397
|
+
"deltaCursor"
|
|
398
|
+
];
|
|
399
|
+
const PAGE_LIMIT_HINT = "Call again with a smaller page.limit and follow page.next to see every row.";
|
|
400
|
+
const PER_PAGE_HINT = "Call again with a smaller perPage to page through every row.";
|
|
401
|
+
const LIGHT_SPAN_FIELDS = Object.keys(coreStorage.getTraceLightResponseSchema.shape.spans.element.shape);
|
|
402
|
+
/** Light span record with its status (stores may omit it; the UI derives it the same way). */
|
|
403
|
+
function lightSpan(span) {
|
|
404
|
+
return {
|
|
405
|
+
...Object.fromEntries(LIGHT_SPAN_FIELDS.filter((key) => key in span).map((key) => [key, span[key]])),
|
|
406
|
+
status: span.status ?? coreStorage.computeTraceStatus(span)
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* MCP clients (and the Anthropic API) need a plain `type: object` input schema without top-level combinators.
|
|
411
|
+
* The route still validates the full body; the tool schema leaves out delta polling, which needs a client loop.
|
|
412
|
+
*/
|
|
413
|
+
function asObjectSchema(schema) {
|
|
414
|
+
if (!schema || schema.type !== "object" || COMBINATORS.some((key) => key in schema)) return {
|
|
415
|
+
type: "object",
|
|
416
|
+
additionalProperties: true
|
|
417
|
+
};
|
|
418
|
+
const properties = { ...schema.properties };
|
|
419
|
+
if (properties.mode) for (const key of DELTA_POLLING) delete properties[key];
|
|
420
|
+
if (properties.page && properties.pagination) delete properties.pagination;
|
|
421
|
+
return compact({
|
|
422
|
+
...schema,
|
|
423
|
+
properties
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* List routes take filters as flat query params, where complex values may also arrive as JSON strings.
|
|
428
|
+
* The tool schema keeps the structured branch and drops delta polling, which an MCP client cannot use.
|
|
429
|
+
*/
|
|
430
|
+
function listQuerySchema(route) {
|
|
431
|
+
const json = toJSONSchema(route.queryParamSchema);
|
|
432
|
+
const properties = {};
|
|
433
|
+
for (const [key, value] of Object.entries(json?.properties ?? {})) {
|
|
434
|
+
if (DELTA_POLLING.includes(key)) continue;
|
|
435
|
+
const branches = value.anyOf ?? [];
|
|
436
|
+
const structured = branches.filter((branch) => branch.type !== "string" || branch.enum || branch.format);
|
|
437
|
+
properties[key] = branches.length > 1 && structured.length === 1 ? structured[0] : value;
|
|
438
|
+
}
|
|
439
|
+
return compact({
|
|
440
|
+
type: "object",
|
|
441
|
+
properties
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
const OPS = [
|
|
445
|
+
"aggregate",
|
|
446
|
+
"breakdown",
|
|
447
|
+
"timeseries",
|
|
448
|
+
"percentiles"
|
|
449
|
+
];
|
|
450
|
+
/**
|
|
451
|
+
* One `analyze_<source>` tool per family (D15). The per-op body fields are merged into one flat object
|
|
452
|
+
* (each field says which ops use it); the call goes to that op's own route, which validates the body
|
|
453
|
+
* and authorizes the call.
|
|
454
|
+
*/
|
|
455
|
+
function analyzeSchema(routes) {
|
|
456
|
+
const variants = /* @__PURE__ */ new Map();
|
|
457
|
+
const usedBy = /* @__PURE__ */ new Map();
|
|
458
|
+
const required = /* @__PURE__ */ new Map();
|
|
459
|
+
const defs = {};
|
|
460
|
+
for (const op of OPS) {
|
|
461
|
+
const json = JSON.parse(JSON.stringify(asObjectSchema(toJSONSchema(routes[op].bodySchema))).replaceAll("#/$defs/", `#/$defs/${op}_`));
|
|
462
|
+
for (const [name, def] of Object.entries(json.$defs ?? {})) defs[`${op}_${name}`] = def;
|
|
463
|
+
for (const [key, value] of Object.entries(json.properties ?? {})) {
|
|
464
|
+
const { description: _description, ...shape } = value;
|
|
465
|
+
if (!variants.has(key)) variants.set(key, /* @__PURE__ */ new Map());
|
|
466
|
+
if (!variants.get(key).has(JSON.stringify(shape))) variants.get(key).set(JSON.stringify(shape), value);
|
|
467
|
+
usedBy.set(key, [...usedBy.get(key) ?? [], op]);
|
|
468
|
+
}
|
|
469
|
+
for (const key of json.required ?? []) required.set(key, (required.get(key) ?? 0) + 1);
|
|
470
|
+
}
|
|
471
|
+
const properties = {};
|
|
472
|
+
for (const [key, shapes] of variants) {
|
|
473
|
+
const all = [...shapes.values()];
|
|
474
|
+
properties[key] = all.length === 1 ? all[0] : {
|
|
475
|
+
anyOf: all.map(({ description: _description, ...shape }) => shape),
|
|
476
|
+
description: all[0].description
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
for (const [key, ops] of usedBy) {
|
|
480
|
+
const scope = ops.length === OPS.length ? "" : ` Used by op: ${ops.join(", ")}.`;
|
|
481
|
+
const needed = ops.length !== OPS.length && required.get(key) ? ` Required for ${ops.join(", ")}.` : "";
|
|
482
|
+
if (scope || needed) {
|
|
483
|
+
const prop = properties[key];
|
|
484
|
+
properties[key] = {
|
|
485
|
+
...prop,
|
|
486
|
+
description: `${prop.description ?? ""}${scope}${needed}`.trim()
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const alwaysRequired = [...required].filter(([, count]) => count === OPS.length).map(([key]) => key);
|
|
491
|
+
return {
|
|
492
|
+
...Object.keys(defs).length ? { $defs: defs } : {},
|
|
493
|
+
type: "object",
|
|
494
|
+
properties: {
|
|
495
|
+
op: {
|
|
496
|
+
type: "string",
|
|
497
|
+
enum: [...OPS],
|
|
498
|
+
description: "aggregate: one value; breakdown: grouped by labels; timeseries: bucketed over time; percentiles: distribution."
|
|
499
|
+
},
|
|
500
|
+
...properties
|
|
501
|
+
},
|
|
502
|
+
required: ["op", ...alwaysRequired]
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
/** Observability (traces, spans, logs) and observability analytics (metrics, scores, feedback). */
|
|
506
|
+
function addObservabilityTools(kit) {
|
|
507
|
+
const { call, addOperation, addCombined, config } = kit;
|
|
508
|
+
if (config.toolsets.has("observability")) {
|
|
509
|
+
const bodyTool = (route, rows, schema = route.bodySchema) => addOperation(route, hoistRepeated(asObjectSchema(toJSONSchema(schema))), async (args, signal) => {
|
|
510
|
+
const result = await call(route, { body: args }, signal);
|
|
511
|
+
return rows ? fitRows(result, rows, PAGE_LIMIT_HINT, {
|
|
512
|
+
cursors: CURSORS,
|
|
513
|
+
detail: rows === "traces" || rows === "spans" ? "get_span" : void 0
|
|
514
|
+
}) : result;
|
|
515
|
+
});
|
|
516
|
+
bodyTool(QUERY_TRACES, "traces");
|
|
517
|
+
bodyTool(AGGREGATE_TRACES);
|
|
518
|
+
bodyTool(QUERY_SPANS, "spans");
|
|
519
|
+
bodyTool(AGGREGATE_SPANS);
|
|
520
|
+
bodyTool(QUERY_THREADS, "threads", coreStorage.threadQueryRequestSchema);
|
|
521
|
+
bodyTool(GET_TRACE_QUERY_FIELDS);
|
|
522
|
+
bodyTool(GET_TRACE_QUERY_VALUES);
|
|
523
|
+
const traceId = str("Trace id.");
|
|
524
|
+
const { traceStructure } = kit.capabilities;
|
|
525
|
+
addOperation(GET_TRACE_LIGHT_ROUTE, object({
|
|
526
|
+
traceId,
|
|
527
|
+
offset: {
|
|
528
|
+
type: "integer",
|
|
529
|
+
minimum: 0,
|
|
530
|
+
description: "Spans to skip: the nextOffset of a truncated result."
|
|
531
|
+
}
|
|
532
|
+
}, ["traceId"]), async (args, signal) => {
|
|
533
|
+
const trace = await call(traceStructure ? GET_TRACE_LIGHT_ROUTE : GET_TRACE_ROUTE, { pathParams: { traceId: args.traceId } }, signal);
|
|
534
|
+
const spans = Array.isArray(trace?.spans) ? trace.spans : [];
|
|
535
|
+
const offset = typeof args.offset === "number" ? args.offset : 0;
|
|
536
|
+
const page = spans.slice(offset).map(lightSpan);
|
|
537
|
+
const result = fitRows({
|
|
538
|
+
traceId: trace?.traceId ?? args.traceId,
|
|
539
|
+
spanCount: spans.length,
|
|
540
|
+
...offset ? { offset } : {},
|
|
541
|
+
spans: page
|
|
542
|
+
}, "spans", "Call get_trace again with offset: nextOffset for the rest.", { detail: "get_span" });
|
|
543
|
+
const kept = result.spans.length;
|
|
544
|
+
return kept < page.length ? {
|
|
545
|
+
...result,
|
|
546
|
+
nextOffset: offset + kept
|
|
547
|
+
} : result;
|
|
548
|
+
});
|
|
549
|
+
addOperation(GET_SPAN_ROUTE, object({
|
|
550
|
+
traceId,
|
|
551
|
+
spanId: str("Span id.")
|
|
552
|
+
}, ["traceId", "spanId"]), (args, signal) => call(GET_SPAN_ROUTE, { pathParams: {
|
|
553
|
+
traceId: args.traceId,
|
|
554
|
+
spanId: args.spanId
|
|
555
|
+
} }, signal));
|
|
556
|
+
addOperation(GET_TRACE_TRAJECTORY_ROUTE, object({ traceId }, ["traceId"]), (args, signal) => call(GET_TRACE_TRAJECTORY_ROUTE, { pathParams: { traceId: args.traceId } }, signal));
|
|
557
|
+
addOperation(LIST_TRACES_ROUTE, hoistRepeated(listQuerySchema(LIST_TRACES_ROUTE)), async (args, signal) => fitRows(await call(LIST_TRACES_ROUTE, { query: args }, signal), "spans", PER_PAGE_HINT, {
|
|
558
|
+
cursors: CURSORS,
|
|
559
|
+
detail: "get_span"
|
|
560
|
+
}));
|
|
561
|
+
addOperation(LIST_LOGS, hoistRepeated(listQuerySchema(LIST_LOGS)), async (args, signal) => fitRows(await call(LIST_LOGS, { query: args }, signal), "logs", PER_PAGE_HINT, { cursors: CURSORS }));
|
|
562
|
+
}
|
|
563
|
+
if (config.toolsets.has("observability_analytics")) {
|
|
564
|
+
for (const [route, key] of [[LIST_SCORES, "scores"], [LIST_FEEDBACK, "feedback"]]) addOperation(route, hoistRepeated(listQuerySchema(route)), async (args, signal) => fitRows(await call(route, { query: args }, signal), key, PER_PAGE_HINT, { cursors: CURSORS }));
|
|
565
|
+
const analyze = (routes) => addCombined(Object.values(routes), hoistRepeated(analyzeSchema(routes)), (args, signal) => {
|
|
566
|
+
const { op, ...body } = args;
|
|
567
|
+
const route = typeof op === "string" && Object.hasOwn(routes, op) ? routes[op] : void 0;
|
|
568
|
+
if (!route) throw toolError(400, `Unknown op "${String(op)}". Use one of: ${OPS.join(", ")}.`);
|
|
569
|
+
return call(route, { body }, signal);
|
|
570
|
+
});
|
|
571
|
+
analyze({
|
|
572
|
+
aggregate: GET_METRIC_AGGREGATE,
|
|
573
|
+
breakdown: GET_METRIC_BREAKDOWN,
|
|
574
|
+
timeseries: GET_METRIC_TIME_SERIES,
|
|
575
|
+
percentiles: GET_METRIC_PERCENTILES
|
|
576
|
+
});
|
|
577
|
+
analyze({
|
|
578
|
+
aggregate: GET_SCORE_AGGREGATE,
|
|
579
|
+
breakdown: GET_SCORE_BREAKDOWN,
|
|
580
|
+
timeseries: GET_SCORE_TIME_SERIES,
|
|
581
|
+
percentiles: GET_SCORE_PERCENTILES
|
|
582
|
+
});
|
|
583
|
+
analyze({
|
|
584
|
+
aggregate: GET_FEEDBACK_AGGREGATE,
|
|
585
|
+
breakdown: GET_FEEDBACK_BREAKDOWN,
|
|
586
|
+
timeseries: GET_FEEDBACK_TIME_SERIES,
|
|
587
|
+
percentiles: GET_FEEDBACK_PERCENTILES
|
|
588
|
+
});
|
|
589
|
+
addCombined([
|
|
590
|
+
GET_METRIC_NAMES,
|
|
591
|
+
GET_METRIC_LABEL_KEYS,
|
|
592
|
+
GET_METRIC_LABEL_VALUES
|
|
593
|
+
], object({
|
|
594
|
+
metricName: str("List the label keys of this metric (or, with labelKey, one label’s values)."),
|
|
595
|
+
labelKey: str("With metricName, list the values of this label."),
|
|
596
|
+
prefix: str("Only names or values starting with this."),
|
|
597
|
+
limit: {
|
|
598
|
+
type: "integer",
|
|
599
|
+
minimum: 1,
|
|
600
|
+
description: "Maximum results."
|
|
601
|
+
}
|
|
602
|
+
}), (args, signal) => {
|
|
603
|
+
const { metricName, labelKey, prefix, limit } = args;
|
|
604
|
+
if (labelKey && !metricName) throw toolError(400, "labelKey needs metricName.");
|
|
605
|
+
if (metricName && labelKey) return call(GET_METRIC_LABEL_VALUES, { query: {
|
|
606
|
+
metricName,
|
|
607
|
+
labelKey,
|
|
608
|
+
prefix,
|
|
609
|
+
limit
|
|
610
|
+
} }, signal);
|
|
611
|
+
if (metricName) return call(GET_METRIC_LABEL_KEYS, { query: { metricName } }, signal);
|
|
612
|
+
return call(GET_METRIC_NAMES, { query: {
|
|
613
|
+
prefix,
|
|
614
|
+
limit
|
|
615
|
+
} }, signal);
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
// src/server/mcp/toolsets/stored-agents.ts
|
|
620
|
+
const PUBLISH_DESCRIPTION = "Publish the change so call_agent uses it right away. Defaults to true.";
|
|
621
|
+
function bodySchema(schema, omit) {
|
|
622
|
+
const json = toJSONSchema(schema) ?? { type: "object" };
|
|
623
|
+
const properties = { ...json.properties };
|
|
624
|
+
for (const key of omit) delete properties[key];
|
|
625
|
+
properties.autoPublish = {
|
|
626
|
+
type: "boolean",
|
|
627
|
+
description: PUBLISH_DESCRIPTION
|
|
628
|
+
};
|
|
629
|
+
return hoistRepeated(compact({
|
|
630
|
+
...json,
|
|
631
|
+
properties,
|
|
632
|
+
required: (json.required ?? []).filter((key) => !omit.includes(key))
|
|
633
|
+
}));
|
|
634
|
+
}
|
|
635
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
636
|
+
/** The keys of a stored model the editor reads: what it runs (`provider/name`) and its model settings. */
|
|
637
|
+
const MODEL_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
638
|
+
"provider",
|
|
639
|
+
"name",
|
|
640
|
+
"temperature",
|
|
641
|
+
"topP",
|
|
642
|
+
"frequencyPenalty",
|
|
643
|
+
"presencePenalty",
|
|
644
|
+
"maxCompletionTokens"
|
|
645
|
+
]);
|
|
646
|
+
/**
|
|
647
|
+
* The agent's own model, per variant when conditional. The editor runs `${provider}/${name}`, so that is what's
|
|
648
|
+
* checked. Any other key is rejected: the policy would read `id`/`providerId`/`modelId` before `name`, and the
|
|
649
|
+
* editor ignores them, so they could make the policy check a model the agent doesn't run.
|
|
650
|
+
*/
|
|
651
|
+
function agentModelUses(model) {
|
|
652
|
+
if (model === void 0 || model === null) return [];
|
|
653
|
+
return (Array.isArray(model) ? model.map((variant, index) => [isObject(variant) ? variant.value : void 0, `model[${index}].value`]) : [[model, "model"]]).map(([value, field]) => {
|
|
654
|
+
if (!isObject(value)) return {
|
|
655
|
+
field,
|
|
656
|
+
implicit: "is not a provider and name"
|
|
657
|
+
};
|
|
658
|
+
const unknown = Object.keys(value).filter((key) => !MODEL_CONFIG_KEYS.has(key));
|
|
659
|
+
if (unknown.length > 0) return {
|
|
660
|
+
field,
|
|
661
|
+
implicit: `has keys a stored model doesn't take (${unknown.join(", ")})`
|
|
662
|
+
};
|
|
663
|
+
const { provider, name } = value;
|
|
664
|
+
return typeof provider === "string" && provider && typeof name === "string" && name ? {
|
|
665
|
+
field,
|
|
666
|
+
model: {
|
|
667
|
+
provider,
|
|
668
|
+
name
|
|
669
|
+
}
|
|
670
|
+
} : {
|
|
671
|
+
field,
|
|
672
|
+
implicit: "is not a provider and name"
|
|
673
|
+
};
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
/** Keys that name a model wherever they appear in free-form config; `modelSettings` and the like don't. */
|
|
677
|
+
const MODEL_KEY = /^(model|models|modelList)$/;
|
|
678
|
+
/**
|
|
679
|
+
* Every model named in free-form config (default options, which pass unknown keys through to the agent), at any
|
|
680
|
+
* depth: a string `model` is checked, anything else under a model key is rejected.
|
|
681
|
+
*/
|
|
682
|
+
function namedModelUses(value, path) {
|
|
683
|
+
if (Array.isArray(value)) return value.flatMap((item, index) => namedModelUses(item, `${path}[${index}]`));
|
|
684
|
+
if (!isObject(value)) return [];
|
|
685
|
+
return Object.entries(value).flatMap(([key, child]) => {
|
|
686
|
+
const field = `${path}.${key}`;
|
|
687
|
+
if (!MODEL_KEY.test(key)) return namedModelUses(child, field);
|
|
688
|
+
if (child === void 0) return [];
|
|
689
|
+
return key === "model" && typeof child === "string" ? [{
|
|
690
|
+
field,
|
|
691
|
+
model: child
|
|
692
|
+
}] : [{
|
|
693
|
+
field,
|
|
694
|
+
implicit: "is not a model id"
|
|
695
|
+
}];
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
/** Models named in default options, per variant when conditional (the editor merges matching variants shallowly). */
|
|
699
|
+
function defaultOptionsUses(defaultOptions) {
|
|
700
|
+
if (Array.isArray(defaultOptions)) return defaultOptions.flatMap((variant, index) => namedModelUses(isObject(variant) ? variant.value : void 0, `defaultOptions[${index}].value`));
|
|
701
|
+
return namedModelUses(defaultOptions, "defaultOptions");
|
|
702
|
+
}
|
|
703
|
+
/** OM model values that defer to a default the caller can't see: `'auto'` picks per main model and environment. */
|
|
704
|
+
const IMPLICIT_OM_MODELS = /* @__PURE__ */ new Set(["auto", "default"]);
|
|
705
|
+
/**
|
|
706
|
+
* Models Observational Memory runs. Observer and reflector each fall back to the other step's model and then to
|
|
707
|
+
* an implicit one: `true` runs on the editor's builder default OM model, and a config without a model (or with
|
|
708
|
+
* `'auto'`/`'default'`) on Observational Memory's own pick, which depends on the main model and environment.
|
|
709
|
+
*/
|
|
710
|
+
function observationalMemoryUses(om, field) {
|
|
711
|
+
if (om === true) return [{
|
|
712
|
+
field,
|
|
713
|
+
implicit: "true runs on the default Observational Memory model"
|
|
714
|
+
}];
|
|
715
|
+
if (!isObject(om)) return [];
|
|
716
|
+
const observation = isObject(om.observation) ? om.observation.model : void 0;
|
|
717
|
+
const reflection = isObject(om.reflection) ? om.reflection.model : void 0;
|
|
718
|
+
const uses = [
|
|
719
|
+
[`${field}.model`, om.model],
|
|
720
|
+
[`${field}.observation.model`, observation],
|
|
721
|
+
[`${field}.reflection.model`, reflection]
|
|
722
|
+
].filter((entry) => typeof entry[1] === "string" && !IMPLICIT_OM_MODELS.has(entry[1])).map(([path, model]) => ({
|
|
723
|
+
field: path,
|
|
724
|
+
model
|
|
725
|
+
}));
|
|
726
|
+
const observer = om.model ?? observation ?? reflection;
|
|
727
|
+
const reflector = om.model ?? reflection ?? observation;
|
|
728
|
+
const isImplicit = (model) => typeof model !== "string" || IMPLICIT_OM_MODELS.has(model);
|
|
729
|
+
if (isImplicit(observer) || isImplicit(reflector)) uses.push({
|
|
730
|
+
field,
|
|
731
|
+
implicit: "sets no explicit model, so it runs on an automatically picked default model"
|
|
732
|
+
});
|
|
733
|
+
return uses;
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Models inside a stored agent's memory field (static or conditional; inline or bare config): Observational
|
|
737
|
+
* Memory's observer/reflector and the title model (without one, titles use the agent's model). Registered
|
|
738
|
+
* memory refs carry none.
|
|
739
|
+
*/
|
|
740
|
+
function memoryUses(memory, field = "memory") {
|
|
741
|
+
return (Array.isArray(memory) ? memory.map((variant, index) => [isObject(variant) ? variant.value : void 0, `${field}[${index}].value`]) : [[memory, field]]).flatMap(([variant, path]) => {
|
|
742
|
+
if (!isObject(variant)) return [];
|
|
743
|
+
const inline = variant.type === "inline";
|
|
744
|
+
const config = inline ? variant.config : variant;
|
|
745
|
+
if (!isObject(config)) return [];
|
|
746
|
+
const configPath = inline ? `${path}.config` : path;
|
|
747
|
+
const title = isObject(config.options) ? config.options.generateTitle : void 0;
|
|
748
|
+
return [...observationalMemoryUses(config.observationalMemory, `${configPath}.observationalMemory`), ...isObject(title) && title.model !== void 0 ? [typeof title.model === "string" ? {
|
|
749
|
+
field: `${configPath}.options.generateTitle.model`,
|
|
750
|
+
model: title.model
|
|
751
|
+
} : {
|
|
752
|
+
field: `${configPath}.options.generateTitle.model`,
|
|
753
|
+
implicit: "is not a model id"
|
|
754
|
+
}] : []];
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Models in a stored agent's fallback list, which replaces the models of a code agent that hands its model list
|
|
759
|
+
* to the editor. A disabled entry never runs, so it isn't checked; an entry the policy can't read is implicit.
|
|
760
|
+
*/
|
|
761
|
+
function modelListUses(modelList) {
|
|
762
|
+
if (!Array.isArray(modelList)) return [];
|
|
763
|
+
return modelList.flatMap((entry, index) => {
|
|
764
|
+
if (!isObject(entry) || entry.enabled === false) return [];
|
|
765
|
+
const field = `modelList[${index}]`;
|
|
766
|
+
return typeof entry.provider === "string" && typeof entry.modelId === "string" ? [{
|
|
767
|
+
field,
|
|
768
|
+
model: `${entry.provider}/${entry.modelId}`
|
|
769
|
+
}] : [{
|
|
770
|
+
field,
|
|
771
|
+
implicit: "is not a provider and model id"
|
|
772
|
+
}];
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Models inside a stored agent's input or output processor graph (static or conditional), at every nesting depth:
|
|
777
|
+
* every model named in each step's config (`config.model` for the built-in providers). A provider whose config
|
|
778
|
+
* schema needs a model, given none, is implicit; a `model` that isn't a string is too, since the policy can't check it.
|
|
779
|
+
*/
|
|
780
|
+
function processorUses(processors, field, editor) {
|
|
781
|
+
const stepUses = (step, path) => {
|
|
782
|
+
if (!isObject(step)) return [];
|
|
783
|
+
const config = isObject(step.config) ? step.config : {};
|
|
784
|
+
const modelField = `${path}.config.model`;
|
|
785
|
+
const named = namedModelUses(config, `${path}.config`);
|
|
786
|
+
if (config.model !== void 0) return named;
|
|
787
|
+
return (typeof step.providerId === "string" ? editor?.getProcessorProvider?.(step.providerId) : void 0)?.configSchema.safeParse({}).error?.issues.some((issue) => issue.path[0] === "model") ? [...named, {
|
|
788
|
+
field: modelField,
|
|
789
|
+
implicit: "is not set, so the processor runs on a default model"
|
|
790
|
+
}] : named;
|
|
791
|
+
};
|
|
792
|
+
const entryUses = (entry, path) => {
|
|
793
|
+
if (!isObject(entry)) return [];
|
|
794
|
+
const list = (entries, at) => Array.isArray(entries) ? entries.flatMap((child, index) => entryUses(child, `${at}[${index}]`)) : [];
|
|
795
|
+
if (entry.type === "step") return stepUses(entry.step, `${path}.step`);
|
|
796
|
+
if (entry.type === "parallel" && Array.isArray(entry.branches)) return entry.branches.flatMap((branch, index) => list(branch, `${path}.branches[${index}]`));
|
|
797
|
+
if (entry.type === "conditional" && Array.isArray(entry.conditions)) return entry.conditions.flatMap((condition, index) => isObject(condition) ? list(condition.steps, `${path}.conditions[${index}].steps`) : []);
|
|
798
|
+
return [];
|
|
799
|
+
};
|
|
800
|
+
return (Array.isArray(processors) ? processors.map((variant, index) => [isObject(variant) ? variant.value : void 0, `${field}[${index}].value`]) : [[processors, field]]).flatMap(([graph, path]) => isObject(graph) && Array.isArray(graph.steps) ? graph.steps.flatMap((entry, index) => entryUses(entry, `${path}.steps[${index}]`)) : []);
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* The builder model policy and the builder it came from. Unlike the shared helper, which treats a builder that
|
|
804
|
+
* fails to resolve as "no policy" so agent runs don't fail, the write tools fail closed: no check, no write.
|
|
805
|
+
*/
|
|
806
|
+
async function resolvePolicy(editor) {
|
|
807
|
+
if (typeof editor?.resolveBuilder !== "function") return void 0;
|
|
808
|
+
if (typeof editor.hasEnabledBuilderConfig === "function" && !editor.hasEnabledBuilderConfig()) return void 0;
|
|
809
|
+
try {
|
|
810
|
+
const builder = await editor.resolveBuilder();
|
|
811
|
+
const { builderToModelPolicy } = await import("@mastra/core/agent-builder/ee");
|
|
812
|
+
return {
|
|
813
|
+
builder,
|
|
814
|
+
policy: builderToModelPolicy(builder)
|
|
815
|
+
};
|
|
816
|
+
} catch {
|
|
817
|
+
throw toolError(503, { message: "The builder model policy could not be resolved, so the agent was not saved. Try again later." });
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
const describeAllowed = (allowed) => allowed.map((entry) => `${entry.provider}/${entry.modelId ?? "*"}`).join(", ");
|
|
821
|
+
/**
|
|
822
|
+
* Stored agents (agent builder). The routes enforce `stored-agents:*` permissions, author/visibility
|
|
823
|
+
* ownership and builder defaults; the MCP tools also enforce the builder model policy on every model the
|
|
824
|
+
* agent will run, which the HTTP routes leave to the Studio model picker.
|
|
825
|
+
*/
|
|
826
|
+
function addStoredAgentTools(kit) {
|
|
827
|
+
const { mastra, call, addOperation } = kit;
|
|
828
|
+
/**
|
|
829
|
+
* Enforces the builder model policy on every model the agent will run: its model (each conditional variant),
|
|
830
|
+
* models named in its default options, its enabled fallback models, its memory models and its processor models.
|
|
831
|
+
* Models the policy can't check (implicit defaults, unknown shapes) are rejected. On create, omitted memory gets the builder default: the admin's pinned memory, else Observational
|
|
832
|
+
* Memory on its default model (the editor's `BUILDER_BASELINE_DEFAULTS`).
|
|
833
|
+
*/
|
|
834
|
+
const assertModelsAllowed = async (body, isCreate) => {
|
|
835
|
+
const editor = mastra.getEditor();
|
|
836
|
+
const resolved = await resolvePolicy(editor);
|
|
837
|
+
if (!resolved?.policy.active || !resolved.policy.allowed?.length) return;
|
|
838
|
+
const allowed = resolved.policy.allowed;
|
|
839
|
+
let uses;
|
|
840
|
+
if (isCreate && body.memory === void 0) {
|
|
841
|
+
const pinned = resolved.builder?.getConfiguration()?.agent?.memory;
|
|
842
|
+
uses = pinned === void 0 ? [{
|
|
843
|
+
field: "memory",
|
|
844
|
+
implicit: "is omitted, so the builder default turns on Observational Memory with its default model"
|
|
845
|
+
}] : memoryUses(pinned).map((use) => ({
|
|
846
|
+
...use,
|
|
847
|
+
field: `${use.field} (builder default)`
|
|
848
|
+
}));
|
|
849
|
+
} else uses = memoryUses(body.memory);
|
|
850
|
+
uses.unshift(...agentModelUses(body.model));
|
|
851
|
+
uses.push(...defaultOptionsUses(body.defaultOptions), ...modelListUses(body.modelList), ...processorUses(body.inputProcessors, "inputProcessors", editor), ...processorUses(body.outputProcessors, "outputProcessors", editor));
|
|
852
|
+
const { assertModelAllowed: assertAllowed, toModelCandidates } = await import("@mastra/core/agent-builder/ee");
|
|
853
|
+
const problems = [];
|
|
854
|
+
for (const use of uses) {
|
|
855
|
+
if ("implicit" in use) {
|
|
856
|
+
problems.push(`${use.field}: ${use.implicit}, which the builder model policy cannot check; set an allowed model`);
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
const { model } = use;
|
|
860
|
+
if (toModelCandidates(model).length === 0) {
|
|
861
|
+
problems.push(`${use.field}: ${JSON.stringify(use.model)} is not a provider/model id the policy can check`);
|
|
862
|
+
continue;
|
|
863
|
+
}
|
|
864
|
+
try {
|
|
865
|
+
assertAllowed(allowed, model);
|
|
866
|
+
} catch (error) {
|
|
867
|
+
problems.push(`${use.field}: ${(error instanceof Error ? error.message : "Model not allowed").replace(/\.$/, "")}`);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
if (problems.length > 0) throw toolError(422, { message: `${problems.join("; ")}. Allowed models: ${describeAllowed(allowed)}. Call list_available_models for the models you can use.` });
|
|
871
|
+
};
|
|
872
|
+
const withPublish = (args) => ({
|
|
873
|
+
...args,
|
|
874
|
+
autoPublish: args.autoPublish ?? true
|
|
875
|
+
});
|
|
876
|
+
addOperation(GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE, object({}), (_args, signal) => call(GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE, {}, signal));
|
|
877
|
+
addOperation(LIST_STORED_AGENTS_ROUTE, object({
|
|
878
|
+
status: {
|
|
879
|
+
type: "string",
|
|
880
|
+
enum: [
|
|
881
|
+
"draft",
|
|
882
|
+
"published",
|
|
883
|
+
"archived"
|
|
884
|
+
],
|
|
885
|
+
description: "Defaults to published."
|
|
886
|
+
},
|
|
887
|
+
page: {
|
|
888
|
+
type: "integer",
|
|
889
|
+
minimum: 0,
|
|
890
|
+
description: "Page number, from 0."
|
|
891
|
+
},
|
|
892
|
+
perPage: {
|
|
893
|
+
type: "integer",
|
|
894
|
+
minimum: 1,
|
|
895
|
+
description: "Agents per page. Defaults to 100."
|
|
896
|
+
}
|
|
897
|
+
}), (args, signal) => call(LIST_STORED_AGENTS_ROUTE, { query: args }, signal));
|
|
898
|
+
const storedAgentId = str("Stored agent id. Call list_stored_agents to find ids.");
|
|
899
|
+
addOperation(GET_STORED_AGENT_ROUTE, object({ storedAgentId }, ["storedAgentId"]), (args, signal) => call(GET_STORED_AGENT_ROUTE, { pathParams: { storedAgentId: args.storedAgentId } }, signal));
|
|
900
|
+
addOperation(CREATE_STORED_AGENT_ROUTE, bodySchema(createStoredAgentBodySchema, ["authorId"]), async (args, signal) => {
|
|
901
|
+
await assertModelsAllowed(args, true);
|
|
902
|
+
return call(CREATE_STORED_AGENT_ROUTE, { body: withPublish(args) }, signal);
|
|
903
|
+
});
|
|
904
|
+
addOperation(UPDATE_STORED_AGENT_ROUTE, (() => {
|
|
905
|
+
const schema = bodySchema(updateStoredAgentBodySchema, ["authorId"]);
|
|
906
|
+
return {
|
|
907
|
+
...schema,
|
|
908
|
+
properties: {
|
|
909
|
+
storedAgentId,
|
|
910
|
+
...schema.properties
|
|
911
|
+
},
|
|
912
|
+
required: ["storedAgentId"]
|
|
913
|
+
};
|
|
914
|
+
})(), async (args, signal) => {
|
|
915
|
+
const { storedAgentId: id, ...body } = args;
|
|
916
|
+
await assertModelsAllowed(body, false);
|
|
917
|
+
return call(UPDATE_STORED_AGENT_ROUTE, {
|
|
918
|
+
pathParams: { storedAgentId: id },
|
|
919
|
+
body: withPublish(body)
|
|
920
|
+
}, signal);
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
// src/server/mcp/catalogue.ts
|
|
924
|
+
const MAX_TOOL_NAME_LENGTH = 64;
|
|
925
|
+
/** A backing route's permission is a read when every permission it accepts has the `read` action. */
|
|
926
|
+
function isReadRoute(route) {
|
|
927
|
+
const permission = getEffectivePermission(route);
|
|
928
|
+
if (!permission) return false;
|
|
929
|
+
return (Array.isArray(permission) ? permission : [permission]).every((p) => p.split(":")[1] === "read");
|
|
930
|
+
}
|
|
931
|
+
function shortHash(value) {
|
|
932
|
+
let hash = 2166136261;
|
|
933
|
+
for (let i = 0; i < value.length; i++) {
|
|
934
|
+
hash ^= value.charCodeAt(i);
|
|
935
|
+
hash = Math.imul(hash, 16777619);
|
|
936
|
+
}
|
|
937
|
+
return (hash >>> 0).toString(16).padStart(8, "0").slice(0, 6);
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Names entity tools `<prefix>_<id>`, sanitized to `[A-Za-z0-9_-]` and at most 64 characters.
|
|
941
|
+
* Ids that are already valid are named first, so they keep the plain name when a sanitized id collides with them.
|
|
942
|
+
*/
|
|
943
|
+
function nameEntityTools(prefix, ids, used) {
|
|
944
|
+
const names = /* @__PURE__ */ new Map();
|
|
945
|
+
const sanitize = (id) => id.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
946
|
+
const ordered = [...ids].sort((a, b) => {
|
|
947
|
+
const aClean = sanitize(a) === a;
|
|
948
|
+
return aClean === (sanitize(b) === b) ? a.localeCompare(b) : aClean ? -1 : 1;
|
|
949
|
+
});
|
|
950
|
+
for (const id of ordered) {
|
|
951
|
+
let name = `${prefix}_${sanitize(id)}`;
|
|
952
|
+
if (name.length > MAX_TOOL_NAME_LENGTH || used.has(name)) name = `${name.slice(0, 57)}_${shortHash(id)}`;
|
|
953
|
+
used.add(name);
|
|
954
|
+
names.set(id, name);
|
|
955
|
+
}
|
|
956
|
+
return names;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Maps every name of a registered primitive (its `.id` and registration key) to all of its names.
|
|
960
|
+
* A name that is some primitive's `.id` resolves to that primitive, as in the handlers' id-first lookups.
|
|
961
|
+
*/
|
|
962
|
+
function registryNames(...registries) {
|
|
963
|
+
const byId = /* @__PURE__ */ new Map();
|
|
964
|
+
for (const registry of registries) for (const [key, value] of Object.entries(registry ?? {})) {
|
|
965
|
+
const id = typeof value?.id === "string" ? value.id : key;
|
|
966
|
+
const names = byId.get(id) ?? /* @__PURE__ */ new Set([id]);
|
|
967
|
+
names.add(key);
|
|
968
|
+
byId.set(id, names);
|
|
969
|
+
}
|
|
970
|
+
const byName = /* @__PURE__ */ new Map();
|
|
971
|
+
for (const names of byId.values()) for (const name of names) byName.set(name, [...names]);
|
|
972
|
+
for (const [id, names] of byId) byName.set(id, [...names]);
|
|
973
|
+
return byName;
|
|
974
|
+
}
|
|
975
|
+
function toolError(status, body) {
|
|
976
|
+
const details = body && typeof body === "object" ? body : {};
|
|
977
|
+
const message = details.message ?? details.error ?? (typeof body === "string" ? body : "Request failed");
|
|
978
|
+
const issues = Array.isArray(details.issues) ? ` ${JSON.stringify(details.issues)}` : "";
|
|
979
|
+
return new MastraError({
|
|
980
|
+
id: "MASTRA_MCP_TOOL_CALL_FAILED",
|
|
981
|
+
domain: ErrorDomain.MCP,
|
|
982
|
+
category: status >= 500 ? ErrorCategory.SYSTEM : ErrorCategory.USER,
|
|
983
|
+
text: `${status} ${String(message)}${issues}`,
|
|
984
|
+
details: { status }
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
const missingDescriptionWarnings = /* @__PURE__ */ new WeakMap();
|
|
988
|
+
function describeAgent(mastra, id, agent) {
|
|
989
|
+
if (agent?.description) return agent.description;
|
|
990
|
+
let warned = missingDescriptionWarnings.get(mastra);
|
|
991
|
+
if (!warned) missingDescriptionWarnings.set(mastra, warned = /* @__PURE__ */ new Set());
|
|
992
|
+
if (!warned.has(id)) {
|
|
993
|
+
warned.add(id);
|
|
994
|
+
mastra.getLogger()?.warn(`Agent "${id}" has no description; MCP clients get a generic one. Add a description to the agent.`);
|
|
995
|
+
}
|
|
996
|
+
return `Call the ${agent?.name ?? id} agent.`;
|
|
997
|
+
}
|
|
998
|
+
/**
|
|
999
|
+
* Builds the tools one caller sees on the built-in MCP server.
|
|
1000
|
+
*
|
|
1001
|
+
* Each tool is backed by a server route and runs it with `dispatchRoute` and the caller's own
|
|
1002
|
+
* RequestContext, so RBAC, FGA, and the handler's ownership checks are exactly those of the HTTP route.
|
|
1003
|
+
* Tools the caller would be refused are left out; every call is authorized again.
|
|
1004
|
+
*/
|
|
1005
|
+
async function buildBuiltinMCPTools(ctx, config) {
|
|
1006
|
+
const { mastra, requestContext } = ctx;
|
|
1007
|
+
const capabilities = await getBuiltinMCPCapabilities(mastra);
|
|
1008
|
+
const routeContext = {
|
|
1009
|
+
mastra,
|
|
1010
|
+
requestContext,
|
|
1011
|
+
registeredTools: ctx.registeredTools,
|
|
1012
|
+
taskStore: ctx.taskStore,
|
|
1013
|
+
routePrefix: ctx.routePrefix,
|
|
1014
|
+
abortSignal: ctx.abortSignal,
|
|
1015
|
+
request: ctx.request
|
|
1016
|
+
};
|
|
1017
|
+
const mcpExecuteRoute = {
|
|
1018
|
+
...ctx.mcpRoute,
|
|
1019
|
+
requiresPermission: "mcp:execute"
|
|
1020
|
+
};
|
|
1021
|
+
const canExecute = checkRouteRBAC(mastra, mcpExecuteRoute, requestContext) === null;
|
|
1022
|
+
/** Whether the caller may run this route from a tool: route-level RBAC and read-only mode. */
|
|
1023
|
+
const permitted = (route) => canExecute && (!config.readOnly || isReadRoute(route)) && checkRouteRBAC(mastra, route, requestContext) === null;
|
|
1024
|
+
/** Whether the route's own tool is offered: permitted, in the configured toolsets, and supported by the server. */
|
|
1025
|
+
const offered = (route) => Boolean(route.mcp) && config.toolsets.has(route.mcp.toolset) && (route.mcp.requires?.(capabilities) ?? true) && permitted(route);
|
|
1026
|
+
const call = async (route, input, signal) => {
|
|
1027
|
+
const denied = checkRouteRBAC(mastra, mcpExecuteRoute, requestContext);
|
|
1028
|
+
if (denied) throw toolError(denied.status, denied);
|
|
1029
|
+
const abortSignal = signal ? AbortSignal.any([signal, ctx.abortSignal]) : ctx.abortSignal;
|
|
1030
|
+
const result = await dispatchRoute(route, input, {
|
|
1031
|
+
...routeContext,
|
|
1032
|
+
abortSignal
|
|
1033
|
+
});
|
|
1034
|
+
if (!result.ok) throw toolError(result.status, result.body);
|
|
1035
|
+
return result.result;
|
|
1036
|
+
};
|
|
1037
|
+
const registries = {
|
|
1038
|
+
agents: () => registryNames(mastra.listAgents()),
|
|
1039
|
+
workflows: () => registryNames(mastra.listWorkflows()),
|
|
1040
|
+
tools: () => registryNames(ctx.registeredTools, mastra.listTools())
|
|
1041
|
+
};
|
|
1042
|
+
const registryCache = /* @__PURE__ */ new Map();
|
|
1043
|
+
/** Every name of the registered primitive called `name` (just `name` when it isn't registered). */
|
|
1044
|
+
const namesOf = (kind, name) => {
|
|
1045
|
+
let names = registryCache.get(kind);
|
|
1046
|
+
if (!names) registryCache.set(kind, names = registries[kind]());
|
|
1047
|
+
return names.get(name) ?? [name];
|
|
1048
|
+
};
|
|
1049
|
+
/** Resolves a caller-supplied id with the backing handler's own resolver, then returns every name it has. */
|
|
1050
|
+
const resolveNames = async (kind, id) => {
|
|
1051
|
+
let resolved;
|
|
1052
|
+
try {
|
|
1053
|
+
if (kind === "agents") resolved = (await getAgentFromSystem({
|
|
1054
|
+
mastra,
|
|
1055
|
+
agentId: id,
|
|
1056
|
+
requestContext
|
|
1057
|
+
})).id;
|
|
1058
|
+
else if (kind === "workflows") resolved = (await listWorkflowsFromSystem({
|
|
1059
|
+
mastra,
|
|
1060
|
+
workflowId: id
|
|
1061
|
+
})).workflow.id;
|
|
1062
|
+
else resolved = (await findTool({
|
|
1063
|
+
mastra,
|
|
1064
|
+
registeredTools: ctx.registeredTools,
|
|
1065
|
+
toolId: id,
|
|
1066
|
+
requestContext
|
|
1067
|
+
}))?.id;
|
|
1068
|
+
} catch {}
|
|
1069
|
+
return [.../* @__PURE__ */ new Set([id, ...resolved ? namesOf(kind, resolved) : []])];
|
|
1070
|
+
};
|
|
1071
|
+
const requireSelected = async (kind, id, label) => {
|
|
1072
|
+
if (!config.isSelected(kind, await resolveNames(kind, id))) throw toolError(404, `${label} not found`);
|
|
1073
|
+
};
|
|
1074
|
+
/** Keys of listed entities that a configured id list (e.g. `featured`) names by `.id` or registration key. */
|
|
1075
|
+
const named = (kind, listed, ids) => [...listed.keys()].filter((key) => namesOf(kind, key).some((name) => ids.includes(name)));
|
|
1076
|
+
/** Lists visible entities through the backing list route, so FGA filtering and stored agents are inherited. */
|
|
1077
|
+
const listVisible = async (route, kind, query) => {
|
|
1078
|
+
if (checkRouteRBAC(mastra, route, requestContext)) return void 0;
|
|
1079
|
+
const result = await dispatchRoute(route, { query }, routeContext);
|
|
1080
|
+
if (!result.ok) return void 0;
|
|
1081
|
+
const entries = Object.entries(result.result ?? {});
|
|
1082
|
+
return new Map(entries.filter(([key]) => config.isSelected(kind, namesOf(kind, key))));
|
|
1083
|
+
};
|
|
1084
|
+
const idParam = (label, ids, listTool) => ids && ids.length > 0 && ids.length <= config.enumLimit ? {
|
|
1085
|
+
type: "string",
|
|
1086
|
+
enum: ids,
|
|
1087
|
+
description: `${label} id. Call ${listTool} for descriptions.`
|
|
1088
|
+
} : str(`${label} id. Call ${listTool} to find ids.`);
|
|
1089
|
+
const annotationsFor = (route, extra = {}) => isReadRoute(route) ? {
|
|
1090
|
+
readOnlyHint: true,
|
|
1091
|
+
...extra
|
|
1092
|
+
} : {
|
|
1093
|
+
readOnlyHint: false,
|
|
1094
|
+
destructiveHint: false,
|
|
1095
|
+
...extra
|
|
1096
|
+
};
|
|
1097
|
+
const tools = {};
|
|
1098
|
+
const used = /* @__PURE__ */ new Set();
|
|
1099
|
+
const add = (name, route, description, inputSchema, execute, options = {}) => {
|
|
1100
|
+
used.add(name);
|
|
1101
|
+
tools[name] = createTool({
|
|
1102
|
+
id: name,
|
|
1103
|
+
description,
|
|
1104
|
+
inputSchema,
|
|
1105
|
+
outputSchema: options.outputSchema,
|
|
1106
|
+
mcp: { annotations: options.annotations ?? annotationsFor(route) },
|
|
1107
|
+
execute: async (args, context) => execute(args ?? {}, context?.abortSignal)
|
|
1108
|
+
});
|
|
1109
|
+
};
|
|
1110
|
+
const addOperation = (route, inputSchema, execute, options) => {
|
|
1111
|
+
if (offered(route)) add(route.mcp.name, route, route.mcp.description, inputSchema, execute, options);
|
|
1112
|
+
};
|
|
1113
|
+
const matches = (query, ...values) => typeof query !== "string" || values.some((value) => typeof value === "string" && value.toLowerCase().includes(query.toLowerCase()));
|
|
1114
|
+
const listInput = (label) => object({ query: str(`Only return ${label} whose id or name contains this text.`) });
|
|
1115
|
+
let visibleAgents;
|
|
1116
|
+
const listVisibleAgents = () => visibleAgents ??= listVisible(LIST_AGENTS_ROUTE, "agents", { partial: "true" });
|
|
1117
|
+
if (config.toolsets.has("agents")) {
|
|
1118
|
+
const agents = await listVisibleAgents();
|
|
1119
|
+
const agentIds = agents ? [...agents.keys()].sort() : void 0;
|
|
1120
|
+
const callAgentOutput = object({
|
|
1121
|
+
text: { type: "string" },
|
|
1122
|
+
threadId: { type: "string" },
|
|
1123
|
+
runId: { type: "string" },
|
|
1124
|
+
usage: { type: "object" }
|
|
1125
|
+
});
|
|
1126
|
+
const callAgent = async (agentId, args, signal) => {
|
|
1127
|
+
await requireSelected("agents", agentId, "Agent");
|
|
1128
|
+
const { message } = args;
|
|
1129
|
+
const resourceId = args.resourceId ?? requestContext.get("mastra__resourceId");
|
|
1130
|
+
const threadId = args.threadId ?? (resourceId ? crypto.randomUUID() : void 0);
|
|
1131
|
+
const body = { messages: [{
|
|
1132
|
+
role: "user",
|
|
1133
|
+
content: message
|
|
1134
|
+
}] };
|
|
1135
|
+
if (threadId || resourceId) body.memory = {
|
|
1136
|
+
thread: threadId,
|
|
1137
|
+
resource: resourceId
|
|
1138
|
+
};
|
|
1139
|
+
const result = await call(GENERATE_AGENT_ROUTE, {
|
|
1140
|
+
pathParams: { agentId },
|
|
1141
|
+
body
|
|
1142
|
+
}, signal);
|
|
1143
|
+
return {
|
|
1144
|
+
text: result?.text ?? "",
|
|
1145
|
+
...threadId ? { threadId } : {},
|
|
1146
|
+
...result?.runId ? { runId: result.runId } : {},
|
|
1147
|
+
...result?.totalUsage || result?.usage ? { usage: result.totalUsage ?? result.usage } : {}
|
|
1148
|
+
};
|
|
1149
|
+
};
|
|
1150
|
+
const messageInput = {
|
|
1151
|
+
message: str("The message to send."),
|
|
1152
|
+
threadId: str("Conversation thread id. Reuse the threadId from an earlier reply to continue it."),
|
|
1153
|
+
resourceId: str("Owner of the conversation memory (for example a user id).")
|
|
1154
|
+
};
|
|
1155
|
+
const agentAnnotations = {
|
|
1156
|
+
readOnlyHint: false,
|
|
1157
|
+
destructiveHint: false,
|
|
1158
|
+
openWorldHint: true
|
|
1159
|
+
};
|
|
1160
|
+
addOperation(LIST_AGENTS_ROUTE, listInput("agents"), async (args, signal) => {
|
|
1161
|
+
const listed = await call(LIST_AGENTS_ROUTE, { query: { partial: "true" } }, signal);
|
|
1162
|
+
return { agents: Object.entries(listed ?? {}).filter(([id, agent]) => config.isSelected("agents", namesOf("agents", id)) && matches(args.query, id, agent?.name)).map(([id, agent]) => ({
|
|
1163
|
+
id,
|
|
1164
|
+
name: agent?.name,
|
|
1165
|
+
description: describeAgent(mastra, id, agent)
|
|
1166
|
+
})) };
|
|
1167
|
+
});
|
|
1168
|
+
addOperation(GET_AGENT_BY_ID_ROUTE, object({ agentId: idParam("Agent", agentIds, "list_agents") }, ["agentId"]), async (args, signal) => {
|
|
1169
|
+
await requireSelected("agents", args.agentId, "Agent");
|
|
1170
|
+
return call(GET_AGENT_BY_ID_ROUTE, { pathParams: { agentId: args.agentId } }, signal);
|
|
1171
|
+
});
|
|
1172
|
+
addOperation(GENERATE_AGENT_ROUTE, object({
|
|
1173
|
+
agentId: idParam("Agent", agentIds, "list_agents"),
|
|
1174
|
+
...messageInput
|
|
1175
|
+
}, ["agentId", "message"]), (args, signal) => callAgent(args.agentId, args, signal), {
|
|
1176
|
+
annotations: agentAnnotations,
|
|
1177
|
+
outputSchema: callAgentOutput
|
|
1178
|
+
});
|
|
1179
|
+
if (agents && offered(GENERATE_AGENT_ROUTE)) {
|
|
1180
|
+
const featured = [];
|
|
1181
|
+
for (const id of named("agents", agents, config.featured.agents)) if (!await authorizeRoute(mastra, GENERATE_AGENT_ROUTE, { agentId: id }, requestContext)) featured.push(id);
|
|
1182
|
+
for (const [id, name] of nameEntityTools("agent", featured, used)) add(name, GENERATE_AGENT_ROUTE, describeAgent(mastra, id, agents.get(id)), object(messageInput, ["message"]), (args, signal) => callAgent(id, args, signal), {
|
|
1183
|
+
annotations: agentAnnotations,
|
|
1184
|
+
outputSchema: callAgentOutput
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
if (config.toolsets.has("workflows")) {
|
|
1189
|
+
const workflows = await listVisible(LIST_WORKFLOWS_ROUTE, "workflows", { partial: "true" });
|
|
1190
|
+
const workflowIds = workflows ? [...workflows.keys()].sort() : void 0;
|
|
1191
|
+
const workflowId = () => idParam("Workflow", workflowIds, "list_workflows");
|
|
1192
|
+
const runId = str("Workflow run id.");
|
|
1193
|
+
/** Suspended runs return what a client needs to resume them with resume_workflow_run. */
|
|
1194
|
+
const toRunResult = (id, result) => result?.status === "suspended" ? {
|
|
1195
|
+
status: "suspended",
|
|
1196
|
+
runId: id,
|
|
1197
|
+
suspendPayload: result.suspendPayload,
|
|
1198
|
+
suspendedSteps: result.suspended
|
|
1199
|
+
} : {
|
|
1200
|
+
runId: id,
|
|
1201
|
+
...result
|
|
1202
|
+
};
|
|
1203
|
+
const startWorkflow = async (id, args, signal) => {
|
|
1204
|
+
await requireSelected("workflows", id, "Workflow");
|
|
1205
|
+
const run = args.runId ?? crypto.randomUUID();
|
|
1206
|
+
const result = await call(START_ASYNC_WORKFLOW_ROUTE, {
|
|
1207
|
+
pathParams: { workflowId: id },
|
|
1208
|
+
query: { runId: run },
|
|
1209
|
+
body: { inputData: args.inputData }
|
|
1210
|
+
}, signal);
|
|
1211
|
+
return toRunResult(run, result);
|
|
1212
|
+
};
|
|
1213
|
+
addOperation(LIST_WORKFLOWS_ROUTE, listInput("workflows"), async (args, signal) => {
|
|
1214
|
+
const listed = await call(LIST_WORKFLOWS_ROUTE, { query: { partial: "true" } }, signal);
|
|
1215
|
+
return { workflows: Object.entries(listed ?? {}).filter(([id, workflow]) => config.isSelected("workflows", namesOf("workflows", id)) && matches(args.query, id, workflow?.name)).map(([id, workflow]) => ({
|
|
1216
|
+
id,
|
|
1217
|
+
name: workflow?.name,
|
|
1218
|
+
description: workflow?.description
|
|
1219
|
+
})) };
|
|
1220
|
+
});
|
|
1221
|
+
addOperation(GET_WORKFLOW_BY_ID_ROUTE, object({ workflowId: workflowId() }, ["workflowId"]), async (args, signal) => {
|
|
1222
|
+
await requireSelected("workflows", args.workflowId, "Workflow");
|
|
1223
|
+
return call(GET_WORKFLOW_BY_ID_ROUTE, { pathParams: { workflowId: args.workflowId } }, signal);
|
|
1224
|
+
});
|
|
1225
|
+
addOperation(START_ASYNC_WORKFLOW_ROUTE, object({
|
|
1226
|
+
workflowId: workflowId(),
|
|
1227
|
+
inputData: { description: "Input matching the workflow input schema (see get_workflow)." },
|
|
1228
|
+
runId: str("Optional id for the new run.")
|
|
1229
|
+
}, ["workflowId"]), (args, signal) => startWorkflow(args.workflowId, args, signal));
|
|
1230
|
+
addOperation(GET_WORKFLOW_RUN_BY_ID_ROUTE, object({
|
|
1231
|
+
workflowId: workflowId(),
|
|
1232
|
+
runId,
|
|
1233
|
+
fields: str("Comma-separated fields to return: result, error, payload, steps, activeStepsPath.")
|
|
1234
|
+
}, ["workflowId", "runId"]), async (args, signal) => {
|
|
1235
|
+
await requireSelected("workflows", args.workflowId, "Workflow");
|
|
1236
|
+
return call(GET_WORKFLOW_RUN_BY_ID_ROUTE, {
|
|
1237
|
+
pathParams: {
|
|
1238
|
+
workflowId: args.workflowId,
|
|
1239
|
+
runId: args.runId
|
|
1240
|
+
},
|
|
1241
|
+
query: args.fields ? { fields: args.fields } : {}
|
|
1242
|
+
}, signal);
|
|
1243
|
+
});
|
|
1244
|
+
addOperation(RESUME_ASYNC_WORKFLOW_ROUTE, object({
|
|
1245
|
+
workflowId: workflowId(),
|
|
1246
|
+
runId,
|
|
1247
|
+
step: str("Suspended step to resume. Defaults to the suspended step."),
|
|
1248
|
+
resumeData: { description: "Data the suspended step asked for." }
|
|
1249
|
+
}, ["workflowId", "runId"]), async (args, signal) => {
|
|
1250
|
+
await requireSelected("workflows", args.workflowId, "Workflow");
|
|
1251
|
+
const result = await call(RESUME_ASYNC_WORKFLOW_ROUTE, {
|
|
1252
|
+
pathParams: { workflowId: args.workflowId },
|
|
1253
|
+
query: { runId: args.runId },
|
|
1254
|
+
body: {
|
|
1255
|
+
step: args.step,
|
|
1256
|
+
resumeData: args.resumeData
|
|
1257
|
+
}
|
|
1258
|
+
}, signal);
|
|
1259
|
+
return toRunResult(args.runId, result);
|
|
1260
|
+
});
|
|
1261
|
+
addOperation(CANCEL_WORKFLOW_RUN_ROUTE, object({
|
|
1262
|
+
workflowId: workflowId(),
|
|
1263
|
+
runId
|
|
1264
|
+
}, ["workflowId", "runId"]), async (args, signal) => {
|
|
1265
|
+
await requireSelected("workflows", args.workflowId, "Workflow");
|
|
1266
|
+
return call(CANCEL_WORKFLOW_RUN_ROUTE, { pathParams: {
|
|
1267
|
+
workflowId: args.workflowId,
|
|
1268
|
+
runId: args.runId
|
|
1269
|
+
} }, signal);
|
|
1270
|
+
}, { annotations: {
|
|
1271
|
+
readOnlyHint: false,
|
|
1272
|
+
destructiveHint: true
|
|
1273
|
+
} });
|
|
1274
|
+
if (workflows && offered(START_ASYNC_WORKFLOW_ROUTE)) {
|
|
1275
|
+
const registered = mastra.listWorkflows();
|
|
1276
|
+
const featured = /* @__PURE__ */ new Map();
|
|
1277
|
+
for (const key of named("workflows", workflows, config.featured.workflows)) {
|
|
1278
|
+
const id = registered[key]?.id ?? key;
|
|
1279
|
+
if (!await authorizeRoute(mastra, START_ASYNC_WORKFLOW_ROUTE, { workflowId: id }, requestContext)) featured.set(id, key);
|
|
1280
|
+
}
|
|
1281
|
+
for (const [id, name] of nameEntityTools("workflow", [...featured.keys()], used)) {
|
|
1282
|
+
const key = featured.get(id);
|
|
1283
|
+
const inputSchema = toJSONSchema(registered[key]?.inputSchema);
|
|
1284
|
+
const isObject = inputSchema?.type === "object";
|
|
1285
|
+
add(name, START_ASYNC_WORKFLOW_ROUTE, workflows.get(key)?.description ?? registered[key]?.description ?? `Run the ${id} workflow.`, isObject ? inputSchema : object({ inputData: inputSchema ?? {} }), (args, signal) => startWorkflow(id, { inputData: isObject ? args : args.inputData }, signal));
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
if (config.toolsets.has("tools")) {
|
|
1290
|
+
const listed = await listVisible(LIST_TOOLS_ROUTE, "tools");
|
|
1291
|
+
const visible = listed ? [...listed.keys()].map((key) => {
|
|
1292
|
+
const tool = ctx.registeredTools?.[key] ?? mastra.listTools()?.[key];
|
|
1293
|
+
return {
|
|
1294
|
+
key,
|
|
1295
|
+
id: tool?.id ?? key,
|
|
1296
|
+
tool
|
|
1297
|
+
};
|
|
1298
|
+
}) : [];
|
|
1299
|
+
if (listed !== void 0 && visible.length <= config.enumLimit && offered(EXECUTE_TOOL_ROUTE)) {
|
|
1300
|
+
const allowed = [];
|
|
1301
|
+
for (const entry of visible) if (!await authorizeRoute(mastra, EXECUTE_TOOL_ROUTE, { toolId: entry.id }, requestContext)) allowed.push(entry);
|
|
1302
|
+
const byId = new Map(allowed.map((entry) => [entry.id, entry]));
|
|
1303
|
+
for (const [id, name] of nameEntityTools("tool", [...byId.keys()], used)) {
|
|
1304
|
+
const { tool } = byId.get(id);
|
|
1305
|
+
const inputSchema = toJSONSchema(tool?.inputSchema);
|
|
1306
|
+
const isObject = inputSchema?.type === "object";
|
|
1307
|
+
add(name, EXECUTE_TOOL_ROUTE, tool?.description ?? `Call the ${id} tool.`, isObject ? inputSchema : object({ data: inputSchema ?? {} }), async (args, signal) => {
|
|
1308
|
+
await requireSelected("tools", id, "Tool");
|
|
1309
|
+
return call(EXECUTE_TOOL_ROUTE, {
|
|
1310
|
+
pathParams: { toolId: id },
|
|
1311
|
+
body: { data: isObject ? args : args.data }
|
|
1312
|
+
}, signal);
|
|
1313
|
+
}, { annotations: {
|
|
1314
|
+
readOnlyHint: false,
|
|
1315
|
+
destructiveHint: false,
|
|
1316
|
+
...tool?.mcp?.annotations
|
|
1317
|
+
} });
|
|
1318
|
+
}
|
|
1319
|
+
} else {
|
|
1320
|
+
const toolIds = listed ? visible.map((entry) => entry.id).sort() : void 0;
|
|
1321
|
+
const toolId = () => idParam("Tool", toolIds, "list_tools");
|
|
1322
|
+
addOperation(LIST_TOOLS_ROUTE, listInput("tools"), async (args, signal) => {
|
|
1323
|
+
const tools = await call(LIST_TOOLS_ROUTE, {}, signal);
|
|
1324
|
+
return { tools: Object.entries(tools ?? {}).map(([key, tool]) => ({
|
|
1325
|
+
key,
|
|
1326
|
+
id: tool?.id ?? key,
|
|
1327
|
+
description: tool?.description
|
|
1328
|
+
})).filter((tool) => config.isSelected("tools", [...namesOf("tools", tool.key), tool.id]) && matches(args.query, tool.id)).map(({ id, description }) => ({
|
|
1329
|
+
id,
|
|
1330
|
+
description
|
|
1331
|
+
})) };
|
|
1332
|
+
});
|
|
1333
|
+
addOperation(GET_TOOL_BY_ID_ROUTE, object({ toolId: toolId() }, ["toolId"]), async (args, signal) => {
|
|
1334
|
+
await requireSelected("tools", args.toolId, "Tool");
|
|
1335
|
+
return call(GET_TOOL_BY_ID_ROUTE, { pathParams: { toolId: args.toolId } }, signal);
|
|
1336
|
+
});
|
|
1337
|
+
addOperation(EXECUTE_TOOL_ROUTE, object({
|
|
1338
|
+
toolId: toolId(),
|
|
1339
|
+
data: { description: "Input matching the tool input schema (see get_tool)." }
|
|
1340
|
+
}, ["toolId"]), async (args, signal) => {
|
|
1341
|
+
await requireSelected("tools", args.toolId, "Tool");
|
|
1342
|
+
return call(EXECUTE_TOOL_ROUTE, {
|
|
1343
|
+
pathParams: { toolId: args.toolId },
|
|
1344
|
+
body: { data: args.data }
|
|
1345
|
+
}, signal);
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
const kit = {
|
|
1350
|
+
mastra,
|
|
1351
|
+
requestContext,
|
|
1352
|
+
config,
|
|
1353
|
+
capabilities,
|
|
1354
|
+
offered,
|
|
1355
|
+
permitted,
|
|
1356
|
+
call,
|
|
1357
|
+
add,
|
|
1358
|
+
addOperation,
|
|
1359
|
+
addCombined: (routes, inputSchema, execute) => {
|
|
1360
|
+
if (routes.every(offered)) add(routes[0].mcp.name, routes[0], routes[0].mcp.description, inputSchema, execute);
|
|
1361
|
+
},
|
|
1362
|
+
visibleAgentIds: async () => {
|
|
1363
|
+
const agents = await listVisibleAgents();
|
|
1364
|
+
return agents ? [...agents.keys()].sort() : void 0;
|
|
1365
|
+
},
|
|
1366
|
+
requireSelected,
|
|
1367
|
+
idParam
|
|
1368
|
+
};
|
|
1369
|
+
if (config.toolsets.has("memory")) await addMemoryTools(kit);
|
|
1370
|
+
addObservabilityTools(kit);
|
|
1371
|
+
if (config.toolsets.has("stored_agents")) addStoredAgentTools(kit);
|
|
1372
|
+
return tools;
|
|
1373
|
+
}
|
|
1374
|
+
export { buildBuiltinMCPTools };
|
|
1375
|
+
|
|
1376
|
+
//# sourceMappingURL=catalogue-CUJevxy3.js.map
|