@decocms/mesh 2.155.0 → 2.156.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/dist/client/assets/{AlertCircle-D8CXFvYW.js → AlertCircle-Bs59-MFg.js} +1 -1
- package/dist/client/assets/{AlignLeft-CI8EzNNL.js → AlignLeft-Dw8zoQY4.js} +1 -1
- package/dist/client/assets/{ArrowDown-Day-BlQM.js → ArrowDown-Dz0Qb_uU.js} +1 -1
- package/dist/client/assets/{ArrowLeft-B2yP6vhy.js → ArrowLeft-nf9Juy8Q.js} +1 -1
- package/dist/client/assets/{ArrowUp-Bc1LEzvX.js → ArrowUp-BbpofAC9.js} +1 -1
- package/dist/client/assets/{Check-_ISbUca5.js → Check-DkUOUUvl.js} +1 -1
- package/dist/client/assets/{CheckCircle-DE93B6bt.js → CheckCircle-CoODIWm2.js} +1 -1
- package/dist/client/assets/{CheckDone01-B9vdsp1y.js → CheckDone01-3g3DwmsK.js} +1 -1
- package/dist/client/assets/{CheckVerified02-gWJxMpzI.js → CheckVerified02-ON1zMxxY.js} +1 -1
- package/dist/client/assets/{ChevronDown-CJ2cKOCp.js → ChevronDown-BbYSw3gW.js} +1 -1
- package/dist/client/assets/{ChevronLeft-DD-X9Vf_.js → ChevronLeft-BdXsYB4U.js} +1 -1
- package/dist/client/assets/{ChevronRight-BvDz0sNw.js → ChevronRight-CjCVJLyu.js} +1 -1
- package/dist/client/assets/{Clock-CUBQd8Xv.js → Clock-COZirC3k.js} +1 -1
- package/dist/client/assets/{Code01-CfHDXm0H.js → Code01-CVjIFtwF.js} +1 -1
- package/dist/client/assets/{Container-JazsSIaU.js → Container-B7A8_KBN.js} +1 -1
- package/dist/client/assets/{Copy01-Bc3vF4AL.js → Copy01-C93l6BzU.js} +1 -1
- package/dist/client/assets/{Dataflow03-w5UTvR4Y.js → Dataflow03-DNjhW7pv.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-CBTiljAf.js → DotsHorizontal-DcWcXgQH.js} +1 -1
- package/dist/client/assets/{DotsVertical-CaacL-UQ.js → DotsVertical-BapfFqW7.js} +1 -1
- package/dist/client/assets/{Download01-DFr08rCI.js → Download01-BRstR0UY.js} +1 -1
- package/dist/client/assets/{Edit01-VBYk6Owq.js → Edit01-DtYfEnGF.js} +1 -1
- package/dist/client/assets/{Edit05-BU6KlPcQ.js → Edit05-DQ2CQYfv.js} +1 -1
- package/dist/client/assets/{Eye-ARGTvinm.js → Eye-XXQM_dJM.js} +1 -1
- package/dist/client/assets/{File02-97eXNMek.js → File02-DGAZy0Mt.js} +1 -1
- package/dist/client/assets/{File06-Bg0UrqAj.js → File06-ZUl6cIYH.js} +1 -1
- package/dist/client/assets/{FilterLines-DGpMRkwN.js → FilterLines-CvLBb8Sk.js} +1 -1
- package/dist/client/assets/{Globe01-Dp1bsNvD.js → Globe01-ChS8SOsa.js} +1 -1
- package/dist/client/assets/{Globe02-CVZ2J37_.js → Globe02-B46wV9TK.js} +1 -1
- package/dist/client/assets/{Grid01-Bh1lnye-.js → Grid01-Dy_WT2Qh.js} +1 -1
- package/dist/client/assets/{Hash02-CPcpM8m3.js → Hash02-9vu51rHE.js} +1 -1
- package/dist/client/assets/{Home02-BiL0_a3T.js → Home02-ChIcWqLn.js} +1 -1
- package/dist/client/assets/{Image01-MBqu9WJ7.js → Image01-Cxkf0b_u.js} +1 -1
- package/dist/client/assets/{Inbox01-aA-lE1QX.js → Inbox01-LNemh7Cb.js} +1 -1
- package/dist/client/assets/{InfoCircle-t3NR9Grk.js → InfoCircle-NXgRDQJn.js} +1 -1
- package/dist/client/assets/{Key01-E1ZnfF0D.js → Key01-CcNMAY7j.js} +1 -1
- package/dist/client/assets/{LayersTwo01-DCvFdGJI.js → LayersTwo01-DTOMxetS.js} +1 -1
- package/dist/client/assets/{LayoutLeft-CrTAatnF.js → LayoutLeft-ZroHzCuC.js} +1 -1
- package/dist/client/assets/{Link01-5WPeXJ1q.js → Link01-QiWlAOzA.js} +1 -1
- package/dist/client/assets/{LinkExternal01-DFH78r9f.js → LinkExternal01-BC7WVZcF.js} +1 -1
- package/dist/client/assets/{List-BxL8IDCE.js → List-BqunIiY3.js} +1 -1
- package/dist/client/assets/{Loading01-C5CNb3s-.js → Loading01-BOkSHCoD.js} +1 -1
- package/dist/client/assets/{Lock01-BOeViK9Y.js → Lock01-CcU76TTW.js} +1 -1
- package/dist/client/assets/{Play-CHeJR5MN.js → Play-BpaHzpsT.js} +1 -1
- package/dist/client/assets/{Plus-DwHqymxX.js → Plus-DWI787eW.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-DOnZ44OA.js → RefreshCcw01-DbmuSXo7.js} +1 -1
- package/dist/client/assets/{Save01-C1WnpZn8.js → Save01-CbAM3mcV.js} +1 -1
- package/dist/client/assets/{SearchMd-BrEq0pjT.js → SearchMd-T3ZkKjBg.js} +1 -1
- package/dist/client/assets/{Settings01-CPifi92B.js → Settings01-Cskvtoii.js} +1 -1
- package/dist/client/assets/{Shield01-CdtmebB7.js → Shield01-CCfMbSVC.js} +1 -1
- package/dist/client/assets/{Terminal-CClhWVt_.js → Terminal-v8W36mE5.js} +1 -1
- package/dist/client/assets/{Trash01-CNXXoz2j.js → Trash01-DxnA9tHI.js} +1 -1
- package/dist/client/assets/{Upload01-72wJg_54.js → Upload01-CpKFEXy9.js} +1 -1
- package/dist/client/assets/{Users03-Dm2iXTgw.js → Users03-tzmbE9Pg.js} +1 -1
- package/dist/client/assets/{X-yceQDp_o.js → X-BArwBghE.js} +1 -1
- package/dist/client/assets/{XCircle-Buzxifsr.js → XCircle-Dkc-xx3W.js} +1 -1
- package/dist/client/assets/{XClose-CWdR8ztK.js → XClose-BjV3U8XP.js} +1 -1
- package/dist/client/assets/{Zap-CRbJSOoN.js → Zap-C73llusZ.js} +1 -1
- package/dist/client/assets/{agent-connections-preview-DO4lQag9.js → agent-connections-preview-DTKsSGmf.js} +1 -1
- package/dist/client/assets/{agent-detail-CH7DXB6D.js → agent-detail-BhPTpKUh.js} +1 -1
- package/dist/client/assets/{agents-s8vQsuhF.js → agents-CiG_nRlZ.js} +1 -1
- package/dist/client/assets/{alert-dialog-4uvZEEFx.js → alert-dialog-7V4QlHda.js} +1 -1
- package/dist/client/assets/{auth-catchall-xOcyXhZ4.js → auth-catchall-DMhZzhJs.js} +1 -1
- package/dist/client/assets/{avatar-D_GwJ74E.js → avatar-BPQHNNVd.js} +1 -1
- package/dist/client/assets/{badge-DHsu3lW8.js → badge-ByQM1I_k.js} +1 -1
- package/dist/client/assets/{binder-GLGY8d7n.js → binder-CqdQY-AC.js} +1 -1
- package/dist/client/assets/{breadcrumb-Bq33GatY.js → breadcrumb-B9R2yHN7.js} +1 -1
- package/dist/client/assets/{card-BnXBsAYW.js → card-Bd8o2mZU.js} +1 -1
- package/dist/client/assets/{chart-Jwerghze.js → chart-B4riceQG.js} +1 -1
- package/dist/client/assets/{checkbox-DqLJvt0U.js → checkbox-DzcDV29j.js} +1 -1
- package/dist/client/assets/{circle-alert-DGTzPFBs.js → circle-alert-KPlpJuIo.js} +1 -1
- package/dist/client/assets/{collapsible-DTMpeVSV.js → collapsible-CTRxHU-e.js} +1 -1
- package/dist/client/assets/{collection-detail-CzYeKxf3.js → collection-detail-BUKFY8d9.js} +1 -1
- package/dist/client/assets/{collection-display-button-Coo-60zD.js → collection-display-button-DdwCFrup.js} +1 -1
- package/dist/client/assets/{collection-search-Dpb-MiLc.js → collection-search-CFK3Fogs.js} +1 -1
- package/dist/client/assets/{collection-tab-BrrpLl8S.js → collection-tab-GUD2ha8P.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-ukh1uFNi.js → collection-table-wrapper-uT05JOZp.js} +1 -1
- package/dist/client/assets/{collection-tabs-DRt3OoJI.js → collection-tabs-BjVD8BxE.js} +1 -1
- package/dist/client/assets/{command-BesVTSVA.js → command-DE4r9Umm.js} +1 -1
- package/dist/client/assets/{connect-BKj-3sVK.js → connect-DRIoTcp6.js} +1 -1
- package/dist/client/assets/{connection-card-BnKKlp6v.js → connection-card-C3Hv7jlt.js} +1 -1
- package/dist/client/assets/{connection-detail-yqsLq0sT.js → connection-detail-DB61osV0.js} +1 -1
- package/dist/client/assets/{connection-status-CmcQdk2D.js → connection-status-C_6CvTRw.js} +1 -1
- package/dist/client/assets/{connections-D87n3ynC.js → connections-C1lTOZkS.js} +1 -1
- package/dist/client/assets/constants-DZ0W1PjZ.js +1 -0
- package/dist/client/assets/{constants-uA8MqaDa.js → constants-prM-CtJ8.js} +1 -1
- package/dist/client/assets/{context-3GupwOmI.js → context-DMJsn1tf.js} +1 -1
- package/dist/client/assets/{create-organization-dialog-DM74wNIS.js → create-organization-dialog-Dk7HFJ_J.js} +1 -1
- package/dist/client/assets/{create-project-dialog--yM2xUAQ.js → create-project-dialog-B_pzi30J.js} +1 -1
- package/dist/client/assets/{danger-CHR2g40b.js → danger-O0juajMd.js} +1 -1
- package/dist/client/assets/{danger-zone-JzMC3sNX.js → danger-zone-CRRZ_tGI.js} +1 -1
- package/dist/client/assets/{decopilot-events-DV5WFiTr.js → decopilot-events-BLIo-vWg.js} +1 -1
- package/dist/client/assets/{dependencies-B7PjY4lO.js → dependencies-re7FgNSi.js} +1 -1
- package/dist/client/assets/{dialog-Dd4Env_T.js → dialog-BfWWA8WQ.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CrI0GFHN.js → dropdown-menu-BDj6V-nl.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-DbO_KebA.js → dynamic-plugin-layout-aAsl_owd.js} +1 -1
- package/dist/client/assets/{editable-task-title-Bb5NITwW.js → editable-task-title-CTSOSdAR.js} +1 -1
- package/dist/client/assets/{empty-state-CoKcoPlD.js → empty-state-CV7c4nhi.js} +1 -1
- package/dist/client/assets/{env-vars-editor-Cixxle6O.js → env-vars-editor-B6pRK0dL.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BWxoMBxo.js → extract-connection-data-DuqlHFwj.js} +1 -1
- package/dist/client/assets/{file-browser-B-WuXqBw.js → file-browser-29eWgXLl.js} +2 -2
- package/dist/client/assets/{form-CDc5v7vG.js → form-CHkiLe_Z.js} +1 -1
- package/dist/client/assets/{general-BlwDs4Gt.js → general-D95UeTFU.js} +1 -1
- package/dist/client/assets/{grid-view-my6yFN0G.js → grid-view-Cbk_J7lt.js} +1 -1
- package/dist/client/assets/{home-K5xf3d4P.js → home-SGWWjI9I.js} +1 -1
- package/dist/client/assets/{icon-picker-C64qSQSj.js → icon-picker-1SKrkRaS.js} +1 -1
- package/dist/client/assets/{index-nULh3Jbz.js → index-B6Mek3OU.js} +1 -1
- package/dist/client/assets/{index-DFAo9rQe.js → index-BDLMC2Gq.js} +1 -1
- package/dist/client/assets/{index-B5eO4JcQ.js → index-BkOyze3c.js} +1 -1
- package/dist/client/assets/{index-C61JJs1z.js → index-BuTZf6fB.js} +1 -1
- package/dist/client/assets/{index-B-j6trDA.js → index-C8rduhby.js} +1 -1
- package/dist/client/assets/{index-BEjkeuVE.js → index-D4YI9CPG.js} +1 -1
- package/dist/client/assets/{index-B9IOD0c9.js → index-DD20aJ8l.js} +1 -1
- package/dist/client/assets/{index-oE_2MbI2.js → index-l0Z9QQ6e.js} +3 -3
- package/dist/client/assets/{index-DmMaJcHH.js → index-vBfiJY33.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-BzTvfVsR.js → infiniteQueryObserver-DB5UPUsf.js} +1 -1
- package/dist/client/assets/{input-BC5yyfKN.js → input-CFqhfskI.js} +1 -1
- package/dist/client/assets/{integration-icon-DDvj2Mai.js → integration-icon-CUBxa1qi.js} +1 -1
- package/dist/client/assets/{label-CkkXXU_K.js → label-D403RycM.js} +1 -1
- package/dist/client/assets/{layout-BfzXWUCI.js → layout-CNBSiHmb.js} +1 -1
- package/dist/client/assets/{layout-B2G37Dgf.js → layout-DBxY0QNK.js} +1 -1
- package/dist/client/assets/{localstorage-keys-CKFbpBwk.js → localstorage-keys-bNYGQiS5.js} +1 -1
- package/dist/client/assets/{login-tT7tXvKE.js → login-Coi9lgoQ.js} +1 -1
- package/dist/client/assets/{markdown-ITAfYNdc.js → markdown-BzMvr4SF.js} +1 -1
- package/dist/client/assets/{mcp-app-renderer-B-WbfS4U.js → mcp-app-renderer-Dcay8bVo.js} +1 -1
- package/dist/client/assets/{mcp-oauth-CwCWvJTQ.js → mcp-oauth-1kgZ5k8q.js} +1 -1
- package/dist/client/assets/{mcp-server-card-dIAgZU40.js → mcp-server-card-BEQnIYDh.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-C7Vgk4MY.js → mcp-server-detail-RzXDjU9o.js} +2 -2
- package/dist/client/assets/{members-zPa8JINJ.js → members-D7zMcU4E.js} +1 -1
- package/dist/client/assets/{monaco-editor-BrEmU23y.js → monaco-editor-BR1LL2MP.js} +1 -1
- package/dist/client/assets/{monitoring-CiWZlhCJ.js → monitoring-RaERPZK6.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-edit-_0jdq7SI.js → monitoring-dashboard-edit-BCnnPWe4.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-view-DCEVvjKH.js → monitoring-dashboard-view-DAixGt5w.js} +1 -1
- package/dist/client/assets/{oauth-callback-FZB9yYWI.js → oauth-callback-DO_exRda.js} +1 -1
- package/dist/client/assets/{page-BAqkkkwD.js → page-Brz7RgZ3.js} +1 -1
- package/dist/client/assets/{page-DcVGgmuB.js → page-CXE16SzH.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-C3GV-xRm.js → plugin-empty-state-AEPw1tYq.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-C-6qQ0am.js → plugin-empty-state-BDd46h41.js} +1 -1
- package/dist/client/assets/{plugin-header-BMn4x0Pn.js → plugin-header-BPDMiwza.js} +1 -1
- package/dist/client/assets/{plugin-header-DUMlJQBX.js → plugin-header-DWJfGrKJ.js} +1 -1
- package/dist/client/assets/plugins-B92UXXEo.js +1 -0
- package/dist/client/assets/{popover-BkEpFI3f.js → popover-5tb_mjaq.js} +1 -1
- package/dist/client/assets/{project-app-view-D5NeW_KH.js → project-app-view-B7FzwWSb.js} +1 -1
- package/dist/client/assets/{project-layout-C9WOcenb.js → project-layout-DadU_A1s.js} +1 -1
- package/dist/client/assets/{project-plugins-CkJMA4dq.js → project-plugins-BxmgDO5A.js} +1 -1
- package/dist/client/assets/{projects-list-4zFzlLnG.js → projects-list-B0Z1B99P.js} +1 -1
- package/dist/client/assets/{readme-viewer-CWxI7nWr.js → readme-viewer-BjK7Zl_V.js} +1 -1
- package/dist/client/assets/{registry-layout-3azcHDEv.js → registry-layout-cIqIHqTI.js} +1 -1
- package/dist/client/assets/{registry-utils-BcBIgH2H.js → registry-utils-DFl_j1fH.js} +1 -1
- package/dist/client/assets/{reports-layout-CzM7MLsX.js → reports-layout-CUt-wC2j.js} +1 -1
- package/dist/client/assets/{reset-password-CsoXzJu2.js → reset-password-CTPHxDlK.js} +1 -1
- package/dist/client/assets/{resizable-DGeYIRjm.js → resizable-C8k9dJps.js} +1 -1
- package/dist/client/assets/{save-actions-BaZKzrz2.js → save-actions-BAmMJ2U_.js} +1 -1
- package/dist/client/assets/{scroll-area-Dvwme8cu.js → scroll-area-B0P50W_M.js} +1 -1
- package/dist/client/assets/{select-CxPd29YM.js → select-xXRsppN_.js} +1 -1
- package/dist/client/assets/{shell-layout-C4ByfWdR.js → shell-layout-CZ3Eys93.js} +2 -2
- package/dist/client/assets/{sidebar-settings-D1p5Aa62.js → sidebar-settings-CPwlwUER.js} +1 -1
- package/dist/client/assets/{skeleton-C27NGY_0.js → skeleton-Dou8rvsk.js} +1 -1
- package/dist/client/assets/{spinner-D4_yC4Mh.js → spinner-Dq0PMuAh.js} +1 -1
- package/dist/client/assets/{store-invite-C-097A7Z.js → store-invite-Bhsm8YmJ.js} +1 -1
- package/dist/client/assets/{switch-CQwK32aq.js → switch-Dh35-fJK.js} +1 -1
- package/dist/client/assets/{table-BFE5Uyhx.js → table-BMlt2v6O.js} +1 -1
- package/dist/client/assets/{tabs-BTOAzRdU.js → tabs-DkMM996O.js} +1 -1
- package/dist/client/assets/tasks-BxM8TF66.js +1 -0
- package/dist/client/assets/{tasks-panel-BSvIT8kw.js → tasks-panel-enwGB9mv.js} +1 -1
- package/dist/client/assets/{textarea-SOC_QN3r.js → textarea-BLQwXJbX.js} +1 -1
- package/dist/client/assets/{time-range-picker-DC05lL00.js → time-range-picker-VshkDS4j.js} +1 -1
- package/dist/client/assets/{toggle-group-ecMgl5dA.js → toggle-group-DvPlD8p0.js} +1 -1
- package/dist/client/assets/{tools-list-DRbt-GQT.js → tools-list-Ca2Lv4ID.js} +1 -1
- package/dist/client/assets/{tooltip-CfJyDfiQ.js → tooltip-B6_Dcqz7.js} +1 -1
- package/dist/client/assets/{topbar-portal-BnVdcS39.js → topbar-portal-nlkx6nZp.js} +1 -1
- package/dist/client/assets/{types-CZfjx8QG.js → types-pZ6MwMQl.js} +1 -1
- package/dist/client/assets/{use-binding-CD2rnHew.js → use-binding-CMk2m6d4.js} +1 -1
- package/dist/client/assets/{use-collections-BV71cmYk.js → use-collections-B5TLVCRl.js} +1 -1
- package/dist/client/assets/{use-connection-7qXdMybp.js → use-connection-3RKKi-Jy.js} +1 -1
- package/dist/client/assets/{use-copy-Cc7XW2Hc.js → use-copy-CvNU8_nz.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-tSLE2nnw.js → use-create-virtual-mcp-nEnWv-M_.js} +1 -1
- package/dist/client/assets/{use-install-from-registry-CAJArK0w.js → use-install-from-registry-CIMUHM4u.js} +1 -1
- package/dist/client/assets/{use-list-state-BGESvuo1.js → use-list-state-E0SKFC-D.js} +1 -1
- package/dist/client/assets/{use-llm-B7UO9DI8.js → use-llm-tYQ6bCCy.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-CxYW06DO.js → use-mcp-prompts-B8GLraln.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-BBd1wh9l.js → use-mcp-tools-CymsUuup.js} +1 -1
- package/dist/client/assets/{use-members-B-ckCttR.js → use-members-NFrxl9N_.js} +1 -1
- package/dist/client/assets/{use-mobile-Bu4jzm8F.js → use-mobile-_ANkgP-S.js} +1 -1
- package/dist/client/assets/{use-preferences-wIlCfDgU.js → use-preferences-BELQ4MmA.js} +1 -1
- package/dist/client/assets/{use-project-B9A5SY4K.js → use-project-CGmrmmBP.js} +1 -1
- package/dist/client/assets/{use-settings-modal-DUOHGiXQ.js → use-settings-modal-BYJedI74.js} +1 -1
- package/dist/client/assets/{use-view-mode-DQb4yKWd.js → use-view-mode-CZbBCtDx.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-DTCdJgfP.js → use-virtual-mcp-B9ZCCb3v.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-BZilKoJW.js +1 -0
- package/dist/client/assets/{useMutation-DdGCKlze.js → useMutation-CoD4li_i.js} +1 -1
- package/dist/client/assets/useQuery-DUftGQJJ.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-CI0wg1_s.js +1 -0
- package/dist/client/assets/{user-B5rWHRLV.js → user-CMKLpVFu.js} +1 -1
- package/dist/client/assets/{workflow-BmXavpfY.js → workflow-DCmgX9Dh.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +288 -288
- package/dist/server/migrate.js +1 -1
- package/dist/server/server.js +268 -268
- package/package.json +1 -1
- package/dist/client/assets/constants-BhYNqKbk.js +0 -1
- package/dist/client/assets/plugins-BswQXAf_.js +0 -1
- package/dist/client/assets/tasks-C9pAXZkw.js +0 -1
- package/dist/client/assets/useInfiniteQuery-DORe7h7l.js +0 -1
- package/dist/client/assets/useQuery-B63y3s7J.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-3Im9HP3l.js +0 -1
package/dist/server/migrate.js
CHANGED
|
@@ -1963,7 +1963,7 @@ ${X.stack}`;return W}}catch{}if(typeof X.toString==="function")try{let W=X.toStr
|
|
|
1963
1963
|
};
|
|
1964
1964
|
`,F=await Ch({code:H,tools:K,timeoutMs:30000});if(F.error)return{content:[{type:"text",text:`Virtual tool error: ${F.error}`}],isError:!0};return{content:[{type:"text",text:JSON.stringify(F.returnValue??null)}]}}catch(Z){return{content:[{type:"text",text:`Virtual tool execution failed: ${Z instanceof Error?Z.message:String(Z)}`}],isError:!0}}}async listResources(){return{resources:(await this._cachedResources).data}}async readResource(Y){let X=await this._cachedResources,J=this._clients,G=X.mappings.get(Y.uri);if(!G)throw Error(`Resource not found: ${Y.uri}`);let W=J.get(G);if(!W)throw Error(`Connection not found for resource: ${Y.uri}`);return await W.readResource(Y)}async listPrompts(){return{prompts:(await this._cachedPrompts).data}}async getPrompt(Y){let X=await this._cachedPrompts,J=this._clients,G=X.mappings.get(Y.name);if(!G)throw Error(`Prompt not found: ${Y.name}`);let W=J.get(G);if(!W)throw Error(`Connection not found for prompt: ${Y.name}`);return await W.getPrompt(Y)}async callStreamableTool(Y,X){let J=await this._cachedTools,G=this._clients,W=J.mappings.get(Y);if(W){let K=G.get(W);if(K&&"callStreamableTool"in K)return K.callStreamableTool(Y,X)}let Q=await this.callTool({name:Y,arguments:X});return new Response(JSON.stringify(Q),{headers:{"Content-Type":"application/json"}})}async[Symbol.asyncDispose](){await P46(this._clients)}async close(){await P46(this._clients),await super.close()}getInstructions(){return this.options.virtualMcp.metadata?.instructions??void 0}}});var E46,bi4,T46,hi4,hh;var PR1=f(()=>{k0();z2();wR1();E46=D.object({query:D.string().min(1).describe("Search query to find tools by name or description"),limit:D.number().default(10).describe("Maximum number of results to return")}),bi4=D.toJSONSchema(E46),T46=D.object({tools:D.array(D.string()).min(1).describe("Array of tool names to get detailed schemas for")}),hi4=D.toJSONSchema(T46);hh=class hh extends AR{constructor(Y,X){super(Y,X)}getSearchTool(Y){return{name:"GATEWAY_SEARCH_TOOLS",description:`Search for available tools by name or description. Returns tool names and brief descriptions without full schemas. Use this to discover tools before calling GATEWAY_DESCRIBE_TOOLS for detailed schemas. Total tools: ${Y}.`,inputSchema:bi4,annotations:{title:"Search Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}}getDescribeTool(){return{name:"GATEWAY_DESCRIBE_TOOLS",description:"Get detailed schemas for specific tools. Call after GATEWAY_SEARCH_TOOLS to get full input/output schemas.",inputSchema:hi4,annotations:{title:"Describe Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}}async handleSearch(Y){let X=E46.safeParse(Y);if(!X.success)return kB({error:X.error.flatten()});let J=await this._cachedTools,G=Nz(J.data),W=W61(X.data.query,G,X.data.limit);return Ih({query:X.data.query,results:W.map((Q)=>({name:Q.name,description:Q.description,connection:Q._meta.connectionTitle})),totalAvailable:G.length})}async handleDescribe(Y){let X=T46.safeParse(Y);if(!X.success)return kB({error:X.error.flatten()});let J=await this._cachedTools,G=Nz(J.data),W=Z61(X.data.tools,G);return Ih({tools:W.tools,notFound:W.notFound})}async listTools(){let Y=await this._cachedTools,X=Nz(Y.data);return{tools:[this.getSearchTool(X.length),this.getDescribeTool()]}}async callTool(Y){if(Y.name==="GATEWAY_SEARCH_TOOLS")return this.handleSearch(Y.arguments??{});if(Y.name==="GATEWAY_DESCRIBE_TOOLS")return this.handleDescribe(Y.arguments??{});return{content:[{type:"text",text:`Unknown tool: ${Y.name}. Available: GATEWAY_SEARCH_TOOLS, GATEWAY_DESCRIBE_TOOLS`}],isError:!0}}async routeToolCall(Y){return AR.prototype.callTool.call(this,Y)}}});var R46,xi4,ER1;var C46=f(()=>{k0();z2();PR1();R46=D.object({code:D.string().min(1).describe("JavaScript code to execute. It runs as an async function body; you can use top-level `return` and `await`."),timeoutMs:D.number().default(3000).describe("Max execution time in milliseconds (default: 3000).")}),xi4=D.toJSONSchema(R46);ER1=class ER1 extends hh{constructor(Y,X){super(Y,X)}getRunCodeTool(){return{name:"GATEWAY_RUN_CODE",description:'Run JavaScript code in a sandbox. Code must be an ES module that `export default`s an async function that receives (tools) as its first parameter. Use GATEWAY_DESCRIBE_TOOLS to understand the input/output schemas for a tool before calling it. Use `await tools.toolName(args)` or `await tools["tool-name"](args)` to call tools.',inputSchema:xi4,annotations:{title:"Run Code",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}}}async handleRunCode(Y){let X=R46.safeParse(Y);if(!X.success)return kB({error:X.error.flatten()});let J=await this._cachedTools,W={tools:Nz(J.data),callTool:async(K,Z)=>{return this.routeToolCall({name:K,arguments:Z})}},Q=await Q61(X.data.code,W,X.data.timeoutMs);if(Q.error)return kB(Q);return Ih(Q)}async listTools(){return{tools:[...(await super.listTools()).tools,this.getRunCodeTool()]}}async callTool(Y){if(Y.name==="GATEWAY_RUN_CODE")return this.handleRunCode(Y.arguments??{});return super.callTool(Y)}}});function j46(Y){let X=Y.slice().sort().join(","),J=I46.get(X);if(!J){let G=D.object({name:(Y.length>0?D.enum(Y):D.string()).describe("The name of the tool to execute"),arguments:D.record(D.string(),D.unknown()).default({}).describe("Arguments to pass to the tool")});J={schema:G,jsonSchema:D.toJSONSchema(G)},I46.set(X,J)}return J}var I46,TR1;var _46=f(()=>{k0();z2();PR1();I46=new Map;TR1=class TR1 extends hh{constructor(Y,X){super(Y,X)}async getCallTool(){let Y=await this._cachedTools,J=Nz(Y.data).map((W)=>W.name),{jsonSchema:G}=j46(J);return{name:"GATEWAY_CALL_TOOL",description:"Execute a tool by name. Use GATEWAY_DESCRIBE_TOOLS first to understand the input schema.",inputSchema:G,annotations:{title:"Call Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}}}async handleCallTool(Y){let X=await this._cachedTools,J=Nz(X.data),G=J.map((F)=>F.name),{schema:W}=j46(G),Q=W.safeParse(Y);if(!Q.success)return kB({error:Q.error.flatten()});let{name:K,arguments:Z}=Q.data;if(!new Map(J.map((F)=>[F.name,F])).has(K))return{content:[{type:"text",text:`Tool not found: ${K}. Use GATEWAY_SEARCH_TOOLS to find available tools.`}],isError:!0};return this.routeToolCall({name:K,arguments:Z})}async listTools(){let Y=await super.listTools(),X=await this.getCallTool();return{tools:[...Y.tools,X]}}async callTool(Y){if(Y.name==="GATEWAY_CALL_TOOL")return this.handleCallTool(Y.arguments??{});return super.callTool(Y)}}});function gi4(Y,X){if(Y.connection_type!=="VIRTUAL")return!1;if(!X||JL(X))return!1;return Y.id===X}async function S46(Y,X,J=!1){let G=Y.id,W=await X.storage.virtualMcps.findById(G);if(!W)throw Error(`Virtual MCP not found: ${G}`);return ui4(W,X,"passthrough",J)}async function ui4(Y,X,J,G=!1){let Q=Y.connections.map((V)=>V.connection_id).map((V)=>X.storage.connections.findById(V)),K=Y.id?await X.storage.connections.findById(Y.id):null,Z=await Promise.all(Q),H=[];if(K?.tools){for(let V of K.tools)if(w46(V))H.push(V)}let $={connections:Z.filter((V)=>V!==null&&V.status==="active"&&!gi4(V,Y.id)),virtualMcp:Y,virtualTools:H.length>0?H:void 0,superUser:G};return J==="smart_tool_selection"?new TR1($,X):J==="code_execution"?new ER1($,X):new AR($,X)}var k46=f(()=>{iY();yB();C46();wR1();_46()});async function PR(Y,X,J=!1){if(Y.connection_type==="VIRTUAL")return S46(Y,X,J);return D46(Y,X,J)}var RR1=f(()=>{L46();k46()});var v46=f(()=>{iY();jX();RR1();NR1()});function mi4(Y,X,J){return async(G,W)=>{try{let Q=G.params.name,K=async()=>{let{tools:H}=await J();return H.find(($)=>$.name===Q)?._meta};return await new fh(Y.authInstance,Y.auth.user?.id??Y.auth.apiKey?.userId,Q,Y.boundAuth,Y.auth.user?.role,X,K).check(Q),await W()}catch(Q){return new Response(JSON.stringify({error:`Authorization failed: ${Q.message}`}),{status:403,headers:{"Content-Type":"application/json"}})}}}function MR1(Y,X,J,G,W){let Q=async(Z,H)=>{if(J.connection_type==="VIRTUAL"){let q=await Y.callTool({name:Z,arguments:H});return new Response(JSON.stringify(q),{headers:{"Content-Type":"application/json"}})}if(!J.connection_url)throw Error("Streamable tools require HTTP connection with URL");let F=J.connection_url,$={method:"tools/call",params:{name:Z,arguments:H}};if(!W.superUser){let B=await mi4(G,X,Y.listTools.bind(Y))($,async()=>{return new Response});if(!B.ok)return B}let V=G.connectionId&&G.connectionId!==X?G.connectionId:void 0;return q46({ctx:G,enabled:YH0().enabled,connectionId:X,connectionTitle:J.title,virtualMcpId:V})($,async()=>{let q=await kh(J,G,W.superUser),B=J.connection_headers;if(B&&"headers"in B)Object.assign(q,B.headers);let U=new URL(F);U.pathname=U.pathname.replace(/\/$/,"")+`/call-tool/${$.params.name}`;let O=JSON.parse(JSON.stringify($.params.arguments,(N,P)=>{if(P instanceof AbortSignal)return;if(typeof P==="function"||typeof P==="symbol")return;if(P===void 0)return;return P})),M=JSON.stringify(O);return await G.tracer.startActiveSpan("mcp.proxy.callStreamableTool",{attributes:{"connection.id":X,"tool.name":$.params.name,"request.id":G.metadata.requestId}},async(N)=>{let P=Date.now();try{let A=await fetch(U.toString(),{method:"POST",redirect:"manual",body:M,headers:{...q,"Content-Type":"application/json"}}),R=Date.now()-P;return G.meter.createHistogram("connection.proxy.streamable.duration").record(R,{"connection.id":X,"tool.name":$.params.name,status:A.ok?"success":"error"}),G.meter.createCounter("connection.proxy.streamable.requests").add(1,{"connection.id":X,"tool.name":$.params.name,status:A.ok?"success":"error"}),N.end(),A}catch(A){let R=A,T=Date.now()-P;throw console.error("[with-streaming-support] fetch error",{connectionId:X,toolName:$.params.name,error:R.message,errorStack:R.stack,duration:T}),G.meter.createHistogram("connection.proxy.streamable.duration").record(T,{"connection.id":X,"tool.name":$.params.name,status:"error"}),G.meter.createCounter("connection.proxy.streamable.errors").add(1,{"connection.id":X,"tool.name":$.params.name,error:R.message}),N.recordException(R),N.end(),A}})})},K=Object.assign(Object.create(Object.getPrototypeOf(Y)),Y);return K.callStreamableTool=Q,K}var y46=f(()=>{HR1();$R1();$L1();LR1()});var f46=f(()=>{y46()});var AR1=f(()=>{RR1();v46();f46()});function b46(Y,X,J){if(X.some((G)=>G!=="*"&&G.startsWith("SELF::"))&&Y.SELF===void 0)Y.SELF={value:`${J}_self`}}async function ci4(Y,X,J,G){for(let Q of X){if(Q==="*")continue;let[K]=e66(Q),Z=$61(K,Y);if(Z===void 0||Z===null)throw Error(`Scope references key "${K}" but it's not present in state`)}let W=Y46(Y,X);for(let Q of W){if(Q.endsWith("_self"))continue;let K=await G.storage.connections.findById(Q);if(!K||K.organization_id!==J)throw Error(`Referenced connection not found: ${Q}`);try{await G.access.check(Q)}catch(Z){throw Error(`Access denied to referenced connection: ${Q}. ${Z.message}`)}}}var li4,di4,CR1;var h46=f(()=>{QR1();AR1();KR1();k0();j6();J61();Oz();li4=D.object({id:D.string().describe("ID of the connection to update"),data:Q_.describe("Partial connection data to update")}),di4=D.object({item:YG.describe("The updated connection entity")});CR1=S0({name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update an existing MCP connection in the organization",annotations:{title:"Update Connection",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:li4,outputSchema:di4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to update connection");let{id:W,data:Q}=Y,K=await X.storage.connections.findById(W);if(!K||K.organization_id!==J.id)throw Error("Connection not found in organization");let Z=Q.connection_type??K.connection_type,H=Q.connection_url??K.connection_url;if(Z==="VIRTUAL"){let O=GL(H);if(!O)throw Error("VIRTUAL connection requires connection_url in format: virtual://$virtual_mcp_id");let M=await X.storage.virtualMcps.findById(O);if(!M)throw Error(`Virtual MCP not found: ${O}`);if(M.organization_id!==J.id)throw Error("Virtual MCP does not belong to the current organization");H=WL(O)}let F=Q.configuration_state??K.configuration_state??{},$=Q.configuration_scopes??K.configuration_scopes??[];if(Q.configuration_state!==void 0||Q.configuration_scopes!==void 0){if(Q.configuration_state!==void 0)F=Q.configuration_state??{};else if(F===null||F===void 0)F={};if(Q.configuration_scopes!==void 0)$=Q.configuration_scopes??[];if($.length>0){let O=F;b46(O,$,J.id),await ci4(O,$,J.id,X)}}let V=Q.connection_token??K.connection_token;if(!V)try{let M=await new Sh(X.db,X.vault).get(W);if(M?.accessToken)V=M.accessToken}catch{}let z=await qR({id:K.id,title:Q.title??K.title,connection_type:Z,connection_url:H,connection_token:V,connection_headers:Q.connection_headers??K.connection_headers}).catch(()=>null),q=z?.tools?.length?z.tools:null;if(Q.configuration_scopes===void 0&&z?.scopes?.length)$=z.scopes;b46(F,$,J.id);let B={...Q,connection_url:H,tools:q,configuration_state:F,configuration_scopes:$,updated_by:G},U=await X.storage.connections.update(W,B);if((Q.configuration_state!==void 0||Q.configuration_scopes!==void 0)&&F&&$)try{await(await PR(U,X,!1)).callTool({name:"ON_MCP_CONFIGURATION",arguments:{state:F,scopes:$}})}catch(O){console.error("Failed to invoke ON_MCP_CONFIGURATION callback",O)}return{item:U}}})});var pi4,IR1;var x46=f(()=>{qW();k0();j6();Oz();pi4=NS.extend({force:D.boolean().optional().describe("If true, removes this connection from all agents that reference it before deleting")}),IR1=S0({name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete a connection",annotations:{title:"Delete Connection",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:pi4,outputSchema:wS(YG),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.connections.findById(Y.id);if(!G)throw Error(`Connection not found: ${Y.id}`);if(G.organization_id!==J.id)throw Error("Connection not found in organization");if(G.metadata?.isFixed===!0)throw Error("This connection is a fixed system connection and cannot be deleted");let Q=await X.storage.virtualMcps.listByConnectionId(J.id,Y.id);if(Q.length>0)if(Y.force)await X.storage.virtualMcps.removeConnectionReferences(Y.id);else throw Error(JSON.stringify({code:"CONNECTION_IN_USE",agentNames:Q.map((K)=>K.title)}));return await X.storage.connections.delete(Y.id),{item:G}}})});var jR1;var g46=f(()=>{k0();j6();jR1=S0({name:"CONNECTION_TEST",description:"Test connection health and latency",annotations:{title:"Test Connection",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},inputSchema:D.object({id:D.string()}),outputSchema:D.object({id:D.string(),healthy:D.boolean(),latencyMs:D.number()}),handler:async(Y,X)=>{let J=J6(X);await X.access.check();let G=await X.storage.connections.findById(Y.id);if(!G||G.organization_id!==J.id)throw Error("Connection not found");let W=await X.storage.connections.testConnection(Y.id);return{id:Y.id,...W}}})});var u46=f(()=>{d66();s66();t66();h46();x46();g46()});function m46(Y){if(Y===null||Y===void 0)return"NULL";if(typeof Y==="number")return String(Y);if(typeof Y==="boolean")return Y?"TRUE":"FALSE";if(typeof Y==="string")return`'${Y.replace(/'/g,"''")}'`;if(Y instanceof Date)return`'${Y.toISOString()}'`;return`'${JSON.stringify(Y).replace(/'/g,"''")}'`}function ai4(Y,X){let J=Y;for(let W=X.length;W>=1;W--){let Q=`$${W}`;if(J.includes(Q))J=J.replaceAll(Q,m46(X[W-1]))}let G=[];for(let W=0;W<J.length;W++)if(J[W]==="?")G.push(W);for(let W=Math.min(G.length,X.length)-1;W>=0;W--){let Q=G[W],K=m46(X[W]);J=J.slice(0,Q)+K+J.slice(Q+1)}return J}function l46(Y){return Y.replace(/-/g,"_")}function oi4(Y){return`app_${l46(Y)}`}function si4(Y){return`app_role_${l46(Y)}`}function ti4(Y){if(Y instanceof Error){let X=Y.message.toLowerCase(),J=Y.code;return J==="3F000"||J==="42704"||J==="22023"||X.includes("schema")&&X.includes("does not exist")||X.includes("role")&&X.includes("does not exist")}return!1}async function ei4(Y,X,J){if(await O0`CREATE SCHEMA IF NOT EXISTS ${O0.id(X)}`.execute(Y),!(await O0`
|
|
1965
1965
|
SELECT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ${J}) as exists
|
|
1966
|
-
`.execute(Y)).rows[0]?.exists)await O0`CREATE ROLE ${O0.id(J)} NOLOGIN`.execute(Y);await O0`GRANT ${O0.id(J)} TO CURRENT_USER`.execute(Y),await O0`GRANT USAGE, CREATE ON SCHEMA ${O0.id(X)} TO ${O0.id(J)}`.execute(Y),await O0`GRANT ALL ON ALL TABLES IN SCHEMA ${O0.id(X)} TO ${O0.id(J)}`.execute(Y),await O0`GRANT ALL ON ALL SEQUENCES IN SCHEMA ${O0.id(X)} TO ${O0.id(J)}`.execute(Y),await O0`ALTER DEFAULT PRIVILEGES IN SCHEMA ${O0.id(X)} GRANT ALL ON TABLES TO ${O0.id(J)}`.execute(Y),await O0`ALTER DEFAULT PRIVILEGES IN SCHEMA ${O0.id(X)} GRANT ALL ON SEQUENCES TO ${O0.id(J)}`.execute(Y),await O0`REVOKE ALL ON SCHEMA public FROM ${O0.id(J)}`.execute(Y)}async function Ya4(Y,X,J,G){try{return await Y.transaction().execute(async(W)=>{return await O0`SET LOCAL ROLE ${O0.id(J)}`.execute(W),await O0`SET LOCAL search_path TO ${O0.id(X)}`.execute(W),await O0.raw(G).execute(W)})}catch(W){if(ti4(W))return await ei4(Y,X,J),await Y.transaction().execute(async(Q)=>{return await O0`SET LOCAL ROLE ${O0.id(J)}`.execute(Q),await O0`SET LOCAL search_path TO ${O0.id(X)}`.execute(Q),await O0.raw(G).execute(Q)});throw W}}var ii4,ri4,d46;var c46=f(()=>{i8();k0();j6();ii4=D.object({results:D.array(D.unknown()).optional(),success:D.boolean().optional()});ri4=D.object({sql:D.string().describe("The SQL query to run"),params:D.array(D.any()).describe("The parameters to pass to the SQL query").optional()});d46=S0({name:"DATABASES_RUN_SQL",description:"Run a SQL query against the database",annotations:{title:"Run SQL Query",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:ri4,outputSchema:D.object({result:D.array(ii4)}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=ai4(Y.sql,Y.params||[]);if(!X.connectionId)throw Error("Connection context required for database access");let G=oi4(X.connectionId),W=si4(X.connectionId);return{result:[{results:(await Ya4(X.db,G,W,J)).rows,success:!0}]}}})});var p46,Ja4,n46;var Mz=f(()=>{k0();Jn();p46=D.object({connectionId:D.string().optional().describe("Filter subscriptions by connection ID (optional)")}),Ja4=D.object({id:D.string().describe("Subscription ID"),connectionId:D.string().describe("Subscriber connection ID"),eventType:D.string().describe("Event type pattern"),publisher:D.string().nullable().describe("Publisher connection filter (null = all publishers)"),filter:D.string().nullable().describe("JSONPath filter expression"),enabled:D.boolean().describe("Whether subscription is enabled"),createdAt:D.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:D.string().datetime().describe("Updated timestamp (ISO 8601)")}),n46=D.object({subscriptions:D.array(Ja4).describe("List of subscriptions")})});var _R1;var i46=f(()=>{j6();Mz();_R1=S0({name:"EVENT_PUBLISH",description:"Publish an event to the event bus. Supports immediate, scheduled (deliverAt), and recurring (cron) delivery. The source is automatically set to the caller's connection ID.",annotations:{title:"Publish Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:MS,outputSchema:AS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to publish events. Use a connection-scoped token.");let W=await X.eventBus.publish(J.id,G,{type:Y.type,subject:Y.subject,data:Y.data,deliverAt:Y.deliverAt,cron:Y.cron});return{id:W.id,type:W.type,source:W.source,time:W.time}}})});var SR1;var a46=f(()=>{j6();Mz();SR1=S0({name:"EVENT_SUBSCRIBE",description:"Subscribe to events of a specific type. The subscriber is automatically set to the caller's connection.",annotations:{title:"Subscribe to Events",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:PS,outputSchema:ES,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to subscribe. Use a connection-scoped token.");let W=await X.eventBus.subscribe(J.id,{connectionId:G,eventType:Y.eventType,publisher:Y.publisher,filter:Y.filter});return{subscription:{id:W.id,connectionId:W.connectionId,eventType:W.eventType,publisher:W.publisher,filter:W.filter,enabled:W.enabled,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}}}})});var kR1;var r46=f(()=>{j6();Mz();kR1=S0({name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events by removing a subscription.",annotations:{title:"Unsubscribe from Events",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:CS,outputSchema:IS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to unsubscribe. Use a connection-scoped token.");let W=await X.eventBus.getSubscription(J.id,Y.subscriptionId);if(!W)throw Error(`Subscription not found: ${Y.subscriptionId}`);if(W.connectionId!==G)throw Error("Cannot unsubscribe from a subscription owned by another connection");return{success:(await X.eventBus.unsubscribe(J.id,Y.subscriptionId)).success,subscriptionId:Y.subscriptionId}}})});var vR1;var o46=f(()=>{j6();Mz();vR1=S0({name:"EVENT_CANCEL",description:"Cancel a recurring event to stop future deliveries. Only the publisher can cancel their own events.",annotations:{title:"Cancel Recurring Event",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:jS,outputSchema:_S,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to cancel events. Use a connection-scoped token.");if(!await X.eventBus.getEvent(J.id,Y.eventId))throw Error(`Event not found: ${Y.eventId}`);if(!(await X.eventBus.cancelEvent(J.id,Y.eventId,G)).success)throw Error("Failed to cancel event. Either the event is already completed/failed, or you are not the publisher.");return{success:!0,eventId:Y.eventId}}})});var yR1;var s46=f(()=>{j6();Mz();yR1=S0({name:"EVENT_ACK",description:"Acknowledge delivery of an event. Call after successfully processing an event received via ON_EVENTS with retryAfter.",annotations:{title:"Acknowledge Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:SS,outputSchema:kS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to acknowledge events. Use a connection-scoped token.");if(!(await X.eventBus.ackEvent(J.id,Y.eventId,G)).success)throw Error("Failed to acknowledge event. Either the event was not found, already delivered, or you are not a subscriber.");return{success:!0,eventId:Y.eventId}}})});var fR1;var t46=f(()=>{j6();Mz();fR1=S0({name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions, optionally filtered by connection ID.",annotations:{title:"List Event Subscriptions",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:p46,outputSchema:n46,handler:async(Y,X)=>{n0(X);let J=J6(X);return await X.access.check(),{subscriptions:(await X.eventBus.listSubscriptions(J.id,Y.connectionId)).map((W)=>({id:W.id,connectionId:W.connectionId,eventType:W.eventType,publisher:W.publisher,filter:W.filter,enabled:W.enabled,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}))}}})});var bR1;var e46=f(()=>{j6();Mz();bR1=S0({name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state. Creates new, deletes removed, updates changed filters. Subscriptions are identified by (eventType, publisher).",annotations:{title:"Sync Event Subscriptions",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:TS,outputSchema:RS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to sync subscriptions. Use a connection-scoped token.");let W=await X.eventBus.syncSubscriptions(J.id,{connectionId:G,subscriptions:Y.subscriptions});return{created:W.created,updated:W.updated,deleted:W.deleted,unchanged:W.unchanged,subscriptions:W.subscriptions.map((Q)=>({id:Q.id,connectionId:Q.connectionId,eventType:Q.eventType,publisher:Q.publisher,filter:Q.filter,enabled:Q.enabled,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}))}}})});var Y86=f(()=>{i46();a46();r46();o46();s46();t46();e46();Mz()});var ER=f(()=>{wc()});function X86(){return`/icons/capy-${Math.floor(Math.random()*39)+0}.png`}var Wa4,Za4,hR1;var J86=f(()=>{k0();j6();ER();Wa4=D.object({data:H_.describe("Data for the new virtual MCP")}),Za4=D.object({item:GZ.describe("The created virtual MCP entity")}),hR1=S0({name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create a new Virtual MCP",annotations:{title:"Create Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:Wa4,outputSchema:Za4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to create virtual MCP");let W={...Y.data,icon:Y.data.icon??X86()};return{item:await X.storage.virtualMcps.create(J.id,G,W)}}})});function Qa4(Y){let X=[],J=0;while(J<Y.length){let G=Y[J];if(G==="%")X.push(".*");else if(G==="_")X.push(".");else if(/[.*+?^${}()|[\]\\]/.test(G))X.push("\\"+G);else X.push(G);J++}return X.join("")}function fB(Y){return typeof Y==="string"||typeof Y==="number"}function xR1(Y,X){let J=X.split("."),G=Y;for(let W of J){if(G==null||typeof G!=="object")return;G=G[W]}return G}function Ka4(Y,X){return Y.connections.some((J)=>J.connection_id===X)}function L61(Y,X){if("conditions"in X){let{operator:Z,conditions:H}=X;switch(Z){case"and":return H.every((F)=>L61(Y,F));case"or":return H.some((F)=>L61(Y,F));case"not":return!H.every((F)=>L61(Y,F));default:return!0}}let{field:J,operator:G,value:W}=X,Q=J.join(".");if(Q==="connection_id"){if(G!=="eq"||typeof W!=="string")return!1;return Ka4(Y,W)}let K=xR1(Y,Q);switch(G){case"eq":return K===W;case"gt":return fB(K)&&fB(W)&&K>W;case"gte":return fB(K)&&fB(W)&&K>=W;case"lt":return fB(K)&&fB(W)&&K<W;case"lte":return fB(K)&&fB(W)&&K<=W;case"in":return Array.isArray(W)&&W.includes(K);case"like":if(typeof K!=="string"||typeof W!=="string")return!1;if(W.length>100)return!1;let Z=Qa4(W);return new RegExp(`^${Z}$`,"i").test(K);case"contains":if(typeof K!=="string"||typeof W!=="string")return!1;return K.toLowerCase().includes(W.toLowerCase());default:return!0}}function Ha4(Y,X){return[...Y].sort((J,G)=>{for(let W of X){let Q=W.field.join("."),K=xR1(J,Q),Z=xR1(G,Q),H=0;if(K==null&&Z==null)continue;if(K==null)H=W.nulls==="first"?-1:1;else if(Z==null)H=W.nulls==="first"?1:-1;else if(typeof K==="string"&&typeof Z==="string")H=K.localeCompare(Z);else if(typeof K==="number"&&typeof Z==="number")H=K-Z;else H=String(K).localeCompare(String(Z));if(H!==0)return W.direction==="desc"?-H:H}return 0})}var Fa4,$a4,gR1;var G86=f(()=>{qW();j6();ER();Fa4=XK,$a4=n$(GZ),gR1=S0({name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List all MCP virtual MCPs in the organization",annotations:{title:"List Virtual MCPs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Fa4,outputSchema:$a4,handler:async(Y,X)=>{await X.access.check();let J=J6(X),G=Y.where&&!("conditions"in Y.where)&&Y.where.field.join(".")==="connection_id"&&Y.where.operator==="eq"&&typeof Y.where.value==="string"?Y.where.value:void 0,Q=G?await X.storage.virtualMcps.listByConnectionId(J.id,G):await X.storage.virtualMcps.list(J.id);if(Y.where)Q=Q.filter((V)=>L61(V,Y.where));if(Y.orderBy&&Y.orderBy.length>0)Q=Ha4(Q,Y.orderBy);let K=Q.length,Z=Y.offset??0,H=Y.limit??100,F=Q.slice(Z,Z+H),$=Z+H<K;return{items:F,totalCount:K,hasMore:$}}})});var Va4,za4,uR1;var W86=f(()=>{k0();j6();ER();Va4=D.object({id:D.string().describe("ID of the virtual MCP to retrieve")}),za4=D.object({item:GZ.nullable().describe("The retrieved virtual MCP, or null if not found")}),uR1=S0({name:"COLLECTION_VIRTUAL_MCP_GET",description:"Get an MCP virtual MCP by ID",annotations:{title:"Get Virtual MCP",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Va4,outputSchema:za4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.id);if(G&&G.organization_id!==J.id)return{item:null};if(!G)return{item:null};return{item:G}}})});var qa4,Ua4,mR1;var Z86=f(()=>{k0();j6();ER();qa4=D.object({id:D.string().describe("ID of the virtual MCP to update"),data:F_.describe("Partial virtual MCP data to update")}),Ua4=D.object({item:GZ.describe("The updated virtual MCP entity")}),mR1=S0({name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update an MCP virtual MCP",annotations:{title:"Update Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:qa4,outputSchema:Ua4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to update virtual MCP");let W=await X.storage.virtualMcps.findById(Y.id);if(!W)throw Error(`Virtual MCP not found: ${Y.id}`);if(W.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.id}`);return{item:await X.storage.virtualMcps.update(Y.id,G,Y.data)}}})});var Ba4,Da4,lR1;var Q86=f(()=>{k0();j6();ER();Ba4=D.object({id:D.string().describe("ID of the virtual MCP to delete")}),Da4=D.object({item:GZ.describe("The deleted virtual MCP entity")}),lR1=S0({name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete an MCP virtual MCP",annotations:{title:"Delete Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Ba4,outputSchema:Da4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.id);if(!G)throw Error(`Virtual MCP not found: ${Y.id}`);if(G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.id}`);return await X.storage.virtualMcps.delete(Y.id),{item:G}}})});var K86=f(()=>{J86();G86();W86();Z86();Q86()});var Oa4,Na4,dR1;var H86=f(()=>{k0();j6();yB();Oa4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP to add the tool to"),data:O46.describe("Virtual tool data")}),Na4=D.object({item:aF.describe("The created virtual tool")}),dR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_CREATE",description:"Create a new virtual tool on a Virtual MCP. The tool code should be a JavaScript ES module that exports a default async function: export default async (tools, args) => { ... }. Specify connection_dependencies to indicate which connections this tool uses.",annotations:{title:"Create Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:Oa4,outputSchema:Na4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let W=Y.data.connection_dependencies??[];return{item:await X.storage.virtualMcps.createVirtualTool(Y.virtual_mcp_id,Y.data,W)}}})});var wa4,Ma4,cR1;var F86=f(()=>{k0();j6();yB();wa4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP to list tools for"),limit:D.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:D.number().int().min(0).optional().describe("Number of items to skip")}),Ma4=D.object({items:D.array(aF).describe("Array of virtual tools"),totalCount:D.number().int().min(0).optional().describe("Total number of virtual tools"),hasMore:D.boolean().optional().describe("Whether there are more items available")}),cR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List all virtual tools for a Virtual MCP",annotations:{title:"List Virtual Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:wa4,outputSchema:Ma4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)return{items:[],totalCount:0,hasMore:!1};let W=await X.storage.virtualMcps.listVirtualTools(Y.virtual_mcp_id),Q=W.length,K=Y.offset??0,Z=Y.limit??100,H=W.slice(K,K+Z),F=K+Z<Q;return{items:H,totalCount:Q,hasMore:F}}})});var Aa4,Pa4,pR1;var $86=f(()=>{k0();j6();yB();Aa4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP"),name:D.string().describe("Name of the virtual tool to retrieve")}),Pa4=D.object({item:aF.nullable().describe("The retrieved virtual tool, or null if not found")}),pR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"Get a virtual tool by name from a Virtual MCP",annotations:{title:"Get Virtual Tool",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Aa4,outputSchema:Pa4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)return{item:null};return{item:await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name)}}})});var Ea4,Ta4,nR1;var V86=f(()=>{k0();j6();yB();Ea4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP"),name:D.string().describe("Current name of the virtual tool to update"),data:N46.describe("Partial virtual tool data to update")}),Ta4=D.object({item:aF.describe("The updated virtual tool")}),nR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_UPDATE",description:"Update an existing virtual tool on a Virtual MCP. Specify connection_dependencies to update which connections this tool uses.",annotations:{title:"Update Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Ea4,outputSchema:Ta4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);if(!await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name))throw Error(`Virtual tool not found: ${Y.name}`);let Q=Y.data.connection_dependencies;return{item:await X.storage.virtualMcps.updateVirtualTool(Y.virtual_mcp_id,Y.name,Y.data,Q)}}})});var Ra4,Ca4,iR1;var z86=f(()=>{k0();j6();yB();Ra4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP"),name:D.string().describe("Name of the virtual tool to delete")}),Ca4=D.object({item:aF.describe("The deleted virtual tool")}),iR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete a virtual tool from a Virtual MCP",annotations:{title:"Delete Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Ra4,outputSchema:Ca4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let W=await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name);if(!W)throw Error(`Virtual tool not found: ${Y.name}`);return await X.storage.virtualMcps.deleteVirtualTool(Y.virtual_mcp_id,Y.name),{item:W}}})});var q86=f(()=>{H86();F86();$86();V86();z86()});var ja4,aR1;var U86=f(()=>{Kb();j6();k0();ja4=D.object({id:D.string().optional().describe("Unique log identifier"),organizationId:D.string().describe("Organization ID"),connectionId:D.string().describe("Connection ID"),connectionTitle:D.string().describe("Connection display name"),toolName:D.string().describe("Name of the tool that was called"),input:D.record(D.string(),D.unknown()).describe("Redacted tool input"),output:D.record(D.string(),D.unknown()).describe("Redacted tool output"),isError:D.boolean().describe("Whether the call resulted in an error"),errorMessage:D.string().nullish().describe("Error message if applicable"),durationMs:D.number().describe("Call duration in milliseconds"),timestamp:D.string().describe("ISO 8601 timestamp of the call"),userId:D.string().nullish().describe("User who triggered the call"),requestId:D.string().describe("Unique request identifier"),userAgent:D.string().nullish().describe("Client identifier (x-mesh-client header)"),virtualMcpId:D.string().nullish().describe("Virtual MCP (Agent) ID if routed through an agent"),properties:D.record(D.string(),D.string()).nullish().describe("Custom key-value metadata attached to the log")}),aR1=S0({name:"MONITORING_LOGS_LIST",description:"List monitoring logs for tool calls in the organization",annotations:{title:"List Monitoring Logs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({connectionId:D.string().optional().describe("Filter by connection ID"),excludeConnectionIds:D.array(D.string()).optional().describe("Exclude logs from these connection IDs (e.g. system connections)"),virtualMcpId:D.string().optional().describe("Filter by Virtual MCP (Agent) ID"),toolName:D.string().optional().describe("Filter by tool name"),isError:D.boolean().optional().describe("Filter by error status"),startDate:D.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:D.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)"),limit:D.number().default(20).describe("Maximum number of results"),offset:D.number().default(0).describe("Offset for pagination"),properties:D.record(D.string(),D.string()).optional().describe("Filter by exact property key=value matches"),propertyKeys:D.array(D.string()).optional().describe("Filter by logs that have these property keys"),propertyPatterns:D.record(D.string(),D.string()).optional().describe("Filter by property value patterns (SQL LIKE, use % as wildcard)"),propertyInValues:D.record(D.string(),D.string()).optional().describe("Filter by exact match within comma-separated values (e.g., user_tags in 'Engineering')")}),outputSchema:D.object({logs:D.array(ja4).describe("Array of monitoring logs"),total:D.number().describe("Total number of logs matching filters"),offset:D.number().describe("Current offset for pagination"),limit:D.number().describe("Current limit for pagination")}),handler:async(Y,X)=>{await G06();let J=J6(X),W=Y.properties||Y.propertyKeys||Y.propertyPatterns||Y.propertyInValues?{properties:Y.properties,propertyKeys:Y.propertyKeys,propertyPatterns:Y.propertyPatterns,propertyInValues:Y.propertyInValues}:void 0,Q={organizationId:J.id,connectionId:Y.connectionId,excludeConnectionIds:Y.excludeConnectionIds,virtualMcpId:Y.virtualMcpId,toolName:Y.toolName,isError:Y.isError,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0,limit:Y.limit,offset:Y.offset,propertyFilters:W},K=await X.storage.monitoring.query(Q);return{logs:K.logs.map((Z)=>({...Z,timestamp:Z.timestamp instanceof Date?Z.timestamp.toISOString():Z.timestamp})),total:K.total,offset:Y.offset,limit:Y.limit}}})});var rR1;var B86=f(()=>{j6();k0();rR1=S0({name:"MONITORING_STATS",description:"Get aggregated statistics for tool call monitoring",annotations:{title:"Get Monitoring Stats",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({startDate:D.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:D.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)")}),outputSchema:D.object({totalCalls:D.number().describe("Total number of tool calls"),errorRate:D.number().describe("Error rate as a decimal (0 to 1)"),avgDurationMs:D.number().describe("Average call duration in milliseconds"),errorRatePercent:D.string().describe("Error rate as a percentage string")}),handler:async(Y,X)=>{let G={organizationId:J6(X).id,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0},W=await X.storage.monitoring.getStats(G);return{...W,errorRatePercent:(W.errorRate*100).toFixed(2)}}})});var D86=f(()=>{U86();B86()});var Sa4,ka4,va4,oR1,ya4,fa4,xh,gh,bB,ba4,ha4,L86;var q2=f(()=>{k0();Sa4=D.enum(["sum","avg","min","max","count","count_all","last"]).describe("Aggregation function to apply"),ka4=D.enum(["metric","timeseries","table"]).describe("Widget display type"),va4=D.object({path:D.string().describe("JSONPath to extract value, e.g., '$.usage.total_tokens'"),from:D.enum(["input","output"]).describe("Extract from tool call input or output")}),oR1=D.enum(["connection_id","connection_title","user_id","tool_name","virtual_mcp_id"]).describe("Table column to group by (takes priority over JSONPath groupBy)"),ya4=D.object({fn:Sa4,groupBy:D.string().optional().describe("Optional JSONPath for grouping results"),groupByColumn:oR1.optional(),interval:D.string().optional().describe("For timeseries widgets: interval like '1h', '1d', '15m'")}),fa4=D.object({connectionIds:D.array(D.string()).optional().describe("Filter to specific connections"),toolNames:D.array(D.string()).optional().describe("Filter to specific tools")}),xh=D.object({id:D.string().describe("Unique widget identifier"),name:D.string().describe("Widget display name"),type:ka4,source:va4,aggregation:ya4,filter:fa4.optional()}),gh=D.object({connectionIds:D.array(D.string()).optional().describe("Filter to specific connections"),virtualMcpIds:D.array(D.string()).optional().describe("Filter to specific virtual MCPs/agents"),toolNames:D.array(D.string()).optional().describe("Filter to specific tools"),propertyFilters:D.record(D.string(),D.string()).optional().describe("Filter by exact metadata property key=value matches (e.g., { environment: 'production' })")}),bB=D.object({id:D.string().describe("Unique dashboard identifier"),organizationId:D.string().describe("Organization ID"),name:D.string().describe("Dashboard name"),description:D.string().nullable().describe("Dashboard description"),filters:gh.nullable().describe("Global filters applied to all widgets"),widgets:D.array(xh).describe("Widget definitions"),createdBy:D.string().describe("User ID who created the dashboard"),createdAt:D.string().describe("Creation timestamp"),updatedAt:D.string().describe("Last update timestamp")}),ba4=D.object({key:D.string().describe("Group key value"),value:D.number().describe("Aggregated value for this group")}),ha4=D.object({timestamp:D.string().describe("Time bucket timestamp"),value:D.number().describe("Aggregated value for this time bucket")}),L86=D.object({widgetId:D.string().describe("Widget ID this result is for"),value:D.number().nullable().describe("Aggregated value (for metric type)"),groups:D.array(ba4).optional().describe("Grouped results (when groupBy is specified)"),timeseries:D.array(ha4).optional().describe("Timeseries data (for timeseries type)")})});var sR1;var O86=f(()=>{j6();k0();q2();sR1=S0({name:"MONITORING_DASHBOARD_CREATE",description:"Create a new monitoring dashboard with JSONPath widgets",annotations:{title:"Create Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({name:D.string().min(1).describe("Dashboard name"),description:D.string().optional().describe("Dashboard description"),filters:gh.optional().describe("Global filters applied to all widgets"),widgets:D.array(xh).min(1).describe("Widget definitions (at least one required)")}),outputSchema:bB,handler:async(Y,X)=>{let J=J6(X),G=X.auth.user?.id;if(!G)throw Error("User authentication required");let W=await X.storage.monitoringDashboards.create(J.id,G,{name:Y.name,description:Y.description,filters:Y.filters,widgets:Y.widgets});return{id:W.id,organizationId:W.organizationId,name:W.name,description:W.description,filters:W.filters,widgets:W.widgets,createdBy:W.createdBy,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}}})});var tR1;var N86=f(()=>{j6();k0();q2();tR1=S0({name:"MONITORING_DASHBOARD_GET",description:"Get a monitoring dashboard by ID",annotations:{title:"Get Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string().describe("Dashboard ID")}),outputSchema:bB.nullable(),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.id);if(!G||G.organizationId!==J.id)return null;return{id:G.id,organizationId:G.organizationId,name:G.name,description:G.description,filters:G.filters,widgets:G.widgets,createdBy:G.createdBy,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}})});var eR1;var w86=f(()=>{j6();k0();q2();eR1=S0({name:"MONITORING_DASHBOARD_LIST",description:"List all monitoring dashboards for the organization",annotations:{title:"List Monitoring Dashboards",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({dashboards:D.array(bB).describe("List of dashboards"),total:D.number().describe("Total number of dashboards")}),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.list(J.id);return{dashboards:G.map((W)=>({id:W.id,organizationId:W.organizationId,name:W.name,description:W.description,filters:W.filters,widgets:W.widgets,createdBy:W.createdBy,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt})),total:G.length}}})});var YC1;var M86=f(()=>{j6();k0();q2();YC1=S0({name:"MONITORING_DASHBOARD_UPDATE",description:"Update an existing monitoring dashboard",annotations:{title:"Update Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string().describe("Dashboard ID to update"),name:D.string().optional().describe("New dashboard name"),description:D.string().nullable().optional().describe("New dashboard description"),filters:gh.nullable().optional().describe("New global filters"),widgets:D.array(xh).optional().describe("New widget definitions")}),outputSchema:bB,handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.id);if(!G||G.organizationId!==J.id)throw Error(`Dashboard ${Y.id} not found`);let W={};if(Y.name!==void 0)W.name=Y.name;if(Y.description!==void 0)W.description=Y.description;if(Y.filters!==void 0)W.filters=Y.filters;if(Y.widgets!==void 0)W.widgets=Y.widgets;let Q=await X.storage.monitoringDashboards.update(Y.id,W);return{id:Q.id,organizationId:Q.organizationId,name:Q.name,description:Q.description,filters:Q.filters,widgets:Q.widgets,createdBy:Q.createdBy,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}}})});var XC1;var A86=f(()=>{j6();k0();XC1=S0({name:"MONITORING_DASHBOARD_DELETE",description:"Delete a monitoring dashboard",annotations:{title:"Delete Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string().describe("Dashboard ID to delete")}),outputSchema:D.object({success:D.boolean().describe("Whether the deletion was successful")}),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.id);if(!G||G.organizationId!==J.id)throw Error(`Dashboard ${Y.id} not found`);return await X.storage.monitoringDashboards.delete(Y.id),{success:!0}}})});var JC1;var P86=f(()=>{j6();k0();q2();JC1=S0({name:"MONITORING_DASHBOARD_QUERY",description:"Execute a dashboard's widgets and return aggregated monitoring data",annotations:{title:"Query Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({dashboardId:D.string().describe("Dashboard ID to query"),timeRange:D.object({startDate:D.string().datetime().describe("Start of time range (ISO 8601)"),endDate:D.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:D.object({properties:D.record(D.string(),D.string()).optional().describe("Exact match: property key equals value"),propertyKeys:D.array(D.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:D.record(D.string(),D.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE, use % as wildcard)"),propertyInValues:D.record(D.string(),D.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Runtime property filters applied to all widgets (merged with dashboard-level filters)")}),outputSchema:D.object({dashboardId:D.string().describe("Dashboard ID"),results:D.array(L86).describe("Widget query results"),timeRange:D.object({startDate:D.string(),endDate:D.string()}).describe("Time range used for the query")}),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.dashboardId);if(!G||G.organizationId!==J.id)throw Error(`Dashboard ${Y.dashboardId} not found`);let W=new Date,Q=Y.timeRange?.startDate?new Date(Y.timeRange.startDate):new Date(W.getTime()-86400000),K=Y.timeRange?.endDate?new Date(Y.timeRange.endDate):W,Z=await Promise.all(G.widgets.map(async(H)=>{let F=G.filters?.propertyFilters,$=Y.propertyFilters,V=F||$?{properties:{...F,...$?.properties},propertyKeys:$?.propertyKeys,propertyPatterns:$?.propertyPatterns,propertyInValues:$?.propertyInValues}:void 0,z={connectionIds:H.filter?.connectionIds??G.filters?.connectionIds??void 0,virtualMcpIds:G.filters?.virtualMcpIds??void 0,toolNames:H.filter?.toolNames??G.filters?.toolNames??void 0,startDate:Q,endDate:K,propertyFilters:V};try{let q=await X.storage.monitoring.aggregate({organizationId:J.id,path:H.source.path,from:H.source.from,aggregation:H.aggregation.fn,groupBy:H.aggregation.groupBy,groupByColumn:H.aggregation.groupByColumn,interval:H.aggregation.interval,filters:z});return{widgetId:H.id,value:q.value,groups:q.groups,timeseries:q.timeseries}}catch(q){return console.error(`Widget ${H.id} aggregation failed:`,q),{widgetId:H.id,value:null,groups:void 0,timeseries:void 0}}}));return{dashboardId:Y.dashboardId,results:Z,timeRange:{startDate:Q.toISOString(),endDate:K.toISOString()}}}})});var xa4,GC1;var E86=f(()=>{j6();k0();q2();xa4=D.object({type:D.enum(["metric","timeseries","table"]),source:D.object({path:D.string().describe("JSONPath to extract value from"),from:D.enum(["input","output"]).describe("Extract from input or output")}),aggregation:D.object({fn:D.enum(["sum","avg","min","max","count","count_all","last"]).describe("Aggregation function"),groupBy:D.string().optional().describe("JSONPath for grouping (table)"),groupByColumn:oR1.optional(),interval:D.string().optional().describe("Time interval for timeseries (15m, 1h, 1d)"),limit:D.number().int().positive().optional().describe("Max number of groups to return (applies to groupBy/groupByColumn, ordered by value desc)")}),filter:D.object({connectionIds:D.array(D.string()).optional(),toolNames:D.array(D.string()).optional()}).optional()}),GC1=S0({name:"MONITORING_WIDGET_PREVIEW",description:"Preview a widget aggregation without saving. Used to test queries in the dashboard editor.",annotations:{title:"Preview Monitoring Widget",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({widget:xa4.describe("Widget configuration to preview"),timeRange:D.object({startDate:D.string().datetime().describe("Start of time range (ISO 8601)"),endDate:D.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:D.object({properties:D.record(D.string(),D.string()).optional().describe("Exact match: property key equals value"),propertyKeys:D.array(D.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:D.record(D.string(),D.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE)"),propertyInValues:D.record(D.string(),D.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Property filters to apply"),skipCount:D.boolean().optional().describe("Skip the countMatched query to reduce database load when the count is not needed")}),outputSchema:D.object({value:D.number().nullable().optional().describe("Aggregated value"),groups:D.array(D.object({key:D.string(),value:D.number()})).optional().describe("Grouped results for table widgets"),timeseries:D.array(D.object({timestamp:D.string(),value:D.number()})).optional().describe("Timeseries data points"),matchedRecords:D.number().optional().describe("Number of records that matched (omitted when skipCount is true)"),timeRange:D.object({startDate:D.string(),endDate:D.string()}).describe("Time range used for the query")}),handler:async(Y,X)=>{let J=J6(X),{widget:G,timeRange:W}=Y,Q=new Date,K=W?.startDate?new Date(W.startDate):new Date(Q.getTime()-86400000),Z=W?.endDate?new Date(W.endDate):Q,H={connectionIds:G.filter?.connectionIds,toolNames:G.filter?.toolNames,startDate:K,endDate:Z,propertyFilters:Y.propertyFilters};try{let F=Y.skipCount?void 0:await X.storage.monitoring.countMatched({organizationId:J.id,path:G.source.path,from:G.source.from,filters:H}),$=await X.storage.monitoring.aggregate({organizationId:J.id,path:G.source.path,from:G.source.from,aggregation:G.aggregation.fn,groupBy:G.aggregation.groupBy,groupByColumn:G.aggregation.groupByColumn,interval:G.aggregation.interval,limit:G.aggregation.limit,filters:H});return{value:$.value,groups:$.groups,timeseries:$.timeseries,matchedRecords:F,timeRange:{startDate:K.toISOString(),endDate:Z.toISOString()}}}catch(F){return console.error("Widget preview aggregation failed:",F),{value:null,matchedRecords:void 0,timeRange:{startDate:K.toISOString(),endDate:Z.toISOString()}}}}})});var T86=f(()=>{O86();N86();w86();M86();A86();P86();E86()});var WC1;var R86=f(()=>{k0();j6();WC1=S0({name:"ORGANIZATION_CREATE",description:"Create a new organization",annotations:{title:"Create Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({slug:D.string().min(1).max(50).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens"),name:D.string().min(1).max(255),description:D.string().optional()}),outputSchema:D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),members:D.array(D.any()).optional()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=XY(X);if(!J)throw Error("User ID required to create organization");let G=await X.boundAuth.organization.create({name:Y.name,slug:Y.slug,metadata:Y.description?{description:Y.description}:void 0,userId:J});if(!G)throw Error("Failed to create organization");return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var ZC1;var C86=f(()=>{k0();j6();ZC1=S0({name:"ORGANIZATION_LIST",description:"List all organizations user has access to",annotations:{title:"List Organizations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({userId:D.string().optional()}),outputSchema:D.object({organizations:D.array(D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=XY(X),G=Y.userId||J;if(!G)throw Error("User ID required to list organizations");return{organizations:(await X.boundAuth.organization.list(G)).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt}))}}})});var QC1;var I86=f(()=>{k0();j6();QC1=S0({name:"ORGANIZATION_GET",description:"Get organization details by slug or ID",annotations:{title:"Get Organization",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),members:D.array(D.any()).optional(),invitations:D.array(D.any()).optional()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=await X.boundAuth.organization.get();if(!J)throw Error("No active organization found");let G=new Date,W=J.invitations?.filter((Q)=>new Date(Q.expiresAt)>G);return{...J,invitations:W,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var KC1;var j86=f(()=>{k0();j6();KC1=S0({name:"ORGANIZATION_UPDATE",description:"Update an existing organization",annotations:{title:"Update Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string(),slug:D.string().min(1).max(50).regex(/^[a-z0-9-]+$/).optional(),name:D.string().min(1).max(255).optional(),description:D.string().optional()}),outputSchema:D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{n0(X),await X.access.check();let J={};if(Y.name)J.name=Y.name;if(Y.slug)J.slug=Y.slug;if(Y.description)J.metadata={description:Y.description};let G=await X.boundAuth.organization.update({organizationId:Y.id,data:J});if(!G)throw Error("Failed to update organization");return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var HC1;var _86=f(()=>{k0();j6();HC1=S0({name:"ORGANIZATION_DELETE",description:"Delete an organization",annotations:{title:"Delete Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string()}),outputSchema:D.object({success:D.boolean(),id:D.string()}),handler:async(Y,X)=>{return n0(X),await X.access.check(),await X.boundAuth.organization.delete(Y.id),{success:!0,id:Y.id}}})});var uh;var FC1=f(()=>{k0();uh=D.object({title:D.string(),url:D.string(),icon:D.string()})});var $C1;var S86=f(()=>{k0();j6();FC1();$C1=S0({name:"ORGANIZATION_SETTINGS_GET",description:"Get organization-level settings",annotations:{title:"Get Organization Settings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({organizationId:D.string(),sidebar_items:D.array(uh).nullable().optional(),enabled_plugins:D.array(D.string()).nullable().optional(),createdAt:D.string().datetime().optional().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().optional().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let G=await X.storage.organizationSettings.get(J);if(!G)return{organizationId:J};return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}})});var VC1;var k86=f(()=>{k0();j6();FC1();VC1=S0({name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization-level settings",annotations:{title:"Update Organization Settings",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string(),sidebar_items:D.array(uh).optional(),enabled_plugins:D.array(D.string()).optional()}),outputSchema:D.object({organizationId:D.string(),sidebar_items:D.array(uh).nullable().optional(),enabled_plugins:D.array(D.string()).nullable().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{if(n0(X),await X.access.check(),X.organization&&X.organization.id!==Y.organizationId)throw Error("Cannot update settings for a different organization");let J=await X.storage.organizationSettings.upsert(Y.organizationId,{sidebar_items:Y.sidebar_items,enabled_plugins:Y.enabled_plugins});return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var zC1;var v86=f(()=>{k0();j6();zC1=S0({name:"ORGANIZATION_MEMBER_ADD",description:"Add a member to an organization",annotations:{title:"Add Organization Member",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().optional(),userId:D.string(),role:D.array(D.string())}),outputSchema:D.object({id:D.string(),organizationId:D.string(),userId:D.string(),role:D.union([D.string(),D.array(D.string())]),createdAt:D.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=Y.organizationId||X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");if(J!==X.organization?.id)throw Error("Organization ID does not match authenticated organization");let G=await X.boundAuth.organization.addMember({organizationId:J,userId:Y.userId,role:Y.role});if(!G)throw Error("Failed to add member");return{...G,role:G.role,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var qC1;var y86=f(()=>{k0();j6();qC1=S0({name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove a member from an organization",annotations:{title:"Remove Organization Member",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().optional(),memberIdOrEmail:D.string()}),outputSchema:D.object({success:D.boolean(),memberIdOrEmail:D.string()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=Y.organizationId||X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");return await X.boundAuth.organization.removeMember({organizationId:J,memberIdOrEmail:Y.memberIdOrEmail}),{success:!0,memberIdOrEmail:Y.memberIdOrEmail}}})});var UC1;var f86=f(()=>{k0();j6();UC1=S0({name:"ORGANIZATION_MEMBER_LIST",description:"List all members in an organization",annotations:{title:"List Organization Members",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({limit:D.number().optional(),offset:D.number().optional()}),outputSchema:D.object({members:D.array(D.object({id:D.string(),organizationId:D.string(),userId:D.string(),role:D.string(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),user:D.object({id:D.string(),name:D.string(),email:D.string(),image:D.string().optional()}).optional()}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let G=await X.boundAuth.organization.listMembers({organizationId:J,limit:Y.limit,offset:Y.offset});return{members:(Array.isArray(G)?G:[]).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt}))}}})});var BC1;var b86=f(()=>{k0();j6();BC1=S0({name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update a member's role in an organization",annotations:{title:"Update Member Role",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().optional(),memberId:D.string(),role:D.array(D.string())}),outputSchema:D.object({id:D.string(),organizationId:D.string(),userId:D.string(),role:D.union([D.literal("admin"),D.literal("member"),D.literal("owner")]),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),user:D.object({email:D.string(),name:D.string(),image:D.string().optional()})}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=Y.organizationId||X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let G=await X.boundAuth.organization.updateMemberRole({organizationId:J,memberId:Y.memberId,role:Y.role});if(!G)throw Error("Failed to update member role");return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var h86=f(()=>{R86();C86();I86();j86();_86();S86();k86();v86();y86();f86();b86()});var ma4,O61,la4,Az,x86,N61;var hB=f(()=>{k0();ma4=D.object({banner:D.string().nullable(),bannerColor:D.string().nullable(),icon:D.string().nullable(),themeColor:D.string().nullable()}),O61=D.object({banner:D.string().nullable().optional(),bannerColor:D.string().nullable().optional(),icon:D.string().nullable().optional(),themeColor:D.string().nullable().optional()}),la4=D.object({id:D.string(),title:D.string(),icon:D.string().nullable()}),Az=D.object({id:D.string(),organizationId:D.string(),slug:D.string(),name:D.string(),description:D.string().nullable(),enabledPlugins:D.array(D.string()).nullable(),ui:ma4.nullable(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().describe("ISO 8601 timestamp")}),x86=Az.omit({organizationId:!0}).extend({boundConnections:D.array(la4)}),N61=D.object({id:D.string(),projectId:D.string(),pluginId:D.string(),connectionId:D.string().nullable(),settings:D.record(D.string(),D.unknown()).nullable(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().describe("ISO 8601 timestamp")})});var DC1;var g86=f(()=>{k0();j6();hB();DC1=S0({name:"PROJECT_LIST",description:"List all projects in an organization",annotations:{title:"List Projects",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().describe("Organization ID to list projects for")}),outputSchema:D.object({projects:D.array(x86)}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=await X.storage.projects.list(Y.organizationId),G=J.map((Q)=>Q.id),W=await X.storage.projectPluginConfigs.getBoundConnectionsForProjects(G);return{projects:J.map((Q)=>({id:Q.id,slug:Q.slug,name:Q.name,description:Q.description,enabledPlugins:Q.enabledPlugins,ui:Q.ui,boundConnections:W.get(Q.id)??[],createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}))}}})});var LC1;var u86=f(()=>{k0();j6();hB();LC1=S0({name:"PROJECT_GET",description:"Get a project by ID or slug",annotations:{title:"Get Project",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().describe("Organization ID"),projectId:D.string().optional().describe("Project ID (either this or slug required)"),slug:D.string().optional().describe("Project slug (either this or projectId required)")}).refine((Y)=>Y.projectId||Y.slug,{message:"Either projectId or slug must be provided"}),outputSchema:D.object({project:Az.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=null;if(Y.projectId)J=await X.storage.projects.get(Y.projectId);else if(Y.slug)J=await X.storage.projects.getBySlug(Y.organizationId,Y.slug);if(!J)return{project:null};return{project:{id:J.id,organizationId:J.organizationId,slug:J.slug,name:J.name,description:J.description,enabledPlugins:J.enabledPlugins,ui:J.ui,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}}})});var OC1;var m86=f(()=>{k0();iY();j6();hB();OC1=S0({name:"PROJECT_CREATE",description:"Create a new project in an organization",annotations:{title:"Create Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().describe("Organization ID"),slug:D.string().min(1).max(100).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens").describe("URL-friendly identifier"),name:D.string().min(1).max(200).describe("Display name"),description:D.string().max(1000).nullable().optional().describe("Project description"),enabledPlugins:D.array(D.string()).nullable().optional().describe("Plugin IDs to enable"),ui:O61.nullable().optional().describe("UI customization")}),outputSchema:D.object({project:Az}),handler:async(Y,X)=>{n0(X),await X.access.check();let{organizationId:J,slug:G,name:W,description:Q,enabledPlugins:K,ui:Z}=Y;if(G===C3)throw Error(`Slug "${C3}" is reserved`);if(await X.storage.projects.getBySlug(J,G))throw Error(`Project with slug "${G}" already exists in this organization`);let F=Z?{banner:Z.banner??null,bannerColor:Z.bannerColor??null,icon:Z.icon??null,themeColor:Z.themeColor??null}:null,$=await X.storage.projects.create({organizationId:J,slug:G,name:W,description:Q??null,enabledPlugins:K??null,ui:F});return{project:{id:$.id,organizationId:$.organizationId,slug:$.slug,name:$.name,description:$.description,enabledPlugins:$.enabledPlugins,ui:$.ui,createdAt:$.createdAt instanceof Date?$.createdAt.toISOString():$.createdAt,updatedAt:$.updatedAt instanceof Date?$.updatedAt.toISOString():$.updatedAt}}}})});var NC1;var l86=f(()=>{k0();j6();hB();NC1=S0({name:"PROJECT_UPDATE",description:"Update a project's details",annotations:{title:"Update Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID to update"),name:D.string().min(1).max(200).optional().describe("New display name"),description:D.string().max(1000).nullable().optional().describe("New description"),enabledPlugins:D.array(D.string()).nullable().optional().describe("Updated plugin IDs"),ui:O61.nullable().optional().describe("Updated UI customization")}),outputSchema:D.object({project:Az.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,name:G,description:W,enabledPlugins:Q,ui:K}=Y,Z={};if(G!==void 0)Z.name=G;if(W!==void 0)Z.description=W;if(Q!==void 0)Z.enabledPlugins=Q;if(K!==void 0)Z.ui=K?{banner:K.banner??null,bannerColor:K.bannerColor??null,icon:K.icon??null,themeColor:K.themeColor??null}:null;let H=await X.storage.projects.update(J,Z);if(!H)return{project:null};return{project:{id:H.id,organizationId:H.organizationId,slug:H.slug,name:H.name,description:H.description,enabledPlugins:H.enabledPlugins,ui:H.ui,createdAt:H.createdAt instanceof Date?H.createdAt.toISOString():H.createdAt,updatedAt:H.updatedAt instanceof Date?H.updatedAt.toISOString():H.updatedAt}}}})});var wC1;var d86=f(()=>{k0();iY();j6();wC1=S0({name:"PROJECT_DELETE",description:"Delete a project (cannot delete org-admin)",annotations:{title:"Delete Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID to delete")}),outputSchema:D.object({success:D.boolean(),message:D.string().optional()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J}=Y,G=await X.storage.projects.get(J);if(!G)return{success:!1,message:"Project not found"};if(G.slug===C3)return{success:!1,message:"Cannot delete the org-admin project"};return{success:await X.storage.projects.delete(J)}}})});var MC1;var c86=f(()=>{k0();j6();hB();MC1=S0({name:"PROJECT_PLUGIN_CONFIG_GET",description:"Get plugin configuration for a project",annotations:{title:"Get Project Plugin Config",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),pluginId:D.string().describe("Plugin ID")}),outputSchema:D.object({config:N61.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,pluginId:G}=Y,W=await X.storage.projectPluginConfigs.get(J,G);if(!W)return{config:null};return{config:{id:W.id,projectId:W.projectId,pluginId:W.pluginId,connectionId:W.connectionId,settings:W.settings,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}}}})});var AC1;var p86=f(()=>{k0();j6();hB();H61();AC1=S0({name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update or create plugin configuration for a project",annotations:{title:"Update Project Plugin Config",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),pluginId:D.string().describe("Plugin ID"),connectionId:D.string().nullable().optional().describe("MCP connection to bind"),settings:D.record(D.string(),D.unknown()).nullable().optional().describe("Plugin-specific settings")}),outputSchema:D.object({config:N61}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,pluginId:G,connectionId:W,settings:Q}=Y,K=XY(X),Z=await X.storage.projects.get(J);if(!Z)throw Error(`Project not found: ${J}`);let H=W?await X.storage.connections.findById(W):null;if(W&&Z.organizationId&&!H&&OR()){if(K61(W,Z.organizationId)){if(!K)throw Error("User ID required to create dev-assets connection");let $=NR(Z.organizationId,AK());await X.storage.connections.create({...$,organization_id:Z.organizationId,created_by:K})}}let F=await X.storage.projectPluginConfigs.upsert(J,G,{connectionId:W,settings:Q});return{config:{id:F.id,projectId:F.projectId,pluginId:F.pluginId,connectionId:F.connectionId,settings:F.settings,createdAt:F.createdAt instanceof Date?F.createdAt.toISOString():F.createdAt,updatedAt:F.updatedAt instanceof Date?F.updatedAt.toISOString():F.updatedAt}}}})});var da4,PC1;var n86=f(()=>{k0();j6();da4=D.object({id:D.string(),title:D.string(),icon:D.string().nullable(),connectionType:D.string(),status:D.string()}),PC1=S0({name:"PROJECT_CONNECTION_LIST",description:"List connections associated with a project",annotations:{title:"List Project Connections",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID")}),outputSchema:D.object({connections:D.array(da4)}),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let{projectId:G}=Y,W=await X.storage.projects.get(G);if(!W||W.organizationId!==J.id)throw Error(`Project not found: ${G}`);let Q=await X.storage.projectConnections.list(G);return{connections:(await Promise.all(Q.map((H)=>X.storage.connections.findById(H.connectionId)))).filter((H)=>H!=null).map((H)=>({id:H.id,title:H.title,icon:H.icon??null,connectionType:H.connection_type,status:H.status}))}}})});var EC1;var i86=f(()=>{k0();j6();EC1=S0({name:"PROJECT_CONNECTION_ADD",description:"Associate a connection with a project",annotations:{title:"Add Project Connection",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),connectionId:D.string().describe("Connection ID to associate")}),outputSchema:D.object({success:D.boolean(),projectConnectionId:D.string()}),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let{projectId:G,connectionId:W}=Y,Q=await X.storage.projects.get(G);if(!Q||Q.organizationId!==J.id)throw Error(`Project not found: ${G}`);let K=await X.storage.connections.findById(W);if(!K||K.organization_id!==J.id)throw Error(`Connection not found: ${W}`);return{success:!0,projectConnectionId:(await X.storage.projectConnections.add(G,W)).id}}})});var TC1;var a86=f(()=>{k0();j6();TC1=S0({name:"PROJECT_CONNECTION_REMOVE",description:"Remove a connection association from a project",annotations:{title:"Remove Project Connection",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),connectionId:D.string().describe("Connection ID to disassociate")}),outputSchema:D.object({success:D.boolean()}),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let{projectId:G,connectionId:W}=Y,Q=await X.storage.projects.get(G);if(!Q||Q.organizationId!==J.id)throw Error(`Project not found: ${G}`);let K=await X.storage.connections.findById(W);if(!K||K.organization_id!==J.id)throw Error(`Connection not found: ${W}`);let Z=await X.storage.projectConnections.remove(G,W);if(Q?.ui?.pinnedViews?.length){let H=Q.ui.pinnedViews.filter((F)=>F.connectionId!==W);if(H.length!==Q.ui.pinnedViews.length){let F={...Q.ui,pinnedViews:H.length>0?H:null};await X.storage.projects.update(G,{ui:F})}}return{success:Z}}})});var ca4,RC1;var r86=f(()=>{k0();j6();hB();ca4=D.object({connectionId:D.string(),toolName:D.string(),label:D.string(),icon:D.string().nullable()}),RC1=S0({name:"PROJECT_PINNED_VIEWS_UPDATE",description:"Update the pinned sidebar views for a project",annotations:{title:"Update Pinned Views",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),pinnedViews:D.array(ca4).describe("Pinned views to set for the project sidebar")}),outputSchema:D.object({project:Az.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,pinnedViews:G}=Y,W=await X.storage.projects.get(J);if(!W)throw Error(`Project not found: ${J}`);let K={...W.ui??{banner:null,bannerColor:null,icon:null,themeColor:null},pinnedViews:G.length>0?G:null},Z=await X.storage.projects.update(J,{ui:K});if(!Z)return{project:null};return{project:{id:Z.id,organizationId:Z.organizationId,slug:Z.slug,name:Z.name,description:Z.description,enabledPlugins:Z.enabledPlugins,ui:Z.ui,createdAt:Z.createdAt instanceof Date?Z.createdAt.toISOString():Z.createdAt,updatedAt:Z.updatedAt instanceof Date?Z.updatedAt.toISOString():Z.updatedAt}}}})});var o86=f(()=>{g86();u86();m86();l86();d86();c86();p86();n86();i86();a86();r86()});var CC1;var s86=f(()=>{k0();j6();CC1=S0({name:"TAGS_LIST",description:"List all tags in an organization",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({tags:D.array(D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X);return{tags:(await X.storage.tags.listOrgTags(J.id)).map((W)=>({...W,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():String(W.createdAt)}))}}})});var IC1;var t86=f(()=>{k0();j6();IC1=S0({name:"TAGS_CREATE",description:"Create a new tag in an organization",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({name:D.string().min(1).max(50).describe("Tag name")}),outputSchema:D.object({tag:D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")})}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X),G=await X.storage.tags.createTag(J.id,Y.name);return{tag:{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}}}})});var jC1;var e86=f(()=>{k0();j6();jC1=S0({name:"TAGS_DELETE",description:"Delete a tag from an organization (removes from all members)",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({tagId:D.string().describe("Tag ID to delete")}),outputSchema:D.object({success:D.boolean()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X),G=await X.storage.tags.getTag(Y.tagId);if(!G)throw Error("Tag not found");if(G.organizationId!==J.id)throw Error("Tag does not belong to this organization");return await X.storage.tags.deleteTag(Y.tagId),{success:!0}}})});var _C1;var Y96=f(()=>{k0();j6();_C1=S0({name:"MEMBER_TAGS_GET",description:"Get tags assigned to a member",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({memberId:D.string().describe("Member ID")}),outputSchema:D.object({tags:D.array(D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,J.id))throw Error(`Member not found in this organization: ${Y.memberId}`);return{tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}))}}})});var SC1;var X96=f(()=>{k0();j6();SC1=S0({name:"MEMBER_TAGS_SET",description:"Set tags for a member (replaces all existing tags)",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({memberId:D.string().describe("Member ID"),tagIds:D.array(D.string()).describe("Array of tag IDs to assign")}),outputSchema:D.object({success:D.boolean(),tags:D.array(D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,J.id))throw Error(`Member not found in this organization: ${Y.memberId}`);for(let Q of Y.tagIds){let K=await X.storage.tags.getTag(Q);if(!K)throw Error(`Tag not found: ${Q}`);if(K.organizationId!==J.id)throw Error(`Tag does not belong to this organization: ${Q}`)}return await X.storage.tags.setMemberTags(Y.memberId,Y.tagIds),{success:!0,tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}))}}})});var J96=f(()=>{s86();t86();e86();Y96();X96()});var G96=f(()=>{iY()});var W96,rF,Z96,Q96;var U2=f(()=>{k0();G96();W96=D.object({id:D.string().describe("Unique message ID"),thread_id:D.string().describe("ID of the parent thread"),metadata:D.unknown().optional().describe("Optional message metadata"),parts:D.array(D.record(D.string(),D.unknown())).describe("Message content parts (AI SDK UIMessagePart format)"),role:D.enum(["user","assistant","system"]).describe("Message role"),created_at:D.string().datetime().describe("Timestamp of creation"),updated_at:D.string().datetime().describe("Timestamp of last update")}),rF=D.object({id:D.string().describe("Unique thread ID"),organization_id:D.string().describe("Organization this thread belongs to"),title:D.string().describe("Thread title"),description:D.string().nullable().describe("Thread description"),created_at:D.string().datetime().describe("Timestamp of creation"),updated_at:D.string().datetime().describe("Timestamp of last update"),hidden:D.boolean().optional().describe("Whether the thread is hidden"),status:D.enum([...PM,"expired"]).describe("Thread execution status. 'expired' is virtual -- computed at read time for stale in_progress threads"),created_by:D.string().describe("User ID who created the thread"),updated_by:D.string().nullable().describe("User ID who last updated the thread")}),Z96=D.object({id:D.string().optional().describe("Optional custom ID for the thread"),title:D.string().describe("Thread title"),description:D.string().nullish().describe("Thread description")}),Q96=D.object({title:D.string().optional().describe("New thread title"),description:D.string().nullish().describe("New thread description"),hidden:D.boolean().optional().describe("Whether the thread is hidden")})});var ia4,aa4,kC1;var K96=f(()=>{k0();j6();U2();Eh();ia4=D.object({data:Z96.describe("Data for the new thread (id is auto-generated if not provided)")}),aa4=D.object({item:rF.describe("The created thread entity")}),kC1=S0({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread in the organization",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:ia4,outputSchema:aa4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to create thread");let W=Y.data.id??SB("thrd"),Q=await X.storage.threads.create({id:W,organization_id:J.id,title:Y.data.title,description:Y.data.description,created_by:G});return{item:{...Q,hidden:Q.hidden??!1}}}})});function xB(Y,X=Date.now()){let J=Y.status;if(J==="in_progress"){let G=new Date(Y.updated_at).getTime();if(!Number.isFinite(G)||X-G>1800000)J="expired"}return{...Y,status:J,hidden:Y.hidden??!1}}var ra4,oa4,vC1;var H96=f(()=>{qW();j6();U2();k0();ra4=XK.extend({where:D.object({created_by:D.string().optional()}).optional()}),oa4=n$(rF),vC1=S0({name:"COLLECTION_THREADS_LIST",description:"List all threads in the organization with filtering, sorting, and pagination",annotations:{title:"List Threads",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:ra4,outputSchema:oa4,handler:async(Y,X)=>{if(await X.access.check(),!X.auth.user?.id)throw Error("User ID required to list threads");let G=J6(X),W=Y.offset??0,Q=Y.limit??100,K=Y.where?.created_by,{threads:Z,total:H}=await X.storage.threads.list(G.id,K,{limit:Q,offset:W}),F=W+Q<H,$=Date.now();return{items:Z.map((V)=>xB(V,$)),totalCount:H,hasMore:F}}})});var sa4,yC1;var F96=f(()=>{qW();j6();U2();sa4=OS(rF),yC1=S0({name:"COLLECTION_THREADS_GET",description:"Get thread details by ID",annotations:{title:"Get Thread",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:LS,outputSchema:sa4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.threads.get(Y.id);if(!G||G.organization_id!==J.id)return{item:null};return{item:xB(G)}}})});var ta4,ea4,fC1;var $96=f(()=>{k0();j6();U2();ta4=D.object({id:D.string().describe("ID of the thread to update"),data:Q96.describe("Partial thread data to update")}),ea4=D.object({item:rF.describe("The updated thread entity")}),fC1=S0({name:"COLLECTION_THREADS_UPDATE",description:"Update an existing thread in the organization",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:ta4,outputSchema:ea4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to update thread");let{id:W,data:Q}=Y,K=await X.storage.threads.get(W);if(!K||K.organization_id!==J.id)throw Error("Thread not found in organization");let Z=await X.storage.threads.update(W,{title:Q.title,description:Q.description,hidden:Q.hidden,updated_by:G});return{item:xB(Z)}}})});var bC1;var V96=f(()=>{qW();j6();U2();bC1=S0({name:"COLLECTION_THREADS_DELETE",description:"Delete a thread",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:NS,outputSchema:wS(rF),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.threads.get(Y.id);if(!G)throw Error(`Thread not found: ${Y.id}`);if(G.organization_id!==J.id)throw Error(`Thread not found: ${Y.id}`);return await X.storage.threads.delete(Y.id),{item:xB(G)}}})});function z96(Y){if(!Y)return null;if("field"in Y&&Y.field[0]==="thread_id"&&Y.operator==="eq")return String(Y.value);if("conditions"in Y)for(let X of Y.conditions){let J=z96(X);if(J)return J}return null}var Yr4,hC1;var q96=f(()=>{qW();j6();U2();Yr4=n$(W96),hC1=S0({name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List all messages for a specific thread",annotations:{title:"List Thread Messages",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:XK,outputSchema:Yr4,handler:async(Y,X)=>{let J=J6(X);await X.access.check();let G=z96(Y.where);if(!G)throw Error("thread_id filter is required in where clause");let W=await X.storage.threads.get(G);if(!W||W.organization_id!==J.id)return{items:[],totalCount:0,hasMore:!1};let Q=Y.offset??0,K=Y.limit??100,{messages:Z,total:H}=await X.storage.threads.listMessages(G,{limit:K,offset:Q}),F=Q+K<H;return{items:Z,totalCount:H,hasMore:F}}})});var U96=f(()=>{K96();H96();F96();$96();V96();q96()});var Jr4,Gr4,xC1;var B96=f(()=>{k0();j6();Jr4=D.object({id:D.string().min(1)}),Gr4=D.object({user:D.object({id:D.string(),name:D.string(),email:D.string(),image:D.string().nullable()}).nullable()}),xC1=S0({name:"USER_GET",description:"Get a user by id (restricted to shared organizations)",annotations:{title:"Get User",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Jr4,outputSchema:Gr4,handler:async(Y,X)=>{await X.access.check(),n0(X);let J=XY(X);if(!J)throw Error("Authentication required");let G=await X.storage.users.findById(Y.id,J);if(!G)return{user:null};return{user:{id:G.id,name:G.name,email:G.email,image:G.image??null}}}})});var D96=f(()=>{B96()});var O96={};u6(O96,{managementMCP:()=>Kr4,ALL_TOOLS:()=>L96});var Zr4,Qr4,L96,Kr4=async(Y)=>{let X=null;if(Y.organization){let W=await Y.storage.organizationSettings.get(Y.organization.id),Q=await Y.storage.projects.list(Y.organization.id),K=new Set(W?.enabled_plugins??[]);for(let Z of Q)if(Z.enabledPlugins)for(let H of Z.enabledPlugins)K.add(H);X=K.size>0?[...K]:null}let J=FY0(L96,X),G=new EM({name:"mcp-mesh-management",version:"1.0.0"},{capabilities:{tools:{}}});for(let W of J){let Q=W.inputSchema&&typeof W.inputSchema==="object"&&"shape"in W.inputSchema?W.inputSchema:D.object({}),K=W.outputSchema&&typeof W.outputSchema==="object"&&"shape"in W.outputSchema?W.outputSchema:void 0,Z=Q.shape,H=K?.shape;G.registerTool(W.name,{description:W.description??"",inputSchema:Z,outputSchema:H,annotations:W.annotations,_meta:W._meta},async(F)=>{Y.access.setToolName(W.name);try{let $=await W.execute(F,Y);return{content:[{type:"text",text:JSON.stringify($)}],structuredContent:$}}catch($){return{content:[{type:"text",text:`Error: ${$.message}`}],isError:!0}}})}return G};var N96=f(()=>{Aa();Mc();k0();M66();l66();u46();c46();Y86();K86();q86();D86();T86();h86();o86();J96();U96();D96();Zr4=[WC1,ZC1,QC1,KC1,HC1,$C1,VC1,zC1,qC1,UC1,BC1,YR1,GR1,WR1,CR1,IR1,jR1,hR1,gR1,uR1,mR1,lR1,dR1,cR1,pR1,nR1,iR1,d46,aR1,rR1,sR1,tR1,eR1,YC1,XC1,JC1,GC1,nT1,aT1,rT1,iT1,_R1,SR1,kR1,vR1,yR1,fR1,bR1,xC1,sT1,tT1,eT1,kC1,vC1,yC1,fC1,bC1,hC1,CC1,IC1,jC1,_C1,SC1,DC1,LC1,OC1,NC1,wC1,MC1,AC1,PC1,EC1,TC1,RC1],Qr4=$Y0(),L96=[...Zr4,...Qr4]});function Hr4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (N96(),O96));return X.map((J)=>{return{name:J.name,inputSchema:D.toJSONSchema(J.inputSchema,{unrepresentable:"any"}),outputSchema:J.outputSchema?D.toJSONSchema(J.outputSchema,{unrepresentable:"any"}):void 0,description:J.description}})},data:XZ1(AK(),Y)},{data:YZ1()},{data:eW1(Y)}]}async function w96(Y,X){try{let J=$R(),G=new _T1(process.env.ENCRYPTION_KEY||""),W=new ST1(J.db,G),Q=new kT1(J.db),K=Hr4(Y);try{await Q.create({organizationId:Y,slug:C3,name:$w,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(K.map(async(Z)=>{let H=null;if(Z.permissions)H=(await TR.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await qR({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),$=await Z.getTools?.()??F?.tools??null,V=F?.scopes?.length?F.scopes:null,z=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await W.create({...Z.data,id:z,tools:$,configuration_scopes:V,organization_id:Y,created_by:X,connection_token:Z.data.connection_token??H})}))}catch(J){console.error("Error creating default MCP connections:",J)}}var M96=f(()=>{iY();e01();U06();B06();D06();J61();k0();V61()});var A96;var P96=f(()=>{A96=["owner","admin"]});var Fr4=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},E96=(Y)=>{if(Y.providerId==="microsoft")return Fr4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function $r4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Vr4(){let Y=Math.floor(Math.random()*R96.length),X=Math.floor(Math.random()*T96.length),J=R96[Y]??"deco",G=T96[X]??"studio";return`${J}-${G}`}function Mr4(){let Y=[mh],X=new URL(mh);if(X.hostname==="localhost")Y.push(mh.replace("localhost","127.0.0.1"));else if(X.hostname==="127.0.0.1")Y.push(mh.replace("127.0.0.1","localhost"));return Y}var T96,R96,zr4,qr4,w61,Ur4,Br4,Dr4,C96,dY,I96=void 0,gC1=void 0,Lr4=!1,Or4,Nr4,wr4,mh,TR;var V61=f(()=>{cX0();NQ0();XK0();pB1();iK0();aK0();$L1();XH0();e01();jT1();F06();M96();P96();T96=["labs","agent","studio","workspace","systems","core","cloud","works"],R96=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];zr4=Object.values(iq1()).map((Y)=>Y.map((X)=>X.name)).flat(),qr4={...so,self:["*",...zr4]},w61=OF(qr4),Ur4=w61.newRole({self:["*"],...Uy.statements}),Br4=w61.newRole({self:["*"],...Uy.statements}),Dr4=w61.newRole({self:["*"],...Uy.statements}),C96=Object.values(iq1()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),dY=qs.auth;if(dY.inviteEmailProviderId&&dY.emailProviders&&dY.emailProviders.length>0){let Y=Ah(dY.emailProviders,dY.inviteEmailProviderId);if(Y){let X=Mh(Y);I96=async(J)=>{let G=J.inviter.user?.name||J.inviter.user?.email,W=`${AK()}/auth/accept-invitation?invitationId=${J.invitation.id}&redirectTo=/`;await X({to:J.email,subject:`Invitation to join ${J.organization.name}`,html:`
|
|
1966
|
+
`.execute(Y)).rows[0]?.exists)await O0`CREATE ROLE ${O0.id(J)} NOLOGIN`.execute(Y);await O0`GRANT ${O0.id(J)} TO CURRENT_USER`.execute(Y),await O0`GRANT USAGE, CREATE ON SCHEMA ${O0.id(X)} TO ${O0.id(J)}`.execute(Y),await O0`GRANT ALL ON ALL TABLES IN SCHEMA ${O0.id(X)} TO ${O0.id(J)}`.execute(Y),await O0`GRANT ALL ON ALL SEQUENCES IN SCHEMA ${O0.id(X)} TO ${O0.id(J)}`.execute(Y),await O0`ALTER DEFAULT PRIVILEGES IN SCHEMA ${O0.id(X)} GRANT ALL ON TABLES TO ${O0.id(J)}`.execute(Y),await O0`ALTER DEFAULT PRIVILEGES IN SCHEMA ${O0.id(X)} GRANT ALL ON SEQUENCES TO ${O0.id(J)}`.execute(Y),await O0`REVOKE ALL ON SCHEMA public FROM ${O0.id(J)}`.execute(Y)}async function Ya4(Y,X,J,G){try{return await Y.transaction().execute(async(W)=>{return await O0`SET LOCAL ROLE ${O0.id(J)}`.execute(W),await O0`SET LOCAL search_path TO ${O0.id(X)}`.execute(W),await O0.raw(G).execute(W)})}catch(W){if(ti4(W))return await ei4(Y,X,J),await Y.transaction().execute(async(Q)=>{return await O0`SET LOCAL ROLE ${O0.id(J)}`.execute(Q),await O0`SET LOCAL search_path TO ${O0.id(X)}`.execute(Q),await O0.raw(G).execute(Q)});throw W}}var ii4,ri4,d46;var c46=f(()=>{i8();k0();j6();ii4=D.object({results:D.array(D.unknown()).optional(),success:D.boolean().optional()});ri4=D.object({sql:D.string().describe("The SQL query to run"),params:D.array(D.any()).describe("The parameters to pass to the SQL query").optional()});d46=S0({name:"DATABASES_RUN_SQL",description:"Run a SQL query against the database",annotations:{title:"Run SQL Query",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:ri4,outputSchema:D.object({result:D.array(ii4)}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=ai4(Y.sql,Y.params||[]);if(!X.connectionId)throw Error("Connection context required for database access");let G=oi4(X.connectionId),W=si4(X.connectionId);return{result:[{results:(await Ya4(X.db,G,W,J)).rows,success:!0}]}}})});var p46,Ja4,n46;var Mz=f(()=>{k0();Jn();p46=D.object({connectionId:D.string().optional().describe("Filter subscriptions by connection ID (optional)")}),Ja4=D.object({id:D.string().describe("Subscription ID"),connectionId:D.string().describe("Subscriber connection ID"),eventType:D.string().describe("Event type pattern"),publisher:D.string().nullable().describe("Publisher connection filter (null = all publishers)"),filter:D.string().nullable().describe("JSONPath filter expression"),enabled:D.boolean().describe("Whether subscription is enabled"),createdAt:D.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:D.string().datetime().describe("Updated timestamp (ISO 8601)")}),n46=D.object({subscriptions:D.array(Ja4).describe("List of subscriptions")})});var _R1;var i46=f(()=>{j6();Mz();_R1=S0({name:"EVENT_PUBLISH",description:"Publish an event to the event bus. Supports immediate, scheduled (deliverAt), and recurring (cron) delivery. The source is automatically set to the caller's connection ID.",annotations:{title:"Publish Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:MS,outputSchema:AS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to publish events. Use a connection-scoped token.");let W=await X.eventBus.publish(J.id,G,{type:Y.type,subject:Y.subject,data:Y.data,deliverAt:Y.deliverAt,cron:Y.cron});return{id:W.id,type:W.type,source:W.source,time:W.time}}})});var SR1;var a46=f(()=>{j6();Mz();SR1=S0({name:"EVENT_SUBSCRIBE",description:"Subscribe to events of a specific type. The subscriber is automatically set to the caller's connection.",annotations:{title:"Subscribe to Events",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:PS,outputSchema:ES,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to subscribe. Use a connection-scoped token.");let W=await X.eventBus.subscribe(J.id,{connectionId:G,eventType:Y.eventType,publisher:Y.publisher,filter:Y.filter});return{subscription:{id:W.id,connectionId:W.connectionId,eventType:W.eventType,publisher:W.publisher,filter:W.filter,enabled:W.enabled,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}}}})});var kR1;var r46=f(()=>{j6();Mz();kR1=S0({name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events by removing a subscription.",annotations:{title:"Unsubscribe from Events",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:CS,outputSchema:IS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to unsubscribe. Use a connection-scoped token.");let W=await X.eventBus.getSubscription(J.id,Y.subscriptionId);if(!W)throw Error(`Subscription not found: ${Y.subscriptionId}`);if(W.connectionId!==G)throw Error("Cannot unsubscribe from a subscription owned by another connection");return{success:(await X.eventBus.unsubscribe(J.id,Y.subscriptionId)).success,subscriptionId:Y.subscriptionId}}})});var vR1;var o46=f(()=>{j6();Mz();vR1=S0({name:"EVENT_CANCEL",description:"Cancel a recurring event to stop future deliveries. Only the publisher can cancel their own events.",annotations:{title:"Cancel Recurring Event",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:jS,outputSchema:_S,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to cancel events. Use a connection-scoped token.");if(!await X.eventBus.getEvent(J.id,Y.eventId))throw Error(`Event not found: ${Y.eventId}`);if(!(await X.eventBus.cancelEvent(J.id,Y.eventId,G)).success)throw Error("Failed to cancel event. Either the event is already completed/failed, or you are not the publisher.");return{success:!0,eventId:Y.eventId}}})});var yR1;var s46=f(()=>{j6();Mz();yR1=S0({name:"EVENT_ACK",description:"Acknowledge delivery of an event. Call after successfully processing an event received via ON_EVENTS with retryAfter.",annotations:{title:"Acknowledge Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:SS,outputSchema:kS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to acknowledge events. Use a connection-scoped token.");if(!(await X.eventBus.ackEvent(J.id,Y.eventId,G)).success)throw Error("Failed to acknowledge event. Either the event was not found, already delivered, or you are not a subscriber.");return{success:!0,eventId:Y.eventId}}})});var fR1;var t46=f(()=>{j6();Mz();fR1=S0({name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions, optionally filtered by connection ID.",annotations:{title:"List Event Subscriptions",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:p46,outputSchema:n46,handler:async(Y,X)=>{n0(X);let J=J6(X);return await X.access.check(),{subscriptions:(await X.eventBus.listSubscriptions(J.id,Y.connectionId)).map((W)=>({id:W.id,connectionId:W.connectionId,eventType:W.eventType,publisher:W.publisher,filter:W.filter,enabled:W.enabled,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}))}}})});var bR1;var e46=f(()=>{j6();Mz();bR1=S0({name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state. Creates new, deletes removed, updates changed filters. Subscriptions are identified by (eventType, publisher).",annotations:{title:"Sync Event Subscriptions",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:TS,outputSchema:RS,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=X.connectionId;if(!G)throw Error("Connection ID required to sync subscriptions. Use a connection-scoped token.");let W=await X.eventBus.syncSubscriptions(J.id,{connectionId:G,subscriptions:Y.subscriptions});return{created:W.created,updated:W.updated,deleted:W.deleted,unchanged:W.unchanged,subscriptions:W.subscriptions.map((Q)=>({id:Q.id,connectionId:Q.connectionId,eventType:Q.eventType,publisher:Q.publisher,filter:Q.filter,enabled:Q.enabled,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}))}}})});var Y86=f(()=>{i46();a46();r46();o46();s46();t46();e46();Mz()});var ER=f(()=>{wc()});function X86(){return`/icons/capy-${Math.floor(Math.random()*39)+0}.png`}var Wa4,Za4,hR1;var J86=f(()=>{k0();j6();ER();Wa4=D.object({data:H_.describe("Data for the new virtual MCP")}),Za4=D.object({item:GZ.describe("The created virtual MCP entity")}),hR1=S0({name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create a new Virtual MCP",annotations:{title:"Create Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:Wa4,outputSchema:Za4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to create virtual MCP");let W={...Y.data,icon:Y.data.icon??X86()};return{item:await X.storage.virtualMcps.create(J.id,G,W)}}})});function Qa4(Y){let X=[],J=0;while(J<Y.length){let G=Y[J];if(G==="%")X.push(".*");else if(G==="_")X.push(".");else if(/[.*+?^${}()|[\]\\]/.test(G))X.push("\\"+G);else X.push(G);J++}return X.join("")}function fB(Y){return typeof Y==="string"||typeof Y==="number"}function xR1(Y,X){let J=X.split("."),G=Y;for(let W of J){if(G==null||typeof G!=="object")return;G=G[W]}return G}function Ka4(Y,X){return Y.connections.some((J)=>J.connection_id===X)}function L61(Y,X){if("conditions"in X){let{operator:Z,conditions:H}=X;switch(Z){case"and":return H.every((F)=>L61(Y,F));case"or":return H.some((F)=>L61(Y,F));case"not":return!H.every((F)=>L61(Y,F));default:return!0}}let{field:J,operator:G,value:W}=X,Q=J.join(".");if(Q==="connection_id"){if(G!=="eq"||typeof W!=="string")return!1;return Ka4(Y,W)}let K=xR1(Y,Q);switch(G){case"eq":return K===W;case"gt":return fB(K)&&fB(W)&&K>W;case"gte":return fB(K)&&fB(W)&&K>=W;case"lt":return fB(K)&&fB(W)&&K<W;case"lte":return fB(K)&&fB(W)&&K<=W;case"in":return Array.isArray(W)&&W.includes(K);case"like":if(typeof K!=="string"||typeof W!=="string")return!1;if(W.length>100)return!1;let Z=Qa4(W);return new RegExp(`^${Z}$`,"i").test(K);case"contains":if(typeof K!=="string"||typeof W!=="string")return!1;return K.toLowerCase().includes(W.toLowerCase());default:return!0}}function Ha4(Y,X){return[...Y].sort((J,G)=>{for(let W of X){let Q=W.field.join("."),K=xR1(J,Q),Z=xR1(G,Q),H=0;if(K==null&&Z==null)continue;if(K==null)H=W.nulls==="first"?-1:1;else if(Z==null)H=W.nulls==="first"?1:-1;else if(typeof K==="string"&&typeof Z==="string")H=K.localeCompare(Z);else if(typeof K==="number"&&typeof Z==="number")H=K-Z;else H=String(K).localeCompare(String(Z));if(H!==0)return W.direction==="desc"?-H:H}return 0})}var Fa4,$a4,gR1;var G86=f(()=>{qW();j6();ER();Fa4=XK,$a4=n$(GZ),gR1=S0({name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List all MCP virtual MCPs in the organization",annotations:{title:"List Virtual MCPs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Fa4,outputSchema:$a4,handler:async(Y,X)=>{await X.access.check();let J=J6(X),G=Y.where&&!("conditions"in Y.where)&&Y.where.field.join(".")==="connection_id"&&Y.where.operator==="eq"&&typeof Y.where.value==="string"?Y.where.value:void 0,Q=G?await X.storage.virtualMcps.listByConnectionId(J.id,G):await X.storage.virtualMcps.list(J.id);if(Y.where)Q=Q.filter((V)=>L61(V,Y.where));if(Y.orderBy&&Y.orderBy.length>0)Q=Ha4(Q,Y.orderBy);let K=Q.length,Z=Y.offset??0,H=Y.limit??100,F=Q.slice(Z,Z+H),$=Z+H<K;return{items:F,totalCount:K,hasMore:$}}})});var Va4,za4,uR1;var W86=f(()=>{k0();j6();ER();Va4=D.object({id:D.string().describe("ID of the virtual MCP to retrieve")}),za4=D.object({item:GZ.nullable().describe("The retrieved virtual MCP, or null if not found")}),uR1=S0({name:"COLLECTION_VIRTUAL_MCP_GET",description:"Get an MCP virtual MCP by ID",annotations:{title:"Get Virtual MCP",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Va4,outputSchema:za4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.id);if(G&&G.organization_id!==J.id)return{item:null};if(!G)return{item:null};return{item:G}}})});var qa4,Ua4,mR1;var Z86=f(()=>{k0();j6();ER();qa4=D.object({id:D.string().describe("ID of the virtual MCP to update"),data:F_.describe("Partial virtual MCP data to update")}),Ua4=D.object({item:GZ.describe("The updated virtual MCP entity")}),mR1=S0({name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update an MCP virtual MCP",annotations:{title:"Update Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:qa4,outputSchema:Ua4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to update virtual MCP");let W=await X.storage.virtualMcps.findById(Y.id);if(!W)throw Error(`Virtual MCP not found: ${Y.id}`);if(W.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.id}`);return{item:await X.storage.virtualMcps.update(Y.id,G,Y.data)}}})});var Ba4,Da4,lR1;var Q86=f(()=>{k0();j6();ER();Ba4=D.object({id:D.string().describe("ID of the virtual MCP to delete")}),Da4=D.object({item:GZ.describe("The deleted virtual MCP entity")}),lR1=S0({name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete an MCP virtual MCP",annotations:{title:"Delete Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Ba4,outputSchema:Da4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.id);if(!G)throw Error(`Virtual MCP not found: ${Y.id}`);if(G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.id}`);return await X.storage.virtualMcps.delete(Y.id),{item:G}}})});var K86=f(()=>{J86();G86();W86();Z86();Q86()});var Oa4,Na4,dR1;var H86=f(()=>{k0();j6();yB();Oa4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP to add the tool to"),data:O46.describe("Virtual tool data")}),Na4=D.object({item:aF.describe("The created virtual tool")}),dR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_CREATE",description:"Create a new virtual tool on a Virtual MCP. The tool code should be a JavaScript ES module that exports a default async function: export default async (tools, args) => { ... }. Specify connection_dependencies to indicate which connections this tool uses.",annotations:{title:"Create Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:Oa4,outputSchema:Na4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let W=Y.data.connection_dependencies??[];return{item:await X.storage.virtualMcps.createVirtualTool(Y.virtual_mcp_id,Y.data,W)}}})});var wa4,Ma4,cR1;var F86=f(()=>{k0();j6();yB();wa4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP to list tools for"),limit:D.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:D.number().int().min(0).optional().describe("Number of items to skip")}),Ma4=D.object({items:D.array(aF).describe("Array of virtual tools"),totalCount:D.number().int().min(0).optional().describe("Total number of virtual tools"),hasMore:D.boolean().optional().describe("Whether there are more items available")}),cR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List all virtual tools for a Virtual MCP",annotations:{title:"List Virtual Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:wa4,outputSchema:Ma4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)return{items:[],totalCount:0,hasMore:!1};let W=await X.storage.virtualMcps.listVirtualTools(Y.virtual_mcp_id),Q=W.length,K=Y.offset??0,Z=Y.limit??100,H=W.slice(K,K+Z),F=K+Z<Q;return{items:H,totalCount:Q,hasMore:F}}})});var Aa4,Pa4,pR1;var $86=f(()=>{k0();j6();yB();Aa4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP"),name:D.string().describe("Name of the virtual tool to retrieve")}),Pa4=D.object({item:aF.nullable().describe("The retrieved virtual tool, or null if not found")}),pR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"Get a virtual tool by name from a Virtual MCP",annotations:{title:"Get Virtual Tool",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Aa4,outputSchema:Pa4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)return{item:null};return{item:await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name)}}})});var Ea4,Ta4,nR1;var V86=f(()=>{k0();j6();yB();Ea4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP"),name:D.string().describe("Current name of the virtual tool to update"),data:N46.describe("Partial virtual tool data to update")}),Ta4=D.object({item:aF.describe("The updated virtual tool")}),nR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_UPDATE",description:"Update an existing virtual tool on a Virtual MCP. Specify connection_dependencies to update which connections this tool uses.",annotations:{title:"Update Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Ea4,outputSchema:Ta4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);if(!await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name))throw Error(`Virtual tool not found: ${Y.name}`);let Q=Y.data.connection_dependencies;return{item:await X.storage.virtualMcps.updateVirtualTool(Y.virtual_mcp_id,Y.name,Y.data,Q)}}})});var Ra4,Ca4,iR1;var z86=f(()=>{k0();j6();yB();Ra4=D.object({virtual_mcp_id:D.string().describe("ID of the Virtual MCP"),name:D.string().describe("Name of the virtual tool to delete")}),Ca4=D.object({item:aF.describe("The deleted virtual tool")}),iR1=S0({name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete a virtual tool from a Virtual MCP",annotations:{title:"Delete Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Ra4,outputSchema:Ca4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!G||G.organization_id!==J.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let W=await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name);if(!W)throw Error(`Virtual tool not found: ${Y.name}`);return await X.storage.virtualMcps.deleteVirtualTool(Y.virtual_mcp_id,Y.name),{item:W}}})});var q86=f(()=>{H86();F86();$86();V86();z86()});var ja4,aR1;var U86=f(()=>{Kb();j6();k0();ja4=D.object({id:D.string().optional().describe("Unique log identifier"),organizationId:D.string().describe("Organization ID"),connectionId:D.string().describe("Connection ID"),connectionTitle:D.string().describe("Connection display name"),toolName:D.string().describe("Name of the tool that was called"),input:D.record(D.string(),D.unknown()).describe("Redacted tool input"),output:D.record(D.string(),D.unknown()).describe("Redacted tool output"),isError:D.boolean().describe("Whether the call resulted in an error"),errorMessage:D.string().nullish().describe("Error message if applicable"),durationMs:D.number().describe("Call duration in milliseconds"),timestamp:D.string().describe("ISO 8601 timestamp of the call"),userId:D.string().nullish().describe("User who triggered the call"),requestId:D.string().describe("Unique request identifier"),userAgent:D.string().nullish().describe("Client identifier (x-mesh-client header)"),virtualMcpId:D.string().nullish().describe("Virtual MCP (Agent) ID if routed through an agent"),properties:D.record(D.string(),D.string()).nullish().describe("Custom key-value metadata attached to the log")}),aR1=S0({name:"MONITORING_LOGS_LIST",description:"List monitoring logs for tool calls in the organization",annotations:{title:"List Monitoring Logs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({connectionId:D.string().optional().describe("Filter by connection ID"),excludeConnectionIds:D.array(D.string()).optional().describe("Exclude logs from these connection IDs (e.g. system connections)"),virtualMcpId:D.string().optional().describe("Filter by Virtual MCP (Agent) ID"),toolName:D.string().optional().describe("Filter by tool name"),isError:D.boolean().optional().describe("Filter by error status"),startDate:D.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:D.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)"),limit:D.number().default(20).describe("Maximum number of results"),offset:D.number().default(0).describe("Offset for pagination"),properties:D.record(D.string(),D.string()).optional().describe("Filter by exact property key=value matches"),propertyKeys:D.array(D.string()).optional().describe("Filter by logs that have these property keys"),propertyPatterns:D.record(D.string(),D.string()).optional().describe("Filter by property value patterns (SQL LIKE, use % as wildcard)"),propertyInValues:D.record(D.string(),D.string()).optional().describe("Filter by exact match within comma-separated values (e.g., user_tags in 'Engineering')")}),outputSchema:D.object({logs:D.array(ja4).describe("Array of monitoring logs"),total:D.number().describe("Total number of logs matching filters"),offset:D.number().describe("Current offset for pagination"),limit:D.number().describe("Current limit for pagination")}),handler:async(Y,X)=>{await G06();let J=J6(X),W=Y.properties||Y.propertyKeys||Y.propertyPatterns||Y.propertyInValues?{properties:Y.properties,propertyKeys:Y.propertyKeys,propertyPatterns:Y.propertyPatterns,propertyInValues:Y.propertyInValues}:void 0,Q={organizationId:J.id,connectionId:Y.connectionId,excludeConnectionIds:Y.excludeConnectionIds,virtualMcpId:Y.virtualMcpId,toolName:Y.toolName,isError:Y.isError,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0,limit:Y.limit,offset:Y.offset,propertyFilters:W},K=await X.storage.monitoring.query(Q);return{logs:K.logs.map((Z)=>({...Z,timestamp:Z.timestamp instanceof Date?Z.timestamp.toISOString():Z.timestamp})),total:K.total,offset:Y.offset,limit:Y.limit}}})});var rR1;var B86=f(()=>{j6();k0();rR1=S0({name:"MONITORING_STATS",description:"Get aggregated statistics for tool call monitoring",annotations:{title:"Get Monitoring Stats",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({startDate:D.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:D.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)")}),outputSchema:D.object({totalCalls:D.number().describe("Total number of tool calls"),errorRate:D.number().describe("Error rate as a decimal (0 to 1)"),avgDurationMs:D.number().describe("Average call duration in milliseconds"),errorRatePercent:D.string().describe("Error rate as a percentage string")}),handler:async(Y,X)=>{let G={organizationId:J6(X).id,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0},W=await X.storage.monitoring.getStats(G);return{...W,errorRatePercent:(W.errorRate*100).toFixed(2)}}})});var D86=f(()=>{U86();B86()});var Sa4,ka4,va4,oR1,ya4,fa4,xh,gh,bB,ba4,ha4,L86;var q2=f(()=>{k0();Sa4=D.enum(["sum","avg","min","max","count","count_all","last"]).describe("Aggregation function to apply"),ka4=D.enum(["metric","timeseries","table"]).describe("Widget display type"),va4=D.object({path:D.string().describe("JSONPath to extract value, e.g., '$.usage.total_tokens'"),from:D.enum(["input","output"]).describe("Extract from tool call input or output")}),oR1=D.enum(["connection_id","connection_title","user_id","tool_name","virtual_mcp_id"]).describe("Table column to group by (takes priority over JSONPath groupBy)"),ya4=D.object({fn:Sa4,groupBy:D.string().optional().describe("Optional JSONPath for grouping results"),groupByColumn:oR1.optional(),interval:D.string().optional().describe("For timeseries widgets: interval like '1h', '1d', '15m'")}),fa4=D.object({connectionIds:D.array(D.string()).optional().describe("Filter to specific connections"),toolNames:D.array(D.string()).optional().describe("Filter to specific tools")}),xh=D.object({id:D.string().describe("Unique widget identifier"),name:D.string().describe("Widget display name"),type:ka4,source:va4,aggregation:ya4,filter:fa4.optional()}),gh=D.object({connectionIds:D.array(D.string()).optional().describe("Filter to specific connections"),virtualMcpIds:D.array(D.string()).optional().describe("Filter to specific virtual MCPs/agents"),toolNames:D.array(D.string()).optional().describe("Filter to specific tools"),propertyFilters:D.record(D.string(),D.string()).optional().describe("Filter by exact metadata property key=value matches (e.g., { environment: 'production' })")}),bB=D.object({id:D.string().describe("Unique dashboard identifier"),organizationId:D.string().describe("Organization ID"),name:D.string().describe("Dashboard name"),description:D.string().nullable().describe("Dashboard description"),filters:gh.nullable().describe("Global filters applied to all widgets"),widgets:D.array(xh).describe("Widget definitions"),createdBy:D.string().describe("User ID who created the dashboard"),createdAt:D.string().describe("Creation timestamp"),updatedAt:D.string().describe("Last update timestamp")}),ba4=D.object({key:D.string().describe("Group key value"),value:D.number().describe("Aggregated value for this group")}),ha4=D.object({timestamp:D.string().describe("Time bucket timestamp"),value:D.number().describe("Aggregated value for this time bucket")}),L86=D.object({widgetId:D.string().describe("Widget ID this result is for"),value:D.number().nullable().describe("Aggregated value (for metric type)"),groups:D.array(ba4).optional().describe("Grouped results (when groupBy is specified)"),timeseries:D.array(ha4).optional().describe("Timeseries data (for timeseries type)")})});var sR1;var O86=f(()=>{j6();k0();q2();sR1=S0({name:"MONITORING_DASHBOARD_CREATE",description:"Create a new monitoring dashboard with JSONPath widgets",annotations:{title:"Create Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({name:D.string().min(1).describe("Dashboard name"),description:D.string().optional().describe("Dashboard description"),filters:gh.optional().describe("Global filters applied to all widgets"),widgets:D.array(xh).min(1).describe("Widget definitions (at least one required)")}),outputSchema:bB,handler:async(Y,X)=>{let J=J6(X),G=X.auth.user?.id;if(!G)throw Error("User authentication required");let W=await X.storage.monitoringDashboards.create(J.id,G,{name:Y.name,description:Y.description,filters:Y.filters,widgets:Y.widgets});return{id:W.id,organizationId:W.organizationId,name:W.name,description:W.description,filters:W.filters,widgets:W.widgets,createdBy:W.createdBy,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}}})});var tR1;var N86=f(()=>{j6();k0();q2();tR1=S0({name:"MONITORING_DASHBOARD_GET",description:"Get a monitoring dashboard by ID",annotations:{title:"Get Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string().describe("Dashboard ID")}),outputSchema:bB.nullable(),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.id);if(!G||G.organizationId!==J.id)return null;return{id:G.id,organizationId:G.organizationId,name:G.name,description:G.description,filters:G.filters,widgets:G.widgets,createdBy:G.createdBy,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}})});var eR1;var w86=f(()=>{j6();k0();q2();eR1=S0({name:"MONITORING_DASHBOARD_LIST",description:"List all monitoring dashboards for the organization",annotations:{title:"List Monitoring Dashboards",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({dashboards:D.array(bB).describe("List of dashboards"),total:D.number().describe("Total number of dashboards")}),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.list(J.id);return{dashboards:G.map((W)=>({id:W.id,organizationId:W.organizationId,name:W.name,description:W.description,filters:W.filters,widgets:W.widgets,createdBy:W.createdBy,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt})),total:G.length}}})});var YC1;var M86=f(()=>{j6();k0();q2();YC1=S0({name:"MONITORING_DASHBOARD_UPDATE",description:"Update an existing monitoring dashboard",annotations:{title:"Update Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string().describe("Dashboard ID to update"),name:D.string().optional().describe("New dashboard name"),description:D.string().nullable().optional().describe("New dashboard description"),filters:gh.nullable().optional().describe("New global filters"),widgets:D.array(xh).optional().describe("New widget definitions")}),outputSchema:bB,handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.id);if(!G||G.organizationId!==J.id)throw Error(`Dashboard ${Y.id} not found`);let W={};if(Y.name!==void 0)W.name=Y.name;if(Y.description!==void 0)W.description=Y.description;if(Y.filters!==void 0)W.filters=Y.filters;if(Y.widgets!==void 0)W.widgets=Y.widgets;let Q=await X.storage.monitoringDashboards.update(Y.id,W);return{id:Q.id,organizationId:Q.organizationId,name:Q.name,description:Q.description,filters:Q.filters,widgets:Q.widgets,createdBy:Q.createdBy,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}}})});var XC1;var A86=f(()=>{j6();k0();XC1=S0({name:"MONITORING_DASHBOARD_DELETE",description:"Delete a monitoring dashboard",annotations:{title:"Delete Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string().describe("Dashboard ID to delete")}),outputSchema:D.object({success:D.boolean().describe("Whether the deletion was successful")}),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.id);if(!G||G.organizationId!==J.id)throw Error(`Dashboard ${Y.id} not found`);return await X.storage.monitoringDashboards.delete(Y.id),{success:!0}}})});var JC1;var P86=f(()=>{j6();k0();q2();JC1=S0({name:"MONITORING_DASHBOARD_QUERY",description:"Execute a dashboard's widgets and return aggregated monitoring data",annotations:{title:"Query Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({dashboardId:D.string().describe("Dashboard ID to query"),timeRange:D.object({startDate:D.string().datetime().describe("Start of time range (ISO 8601)"),endDate:D.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:D.object({properties:D.record(D.string(),D.string()).optional().describe("Exact match: property key equals value"),propertyKeys:D.array(D.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:D.record(D.string(),D.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE, use % as wildcard)"),propertyInValues:D.record(D.string(),D.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Runtime property filters applied to all widgets (merged with dashboard-level filters)")}),outputSchema:D.object({dashboardId:D.string().describe("Dashboard ID"),results:D.array(L86).describe("Widget query results"),timeRange:D.object({startDate:D.string(),endDate:D.string()}).describe("Time range used for the query")}),handler:async(Y,X)=>{let J=J6(X),G=await X.storage.monitoringDashboards.get(Y.dashboardId);if(!G||G.organizationId!==J.id)throw Error(`Dashboard ${Y.dashboardId} not found`);let W=new Date,Q=Y.timeRange?.startDate?new Date(Y.timeRange.startDate):new Date(W.getTime()-86400000),K=Y.timeRange?.endDate?new Date(Y.timeRange.endDate):W,Z=await Promise.all(G.widgets.map(async(H)=>{let F=G.filters?.propertyFilters,$=Y.propertyFilters,V=F||$?{properties:{...F,...$?.properties},propertyKeys:$?.propertyKeys,propertyPatterns:$?.propertyPatterns,propertyInValues:$?.propertyInValues}:void 0,z={connectionIds:H.filter?.connectionIds??G.filters?.connectionIds??void 0,virtualMcpIds:G.filters?.virtualMcpIds??void 0,toolNames:H.filter?.toolNames??G.filters?.toolNames??void 0,startDate:Q,endDate:K,propertyFilters:V};try{let q=await X.storage.monitoring.aggregate({organizationId:J.id,path:H.source.path,from:H.source.from,aggregation:H.aggregation.fn,groupBy:H.aggregation.groupBy,groupByColumn:H.aggregation.groupByColumn,interval:H.aggregation.interval,filters:z});return{widgetId:H.id,value:q.value,groups:q.groups,timeseries:q.timeseries}}catch(q){return console.error(`Widget ${H.id} aggregation failed:`,q),{widgetId:H.id,value:null,groups:void 0,timeseries:void 0}}}));return{dashboardId:Y.dashboardId,results:Z,timeRange:{startDate:Q.toISOString(),endDate:K.toISOString()}}}})});var xa4,GC1;var E86=f(()=>{j6();k0();q2();xa4=D.object({type:D.enum(["metric","timeseries","table"]),source:D.object({path:D.string().describe("JSONPath to extract value from"),from:D.enum(["input","output"]).describe("Extract from input or output")}),aggregation:D.object({fn:D.enum(["sum","avg","min","max","count","count_all","last"]).describe("Aggregation function"),groupBy:D.string().optional().describe("JSONPath for grouping (table)"),groupByColumn:oR1.optional(),interval:D.string().optional().describe("Time interval for timeseries (15m, 1h, 1d)"),limit:D.number().int().positive().optional().describe("Max number of groups to return (applies to groupBy/groupByColumn, ordered by value desc)")}),filter:D.object({connectionIds:D.array(D.string()).optional(),toolNames:D.array(D.string()).optional()}).optional()}),GC1=S0({name:"MONITORING_WIDGET_PREVIEW",description:"Preview a widget aggregation without saving. Used to test queries in the dashboard editor.",annotations:{title:"Preview Monitoring Widget",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({widget:xa4.describe("Widget configuration to preview"),timeRange:D.object({startDate:D.string().datetime().describe("Start of time range (ISO 8601)"),endDate:D.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:D.object({properties:D.record(D.string(),D.string()).optional().describe("Exact match: property key equals value"),propertyKeys:D.array(D.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:D.record(D.string(),D.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE)"),propertyInValues:D.record(D.string(),D.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Property filters to apply"),skipCount:D.boolean().optional().describe("Skip the countMatched query to reduce database load when the count is not needed")}),outputSchema:D.object({value:D.number().nullable().optional().describe("Aggregated value"),groups:D.array(D.object({key:D.string(),value:D.number()})).optional().describe("Grouped results for table widgets"),timeseries:D.array(D.object({timestamp:D.string(),value:D.number()})).optional().describe("Timeseries data points"),matchedRecords:D.number().optional().describe("Number of records that matched (omitted when skipCount is true)"),timeRange:D.object({startDate:D.string(),endDate:D.string()}).describe("Time range used for the query")}),handler:async(Y,X)=>{let J=J6(X),{widget:G,timeRange:W}=Y,Q=new Date,K=W?.startDate?new Date(W.startDate):new Date(Q.getTime()-86400000),Z=W?.endDate?new Date(W.endDate):Q,H={connectionIds:G.filter?.connectionIds,toolNames:G.filter?.toolNames,startDate:K,endDate:Z,propertyFilters:Y.propertyFilters};try{let F=Y.skipCount?void 0:await X.storage.monitoring.countMatched({organizationId:J.id,path:G.source.path,from:G.source.from,filters:H}),$=await X.storage.monitoring.aggregate({organizationId:J.id,path:G.source.path,from:G.source.from,aggregation:G.aggregation.fn,groupBy:G.aggregation.groupBy,groupByColumn:G.aggregation.groupByColumn,interval:G.aggregation.interval,limit:G.aggregation.limit,filters:H});return{value:$.value,groups:$.groups,timeseries:$.timeseries,matchedRecords:F,timeRange:{startDate:K.toISOString(),endDate:Z.toISOString()}}}catch(F){return console.error("Widget preview aggregation failed:",F),{value:null,matchedRecords:void 0,timeRange:{startDate:K.toISOString(),endDate:Z.toISOString()}}}}})});var T86=f(()=>{O86();N86();w86();M86();A86();P86();E86()});var WC1;var R86=f(()=>{k0();j6();WC1=S0({name:"ORGANIZATION_CREATE",description:"Create a new organization",annotations:{title:"Create Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({slug:D.string().min(1).max(50).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens"),name:D.string().min(1).max(255),description:D.string().optional()}),outputSchema:D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),members:D.array(D.any()).optional()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=XY(X);if(!J)throw Error("User ID required to create organization");let G=await X.boundAuth.organization.create({name:Y.name,slug:Y.slug,metadata:Y.description?{description:Y.description}:void 0,userId:J});if(!G)throw Error("Failed to create organization");return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var ZC1;var C86=f(()=>{k0();j6();ZC1=S0({name:"ORGANIZATION_LIST",description:"List all organizations user has access to",annotations:{title:"List Organizations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({userId:D.string().optional()}),outputSchema:D.object({organizations:D.array(D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=XY(X),G=Y.userId||J;if(!G)throw Error("User ID required to list organizations");return{organizations:(await X.boundAuth.organization.list(G)).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt}))}}})});var QC1;var I86=f(()=>{k0();j6();QC1=S0({name:"ORGANIZATION_GET",description:"Get organization details by slug or ID",annotations:{title:"Get Organization",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),members:D.array(D.any()).optional(),invitations:D.array(D.any()).optional()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=await X.boundAuth.organization.get();if(!J)throw Error("No active organization found");let G=new Date,W=J.invitations?.filter((Q)=>new Date(Q.expiresAt)>G);return{...J,invitations:W,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var KC1;var j86=f(()=>{k0();j6();KC1=S0({name:"ORGANIZATION_UPDATE",description:"Update an existing organization",annotations:{title:"Update Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string(),slug:D.string().min(1).max(50).regex(/^[a-z0-9-]+$/).optional(),name:D.string().min(1).max(255).optional(),description:D.string().optional()}),outputSchema:D.object({id:D.string(),name:D.string(),slug:D.string(),logo:D.string().nullable().optional(),metadata:D.any().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{n0(X),await X.access.check();let J={};if(Y.name)J.name=Y.name;if(Y.slug)J.slug=Y.slug;if(Y.description)J.metadata={description:Y.description};let G=await X.boundAuth.organization.update({organizationId:Y.id,data:J});if(!G)throw Error("Failed to update organization");return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var HC1;var _86=f(()=>{k0();j6();HC1=S0({name:"ORGANIZATION_DELETE",description:"Delete an organization",annotations:{title:"Delete Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({id:D.string()}),outputSchema:D.object({success:D.boolean(),id:D.string()}),handler:async(Y,X)=>{return n0(X),await X.access.check(),await X.boundAuth.organization.delete(Y.id),{success:!0,id:Y.id}}})});var uh;var FC1=f(()=>{k0();uh=D.object({title:D.string(),url:D.string(),icon:D.string()})});var $C1;var S86=f(()=>{k0();j6();FC1();$C1=S0({name:"ORGANIZATION_SETTINGS_GET",description:"Get organization-level settings",annotations:{title:"Get Organization Settings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({organizationId:D.string(),sidebar_items:D.array(uh).nullable().optional(),enabled_plugins:D.array(D.string()).nullable().optional(),createdAt:D.string().datetime().optional().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().optional().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let G=await X.storage.organizationSettings.get(J);if(!G)return{organizationId:J};return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}})});var VC1;var k86=f(()=>{k0();j6();FC1();VC1=S0({name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization-level settings",annotations:{title:"Update Organization Settings",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string(),sidebar_items:D.array(uh).optional(),enabled_plugins:D.array(D.string()).optional()}),outputSchema:D.object({organizationId:D.string(),sidebar_items:D.array(uh).nullable().optional(),enabled_plugins:D.array(D.string()).nullable().optional(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{if(n0(X),await X.access.check(),X.organization&&X.organization.id!==Y.organizationId)throw Error("Cannot update settings for a different organization");let J=await X.storage.organizationSettings.upsert(Y.organizationId,{sidebar_items:Y.sidebar_items,enabled_plugins:Y.enabled_plugins});return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var zC1;var v86=f(()=>{k0();j6();zC1=S0({name:"ORGANIZATION_MEMBER_ADD",description:"Add a member to an organization",annotations:{title:"Add Organization Member",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().optional(),userId:D.string(),role:D.array(D.string())}),outputSchema:D.object({id:D.string(),organizationId:D.string(),userId:D.string(),role:D.union([D.string(),D.array(D.string())]),createdAt:D.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=Y.organizationId||X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");if(J!==X.organization?.id)throw Error("Organization ID does not match authenticated organization");let G=await X.boundAuth.organization.addMember({organizationId:J,userId:Y.userId,role:Y.role});if(!G)throw Error("Failed to add member");return{...G,role:G.role,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var qC1;var y86=f(()=>{k0();j6();qC1=S0({name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove a member from an organization",annotations:{title:"Remove Organization Member",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().optional(),memberIdOrEmail:D.string()}),outputSchema:D.object({success:D.boolean(),memberIdOrEmail:D.string()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=Y.organizationId||X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");return await X.boundAuth.organization.removeMember({organizationId:J,memberIdOrEmail:Y.memberIdOrEmail}),{success:!0,memberIdOrEmail:Y.memberIdOrEmail}}})});var UC1;var f86=f(()=>{k0();j6();UC1=S0({name:"ORGANIZATION_MEMBER_LIST",description:"List all members in an organization",annotations:{title:"List Organization Members",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({limit:D.number().optional(),offset:D.number().optional()}),outputSchema:D.object({members:D.array(D.object({id:D.string(),organizationId:D.string(),userId:D.string(),role:D.string(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),user:D.object({id:D.string(),name:D.string(),email:D.string(),image:D.string().optional()}).optional()}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let G=await X.boundAuth.organization.listMembers({organizationId:J,limit:Y.limit,offset:Y.offset});return{members:(Array.isArray(G)?G:[]).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt}))}}})});var BC1;var b86=f(()=>{k0();j6();BC1=S0({name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update a member's role in an organization",annotations:{title:"Update Member Role",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().optional(),memberId:D.string(),role:D.array(D.string())}),outputSchema:D.object({id:D.string(),organizationId:D.string(),userId:D.string(),role:D.union([D.literal("admin"),D.literal("member"),D.literal("owner")]),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),user:D.object({email:D.string(),name:D.string(),image:D.string().optional()})}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=Y.organizationId||X.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let G=await X.boundAuth.organization.updateMemberRole({organizationId:J,memberId:Y.memberId,role:Y.role});if(!G)throw Error("Failed to update member role");return{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt}}})});var h86=f(()=>{R86();C86();I86();j86();_86();S86();k86();v86();y86();f86();b86()});var ma4,O61,la4,Az,x86,N61;var hB=f(()=>{k0();ma4=D.object({banner:D.string().nullable(),bannerColor:D.string().nullable(),icon:D.string().nullable(),themeColor:D.string().nullable()}),O61=D.object({banner:D.string().nullable().optional(),bannerColor:D.string().nullable().optional(),icon:D.string().nullable().optional(),themeColor:D.string().nullable().optional()}),la4=D.object({id:D.string(),title:D.string(),icon:D.string().nullable()}),Az=D.object({id:D.string(),organizationId:D.string(),slug:D.string(),name:D.string(),description:D.string().nullable(),enabledPlugins:D.array(D.string()).nullable(),ui:ma4.nullable(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().describe("ISO 8601 timestamp")}),x86=Az.omit({organizationId:!0}).extend({boundConnections:D.array(la4)}),N61=D.object({id:D.string(),projectId:D.string(),pluginId:D.string(),connectionId:D.string().nullable(),settings:D.record(D.string(),D.unknown()).nullable(),createdAt:D.string().datetime().describe("ISO 8601 timestamp"),updatedAt:D.string().datetime().describe("ISO 8601 timestamp")})});var DC1;var g86=f(()=>{k0();j6();hB();DC1=S0({name:"PROJECT_LIST",description:"List all projects in an organization",annotations:{title:"List Projects",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().describe("Organization ID to list projects for")}),outputSchema:D.object({projects:D.array(x86)}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=await X.storage.projects.list(Y.organizationId),G=J.map((Q)=>Q.id),W=await X.storage.projectPluginConfigs.getBoundConnectionsForProjects(G);return{projects:J.map((Q)=>({id:Q.id,slug:Q.slug,name:Q.name,description:Q.description,enabledPlugins:Q.enabledPlugins,ui:Q.ui,boundConnections:W.get(Q.id)??[],createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}))}}})});var LC1;var u86=f(()=>{k0();j6();hB();LC1=S0({name:"PROJECT_GET",description:"Get a project by ID or slug",annotations:{title:"Get Project",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().describe("Organization ID"),projectId:D.string().optional().describe("Project ID (either this or slug required)"),slug:D.string().optional().describe("Project slug (either this or projectId required)")}).refine((Y)=>Y.projectId||Y.slug,{message:"Either projectId or slug must be provided"}),outputSchema:D.object({project:Az.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=null;if(Y.projectId)J=await X.storage.projects.get(Y.projectId);else if(Y.slug)J=await X.storage.projects.getBySlug(Y.organizationId,Y.slug);if(!J)return{project:null};return{project:{id:J.id,organizationId:J.organizationId,slug:J.slug,name:J.name,description:J.description,enabledPlugins:J.enabledPlugins,ui:J.ui,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}}})});var OC1;var m86=f(()=>{k0();iY();j6();hB();OC1=S0({name:"PROJECT_CREATE",description:"Create a new project in an organization",annotations:{title:"Create Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({organizationId:D.string().describe("Organization ID"),slug:D.string().min(1).max(100).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens").describe("URL-friendly identifier"),name:D.string().min(1).max(200).describe("Display name"),description:D.string().max(1000).nullable().optional().describe("Project description"),enabledPlugins:D.array(D.string()).nullable().optional().describe("Plugin IDs to enable"),ui:O61.nullable().optional().describe("UI customization")}),outputSchema:D.object({project:Az}),handler:async(Y,X)=>{n0(X),await X.access.check();let{organizationId:J,slug:G,name:W,description:Q,enabledPlugins:K,ui:Z}=Y;if(G===C3)throw Error(`Slug "${C3}" is reserved`);if(await X.storage.projects.getBySlug(J,G))throw Error(`Project with slug "${G}" already exists in this organization`);let F=Z?{banner:Z.banner??null,bannerColor:Z.bannerColor??null,icon:Z.icon??null,themeColor:Z.themeColor??null}:null,$=await X.storage.projects.create({organizationId:J,slug:G,name:W,description:Q??null,enabledPlugins:K??null,ui:F});return{project:{id:$.id,organizationId:$.organizationId,slug:$.slug,name:$.name,description:$.description,enabledPlugins:$.enabledPlugins,ui:$.ui,createdAt:$.createdAt instanceof Date?$.createdAt.toISOString():$.createdAt,updatedAt:$.updatedAt instanceof Date?$.updatedAt.toISOString():$.updatedAt}}}})});var NC1;var l86=f(()=>{k0();j6();hB();NC1=S0({name:"PROJECT_UPDATE",description:"Update a project's details",annotations:{title:"Update Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID to update"),name:D.string().min(1).max(200).optional().describe("New display name"),description:D.string().max(1000).nullable().optional().describe("New description"),enabledPlugins:D.array(D.string()).nullable().optional().describe("Updated plugin IDs"),ui:O61.nullable().optional().describe("Updated UI customization")}),outputSchema:D.object({project:Az.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,name:G,description:W,enabledPlugins:Q,ui:K}=Y,Z={};if(G!==void 0)Z.name=G;if(W!==void 0)Z.description=W;if(Q!==void 0)Z.enabledPlugins=Q;if(K!==void 0)Z.ui=K?{banner:K.banner??null,bannerColor:K.bannerColor??null,icon:K.icon??null,themeColor:K.themeColor??null}:null;let H=await X.storage.projects.update(J,Z);if(!H)return{project:null};return{project:{id:H.id,organizationId:H.organizationId,slug:H.slug,name:H.name,description:H.description,enabledPlugins:H.enabledPlugins,ui:H.ui,createdAt:H.createdAt instanceof Date?H.createdAt.toISOString():H.createdAt,updatedAt:H.updatedAt instanceof Date?H.updatedAt.toISOString():H.updatedAt}}}})});var wC1;var d86=f(()=>{k0();iY();j6();wC1=S0({name:"PROJECT_DELETE",description:"Delete a project (cannot delete org-admin)",annotations:{title:"Delete Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID to delete")}),outputSchema:D.object({success:D.boolean(),message:D.string().optional()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J}=Y,G=await X.storage.projects.get(J);if(!G)return{success:!1,message:"Project not found"};if(G.slug===C3)return{success:!1,message:"Cannot delete the org-admin project"};return{success:await X.storage.projects.delete(J)}}})});var MC1;var c86=f(()=>{k0();j6();hB();MC1=S0({name:"PROJECT_PLUGIN_CONFIG_GET",description:"Get plugin configuration for a project",annotations:{title:"Get Project Plugin Config",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),pluginId:D.string().describe("Plugin ID")}),outputSchema:D.object({config:N61.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,pluginId:G}=Y,W=await X.storage.projectPluginConfigs.get(J,G);if(!W)return{config:null};return{config:{id:W.id,projectId:W.projectId,pluginId:W.pluginId,connectionId:W.connectionId,settings:W.settings,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():W.createdAt,updatedAt:W.updatedAt instanceof Date?W.updatedAt.toISOString():W.updatedAt}}}})});var AC1;var p86=f(()=>{k0();j6();hB();H61();AC1=S0({name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update or create plugin configuration for a project",annotations:{title:"Update Project Plugin Config",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),pluginId:D.string().describe("Plugin ID"),connectionId:D.string().nullable().optional().describe("MCP connection to bind"),settings:D.record(D.string(),D.unknown()).nullable().optional().describe("Plugin-specific settings")}),outputSchema:D.object({config:N61}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,pluginId:G,connectionId:W,settings:Q}=Y,K=XY(X),Z=await X.storage.projects.get(J);if(!Z)throw Error(`Project not found: ${J}`);let H=W?await X.storage.connections.findById(W):null;if(W&&Z.organizationId&&!H&&OR()){if(K61(W,Z.organizationId)){if(!K)throw Error("User ID required to create dev-assets connection");let $=NR(Z.organizationId,AK());await X.storage.connections.create({...$,organization_id:Z.organizationId,created_by:K})}}let F=await X.storage.projectPluginConfigs.upsert(J,G,{connectionId:W,settings:Q});return{config:{id:F.id,projectId:F.projectId,pluginId:F.pluginId,connectionId:F.connectionId,settings:F.settings,createdAt:F.createdAt instanceof Date?F.createdAt.toISOString():F.createdAt,updatedAt:F.updatedAt instanceof Date?F.updatedAt.toISOString():F.updatedAt}}}})});var da4,PC1;var n86=f(()=>{k0();j6();da4=D.object({id:D.string(),title:D.string(),icon:D.string().nullable(),connectionType:D.string(),status:D.string()}),PC1=S0({name:"PROJECT_CONNECTION_LIST",description:"List connections associated with a project",annotations:{title:"List Project Connections",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID")}),outputSchema:D.object({connections:D.array(da4)}),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let{projectId:G}=Y,W=await X.storage.projects.get(G);if(!W||W.organizationId!==J.id)throw Error(`Project not found: ${G}`);let Q=await X.storage.projectConnections.list(G);return{connections:(await Promise.all(Q.map((H)=>X.storage.connections.findById(H.connectionId)))).filter((H)=>H!=null).map((H)=>({id:H.id,title:H.title,icon:H.icon??null,connectionType:H.connection_type,status:H.status}))}}})});var EC1;var i86=f(()=>{k0();j6();EC1=S0({name:"PROJECT_CONNECTION_ADD",description:"Associate a connection with a project",annotations:{title:"Add Project Connection",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),connectionId:D.string().describe("Connection ID to associate")}),outputSchema:D.object({success:D.boolean(),projectConnectionId:D.string()}),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let{projectId:G,connectionId:W}=Y,Q=await X.storage.projects.get(G);if(!Q||Q.organizationId!==J.id)throw Error(`Project not found: ${G}`);let K=await X.storage.connections.findById(W);if(!K||K.organization_id!==J.id)throw Error(`Connection not found: ${W}`);return{success:!0,projectConnectionId:(await X.storage.projectConnections.add(G,W)).id}}})});var TC1;var a86=f(()=>{k0();j6();TC1=S0({name:"PROJECT_CONNECTION_REMOVE",description:"Remove a connection association from a project",annotations:{title:"Remove Project Connection",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),connectionId:D.string().describe("Connection ID to disassociate")}),outputSchema:D.object({success:D.boolean()}),handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let{projectId:G,connectionId:W}=Y,Q=await X.storage.projects.get(G);if(!Q||Q.organizationId!==J.id)throw Error(`Project not found: ${G}`);let K=await X.storage.connections.findById(W);if(!K||K.organization_id!==J.id)throw Error(`Connection not found: ${W}`);let Z=await X.storage.projectConnections.remove(G,W);if(Q?.ui?.pinnedViews?.length){let H=Q.ui.pinnedViews.filter((F)=>F.connectionId!==W);if(H.length!==Q.ui.pinnedViews.length){let F={...Q.ui,pinnedViews:H.length>0?H:null};await X.storage.projects.update(G,{ui:F})}}return{success:Z}}})});var ca4,RC1;var r86=f(()=>{k0();j6();hB();ca4=D.object({connectionId:D.string(),toolName:D.string(),label:D.string(),icon:D.string().nullable()}),RC1=S0({name:"PROJECT_PINNED_VIEWS_UPDATE",description:"Update the pinned sidebar views for a project",annotations:{title:"Update Pinned Views",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({projectId:D.string().describe("Project ID"),pinnedViews:D.array(ca4).describe("Pinned views to set for the project sidebar")}),outputSchema:D.object({project:Az.nullable()}),handler:async(Y,X)=>{n0(X),await X.access.check();let{projectId:J,pinnedViews:G}=Y,W=await X.storage.projects.get(J);if(!W)throw Error(`Project not found: ${J}`);let K={...W.ui??{banner:null,bannerColor:null,icon:null,themeColor:null},pinnedViews:G.length>0?G:null},Z=await X.storage.projects.update(J,{ui:K});if(!Z)return{project:null};return{project:{id:Z.id,organizationId:Z.organizationId,slug:Z.slug,name:Z.name,description:Z.description,enabledPlugins:Z.enabledPlugins,ui:Z.ui,createdAt:Z.createdAt instanceof Date?Z.createdAt.toISOString():Z.createdAt,updatedAt:Z.updatedAt instanceof Date?Z.updatedAt.toISOString():Z.updatedAt}}}})});var o86=f(()=>{g86();u86();m86();l86();d86();c86();p86();n86();i86();a86();r86()});var CC1;var s86=f(()=>{k0();j6();CC1=S0({name:"TAGS_LIST",description:"List all tags in an organization",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({}),outputSchema:D.object({tags:D.array(D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X);return{tags:(await X.storage.tags.listOrgTags(J.id)).map((W)=>({...W,createdAt:W.createdAt instanceof Date?W.createdAt.toISOString():String(W.createdAt)}))}}})});var IC1;var t86=f(()=>{k0();j6();IC1=S0({name:"TAGS_CREATE",description:"Create a new tag in an organization",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:D.object({name:D.string().min(1).max(50).describe("Tag name")}),outputSchema:D.object({tag:D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")})}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X),G=await X.storage.tags.createTag(J.id,Y.name);return{tag:{...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}}}})});var jC1;var e86=f(()=>{k0();j6();jC1=S0({name:"TAGS_DELETE",description:"Delete a tag from an organization (removes from all members)",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({tagId:D.string().describe("Tag ID to delete")}),outputSchema:D.object({success:D.boolean()}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X),G=await X.storage.tags.getTag(Y.tagId);if(!G)throw Error("Tag not found");if(G.organizationId!==J.id)throw Error("Tag does not belong to this organization");return await X.storage.tags.deleteTag(Y.tagId),{success:!0}}})});var _C1;var Y96=f(()=>{k0();j6();_C1=S0({name:"MEMBER_TAGS_GET",description:"Get tags assigned to a member",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({memberId:D.string().describe("Member ID")}),outputSchema:D.object({tags:D.array(D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,J.id))throw Error(`Member not found in this organization: ${Y.memberId}`);return{tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}))}}})});var SC1;var X96=f(()=>{k0();j6();SC1=S0({name:"MEMBER_TAGS_SET",description:"Set tags for a member (replaces all existing tags)",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D.object({memberId:D.string().describe("Member ID"),tagIds:D.array(D.string()).describe("Array of tag IDs to assign")}),outputSchema:D.object({success:D.boolean(),tags:D.array(D.object({id:D.string(),organizationId:D.string(),name:D.string(),createdAt:D.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{n0(X),await X.access.check();let J=J6(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,J.id))throw Error(`Member not found in this organization: ${Y.memberId}`);for(let Q of Y.tagIds){let K=await X.storage.tags.getTag(Q);if(!K)throw Error(`Tag not found: ${Q}`);if(K.organizationId!==J.id)throw Error(`Tag does not belong to this organization: ${Q}`)}return await X.storage.tags.setMemberTags(Y.memberId,Y.tagIds),{success:!0,tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((Q)=>({...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}))}}})});var J96=f(()=>{s86();t86();e86();Y96();X96()});var G96=f(()=>{iY()});var W96,rF,Z96,Q96;var U2=f(()=>{k0();G96();W96=D.object({id:D.string().describe("Unique message ID"),thread_id:D.string().describe("ID of the parent thread"),metadata:D.unknown().optional().describe("Optional message metadata"),parts:D.array(D.record(D.string(),D.unknown())).describe("Message content parts (AI SDK UIMessagePart format)"),role:D.enum(["user","assistant","system"]).describe("Message role"),created_at:D.string().datetime().describe("Timestamp of creation"),updated_at:D.string().datetime().describe("Timestamp of last update")}),rF=D.object({id:D.string().describe("Unique thread ID"),organization_id:D.string().describe("Organization this thread belongs to"),title:D.string().describe("Thread title"),description:D.string().nullable().describe("Thread description"),created_at:D.string().datetime().describe("Timestamp of creation"),updated_at:D.string().datetime().describe("Timestamp of last update"),hidden:D.boolean().optional().describe("Whether the thread is hidden"),status:D.enum([...PM,"expired"]).describe("Thread execution status. 'expired' is virtual -- computed at read time for stale in_progress threads"),created_by:D.string().describe("User ID who created the thread"),updated_by:D.string().nullable().describe("User ID who last updated the thread")}),Z96=D.object({id:D.string().optional().describe("Optional custom ID for the thread"),title:D.string().describe("Thread title"),description:D.string().nullish().describe("Thread description")}),Q96=D.object({title:D.string().optional().describe("New thread title"),description:D.string().nullish().describe("New thread description"),hidden:D.boolean().optional().describe("Whether the thread is hidden")})});var ia4,aa4,kC1;var K96=f(()=>{k0();j6();U2();Eh();ia4=D.object({data:Z96.describe("Data for the new thread (id is auto-generated if not provided)")}),aa4=D.object({item:rF.describe("The created thread entity")}),kC1=S0({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread in the organization",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:ia4,outputSchema:aa4,handler:async(Y,X)=>{n0(X);let J=J6(X);await X.access.check();let G=XY(X);if(!G)throw Error("User ID required to create thread");let W=Y.data.id??SB("thrd"),Q=await X.storage.threads.create({id:W,organization_id:J.id,title:Y.data.title,description:Y.data.description,created_by:G});return{item:{...Q,hidden:Q.hidden??!1}}}})});function xB(Y,X=Date.now()){let J=Y.status;if(J==="in_progress"){let G=new Date(Y.updated_at).getTime();if(!Number.isFinite(G)||X-G>1800000)J="expired"}return{...Y,status:J,hidden:Y.hidden??!1}}var ra4,oa4,vC1;var H96=f(()=>{qW();j6();U2();k0();ra4=XK.extend({where:D.object({created_by:D.string().optional()}).optional()}),oa4=n$(rF),vC1=S0({name:"COLLECTION_THREADS_LIST",description:"List all threads in the organization with filtering, sorting, and pagination",annotations:{title:"List Threads",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:ra4,outputSchema:oa4,handler:async(Y,X)=>{if(await X.access.check(),!X.auth.user?.id)throw Error("User ID required to list threads");J6(X);let G=Y.offset??0,W=Y.limit??100,Q=Y.where?.created_by,{threads:K,total:Z}=await X.storage.threads.list(Q,{limit:W,offset:G}),H=G+W<Z,F=Date.now();return{items:K.map(($)=>xB($,F)),totalCount:Z,hasMore:H}}})});var sa4,yC1;var F96=f(()=>{qW();j6();U2();sa4=OS(rF),yC1=S0({name:"COLLECTION_THREADS_GET",description:"Get thread details by ID",annotations:{title:"Get Thread",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:LS,outputSchema:sa4,handler:async(Y,X)=>{n0(X),J6(X),await X.access.check();let J=await X.storage.threads.get(Y.id);if(!J)return{item:null};return{item:xB(J)}}})});var ta4,ea4,fC1;var $96=f(()=>{k0();j6();U2();ta4=D.object({id:D.string().describe("ID of the thread to update"),data:Q96.describe("Partial thread data to update")}),ea4=D.object({item:rF.describe("The updated thread entity")}),fC1=S0({name:"COLLECTION_THREADS_UPDATE",description:"Update an existing thread in the organization",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:ta4,outputSchema:ea4,handler:async(Y,X)=>{n0(X),J6(X),await X.access.check();let J=XY(X);if(!J)throw Error("User ID required to update thread");let{id:G,data:W}=Y;if(!await X.storage.threads.get(G))throw Error("Thread not found in organization");let K=await X.storage.threads.update(G,{title:W.title,description:W.description,hidden:W.hidden,updated_by:J});return{item:xB(K)}}})});var bC1;var V96=f(()=>{qW();j6();U2();bC1=S0({name:"COLLECTION_THREADS_DELETE",description:"Delete a thread",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:NS,outputSchema:wS(rF),handler:async(Y,X)=>{n0(X),J6(X),await X.access.check();let J=await X.storage.threads.get(Y.id);if(!J)throw Error(`Thread not found: ${Y.id}`);return await X.storage.threads.delete(Y.id),{item:xB(J)}}})});function z96(Y){if(!Y)return null;if("field"in Y&&Y.field[0]==="thread_id"&&Y.operator==="eq")return String(Y.value);if("conditions"in Y)for(let X of Y.conditions){let J=z96(X);if(J)return J}return null}var Yr4,hC1;var q96=f(()=>{qW();j6();U2();Yr4=n$(W96),hC1=S0({name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List all messages for a specific thread",annotations:{title:"List Thread Messages",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:XK,outputSchema:Yr4,handler:async(Y,X)=>{J6(X),await X.access.check();let J=z96(Y.where);if(!J)throw Error("thread_id filter is required in where clause");let G=Y.offset??0,W=Y.limit??100,{messages:Q,total:K}=await X.storage.threads.listMessages(J,{limit:W,offset:G}),Z=G+W<K;return{items:Q,totalCount:K,hasMore:Z}}})});var U96=f(()=>{K96();H96();F96();$96();V96();q96()});var Jr4,Gr4,xC1;var B96=f(()=>{k0();j6();Jr4=D.object({id:D.string().min(1)}),Gr4=D.object({user:D.object({id:D.string(),name:D.string(),email:D.string(),image:D.string().nullable()}).nullable()}),xC1=S0({name:"USER_GET",description:"Get a user by id (restricted to shared organizations)",annotations:{title:"Get User",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Jr4,outputSchema:Gr4,handler:async(Y,X)=>{await X.access.check(),n0(X);let J=XY(X);if(!J)throw Error("Authentication required");let G=await X.storage.users.findById(Y.id,J);if(!G)return{user:null};return{user:{id:G.id,name:G.name,email:G.email,image:G.image??null}}}})});var D96=f(()=>{B96()});var O96={};u6(O96,{managementMCP:()=>Kr4,ALL_TOOLS:()=>L96});var Zr4,Qr4,L96,Kr4=async(Y)=>{let X=null;if(Y.organization){let W=await Y.storage.organizationSettings.get(Y.organization.id),Q=await Y.storage.projects.list(Y.organization.id),K=new Set(W?.enabled_plugins??[]);for(let Z of Q)if(Z.enabledPlugins)for(let H of Z.enabledPlugins)K.add(H);X=K.size>0?[...K]:null}let J=FY0(L96,X),G=new EM({name:"mcp-mesh-management",version:"1.0.0"},{capabilities:{tools:{}}});for(let W of J){let Q=W.inputSchema&&typeof W.inputSchema==="object"&&"shape"in W.inputSchema?W.inputSchema:D.object({}),K=W.outputSchema&&typeof W.outputSchema==="object"&&"shape"in W.outputSchema?W.outputSchema:void 0,Z=Q.shape,H=K?.shape;G.registerTool(W.name,{description:W.description??"",inputSchema:Z,outputSchema:H,annotations:W.annotations,_meta:W._meta},async(F)=>{Y.access.setToolName(W.name);try{let $=await W.execute(F,Y);return{content:[{type:"text",text:JSON.stringify($)}],structuredContent:$}}catch($){return{content:[{type:"text",text:`Error: ${$.message}`}],isError:!0}}})}return G};var N96=f(()=>{Aa();Mc();k0();M66();l66();u46();c46();Y86();K86();q86();D86();T86();h86();o86();J96();U96();D96();Zr4=[WC1,ZC1,QC1,KC1,HC1,$C1,VC1,zC1,qC1,UC1,BC1,YR1,GR1,WR1,CR1,IR1,jR1,hR1,gR1,uR1,mR1,lR1,dR1,cR1,pR1,nR1,iR1,d46,aR1,rR1,sR1,tR1,eR1,YC1,XC1,JC1,GC1,nT1,aT1,rT1,iT1,_R1,SR1,kR1,vR1,yR1,fR1,bR1,xC1,sT1,tT1,eT1,kC1,vC1,yC1,fC1,bC1,hC1,CC1,IC1,jC1,_C1,SC1,DC1,LC1,OC1,NC1,wC1,MC1,AC1,PC1,EC1,TC1,RC1],Qr4=$Y0(),L96=[...Zr4,...Qr4]});function Hr4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (N96(),O96));return X.map((J)=>{return{name:J.name,inputSchema:D.toJSONSchema(J.inputSchema,{unrepresentable:"any"}),outputSchema:J.outputSchema?D.toJSONSchema(J.outputSchema,{unrepresentable:"any"}):void 0,description:J.description}})},data:XZ1(AK(),Y)},{data:YZ1()},{data:eW1(Y)}]}async function w96(Y,X){try{let J=$R(),G=new _T1(process.env.ENCRYPTION_KEY||""),W=new ST1(J.db,G),Q=new kT1(J.db),K=Hr4(Y);try{await Q.create({organizationId:Y,slug:C3,name:$w,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(K.map(async(Z)=>{let H=null;if(Z.permissions)H=(await TR.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await qR({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),$=await Z.getTools?.()??F?.tools??null,V=F?.scopes?.length?F.scopes:null,z=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await W.create({...Z.data,id:z,tools:$,configuration_scopes:V,organization_id:Y,created_by:X,connection_token:Z.data.connection_token??H})}))}catch(J){console.error("Error creating default MCP connections:",J)}}var M96=f(()=>{iY();e01();U06();B06();D06();J61();k0();V61()});var A96;var P96=f(()=>{A96=["owner","admin"]});var Fr4=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},E96=(Y)=>{if(Y.providerId==="microsoft")return Fr4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function $r4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function Vr4(){let Y=Math.floor(Math.random()*R96.length),X=Math.floor(Math.random()*T96.length),J=R96[Y]??"deco",G=T96[X]??"studio";return`${J}-${G}`}function Mr4(){let Y=[mh],X=new URL(mh);if(X.hostname==="localhost")Y.push(mh.replace("localhost","127.0.0.1"));else if(X.hostname==="127.0.0.1")Y.push(mh.replace("127.0.0.1","localhost"));return Y}var T96,R96,zr4,qr4,w61,Ur4,Br4,Dr4,C96,dY,I96=void 0,gC1=void 0,Lr4=!1,Or4,Nr4,wr4,mh,TR;var V61=f(()=>{cX0();NQ0();XK0();pB1();iK0();aK0();$L1();XH0();e01();jT1();F06();M96();P96();T96=["labs","agent","studio","workspace","systems","core","cloud","works"],R96=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];zr4=Object.values(iq1()).map((Y)=>Y.map((X)=>X.name)).flat(),qr4={...so,self:["*",...zr4]},w61=OF(qr4),Ur4=w61.newRole({self:["*"],...Uy.statements}),Br4=w61.newRole({self:["*"],...Uy.statements}),Dr4=w61.newRole({self:["*"],...Uy.statements}),C96=Object.values(iq1()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),dY=qs.auth;if(dY.inviteEmailProviderId&&dY.emailProviders&&dY.emailProviders.length>0){let Y=Ah(dY.emailProviders,dY.inviteEmailProviderId);if(Y){let X=Mh(Y);I96=async(J)=>{let G=J.inviter.user?.name||J.inviter.user?.email,W=`${AK()}/auth/accept-invitation?invitationId=${J.invitation.id}&redirectTo=/`;await X({to:J.email,subject:`Invitation to join ${J.organization.name}`,html:`
|
|
1967
1967
|
<h2>You've been invited!</h2>
|
|
1968
1968
|
<p>${G} has invited you to join <strong>${J.organization.name}</strong>.</p>
|
|
1969
1969
|
<p><a href="${W}">Click here to accept the invitation</a></p>
|