@decocms/mesh 2.114.4 → 2.115.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-87pz6CLK.js → AlertCircle-DiL2HrFE.js} +1 -1
- package/dist/client/assets/{AlertOctagon-CdS8EaWw.js → AlertOctagon-2d8rAOd4.js} +1 -1
- package/dist/client/assets/{AlertTriangle--2XdWwTl.js → AlertTriangle-VgUX_bsB.js} +1 -1
- package/dist/client/assets/{ArrowLeft-P05LGWIS.js → ArrowLeft-Br1qiDir.js} +1 -1
- package/dist/client/assets/{ArrowUp-DEd986Yz.js → ArrowUp-BjfCYJa6.js} +1 -1
- package/dist/client/assets/{Check-ss4b3kGL.js → Check-B14Bp2E0.js} +1 -1
- package/dist/client/assets/{CheckCircle-RhCNDucM.js → CheckCircle-qs5k2cFp.js} +1 -1
- package/dist/client/assets/{CheckDone01-B808ZC9T.js → CheckDone01-COU71F1q.js} +1 -1
- package/dist/client/assets/{CheckVerified02-o5r0ZVSD.js → CheckVerified02-C_h0QKPV.js} +1 -1
- package/dist/client/assets/{ChevronDown-Fa8gvE4N.js → ChevronDown-DmZAA_RH.js} +1 -1
- package/dist/client/assets/{ChevronRight-ChAH8Cbi.js → ChevronRight-IL2oOJI2.js} +1 -1
- package/dist/client/assets/{Clock-Dk8zDWze.js → Clock-BeB-7xuQ.js} +1 -1
- package/dist/client/assets/{Code01-C_agqm3t.js → Code01-DnUALMy9.js} +1 -1
- package/dist/client/assets/{Container-Cg4Dgkr4.js → Container-BGGgIzJh.js} +1 -1
- package/dist/client/assets/{Copy01-bMByqBkp.js → Copy01-BZzZvWHY.js} +1 -1
- package/dist/client/assets/{Dataflow03-CEuNPUr-.js → Dataflow03-BnILNUas.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-BLBXXghA.js → DotsHorizontal-C1qTqyiq.js} +1 -1
- package/dist/client/assets/{DotsVertical-Oa06p8Tg.js → DotsVertical-B-SoXTlv.js} +1 -1
- package/dist/client/assets/{Download01-BhULX8s0.js → Download01-CW2ve7I5.js} +1 -1
- package/dist/client/assets/{Edit01-BtYeQc5J.js → Edit01-CA_byL8x.js} +1 -1
- package/dist/client/assets/{Eye-qLu7cENa.js → Eye-DuHzxuzN.js} +1 -1
- package/dist/client/assets/{File02-D2v6m157.js → File02-HWzOQAS5.js} +1 -1
- package/dist/client/assets/{File06-_dVy8VA8.js → File06-6ostm09J.js} +1 -1
- package/dist/client/assets/{FilterLines-DpJa053z.js → FilterLines-n9w8nbRb.js} +1 -1
- package/dist/client/assets/{Globe01-syo4E_rH.js → Globe01-C7OLr5gu.js} +1 -1
- package/dist/client/assets/{Globe02-qg-RL6U7.js → Globe02-DCQdCg-U.js} +1 -1
- package/dist/client/assets/{Grid01-y6wravTy.js → Grid01--gwdVXxp.js} +1 -1
- package/dist/client/assets/{Hash02-BcrU8na2.js → Hash02-B3ztCRZG.js} +1 -1
- package/dist/client/assets/{Home02-BUCKOZtr.js → Home02-5xEMThw1.js} +1 -1
- package/dist/client/assets/{Image01-Cn9rvjGe.js → Image01-CHvGzt2y.js} +1 -1
- package/dist/client/assets/{Inbox01-qG8YVC9s.js → Inbox01-D__eEiRp.js} +1 -1
- package/dist/client/assets/{InfoCircle-CbVsxQ4Q.js → InfoCircle-BaJSxaGK.js} +1 -1
- package/dist/client/assets/{Key01-CnpUPM6j.js → Key01-CAUAOxiV.js} +1 -1
- package/dist/client/assets/{LinkExternal01-uo5sGjy_.js → LinkExternal01-UC_M5qWQ.js} +1 -1
- package/dist/client/assets/{List-B2d-tXq3.js → List-BJooyaoM.js} +1 -1
- package/dist/client/assets/{Loading01-BGxaLQXT.js → Loading01-1Zu_WpPr.js} +1 -1
- package/dist/client/assets/{Lock01-CVHqL_9F.js → Lock01-DPYIJ_nA.js} +1 -1
- package/dist/client/assets/{Pin01-zABFbrLH.js → Pin01-DJanT9uS.js} +1 -1
- package/dist/client/assets/{Play-CIXUmOTN.js → Play-CahYnURS.js} +1 -1
- package/dist/client/assets/{Plus-DiCPboGz.js → Plus-CRFHrfK2.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-DeRXjGPw.js → RefreshCcw01-DuNb9sh9.js} +1 -1
- package/dist/client/assets/{RefreshCw01-CLKI7ij5.js → RefreshCw01-CppBn3YV.js} +1 -1
- package/dist/client/assets/{Rows03-pDN6Wibn.js → Rows03-CjT39fIX.js} +1 -1
- package/dist/client/assets/{Save01-Caa5iL9S.js → Save01-_XMAksec.js} +1 -1
- package/dist/client/assets/{SearchMd-DNHArz2n.js → SearchMd-CZA5t4_M.js} +1 -1
- package/dist/client/assets/{Settings01-76tXwBFs.js → Settings01-CmfD9-kk.js} +1 -1
- package/dist/client/assets/{Share07-Cb8g3CuD.js → Share07-tPlC5hop.js} +1 -1
- package/dist/client/assets/{Shield01-BqSt8I5_.js → Shield01-BTe6K6H4.js} +1 -1
- package/dist/client/assets/{Terminal-bmnW7izs.js → Terminal-JVvp8Qza.js} +1 -1
- package/dist/client/assets/{Tool01-l3ZX94SA.js → Tool01-BY8zBv5Q.js} +1 -1
- package/dist/client/assets/{Trash01-Ds89dEyi.js → Trash01-uafi7Ilf.js} +1 -1
- package/dist/client/assets/{Upload01-CrLebV8u.js → Upload01-j9dbqfwl.js} +1 -1
- package/dist/client/assets/{Users03-973jhxVC.js → Users03-DcEKYrkA.js} +1 -1
- package/dist/client/assets/{XCircle-DzvEACuz.js → XCircle-BUqdRo4A.js} +1 -1
- package/dist/client/assets/{XClose-Gebe3Lpq.js → XClose-BmynBvu4.js} +1 -1
- package/dist/client/assets/{agent-connections-preview-DbSOq9MS.js → agent-connections-preview-PbH9WU_0.js} +1 -1
- package/dist/client/assets/agent-detail-Cq0CB4eM.js +1 -0
- package/dist/client/assets/agents-6ayYcmP9.js +1 -0
- package/dist/client/assets/alert-dialog-BXLdEhYw.js +7 -0
- package/dist/client/assets/{auth-catchall-DxtwIAjW.js → auth-catchall-BmN6aGyF.js} +1 -1
- package/dist/client/assets/{avatar-LGTR0-dJ.js → avatar-Bc7s3LEL.js} +1 -1
- package/dist/client/assets/{badge-C68TEc2s.js → badge-D4AHLMOm.js} +1 -1
- package/dist/client/assets/{binder-DTwuH7RP.js → binder-c0e82ZKj.js} +1 -1
- package/dist/client/assets/{breadcrumb-BOSBMWhe.js → breadcrumb-DM1tOdpW.js} +1 -1
- package/dist/client/assets/{button-CltXgBt_.js → button-DlMEAXru.js} +1 -1
- package/dist/client/assets/{card-DNFGWPL4.js → card-BJlwqw9P.js} +1 -1
- package/dist/client/assets/{checkbox-SgEy5KuG.js → checkbox-2ZZDRGKg.js} +1 -1
- package/dist/client/assets/{circle-alert-DYvJv5Ko.js → circle-alert-BU4aPU4k.js} +1 -1
- package/dist/client/assets/{collection-detail-DOEKC0g2.js → collection-detail-CcvsZ6SX.js} +2 -2
- package/dist/client/assets/{collection-tab-CwxRZx7g.js → collection-tab-D1U8qcC9.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-BYOlimKE.js → collection-table-wrapper-CTR1SyIy.js} +1 -1
- package/dist/client/assets/{collection-tabs-DZs_zgEM.js → collection-tabs-DX49JXWl.js} +1 -1
- package/dist/client/assets/{command-C0kPCKZR.js → command-CZie2XvG.js} +1 -1
- package/dist/client/assets/{connect-BmfBu9IA.js → connect-BuwxUgJG.js} +1 -1
- package/dist/client/assets/{connection-card-CbMxUD52.js → connection-card-CI7L8iKE.js} +1 -1
- package/dist/client/assets/connection-detail-CRaZ-Ye2.js +1 -0
- package/dist/client/assets/connections-B0wIwXTZ.js +1 -0
- package/dist/client/assets/constants-4GzD41KM.js +1 -0
- package/dist/client/assets/constants-PL5hL4qd.js +1 -0
- package/dist/client/assets/{create-organization-dialog-DWhsnVmx.js → create-organization-dialog-CfW7SB8o.js} +1 -1
- package/dist/client/assets/{create-project-dialog-BWMdEfgz.js → create-project-dialog-dfuHufiJ.js} +1 -1
- package/dist/client/assets/dialog-Cwnz3LEA.js +1 -0
- package/dist/client/assets/dropdown-menu-BJqdu9io.js +1 -0
- package/dist/client/assets/dynamic-plugin-layout-aRox8LyK.js +1 -0
- package/dist/client/assets/{empty-state-BMzLHZqs.js → empty-state-BkmlXyqb.js} +1 -1
- package/dist/client/assets/{empty-state-BlbQO4ML.js → empty-state-BlBaHJ3u.js} +1 -1
- package/dist/client/assets/{env-vars-editor-D3JCI8w3.js → env-vars-editor-qzHFuA5w.js} +1 -1
- package/dist/client/assets/{error-boundary-662X7_hb.js → error-boundary-Dk3_bHxS.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BvfJRMa3.js → extract-connection-data-Cl1h0kax.js} +1 -1
- package/dist/client/assets/{file-browser-C-pRVfCH.js → file-browser-BpuuoaOY.js} +2 -2
- package/dist/client/assets/form-B3bK9lhs.js +1 -0
- package/dist/client/assets/{grid-view-DKReXcqi.js → grid-view-tbrO-yA3.js} +1 -1
- package/dist/client/assets/{home-GupKXTmH.js → home-DEEFTVc1.js} +1 -1
- package/dist/client/assets/{index-D05EUZ3I.js → index-1CQrZ9Zl.js} +1 -1
- package/dist/client/assets/{index-C19yOmWI.js → index-2jF2yJ2o.js} +1 -1
- package/dist/client/assets/{index-x5rY3SSD.js → index-BPtZHCt5.js} +2 -2
- package/dist/client/assets/index-CeXKeP7Z.js +1 -0
- package/dist/client/assets/{index-DwOUIYFf.js → index-DGrxQVii.js} +1 -1
- package/dist/client/assets/{index-CEExljIY.js → index-DjF4GflS.js} +1 -1
- package/dist/client/assets/{index-DPXGfIj1.js → index-MzZr0KB3.js} +1 -1
- package/dist/client/assets/index-Pglfh9Lp.css +1 -0
- package/dist/client/assets/{index-SRTXqQcy.js → index-oUlshpJJ.js} +30 -30
- package/dist/client/assets/{infiniteQueryObserver-BjF-zV5L.js → infiniteQueryObserver-CzTbTGuU.js} +1 -1
- package/dist/client/assets/{input-huks5fJI.js → input-BTxNeBOO.js} +1 -1
- package/dist/client/assets/{integration-icon-Cp1HpUk7.js → integration-icon-CTPrN73-.js} +1 -1
- package/dist/client/assets/{label-DcRY2Z_c.js → label-bLbRV7ZJ.js} +1 -1
- package/dist/client/assets/{layout-DTsboEzi.js → layout-D-svMqBO.js} +1 -1
- package/dist/client/assets/{localstorage-keys-BydGgvW4.js → localstorage-keys-z-WZ22Zi.js} +1 -1
- package/dist/client/assets/{login-B7tDHi06.js → login-D0xu4-Fa.js} +1 -1
- package/dist/client/assets/{markdown-BdmxXnSU.js → markdown-CgNryeyO.js} +1 -1
- package/dist/client/assets/{mcp-oauth-BZCsbdmd.js → mcp-oauth-Dj71M6pS.js} +1 -1
- package/dist/client/assets/{mcp-server-card-8ZVI_22n.js → mcp-server-card-Bc5AS-wf.js} +1 -1
- package/dist/client/assets/mcp-server-detail-D02AsVR7.js +2 -0
- package/dist/client/assets/members-EmtbbMjC.js +3 -0
- package/dist/client/assets/{monitoring-BxQSGXDM.js → monitoring-C-93CV4C.js} +1 -1
- package/dist/client/assets/monitoring-dashboard-edit-Bdp6e51N.js +1 -0
- package/dist/client/assets/{monitoring-dashboard-view-CVnGc94e.js → monitoring-dashboard-view-Bx7z2_z0.js} +2 -2
- package/dist/client/assets/{oauth-callback-CigfvTht.js → oauth-callback-CkkG9d7v.js} +1 -1
- package/dist/client/assets/page-BGugjR0I.js +1 -0
- package/dist/client/assets/page-ITQU-Zp8.js +1 -0
- package/dist/client/assets/{plugin-empty-state-DTgTWXI7.js → plugin-empty-state-AgNFTQ0u.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-DDTxMT2j.js → plugin-empty-state-DlghdeMy.js} +1 -1
- package/dist/client/assets/{plugin-header-BC9DhoPL.js → plugin-header-BiKI-0GN.js} +1 -1
- package/dist/client/assets/{plugin-header-B3ObCcqy.js → plugin-header-DxI4kgNA.js} +1 -1
- package/dist/client/assets/{popover-DcSaWbV8.js → popover-DK0-mkfJ.js} +1 -1
- package/dist/client/assets/project-layout-ClSoqo8C.js +1 -0
- package/dist/client/assets/projects-list-78EdWnMz.js +1 -0
- package/dist/client/assets/ranking-layout-BipS-5d4.js +1 -0
- package/dist/client/assets/{readme-viewer-2ismStm5.js → readme-viewer-CYVu4zA3.js} +1 -1
- package/dist/client/assets/{registry-layout-DEblsXP7.js → registry-layout-DuUFYDsK.js} +3 -3
- package/dist/client/assets/{registry-utils-Dac8ZTsT.js → registry-utils-BJco7Nso.js} +1 -1
- package/dist/client/assets/{reports-layout-DbnfP1q6.js → reports-layout-DWL4B4XL.js} +2 -2
- package/dist/client/assets/{reset-password-B89jE3ej.js → reset-password-C7TFy7aQ.js} +1 -1
- package/dist/client/assets/{resizable-h22LB830.js → resizable-zYSMb8PO.js} +1 -1
- package/dist/client/assets/{save-actions-DA7n9oDQ.js → save-actions-BdnWXMVf.js} +1 -1
- package/dist/client/assets/{scroll-area-BKmtzCq2.js → scroll-area-30X2y975.js} +1 -1
- package/dist/client/assets/select-Duopl7P2.js +1 -0
- package/dist/client/assets/shell-layout-CI23YHUg.js +3 -0
- package/dist/client/assets/skeleton-CmCa76Pe.js +1 -0
- package/dist/client/assets/{spinner-F4mIr_hT.js → spinner--6L1PAKk.js} +1 -1
- package/dist/client/assets/{store-invite-CtnVmWXj.js → store-invite-DNBT5DzD.js} +1 -1
- package/dist/client/assets/{switch-BL62l8Ib.js → switch-CzMTfJyd.js} +1 -1
- package/dist/client/assets/{table-CbXfRrNf.js → table-DPbr8gQl.js} +1 -1
- package/dist/client/assets/tasks-CqaWmm56.js +1 -0
- package/dist/client/assets/{textarea-B8s2FGNX.js → textarea-BNPURYr9.js} +1 -1
- package/dist/client/assets/{time-range-picker-CfimiwqE.js → time-range-picker-C-sEn-dP.js} +1 -1
- package/dist/client/assets/{toggle-group-BKCwzeo_.js → toggle-group-bVqu9tww.js} +1 -1
- package/dist/client/assets/{tools-list-CyzEbx-9.js → tools-list-D2XTdfAR.js} +1 -1
- package/dist/client/assets/tooltip-BnwJ5PQp.js +1 -0
- package/dist/client/assets/{topbar-portal-D7WeU3yz.js → topbar-portal-CrFEl7XT.js} +1 -1
- package/dist/client/assets/{typewriter-title-CHhLNB1a.js → typewriter-title-Dh7JaY-s.js} +1 -1
- package/dist/client/assets/{use-binding-DdkmvlxZ.js → use-binding-CSl5A5cE.js} +1 -1
- package/dist/client/assets/{use-connection-DAgRP50x.js → use-connection-CJPryUMd.js} +1 -1
- package/dist/client/assets/{use-copy-Bo2sIPym.js → use-copy-DELXo_w6.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-fdVT40_L.js → use-create-virtual-mcp-CEbxqW61.js} +1 -1
- package/dist/client/assets/use-deco-chat-open-Bj4jxMD7.js +23 -0
- package/dist/client/assets/{use-install-from-registry-M1-5-P-0.js → use-install-from-registry-Vj4wJ4IH.js} +1 -1
- package/dist/client/assets/{use-list-state-BnheaE8u.js → use-list-state-cJ107QPf.js} +1 -1
- package/dist/client/assets/{use-llm-CBphLfYI.js → use-llm-us82LJMh.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-B3rnWj2C.js → use-mcp-prompts-Sqkswu5s.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-CPX0xnjy.js → use-mcp-tools-Dj4ni5D7.js} +1 -1
- package/dist/client/assets/use-mobile-EmqlWdQN.js +1 -0
- package/dist/client/assets/{use-organization-settings-Cz1UAsSG.js → use-organization-settings-CMrztk0j.js} +1 -1
- package/dist/client/assets/{use-project-BNMLIvlD.js → use-project-BYeZMfFI.js} +1 -1
- package/dist/client/assets/use-settings-modal-tvp-XYtD.js +1 -0
- package/dist/client/assets/use-view-mode-Dg_d9_Oy.js +1 -0
- package/dist/client/assets/{use-virtual-mcp-B5BaJrTw.js → use-virtual-mcp-BzAB1Jwk.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-DS7Rp5Du.js +1 -0
- package/dist/client/assets/{useMutation-Bq7GjWDP.js → useMutation-kpLmB8S8.js} +1 -1
- package/dist/client/assets/useQuery-Do4lYH9e.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-8nf2pI1w.js +1 -0
- package/dist/client/assets/workflow-DbuBBxB5.js +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/cli.js +1 -1
- package/dist/server/migrate.js +1 -1
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/agent-detail-B2onMGmp.js +0 -1
- package/dist/client/assets/agents-4P_yJ9zI.js +0 -1
- package/dist/client/assets/alert-dialog-D-bpjwrd.js +0 -7
- package/dist/client/assets/connection-detail-DxTGeOXe.js +0 -1
- package/dist/client/assets/connections-DCdMs0gK.js +0 -1
- package/dist/client/assets/constants-BknqBFNn.js +0 -1
- package/dist/client/assets/constants-FCOQt1Nx.js +0 -1
- package/dist/client/assets/dialog-CoIpVxsf.js +0 -1
- package/dist/client/assets/dropdown-menu-RanCPsC8.js +0 -1
- package/dist/client/assets/dynamic-plugin-layout-C9oD8t_6.js +0 -1
- package/dist/client/assets/form-GFfRzzeS.js +0 -1
- package/dist/client/assets/index-BvM-U-XB.js +0 -1
- package/dist/client/assets/index-CT7EZ55B.js +0 -1
- package/dist/client/assets/index-QsCquYg-.css +0 -1
- package/dist/client/assets/mcp-server-detail-0ieYYiyf.js +0 -2
- package/dist/client/assets/members-CvfVBZxM.js +0 -3
- package/dist/client/assets/monitoring-dashboard-edit-9B7Jzd1Y.js +0 -1
- package/dist/client/assets/page-D4LKpPAI.js +0 -1
- package/dist/client/assets/page-DAkc-y77.js +0 -1
- package/dist/client/assets/project-layout-vo1O7yUx.js +0 -1
- package/dist/client/assets/project-settings-DhjkY1yg.js +0 -1
- package/dist/client/assets/projects-list-DrQICZdg.js +0 -1
- package/dist/client/assets/ranking-layout-CDLPoM3K.js +0 -1
- package/dist/client/assets/select-Bly56K9Q.js +0 -1
- package/dist/client/assets/shell-layout-D9kTN_A3.js +0 -3
- package/dist/client/assets/tasks-CEtbtstY.js +0 -1
- package/dist/client/assets/tooltip-Bn-48UAI.js +0 -1
- package/dist/client/assets/use-deco-chat-open-DFTbj6_G.js +0 -23
- package/dist/client/assets/use-view-mode-D2cP_FrA.js +0 -1
- package/dist/client/assets/useInfiniteQuery-SMlnrZp0.js +0 -1
- package/dist/client/assets/useQuery-pVrum8lO.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-oK3vyxJn.js +0 -1
- package/dist/client/assets/workflow-61tE2hAr.js +0 -1
package/dist/server/migrate.js
CHANGED
|
@@ -1476,7 +1476,7 @@ ${Q.stack}`;return G}}catch{}if(typeof Q.toString==="function")try{let G=Q.toStr
|
|
|
1476
1476
|
};
|
|
1477
1477
|
`,F=await aR({code:H,tools:W,timeoutMs:30000});if(F.error)return{content:[{type:"text",text:`Virtual tool error: ${F.error}`}],isError:!0};return{content:[{type:"text",text:JSON.stringify(F.returnValue??null)}]}}catch(Z){return{content:[{type:"text",text:`Virtual tool execution failed: ${Z instanceof Error?Z.message:String(Z)}`}],isError:!0}}}async listResources(){return{resources:(await this._cachedResources).data}}async readResource(Y){let Q=await this._cachedResources,X=this._clients,J=Q.mappings.get(Y.uri);if(!J)throw Error(`Resource not found: ${Y.uri}`);let G=X.get(J);if(!G)throw Error(`Connection not found for resource: ${Y.uri}`);return await G.readResource(Y)}async listPrompts(){return{prompts:(await this._cachedPrompts).data}}async getPrompt(Y){let Q=await this._cachedPrompts,X=this._clients,J=Q.mappings.get(Y.name);if(!J)throw Error(`Prompt not found: ${Y.name}`);let G=X.get(J);if(!G)throw Error(`Connection not found for prompt: ${Y.name}`);return await G.getPrompt(Y)}async callStreamableTool(Y,Q){let X=await this._cachedTools,J=this._clients,G=X.mappings.get(Y);if(G){let W=J.get(G);if(W&&"callStreamableTool"in W)return W.callStreamableTool(Y,Q)}let K=await this.callTool({name:Y,arguments:Q});return new Response(JSON.stringify(K),{headers:{"Content-Type":"application/json"}})}async[Symbol.asyncDispose](){await Rf0(this._clients)}async close(){await Rf0(this._clients),await super.close()}getInstructions(){return this.options.virtualMcp.metadata?.instructions??void 0}}});var If0,BE4,jf0,UE4,JI;var E$1=S(()=>{y1();GU();w$1();If0=q.object({query:q.string().min(1).describe("Search query to find tools by name or description"),limit:q.number().default(10).describe("Maximum number of results to return")}),BE4=q.toJSONSchema(If0),jf0=q.object({tools:q.array(q.string()).min(1).describe("Array of tool names to get detailed schemas for")}),UE4=q.toJSONSchema(jf0);JI=class JI extends mN{constructor(Y,Q){super(Y,Q)}getSearchTool(Y){return{name:"GATEWAY_SEARCH_TOOLS",description:`Search for available tools by name or description. Returns tool names and brief descriptions without full schemas. Use this to discover tools before calling GATEWAY_DESCRIBE_TOOLS for detailed schemas. Total tools: ${Y}.`,inputSchema:BE4,annotations:{title:"Search Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}}getDescribeTool(){return{name:"GATEWAY_DESCRIBE_TOOLS",description:"Get detailed schemas for specific tools. Call after GATEWAY_SEARCH_TOOLS to get full input/output schemas.",inputSchema:UE4,annotations:{title:"Describe Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1}}}async handleSearch(Y){let Q=If0.safeParse(Y);if(!Q.success)return M$({error:Q.error.flatten()});let X=await this._cachedTools,J=m3(X.data),G=Kp(Q.data.query,J,Q.data.limit);return rR({query:Q.data.query,results:G.map((K)=>({name:K.name,description:K.description,connection:K._meta.connectionTitle})),totalAvailable:J.length})}async handleDescribe(Y){let Q=jf0.safeParse(Y);if(!Q.success)return M$({error:Q.error.flatten()});let X=await this._cachedTools,J=m3(X.data),G=Hp(Q.data.tools,J);return rR({tools:G.tools,notFound:G.notFound})}async listTools(){let Y=await this._cachedTools,Q=m3(Y.data);return{tools:[this.getSearchTool(Q.length),this.getDescribeTool()]}}async callTool(Y){if(Y.name==="GATEWAY_SEARCH_TOOLS")return this.handleSearch(Y.arguments??{});if(Y.name==="GATEWAY_DESCRIBE_TOOLS")return this.handleDescribe(Y.arguments??{});return{content:[{type:"text",text:`Unknown tool: ${Y.name}. Available: GATEWAY_SEARCH_TOOLS, GATEWAY_DESCRIBE_TOOLS`}],isError:!0}}async routeToolCall(Y){return mN.prototype.callTool.call(this,Y)}}});var Sf0,zE4,T$1;var _f0=S(()=>{y1();GU();E$1();Sf0=q.object({code:q.string().min(1).describe("JavaScript code to execute. It runs as an async function body; you can use top-level `return` and `await`."),timeoutMs:q.number().default(3000).describe("Max execution time in milliseconds (default: 3000).")}),zE4=q.toJSONSchema(Sf0);T$1=class T$1 extends JI{constructor(Y,Q){super(Y,Q)}getRunCodeTool(){return{name:"GATEWAY_RUN_CODE",description:'Run JavaScript code in a sandbox. Code must be an ES module that `export default`s an async function that receives (tools) as its first parameter. Use GATEWAY_DESCRIBE_TOOLS to understand the input/output schemas for a tool before calling it. Use `await tools.toolName(args)` or `await tools["tool-name"](args)` to call tools.',inputSchema:zE4,annotations:{title:"Run Code",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}}}async handleRunCode(Y){let Q=Sf0.safeParse(Y);if(!Q.success)return M$({error:Q.error.flatten()});let X=await this._cachedTools,G={tools:m3(X.data),callTool:async(W,Z)=>{return this.routeToolCall({name:W,arguments:Z})}},K=await Fp(Q.data.code,G,Q.data.timeoutMs);if(K.error)return M$(K);return rR(K)}async listTools(){return{tools:[...(await super.listTools()).tools,this.getRunCodeTool()]}}async callTool(Y){if(Y.name==="GATEWAY_RUN_CODE")return this.handleRunCode(Y.arguments??{});return super.callTool(Y)}}});function kf0(Y){let Q=Y.slice().sort().join(","),X=vf0.get(Q);if(!X){let J=q.object({name:(Y.length>0?q.enum(Y):q.string()).describe("The name of the tool to execute"),arguments:q.record(q.string(),q.unknown()).default({}).describe("Arguments to pass to the tool")});X={schema:J,jsonSchema:q.toJSONSchema(J)},vf0.set(Q,X)}return X}var vf0,C$1;var yf0=S(()=>{y1();GU();E$1();vf0=new Map;C$1=class C$1 extends JI{constructor(Y,Q){super(Y,Q)}async getCallTool(){let Y=await this._cachedTools,X=m3(Y.data).map((G)=>G.name),{jsonSchema:J}=kf0(X);return{name:"GATEWAY_CALL_TOOL",description:"Execute a tool by name. Use GATEWAY_DESCRIBE_TOOLS first to understand the input schema.",inputSchema:J,annotations:{title:"Call Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0}}}async handleCallTool(Y){let Q=await this._cachedTools,X=m3(Q.data),J=X.map((F)=>F.name),{schema:G}=kf0(J),K=G.safeParse(Y);if(!K.success)return M$({error:K.error.flatten()});let{name:W,arguments:Z}=K.data;if(!new Map(X.map((F)=>[F.name,F])).has(W))return{content:[{type:"text",text:`Tool not found: ${W}. Use GATEWAY_SEARCH_TOOLS to find available tools.`}],isError:!0};return this.routeToolCall({name:W,arguments:Z})}async listTools(){let Y=await super.listTools(),Q=await this.getCallTool();return{tools:[...Y.tools,Q]}}async callTool(Y){if(Y.name==="GATEWAY_CALL_TOOL")return this.handleCallTool(Y.arguments??{});return super.callTool(Y)}}});function DE4(Y,Q){if(Y.connection_type!=="VIRTUAL")return!1;if(!Q||OV(Q))return!1;return Y.id===Q}async function ff0(Y,Q,X=!1){let J=Y.id,G=await Q.storage.virtualMcps.findById(J);if(!G)throw Error(`Virtual MCP not found: ${J}`);return OE4(G,Q,"passthrough",X)}async function OE4(Y,Q,X,J=!1){let K=Y.connections.map((V)=>V.connection_id).map((V)=>Q.storage.connections.findById(V)),W=Y.id?await Q.storage.connections.findById(Y.id):null,Z=await Promise.all(K),H=[];if(W?.tools){for(let V of W.tools)if(Ef0(V))H.push(V)}let $={connections:Z.filter((V)=>V!==null&&V.status==="active"&&!DE4(V,Y.id)),virtualMcp:Y,virtualTools:H.length>0?H:void 0,superUser:J};return X==="smart_tool_selection"?new C$1($,Q):X==="code_execution"?new T$1($,Q):new mN($,Q)}var bf0=S(()=>{jY();A$();_f0();w$1();yf0()});async function lN(Y,Q,X=!1){if(Y.connection_type==="VIRTUAL")return ff0(Y,Q,X);return Mf0(Y,Q,X)}var R$1=S(()=>{wf0();bf0()});var hf0=S(()=>{jY();IY();R$1();M$1()});function LE4(Y,Q,X){return async(J,G)=>{try{let K=J.params.name,W=async()=>{let{tools:H}=await X();return H.find(($)=>$.name===K)?._meta};return await new XI(Y.authInstance,Y.auth.user?.id??Y.auth.apiKey?.userId,K,Y.boundAuth,Y.auth.user?.role,Q,W).check(K),await G()}catch(K){return new Response(JSON.stringify({error:`Authorization failed: ${K.message}`}),{status:403,headers:{"Content-Type":"application/json"}})}}}function A$1(Y,Q,X,J,G){let K=async(Z,H)=>{if(X.connection_type==="VIRTUAL"){let U=await Y.callTool({name:Z,arguments:H});return new Response(JSON.stringify(U),{headers:{"Content-Type":"application/json"}})}if(!X.connection_url)throw Error("Streamable tools require HTTP connection with URL");let F=X.connection_url,$={method:"tools/call",params:{name:Z,arguments:H}};if(!G.superUser){let z=await LE4(J,Q,Y.listTools.bind(Y))($,async()=>{return new Response});if(!z.ok)return z}let V=J.connectionId&&J.connectionId!==Q?J.connectionId:void 0;return Of0({ctx:J,enabled:yh().enabled,connectionId:Q,connectionTitle:X.title,virtualMcpId:V})($,async()=>{let U=await eR(X,J,G.superUser),z=X.connection_headers;if(z&&"headers"in z)Object.assign(U,z.headers);let O=new URL(F);O.pathname=O.pathname.replace(/\/$/,"")+`/call-tool/${$.params.name}`;let M=JSON.parse(JSON.stringify($.params.arguments,(P,j)=>{if(j instanceof AbortSignal)return;if(typeof j==="function"||typeof j==="symbol")return;if(j===void 0)return;return j})),w=JSON.stringify(M);return await J.tracer.startActiveSpan("mcp.proxy.callStreamableTool",{attributes:{"connection.id":Q,"tool.name":$.params.name,"request.id":J.metadata.requestId}},async(P)=>{let j=Date.now();try{let C=await fetch(O.toString(),{method:"POST",redirect:"manual",body:w,headers:{...U,"Content-Type":"application/json"}}),E=Date.now()-j;return J.meter.createHistogram("connection.proxy.streamable.duration").record(E,{"connection.id":Q,"tool.name":$.params.name,status:C.ok?"success":"error"}),J.meter.createCounter("connection.proxy.streamable.requests").add(1,{"connection.id":Q,"tool.name":$.params.name,status:C.ok?"success":"error"}),P.end(),C}catch(C){let E=C,I=Date.now()-j;throw console.error("[with-streaming-support] fetch error",{connectionId:Q,toolName:$.params.name,error:E.message,errorStack:E.stack,duration:I}),J.meter.createHistogram("connection.proxy.streamable.duration").record(I,{"connection.id":Q,"tool.name":$.params.name,status:"error"}),J.meter.createCounter("connection.proxy.streamable.errors").add(1,{"connection.id":Q,"tool.name":$.params.name,error:E.message}),P.recordException(E),P.end(),C}})})},W=Object.assign(Object.create(Object.getPrototypeOf(Y)),Y);return W.callStreamableTool=K,W}var xf0=S(()=>{V$1();B$1();fh();L$1()});var gf0=S(()=>{xf0()});var P$1=S(()=>{R$1();hf0();gf0()});async function wE4(Y,Q,X,J){for(let K of Q){if(K==="*")continue;let[W]=Jf0(K),Z=Bp(W,Y);if(Z===void 0||Z===null)throw Error(`Scope references key "${W}" but it's not present in state`)}let G=Gf0(Y,Q);for(let K of G){if(K.endsWith("_self"))continue;let W=await J.storage.connections.findById(K);if(!W||W.organization_id!==X)throw Error(`Referenced connection not found: ${K}`);try{await J.access.check(K)}catch(Z){throw Error(`Access denied to referenced connection: ${K}. ${Z.message}`)}}}var NE4,ME4,I$1;var uf0=S(()=>{F$1();P$1();$$1();y1();k0();mm();L3();NE4=q.object({id:q.string().describe("ID of the connection to update"),data:TA.describe("Partial connection data to update")}),ME4=q.object({item:P5.describe("The updated connection entity")});I$1=v1({name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update an existing MCP connection in the organization",annotations:{title:"Update Connection",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:NE4,outputSchema:ME4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to update connection");let{id:G,data:K}=Y,W=await Q.storage.connections.findById(G);if(!W||W.organization_id!==X.id)throw Error("Connection not found in organization");let Z=K.connection_type??W.connection_type,H=K.connection_url??W.connection_url;if(Z==="VIRTUAL"){let M=LV(H);if(!M)throw Error("VIRTUAL connection requires connection_url in format: virtual://$virtual_mcp_id");let w=await Q.storage.virtualMcps.findById(M);if(!w)throw Error(`Virtual MCP not found: ${M}`);if(w.organization_id!==X.id)throw Error("Virtual MCP does not belong to the current organization");H=NV(M)}let F=K.configuration_state??W.configuration_state??{},$=K.configuration_scopes??W.configuration_scopes??[];if(K.configuration_state!==void 0||K.configuration_scopes!==void 0){if(K.configuration_state!==void 0)F=K.configuration_state??{};else if(F===null||F===void 0)F={};if(K.configuration_scopes!==void 0)$=K.configuration_scopes??[];if($.length>0)await wE4(F,$,X.id,Q)}let V=K.connection_token??W.connection_token;if(!V)try{let w=await new tR(Q.db,Q.vault).get(G);if(w?.accessToken)V=w.accessToken}catch{}let B=await cL({id:W.id,title:K.title??W.title,connection_type:Z,connection_url:H,connection_token:V,connection_headers:K.connection_headers??W.connection_headers}).catch(()=>null),U=B?.length?B:null,z={...K,connection_url:H,tools:U,configuration_state:F,configuration_scopes:$,updated_by:J},O=await Q.storage.connections.update(G,z);if((K.configuration_state!==void 0||K.configuration_scopes!==void 0)&&F&&$)try{await(await lN(O,Q,!1)).callTool({name:"ON_MCP_CONFIGURATION",arguments:{state:F,scopes:$}})}catch(M){console.error("Failed to invoke ON_MCP_CONFIGURATION callback",M)}return{item:O}}})});var AE4,j$1;var mf0=S(()=>{gX();y1();k0();L3();AE4=PC.extend({force:q.boolean().optional().describe("If true, removes this connection from all agents that reference it before deleting")}),j$1=v1({name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete a connection",annotations:{title:"Delete Connection",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:AE4,outputSchema:EC(P5),handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.connections.findById(Y.id);if(!J)throw Error(`Connection not found: ${Y.id}`);if(J.organization_id!==X.id)throw Error("Connection not found in organization");if(J.metadata?.isFixed===!0)throw Error("This connection is a fixed system connection and cannot be deleted");let K=await Q.storage.virtualMcps.listByConnectionId(X.id,Y.id);if(K.length>0)if(Y.force)await Q.storage.virtualMcps.removeConnectionReferences(Y.id);else throw Error(JSON.stringify({code:"CONNECTION_IN_USE",agentNames:K.map((W)=>W.title)}));return await Q.storage.connections.delete(Y.id),{item:J}}})});var S$1;var lf0=S(()=>{y1();k0();S$1=v1({name:"CONNECTION_TEST",description:"Test connection health and latency",annotations:{title:"Test Connection",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},inputSchema:q.object({id:q.string()}),outputSchema:q.object({id:q.string(),healthy:q.boolean(),latencyMs:q.number()}),handler:async(Y,Q)=>{let X=B0(Q);await Q.access.check();let J=await Q.storage.connections.findById(Y.id);if(!J||J.organization_id!==X.id)throw Error("Connection not found");let G=await Q.storage.connections.testConnection(Y.id);return{id:Y.id,...G}}})});var df0=S(()=>{iy0();Qf0();Xf0();uf0();mf0();lf0()});import{sql as S4}from"kysely";function pf0(Y){if(Y===null||Y===void 0)return"NULL";if(typeof Y==="number")return String(Y);if(typeof Y==="boolean")return Y?"TRUE":"FALSE";if(typeof Y==="string")return`'${Y.replace(/'/g,"''")}'`;if(Y instanceof Date)return`'${Y.toISOString()}'`;return`'${JSON.stringify(Y).replace(/'/g,"''")}'`}function TE4(Y,Q){let X=Y;for(let G=Q.length;G>=1;G--){let K=`$${G}`;if(X.includes(K))X=X.replaceAll(K,pf0(Q[G-1]))}let J=[];for(let G=0;G<X.length;G++)if(X[G]==="?")J.push(G);for(let G=Math.min(J.length,Q.length)-1;G>=0;G--){let K=J[G],W=pf0(Q[G]);X=X.slice(0,K)+W+X.slice(K+1)}return X}function cf0(Y){return Y.replace(/-/g,"_")}function RE4(Y){return`app_${cf0(Y)}`}function IE4(Y){return`app_role_${cf0(Y)}`}function jE4(Y){if(Y instanceof Error){let Q=Y.message.toLowerCase(),X=Y.code;return X==="3F000"||X==="42704"||X==="22023"||Q.includes("schema")&&Q.includes("does not exist")||Q.includes("role")&&Q.includes("does not exist")}return!1}async function SE4(Y,Q,X){if(await S4`CREATE SCHEMA IF NOT EXISTS ${S4.id(Q)}`.execute(Y),!(await S4`
|
|
1478
1478
|
SELECT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ${X}) as exists
|
|
1479
|
-
`.execute(Y)).rows[0]?.exists)await S4`CREATE ROLE ${S4.id(X)} NOLOGIN`.execute(Y);await S4`GRANT ${S4.id(X)} TO CURRENT_USER`.execute(Y),await S4`GRANT USAGE, CREATE ON SCHEMA ${S4.id(Q)} TO ${S4.id(X)}`.execute(Y),await S4`GRANT ALL ON ALL TABLES IN SCHEMA ${S4.id(Q)} TO ${S4.id(X)}`.execute(Y),await S4`GRANT ALL ON ALL SEQUENCES IN SCHEMA ${S4.id(Q)} TO ${S4.id(X)}`.execute(Y),await S4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${S4.id(Q)} GRANT ALL ON TABLES TO ${S4.id(X)}`.execute(Y),await S4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${S4.id(Q)} GRANT ALL ON SEQUENCES TO ${S4.id(X)}`.execute(Y),await S4`REVOKE ALL ON SCHEMA public FROM ${S4.id(X)}`.execute(Y)}async function _E4(Y,Q,X,J){try{return await Y.transaction().execute(async(G)=>{return await S4`SET LOCAL ROLE ${S4.id(X)}`.execute(G),await S4`SET LOCAL search_path TO ${S4.id(Q)}`.execute(G),await S4.raw(J).execute(G)})}catch(G){if(jE4(G))return await SE4(Y,Q,X),await Y.transaction().execute(async(K)=>{return await S4`SET LOCAL ROLE ${S4.id(X)}`.execute(K),await S4`SET LOCAL search_path TO ${S4.id(Q)}`.execute(K),await S4.raw(J).execute(K)});throw G}}var EE4,CE4,nf0;var if0=S(()=>{y1();k0();EE4=q.object({results:q.array(q.unknown()).optional(),success:q.boolean().optional()});CE4=q.object({sql:q.string().describe("The SQL query to run"),params:q.array(q.any()).describe("The parameters to pass to the SQL query").optional()});nf0=v1({name:"DATABASES_RUN_SQL",description:"Run a SQL query against the database",annotations:{title:"Run SQL Query",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:CE4,outputSchema:q.object({result:q.array(EE4)}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=TE4(Y.sql,Y.params||[]);if(!Q.connectionId)throw Error("Connection context required for database access");let J=RE4(Q.connectionId),G=IE4(Q.connectionId);return{result:[{results:(await _E4(Q.db,J,G,X)).rows,success:!0}]}}})});var af0,kE4,rf0;var d3=S(()=>{y1();tm();af0=q.object({connectionId:q.string().optional().describe("Filter subscriptions by connection ID (optional)")}),kE4=q.object({id:q.string().describe("Subscription ID"),connectionId:q.string().describe("Subscriber connection ID"),eventType:q.string().describe("Event type pattern"),publisher:q.string().nullable().describe("Publisher connection filter (null = all publishers)"),filter:q.string().nullable().describe("JSONPath filter expression"),enabled:q.boolean().describe("Whether subscription is enabled"),createdAt:q.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:q.string().datetime().describe("Updated timestamp (ISO 8601)")}),rf0=q.object({subscriptions:q.array(kE4).describe("List of subscriptions")})});var _$1;var of0=S(()=>{k0();d3();_$1=v1({name:"EVENT_PUBLISH",description:"Publish an event to the event bus. Supports immediate, scheduled (deliverAt), and recurring (cron) delivery. The source is automatically set to the caller's connection ID.",annotations:{title:"Publish Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:TC,outputSchema:CC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to publish events. Use a connection-scoped token.");let G=await Q.eventBus.publish(X.id,J,{type:Y.type,subject:Y.subject,data:Y.data,deliverAt:Y.deliverAt,cron:Y.cron});return{id:G.id,type:G.type,source:G.source,time:G.time}}})});var v$1;var sf0=S(()=>{k0();d3();v$1=v1({name:"EVENT_SUBSCRIBE",description:"Subscribe to events of a specific type. The subscriber is automatically set to the caller's connection.",annotations:{title:"Subscribe to Events",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:RC,outputSchema:IC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to subscribe. Use a connection-scoped token.");let G=await Q.eventBus.subscribe(X.id,{connectionId:J,eventType:Y.eventType,publisher:Y.publisher,filter:Y.filter});return{subscription:{id:G.id,connectionId:G.connectionId,eventType:G.eventType,publisher:G.publisher,filter:G.filter,enabled:G.enabled,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}}})});var k$1;var tf0=S(()=>{k0();d3();k$1=v1({name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events by removing a subscription.",annotations:{title:"Unsubscribe from Events",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:_C,outputSchema:vC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to unsubscribe. Use a connection-scoped token.");let G=await Q.eventBus.getSubscription(X.id,Y.subscriptionId);if(!G)throw Error(`Subscription not found: ${Y.subscriptionId}`);if(G.connectionId!==J)throw Error("Cannot unsubscribe from a subscription owned by another connection");return{success:(await Q.eventBus.unsubscribe(X.id,Y.subscriptionId)).success,subscriptionId:Y.subscriptionId}}})});var y$1;var ef0=S(()=>{k0();d3();y$1=v1({name:"EVENT_CANCEL",description:"Cancel a recurring event to stop future deliveries. Only the publisher can cancel their own events.",annotations:{title:"Cancel Recurring Event",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:kC,outputSchema:yC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to cancel events. Use a connection-scoped token.");if(!await Q.eventBus.getEvent(X.id,Y.eventId))throw Error(`Event not found: ${Y.eventId}`);if(!(await Q.eventBus.cancelEvent(X.id,Y.eventId,J)).success)throw Error("Failed to cancel event. Either the event is already completed/failed, or you are not the publisher.");return{success:!0,eventId:Y.eventId}}})});var f$1;var Yb0=S(()=>{k0();d3();f$1=v1({name:"EVENT_ACK",description:"Acknowledge delivery of an event. Call after successfully processing an event received via ON_EVENTS with retryAfter.",annotations:{title:"Acknowledge Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:fC,outputSchema:bC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to acknowledge events. Use a connection-scoped token.");if(!(await Q.eventBus.ackEvent(X.id,Y.eventId,J)).success)throw Error("Failed to acknowledge event. Either the event was not found, already delivered, or you are not a subscriber.");return{success:!0,eventId:Y.eventId}}})});var b$1;var Qb0=S(()=>{k0();d3();b$1=v1({name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions, optionally filtered by connection ID.",annotations:{title:"List Event Subscriptions",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:af0,outputSchema:rf0,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);return await Q.access.check(),{subscriptions:(await Q.eventBus.listSubscriptions(X.id,Y.connectionId)).map((G)=>({id:G.id,connectionId:G.connectionId,eventType:G.eventType,publisher:G.publisher,filter:G.filter,enabled:G.enabled,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}))}}})});var h$1;var Xb0=S(()=>{k0();d3();h$1=v1({name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state. Creates new, deletes removed, updates changed filters. Subscriptions are identified by (eventType, publisher).",annotations:{title:"Sync Event Subscriptions",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:jC,outputSchema:SC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to sync subscriptions. Use a connection-scoped token.");let G=await Q.eventBus.syncSubscriptions(X.id,{connectionId:J,subscriptions:Y.subscriptions});return{created:G.created,updated:G.updated,deleted:G.deleted,unchanged:G.unchanged,subscriptions:G.subscriptions.map((K)=>({id:K.id,connectionId:K.connectionId,eventType:K.eventType,publisher:K.publisher,filter:K.filter,enabled:K.enabled,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt,updatedAt:K.updatedAt instanceof Date?K.updatedAt.toISOString():K.updatedAt}))}}})});var Jb0=S(()=>{of0();sf0();tf0();ef0();Yb0();Qb0();Xb0();d3()});var dN=S(()=>{wk()});function Gb0(){return`/icons/capy-${Math.floor(Math.random()*39)+0}.png`}var fE4,bE4,x$1;var Wb0=S(()=>{y1();k0();dN();fE4=q.object({data:RA.describe("Data for the new virtual MCP")}),bE4=q.object({item:tX.describe("The created virtual MCP entity")}),x$1=v1({name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create a new Virtual MCP",annotations:{title:"Create Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:fE4,outputSchema:bE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to create virtual MCP");let G={...Y.data,icon:Y.data.icon??Gb0()};return{item:await Q.storage.virtualMcps.create(X.id,J,G)}}})});function hE4(Y){let Q=[],X=0;while(X<Y.length){let J=Y[X];if(J==="%")Q.push(".*");else if(J==="_")Q.push(".");else if(/[.*+?^${}()|[\]\\]/.test(J))Q.push("\\"+J);else Q.push(J);X++}return Q.join("")}function P$(Y){return typeof Y==="string"||typeof Y==="number"}function g$1(Y,Q){let X=Q.split("."),J=Y;for(let G of X){if(J==null||typeof J!=="object")return;J=J[G]}return J}function xE4(Y,Q){return Y.connections.some((X)=>X.connection_id===Q)}function Op(Y,Q){if("conditions"in Q){let{operator:Z,conditions:H}=Q;switch(Z){case"and":return H.every((F)=>Op(Y,F));case"or":return H.some((F)=>Op(Y,F));case"not":return!H.every((F)=>Op(Y,F));default:return!0}}let{field:X,operator:J,value:G}=Q,K=X.join(".");if(K==="connection_id"){if(J!=="eq"||typeof G!=="string")return!1;return xE4(Y,G)}let W=g$1(Y,K);switch(J){case"eq":return W===G;case"gt":return P$(W)&&P$(G)&&W>G;case"gte":return P$(W)&&P$(G)&&W>=G;case"lt":return P$(W)&&P$(G)&&W<G;case"lte":return P$(W)&&P$(G)&&W<=G;case"in":return Array.isArray(G)&&G.includes(W);case"like":if(typeof W!=="string"||typeof G!=="string")return!1;if(G.length>100)return!1;let Z=hE4(G);return new RegExp(`^${Z}$`,"i").test(W);case"contains":if(typeof W!=="string"||typeof G!=="string")return!1;return W.toLowerCase().includes(G.toLowerCase());default:return!0}}function gE4(Y,Q){return[...Y].sort((X,J)=>{for(let G of Q){let K=G.field.join("."),W=g$1(X,K),Z=g$1(J,K),H=0;if(W==null&&Z==null)continue;if(W==null)H=G.nulls==="first"?-1:1;else if(Z==null)H=G.nulls==="first"?1:-1;else if(typeof W==="string"&&typeof Z==="string")H=W.localeCompare(Z);else if(typeof W==="number"&&typeof Z==="number")H=W-Z;else H=String(W).localeCompare(String(Z));if(H!==0)return G.direction==="desc"?-H:H}return 0})}var uE4,mE4,u$1;var Zb0=S(()=>{gX();k0();dN();uE4=dG,mE4=M3(tX),u$1=v1({name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List all MCP virtual MCPs in the organization",annotations:{title:"List Virtual MCPs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:uE4,outputSchema:mE4,handler:async(Y,Q)=>{await Q.access.check();let X=B0(Q),J=Y.where&&!("conditions"in Y.where)&&Y.where.field.join(".")==="connection_id"&&Y.where.operator==="eq"&&typeof Y.where.value==="string"?Y.where.value:void 0,K=J?await Q.storage.virtualMcps.listByConnectionId(X.id,J):await Q.storage.virtualMcps.list(X.id);if(Y.where)K=K.filter((V)=>Op(V,Y.where));if(Y.orderBy&&Y.orderBy.length>0)K=gE4(K,Y.orderBy);let W=K.length,Z=Y.offset??0,H=Y.limit??100,F=K.slice(Z,Z+H),$=Z+H<W;return{items:F,totalCount:W,hasMore:$}}})});var lE4,dE4,m$1;var Kb0=S(()=>{y1();k0();dN();lE4=q.object({id:q.string().describe("ID of the virtual MCP to retrieve")}),dE4=q.object({item:tX.nullable().describe("The retrieved virtual MCP, or null if not found")}),m$1=v1({name:"COLLECTION_VIRTUAL_MCP_GET",description:"Get an MCP virtual MCP by ID",annotations:{title:"Get Virtual MCP",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:lE4,outputSchema:dE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.id);if(J&&J.organization_id!==X.id)return{item:null};if(!J)return{item:null};return{item:J}}})});var pE4,cE4,l$1;var Hb0=S(()=>{y1();k0();dN();pE4=q.object({id:q.string().describe("ID of the virtual MCP to update"),data:IA.describe("Partial virtual MCP data to update")}),cE4=q.object({item:tX.describe("The updated virtual MCP entity")}),l$1=v1({name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update an MCP virtual MCP",annotations:{title:"Update Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:pE4,outputSchema:cE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to update virtual MCP");let G=await Q.storage.virtualMcps.findById(Y.id);if(!G)throw Error(`Virtual MCP not found: ${Y.id}`);if(G.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.id}`);return{item:await Q.storage.virtualMcps.update(Y.id,J,Y.data)}}})});var nE4,iE4,d$1;var Fb0=S(()=>{y1();k0();dN();nE4=q.object({id:q.string().describe("ID of the virtual MCP to delete")}),iE4=q.object({item:tX.describe("The deleted virtual MCP entity")}),d$1=v1({name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete an MCP virtual MCP",annotations:{title:"Delete Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:nE4,outputSchema:iE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.id);if(!J)throw Error(`Virtual MCP not found: ${Y.id}`);if(J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.id}`);return await Q.storage.virtualMcps.delete(Y.id),{item:J}}})});var $b0=S(()=>{Wb0();Zb0();Kb0();Hb0();Fb0()});var rE4,oE4,p$1;var Vb0=S(()=>{y1();k0();A$();rE4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP to add the tool to"),data:Af0.describe("Virtual tool data")}),oE4=q.object({item:pZ.describe("The created virtual tool")}),p$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_CREATE",description:"Create a new virtual tool on a Virtual MCP. The tool code should be a JavaScript ES module that exports a default async function: export default async (tools, args) => { ... }. Specify connection_dependencies to indicate which connections this tool uses.",annotations:{title:"Create Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:rE4,outputSchema:oE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=Y.data.connection_dependencies??[];return{item:await Q.storage.virtualMcps.createVirtualTool(Y.virtual_mcp_id,Y.data,G)}}})});var sE4,tE4,c$1;var qb0=S(()=>{y1();k0();A$();sE4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP to list tools for"),limit:q.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:q.number().int().min(0).optional().describe("Number of items to skip")}),tE4=q.object({items:q.array(pZ).describe("Array of virtual tools"),totalCount:q.number().int().min(0).optional().describe("Total number of virtual tools"),hasMore:q.boolean().optional().describe("Whether there are more items available")}),c$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List all virtual tools for a Virtual MCP",annotations:{title:"List Virtual Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:sE4,outputSchema:tE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)return{items:[],totalCount:0,hasMore:!1};let G=await Q.storage.virtualMcps.listVirtualTools(Y.virtual_mcp_id),K=G.length,W=Y.offset??0,Z=Y.limit??100,H=G.slice(W,W+Z),F=W+Z<K;return{items:H,totalCount:K,hasMore:F}}})});var eE4,YT4,n$1;var Bb0=S(()=>{y1();k0();A$();eE4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP"),name:q.string().describe("Name of the virtual tool to retrieve")}),YT4=q.object({item:pZ.nullable().describe("The retrieved virtual tool, or null if not found")}),n$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"Get a virtual tool by name from a Virtual MCP",annotations:{title:"Get Virtual Tool",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:eE4,outputSchema:YT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)return{item:null};return{item:await Q.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name)}}})});var QT4,XT4,i$1;var Ub0=S(()=>{y1();k0();A$();QT4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP"),name:q.string().describe("Current name of the virtual tool to update"),data:Pf0.describe("Partial virtual tool data to update")}),XT4=q.object({item:pZ.describe("The updated virtual tool")}),i$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_UPDATE",description:"Update an existing virtual tool on a Virtual MCP. Specify connection_dependencies to update which connections this tool uses.",annotations:{title:"Update Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:QT4,outputSchema:XT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);if(!await Q.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name))throw Error(`Virtual tool not found: ${Y.name}`);let K=Y.data.connection_dependencies;return{item:await Q.storage.virtualMcps.updateVirtualTool(Y.virtual_mcp_id,Y.name,Y.data,K)}}})});var JT4,GT4,a$1;var zb0=S(()=>{y1();k0();A$();JT4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP"),name:q.string().describe("Name of the virtual tool to delete")}),GT4=q.object({item:pZ.describe("The deleted virtual tool")}),a$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete a virtual tool from a Virtual MCP",annotations:{title:"Delete Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:JT4,outputSchema:GT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=await Q.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name);if(!G)throw Error(`Virtual tool not found: ${Y.name}`);return await Q.storage.virtualMcps.deleteVirtualTool(Y.virtual_mcp_id,Y.name),{item:G}}})});var Db0=S(()=>{Vb0();qb0();Bb0();Ub0();zb0()});var ZT4,r$1;var Ob0=S(()=>{k0();y1();ZT4=q.object({id:q.string().optional().describe("Unique log identifier"),organizationId:q.string().describe("Organization ID"),connectionId:q.string().describe("Connection ID"),connectionTitle:q.string().describe("Connection display name"),toolName:q.string().describe("Name of the tool that was called"),input:q.record(q.string(),q.unknown()).describe("Redacted tool input"),output:q.record(q.string(),q.unknown()).describe("Redacted tool output"),isError:q.boolean().describe("Whether the call resulted in an error"),errorMessage:q.string().nullish().describe("Error message if applicable"),durationMs:q.number().describe("Call duration in milliseconds"),timestamp:q.string().describe("ISO 8601 timestamp of the call"),userId:q.string().nullish().describe("User who triggered the call"),requestId:q.string().describe("Unique request identifier"),userAgent:q.string().nullish().describe("Client identifier (x-mesh-client header)"),virtualMcpId:q.string().nullish().describe("Virtual MCP (Agent) ID if routed through an agent"),properties:q.record(q.string(),q.string()).nullish().describe("Custom key-value metadata attached to the log")}),r$1=v1({name:"MONITORING_LOGS_LIST",description:"List monitoring logs for tool calls in the organization",annotations:{title:"List Monitoring Logs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({connectionId:q.string().optional().describe("Filter by connection ID"),excludeConnectionIds:q.array(q.string()).optional().describe("Exclude logs from these connection IDs (e.g. system connections)"),virtualMcpId:q.string().optional().describe("Filter by Virtual MCP (Agent) ID"),toolName:q.string().optional().describe("Filter by tool name"),isError:q.boolean().optional().describe("Filter by error status"),startDate:q.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:q.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)"),limit:q.number().default(20).describe("Maximum number of results"),offset:q.number().default(0).describe("Offset for pagination"),properties:q.record(q.string(),q.string()).optional().describe("Filter by exact property key=value matches"),propertyKeys:q.array(q.string()).optional().describe("Filter by logs that have these property keys"),propertyPatterns:q.record(q.string(),q.string()).optional().describe("Filter by property value patterns (SQL LIKE, use % as wildcard)"),propertyInValues:q.record(q.string(),q.string()).optional().describe("Filter by exact match within comma-separated values (e.g., user_tags in 'Engineering')")}),outputSchema:q.object({logs:q.array(ZT4).describe("Array of monitoring logs"),total:q.number().describe("Total number of logs matching filters"),offset:q.number().describe("Current offset for pagination"),limit:q.number().describe("Current limit for pagination")}),handler:async(Y,Q)=>{let X=B0(Q),G=Y.properties||Y.propertyKeys||Y.propertyPatterns||Y.propertyInValues?{properties:Y.properties,propertyKeys:Y.propertyKeys,propertyPatterns:Y.propertyPatterns,propertyInValues:Y.propertyInValues}:void 0,K={organizationId:X.id,connectionId:Y.connectionId,excludeConnectionIds:Y.excludeConnectionIds,virtualMcpId:Y.virtualMcpId,toolName:Y.toolName,isError:Y.isError,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0,limit:Y.limit,offset:Y.offset,propertyFilters:G},W=await Q.storage.monitoring.query(K);return{logs:W.logs.map((Z)=>({...Z,timestamp:Z.timestamp instanceof Date?Z.timestamp.toISOString():Z.timestamp})),total:W.total,offset:Y.offset,limit:Y.limit}}})});var o$1;var Lb0=S(()=>{k0();y1();o$1=v1({name:"MONITORING_STATS",description:"Get aggregated statistics for tool call monitoring",annotations:{title:"Get Monitoring Stats",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({startDate:q.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:q.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)")}),outputSchema:q.object({totalCalls:q.number().describe("Total number of tool calls"),errorRate:q.number().describe("Error rate as a decimal (0 to 1)"),avgDurationMs:q.number().describe("Average call duration in milliseconds"),errorRatePercent:q.string().describe("Error rate as a percentage string")}),handler:async(Y,Q)=>{let J={organizationId:B0(Q).id,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0},G=await Q.storage.monitoring.getStats(J);return{...G,errorRatePercent:(G.errorRate*100).toFixed(2)}}})});var Nb0=S(()=>{Ob0();Lb0()});var HT4,FT4,$T4,VT4,qT4,GI,WI,E$,BT4,UT4,Mb0;var pN=S(()=>{y1();HT4=q.enum(["sum","avg","min","max","count","last"]).describe("Aggregation function to apply"),FT4=q.enum(["metric","timeseries","table"]).describe("Widget display type"),$T4=q.object({path:q.string().describe("JSONPath to extract value, e.g., '$.usage.total_tokens'"),from:q.enum(["input","output"]).describe("Extract from tool call input or output")}),VT4=q.object({fn:HT4,groupBy:q.string().optional().describe("Optional JSONPath for grouping results"),interval:q.string().optional().describe("For timeseries widgets: interval like '1h', '1d', '15m'")}),qT4=q.object({connectionIds:q.array(q.string()).optional().describe("Filter to specific connections"),toolNames:q.array(q.string()).optional().describe("Filter to specific tools")}),GI=q.object({id:q.string().describe("Unique widget identifier"),name:q.string().describe("Widget display name"),type:FT4,source:$T4,aggregation:VT4,filter:qT4.optional()}),WI=q.object({connectionIds:q.array(q.string()).optional().describe("Filter to specific connections"),virtualMcpIds:q.array(q.string()).optional().describe("Filter to specific virtual MCPs/agents"),toolNames:q.array(q.string()).optional().describe("Filter to specific tools"),propertyFilters:q.record(q.string(),q.string()).optional().describe("Filter by exact metadata property key=value matches (e.g., { environment: 'production' })")}),E$=q.object({id:q.string().describe("Unique dashboard identifier"),organizationId:q.string().describe("Organization ID"),name:q.string().describe("Dashboard name"),description:q.string().nullable().describe("Dashboard description"),filters:WI.nullable().describe("Global filters applied to all widgets"),widgets:q.array(GI).describe("Widget definitions"),createdBy:q.string().describe("User ID who created the dashboard"),createdAt:q.string().describe("Creation timestamp"),updatedAt:q.string().describe("Last update timestamp")}),BT4=q.object({key:q.string().describe("Group key value"),value:q.number().describe("Aggregated value for this group")}),UT4=q.object({timestamp:q.string().describe("Time bucket timestamp"),value:q.number().describe("Aggregated value for this time bucket")}),Mb0=q.object({widgetId:q.string().describe("Widget ID this result is for"),value:q.number().nullable().describe("Aggregated value (for metric type)"),groups:q.array(BT4).optional().describe("Grouped results (when groupBy is specified)"),timeseries:q.array(UT4).optional().describe("Timeseries data (for timeseries type)")})});var s$1;var wb0=S(()=>{k0();y1();pN();s$1=v1({name:"MONITORING_DASHBOARD_CREATE",description:"Create a new monitoring dashboard with JSONPath widgets",annotations:{title:"Create Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({name:q.string().min(1).describe("Dashboard name"),description:q.string().optional().describe("Dashboard description"),filters:WI.optional().describe("Global filters applied to all widgets"),widgets:q.array(GI).min(1).describe("Widget definitions (at least one required)")}),outputSchema:E$,handler:async(Y,Q)=>{let X=B0(Q),J=Q.auth.user?.id;if(!J)throw Error("User authentication required");let G=await Q.storage.monitoringDashboards.create(X.id,J,{name:Y.name,description:Y.description,filters:Y.filters,widgets:Y.widgets});return{id:G.id,organizationId:G.organizationId,name:G.name,description:G.description,filters:G.filters,widgets:G.widgets,createdBy:G.createdBy,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}})});var t$1;var Ab0=S(()=>{k0();y1();pN();t$1=v1({name:"MONITORING_DASHBOARD_GET",description:"Get a monitoring dashboard by ID",annotations:{title:"Get Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string().describe("Dashboard ID")}),outputSchema:E$.nullable(),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.id);if(!J||J.organizationId!==X.id)return null;return{id:J.id,organizationId:J.organizationId,name:J.name,description:J.description,filters:J.filters,widgets:J.widgets,createdBy:J.createdBy,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var e$1;var Pb0=S(()=>{k0();y1();pN();e$1=v1({name:"MONITORING_DASHBOARD_LIST",description:"List all monitoring dashboards for the organization",annotations:{title:"List Monitoring Dashboards",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({dashboards:q.array(E$).describe("List of dashboards"),total:q.number().describe("Total number of dashboards")}),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.list(X.id);return{dashboards:J.map((G)=>({id:G.id,organizationId:G.organizationId,name:G.name,description:G.description,filters:G.filters,widgets:G.widgets,createdBy:G.createdBy,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt})),total:J.length}}})});var YV1;var Eb0=S(()=>{k0();y1();pN();YV1=v1({name:"MONITORING_DASHBOARD_UPDATE",description:"Update an existing monitoring dashboard",annotations:{title:"Update Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string().describe("Dashboard ID to update"),name:q.string().optional().describe("New dashboard name"),description:q.string().nullable().optional().describe("New dashboard description"),filters:WI.nullable().optional().describe("New global filters"),widgets:q.array(GI).optional().describe("New widget definitions")}),outputSchema:E$,handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.id);if(!J||J.organizationId!==X.id)throw Error(`Dashboard ${Y.id} not found`);let G={};if(Y.name!==void 0)G.name=Y.name;if(Y.description!==void 0)G.description=Y.description;if(Y.filters!==void 0)G.filters=Y.filters;if(Y.widgets!==void 0)G.widgets=Y.widgets;let K=await Q.storage.monitoringDashboards.update(Y.id,G);return{id:K.id,organizationId:K.organizationId,name:K.name,description:K.description,filters:K.filters,widgets:K.widgets,createdBy:K.createdBy,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt,updatedAt:K.updatedAt instanceof Date?K.updatedAt.toISOString():K.updatedAt}}})});var QV1;var Tb0=S(()=>{k0();y1();QV1=v1({name:"MONITORING_DASHBOARD_DELETE",description:"Delete a monitoring dashboard",annotations:{title:"Delete Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string().describe("Dashboard ID to delete")}),outputSchema:q.object({success:q.boolean().describe("Whether the deletion was successful")}),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.id);if(!J||J.organizationId!==X.id)throw Error(`Dashboard ${Y.id} not found`);return await Q.storage.monitoringDashboards.delete(Y.id),{success:!0}}})});var XV1;var Cb0=S(()=>{k0();y1();pN();XV1=v1({name:"MONITORING_DASHBOARD_QUERY",description:"Execute a dashboard's widgets and return aggregated monitoring data",annotations:{title:"Query Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({dashboardId:q.string().describe("Dashboard ID to query"),timeRange:q.object({startDate:q.string().datetime().describe("Start of time range (ISO 8601)"),endDate:q.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:q.object({properties:q.record(q.string(),q.string()).optional().describe("Exact match: property key equals value"),propertyKeys:q.array(q.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:q.record(q.string(),q.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE, use % as wildcard)"),propertyInValues:q.record(q.string(),q.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Runtime property filters applied to all widgets (merged with dashboard-level filters)")}),outputSchema:q.object({dashboardId:q.string().describe("Dashboard ID"),results:q.array(Mb0).describe("Widget query results"),timeRange:q.object({startDate:q.string(),endDate:q.string()}).describe("Time range used for the query")}),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.dashboardId);if(!J||J.organizationId!==X.id)throw Error(`Dashboard ${Y.dashboardId} not found`);let G=new Date,K=Y.timeRange?.startDate?new Date(Y.timeRange.startDate):new Date(G.getTime()-86400000),W=Y.timeRange?.endDate?new Date(Y.timeRange.endDate):G,Z=await Promise.all(J.widgets.map(async(H)=>{let F=J.filters?.propertyFilters,$=Y.propertyFilters,V=F||$?{properties:{...F,...$?.properties},propertyKeys:$?.propertyKeys,propertyPatterns:$?.propertyPatterns,propertyInValues:$?.propertyInValues}:void 0,B={connectionIds:H.filter?.connectionIds??J.filters?.connectionIds??void 0,virtualMcpIds:J.filters?.virtualMcpIds??void 0,toolNames:H.filter?.toolNames??J.filters?.toolNames??void 0,startDate:K,endDate:W,propertyFilters:V};try{let U=await Q.storage.monitoring.aggregate({organizationId:X.id,path:H.source.path,from:H.source.from,aggregation:H.aggregation.fn,groupBy:H.aggregation.groupBy,interval:H.aggregation.interval,filters:B});return{widgetId:H.id,value:U.value,groups:U.groups,timeseries:U.timeseries}}catch(U){return console.error(`Widget ${H.id} aggregation failed:`,U),{widgetId:H.id,value:null,groups:void 0,timeseries:void 0}}}));return{dashboardId:Y.dashboardId,results:Z,timeRange:{startDate:K.toISOString(),endDate:W.toISOString()}}}})});var zT4,JV1;var Rb0=S(()=>{k0();y1();zT4=q.object({type:q.enum(["metric","timeseries","table"]),source:q.object({path:q.string().describe("JSONPath to extract value from"),from:q.enum(["input","output"]).describe("Extract from input or output")}),aggregation:q.object({fn:q.enum(["sum","avg","min","max","count","last"]).describe("Aggregation function"),groupBy:q.string().optional().describe("JSONPath for grouping (table)"),interval:q.string().optional().describe("Time interval for timeseries (15m, 1h, 1d)")}),filter:q.object({connectionIds:q.array(q.string()).optional(),toolNames:q.array(q.string()).optional()}).optional()}),JV1=v1({name:"MONITORING_WIDGET_PREVIEW",description:"Preview a widget aggregation without saving. Used to test queries in the dashboard editor.",annotations:{title:"Preview Monitoring Widget",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({widget:zT4.describe("Widget configuration to preview"),timeRange:q.object({startDate:q.string().datetime().describe("Start of time range (ISO 8601)"),endDate:q.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:q.object({properties:q.record(q.string(),q.string()).optional().describe("Exact match: property key equals value"),propertyKeys:q.array(q.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:q.record(q.string(),q.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE)"),propertyInValues:q.record(q.string(),q.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Property filters to apply")}),outputSchema:q.object({value:q.number().nullable().optional().describe("Aggregated value"),groups:q.array(q.object({key:q.string(),value:q.number()})).optional().describe("Grouped results for table widgets"),timeseries:q.array(q.object({timestamp:q.string(),value:q.number()})).optional().describe("Timeseries data points"),matchedRecords:q.number().describe("Number of records that matched"),timeRange:q.object({startDate:q.string(),endDate:q.string()}).describe("Time range used for the query")}),handler:async(Y,Q)=>{let X=B0(Q),{widget:J,timeRange:G}=Y,K=new Date,W=G?.startDate?new Date(G.startDate):new Date(K.getTime()-86400000),Z=G?.endDate?new Date(G.endDate):K,H={connectionIds:J.filter?.connectionIds,toolNames:J.filter?.toolNames,startDate:W,endDate:Z,propertyFilters:Y.propertyFilters};try{let F=await Q.storage.monitoring.countMatched({organizationId:X.id,path:J.source.path,from:J.source.from,filters:H}),$=await Q.storage.monitoring.aggregate({organizationId:X.id,path:J.source.path,from:J.source.from,aggregation:J.aggregation.fn,groupBy:J.aggregation.groupBy,interval:J.aggregation.interval,filters:H});return{value:$.value,groups:$.groups,timeseries:$.timeseries,matchedRecords:F,timeRange:{startDate:W.toISOString(),endDate:Z.toISOString()}}}catch(F){return console.error("Widget preview aggregation failed:",F),{value:null,matchedRecords:0,timeRange:{startDate:W.toISOString(),endDate:Z.toISOString()}}}}})});var Ib0=S(()=>{wb0();Ab0();Pb0();Eb0();Tb0();Cb0();Rb0()});var GV1;var jb0=S(()=>{y1();k0();GV1=v1({name:"ORGANIZATION_CREATE",description:"Create a new organization",annotations:{title:"Create Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({slug:q.string().min(1).max(50).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens"),name:q.string().min(1).max(255),description:q.string().optional()}),outputSchema:q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),members:q.array(q.any()).optional()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=D9(Q);if(!X)throw Error("User ID required to create organization");let J=await Q.boundAuth.organization.create({name:Y.name,slug:Y.slug,metadata:Y.description?{description:Y.description}:void 0,userId:X});if(!J)throw Error("Failed to create organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var WV1;var Sb0=S(()=>{y1();k0();WV1=v1({name:"ORGANIZATION_LIST",description:"List all organizations user has access to",annotations:{title:"List Organizations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({userId:q.string().optional()}),outputSchema:q.object({organizations:q.array(q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=D9(Q),J=Y.userId||X;if(!J)throw Error("User ID required to list organizations");return{organizations:(await Q.boundAuth.organization.list(J)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt}))}}})});var ZV1;var _b0=S(()=>{y1();k0();ZV1=v1({name:"ORGANIZATION_GET",description:"Get organization details by slug or ID",annotations:{title:"Get Organization",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),members:q.array(q.any()).optional(),invitations:q.array(q.any()).optional()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=await Q.boundAuth.organization.get();if(!X)throw Error("No active organization found");let J=new Date,G=X.invitations?.filter((K)=>new Date(K.expiresAt)>J);return{...X,invitations:G,createdAt:X.createdAt instanceof Date?X.createdAt.toISOString():X.createdAt}}})});var KV1;var vb0=S(()=>{y1();k0();KV1=v1({name:"ORGANIZATION_UPDATE",description:"Update an existing organization",annotations:{title:"Update Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string(),slug:q.string().min(1).max(50).regex(/^[a-z0-9-]+$/).optional(),name:q.string().min(1).max(255).optional(),description:q.string().optional()}),outputSchema:q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X={};if(Y.name)X.name=Y.name;if(Y.slug)X.slug=Y.slug;if(Y.description)X.metadata={description:Y.description};let J=await Q.boundAuth.organization.update({organizationId:Y.id,data:X});if(!J)throw Error("Failed to update organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var HV1;var kb0=S(()=>{y1();k0();HV1=v1({name:"ORGANIZATION_DELETE",description:"Delete an organization",annotations:{title:"Delete Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string()}),outputSchema:q.object({success:q.boolean(),id:q.string()}),handler:async(Y,Q)=>{return o1(Q),await Q.access.check(),await Q.boundAuth.organization.delete(Y.id),{success:!0,id:Y.id}}})});var ZI;var FV1=S(()=>{y1();ZI=q.object({title:q.string(),url:q.string(),icon:q.string()})});var $V1;var yb0=S(()=>{y1();k0();FV1();$V1=v1({name:"ORGANIZATION_SETTINGS_GET",description:"Get organization-level settings",annotations:{title:"Get Organization Settings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({organizationId:q.string(),sidebar_items:q.array(ZI).nullable().optional(),enabled_plugins:q.array(q.string()).nullable().optional(),createdAt:q.string().datetime().optional().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().optional().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let J=await Q.storage.organizationSettings.get(X);if(!J)return{organizationId:X};return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var VV1;var fb0=S(()=>{y1();k0();FV1();VV1=v1({name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization-level settings",annotations:{title:"Update Organization Settings",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string(),sidebar_items:q.array(ZI).optional(),enabled_plugins:q.array(q.string()).optional()}),outputSchema:q.object({organizationId:q.string(),sidebar_items:q.array(ZI).nullable().optional(),enabled_plugins:q.array(q.string()).nullable().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{if(o1(Q),await Q.access.check(),Q.organization&&Q.organization.id!==Y.organizationId)throw Error("Cannot update settings for a different organization");let X=await Q.storage.organizationSettings.upsert(Y.organizationId,{sidebar_items:Y.sidebar_items,enabled_plugins:Y.enabled_plugins});return{...X,createdAt:X.createdAt instanceof Date?X.createdAt.toISOString():X.createdAt,updatedAt:X.updatedAt instanceof Date?X.updatedAt.toISOString():X.updatedAt}}})});var qV1;var bb0=S(()=>{y1();k0();qV1=v1({name:"ORGANIZATION_MEMBER_ADD",description:"Add a member to an organization",annotations:{title:"Add Organization Member",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().optional(),userId:q.string(),role:q.array(q.string())}),outputSchema:q.object({id:q.string(),organizationId:q.string(),userId:q.string(),role:q.union([q.string(),q.array(q.string())]),createdAt:q.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Y.organizationId||Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let J=await Q.boundAuth.organization.addMember({organizationId:X,userId:Y.userId,role:Y.role});if(!J)throw Error("Failed to add member");return{...J,role:J.role,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var BV1;var hb0=S(()=>{y1();k0();BV1=v1({name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove a member from an organization",annotations:{title:"Remove Organization Member",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().optional(),memberIdOrEmail:q.string()}),outputSchema:q.object({success:q.boolean(),memberIdOrEmail:q.string()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Y.organizationId||Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");return await Q.boundAuth.organization.removeMember({organizationId:X,memberIdOrEmail:Y.memberIdOrEmail}),{success:!0,memberIdOrEmail:Y.memberIdOrEmail}}})});var UV1;var xb0=S(()=>{y1();k0();UV1=v1({name:"ORGANIZATION_MEMBER_LIST",description:"List all members in an organization",annotations:{title:"List Organization Members",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({limit:q.number().optional(),offset:q.number().optional()}),outputSchema:q.object({members:q.array(q.object({id:q.string(),organizationId:q.string(),userId:q.string(),role:q.string(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),user:q.object({id:q.string(),name:q.string(),email:q.string(),image:q.string().optional()}).optional()}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let J=await Q.boundAuth.organization.listMembers({organizationId:X,limit:Y.limit,offset:Y.offset});return{members:(Array.isArray(J)?J:[]).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt}))}}})});var zV1;var gb0=S(()=>{y1();k0();zV1=v1({name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update a member's role in an organization",annotations:{title:"Update Member Role",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().optional(),memberId:q.string(),role:q.array(q.string())}),outputSchema:q.object({id:q.string(),organizationId:q.string(),userId:q.string(),role:q.union([q.literal("admin"),q.literal("member"),q.literal("owner")]),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),user:q.object({email:q.string(),name:q.string(),image:q.string().optional()})}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Y.organizationId||Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let J=await Q.boundAuth.organization.updateMemberRole({organizationId:X,memberId:Y.memberId,role:Y.role});if(!J)throw Error("Failed to update member role");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var ub0=S(()=>{jb0();Sb0();_b0();vb0();kb0();yb0();fb0();bb0();hb0();xb0();gb0()});var LT4,Lp,NT4,WU,mb0,Np;var ZU=S(()=>{y1();LT4=q.object({banner:q.string().nullable(),bannerColor:q.string().nullable(),icon:q.string().nullable(),themeColor:q.string().nullable()}),Lp=q.object({banner:q.string().nullable().optional(),bannerColor:q.string().nullable().optional(),icon:q.string().nullable().optional(),themeColor:q.string().nullable().optional()}),NT4=q.object({id:q.string(),title:q.string(),icon:q.string().nullable()}),WU=q.object({id:q.string(),organizationId:q.string(),slug:q.string(),name:q.string(),description:q.string().nullable(),enabledPlugins:q.array(q.string()).nullable(),ui:LT4.nullable(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().describe("ISO 8601 timestamp")}),mb0=WU.omit({organizationId:!0}).extend({boundConnections:q.array(NT4)}),Np=q.object({id:q.string(),projectId:q.string(),pluginId:q.string(),connectionId:q.string().nullable(),settings:q.record(q.string(),q.unknown()).nullable(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().describe("ISO 8601 timestamp")})});var DV1;var lb0=S(()=>{y1();k0();ZU();DV1=v1({name:"PROJECT_LIST",description:"List all projects in an organization",annotations:{title:"List Projects",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().describe("Organization ID to list projects for")}),outputSchema:q.object({projects:q.array(mb0)}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=await Q.storage.projects.list(Y.organizationId),J=X.map((K)=>K.id),G=await Q.storage.projectPluginConfigs.getBoundConnectionsForProjects(J);return{projects:X.map((K)=>({id:K.id,slug:K.slug,name:K.name,description:K.description,enabledPlugins:K.enabledPlugins,ui:K.ui,boundConnections:G.get(K.id)??[],createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt,updatedAt:K.updatedAt instanceof Date?K.updatedAt.toISOString():K.updatedAt}))}}})});var OV1;var db0=S(()=>{y1();k0();ZU();OV1=v1({name:"PROJECT_GET",description:"Get a project by ID or slug",annotations:{title:"Get Project",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().describe("Organization ID"),projectId:q.string().optional().describe("Project ID (either this or slug required)"),slug:q.string().optional().describe("Project slug (either this or projectId required)")}).refine((Y)=>Y.projectId||Y.slug,{message:"Either projectId or slug must be provided"}),outputSchema:q.object({project:WU.nullable()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=null;if(Y.projectId)X=await Q.storage.projects.get(Y.projectId);else if(Y.slug)X=await Q.storage.projects.getBySlug(Y.organizationId,Y.slug);if(!X)return{project:null};return{project:{id:X.id,organizationId:X.organizationId,slug:X.slug,name:X.name,description:X.description,enabledPlugins:X.enabledPlugins,ui:X.ui,createdAt:X.createdAt instanceof Date?X.createdAt.toISOString():X.createdAt,updatedAt:X.updatedAt instanceof Date?X.updatedAt.toISOString():X.updatedAt}}}})});var LV1;var pb0=S(()=>{y1();jY();k0();ZU();LV1=v1({name:"PROJECT_CREATE",description:"Create a new project in an organization",annotations:{title:"Create Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().describe("Organization ID"),slug:q.string().min(1).max(100).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens").describe("URL-friendly identifier"),name:q.string().min(1).max(200).describe("Display name"),description:q.string().max(1000).nullable().optional().describe("Project description"),enabledPlugins:q.array(q.string()).nullable().optional().describe("Plugin IDs to enable"),ui:Lp.nullable().optional().describe("UI customization")}),outputSchema:q.object({project:WU}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{organizationId:X,slug:J,name:G,description:K,enabledPlugins:W,ui:Z}=Y;if(J===n7)throw Error(`Slug "${n7}" is reserved`);if(await Q.storage.projects.getBySlug(X,J))throw Error(`Project with slug "${J}" already exists in this organization`);let F=Z?{banner:Z.banner??null,bannerColor:Z.bannerColor??null,icon:Z.icon??null,themeColor:Z.themeColor??null}:null,$=await Q.storage.projects.create({organizationId:X,slug:J,name:G,description:K??null,enabledPlugins:W??null,ui:F});return{project:{id:$.id,organizationId:$.organizationId,slug:$.slug,name:$.name,description:$.description,enabledPlugins:$.enabledPlugins,ui:$.ui,createdAt:$.createdAt instanceof Date?$.createdAt.toISOString():$.createdAt,updatedAt:$.updatedAt instanceof Date?$.updatedAt.toISOString():$.updatedAt}}}})});var NV1;var cb0=S(()=>{y1();k0();ZU();NV1=v1({name:"PROJECT_UPDATE",description:"Update a project's details",annotations:{title:"Update Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID to update"),name:q.string().min(1).max(200).optional().describe("New display name"),description:q.string().max(1000).nullable().optional().describe("New description"),enabledPlugins:q.array(q.string()).nullable().optional().describe("Updated plugin IDs"),ui:Lp.nullable().optional().describe("Updated UI customization")}),outputSchema:q.object({project:WU.nullable()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X,name:J,description:G,enabledPlugins:K,ui:W}=Y,Z={};if(J!==void 0)Z.name=J;if(G!==void 0)Z.description=G;if(K!==void 0)Z.enabledPlugins=K;if(W!==void 0)Z.ui=W?{banner:W.banner??null,bannerColor:W.bannerColor??null,icon:W.icon??null,themeColor:W.themeColor??null}:null;let H=await Q.storage.projects.update(X,Z);if(!H)return{project:null};return{project:{id:H.id,organizationId:H.organizationId,slug:H.slug,name:H.name,description:H.description,enabledPlugins:H.enabledPlugins,ui:H.ui,createdAt:H.createdAt instanceof Date?H.createdAt.toISOString():H.createdAt,updatedAt:H.updatedAt instanceof Date?H.updatedAt.toISOString():H.updatedAt}}}})});var MV1;var nb0=S(()=>{y1();jY();k0();MV1=v1({name:"PROJECT_DELETE",description:"Delete a project (cannot delete org-admin)",annotations:{title:"Delete Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID to delete")}),outputSchema:q.object({success:q.boolean(),message:q.string().optional()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X}=Y,J=await Q.storage.projects.get(X);if(!J)return{success:!1,message:"Project not found"};if(J.slug===n7)return{success:!1,message:"Cannot delete the org-admin project"};return{success:await Q.storage.projects.delete(X)}}})});var wV1;var ib0=S(()=>{y1();k0();ZU();wV1=v1({name:"PROJECT_PLUGIN_CONFIG_GET",description:"Get plugin configuration for a project",annotations:{title:"Get Project Plugin Config",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID"),pluginId:q.string().describe("Plugin ID")}),outputSchema:q.object({config:Np.nullable()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X,pluginId:J}=Y,G=await Q.storage.projectPluginConfigs.get(X,J);if(!G)return{config:null};return{config:{id:G.id,projectId:G.projectId,pluginId:G.pluginId,connectionId:G.connectionId,settings:G.settings,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}}})});var AV1;var ab0=S(()=>{y1();k0();ZU();Vp();AV1=v1({name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update or create plugin configuration for a project",annotations:{title:"Update Project Plugin Config",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID"),pluginId:q.string().describe("Plugin ID"),connectionId:q.string().nullable().optional().describe("MCP connection to bind"),settings:q.record(q.string(),q.unknown()).nullable().optional().describe("Plugin-specific settings")}),outputSchema:q.object({config:Np}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X,pluginId:J,connectionId:G,settings:K}=Y,W=D9(Q),Z=await Q.storage.projects.get(X);if(!Z)throw Error(`Project not found: ${X}`);let H=G?await Q.storage.connections.findById(G):null;if(G&&Z.organizationId&&!H&&hN()){if($p(G,Z.organizationId)){if(!W)throw Error("User ID required to create dev-assets connection");let $=xN(Z.organizationId,AG());await Q.storage.connections.create({...$,organization_id:Z.organizationId,created_by:W})}}let F=await Q.storage.projectPluginConfigs.upsert(X,J,{connectionId:G,settings:K});return{config:{id:F.id,projectId:F.projectId,pluginId:F.pluginId,connectionId:F.connectionId,settings:F.settings,createdAt:F.createdAt instanceof Date?F.createdAt.toISOString():F.createdAt,updatedAt:F.updatedAt instanceof Date?F.updatedAt.toISOString():F.updatedAt}}}})});var rb0=S(()=>{lb0();db0();pb0();cb0();nb0();ib0();ab0()});var PV1;var ob0=S(()=>{y1();k0();PV1=v1({name:"TAGS_LIST",description:"List all tags in an organization",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({tags:q.array(q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q);return{tags:(await Q.storage.tags.listOrgTags(X.id)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var EV1;var sb0=S(()=>{y1();k0();EV1=v1({name:"TAGS_CREATE",description:"Create a new tag in an organization",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({name:q.string().min(1).max(50).describe("Tag name")}),outputSchema:q.object({tag:q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")})}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q),J=await Q.storage.tags.createTag(X.id,Y.name);return{tag:{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():String(J.createdAt)}}}})});var TV1;var tb0=S(()=>{y1();k0();TV1=v1({name:"TAGS_DELETE",description:"Delete a tag from an organization (removes from all members)",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({tagId:q.string().describe("Tag ID to delete")}),outputSchema:q.object({success:q.boolean()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q),J=await Q.storage.tags.getTag(Y.tagId);if(!J)throw Error("Tag not found");if(J.organizationId!==X.id)throw Error("Tag does not belong to this organization");return await Q.storage.tags.deleteTag(Y.tagId),{success:!0}}})});var CV1;var eb0=S(()=>{y1();k0();CV1=v1({name:"MEMBER_TAGS_GET",description:"Get tags assigned to a member",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({memberId:q.string().describe("Member ID")}),outputSchema:q.object({tags:q.array(q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q);if(!await Q.storage.tags.verifyMemberOrg(Y.memberId,X.id))throw Error(`Member not found in this organization: ${Y.memberId}`);return{tags:(await Q.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var RV1;var Yh0=S(()=>{y1();k0();RV1=v1({name:"MEMBER_TAGS_SET",description:"Set tags for a member (replaces all existing tags)",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({memberId:q.string().describe("Member ID"),tagIds:q.array(q.string()).describe("Array of tag IDs to assign")}),outputSchema:q.object({success:q.boolean(),tags:q.array(q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q);if(!await Q.storage.tags.verifyMemberOrg(Y.memberId,X.id))throw Error(`Member not found in this organization: ${Y.memberId}`);for(let K of Y.tagIds){let W=await Q.storage.tags.getTag(K);if(!W)throw Error(`Tag not found: ${K}`);if(W.organizationId!==X.id)throw Error(`Tag does not belong to this organization: ${K}`)}return await Q.storage.tags.setMemberTags(Y.memberId,Y.tagIds),{success:!0,tags:(await Q.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var Qh0=S(()=>{ob0();sb0();tb0();eb0();Yh0()});var Xh0;var Jh0=S(()=>{Xh0=["in_progress","requires_action","failed","completed"]});var Gh0,cZ,Wh0,Zh0;var KU=S(()=>{y1();Jh0();Gh0=q.object({id:q.string().describe("Unique message ID"),thread_id:q.string().describe("ID of the parent thread"),metadata:q.unknown().optional().describe("Optional message metadata"),parts:q.array(q.record(q.string(),q.unknown())).describe("Message content parts (AI SDK UIMessagePart format)"),role:q.enum(["user","assistant","system"]).describe("Message role"),created_at:q.string().datetime().describe("Timestamp of creation"),updated_at:q.string().datetime().describe("Timestamp of last update")}),cZ=q.object({id:q.string().describe("Unique thread ID"),organization_id:q.string().describe("Organization this thread belongs to"),title:q.string().describe("Thread title"),description:q.string().nullable().describe("Thread description"),created_at:q.string().datetime().describe("Timestamp of creation"),updated_at:q.string().datetime().describe("Timestamp of last update"),hidden:q.boolean().optional().describe("Whether the thread is hidden"),status:q.enum([...Xh0,"expired"]).describe("Thread execution status. 'expired' is virtual -- computed at read time for stale in_progress threads"),created_by:q.string().describe("User ID who created the thread"),updated_by:q.string().nullable().describe("User ID who last updated the thread")}),Wh0=q.object({id:q.string().optional().describe("Optional custom ID for the thread"),title:q.string().describe("Thread title"),description:q.string().nullish().describe("Thread description")}),Zh0=q.object({title:q.string().optional().describe("New thread title"),description:q.string().nullish().describe("New thread description"),hidden:q.boolean().optional().describe("Whether the thread is hidden")})});var AT4,PT4,IV1;var Kh0=S(()=>{y1();k0();KU();BC();AT4=q.object({data:Wh0.describe("Data for the new thread (id is auto-generated if not provided)")}),PT4=q.object({item:cZ.describe("The created thread entity")}),IV1=v1({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread in the organization",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:AT4,outputSchema:PT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to create thread");let G=Y.data.id??Y$("thrd"),K=await Q.storage.threads.create({id:G,organization_id:X.id,title:Y.data.title,description:Y.data.description,created_by:J});return{item:{...K,hidden:K.hidden??!1}}}})});function T$(Y,Q=Date.now()){let X=Y.status;if(X==="in_progress"){let J=new Date(Y.updated_at).getTime();if(!Number.isFinite(J)||Q-J>1800000)X="expired"}return{...Y,status:X,hidden:Y.hidden??!1}}var ET4,TT4,jV1;var Hh0=S(()=>{gX();k0();KU();y1();ET4=dG.extend({where:q.object({created_by:q.string().optional()}).optional()}),TT4=M3(cZ),jV1=v1({name:"COLLECTION_THREADS_LIST",description:"List all threads in the organization with filtering, sorting, and pagination",annotations:{title:"List Threads",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:ET4,outputSchema:TT4,handler:async(Y,Q)=>{await Q.access.check();let X=Q.auth.user?.id;if(!X)throw Error("User ID required to list threads");let J=B0(Q),G=Y.offset??0,K=Y.limit??100,{threads:W,total:Z}=await Q.storage.threads.list(J.id,X,{limit:K,offset:G}),H=G+K<Z,F=Date.now();return{items:W.map(($)=>T$($,F)),totalCount:Z,hasMore:H}}})});var CT4,SV1;var Fh0=S(()=>{gX();k0();KU();CT4=AC(cZ),SV1=v1({name:"COLLECTION_THREADS_GET",description:"Get thread details by ID",annotations:{title:"Get Thread",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:wC,outputSchema:CT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.threads.get(Y.id);if(!J||J.organization_id!==X.id)return{item:null};return{item:T$(J)}}})});var RT4,IT4,_V1;var $h0=S(()=>{y1();k0();KU();RT4=q.object({id:q.string().describe("ID of the thread to update"),data:Zh0.describe("Partial thread data to update")}),IT4=q.object({item:cZ.describe("The updated thread entity")}),_V1=v1({name:"COLLECTION_THREADS_UPDATE",description:"Update an existing thread in the organization",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:RT4,outputSchema:IT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to update thread");let{id:G,data:K}=Y,W=await Q.storage.threads.get(G);if(!W||W.organization_id!==X.id)throw Error("Thread not found in organization");let Z=await Q.storage.threads.update(G,{title:K.title,description:K.description,hidden:K.hidden,updated_by:J});return{item:T$(Z)}}})});var vV1;var Vh0=S(()=>{gX();k0();KU();vV1=v1({name:"COLLECTION_THREADS_DELETE",description:"Delete a thread",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:PC,outputSchema:EC(cZ),handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.threads.get(Y.id);if(!J)throw Error(`Thread not found: ${Y.id}`);if(J.organization_id!==X.id)throw Error(`Thread not found: ${Y.id}`);return await Q.storage.threads.delete(Y.id),{item:T$(J)}}})});function qh0(Y){if(!Y)return null;if("field"in Y&&Y.field[0]==="thread_id"&&Y.operator==="eq")return String(Y.value);if("conditions"in Y)for(let Q of Y.conditions){let X=qh0(Q);if(X)return X}return null}var jT4,kV1;var Bh0=S(()=>{gX();k0();KU();jT4=M3(Gh0),kV1=v1({name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List all messages for a specific thread",annotations:{title:"List Thread Messages",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:dG,outputSchema:jT4,handler:async(Y,Q)=>{let X=B0(Q);await Q.access.check();let J=qh0(Y.where);if(!J)throw Error("thread_id filter is required in where clause");let G=await Q.storage.threads.get(J);if(!G||G.organization_id!==X.id)return{items:[],totalCount:0,hasMore:!1};let K=Y.offset??0,W=Y.limit??100,{messages:Z,total:H}=await Q.storage.threads.listMessages(J,{limit:W,offset:K}),F=K+W<H;return{items:Z,totalCount:H,hasMore:F}}})});var Uh0=S(()=>{Kh0();Hh0();Fh0();$h0();Vh0();Bh0()});var _T4,vT4,yV1;var zh0=S(()=>{y1();k0();_T4=q.object({id:q.string().min(1)}),vT4=q.object({user:q.object({id:q.string(),name:q.string(),email:q.string(),image:q.string().nullable()}).nullable()}),yV1=v1({name:"USER_GET",description:"Get a user by id (restricted to shared organizations)",annotations:{title:"Get User",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:_T4,outputSchema:vT4,handler:async(Y,Q)=>{await Q.access.check(),o1(Q);let X=D9(Q);if(!X)throw Error("Authentication required");let J=await Q.storage.users.findById(Y.id,X);if(!J)return{user:null};return{user:{id:J.id,name:J.name,email:J.email,image:J.image??null}}}})});var Dh0=S(()=>{zh0()});var Lh0={};t0(Lh0,{managementMCP:()=>bT4,ALL_TOOLS:()=>Oh0});var yT4,fT4,Oh0,bT4=async(Y)=>{let Q=null;if(Y.organization){let G=await Y.storage.organizationSettings.get(Y.organization.id),K=await Y.storage.projects.list(Y.organization.id),W=new Set(G?.enabled_plugins??[]);for(let Z of K)if(Z.enabledPlugins)for(let H of Z.enabledPlugins)W.add(H);Q=W.size>0?[...W]:null}let X=Fy0(Oh0,Q),J=new jz({name:"mcp-mesh-management",version:"1.0.0"},{capabilities:{tools:{}}});for(let G of X){let K=G.inputSchema&&typeof G.inputSchema==="object"&&"shape"in G.inputSchema?G.inputSchema:q.object({}),W=G.outputSchema&&typeof G.outputSchema==="object"&&"shape"in G.outputSchema?G.outputSchema:void 0,Z=K.shape,H=W?.shape;J.registerTool(G.name,{description:G.description??"",inputSchema:Z,outputSchema:H,annotations:G.annotations},async(F)=>{Y.access.setToolName(G.name);try{let $=await G.execute(F,Y);return{content:[{type:"text",text:JSON.stringify($)}],structuredContent:$}}catch($){return{content:[{type:"text",text:`Error: ${$.message}`}],isError:!0}}})}return J};var Nh0=S(()=>{iF1();Ak();y1();Ty0();ny0();df0();if0();Jb0();$b0();Db0();Nb0();Ib0();ub0();rb0();Qh0();Uh0();Dh0();yT4=[GV1,WV1,ZV1,KV1,HV1,$V1,VV1,qV1,BV1,UV1,zV1,J$1,Z$1,K$1,I$1,j$1,S$1,x$1,u$1,m$1,l$1,d$1,p$1,c$1,n$1,i$1,a$1,nf0,r$1,o$1,s$1,t$1,e$1,YV1,QV1,XV1,JV1,rF1,sF1,tF1,oF1,_$1,v$1,k$1,y$1,f$1,b$1,h$1,yV1,Y$1,Q$1,X$1,IV1,jV1,SV1,_V1,vV1,kV1,PV1,EV1,TV1,CV1,RV1,DV1,OV1,LV1,NV1,MV1,wV1,AV1],fT4=$y0(),Oh0=[...yT4,...fT4]});function hT4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:Q}=await Promise.resolve().then(() => (Nh0(),Lh0));return Q.map((X)=>{return{name:X.name,inputSchema:q.toJSONSchema(X.inputSchema,{unrepresentable:"any"}),outputSchema:X.outputSchema?q.toJSONSchema(X.outputSchema,{unrepresentable:"any"}):void 0,description:X.description}})},data:Ft(AG(),Y)},{data:Ht()},{data:Kt(Y)}]}async function Mh0(Y,Q){try{let X=FC(),J=new qZ1(process.env.ENCRYPTION_KEY||""),G=new BZ1(X.db,J),K=new UZ1(X.db),W=hT4(Y);try{await K.create({organizationId:Y,slug:n7,name:OU,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(W.map(async(Z)=>{let H=null;if(Z.permissions)H=(await cN.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:Q,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await cL({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),$=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await G.create({...Z.data,id:$,tools:F,organization_id:Y,created_by:Q,connection_token:Z.data.connection_token??H})}))}catch(X){console.error("Error creating default MCP connections:",X)}}var wh0=S(()=>{jY();fm();$M0();VM0();qM0();mm();y1();Up()});var Ah0;var Ph0=S(()=>{Ah0=["owner","admin"]});var xT4=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},Eh0=(Y)=>{if(Y.providerId==="microsoft")return xT4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function gT4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function uT4(){let Y=Math.floor(Math.random()*Ch0.length),Q=Math.floor(Math.random()*Th0.length),X=Ch0[Y]??"deco",J=Th0[Q]??"studio";return`${X}-${J}`}var Th0,Ch0,mT4,lT4,Mp,dT4,pT4,cT4,Rh0,t9,Ih0=void 0,fV1=void 0,nT4=!1,iT4,aT4,rT4,cN;var Up=S(()=>{K21();jk1();zf1();g41();Kb1();Hb1();fh();Ub1();fm();VZ1();WM0();wh0();Ph0();Th0=["labs","agent","studio","workspace","systems","core","cloud","works"],Ch0=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];mT4=Object.values(te()).map((Y)=>Y.map((Q)=>Q.name)).flat(),lT4={...Oh,self:["*",...mT4]},Mp=WZ(lT4),dT4=Mp.newRole({self:["*"],...x2.statements}),pT4=Mp.newRole({self:["*"],...x2.statements}),cT4=Mp.newRole({self:["*"],...x2.statements}),Rh0=Object.values(te()).map((Y)=>Y.map((Q)=>`self:${Q.name}`)).flat(),t9=kh.auth;if(t9.inviteEmailProviderId&&t9.emailProviders&&t9.emailProviders.length>0){let Y=VC(t9.emailProviders,t9.inviteEmailProviderId);if(Y){let Q=$C(Y);Ih0=async(X)=>{let J=X.inviter.user?.name||X.inviter.user?.email,G=`${AG()}/auth/accept-invitation?invitationId=${X.invitation.id}&redirectTo=/`;await Q({to:X.email,subject:`Invitation to join ${X.organization.name}`,html:`
|
|
1479
|
+
`.execute(Y)).rows[0]?.exists)await S4`CREATE ROLE ${S4.id(X)} NOLOGIN`.execute(Y);await S4`GRANT ${S4.id(X)} TO CURRENT_USER`.execute(Y),await S4`GRANT USAGE, CREATE ON SCHEMA ${S4.id(Q)} TO ${S4.id(X)}`.execute(Y),await S4`GRANT ALL ON ALL TABLES IN SCHEMA ${S4.id(Q)} TO ${S4.id(X)}`.execute(Y),await S4`GRANT ALL ON ALL SEQUENCES IN SCHEMA ${S4.id(Q)} TO ${S4.id(X)}`.execute(Y),await S4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${S4.id(Q)} GRANT ALL ON TABLES TO ${S4.id(X)}`.execute(Y),await S4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${S4.id(Q)} GRANT ALL ON SEQUENCES TO ${S4.id(X)}`.execute(Y),await S4`REVOKE ALL ON SCHEMA public FROM ${S4.id(X)}`.execute(Y)}async function _E4(Y,Q,X,J){try{return await Y.transaction().execute(async(G)=>{return await S4`SET LOCAL ROLE ${S4.id(X)}`.execute(G),await S4`SET LOCAL search_path TO ${S4.id(Q)}`.execute(G),await S4.raw(J).execute(G)})}catch(G){if(jE4(G))return await SE4(Y,Q,X),await Y.transaction().execute(async(K)=>{return await S4`SET LOCAL ROLE ${S4.id(X)}`.execute(K),await S4`SET LOCAL search_path TO ${S4.id(Q)}`.execute(K),await S4.raw(J).execute(K)});throw G}}var EE4,CE4,nf0;var if0=S(()=>{y1();k0();EE4=q.object({results:q.array(q.unknown()).optional(),success:q.boolean().optional()});CE4=q.object({sql:q.string().describe("The SQL query to run"),params:q.array(q.any()).describe("The parameters to pass to the SQL query").optional()});nf0=v1({name:"DATABASES_RUN_SQL",description:"Run a SQL query against the database",annotations:{title:"Run SQL Query",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:CE4,outputSchema:q.object({result:q.array(EE4)}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=TE4(Y.sql,Y.params||[]);if(!Q.connectionId)throw Error("Connection context required for database access");let J=RE4(Q.connectionId),G=IE4(Q.connectionId);return{result:[{results:(await _E4(Q.db,J,G,X)).rows,success:!0}]}}})});var af0,kE4,rf0;var d3=S(()=>{y1();tm();af0=q.object({connectionId:q.string().optional().describe("Filter subscriptions by connection ID (optional)")}),kE4=q.object({id:q.string().describe("Subscription ID"),connectionId:q.string().describe("Subscriber connection ID"),eventType:q.string().describe("Event type pattern"),publisher:q.string().nullable().describe("Publisher connection filter (null = all publishers)"),filter:q.string().nullable().describe("JSONPath filter expression"),enabled:q.boolean().describe("Whether subscription is enabled"),createdAt:q.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:q.string().datetime().describe("Updated timestamp (ISO 8601)")}),rf0=q.object({subscriptions:q.array(kE4).describe("List of subscriptions")})});var _$1;var of0=S(()=>{k0();d3();_$1=v1({name:"EVENT_PUBLISH",description:"Publish an event to the event bus. Supports immediate, scheduled (deliverAt), and recurring (cron) delivery. The source is automatically set to the caller's connection ID.",annotations:{title:"Publish Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:TC,outputSchema:CC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to publish events. Use a connection-scoped token.");let G=await Q.eventBus.publish(X.id,J,{type:Y.type,subject:Y.subject,data:Y.data,deliverAt:Y.deliverAt,cron:Y.cron});return{id:G.id,type:G.type,source:G.source,time:G.time}}})});var v$1;var sf0=S(()=>{k0();d3();v$1=v1({name:"EVENT_SUBSCRIBE",description:"Subscribe to events of a specific type. The subscriber is automatically set to the caller's connection.",annotations:{title:"Subscribe to Events",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:RC,outputSchema:IC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to subscribe. Use a connection-scoped token.");let G=await Q.eventBus.subscribe(X.id,{connectionId:J,eventType:Y.eventType,publisher:Y.publisher,filter:Y.filter});return{subscription:{id:G.id,connectionId:G.connectionId,eventType:G.eventType,publisher:G.publisher,filter:G.filter,enabled:G.enabled,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}}})});var k$1;var tf0=S(()=>{k0();d3();k$1=v1({name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events by removing a subscription.",annotations:{title:"Unsubscribe from Events",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:_C,outputSchema:vC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to unsubscribe. Use a connection-scoped token.");let G=await Q.eventBus.getSubscription(X.id,Y.subscriptionId);if(!G)throw Error(`Subscription not found: ${Y.subscriptionId}`);if(G.connectionId!==J)throw Error("Cannot unsubscribe from a subscription owned by another connection");return{success:(await Q.eventBus.unsubscribe(X.id,Y.subscriptionId)).success,subscriptionId:Y.subscriptionId}}})});var y$1;var ef0=S(()=>{k0();d3();y$1=v1({name:"EVENT_CANCEL",description:"Cancel a recurring event to stop future deliveries. Only the publisher can cancel their own events.",annotations:{title:"Cancel Recurring Event",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:kC,outputSchema:yC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to cancel events. Use a connection-scoped token.");if(!await Q.eventBus.getEvent(X.id,Y.eventId))throw Error(`Event not found: ${Y.eventId}`);if(!(await Q.eventBus.cancelEvent(X.id,Y.eventId,J)).success)throw Error("Failed to cancel event. Either the event is already completed/failed, or you are not the publisher.");return{success:!0,eventId:Y.eventId}}})});var f$1;var Yb0=S(()=>{k0();d3();f$1=v1({name:"EVENT_ACK",description:"Acknowledge delivery of an event. Call after successfully processing an event received via ON_EVENTS with retryAfter.",annotations:{title:"Acknowledge Event",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:fC,outputSchema:bC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to acknowledge events. Use a connection-scoped token.");if(!(await Q.eventBus.ackEvent(X.id,Y.eventId,J)).success)throw Error("Failed to acknowledge event. Either the event was not found, already delivered, or you are not a subscriber.");return{success:!0,eventId:Y.eventId}}})});var b$1;var Qb0=S(()=>{k0();d3();b$1=v1({name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions, optionally filtered by connection ID.",annotations:{title:"List Event Subscriptions",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:af0,outputSchema:rf0,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);return await Q.access.check(),{subscriptions:(await Q.eventBus.listSubscriptions(X.id,Y.connectionId)).map((G)=>({id:G.id,connectionId:G.connectionId,eventType:G.eventType,publisher:G.publisher,filter:G.filter,enabled:G.enabled,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}))}}})});var h$1;var Xb0=S(()=>{k0();d3();h$1=v1({name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state. Creates new, deletes removed, updates changed filters. Subscriptions are identified by (eventType, publisher).",annotations:{title:"Sync Event Subscriptions",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:jC,outputSchema:SC,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=Q.connectionId;if(!J)throw Error("Connection ID required to sync subscriptions. Use a connection-scoped token.");let G=await Q.eventBus.syncSubscriptions(X.id,{connectionId:J,subscriptions:Y.subscriptions});return{created:G.created,updated:G.updated,deleted:G.deleted,unchanged:G.unchanged,subscriptions:G.subscriptions.map((K)=>({id:K.id,connectionId:K.connectionId,eventType:K.eventType,publisher:K.publisher,filter:K.filter,enabled:K.enabled,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt,updatedAt:K.updatedAt instanceof Date?K.updatedAt.toISOString():K.updatedAt}))}}})});var Jb0=S(()=>{of0();sf0();tf0();ef0();Yb0();Qb0();Xb0();d3()});var dN=S(()=>{wk()});function Gb0(){return`/icons/capy-${Math.floor(Math.random()*39)+0}.png`}var fE4,bE4,x$1;var Wb0=S(()=>{y1();k0();dN();fE4=q.object({data:RA.describe("Data for the new virtual MCP")}),bE4=q.object({item:tX.describe("The created virtual MCP entity")}),x$1=v1({name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create a new Virtual MCP",annotations:{title:"Create Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:fE4,outputSchema:bE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to create virtual MCP");let G={...Y.data,icon:Y.data.icon??Gb0()};return{item:await Q.storage.virtualMcps.create(X.id,J,G)}}})});function hE4(Y){let Q=[],X=0;while(X<Y.length){let J=Y[X];if(J==="%")Q.push(".*");else if(J==="_")Q.push(".");else if(/[.*+?^${}()|[\]\\]/.test(J))Q.push("\\"+J);else Q.push(J);X++}return Q.join("")}function P$(Y){return typeof Y==="string"||typeof Y==="number"}function g$1(Y,Q){let X=Q.split("."),J=Y;for(let G of X){if(J==null||typeof J!=="object")return;J=J[G]}return J}function xE4(Y,Q){return Y.connections.some((X)=>X.connection_id===Q)}function Op(Y,Q){if("conditions"in Q){let{operator:Z,conditions:H}=Q;switch(Z){case"and":return H.every((F)=>Op(Y,F));case"or":return H.some((F)=>Op(Y,F));case"not":return!H.every((F)=>Op(Y,F));default:return!0}}let{field:X,operator:J,value:G}=Q,K=X.join(".");if(K==="connection_id"){if(J!=="eq"||typeof G!=="string")return!1;return xE4(Y,G)}let W=g$1(Y,K);switch(J){case"eq":return W===G;case"gt":return P$(W)&&P$(G)&&W>G;case"gte":return P$(W)&&P$(G)&&W>=G;case"lt":return P$(W)&&P$(G)&&W<G;case"lte":return P$(W)&&P$(G)&&W<=G;case"in":return Array.isArray(G)&&G.includes(W);case"like":if(typeof W!=="string"||typeof G!=="string")return!1;if(G.length>100)return!1;let Z=hE4(G);return new RegExp(`^${Z}$`,"i").test(W);case"contains":if(typeof W!=="string"||typeof G!=="string")return!1;return W.toLowerCase().includes(G.toLowerCase());default:return!0}}function gE4(Y,Q){return[...Y].sort((X,J)=>{for(let G of Q){let K=G.field.join("."),W=g$1(X,K),Z=g$1(J,K),H=0;if(W==null&&Z==null)continue;if(W==null)H=G.nulls==="first"?-1:1;else if(Z==null)H=G.nulls==="first"?1:-1;else if(typeof W==="string"&&typeof Z==="string")H=W.localeCompare(Z);else if(typeof W==="number"&&typeof Z==="number")H=W-Z;else H=String(W).localeCompare(String(Z));if(H!==0)return G.direction==="desc"?-H:H}return 0})}var uE4,mE4,u$1;var Zb0=S(()=>{gX();k0();dN();uE4=dG,mE4=M3(tX),u$1=v1({name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List all MCP virtual MCPs in the organization",annotations:{title:"List Virtual MCPs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:uE4,outputSchema:mE4,handler:async(Y,Q)=>{await Q.access.check();let X=B0(Q),J=Y.where&&!("conditions"in Y.where)&&Y.where.field.join(".")==="connection_id"&&Y.where.operator==="eq"&&typeof Y.where.value==="string"?Y.where.value:void 0,K=J?await Q.storage.virtualMcps.listByConnectionId(X.id,J):await Q.storage.virtualMcps.list(X.id);if(Y.where)K=K.filter((V)=>Op(V,Y.where));if(Y.orderBy&&Y.orderBy.length>0)K=gE4(K,Y.orderBy);let W=K.length,Z=Y.offset??0,H=Y.limit??100,F=K.slice(Z,Z+H),$=Z+H<W;return{items:F,totalCount:W,hasMore:$}}})});var lE4,dE4,m$1;var Kb0=S(()=>{y1();k0();dN();lE4=q.object({id:q.string().describe("ID of the virtual MCP to retrieve")}),dE4=q.object({item:tX.nullable().describe("The retrieved virtual MCP, or null if not found")}),m$1=v1({name:"COLLECTION_VIRTUAL_MCP_GET",description:"Get an MCP virtual MCP by ID",annotations:{title:"Get Virtual MCP",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:lE4,outputSchema:dE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.id);if(J&&J.organization_id!==X.id)return{item:null};if(!J)return{item:null};return{item:J}}})});var pE4,cE4,l$1;var Hb0=S(()=>{y1();k0();dN();pE4=q.object({id:q.string().describe("ID of the virtual MCP to update"),data:IA.describe("Partial virtual MCP data to update")}),cE4=q.object({item:tX.describe("The updated virtual MCP entity")}),l$1=v1({name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update an MCP virtual MCP",annotations:{title:"Update Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:pE4,outputSchema:cE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to update virtual MCP");let G=await Q.storage.virtualMcps.findById(Y.id);if(!G)throw Error(`Virtual MCP not found: ${Y.id}`);if(G.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.id}`);return{item:await Q.storage.virtualMcps.update(Y.id,J,Y.data)}}})});var nE4,iE4,d$1;var Fb0=S(()=>{y1();k0();dN();nE4=q.object({id:q.string().describe("ID of the virtual MCP to delete")}),iE4=q.object({item:tX.describe("The deleted virtual MCP entity")}),d$1=v1({name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete an MCP virtual MCP",annotations:{title:"Delete Virtual MCP",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:nE4,outputSchema:iE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.id);if(!J)throw Error(`Virtual MCP not found: ${Y.id}`);if(J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.id}`);return await Q.storage.virtualMcps.delete(Y.id),{item:J}}})});var $b0=S(()=>{Wb0();Zb0();Kb0();Hb0();Fb0()});var rE4,oE4,p$1;var Vb0=S(()=>{y1();k0();A$();rE4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP to add the tool to"),data:Af0.describe("Virtual tool data")}),oE4=q.object({item:pZ.describe("The created virtual tool")}),p$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_CREATE",description:"Create a new virtual tool on a Virtual MCP. The tool code should be a JavaScript ES module that exports a default async function: export default async (tools, args) => { ... }. Specify connection_dependencies to indicate which connections this tool uses.",annotations:{title:"Create Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:rE4,outputSchema:oE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=Y.data.connection_dependencies??[];return{item:await Q.storage.virtualMcps.createVirtualTool(Y.virtual_mcp_id,Y.data,G)}}})});var sE4,tE4,c$1;var qb0=S(()=>{y1();k0();A$();sE4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP to list tools for"),limit:q.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:q.number().int().min(0).optional().describe("Number of items to skip")}),tE4=q.object({items:q.array(pZ).describe("Array of virtual tools"),totalCount:q.number().int().min(0).optional().describe("Total number of virtual tools"),hasMore:q.boolean().optional().describe("Whether there are more items available")}),c$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List all virtual tools for a Virtual MCP",annotations:{title:"List Virtual Tools",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:sE4,outputSchema:tE4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)return{items:[],totalCount:0,hasMore:!1};let G=await Q.storage.virtualMcps.listVirtualTools(Y.virtual_mcp_id),K=G.length,W=Y.offset??0,Z=Y.limit??100,H=G.slice(W,W+Z),F=W+Z<K;return{items:H,totalCount:K,hasMore:F}}})});var eE4,YT4,n$1;var Bb0=S(()=>{y1();k0();A$();eE4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP"),name:q.string().describe("Name of the virtual tool to retrieve")}),YT4=q.object({item:pZ.nullable().describe("The retrieved virtual tool, or null if not found")}),n$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"Get a virtual tool by name from a Virtual MCP",annotations:{title:"Get Virtual Tool",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:eE4,outputSchema:YT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)return{item:null};return{item:await Q.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name)}}})});var QT4,XT4,i$1;var Ub0=S(()=>{y1();k0();A$();QT4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP"),name:q.string().describe("Current name of the virtual tool to update"),data:Pf0.describe("Partial virtual tool data to update")}),XT4=q.object({item:pZ.describe("The updated virtual tool")}),i$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_UPDATE",description:"Update an existing virtual tool on a Virtual MCP. Specify connection_dependencies to update which connections this tool uses.",annotations:{title:"Update Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:QT4,outputSchema:XT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);if(!await Q.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name))throw Error(`Virtual tool not found: ${Y.name}`);let K=Y.data.connection_dependencies;return{item:await Q.storage.virtualMcps.updateVirtualTool(Y.virtual_mcp_id,Y.name,Y.data,K)}}})});var JT4,GT4,a$1;var zb0=S(()=>{y1();k0();A$();JT4=q.object({virtual_mcp_id:q.string().describe("ID of the Virtual MCP"),name:q.string().describe("Name of the virtual tool to delete")}),GT4=q.object({item:pZ.describe("The deleted virtual tool")}),a$1=v1({name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete a virtual tool from a Virtual MCP",annotations:{title:"Delete Virtual Tool",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:JT4,outputSchema:GT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==X.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=await Q.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name);if(!G)throw Error(`Virtual tool not found: ${Y.name}`);return await Q.storage.virtualMcps.deleteVirtualTool(Y.virtual_mcp_id,Y.name),{item:G}}})});var Db0=S(()=>{Vb0();qb0();Bb0();Ub0();zb0()});var ZT4,r$1;var Ob0=S(()=>{k0();y1();ZT4=q.object({id:q.string().optional().describe("Unique log identifier"),organizationId:q.string().describe("Organization ID"),connectionId:q.string().describe("Connection ID"),connectionTitle:q.string().describe("Connection display name"),toolName:q.string().describe("Name of the tool that was called"),input:q.record(q.string(),q.unknown()).describe("Redacted tool input"),output:q.record(q.string(),q.unknown()).describe("Redacted tool output"),isError:q.boolean().describe("Whether the call resulted in an error"),errorMessage:q.string().nullish().describe("Error message if applicable"),durationMs:q.number().describe("Call duration in milliseconds"),timestamp:q.string().describe("ISO 8601 timestamp of the call"),userId:q.string().nullish().describe("User who triggered the call"),requestId:q.string().describe("Unique request identifier"),userAgent:q.string().nullish().describe("Client identifier (x-mesh-client header)"),virtualMcpId:q.string().nullish().describe("Virtual MCP (Agent) ID if routed through an agent"),properties:q.record(q.string(),q.string()).nullish().describe("Custom key-value metadata attached to the log")}),r$1=v1({name:"MONITORING_LOGS_LIST",description:"List monitoring logs for tool calls in the organization",annotations:{title:"List Monitoring Logs",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({connectionId:q.string().optional().describe("Filter by connection ID"),excludeConnectionIds:q.array(q.string()).optional().describe("Exclude logs from these connection IDs (e.g. system connections)"),virtualMcpId:q.string().optional().describe("Filter by Virtual MCP (Agent) ID"),toolName:q.string().optional().describe("Filter by tool name"),isError:q.boolean().optional().describe("Filter by error status"),startDate:q.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:q.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)"),limit:q.number().default(20).describe("Maximum number of results"),offset:q.number().default(0).describe("Offset for pagination"),properties:q.record(q.string(),q.string()).optional().describe("Filter by exact property key=value matches"),propertyKeys:q.array(q.string()).optional().describe("Filter by logs that have these property keys"),propertyPatterns:q.record(q.string(),q.string()).optional().describe("Filter by property value patterns (SQL LIKE, use % as wildcard)"),propertyInValues:q.record(q.string(),q.string()).optional().describe("Filter by exact match within comma-separated values (e.g., user_tags in 'Engineering')")}),outputSchema:q.object({logs:q.array(ZT4).describe("Array of monitoring logs"),total:q.number().describe("Total number of logs matching filters"),offset:q.number().describe("Current offset for pagination"),limit:q.number().describe("Current limit for pagination")}),handler:async(Y,Q)=>{let X=B0(Q),G=Y.properties||Y.propertyKeys||Y.propertyPatterns||Y.propertyInValues?{properties:Y.properties,propertyKeys:Y.propertyKeys,propertyPatterns:Y.propertyPatterns,propertyInValues:Y.propertyInValues}:void 0,K={organizationId:X.id,connectionId:Y.connectionId,excludeConnectionIds:Y.excludeConnectionIds,virtualMcpId:Y.virtualMcpId,toolName:Y.toolName,isError:Y.isError,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0,limit:Y.limit,offset:Y.offset,propertyFilters:G},W=await Q.storage.monitoring.query(K);return{logs:W.logs.map((Z)=>({...Z,timestamp:Z.timestamp instanceof Date?Z.timestamp.toISOString():Z.timestamp})),total:W.total,offset:Y.offset,limit:Y.limit}}})});var o$1;var Lb0=S(()=>{k0();y1();o$1=v1({name:"MONITORING_STATS",description:"Get aggregated statistics for tool call monitoring",annotations:{title:"Get Monitoring Stats",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({startDate:q.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:q.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)")}),outputSchema:q.object({totalCalls:q.number().describe("Total number of tool calls"),errorRate:q.number().describe("Error rate as a decimal (0 to 1)"),avgDurationMs:q.number().describe("Average call duration in milliseconds"),errorRatePercent:q.string().describe("Error rate as a percentage string")}),handler:async(Y,Q)=>{let J={organizationId:B0(Q).id,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0},G=await Q.storage.monitoring.getStats(J);return{...G,errorRatePercent:(G.errorRate*100).toFixed(2)}}})});var Nb0=S(()=>{Ob0();Lb0()});var HT4,FT4,$T4,VT4,qT4,GI,WI,E$,BT4,UT4,Mb0;var pN=S(()=>{y1();HT4=q.enum(["sum","avg","min","max","count","last"]).describe("Aggregation function to apply"),FT4=q.enum(["metric","timeseries","table"]).describe("Widget display type"),$T4=q.object({path:q.string().describe("JSONPath to extract value, e.g., '$.usage.total_tokens'"),from:q.enum(["input","output"]).describe("Extract from tool call input or output")}),VT4=q.object({fn:HT4,groupBy:q.string().optional().describe("Optional JSONPath for grouping results"),interval:q.string().optional().describe("For timeseries widgets: interval like '1h', '1d', '15m'")}),qT4=q.object({connectionIds:q.array(q.string()).optional().describe("Filter to specific connections"),toolNames:q.array(q.string()).optional().describe("Filter to specific tools")}),GI=q.object({id:q.string().describe("Unique widget identifier"),name:q.string().describe("Widget display name"),type:FT4,source:$T4,aggregation:VT4,filter:qT4.optional()}),WI=q.object({connectionIds:q.array(q.string()).optional().describe("Filter to specific connections"),virtualMcpIds:q.array(q.string()).optional().describe("Filter to specific virtual MCPs/agents"),toolNames:q.array(q.string()).optional().describe("Filter to specific tools"),propertyFilters:q.record(q.string(),q.string()).optional().describe("Filter by exact metadata property key=value matches (e.g., { environment: 'production' })")}),E$=q.object({id:q.string().describe("Unique dashboard identifier"),organizationId:q.string().describe("Organization ID"),name:q.string().describe("Dashboard name"),description:q.string().nullable().describe("Dashboard description"),filters:WI.nullable().describe("Global filters applied to all widgets"),widgets:q.array(GI).describe("Widget definitions"),createdBy:q.string().describe("User ID who created the dashboard"),createdAt:q.string().describe("Creation timestamp"),updatedAt:q.string().describe("Last update timestamp")}),BT4=q.object({key:q.string().describe("Group key value"),value:q.number().describe("Aggregated value for this group")}),UT4=q.object({timestamp:q.string().describe("Time bucket timestamp"),value:q.number().describe("Aggregated value for this time bucket")}),Mb0=q.object({widgetId:q.string().describe("Widget ID this result is for"),value:q.number().nullable().describe("Aggregated value (for metric type)"),groups:q.array(BT4).optional().describe("Grouped results (when groupBy is specified)"),timeseries:q.array(UT4).optional().describe("Timeseries data (for timeseries type)")})});var s$1;var wb0=S(()=>{k0();y1();pN();s$1=v1({name:"MONITORING_DASHBOARD_CREATE",description:"Create a new monitoring dashboard with JSONPath widgets",annotations:{title:"Create Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({name:q.string().min(1).describe("Dashboard name"),description:q.string().optional().describe("Dashboard description"),filters:WI.optional().describe("Global filters applied to all widgets"),widgets:q.array(GI).min(1).describe("Widget definitions (at least one required)")}),outputSchema:E$,handler:async(Y,Q)=>{let X=B0(Q),J=Q.auth.user?.id;if(!J)throw Error("User authentication required");let G=await Q.storage.monitoringDashboards.create(X.id,J,{name:Y.name,description:Y.description,filters:Y.filters,widgets:Y.widgets});return{id:G.id,organizationId:G.organizationId,name:G.name,description:G.description,filters:G.filters,widgets:G.widgets,createdBy:G.createdBy,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}})});var t$1;var Ab0=S(()=>{k0();y1();pN();t$1=v1({name:"MONITORING_DASHBOARD_GET",description:"Get a monitoring dashboard by ID",annotations:{title:"Get Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string().describe("Dashboard ID")}),outputSchema:E$.nullable(),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.id);if(!J||J.organizationId!==X.id)return null;return{id:J.id,organizationId:J.organizationId,name:J.name,description:J.description,filters:J.filters,widgets:J.widgets,createdBy:J.createdBy,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var e$1;var Pb0=S(()=>{k0();y1();pN();e$1=v1({name:"MONITORING_DASHBOARD_LIST",description:"List all monitoring dashboards for the organization",annotations:{title:"List Monitoring Dashboards",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({dashboards:q.array(E$).describe("List of dashboards"),total:q.number().describe("Total number of dashboards")}),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.list(X.id);return{dashboards:J.map((G)=>({id:G.id,organizationId:G.organizationId,name:G.name,description:G.description,filters:G.filters,widgets:G.widgets,createdBy:G.createdBy,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt})),total:J.length}}})});var YV1;var Eb0=S(()=>{k0();y1();pN();YV1=v1({name:"MONITORING_DASHBOARD_UPDATE",description:"Update an existing monitoring dashboard",annotations:{title:"Update Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string().describe("Dashboard ID to update"),name:q.string().optional().describe("New dashboard name"),description:q.string().nullable().optional().describe("New dashboard description"),filters:WI.nullable().optional().describe("New global filters"),widgets:q.array(GI).optional().describe("New widget definitions")}),outputSchema:E$,handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.id);if(!J||J.organizationId!==X.id)throw Error(`Dashboard ${Y.id} not found`);let G={};if(Y.name!==void 0)G.name=Y.name;if(Y.description!==void 0)G.description=Y.description;if(Y.filters!==void 0)G.filters=Y.filters;if(Y.widgets!==void 0)G.widgets=Y.widgets;let K=await Q.storage.monitoringDashboards.update(Y.id,G);return{id:K.id,organizationId:K.organizationId,name:K.name,description:K.description,filters:K.filters,widgets:K.widgets,createdBy:K.createdBy,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt,updatedAt:K.updatedAt instanceof Date?K.updatedAt.toISOString():K.updatedAt}}})});var QV1;var Tb0=S(()=>{k0();y1();QV1=v1({name:"MONITORING_DASHBOARD_DELETE",description:"Delete a monitoring dashboard",annotations:{title:"Delete Monitoring Dashboard",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string().describe("Dashboard ID to delete")}),outputSchema:q.object({success:q.boolean().describe("Whether the deletion was successful")}),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.id);if(!J||J.organizationId!==X.id)throw Error(`Dashboard ${Y.id} not found`);return await Q.storage.monitoringDashboards.delete(Y.id),{success:!0}}})});var XV1;var Cb0=S(()=>{k0();y1();pN();XV1=v1({name:"MONITORING_DASHBOARD_QUERY",description:"Execute a dashboard's widgets and return aggregated monitoring data",annotations:{title:"Query Monitoring Dashboard",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({dashboardId:q.string().describe("Dashboard ID to query"),timeRange:q.object({startDate:q.string().datetime().describe("Start of time range (ISO 8601)"),endDate:q.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:q.object({properties:q.record(q.string(),q.string()).optional().describe("Exact match: property key equals value"),propertyKeys:q.array(q.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:q.record(q.string(),q.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE, use % as wildcard)"),propertyInValues:q.record(q.string(),q.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Runtime property filters applied to all widgets (merged with dashboard-level filters)")}),outputSchema:q.object({dashboardId:q.string().describe("Dashboard ID"),results:q.array(Mb0).describe("Widget query results"),timeRange:q.object({startDate:q.string(),endDate:q.string()}).describe("Time range used for the query")}),handler:async(Y,Q)=>{let X=B0(Q),J=await Q.storage.monitoringDashboards.get(Y.dashboardId);if(!J||J.organizationId!==X.id)throw Error(`Dashboard ${Y.dashboardId} not found`);let G=new Date,K=Y.timeRange?.startDate?new Date(Y.timeRange.startDate):new Date(G.getTime()-86400000),W=Y.timeRange?.endDate?new Date(Y.timeRange.endDate):G,Z=await Promise.all(J.widgets.map(async(H)=>{let F=J.filters?.propertyFilters,$=Y.propertyFilters,V=F||$?{properties:{...F,...$?.properties},propertyKeys:$?.propertyKeys,propertyPatterns:$?.propertyPatterns,propertyInValues:$?.propertyInValues}:void 0,B={connectionIds:H.filter?.connectionIds??J.filters?.connectionIds??void 0,virtualMcpIds:J.filters?.virtualMcpIds??void 0,toolNames:H.filter?.toolNames??J.filters?.toolNames??void 0,startDate:K,endDate:W,propertyFilters:V};try{let U=await Q.storage.monitoring.aggregate({organizationId:X.id,path:H.source.path,from:H.source.from,aggregation:H.aggregation.fn,groupBy:H.aggregation.groupBy,interval:H.aggregation.interval,filters:B});return{widgetId:H.id,value:U.value,groups:U.groups,timeseries:U.timeseries}}catch(U){return console.error(`Widget ${H.id} aggregation failed:`,U),{widgetId:H.id,value:null,groups:void 0,timeseries:void 0}}}));return{dashboardId:Y.dashboardId,results:Z,timeRange:{startDate:K.toISOString(),endDate:W.toISOString()}}}})});var zT4,JV1;var Rb0=S(()=>{k0();y1();zT4=q.object({type:q.enum(["metric","timeseries","table"]),source:q.object({path:q.string().describe("JSONPath to extract value from"),from:q.enum(["input","output"]).describe("Extract from input or output")}),aggregation:q.object({fn:q.enum(["sum","avg","min","max","count","last"]).describe("Aggregation function"),groupBy:q.string().optional().describe("JSONPath for grouping (table)"),interval:q.string().optional().describe("Time interval for timeseries (15m, 1h, 1d)")}),filter:q.object({connectionIds:q.array(q.string()).optional(),toolNames:q.array(q.string()).optional()}).optional()}),JV1=v1({name:"MONITORING_WIDGET_PREVIEW",description:"Preview a widget aggregation without saving. Used to test queries in the dashboard editor.",annotations:{title:"Preview Monitoring Widget",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({widget:zT4.describe("Widget configuration to preview"),timeRange:q.object({startDate:q.string().datetime().describe("Start of time range (ISO 8601)"),endDate:q.string().datetime().describe("End of time range (ISO 8601)")}).optional().describe("Time range for the query (defaults to last 24 hours)"),propertyFilters:q.object({properties:q.record(q.string(),q.string()).optional().describe("Exact match: property key equals value"),propertyKeys:q.array(q.string()).optional().describe("Exists: filter logs that have these property keys"),propertyPatterns:q.record(q.string(),q.string()).optional().describe("Pattern match: property value matches pattern (SQL LIKE)"),propertyInValues:q.record(q.string(),q.string()).optional().describe("In match: exact match within comma-separated values")}).optional().describe("Property filters to apply")}),outputSchema:q.object({value:q.number().nullable().optional().describe("Aggregated value"),groups:q.array(q.object({key:q.string(),value:q.number()})).optional().describe("Grouped results for table widgets"),timeseries:q.array(q.object({timestamp:q.string(),value:q.number()})).optional().describe("Timeseries data points"),matchedRecords:q.number().describe("Number of records that matched"),timeRange:q.object({startDate:q.string(),endDate:q.string()}).describe("Time range used for the query")}),handler:async(Y,Q)=>{let X=B0(Q),{widget:J,timeRange:G}=Y,K=new Date,W=G?.startDate?new Date(G.startDate):new Date(K.getTime()-86400000),Z=G?.endDate?new Date(G.endDate):K,H={connectionIds:J.filter?.connectionIds,toolNames:J.filter?.toolNames,startDate:W,endDate:Z,propertyFilters:Y.propertyFilters};try{let F=await Q.storage.monitoring.countMatched({organizationId:X.id,path:J.source.path,from:J.source.from,filters:H}),$=await Q.storage.monitoring.aggregate({organizationId:X.id,path:J.source.path,from:J.source.from,aggregation:J.aggregation.fn,groupBy:J.aggregation.groupBy,interval:J.aggregation.interval,filters:H});return{value:$.value,groups:$.groups,timeseries:$.timeseries,matchedRecords:F,timeRange:{startDate:W.toISOString(),endDate:Z.toISOString()}}}catch(F){return console.error("Widget preview aggregation failed:",F),{value:null,matchedRecords:0,timeRange:{startDate:W.toISOString(),endDate:Z.toISOString()}}}}})});var Ib0=S(()=>{wb0();Ab0();Pb0();Eb0();Tb0();Cb0();Rb0()});var GV1;var jb0=S(()=>{y1();k0();GV1=v1({name:"ORGANIZATION_CREATE",description:"Create a new organization",annotations:{title:"Create Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({slug:q.string().min(1).max(50).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens"),name:q.string().min(1).max(255),description:q.string().optional()}),outputSchema:q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),members:q.array(q.any()).optional()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=D9(Q);if(!X)throw Error("User ID required to create organization");let J=await Q.boundAuth.organization.create({name:Y.name,slug:Y.slug,metadata:Y.description?{description:Y.description}:void 0,userId:X});if(!J)throw Error("Failed to create organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var WV1;var Sb0=S(()=>{y1();k0();WV1=v1({name:"ORGANIZATION_LIST",description:"List all organizations user has access to",annotations:{title:"List Organizations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({userId:q.string().optional()}),outputSchema:q.object({organizations:q.array(q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=D9(Q),J=Y.userId||X;if(!J)throw Error("User ID required to list organizations");return{organizations:(await Q.boundAuth.organization.list(J)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt}))}}})});var ZV1;var _b0=S(()=>{y1();k0();ZV1=v1({name:"ORGANIZATION_GET",description:"Get organization details by slug or ID",annotations:{title:"Get Organization",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),members:q.array(q.any()).optional(),invitations:q.array(q.any()).optional()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=await Q.boundAuth.organization.get();if(!X)throw Error("No active organization found");let J=new Date,G=X.invitations?.filter((K)=>new Date(K.expiresAt)>J);return{...X,invitations:G,createdAt:X.createdAt instanceof Date?X.createdAt.toISOString():X.createdAt}}})});var KV1;var vb0=S(()=>{y1();k0();KV1=v1({name:"ORGANIZATION_UPDATE",description:"Update an existing organization",annotations:{title:"Update Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string(),slug:q.string().min(1).max(50).regex(/^[a-z0-9-]+$/).optional(),name:q.string().min(1).max(255).optional(),description:q.string().optional()}),outputSchema:q.object({id:q.string(),name:q.string(),slug:q.string(),logo:q.string().nullable().optional(),metadata:q.any().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X={};if(Y.name)X.name=Y.name;if(Y.slug)X.slug=Y.slug;if(Y.description)X.metadata={description:Y.description};let J=await Q.boundAuth.organization.update({organizationId:Y.id,data:X});if(!J)throw Error("Failed to update organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var HV1;var kb0=S(()=>{y1();k0();HV1=v1({name:"ORGANIZATION_DELETE",description:"Delete an organization",annotations:{title:"Delete Organization",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({id:q.string()}),outputSchema:q.object({success:q.boolean(),id:q.string()}),handler:async(Y,Q)=>{return o1(Q),await Q.access.check(),await Q.boundAuth.organization.delete(Y.id),{success:!0,id:Y.id}}})});var ZI;var FV1=S(()=>{y1();ZI=q.object({title:q.string(),url:q.string(),icon:q.string()})});var $V1;var yb0=S(()=>{y1();k0();FV1();$V1=v1({name:"ORGANIZATION_SETTINGS_GET",description:"Get organization-level settings",annotations:{title:"Get Organization Settings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({organizationId:q.string(),sidebar_items:q.array(ZI).nullable().optional(),enabled_plugins:q.array(q.string()).nullable().optional(),createdAt:q.string().datetime().optional().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().optional().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let J=await Q.storage.organizationSettings.get(X);if(!J)return{organizationId:X};return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var VV1;var fb0=S(()=>{y1();k0();FV1();VV1=v1({name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization-level settings",annotations:{title:"Update Organization Settings",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string(),sidebar_items:q.array(ZI).optional(),enabled_plugins:q.array(q.string()).optional()}),outputSchema:q.object({organizationId:q.string(),sidebar_items:q.array(ZI).nullable().optional(),enabled_plugins:q.array(q.string()).nullable().optional(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{if(o1(Q),await Q.access.check(),Q.organization&&Q.organization.id!==Y.organizationId)throw Error("Cannot update settings for a different organization");let X=await Q.storage.organizationSettings.upsert(Y.organizationId,{sidebar_items:Y.sidebar_items,enabled_plugins:Y.enabled_plugins});return{...X,createdAt:X.createdAt instanceof Date?X.createdAt.toISOString():X.createdAt,updatedAt:X.updatedAt instanceof Date?X.updatedAt.toISOString():X.updatedAt}}})});var qV1;var bb0=S(()=>{y1();k0();qV1=v1({name:"ORGANIZATION_MEMBER_ADD",description:"Add a member to an organization",annotations:{title:"Add Organization Member",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().optional(),userId:q.string(),role:q.array(q.string())}),outputSchema:q.object({id:q.string(),organizationId:q.string(),userId:q.string(),role:q.union([q.string(),q.array(q.string())]),createdAt:q.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Y.organizationId||Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");if(X!==Q.organization?.id)throw Error("Organization ID does not match authenticated organization");let J=await Q.boundAuth.organization.addMember({organizationId:X,userId:Y.userId,role:Y.role});if(!J)throw Error("Failed to add member");return{...J,role:J.role,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var BV1;var hb0=S(()=>{y1();k0();BV1=v1({name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove a member from an organization",annotations:{title:"Remove Organization Member",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().optional(),memberIdOrEmail:q.string()}),outputSchema:q.object({success:q.boolean(),memberIdOrEmail:q.string()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Y.organizationId||Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");return await Q.boundAuth.organization.removeMember({organizationId:X,memberIdOrEmail:Y.memberIdOrEmail}),{success:!0,memberIdOrEmail:Y.memberIdOrEmail}}})});var UV1;var xb0=S(()=>{y1();k0();UV1=v1({name:"ORGANIZATION_MEMBER_LIST",description:"List all members in an organization",annotations:{title:"List Organization Members",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({limit:q.number().optional(),offset:q.number().optional()}),outputSchema:q.object({members:q.array(q.object({id:q.string(),organizationId:q.string(),userId:q.string(),role:q.string(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),user:q.object({id:q.string(),name:q.string(),email:q.string(),image:q.string().optional()}).optional()}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let J=await Q.boundAuth.organization.listMembers({organizationId:X,limit:Y.limit,offset:Y.offset});return{members:(Array.isArray(J)?J:[]).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt}))}}})});var zV1;var gb0=S(()=>{y1();k0();zV1=v1({name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update a member's role in an organization",annotations:{title:"Update Member Role",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().optional(),memberId:q.string(),role:q.array(q.string())}),outputSchema:q.object({id:q.string(),organizationId:q.string(),userId:q.string(),role:q.union([q.literal("admin"),q.literal("member"),q.literal("owner")]),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),user:q.object({email:q.string(),name:q.string(),image:q.string().optional()})}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=Y.organizationId||Q.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let J=await Q.boundAuth.organization.updateMemberRole({organizationId:X,memberId:Y.memberId,role:Y.role});if(!J)throw Error("Failed to update member role");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var ub0=S(()=>{jb0();Sb0();_b0();vb0();kb0();yb0();fb0();bb0();hb0();xb0();gb0()});var LT4,Lp,NT4,WU,mb0,Np;var ZU=S(()=>{y1();LT4=q.object({banner:q.string().nullable(),bannerColor:q.string().nullable(),icon:q.string().nullable(),themeColor:q.string().nullable()}),Lp=q.object({banner:q.string().nullable().optional(),bannerColor:q.string().nullable().optional(),icon:q.string().nullable().optional(),themeColor:q.string().nullable().optional()}),NT4=q.object({id:q.string(),title:q.string(),icon:q.string().nullable()}),WU=q.object({id:q.string(),organizationId:q.string(),slug:q.string(),name:q.string(),description:q.string().nullable(),enabledPlugins:q.array(q.string()).nullable(),ui:LT4.nullable(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().describe("ISO 8601 timestamp")}),mb0=WU.omit({organizationId:!0}).extend({boundConnections:q.array(NT4)}),Np=q.object({id:q.string(),projectId:q.string(),pluginId:q.string(),connectionId:q.string().nullable(),settings:q.record(q.string(),q.unknown()).nullable(),createdAt:q.string().datetime().describe("ISO 8601 timestamp"),updatedAt:q.string().datetime().describe("ISO 8601 timestamp")})});var DV1;var lb0=S(()=>{y1();k0();ZU();DV1=v1({name:"PROJECT_LIST",description:"List all projects in an organization",annotations:{title:"List Projects",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().describe("Organization ID to list projects for")}),outputSchema:q.object({projects:q.array(mb0)}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=await Q.storage.projects.list(Y.organizationId),J=X.map((K)=>K.id),G=await Q.storage.projectPluginConfigs.getBoundConnectionsForProjects(J);return{projects:X.map((K)=>({id:K.id,slug:K.slug,name:K.name,description:K.description,enabledPlugins:K.enabledPlugins,ui:K.ui,boundConnections:G.get(K.id)??[],createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt,updatedAt:K.updatedAt instanceof Date?K.updatedAt.toISOString():K.updatedAt}))}}})});var OV1;var db0=S(()=>{y1();k0();ZU();OV1=v1({name:"PROJECT_GET",description:"Get a project by ID or slug",annotations:{title:"Get Project",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().describe("Organization ID"),projectId:q.string().optional().describe("Project ID (either this or slug required)"),slug:q.string().optional().describe("Project slug (either this or projectId required)")}).refine((Y)=>Y.projectId||Y.slug,{message:"Either projectId or slug must be provided"}),outputSchema:q.object({project:WU.nullable()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=null;if(Y.projectId)X=await Q.storage.projects.get(Y.projectId);else if(Y.slug)X=await Q.storage.projects.getBySlug(Y.organizationId,Y.slug);if(!X)return{project:null};return{project:{id:X.id,organizationId:X.organizationId,slug:X.slug,name:X.name,description:X.description,enabledPlugins:X.enabledPlugins,ui:X.ui,createdAt:X.createdAt instanceof Date?X.createdAt.toISOString():X.createdAt,updatedAt:X.updatedAt instanceof Date?X.updatedAt.toISOString():X.updatedAt}}}})});var LV1;var pb0=S(()=>{y1();jY();k0();ZU();LV1=v1({name:"PROJECT_CREATE",description:"Create a new project in an organization",annotations:{title:"Create Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({organizationId:q.string().describe("Organization ID"),slug:q.string().min(1).max(100).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens").describe("URL-friendly identifier"),name:q.string().min(1).max(200).describe("Display name"),description:q.string().max(1000).nullable().optional().describe("Project description"),enabledPlugins:q.array(q.string()).nullable().optional().describe("Plugin IDs to enable"),ui:Lp.nullable().optional().describe("UI customization")}),outputSchema:q.object({project:WU}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{organizationId:X,slug:J,name:G,description:K,enabledPlugins:W,ui:Z}=Y;if(J===n7)throw Error(`Slug "${n7}" is reserved`);if(await Q.storage.projects.getBySlug(X,J))throw Error(`Project with slug "${J}" already exists in this organization`);let F=Z?{banner:Z.banner??null,bannerColor:Z.bannerColor??null,icon:Z.icon??null,themeColor:Z.themeColor??null}:null,$=await Q.storage.projects.create({organizationId:X,slug:J,name:G,description:K??null,enabledPlugins:W??null,ui:F});return{project:{id:$.id,organizationId:$.organizationId,slug:$.slug,name:$.name,description:$.description,enabledPlugins:$.enabledPlugins,ui:$.ui,createdAt:$.createdAt instanceof Date?$.createdAt.toISOString():$.createdAt,updatedAt:$.updatedAt instanceof Date?$.updatedAt.toISOString():$.updatedAt}}}})});var NV1;var cb0=S(()=>{y1();k0();ZU();NV1=v1({name:"PROJECT_UPDATE",description:"Update a project's details",annotations:{title:"Update Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID to update"),name:q.string().min(1).max(200).optional().describe("New display name"),description:q.string().max(1000).nullable().optional().describe("New description"),enabledPlugins:q.array(q.string()).nullable().optional().describe("Updated plugin IDs"),ui:Lp.nullable().optional().describe("Updated UI customization")}),outputSchema:q.object({project:WU.nullable()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X,name:J,description:G,enabledPlugins:K,ui:W}=Y,Z={};if(J!==void 0)Z.name=J;if(G!==void 0)Z.description=G;if(K!==void 0)Z.enabledPlugins=K;if(W!==void 0)Z.ui=W?{banner:W.banner??null,bannerColor:W.bannerColor??null,icon:W.icon??null,themeColor:W.themeColor??null}:null;let H=await Q.storage.projects.update(X,Z);if(!H)return{project:null};return{project:{id:H.id,organizationId:H.organizationId,slug:H.slug,name:H.name,description:H.description,enabledPlugins:H.enabledPlugins,ui:H.ui,createdAt:H.createdAt instanceof Date?H.createdAt.toISOString():H.createdAt,updatedAt:H.updatedAt instanceof Date?H.updatedAt.toISOString():H.updatedAt}}}})});var MV1;var nb0=S(()=>{y1();jY();k0();MV1=v1({name:"PROJECT_DELETE",description:"Delete a project (cannot delete org-admin)",annotations:{title:"Delete Project",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID to delete")}),outputSchema:q.object({success:q.boolean(),message:q.string().optional()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X}=Y,J=await Q.storage.projects.get(X);if(!J)return{success:!1,message:"Project not found"};if(J.slug===n7)return{success:!1,message:"Cannot delete the org-admin project"};return{success:await Q.storage.projects.delete(X)}}})});var wV1;var ib0=S(()=>{y1();k0();ZU();wV1=v1({name:"PROJECT_PLUGIN_CONFIG_GET",description:"Get plugin configuration for a project",annotations:{title:"Get Project Plugin Config",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID"),pluginId:q.string().describe("Plugin ID")}),outputSchema:q.object({config:Np.nullable()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X,pluginId:J}=Y,G=await Q.storage.projectPluginConfigs.get(X,J);if(!G)return{config:null};return{config:{id:G.id,projectId:G.projectId,pluginId:G.pluginId,connectionId:G.connectionId,settings:G.settings,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():G.createdAt,updatedAt:G.updatedAt instanceof Date?G.updatedAt.toISOString():G.updatedAt}}}})});var AV1;var ab0=S(()=>{y1();k0();ZU();Vp();AV1=v1({name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update or create plugin configuration for a project",annotations:{title:"Update Project Plugin Config",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({projectId:q.string().describe("Project ID"),pluginId:q.string().describe("Plugin ID"),connectionId:q.string().nullable().optional().describe("MCP connection to bind"),settings:q.record(q.string(),q.unknown()).nullable().optional().describe("Plugin-specific settings")}),outputSchema:q.object({config:Np}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let{projectId:X,pluginId:J,connectionId:G,settings:K}=Y,W=D9(Q),Z=await Q.storage.projects.get(X);if(!Z)throw Error(`Project not found: ${X}`);let H=G?await Q.storage.connections.findById(G):null;if(G&&Z.organizationId&&!H&&hN()){if($p(G,Z.organizationId)){if(!W)throw Error("User ID required to create dev-assets connection");let $=xN(Z.organizationId,AG());await Q.storage.connections.create({...$,organization_id:Z.organizationId,created_by:W})}}let F=await Q.storage.projectPluginConfigs.upsert(X,J,{connectionId:G,settings:K});return{config:{id:F.id,projectId:F.projectId,pluginId:F.pluginId,connectionId:F.connectionId,settings:F.settings,createdAt:F.createdAt instanceof Date?F.createdAt.toISOString():F.createdAt,updatedAt:F.updatedAt instanceof Date?F.updatedAt.toISOString():F.updatedAt}}}})});var rb0=S(()=>{lb0();db0();pb0();cb0();nb0();ib0();ab0()});var PV1;var ob0=S(()=>{y1();k0();PV1=v1({name:"TAGS_LIST",description:"List all tags in an organization",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({}),outputSchema:q.object({tags:q.array(q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q);return{tags:(await Q.storage.tags.listOrgTags(X.id)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var EV1;var sb0=S(()=>{y1();k0();EV1=v1({name:"TAGS_CREATE",description:"Create a new tag in an organization",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:q.object({name:q.string().min(1).max(50).describe("Tag name")}),outputSchema:q.object({tag:q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")})}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q),J=await Q.storage.tags.createTag(X.id,Y.name);return{tag:{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():String(J.createdAt)}}}})});var TV1;var tb0=S(()=>{y1();k0();TV1=v1({name:"TAGS_DELETE",description:"Delete a tag from an organization (removes from all members)",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({tagId:q.string().describe("Tag ID to delete")}),outputSchema:q.object({success:q.boolean()}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q),J=await Q.storage.tags.getTag(Y.tagId);if(!J)throw Error("Tag not found");if(J.organizationId!==X.id)throw Error("Tag does not belong to this organization");return await Q.storage.tags.deleteTag(Y.tagId),{success:!0}}})});var CV1;var eb0=S(()=>{y1();k0();CV1=v1({name:"MEMBER_TAGS_GET",description:"Get tags assigned to a member",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({memberId:q.string().describe("Member ID")}),outputSchema:q.object({tags:q.array(q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q);if(!await Q.storage.tags.verifyMemberOrg(Y.memberId,X.id))throw Error(`Member not found in this organization: ${Y.memberId}`);return{tags:(await Q.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var RV1;var Yh0=S(()=>{y1();k0();RV1=v1({name:"MEMBER_TAGS_SET",description:"Set tags for a member (replaces all existing tags)",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:q.object({memberId:q.string().describe("Member ID"),tagIds:q.array(q.string()).describe("Array of tag IDs to assign")}),outputSchema:q.object({success:q.boolean(),tags:q.array(q.object({id:q.string(),organizationId:q.string(),name:q.string(),createdAt:q.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,Q)=>{o1(Q),await Q.access.check();let X=B0(Q);if(!await Q.storage.tags.verifyMemberOrg(Y.memberId,X.id))throw Error(`Member not found in this organization: ${Y.memberId}`);for(let K of Y.tagIds){let W=await Q.storage.tags.getTag(K);if(!W)throw Error(`Tag not found: ${K}`);if(W.organizationId!==X.id)throw Error(`Tag does not belong to this organization: ${K}`)}return await Q.storage.tags.setMemberTags(Y.memberId,Y.tagIds),{success:!0,tags:(await Q.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var Qh0=S(()=>{ob0();sb0();tb0();eb0();Yh0()});var Xh0;var Jh0=S(()=>{Xh0=["in_progress","requires_action","failed","completed"]});var Gh0,cZ,Wh0,Zh0;var KU=S(()=>{y1();Jh0();Gh0=q.object({id:q.string().describe("Unique message ID"),thread_id:q.string().describe("ID of the parent thread"),metadata:q.unknown().optional().describe("Optional message metadata"),parts:q.array(q.record(q.string(),q.unknown())).describe("Message content parts (AI SDK UIMessagePart format)"),role:q.enum(["user","assistant","system"]).describe("Message role"),created_at:q.string().datetime().describe("Timestamp of creation"),updated_at:q.string().datetime().describe("Timestamp of last update")}),cZ=q.object({id:q.string().describe("Unique thread ID"),organization_id:q.string().describe("Organization this thread belongs to"),title:q.string().describe("Thread title"),description:q.string().nullable().describe("Thread description"),created_at:q.string().datetime().describe("Timestamp of creation"),updated_at:q.string().datetime().describe("Timestamp of last update"),hidden:q.boolean().optional().describe("Whether the thread is hidden"),status:q.enum([...Xh0,"expired"]).describe("Thread execution status. 'expired' is virtual -- computed at read time for stale in_progress threads"),created_by:q.string().describe("User ID who created the thread"),updated_by:q.string().nullable().describe("User ID who last updated the thread")}),Wh0=q.object({id:q.string().optional().describe("Optional custom ID for the thread"),title:q.string().describe("Thread title"),description:q.string().nullish().describe("Thread description")}),Zh0=q.object({title:q.string().optional().describe("New thread title"),description:q.string().nullish().describe("New thread description"),hidden:q.boolean().optional().describe("Whether the thread is hidden")})});var AT4,PT4,IV1;var Kh0=S(()=>{y1();k0();KU();BC();AT4=q.object({data:Wh0.describe("Data for the new thread (id is auto-generated if not provided)")}),PT4=q.object({item:cZ.describe("The created thread entity")}),IV1=v1({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread in the organization",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:AT4,outputSchema:PT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to create thread");let G=Y.data.id??Y$("thrd"),K=await Q.storage.threads.create({id:G,organization_id:X.id,title:Y.data.title,description:Y.data.description,created_by:J});return{item:{...K,hidden:K.hidden??!1}}}})});function T$(Y,Q=Date.now()){let X=Y.status;if(X==="in_progress"){let J=new Date(Y.updated_at).getTime();if(!Number.isFinite(J)||Q-J>1800000)X="expired"}return{...Y,status:X,hidden:Y.hidden??!1}}var ET4,TT4,jV1;var Hh0=S(()=>{gX();k0();KU();y1();ET4=dG.extend({where:q.object({created_by:q.string().optional()}).optional()}),TT4=M3(cZ),jV1=v1({name:"COLLECTION_THREADS_LIST",description:"List all threads in the organization with filtering, sorting, and pagination",annotations:{title:"List Threads",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:ET4,outputSchema:TT4,handler:async(Y,Q)=>{await Q.access.check();let X=Q.auth.user?.id;if(!X)throw Error("User ID required to list threads");let J=B0(Q),G=Y.offset??0,K=Y.limit??100,{threads:W,total:Z}=await Q.storage.threads.list(J.id,X,{limit:K,offset:G}),H=G+K<Z,F=Date.now();return{items:W.map(($)=>T$($,F)),totalCount:Z,hasMore:H}}})});var CT4,SV1;var Fh0=S(()=>{gX();k0();KU();CT4=AC(cZ),SV1=v1({name:"COLLECTION_THREADS_GET",description:"Get thread details by ID",annotations:{title:"Get Thread",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:wC,outputSchema:CT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.threads.get(Y.id);if(!J||J.organization_id!==X.id)return{item:null};return{item:T$(J)}}})});var RT4,IT4,_V1;var $h0=S(()=>{y1();k0();KU();RT4=q.object({id:q.string().describe("ID of the thread to update"),data:Zh0.describe("Partial thread data to update")}),IT4=q.object({item:cZ.describe("The updated thread entity")}),_V1=v1({name:"COLLECTION_THREADS_UPDATE",description:"Update an existing thread in the organization",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:RT4,outputSchema:IT4,handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=D9(Q);if(!J)throw Error("User ID required to update thread");let{id:G,data:K}=Y,W=await Q.storage.threads.get(G);if(!W||W.organization_id!==X.id)throw Error("Thread not found in organization");let Z=await Q.storage.threads.update(G,{title:K.title,description:K.description,hidden:K.hidden,updated_by:J});return{item:T$(Z)}}})});var vV1;var Vh0=S(()=>{gX();k0();KU();vV1=v1({name:"COLLECTION_THREADS_DELETE",description:"Delete a thread",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:PC,outputSchema:EC(cZ),handler:async(Y,Q)=>{o1(Q);let X=B0(Q);await Q.access.check();let J=await Q.storage.threads.get(Y.id);if(!J)throw Error(`Thread not found: ${Y.id}`);if(J.organization_id!==X.id)throw Error(`Thread not found: ${Y.id}`);return await Q.storage.threads.delete(Y.id),{item:T$(J)}}})});function qh0(Y){if(!Y)return null;if("field"in Y&&Y.field[0]==="thread_id"&&Y.operator==="eq")return String(Y.value);if("conditions"in Y)for(let Q of Y.conditions){let X=qh0(Q);if(X)return X}return null}var jT4,kV1;var Bh0=S(()=>{gX();k0();KU();jT4=M3(Gh0),kV1=v1({name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List all messages for a specific thread",annotations:{title:"List Thread Messages",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:dG,outputSchema:jT4,handler:async(Y,Q)=>{let X=B0(Q);await Q.access.check();let J=qh0(Y.where);if(!J)throw Error("thread_id filter is required in where clause");let G=await Q.storage.threads.get(J);if(!G||G.organization_id!==X.id)return{items:[],totalCount:0,hasMore:!1};let K=Y.offset??0,W=Y.limit??100,{messages:Z,total:H}=await Q.storage.threads.listMessages(J,{limit:W,offset:K}),F=K+W<H;return{items:Z,totalCount:H,hasMore:F}}})});var Uh0=S(()=>{Kh0();Hh0();Fh0();$h0();Vh0();Bh0()});var _T4,vT4,yV1;var zh0=S(()=>{y1();k0();_T4=q.object({id:q.string().min(1)}),vT4=q.object({user:q.object({id:q.string(),name:q.string(),email:q.string(),image:q.string().nullable()}).nullable()}),yV1=v1({name:"USER_GET",description:"Get a user by id (restricted to shared organizations)",annotations:{title:"Get User",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:_T4,outputSchema:vT4,handler:async(Y,Q)=>{await Q.access.check(),o1(Q);let X=D9(Q);if(!X)throw Error("Authentication required");let J=await Q.storage.users.findById(Y.id,X);if(!J)return{user:null};return{user:{id:J.id,name:J.name,email:J.email,image:J.image??null}}}})});var Dh0=S(()=>{zh0()});var Lh0={};t0(Lh0,{managementMCP:()=>bT4,ALL_TOOLS:()=>Oh0});var yT4,fT4,Oh0,bT4=async(Y)=>{let Q=null;if(Y.organization){let G=await Y.storage.organizationSettings.get(Y.organization.id),K=await Y.storage.projects.list(Y.organization.id),W=new Set(G?.enabled_plugins??[]);for(let Z of K)if(Z.enabledPlugins)for(let H of Z.enabledPlugins)W.add(H);Q=W.size>0?[...W]:null}let X=Fy0(Oh0,Q),J=new jz({name:"mcp-mesh-management",version:"1.0.0"},{capabilities:{tools:{}}});for(let G of X){let K=G.inputSchema&&typeof G.inputSchema==="object"&&"shape"in G.inputSchema?G.inputSchema:q.object({}),W=G.outputSchema&&typeof G.outputSchema==="object"&&"shape"in G.outputSchema?G.outputSchema:void 0,Z=K.shape,H=W?.shape;J.registerTool(G.name,{description:G.description??"",inputSchema:Z,outputSchema:H,annotations:G.annotations},async(F)=>{Y.access.setToolName(G.name);try{let $=await G.execute(F,Y);return{content:[{type:"text",text:JSON.stringify($)}],structuredContent:$}}catch($){return{content:[{type:"text",text:`Error: ${$.message}`}],isError:!0}}})}return J};var Nh0=S(()=>{iF1();Ak();y1();Ty0();ny0();df0();if0();Jb0();$b0();Db0();Nb0();Ib0();ub0();rb0();Qh0();Uh0();Dh0();yT4=[GV1,WV1,ZV1,KV1,HV1,$V1,VV1,qV1,BV1,UV1,zV1,J$1,Z$1,K$1,I$1,j$1,S$1,x$1,u$1,m$1,l$1,d$1,p$1,c$1,n$1,i$1,a$1,nf0,r$1,o$1,s$1,t$1,e$1,YV1,QV1,XV1,JV1,rF1,sF1,tF1,oF1,_$1,v$1,k$1,y$1,f$1,b$1,h$1,yV1,Y$1,Q$1,X$1,IV1,jV1,SV1,_V1,vV1,kV1,PV1,EV1,TV1,CV1,RV1,DV1,OV1,LV1,NV1,MV1,wV1,AV1],fT4=$y0(),Oh0=[...yT4,...fT4]});function hT4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:Q}=await Promise.resolve().then(() => (Nh0(),Lh0));return Q.map((X)=>{return{name:X.name,inputSchema:q.toJSONSchema(X.inputSchema,{unrepresentable:"any"}),outputSchema:X.outputSchema?q.toJSONSchema(X.outputSchema,{unrepresentable:"any"}):void 0,description:X.description}})},data:Ft(AG(),Y)},{data:Ht()},{data:Kt(Y)}]}async function Mh0(Y,Q){try{let X=FC(),J=new qZ1(process.env.ENCRYPTION_KEY||""),G=new BZ1(X.db,J),K=new UZ1(X.db),W=hT4(Y);try{await K.create({organizationId:Y,slug:n7,name:OU,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(W.map(async(Z)=>{let H=null;if(Z.permissions)H=(await cN.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:Q,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await cL({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),$=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await G.create({...Z.data,id:$,tools:F,organization_id:Y,created_by:Q,connection_token:Z.data.connection_token??H})}))}catch(X){console.error("Error creating default MCP connections:",X)}}var wh0=S(()=>{jY();fm();$M0();VM0();qM0();mm();y1();Up()});var Ah0;var Ph0=S(()=>{Ah0=["owner","admin"]});var xT4=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},Eh0=(Y)=>{if(Y.providerId==="microsoft")return xT4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function gT4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function uT4(){let Y=Math.floor(Math.random()*Ch0.length),Q=Math.floor(Math.random()*Th0.length),X=Ch0[Y]??"deco",J=Th0[Q]??"studio";return`${X}-${J}`}var Th0,Ch0,mT4,lT4,Mp,dT4,pT4,cT4,Rh0,t9,Ih0=void 0,fV1=void 0,nT4=!1,iT4,aT4,rT4,cN;var Up=S(()=>{K21();jk1();zf1();g41();Kb1();Hb1();fh();Ub1();fm();VZ1();WM0();wh0();Ph0();Th0=["labs","agent","studio","workspace","systems","core","cloud","works"],Ch0=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];mT4=Object.values(te()).map((Y)=>Y.map((Q)=>Q.name)).flat(),lT4={...Oh,self:["*",...mT4]},Mp=WZ(lT4),dT4=Mp.newRole({self:["*"],...x2.statements}),pT4=Mp.newRole({self:["*"],...x2.statements}),cT4=Mp.newRole({self:["*"],...x2.statements}),Rh0=Object.values(te()).map((Y)=>Y.map((Q)=>`self:${Q.name}`)).flat(),t9=kh.auth;if(t9.inviteEmailProviderId&&t9.emailProviders&&t9.emailProviders.length>0){let Y=VC(t9.emailProviders,t9.inviteEmailProviderId);if(Y){let Q=$C(Y);Ih0=async(X)=>{let J=X.inviter.user?.name||X.inviter.user?.email,G=`${AG()}/auth/accept-invitation?invitationId=${X.invitation.id}&redirectTo=/`;await Q({to:X.email,subject:`Invitation to join ${X.organization.name}`,html:`
|
|
1480
1480
|
<h2>You've been invited!</h2>
|
|
1481
1481
|
<p>${J} has invited you to join <strong>${X.organization.name}</strong>.</p>
|
|
1482
1482
|
<p><a href="${G}">Click here to accept the invitation</a></p>
|