@mastra/server 1.13.2 → 1.13.3-alpha.0
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/CHANGELOG.md +9 -0
- package/dist/{chunk-LKF5W6CH.cjs → chunk-2C67BFVB.cjs} +10 -10
- package/dist/{chunk-LKF5W6CH.cjs.map → chunk-2C67BFVB.cjs.map} +1 -1
- package/dist/chunk-2ERW3HSX.js +1 -1
- package/dist/{chunk-U4VL3LBC.cjs → chunk-2IRG5IIL.cjs} +1545 -590
- package/dist/chunk-2IRG5IIL.cjs.map +1 -0
- package/dist/{chunk-UOUYGOAQ.cjs → chunk-3TULCS3D.cjs} +24 -24
- package/dist/{chunk-UOUYGOAQ.cjs.map → chunk-3TULCS3D.cjs.map} +1 -1
- package/dist/{chunk-RHEEYK4H.js → chunk-4S2JD5RO.js} +3 -3
- package/dist/{chunk-RHEEYK4H.js.map → chunk-4S2JD5RO.js.map} +1 -1
- package/dist/{chunk-JHZRTNIW.cjs → chunk-5KUSWTHH.cjs} +17 -17
- package/dist/{chunk-JHZRTNIW.cjs.map → chunk-5KUSWTHH.cjs.map} +1 -1
- package/dist/{chunk-FRRHYZR6.cjs → chunk-5N66PU3H.cjs} +4 -4
- package/dist/{chunk-FRRHYZR6.cjs.map → chunk-5N66PU3H.cjs.map} +1 -1
- package/dist/{chunk-YQSTTYAA.js → chunk-7DAMVPUL.js} +3 -3
- package/dist/{chunk-YQSTTYAA.js.map → chunk-7DAMVPUL.js.map} +1 -1
- package/dist/{chunk-N5TSRVSJ.cjs → chunk-7KPX5LQS.cjs} +10 -10
- package/dist/{chunk-N5TSRVSJ.cjs.map → chunk-7KPX5LQS.cjs.map} +1 -1
- package/dist/{chunk-TWH4646Y.js → chunk-BVSKSP5Z.js} +5 -5
- package/dist/{chunk-TWH4646Y.js.map → chunk-BVSKSP5Z.js.map} +1 -1
- package/dist/{chunk-XKLJYRAA.js → chunk-BZZVTO7B.js} +4 -4
- package/dist/{chunk-XKLJYRAA.js.map → chunk-BZZVTO7B.js.map} +1 -1
- package/dist/chunk-CCDCBWFG.js +439 -0
- package/dist/chunk-CCDCBWFG.js.map +1 -0
- package/dist/{chunk-V5UM53T3.cjs → chunk-CP42WZQR.cjs} +10 -10
- package/dist/{chunk-V5UM53T3.cjs.map → chunk-CP42WZQR.cjs.map} +1 -1
- package/dist/{chunk-LUI5H2OG.cjs → chunk-CQ4HCBIU.cjs} +11 -11
- package/dist/{chunk-LUI5H2OG.cjs.map → chunk-CQ4HCBIU.cjs.map} +1 -1
- package/dist/{chunk-B3JW6PKL.js → chunk-DGC275TW.js} +4 -4
- package/dist/{chunk-B3JW6PKL.js.map → chunk-DGC275TW.js.map} +1 -1
- package/dist/{chunk-UGEQCMTF.cjs → chunk-DPYDYUNE.cjs} +6 -6
- package/dist/{chunk-UGEQCMTF.cjs.map → chunk-DPYDYUNE.cjs.map} +1 -1
- package/dist/{chunk-NKDJ3NB7.cjs → chunk-EJNF3SHB.cjs} +13 -13
- package/dist/{chunk-NKDJ3NB7.cjs.map → chunk-EJNF3SHB.cjs.map} +1 -1
- package/dist/{chunk-6QUFDLBF.js → chunk-EQNEDXMN.js} +1455 -500
- package/dist/chunk-EQNEDXMN.js.map +1 -0
- package/dist/{chunk-4HFYR562.cjs → chunk-EXKS4QPI.cjs} +4 -4
- package/dist/{chunk-4HFYR562.cjs.map → chunk-EXKS4QPI.cjs.map} +1 -1
- package/dist/{chunk-MT3JDOGB.js → chunk-FT4DS553.js} +3 -3
- package/dist/{chunk-MT3JDOGB.js.map → chunk-FT4DS553.js.map} +1 -1
- package/dist/{chunk-OWE6WTET.cjs → chunk-FUFSS7VA.cjs} +60 -72
- package/dist/chunk-FUFSS7VA.cjs.map +1 -0
- package/dist/{chunk-WJVTQDVD.js → chunk-G3RFKJJU.js} +3 -3
- package/dist/{chunk-WJVTQDVD.js.map → chunk-G3RFKJJU.js.map} +1 -1
- package/dist/{chunk-Y6KP7L4G.js → chunk-GE7ISCV6.js} +4 -4
- package/dist/{chunk-Y6KP7L4G.js.map → chunk-GE7ISCV6.js.map} +1 -1
- package/dist/{chunk-OM7JB5WU.js → chunk-GMVZRGQO.js} +5 -5
- package/dist/{chunk-OM7JB5WU.js.map → chunk-GMVZRGQO.js.map} +1 -1
- package/dist/{chunk-7P26KAVV.js → chunk-HEWFB56B.js} +3 -3
- package/dist/{chunk-7P26KAVV.js.map → chunk-HEWFB56B.js.map} +1 -1
- package/dist/chunk-I4THGZHE.js +1 -1
- package/dist/{chunk-7XTR7SGG.js → chunk-I5GL572F.js} +4 -4
- package/dist/{chunk-7XTR7SGG.js.map → chunk-I5GL572F.js.map} +1 -1
- package/dist/{chunk-K5LN7LC7.cjs → chunk-IG42BJP2.cjs} +6 -6
- package/dist/{chunk-K5LN7LC7.cjs.map → chunk-IG42BJP2.cjs.map} +1 -1
- package/dist/{chunk-FK2EKCKD.cjs → chunk-IY22KGE5.cjs} +10 -10
- package/dist/{chunk-FK2EKCKD.cjs.map → chunk-IY22KGE5.cjs.map} +1 -1
- package/dist/{chunk-YPINITSJ.js → chunk-JPEQNYEX.js} +4 -4
- package/dist/{chunk-YPINITSJ.js.map → chunk-JPEQNYEX.js.map} +1 -1
- package/dist/{chunk-RIX6WEJ2.js → chunk-JWVHBH4H.js} +4 -4
- package/dist/{chunk-RIX6WEJ2.js.map → chunk-JWVHBH4H.js.map} +1 -1
- package/dist/{chunk-NPM6FP7U.js → chunk-KOSD566C.js} +31 -43
- package/dist/chunk-KOSD566C.js.map +1 -0
- package/dist/{chunk-N4LZOZNQ.js → chunk-KRQBZU47.js} +3 -3
- package/dist/{chunk-N4LZOZNQ.js.map → chunk-KRQBZU47.js.map} +1 -1
- package/dist/{chunk-TP2QIZM2.cjs → chunk-L3PKZOCH.cjs} +23 -23
- package/dist/{chunk-TP2QIZM2.cjs.map → chunk-L3PKZOCH.cjs.map} +1 -1
- package/dist/{chunk-72KRYAZX.cjs → chunk-LB2Q4XI4.cjs} +30 -30
- package/dist/{chunk-72KRYAZX.cjs.map → chunk-LB2Q4XI4.cjs.map} +1 -1
- package/dist/{chunk-QMSOF7KE.cjs → chunk-M4UDCRIN.cjs} +4 -4
- package/dist/{chunk-QMSOF7KE.cjs.map → chunk-M4UDCRIN.cjs.map} +1 -1
- package/dist/chunk-M7JI4K5X.js +439 -0
- package/dist/chunk-M7JI4K5X.js.map +1 -0
- package/dist/{chunk-ODFFO43L.js → chunk-MQYYBBST.js} +3 -3
- package/dist/{chunk-ODFFO43L.js.map → chunk-MQYYBBST.js.map} +1 -1
- package/dist/{chunk-OKKKF7JI.cjs → chunk-MUMROKYH.cjs} +10 -10
- package/dist/{chunk-OKKKF7JI.cjs.map → chunk-MUMROKYH.cjs.map} +1 -1
- package/dist/{chunk-44S3O6VF.cjs → chunk-NGXIF36D.cjs} +28 -28
- package/dist/{chunk-44S3O6VF.cjs.map → chunk-NGXIF36D.cjs.map} +1 -1
- package/dist/{chunk-2X2QEOBC.cjs → chunk-NPVDYB24.cjs} +7 -7
- package/dist/{chunk-2X2QEOBC.cjs.map → chunk-NPVDYB24.cjs.map} +1 -1
- package/dist/{chunk-K3MAWEYM.js → chunk-NWIV4GMD.js} +4 -6
- package/dist/chunk-NWIV4GMD.js.map +1 -0
- package/dist/{chunk-EZCRZUSZ.cjs → chunk-O3GIJNJQ.cjs} +5 -7
- package/dist/chunk-O3GIJNJQ.cjs.map +1 -0
- package/dist/{chunk-XD5DGMZ7.js → chunk-OI6EEQT7.js} +3 -3
- package/dist/{chunk-XD5DGMZ7.js.map → chunk-OI6EEQT7.js.map} +1 -1
- package/dist/chunk-OP626LZY.js +1 -1
- package/dist/{chunk-B2I3RSXI.js → chunk-P3K2AI2N.js} +3 -3
- package/dist/{chunk-B2I3RSXI.js.map → chunk-P3K2AI2N.js.map} +1 -1
- package/dist/chunk-PALNMAC6.js +1 -1
- package/dist/chunk-PONEV4T5.js +1 -1
- package/dist/chunk-POPDRQ4N.cjs +441 -0
- package/dist/chunk-POPDRQ4N.cjs.map +1 -0
- package/dist/{chunk-C6CO5YP4.cjs → chunk-PRJNJRA5.cjs} +11 -11
- package/dist/{chunk-C6CO5YP4.cjs.map → chunk-PRJNJRA5.cjs.map} +1 -1
- package/dist/{chunk-EWYXWEIC.js → chunk-Q2YWHC5Y.js} +4 -4
- package/dist/{chunk-EWYXWEIC.js.map → chunk-Q2YWHC5Y.js.map} +1 -1
- package/dist/{chunk-LQ7HUDWG.js → chunk-QFRGVIVR.js} +4 -4
- package/dist/{chunk-LQ7HUDWG.js.map → chunk-QFRGVIVR.js.map} +1 -1
- package/dist/{chunk-Z5G5VHKI.cjs → chunk-RDXGM57M.cjs} +6 -6
- package/dist/{chunk-Z5G5VHKI.cjs.map → chunk-RDXGM57M.cjs.map} +1 -1
- package/dist/{chunk-K2HPB7GW.cjs → chunk-RESGDHIW.cjs} +12 -12
- package/dist/{chunk-K2HPB7GW.cjs.map → chunk-RESGDHIW.cjs.map} +1 -1
- package/dist/{chunk-LB37QWAP.js → chunk-RMHXKTUL.js} +3 -3
- package/dist/{chunk-LB37QWAP.js.map → chunk-RMHXKTUL.js.map} +1 -1
- package/dist/{chunk-3O2XU4R5.js → chunk-ROIFTNGB.js} +3 -3
- package/dist/{chunk-3O2XU4R5.js.map → chunk-ROIFTNGB.js.map} +1 -1
- package/dist/{chunk-BHU52WEM.js → chunk-RRN5I7DU.js} +3 -3
- package/dist/{chunk-BHU52WEM.js.map → chunk-RRN5I7DU.js.map} +1 -1
- package/dist/{chunk-G7COYXLW.js → chunk-RW6FVQAV.js} +3 -3
- package/dist/{chunk-G7COYXLW.js.map → chunk-RW6FVQAV.js.map} +1 -1
- package/dist/{chunk-BSI7ATYY.js → chunk-SE5JSC3Z.js} +3 -3
- package/dist/{chunk-BSI7ATYY.js.map → chunk-SE5JSC3Z.js.map} +1 -1
- package/dist/{chunk-TEPMJUHR.cjs → chunk-SUEWCFGL.cjs} +11 -11
- package/dist/{chunk-TEPMJUHR.cjs.map → chunk-SUEWCFGL.cjs.map} +1 -1
- package/dist/{chunk-Q4ZCPUL5.js → chunk-TYIWMIEZ.js} +4 -4
- package/dist/{chunk-Q4ZCPUL5.js.map → chunk-TYIWMIEZ.js.map} +1 -1
- package/dist/{chunk-VW7DYXR4.js → chunk-U3JH74LQ.js} +4 -4
- package/dist/{chunk-VW7DYXR4.js.map → chunk-U3JH74LQ.js.map} +1 -1
- package/dist/{chunk-R55KCZUE.cjs → chunk-UGSSDVWX.cjs} +10 -10
- package/dist/{chunk-R55KCZUE.cjs.map → chunk-UGSSDVWX.cjs.map} +1 -1
- package/dist/{chunk-LXUP2PQ7.js → chunk-ULTBLCHU.js} +4 -4
- package/dist/{chunk-LXUP2PQ7.js.map → chunk-ULTBLCHU.js.map} +1 -1
- package/dist/{chunk-3VBBHP5G.cjs → chunk-V3CQAU6N.cjs} +5 -5
- package/dist/{chunk-3VBBHP5G.cjs.map → chunk-V3CQAU6N.cjs.map} +1 -1
- package/dist/{chunk-WFZINVND.cjs → chunk-V4GV2KFM.cjs} +10 -10
- package/dist/{chunk-WFZINVND.cjs.map → chunk-V4GV2KFM.cjs.map} +1 -1
- package/dist/chunk-V7DWWIJ6.js +1 -1
- package/dist/{chunk-4XOJJK3B.cjs → chunk-VAZTGRCX.cjs} +10 -10
- package/dist/{chunk-4XOJJK3B.cjs.map → chunk-VAZTGRCX.cjs.map} +1 -1
- package/dist/{chunk-NVOAOFBL.js → chunk-VFXULNPW.js} +5 -5
- package/dist/{chunk-NVOAOFBL.js.map → chunk-VFXULNPW.js.map} +1 -1
- package/dist/{chunk-XJNEUXLW.cjs → chunk-VTGBTI6I.cjs} +11 -11
- package/dist/{chunk-XJNEUXLW.cjs.map → chunk-VTGBTI6I.cjs.map} +1 -1
- package/dist/{chunk-TNAIJP7Y.cjs → chunk-XPUEUWJA.cjs} +14 -14
- package/dist/{chunk-TNAIJP7Y.cjs.map → chunk-XPUEUWJA.cjs.map} +1 -1
- package/dist/{chunk-G7SPHSNU.js → chunk-YNRFZBX3.js} +3 -3
- package/dist/{chunk-G7SPHSNU.js.map → chunk-YNRFZBX3.js.map} +1 -1
- package/dist/{chunk-763JNSNR.cjs → chunk-YUJZ5S5E.cjs} +10 -10
- package/dist/{chunk-763JNSNR.cjs.map → chunk-YUJZ5S5E.cjs.map} +1 -1
- package/dist/{chunk-EJALJUGI.cjs → chunk-YVUN6KLP.cjs} +11 -11
- package/dist/{chunk-EJALJUGI.cjs.map → chunk-YVUN6KLP.cjs.map} +1 -1
- package/dist/chunk-ZBP3CYEO.cjs +441 -0
- package/dist/chunk-ZBP3CYEO.cjs.map +1 -0
- package/dist/{chunk-A4GP73T6.js → chunk-ZVVO7QD4.js} +3 -3
- package/dist/{chunk-A4GP73T6.js.map → chunk-ZVVO7QD4.js.map} +1 -1
- package/dist/dist-47C5ZLC7.js +1 -1
- package/dist/dist-BSWYTOHE.js +1 -1
- package/dist/dist-GKNLMW5G.js +1 -1
- package/dist/dist-RVKG65AN.js +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{observational-memory-XXD6E2SO-3I4EZBKC.cjs → observational-memory-XXD6E2SO-RTIRYSYO.cjs} +3 -3
- package/dist/{observational-memory-XXD6E2SO-3I4EZBKC.cjs.map → observational-memory-XXD6E2SO-RTIRYSYO.cjs.map} +1 -1
- package/dist/{observational-memory-XXD6E2SO-QVSLOLI6.js → observational-memory-XXD6E2SO-TGAG7QCA.js} +3 -3
- package/dist/{observational-memory-XXD6E2SO-QVSLOLI6.js.map → observational-memory-XXD6E2SO-TGAG7QCA.js.map} +1 -1
- package/dist/{probe-image-size-7HF7Q24F.cjs → probe-image-size-NW5AOXWX.cjs} +22 -6
- package/dist/probe-image-size-NW5AOXWX.cjs.map +1 -0
- package/dist/{probe-image-size-M5NYSF5D.js → probe-image-size-VSBN7AG5.js} +22 -6
- package/dist/probe-image-size-VSBN7AG5.js.map +1 -0
- package/dist/server/handlers/a2a.cjs +9 -9
- package/dist/server/handlers/a2a.js +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agent-versions.cjs +8 -8
- package/dist/server/handlers/agent-versions.js +1 -1
- package/dist/server/handlers/agents.cjs +33 -33
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/auth.cjs +10 -10
- package/dist/server/handlers/auth.js +1 -1
- package/dist/server/handlers/datasets.cjs +21 -21
- package/dist/server/handlers/datasets.js +1 -1
- package/dist/server/handlers/logs.cjs +4 -4
- package/dist/server/handlers/logs.js +1 -1
- package/dist/server/handlers/mcp-client-versions.cjs +8 -8
- package/dist/server/handlers/mcp-client-versions.js +1 -1
- package/dist/server/handlers/mcp.cjs +9 -9
- package/dist/server/handlers/mcp.js +1 -1
- package/dist/server/handlers/memory.cjs +27 -27
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/observability.cjs +5 -5
- package/dist/server/handlers/observability.js +1 -1
- package/dist/server/handlers/processor-providers.cjs +3 -3
- package/dist/server/handlers/processor-providers.js +1 -1
- package/dist/server/handlers/processors.cjs +4 -4
- package/dist/server/handlers/processors.js +1 -1
- package/dist/server/handlers/prompt-block-versions.cjs +8 -8
- package/dist/server/handlers/prompt-block-versions.js +1 -1
- package/dist/server/handlers/scorer-versions.cjs +8 -8
- package/dist/server/handlers/scorer-versions.js +1 -1
- package/dist/server/handlers/scores.cjs +7 -7
- package/dist/server/handlers/scores.js +1 -1
- package/dist/server/handlers/stored-agents.cjs +7 -7
- package/dist/server/handlers/stored-agents.js +1 -1
- package/dist/server/handlers/stored-mcp-clients.cjs +6 -6
- package/dist/server/handlers/stored-mcp-clients.js +1 -1
- package/dist/server/handlers/stored-prompt-blocks.cjs +6 -6
- package/dist/server/handlers/stored-prompt-blocks.js +1 -1
- package/dist/server/handlers/stored-scorers.cjs +6 -6
- package/dist/server/handlers/stored-scorers.js +1 -1
- package/dist/server/handlers/stored-skills.cjs +7 -7
- package/dist/server/handlers/stored-skills.js +1 -1
- package/dist/server/handlers/stored-workspaces.cjs +6 -6
- package/dist/server/handlers/stored-workspaces.js +1 -1
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.js +1 -1
- package/dist/server/handlers/tool-providers.cjs +5 -5
- package/dist/server/handlers/tool-providers.js +1 -1
- package/dist/server/handlers/tools.cjs +6 -6
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/vector.cjs +16 -16
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +8 -8
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +24 -24
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers/workspace.cjs +26 -26
- package/dist/server/handlers/workspace.js +1 -1
- package/dist/server/handlers.cjs +26 -26
- package/dist/server/handlers.js +13 -13
- package/dist/server/server-adapter/index.cjs +263 -263
- package/dist/server/server-adapter/index.js +33 -33
- package/dist/{token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js → token-APYSY3BW-IQ2CXU3Y-EMNLFKSZ.js} +11 -11
- package/dist/token-APYSY3BW-IQ2CXU3Y-EMNLFKSZ.js.map +1 -0
- package/dist/{token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs → token-APYSY3BW-IQ2CXU3Y-Q4YZA7WQ.cjs} +14 -14
- package/dist/token-APYSY3BW-IQ2CXU3Y-Q4YZA7WQ.cjs.map +1 -0
- package/dist/{token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js → token-APYSY3BW-YTVQELJT-QZMDAHMZ.js} +11 -11
- package/dist/token-APYSY3BW-YTVQELJT-QZMDAHMZ.js.map +1 -0
- package/dist/{token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs → token-APYSY3BW-YTVQELJT-T42LCASH.cjs} +14 -14
- package/dist/token-APYSY3BW-YTVQELJT-T42LCASH.cjs.map +1 -0
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR-CFO4FSTH.js +8 -0
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR-CFO4FSTH.js.map +1 -0
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR-OTS4QKL5.cjs +10 -0
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR-OTS4QKL5.cjs.map +1 -0
- package/dist/token-util-RMHT2CPJ-Z4NYHFEI-73T5DTFC.cjs +10 -0
- package/dist/token-util-RMHT2CPJ-Z4NYHFEI-73T5DTFC.cjs.map +1 -0
- package/dist/token-util-RMHT2CPJ-Z4NYHFEI-SHFH4TVB.js +8 -0
- package/dist/token-util-RMHT2CPJ-Z4NYHFEI-SHFH4TVB.js.map +1 -0
- package/package.json +5 -5
- package/dist/chunk-6G2RQWKA.cjs +0 -252
- package/dist/chunk-6G2RQWKA.cjs.map +0 -1
- package/dist/chunk-6QUFDLBF.js.map +0 -1
- package/dist/chunk-EZCRZUSZ.cjs.map +0 -1
- package/dist/chunk-HZINLMHL.cjs +0 -252
- package/dist/chunk-HZINLMHL.cjs.map +0 -1
- package/dist/chunk-IS3HHGL4.js +0 -250
- package/dist/chunk-IS3HHGL4.js.map +0 -1
- package/dist/chunk-K3MAWEYM.js.map +0 -1
- package/dist/chunk-NPM6FP7U.js.map +0 -1
- package/dist/chunk-OS7SAIRA.js +0 -250
- package/dist/chunk-OS7SAIRA.js.map +0 -1
- package/dist/chunk-OWE6WTET.cjs.map +0 -1
- package/dist/chunk-U4VL3LBC.cjs.map +0 -1
- package/dist/probe-image-size-7HF7Q24F.cjs.map +0 -1
- package/dist/probe-image-size-M5NYSF5D.js.map +0 -1
- package/dist/token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs.map +0 -1
- package/dist/token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js.map +0 -1
- package/dist/token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs.map +0 -1
- package/dist/token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js.map +0 -1
- package/dist/token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js +0 -8
- package/dist/token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js.map +0 -1
- package/dist/token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs +0 -10
- package/dist/token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs.map +0 -1
- package/dist/token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs +0 -10
- package/dist/token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs.map +0 -1
- package/dist/token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js +0 -8
- package/dist/token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/handlers/mcp.ts"],"names":["__export","createRoute","listMcpServersQuerySchema","listMcpServersResponseSchema","HTTPException","mcpServerDetailPathParams","getMcpServerDetailQuerySchema","serverDetailSchema","mcpServerIdPathParams","listMcpServerToolsResponseSchema","mcpServerToolPathParams","mcpToolInfoSchema","executeToolBodySchema","executeToolResponseSchema"],"mappings":";;;;;;;;AAAA,IAAA,WAAA,GAAA;AAAAA,0BAAA,CAAA,WAAA,EAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,gCAAA,EAAA,MAAA,gCAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAsBO,IAAM,yBAAyBC,6BAAA,CAAY;AAAA,EAChD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,iBAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,gBAAA,EAAkBC,2CAAA;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EACd,eAAA,EAAiBO,uCAAA;AAAA,EACjB,OAAA,EAAS,kBAAA;AAAA,EACT,WAAA,EAAa,2EAAA;AAAA,EACb,IAAA,EAAM,CAAC,KAAK,CAAA;AAAA,EACZ,YAAA,EAAc,IAAA;AAAA,EACd,SAAS,uBAAA,CAAwB;AACnC,CAAC","file":"chunk-TEPMJUHR.cjs","sourcesContent":["import type { MCPServerBase as MastraMCPServerImplementation, ServerInfo } from '@mastra/core/mcp';\nimport { HTTPException } from '../http-exception';\nimport {\n mcpServerDetailPathParams,\n mcpServerToolPathParams,\n executeToolBodySchema,\n listMcpServersQuerySchema,\n getMcpServerDetailQuerySchema,\n listMcpServersResponseSchema,\n serverDetailSchema,\n mcpServerIdPathParams,\n listMcpServerToolsResponseSchema,\n mcpToolInfoSchema,\n executeToolResponseSchema,\n} from '../schemas/mcp';\nimport type { ServerContext } from '../server-adapter';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\n// ============================================================================\n// Route Definitions (createRoute pattern for server adapters)\n// ============================================================================\n\nexport const LIST_MCP_SERVERS_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/v0/servers',\n responseType: 'json',\n queryParamSchema: listMcpServersQuerySchema,\n responseSchema: listMcpServersResponseSchema,\n summary: 'List MCP servers',\n description: 'Returns a list of registered MCP servers with pagination support',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({\n mastra,\n routePrefix,\n page,\n perPage,\n limit,\n offset,\n }: ServerContext & { page?: number; perPage?: number; limit?: number; offset?: number }) => {\n if (!mastra || typeof mastra.listMCPServers !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or listMCPServers method not available' });\n }\n\n const servers = mastra.listMCPServers();\n\n if (!servers) {\n return { servers: [], total_count: 0, next: null };\n }\n\n const serverList = Object.values(servers) as MastraMCPServerImplementation[];\n const totalCount = serverList.length;\n\n // Support both page/perPage and limit/offset for backwards compatibility\n // Detect which format user is using - prefer page/perPage if both provided\n const useLegacyFormat =\n (limit !== undefined || offset !== undefined) && page === undefined && perPage === undefined;\n\n // If perPage provided, use it; otherwise fall back to limit\n const finalPerPage = perPage ?? limit;\n // If page provided, use it; otherwise convert from offset\n let finalPage = page;\n if (finalPage === undefined && offset !== undefined && finalPerPage !== undefined && finalPerPage > 0) {\n finalPage = Math.floor(offset / finalPerPage);\n }\n\n // Calculate offset from page/perPage\n const actualOffset = finalPage !== undefined && finalPerPage !== undefined ? finalPage * finalPerPage : 0;\n\n // Apply pagination\n let paginatedServers = serverList;\n let nextUrl: string | null = null;\n\n if (finalPerPage !== undefined) {\n paginatedServers = serverList.slice(actualOffset, actualOffset + finalPerPage);\n\n // Calculate next URL if there are more results\n if (actualOffset + finalPerPage < totalCount) {\n const nextPage = (finalPage ?? 0) + 1;\n // Return next URL in same format as request (legacy limit/offset or page/perPage)\n const prefix = routePrefix ?? '';\n if (useLegacyFormat) {\n const nextOffset = actualOffset + finalPerPage;\n nextUrl = `${prefix}/mcp/v0/servers?limit=${finalPerPage}&offset=${nextOffset}`;\n } else {\n nextUrl = `${prefix}/mcp/v0/servers?perPage=${finalPerPage}&page=${nextPage}`;\n }\n }\n }\n\n // Get server info for each server\n const serverInfoList: ServerInfo[] = paginatedServers.map(server => server.getServerInfo());\n\n return {\n servers: serverInfoList,\n total_count: totalCount,\n next: nextUrl,\n };\n },\n});\n\nexport const GET_MCP_SERVER_DETAIL_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/v0/servers/:id',\n responseType: 'json',\n pathParamSchema: mcpServerDetailPathParams,\n queryParamSchema: getMcpServerDetailQuerySchema,\n responseSchema: serverDetailSchema,\n summary: 'Get MCP server details',\n description: 'Returns detailed information about a specific MCP server',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, id, version }: ServerContext & { id: string; version?: string }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(id);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${id}' not found` });\n }\n\n const serverDetail = server.getServerDetail();\n\n // If a specific version was requested, check if it matches\n if (version && serverDetail.version_detail.version !== version) {\n throw new HTTPException(404, {\n message: `MCP server with ID '${id}' found, but not version '${version}'. Available version: ${serverDetail.version_detail.version}`,\n });\n }\n\n return serverDetail;\n },\n});\n\nexport const LIST_MCP_SERVER_TOOLS_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/:serverId/tools',\n responseType: 'json',\n pathParamSchema: mcpServerIdPathParams,\n responseSchema: listMcpServerToolsResponseSchema,\n summary: 'List MCP server tools',\n description: 'Returns a list of tools available on the specified MCP server',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId }: ServerContext & { serverId: string }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${serverId}' not found` });\n }\n\n if (typeof server.getToolListInfo !== 'function') {\n throw new HTTPException(501, { message: `Server '${serverId}' cannot list tools in this way.` });\n }\n\n return server.getToolListInfo();\n },\n});\n\nexport const GET_MCP_SERVER_TOOL_DETAIL_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/:serverId/tools/:toolId',\n responseType: 'json',\n pathParamSchema: mcpServerToolPathParams,\n responseSchema: mcpToolInfoSchema,\n summary: 'Get MCP server tool details',\n description: 'Returns detailed information about a specific tool on the MCP server',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId, toolId }: ServerContext & { serverId: string; toolId: string }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${serverId}' not found` });\n }\n\n if (typeof server.getToolInfo !== 'function') {\n throw new HTTPException(501, { message: `Server '${serverId}' cannot provide tool details in this way.` });\n }\n\n const toolInfo = server.getToolInfo(toolId);\n if (!toolInfo) {\n throw new HTTPException(404, { message: `Tool with ID '${toolId}' not found on MCP server '${serverId}'` });\n }\n\n return toolInfo;\n },\n});\n\nexport const EXECUTE_MCP_SERVER_TOOL_ROUTE = createRoute({\n method: 'POST',\n path: '/mcp/:serverId/tools/:toolId/execute',\n responseType: 'json',\n pathParamSchema: mcpServerToolPathParams,\n bodySchema: executeToolBodySchema,\n responseSchema: executeToolResponseSchema,\n summary: 'Execute MCP server tool',\n description: 'Executes a tool on the specified MCP server with the provided arguments',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({\n mastra,\n serverId,\n toolId,\n data,\n }: ServerContext & { serverId: string; toolId: string; data?: unknown }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${serverId}' not found` });\n }\n\n if (typeof server.executeTool !== 'function') {\n throw new HTTPException(501, { message: `Server '${serverId}' cannot execute tools in this way.` });\n }\n\n const result = await server.executeTool(toolId, data);\n return { result };\n },\n});\n\n// ============================================================================\n// MCP Transport Routes (Streamable HTTP and SSE)\n// ============================================================================\n\n/**\n * MCP transport options that can be passed to startHTTP() or startSSE().\n * Includes serverless mode for running in stateless environments like Cloudflare Workers or Vercel Edge.\n */\nexport interface MCPTransportOptions {\n /**\n * When true, runs in stateless mode without session management.\n * Ideal for serverless environments where you can't maintain persistent connections.\n */\n serverless?: boolean;\n /**\n * Custom session ID generator function.\n */\n sessionIdGenerator?: () => string;\n}\n\n/**\n * MCP HTTP Transport response type.\n * Adapters use this to set up the HTTP transport via MCPServer.startHTTP()\n */\nexport interface MCPHttpTransportResult {\n server: MastraMCPServerImplementation;\n httpPath: string;\n /**\n * Optional MCP transport options for this specific route.\n * These override any class-level mcpOptions configured on the adapter.\n */\n mcpOptions?: MCPTransportOptions;\n}\n\n/**\n * MCP SSE Transport response type.\n * Adapters use this to set up the SSE transport via MCPServer.startSSE() or startHonoSSE()\n *\n * Note: SSE transport is inherently stateful and doesn't support serverless mode.\n */\nexport interface MCPSseTransportResult {\n server: MastraMCPServerImplementation;\n ssePath: string;\n messagePath: string;\n}\n\nexport const MCP_HTTP_TRANSPORT_ROUTE = createRoute({\n method: 'ALL',\n path: '/mcp/:serverId/mcp',\n responseType: 'mcp-http',\n pathParamSchema: mcpServerIdPathParams,\n summary: 'MCP HTTP Transport',\n description: 'Streamable HTTP transport endpoint for MCP protocol communication',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId }: ServerContext & { serverId: string }): Promise<MCPHttpTransportResult> => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server '${serverId}' not found` });\n }\n\n return {\n server,\n httpPath: `/mcp/${serverId}/mcp`,\n };\n },\n});\n\nexport const MCP_SSE_TRANSPORT_ROUTE = createRoute({\n method: 'ALL',\n path: '/mcp/:serverId/sse',\n responseType: 'mcp-sse',\n pathParamSchema: mcpServerIdPathParams,\n summary: 'MCP SSE Transport',\n description: 'SSE transport endpoint for MCP protocol communication',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId }: ServerContext & { serverId: string }): Promise<MCPSseTransportResult> => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server '${serverId}' not found` });\n }\n\n return {\n server,\n ssePath: `/mcp/${serverId}/sse`,\n messagePath: `/mcp/${serverId}/messages`,\n };\n },\n});\n\nexport const MCP_SSE_MESSAGES_ROUTE = createRoute({\n method: 'POST',\n path: '/mcp/:serverId/messages',\n responseType: 'mcp-sse',\n pathParamSchema: mcpServerIdPathParams,\n summary: 'MCP SSE Messages',\n description: 'Message endpoint for SSE transport (posts messages to active SSE streams)',\n tags: ['MCP'],\n requiresAuth: true,\n handler: MCP_SSE_TRANSPORT_ROUTE.handler,\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/mcp.ts"],"names":["__export","createRoute","listMcpServersQuerySchema","listMcpServersResponseSchema","HTTPException","mcpServerDetailPathParams","getMcpServerDetailQuerySchema","serverDetailSchema","mcpServerIdPathParams","listMcpServerToolsResponseSchema","mcpServerToolPathParams","mcpToolInfoSchema","executeToolBodySchema","executeToolResponseSchema"],"mappings":";;;;;;;;AAAA,IAAA,WAAA,GAAA;AAAAA,0BAAA,CAAA,WAAA,EAAA;AAAA,EAAA,6BAAA,EAAA,MAAA,6BAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,gCAAA,EAAA,MAAA,gCAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,2BAAA,EAAA,MAAA,2BAAA;AAAA,EAAA,wBAAA,EAAA,MAAA,wBAAA;AAAA,EAAA,sBAAA,EAAA,MAAA,sBAAA;AAAA,EAAA,uBAAA,EAAA,MAAA;AAAA,CAAA,CAAA;AAsBO,IAAM,yBAAyBC,6BAAA,CAAY;AAAA,EAChD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,iBAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,gBAAA,EAAkBC,2CAAA;AAAA,EAClB,cAAA,EAAgBC,8CAAA;AAAA,EAChB,OAAA,EAAS,kBAAA;AAAA,EACT,WAAA,EAAa,kEAAA;AAAA,EACb,IAAA,EAAM,CAAC,KAAK,CAAA;AAAA,EACZ,YAAA,EAAc,IAAA;AAAA,EACd,SAAS,OAAO;AAAA,IACd,MAAA;AAAA,IACA,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FGL.cjs","sourcesContent":["import type { MCPServerBase as MastraMCPServerImplementation, ServerInfo } from '@mastra/core/mcp';\nimport { HTTPException } from '../http-exception';\nimport {\n mcpServerDetailPathParams,\n mcpServerToolPathParams,\n executeToolBodySchema,\n listMcpServersQuerySchema,\n getMcpServerDetailQuerySchema,\n listMcpServersResponseSchema,\n serverDetailSchema,\n mcpServerIdPathParams,\n listMcpServerToolsResponseSchema,\n mcpToolInfoSchema,\n executeToolResponseSchema,\n} from '../schemas/mcp';\nimport type { ServerContext } from '../server-adapter';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\n// ============================================================================\n// Route Definitions (createRoute pattern for server adapters)\n// ============================================================================\n\nexport const LIST_MCP_SERVERS_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/v0/servers',\n responseType: 'json',\n queryParamSchema: listMcpServersQuerySchema,\n responseSchema: listMcpServersResponseSchema,\n summary: 'List MCP servers',\n description: 'Returns a list of registered MCP servers with pagination support',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({\n mastra,\n routePrefix,\n page,\n perPage,\n limit,\n offset,\n }: ServerContext & { page?: number; perPage?: number; limit?: number; offset?: number }) => {\n if (!mastra || typeof mastra.listMCPServers !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or listMCPServers method not available' });\n }\n\n const servers = mastra.listMCPServers();\n\n if (!servers) {\n return { servers: [], total_count: 0, next: null };\n }\n\n const serverList = Object.values(servers) as MastraMCPServerImplementation[];\n const totalCount = serverList.length;\n\n // Support both page/perPage and limit/offset for backwards compatibility\n // Detect which format user is using - prefer page/perPage if both provided\n const useLegacyFormat =\n (limit !== undefined || offset !== undefined) && page === undefined && perPage === undefined;\n\n // If perPage provided, use it; otherwise fall back to limit\n const finalPerPage = perPage ?? limit;\n // If page provided, use it; otherwise convert from offset\n let finalPage = page;\n if (finalPage === undefined && offset !== undefined && finalPerPage !== undefined && finalPerPage > 0) {\n finalPage = Math.floor(offset / finalPerPage);\n }\n\n // Calculate offset from page/perPage\n const actualOffset = finalPage !== undefined && finalPerPage !== undefined ? finalPage * finalPerPage : 0;\n\n // Apply pagination\n let paginatedServers = serverList;\n let nextUrl: string | null = null;\n\n if (finalPerPage !== undefined) {\n paginatedServers = serverList.slice(actualOffset, actualOffset + finalPerPage);\n\n // Calculate next URL if there are more results\n if (actualOffset + finalPerPage < totalCount) {\n const nextPage = (finalPage ?? 0) + 1;\n // Return next URL in same format as request (legacy limit/offset or page/perPage)\n const prefix = routePrefix ?? '';\n if (useLegacyFormat) {\n const nextOffset = actualOffset + finalPerPage;\n nextUrl = `${prefix}/mcp/v0/servers?limit=${finalPerPage}&offset=${nextOffset}`;\n } else {\n nextUrl = `${prefix}/mcp/v0/servers?perPage=${finalPerPage}&page=${nextPage}`;\n }\n }\n }\n\n // Get server info for each server\n const serverInfoList: ServerInfo[] = paginatedServers.map(server => server.getServerInfo());\n\n return {\n servers: serverInfoList,\n total_count: totalCount,\n next: nextUrl,\n };\n },\n});\n\nexport const GET_MCP_SERVER_DETAIL_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/v0/servers/:id',\n responseType: 'json',\n pathParamSchema: mcpServerDetailPathParams,\n queryParamSchema: getMcpServerDetailQuerySchema,\n responseSchema: serverDetailSchema,\n summary: 'Get MCP server details',\n description: 'Returns detailed information about a specific MCP server',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, id, version }: ServerContext & { id: string; version?: string }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(id);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${id}' not found` });\n }\n\n const serverDetail = server.getServerDetail();\n\n // If a specific version was requested, check if it matches\n if (version && serverDetail.version_detail.version !== version) {\n throw new HTTPException(404, {\n message: `MCP server with ID '${id}' found, but not version '${version}'. Available version: ${serverDetail.version_detail.version}`,\n });\n }\n\n return serverDetail;\n },\n});\n\nexport const LIST_MCP_SERVER_TOOLS_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/:serverId/tools',\n responseType: 'json',\n pathParamSchema: mcpServerIdPathParams,\n responseSchema: listMcpServerToolsResponseSchema,\n summary: 'List MCP server tools',\n description: 'Returns a list of tools available on the specified MCP server',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId }: ServerContext & { serverId: string }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${serverId}' not found` });\n }\n\n if (typeof server.getToolListInfo !== 'function') {\n throw new HTTPException(501, { message: `Server '${serverId}' cannot list tools in this way.` });\n }\n\n return server.getToolListInfo();\n },\n});\n\nexport const GET_MCP_SERVER_TOOL_DETAIL_ROUTE = createRoute({\n method: 'GET',\n path: '/mcp/:serverId/tools/:toolId',\n responseType: 'json',\n pathParamSchema: mcpServerToolPathParams,\n responseSchema: mcpToolInfoSchema,\n summary: 'Get MCP server tool details',\n description: 'Returns detailed information about a specific tool on the MCP server',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId, toolId }: ServerContext & { serverId: string; toolId: string }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${serverId}' not found` });\n }\n\n if (typeof server.getToolInfo !== 'function') {\n throw new HTTPException(501, { message: `Server '${serverId}' cannot provide tool details in this way.` });\n }\n\n const toolInfo = server.getToolInfo(toolId);\n if (!toolInfo) {\n throw new HTTPException(404, { message: `Tool with ID '${toolId}' not found on MCP server '${serverId}'` });\n }\n\n return toolInfo;\n },\n});\n\nexport const EXECUTE_MCP_SERVER_TOOL_ROUTE = createRoute({\n method: 'POST',\n path: '/mcp/:serverId/tools/:toolId/execute',\n responseType: 'json',\n pathParamSchema: mcpServerToolPathParams,\n bodySchema: executeToolBodySchema,\n responseSchema: executeToolResponseSchema,\n summary: 'Execute MCP server tool',\n description: 'Executes a tool on the specified MCP server with the provided arguments',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({\n mastra,\n serverId,\n toolId,\n data,\n }: ServerContext & { serverId: string; toolId: string; data?: unknown }) => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server with ID '${serverId}' not found` });\n }\n\n if (typeof server.executeTool !== 'function') {\n throw new HTTPException(501, { message: `Server '${serverId}' cannot execute tools in this way.` });\n }\n\n const result = await server.executeTool(toolId, data);\n return { result };\n },\n});\n\n// ============================================================================\n// MCP Transport Routes (Streamable HTTP and SSE)\n// ============================================================================\n\n/**\n * MCP transport options that can be passed to startHTTP() or startSSE().\n * Includes serverless mode for running in stateless environments like Cloudflare Workers or Vercel Edge.\n */\nexport interface MCPTransportOptions {\n /**\n * When true, runs in stateless mode without session management.\n * Ideal for serverless environments where you can't maintain persistent connections.\n */\n serverless?: boolean;\n /**\n * Custom session ID generator function.\n */\n sessionIdGenerator?: () => string;\n}\n\n/**\n * MCP HTTP Transport response type.\n * Adapters use this to set up the HTTP transport via MCPServer.startHTTP()\n */\nexport interface MCPHttpTransportResult {\n server: MastraMCPServerImplementation;\n httpPath: string;\n /**\n * Optional MCP transport options for this specific route.\n * These override any class-level mcpOptions configured on the adapter.\n */\n mcpOptions?: MCPTransportOptions;\n}\n\n/**\n * MCP SSE Transport response type.\n * Adapters use this to set up the SSE transport via MCPServer.startSSE() or startHonoSSE()\n *\n * Note: SSE transport is inherently stateful and doesn't support serverless mode.\n */\nexport interface MCPSseTransportResult {\n server: MastraMCPServerImplementation;\n ssePath: string;\n messagePath: string;\n}\n\nexport const MCP_HTTP_TRANSPORT_ROUTE = createRoute({\n method: 'ALL',\n path: '/mcp/:serverId/mcp',\n responseType: 'mcp-http',\n pathParamSchema: mcpServerIdPathParams,\n summary: 'MCP HTTP Transport',\n description: 'Streamable HTTP transport endpoint for MCP protocol communication',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId }: ServerContext & { serverId: string }): Promise<MCPHttpTransportResult> => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server '${serverId}' not found` });\n }\n\n return {\n server,\n httpPath: `/mcp/${serverId}/mcp`,\n };\n },\n});\n\nexport const MCP_SSE_TRANSPORT_ROUTE = createRoute({\n method: 'ALL',\n path: '/mcp/:serverId/sse',\n responseType: 'mcp-sse',\n pathParamSchema: mcpServerIdPathParams,\n summary: 'MCP SSE Transport',\n description: 'SSE transport endpoint for MCP protocol communication',\n tags: ['MCP'],\n requiresAuth: true,\n handler: async ({ mastra, serverId }: ServerContext & { serverId: string }): Promise<MCPSseTransportResult> => {\n if (!mastra || typeof mastra.getMCPServerById !== 'function') {\n throw new HTTPException(500, { message: 'Mastra instance or getMCPServerById method not available' });\n }\n\n const server = mastra.getMCPServerById(serverId);\n\n if (!server) {\n throw new HTTPException(404, { message: `MCP server '${serverId}' not found` });\n }\n\n return {\n server,\n ssePath: `/mcp/${serverId}/sse`,\n messagePath: `/mcp/${serverId}/messages`,\n };\n },\n});\n\nexport const MCP_SSE_MESSAGES_ROUTE = createRoute({\n method: 'POST',\n path: '/mcp/:serverId/messages',\n responseType: 'mcp-sse',\n pathParamSchema: mcpServerIdPathParams,\n summary: 'MCP SSE Messages',\n description: 'Message endpoint for SSE transport (posts messages to active SSE streams)',\n tags: ['MCP'],\n requiresAuth: true,\n handler: MCP_SSE_TRANSPORT_ROUTE.handler,\n});\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { listStoredScorersResponseSchema, listStoredScorersQuerySchema, getStoredScorerResponseSchema, storedScorerIdPathParams, createStoredScorerResponseSchema, createStoredScorerBodySchema, updateStoredScorerResponseSchema, updateStoredScorerBodySchema, deleteStoredScorerResponseSchema } from './chunk-BTRFBBRF.js';
|
|
2
2
|
import { handleAutoVersioning } from './chunk-33QPJPK4.js';
|
|
3
|
-
import { toSlug } from './chunk-
|
|
3
|
+
import { toSlug } from './chunk-7DAMVPUL.js';
|
|
4
4
|
import { statusQuerySchema } from './chunk-USZD5AX2.js';
|
|
5
5
|
import { handleError } from './chunk-NA7LKQPZ.js';
|
|
6
|
-
import { createRoute } from './chunk-
|
|
6
|
+
import { createRoute } from './chunk-NWIV4GMD.js';
|
|
7
7
|
import { HTTPException } from './chunk-6QWQZI4Q.js';
|
|
8
8
|
|
|
9
9
|
// src/server/handlers/stored-scorers.ts
|
|
@@ -271,5 +271,5 @@ var DELETE_STORED_SCORER_ROUTE = createRoute({
|
|
|
271
271
|
});
|
|
272
272
|
|
|
273
273
|
export { CREATE_STORED_SCORER_ROUTE, DELETE_STORED_SCORER_ROUTE, GET_STORED_SCORER_ROUTE, LIST_STORED_SCORERS_ROUTE, UPDATE_STORED_SCORER_ROUTE };
|
|
274
|
-
//# sourceMappingURL=chunk-
|
|
275
|
-
//# sourceMappingURL=chunk-
|
|
274
|
+
//# sourceMappingURL=chunk-TYIWMIEZ.js.map
|
|
275
|
+
//# sourceMappingURL=chunk-TYIWMIEZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/handlers/stored-scorers.ts"],"names":[],"mappings":";;;;;;;;;AAoBA,IAAM,6BAAA,GAAgC;AAAA,EACpC,MAAA;AAAA,EACA,aAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,cAAA;AAAA,EACA,YAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CA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S,6BAA6B,CAAA;AAAA,MACvE;AAEA,MAAA,MAAM,WAAA,GAAc,MAAM,OAAA,CAAQ,QAAA,CAAS,mBAAmB,CAAA;AAC9D,MAAA,IAAI,CAAC,WAAA,EAAa;AAChB,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,sDAAsD,CAAA;AAAA,MAChG;AAGA,MAAA,MAAM,QAAA,GAAW,MAAM,WAAA,CAAY,OAAA,CAAQ,cAAc,CAAA;AACzD,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,cAAc,GAAA,EAAK,EAAE,SAAS,CAAA,iCAAA,EAAoC,cAAc,cAAc,CAAA;AAAA,MAC1G;AAEA,MAAA,MAAM,WAAA,CAAY,OAAO,cAAc,CAAA;AAGvC,MAAA,MAAA,CAAO,SAAA,EAAU,EAAG,MAAA,CAAO,UAAA,CAAW,cAAc,CAAA;AAEpD,MAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA,kBAAA,EAAqB,cAAc,CAAA,qBAAA,CAAA,EAAwB;AAAA,IAC9F,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,yCAAyC,CAAA;AAAA,IACrE;AAAA,EACF;AACF,CAAC","file":"chunk-Q4ZCPUL5.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n storedScorerIdPathParams,\n statusQuerySchema,\n listStoredScorersQuerySchema,\n createStoredScorerBodySchema,\n updateStoredScorerBodySchema,\n listStoredScorersResponseSchema,\n getStoredScorerResponseSchema,\n createStoredScorerResponseSchema,\n updateStoredScorerResponseSchema,\n deleteStoredScorerResponseSchema,\n} from '../schemas/stored-scorers';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst SCORER_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'type',\n 'model',\n 'instructions',\n 'scoreRange',\n 'presetConfig',\n 'defaultSampling',\n] as const;\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/scorers - List all stored scorer definitions\n */\nexport const LIST_STORED_SCORERS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/scorers',\n responseType: 'json',\n queryParamSchema: listStoredScorersQuerySchema,\n responseSchema: listStoredScorersResponseSchema,\n summary: 'List stored scorer definitions',\n description: 'Returns a paginated list of all scorer definitions stored in the database',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n const result = await scorerStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId,\n metadata,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing stored scorer definitions');\n }\n },\n});\n\n/**\n * GET /stored/scorers/:storedScorerId - Get a stored scorer definition by ID\n */\nexport const GET_STORED_SCORER_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/scorers/:storedScorerId',\n responseType: 'json',\n pathParamSchema: storedScorerIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredScorerResponseSchema,\n summary: 'Get stored scorer definition by ID',\n description:\n 'Returns a specific scorer definition from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({ mastra, storedScorerId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n const scorer = await scorerStore.getByIdResolved(storedScorerId, { status });\n\n if (!scorer) {\n throw new HTTPException(404, { message: `Stored scorer definition with id ${storedScorerId} not found` });\n }\n\n return scorer;\n } catch (error) {\n return handleError(error, 'Error getting stored scorer definition');\n }\n },\n});\n\n/**\n * POST /stored/scorers - Create a new stored scorer definition\n */\nexport const CREATE_STORED_SCORER_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/scorers',\n responseType: 'json',\n bodySchema: createStoredScorerBodySchema,\n responseSchema: createStoredScorerResponseSchema,\n summary: 'Create stored scorer definition',\n description: 'Creates a new scorer definition in storage with the provided configuration',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive scorer definition ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if scorer definition with this ID already exists\n const existing = await scorerStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Scorer definition with id ${id} already exists` });\n }\n\n await scorerStore.create({\n scorerDefinition: {\n id,\n authorId,\n metadata,\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n },\n });\n\n // Return the resolved scorer definition (thin record + version config)\n // Use draft status since newly created entities start as drafts\n const resolved = await scorerStore.getByIdResolved(id, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created scorer definition' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error creating stored scorer definition');\n }\n },\n});\n\n/**\n * PATCH /stored/scorers/:storedScorerId - Update a stored scorer definition\n */\nexport const UPDATE_STORED_SCORER_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/scorers/:storedScorerId',\n responseType: 'json',\n pathParamSchema: storedScorerIdPathParams,\n bodySchema: updateStoredScorerBodySchema,\n responseSchema: updateStoredScorerResponseSchema,\n summary: 'Update stored scorer definition',\n description: 'Updates an existing scorer definition in storage with the provided fields',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedScorerId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n // Check if scorer definition exists\n const existing = await scorerStore.getById(storedScorerId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored scorer definition with id ${storedScorerId} not found` });\n }\n\n // Update the scorer definition with both metadata-level and config-level fields\n const updatedScorer = await scorerStore.update({\n id: storedScorerId,\n authorId,\n metadata,\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n });\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = {\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n // It does NOT update activeVersionId — the version stays as a draft until explicitly published.\n await handleAutoVersioning(\n scorerStore as unknown as VersionedStoreInterface,\n storedScorerId,\n 'scorerDefinitionId',\n SCORER_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedScorer,\n providedConfigFields,\n );\n\n // Clear the cached scorer instance so the next request gets the updated config\n const editor = mastra.getEditor();\n if (editor) {\n editor.scorer.clearCache(storedScorerId);\n }\n\n // Return the resolved scorer definition with the latest (draft) version so the UI sees its edits\n const resolved = await scorerStore.getByIdResolved(storedScorerId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated scorer definition' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error updating stored scorer definition');\n }\n },\n});\n\n/**\n * DELETE /stored/scorers/:storedScorerId - Delete a stored scorer definition\n */\nexport const DELETE_STORED_SCORER_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/scorers/:storedScorerId',\n responseType: 'json',\n pathParamSchema: storedScorerIdPathParams,\n responseSchema: deleteStoredScorerResponseSchema,\n summary: 'Delete stored scorer definition',\n description: 'Deletes a scorer definition from storage by its unique identifier',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({ mastra, storedScorerId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n // Check if scorer definition exists\n const existing = await scorerStore.getById(storedScorerId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored scorer definition with id ${storedScorerId} not found` });\n }\n\n await scorerStore.delete(storedScorerId);\n\n // Clear the cached scorer instance\n mastra.getEditor()?.scorer.clearCache(storedScorerId);\n\n return { success: true, message: `Scorer definition ${storedScorerId} deleted successfully` };\n } catch (error) {\n return handleError(error, 'Error deleting stored scorer definition');\n }\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/stored-scorers.ts"],"names":[],"mappings":";;;;;;;;;AAoBA,IAAM,6BAAA,GAAgC;AAAA,EACpC,MAAA;AAAA,EACA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AA,EAAW;AAElC,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6BAA6B,CAAA;AAAA,MACvE;AAEA,MAAA,MAAM,WAAA,GAAc,MAAM,OAAA,CAAQ,QAAA,CAAS,mBAAmB,CAAA;AAC9D,MAAA,IAAI,CAAC,WAAA,EAAa;AAChB,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,sDAAsD,CAAA;AAAA,MAChG;AAGA,MAAA,MAAM,QAAA,GAAW,MAAM,WAAA,CAAY,OAAA,CAAQ,cAAc,CAAA;AACzD,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,cAAc,GAAA,EAAK,EAAE,SAAS,CAAA,iCAAA,EAAoC,cAAc,cAAc,CAAA;AAAA,MAC1G;AAEA,MAAA,MAAM,WAAA,CAAY,OAAO,cAAc,CAAA;AAGvC,MAAA,MAAA,CAAO,SAAA,EAAU,EAAG,MAAA,CAAO,UAAA,CAAW,cAAc,CAAA;AAEpD,MAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA,kBAAA,EAAqB,cAAc,CAAA,qBAAA,CAAA,EAAwB;AAAA,IAC9F,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,yCAAyC,CAAA;AAAA,IACrE;AAAA,EACF;AACF,CAAC","file":"chunk-TYIWMIEZ.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n storedScorerIdPathParams,\n statusQuerySchema,\n listStoredScorersQuerySchema,\n createStoredScorerBodySchema,\n updateStoredScorerBodySchema,\n listStoredScorersResponseSchema,\n getStoredScorerResponseSchema,\n createStoredScorerResponseSchema,\n updateStoredScorerResponseSchema,\n deleteStoredScorerResponseSchema,\n} from '../schemas/stored-scorers';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst SCORER_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'type',\n 'model',\n 'instructions',\n 'scoreRange',\n 'presetConfig',\n 'defaultSampling',\n] as const;\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/scorers - List all stored scorer definitions\n */\nexport const LIST_STORED_SCORERS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/scorers',\n responseType: 'json',\n queryParamSchema: listStoredScorersQuerySchema,\n responseSchema: listStoredScorersResponseSchema,\n summary: 'List stored scorer definitions',\n description: 'Returns a paginated list of all scorer definitions stored in the database',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n const result = await scorerStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId,\n metadata,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing stored scorer definitions');\n }\n },\n});\n\n/**\n * GET /stored/scorers/:storedScorerId - Get a stored scorer definition by ID\n */\nexport const GET_STORED_SCORER_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/scorers/:storedScorerId',\n responseType: 'json',\n pathParamSchema: storedScorerIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredScorerResponseSchema,\n summary: 'Get stored scorer definition by ID',\n description:\n 'Returns a specific scorer definition from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({ mastra, storedScorerId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n const scorer = await scorerStore.getByIdResolved(storedScorerId, { status });\n\n if (!scorer) {\n throw new HTTPException(404, { message: `Stored scorer definition with id ${storedScorerId} not found` });\n }\n\n return scorer;\n } catch (error) {\n return handleError(error, 'Error getting stored scorer definition');\n }\n },\n});\n\n/**\n * POST /stored/scorers - Create a new stored scorer definition\n */\nexport const CREATE_STORED_SCORER_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/scorers',\n responseType: 'json',\n bodySchema: createStoredScorerBodySchema,\n responseSchema: createStoredScorerResponseSchema,\n summary: 'Create stored scorer definition',\n description: 'Creates a new scorer definition in storage with the provided configuration',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive scorer definition ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if scorer definition with this ID already exists\n const existing = await scorerStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Scorer definition with id ${id} already exists` });\n }\n\n await scorerStore.create({\n scorerDefinition: {\n id,\n authorId,\n metadata,\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n },\n });\n\n // Return the resolved scorer definition (thin record + version config)\n // Use draft status since newly created entities start as drafts\n const resolved = await scorerStore.getByIdResolved(id, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created scorer definition' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error creating stored scorer definition');\n }\n },\n});\n\n/**\n * PATCH /stored/scorers/:storedScorerId - Update a stored scorer definition\n */\nexport const UPDATE_STORED_SCORER_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/scorers/:storedScorerId',\n responseType: 'json',\n pathParamSchema: storedScorerIdPathParams,\n bodySchema: updateStoredScorerBodySchema,\n responseSchema: updateStoredScorerResponseSchema,\n summary: 'Update stored scorer definition',\n description: 'Updates an existing scorer definition in storage with the provided fields',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedScorerId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n // Check if scorer definition exists\n const existing = await scorerStore.getById(storedScorerId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored scorer definition with id ${storedScorerId} not found` });\n }\n\n // Update the scorer definition with both metadata-level and config-level fields\n const updatedScorer = await scorerStore.update({\n id: storedScorerId,\n authorId,\n metadata,\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n });\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = {\n name,\n description,\n type,\n model,\n instructions,\n scoreRange,\n presetConfig,\n defaultSampling,\n };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n // It does NOT update activeVersionId — the version stays as a draft until explicitly published.\n await handleAutoVersioning(\n scorerStore as unknown as VersionedStoreInterface,\n storedScorerId,\n 'scorerDefinitionId',\n SCORER_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedScorer,\n providedConfigFields,\n );\n\n // Clear the cached scorer instance so the next request gets the updated config\n const editor = mastra.getEditor();\n if (editor) {\n editor.scorer.clearCache(storedScorerId);\n }\n\n // Return the resolved scorer definition with the latest (draft) version so the UI sees its edits\n const resolved = await scorerStore.getByIdResolved(storedScorerId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated scorer definition' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error updating stored scorer definition');\n }\n },\n});\n\n/**\n * DELETE /stored/scorers/:storedScorerId - Delete a stored scorer definition\n */\nexport const DELETE_STORED_SCORER_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/scorers/:storedScorerId',\n responseType: 'json',\n pathParamSchema: storedScorerIdPathParams,\n responseSchema: deleteStoredScorerResponseSchema,\n summary: 'Delete stored scorer definition',\n description: 'Deletes a scorer definition from storage by its unique identifier',\n tags: ['Stored Scorers'],\n requiresAuth: true,\n handler: async ({ mastra, storedScorerId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const scorerStore = await storage.getStore('scorerDefinitions');\n if (!scorerStore) {\n throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n }\n\n // Check if scorer definition exists\n const existing = await scorerStore.getById(storedScorerId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored scorer definition with id ${storedScorerId} not found` });\n }\n\n await scorerStore.delete(storedScorerId);\n\n // Clear the cached scorer instance\n mastra.getEditor()?.scorer.clearCache(storedScorerId);\n\n return { success: true, message: `Scorer definition ${storedScorerId} deleted successfully` };\n } catch (error) {\n return handleError(error, 'Error deleting stored scorer definition');\n }\n },\n});\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { listStoredPromptBlocksResponseSchema, listStoredPromptBlocksQuerySchema, getStoredPromptBlockResponseSchema, storedPromptBlockIdPathParams, createStoredPromptBlockResponseSchema, createStoredPromptBlockBodySchema, updateStoredPromptBlockResponseSchema, updateStoredPromptBlockBodySchema, deleteStoredPromptBlockResponseSchema } from './chunk-7NDOPT3W.js';
|
|
2
2
|
import { handleAutoVersioning } from './chunk-33QPJPK4.js';
|
|
3
|
-
import { toSlug } from './chunk-
|
|
3
|
+
import { toSlug } from './chunk-7DAMVPUL.js';
|
|
4
4
|
import { statusQuerySchema } from './chunk-USZD5AX2.js';
|
|
5
5
|
import { handleError } from './chunk-NA7LKQPZ.js';
|
|
6
|
-
import { createRoute } from './chunk-
|
|
6
|
+
import { createRoute } from './chunk-NWIV4GMD.js';
|
|
7
7
|
import { HTTPException } from './chunk-6QWQZI4Q.js';
|
|
8
8
|
|
|
9
9
|
// src/server/handlers/stored-prompt-blocks.ts
|
|
@@ -259,5 +259,5 @@ var DELETE_STORED_PROMPT_BLOCK_ROUTE = createRoute({
|
|
|
259
259
|
});
|
|
260
260
|
|
|
261
261
|
export { CREATE_STORED_PROMPT_BLOCK_ROUTE, DELETE_STORED_PROMPT_BLOCK_ROUTE, GET_STORED_PROMPT_BLOCK_ROUTE, LIST_STORED_PROMPT_BLOCKS_ROUTE, UPDATE_STORED_PROMPT_BLOCK_ROUTE };
|
|
262
|
-
//# sourceMappingURL=chunk-
|
|
263
|
-
//# sourceMappingURL=chunk-
|
|
262
|
+
//# sourceMappingURL=chunk-U3JH74LQ.js.map
|
|
263
|
+
//# sourceMappingURL=chunk-U3JH74LQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/handlers/stored-prompt-blocks.ts"],"names":[],"mappings":";;;;;;;;;AAoBA,IAAM,mCAAA,GAAsC;AAAA,EAC1C,MAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EAC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A,EAA+B,mBAAmB,cAAc,CAAA;AAAA,MAC1G;AAEA,MAAA,MAAM,gBAAA,CAAiB,OAAO,mBAAmB,CAAA;AAEjD,MAAA,OAAO;AAAA,QACL,OAAA,EAAS,IAAA;AAAA,QACT,OAAA,EAAS,gBAAgB,mBAAmB,CAAA,qBAAA;AAAA,OAC9C;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,oCAAoC,CAAA;AAAA,IAChE;AAAA,EACF;AACF,CAAC","file":"chunk-VW7DYXR4.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n storedPromptBlockIdPathParams,\n statusQuerySchema,\n listStoredPromptBlocksQuerySchema,\n createStoredPromptBlockBodySchema,\n updateStoredPromptBlockBodySchema,\n listStoredPromptBlocksResponseSchema,\n getStoredPromptBlockResponseSchema,\n createStoredPromptBlockResponseSchema,\n updateStoredPromptBlockResponseSchema,\n deleteStoredPromptBlockResponseSchema,\n} from '../schemas/stored-prompt-blocks';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'content',\n 'rules',\n 'requestContextSchema',\n] as const;\n\n/** Computes whether a prompt block has an unpublished draft version. */\nfunction computeHasDraft(\n latestVersion: { id: string } | null | undefined,\n activeVersionId: string | null | undefined,\n): boolean {\n return !!(latestVersion && (!activeVersionId || latestVersion.id !== activeVersionId));\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/prompt-blocks - List all stored prompt blocks\n */\nexport const LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n queryParamSchema: listStoredPromptBlocksQuerySchema,\n responseSchema: listStoredPromptBlocksResponseSchema,\n summary: 'List stored prompt blocks',\n description: 'Returns a paginated list of all prompt blocks stored in the database',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const result = await promptBlockStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId,\n metadata,\n });\n\n // For each block, fetch the latest version to compute hasDraft.\n // resolvedVersionId from listResolved defaults to 'published' resolution,\n // so we need the actual latest version to detect unpublished drafts.\n const promptBlocks = await Promise.all(\n result.promptBlocks.map(async (block: (typeof result.promptBlocks)[number]) => {\n const latestVersion = await promptBlockStore.getLatestVersion(block.id);\n return { ...block, hasDraft: computeHasDraft(latestVersion, block.activeVersionId) };\n }),\n );\n\n return { ...result, promptBlocks };\n } catch (error) {\n return handleError(error, 'Error listing stored prompt blocks');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:storedPromptBlockId - Get a stored prompt block by ID\n */\nexport const GET_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredPromptBlockResponseSchema,\n summary: 'Get stored prompt block by ID',\n description:\n 'Returns a specific prompt block from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status });\n\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n\n return { ...promptBlock, hasDraft: computeHasDraft(latestVersion, promptBlock.activeVersionId) };\n } catch (error) {\n return handleError(error, 'Error getting stored prompt block');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks - Create a new stored prompt block\n */\nexport const CREATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n bodySchema: createStoredPromptBlockBodySchema,\n responseSchema: createStoredPromptBlockResponseSchema,\n summary: 'Create stored prompt block',\n description: 'Creates a new prompt block in storage with the provided configuration',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive prompt block ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if prompt block with this ID already exists\n const existing = await promptBlockStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Prompt block with id ${id} already exists` });\n }\n\n await promptBlockStore.create({\n promptBlock: {\n id,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n },\n });\n\n // Return the resolved prompt block (thin record + version config)\n // Use draft status since newly created entities start as drafts\n const resolved = await promptBlockStore.getByIdResolved(id, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(id);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error creating stored prompt block');\n }\n },\n});\n\n/**\n * PATCH /stored/prompt-blocks/:storedPromptBlockId - Update a stored prompt block\n */\nexport const UPDATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n bodySchema: updateStoredPromptBlockBodySchema,\n responseSchema: updateStoredPromptBlockResponseSchema,\n summary: 'Update stored prompt block',\n description: 'Updates an existing prompt block in storage with the provided fields',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedPromptBlockId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n // Update the prompt block with both metadata-level and config-level fields\n const updatedPromptBlock = await promptBlockStore.update({\n id: storedPromptBlockId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n });\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = { name, description, content, rules, requestContextSchema };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n // It does NOT update activeVersionId — the version stays as a draft until explicitly published.\n await handleAutoVersioning(\n promptBlockStore as unknown as VersionedStoreInterface,\n storedPromptBlockId,\n 'blockId',\n PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedPromptBlock,\n providedConfigFields,\n );\n\n // Return the resolved prompt block with the latest (draft) version so the UI sees its edits\n const resolved = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error updating stored prompt block');\n }\n },\n});\n\n/**\n * DELETE /stored/prompt-blocks/:storedPromptBlockId - Delete a stored prompt block\n */\nexport const DELETE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n responseSchema: deleteStoredPromptBlockResponseSchema,\n summary: 'Delete stored prompt block',\n description: 'Deletes a prompt block from storage by its unique identifier',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n await promptBlockStore.delete(storedPromptBlockId);\n\n return {\n success: true,\n message: `Prompt block ${storedPromptBlockId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored prompt block');\n }\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/stored-prompt-blocks.ts"],"names":[],"mappings":";;;;;;;;;AAoBA,IAAM,mCAAA,GAAsC;AAAA,EAC1C,MAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAA;AAGA,SAAS,eAAA,CACP,eACA,eAAA,EACS;AACT,EAAA,OAAO,CAAC,EAAE,aAAA,KAAkB,CAAC,eAAA,IAAmB,cAAc,EAAA,KAAO,eAAA,CAAA,CAAA;AACvE;AASO,IAAM,kCAAkC,WAAA,CAAY;AAAA,EACzD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,uBAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,gBAAA,EAAkB,iCAAA;AAAA,EAClB,cAAA,EAAgB,oCAAA;AAAA,EAChB,OAAA,EAAS,2BAAA;AAAA,EACT,WAAA,EAAa,sEAAA;AAAA,EACb,IAAA,EAAM,CAAC,sBAAsB,CAAA;AAAA,EAC7B,YAAA,EAAc,IAAA;AAAA,EACd,OAAA,EAAS,OAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,SAAS,OAAA,EAAS,MAAA,EAAQ,QAAA,EAAU,QAAA,EAAS,KAAM;AACjF,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAElC,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6BAA6B,CAAA;AAAA,MACvE;AAEA,MAAA,MAAM,gBAAA,GAAmB,MAAM,OAAA,CAAQ,QAAA,CAAS,cAAc,CAAA;AAC9D,MAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,QAAA,MAAM,I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MAAA,IAAI,CAAC,gBAAA,EAAkB;AACrB,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,iDAAiD,CAAA;AAAA,MAC3F;AAGA,MAAA,MAAM,QAAA,GAAW,MAAM,gBAAA,CAAiB,OAAA,CAAQ,mBAAmB,CAAA;AACnE,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,cAAc,GAAA,EAAK,EAAE,SAAS,CAAA,4BAAA,EAA+B,mBAAmB,cAAc,CAAA;AAAA,MAC1G;AAEA,MAAA,MAAM,gBAAA,CAAiB,OAAO,mBAAmB,CAAA;AAEjD,MAAA,OAAO;AAAA,QACL,OAAA,EAAS,IAAA;AAAA,QACT,OAAA,EAAS,gBAAgB,mBAAmB,CAAA,qBAAA;AAAA,OAC9C;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,oCAAoC,CAAA;AAAA,IAChE;AAAA,EACF;AACF,CAAC","file":"chunk-U3JH74LQ.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n storedPromptBlockIdPathParams,\n statusQuerySchema,\n listStoredPromptBlocksQuerySchema,\n createStoredPromptBlockBodySchema,\n updateStoredPromptBlockBodySchema,\n listStoredPromptBlocksResponseSchema,\n getStoredPromptBlockResponseSchema,\n createStoredPromptBlockResponseSchema,\n updateStoredPromptBlockResponseSchema,\n deleteStoredPromptBlockResponseSchema,\n} from '../schemas/stored-prompt-blocks';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\nimport { handleAutoVersioning } from './version-helpers';\nimport type { VersionedStoreInterface } from './version-helpers';\n\nconst PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS = [\n 'name',\n 'description',\n 'content',\n 'rules',\n 'requestContextSchema',\n] as const;\n\n/** Computes whether a prompt block has an unpublished draft version. */\nfunction computeHasDraft(\n latestVersion: { id: string } | null | undefined,\n activeVersionId: string | null | undefined,\n): boolean {\n return !!(latestVersion && (!activeVersionId || latestVersion.id !== activeVersionId));\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/prompt-blocks - List all stored prompt blocks\n */\nexport const LIST_STORED_PROMPT_BLOCKS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n queryParamSchema: listStoredPromptBlocksQuerySchema,\n responseSchema: listStoredPromptBlocksResponseSchema,\n summary: 'List stored prompt blocks',\n description: 'Returns a paginated list of all prompt blocks stored in the database',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, status, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const result = await promptBlockStore.listResolved({\n page,\n perPage,\n orderBy,\n status,\n authorId,\n metadata,\n });\n\n // For each block, fetch the latest version to compute hasDraft.\n // resolvedVersionId from listResolved defaults to 'published' resolution,\n // so we need the actual latest version to detect unpublished drafts.\n const promptBlocks = await Promise.all(\n result.promptBlocks.map(async (block: (typeof result.promptBlocks)[number]) => {\n const latestVersion = await promptBlockStore.getLatestVersion(block.id);\n return { ...block, hasDraft: computeHasDraft(latestVersion, block.activeVersionId) };\n }),\n );\n\n return { ...result, promptBlocks };\n } catch (error) {\n return handleError(error, 'Error listing stored prompt blocks');\n }\n },\n});\n\n/**\n * GET /stored/prompt-blocks/:storedPromptBlockId - Get a stored prompt block by ID\n */\nexport const GET_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n queryParamSchema: statusQuerySchema,\n responseSchema: getStoredPromptBlockResponseSchema,\n summary: 'Get stored prompt block by ID',\n description:\n 'Returns a specific prompt block from storage by its unique identifier. Use ?status=draft to resolve with the latest (draft) version, or ?status=published (default) for the active published version.',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId, status }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n const promptBlock = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status });\n\n if (!promptBlock) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n\n return { ...promptBlock, hasDraft: computeHasDraft(latestVersion, promptBlock.activeVersionId) };\n } catch (error) {\n return handleError(error, 'Error getting stored prompt block');\n }\n },\n});\n\n/**\n * POST /stored/prompt-blocks - Create a new stored prompt block\n */\nexport const CREATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/prompt-blocks',\n responseType: 'json',\n bodySchema: createStoredPromptBlockBodySchema,\n responseSchema: createStoredPromptBlockResponseSchema,\n summary: 'Create stored prompt block',\n description: 'Creates a new prompt block in storage with the provided configuration',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive prompt block ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if prompt block with this ID already exists\n const existing = await promptBlockStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Prompt block with id ${id} already exists` });\n }\n\n await promptBlockStore.create({\n promptBlock: {\n id,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n },\n });\n\n // Return the resolved prompt block (thin record + version config)\n // Use draft status since newly created entities start as drafts\n const resolved = await promptBlockStore.getByIdResolved(id, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(id);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error creating stored prompt block');\n }\n },\n});\n\n/**\n * PATCH /stored/prompt-blocks/:storedPromptBlockId - Update a stored prompt block\n */\nexport const UPDATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n bodySchema: updateStoredPromptBlockBodySchema,\n responseSchema: updateStoredPromptBlockResponseSchema,\n summary: 'Update stored prompt block',\n description: 'Updates an existing prompt block in storage with the provided fields',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedPromptBlockId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n content,\n rules,\n requestContextSchema,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n // Update the prompt block with both metadata-level and config-level fields\n const updatedPromptBlock = await promptBlockStore.update({\n id: storedPromptBlockId,\n authorId,\n metadata,\n name,\n description,\n content,\n rules,\n requestContextSchema,\n });\n\n // Build the snapshot config for auto-versioning comparison\n const configFields = { name, description, content, rules, requestContextSchema };\n\n // Filter out undefined values to get only the config fields that were provided\n const providedConfigFields = Object.fromEntries(Object.entries(configFields).filter(([_, v]) => v !== undefined));\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a new version if there are meaningful config changes.\n // It does NOT update activeVersionId — the version stays as a draft until explicitly published.\n await handleAutoVersioning(\n promptBlockStore as unknown as VersionedStoreInterface,\n storedPromptBlockId,\n 'blockId',\n PROMPT_BLOCK_SNAPSHOT_CONFIG_FIELDS,\n existing,\n updatedPromptBlock,\n providedConfigFields,\n );\n\n // Return the resolved prompt block with the latest (draft) version so the UI sees its edits\n const resolved = await promptBlockStore.getByIdResolved(storedPromptBlockId, { status: 'draft' });\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated prompt block' });\n }\n\n const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n const hasDraft = !!(\n latestVersion &&\n (!resolved.activeVersionId || latestVersion.id !== resolved.activeVersionId)\n );\n\n return { ...resolved, hasDraft };\n } catch (error) {\n return handleError(error, 'Error updating stored prompt block');\n }\n },\n});\n\n/**\n * DELETE /stored/prompt-blocks/:storedPromptBlockId - Delete a stored prompt block\n */\nexport const DELETE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/prompt-blocks/:storedPromptBlockId',\n responseType: 'json',\n pathParamSchema: storedPromptBlockIdPathParams,\n responseSchema: deleteStoredPromptBlockResponseSchema,\n summary: 'Delete stored prompt block',\n description: 'Deletes a prompt block from storage by its unique identifier',\n tags: ['Stored Prompt Blocks'],\n requiresAuth: true,\n handler: async ({ mastra, storedPromptBlockId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const promptBlockStore = await storage.getStore('promptBlocks');\n if (!promptBlockStore) {\n throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n }\n\n // Check if prompt block exists\n const existing = await promptBlockStore.getById(storedPromptBlockId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n }\n\n await promptBlockStore.delete(storedPromptBlockId);\n\n return {\n success: true,\n message: `Prompt block ${storedPromptBlockId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored prompt block');\n }\n },\n});\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkIG42BJP2_cjs = require('./chunk-IG42BJP2.cjs');
|
|
4
4
|
var chunkU3PO2SCK_cjs = require('./chunk-U3PO2SCK.cjs');
|
|
5
5
|
var chunkY2BKW5ND_cjs = require('./chunk-Y2BKW5ND.cjs');
|
|
6
|
-
var
|
|
6
|
+
var chunkO3GIJNJQ_cjs = require('./chunk-O3GIJNJQ.cjs');
|
|
7
7
|
var chunk64ITUOXI_cjs = require('./chunk-64ITUOXI.cjs');
|
|
8
8
|
|
|
9
9
|
// src/server/handlers/stored-workspaces.ts
|
|
10
|
-
var LIST_STORED_WORKSPACES_ROUTE =
|
|
10
|
+
var LIST_STORED_WORKSPACES_ROUTE = chunkO3GIJNJQ_cjs.createRoute({
|
|
11
11
|
method: "GET",
|
|
12
12
|
path: "/stored/workspaces",
|
|
13
13
|
responseType: "json",
|
|
@@ -40,7 +40,7 @@ var LIST_STORED_WORKSPACES_ROUTE = chunkEZCRZUSZ_cjs.createRoute({
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
var GET_STORED_WORKSPACE_ROUTE =
|
|
43
|
+
var GET_STORED_WORKSPACE_ROUTE = chunkO3GIJNJQ_cjs.createRoute({
|
|
44
44
|
method: "GET",
|
|
45
45
|
path: "/stored/workspaces/:storedWorkspaceId",
|
|
46
46
|
responseType: "json",
|
|
@@ -70,7 +70,7 @@ var GET_STORED_WORKSPACE_ROUTE = chunkEZCRZUSZ_cjs.createRoute({
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
|
-
var CREATE_STORED_WORKSPACE_ROUTE =
|
|
73
|
+
var CREATE_STORED_WORKSPACE_ROUTE = chunkO3GIJNJQ_cjs.createRoute({
|
|
74
74
|
method: "POST",
|
|
75
75
|
path: "/stored/workspaces",
|
|
76
76
|
responseType: "json",
|
|
@@ -105,7 +105,7 @@ var CREATE_STORED_WORKSPACE_ROUTE = chunkEZCRZUSZ_cjs.createRoute({
|
|
|
105
105
|
if (!workspaceStore) {
|
|
106
106
|
throw new chunk64ITUOXI_cjs.HTTPException(500, { message: "Workspaces storage domain is not available" });
|
|
107
107
|
}
|
|
108
|
-
const id = providedId ||
|
|
108
|
+
const id = providedId || chunkIG42BJP2_cjs.toSlug(name);
|
|
109
109
|
if (!id) {
|
|
110
110
|
throw new chunk64ITUOXI_cjs.HTTPException(400, {
|
|
111
111
|
message: "Could not derive workspace ID from name. Please provide an explicit id."
|
|
@@ -142,7 +142,7 @@ var CREATE_STORED_WORKSPACE_ROUTE = chunkEZCRZUSZ_cjs.createRoute({
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
|
-
var UPDATE_STORED_WORKSPACE_ROUTE =
|
|
145
|
+
var UPDATE_STORED_WORKSPACE_ROUTE = chunkO3GIJNJQ_cjs.createRoute({
|
|
146
146
|
method: "PATCH",
|
|
147
147
|
path: "/stored/workspaces/:storedWorkspaceId",
|
|
148
148
|
responseType: "json",
|
|
@@ -209,7 +209,7 @@ var UPDATE_STORED_WORKSPACE_ROUTE = chunkEZCRZUSZ_cjs.createRoute({
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
});
|
|
212
|
-
var DELETE_STORED_WORKSPACE_ROUTE =
|
|
212
|
+
var DELETE_STORED_WORKSPACE_ROUTE = chunkO3GIJNJQ_cjs.createRoute({
|
|
213
213
|
method: "DELETE",
|
|
214
214
|
path: "/stored/workspaces/:storedWorkspaceId",
|
|
215
215
|
responseType: "json",
|
|
@@ -249,5 +249,5 @@ exports.DELETE_STORED_WORKSPACE_ROUTE = DELETE_STORED_WORKSPACE_ROUTE;
|
|
|
249
249
|
exports.GET_STORED_WORKSPACE_ROUTE = GET_STORED_WORKSPACE_ROUTE;
|
|
250
250
|
exports.LIST_STORED_WORKSPACES_ROUTE = LIST_STORED_WORKSPACES_ROUTE;
|
|
251
251
|
exports.UPDATE_STORED_WORKSPACE_ROUTE = UPDATE_STORED_WORKSPACE_ROUTE;
|
|
252
|
-
//# sourceMappingURL=chunk-
|
|
253
|
-
//# sourceMappingURL=chunk-
|
|
252
|
+
//# sourceMappingURL=chunk-UGSSDVWX.cjs.map
|
|
253
|
+
//# sourceMappingURL=chunk-UGSSDVWX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/handlers/stored-workspaces.ts"],"names":["createRoute","listStoredWorkspacesQuerySchema","listStoredWorkspacesResponseSchema","HTTPException","handleError","storedWorkspaceIdPathParams","getStoredWorkspaceResponseSchema","createStoredWorkspaceBodySchema","createStoredWorkspaceResponseSchema","toSlug","updateStoredWorkspaceBodySchema","updateStoredWorkspaceResponseSchema","deleteStoredWorkspaceResponseSchema"],"mappings":";;;;;;;;;AAwBO,IAAM,+BAA+BA,6BAAA,CAAY;AAAA,EACtD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,oBAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,gBAAA,EAAkBC,iDAAA;AAAA,EAClB,cAAA,EAAgBC,oDAAA;AAAA,EAChB,OAAA,EAAS,wBAAA;AAAA,EACT,WAAA,EAAa,iFAAA;AAAA,EACb,IAAA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cAAA,EAAgBO,qDAAA;AAAA,EAChB,OAAA,EAAS,yBAAA;AAAA,EACT,WAAA,EAAa,2DAAA;AAAA,EACb,IAAA,EAAM,CAAC,mBAAmB,CAAA;AAAA,EAC1B,YAAA,EAAc,IAAA;AAAA,EACd,OAAA,EAAS,OAAO,EAAE,MAAA,EAAQ,mBAAkB,KAAM;AAChD,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAElC,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,MAAM,IAAIT,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6BAA6B,CAAA;AAAA,MACvE;AAEA,MAAA,MAAM,cAAA,GAAiB,MAAM,OAAA,CAAQ,QAAA,CAAS,YAAY,CAAA;AAC1D,MAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,QAAA,MAAM,IAAIA,+BAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,8CAA8C,CAAA;AAAA,MACxF;AAGA,MAAA,MAAM,QAAA,GAAW,MAAM,cAAA,CAAe,OAAA,CAAQ,iBAAiB,CAAA;AAC/D,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAIA,gCAAc,GAAA,EAAK,EAAE,SAAS,CAAA,yBAAA,EAA4B,iBAAiB,cAAc,CAAA;AAAA,MACrG;AAEA,MAAA,MAAM,cAAA,CAAe,OAAO,iBAAiB,CAAA;AAE7C,MAAA,OAAO;AAAA,QACL,OAAA,EAAS,IAAA;AAAA,QACT,OAAA,EAAS,aAAa,iBAAiB,CAAA,qBAAA;AAAA,OACzC;AAAA,IACF,SAAS,KAAA,EAAO;AACd,MAAA,OAAOC,6BAAA,CAAY,OAAO,iCAAiC,CAAA;AAAA,IAC7D;AAAA,EACF;AACF,CAAC","file":"chunk-R55KCZUE.cjs","sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n storedWorkspaceIdPathParams,\n listStoredWorkspacesQuerySchema,\n createStoredWorkspaceBodySchema,\n updateStoredWorkspaceBodySchema,\n listStoredWorkspacesResponseSchema,\n getStoredWorkspaceResponseSchema,\n createStoredWorkspaceResponseSchema,\n updateStoredWorkspaceResponseSchema,\n deleteStoredWorkspaceResponseSchema,\n} from '../schemas/stored-workspaces';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/workspaces - List all stored workspaces\n */\nexport const LIST_STORED_WORKSPACES_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/workspaces',\n responseType: 'json',\n queryParamSchema: listStoredWorkspacesQuerySchema,\n responseSchema: listStoredWorkspacesResponseSchema,\n summary: 'List stored workspaces',\n description: 'Returns a paginated list of all workspace configurations stored in the database',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n const result = await workspaceStore.listResolved({\n page,\n perPage,\n orderBy,\n authorId,\n metadata,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing stored workspaces');\n }\n },\n});\n\n/**\n * GET /stored/workspaces/:storedWorkspaceId - Get a stored workspace by ID\n */\nexport const GET_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/workspaces/:storedWorkspaceId',\n responseType: 'json',\n pathParamSchema: storedWorkspaceIdPathParams,\n responseSchema: getStoredWorkspaceResponseSchema,\n summary: 'Get stored workspace by ID',\n description:\n 'Returns a specific workspace from storage by its unique identifier (resolved with active version config)',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({ mastra, storedWorkspaceId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n const workspace = await workspaceStore.getByIdResolved(storedWorkspaceId);\n\n if (!workspace) {\n throw new HTTPException(404, { message: `Stored workspace with id ${storedWorkspaceId} not found` });\n }\n\n return workspace;\n } catch (error) {\n return handleError(error, 'Error getting stored workspace');\n }\n },\n});\n\n/**\n * POST /stored/workspaces - Create a new stored workspace\n */\nexport const CREATE_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/workspaces',\n responseType: 'json',\n bodySchema: createStoredWorkspaceBodySchema,\n responseSchema: createStoredWorkspaceResponseSchema,\n summary: 'Create stored workspace',\n description: 'Creates a new workspace configuration in storage with the provided settings',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive workspace ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if workspace with this ID already exists\n const existing = await workspaceStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Workspace with id ${id} already exists` });\n }\n\n await workspaceStore.create({\n workspace: {\n id,\n authorId,\n metadata,\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n },\n });\n\n // Return the resolved workspace (thin record + version config)\n const resolved = await workspaceStore.getByIdResolved(id);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created workspace' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error creating stored workspace');\n }\n },\n});\n\n/**\n * PATCH /stored/workspaces/:storedWorkspaceId - Update a stored workspace\n */\nexport const UPDATE_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/workspaces/:storedWorkspaceId',\n responseType: 'json',\n pathParamSchema: storedWorkspaceIdPathParams,\n bodySchema: updateStoredWorkspaceBodySchema,\n responseSchema: updateStoredWorkspaceResponseSchema,\n summary: 'Update stored workspace',\n description: 'Updates an existing workspace in storage with the provided fields',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedWorkspaceId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n // Check if workspace exists\n const existing = await workspaceStore.getById(storedWorkspaceId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored workspace with id ${storedWorkspaceId} not found` });\n }\n\n // Update the workspace with both metadata-level and config-level fields\n // The storage layer handles separating these into record updates vs new-version creation\n await workspaceStore.update({\n id: storedWorkspaceId,\n authorId,\n metadata,\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n });\n\n // Return the resolved workspace with the updated config\n const resolved = await workspaceStore.getByIdResolved(storedWorkspaceId);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated workspace' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error updating stored workspace');\n }\n },\n});\n\n/**\n * DELETE /stored/workspaces/:storedWorkspaceId - Delete a stored workspace\n */\nexport const DELETE_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/workspaces/:storedWorkspaceId',\n responseType: 'json',\n pathParamSchema: storedWorkspaceIdPathParams,\n responseSchema: deleteStoredWorkspaceResponseSchema,\n summary: 'Delete stored workspace',\n description: 'Deletes a workspace from storage by its unique identifier',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({ mastra, storedWorkspaceId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n // Check if workspace exists\n const existing = await workspaceStore.getById(storedWorkspaceId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored workspace with id ${storedWorkspaceId} not found` });\n }\n\n await workspaceStore.delete(storedWorkspaceId);\n\n return {\n success: true,\n message: `Workspace ${storedWorkspaceId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored workspace');\n }\n },\n});\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/server/handlers/stored-workspaces.ts"],"names":["createRoute","listStoredWorkspacesQuerySchema","listStoredWorkspacesResponseSchema","HTTPException","handleError","storedWorkspaceIdPathParams","getStoredWorkspaceResponseSchema","createStoredWorkspaceBodySchema","createStoredWorkspaceResponseSchema","toSlug","updateStoredWorkspaceBodySchema","updateStoredWorkspaceResponseSchema","deleteStoredWorkspaceResponseSchema"],"mappings":";;;;;;;;;AAwBO,IAAM,+BAA+BA,6BAAA,CAAY;AAAA,EACtD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,oBAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,gBAAA,EAAkBC,iDAAA;AAAA,EAClB,cAAA,EAAgBC,oDAAA;AAAA,EAChB,OAAA,EAAS,wBAAA;AAAA,EACT,WAAA,E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listStoredWorkspacesQuerySchema,\n createStoredWorkspaceBodySchema,\n updateStoredWorkspaceBodySchema,\n listStoredWorkspacesResponseSchema,\n getStoredWorkspaceResponseSchema,\n createStoredWorkspaceResponseSchema,\n updateStoredWorkspaceResponseSchema,\n deleteStoredWorkspaceResponseSchema,\n} from '../schemas/stored-workspaces';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { toSlug } from '../utils';\n\nimport { handleError } from './error';\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/workspaces - List all stored workspaces\n */\nexport const LIST_STORED_WORKSPACES_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/workspaces',\n responseType: 'json',\n queryParamSchema: listStoredWorkspacesQuerySchema,\n responseSchema: listStoredWorkspacesResponseSchema,\n summary: 'List stored workspaces',\n description: 'Returns a paginated list of all workspace configurations stored in the database',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, authorId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n const result = await workspaceStore.listResolved({\n page,\n perPage,\n orderBy,\n authorId,\n metadata,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing stored workspaces');\n }\n },\n});\n\n/**\n * GET /stored/workspaces/:storedWorkspaceId - Get a stored workspace by ID\n */\nexport const GET_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/workspaces/:storedWorkspaceId',\n responseType: 'json',\n pathParamSchema: storedWorkspaceIdPathParams,\n responseSchema: getStoredWorkspaceResponseSchema,\n summary: 'Get stored workspace by ID',\n description:\n 'Returns a specific workspace from storage by its unique identifier (resolved with active version config)',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({ mastra, storedWorkspaceId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n const workspace = await workspaceStore.getByIdResolved(storedWorkspaceId);\n\n if (!workspace) {\n throw new HTTPException(404, { message: `Stored workspace with id ${storedWorkspaceId} not found` });\n }\n\n return workspace;\n } catch (error) {\n return handleError(error, 'Error getting stored workspace');\n }\n },\n});\n\n/**\n * POST /stored/workspaces - Create a new stored workspace\n */\nexport const CREATE_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/workspaces',\n responseType: 'json',\n bodySchema: createStoredWorkspaceBodySchema,\n responseSchema: createStoredWorkspaceResponseSchema,\n summary: 'Create stored workspace',\n description: 'Creates a new workspace configuration in storage with the provided settings',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id: providedId,\n authorId,\n metadata,\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n // Derive ID from name if not explicitly provided\n const id = providedId || toSlug(name);\n\n if (!id) {\n throw new HTTPException(400, {\n message: 'Could not derive workspace ID from name. Please provide an explicit id.',\n });\n }\n\n // Check if workspace with this ID already exists\n const existing = await workspaceStore.getById(id);\n if (existing) {\n throw new HTTPException(409, { message: `Workspace with id ${id} already exists` });\n }\n\n await workspaceStore.create({\n workspace: {\n id,\n authorId,\n metadata,\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n },\n });\n\n // Return the resolved workspace (thin record + version config)\n const resolved = await workspaceStore.getByIdResolved(id);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve created workspace' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error creating stored workspace');\n }\n },\n});\n\n/**\n * PATCH /stored/workspaces/:storedWorkspaceId - Update a stored workspace\n */\nexport const UPDATE_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/workspaces/:storedWorkspaceId',\n responseType: 'json',\n pathParamSchema: storedWorkspaceIdPathParams,\n bodySchema: updateStoredWorkspaceBodySchema,\n responseSchema: updateStoredWorkspaceResponseSchema,\n summary: 'Update stored workspace',\n description: 'Updates an existing workspace in storage with the provided fields',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedWorkspaceId,\n // Metadata-level fields\n authorId,\n metadata,\n // Config fields (snapshot-level)\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n // Check if workspace exists\n const existing = await workspaceStore.getById(storedWorkspaceId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored workspace with id ${storedWorkspaceId} not found` });\n }\n\n // Update the workspace with both metadata-level and config-level fields\n // The storage layer handles separating these into record updates vs new-version creation\n await workspaceStore.update({\n id: storedWorkspaceId,\n authorId,\n metadata,\n name,\n description,\n filesystem,\n sandbox,\n mounts,\n search,\n skills,\n tools,\n autoSync,\n operationTimeout,\n });\n\n // Return the resolved workspace with the updated config\n const resolved = await workspaceStore.getByIdResolved(storedWorkspaceId);\n if (!resolved) {\n throw new HTTPException(500, { message: 'Failed to resolve updated workspace' });\n }\n\n return resolved;\n } catch (error) {\n return handleError(error, 'Error updating stored workspace');\n }\n },\n});\n\n/**\n * DELETE /stored/workspaces/:storedWorkspaceId - Delete a stored workspace\n */\nexport const DELETE_STORED_WORKSPACE_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/workspaces/:storedWorkspaceId',\n responseType: 'json',\n pathParamSchema: storedWorkspaceIdPathParams,\n responseSchema: deleteStoredWorkspaceResponseSchema,\n summary: 'Delete stored workspace',\n description: 'Deletes a workspace from storage by its unique identifier',\n tags: ['Stored Workspaces'],\n requiresAuth: true,\n handler: async ({ mastra, storedWorkspaceId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const workspaceStore = await storage.getStore('workspaces');\n if (!workspaceStore) {\n throw new HTTPException(500, { message: 'Workspaces storage domain is not available' });\n }\n\n // Check if workspace exists\n const existing = await workspaceStore.getById(storedWorkspaceId);\n if (!existing) {\n throw new HTTPException(404, { message: `Stored workspace with id ${storedWorkspaceId} not found` });\n }\n\n await workspaceStore.delete(storedWorkspaceId);\n\n return {\n success: true,\n message: `Workspace ${storedWorkspaceId} deleted successfully`,\n };\n } catch (error) {\n return handleError(error, 'Error deleting stored workspace');\n }\n },\n});\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { handleAutoVersioning } from './chunk-33QPJPK4.js';
|
|
2
|
-
import { toSlug } from './chunk-
|
|
2
|
+
import { toSlug } from './chunk-7DAMVPUL.js';
|
|
3
3
|
import { listStoredAgentsResponseSchema, listStoredAgentsQuerySchema, getStoredAgentResponseSchema, storedAgentIdPathParams, createStoredAgentResponseSchema, createStoredAgentBodySchema, updateStoredAgentResponseSchema, updateStoredAgentBodySchema, deleteStoredAgentResponseSchema, previewInstructionsResponseSchema, previewInstructionsBodySchema } from './chunk-VKTJMAUK.js';
|
|
4
4
|
import { statusQuerySchema } from './chunk-USZD5AX2.js';
|
|
5
5
|
import { handleError } from './chunk-NA7LKQPZ.js';
|
|
6
|
-
import { createRoute } from './chunk-
|
|
6
|
+
import { createRoute } from './chunk-NWIV4GMD.js';
|
|
7
7
|
import { HTTPException } from './chunk-6QWQZI4Q.js';
|
|
8
8
|
|
|
9
9
|
// src/server/handlers/stored-agents.ts
|
|
@@ -354,5 +354,5 @@ var PREVIEW_INSTRUCTIONS_ROUTE = createRoute({
|
|
|
354
354
|
});
|
|
355
355
|
|
|
356
356
|
export { CREATE_STORED_AGENT_ROUTE, DELETE_STORED_AGENT_ROUTE, GET_STORED_AGENT_ROUTE, LIST_STORED_AGENTS_ROUTE, PREVIEW_INSTRUCTIONS_ROUTE, UPDATE_STORED_AGENT_ROUTE };
|
|
357
|
-
//# sourceMappingURL=chunk-
|
|
358
|
-
//# sourceMappingURL=chunk-
|
|
357
|
+
//# sourceMappingURL=chunk-ULTBLCHU.js.map
|
|
358
|
+
//# sourceMappingURL=chunk-ULTBLCHU.js.map
|