@decocms/mesh 2.139.0 → 2.139.2
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-Du6fB3-T.js → AlertCircle-BDyT9vNZ.js} +1 -1
- package/dist/client/assets/{AlignLeft-BB2PryWK.js → AlignLeft-BixvP29Y.js} +1 -1
- package/dist/client/assets/{ArrowDown-MBF4qfeq.js → ArrowDown-BYesfwXe.js} +1 -1
- package/dist/client/assets/{ArrowLeft-MHWNQw1u.js → ArrowLeft-BAkHebXa.js} +1 -1
- package/dist/client/assets/{ArrowUp-nwGLUGoR.js → ArrowUp-BCyv-ojK.js} +1 -1
- package/dist/client/assets/{Check-rkFTDUnB.js → Check-Camn3oQw.js} +1 -1
- package/dist/client/assets/{CheckCircle-BMnBlweF.js → CheckCircle-B7XGhEcJ.js} +1 -1
- package/dist/client/assets/{CheckDone01-B6UNHl2N.js → CheckDone01-CldSAlfc.js} +1 -1
- package/dist/client/assets/{CheckVerified02-nkuDDvAL.js → CheckVerified02-K0TWAV06.js} +1 -1
- package/dist/client/assets/{ChevronDown-D0kStRqm.js → ChevronDown-DkqBWU_h.js} +1 -1
- package/dist/client/assets/{ChevronLeft-KolET6Zv.js → ChevronLeft-BPmkNFNc.js} +1 -1
- package/dist/client/assets/{ChevronRight-D1sI_Ijw.js → ChevronRight-BI34N28O.js} +1 -1
- package/dist/client/assets/{Clock-DR3iqeaG.js → Clock-BqFZuRNT.js} +1 -1
- package/dist/client/assets/{Code01-CFqfQe4V.js → Code01-DcYAohyI.js} +1 -1
- package/dist/client/assets/{Container-BSSb3CBt.js → Container-B8pG1v5Y.js} +1 -1
- package/dist/client/assets/{Copy01-tYgWW7Z7.js → Copy01-GXSpNbxP.js} +1 -1
- package/dist/client/assets/{Dataflow03-BjW1O4g6.js → Dataflow03-Cz5aNZkd.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-CZetTyjY.js → DotsHorizontal-DseOTG6x.js} +1 -1
- package/dist/client/assets/{DotsVertical-CmV9wwH7.js → DotsVertical-DgG2OQVv.js} +1 -1
- package/dist/client/assets/{Download01-DP_85E1L.js → Download01-DV6jzPqo.js} +1 -1
- package/dist/client/assets/{Edit01-DLt4viGj.js → Edit01-nsEjgwmh.js} +1 -1
- package/dist/client/assets/{Edit05-CRwglEOR.js → Edit05-BLS2FJfm.js} +1 -1
- package/dist/client/assets/{Eye-B2hby3r0.js → Eye-DQF_Qzuy.js} +1 -1
- package/dist/client/assets/{File02-DcmHoWfe.js → File02-QDXoffKV.js} +1 -1
- package/dist/client/assets/{File06-P-yLdUH3.js → File06-DNhGyMHz.js} +1 -1
- package/dist/client/assets/{FilterLines-CLAaqewT.js → FilterLines-lwBT4U5d.js} +1 -1
- package/dist/client/assets/{Globe01-lhdAzS1a.js → Globe01-lQfF_p8O.js} +1 -1
- package/dist/client/assets/{Globe02-kTB2nNF6.js → Globe02-sIfslzHX.js} +1 -1
- package/dist/client/assets/{Grid01-uA-KjK4P.js → Grid01-CTYtPHN4.js} +1 -1
- package/dist/client/assets/{Hash02-DIk3AwE8.js → Hash02-DU1c1Jak.js} +1 -1
- package/dist/client/assets/{Home02-DxJI0U9t.js → Home02-D8QOVzlb.js} +1 -1
- package/dist/client/assets/{Image01-CwLEkhKm.js → Image01-BNs8seI1.js} +1 -1
- package/dist/client/assets/{Inbox01-DtkSOVs2.js → Inbox01-DTh-ZtU7.js} +1 -1
- package/dist/client/assets/{InfoCircle-Bk5RAOq4.js → InfoCircle-s0dGNMks.js} +1 -1
- package/dist/client/assets/{Key01-DwZUxnT6.js → Key01-CHf-4NZR.js} +1 -1
- package/dist/client/assets/{LayersTwo01-BOewAoxC.js → LayersTwo01-zg7ssS5q.js} +1 -1
- package/dist/client/assets/{LayoutLeft-BCns0XHC.js → LayoutLeft-vITOgZDF.js} +1 -1
- package/dist/client/assets/{Link01-D55ffrtA.js → Link01-B46W_qyR.js} +1 -1
- package/dist/client/assets/{LinkExternal01-B6ZbHgbX.js → LinkExternal01-CWUdHxEb.js} +1 -1
- package/dist/client/assets/{List-CTxbvNpA.js → List-DXD0Q-rz.js} +1 -1
- package/dist/client/assets/{Loading01-ZX06xZy4.js → Loading01-HszUOya-.js} +1 -1
- package/dist/client/assets/{Lock01-BdehYb6x.js → Lock01-sWjWjRt6.js} +1 -1
- package/dist/client/assets/{Play-BZUCyc1M.js → Play-DYN0MmVY.js} +1 -1
- package/dist/client/assets/{Plus-DfSe6meC.js → Plus-BaoKmylk.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-lQZhHyQW.js → RefreshCcw01-yUiODtTq.js} +1 -1
- package/dist/client/assets/{Save01-B0MC8MAr.js → Save01-Co3EpgQC.js} +1 -1
- package/dist/client/assets/{SearchMd-BJW1WwdD.js → SearchMd-3WCi1VDc.js} +1 -1
- package/dist/client/assets/{Settings01-Cq86UQ_U.js → Settings01-84eR-C3B.js} +1 -1
- package/dist/client/assets/{Shield01-DL_Ij6Ye.js → Shield01-WvymnQYW.js} +1 -1
- package/dist/client/assets/{Terminal-BoTiYZzB.js → Terminal-CM1LxJaq.js} +1 -1
- package/dist/client/assets/{Trash01-BF5joJVw.js → Trash01-CAKaaYMp.js} +1 -1
- package/dist/client/assets/{Upload01-CevHuUsD.js → Upload01-BDarTYGT.js} +1 -1
- package/dist/client/assets/{Users03-BChgBZvs.js → Users03-D0y7vtGV.js} +1 -1
- package/dist/client/assets/{X-Br_8Pcje.js → X-BS-0d43p.js} +1 -1
- package/dist/client/assets/{XCircle-CHV2soON.js → XCircle-BJZFrCgV.js} +1 -1
- package/dist/client/assets/{XClose-CngVUjAw.js → XClose-6pBqg-B-.js} +1 -1
- package/dist/client/assets/{Zap-BB2-7sch.js → Zap-MB79YnxU.js} +1 -1
- package/dist/client/assets/{agent-connections-preview-DjHTWMtp.js → agent-connections-preview-D0T58SYV.js} +1 -1
- package/dist/client/assets/{agent-detail-lU3sHCth.js → agent-detail-BRsW7IYa.js} +1 -1
- package/dist/client/assets/{agents-7Bxgq-1z.js → agents-juAVT19y.js} +1 -1
- package/dist/client/assets/{alert-dialog-DKBAIL5X.js → alert-dialog-CtNI8LvE.js} +1 -1
- package/dist/client/assets/{auth-catchall-BQcv9slA.js → auth-catchall-BNohJky1.js} +1 -1
- package/dist/client/assets/{avatar-BeKMLeOK.js → avatar-7hY_H5zt.js} +1 -1
- package/dist/client/assets/{badge-lNsdvrPX.js → badge-DfhuIA_7.js} +1 -1
- package/dist/client/assets/{binder-M03ehuyS.js → binder-C6fAESck.js} +1 -1
- package/dist/client/assets/{breadcrumb-CbuQGV2e.js → breadcrumb-DZJzQEPd.js} +1 -1
- package/dist/client/assets/{card-CT6tLP8V.js → card-DXg2GX79.js} +1 -1
- package/dist/client/assets/{chart-DQcJSXSh.js → chart-BWnEsG4R.js} +1 -1
- package/dist/client/assets/{checkbox-CcR9shtW.js → checkbox-CA1NpLng.js} +1 -1
- package/dist/client/assets/{circle-alert-ClRs8xPF.js → circle-alert-DpFL31gA.js} +1 -1
- package/dist/client/assets/{collapsible-DzPnEQQK.js → collapsible-CZMy3y5l.js} +1 -1
- package/dist/client/assets/{collection-detail-xSPIsewR.js → collection-detail-C59CwIQH.js} +1 -1
- package/dist/client/assets/{collection-display-button-DmhgFxWQ.js → collection-display-button-CVVCR82C.js} +1 -1
- package/dist/client/assets/{collection-search-CJODK4wM.js → collection-search-BVMX34xh.js} +1 -1
- package/dist/client/assets/{collection-tab-JdGvu78y.js → collection-tab-Dq2y4UTN.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-DcuTtOH8.js → collection-table-wrapper-C0TGGJ6J.js} +1 -1
- package/dist/client/assets/{collection-tabs-Nnu_1f99.js → collection-tabs-fHRefLVF.js} +1 -1
- package/dist/client/assets/{command-BLLQ4m1J.js → command-DQZMRksB.js} +1 -1
- package/dist/client/assets/{connect-ct0t4q_d.js → connect-BPIjHna-.js} +1 -1
- package/dist/client/assets/{connection-card-DPP04y2O.js → connection-card-CVWbDwe1.js} +1 -1
- package/dist/client/assets/{connection-detail-efOk6PaG.js → connection-detail-BE8aQ9Vr.js} +1 -1
- package/dist/client/assets/{connection-status-D-HN2zGB.js → connection-status-CIfK1aaf.js} +1 -1
- package/dist/client/assets/{connections-BTpfo1XT.js → connections-DE-LDmih.js} +1 -1
- package/dist/client/assets/{constants-n-gIPEUY.js → constants-9aDFHfpv.js} +1 -1
- package/dist/client/assets/constants-C6iMC3JV.js +1 -0
- package/dist/client/assets/{create-organization-dialog-D9UCiEFU.js → create-organization-dialog-rPVbE78O.js} +1 -1
- package/dist/client/assets/{create-project-dialog-B3k-tP2b.js → create-project-dialog-eGd8v6in.js} +1 -1
- package/dist/client/assets/{danger-5Jol91M3.js → danger-CN2jIiYh.js} +1 -1
- package/dist/client/assets/{danger-zone-BiPia_pz.js → danger-zone-DFB5uHUA.js} +1 -1
- package/dist/client/assets/{decopilot-events-C3HhCqtz.js → decopilot-events-BNDSGGPU.js} +1 -1
- package/dist/client/assets/{dependencies-wOmZW20z.js → dependencies-B2LWAesw.js} +1 -1
- package/dist/client/assets/{dialog-BqMxGyd1.js → dialog-C82flYm2.js} +1 -1
- package/dist/client/assets/{dropdown-menu-hTX487a_.js → dropdown-menu-CxuRGQYq.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-CHC4VJ91.js → dynamic-plugin-layout-CQiNNzkD.js} +1 -1
- package/dist/client/assets/{editable-task-title-DKcT54Le.js → editable-task-title-0i5466nX.js} +1 -1
- package/dist/client/assets/{empty-state-gxm2ae19.js → empty-state-BRx85n5e.js} +1 -1
- package/dist/client/assets/{env-vars-editor-yjQPUZEB.js → env-vars-editor-7rdGUbIW.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BNaNV9nd.js → extract-connection-data-C3TnWHFq.js} +1 -1
- package/dist/client/assets/{file-browser-B_w2Fo8g.js → file-browser-B6_JSvky.js} +2 -2
- package/dist/client/assets/{form-BZ8a73CT.js → form-yfGhYWGK.js} +1 -1
- package/dist/client/assets/{general-Cc0MmTIr.js → general-BO87mKaj.js} +1 -1
- package/dist/client/assets/{grid-view-v7BeOJyM.js → grid-view-CafNEeZS.js} +1 -1
- package/dist/client/assets/{home-BzMyuOsP.js → home-DODydEdy.js} +1 -1
- package/dist/client/assets/{icon-picker-BE1LYrai.js → icon-picker-BxryrKdj.js} +1 -1
- package/dist/client/assets/{index-DAa3pAko.js → index-B9MYwIUx.js} +1 -1
- package/dist/client/assets/{index-k2FJks3Z.js → index-BE5cW0kh.js} +1 -1
- package/dist/client/assets/{index-DYvAXdYi.js → index-BxIsqm8s.js} +1 -1
- package/dist/client/assets/{index-C7H080jj.js → index-CPVHF3xw.js} +1 -1
- package/dist/client/assets/{index-Ci5ff0fv.js → index-Cay1thV-.js} +1 -1
- package/dist/client/assets/{index-CraS_LAN.js → index-Dk8Q7M5D.js} +1 -1
- package/dist/client/assets/{index-BbuvbhcC.js → index-PEK2-Gur.js} +3 -3
- package/dist/client/assets/{index-BZFrXICm.js → index-cyFdlvvQ.js} +1 -1
- package/dist/client/assets/{index-ZHLggT8x.js → index-xpVnmlVH.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-H81V3tWZ.js → infiniteQueryObserver-C6bi1NMJ.js} +1 -1
- package/dist/client/assets/{input-3waZIRG0.js → input-sgdy4h-T.js} +1 -1
- package/dist/client/assets/{integration-icon-Cso-M9or.js → integration-icon-CF_VTof8.js} +1 -1
- package/dist/client/assets/{label-DHJ1lML9.js → label-BrZsvi2a.js} +1 -1
- package/dist/client/assets/{layout-DyxVovYn.js → layout-BIum7cxT.js} +1 -1
- package/dist/client/assets/{layout-BHXH71-a.js → layout-CV1aMVHy.js} +1 -1
- package/dist/client/assets/{localstorage-keys-D_Pd-WOH.js → localstorage-keys-F1lq-lvV.js} +1 -1
- package/dist/client/assets/{login-DloCSWP8.js → login-DW4fba0v.js} +1 -1
- package/dist/client/assets/{markdown-CtTTB3CC.js → markdown-CbEbvbZf.js} +1 -1
- package/dist/client/assets/{mcp-app-renderer-Co9vbSF6.js → mcp-app-renderer-C_3fiOtj.js} +1 -1
- package/dist/client/assets/{mcp-oauth-B58ki0is.js → mcp-oauth-6xg1H94l.js} +1 -1
- package/dist/client/assets/{mcp-server-card-eRzuABKg.js → mcp-server-card-CWDv948O.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-BozIkCLL.js → mcp-server-detail-tO42oFY4.js} +2 -2
- package/dist/client/assets/{members-CADVAEuM.js → members-DKDzvaot.js} +1 -1
- package/dist/client/assets/{monaco-editor-Sh_ObU6G.js → monaco-editor-B-R8mcTi.js} +1 -1
- package/dist/client/assets/{monitoring-B0LVSOhy.js → monitoring-X0-0osFY.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-edit-CDUoT798.js → monitoring-dashboard-edit-rOc8ctLL.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-view-BL3JEgeZ.js → monitoring-dashboard-view-BOcU-Ptb.js} +1 -1
- package/dist/client/assets/{oauth-callback-BhfjTfmd.js → oauth-callback-Dt0Z_xAu.js} +1 -1
- package/dist/client/assets/{page-BdA5uaoQ.js → page-Bg_wbn7m.js} +1 -1
- package/dist/client/assets/{page-9bMuozxf.js → page-C2NqyE1l.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-BXHHXNws.js → plugin-empty-state-BA7ocyXk.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-DBZCiMWm.js → plugin-empty-state-yRJgz3Tr.js} +1 -1
- package/dist/client/assets/{plugin-header-Cbca13kt.js → plugin-header-BDXHoMCR.js} +1 -1
- package/dist/client/assets/{plugin-header-BzUhEBbJ.js → plugin-header-BjlvBkY0.js} +1 -1
- package/dist/client/assets/plugins-C2IeqTZD.js +1 -0
- package/dist/client/assets/{popover-CWJLt_uV.js → popover-W_pvoCtS.js} +1 -1
- package/dist/client/assets/{project-app-view-CJfYPzV-.js → project-app-view-0TT6VGtD.js} +1 -1
- package/dist/client/assets/{project-layout-P4eKM-Ti.js → project-layout-EE8sGSdV.js} +1 -1
- package/dist/client/assets/{project-plugins-CMEcmqQp.js → project-plugins-CUoGWXtV.js} +1 -1
- package/dist/client/assets/{projects-list-D66u7j5e.js → projects-list-bUHr7Hxj.js} +1 -1
- package/dist/client/assets/{readme-viewer-CVTlRXwe.js → readme-viewer-udR9CDuh.js} +1 -1
- package/dist/client/assets/{registry-layout-DzvCTbrR.js → registry-layout-DDBt9uFS.js} +1 -1
- package/dist/client/assets/{registry-utils-C5IK-CtX.js → registry-utils-BUxN-Xyw.js} +1 -1
- package/dist/client/assets/{reports-layout-DnkfeNb1.js → reports-layout-CCWEuXOO.js} +1 -1
- package/dist/client/assets/{reset-password-CFsJBYwB.js → reset-password-Cm4-0xVl.js} +1 -1
- package/dist/client/assets/{resizable-Cep1sUzM.js → resizable-B67Be6M0.js} +1 -1
- package/dist/client/assets/{save-actions-D4UE0JTc.js → save-actions-FUGEGF6q.js} +1 -1
- package/dist/client/assets/{scroll-area-D6XeyTsR.js → scroll-area-CK7vwAfQ.js} +1 -1
- package/dist/client/assets/{select-DPbkZ4ar.js → select-C05ByfCe.js} +1 -1
- package/dist/client/assets/{shell-layout-oqyow6pO.js → shell-layout-DTEZojRn.js} +2 -2
- package/dist/client/assets/{sidebar-settings-D-TgpFWp.js → sidebar-settings-Dcd14gbU.js} +1 -1
- package/dist/client/assets/{skeleton-B38orBov.js → skeleton-UoFZ21oo.js} +1 -1
- package/dist/client/assets/{spinner-BNG3N_t6.js → spinner-BGQowtes.js} +1 -1
- package/dist/client/assets/{store-invite-CFW94lsm.js → store-invite-Cq-AwKEe.js} +1 -1
- package/dist/client/assets/{switch-D6sm-Y-R.js → switch-Q4KewAfm.js} +1 -1
- package/dist/client/assets/{table-BvLxXDfn.js → table-X8r3lDFL.js} +1 -1
- package/dist/client/assets/{tabs-nWDaFSMc.js → tabs-B8_PkbMO.js} +1 -1
- package/dist/client/assets/tasks-BvxRdrj9.js +1 -0
- package/dist/client/assets/{tasks-panel-BdQX0uim.js → tasks-panel-CC3yneqS.js} +1 -1
- package/dist/client/assets/{textarea-p_mS6xX2.js → textarea-pi2cWSId.js} +1 -1
- package/dist/client/assets/{time-range-picker-j0144Jvi.js → time-range-picker-BrfuDGgP.js} +1 -1
- package/dist/client/assets/{toggle-group-DVsMubxS.js → toggle-group-BhefXfHG.js} +1 -1
- package/dist/client/assets/{tools-list-rtd0HPYN.js → tools-list-MmMBTqrs.js} +1 -1
- package/dist/client/assets/{tooltip-CsJI985k.js → tooltip-CWYwrzX7.js} +1 -1
- package/dist/client/assets/{topbar-portal-C-eYDvnC.js → topbar-portal-RlfRVDuU.js} +1 -1
- package/dist/client/assets/{types-BS1D50tN.js → types-DfAuQBsH.js} +1 -1
- package/dist/client/assets/{use-binding-BxaStPuI.js → use-binding-bR1unh0d.js} +1 -1
- package/dist/client/assets/{use-collections-C3ir-ysk.js → use-collections-CdWUwl8U.js} +1 -1
- package/dist/client/assets/{use-connection-CMXOVbJV.js → use-connection-Cknhz6to.js} +1 -1
- package/dist/client/assets/{use-copy-B9IZm0yW.js → use-copy-2ZhzXjqK.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-D-mfuBxt.js → use-create-virtual-mcp-DtdhklAc.js} +1 -1
- package/dist/client/assets/{use-install-from-registry-BZO6gquV.js → use-install-from-registry-BzL8TqTO.js} +1 -1
- package/dist/client/assets/{use-list-state-BIMMDA8z.js → use-list-state-BFxcsMHC.js} +1 -1
- package/dist/client/assets/{use-llm-BYjz4dgp.js → use-llm-D6vMdIHx.js} +1 -1
- package/dist/client/assets/{use-mcp-resources-C28CMUKd.js → use-mcp-resources-V7_1ln1p.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-DGxTCxiy.js → use-mcp-tools-BMktygYP.js} +1 -1
- package/dist/client/assets/{use-members-dt37d3hU.js → use-members-CZzrsjqR.js} +1 -1
- package/dist/client/assets/{use-mobile-sCOjBNgX.js → use-mobile-DqFS2tGv.js} +1 -1
- package/dist/client/assets/{use-project-BdYSYYtQ.js → use-project-mIp9moJF.js} +1 -1
- package/dist/client/assets/{use-settings-modal-BfZ6-wC3.js → use-settings-modal-CK97wy3L.js} +1 -1
- package/dist/client/assets/{use-view-mode-oKsffCkq.js → use-view-mode-CkSeKCK_.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-BfsjEQwH.js → use-virtual-mcp-DncJVsC2.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-l2zBIMez.js +1 -0
- package/dist/client/assets/{useMutation-DlDipIME.js → useMutation-Bwc-v8Ow.js} +1 -1
- package/dist/client/assets/useQuery-C84LCuAf.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-B9Fj3djj.js +1 -0
- package/dist/client/assets/{user-LUr-tC3q.js → user-CLAm4Myt.js} +1 -1
- package/dist/client/assets/{workflow-rge1swVl.js → workflow-BuPqeBHK.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/constants-uhhGmW7q.js +0 -1
- package/dist/client/assets/plugins-BErYCDQ8.js +0 -1
- package/dist/client/assets/tasks-CjpbWRoG.js +0 -1
- package/dist/client/assets/useInfiniteQuery-WbErrTJi.js +0 -1
- package/dist/client/assets/useQuery-DSSFwRKz.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-BPe_aSZI.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as y,m as p}from"./index-
|
|
1
|
+
import{c as y,m as p}from"./index-PEK2-Gur.js";import{u as q}from"./useQuery-C84LCuAf.js";import{u as C}from"./useMutation-Bwc-v8Ow.js";import{K as T}from"./constants-9aDFHfpv.js";function w(r){const e=y.c(12);let t,s;e[0]!==r?({client:t,...s}=r,e[0]=r,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let o;e[5]!==t?(o=async()=>await t.listTools(),e[5]=t,e[6]=o):o=e[6];const i=s.staleTime??3e4;let n;return e[7]!==s||e[8]!==l||e[9]!==o||e[10]!==i?(n={...s,queryKey:l,queryFn:o,staleTime:i,retry:!1},e[7]=s,e[8]=l,e[9]=o,e[10]=i,e[11]=n):n=e[11],p(n)}function F(r){const e=y.c(12);let t,s;e[0]!==r?({client:t,...s}=r,e[0]=r,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let o;e[5]!==t?(o=async()=>await t.listTools(),e[5]=t,e[6]=o):o=e[6];const i=s.staleTime??3e4;let n;return e[7]!==s||e[8]!==l||e[9]!==o||e[10]!==i?(n={...s,queryKey:l,queryFn:o,staleTime:i,retry:!1},e[7]=s,e[8]=l,e[9]=o,e[10]=i,e[11]=n):n=e[11],q(n)}function P(r){const e=y.c(21);let t,s,l,o;e[0]!==r?({client:t,toolName:o,toolArguments:l,...s}=r,e[0]=r,e[1]=t,e[2]=s,e[3]=l,e[4]=o):(t=e[1],s=e[2],l=e[3],o=e[4]);let i,n,u;if(e[5]!==t||e[6]!==s||e[7]!==l||e[8]!==o){const m=JSON.stringify(l??{});u=p,i=s,n=T.mcpToolCall(t,o,m),e[5]=t,e[6]=s,e[7]=l,e[8]=o,e[9]=i,e[10]=n,e[11]=u}else i=e[9],n=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==o?(a=async()=>await t.callTool({name:o,arguments:l}),e[12]=t,e[13]=l,e[14]=o,e[15]=a):a=e[15];const f=s.staleTime??3e4;let c;return e[16]!==i||e[17]!==n||e[18]!==a||e[19]!==f?(c={...i,queryKey:n,queryFn:a,staleTime:f,retry:!1},e[16]=i,e[17]=n,e[18]=a,e[19]=f,e[20]=c):c=e[20],u(c)}function $(r){const e=y.c(21);let t,s,l,o;e[0]!==r?({client:t,toolName:o,toolArguments:l,...s}=r,e[0]=r,e[1]=t,e[2]=s,e[3]=l,e[4]=o):(t=e[1],s=e[2],l=e[3],o=e[4]);let i,n,u;if(e[5]!==t||e[6]!==s||e[7]!==l||e[8]!==o){const m=JSON.stringify(l??{});u=q,i=s,n=T.mcpToolCall(t,o,m),e[5]=t,e[6]=s,e[7]=l,e[8]=o,e[9]=i,e[10]=n,e[11]=u}else i=e[9],n=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==o?(a=async()=>await t.callTool({name:o,arguments:l}),e[12]=t,e[13]=l,e[14]=o,e[15]=a):a=e[15];const f=s.staleTime??3e4;let c;return e[16]!==i||e[17]!==n||e[18]!==a||e[19]!==f?(c={...i,queryKey:n,queryFn:a,staleTime:f,retry:!1},e[16]=i,e[17]=n,e[18]=a,e[19]=f,e[20]=c):c=e[20],u(c)}function L(r){const e=y.c(8);let t,s;e[0]!==r?({client:t,...s}=r,e[0]=r,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let l;e[3]!==t?(l=async i=>await t.callTool(i),e[3]=t,e[4]=l):l=e[4];let o;return e[5]!==s||e[6]!==l?(o={...s,mutationFn:l},e[5]=s,e[6]=l,e[7]=o):o=e[7],C(o)}export{L as a,$ as b,w as c,F as d,P as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as n,u as o,m as u,K as i,d as a}from"./index-
|
|
1
|
+
import{c as n,u as o,m as u,K as i,d as a}from"./index-PEK2-Gur.js";function l(){const e=n.c(4),{locator:r}=o();let t;e[0]!==r?(t=i.members(r),e[0]=r,e[1]=t):t=e[1];let s;return e[2]!==t?(s={queryKey:t,queryFn:m},e[2]=t,e[3]=s):s=e[3],u(s)}function m(){return a.organization.listMembers()}export{l as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as m,r}from"./index-
|
|
1
|
+
import{c as m,r}from"./index-PEK2-Gur.js";const a=768,o=()=>globalThis.innerWidth<a;function u(){const e=m.c(2),[l,n]=r.useState(o);let t,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=()=>{const i=()=>n(o),c=globalThis.matchMedia(`(max-width: ${a-1}px)`);return c.addEventListener("change",i),n(o),()=>c.removeEventListener("change",i)},s=[],e[0]=t,e[1]=s):(t=e[0],s=e[1]),r.useEffect(t,s),l}export{u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as m,c as C,m as T}from"./index-
|
|
1
|
+
import{K as m,c as C,m as T}from"./index-PEK2-Gur.js";import{u as y}from"./useQuery-C84LCuAf.js";import{u as f,a}from"./constants-9aDFHfpv.js";function S(t,s){const e=C.c(13);let r;e[0]!==t?(r={connectionId:a,orgId:t},e[0]=t,e[1]=r):r=e[1];const l=f(r);let u;e[2]!==t||e[3]!==s?(u=m.project(t,s),e[2]=t,e[3]=s,e[4]=u):u=e[4];let c;e[5]!==l||e[6]!==t||e[7]!==s?(c=async()=>{const p=await l.callTool({name:"PROJECT_GET",arguments:{organizationId:t,slug:s}});return(p.structuredContent??p).project},e[5]=l,e[6]=t,e[7]=s,e[8]=c):c=e[8];const o=!!t&&!!s;let n;return e[9]!==u||e[10]!==c||e[11]!==o?(n={queryKey:u,queryFn:c,enabled:o,staleTime:3e4},e[9]=u,e[10]=c,e[11]=o,e[12]=n):n=e[12],y(n)}function _(t,s){const e=f({connectionId:a,orgId:t}),r={queryKey:m.projects(t),queryFn:async()=>{const l=await e.callTool({name:"PROJECT_LIST",arguments:{organizationId:t}});return(l.structuredContent??l).projects.map(c=>({...c,organizationId:t}))},staleTime:3e4};return s?.suspense?T(r):y({...r,enabled:!!t})}export{_ as a,S as u};
|
package/dist/client/assets/{use-settings-modal-BfZ6-wC3.js → use-settings-modal-CK97wy3L.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as g,c as v,b as C,a as k,e as E}from"./index-
|
|
1
|
+
import{r as g,c as v,b as C,a as k,e as E}from"./index-PEK2-Gur.js";const x=({size:e=24,color:t="currentColor",...s})=>g.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},g.createElement("path",{d:"M15 21v-5.4c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C14.24 14 13.96 14 13.4 14h-2.8c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C9 14.76 9 15.04 9 15.6V21M3 7a3 3 0 0 0 6 0 3 3 0 1 0 6 0 3 3 0 1 0 6 0M6.2 21h11.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C21 19.48 21 18.92 21 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C19.48 3 18.92 3 17.8 3H6.2c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C3 4.52 3 5.08 3 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C4.52 21 5.08 21 6.2 21Z"}));x.displayName="Building02";const M=({size:e=24,color:t="currentColor",...s})=>g.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},g.createElement("path",{d:"M15.938 15.938A7.001 7.001 0 0 0 15 2a7.001 7.001 0 0 0-6.938 6.062M16 15a7 7 0 1 1-14 0 7 7 0 0 1 14 0Z"}));M.displayName="Coins01";const j=new Set(["account.profile","account.preferences","account.experimental","org.general","org.plugins","org.billing"]);function w(e){return e?j.has(e):!1}function _(){const e=v.c(17),t=C();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={strict:!1},e[0]=s):s=e[0];const r=k(s);let i;e[1]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[1]=i):i=e[1];const{org:o,project:n}=E(i);let c;e[2]!==r.settings?(c=w(r.settings)?r.settings:void 0,e[2]=r.settings,e[3]=c):c=e[3];const m=c,p=!!m;let a;e[4]!==t||e[5]!==o||e[6]!==n?(a=S=>{!o||!n||t({to:"/$org/$project",params:{org:o,project:n},search:{settings:S}})},e[4]=t,e[5]=o,e[6]=n,e[7]=a):a=e[7];const f=a;let l;e[8]!==t||e[9]!==o||e[10]!==n?(l=()=>{!o||!n||t({to:"/$org/$project",params:{org:o,project:n},search:{}})},e[8]=t,e[9]=o,e[10]=n,e[11]=l):l=e[11];const h=l,d=m??"account.preferences";let u;return e[12]!==h||e[13]!==p||e[14]!==f||e[15]!==d?(u={isOpen:p,activeSection:d,open:f,close:h},e[12]=h,e[13]=p,e[14]=f,e[15]=d,e[16]=u):u=e[16],u}export{M as i,x as t,_ as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as p,r as f}from"./index-
|
|
1
|
+
import{c as p,r as f}from"./index-PEK2-Gur.js";import{u as w}from"./use-mobile-DqFS2tGv.js";function S(m,M){const e=p.c(12),u=M===void 0?"cards":M,o=w(),b=f.useRef(o),s=m?`deco-view-mode-${m}`:"deco-view-mode";let i;e[0]!==u||e[1]!==s?(i=()=>{const r=globalThis.localStorage?.getItem(s);return r==="cards"||r==="table"?r:u},e[0]=u,e[1]=s,e[2]=i):i=e[2];const[t,g]=f.useState(i);let l;e[3]!==s?(l=r=>{g(r),globalThis.localStorage?.setItem(s,r)},e[3]=s,e[4]=l):l=e[4];const d=l;let c,a;e[5]!==o||e[6]!==t?(c=()=>{!b.current&&o&&t==="table"&&g("cards"),b.current=o},a=[o,t],e[5]=o,e[6]=t,e[7]=c,e[8]=a):(c=e[7],a=e[8]),f.useEffect(c,a);let n;return e[9]!==d||e[10]!==t?(n=[t,d],e[9]=d,e[10]=t,e[11]=n):n=e[11],n}export{S as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c,u as r}from"./index-
|
|
1
|
+
import{c,u as r}from"./index-PEK2-Gur.js";import{e as a,u as C,d as I}from"./use-collections-CdWUwl8U.js";import{a as l,u}from"./constants-9aDFHfpv.js";function m(i){const t=c.c(4);let o;t[0]!==i?(o=i===void 0?{}:i,t[0]=i,t[1]=o):o=t[1];const n=o,{org:e}=r();let s;t[2]!==e.id?(s={connectionId:l,orgId:e.id},t[2]=e.id,t[3]=s):s=t[3];const d=u(s);return a(e.id,"VIRTUAL_MCP",d,n)}function V(i){const t=c.c(2),{org:o}=r();let n;t[0]!==o.id?(n={connectionId:l,orgId:o.id},t[0]=o.id,t[1]=n):n=t[1];const e=u(n);return I(o.id,"VIRTUAL_MCP",i??void 0,e)}function p(){const i=c.c(2),{org:t}=r();let o;i[0]!==t.id?(o={connectionId:l,orgId:t.id},i[0]=t.id,i[1]=o):o=i[1];const n=u(o);return C(t.id,"VIRTUAL_MCP",n)}export{p as a,m as b,V as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as u}from"./infiniteQueryObserver-C6bi1NMJ.js";import{$ as i}from"./index-PEK2-Gur.js";function t(e,r){return i(e,u,r)}export{t as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aP as l,aQ as p,aR as n,aS as d,aT as h,n as b,r as o,aU as m,aV as f}from"./index-
|
|
1
|
+
import{aP as l,aQ as p,aR as n,aS as d,aT as h,n as b,r as o,aU as m,aV as f}from"./index-PEK2-Gur.js";var v=class extends l{#s;#i=void 0;#t;#e;constructor(t,s){super(),this.#s=t,this.setOptions(s),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const s=this.options;this.options=this.#s.defaultMutationOptions(t),p(this.options,s)||this.#s.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#t,observer:this}),s?.mutationKey&&this.options.mutationKey&&n(s.mutationKey)!==n(this.options.mutationKey)?this.reset():this.#t?.state.status==="pending"&&this.#t.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#t?.removeObserver(this)}onMutationUpdate(t){this.#r(),this.#o(t)}getCurrentResult(){return this.#i}reset(){this.#t?.removeObserver(this),this.#t=void 0,this.#r(),this.#o()}mutate(t,s){return this.#e=s,this.#t?.removeObserver(this),this.#t=this.#s.getMutationCache().build(this.#s,this.options),this.#t.addObserver(this),this.#t.execute(t)}#r(){const t=this.#t?.state??d();this.#i={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#o(t){h.batch(()=>{if(this.#e&&this.hasListeners()){const s=this.#i.variables,i=this.#i.context,e={client:this.#s,meta:this.options.meta,mutationKey:this.options.mutationKey};t?.type==="success"?(this.#e.onSuccess?.(t.data,s,i,e),this.#e.onSettled?.(t.data,null,s,i,e)):t?.type==="error"&&(this.#e.onError?.(t.error,s,i,e),this.#e.onSettled?.(void 0,t.error,s,i,e))}this.listeners.forEach(s=>{s(this.#i)})})}};function O(t,s){const i=b(s),[e]=o.useState(()=>new v(i,t));o.useEffect(()=>{e.setOptions(t)},[e,t]);const r=o.useSyncExternalStore(o.useCallback(a=>e.subscribe(h.batchCalls(a)),[e]),()=>e.getCurrentResult(),()=>e.getCurrentResult()),u=o.useCallback((a,c)=>{e.mutate(a,c).catch(m)},[e]);if(r.error&&f(e.options.throwOnError,[r.error]))throw r.error;return{...r,mutate:u,mutateAsync:r.mutate}}export{O as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as u,a6 as s}from"./index-PEK2-Gur.js";function o(e,r){return u(e,s,r)}export{o as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{I as s}from"./infiniteQueryObserver-C6bi1NMJ.js";import{$ as u,a0 as n}from"./index-PEK2-Gur.js";function a(r,e){return u({...r,enabled:!0,suspense:!0,throwOnError:n},s,e)}export{a as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as w,u as C,K as S,v as y,j as t}from"./index-
|
|
1
|
+
import{c as w,u as C,K as S,v as y,j as t}from"./index-PEK2-Gur.js";import{A as E}from"./avatar-7hY_H5zt.js";import{u as k}from"./useQuery-C84LCuAf.js";import{a as A,u as _}from"./constants-9aDFHfpv.js";function K(m){const e=w.c(11),{org:h}=C();let x;e[0]!==h.id?(x={connectionId:A,orgId:h.id},e[0]=h.id,e[1]=x):x=e[1];const u=_(x);let d;e[2]!==m?(d=S.user(m),e[2]=m,e[3]=d):d=e[3];let s;e[4]!==u||e[5]!==m?(s=async()=>{const r=await u.callTool({name:"USER_GET",arguments:{id:m}});return(r.structuredContent??r).user},e[4]=u,e[5]=m,e[6]=s):s=e[6];const l=!!m;let o;return e[7]!==d||e[8]!==s||e[9]!==l?(o={queryKey:d,queryFn:s,staleTime:3e5,retry:1,enabled:l},e[7]=d,e[8]=s,e[9]=l,e[10]=o):o=e[10],k(o)}function q(m){const e=w.c(36),{id:h,size:x,showEmail:u,avatarOnly:d,className:s}=m,l=x===void 0?"xs":x,o=u===void 0?!1:u,r=d===void 0?!1:d,{data:c,isLoading:U,isError:b}=K(h);if(U){let a;e[0]!==s?(a=y("flex items-center gap-2",s),e[0]=s,e[1]=a):a=e[1];let i;e[2]!==l?(i=t.jsx(E.Skeleton,{shape:"circle",size:l}),e[2]=l,e[3]=i):i=e[3];let n;e[4]!==r||e[5]!==o?(n=!r&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"h-3 w-24 bg-muted animate-pulse rounded"}),o&&t.jsx("div",{className:"h-2 w-32 bg-muted animate-pulse rounded"})]}),e[4]=r,e[5]=o,e[6]=n):n=e[6];let f;return e[7]!==a||e[8]!==i||e[9]!==n?(f=t.jsxs("div",{className:a,children:[i,n]}),e[7]=a,e[8]=i,e[9]=n,e[10]=f):f=e[10],f}if(b||!c){let a;e[11]!==s?(a=y("flex items-center gap-2",s),e[11]=s,e[12]=a):a=e[12];let i;e[13]!==l?(i=t.jsx(E,{shape:"circle",size:l,fallback:"?",muted:!0}),e[13]=l,e[14]=i):i=e[14];let n;e[15]!==r?(n=!r&&t.jsx("div",{className:"flex flex-col",children:t.jsx("div",{className:"text-sm text-muted-foreground",children:"Unknown User"})}),e[15]=r,e[16]=n):n=e[16];let f;return e[17]!==a||e[18]!==i||e[19]!==n?(f=t.jsxs("div",{className:a,children:[i,n]}),e[17]=a,e[18]=i,e[19]=n,e[20]=f):f=e[20],f}let p;e[21]!==s?(p=y("flex items-center gap-2",s),e[21]=s,e[22]=p):p=e[22];const N=c.image??void 0;let v;e[23]!==l||e[24]!==N||e[25]!==c.name?(v=t.jsx(E,{shape:"circle",size:l,url:N,fallback:c.name}),e[23]=l,e[24]=N,e[25]=c.name,e[26]=v):v=e[26];let j;e[27]!==r||e[28]!==o||e[29]!==c.email||e[30]!==c.name?(j=!r&&t.jsxs("div",{className:"flex flex-col",children:[t.jsx("div",{className:"text-sm font-medium",children:c.name}),o&&t.jsx("div",{className:"text-xs text-muted-foreground",children:c.email})]}),e[27]=r,e[28]=o,e[29]=c.email,e[30]=c.name,e[31]=j):j=e[31];let g;return e[32]!==p||e[33]!==v||e[34]!==j?(g=t.jsxs("div",{className:p,children:[v,j]}),e[32]=p,e[33]=v,e[34]=j,e[35]=g):g=e[35],g}export{q as U};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as g,u as C,n as W,K as x,t as _,j as i,B as I}from"./index-
|
|
1
|
+
import{c as g,u as C,n as W,K as x,t as _,j as i,B as I}from"./index-PEK2-Gur.js";import{a as w,u as L}from"./constants-9aDFHfpv.js";import{C as k}from"./collection-tab-Dq2y4UTN.js";import{E as O}from"./collection-search-BVMX34xh.js";import{u as S}from"./useMutation-Bwc-v8Ow.js";import{P as u}from"./index-CPVHF3xw.js";import{B as b,a as h,b as P,c as y}from"./breadcrumb-DZJzQEPd.js";import{e as T}from"./Dataflow03-Cz5aNZkd.js";import"./generate-id-Dyweu44Y.js";import"./collection-display-button-CVVCR82C.js";import"./dropdown-menu-CxuRGQYq.js";import"./Check-Camn3oQw.js";import"./ChevronRight-BI34N28O.js";import"./ArrowDown-BYesfwXe.js";import"./ArrowUp-BCyv-ojK.js";import"./Grid01-CTYtPHN4.js";import"./List-DXD0Q-rz.js";import"./tooltip-CWYwrzX7.js";import"./index-xpVnmlVH.js";import"./badge-DfhuIA_7.js";import"./card-DXg2GX79.js";import"./integration-icon-CF_VTof8.js";import"./Container-B8pG1v5Y.js";import"./Copy01-GXSpNbxP.js";import"./DotsVertical-DgG2OQVv.js";import"./Edit01-nsEjgwmh.js";import"./Eye-DQF_Qzuy.js";import"./Trash01-CAKaaYMp.js";import"./collection-table-wrapper-C0TGGJ6J.js";import"./table-X8r3lDFL.js";import"./empty-state-BRx85n5e.js";import"./Inbox01-DTh-ZtU7.js";import"./user-CLAm4Myt.js";import"./avatar-7hY_H5zt.js";import"./useQuery-C84LCuAf.js";import"./use-list-state-BFxcsMHC.js";import"./use-view-mode-CkSeKCK_.js";import"./use-mobile-DqFS2tGv.js";import"./constants-C6iMC3JV.js";import"./alert-dialog-CtNI8LvE.js";import"./use-collections-CdWUwl8U.js";import"./Plus-BaoKmylk.js";import"./layout-BIum7cxT.js";import"./Loading01-HszUOya-.js";import"./SearchMd-3WCi1VDc.js";import"./input-sgdy4h-T.js";import"./localstorage-keys-F1lq-lvV.js";function B(){const e=g.c(12),{org:t,project:r}=C(),a=W();let c;e[0]!==t.id?(c={connectionId:w,orgId:t.id},e[0]=t.id,e[1]=c):c=e[1];const l=L(c);let o;e[2]!==l||e[3]!==r?(o=async d=>{const m=r.enabledPlugins??[];if(m.includes(d))return;const p=[...m,d],j=await l.callTool({name:"PROJECT_UPDATE",arguments:{projectId:r.id,enabledPlugins:p}});return j.structuredContent??j},e[2]=l,e[3]=r,e[4]=o):o=e[4];let n;e[5]!==t.id||e[6]!==r||e[7]!==a?(n=()=>{a.invalidateQueries({queryKey:x.project(t.id,r.slug)}),a.invalidateQueries({queryKey:x.projects(t.id)})},e[5]=t.id,e[6]=r,e[7]=a,e[8]=n):n=e[8];let s;return e[9]!==o||e[10]!==n?(s={mutationFn:o,onSuccess:n,onError:K},e[9]=o,e[10]=n,e[11]=s):s=e[11],S(s)}function K(e){_.error("Failed to enable plugin: "+(e instanceof Error?e.message:"Unknown error"))}function N(e){const t=g.c(12),{pluginId:r,title:a,description:c,icon:l}=e,o=B();let n;t[0]!==o||t[1]!==r?(n=async()=>{try{await o.mutateAsync(r),_.success("Plugin enabled!")}catch{}},t[0]=o,t[1]=r,t[2]=n):n=t[2];const s=n,f=l??null,d=o.isPending?"Enabling…":"Enable plugin";let m;t[3]!==o.isPending||t[4]!==s||t[5]!==d?(m=i.jsx(I,{onClick:s,disabled:o.isPending,children:d}),t[3]=o.isPending,t[4]=s,t[5]=d,t[6]=m):m=t[6];let p;return t[7]!==c||t[8]!==f||t[9]!==m||t[10]!==a?(p=i.jsx(O,{image:f,title:a,description:c,actions:m}),t[7]=c,t[8]=f,t[9]=m,t[10]=a,t[11]=p):p=t[11],p}const E="workflows",F={name:"WORKFLOW",displayName:"Workflow",hasCreateTool:!0,hasUpdateTool:!0,hasDeleteTool:!0};function Se(){const e=g.c(5),{project:t,org:r}=C();if(!(t.enabledPlugins??[]).includes(E)){let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(u.Header,{children:i.jsx(u.Header.Left,{children:i.jsx(b,{children:i.jsx(h,{children:i.jsx(P,{children:i.jsx(y,{children:"Workflows"})})})})})}),e[0]=n):n=e[0];let s;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=i.jsxs(u,{children:[n,i.jsx(u.Content,{children:i.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:i.jsx(N,{pluginId:E,title:"Enable Workflows",description:"Automate multi-step processes by enabling the Workflows plugin. Once enabled you can create, run, and monitor workflows.",icon:i.jsx("div",{className:"bg-muted p-4 rounded-full",children:i.jsx(T,{className:"size-8 text-muted-foreground"})})})})})]}),e[1]=s):s=e[1],s}let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=i.jsx(u.Header,{children:i.jsx(u.Header.Left,{children:i.jsx(b,{children:i.jsx(h,{children:i.jsx(P,{children:i.jsx(y,{children:"Workflows"})})})})})}),e[2]=l):l=e[2];let o;return e[3]!==r.slug?(o=i.jsxs(u,{children:[l,i.jsx(u.Content,{children:i.jsx(k,{connectionId:w,org:r.slug,activeCollection:F})})]}),e[3]=r.slug,e[4]=o):o=e[4],o}export{Se as default};
|
package/dist/client/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<title>MCP Mesh</title>
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
|
-
<script type="module" crossorigin src="/assets/index-
|
|
6
|
+
<script type="module" crossorigin src="/assets/index-PEK2-Gur.js"></script>
|
|
7
7
|
<link rel="stylesheet" crossorigin href="/assets/index-D6E08wfB.css">
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
package/dist/server/cli.js
CHANGED
|
@@ -1516,7 +1516,7 @@ ${Q.stack}`;return G}}catch{}if(typeof Q.toString==="function")try{let G=Q.toStr
|
|
|
1516
1516
|
`.execute(Y),J=new Set(X.rows.map((W)=>`${W.plugin_id}/${W.name}`)),G=new Map;for(let{pluginId:W,migration:Z}of Q){if(!G.has(W))G.set(W,[]);G.get(W).push({name:Z.name,up:Z.up})}let K=0;for(let[W,Z]of G){Z.sort((H,$)=>H.name.localeCompare($.name));for(let H of Z){let $=`${W}/${H.name}`;if(J.has($))continue;if(K===0)console.log("\uD83D\uDD0C Running plugin migrations...");K++,console.log(` Running: ${$}`),await H.up(Y);let F=new Date().toISOString();await EF`
|
|
1517
1517
|
INSERT INTO plugin_migrations (plugin_id, name, timestamp)
|
|
1518
1518
|
VALUES (${W}, ${H.name}, ${F})
|
|
1519
|
-
`.execute(Y)}}if(K>0)console.log(`\u2705 ${K} plugin migration(s) completed`)}async function ba0(Y,Q){await Sp6(Y,Q),await kp6(Y,Q);let X=new ya0({db:Y,provider:{getMigrations:()=>Promise.resolve(vx)}}),{error:J,results:G}=await X.migrateToLatest();if(G?.forEach((K)=>{if(K.status==="Success")console.log(`\u2705 Migration "${K.migrationName}" executed successfully`);else if(K.status==="Error")console.error(`\u274C Failed to execute migration "${K.migrationName}"`)}),J)throw console.error("Failed to migrate"),console.error(J),J}async function _p6(Y){let{keepOpen:Q=!1,database:X,skipBetterAuth:J=!1,seed:G}=Y??{};if(!J&&!X)await va0();let K=X??fD(),W=async()=>{if(!Q&&!X)console.log("\uD83D\uDD12 Closing database connection..."),await fj0(K).catch((Z)=>{console.warn("Warning: Error closing database:",Z)})};try{console.log("\uD83D\uDCCA Running Kysely migrations..."),await ba0(K.db,K.type),console.log("\uD83C\uDF89 Core migrations completed successfully"),await vp6(K.db);let Z;if(G)Z=await C91(K.db,G);return await W(),{seedResult:Z}}catch(Z){throw await W(),Z}}async function yp6(){let Y=fD(),Q=new ya0({db:Y.db,provider:{getMigrations:()=>Promise.resolve(vx)}}),{error:X,results:J}=await Q.migrateDown();if(J?.forEach((G)=>{if(G.status==="Success")console.log(`\u2705 Migration "${G.migrationName}" rolled back successfully`);else if(G.status==="Error")console.error(`\u274C Failed to rollback migration "${G.migrationName}"`)}),X)throw console.error("Failed to rollback migration"),console.error(X),X}var xa0=S(()=>{T91();rS1();_a0();Bv();PS()});var AX;var jP=S(()=>{AX=class extends Error{res;status;constructor(Y=500,Q){super(Q?.message,{cause:Q?.cause});this.res=Q?.res,this.status=Y}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}}});var ga0,fp6,bp6=(Y,Q)=>{if(!Y)return{};let X=new Headers(Y.headers);if(Q){let J=X.get("connection");if(J){let G=J.split(",").map((W)=>W.trim()),K=G.filter((W)=>!fp6.test(W));if(K.length>0)throw new AX(400,{message:`Invalid Connection header value: ${K.join(", ")}`});G.forEach((W)=>{X.delete(W)})}}return ga0.forEach((J)=>{X.delete(J)}),{method:Y.method,body:Y.body,duplex:Y.body?"half":void 0,headers:X,signal:Y.signal}},hp6=(Y)=>{if(!Y.headers||Array.isArray(Y.headers)||Y.headers instanceof Headers)return Y;let Q=new Headers;for(let[X,J]of Object.entries(Y.headers))if(J==null)Q.delete(X);else Q.set(X,J);return Y.headers=Q,Y},ua0=async(Y,Q)=>{let{raw:X,customFetch:J,strictConnectionProcessing:G=!1,...K}=Q instanceof Request?{raw:Q}:Q??{},W=new Request(Y,{...bp6(X,G),...hp6(K)});W.headers.delete("accept-encoding");let Z=await(J||fetch)(W),H=new Headers(Z.headers);if(ga0.forEach(($)=>{H.delete($)}),H.has("content-encoding"))H.delete("content-encoding"),H.delete("content-length");return new Response(Z.body,{status:Z.status,statusText:Z.statusText,headers:H})};var ma0=S(()=>{jP();ga0=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade"],fp6=/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/});var la0=(Y)=>(Q)=>{let X=new URL(Q.req.raw.url),J=new URL(Y);return J.pathname=X.pathname,J.search=X.search,ua0(J,{raw:Q.req.raw,headers:{...Q.req.raw.headers}})};var da0=S(()=>{ma0()});import{resolve as kv,dirname as xp6,join as gp6,extname as up6,basename as mp6,sep as pa0}from"path";function lp6(Y,Q){if(Y===Q||mp6(Y)==="index.html")return{"Cache-Control":"no-cache"};if(Y.includes(`${pa0}assets${pa0}`))return{"Cache-Control":"public, max-age=31536000, immutable"};return{}}function cp6(Y,Q){let X=kv(Q),J=kv(Y);return J===X||J.startsWith(X+"/")}function np6({requestPath:Y,clientDir:Q}){let X=Y.startsWith("/")?Y.slice(1):Y,J=kv(Q,X);if(!cp6(J,Q))return null;return J}function ca0(Y,Q="../client"){let X=new URL(Y),J=xp6(X.pathname);return kv(J,Q)}function na0(Y={}){let{env:Q="production",devServerUrl:X=dp6,clientDir:J=pp6,isServerPath:G=()=>!1}=Y;if(Q==="development"){let K=la0(X);return async function(Z){let H=new URL(Z.url);if(G(H.pathname))return null;let $={req:{raw:Z,url:Z.url}};return K($)}}return async function(W){if(W.method!=="GET")return null;let Z=new URL(W.url),H;try{H=decodeURIComponent(Z.pathname)}catch{return null}if(G(H))return null;let $=np6({requestPath:H,clientDir:J});if(!$)return null;let F=gp6($,"index.html"),V=kv(J,"index.html"),B=W.headers.get("accept"),z=B?.includes("text/html")||B?.includes("*/*")&&["",".html"].includes(up6($))?[F,V]:[];for(let D of[$,...z])try{let L=Bun.file(D);if(await L.exists())return new Response(L,{headers:lp6(D,V)})}catch{}if(H.includes("/assets/"))return new Response("Not Found",{status:404,headers:{"Cache-Control":"no-store"}});return null}}var dp6,pp6="./dist/client";var ia0=S(()=>{da0();dp6=`http://localhost:${process.env.VITE_PORT||"4000"}`});function ra0(Y){if(!Y)return!1;try{return new URL(Y).host==="api.decocms.com"&&Y!=="https://api.decocms.com/mcp/registry"}catch{return!1}}var aa0="https://api.decocms.com/mcp/registry";var DL1=(Y,Q,X)=>{return(J,G)=>{let K=-1;return W(0);async function W(Z){if(Z<=K)throw Error("next() called multiple times");K=Z;let H,$=!1,F;if(Y[Z])F=Y[Z][0][0],J.req.routeIndex=Z;else F=Z===Y.length&&G||void 0;if(F)try{H=await F(J,()=>W(Z+1))}catch(V){if(V instanceof Error&&Q)J.error=V,H=await Q(V,J),$=!0;else throw V}else if(J.finalized===!1&&X)H=await X(J);if(H&&(J.finalized===!1||$))J.res=H;return J}}};var oa0=()=>{};var sa0;var ta0=S(()=>{sa0=Symbol()});async function ip6(Y,Q){let X=await Y.formData();if(X)return ap6(X,Q);return{}}function ap6(Y,Q){let X=Object.create(null);if(Y.forEach((J,G)=>{if(!(Q.all||G.endsWith("[]")))X[G]=J;else rp6(X,G,J)}),Q.dot)Object.entries(X).forEach(([J,G])=>{if(J.includes("."))op6(X,J,G),delete X[J]});return X}var ea0=async(Y,Q=Object.create(null))=>{let{all:X=!1,dot:J=!1}=Q,K=(Y instanceof yr?Y.raw.headers:Y.headers).get("Content-Type");if(K?.startsWith("multipart/form-data")||K?.startsWith("application/x-www-form-urlencoded"))return ip6(Y,{all:X,dot:J});return{}},rp6=(Y,Q,X)=>{if(Y[Q]!==void 0)if(Array.isArray(Y[Q]))Y[Q].push(X);else Y[Q]=[Y[Q],X];else if(!Q.endsWith("[]"))Y[Q]=X;else Y[Q]=[X]},op6=(Y,Q,X)=>{let J=Y,G=Q.split(".");G.forEach((K,W)=>{if(W===G.length-1)J[K]=X;else{if(!J[K]||typeof J[K]!=="object"||Array.isArray(J[K])||J[K]instanceof File)J[K]=Object.create(null);J=J[K]}})};var Yr0=S(()=>{OL1()});var LL1=(Y)=>{let Q=Y.split("/");if(Q[0]==="")Q.shift();return Q},Qr0=(Y)=>{let{groups:Q,path:X}=sp6(Y),J=LL1(X);return tp6(J,Q)},sp6=(Y)=>{let Q=[];return Y=Y.replace(/\{[^}]+\}/g,(X,J)=>{let G=`@${J}`;return Q.push([G,X]),G}),{groups:Q,path:Y}},tp6=(Y,Q)=>{for(let X=Q.length-1;X>=0;X--){let[J]=Q[X];for(let G=Y.length-1;G>=0;G--)if(Y[G].includes(J)){Y[G]=Y[G].replace(J,Q[X][1]);break}}return Y},fr,Xr0=(Y,Q)=>{if(Y==="*")return"*";let X=Y.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(X){let J=`${Y}#${Q}`;if(!fr[J])if(X[2])fr[J]=Q&&Q[0]!==":"&&Q[0]!=="*"?[J,X[1],new RegExp(`^${X[2]}(?=/${Q})`)]:[Y,X[1],new RegExp(`^${X[2]}$`)];else fr[J]=[Y,X[1],!0];return fr[J]}return null},SP=(Y,Q)=>{try{return Q(Y)}catch{return Y.replace(/(?:%[0-9A-Fa-f]{2})+/g,(X)=>{try{return Q(X)}catch{return X}})}},ep6=(Y)=>SP(Y,decodeURI),ML1=(Y)=>{let Q=Y.url,X=Q.indexOf("/",Q.indexOf(":")+4),J=X;for(;J<Q.length;J++){let G=Q.charCodeAt(J);if(G===37){let K=Q.indexOf("?",J),W=Q.indexOf("#",J),Z=K===-1?W===-1?void 0:W:W===-1?K:Math.min(K,W),H=Q.slice(X,Z);return ep6(H.includes("%25")?H.replace(/%25/g,"%2525"):H)}else if(G===63||G===35)break}return Q.slice(X,J)},Jr0=(Y)=>{let Q=ML1(Y);return Q.length>1&&Q.at(-1)==="/"?Q.slice(0,-1):Q},PO=(Y,Q,...X)=>{if(X.length)Q=PO(Q,...X);return`${Y?.[0]==="/"?"":"/"}${Y}${Q==="/"?"":`${Y?.at(-1)==="/"?"":"/"}${Q?.[0]==="/"?Q.slice(1):Q}`}`},br=(Y)=>{if(Y.charCodeAt(Y.length-1)!==63||!Y.includes(":"))return null;let Q=Y.split("/"),X=[],J="";return Q.forEach((G)=>{if(G!==""&&!/\:/.test(G))J+="/"+G;else if(/\:/.test(G))if(/\?/.test(G)){if(X.length===0&&J==="")X.push("/");else X.push(J);let K=G.replace("?","");J+="/"+K,X.push(J)}else J+="/"+G}),X.filter((G,K,W)=>W.indexOf(G)===K)},NL1=(Y)=>{if(!/[%+]/.test(Y))return Y;if(Y.indexOf("+")!==-1)Y=Y.replace(/\+/g," ");return Y.indexOf("%")!==-1?SP(Y,vv):Y},Gr0=(Y,Q,X)=>{let J;if(!X&&Q&&!/[%+]/.test(Q)){let W=Y.indexOf("?",8);if(W===-1)return;if(!Y.startsWith(Q,W+1))W=Y.indexOf(`&${Q}`,W+1);while(W!==-1){let Z=Y.charCodeAt(W+Q.length+1);if(Z===61){let H=W+Q.length+2,$=Y.indexOf("&",H);return NL1(Y.slice(H,$===-1?void 0:$))}else if(Z==38||isNaN(Z))return"";W=Y.indexOf(`&${Q}`,W+1)}if(J=/[%+]/.test(Y),!J)return}let G={};J??=/[%+]/.test(Y);let K=Y.indexOf("?",8);while(K!==-1){let W=Y.indexOf("&",K+1),Z=Y.indexOf("=",K);if(Z>W&&W!==-1)Z=-1;let H=Y.slice(K+1,Z===-1?W===-1?void 0:W:Z);if(J)H=NL1(H);if(K=W,H==="")continue;let $;if(Z===-1)$="";else if($=Y.slice(Z+1,W===-1?void 0:W),J)$=NL1($);if(X){if(!(G[H]&&Array.isArray(G[H])))G[H]=[];G[H].push($)}else G[H]??=$}return Q?G[Q]:G},Wr0,Zr0=(Y,Q)=>{return Gr0(Y,Q,!0)},vv;var EO=S(()=>{fr={},Wr0=Gr0,vv=decodeURIComponent});var Kr0=(Y)=>SP(Y,vv),yr;var OL1=S(()=>{jP();ta0();Yr0();EO();yr=class{raw;#Y;#Q;routeIndex=0;path;bodyCache={};constructor(Y,Q="/",X=[[]]){this.raw=Y,this.path=Q,this.#Q=X,this.#Y={}}param(Y){return Y?this.#X(Y):this.#J()}#X(Y){let Q=this.#Q[0][this.routeIndex][1][Y],X=this.#W(Q);return X&&/\%/.test(X)?Kr0(X):X}#J(){let Y={},Q=Object.keys(this.#Q[0][this.routeIndex][1]);for(let X of Q){let J=this.#W(this.#Q[0][this.routeIndex][1][X]);if(J!==void 0)Y[X]=/\%/.test(J)?Kr0(J):J}return Y}#W(Y){return this.#Q[1]?this.#Q[1][Y]:Y}query(Y){return Wr0(this.url,Y)}queries(Y){return Zr0(this.url,Y)}header(Y){if(Y)return this.raw.headers.get(Y)??void 0;let Q={};return this.raw.headers.forEach((X,J)=>{Q[J]=X}),Q}async parseBody(Y){return this.bodyCache.parsedBody??=await ea0(this,Y)}#G=(Y)=>{let{bodyCache:Q,raw:X}=this,J=Q[Y];if(J)return J;let G=Object.keys(Q)[0];if(G)return Q[G].then((K)=>{if(G==="json")K=JSON.stringify(K);return new Response(K)[Y]()});return Q[Y]=X[Y]()};json(){return this.#G("text").then((Y)=>JSON.parse(Y))}text(){return this.#G("text")}arrayBuffer(){return this.#G("arrayBuffer")}blob(){return this.#G("blob")}formData(){return this.#G("formData")}addValidatedData(Y,Q){this.#Y[Y]=Q}valid(Y){return this.#Y[Y]}get url(){return this.raw.url}get method(){return this.raw.method}get[sa0](){return this.#Q}get matchedRoutes(){return this.#Q[0].map(([[,Y]])=>Y)}get routePath(){return this.#Q[0].map(([[,Y]])=>Y)[this.routeIndex].path}}});var hr,Yc6=(Y,Q)=>{let X=new String(Y);return X.isEscaped=!0,X.callbacks=Q,X},_v=async(Y,Q,X,J,G)=>{if(typeof Y==="object"&&!(Y instanceof String)){if(!(Y instanceof Promise))Y=Y.toString();if(Y instanceof Promise)Y=await Y}let K=Y.callbacks;if(!K?.length)return Promise.resolve(Y);if(G)G[0]+=Y;else G=[Y];let W=Promise.all(K.map((Z)=>Z({phase:Q,buffer:G,context:J}))).then((Z)=>Promise.all(Z.filter(Boolean).map((H)=>_v(H,Q,!1,J,G))).then(()=>G[0]));if(X)return Yc6(await W,K);else return W};var wL1=S(()=>{hr={Stringify:1,BeforeStream:2,Stream:3}});var Hr0="text/plain; charset=UTF-8",AL1=(Y,Q)=>{return{"Content-Type":Y,...Q}},yv=(Y,Q)=>new Response(Y,Q),$r0=class{#Y;#Q;env={};#X;finalized=!1;error;#J;#W;#G;#K;#Z;#$;#H;#V;#q;constructor(Y,Q){if(this.#Y=Y,Q)this.#W=Q.executionCtx,this.env=Q.env,this.#$=Q.notFoundHandler,this.#q=Q.path,this.#V=Q.matchResult}get req(){return this.#Q??=new yr(this.#Y,this.#q,this.#V),this.#Q}get event(){if(this.#W&&"respondWith"in this.#W)return this.#W;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#W)return this.#W;else throw Error("This context has no ExecutionContext")}get res(){return this.#G||=yv(null,{headers:this.#H??=new Headers})}set res(Y){if(this.#G&&Y){Y=yv(Y.body,Y);for(let[Q,X]of this.#G.headers.entries()){if(Q==="content-type")continue;if(Q==="set-cookie"){let J=this.#G.headers.getSetCookie();Y.headers.delete("set-cookie");for(let G of J)Y.headers.append("set-cookie",G)}else Y.headers.set(Q,X)}}this.#G=Y,this.finalized=!0}render=(...Y)=>{return this.#Z??=(Q)=>this.html(Q),this.#Z(...Y)};setLayout=(Y)=>this.#K=Y;getLayout=()=>this.#K;setRenderer=(Y)=>{this.#Z=Y};header=(Y,Q,X)=>{if(this.finalized)this.#G=yv(this.#G.body,this.#G);let J=this.#G?this.#G.headers:this.#H??=new Headers;if(Q===void 0)J.delete(Y);else if(X?.append)J.append(Y,Q);else J.set(Y,Q)};status=(Y)=>{this.#J=Y};set=(Y,Q)=>{this.#X??=new Map,this.#X.set(Y,Q)};get=(Y)=>{return this.#X?this.#X.get(Y):void 0};get var(){if(!this.#X)return{};return Object.fromEntries(this.#X)}#F(Y,Q,X){let J=this.#G?new Headers(this.#G.headers):this.#H??new Headers;if(typeof Q==="object"&&"headers"in Q){let K=Q.headers instanceof Headers?Q.headers:new Headers(Q.headers);for(let[W,Z]of K)if(W.toLowerCase()==="set-cookie")J.append(W,Z);else J.set(W,Z)}if(X)for(let[K,W]of Object.entries(X))if(typeof W==="string")J.set(K,W);else{J.delete(K);for(let Z of W)J.append(K,Z)}let G=typeof Q==="number"?Q:Q?.status??this.#J;return yv(Y,{status:G,headers:J})}newResponse=(...Y)=>this.#F(...Y);body=(Y,Q,X)=>this.#F(Y,Q,X);text=(Y,Q,X)=>{return!this.#H&&!this.#J&&!Q&&!X&&!this.finalized?new Response(Y):this.#F(Y,Q,AL1(Hr0,X))};json=(Y,Q,X)=>{return this.#F(JSON.stringify(Y),Q,AL1("application/json",X))};html=(Y,Q,X)=>{let J=(G)=>this.#F(G,Q,AL1("text/html; charset=UTF-8",X));return typeof Y==="object"?_v(Y,hr.Stringify,!1,{}).then(J):J(Y)};redirect=(Y,Q)=>{let X=String(Y);return this.header("Location",!/[^\x00-\xFF]/.test(X)?X:encodeURI(X)),this.newResponse(null,Q??302)};notFound=()=>{return this.#$??=()=>yv(),this.#$(this)}};var xr=S(()=>{OL1();wL1()});var n9="ALL",Fr0="all",Vr0,gr="Can not add a route since the matcher is already built.",ur;var TO=S(()=>{Vr0=["get","post","put","delete","options","patch"],ur=class extends Error{}});var qr0="__COMPOSED_HANDLER";var Br0=()=>{};var Qc6=(Y)=>{return Y.text("404 Not Found",404)},Ur0=(Y,Q)=>{if("getResponse"in Y){let X=Y.getResponse();return Q.newResponse(X.body,X)}return console.error(Y),Q.text("Internal Server Error",500)},zr0=class Y{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#Y="/";routes=[];constructor(Q={}){[...Vr0,Fr0].forEach((K)=>{this[K]=(W,...Z)=>{if(typeof W==="string")this.#Y=W;else this.#J(K,this.#Y,W);return Z.forEach((H)=>{this.#J(K,this.#Y,H)}),this}}),this.on=(K,W,...Z)=>{for(let H of[W].flat()){this.#Y=H;for(let $ of[K].flat())Z.map((F)=>{this.#J($.toUpperCase(),this.#Y,F)})}return this},this.use=(K,...W)=>{if(typeof K==="string")this.#Y=K;else this.#Y="*",W.unshift(K);return W.forEach((Z)=>{this.#J(n9,this.#Y,Z)}),this};let{strict:J,...G}=Q;Object.assign(this,G),this.getPath=J??!0?Q.getPath??ML1:Jr0}#Q(){let Q=new Y({router:this.router,getPath:this.getPath});return Q.errorHandler=this.errorHandler,Q.#X=this.#X,Q.routes=this.routes,Q}#X=Qc6;errorHandler=Ur0;route(Q,X){let J=this.basePath(Q);return X.routes.map((G)=>{let K;if(X.errorHandler===Ur0)K=G.handler;else K=async(W,Z)=>(await DL1([],X.errorHandler)(W,()=>G.handler(W,Z))).res,K[qr0]=G.handler;J.#J(G.method,G.path,K)}),this}basePath(Q){let X=this.#Q();return X._basePath=PO(this._basePath,Q),X}onError=(Q)=>{return this.errorHandler=Q,this};notFound=(Q)=>{return this.#X=Q,this};mount(Q,X,J){let G,K;if(J)if(typeof J==="function")K=J;else if(K=J.optionHandler,J.replaceRequest===!1)G=(H)=>H;else G=J.replaceRequest;let W=K?(H)=>{let $=K(H);return Array.isArray($)?$:[$]}:(H)=>{let $=void 0;try{$=H.executionCtx}catch{}return[H.env,$]};G||=(()=>{let H=PO(this._basePath,Q),$=H==="/"?0:H.length;return(F)=>{let V=new URL(F.url);return V.pathname=V.pathname.slice($)||"/",new Request(V,F)}})();let Z=async(H,$)=>{let F=await X(G(H.req.raw),...W(H));if(F)return F;await $()};return this.#J(n9,PO(Q,"*"),Z),this}#J(Q,X,J){Q=Q.toUpperCase(),X=PO(this._basePath,X);let G={basePath:this._basePath,path:X,method:Q,handler:J};this.router.add(Q,X,[J,G]),this.routes.push(G)}#W(Q,X){if(Q instanceof Error)return this.errorHandler(Q,X);throw Q}#G(Q,X,J,G){if(G==="HEAD")return(async()=>new Response(null,await this.#G(Q,X,J,"GET")))();let K=this.getPath(Q,{env:J}),W=this.router.match(G,K),Z=new $r0(Q,{path:K,matchResult:W,env:J,executionCtx:X,notFoundHandler:this.#X});if(W[0].length===1){let $;try{$=W[0][0][0][0](Z,async()=>{Z.res=await this.#X(Z)})}catch(F){return this.#W(F,Z)}return $ instanceof Promise?$.then((F)=>F||(Z.finalized?Z.res:this.#X(Z))).catch((F)=>this.#W(F,Z)):$??this.#X(Z)}let H=DL1(W[0],this.errorHandler,this.#X);return(async()=>{try{let $=await H(Z);if(!$.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return $.res}catch($){return this.#W($,Z)}})()}fetch=(Q,...X)=>{return this.#G(Q,X[1],X[0],Q.method)};request=(Q,X,J,G)=>{if(Q instanceof Request)return this.fetch(X?new Request(Q,X):Q,J,G);return Q=Q.toString(),this.fetch(new Request(/^https?:\/\//.test(Q)?Q:`http://localhost${PO("/",Q)}`,X),J,G)};fire=()=>{addEventListener("fetch",(Q)=>{Q.respondWith(this.#G(Q.request,Q,void 0,Q.request.method))})}};var Dr0=S(()=>{oa0();xr();TO();Br0();EO()});function mr(Y,Q){let X=this.buildAllMatchers(),J=(G,K)=>{let W=X[G]||X[n9],Z=W[2][K];if(Z)return Z;let H=K.match(W[0]);if(!H)return[[],fv];let $=H.indexOf("",1);return[W[1][$],H]};return this.match=J,J(Y,Q)}var fv;var PL1=S(()=>{TO();fv=[]});function Jc6(Y,Q){if(Y.length===1)return Q.length===1?Y<Q?-1:1:-1;if(Q.length===1)return 1;if(Y===bv||Y===hv)return 1;else if(Q===bv||Q===hv)return-1;if(Y===lr)return 1;else if(Q===lr)return-1;return Y.length===Q.length?Y<Q?-1:1:Q.length-Y.length}var lr="[^/]+",bv=".*",hv="(?:|/.*)",CO,Xc6,Or0=class Y{#Y;#Q;#X=Object.create(null);insert(Q,X,J,G,K){if(Q.length===0){if(this.#Y!==void 0)throw CO;if(K)return;this.#Y=X;return}let[W,...Z]=Q,H=W==="*"?Z.length===0?["","",bv]:["","",lr]:W==="/*"?["","",hv]:W.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),$;if(H){let F=H[1],V=H[2]||lr;if(F&&H[2]){if(V===".*")throw CO;if(V=V.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(V))throw CO}if($=this.#X[V],!$){if(Object.keys(this.#X).some((B)=>B!==bv&&B!==hv))throw CO;if(K)return;if($=this.#X[V]=new Y,F!=="")$.#Q=G.varIndex++}if(!K&&F!=="")J.push([F,$.#Q])}else if($=this.#X[W],!$){if(Object.keys(this.#X).some((F)=>F.length>1&&F!==bv&&F!==hv))throw CO;if(K)return;$=this.#X[W]=new Y}$.insert(Z,X,J,G,K)}buildRegExpStr(){let X=Object.keys(this.#X).sort(Jc6).map((J)=>{let G=this.#X[J];return(typeof G.#Q==="number"?`(${J})@${G.#Q}`:Xc6.has(J)?`\\${J}`:J)+G.buildRegExpStr()});if(typeof this.#Y==="number")X.unshift(`#${this.#Y}`);if(X.length===0)return"";if(X.length===1)return X[0];return"(?:"+X.join("|")+")"}};var EL1=S(()=>{CO=Symbol(),Xc6=new Set(".\\+*[^]$()")});var Nr0=class{#Y={varIndex:0};#Q=new Or0;insert(Y,Q,X){let J=[],G=[];for(let W=0;;){let Z=!1;if(Y=Y.replace(/\{[^}]+\}/g,(H)=>{let $=`@\\${W}`;return G[W]=[$,H],W++,Z=!0,$}),!Z)break}let K=Y.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let W=G.length-1;W>=0;W--){let[Z]=G[W];for(let H=K.length-1;H>=0;H--)if(K[H].indexOf(Z)!==-1){K[H]=K[H].replace(Z,G[W][1]);break}}return this.#Q.insert(K,Q,J,this.#Y,X),J}buildRegExp(){let Y=this.#Q.buildRegExpStr();if(Y==="")return[/^$/,[],[]];let Q=0,X=[],J=[];return Y=Y.replace(/#(\d+)|@(\d+)|\.\*\$/g,(G,K,W)=>{if(K!==void 0)return X[++Q]=Number(K),"$()";if(W!==void 0)return J[Number(W)]=++Q,"";return""}),[new RegExp(`^${Y}`),X,J]}};var Lr0=S(()=>{EL1()});function wr0(Y){return Mr0[Y]??=new RegExp(Y==="*"?"":`^${Y.replace(/\/\*$|([.\\+*[^\]$()])/g,(Q,X)=>X?`\\${X}`:"(?:|/.*)")}$`)}function Wc6(){Mr0=Object.create(null)}function Zc6(Y){let Q=new Nr0,X=[];if(Y.length===0)return Gc6;let J=Y.map(($)=>[!/\*|\/:/.test($[0]),...$]).sort(([$,F],[V,B])=>$?1:V?-1:F.length-B.length),G=Object.create(null);for(let $=0,F=-1,V=J.length;$<V;$++){let[B,U,z]=J[$];if(B)G[U]=[z.map(([L])=>[L,Object.create(null)]),fv];else F++;let D;try{D=Q.insert(U,F,B)}catch(L){throw L===CO?new ur(U):L}if(B)continue;X[F]=z.map(([L,w])=>{let E=Object.create(null);w-=1;for(;w>=0;w--){let[T,C]=D[w];E[T]=C}return[L,E]})}let[K,W,Z]=Q.buildRegExp();for(let $=0,F=X.length;$<F;$++)for(let V=0,B=X[$].length;V<B;V++){let U=X[$][V]?.[1];if(!U)continue;let z=Object.keys(U);for(let D=0,L=z.length;D<L;D++)U[z[D]]=Z[U[z[D]]]}let H=[];for(let $ in W)H[$]=X[W[$]];return[K,H,G]}function kP(Y,Q){if(!Y)return;for(let X of Object.keys(Y).sort((J,G)=>G.length-J.length))if(wr0(X).test(Q))return[...Y[X]];return}var Gc6,Mr0,dr=class{name="RegExpRouter";#Y;#Q;constructor(){this.#Y={[n9]:Object.create(null)},this.#Q={[n9]:Object.create(null)}}add(Y,Q,X){let J=this.#Y,G=this.#Q;if(!J||!G)throw Error(gr);if(!J[Y])[J,G].forEach((Z)=>{Z[Y]=Object.create(null),Object.keys(Z[n9]).forEach((H)=>{Z[Y][H]=[...Z[n9][H]]})});if(Q==="/*")Q="*";let K=(Q.match(/\/:/g)||[]).length;if(/\*$/.test(Q)){let Z=wr0(Q);if(Y===n9)Object.keys(J).forEach((H)=>{J[H][Q]||=kP(J[H],Q)||kP(J[n9],Q)||[]});else J[Y][Q]||=kP(J[Y],Q)||kP(J[n9],Q)||[];Object.keys(J).forEach((H)=>{if(Y===n9||Y===H)Object.keys(J[H]).forEach(($)=>{Z.test($)&&J[H][$].push([X,K])})}),Object.keys(G).forEach((H)=>{if(Y===n9||Y===H)Object.keys(G[H]).forEach(($)=>Z.test($)&&G[H][$].push([X,K]))});return}let W=br(Q)||[Q];for(let Z=0,H=W.length;Z<H;Z++){let $=W[Z];Object.keys(G).forEach((F)=>{if(Y===n9||Y===F)G[F][$]||=[...kP(J[F],$)||kP(J[n9],$)||[]],G[F][$].push([X,K-H+Z+1])})}}match=mr;buildAllMatchers(){let Y=Object.create(null);return Object.keys(this.#Q).concat(Object.keys(this.#Y)).forEach((Q)=>{Y[Q]||=this.#X(Q)}),this.#Y=this.#Q=void 0,Wc6(),Y}#X(Y){let Q=[],X=Y===n9;if([this.#Y,this.#Q].forEach((J)=>{let G=J[Y]?Object.keys(J[Y]).map((K)=>[K,J[Y][K]]):[];if(G.length!==0)X||=!0,Q.push(...G);else if(Y!==n9)Q.push(...Object.keys(J[n9]).map((K)=>[K,J[n9][K]]))}),!X)return null;else return Zc6(Q)}};var TL1=S(()=>{TO();EO();PL1();EL1();Lr0();Gc6=[/^$/,[],Object.create(null)],Mr0=Object.create(null)});var Kc6=class{name="PreparedRegExpRouter";#Y;#Q;constructor(Y,Q){this.#Y=Y,this.#Q=Q}#X(Y,Q){let X=this.#Y[Y];X[1].forEach((J)=>J&&J.push(Q)),Object.values(X[2]).forEach((J)=>J[0].push(Q))}#J(Y,Q,X,J,G){let K=this.#Y[Y];if(!G)K[2][Q][0].push([X,{}]);else J.forEach((W)=>{if(typeof W==="number")K[1][W].push([X,G]);else K[2][W||Q][0].push([X,G])})}add(Y,Q,X){if(!this.#Y[Y]){let G=this.#Y[n9],K={};for(let W in G[2])K[W]=[G[2][W][0].slice(),fv];this.#Y[Y]=[G[0],G[1].map((W)=>Array.isArray(W)?W.slice():0),K]}if(Q==="/*"||Q==="*"){let G=[X,{}];if(Y===n9)for(let K in this.#Y)this.#X(K,G);else this.#X(Y,G);return}let J=this.#Q[Q];if(!J)throw Error(`Path ${Q} is not registered`);for(let[G,K]of J)if(Y===n9)for(let W in this.#Y)this.#J(W,Q,X,G,K);else this.#J(Y,Q,X,G,K)}buildAllMatchers(){return this.#Y}match=mr};var Ar0=S(()=>{TO();PL1();TL1()});var Pr0=S(()=>{TL1();Ar0()});var CL1=class{name="SmartRouter";#Y=[];#Q=[];constructor(Y){this.#Y=Y.routers}add(Y,Q,X){if(!this.#Q)throw Error(gr);this.#Q.push([Y,Q,X])}match(Y,Q){if(!this.#Q)throw Error("Fatal error");let X=this.#Y,J=this.#Q,G=X.length,K=0,W;for(;K<G;K++){let Z=X[K];try{for(let H=0,$=J.length;H<$;H++)Z.add(...J[H]);W=Z.match(Y,Q)}catch(H){if(H instanceof ur)continue;throw H}this.match=Z.match.bind(Z),this.#Y=[Z],this.#Q=void 0;break}if(K===G)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,W}get activeRouter(){if(this.#Q||this.#Y.length!==1)throw Error("No active router has been determined yet.");return this.#Y[0]}};var Er0=S(()=>{TO()});var Tr0=S(()=>{Er0()});var xv,Hc6=(Y)=>{for(let Q in Y)return!0;return!1},Cr0=class Y{#Y;#Q;#X;#J=0;#W=xv;constructor(Q,X,J){if(this.#Q=J||Object.create(null),this.#Y=[],Q&&X){let G=Object.create(null);G[Q]={handler:X,possibleKeys:[],score:0},this.#Y=[G]}this.#X=[]}insert(Q,X,J){this.#J=++this.#J;let G=this,K=Qr0(X),W=[];for(let Z=0,H=K.length;Z<H;Z++){let $=K[Z],F=K[Z+1],V=Xr0($,F),B=Array.isArray(V)?V[0]:$;if(B in G.#Q){if(G=G.#Q[B],V)W.push(V[1]);continue}if(G.#Q[B]=new Y,V)G.#X.push(V),W.push(V[1]);G=G.#Q[B]}return G.#Y.push({[Q]:{handler:J,possibleKeys:W.filter((Z,H,$)=>$.indexOf(Z)===H),score:this.#J}}),G}#G(Q,X,J,G,K){for(let W=0,Z=X.#Y.length;W<Z;W++){let H=X.#Y[W],$=H[J]||H[n9],F={};if($!==void 0){if($.params=Object.create(null),Q.push($),G!==xv||K&&K!==xv)for(let V=0,B=$.possibleKeys.length;V<B;V++){let U=$.possibleKeys[V],z=F[$.score];$.params[U]=K?.[U]&&!z?K[U]:G[U]??K?.[U],F[$.score]=!0}}}}search(Q,X){let J=[];this.#W=xv;let K=[this],W=LL1(X),Z=[],H=W.length,$=null;for(let F=0;F<H;F++){let V=W[F],B=F===H-1,U=[];for(let D=0,L=K.length;D<L;D++){let w=K[D],E=w.#Q[V];if(E)if(E.#W=w.#W,B){if(E.#Q["*"])this.#G(J,E.#Q["*"],Q,w.#W);this.#G(J,E,Q,w.#W)}else U.push(E);for(let T=0,C=w.#X.length;T<C;T++){let P=w.#X[T],I=w.#W===xv?{}:{...w.#W};if(P==="*"){let g=w.#Q["*"];if(g)this.#G(J,g,Q,w.#W),g.#W=I,U.push(g);continue}let[k,v,f]=P;if(!V&&!(f instanceof RegExp))continue;let b=w.#Q[k];if(f instanceof RegExp){if($===null){$=Array(H);let m=X[0]==="/"?1:0;for(let h=0;h<H;h++)$[h]=m,m+=W[h].length+1}let g=X.substring($[F]),r=f.exec(g);if(r){if(I[v]=r[0],this.#G(J,b,Q,w.#W,I),Hc6(b.#Q)){b.#W=I;let m=r[0].match(/\//)?.length??0;(Z[m]||=[]).push(b)}continue}}if(f===!0||f.test(V))if(I[v]=V,B){if(this.#G(J,b,Q,I,w.#W),b.#Q["*"])this.#G(J,b.#Q["*"],Q,I,w.#W)}else b.#W=I,U.push(b)}}let z=Z.shift();K=z?U.concat(z):U}if(J.length>1)J.sort((F,V)=>{return F.score-V.score});return[J.map(({handler:F,params:V})=>[F,V])]}};var Rr0=S(()=>{TO();EO();xv=Object.create(null)});var RL1=class{name="TrieRouter";#Y;constructor(){this.#Y=new Cr0}add(Y,Q,X){let J=br(Q);if(J){for(let G=0,K=J.length;G<K;G++)this.#Y.insert(Y,J[G],X);return}this.#Y.insert(Y,Q,X)}match(Y,Q){return this.#Y.search(Y,Q)}};var Ir0=S(()=>{EO();Rr0()});var jr0=S(()=>{Ir0()});var qQ;var Sr0=S(()=>{Dr0();Pr0();Tr0();jr0();qQ=class extends zr0{constructor(Y={}){super(Y);this.router=Y.router??new CL1({routers:[new dr,new RL1]})}}});var GK=S(()=>{Sr0()});var $c6,Fc6,IL1=(Y,Q)=>{if(Q&&Y.indexOf(Q)===-1)return{};let X=Y.trim().split(";"),J={};for(let G of X){G=G.trim();let K=G.indexOf("=");if(K===-1)continue;let W=G.substring(0,K).trim();if(Q&&Q!==W||!$c6.test(W))continue;let Z=G.substring(K+1).trim();if(Z.startsWith('"')&&Z.endsWith('"'))Z=Z.slice(1,-1);if(Fc6.test(Z)){if(J[W]=Z.indexOf("%")!==-1?SP(Z,vv):Z,Q)break}}return J};var kr0=S(()=>{EO();$c6=/^[\w!#$%&'*.^`|~+-]+$/,Fc6=/^[ !#-:<-[\]-~]*$/});var vr0=(Y,Q,X)=>{let J=Y.req.raw.headers.get("Cookie");if(typeof Q==="string"){if(!J)return;let K=Q;if(X==="secure")K="__Secure-"+Q;else if(X==="host")K="__Host-"+Q;return IL1(J,K)[K]}if(!J)return{};return IL1(J)};var _r0=S(()=>{kr0()});var yr0=(Y)=>{let X={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...Y},J=((K)=>{if(typeof K==="string")if(K==="*")return()=>K;else return(W)=>K===W?W:null;else if(typeof K==="function")return K;else return(W)=>K.includes(W)?W:null})(X.origin),G=((K)=>{if(typeof K==="function")return K;else if(Array.isArray(K))return()=>K;else return()=>[]})(X.allowMethods);return async function(W,Z){function H(F,V){W.res.headers.set(F,V)}let $=await J(W.req.header("origin")||"",W);if($)H("Access-Control-Allow-Origin",$);if(X.credentials)H("Access-Control-Allow-Credentials","true");if(X.exposeHeaders?.length)H("Access-Control-Expose-Headers",X.exposeHeaders.join(","));if(W.req.method==="OPTIONS"){if(X.origin!=="*")H("Vary","Origin");if(X.maxAge!=null)H("Access-Control-Max-Age",X.maxAge.toString());let F=await G(W.req.header("origin")||"",W);if(F.length)H("Access-Control-Allow-Methods",F.join(","));let V=X.allowHeaders;if(!V?.length){let B=W.req.header("Access-Control-Request-Headers");if(B)V=B.split(/\s*,\s*/)}if(V?.length)H("Access-Control-Allow-Headers",V.join(",")),W.res.headers.append("Vary","Access-Control-Request-Headers");return W.res.headers.delete("Content-Length"),W.res.headers.delete("Content-Type"),new Response(null,{headers:W.res.headers,status:204,statusText:"No Content"})}if(await Z(),X.origin!=="*")W.header("Vary","Origin",{append:!0})}};var fr0=()=>{};function Vc6(){let{process:Y,Deno:Q}=globalThis;return!(typeof Q?.noColor==="boolean"?Q.noColor:Y!==void 0?"NO_COLOR"in Y?.env:!1)}async function br0(){let{navigator:Y}=globalThis,Q="cloudflare:workers";return!(Y!==void 0&&Y.userAgent==="Cloudflare-Workers"?await(async()=>{try{return"NO_COLOR"in((await import("cloudflare:workers")).env??{})}catch{return!1}})():!Vc6())}var hr0=()=>{};async function xr0(Y,Q,X,J,G=0,K){let W=Q==="<--"?`${Q} ${X} ${J}`:`${Q} ${X} ${J} ${await Uc6(G)} ${K}`;Y(W)}var qc6=(Y)=>{let[Q,X]=[",","."];return Y.map((G)=>G.replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+Q)).join(X)},Bc6=(Y)=>{let Q=Date.now()-Y;return qc6([Q<1000?Q+"ms":Math.round(Q/1000)+"s"])},Uc6=async(Y)=>{if(await br0())switch(Y/100|0){case 5:return`\x1B[31m${Y}\x1B[0m`;case 4:return`\x1B[33m${Y}\x1B[0m`;case 3:return`\x1B[36m${Y}\x1B[0m`;case 2:return`\x1B[32m${Y}\x1B[0m`}return`${Y}`},gr0=(Y=console.log)=>{return async function(X,J){let{method:G,url:K}=X.req,W=K.slice(K.indexOf("/",8));await xr0(Y,"<--",G,W);let Z=Date.now();await J(),await xr0(Y,"-->",G,W,X.res.status,Bc6(Z))}};var ur0=S(()=>{hr0()});var mr0=()=>{try{return performance.now()}catch{}return Date.now()},jL1=(Y)=>{let Q={total:!0,enabled:!0,totalDescription:"Total Response Time",autoEnd:!0,crossOrigin:!1,...Y};return async function(J,G){let K=[],W=new Map;if(J.get("metric"))return await G();if(J.set("metric",{headers:K,timers:W}),Q.total)vP(J,"total",Q.totalDescription);if(await G(),Q.total)RO(J,"total");if(Q.autoEnd)W.forEach((H,$)=>RO(J,$));if(typeof Q.enabled==="function"?Q.enabled(J):Q.enabled){J.res.headers.append("Server-Timing",K.join(","));let H=typeof Q.crossOrigin==="function"?Q.crossOrigin(J):Q.crossOrigin;if(H)J.res.headers.append("Timing-Allow-Origin",typeof H==="string"?H:"*")}}},lr0=(Y,Q,X,J,G)=>{let K=Y.get("metric");if(!K){console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");return}if(typeof X==="number"){let W=X.toFixed(G||1),Z=J?`${Q};dur=${W};desc="${J}"`:`${Q};dur=${W}`;K.headers.push(Z)}else{let W=X?`${Q};desc="${X}"`:`${Q}`;K.headers.push(W)}},vP=(Y,Q,X)=>{let J=Y.get("metric");if(!J){console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");return}J.timers.set(Q,{description:X,start:mr0()})},RO=(Y,Q,X)=>{let J=Y.get("metric");if(!J){console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");return}let G=J.timers.get(Q);if(!G){console.warn(`Timer "${Q}" does not exist!`);return}let{description:K,start:W}=G,Z=mr0()-W;lr0(Y,Q,Z,K,X),J.timers.delete(Q)};var dr0=S(()=>{xr()});var pr0=S(()=>{dr0()});class SL1{db;constructor(Y){this.db=Y}async create(Y,Q,X){let J=p8("vir"),G=new Date().toISOString();if(await this.db.insertInto("connections").values({id:J,organization_id:Y,created_by:Q,title:X.title,description:X.description??null,icon:X.icon??null,app_name:null,app_id:null,connection_type:"VIRTUAL",connection_url:`virtual://${J}`,connection_token:null,connection_headers:null,oauth_config:null,configuration_state:null,configuration_scopes:null,metadata:X.metadata?JSON.stringify(X.metadata):null,tools:null,bindings:null,status:X.status??"active",created_at:G,updated_at:G}).execute(),X.connections.length>0)await this.db.insertInto("connection_aggregations").values(X.connections.map((W)=>({id:p8("agg"),parent_connection_id:J,child_connection_id:W.connection_id,selected_tools:W.selected_tools?JSON.stringify(W.selected_tools):null,selected_resources:W.selected_resources?JSON.stringify(W.selected_resources):null,selected_prompts:W.selected_prompts?JSON.stringify(W.selected_prompts):null,dependency_mode:"direct",created_at:G}))).execute();let K=await this.findById(J);if(!K)throw Error(`Failed to create virtual MCP with id: ${J}`);return K}async findById(Y,Q){let X=b3(Y);if(X){let J=Q??X,G=await this.db.selectFrom("connections").selectAll().where("organization_id","=",J).where("status","!=","inactive").where("status","!=","error").execute();return{...Ex(J),connections:G.map((K)=>({connection_id:K.id,selected_tools:null,selected_resources:null,selected_prompts:null}))}}return this.findByIdInternal(this.db,Y)}async findByIdInternal(Y,Q){let X=await Y.selectFrom("connections").selectAll().where("id","=",Q).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!X)return null;let J=await Y.selectFrom("connection_aggregations").selectAll().where("parent_connection_id","=",Q).where("dependency_mode","=","direct").execute();return this.deserializeVirtualMCPEntity(X,J)}async list(Y){let Q=await this.db.selectFrom("connections").selectAll().where("organization_id","=",Y).where("connection_type","=","VIRTUAL").execute(),X=Q.map((K)=>K.id);if(X.length===0)return[];let J=await this.db.selectFrom("connection_aggregations").selectAll().where("parent_connection_id","in",X).where("dependency_mode","=","direct").execute(),G=new Map;for(let K of J){let W=G.get(K.parent_connection_id)??[];W.push(K),G.set(K.parent_connection_id,W)}return Q.map((K)=>this.deserializeVirtualMCPEntity(K,G.get(K.id)??[]))}async listByConnectionId(Y,Q){let J=(await this.db.selectFrom("connection_aggregations").select("parent_connection_id").where("child_connection_id","=",Q).execute()).map((H)=>H.parent_connection_id);if(J.length===0)return[];let G=await this.db.selectFrom("connections").selectAll().where("id","in",J).where("organization_id","=",Y).where("connection_type","=","VIRTUAL").execute();if(G.length===0)return[];let K=G.map((H)=>H.id),W=await this.db.selectFrom("connection_aggregations").selectAll().where("parent_connection_id","in",K).where("dependency_mode","=","direct").execute(),Z=new Map;for(let H of W){let $=Z.get(H.parent_connection_id)??[];$.push(H),Z.set(H.parent_connection_id,$)}return G.map((H)=>this.deserializeVirtualMCPEntity(H,Z.get(H.id)??[]))}async update(Y,Q,X){let J=new Date().toISOString(),G={updated_at:J,updated_by:Q};if(X.title!==void 0)G.title=X.title;if(X.description!==void 0)G.description=X.description;if(X.icon!==void 0)G.icon=X.icon;if(X.status!==void 0)G.status=X.status;if(X.metadata!==void 0)G.metadata=X.metadata?JSON.stringify(X.metadata):null;if(await this.db.updateTable("connections").set(G).where("id","=",Y).where("connection_type","=","VIRTUAL").execute(),X.connections!==void 0){if(await this.db.deleteFrom("connection_aggregations").where("parent_connection_id","=",Y).where("dependency_mode","=","direct").execute(),X.connections.length>0)await this.db.insertInto("connection_aggregations").values(X.connections.map((W)=>({id:p8("agg"),parent_connection_id:Y,child_connection_id:W.connection_id,selected_tools:W.selected_tools?JSON.stringify(W.selected_tools):null,selected_resources:W.selected_resources?JSON.stringify(W.selected_resources):null,selected_prompts:W.selected_prompts?JSON.stringify(W.selected_prompts):null,dependency_mode:"direct",created_at:J}))).execute()}let K=await this.findById(Y);if(!K)throw Error("Virtual MCP not found after update");return K}async delete(Y){await this.db.deleteFrom("connection_aggregations").where("parent_connection_id","=",Y).execute(),await this.db.deleteFrom("connections").where("id","=",Y).where("connection_type","=","VIRTUAL").execute()}async removeConnectionReferences(Y){await this.db.deleteFrom("connection_aggregations").where("child_connection_id","=",Y).execute()}deserializeVirtualMCPEntity(Y,Q){let X=Y.created_at instanceof Date?Y.created_at.toISOString():Y.created_at,J=Y.updated_at instanceof Date?Y.updated_at.toISOString():Y.updated_at,G=Y.status==="active"?"active":"inactive",K=this.parseJson(Y.metadata);return{id:Y.id,organization_id:Y.organization_id,title:Y.title,description:Y.description,icon:Y.icon,status:G,created_at:X,updated_at:J,created_by:Y.created_by,updated_by:Y.updated_by??void 0,metadata:{...K,instructions:K?.instructions??null},connections:Q.map((W)=>({connection_id:W.child_connection_id,selected_tools:this.parseJson(W.selected_tools),selected_resources:this.parseJson(W.selected_resources),selected_prompts:this.parseJson(W.selected_prompts)}))}}parseJson(Y){if(Y===null)return null;if(typeof Y==="string")try{return JSON.parse(Y)}catch{return null}return Y}async listVirtualTools(Y){let Q=await this.db.selectFrom("connections").select(["tools","created_at","updated_at"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!Q)return[];let X=this.parseJson(Q.tools);if(!X)return[];let J=Q.created_at instanceof Date?Q.created_at.toISOString():Q.created_at,G=Q.updated_at instanceof Date?Q.updated_at.toISOString():Q.updated_at;return X.map((K,W)=>({tool:K,originalIndex:W})).filter(({tool:K})=>DB(K)).map(({tool:K,originalIndex:W})=>Ev(`${Y}:${K.name}:${W}`,K,J,G))}async getVirtualTool(Y,Q){let X=await this.db.selectFrom("connections").select(["tools","created_at","updated_at"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!X)return null;let J=this.parseJson(X.tools);if(!J)return null;let G=J.findIndex((H)=>H.name===Q&&DB(H));if(G===-1)return null;let K=J[G],W=X.created_at instanceof Date?X.created_at.toISOString():X.created_at,Z=X.updated_at instanceof Date?X.updated_at.toISOString():X.updated_at;return Ev(`${Y}:${K.name}:${G}`,K,W,Z)}async createVirtualTool(Y,Q,X){let J=new Date().toISOString(),G=await this.db.selectFrom("connections").select(["tools"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!G)throw Error(`Virtual MCP not found: ${Y}`);let K=this.parseJson(G.tools)??[];if(K.some((Z)=>Z.name===Q.name))throw Error(`Tool with name "${Q.name}" already exists`);let W={name:Q.name,description:Q.description,inputSchema:Q.inputSchema,outputSchema:Q.outputSchema,annotations:Q.annotations,_meta:{"mcp.mesh":{"tool.fn":Q.code},connectionDependencies:X}};return K.push(W),await this.db.updateTable("connections").set({tools:JSON.stringify(K),updated_at:J}).where("id","=",Y).execute(),await this.syncIndirectDependencies(Y,X),Ev(`${Y}:${Q.name}:${K.length-1}`,W,J,J)}async updateVirtualTool(Y,Q,X,J){let G=new Date().toISOString(),K=await this.db.selectFrom("connections").select(["tools","created_at"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!K)throw Error(`Virtual MCP not found: ${Y}`);let W=this.parseJson(K.tools)??[],Z=W.findIndex((B)=>B.name===Q&&DB(B));if(Z===-1)throw Error(`Virtual tool not found: ${Q}`);let H=W[Z];if(X.name&&X.name!==Q){if(W.some((B)=>B.name===X.name))throw Error(`Tool with name "${X.name}" already exists`)}let $=J??H._meta.connectionDependencies??[],F={name:X.name??H.name,description:X.description!==void 0?X.description??void 0:H.description,inputSchema:X.inputSchema??H.inputSchema,outputSchema:X.outputSchema!==void 0?X.outputSchema??void 0:H.outputSchema,annotations:X.annotations!==void 0?X.annotations??void 0:H.annotations,_meta:{"mcp.mesh":{"tool.fn":X.code??H._meta["mcp.mesh"]["tool.fn"]},connectionDependencies:$}};if(W[Z]=F,await this.db.updateTable("connections").set({tools:JSON.stringify(W),updated_at:G}).where("id","=",Y).execute(),J!==void 0)await this.recalculateIndirectDependencies(Y,W);let V=K.created_at instanceof Date?K.created_at.toISOString():K.created_at;return Ev(`${Y}:${F.name}:${Z}`,F,V,G)}async deleteVirtualTool(Y,Q){let X=new Date().toISOString(),J=await this.db.selectFrom("connections").select(["tools"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!J)throw Error(`Virtual MCP not found: ${Y}`);let G=this.parseJson(J.tools)??[],K=G.findIndex((W)=>W.name===Q&&DB(W));if(K===-1)throw Error(`Virtual tool not found: ${Q}`);G.splice(K,1),await this.db.updateTable("connections").set({tools:G.length>0?JSON.stringify(G):null,updated_at:X}).where("id","=",Y).execute(),await this.recalculateIndirectDependencies(Y,G)}async syncIndirectDependencies(Y,Q){if(Q.length===0)return;let X=new Date().toISOString(),J=await this.db.selectFrom("connection_aggregations").select(["child_connection_id","dependency_mode"]).where("parent_connection_id","=",Y).execute(),G=new Set(J.map((W)=>W.child_connection_id)),K=Q.filter((W)=>!G.has(W));if(K.length>0)await this.db.insertInto("connection_aggregations").values(K.map((W)=>({id:p8("agg"),parent_connection_id:Y,child_connection_id:W,selected_tools:null,selected_resources:null,selected_prompts:null,dependency_mode:"indirect",created_at:X}))).execute()}async recalculateIndirectDependencies(Y,Q){let X=new Set;for(let Z of Q)if(DB(Z)){let H=Z._meta.connectionDependencies??[];for(let $ of H)X.add($)}let J=await this.db.selectFrom("connection_aggregations").select(["id","child_connection_id","dependency_mode"]).where("parent_connection_id","=",Y).execute(),G=J.filter((Z)=>Z.dependency_mode==="indirect"&&!X.has(Z.child_connection_id)).map((Z)=>Z.id);if(G.length>0)await this.db.deleteFrom("connection_aggregations").where("id","in",G).execute();let K=new Set(J.map((Z)=>Z.child_connection_id)),W=Array.from(X).filter((Z)=>!K.has(Z));if(W.length>0){let Z=new Date().toISOString();await this.db.insertInto("connection_aggregations").values(W.map((H)=>({id:p8("agg"),parent_connection_id:Y,child_connection_id:H,selected_tools:null,selected_resources:null,selected_prompts:null,dependency_mode:"indirect",created_at:Z}))).execute()}}}var cr0=S(()=>{LG();QY();wF()});class kL1{patterns=[{type:"email",regex:/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g},{type:"api_key",regex:/(?:api[_-]?key|token|secret|password|bearer)\s*[:=]\s*['"]?[\w-]{16,}['"]?/gi},{type:"jwt",regex:/eyJ[A-Za-z0-9-_]+\.eyJ[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+/=]*/g},{type:"credit_card",regex:/\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b/g},{type:"ssn",regex:/\b\d{3}-\d{2}-\d{4}\b/g}];redact(Y){if(Y===null||Y===void 0)return Y;if(typeof Y==="string")return this.redactString(Y);if(Array.isArray(Y))return Y.map((Q)=>this.redact(Q));if(typeof Y==="object"){let Q={};for(let[X,J]of Object.entries(Y)){let G=this.redactString(X);Q[G]=this.redact(J)}return Q}return Y}redactString(Y){let Q=Y;for(let X of this.patterns)Q=Q.replace(X.regex,`[REDACTED:${X.type}]`);return Q}}import{sql as E6}from"kysely";class vL1{db;redactor;databaseType;constructor(Y,Q="sqlite"){this.db=Y;this.redactor=new kL1,this.databaseType=Q}jsonExtract(Y,Q){if(this.databaseType==="postgres")return E6`(${E6.ref(Y)}::jsonb)->>${Q}`;let X=`$.${Q}`;return E6`json_extract(${E6.ref(Y)}, ${X})`}jsonExtractWithCommas(Y,Q){if(this.databaseType==="postgres")return E6`(',' || (${E6.ref(Y)}::jsonb)->>${Q} || ',')`;let X=`$.${Q}`;return E6`(',' || json_extract(${E6.ref(Y)}, ${X}) || ',')`}escapeLikeWildcards(Y){return Y.replace(/\\/g,"\\\\").replace(/%/g,"\\%").replace(/_/g,"\\_")}async log(Y){await this.logBatch([Y])}async logBatch(Y){if(Y.length===0)return;let Q=Y.map((X)=>({...X,input:this.redactor.redact(X.input),output:this.redactor.redact(X.output)}));await this.db.transaction().execute(async(X)=>{await X.insertInto("monitoring_logs").values(Q.map((J)=>this.toDbRow(J))).execute()})}async query(Y){let Q=this.db.selectFrom("monitoring_logs").selectAll(),X=this.db.selectFrom("monitoring_logs").select((Z)=>Z.fn.count("id").as("count"));if(Y.organizationId)Q=Q.where("organization_id","=",Y.organizationId),X=X.where("organization_id","=",Y.organizationId);if(Y.connectionId)Q=Q.where("connection_id","=",Y.connectionId),X=X.where("connection_id","=",Y.connectionId);if(Y.excludeConnectionIds&&Y.excludeConnectionIds.length>0)Q=Q.where("connection_id","not in",Y.excludeConnectionIds),X=X.where("connection_id","not in",Y.excludeConnectionIds);if(Y.virtualMcpId)Q=Q.where("virtual_mcp_id","=",Y.virtualMcpId),X=X.where("virtual_mcp_id","=",Y.virtualMcpId);if(Y.toolName)Q=Q.where("tool_name","=",Y.toolName),X=X.where("tool_name","=",Y.toolName);if(Y.isError!==void 0)Q=Q.where("is_error","=",Y.isError?1:0),X=X.where("is_error","=",Y.isError?1:0);if(Y.startDate)Q=Q.where("timestamp",">=",Y.startDate.toISOString()),X=X.where("timestamp",">=",Y.startDate.toISOString());if(Y.endDate)Q=Q.where("timestamp","<=",Y.endDate.toISOString()),X=X.where("timestamp","<=",Y.endDate.toISOString());if(Y.propertyFilters)Q=this.applyPropertyFilters(Q,Y.propertyFilters),X=this.applyPropertyFilters(X,Y.propertyFilters);if(Q=Q.orderBy("timestamp","desc"),Y.limit)Q=Q.limit(Y.limit);if(Y.offset)Q=Q.offset(Y.offset);let[J,G]=await Promise.all([Q.execute(),X.executeTakeFirst()]),K=Number(G?.count||0);return{logs:J.map((Z)=>this.fromDbRow(Z)),total:K}}async getStats(Y){let Q=this.db.selectFrom("monitoring_logs").where("organization_id","=",Y.organizationId);if(Y.startDate)Q=Q.where("timestamp",">=",Y.startDate.toISOString());if(Y.endDate)Q=Q.where("timestamp","<=",Y.endDate.toISOString());let X=await Q.select([(W)=>W.fn.count("id").as("total_count"),(W)=>W.fn.sum(W.ref("is_error")).as("error_count"),(W)=>W.fn.avg("duration_ms").as("avg_duration")]).executeTakeFirst(),J=Number(X?.total_count||0),G=Number(X?.error_count||0),K=Number(X?.avg_duration||0);return{totalCalls:J,errorRate:J>0?G/J:0,avgDurationMs:K}}async aggregate(Y){let{organizationId:Q,path:X,from:J,aggregation:G,groupBy:K,groupByColumn:W,interval:Z,filters:H}=Y,$=J==="input"?"input":"output",F=this.db.selectFrom("monitoring_logs").where("organization_id","=",Q);if(H?.connectionIds&&H.connectionIds.length>0)F=F.where("connection_id","in",H.connectionIds);if(H?.virtualMcpIds&&H.virtualMcpIds.length>0)F=F.where("virtual_mcp_id","in",H.virtualMcpIds);if(H?.toolNames&&H.toolNames.length>0)F=F.where("tool_name","in",H.toolNames);if(H?.startDate)F=F.where("timestamp",">=",H.startDate.toISOString());if(H?.endDate)F=F.where("timestamp","<=",H.endDate.toISOString());if(H?.propertyFilters)F=this.applyPropertyFilters(F,H.propertyFilters);let V=this.jsonExtractPath($,X);if(W){let U=E6.ref(W),z=F.select([E6`${U}`.as("group_key"),this.aggregationExpression(G,V).as("agg_value")]).where(E6`${U}`,"is not",null).groupBy(E6`${U}`).orderBy(E6`agg_value`,"desc");if(Y.limit)z=z.limit(Y.limit);return{value:null,groups:(await z.execute()).map((L)=>({key:String(L.group_key),value:Number(L.agg_value)||0}))}}if(K){let U=this.jsonExtractPathText($,K),z=F.select([E6`${U}`.as("group_key"),this.aggregationExpression(G,V).as("agg_value")]).where(E6`${U}`,"is not",null).groupBy(E6`${U}`).orderBy(E6`agg_value`,"desc");if(Y.limit)z=z.limit(Y.limit);return{value:null,groups:(await z.execute()).map((L)=>({key:String(L.group_key),value:Number(L.agg_value)||0}))}}if(Z){let U=this.timeBucketExpression(Z);return{value:null,timeseries:(await F.select([U.as("time_bucket"),this.aggregationExpression(G,V).as("agg_value")]).groupBy(E6`time_bucket`).orderBy(E6`time_bucket`).execute()).map((D)=>({timestamp:String(D.time_bucket),value:Number(D.agg_value)||0}))}}let B=await F.select([this.aggregationExpression(G,V).as("agg_value")]).executeTakeFirst();return{value:B?Number(B.agg_value)||0:null}}async countMatched(Y){let{organizationId:Q,path:X,from:J,filters:G}=Y,K=J==="input"?"input":"output",W=this.db.selectFrom("monitoring_logs").where("organization_id","=",Q);if(G?.connectionIds&&G.connectionIds.length>0)W=W.where("connection_id","in",G.connectionIds);if(G?.toolNames&&G.toolNames.length>0)W=W.where("tool_name","in",G.toolNames);if(G?.startDate)W=W.where("timestamp",">=",G.startDate.toISOString());if(G?.endDate)W=W.where("timestamp","<=",G.endDate.toISOString());if(G?.propertyFilters)W=this.applyPropertyFilters(W,G.propertyFilters);let Z=this.jsonExtractPathText(K,X),H=await W.where(E6`${Z}`,"is not",null).select(($)=>$.fn.count("id").as("count")).executeTakeFirst();return Number(H?.count||0)}jsonExtractPath(Y,Q){if(this.databaseType==="postgres"){let J=`{${Q.replace(/^\$\.?/,"").split(".").join(",")}}`;return E6`(${E6.ref(Y)}::jsonb #>> ${J})::numeric`}return E6`CAST(json_extract(${E6.ref(Y)}, ${Q}) AS REAL)`}jsonExtractPathText(Y,Q){if(this.databaseType==="postgres"){let J=`{${Q.replace(/^\$\.?/,"").split(".").join(",")}}`;return E6`(${E6.ref(Y)}::jsonb #>> ${J})`}return E6`json_extract(${E6.ref(Y)}, ${Q})`}aggregationExpression(Y,Q){switch(Y){case"sum":return E6`COALESCE(SUM(${Q}), 0)`;case"avg":return E6`COALESCE(AVG(${Q}), 0)`;case"min":return E6`MIN(${Q})`;case"max":return E6`MAX(${Q})`;case"count":return E6`COUNT(${Q})`;case"count_all":return E6`COUNT(*)`;case"last":return E6`MAX(${Q})`;default:return E6`SUM(${Q})`}}timeBucketExpression(Y){let Q=Y.match(/^(\d+)([mhd])$/);if(!Q)throw Error(`Invalid interval format: ${Y}. Use format like "1h", "1d", "15m"`);let[,X,J]=Q;if(!X||!J)throw Error(`Invalid interval format: ${Y}`);let G=parseInt(X,10);if(this.databaseType==="postgres"){let K;switch(J){case"m":K="minute";break;case"h":K="hour";break;case"d":K="day";break;default:K="hour"}if(G===1)return E6`date_trunc(${K}, timestamp::timestamp)`;let Z=G*(J==="m"?60:J==="h"?3600:86400);return E6`to_timestamp(floor(extract(epoch from timestamp::timestamp) / ${Z}) * ${Z})`}switch(J){case"m":if(G===1)return E6`strftime('%Y-%m-%d %H:%M:00', timestamp)`;return E6`strftime('%Y-%m-%d %H:', timestamp) || printf('%02d', (cast(strftime('%M', timestamp) as integer) / ${G}) * ${G}) || ':00'`;case"h":if(G===1)return E6`strftime('%Y-%m-%d %H:00:00', timestamp)`;return E6`strftime('%Y-%m-%d ', timestamp) || printf('%02d', (cast(strftime('%H', timestamp) as integer) / ${G}) * ${G}) || ':00:00'`;case"d":return E6`strftime('%Y-%m-%d 00:00:00', timestamp)`;default:return E6`strftime('%Y-%m-%d %H:00:00', timestamp)`}}applyPropertyFilters(Y,Q){let{properties:X,propertyKeys:J,propertyPatterns:G,propertyInValues:K}=Q;if(X)for(let[W,Z]of Object.entries(X)){let H=this.jsonExtract("properties",W);Y=Y.where(H,"=",Z)}if(J&&J.length>0)for(let W of J){let Z=this.jsonExtract("properties",W);Y=Y.where(Z,"is not",null)}if(G)for(let[W,Z]of Object.entries(G)){let H=this.jsonExtract("properties",W),$=this.databaseType==="postgres"?"ilike":"like";Y=Y.where(H,$,Z)}if(K)for(let[W,Z]of Object.entries(K)){let H=this.jsonExtractWithCommas("properties",W),F=`%,${this.escapeLikeWildcards(Z)},%`,V=E6`${H} LIKE ${F} ESCAPE '\\'`;Y=Y.where(V)}return Y}toDbRow(Y){return{id:Y.id||p8("log"),organization_id:Y.organizationId,connection_id:Y.connectionId,connection_title:Y.connectionTitle,tool_name:Y.toolName,input:JSON.stringify(Y.input),output:JSON.stringify(Y.output),is_error:Y.isError?1:0,error_message:Y.errorMessage||null,duration_ms:Y.durationMs,timestamp:Y.timestamp instanceof Date?Y.timestamp.toISOString():Y.timestamp,user_id:Y.userId||null,request_id:Y.requestId,user_agent:Y.userAgent||null,virtual_mcp_id:Y.virtualMcpId||null,properties:Y.properties?JSON.stringify(Y.properties):null}}fromDbRow(Y){let Q=typeof Y.input==="string"?JSON.parse(Y.input):Y.input,X=typeof Y.output==="string"?JSON.parse(Y.output):Y.output,J=typeof Y.timestamp==="string"?new Date(Y.timestamp):Y.timestamp,G=Y.properties?typeof Y.properties==="string"?JSON.parse(Y.properties):Y.properties:null;return{id:Y.id,organizationId:Y.organization_id,connectionId:Y.connection_id,connectionTitle:Y.connection_title,toolName:Y.tool_name,input:Q,output:X,isError:Y.is_error===1,errorMessage:Y.error_message,durationMs:Y.duration_ms,timestamp:J,userId:Y.user_id,requestId:Y.request_id,userAgent:Y.user_agent,virtualMcpId:Y.virtual_mcp_id,properties:G}}}var nr0=S(()=>{LG()});class _L1{db;constructor(Y){this.db=Y}async create(Y,Q,X){let J=p8("dash"),G=new Date().toISOString();return await this.db.insertInto("monitoring_dashboards").values({id:J,organization_id:Y,name:X.name,description:X.description??null,filters:X.filters?JSON.stringify(X.filters):null,widgets:JSON.stringify(X.widgets),created_by:Q,created_at:G,updated_at:G}).execute(),{id:J,organizationId:Y,name:X.name,description:X.description??null,filters:X.filters??null,widgets:X.widgets,createdBy:Q,createdAt:G,updatedAt:G}}async get(Y){let Q=await this.db.selectFrom("monitoring_dashboards").selectAll().where("id","=",Y).executeTakeFirst();if(!Q)return null;return this.fromDbRow(Q)}async list(Y){return(await this.db.selectFrom("monitoring_dashboards").selectAll().where("organization_id","=",Y).orderBy("created_at","desc").execute()).map((X)=>this.fromDbRow(X))}async update(Y,Q){let J={updated_at:new Date().toISOString()};if(Q.name!==void 0)J.name=Q.name;if(Q.description!==void 0)J.description=Q.description;if(Q.filters!==void 0)J.filters=Q.filters?JSON.stringify(Q.filters):null;if(Q.widgets!==void 0)J.widgets=JSON.stringify(Q.widgets);await this.db.updateTable("monitoring_dashboards").set(J).where("id","=",Y).execute();let G=await this.get(Y);if(!G)throw Error(`Dashboard ${Y} not found after update`);return G}async delete(Y){await this.db.deleteFrom("monitoring_dashboards").where("id","=",Y).execute()}fromDbRow(Y){let Q=Y.filters?typeof Y.filters==="string"?JSON.parse(Y.filters):Y.filters:null,X=typeof Y.widgets==="string"?JSON.parse(Y.widgets):Y.widgets;return{id:Y.id,organizationId:Y.organization_id,name:Y.name,description:Y.description,filters:Q,widgets:X,createdBy:Y.created_by,createdAt:Y.created_at instanceof Date?Y.created_at.toISOString():Y.created_at,updatedAt:Y.updated_at instanceof Date?Y.updated_at.toISOString():Y.updated_at}}}var ir0=S(()=>{LG()});class yL1{db;constructor(Y){this.db=Y}async get(Y){let Q=await this.db.selectFrom("organization_settings").selectAll().where("organizationId","=",Y).executeTakeFirst();if(!Q)return null;return{organizationId:Q.organizationId,sidebar_items:Q.sidebar_items?typeof Q.sidebar_items==="string"?JSON.parse(Q.sidebar_items):Q.sidebar_items:null,enabled_plugins:Q.enabled_plugins?typeof Q.enabled_plugins==="string"?JSON.parse(Q.enabled_plugins):Q.enabled_plugins:null,createdAt:Q.createdAt,updatedAt:Q.updatedAt}}async upsert(Y,Q){let X=new Date().toISOString(),J=Q?.sidebar_items?JSON.stringify(Q.sidebar_items):null,G=Q?.enabled_plugins?JSON.stringify(Q.enabled_plugins):null;await this.db.insertInto("organization_settings").values({organizationId:Y,sidebar_items:J,enabled_plugins:G,createdAt:X,updatedAt:X}).onConflict((W)=>W.column("organizationId").doUpdateSet({sidebar_items:J?J:void 0,enabled_plugins:G?G:void 0,updatedAt:X})).execute();let K=await this.get(Y);if(!K)return{organizationId:Y,sidebar_items:Q?.sidebar_items??null,enabled_plugins:Q?.enabled_plugins??null,createdAt:X,updatedAt:X};return K}}class fL1{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,projectId:Y.project_id,connectionId:Y.connection_id,createdAt:Y.created_at}}async list(Y){return(await this.db.selectFrom("project_connections").selectAll().where("project_id","=",Y).orderBy("created_at","asc").execute()).map((X)=>this.parseRow(X))}async add(Y,Q){let X=new Date().toISOString(),J=p8("pc"),G=await this.db.insertInto("project_connections").values({id:J,project_id:Y,connection_id:Q,created_at:X}).onConflict((W)=>W.columns(["project_id","connection_id"]).doNothing()).returning(["id","project_id","connection_id","created_at"]).executeTakeFirst();if(G)return this.parseRow(G);let K=await this.db.selectFrom("project_connections").selectAll().where("project_id","=",Y).where("connection_id","=",Q).executeTakeFirst();if(!K)throw Error(`Project connection not found after conflict: project=${Y}, connection=${Q}`);return this.parseRow(K)}async remove(Y,Q){return((await this.db.deleteFrom("project_connections").where("project_id","=",Y).where("connection_id","=",Q).executeTakeFirst()).numDeletedRows??0n)>0n}}var ar0=S(()=>{LG()});class bL1{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,projectId:Y.project_id,pluginId:Y.plugin_id,connectionId:Y.connection_id,settings:Y.settings?typeof Y.settings==="string"?JSON.parse(Y.settings):Y.settings:null,createdAt:Y.created_at,updatedAt:Y.updated_at}}async list(Y){return(await this.db.selectFrom("project_plugin_configs").selectAll().where("project_id","=",Y).execute()).map((X)=>this.parseRow(X))}async get(Y,Q){let X=await this.db.selectFrom("project_plugin_configs").selectAll().where("project_id","=",Y).where("plugin_id","=",Q).executeTakeFirst();return X?this.parseRow(X):null}async upsert(Y,Q,X){let J=new Date().toISOString();if(await this.get(Y,Q)){let Z={updated_at:J};if(X.connectionId!==void 0)Z.connection_id=X.connectionId;if(X.settings!==void 0)Z.settings=X.settings?JSON.stringify(X.settings):null;await this.db.updateTable("project_plugin_configs").set(Z).where("project_id","=",Y).where("plugin_id","=",Q).execute();let H=await this.get(Y,Q);if(!H)throw Error("Failed to update project plugin config");return H}let K=p8("ppc");await this.db.insertInto("project_plugin_configs").values({id:K,project_id:Y,plugin_id:Q,connection_id:X.connectionId??null,settings:X.settings?JSON.stringify(X.settings):null,created_at:J,updated_at:J}).execute();let W=await this.get(Y,Q);if(!W)throw Error("Failed to create project plugin config");return W}async delete(Y,Q){return((await this.db.deleteFrom("project_plugin_configs").where("project_id","=",Y).where("plugin_id","=",Q).executeTakeFirst()).numDeletedRows??0n)>0n}async getBoundConnectionsForProjects(Y){if(Y.length===0)return new Map;let Q=await this.db.selectFrom("project_plugin_configs").innerJoin("connections","connections.id","project_plugin_configs.connection_id").select(["project_plugin_configs.project_id","connections.id as connection_id","connections.title","connections.icon"]).where("project_plugin_configs.project_id","in",Y).where("project_plugin_configs.connection_id","is not",null).execute(),X=new Map;for(let J of Q){let G=J.project_id;if(!X.has(G))X.set(G,[]);X.get(G).push({id:J.connection_id,title:J.title,icon:J.icon})}return X}}var rr0=S(()=>{LG()});class hL1{db;constructor(Y){this.db=Y}async listOrgTags(Y){return(await this.db.selectFrom("organization_tags").selectAll().where("organization_id","=",Y).orderBy("name","asc").execute()).map((X)=>this.tagFromDbRow(X))}async getTag(Y){let Q=await this.db.selectFrom("organization_tags").selectAll().where("id","=",Y).executeTakeFirst();return Q?this.tagFromDbRow(Q):null}async getTagByName(Y,Q){let X=await this.db.selectFrom("organization_tags").selectAll().where("organization_id","=",Y).where("name","=",Q).executeTakeFirst();return X?this.tagFromDbRow(X):null}async createTag(Y,Q){let X=p8("tag"),J=new Date().toISOString();await this.db.insertInto("organization_tags").values({id:X,organization_id:Y,name:Q,created_at:J}).onConflict((K)=>K.columns(["organization_id","name"]).doNothing()).execute();let G=await this.getTagByName(Y,Q);if(!G)throw Error(`Failed to create or retrieve tag: ${Q}`);return G}async deleteTag(Y){await this.db.deleteFrom("organization_tags").where("id","=",Y).execute()}async getMemberTags(Y){return(await this.db.selectFrom("member_tags").innerJoin("organization_tags","organization_tags.id","member_tags.tag_id").select(["organization_tags.id","organization_tags.organization_id","organization_tags.name","organization_tags.created_at"]).where("member_tags.member_id","=",Y).orderBy("organization_tags.name","asc").execute()).map((X)=>this.tagFromDbRow(X))}async setMemberTags(Y,Q){await this.db.transaction().execute(async(X)=>{if(await X.deleteFrom("member_tags").where("member_id","=",Y).execute(),Q.length>0){let J=new Date().toISOString();await X.insertInto("member_tags").values(Q.map((G)=>({id:p8("mtag"),member_id:Y,tag_id:G,created_at:J}))).execute()}})}async addMemberTag(Y,Q){let X=new Date().toISOString();await this.db.insertInto("member_tags").values({id:p8("mtag"),member_id:Y,tag_id:Q,created_at:X}).onConflict((J)=>J.columns(["member_id","tag_id"]).doNothing()).execute()}async removeMemberTag(Y,Q){await this.db.deleteFrom("member_tags").where("member_id","=",Y).where("tag_id","=",Q).execute()}async verifyMemberOrg(Y,Q){return await this.db.selectFrom("member").select("id").where("id","=",Y).where("organizationId","=",Q).executeTakeFirst()!==void 0}async getUserTagsInOrg(Y,Q){return(await this.db.selectFrom("member").innerJoin("member_tags","member_tags.member_id","member.id").innerJoin("organization_tags","organization_tags.id","member_tags.tag_id").select(["organization_tags.id","organization_tags.organization_id","organization_tags.name","organization_tags.created_at"]).where("member.userId","=",Y).where("member.organizationId","=",Q).orderBy("organization_tags.name","asc").execute()).map((J)=>this.tagFromDbRow(J))}async getMembersWithTags(Y){let Q=await this.db.selectFrom("member").leftJoin("member_tags","member_tags.member_id","member.id").leftJoin("organization_tags","organization_tags.id","member_tags.tag_id").select(["member.id as memberId","organization_tags.name as tagName"]).where("member.organizationId","=",Y).execute(),X=new Map;for(let J of Q){if(!X.has(J.memberId))X.set(J.memberId,[]);if(J.tagName)X.get(J.memberId).push(J.tagName)}return X}tagFromDbRow(Y){return{id:Y.id,organizationId:Y.organization_id,name:Y.name,createdAt:Y.created_at}}}var or0=S(()=>{LG()});class xL1{db;constructor(Y){this.db=Y}async findById(Y,Q){let X=await this.db.selectFrom("user").select(["user.id","user.name","user.email","user.image","user.createdAt","user.updatedAt"]).where("user.id","=",Y).where((J)=>J.exists(J.selectFrom("member as m1").innerJoin("member as m2","m1.organizationId","m2.organizationId").select("m1.id").where("m1.userId","=",Y).where("m2.userId","=",Q))).executeTakeFirst();if(!X)return null;return{id:X.id,name:X.name,email:X.email,role:"",createdAt:X.createdAt,updatedAt:X.updatedAt,image:X.image??void 0}}}async function sr0(Y,Q){return(await Q.storage.connections.findById(Y))?.connection_url??null}function zc6(Y){let Q=Y.toLowerCase();return Q.includes("resource_metadata=")||Q.includes("invalid_token")||Q.includes("oauth")}async function tr0(Y,Q={}){try{let X=await fetch(Y,{method:"POST",headers:{...Q,"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mcp-mesh-proxy",version:"1.0.0"}}})});if(X.status===401){let J=X.headers.get("WWW-Authenticate");if(J){if(zc6(J))return J}if(await Dc6(Y))return'Bearer realm="mcp"'}return null}catch{return null}}async function Dc6(Y){try{let Q=new URL(Y),X=new URL("/.well-known/oauth-authorization-server",Q.origin),J=await fetch(X.toString(),{method:"GET",headers:{Accept:"application/json"}});if(J.ok){let G=await J.json();if(G.authorization_endpoint||G.token_endpoint||G.issuer)return!0}return!1}catch{return!1}}async function cr(Y){let X=new URL(Y).pathname;if(X.endsWith("/"))X=X.slice(0,-1);let J=new URL(Y);J.pathname=`${X}/.well-known/oauth-protected-resource`;let G=await fetch(J.toString(),{method:"GET",headers:{Accept:"application/json"}});if(G.ok)return G;if(!gL1.includes(G.status))return G;let K=new URL(Y);if(K.pathname=`/.well-known/oauth-protected-resource${X}`,G=await fetch(K.toString(),{method:"GET",headers:{Accept:"application/json"}}),!gL1.includes(G.status))return G;let W=new URL(Y);return W.pathname="/.well-known/oauth-protected-resource",G=await fetch(W.toString(),{method:"GET",headers:{Accept:"application/json"}}),G}async function Oc6(Y,Q){let X=await sr0(Y,Q);if(!X)return null;let J;try{J=new URL(X).origin}catch{return null}try{let G=await cr(X);if(G.ok){let K=await G.json();if(K.authorization_servers?.[0])return K.authorization_servers[0]}}catch{}return J}async function er0(Y){let Q=Y.get("meshContext");if(!Q)Q=await TF.create(Y.req.raw),Y.set("meshContext",Q);return Q}async function Yo0({error:Y,reqUrl:Q,connectionId:X,connectionUrl:J,headers:G}){let K=Y.message?.toLowerCase()??"";if(!(Y.status===401||Y.code===401||Y.message?.includes("401")||K.includes("unauthorized")||K.includes("invalid_token")||K.includes("api key required")||K.includes("api-key required")))return null;if(Boolean(await tr0(J,G)))return new Response(null,{status:401,headers:{"WWW-Authenticate":`Bearer realm="mcp",resource_metadata="${Q.origin}/mcp/${X}/.well-known/oauth-protected-resource"`}});return new Response(JSON.stringify({error:"unauthorized",message:"Authentication required but server does not support OAuth"}),{status:401,headers:{"Content-Type":"application/json"}})}async function uL1(Y){let X=new URL(Y).pathname;if(X.endsWith("/"))X=X.slice(0,-1);let J=X!==""&&X!=="/",G=[];if(J){let W=new URL(Y);W.pathname=`/.well-known/oauth-authorization-server${X}`,G.push(W);let Z=new URL(Y);Z.pathname=`/.well-known/openid-configuration${X}`,G.push(Z);let H=new URL(Y);H.pathname=`${X}/.well-known/openid-configuration`,G.push(H)}else{let W=new URL(Y);W.pathname="/.well-known/oauth-authorization-server",G.push(W);let Z=new URL(Y);Z.pathname="/.well-known/openid-configuration",G.push(Z)}let K=null;for(let W of G){if(K=await fetch(W.toString(),{method:"GET",headers:{Accept:"application/json"}}),K.ok)return K;if(K.status!==404&&K.status!==401)return K}return K}var pr,gL1,Qo0=(Y)=>{if(!(Y.hostname==="localhost"||Y.hostname.endsWith(".localhost")||Y.hostname==="127.0.0.1"))Y.protocol="https:";return Y},Xo0=async(Y)=>{let Q=Y.req.param("connectionId"),X=await er0(Y),J=await sr0(Q,X);if(!J)return Y.json({error:"Connection not found"},404);let G=Qo0(new URL(Y.req.url)),K=`${G.origin}/mcp/${Q}`,W=`${G.origin}/oauth-proxy/${Q}`;try{let Z=await cr(J);if(!Z.ok&&gL1.includes(Z.status)){if(await tr0(J))return new Response(JSON.stringify({resource:K,authorization_servers:[W],bearer_methods_supported:["header"],scopes_supported:["*"]}),{status:200,headers:{"Content-Type":"application/json"}});return new Response(Z.body,{status:Z.status,statusText:Z.statusText,headers:{"Content-Type":"application/json"}})}if(!Z.ok)return new Response(Z.body,{status:Z.status,statusText:Z.statusText,headers:{"Content-Type":"application/json"}});let H=await Z.json();if("issuer"in H&&!("resource"in H)&&(("authorization_endpoint"in H)||("token_endpoint"in H))){let V={resource:K,authorization_servers:[W],bearer_methods_supported:["header"],scopes_supported:"scopes_supported"in H&&Array.isArray(H.scopes_supported)&&H.scopes_supported.length>0?H.scopes_supported:["*"]};return new Response(JSON.stringify(V),{status:200,headers:{"Content-Type":"application/json"}})}let F={...H,resource:K,authorization_servers:[W]};return new Response(JSON.stringify(F),{status:Z.status,statusText:Z.statusText,headers:{"Content-Type":"application/json"}})}catch(Z){let H=Z;return console.error("[oauth-proxy] Failed to proxy OAuth protected resource metadata:",H),Y.json({error:"Failed to proxy OAuth metadata",message:H.message},502)}},Jo0;var mL1=S(()=>{GK();nr();pr=new qQ,gL1=[404,401,406];pr.get("/.well-known/oauth-protected-resource/mcp/:connectionId",(Y)=>Xo0(Y));pr.get("/mcp/:connectionId/.well-known/oauth-protected-resource",(Y)=>Xo0(Y));pr.get("/.well-known/oauth-authorization-server/oauth-proxy/:connectionId",async(Y)=>{let Q=Y.req.param("connectionId"),X=await er0(Y),J=await Oc6(Q,X);if(!J)return Y.json({error:"Connection not found or no auth server"},404);try{let G=await uL1(J);if(!G.ok)return new Response(G.body,{status:G.status,statusText:G.statusText,headers:{"Content-Type":"application/json"}});let K=await G.json(),Z=`${Qo0(new URL(Y.req.url)).origin}/oauth-proxy/${Q}`,H={...K,authorization_endpoint:K.authorization_endpoint?`${Z}/authorize`:void 0,token_endpoint:K.token_endpoint?`${Z}/token`:void 0,registration_endpoint:K.registration_endpoint?`${Z}/register`:void 0};return new Response(JSON.stringify(H),{status:200,headers:{"Content-Type":"application/json"}})}catch(G){let K=G;return console.error("[oauth-proxy] Failed to proxy auth server metadata:",K),Y.json({error:"Failed to proxy auth server metadata",message:K.message},502)}});Jo0=pr});async function ir(Y,Q){let X=Y.get("meshContext");try{let J=Y.req.header("x-org-id"),G=Y.req.header("x-org-slug"),K=J?J:G?await X.db.selectFrom("organization").select("id").where("slug","=",G).executeTakeFirst().then((U)=>U?.id):null,W=Q?Q:K?KL(K):null;if(!W)return Y.json({error:"Agent ID or organization ID is required"},400);let Z=await X.storage.virtualMcps.findById(W,K??void 0);if(!Z)return Y.json({error:"Agent not found"},404);if(K&&Z.organization_id!==K)return Y.json({error:"Agent not found"},404);if(Z.status!=="active")return Y.json({error:`Agent is inactive: ${Z.id??"Decopilot"}`},503);X.connectionId=Z.id??void 0;let H=await X.db.selectFrom("organization").select(["id","slug","name"]).where("id","=",Z.organization_id).executeTakeFirst();if(H)X.organization={id:H.id,slug:H.slug,name:H.name};let $=rO1(Y.req.query("mode")),F=await OB(Z,X,$),V=IU(F,{name:`mcp-virtual-mcp-${Z.title??"Decopilot"}`,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{}},instructions:Z.metadata?.instructions??void 0}),B=new a$({enableJsonResponse:Y.req.header("Accept")?.includes("application/json")??!1});return await V.connect(B),await B.handleRequest(Y.req.raw)}catch(J){let G=J;return console.error("[virtual-mcp] Error handling virtual MCP request:",G),Y.json({error:"Internal server error",message:G.message},500)}}var lL1,Go0;var dL1=S(()=>{QY();Qk();GK();Cv();lL1=new qQ;lL1.all("/gateway/:virtualMcpId?",async(Y)=>{let Q=Y.req.param("virtualMcpId")||Y.req.header("x-virtual-mcp-id");return ir(Y,Q)});lL1.all("/virtual-mcp/:virtualMcpId?",async(Y)=>{let Q=Y.req.param("virtualMcpId")||Y.req.header("x-virtual-mcp-id");return ir(Y,Q)});Go0=lL1});function IO(Y){let Q={client:{callTool:Y.callTool.bind(Y),listTools:Y.listTools.bind(Y)}};if("callStreamableTool"in Y&&Y.callStreamableTool)return{...Q,callStreamableTool:Y.callStreamableTool.bind(Y)};return Q}async function Zo0(Y,Q,{superUser:X}){let J=typeof Y==="string"?await Q.storage.connections.findById(Y,Q.organization?.id):Y;if(!J)throw Error("Connection not found");if(Q.organization&&J.organization_id!==Q.organization.id)throw Error("Connection does not belong to the active organization");if(Q.organization??={id:J.organization_id},J.status!=="active")throw Error(`Connection inactive: ${J.status}`);let G=await y5(J,Q,X),K=tO1(G,J),W=K.getServerCapabilities()??{tools:{},resources:{},prompts:{}},Z=IU(K,{name:"mcp-mesh-proxy-client",version:"1.0.0"},{capabilities:W,instructions:K.getInstructions()}),{client:H,server:$}=V91();await Z.connect($);let F=new eJ({name:"mcp-mesh-proxy-client",version:"1.0.0"});return await F.connect(H),F}async function Ko0(Y,Q){return Zo0(Y,Q,{superUser:!1})}async function pL1(Y,Q){return Zo0(Y,Q,{superUser:!0})}var ar,Wo0=300000,Ho0=(Y,Q)=>{if(Y.message.includes("not found"))return Q.json({error:Y.message},404);if(Y.message.includes("does not belong to the active organization"))return Q.json({error:"Connection not found"},404);if(Y.message.includes("inactive"))return Q.json({error:Y.message},503);return Q.json({error:"Internal server error",message:Y.message},500)},$o0;var jO=S(()=>{RP();QY();AU();Qk();GK();mL1();dL1();ar=new qQ;ar.all("/",async(Y)=>{return ir(Y,void 0)});ar.all("/:connectionId",async(Y)=>{let Q=Y.req.param("connectionId"),X=Y.get("meshContext");try{try{let J=await X.storage.connections.findById(Q,X.organization?.id);if(!J)throw Error("Connection not found");if(X.organization&&J.organization_id!==X.organization.id)throw Error("Connection does not belong to the active organization");if(X.organization??={id:J.organization_id},J.status!=="active")throw Error(`Connection inactive: ${J.status}`);let G=await sO1(J,X,!1),K=new a$({enableJsonResponse:Y.req.raw.headers.get("Accept")?.includes("application/json")??!1});return await G.connect(K),await K.handleRequest(Y.req.raw)}catch(J){let G=await X.storage.connections.findById(Q,X.organization?.id);if(G?.connection_url){let K=await Yo0({error:J,reqUrl:new URL(Y.req.raw.url),connectionId:Q,connectionUrl:G.connection_url,headers:{}});if(K)return K}throw J}}catch(J){return Ho0(J,Y)}});ar.all("/:connectionId/call-tool/:toolName",async(Y)=>{let Q=Y.req.param("connectionId"),X=Y.req.param("toolName"),J=Y.get("meshContext");try{let G=await J.storage.connections.findById(Q,J.organization?.id);if(!G)return Y.json({error:"Connection not found"},404);let W=await(await y5(G,J,!1)).callTool({name:X,arguments:await Y.req.json()});if(W instanceof Response)return W;if(W.isError)return new Response(JSON.stringify(W.content),{headers:{"Content-Type":"application/json"},status:500});return new Response(JSON.stringify(W.structuredContent??W.content),{headers:{"Content-Type":"application/json"}})}catch(G){return Ho0(G,Y)}});$o0=ar});function cL1(Y){let X="You are decopilot, an AI assistant running inside decocms (deco context management system).";if(Y?.trim())X+=`
|
|
1519
|
+
`.execute(Y)}}if(K>0)console.log(`\u2705 ${K} plugin migration(s) completed`)}async function ba0(Y,Q){await Sp6(Y,Q),await kp6(Y,Q);let X=new ya0({db:Y,provider:{getMigrations:()=>Promise.resolve(vx)}}),{error:J,results:G}=await X.migrateToLatest();if(G?.forEach((K)=>{if(K.status==="Success")console.log(`\u2705 Migration "${K.migrationName}" executed successfully`);else if(K.status==="Error")console.error(`\u274C Failed to execute migration "${K.migrationName}"`)}),J)throw console.error("Failed to migrate"),console.error(J),J}async function _p6(Y){let{keepOpen:Q=!1,database:X,skipBetterAuth:J=!1,seed:G}=Y??{};if(!J&&!X)await va0();let K=X??fD(),W=async()=>{if(!Q&&!X)console.log("\uD83D\uDD12 Closing database connection..."),await fj0(K).catch((Z)=>{console.warn("Warning: Error closing database:",Z)})};try{console.log("\uD83D\uDCCA Running Kysely migrations..."),await ba0(K.db,K.type),console.log("\uD83C\uDF89 Core migrations completed successfully"),await vp6(K.db);let Z;if(G)Z=await C91(K.db,G);return await W(),{seedResult:Z}}catch(Z){throw await W(),Z}}async function yp6(){let Y=fD(),Q=new ya0({db:Y.db,provider:{getMigrations:()=>Promise.resolve(vx)}}),{error:X,results:J}=await Q.migrateDown();if(J?.forEach((G)=>{if(G.status==="Success")console.log(`\u2705 Migration "${G.migrationName}" rolled back successfully`);else if(G.status==="Error")console.error(`\u274C Failed to rollback migration "${G.migrationName}"`)}),X)throw console.error("Failed to rollback migration"),console.error(X),X}var xa0=S(()=>{T91();rS1();_a0();Bv();PS()});var AX;var jP=S(()=>{AX=class extends Error{res;status;constructor(Y=500,Q){super(Q?.message,{cause:Q?.cause});this.res=Q?.res,this.status=Y}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}}});var ga0,fp6,bp6=(Y,Q)=>{if(!Y)return{};let X=new Headers(Y.headers);if(Q){let J=X.get("connection");if(J){let G=J.split(",").map((W)=>W.trim()),K=G.filter((W)=>!fp6.test(W));if(K.length>0)throw new AX(400,{message:`Invalid Connection header value: ${K.join(", ")}`});G.forEach((W)=>{X.delete(W)})}}return ga0.forEach((J)=>{X.delete(J)}),{method:Y.method,body:Y.body,duplex:Y.body?"half":void 0,headers:X,signal:Y.signal}},hp6=(Y)=>{if(!Y.headers||Array.isArray(Y.headers)||Y.headers instanceof Headers)return Y;let Q=new Headers;for(let[X,J]of Object.entries(Y.headers))if(J==null)Q.delete(X);else Q.set(X,J);return Y.headers=Q,Y},ua0=async(Y,Q)=>{let{raw:X,customFetch:J,strictConnectionProcessing:G=!1,...K}=Q instanceof Request?{raw:Q}:Q??{},W=new Request(Y,{...bp6(X,G),...hp6(K)});W.headers.delete("accept-encoding");let Z=await(J||fetch)(W),H=new Headers(Z.headers);if(ga0.forEach(($)=>{H.delete($)}),H.has("content-encoding"))H.delete("content-encoding"),H.delete("content-length");return new Response(Z.body,{status:Z.status,statusText:Z.statusText,headers:H})};var ma0=S(()=>{jP();ga0=["connection","keep-alive","proxy-authenticate","proxy-authorization","te","trailer","transfer-encoding","upgrade"],fp6=/^[!#$%&'*+\-.0-9A-Z^_`a-z|~]+$/});var la0=(Y)=>(Q)=>{let X=new URL(Q.req.raw.url),J=new URL(Y);return J.pathname=X.pathname,J.search=X.search,ua0(J,{raw:Q.req.raw,headers:{...Q.req.raw.headers}})};var da0=S(()=>{ma0()});import{resolve as kv,dirname as xp6,join as gp6,extname as up6,basename as mp6,sep as pa0}from"path";function lp6(Y,Q){if(Y===Q||mp6(Y)==="index.html")return{"Cache-Control":"no-cache"};if(Y.includes(`${pa0}assets${pa0}`))return{"Cache-Control":"public, max-age=31536000, immutable"};return{}}function cp6(Y,Q){let X=kv(Q),J=kv(Y);return J===X||J.startsWith(X+"/")}function np6({requestPath:Y,clientDir:Q}){let X=Y.startsWith("/")?Y.slice(1):Y,J=kv(Q,X);if(!cp6(J,Q))return null;return J}function ca0(Y,Q="../client"){let X=new URL(Y),J=xp6(X.pathname);return kv(J,Q)}function na0(Y={}){let{env:Q="production",devServerUrl:X=dp6,clientDir:J=pp6,isServerPath:G=()=>!1}=Y;if(Q==="development"){let K=la0(X);return async function(Z){let H=new URL(Z.url);if(G(H.pathname))return null;let $={req:{raw:Z,url:Z.url}};return K($)}}return async function(W){if(W.method!=="GET")return null;let Z=new URL(W.url),H;try{H=decodeURIComponent(Z.pathname)}catch{return null}if(G(H))return null;let $=np6({requestPath:H,clientDir:J});if(!$)return null;let F=gp6($,"index.html"),V=kv(J,"index.html"),B=W.headers.get("accept"),z=B?.includes("text/html")||B?.includes("*/*")&&["",".html"].includes(up6($))?[F,V]:[];for(let D of[$,...z])try{let L=Bun.file(D);if(await L.exists())return new Response(L,{headers:lp6(D,V)})}catch{}if(H.includes("/assets/"))return new Response("Not Found",{status:404,headers:{"Cache-Control":"no-store"}});return null}}var dp6,pp6="./dist/client";var ia0=S(()=>{da0();dp6=`http://localhost:${process.env.VITE_PORT||"4000"}`});function ra0(Y){if(!Y)return!1;try{return new URL(Y).host==="api.decocms.com"&&Y!=="https://api.decocms.com/mcp/registry"}catch{return!1}}var aa0="https://api.decocms.com/mcp/registry";var DL1=(Y,Q,X)=>{return(J,G)=>{let K=-1;return W(0);async function W(Z){if(Z<=K)throw Error("next() called multiple times");K=Z;let H,$=!1,F;if(Y[Z])F=Y[Z][0][0],J.req.routeIndex=Z;else F=Z===Y.length&&G||void 0;if(F)try{H=await F(J,()=>W(Z+1))}catch(V){if(V instanceof Error&&Q)J.error=V,H=await Q(V,J),$=!0;else throw V}else if(J.finalized===!1&&X)H=await X(J);if(H&&(J.finalized===!1||$))J.res=H;return J}}};var oa0=()=>{};var sa0;var ta0=S(()=>{sa0=Symbol()});async function ip6(Y,Q){let X=await Y.formData();if(X)return ap6(X,Q);return{}}function ap6(Y,Q){let X=Object.create(null);if(Y.forEach((J,G)=>{if(!(Q.all||G.endsWith("[]")))X[G]=J;else rp6(X,G,J)}),Q.dot)Object.entries(X).forEach(([J,G])=>{if(J.includes("."))op6(X,J,G),delete X[J]});return X}var ea0=async(Y,Q=Object.create(null))=>{let{all:X=!1,dot:J=!1}=Q,K=(Y instanceof yr?Y.raw.headers:Y.headers).get("Content-Type");if(K?.startsWith("multipart/form-data")||K?.startsWith("application/x-www-form-urlencoded"))return ip6(Y,{all:X,dot:J});return{}},rp6=(Y,Q,X)=>{if(Y[Q]!==void 0)if(Array.isArray(Y[Q]))Y[Q].push(X);else Y[Q]=[Y[Q],X];else if(!Q.endsWith("[]"))Y[Q]=X;else Y[Q]=[X]},op6=(Y,Q,X)=>{let J=Y,G=Q.split(".");G.forEach((K,W)=>{if(W===G.length-1)J[K]=X;else{if(!J[K]||typeof J[K]!=="object"||Array.isArray(J[K])||J[K]instanceof File)J[K]=Object.create(null);J=J[K]}})};var Yr0=S(()=>{OL1()});var LL1=(Y)=>{let Q=Y.split("/");if(Q[0]==="")Q.shift();return Q},Qr0=(Y)=>{let{groups:Q,path:X}=sp6(Y),J=LL1(X);return tp6(J,Q)},sp6=(Y)=>{let Q=[];return Y=Y.replace(/\{[^}]+\}/g,(X,J)=>{let G=`@${J}`;return Q.push([G,X]),G}),{groups:Q,path:Y}},tp6=(Y,Q)=>{for(let X=Q.length-1;X>=0;X--){let[J]=Q[X];for(let G=Y.length-1;G>=0;G--)if(Y[G].includes(J)){Y[G]=Y[G].replace(J,Q[X][1]);break}}return Y},fr,Xr0=(Y,Q)=>{if(Y==="*")return"*";let X=Y.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(X){let J=`${Y}#${Q}`;if(!fr[J])if(X[2])fr[J]=Q&&Q[0]!==":"&&Q[0]!=="*"?[J,X[1],new RegExp(`^${X[2]}(?=/${Q})`)]:[Y,X[1],new RegExp(`^${X[2]}$`)];else fr[J]=[Y,X[1],!0];return fr[J]}return null},SP=(Y,Q)=>{try{return Q(Y)}catch{return Y.replace(/(?:%[0-9A-Fa-f]{2})+/g,(X)=>{try{return Q(X)}catch{return X}})}},ep6=(Y)=>SP(Y,decodeURI),ML1=(Y)=>{let Q=Y.url,X=Q.indexOf("/",Q.indexOf(":")+4),J=X;for(;J<Q.length;J++){let G=Q.charCodeAt(J);if(G===37){let K=Q.indexOf("?",J),W=Q.indexOf("#",J),Z=K===-1?W===-1?void 0:W:W===-1?K:Math.min(K,W),H=Q.slice(X,Z);return ep6(H.includes("%25")?H.replace(/%25/g,"%2525"):H)}else if(G===63||G===35)break}return Q.slice(X,J)},Jr0=(Y)=>{let Q=ML1(Y);return Q.length>1&&Q.at(-1)==="/"?Q.slice(0,-1):Q},PO=(Y,Q,...X)=>{if(X.length)Q=PO(Q,...X);return`${Y?.[0]==="/"?"":"/"}${Y}${Q==="/"?"":`${Y?.at(-1)==="/"?"":"/"}${Q?.[0]==="/"?Q.slice(1):Q}`}`},br=(Y)=>{if(Y.charCodeAt(Y.length-1)!==63||!Y.includes(":"))return null;let Q=Y.split("/"),X=[],J="";return Q.forEach((G)=>{if(G!==""&&!/\:/.test(G))J+="/"+G;else if(/\:/.test(G))if(/\?/.test(G)){if(X.length===0&&J==="")X.push("/");else X.push(J);let K=G.replace("?","");J+="/"+K,X.push(J)}else J+="/"+G}),X.filter((G,K,W)=>W.indexOf(G)===K)},NL1=(Y)=>{if(!/[%+]/.test(Y))return Y;if(Y.indexOf("+")!==-1)Y=Y.replace(/\+/g," ");return Y.indexOf("%")!==-1?SP(Y,vv):Y},Gr0=(Y,Q,X)=>{let J;if(!X&&Q&&!/[%+]/.test(Q)){let W=Y.indexOf("?",8);if(W===-1)return;if(!Y.startsWith(Q,W+1))W=Y.indexOf(`&${Q}`,W+1);while(W!==-1){let Z=Y.charCodeAt(W+Q.length+1);if(Z===61){let H=W+Q.length+2,$=Y.indexOf("&",H);return NL1(Y.slice(H,$===-1?void 0:$))}else if(Z==38||isNaN(Z))return"";W=Y.indexOf(`&${Q}`,W+1)}if(J=/[%+]/.test(Y),!J)return}let G={};J??=/[%+]/.test(Y);let K=Y.indexOf("?",8);while(K!==-1){let W=Y.indexOf("&",K+1),Z=Y.indexOf("=",K);if(Z>W&&W!==-1)Z=-1;let H=Y.slice(K+1,Z===-1?W===-1?void 0:W:Z);if(J)H=NL1(H);if(K=W,H==="")continue;let $;if(Z===-1)$="";else if($=Y.slice(Z+1,W===-1?void 0:W),J)$=NL1($);if(X){if(!(G[H]&&Array.isArray(G[H])))G[H]=[];G[H].push($)}else G[H]??=$}return Q?G[Q]:G},Wr0,Zr0=(Y,Q)=>{return Gr0(Y,Q,!0)},vv;var EO=S(()=>{fr={},Wr0=Gr0,vv=decodeURIComponent});var Kr0=(Y)=>SP(Y,vv),yr;var OL1=S(()=>{jP();ta0();Yr0();EO();yr=class{raw;#Y;#Q;routeIndex=0;path;bodyCache={};constructor(Y,Q="/",X=[[]]){this.raw=Y,this.path=Q,this.#Q=X,this.#Y={}}param(Y){return Y?this.#X(Y):this.#J()}#X(Y){let Q=this.#Q[0][this.routeIndex][1][Y],X=this.#W(Q);return X&&/\%/.test(X)?Kr0(X):X}#J(){let Y={},Q=Object.keys(this.#Q[0][this.routeIndex][1]);for(let X of Q){let J=this.#W(this.#Q[0][this.routeIndex][1][X]);if(J!==void 0)Y[X]=/\%/.test(J)?Kr0(J):J}return Y}#W(Y){return this.#Q[1]?this.#Q[1][Y]:Y}query(Y){return Wr0(this.url,Y)}queries(Y){return Zr0(this.url,Y)}header(Y){if(Y)return this.raw.headers.get(Y)??void 0;let Q={};return this.raw.headers.forEach((X,J)=>{Q[J]=X}),Q}async parseBody(Y){return this.bodyCache.parsedBody??=await ea0(this,Y)}#G=(Y)=>{let{bodyCache:Q,raw:X}=this,J=Q[Y];if(J)return J;let G=Object.keys(Q)[0];if(G)return Q[G].then((K)=>{if(G==="json")K=JSON.stringify(K);return new Response(K)[Y]()});return Q[Y]=X[Y]()};json(){return this.#G("text").then((Y)=>JSON.parse(Y))}text(){return this.#G("text")}arrayBuffer(){return this.#G("arrayBuffer")}blob(){return this.#G("blob")}formData(){return this.#G("formData")}addValidatedData(Y,Q){this.#Y[Y]=Q}valid(Y){return this.#Y[Y]}get url(){return this.raw.url}get method(){return this.raw.method}get[sa0](){return this.#Q}get matchedRoutes(){return this.#Q[0].map(([[,Y]])=>Y)}get routePath(){return this.#Q[0].map(([[,Y]])=>Y)[this.routeIndex].path}}});var hr,Yc6=(Y,Q)=>{let X=new String(Y);return X.isEscaped=!0,X.callbacks=Q,X},_v=async(Y,Q,X,J,G)=>{if(typeof Y==="object"&&!(Y instanceof String)){if(!(Y instanceof Promise))Y=Y.toString();if(Y instanceof Promise)Y=await Y}let K=Y.callbacks;if(!K?.length)return Promise.resolve(Y);if(G)G[0]+=Y;else G=[Y];let W=Promise.all(K.map((Z)=>Z({phase:Q,buffer:G,context:J}))).then((Z)=>Promise.all(Z.filter(Boolean).map((H)=>_v(H,Q,!1,J,G))).then(()=>G[0]));if(X)return Yc6(await W,K);else return W};var wL1=S(()=>{hr={Stringify:1,BeforeStream:2,Stream:3}});var Hr0="text/plain; charset=UTF-8",AL1=(Y,Q)=>{return{"Content-Type":Y,...Q}},yv=(Y,Q)=>new Response(Y,Q),$r0=class{#Y;#Q;env={};#X;finalized=!1;error;#J;#W;#G;#K;#Z;#$;#H;#V;#q;constructor(Y,Q){if(this.#Y=Y,Q)this.#W=Q.executionCtx,this.env=Q.env,this.#$=Q.notFoundHandler,this.#q=Q.path,this.#V=Q.matchResult}get req(){return this.#Q??=new yr(this.#Y,this.#q,this.#V),this.#Q}get event(){if(this.#W&&"respondWith"in this.#W)return this.#W;else throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#W)return this.#W;else throw Error("This context has no ExecutionContext")}get res(){return this.#G||=yv(null,{headers:this.#H??=new Headers})}set res(Y){if(this.#G&&Y){Y=yv(Y.body,Y);for(let[Q,X]of this.#G.headers.entries()){if(Q==="content-type")continue;if(Q==="set-cookie"){let J=this.#G.headers.getSetCookie();Y.headers.delete("set-cookie");for(let G of J)Y.headers.append("set-cookie",G)}else Y.headers.set(Q,X)}}this.#G=Y,this.finalized=!0}render=(...Y)=>{return this.#Z??=(Q)=>this.html(Q),this.#Z(...Y)};setLayout=(Y)=>this.#K=Y;getLayout=()=>this.#K;setRenderer=(Y)=>{this.#Z=Y};header=(Y,Q,X)=>{if(this.finalized)this.#G=yv(this.#G.body,this.#G);let J=this.#G?this.#G.headers:this.#H??=new Headers;if(Q===void 0)J.delete(Y);else if(X?.append)J.append(Y,Q);else J.set(Y,Q)};status=(Y)=>{this.#J=Y};set=(Y,Q)=>{this.#X??=new Map,this.#X.set(Y,Q)};get=(Y)=>{return this.#X?this.#X.get(Y):void 0};get var(){if(!this.#X)return{};return Object.fromEntries(this.#X)}#F(Y,Q,X){let J=this.#G?new Headers(this.#G.headers):this.#H??new Headers;if(typeof Q==="object"&&"headers"in Q){let K=Q.headers instanceof Headers?Q.headers:new Headers(Q.headers);for(let[W,Z]of K)if(W.toLowerCase()==="set-cookie")J.append(W,Z);else J.set(W,Z)}if(X)for(let[K,W]of Object.entries(X))if(typeof W==="string")J.set(K,W);else{J.delete(K);for(let Z of W)J.append(K,Z)}let G=typeof Q==="number"?Q:Q?.status??this.#J;return yv(Y,{status:G,headers:J})}newResponse=(...Y)=>this.#F(...Y);body=(Y,Q,X)=>this.#F(Y,Q,X);text=(Y,Q,X)=>{return!this.#H&&!this.#J&&!Q&&!X&&!this.finalized?new Response(Y):this.#F(Y,Q,AL1(Hr0,X))};json=(Y,Q,X)=>{return this.#F(JSON.stringify(Y),Q,AL1("application/json",X))};html=(Y,Q,X)=>{let J=(G)=>this.#F(G,Q,AL1("text/html; charset=UTF-8",X));return typeof Y==="object"?_v(Y,hr.Stringify,!1,{}).then(J):J(Y)};redirect=(Y,Q)=>{let X=String(Y);return this.header("Location",!/[^\x00-\xFF]/.test(X)?X:encodeURI(X)),this.newResponse(null,Q??302)};notFound=()=>{return this.#$??=()=>yv(),this.#$(this)}};var xr=S(()=>{OL1();wL1()});var n9="ALL",Fr0="all",Vr0,gr="Can not add a route since the matcher is already built.",ur;var TO=S(()=>{Vr0=["get","post","put","delete","options","patch"],ur=class extends Error{}});var qr0="__COMPOSED_HANDLER";var Br0=()=>{};var Qc6=(Y)=>{return Y.text("404 Not Found",404)},Ur0=(Y,Q)=>{if("getResponse"in Y){let X=Y.getResponse();return Q.newResponse(X.body,X)}return console.error(Y),Q.text("Internal Server Error",500)},zr0=class Y{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#Y="/";routes=[];constructor(Q={}){[...Vr0,Fr0].forEach((K)=>{this[K]=(W,...Z)=>{if(typeof W==="string")this.#Y=W;else this.#J(K,this.#Y,W);return Z.forEach((H)=>{this.#J(K,this.#Y,H)}),this}}),this.on=(K,W,...Z)=>{for(let H of[W].flat()){this.#Y=H;for(let $ of[K].flat())Z.map((F)=>{this.#J($.toUpperCase(),this.#Y,F)})}return this},this.use=(K,...W)=>{if(typeof K==="string")this.#Y=K;else this.#Y="*",W.unshift(K);return W.forEach((Z)=>{this.#J(n9,this.#Y,Z)}),this};let{strict:J,...G}=Q;Object.assign(this,G),this.getPath=J??!0?Q.getPath??ML1:Jr0}#Q(){let Q=new Y({router:this.router,getPath:this.getPath});return Q.errorHandler=this.errorHandler,Q.#X=this.#X,Q.routes=this.routes,Q}#X=Qc6;errorHandler=Ur0;route(Q,X){let J=this.basePath(Q);return X.routes.map((G)=>{let K;if(X.errorHandler===Ur0)K=G.handler;else K=async(W,Z)=>(await DL1([],X.errorHandler)(W,()=>G.handler(W,Z))).res,K[qr0]=G.handler;J.#J(G.method,G.path,K)}),this}basePath(Q){let X=this.#Q();return X._basePath=PO(this._basePath,Q),X}onError=(Q)=>{return this.errorHandler=Q,this};notFound=(Q)=>{return this.#X=Q,this};mount(Q,X,J){let G,K;if(J)if(typeof J==="function")K=J;else if(K=J.optionHandler,J.replaceRequest===!1)G=(H)=>H;else G=J.replaceRequest;let W=K?(H)=>{let $=K(H);return Array.isArray($)?$:[$]}:(H)=>{let $=void 0;try{$=H.executionCtx}catch{}return[H.env,$]};G||=(()=>{let H=PO(this._basePath,Q),$=H==="/"?0:H.length;return(F)=>{let V=new URL(F.url);return V.pathname=V.pathname.slice($)||"/",new Request(V,F)}})();let Z=async(H,$)=>{let F=await X(G(H.req.raw),...W(H));if(F)return F;await $()};return this.#J(n9,PO(Q,"*"),Z),this}#J(Q,X,J){Q=Q.toUpperCase(),X=PO(this._basePath,X);let G={basePath:this._basePath,path:X,method:Q,handler:J};this.router.add(Q,X,[J,G]),this.routes.push(G)}#W(Q,X){if(Q instanceof Error)return this.errorHandler(Q,X);throw Q}#G(Q,X,J,G){if(G==="HEAD")return(async()=>new Response(null,await this.#G(Q,X,J,"GET")))();let K=this.getPath(Q,{env:J}),W=this.router.match(G,K),Z=new $r0(Q,{path:K,matchResult:W,env:J,executionCtx:X,notFoundHandler:this.#X});if(W[0].length===1){let $;try{$=W[0][0][0][0](Z,async()=>{Z.res=await this.#X(Z)})}catch(F){return this.#W(F,Z)}return $ instanceof Promise?$.then((F)=>F||(Z.finalized?Z.res:this.#X(Z))).catch((F)=>this.#W(F,Z)):$??this.#X(Z)}let H=DL1(W[0],this.errorHandler,this.#X);return(async()=>{try{let $=await H(Z);if(!$.finalized)throw Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return $.res}catch($){return this.#W($,Z)}})()}fetch=(Q,...X)=>{return this.#G(Q,X[1],X[0],Q.method)};request=(Q,X,J,G)=>{if(Q instanceof Request)return this.fetch(X?new Request(Q,X):Q,J,G);return Q=Q.toString(),this.fetch(new Request(/^https?:\/\//.test(Q)?Q:`http://localhost${PO("/",Q)}`,X),J,G)};fire=()=>{addEventListener("fetch",(Q)=>{Q.respondWith(this.#G(Q.request,Q,void 0,Q.request.method))})}};var Dr0=S(()=>{oa0();xr();TO();Br0();EO()});function mr(Y,Q){let X=this.buildAllMatchers(),J=(G,K)=>{let W=X[G]||X[n9],Z=W[2][K];if(Z)return Z;let H=K.match(W[0]);if(!H)return[[],fv];let $=H.indexOf("",1);return[W[1][$],H]};return this.match=J,J(Y,Q)}var fv;var PL1=S(()=>{TO();fv=[]});function Jc6(Y,Q){if(Y.length===1)return Q.length===1?Y<Q?-1:1:-1;if(Q.length===1)return 1;if(Y===bv||Y===hv)return 1;else if(Q===bv||Q===hv)return-1;if(Y===lr)return 1;else if(Q===lr)return-1;return Y.length===Q.length?Y<Q?-1:1:Q.length-Y.length}var lr="[^/]+",bv=".*",hv="(?:|/.*)",CO,Xc6,Or0=class Y{#Y;#Q;#X=Object.create(null);insert(Q,X,J,G,K){if(Q.length===0){if(this.#Y!==void 0)throw CO;if(K)return;this.#Y=X;return}let[W,...Z]=Q,H=W==="*"?Z.length===0?["","",bv]:["","",lr]:W==="/*"?["","",hv]:W.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),$;if(H){let F=H[1],V=H[2]||lr;if(F&&H[2]){if(V===".*")throw CO;if(V=V.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(V))throw CO}if($=this.#X[V],!$){if(Object.keys(this.#X).some((B)=>B!==bv&&B!==hv))throw CO;if(K)return;if($=this.#X[V]=new Y,F!=="")$.#Q=G.varIndex++}if(!K&&F!=="")J.push([F,$.#Q])}else if($=this.#X[W],!$){if(Object.keys(this.#X).some((F)=>F.length>1&&F!==bv&&F!==hv))throw CO;if(K)return;$=this.#X[W]=new Y}$.insert(Z,X,J,G,K)}buildRegExpStr(){let X=Object.keys(this.#X).sort(Jc6).map((J)=>{let G=this.#X[J];return(typeof G.#Q==="number"?`(${J})@${G.#Q}`:Xc6.has(J)?`\\${J}`:J)+G.buildRegExpStr()});if(typeof this.#Y==="number")X.unshift(`#${this.#Y}`);if(X.length===0)return"";if(X.length===1)return X[0];return"(?:"+X.join("|")+")"}};var EL1=S(()=>{CO=Symbol(),Xc6=new Set(".\\+*[^]$()")});var Nr0=class{#Y={varIndex:0};#Q=new Or0;insert(Y,Q,X){let J=[],G=[];for(let W=0;;){let Z=!1;if(Y=Y.replace(/\{[^}]+\}/g,(H)=>{let $=`@\\${W}`;return G[W]=[$,H],W++,Z=!0,$}),!Z)break}let K=Y.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let W=G.length-1;W>=0;W--){let[Z]=G[W];for(let H=K.length-1;H>=0;H--)if(K[H].indexOf(Z)!==-1){K[H]=K[H].replace(Z,G[W][1]);break}}return this.#Q.insert(K,Q,J,this.#Y,X),J}buildRegExp(){let Y=this.#Q.buildRegExpStr();if(Y==="")return[/^$/,[],[]];let Q=0,X=[],J=[];return Y=Y.replace(/#(\d+)|@(\d+)|\.\*\$/g,(G,K,W)=>{if(K!==void 0)return X[++Q]=Number(K),"$()";if(W!==void 0)return J[Number(W)]=++Q,"";return""}),[new RegExp(`^${Y}`),X,J]}};var Lr0=S(()=>{EL1()});function wr0(Y){return Mr0[Y]??=new RegExp(Y==="*"?"":`^${Y.replace(/\/\*$|([.\\+*[^\]$()])/g,(Q,X)=>X?`\\${X}`:"(?:|/.*)")}$`)}function Wc6(){Mr0=Object.create(null)}function Zc6(Y){let Q=new Nr0,X=[];if(Y.length===0)return Gc6;let J=Y.map(($)=>[!/\*|\/:/.test($[0]),...$]).sort(([$,F],[V,B])=>$?1:V?-1:F.length-B.length),G=Object.create(null);for(let $=0,F=-1,V=J.length;$<V;$++){let[B,U,z]=J[$];if(B)G[U]=[z.map(([L])=>[L,Object.create(null)]),fv];else F++;let D;try{D=Q.insert(U,F,B)}catch(L){throw L===CO?new ur(U):L}if(B)continue;X[F]=z.map(([L,w])=>{let E=Object.create(null);w-=1;for(;w>=0;w--){let[T,C]=D[w];E[T]=C}return[L,E]})}let[K,W,Z]=Q.buildRegExp();for(let $=0,F=X.length;$<F;$++)for(let V=0,B=X[$].length;V<B;V++){let U=X[$][V]?.[1];if(!U)continue;let z=Object.keys(U);for(let D=0,L=z.length;D<L;D++)U[z[D]]=Z[U[z[D]]]}let H=[];for(let $ in W)H[$]=X[W[$]];return[K,H,G]}function kP(Y,Q){if(!Y)return;for(let X of Object.keys(Y).sort((J,G)=>G.length-J.length))if(wr0(X).test(Q))return[...Y[X]];return}var Gc6,Mr0,dr=class{name="RegExpRouter";#Y;#Q;constructor(){this.#Y={[n9]:Object.create(null)},this.#Q={[n9]:Object.create(null)}}add(Y,Q,X){let J=this.#Y,G=this.#Q;if(!J||!G)throw Error(gr);if(!J[Y])[J,G].forEach((Z)=>{Z[Y]=Object.create(null),Object.keys(Z[n9]).forEach((H)=>{Z[Y][H]=[...Z[n9][H]]})});if(Q==="/*")Q="*";let K=(Q.match(/\/:/g)||[]).length;if(/\*$/.test(Q)){let Z=wr0(Q);if(Y===n9)Object.keys(J).forEach((H)=>{J[H][Q]||=kP(J[H],Q)||kP(J[n9],Q)||[]});else J[Y][Q]||=kP(J[Y],Q)||kP(J[n9],Q)||[];Object.keys(J).forEach((H)=>{if(Y===n9||Y===H)Object.keys(J[H]).forEach(($)=>{Z.test($)&&J[H][$].push([X,K])})}),Object.keys(G).forEach((H)=>{if(Y===n9||Y===H)Object.keys(G[H]).forEach(($)=>Z.test($)&&G[H][$].push([X,K]))});return}let W=br(Q)||[Q];for(let Z=0,H=W.length;Z<H;Z++){let $=W[Z];Object.keys(G).forEach((F)=>{if(Y===n9||Y===F)G[F][$]||=[...kP(J[F],$)||kP(J[n9],$)||[]],G[F][$].push([X,K-H+Z+1])})}}match=mr;buildAllMatchers(){let Y=Object.create(null);return Object.keys(this.#Q).concat(Object.keys(this.#Y)).forEach((Q)=>{Y[Q]||=this.#X(Q)}),this.#Y=this.#Q=void 0,Wc6(),Y}#X(Y){let Q=[],X=Y===n9;if([this.#Y,this.#Q].forEach((J)=>{let G=J[Y]?Object.keys(J[Y]).map((K)=>[K,J[Y][K]]):[];if(G.length!==0)X||=!0,Q.push(...G);else if(Y!==n9)Q.push(...Object.keys(J[n9]).map((K)=>[K,J[n9][K]]))}),!X)return null;else return Zc6(Q)}};var TL1=S(()=>{TO();EO();PL1();EL1();Lr0();Gc6=[/^$/,[],Object.create(null)],Mr0=Object.create(null)});var Kc6=class{name="PreparedRegExpRouter";#Y;#Q;constructor(Y,Q){this.#Y=Y,this.#Q=Q}#X(Y,Q){let X=this.#Y[Y];X[1].forEach((J)=>J&&J.push(Q)),Object.values(X[2]).forEach((J)=>J[0].push(Q))}#J(Y,Q,X,J,G){let K=this.#Y[Y];if(!G)K[2][Q][0].push([X,{}]);else J.forEach((W)=>{if(typeof W==="number")K[1][W].push([X,G]);else K[2][W||Q][0].push([X,G])})}add(Y,Q,X){if(!this.#Y[Y]){let G=this.#Y[n9],K={};for(let W in G[2])K[W]=[G[2][W][0].slice(),fv];this.#Y[Y]=[G[0],G[1].map((W)=>Array.isArray(W)?W.slice():0),K]}if(Q==="/*"||Q==="*"){let G=[X,{}];if(Y===n9)for(let K in this.#Y)this.#X(K,G);else this.#X(Y,G);return}let J=this.#Q[Q];if(!J)throw Error(`Path ${Q} is not registered`);for(let[G,K]of J)if(Y===n9)for(let W in this.#Y)this.#J(W,Q,X,G,K);else this.#J(Y,Q,X,G,K)}buildAllMatchers(){return this.#Y}match=mr};var Ar0=S(()=>{TO();PL1();TL1()});var Pr0=S(()=>{TL1();Ar0()});var CL1=class{name="SmartRouter";#Y=[];#Q=[];constructor(Y){this.#Y=Y.routers}add(Y,Q,X){if(!this.#Q)throw Error(gr);this.#Q.push([Y,Q,X])}match(Y,Q){if(!this.#Q)throw Error("Fatal error");let X=this.#Y,J=this.#Q,G=X.length,K=0,W;for(;K<G;K++){let Z=X[K];try{for(let H=0,$=J.length;H<$;H++)Z.add(...J[H]);W=Z.match(Y,Q)}catch(H){if(H instanceof ur)continue;throw H}this.match=Z.match.bind(Z),this.#Y=[Z],this.#Q=void 0;break}if(K===G)throw Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,W}get activeRouter(){if(this.#Q||this.#Y.length!==1)throw Error("No active router has been determined yet.");return this.#Y[0]}};var Er0=S(()=>{TO()});var Tr0=S(()=>{Er0()});var xv,Hc6=(Y)=>{for(let Q in Y)return!0;return!1},Cr0=class Y{#Y;#Q;#X;#J=0;#W=xv;constructor(Q,X,J){if(this.#Q=J||Object.create(null),this.#Y=[],Q&&X){let G=Object.create(null);G[Q]={handler:X,possibleKeys:[],score:0},this.#Y=[G]}this.#X=[]}insert(Q,X,J){this.#J=++this.#J;let G=this,K=Qr0(X),W=[];for(let Z=0,H=K.length;Z<H;Z++){let $=K[Z],F=K[Z+1],V=Xr0($,F),B=Array.isArray(V)?V[0]:$;if(B in G.#Q){if(G=G.#Q[B],V)W.push(V[1]);continue}if(G.#Q[B]=new Y,V)G.#X.push(V),W.push(V[1]);G=G.#Q[B]}return G.#Y.push({[Q]:{handler:J,possibleKeys:W.filter((Z,H,$)=>$.indexOf(Z)===H),score:this.#J}}),G}#G(Q,X,J,G,K){for(let W=0,Z=X.#Y.length;W<Z;W++){let H=X.#Y[W],$=H[J]||H[n9],F={};if($!==void 0){if($.params=Object.create(null),Q.push($),G!==xv||K&&K!==xv)for(let V=0,B=$.possibleKeys.length;V<B;V++){let U=$.possibleKeys[V],z=F[$.score];$.params[U]=K?.[U]&&!z?K[U]:G[U]??K?.[U],F[$.score]=!0}}}}search(Q,X){let J=[];this.#W=xv;let K=[this],W=LL1(X),Z=[],H=W.length,$=null;for(let F=0;F<H;F++){let V=W[F],B=F===H-1,U=[];for(let D=0,L=K.length;D<L;D++){let w=K[D],E=w.#Q[V];if(E)if(E.#W=w.#W,B){if(E.#Q["*"])this.#G(J,E.#Q["*"],Q,w.#W);this.#G(J,E,Q,w.#W)}else U.push(E);for(let T=0,C=w.#X.length;T<C;T++){let P=w.#X[T],I=w.#W===xv?{}:{...w.#W};if(P==="*"){let g=w.#Q["*"];if(g)this.#G(J,g,Q,w.#W),g.#W=I,U.push(g);continue}let[k,v,f]=P;if(!V&&!(f instanceof RegExp))continue;let b=w.#Q[k];if(f instanceof RegExp){if($===null){$=Array(H);let m=X[0]==="/"?1:0;for(let h=0;h<H;h++)$[h]=m,m+=W[h].length+1}let g=X.substring($[F]),r=f.exec(g);if(r){if(I[v]=r[0],this.#G(J,b,Q,w.#W,I),Hc6(b.#Q)){b.#W=I;let m=r[0].match(/\//)?.length??0;(Z[m]||=[]).push(b)}continue}}if(f===!0||f.test(V))if(I[v]=V,B){if(this.#G(J,b,Q,I,w.#W),b.#Q["*"])this.#G(J,b.#Q["*"],Q,I,w.#W)}else b.#W=I,U.push(b)}}let z=Z.shift();K=z?U.concat(z):U}if(J.length>1)J.sort((F,V)=>{return F.score-V.score});return[J.map(({handler:F,params:V})=>[F,V])]}};var Rr0=S(()=>{TO();EO();xv=Object.create(null)});var RL1=class{name="TrieRouter";#Y;constructor(){this.#Y=new Cr0}add(Y,Q,X){let J=br(Q);if(J){for(let G=0,K=J.length;G<K;G++)this.#Y.insert(Y,J[G],X);return}this.#Y.insert(Y,Q,X)}match(Y,Q){return this.#Y.search(Y,Q)}};var Ir0=S(()=>{EO();Rr0()});var jr0=S(()=>{Ir0()});var qQ;var Sr0=S(()=>{Dr0();Pr0();Tr0();jr0();qQ=class extends zr0{constructor(Y={}){super(Y);this.router=Y.router??new CL1({routers:[new dr,new RL1]})}}});var GK=S(()=>{Sr0()});var $c6,Fc6,IL1=(Y,Q)=>{if(Q&&Y.indexOf(Q)===-1)return{};let X=Y.trim().split(";"),J={};for(let G of X){G=G.trim();let K=G.indexOf("=");if(K===-1)continue;let W=G.substring(0,K).trim();if(Q&&Q!==W||!$c6.test(W))continue;let Z=G.substring(K+1).trim();if(Z.startsWith('"')&&Z.endsWith('"'))Z=Z.slice(1,-1);if(Fc6.test(Z)){if(J[W]=Z.indexOf("%")!==-1?SP(Z,vv):Z,Q)break}}return J};var kr0=S(()=>{EO();$c6=/^[\w!#$%&'*.^`|~+-]+$/,Fc6=/^[ !#-:<-[\]-~]*$/});var vr0=(Y,Q,X)=>{let J=Y.req.raw.headers.get("Cookie");if(typeof Q==="string"){if(!J)return;let K=Q;if(X==="secure")K="__Secure-"+Q;else if(X==="host")K="__Host-"+Q;return IL1(J,K)[K]}if(!J)return{};return IL1(J)};var _r0=S(()=>{kr0()});var yr0=(Y)=>{let X={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...Y},J=((K)=>{if(typeof K==="string")if(K==="*")return()=>K;else return(W)=>K===W?W:null;else if(typeof K==="function")return K;else return(W)=>K.includes(W)?W:null})(X.origin),G=((K)=>{if(typeof K==="function")return K;else if(Array.isArray(K))return()=>K;else return()=>[]})(X.allowMethods);return async function(W,Z){function H(F,V){W.res.headers.set(F,V)}let $=await J(W.req.header("origin")||"",W);if($)H("Access-Control-Allow-Origin",$);if(X.credentials)H("Access-Control-Allow-Credentials","true");if(X.exposeHeaders?.length)H("Access-Control-Expose-Headers",X.exposeHeaders.join(","));if(W.req.method==="OPTIONS"){if(X.origin!=="*")H("Vary","Origin");if(X.maxAge!=null)H("Access-Control-Max-Age",X.maxAge.toString());let F=await G(W.req.header("origin")||"",W);if(F.length)H("Access-Control-Allow-Methods",F.join(","));let V=X.allowHeaders;if(!V?.length){let B=W.req.header("Access-Control-Request-Headers");if(B)V=B.split(/\s*,\s*/)}if(V?.length)H("Access-Control-Allow-Headers",V.join(",")),W.res.headers.append("Vary","Access-Control-Request-Headers");return W.res.headers.delete("Content-Length"),W.res.headers.delete("Content-Type"),new Response(null,{headers:W.res.headers,status:204,statusText:"No Content"})}if(await Z(),X.origin!=="*")W.header("Vary","Origin",{append:!0})}};var fr0=()=>{};function Vc6(){let{process:Y,Deno:Q}=globalThis;return!(typeof Q?.noColor==="boolean"?Q.noColor:Y!==void 0?"NO_COLOR"in Y?.env:!1)}async function br0(){let{navigator:Y}=globalThis,Q="cloudflare:workers";return!(Y!==void 0&&Y.userAgent==="Cloudflare-Workers"?await(async()=>{try{return"NO_COLOR"in((await import("cloudflare:workers")).env??{})}catch{return!1}})():!Vc6())}var hr0=()=>{};async function xr0(Y,Q,X,J,G=0,K){let W=Q==="<--"?`${Q} ${X} ${J}`:`${Q} ${X} ${J} ${await Uc6(G)} ${K}`;Y(W)}var qc6=(Y)=>{let[Q,X]=[",","."];return Y.map((G)=>G.replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+Q)).join(X)},Bc6=(Y)=>{let Q=Date.now()-Y;return qc6([Q<1000?Q+"ms":Math.round(Q/1000)+"s"])},Uc6=async(Y)=>{if(await br0())switch(Y/100|0){case 5:return`\x1B[31m${Y}\x1B[0m`;case 4:return`\x1B[33m${Y}\x1B[0m`;case 3:return`\x1B[36m${Y}\x1B[0m`;case 2:return`\x1B[32m${Y}\x1B[0m`}return`${Y}`},gr0=(Y=console.log)=>{return async function(X,J){let{method:G,url:K}=X.req,W=K.slice(K.indexOf("/",8));await xr0(Y,"<--",G,W);let Z=Date.now();await J(),await xr0(Y,"-->",G,W,X.res.status,Bc6(Z))}};var ur0=S(()=>{hr0()});var mr0=()=>{try{return performance.now()}catch{}return Date.now()},jL1=(Y)=>{let Q={total:!0,enabled:!0,totalDescription:"Total Response Time",autoEnd:!0,crossOrigin:!1,...Y};return async function(J,G){let K=[],W=new Map;if(J.get("metric"))return await G();if(J.set("metric",{headers:K,timers:W}),Q.total)vP(J,"total",Q.totalDescription);if(await G(),Q.total)RO(J,"total");if(Q.autoEnd)W.forEach((H,$)=>RO(J,$));if(typeof Q.enabled==="function"?Q.enabled(J):Q.enabled){J.res.headers.append("Server-Timing",K.join(","));let H=typeof Q.crossOrigin==="function"?Q.crossOrigin(J):Q.crossOrigin;if(H)J.res.headers.append("Timing-Allow-Origin",typeof H==="string"?H:"*")}}},lr0=(Y,Q,X,J,G)=>{let K=Y.get("metric");if(!K){console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");return}if(typeof X==="number"){let W=X.toFixed(G||1),Z=J?`${Q};dur=${W};desc="${J}"`:`${Q};dur=${W}`;K.headers.push(Z)}else{let W=X?`${Q};desc="${X}"`:`${Q}`;K.headers.push(W)}},vP=(Y,Q,X)=>{let J=Y.get("metric");if(!J){console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");return}J.timers.set(Q,{description:X,start:mr0()})},RO=(Y,Q,X)=>{let J=Y.get("metric");if(!J){console.warn("Metrics not initialized! Please add the `timing()` middleware to this route!");return}let G=J.timers.get(Q);if(!G){console.warn(`Timer "${Q}" does not exist!`);return}let{description:K,start:W}=G,Z=mr0()-W;lr0(Y,Q,Z,K,X),J.timers.delete(Q)};var dr0=S(()=>{xr()});var pr0=S(()=>{dr0()});class SL1{db;constructor(Y){this.db=Y}async create(Y,Q,X){let J=p8("vir"),G=new Date().toISOString();if(await this.db.insertInto("connections").values({id:J,organization_id:Y,created_by:Q,title:X.title,description:X.description??null,icon:X.icon??null,app_name:null,app_id:null,connection_type:"VIRTUAL",connection_url:`virtual://${J}`,connection_token:null,connection_headers:null,oauth_config:null,configuration_state:null,configuration_scopes:null,metadata:X.metadata?JSON.stringify(X.metadata):null,tools:null,bindings:null,status:X.status??"active",created_at:G,updated_at:G}).execute(),X.connections.length>0)await this.db.insertInto("connection_aggregations").values(X.connections.map((W)=>({id:p8("agg"),parent_connection_id:J,child_connection_id:W.connection_id,selected_tools:W.selected_tools?JSON.stringify(W.selected_tools):null,selected_resources:W.selected_resources?JSON.stringify(W.selected_resources):null,selected_prompts:W.selected_prompts?JSON.stringify(W.selected_prompts):null,dependency_mode:"direct",created_at:G}))).execute();let K=await this.findById(J);if(!K)throw Error(`Failed to create virtual MCP with id: ${J}`);return K}async findById(Y,Q){let X=b3(Y);if(X){let J=Q??X,G=await this.db.selectFrom("connections").selectAll().where("organization_id","=",J).where("status","!=","inactive").where("status","!=","error").execute();return{...Ex(J),connections:G.map((K)=>({connection_id:K.id,selected_tools:null,selected_resources:null,selected_prompts:null}))}}return this.findByIdInternal(this.db,Y)}async findByIdInternal(Y,Q){let X=await Y.selectFrom("connections").selectAll().where("id","=",Q).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!X)return null;let J=await Y.selectFrom("connection_aggregations").selectAll().where("parent_connection_id","=",Q).where("dependency_mode","=","direct").execute();return this.deserializeVirtualMCPEntity(X,J)}async list(Y){let Q=await this.db.selectFrom("connections").selectAll().where("organization_id","=",Y).where("connection_type","=","VIRTUAL").execute(),X=Q.map((K)=>K.id);if(X.length===0)return[];let J=await this.db.selectFrom("connection_aggregations").selectAll().where("parent_connection_id","in",X).where("dependency_mode","=","direct").execute(),G=new Map;for(let K of J){let W=G.get(K.parent_connection_id)??[];W.push(K),G.set(K.parent_connection_id,W)}return Q.map((K)=>this.deserializeVirtualMCPEntity(K,G.get(K.id)??[]))}async listByConnectionId(Y,Q){let J=(await this.db.selectFrom("connection_aggregations").select("parent_connection_id").where("child_connection_id","=",Q).execute()).map((H)=>H.parent_connection_id);if(J.length===0)return[];let G=await this.db.selectFrom("connections").selectAll().where("id","in",J).where("organization_id","=",Y).where("connection_type","=","VIRTUAL").execute();if(G.length===0)return[];let K=G.map((H)=>H.id),W=await this.db.selectFrom("connection_aggregations").selectAll().where("parent_connection_id","in",K).where("dependency_mode","=","direct").execute(),Z=new Map;for(let H of W){let $=Z.get(H.parent_connection_id)??[];$.push(H),Z.set(H.parent_connection_id,$)}return G.map((H)=>this.deserializeVirtualMCPEntity(H,Z.get(H.id)??[]))}async update(Y,Q,X){let J=new Date().toISOString(),G={updated_at:J,updated_by:Q};if(X.title!==void 0)G.title=X.title;if(X.description!==void 0)G.description=X.description;if(X.icon!==void 0)G.icon=X.icon;if(X.status!==void 0)G.status=X.status;if(X.metadata!==void 0)G.metadata=X.metadata?JSON.stringify(X.metadata):null;if(await this.db.updateTable("connections").set(G).where("id","=",Y).where("connection_type","=","VIRTUAL").execute(),X.connections!==void 0){if(await this.db.deleteFrom("connection_aggregations").where("parent_connection_id","=",Y).where("dependency_mode","=","direct").execute(),X.connections.length>0)await this.db.insertInto("connection_aggregations").values(X.connections.map((W)=>({id:p8("agg"),parent_connection_id:Y,child_connection_id:W.connection_id,selected_tools:W.selected_tools?JSON.stringify(W.selected_tools):null,selected_resources:W.selected_resources?JSON.stringify(W.selected_resources):null,selected_prompts:W.selected_prompts?JSON.stringify(W.selected_prompts):null,dependency_mode:"direct",created_at:J}))).execute()}let K=await this.findById(Y);if(!K)throw Error("Virtual MCP not found after update");return K}async delete(Y){await this.db.deleteFrom("connection_aggregations").where("parent_connection_id","=",Y).execute(),await this.db.deleteFrom("connections").where("id","=",Y).where("connection_type","=","VIRTUAL").execute()}async removeConnectionReferences(Y){await this.db.deleteFrom("connection_aggregations").where("child_connection_id","=",Y).execute()}deserializeVirtualMCPEntity(Y,Q){let X=Y.created_at instanceof Date?Y.created_at.toISOString():Y.created_at,J=Y.updated_at instanceof Date?Y.updated_at.toISOString():Y.updated_at,G=Y.status==="active"?"active":"inactive",K=this.parseJson(Y.metadata);return{id:Y.id,organization_id:Y.organization_id,title:Y.title,description:Y.description,icon:Y.icon,status:G,created_at:X,updated_at:J,created_by:Y.created_by,updated_by:Y.updated_by??void 0,metadata:{...K,instructions:K?.instructions??null},connections:Q.map((W)=>({connection_id:W.child_connection_id,selected_tools:this.parseJson(W.selected_tools),selected_resources:this.parseJson(W.selected_resources),selected_prompts:this.parseJson(W.selected_prompts)}))}}parseJson(Y){if(Y===null)return null;if(typeof Y==="string")try{return JSON.parse(Y)}catch{return null}return Y}async listVirtualTools(Y){let Q=await this.db.selectFrom("connections").select(["tools","created_at","updated_at"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!Q)return[];let X=this.parseJson(Q.tools);if(!X)return[];let J=Q.created_at instanceof Date?Q.created_at.toISOString():Q.created_at,G=Q.updated_at instanceof Date?Q.updated_at.toISOString():Q.updated_at;return X.map((K,W)=>({tool:K,originalIndex:W})).filter(({tool:K})=>DB(K)).map(({tool:K,originalIndex:W})=>Ev(`${Y}:${K.name}:${W}`,K,J,G))}async getVirtualTool(Y,Q){let X=await this.db.selectFrom("connections").select(["tools","created_at","updated_at"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!X)return null;let J=this.parseJson(X.tools);if(!J)return null;let G=J.findIndex((H)=>H.name===Q&&DB(H));if(G===-1)return null;let K=J[G],W=X.created_at instanceof Date?X.created_at.toISOString():X.created_at,Z=X.updated_at instanceof Date?X.updated_at.toISOString():X.updated_at;return Ev(`${Y}:${K.name}:${G}`,K,W,Z)}async createVirtualTool(Y,Q,X){let J=new Date().toISOString(),G=await this.db.selectFrom("connections").select(["tools"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!G)throw Error(`Virtual MCP not found: ${Y}`);let K=this.parseJson(G.tools)??[];if(K.some((Z)=>Z.name===Q.name))throw Error(`Tool with name "${Q.name}" already exists`);let W={name:Q.name,description:Q.description,inputSchema:Q.inputSchema,outputSchema:Q.outputSchema,annotations:Q.annotations,_meta:{"mcp.mesh":{"tool.fn":Q.code},connectionDependencies:X}};return K.push(W),await this.db.updateTable("connections").set({tools:JSON.stringify(K),updated_at:J}).where("id","=",Y).execute(),await this.syncIndirectDependencies(Y,X),Ev(`${Y}:${Q.name}:${K.length-1}`,W,J,J)}async updateVirtualTool(Y,Q,X,J){let G=new Date().toISOString(),K=await this.db.selectFrom("connections").select(["tools","created_at"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!K)throw Error(`Virtual MCP not found: ${Y}`);let W=this.parseJson(K.tools)??[],Z=W.findIndex((B)=>B.name===Q&&DB(B));if(Z===-1)throw Error(`Virtual tool not found: ${Q}`);let H=W[Z];if(X.name&&X.name!==Q){if(W.some((B)=>B.name===X.name))throw Error(`Tool with name "${X.name}" already exists`)}let $=J??H._meta.connectionDependencies??[],F={name:X.name??H.name,description:X.description!==void 0?X.description??void 0:H.description,inputSchema:X.inputSchema??H.inputSchema,outputSchema:X.outputSchema!==void 0?X.outputSchema??void 0:H.outputSchema,annotations:X.annotations!==void 0?X.annotations??void 0:H.annotations,_meta:{"mcp.mesh":{"tool.fn":X.code??H._meta["mcp.mesh"]["tool.fn"]},connectionDependencies:$}};if(W[Z]=F,await this.db.updateTable("connections").set({tools:JSON.stringify(W),updated_at:G}).where("id","=",Y).execute(),J!==void 0)await this.recalculateIndirectDependencies(Y,W);let V=K.created_at instanceof Date?K.created_at.toISOString():K.created_at;return Ev(`${Y}:${F.name}:${Z}`,F,V,G)}async deleteVirtualTool(Y,Q){let X=new Date().toISOString(),J=await this.db.selectFrom("connections").select(["tools"]).where("id","=",Y).where("connection_type","=","VIRTUAL").executeTakeFirst();if(!J)throw Error(`Virtual MCP not found: ${Y}`);let G=this.parseJson(J.tools)??[],K=G.findIndex((W)=>W.name===Q&&DB(W));if(K===-1)throw Error(`Virtual tool not found: ${Q}`);G.splice(K,1),await this.db.updateTable("connections").set({tools:G.length>0?JSON.stringify(G):null,updated_at:X}).where("id","=",Y).execute(),await this.recalculateIndirectDependencies(Y,G)}async syncIndirectDependencies(Y,Q){if(Q.length===0)return;let X=new Date().toISOString(),J=await this.db.selectFrom("connection_aggregations").select(["child_connection_id","dependency_mode"]).where("parent_connection_id","=",Y).execute(),G=new Set(J.map((W)=>W.child_connection_id)),K=Q.filter((W)=>!G.has(W));if(K.length>0)await this.db.insertInto("connection_aggregations").values(K.map((W)=>({id:p8("agg"),parent_connection_id:Y,child_connection_id:W,selected_tools:null,selected_resources:null,selected_prompts:null,dependency_mode:"indirect",created_at:X}))).execute()}async recalculateIndirectDependencies(Y,Q){let X=new Set;for(let Z of Q)if(DB(Z)){let H=Z._meta.connectionDependencies??[];for(let $ of H)X.add($)}let J=await this.db.selectFrom("connection_aggregations").select(["id","child_connection_id","dependency_mode"]).where("parent_connection_id","=",Y).execute(),G=J.filter((Z)=>Z.dependency_mode==="indirect"&&!X.has(Z.child_connection_id)).map((Z)=>Z.id);if(G.length>0)await this.db.deleteFrom("connection_aggregations").where("id","in",G).execute();let K=new Set(J.map((Z)=>Z.child_connection_id)),W=Array.from(X).filter((Z)=>!K.has(Z));if(W.length>0){let Z=new Date().toISOString();await this.db.insertInto("connection_aggregations").values(W.map((H)=>({id:p8("agg"),parent_connection_id:Y,child_connection_id:H,selected_tools:null,selected_resources:null,selected_prompts:null,dependency_mode:"indirect",created_at:Z}))).execute()}}}var cr0=S(()=>{LG();QY();wF()});class kL1{patterns=[{type:"email",regex:/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g},{type:"api_key",regex:/(?:api[_-]?key|token|secret|password|bearer)\s*[:=]\s*['"]?[\w-]{16,}['"]?/gi},{type:"jwt",regex:/eyJ[A-Za-z0-9-_]+\.eyJ[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+/=]*/g},{type:"credit_card",regex:/\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b/g},{type:"ssn",regex:/\b\d{3}-\d{2}-\d{4}\b/g}];redact(Y){if(Y===null||Y===void 0)return Y;if(typeof Y==="string")return this.redactString(Y);if(Array.isArray(Y))return Y.map((Q)=>this.redact(Q));if(typeof Y==="object"){let Q={};for(let[X,J]of Object.entries(Y)){let G=this.redactString(X);Q[G]=this.redact(J)}return Q}return Y}redactString(Y){let Q=Y;for(let X of this.patterns)Q=Q.replace(X.regex,`[REDACTED:${X.type}]`);return Q}}import{sql as E6}from"kysely";class vL1{db;redactor;databaseType;constructor(Y,Q="sqlite"){this.db=Y;this.redactor=new kL1,this.databaseType=Q}jsonExtract(Y,Q){if(this.databaseType==="postgres")return E6`(${E6.ref(Y)}::jsonb)->>${Q}`;let X=`$.${Q}`;return E6`json_extract(${E6.ref(Y)}, ${X})`}jsonExtractWithCommas(Y,Q){if(this.databaseType==="postgres")return E6`(',' || (${E6.ref(Y)}::jsonb)->>${Q} || ',')`;let X=`$.${Q}`;return E6`(',' || json_extract(${E6.ref(Y)}, ${X}) || ',')`}escapeLikeWildcards(Y){return Y.replace(/\\/g,"\\\\").replace(/%/g,"\\%").replace(/_/g,"\\_")}async log(Y){await this.logBatch([Y])}async logBatch(Y){if(Y.length===0)return;let Q=Y.map((X)=>({...X,input:this.redactor.redact(X.input),output:this.redactor.redact(X.output)}));await this.db.transaction().execute(async(X)=>{await X.insertInto("monitoring_logs").values(Q.map((J)=>this.toDbRow(J))).execute()})}async query(Y){let Q=this.db.selectFrom("monitoring_logs").selectAll(),X=this.db.selectFrom("monitoring_logs").select((Z)=>Z.fn.countAll().as("count"));if(Y.organizationId)Q=Q.where("organization_id","=",Y.organizationId),X=X.where("organization_id","=",Y.organizationId);if(Y.connectionId)Q=Q.where("connection_id","=",Y.connectionId),X=X.where("connection_id","=",Y.connectionId);if(Y.excludeConnectionIds&&Y.excludeConnectionIds.length>0)Q=Q.where("connection_id","not in",Y.excludeConnectionIds),X=X.where("connection_id","not in",Y.excludeConnectionIds);if(Y.virtualMcpId)Q=Q.where("virtual_mcp_id","=",Y.virtualMcpId),X=X.where("virtual_mcp_id","=",Y.virtualMcpId);if(Y.toolName)Q=Q.where("tool_name","=",Y.toolName),X=X.where("tool_name","=",Y.toolName);if(Y.isError!==void 0)Q=Q.where("is_error","=",Y.isError?1:0),X=X.where("is_error","=",Y.isError?1:0);if(Y.startDate)Q=Q.where("timestamp",">=",Y.startDate.toISOString()),X=X.where("timestamp",">=",Y.startDate.toISOString());if(Y.endDate)Q=Q.where("timestamp","<=",Y.endDate.toISOString()),X=X.where("timestamp","<=",Y.endDate.toISOString());if(Y.propertyFilters)Q=this.applyPropertyFilters(Q,Y.propertyFilters),X=this.applyPropertyFilters(X,Y.propertyFilters);if(Q=Q.orderBy("timestamp","desc"),Y.limit)Q=Q.limit(Y.limit);if(Y.offset)Q=Q.offset(Y.offset);let[J,G]=await Promise.all([Q.execute(),X.executeTakeFirst()]),K=Number(G?.count||0);return{logs:J.map((Z)=>this.fromDbRow(Z)),total:K}}async getStats(Y){let Q=this.db.selectFrom("monitoring_logs").where("organization_id","=",Y.organizationId);if(Y.startDate)Q=Q.where("timestamp",">=",Y.startDate.toISOString());if(Y.endDate)Q=Q.where("timestamp","<=",Y.endDate.toISOString());let X=await Q.select([(W)=>W.fn.countAll().as("total_count"),(W)=>W.fn.sum(W.ref("is_error")).as("error_count"),(W)=>W.fn.avg("duration_ms").as("avg_duration")]).executeTakeFirst(),J=Number(X?.total_count||0),G=Number(X?.error_count||0),K=Number(X?.avg_duration||0);return{totalCalls:J,errorRate:J>0?G/J:0,avgDurationMs:K}}async aggregate(Y){let{organizationId:Q,path:X,from:J,aggregation:G,groupBy:K,groupByColumn:W,interval:Z,filters:H}=Y,$=J==="input"?"input":"output",F=this.db.selectFrom("monitoring_logs").where("organization_id","=",Q);if(H?.connectionIds&&H.connectionIds.length>0)F=F.where("connection_id","in",H.connectionIds);if(H?.virtualMcpIds&&H.virtualMcpIds.length>0)F=F.where("virtual_mcp_id","in",H.virtualMcpIds);if(H?.toolNames&&H.toolNames.length>0)F=F.where("tool_name","in",H.toolNames);if(H?.startDate)F=F.where("timestamp",">=",H.startDate.toISOString());if(H?.endDate)F=F.where("timestamp","<=",H.endDate.toISOString());if(H?.propertyFilters)F=this.applyPropertyFilters(F,H.propertyFilters);let V=this.jsonExtractPath($,X);if(W){let U=E6.ref(W),z=F.select([E6`${U}`.as("group_key"),this.aggregationExpression(G,V).as("agg_value")]).where(E6`${U}`,"is not",null).groupBy(E6`${U}`).orderBy(E6`agg_value`,"desc");if(Y.limit)z=z.limit(Y.limit);return{value:null,groups:(await z.execute()).map((L)=>({key:String(L.group_key),value:Number(L.agg_value)||0}))}}if(K){let U=this.jsonExtractPathText($,K),z=F.select([E6`${U}`.as("group_key"),this.aggregationExpression(G,V).as("agg_value")]).where(E6`${U}`,"is not",null).groupBy(E6`${U}`).orderBy(E6`agg_value`,"desc");if(Y.limit)z=z.limit(Y.limit);return{value:null,groups:(await z.execute()).map((L)=>({key:String(L.group_key),value:Number(L.agg_value)||0}))}}if(Z){let U=this.timeBucketExpression(Z);return{value:null,timeseries:(await F.select([U.as("time_bucket"),this.aggregationExpression(G,V).as("agg_value")]).groupBy(E6`time_bucket`).orderBy(E6`time_bucket`).execute()).map((D)=>({timestamp:String(D.time_bucket),value:Number(D.agg_value)||0}))}}let B=await F.select([this.aggregationExpression(G,V).as("agg_value")]).executeTakeFirst();return{value:B?Number(B.agg_value)||0:null}}async countMatched(Y){let{organizationId:Q,path:X,from:J,filters:G}=Y,K=J==="input"?"input":"output",W=this.db.selectFrom("monitoring_logs").where("organization_id","=",Q);if(G?.connectionIds&&G.connectionIds.length>0)W=W.where("connection_id","in",G.connectionIds);if(G?.toolNames&&G.toolNames.length>0)W=W.where("tool_name","in",G.toolNames);if(G?.startDate)W=W.where("timestamp",">=",G.startDate.toISOString());if(G?.endDate)W=W.where("timestamp","<=",G.endDate.toISOString());if(G?.propertyFilters)W=this.applyPropertyFilters(W,G.propertyFilters);let Z=this.jsonExtractPathText(K,X),H=await W.where(E6`${Z}`,"is not",null).select(($)=>$.fn.countAll().as("count")).executeTakeFirst();return Number(H?.count||0)}jsonExtractPath(Y,Q){if(this.databaseType==="postgres"){let J=`{${Q.replace(/^\$\.?/,"").split(".").join(",")}}`;return E6`(${E6.ref(Y)}::jsonb #>> ${J})::numeric`}return E6`CAST(json_extract(${E6.ref(Y)}, ${Q}) AS REAL)`}jsonExtractPathText(Y,Q){if(this.databaseType==="postgres"){let J=`{${Q.replace(/^\$\.?/,"").split(".").join(",")}}`;return E6`(${E6.ref(Y)}::jsonb #>> ${J})`}return E6`json_extract(${E6.ref(Y)}, ${Q})`}aggregationExpression(Y,Q){switch(Y){case"sum":return E6`COALESCE(SUM(${Q}), 0)`;case"avg":return E6`COALESCE(AVG(${Q}), 0)`;case"min":return E6`MIN(${Q})`;case"max":return E6`MAX(${Q})`;case"count":return E6`COUNT(${Q})`;case"count_all":return E6`COUNT(*)`;case"last":return E6`MAX(${Q})`;default:return E6`SUM(${Q})`}}timeBucketExpression(Y){let Q=Y.match(/^(\d+)([mhd])$/);if(!Q)throw Error(`Invalid interval format: ${Y}. Use format like "1h", "1d", "15m"`);let[,X,J]=Q;if(!X||!J)throw Error(`Invalid interval format: ${Y}`);let G=parseInt(X,10);if(this.databaseType==="postgres"){let K;switch(J){case"m":K="minute";break;case"h":K="hour";break;case"d":K="day";break;default:K="hour"}if(G===1)return E6`date_trunc(${K}, timestamp::timestamp)`;let Z=G*(J==="m"?60:J==="h"?3600:86400);return E6`to_timestamp(floor(extract(epoch from timestamp::timestamp) / ${Z}) * ${Z})`}switch(J){case"m":if(G===1)return E6`strftime('%Y-%m-%d %H:%M:00', timestamp)`;return E6`strftime('%Y-%m-%d %H:', timestamp) || printf('%02d', (cast(strftime('%M', timestamp) as integer) / ${G}) * ${G}) || ':00'`;case"h":if(G===1)return E6`strftime('%Y-%m-%d %H:00:00', timestamp)`;return E6`strftime('%Y-%m-%d ', timestamp) || printf('%02d', (cast(strftime('%H', timestamp) as integer) / ${G}) * ${G}) || ':00:00'`;case"d":return E6`strftime('%Y-%m-%d 00:00:00', timestamp)`;default:return E6`strftime('%Y-%m-%d %H:00:00', timestamp)`}}applyPropertyFilters(Y,Q){let{properties:X,propertyKeys:J,propertyPatterns:G,propertyInValues:K}=Q;if(X)for(let[W,Z]of Object.entries(X)){let H=this.jsonExtract("properties",W);Y=Y.where(H,"=",Z)}if(J&&J.length>0)for(let W of J){let Z=this.jsonExtract("properties",W);Y=Y.where(Z,"is not",null)}if(G)for(let[W,Z]of Object.entries(G)){let H=this.jsonExtract("properties",W),$=this.databaseType==="postgres"?"ilike":"like";Y=Y.where(H,$,Z)}if(K)for(let[W,Z]of Object.entries(K)){let H=this.jsonExtractWithCommas("properties",W),F=`%,${this.escapeLikeWildcards(Z)},%`,V=E6`${H} LIKE ${F} ESCAPE '\\'`;Y=Y.where(V)}return Y}toDbRow(Y){return{id:Y.id||p8("log"),organization_id:Y.organizationId,connection_id:Y.connectionId,connection_title:Y.connectionTitle,tool_name:Y.toolName,input:JSON.stringify(Y.input),output:JSON.stringify(Y.output),is_error:Y.isError?1:0,error_message:Y.errorMessage||null,duration_ms:Y.durationMs,timestamp:Y.timestamp instanceof Date?Y.timestamp.toISOString():Y.timestamp,user_id:Y.userId||null,request_id:Y.requestId,user_agent:Y.userAgent||null,virtual_mcp_id:Y.virtualMcpId||null,properties:Y.properties?JSON.stringify(Y.properties):null}}fromDbRow(Y){let Q=typeof Y.input==="string"?JSON.parse(Y.input):Y.input,X=typeof Y.output==="string"?JSON.parse(Y.output):Y.output,J=typeof Y.timestamp==="string"?new Date(Y.timestamp):Y.timestamp,G=Y.properties?typeof Y.properties==="string"?JSON.parse(Y.properties):Y.properties:null;return{id:Y.id,organizationId:Y.organization_id,connectionId:Y.connection_id,connectionTitle:Y.connection_title,toolName:Y.tool_name,input:Q,output:X,isError:Y.is_error===1,errorMessage:Y.error_message,durationMs:Y.duration_ms,timestamp:J,userId:Y.user_id,requestId:Y.request_id,userAgent:Y.user_agent,virtualMcpId:Y.virtual_mcp_id,properties:G}}}var nr0=S(()=>{LG()});class _L1{db;constructor(Y){this.db=Y}async create(Y,Q,X){let J=p8("dash"),G=new Date().toISOString();return await this.db.insertInto("monitoring_dashboards").values({id:J,organization_id:Y,name:X.name,description:X.description??null,filters:X.filters?JSON.stringify(X.filters):null,widgets:JSON.stringify(X.widgets),created_by:Q,created_at:G,updated_at:G}).execute(),{id:J,organizationId:Y,name:X.name,description:X.description??null,filters:X.filters??null,widgets:X.widgets,createdBy:Q,createdAt:G,updatedAt:G}}async get(Y){let Q=await this.db.selectFrom("monitoring_dashboards").selectAll().where("id","=",Y).executeTakeFirst();if(!Q)return null;return this.fromDbRow(Q)}async list(Y){return(await this.db.selectFrom("monitoring_dashboards").selectAll().where("organization_id","=",Y).orderBy("created_at","desc").execute()).map((X)=>this.fromDbRow(X))}async update(Y,Q){let J={updated_at:new Date().toISOString()};if(Q.name!==void 0)J.name=Q.name;if(Q.description!==void 0)J.description=Q.description;if(Q.filters!==void 0)J.filters=Q.filters?JSON.stringify(Q.filters):null;if(Q.widgets!==void 0)J.widgets=JSON.stringify(Q.widgets);await this.db.updateTable("monitoring_dashboards").set(J).where("id","=",Y).execute();let G=await this.get(Y);if(!G)throw Error(`Dashboard ${Y} not found after update`);return G}async delete(Y){await this.db.deleteFrom("monitoring_dashboards").where("id","=",Y).execute()}fromDbRow(Y){let Q=Y.filters?typeof Y.filters==="string"?JSON.parse(Y.filters):Y.filters:null,X=typeof Y.widgets==="string"?JSON.parse(Y.widgets):Y.widgets;return{id:Y.id,organizationId:Y.organization_id,name:Y.name,description:Y.description,filters:Q,widgets:X,createdBy:Y.created_by,createdAt:Y.created_at instanceof Date?Y.created_at.toISOString():Y.created_at,updatedAt:Y.updated_at instanceof Date?Y.updated_at.toISOString():Y.updated_at}}}var ir0=S(()=>{LG()});class yL1{db;constructor(Y){this.db=Y}async get(Y){let Q=await this.db.selectFrom("organization_settings").selectAll().where("organizationId","=",Y).executeTakeFirst();if(!Q)return null;return{organizationId:Q.organizationId,sidebar_items:Q.sidebar_items?typeof Q.sidebar_items==="string"?JSON.parse(Q.sidebar_items):Q.sidebar_items:null,enabled_plugins:Q.enabled_plugins?typeof Q.enabled_plugins==="string"?JSON.parse(Q.enabled_plugins):Q.enabled_plugins:null,createdAt:Q.createdAt,updatedAt:Q.updatedAt}}async upsert(Y,Q){let X=new Date().toISOString(),J=Q?.sidebar_items?JSON.stringify(Q.sidebar_items):null,G=Q?.enabled_plugins?JSON.stringify(Q.enabled_plugins):null;await this.db.insertInto("organization_settings").values({organizationId:Y,sidebar_items:J,enabled_plugins:G,createdAt:X,updatedAt:X}).onConflict((W)=>W.column("organizationId").doUpdateSet({sidebar_items:J?J:void 0,enabled_plugins:G?G:void 0,updatedAt:X})).execute();let K=await this.get(Y);if(!K)return{organizationId:Y,sidebar_items:Q?.sidebar_items??null,enabled_plugins:Q?.enabled_plugins??null,createdAt:X,updatedAt:X};return K}}class fL1{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,projectId:Y.project_id,connectionId:Y.connection_id,createdAt:Y.created_at}}async list(Y){return(await this.db.selectFrom("project_connections").selectAll().where("project_id","=",Y).orderBy("created_at","asc").execute()).map((X)=>this.parseRow(X))}async add(Y,Q){let X=new Date().toISOString(),J=p8("pc"),G=await this.db.insertInto("project_connections").values({id:J,project_id:Y,connection_id:Q,created_at:X}).onConflict((W)=>W.columns(["project_id","connection_id"]).doNothing()).returning(["id","project_id","connection_id","created_at"]).executeTakeFirst();if(G)return this.parseRow(G);let K=await this.db.selectFrom("project_connections").selectAll().where("project_id","=",Y).where("connection_id","=",Q).executeTakeFirst();if(!K)throw Error(`Project connection not found after conflict: project=${Y}, connection=${Q}`);return this.parseRow(K)}async remove(Y,Q){return((await this.db.deleteFrom("project_connections").where("project_id","=",Y).where("connection_id","=",Q).executeTakeFirst()).numDeletedRows??0n)>0n}}var ar0=S(()=>{LG()});class bL1{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,projectId:Y.project_id,pluginId:Y.plugin_id,connectionId:Y.connection_id,settings:Y.settings?typeof Y.settings==="string"?JSON.parse(Y.settings):Y.settings:null,createdAt:Y.created_at,updatedAt:Y.updated_at}}async list(Y){return(await this.db.selectFrom("project_plugin_configs").selectAll().where("project_id","=",Y).execute()).map((X)=>this.parseRow(X))}async get(Y,Q){let X=await this.db.selectFrom("project_plugin_configs").selectAll().where("project_id","=",Y).where("plugin_id","=",Q).executeTakeFirst();return X?this.parseRow(X):null}async upsert(Y,Q,X){let J=new Date().toISOString();if(await this.get(Y,Q)){let Z={updated_at:J};if(X.connectionId!==void 0)Z.connection_id=X.connectionId;if(X.settings!==void 0)Z.settings=X.settings?JSON.stringify(X.settings):null;await this.db.updateTable("project_plugin_configs").set(Z).where("project_id","=",Y).where("plugin_id","=",Q).execute();let H=await this.get(Y,Q);if(!H)throw Error("Failed to update project plugin config");return H}let K=p8("ppc");await this.db.insertInto("project_plugin_configs").values({id:K,project_id:Y,plugin_id:Q,connection_id:X.connectionId??null,settings:X.settings?JSON.stringify(X.settings):null,created_at:J,updated_at:J}).execute();let W=await this.get(Y,Q);if(!W)throw Error("Failed to create project plugin config");return W}async delete(Y,Q){return((await this.db.deleteFrom("project_plugin_configs").where("project_id","=",Y).where("plugin_id","=",Q).executeTakeFirst()).numDeletedRows??0n)>0n}async getBoundConnectionsForProjects(Y){if(Y.length===0)return new Map;let Q=await this.db.selectFrom("project_plugin_configs").innerJoin("connections","connections.id","project_plugin_configs.connection_id").select(["project_plugin_configs.project_id","connections.id as connection_id","connections.title","connections.icon"]).where("project_plugin_configs.project_id","in",Y).where("project_plugin_configs.connection_id","is not",null).execute(),X=new Map;for(let J of Q){let G=J.project_id;if(!X.has(G))X.set(G,[]);X.get(G).push({id:J.connection_id,title:J.title,icon:J.icon})}return X}}var rr0=S(()=>{LG()});class hL1{db;constructor(Y){this.db=Y}async listOrgTags(Y){return(await this.db.selectFrom("organization_tags").selectAll().where("organization_id","=",Y).orderBy("name","asc").execute()).map((X)=>this.tagFromDbRow(X))}async getTag(Y){let Q=await this.db.selectFrom("organization_tags").selectAll().where("id","=",Y).executeTakeFirst();return Q?this.tagFromDbRow(Q):null}async getTagByName(Y,Q){let X=await this.db.selectFrom("organization_tags").selectAll().where("organization_id","=",Y).where("name","=",Q).executeTakeFirst();return X?this.tagFromDbRow(X):null}async createTag(Y,Q){let X=p8("tag"),J=new Date().toISOString();await this.db.insertInto("organization_tags").values({id:X,organization_id:Y,name:Q,created_at:J}).onConflict((K)=>K.columns(["organization_id","name"]).doNothing()).execute();let G=await this.getTagByName(Y,Q);if(!G)throw Error(`Failed to create or retrieve tag: ${Q}`);return G}async deleteTag(Y){await this.db.deleteFrom("organization_tags").where("id","=",Y).execute()}async getMemberTags(Y){return(await this.db.selectFrom("member_tags").innerJoin("organization_tags","organization_tags.id","member_tags.tag_id").select(["organization_tags.id","organization_tags.organization_id","organization_tags.name","organization_tags.created_at"]).where("member_tags.member_id","=",Y).orderBy("organization_tags.name","asc").execute()).map((X)=>this.tagFromDbRow(X))}async setMemberTags(Y,Q){await this.db.transaction().execute(async(X)=>{if(await X.deleteFrom("member_tags").where("member_id","=",Y).execute(),Q.length>0){let J=new Date().toISOString();await X.insertInto("member_tags").values(Q.map((G)=>({id:p8("mtag"),member_id:Y,tag_id:G,created_at:J}))).execute()}})}async addMemberTag(Y,Q){let X=new Date().toISOString();await this.db.insertInto("member_tags").values({id:p8("mtag"),member_id:Y,tag_id:Q,created_at:X}).onConflict((J)=>J.columns(["member_id","tag_id"]).doNothing()).execute()}async removeMemberTag(Y,Q){await this.db.deleteFrom("member_tags").where("member_id","=",Y).where("tag_id","=",Q).execute()}async verifyMemberOrg(Y,Q){return await this.db.selectFrom("member").select("id").where("id","=",Y).where("organizationId","=",Q).executeTakeFirst()!==void 0}async getUserTagsInOrg(Y,Q){return(await this.db.selectFrom("member").innerJoin("member_tags","member_tags.member_id","member.id").innerJoin("organization_tags","organization_tags.id","member_tags.tag_id").select(["organization_tags.id","organization_tags.organization_id","organization_tags.name","organization_tags.created_at"]).where("member.userId","=",Y).where("member.organizationId","=",Q).orderBy("organization_tags.name","asc").execute()).map((J)=>this.tagFromDbRow(J))}async getMembersWithTags(Y){let Q=await this.db.selectFrom("member").leftJoin("member_tags","member_tags.member_id","member.id").leftJoin("organization_tags","organization_tags.id","member_tags.tag_id").select(["member.id as memberId","organization_tags.name as tagName"]).where("member.organizationId","=",Y).execute(),X=new Map;for(let J of Q){if(!X.has(J.memberId))X.set(J.memberId,[]);if(J.tagName)X.get(J.memberId).push(J.tagName)}return X}tagFromDbRow(Y){return{id:Y.id,organizationId:Y.organization_id,name:Y.name,createdAt:Y.created_at}}}var or0=S(()=>{LG()});class xL1{db;constructor(Y){this.db=Y}async findById(Y,Q){let X=await this.db.selectFrom("user").select(["user.id","user.name","user.email","user.image","user.createdAt","user.updatedAt"]).where("user.id","=",Y).where((J)=>J.exists(J.selectFrom("member as m1").innerJoin("member as m2","m1.organizationId","m2.organizationId").select("m1.id").where("m1.userId","=",Y).where("m2.userId","=",Q))).executeTakeFirst();if(!X)return null;return{id:X.id,name:X.name,email:X.email,role:"",createdAt:X.createdAt,updatedAt:X.updatedAt,image:X.image??void 0}}}async function sr0(Y,Q){return(await Q.storage.connections.findById(Y))?.connection_url??null}function zc6(Y){let Q=Y.toLowerCase();return Q.includes("resource_metadata=")||Q.includes("invalid_token")||Q.includes("oauth")}async function tr0(Y,Q={}){try{let X=await fetch(Y,{method:"POST",headers:{...Q,"Content-Type":"application/json",Accept:"application/json, text/event-stream"},body:JSON.stringify({jsonrpc:"2.0",id:0,method:"initialize",params:{protocolVersion:"2025-06-18",capabilities:{},clientInfo:{name:"mcp-mesh-proxy",version:"1.0.0"}}})});if(X.status===401){let J=X.headers.get("WWW-Authenticate");if(J){if(zc6(J))return J}if(await Dc6(Y))return'Bearer realm="mcp"'}return null}catch{return null}}async function Dc6(Y){try{let Q=new URL(Y),X=new URL("/.well-known/oauth-authorization-server",Q.origin),J=await fetch(X.toString(),{method:"GET",headers:{Accept:"application/json"}});if(J.ok){let G=await J.json();if(G.authorization_endpoint||G.token_endpoint||G.issuer)return!0}return!1}catch{return!1}}async function cr(Y){let X=new URL(Y).pathname;if(X.endsWith("/"))X=X.slice(0,-1);let J=new URL(Y);J.pathname=`${X}/.well-known/oauth-protected-resource`;let G=await fetch(J.toString(),{method:"GET",headers:{Accept:"application/json"}});if(G.ok)return G;if(!gL1.includes(G.status))return G;let K=new URL(Y);if(K.pathname=`/.well-known/oauth-protected-resource${X}`,G=await fetch(K.toString(),{method:"GET",headers:{Accept:"application/json"}}),!gL1.includes(G.status))return G;let W=new URL(Y);return W.pathname="/.well-known/oauth-protected-resource",G=await fetch(W.toString(),{method:"GET",headers:{Accept:"application/json"}}),G}async function Oc6(Y,Q){let X=await sr0(Y,Q);if(!X)return null;let J;try{J=new URL(X).origin}catch{return null}try{let G=await cr(X);if(G.ok){let K=await G.json();if(K.authorization_servers?.[0])return K.authorization_servers[0]}}catch{}return J}async function er0(Y){let Q=Y.get("meshContext");if(!Q)Q=await TF.create(Y.req.raw),Y.set("meshContext",Q);return Q}async function Yo0({error:Y,reqUrl:Q,connectionId:X,connectionUrl:J,headers:G}){let K=Y.message?.toLowerCase()??"";if(!(Y.status===401||Y.code===401||Y.message?.includes("401")||K.includes("unauthorized")||K.includes("invalid_token")||K.includes("api key required")||K.includes("api-key required")))return null;if(Boolean(await tr0(J,G)))return new Response(null,{status:401,headers:{"WWW-Authenticate":`Bearer realm="mcp",resource_metadata="${Q.origin}/mcp/${X}/.well-known/oauth-protected-resource"`}});return new Response(JSON.stringify({error:"unauthorized",message:"Authentication required but server does not support OAuth"}),{status:401,headers:{"Content-Type":"application/json"}})}async function uL1(Y){let X=new URL(Y).pathname;if(X.endsWith("/"))X=X.slice(0,-1);let J=X!==""&&X!=="/",G=[];if(J){let W=new URL(Y);W.pathname=`/.well-known/oauth-authorization-server${X}`,G.push(W);let Z=new URL(Y);Z.pathname=`/.well-known/openid-configuration${X}`,G.push(Z);let H=new URL(Y);H.pathname=`${X}/.well-known/openid-configuration`,G.push(H)}else{let W=new URL(Y);W.pathname="/.well-known/oauth-authorization-server",G.push(W);let Z=new URL(Y);Z.pathname="/.well-known/openid-configuration",G.push(Z)}let K=null;for(let W of G){if(K=await fetch(W.toString(),{method:"GET",headers:{Accept:"application/json"}}),K.ok)return K;if(K.status!==404&&K.status!==401)return K}return K}var pr,gL1,Qo0=(Y)=>{if(!(Y.hostname==="localhost"||Y.hostname.endsWith(".localhost")||Y.hostname==="127.0.0.1"))Y.protocol="https:";return Y},Xo0=async(Y)=>{let Q=Y.req.param("connectionId"),X=await er0(Y),J=await sr0(Q,X);if(!J)return Y.json({error:"Connection not found"},404);let G=Qo0(new URL(Y.req.url)),K=`${G.origin}/mcp/${Q}`,W=`${G.origin}/oauth-proxy/${Q}`;try{let Z=await cr(J);if(!Z.ok&&gL1.includes(Z.status)){if(await tr0(J))return new Response(JSON.stringify({resource:K,authorization_servers:[W],bearer_methods_supported:["header"],scopes_supported:["*"]}),{status:200,headers:{"Content-Type":"application/json"}});return new Response(Z.body,{status:Z.status,statusText:Z.statusText,headers:{"Content-Type":"application/json"}})}if(!Z.ok)return new Response(Z.body,{status:Z.status,statusText:Z.statusText,headers:{"Content-Type":"application/json"}});let H=await Z.json();if("issuer"in H&&!("resource"in H)&&(("authorization_endpoint"in H)||("token_endpoint"in H))){let V={resource:K,authorization_servers:[W],bearer_methods_supported:["header"],scopes_supported:"scopes_supported"in H&&Array.isArray(H.scopes_supported)&&H.scopes_supported.length>0?H.scopes_supported:["*"]};return new Response(JSON.stringify(V),{status:200,headers:{"Content-Type":"application/json"}})}let F={...H,resource:K,authorization_servers:[W]};return new Response(JSON.stringify(F),{status:Z.status,statusText:Z.statusText,headers:{"Content-Type":"application/json"}})}catch(Z){let H=Z;return console.error("[oauth-proxy] Failed to proxy OAuth protected resource metadata:",H),Y.json({error:"Failed to proxy OAuth metadata",message:H.message},502)}},Jo0;var mL1=S(()=>{GK();nr();pr=new qQ,gL1=[404,401,406];pr.get("/.well-known/oauth-protected-resource/mcp/:connectionId",(Y)=>Xo0(Y));pr.get("/mcp/:connectionId/.well-known/oauth-protected-resource",(Y)=>Xo0(Y));pr.get("/.well-known/oauth-authorization-server/oauth-proxy/:connectionId",async(Y)=>{let Q=Y.req.param("connectionId"),X=await er0(Y),J=await Oc6(Q,X);if(!J)return Y.json({error:"Connection not found or no auth server"},404);try{let G=await uL1(J);if(!G.ok)return new Response(G.body,{status:G.status,statusText:G.statusText,headers:{"Content-Type":"application/json"}});let K=await G.json(),Z=`${Qo0(new URL(Y.req.url)).origin}/oauth-proxy/${Q}`,H={...K,authorization_endpoint:K.authorization_endpoint?`${Z}/authorize`:void 0,token_endpoint:K.token_endpoint?`${Z}/token`:void 0,registration_endpoint:K.registration_endpoint?`${Z}/register`:void 0};return new Response(JSON.stringify(H),{status:200,headers:{"Content-Type":"application/json"}})}catch(G){let K=G;return console.error("[oauth-proxy] Failed to proxy auth server metadata:",K),Y.json({error:"Failed to proxy auth server metadata",message:K.message},502)}});Jo0=pr});async function ir(Y,Q){let X=Y.get("meshContext");try{let J=Y.req.header("x-org-id"),G=Y.req.header("x-org-slug"),K=J?J:G?await X.db.selectFrom("organization").select("id").where("slug","=",G).executeTakeFirst().then((U)=>U?.id):null,W=Q?Q:K?KL(K):null;if(!W)return Y.json({error:"Agent ID or organization ID is required"},400);let Z=await X.storage.virtualMcps.findById(W,K??void 0);if(!Z)return Y.json({error:"Agent not found"},404);if(K&&Z.organization_id!==K)return Y.json({error:"Agent not found"},404);if(Z.status!=="active")return Y.json({error:`Agent is inactive: ${Z.id??"Decopilot"}`},503);X.connectionId=Z.id??void 0;let H=await X.db.selectFrom("organization").select(["id","slug","name"]).where("id","=",Z.organization_id).executeTakeFirst();if(H)X.organization={id:H.id,slug:H.slug,name:H.name};let $=rO1(Y.req.query("mode")),F=await OB(Z,X,$),V=IU(F,{name:`mcp-virtual-mcp-${Z.title??"Decopilot"}`,version:"1.0.0"},{capabilities:{tools:{},resources:{},prompts:{}},instructions:Z.metadata?.instructions??void 0}),B=new a$({enableJsonResponse:Y.req.header("Accept")?.includes("application/json")??!1});return await V.connect(B),await B.handleRequest(Y.req.raw)}catch(J){let G=J;return console.error("[virtual-mcp] Error handling virtual MCP request:",G),Y.json({error:"Internal server error",message:G.message},500)}}var lL1,Go0;var dL1=S(()=>{QY();Qk();GK();Cv();lL1=new qQ;lL1.all("/gateway/:virtualMcpId?",async(Y)=>{let Q=Y.req.param("virtualMcpId")||Y.req.header("x-virtual-mcp-id");return ir(Y,Q)});lL1.all("/virtual-mcp/:virtualMcpId?",async(Y)=>{let Q=Y.req.param("virtualMcpId")||Y.req.header("x-virtual-mcp-id");return ir(Y,Q)});Go0=lL1});function IO(Y){let Q={client:{callTool:Y.callTool.bind(Y),listTools:Y.listTools.bind(Y)}};if("callStreamableTool"in Y&&Y.callStreamableTool)return{...Q,callStreamableTool:Y.callStreamableTool.bind(Y)};return Q}async function Zo0(Y,Q,{superUser:X}){let J=typeof Y==="string"?await Q.storage.connections.findById(Y,Q.organization?.id):Y;if(!J)throw Error("Connection not found");if(Q.organization&&J.organization_id!==Q.organization.id)throw Error("Connection does not belong to the active organization");if(Q.organization??={id:J.organization_id},J.status!=="active")throw Error(`Connection inactive: ${J.status}`);let G=await y5(J,Q,X),K=tO1(G,J),W=K.getServerCapabilities()??{tools:{},resources:{},prompts:{}},Z=IU(K,{name:"mcp-mesh-proxy-client",version:"1.0.0"},{capabilities:W,instructions:K.getInstructions()}),{client:H,server:$}=V91();await Z.connect($);let F=new eJ({name:"mcp-mesh-proxy-client",version:"1.0.0"});return await F.connect(H),F}async function Ko0(Y,Q){return Zo0(Y,Q,{superUser:!1})}async function pL1(Y,Q){return Zo0(Y,Q,{superUser:!0})}var ar,Wo0=300000,Ho0=(Y,Q)=>{if(Y.message.includes("not found"))return Q.json({error:Y.message},404);if(Y.message.includes("does not belong to the active organization"))return Q.json({error:"Connection not found"},404);if(Y.message.includes("inactive"))return Q.json({error:Y.message},503);return Q.json({error:"Internal server error",message:Y.message},500)},$o0;var jO=S(()=>{RP();QY();AU();Qk();GK();mL1();dL1();ar=new qQ;ar.all("/",async(Y)=>{return ir(Y,void 0)});ar.all("/:connectionId",async(Y)=>{let Q=Y.req.param("connectionId"),X=Y.get("meshContext");try{try{let J=await X.storage.connections.findById(Q,X.organization?.id);if(!J)throw Error("Connection not found");if(X.organization&&J.organization_id!==X.organization.id)throw Error("Connection does not belong to the active organization");if(X.organization??={id:J.organization_id},J.status!=="active")throw Error(`Connection inactive: ${J.status}`);let G=await sO1(J,X,!1),K=new a$({enableJsonResponse:Y.req.raw.headers.get("Accept")?.includes("application/json")??!1});return await G.connect(K),await K.handleRequest(Y.req.raw)}catch(J){let G=await X.storage.connections.findById(Q,X.organization?.id);if(G?.connection_url){let K=await Yo0({error:J,reqUrl:new URL(Y.req.raw.url),connectionId:Q,connectionUrl:G.connection_url,headers:{}});if(K)return K}throw J}}catch(J){return Ho0(J,Y)}});ar.all("/:connectionId/call-tool/:toolName",async(Y)=>{let Q=Y.req.param("connectionId"),X=Y.req.param("toolName"),J=Y.get("meshContext");try{let G=await J.storage.connections.findById(Q,J.organization?.id);if(!G)return Y.json({error:"Connection not found"},404);let W=await(await y5(G,J,!1)).callTool({name:X,arguments:await Y.req.json()});if(W instanceof Response)return W;if(W.isError)return new Response(JSON.stringify(W.content),{headers:{"Content-Type":"application/json"},status:500});return new Response(JSON.stringify(W.structuredContent??W.content),{headers:{"Content-Type":"application/json"}})}catch(G){return Ho0(G,Y)}});$o0=ar});function cL1(Y){let X="You are decopilot, an AI assistant running inside decocms (deco context management system).";if(Y?.trim())X+=`
|
|
1520
1520
|
|
|
1521
1521
|
---
|
|
1522
1522
|
|