@decocms/mesh 2.79.1 → 2.80.1

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.
Files changed (155) hide show
  1. package/dist/client/assets/{AlertCircle-CjljO9_K.js → AlertCircle-I0ZBgfYQ.js} +1 -1
  2. package/dist/client/assets/{ArrowUp-DlHoNDRH.js → ArrowUp-CWbsgzJx.js} +1 -1
  3. package/dist/client/assets/{Calendar-BzfXEzG1.js → Calendar-Br-of9Bx.js} +1 -1
  4. package/dist/client/assets/{Check-Cx0Fc2ER.js → Check-7XDeaAob.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-BHqfI-oc.js → CheckCircle-DsyljJow.js} +1 -1
  6. package/dist/client/assets/{CheckDone01-JeEywSHq.js → CheckDone01-BrCJwe9L.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-CYzQevGE.js → ChevronDown-DjYKb0ti.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-ZFn5_7l2.js → ChevronRight-CDMOoq_T.js} +1 -1
  9. package/dist/client/assets/{Code01-BHoiimgb.js → Code01-rhSbsId_.js} +1 -1
  10. package/dist/client/assets/{Copy01-DMVE1jMt.js → Copy01-By0DJI4e.js} +1 -1
  11. package/dist/client/assets/{DotsHorizontal-B8VSxmKN.js → DotsHorizontal-CZypQTS8.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-DmgtVWCP.js → DotsVertical-Dfeh91OM.js} +1 -1
  13. package/dist/client/assets/{Download01-DZAgFAa5.js → Download01-zqhRm8tL.js} +1 -1
  14. package/dist/client/assets/{Edit01-xS3_fhS5.js → Edit01-CeHpCCTm.js} +1 -1
  15. package/dist/client/assets/{File02-CPn42A_T.js → File02-sgq05FIn.js} +1 -1
  16. package/dist/client/assets/{File06-BHrPxaod.js → File06-O7Gdjw1T.js} +1 -1
  17. package/dist/client/assets/{FilterLines-OjKAkVgU.js → FilterLines-CXFrYLpl.js} +1 -1
  18. package/dist/client/assets/{Globe02-DANRNzsK.js → Globe02-iONIGvXX.js} +1 -1
  19. package/dist/client/assets/{Grid01-DfoEVHbX.js → Grid01-ybQAfHJf.js} +1 -1
  20. package/dist/client/assets/{Home02-mm2kWrdz.js → Home02-xOKzuBSl.js} +1 -1
  21. package/dist/client/assets/{Image01-BqS-Pbmk.js → Image01-faQziuY3.js} +1 -1
  22. package/dist/client/assets/{Inbox01-GbeCfKmy.js → Inbox01-Bf9_1DuB.js} +1 -1
  23. package/dist/client/assets/{InfoCircle-B8VcezQA.js → InfoCircle-BHznnG-5.js} +1 -1
  24. package/dist/client/assets/{LinkExternal01-Ba4Ansgj.js → LinkExternal01-_13hZ2Iz.js} +1 -1
  25. package/dist/client/assets/{List-C89gZK5m.js → List-nW4S0vIZ.js} +1 -1
  26. package/dist/client/assets/{Loading01-nhRm_OwM.js → Loading01-DKAt3l4d.js} +1 -1
  27. package/dist/client/assets/{Lock01-BIksl5Jz.js → Lock01-DiEUeHnC.js} +1 -1
  28. package/dist/client/assets/{Pin01-B9_xrwWT.js → Pin01-CML1Eqb9.js} +1 -1
  29. package/dist/client/assets/{Play-YTrai4me.js → Play-C1IlOUyZ.js} +1 -1
  30. package/dist/client/assets/{Plus-DVfCRM0e.js → Plus-pcHQuXb3.js} +1 -1
  31. package/dist/client/assets/{RefreshCcw01-DhKbWajd.js → RefreshCcw01-DRtvZr0B.js} +1 -1
  32. package/dist/client/assets/{SearchMd-Btq9JQM1.js → SearchMd-Byp7pziY.js} +1 -1
  33. package/dist/client/assets/{Settings01-n5GEFijK.js → Settings01-0c_f3iIf.js} +1 -1
  34. package/dist/client/assets/{Settings02-DmQ47Bo8.js → Settings02-DvEEdVgo.js} +1 -1
  35. package/dist/client/assets/{Share07-C0an8t9N.js → Share07-tm51RiqH.js} +1 -1
  36. package/dist/client/assets/{Terminal-COlc6e5_.js → Terminal-pExMIuGo.js} +1 -1
  37. package/dist/client/assets/{Tool01-syn058fN.js → Tool01-Ck61MGrd.js} +1 -1
  38. package/dist/client/assets/{Trash01-pKL0Dwki.js → Trash01-CiRdS40R.js} +1 -1
  39. package/dist/client/assets/{Upload01-Cny6KgII.js → Upload01-CmDl2ilr.js} +1 -1
  40. package/dist/client/assets/{Users03-DxSocU5u.js → Users03-YOMeBBa4.js} +1 -1
  41. package/dist/client/assets/{X-orwHLQvA.js → X-BWvwnU21.js} +1 -1
  42. package/dist/client/assets/{XClose-BvifwoiV.js → XClose-BfW13oFQ.js} +1 -1
  43. package/dist/client/assets/{agent-connections-preview-Ci_AKj2E.js → agent-connections-preview-CQujgSuC.js} +1 -1
  44. package/dist/client/assets/{agent-detail-BJ18jZ58.js → agent-detail-BR7gtqWa.js} +1 -1
  45. package/dist/client/assets/{agents-PSoG53JZ.js → agents-DTsWRoqo.js} +1 -1
  46. package/dist/client/assets/{alert-dialog-DWDyfsZl.js → alert-dialog-BNDRb9kX.js} +1 -1
  47. package/dist/client/assets/auth-catchall-DDqOmfvc.js +1 -0
  48. package/dist/client/assets/{avatar-CHzxmS3u.js → avatar-D7owUHWk.js} +1 -1
  49. package/dist/client/assets/{badge-DjX7aMc2.js → badge-CHLTvrSA.js} +1 -1
  50. package/dist/client/assets/{binder-boG-N4DJ.js → binder-BE0IXnZN.js} +1 -1
  51. package/dist/client/assets/{breadcrumb-C8uFp6Bl.js → breadcrumb-D2BLU7j-.js} +1 -1
  52. package/dist/client/assets/{button-jVZoVSEf.js → button-BZ2r6pCO.js} +1 -1
  53. package/dist/client/assets/{card-B1o7ZI1_.js → card-CrGrXuuQ.js} +1 -1
  54. package/dist/client/assets/{checkbox-DBFzFvmQ.js → checkbox-633rjAF0.js} +1 -1
  55. package/dist/client/assets/{circle-alert-BFldEkBf.js → circle-alert-DAU4eFZZ.js} +1 -1
  56. package/dist/client/assets/{collection-detail-V5sA0ljc.js → collection-detail-B2knGpZ-.js} +1 -1
  57. package/dist/client/assets/{collection-search-BcVP-V1Z.js → collection-search-BUqN_a8F.js} +1 -1
  58. package/dist/client/assets/{collection-tab-Ch7kudcF.js → collection-tab-XPIM1FTb.js} +1 -1
  59. package/dist/client/assets/{collection-table-wrapper-DuHnl5-M.js → collection-table-wrapper-DzPVsPcN.js} +1 -1
  60. package/dist/client/assets/{collection-tabs-BoHGtImC.js → collection-tabs-Cjkh8GZz.js} +1 -1
  61. package/dist/client/assets/{command-CyNsts_0.js → command-Bt5r_pbi.js} +1 -1
  62. package/dist/client/assets/{connect-TCaIRpLI.js → connect-CRavlYUd.js} +1 -1
  63. package/dist/client/assets/{connection-card-DvxLz7vp.js → connection-card-DAfdX0gX.js} +1 -1
  64. package/dist/client/assets/{connection-detail-BcHSi6_W.js → connection-detail-8t2CVc2K.js} +1 -1
  65. package/dist/client/assets/{connections-DhYeAlGi.js → connections-gKckc8If.js} +1 -1
  66. package/dist/client/assets/constants-BM_55h3t.js +1 -0
  67. package/dist/client/assets/{constants-B1K1ZOHV.js → constants-DIcFGsBt.js} +1 -1
  68. package/dist/client/assets/{create-organization-dialog-uaL-GIH0.js → create-organization-dialog-B4qE4EPP.js} +1 -1
  69. package/dist/client/assets/{create-project-dialog-CF32CwsT.js → create-project-dialog-CfuFqMTv.js} +1 -1
  70. package/dist/client/assets/{dialog-CD9Wwmjj.js → dialog-CIIi-UQx.js} +1 -1
  71. package/dist/client/assets/{dropdown-menu-1_TCBXfB.js → dropdown-menu-DLplFZtD.js} +1 -1
  72. package/dist/client/assets/{dynamic-plugin-layout-DATDpm42.js → dynamic-plugin-layout-CEvpW3PG.js} +1 -1
  73. package/dist/client/assets/{empty-state-BbUfTlym.js → empty-state-DYJ5Rr6Z.js} +1 -1
  74. package/dist/client/assets/{empty-state-Diyqgtl1.js → empty-state-DobHu_4R.js} +1 -1
  75. package/dist/client/assets/{env-vars-editor-C3mU-QJJ.js → env-vars-editor-BG_gXbGu.js} +1 -1
  76. package/dist/client/assets/{error-boundary-BmGvCwcM.js → error-boundary-D6xcaUnH.js} +1 -1
  77. package/dist/client/assets/{extract-connection-data-B-iX5ruo.js → extract-connection-data-CxFzgz9O.js} +1 -1
  78. package/dist/client/assets/{file-browser-8RURV0zK.js → file-browser-C36Tw4J4.js} +2 -2
  79. package/dist/client/assets/{form-CuPB-18q.js → form-BchiTH9Y.js} +1 -1
  80. package/dist/client/assets/{grid-view-rXagJOfe.js → grid-view-ozKNYSOV.js} +1 -1
  81. package/dist/client/assets/{home-C-ymc_Us.js → home-DgTK-KLO.js} +1 -1
  82. package/dist/client/assets/{index-C2FQIz_S.js → index-B1k63ajN.js} +1 -1
  83. package/dist/client/assets/{index-DUZGLwaX.js → index-BTBgIJM9.js} +1 -1
  84. package/dist/client/assets/{index-D3nlG5Bn.js → index-B_moDQPJ.js} +3 -3
  85. package/dist/client/assets/{index-DNnTxMe0.js → index-C0QGNbj0.js} +1 -1
  86. package/dist/client/assets/{index-CFsUbpkt.js → index-CpD2u8w7.js} +1 -1
  87. package/dist/client/assets/{index-Cl_5HyRE.js → index-Cs6OK7ZJ.js} +1 -1
  88. package/dist/client/assets/{index-BfmXZUrD.js → index-Dr7IE29U.js} +1 -1
  89. package/dist/client/assets/{index-Dlv6gV0o.js → index-FLCAXklL.js} +1 -1
  90. package/dist/client/assets/{index-BZHmd1qO.js → index-nKZ7l-qD.js} +1 -1
  91. package/dist/client/assets/{infiniteQueryObserver-C_2kO8fk.js → infiniteQueryObserver-DDQolF9c.js} +1 -1
  92. package/dist/client/assets/{input-Cfb0z5LB.js → input-H56RLaPs.js} +1 -1
  93. package/dist/client/assets/{integration-icon-DgoP3aRm.js → integration-icon-CmcbLTLF.js} +1 -1
  94. package/dist/client/assets/{label-DLjBs6VT.js → label-CnEH-wHx.js} +1 -1
  95. package/dist/client/assets/{layout-CGitH7Eg.js → layout-E39v_45d.js} +1 -1
  96. package/dist/client/assets/{localstorage-keys-Dcw7WgCK.js → localstorage-keys-2A5BuCMP.js} +1 -1
  97. package/dist/client/assets/{login-uEE_LxIh.js → login-DUOewX13.js} +1 -1
  98. package/dist/client/assets/{mcp-oauth-DcMlPST3.js → mcp-oauth-CUiS6EXj.js} +1 -1
  99. package/dist/client/assets/{mcp-server-card-Dp5-CXOE.js → mcp-server-card-CrJvkvRI.js} +1 -1
  100. package/dist/client/assets/{mcp-server-detail-CxmJ9qyx.js → mcp-server-detail-EKwGhUK0.js} +2 -2
  101. package/dist/client/assets/{members-Fnrk53kf.js → members-BEhN7KWY.js} +1 -1
  102. package/dist/client/assets/{monaco-editor-4bQew_dQ.js → monaco-editor-ie5OYDaT.js} +1 -1
  103. package/dist/client/assets/{monitoring-zeSCmmDz.js → monitoring-C9Og_05l.js} +1 -1
  104. package/dist/client/assets/{oauth-callback-BSP6Sdix.js → oauth-callback-DTiXu8j-.js} +1 -1
  105. package/dist/client/assets/{page-BPzxTPAI.js → page-BlOVdlvB.js} +1 -1
  106. package/dist/client/assets/{page-CXTaRAHP.js → page-CoINftxz.js} +1 -1
  107. package/dist/client/assets/{plugin-empty-state-BlSVDzFR.js → plugin-empty-state-DYY7MksH.js} +1 -1
  108. package/dist/client/assets/{plugin-header-CRX8X2CA.js → plugin-header-D0TUJ_dh.js} +1 -1
  109. package/dist/client/assets/{popover-DZy413j4.js → popover-DUi0j93T.js} +1 -1
  110. package/dist/client/assets/{project-layout-CJ4kCybp.js → project-layout-Bs2TseF0.js} +1 -1
  111. package/dist/client/assets/{project-settings-DFgohQs-.js → project-settings-BFe8kbwe.js} +1 -1
  112. package/dist/client/assets/{projects-list-C0t46Vb3.js → projects-list-BZJ4kuSu.js} +1 -1
  113. package/dist/client/assets/{registry-utils-CTumh--w.js → registry-utils-Dbwaq0MT.js} +1 -1
  114. package/dist/client/assets/{resizable-Do2pmnrG.js → resizable-DARULNUT.js} +1 -1
  115. package/dist/client/assets/{select-Dl5SsVsF.js → select-0DIfFHya.js} +1 -1
  116. package/dist/client/assets/shell-layout-DkiMKDsd.js +12 -0
  117. package/dist/client/assets/{spinner-DA06y-h7.js → spinner-UQinwvDE.js} +1 -1
  118. package/dist/client/assets/{store-invite-DbeHutGf.js → store-invite-m9V1Apll.js} +1 -1
  119. package/dist/client/assets/{switch-CQszwSv3.js → switch-DLJnhL10.js} +1 -1
  120. package/dist/client/assets/{table-Cc1VTSqr.js → table-ChVmeXId.js} +1 -1
  121. package/dist/client/assets/{tasks-2vErKOnA.js → tasks-FpVnuQAi.js} +1 -1
  122. package/dist/client/assets/{textarea-CQw4c4vg.js → textarea-D3j_8Boy.js} +1 -1
  123. package/dist/client/assets/{tools-list-BDp18Pgp.js → tools-list-BO-HUe9R.js} +1 -1
  124. package/dist/client/assets/{topbar-portal-BgZ57TAJ.js → topbar-portal-BNldIEFO.js} +1 -1
  125. package/dist/client/assets/{typewriter-title-B5Ki7tQ5.js → typewriter-title-CGFefZ4P.js} +1 -1
  126. package/dist/client/assets/{use-binding-TgcVoQAA.js → use-binding-ctUHW8Gb.js} +1 -1
  127. package/dist/client/assets/{use-connection-Crfe-Ixd.js → use-connection-BfSp7yqR.js} +1 -1
  128. package/dist/client/assets/{use-create-virtual-mcp-dLbcBuVS.js → use-create-virtual-mcp-CzlywnDr.js} +1 -1
  129. package/dist/client/assets/{use-deco-chat-open-D-wIsSOI.js → use-deco-chat-open-DT_oT7ZX.js} +1 -1
  130. package/dist/client/assets/{use-install-from-registry-CNM1pBya.js → use-install-from-registry-Cq-7Wuu6.js} +1 -1
  131. package/dist/client/assets/{use-list-state-COXmj0f_.js → use-list-state-DuC-NtF1.js} +1 -1
  132. package/dist/client/assets/{use-llm-rvFAkGsK.js → use-llm-BiBRQzNZ.js} +1 -1
  133. package/dist/client/assets/{use-mcp-prompts-DC9szL21.js → use-mcp-prompts-W5CaGZMT.js} +1 -1
  134. package/dist/client/assets/{use-mcp-tools-CvRTK2tY.js → use-mcp-tools-Cpu_8UKM.js} +1 -1
  135. package/dist/client/assets/{use-mobile-Do_29jRD.js → use-mobile-CrC3E0q9.js} +1 -1
  136. package/dist/client/assets/{use-organization-settings-CuBKNeOw.js → use-organization-settings-DrXO6yHJ.js} +1 -1
  137. package/dist/client/assets/{use-project-HGqdCewl.js → use-project-CpOEhNT2.js} +1 -1
  138. package/dist/client/assets/{use-virtual-mcp-VgOM6PoP.js → use-virtual-mcp-U8Yy28A_.js} +1 -1
  139. package/dist/client/assets/useInfiniteQuery-BBirx5Sx.js +1 -0
  140. package/dist/client/assets/{useMutation-9v6OVjLU.js → useMutation-C21m4k3n.js} +1 -1
  141. package/dist/client/assets/useQuery-ChGnYrGf.js +1 -0
  142. package/dist/client/assets/utils-BnM7sr5H.js +1 -0
  143. package/dist/client/assets/{view-mode-toggle-B7iYwEYq.js → view-mode-toggle-ZCV9ZCCk.js} +1 -1
  144. package/dist/client/assets/{workflow-BkMudwRR.js → workflow-BbxZqJ7t.js} +1 -1
  145. package/dist/client/index.html +1 -1
  146. package/dist/server/cli.js +1 -1
  147. package/dist/server/migrate.js +1 -1
  148. package/dist/server/server.js +1 -1
  149. package/package.json +1 -1
  150. package/dist/client/assets/auth-catchall-ePyrAyIw.js +0 -1
  151. package/dist/client/assets/constants-BeVRY8ix.js +0 -1
  152. package/dist/client/assets/shell-layout-FBb2Axq6.js +0 -12
  153. package/dist/client/assets/useInfiniteQuery-DKdNavme.js +0 -1
  154. package/dist/client/assets/useQuery-CQyI9lob.js +0 -1
  155. package/dist/client/assets/utils-ChMoRSU0.js +0 -1
@@ -1193,7 +1193,7 @@ ${X.stack}`;return Q}try{let G=JSON.stringify(X,null,2);if(G!=="{}"&&G.length<10
1193
1193
  Stack trace:
1194
1194
  ${X.stack}`;return G}}catch{}if(typeof X.toString==="function")try{let G=X.toString();if(G!=="[object Object]")return G}catch{}let J=Object.keys(X);if(J.length>0)return`Object with keys: ${J.join(", ")}`;return"[object Object]"}if(typeof Y==="string")return Y;if(typeof Y==="number"||typeof Y==="boolean")return String(Y);if(typeof Y==="function")return`[Function: ${Y.name||"anon"}]`;if(typeof Y==="symbol")return Y.toString();if(typeof Y==="bigint")return Y.toString();try{return String(Y)}catch{return"Unknown value (could not convert to string)"}}function WO(Y,X){switch(typeof X){case"string":return Y.newString(X);case"number":return Y.newNumber(X);case"boolean":return X?Y.true:Y.false;case"undefined":return Y.undefined;case"object":{if(X===null)return Y.null;if(Array.isArray(X)){let J=Y.newArray();return X.forEach((G,K)=>{let W=WO(Y,G);try{Y.setProp(J,String(K),W)}finally{W.dispose?.()}}),J}let Q=Y.newObject();for(let[J,G]of Object.entries(X)){let K=WO(Y,G);try{Y.setProp(Q,J,K)}finally{K.dispose?.()}}return Q}case"function":{let Q=`__hostFn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return Y.newFunction(Q,(...G)=>{try{let K=G.map((Z)=>Y.dump(Z)),W=X(...K);if(W&&typeof W.then==="function"){let Z=Y.newPromise();return W.then((H)=>{try{let F=WO(Y,H);Z.resolve(F),F.dispose(),Y.runtime.executePendingJobs()}catch(F){let $=GO(F),V=Y.newString(`Promise resolution error: ${$}`);Z.reject(V),V.dispose(),Y.runtime.executePendingJobs()}}).catch((H)=>{let F=GO(H),$=Y.newString(`Promise rejection: ${F}`);Z.reject($),$.dispose(),Y.runtime.executePendingJobs()}),Z.handle}return WO(Y,W)}catch(K){let W=GO(K);return Y.newString(`HostFunctionError: ${W}`)}finally{G.forEach((K)=>K.dispose())}})}case"bigint":return Y.newString(X.toString());case"symbol":return Y.newString(X.toString());default:try{return Y.newString(String(X))}catch{return Y.undefined}}}var KO1=()=>{};function FO1(Y){let X=Y.runtime.executePendingJobs(100);try{if("unwrap"in X&&typeof X.unwrap==="function")X.unwrap()}finally{if("dispose"in X&&typeof X.dispose==="function")X.dispose()}}async function HO1(Y,X,Q){let J=Date.now(),G=Y.resolvePromise(X);while(!0){FO1(Y);let K=await Promise.race([G,pY4(0).then(()=>null)]);if(K!==null)return K;if(Date.now()-J>Q)throw Error(`Timed out after ${Q}ms while awaiting a QuickJS promise`)}}async function B2({tools:Y,code:X,timeoutMs:Q}){let W=[];try{let J=await WO1({memoryLimitBytes:33554432,stackSizeBytes:524288});const G=PK(W,J.newContext({interruptAfterMs:Q}),0);const K=PK(W,vD1(G),0);try{let $=G.evalCode(X,"index.mjs",{strip:!0,strict:!0,type:"module"}),V=G.unwrapResult($),q=WO(G,Y);G.setProp(G.global,"tools",q);let B=G.runtime.hasPendingJob()?G.unwrapResult(await HO1(G,V,Q)):V;if(B!==V)V.dispose();let D=G.getProp(B,"default"),O=G.typeof(D);if(O!=="function")return{error:`Code must export default a function (tools). Got ${O}. Example: export default async (tools) => { /* ... */ }`,consoleLogs:K.logs};let L=G.callFunction(D,G.undefined,q),w=G.unwrapResult(L),R=await HO1(G,w,Q),T=G.unwrapResult(R);if(G.runtime.hasPendingJob())FO1(G);return{returnValue:G.dump(T),consoleLogs:K.logs}}catch($){return console.log($),{error:GO($),consoleLogs:K.logs}}}catch(Z){var H=Z,F=1}finally{c3(W,H,F)}}var pY4=(Y)=>new Promise((X)=>setTimeout(X,Y));var $O1=S(()=>{ZO1();KO1()});var PG0=S(()=>{$O1()});async function cY4(Y,X){let Q=Y.connections.map((K)=>K.connection_id),J=[];for(let K of Q){let W=await X.storage.connections.findById(K);if(W&&W.status==="active")J.push(W)}return J.map((K)=>{let W=Y.connections.find((Z)=>Z.connection_id===K.id);return{connection:K,selectedTools:W?.selected_tools??null,selectedResources:W?.selected_resources??null,selectedPrompts:W?.selected_prompts??null}})}async function VO1(Y,X){return(await X.storage.connections.list(Y)).filter((J)=>J.status==="active").map((J)=>({connection:J,selectedTools:null,selectedResources:null,selectedPrompts:null}))}async function nY4(Y,X){let Q=new Map;for(let q of Y)Q.set(q.connection.id,q);let J=Y.map((q)=>q.connection),G=new Map,K=await Promise.allSettled(J.map(async(q)=>{try{let B=await X.createMCPProxy(q);return{connection:q,proxy:B}}catch(B){return console.warn(`[code-execution] Failed to create proxy for connection ${q.id}:`,B),null}}));for(let q of K)if(q.status==="fulfilled"&&q.value)G.set(q.value.connection.id,q.value);let W=await Promise.allSettled(Array.from(G.entries()).map(async([q,B])=>{try{let O=(await B.proxy.listTools()).tools,L=Q.get(q);if(L?.selectedTools&&L.selectedTools.length>0){let w=new Set(L.selectedTools);O=O.filter((R)=>w.has(R.name))}return{connectionId:q,connectionTitle:B.connection.title,tools:O}}catch(D){return console.error(`[code-execution] Failed to list tools for connection ${q}:`,D),null}})),Z=new Set,H=[],F=new Map;for(let q of W){if(q.status!=="fulfilled"||!q.value)continue;let{connectionId:B,connectionTitle:D,tools:O}=q.value;for(let L of O){if(Z.has(L.name))continue;Z.add(L.name),H.push({...L,_meta:{connectionId:B,connectionTitle:D}}),F.set(L.name,B)}}let $=async(q,B)=>{let D=F.get(q);if(!D)return{content:[{type:"text",text:`Tool not found: ${q}`}],isError:!0};let O=G.get(D);if(!O)return{content:[{type:"text",text:`Connection not found for tool: ${q}`}],isError:!0};return await O.proxy.callTool({name:q,arguments:B})},V=[];for(let[,q]of G)V.push(q.proxy.close().catch(()=>{}));return await Promise.all(V),{tools:H,callTool:$}}async function ZO(Y){let X=z1(Y),Q;if(Y.connectionId){let J=await Y.storage.virtualMcps.findById(Y.connectionId,Y.organization?.id);if(J)Q=await cY4(J,Y);else Q=await VO1(X.id,Y)}else Q=await VO1(X.id,Y);return nY4(Q,Y)}function iY4(Y){return Y.toLowerCase().split(/[\s_\-./]+/).filter((X)=>X.length>=2)}function aY4(Y,X){let Q=0,J=X.name.toLowerCase(),G=(X.description??"").toLowerCase(),K=(X._meta?.connectionTitle??"").toLowerCase();for(let W of Y){if(J===W)Q+=10;else if(J.includes(W))Q+=3;if(G.includes(W))Q+=2;if(K.includes(W))Q+=1}return Q}function Gu(Y,X,Q){let J=iY4(Y);if(J.length===0)return X.slice(0,Q);return X.map((G)=>({tool:G,score:aY4(J,G)})).filter((G)=>G.score>0).sort((G,K)=>K.score-G.score).slice(0,Q).map((G)=>G.tool)}function Wu(Y,X){let Q=new Map(X.map((G)=>[G.name,G]));return{tools:Y.map((G)=>Q.get(G)).filter((G)=>G!==void 0).map((G)=>({name:G.name,description:G.description,connection:G._meta?.connectionTitle??"",inputSchema:G.inputSchema,outputSchema:G.outputSchema})),notFound:Y.filter((G)=>!Q.has(G))}}async function Zu(Y,X,Q){let J=Object.fromEntries(X.tools.map((G)=>[G.name,async(K)=>X.callTool(G.name,K??{})]));return B2({code:Y,tools:J,timeoutMs:Q})}function U2(Y){return{content:[{type:"text",text:JSON.stringify(Y,null,2)}]}}function x3(Y){return{content:[{type:"text",text:JSON.stringify(Y,null,2)}],isError:!0}}function WK(Y){let X=new Set(rY4);return Y.filter((Q)=>!X.has(Q.name))}var rY4;var eV=S(()=>{PG0();rY4=["CODE_EXECUTION_SEARCH_TOOLS","CODE_EXECUTION_DESCRIBE_TOOLS","CODE_EXECUTION_RUN_CODE"]});var TG0;var qO1=S(()=>{k1();q2();eV();TG0=f0({name:"CODE_EXECUTION_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 CODE_EXECUTION_DESCRIBE_TOOLS for detailed schemas.",inputSchema:CD1,outputSchema:ID1,handler:async(Y,X)=>{g0(X),z1(X),await X.access.check();let Q=await ZO(X),J=Gu(Y.query,Q.tools,Y.limit);return{query:Y.query,results:J.map((G)=>({name:G.name,description:G.description,connection:G._meta?.connectionTitle??""})),totalAvailable:Q.tools.length}}})});var EG0;var zO1=S(()=>{k1();q2();eV();EG0=f0({name:"CODE_EXECUTION_DESCRIBE_TOOLS",description:"Get detailed schemas for specific tools. Call after CODE_EXECUTION_SEARCH_TOOLS to get full input/output schemas before executing code.",inputSchema:RD1,outputSchema:jD1,handler:async(Y,X)=>{g0(X),z1(X),await X.access.check();let Q=await ZO(X);return Wu(Y.tools,Q.tools)}})});var CG0;var BO1=S(()=>{k1();q2();eV();CG0=f0({name:"CODE_EXECUTION_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 CODE_EXECUTION_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:SD1,outputSchema:kD1,handler:async(Y,X)=>{g0(X),z1(X),await X.access.check();let Q=await ZO(X);return await Zu(Y.code,Q,Y.timeoutMs)}})});var UO1=S(()=>{qO1();zO1();BO1();q2()});var sY4,tY4,IG0;var DO1=S(()=>{eY();b0();k1();ax();XK();sY4=z.object({data:Kw.describe("Data for the new connection (id is auto-generated if not provided)")}),tY4=z.object({item:kX.describe("The created connection entity")}),IG0=f0({name:"COLLECTION_CONNECTIONS_CREATE",description:"Create a new MCP connection in the organization",inputSchema:sY4,outputSchema:tY4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to create connection");let G={...Y.data,organization_id:Q.id,created_by:J};if(G.connection_type==="VIRTUAL"){let H=fF(G.connection_url);if(!H)throw Error("VIRTUAL connection requires connection_url in format: virtual://$virtual_mcp_id");let F=await X.storage.virtualMcps.findById(H);if(!F)throw Error(`Virtual MCP not found: ${H}`);if(F.organization_id!==Q.id)throw Error("Virtual MCP does not belong to the current organization");G.connection_url=hF(H)}let K=await XO({id:`pending-${Date.now()}`,title:G.title,connection_type:G.connection_type,connection_url:G.connection_url,connection_token:G.connection_token,connection_headers:G.connection_headers}).catch(()=>null),W=K?.length?K:null,Z=await X.storage.connections.create({...G,tools:W});return await X.eventBus.publish(Q.id,aQ.SELF(Q.id),{type:"connection.created",data:Z}),{item:Z}}})});function D2(Y,X){if(Y===X)return!0;if(Y==null||X==null)return Y===X;if(typeof Y!==typeof X)return!1;if(Array.isArray(Y)&&Array.isArray(X)){if(Y.length!==X.length)return!1;return Y.every((Q,J)=>D2(Q,X[J]))}if(typeof Y==="object"&&typeof X==="object"){let Q=Object.keys(Y),J=Object.keys(X);if(Q.length!==J.length)return!1;return Q.every((G)=>J.includes(G)&&D2(Y[G],X[G]))}return!1}function MX4(){return(Y)=>{if(!Array.isArray(Y))return!0;let X=[];return Y.every((Q)=>{if(X.some((G)=>D2(Q,G)))return!1;return X.push(Q),!0})}}function Ku(Y,X){return Y.safeParse(X).success}function nY(Y){if(typeof Y==="boolean")return Y?z.any():z.never();let X={};for(let G of fX4)G.apply(X,Y);let Q=[];if(X.string!==!1)Q.push(X.string||z.string());if(X.number!==!1)Q.push(X.number||z.number());if(X.boolean!==!1)Q.push(X.boolean||z.boolean());if(X.null!==!1)Q.push(X.null||z.null());if(X.array!==!1)Q.push(X.array||z.array(z.any()));if(X.tuple!==!1&&X.tuple!==void 0)Q.push(X.tuple);if(X.object!==!1)if(X.object)Q.push(X.object);else{let G=z.custom((K)=>{return typeof K==="object"&&K!==null&&!Array.isArray(K)},"Must be an object, not an array");Q.push(G)}if(X.file!==!1&&X.file!==void 0)Q.push(X.file);let J;if(Q.length===0)J=z.never();else if(Q.length===1)J=Q[0];else if(!Object.keys(Y).some((K)=>K!=="$schema"&&K!=="title"&&K!=="description"))J=z.any();else J=z.union(Q);for(let G of hX4)J=G.apply(J,Y);return J}var eY4=class{apply(Y,X){if(!X.type)return;let Q=Array.isArray(X.type)?X.type:[X.type],J=new Set(Q);if(!J.has("string"))Y.string=!1;if(!J.has("number")&&!J.has("integer"))Y.number=!1;if(!J.has("boolean"))Y.boolean=!1;if(!J.has("null"))Y.null=!1;if(!J.has("array"))Y.array=!1;if(!J.has("object"))Y.object=!1;if(J.has("integer")&&Y.number!==!1){let G=Y.number||z.number();if(G instanceof z.ZodNumber)Y.number=G.int()}}},YX4=class{apply(Y,X){if(X.const===void 0)return;let Q=X.const;if(Y.string=!1,Y.number=!1,Y.boolean=!1,Y.null=!1,Y.array=!1,Y.object=!1,typeof Q==="string")Y.string=z.literal(Q);else if(typeof Q==="number")Y.number=z.literal(Q);else if(typeof Q==="boolean")Y.boolean=z.literal(Q);else if(Q===null)Y.null=z.null();else if(Array.isArray(Q))Y.array=void 0;else if(typeof Q==="object")Y.object=void 0}},XX4=class{apply(Y,X){if(!X.enum)return;if(X.enum.length===0){if(!X.type)Y.string=!1,Y.number=!1,Y.boolean=!1,Y.null=!1,Y.array=!1,Y.object=!1;return}let Q={string:X.enum.filter((J)=>typeof J==="string"),number:X.enum.filter((J)=>typeof J==="number"),boolean:X.enum.filter((J)=>typeof J==="boolean"),null:X.enum.filter((J)=>J===null),array:X.enum.filter((J)=>Array.isArray(J)),object:X.enum.filter((J)=>typeof J==="object"&&J!==null&&!Array.isArray(J))};Y.string=this.createTypeSchema(Q.string,"string"),Y.number=this.createTypeSchema(Q.number,"number"),Y.boolean=this.createTypeSchema(Q.boolean,"boolean"),Y.null=Q.null.length>0?z.null():!1,Y.array=Q.array.length>0?void 0:!1,Y.object=Q.object.length>0?void 0:!1}createTypeSchema(Y,X){if(Y.length===0)return!1;if(Y.length===1)return z.literal(Y[0]);if(X==="string")return z.enum(Y);if(X==="number"){let[Q,J,...G]=Y;return z.union([z.literal(Q),z.literal(J),...G.map((K)=>z.literal(K))])}if(X==="boolean")return z.union([z.literal(!0),z.literal(!1)]);return!1}},QX4=class{apply(Y,X){let Q=X;if(Q.type==="string"&&Q.format==="binary"&&Q.contentEncoding==="binary"){let J=z.file();if(Q.minLength!==void 0)J=J.min(Q.minLength);if(Q.maxLength!==void 0)J=J.max(Q.maxLength);if(Q.contentMediaType!==void 0)J=J.mime(Q.contentMediaType);Y.file=J,Y.string=!1}}},JX4=class{apply(Y,X){let Q=X;if(X.type===void 0&&(Q.minLength!==void 0||Q.maxLength!==void 0||Q.pattern!==void 0)){if(Y.string===void 0)Y.string=z.string()}}},GX4=class{apply(Y,X){let Q=X;if(Q.minLength===void 0)return;if(Y.string!==!1){let J=Y.string||z.string();if(J instanceof z.ZodString)Y.string=J.refine((G)=>{return Array.from(G).length>=Q.minLength},{message:`String must be at least ${Q.minLength} characters long`})}}},WX4=class{apply(Y,X){let Q=X;if(Q.maxLength===void 0)return;if(Y.string!==!1){let J=Y.string||z.string();if(J instanceof z.ZodString)Y.string=J.refine((G)=>{return Array.from(G).length<=Q.maxLength},{message:`String must be at most ${Q.maxLength} characters long`})}}},ZX4=class{apply(Y,X){let Q=X;if(!Q.pattern)return;if(Y.string!==!1){let J=Y.string||z.string();if(J instanceof z.ZodString){let G=new RegExp(Q.pattern);Y.string=J.regex(G)}}}},KX4=class{apply(Y,X){let Q=X;if(Q.minimum===void 0)return;if(Y.number!==!1){let J=Y.number||z.number();if(J instanceof z.ZodNumber)Y.number=J.min(Q.minimum)}}},HX4=class{apply(Y,X){let Q=X;if(Q.maximum===void 0)return;if(Y.number!==!1){let J=Y.number||z.number();if(J instanceof z.ZodNumber)Y.number=J.max(Q.maximum)}}},FX4=class{apply(Y,X){let Q=X;if(Q.exclusiveMinimum===void 0)return;if(Y.number!==!1){let J=Y.number||z.number();if(J instanceof z.ZodNumber)if(typeof Q.exclusiveMinimum==="number")Y.number=J.gt(Q.exclusiveMinimum);else Y.number=!1}}},$X4=class{apply(Y,X){let Q=X;if(Q.exclusiveMaximum===void 0)return;if(Y.number!==!1){let J=Y.number||z.number();if(J instanceof z.ZodNumber)if(typeof Q.exclusiveMaximum==="number")Y.number=J.lt(Q.exclusiveMaximum);else Y.number=!1}}},VX4=class{apply(Y,X){let Q=X;if(Q.multipleOf===void 0)return;if(Y.number!==!1){let J=Y.number||z.number();if(J instanceof z.ZodNumber)Y.number=J.refine((G)=>{if(Q.multipleOf===0)return!1;let K=G/Q.multipleOf,W=Math.round(K),Z=Math.min(Math.abs(G)*Number.EPSILON*10,Math.abs(Q.multipleOf)*Number.EPSILON*10);return Math.abs(K-W)<=Z/Math.abs(Q.multipleOf)},{message:`Must be a multiple of ${Q.multipleOf}`})}}},qX4=class{apply(Y,X){let Q=X;if(X.type===void 0&&(Q.minItems!==void 0||Q.maxItems!==void 0||Q.items!==void 0||Q.prefixItems!==void 0)){if(Y.array===void 0)Y.array=z.array(z.any())}}},zX4=class{apply(Y,X){let Q=X;if(Q.minItems===void 0)return;if(Y.array!==!1)Y.array=(Y.array||z.array(z.any())).min(Q.minItems)}},BX4=class{apply(Y,X){let Q=X;if(Q.maxItems===void 0)return;if(Y.array!==!1)Y.array=(Y.array||z.array(z.any())).max(Q.maxItems)}},UX4=class{apply(Y,X){let Q=X;if(Y.array===!1)return;if(Array.isArray(Q.items))Y.array=Y.array||z.array(z.any());else if(Q.items&&typeof Q.items!=="boolean"&&!Q.prefixItems){let J=nY(Q.items),G=z.array(J);if(Y.array&&Y.array instanceof z.ZodArray){let K=Y.array._def;if(K.checks)K.checks.forEach((W)=>{if(W._zod&&W._zod.def){let Z=W._zod.def;if(Z.check==="min_length"&&Z.minimum!==void 0)G=G.min(Z.minimum);else if(Z.check==="max_length"&&Z.maximum!==void 0)G=G.max(Z.maximum)}})}Y.array=G}else if(typeof Q.items==="boolean"&&Q.items===!1)if(!Q.prefixItems)Y.array=z.array(z.any()).max(0);else Y.array=Y.array||z.array(z.any());else if(typeof Q.items==="boolean"&&Q.items===!0)Y.array=Y.array||z.array(z.any());else if(Q.prefixItems)Y.array=Y.array||z.array(z.any())}},DX4=class{apply(Y,X){if(X.type!=="array")return;let Q=X;if(!Array.isArray(Q.items))return;if(Y.array===!1)return;let J=Q.items.map((K)=>nY(K)),G;if(J.length===0)G=z.tuple([]);else G=z.tuple(J);if(Q.minItems!==void 0&&Q.minItems>J.length)G=!1;if(Q.maxItems!==void 0&&Q.maxItems<J.length)G=!1;Y.tuple=G,Y.array=!1}},OX4=class{apply(Y,X){let Q=X;if(Y.object===!1)return;if(Q.properties||Q.required||Q.additionalProperties!==void 0)Y.object=Y.object||z.object({}).passthrough()}},NX4=class{apply(Y,X){let Q=X;if(X.type===void 0&&(Q.maxProperties!==void 0||Q.minProperties!==void 0)){if(Y.object===void 0)Y.object=z.object({}).passthrough()}}},LX4=class{apply(Y,X){let Q=X;if(Q.maxProperties===void 0)return;if(Y.object!==!1){let J=Y.object||z.object({}).passthrough();Y.object=J.refine((G)=>Object.keys(G).length<=Q.maxProperties,{message:`Object must have at most ${Q.maxProperties} properties`})}}},wX4=class{apply(Y,X){let Q=X;if(Q.minProperties===void 0)return;if(Y.object!==!1){let J=Y.object||z.object({}).passthrough();Y.object=J.refine((G)=>Object.keys(G).length>=Q.minProperties,{message:`Object must have at least ${Q.minProperties} properties`})}}},AX4=class{apply(Y,X){if(!X.not)return Y;let Q=nY(X.not);return Y.refine((J)=>!Ku(Q,J),{message:"Value must not match the 'not' schema"})}},PX4=class{apply(Y,X){if(X.uniqueItems!==!0)return Y;return Y.refine(MX4(),{message:"Array items must be unique"})}},TX4=class{apply(Y,X){if(!X.allOf||X.allOf.length===0)return Y;return X.allOf.map((J)=>nY(J)).reduce((J,G)=>z.intersection(J,G),Y)}},EX4=class{apply(Y,X){if(!X.anyOf||X.anyOf.length===0)return Y;let Q=X.anyOf.length===1?nY(X.anyOf[0]):z.union([nY(X.anyOf[0]),nY(X.anyOf[1]),...X.anyOf.slice(2).map((J)=>nY(J))]);return z.intersection(Y,Q)}},CX4=class{apply(Y,X){if(!X.oneOf||X.oneOf.length===0)return Y;let Q=X.oneOf.map((J)=>nY(J));return Y.refine((J)=>{let G=0;for(let K of Q)if(K.safeParse(J).success){if(G++,G>1)return!1}return G===1},{message:"Value must match exactly one of the oneOf schemas"})}},IX4=class{apply(Y,X){let Q=X;if(Q.prefixItems&&Array.isArray(Q.prefixItems)){let G=Q.prefixItems.map((K)=>nY(K));return Y.refine((K)=>{if(!Array.isArray(K))return!0;for(let W=0;W<Math.min(K.length,G.length);W++)if(!Ku(G[W],K[W]))return!1;if(K.length>G.length){if(typeof Q.items==="boolean"&&Q.items===!1)return!1;else if(Q.items&&typeof Q.items==="object"&&!Array.isArray(Q.items)){let W=nY(Q.items);for(let Z=G.length;Z<K.length;Z++)if(!Ku(W,K[Z]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return Y}},RX4=class{apply(Y,X){let Q=X;if(!Q.properties&&!Q.required&&Q.additionalProperties!==!1)return Y;if(Y instanceof z.ZodObject||Y instanceof z.ZodRecord){let J={};if(Q.properties){for(let[G,K]of Object.entries(Q.properties))if(K!==void 0)J[G]=nY(K)}if(Q.required&&Array.isArray(Q.required)){let G=new Set(Q.required);for(let K of Object.keys(J))if(!G.has(K))J[K]=J[K].optional()}else for(let G of Object.keys(J))J[G]=J[G].optional();if(Q.additionalProperties===!1)return z.object(J);else return z.object(J).passthrough()}return Y.refine((J)=>{if(typeof J!=="object"||J===null||Array.isArray(J))return!0;if(Q.properties){for(let[G,K]of Object.entries(Q.properties))if(K!==void 0){if(Object.getOwnPropertyDescriptor(J,G)!==void 0){if(!nY(K).safeParse(J[G]).success)return!1}}}if(Q.required&&Array.isArray(Q.required)){for(let G of Q.required)if(Object.getOwnPropertyDescriptor(J,G)===void 0)return!1}if(Q.additionalProperties===!1&&Q.properties){let G=new Set(Object.keys(Q.properties));for(let K in J)if(!G.has(K))return!1}return!0},{message:"Object constraints validation failed"})}},jX4=class{apply(Y,X){if(!X.enum||X.enum.length===0)return Y;let Q=X.enum.filter((J)=>Array.isArray(J)||typeof J==="object"&&J!==null);if(Q.length===0)return Y;return Y.refine((J)=>{if(typeof J!=="object"||J===null)return!0;return Q.some((G)=>D2(J,G))},{message:"Value must match one of the enum values"})}},SX4=class{apply(Y,X){if(X.const===void 0)return Y;let Q=X.const;if(typeof Q!=="object"||Q===null)return Y;return Y.refine((J)=>D2(J,Q),{message:"Value must equal the const value"})}},kX4=class{apply(Y,X){if(X.description)Y=Y.describe(X.description);return Y}},vX4=class{apply(Y,X){var Q;let J=X;if(!((Q=J.required)==null?void 0:Q.includes("__proto__"))||X.type!==void 0)return Y;return z.any().refine((G)=>this.validateRequired(G,J.required),{message:"Missing required properties"})}validateRequired(Y,X){if(typeof Y!=="object"||Y===null||Array.isArray(Y))return!0;return X.every((Q)=>Object.prototype.hasOwnProperty.call(Y,Q))}},_X4=class{apply(Y,X){var Q;let J=X;if(J.contains===void 0)return Y;let G=nY(J.contains),K=(Q=J.minContains)!=null?Q:1,W=J.maxContains;return Y.refine((Z)=>{if(!Array.isArray(Z))return!0;let H=0;for(let F of Z)if(Ku(G,F))H++;if(H<K)return!1;if(W!==void 0&&H>W)return!1;return!0},{message:"Array must contain required items matching the schema"})}},yX4=class{apply(Y,X){let{default:Q}=X;if(Q===void 0)return Y;if(!Y.safeParse(Q).success)return Y;return Y.default(Q)}},fX4,hX4;var OO1=S(()=>{a6();a6();a6();a6();a6();a6();a6();a6();a6();a6();a6();a6();a6();a6();fX4=[new YX4,new XX4,new eY4,new QX4,new JX4,new qX4,new NX4,new GX4,new WX4,new ZX4,new KX4,new HX4,new FX4,new $X4,new VX4,new DX4,new zX4,new BX4,new UX4,new LX4,new wX4,new OX4],hX4=[new vX4,new jX4,new SX4,new TX4,new EX4,new CX4,new IX4,new RX4,new _X4,new AX4,new PX4,new yX4,new kX4]});class RG0{constructor(Y){this._url=Y}start(){if(this._socket)throw Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((Y,X)=>{this._socket=new WebSocket(this._url,bX4),this._socket.onerror=(Q)=>{let J="error"in Q?Q.error:Error(`WebSocket error: ${JSON.stringify(Q)}`);X(J),this.onerror?.(J)},this._socket.onopen=()=>{Y()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=(Q)=>{let J;try{J=iQ.parse(JSON.parse(Q.data))}catch(G){this.onerror?.(G);return}this.onmessage?.(J)}})}async close(){this._socket?.close()}send(Y){return new Promise((X,Q)=>{if(!this._socket){Q(Error("Not connected"));return}this._socket?.send(JSON.stringify(Y)),X()})}}var bX4="mcp";var NO1=S(()=>{sY()});function xX4(Y){let X=Y;if(!X||typeof X!=="object"||!("method"in X))return null;switch(X.method){case"initialize":{let Q=X?.params?.protocolVersion;if(!Q)return null;return{type:"emit",message:{result:{protocolVersion:Q,capabilities:{tools:{}},serverInfo:{name:"deco-chat-server",version:"1.0.0"}},jsonrpc:X.jsonrpc??"2.0",id:X.id}}}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}var jG0;var LO1=S(()=>{Zw();jG0=class jG0 extends YH{constructor(Y,X){super(Y,X)}send(Y,X){let Q=xX4(Y);if(Q?.type==="emit")return this.onmessage?.(Q.message),Promise.resolve();if(Q?.type==="suppress")return Promise.resolve();return super.send(Y,X)}}});var wO1,MO1=async(Y,X,Q)=>{let J=uX4(Y.connection,X,Q);if(!J)throw Error("Unknown MCP connection type");let G=new wO1({name:Y?.name??"MCP Client",version:"1.0.0"});return await G.connect(J),{client:G,callStreamableTool:(K,W,Z)=>{if(Y.connection.type!=="HTTP")throw Error("HTTP connection required");let H=new Headers(Q);if(!H.has("Authorization"))H.set("Authorization",`Bearer ${Y.connection.token}`);for(let[V,q]of Object.entries(Y.connection.headers??{}))H.set(V,q);let F=new URL(Y.connection.url),$=F.pathname.replace(/\/+$/,"")||"/";return F.pathname=`${$}/call-tool/${encodeURIComponent(K)}`,fetch(F.href,{method:"POST",redirect:"manual",body:JSON.stringify(W),headers:H,signal:Z})}}},uX4=(Y,X,Q)=>{if(Y.type==="Websocket")return new RG0(new URL(Y.url));if(Y.type!=="SSE"&&Y.type!=="HTTP")return null;let G={...Y.token?{authorization:`Bearer ${Y.token}`}:{},...Q??{},..."headers"in Y?Y.headers||{}:{}};if(Y.type==="SSE"){let K={requestInit:{headers:G,signal:X}};if(Y.token)K.eventSourceInit={fetch:(W,Z)=>{return fetch(W,{...Z,headers:{...G,Accept:"text/event-stream"},signal:X})}};return new iV(new URL(Y.url),K)}return new jG0(new URL(Y.url),{requestInit:{headers:G,signal:X,credentials:"include"}})};var AO1=S(()=>{Sz();cx();NO1();sY();LO1();wO1=class wO1 extends bJ{constructor(Y,X){super(Y,X)}async listTools(Y,X){return await this.request({method:"tools/list",params:Y},jL,X)}}});function EO1(Y){let X=(Q)=>{if("connection"in Y)return MO1({connection:Y.connection},void 0,Q);return Y.client};return new Proxy({},{get(Q,J){if(J==="toJSON")return null;if(typeof J!=="string")throw Error("Name must be a string");if(J==="listTools")return Z;async function G(H,F=J){let $=Y?.debugId?.(),V=$?{"x-trace-debug-id":$}:void 0,{client:q,callStreamableTool:B}=await X(V);if(Y?.streamable?.[String(F)])return B(String(F),H);let{structuredContent:D,isError:O,content:L}=await q.callTool({name:String(F),arguments:H});if(O){let R=L?.[0]?.text,T=typeof R==="string"?PO1(R):null,P=T?.code&&typeof Y?.getErrorByStatusCode==="function"?Y.getErrorByStatusCode(T.code,T.message,T.traceId):null;if(P)throw P;throw Error(`Tool ${String(F)} returned an error: ${JSON.stringify(D??L)}`)}if(D!==void 0)return D;let w=L?.[0]?.text;return typeof w==="string"?PO1(w):void 0}async function K(){let{client:H}=await X(),{tools:F}=await H.listTools();return F}async function W(){if(!("connection"in Y))return K();let H=Y.connection,F=JSON.stringify(H);try{if(!Hu.has(F))Hu.set(F,K());return await Hu.get(F)}catch($){console.error("Failed to list tools",$),Hu.delete(F);return}}async function Z(){return(await W()??[]).map((F)=>TO1(F,G))}return G.asTool=async()=>{let F=(await W()??[]).find(($)=>$.name===J);if(!F)throw Error(`Tool ${J} not found`);return TO1(F,G)},G}})}var PO1=(Y)=>{try{return JSON.parse(Y)}catch{return Y}},Hu,TO1=(Y,X)=>{return{...Y,id:Y.name,inputSchema:Y.inputSchema?nY(Y.inputSchema):void 0,outputSchema:Y.outputSchema?nY(Y.outputSchema):void 0,execute:(Q)=>{return X(Q.context,Y.name)}}};var CO1=S(()=>{OO1();AO1();Hu=new Map});function Fu(Y){return EO1(Y)}var Wz8;var IO1=S(()=>{CO1();Wz8=new Proxy({},{get(Y,X){if(X==="toJSON")return null;if(X==="forConnection")return(Q)=>Fu({connection:Q});return global[X]}})});function $u(Y){return{isImplementedBy:(X)=>{for(let Q of Y){let J=typeof Q.name==="string"?new RegExp(`^${Q.name}$`):Q.name,G=X.find((K)=>J.test(K.name));if(!G&&Q.opt)continue;if(!G)return!1}return!0}}}var Yq=(Y)=>{return{...$u(Y),forClient:(X)=>{return Fu({client:X,streamable:Y.reduce((Q,J)=>{return Q[J.name]=J.streamable===!0,Q},{})})},forConnection:(X)=>{return Fu({connection:X,streamable:Y.reduce((Q,J)=>{return Q[J.name]=J.streamable===!0,Q},{})})}}};var O2=S(()=>{IO1()});function KK(Y){return z.object({items:z.array(Y).describe("Array of collection items"),totalCount:z.number().int().min(0).optional().describe("Total number of matching items (if available)"),hasMore:z.boolean().optional().describe("Whether there are more items available")})}function L2(Y){return z.object({item:Y.nullable().describe("The retrieved item, or null if not found")})}function lX4(Y){return z.object({data:Y.partial().describe("Data for the new entity (id may be auto-generated)")})}function dX4(Y){return z.object({item:Y.describe("The created entity with generated id")})}function pX4(Y){return z.object({id:z.string().describe("ID of the entity to update"),data:Y.partial().describe("Partial entity data to update")})}function cX4(Y){return z.object({item:Y.describe("The updated entity")})}function M2(Y){return z.object({item:Y.describe("The deleted entity")})}function HO(Y,X,Q){let J=Y.toUpperCase(),G=Q?.readOnly??!1,K=[{name:`COLLECTION_${J}_LIST`,inputSchema:ZK,outputSchema:KK(X)},{name:`COLLECTION_${J}_GET`,inputSchema:N2,outputSchema:L2(X)}];if(!G)K.push({name:`COLLECTION_${J}_CREATE`,inputSchema:lX4(X),outputSchema:dX4(X),opt:!0},{name:`COLLECTION_${J}_UPDATE`,inputSchema:pX4(X),outputSchema:cX4(X),opt:!0},{name:`COLLECTION_${J}_DELETE`,inputSchema:w2,outputSchema:M2(X),opt:!0});return K}var KO,gX4,RO1,mX4,ZK,N2,w2;var v5=S(()=>{b0();KO=z.object({id:z.string().describe("Unique identifier for the entity"),title:z.string().describe("Human-readable title for the entity"),description:z.string().nullish().describe("Description of the entity"),created_at:z.string().datetime(),updated_at:z.string().datetime(),created_by:z.string().optional(),updated_by:z.string().optional()}),gX4=z.object({field:z.array(z.string()),operator:z.enum(["eq","gt","gte","lt","lte","in","like","contains"]),value:z.unknown()}),RO1=z.lazy(()=>z.union([gX4,z.object({operator:z.enum(["and","or","not"]),conditions:z.array(RO1)})])),mX4=z.object({field:z.array(z.string()),direction:z.enum(["asc","desc"]),nulls:z.enum(["first","last"]).optional()}),ZK=z.object({where:RO1.optional().describe("Filter expression"),orderBy:z.array(mX4).optional().describe("Sort expressions"),limit:z.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:z.number().int().min(0).optional().describe("Number of items to skip")});N2=z.object({id:z.string().describe("ID of the entity to retrieve")});w2=z.object({id:z.string().describe("ID of the entity to delete")})});var nX4,jO1,Bz8;var SO1=S(()=>{b0();v5();nX4=z.object({id:z.string(),name:z.string(),description:z.string().optional(),inputSchema:z.record(z.string(),z.unknown()),outputSchema:z.record(z.string(),z.unknown()).optional()}),jO1=KO.extend({_meta:z.object({"io.decocms":z.object({id:z.string(),verified:z.boolean(),scopeName:z.string(),appName:z.string(),friendlyName:z.string().nullable().optional(),metadata:z.record(z.string(),z.unknown()).nullable().optional(),publishedAt:z.string().datetime().optional(),updatedAt:z.string().datetime().optional(),tools:z.array(nX4).nullable().optional().describe("Available tools exposed by this app")}).optional()}).optional(),server:z.object({$schema:z.string().optional(),_meta:z.record(z.string(),z.unknown()).optional(),name:z.string().describe("The server name (scope/app)"),title:z.string().optional().describe("User-friendly title"),description:z.string().optional().describe("Server description"),icons:z.array(z.object({src:z.string(),mimeType:z.string().optional(),sizes:z.array(z.string()).optional(),theme:z.enum(["light","dark"]).optional()})).optional(),remotes:z.array(z.object({type:z.enum(["http","stdio","sse"]),url:z.string().optional(),headers:z.array(z.unknown()).optional()})).optional(),packages:z.array(z.unknown()).optional(),repository:z.object({url:z.string(),source:z.string().optional(),subfolder:z.string().optional()}).optional(),version:z.string().optional(),websiteUrl:z.string().optional()})}),Bz8=HO("registry_app",jO1,{readOnly:!0})});var kO1,vO1,_O1,yO1,fO1,SG0;var hO1=S(()=>{b0();O2();kO1=z.object({specversion:z.literal("1.0").describe("CloudEvents specification version"),id:z.string().describe("Unique identifier for this event (UUID recommended)"),source:z.string().describe("Connection ID of the event publisher"),type:z.string().describe("Event type (e.g., 'order.created', 'user.signup')"),time:z.string().datetime().optional().describe("Timestamp of when the event occurred (ISO 8601)"),subject:z.string().optional().describe("Subject/resource identifier (e.g., order ID, user ID)"),datacontenttype:z.string().optional().default("application/json").describe("Content type of the data attribute"),dataschema:z.string().url().optional().describe("URI to the schema for the data attribute"),data:z.unknown().optional().describe("Event payload (any JSON value)")}),vO1=z.object({events:z.array(kO1).min(1).describe("Batch of CloudEvents to process")}),_O1=z.object({success:z.boolean().optional().describe("Whether this event was processed successfully"),error:z.string().optional().describe("Error message for this event"),retryAfter:z.number().int().positive().optional().describe("Re-deliver this event after this many ms")}),yO1=z.object({success:z.boolean().optional().describe("Batch success - applies to events not in results"),error:z.string().optional().describe("Batch error message - applies to events not in results"),processedCount:z.number().int().min(0).optional().describe("Number of events successfully processed"),retryAfter:z.number().int().positive().optional().describe("Batch retryAfter - applies to events not in results"),results:z.record(z.string(),_O1).optional().describe("Per-event results keyed by event ID")}),fO1=[{name:"ON_EVENTS",inputSchema:vO1,outputSchema:yO1}],SG0=Yq(fO1)});var A2,P2,T2,E2,bO1,xO1,C2,I2,R2,j2,S2,k2,v2,_2,uO1,iX4;var gO1=S(()=>{b0();O2();A2=z.object({type:z.string().min(1).max(255).describe("Event type identifier"),subject:z.string().max(255).optional().describe("Subject/resource identifier (e.g., order ID)"),data:z.unknown().optional().describe("Event payload"),deliverAt:z.string().datetime().optional().describe("Scheduled delivery time (ISO 8601). Omit for immediate delivery."),cron:z.string().max(100).optional().describe("Cron expression for recurring delivery. Use EVENT_CANCEL to stop.")}),P2=z.object({id:z.string().describe("Unique event ID"),type:z.string().describe("Event type"),source:z.string().describe("Source connection ID"),time:z.string().describe("Event timestamp")}),T2=z.object({eventType:z.string().min(1).max(255).describe("Event type to subscribe to"),publisher:z.string().optional().describe("Filter events by publisher connection ID"),filter:z.string().max(1000).optional().describe("JSONPath filter expression on event data")}),E2=z.object({subscription:z.object({id:z.string().describe("Subscription ID"),connectionId:z.string().describe("Subscriber connection ID"),eventType:z.string().describe("Event type pattern"),publisher:z.string().nullable().describe("Publisher connection filter"),filter:z.string().nullable().describe("JSONPath filter expression"),enabled:z.boolean().describe("Whether subscription is enabled"),createdAt:z.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:z.string().datetime().describe("Updated timestamp (ISO 8601)")})}),bO1=z.object({eventType:z.string().min(1).max(255).describe("Event type to subscribe to"),publisher:z.string().optional().describe("Filter events by publisher connection ID"),filter:z.string().max(1000).optional().describe("JSONPath filter expression on event data")}),xO1=z.object({id:z.string().describe("Subscription ID"),connectionId:z.string().describe("Subscriber connection ID"),eventType:z.string().describe("Event type pattern"),publisher:z.string().nullable().describe("Publisher connection filter"),filter:z.string().nullable().describe("JSONPath filter expression"),enabled:z.boolean().describe("Whether subscription is enabled"),createdAt:z.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:z.string().datetime().describe("Updated timestamp (ISO 8601)")}),C2=z.object({subscriptions:z.array(bO1).describe("Desired subscriptions - system will create/update/delete to match")}),I2=z.object({created:z.number().int().min(0).describe("Number of subscriptions created"),updated:z.number().int().min(0).describe("Number of subscriptions with filter updated"),deleted:z.number().int().min(0).describe("Number of subscriptions removed"),unchanged:z.number().int().min(0).describe("Number of subscriptions unchanged"),subscriptions:z.array(xO1).describe("Current subscriptions after sync")}),R2=z.object({subscriptionId:z.string().describe("Subscription ID to remove")}),j2=z.object({success:z.boolean().describe("Whether unsubscribe was successful"),subscriptionId:z.string().describe("Subscription ID that was removed")}),S2=z.object({eventId:z.string().describe("Event ID to cancel")}),k2=z.object({success:z.boolean().describe("Whether cancellation was successful"),eventId:z.string().describe("Event ID that was cancelled")}),v2=z.object({eventId:z.string().describe("Event ID to acknowledge")}),_2=z.object({success:z.boolean().describe("Whether ACK was successful"),eventId:z.string().describe("Event ID that was acknowledged")}),uO1=[{name:"EVENT_PUBLISH",inputSchema:A2,outputSchema:P2},{name:"EVENT_SUBSCRIBE",inputSchema:T2,outputSchema:E2},{name:"EVENT_UNSUBSCRIBE",inputSchema:R2,outputSchema:j2},{name:"EVENT_CANCEL",inputSchema:S2,outputSchema:k2},{name:"EVENT_ACK",inputSchema:v2,outputSchema:_2},{name:"EVENT_SYNC_SUBSCRIPTIONS",inputSchema:C2,outputSchema:I2}],iX4=Yq(uO1)});var aX4,rX4,oX4,sX4,tX4,eX4,YQ4,XQ4,QQ4,JQ4,GQ4,WQ4,y2;var Vu=S(()=>{b0();aX4=z.object({prefix:z.string().optional().describe("Filter objects by prefix (e.g., 'folder/' for folder contents)"),maxKeys:z.number().optional().default(1000).describe("Maximum number of keys to return (default: 1000)"),continuationToken:z.string().optional().describe("Token for pagination from previous response"),delimiter:z.string().optional().describe("Delimiter for grouping keys (typically '/'). When set, commonPrefixes returns folder paths.")}),rX4=z.object({objects:z.array(z.object({key:z.string().describe("Object key/path"),size:z.number().describe("Object size in bytes"),lastModified:z.string().describe("Last modified timestamp"),etag:z.string().describe("Entity tag for the object")})),nextContinuationToken:z.string().optional().describe("Token for fetching next page of results"),isTruncated:z.boolean().describe("Whether there are more results available"),commonPrefixes:z.array(z.string()).optional().describe("Folder paths when delimiter is used (e.g., ['photos/2024/', 'photos/2025/'])")}),oX4=z.object({key:z.string().describe("Object key/path to get metadata for")}),sX4=z.object({contentType:z.string().optional().describe("MIME type of the object"),contentLength:z.number().describe("Size of the object in bytes"),lastModified:z.string().describe("Last modified timestamp"),etag:z.string().describe("Entity tag for the object"),metadata:z.record(z.string(),z.string()).optional().describe("Custom metadata key-value pairs")}),tX4=z.object({key:z.string().describe("Object key/path to generate URL for"),expiresIn:z.number().optional().describe("URL expiration time in seconds (default: from state config or 3600)")}),eX4=z.object({url:z.string().describe("Presigned URL for downloading the object"),expiresIn:z.number().describe("Expiration time in seconds that was used")}),YQ4=z.object({key:z.string().describe("Object key/path for the upload"),expiresIn:z.number().optional().describe("URL expiration time in seconds (default: from state config or 3600)"),contentType:z.string().optional().describe("MIME type for the object being uploaded")}),XQ4=z.object({url:z.string().describe("Presigned URL for uploading the object"),expiresIn:z.number().describe("Expiration time in seconds that was used")}),QQ4=z.object({key:z.string().describe("Object key/path to delete")}),JQ4=z.object({success:z.boolean().describe("Whether the deletion was successful"),key:z.string().describe("The key that was deleted")}),GQ4=z.object({keys:z.array(z.string()).max(1000).describe("Array of object keys/paths to delete (max 1000)")}),WQ4=z.object({deleted:z.array(z.string()).describe("Array of successfully deleted keys"),errors:z.array(z.object({key:z.string(),message:z.string()})).describe("Array of errors for failed deletions")}),y2=[{name:"LIST_OBJECTS",inputSchema:aX4,outputSchema:rX4},{name:"GET_OBJECT_METADATA",inputSchema:oX4,outputSchema:sX4},{name:"GET_PRESIGNED_URL",inputSchema:tX4,outputSchema:eX4},{name:"PUT_PRESIGNED_URL",inputSchema:YQ4,outputSchema:XQ4},{name:"DELETE_OBJECT",inputSchema:QQ4,outputSchema:JQ4},{name:"DELETE_OBJECTS",inputSchema:GQ4,outputSchema:WQ4}]});var qu=S(()=>{O2();SO1();hO1();gO1();Vu()});var ZQ4,KQ4,mO1;var lO1=S(()=>{b0();v5();ZQ4=KO.extend({avatar:z.string().describe("URL or data URI to the assistant's avatar image"),system_prompt:z.string().describe("System prompt that defines the assistant's behavior"),virtual_mcp_id:z.string().describe("Virtual MCP ID to use for this assistant"),model:z.object({id:z.string().describe("Model ID"),connectionId:z.string().describe("Connection ID that provides the model")}).describe("Selected model reference for this assistant")}),KQ4=HO("assistant",ZQ4),mO1=[...KQ4]});var f2,HK,pO1,HQ4,FQ4,cO1,$Q4,VQ4,qQ4,zQ4,BQ4,UQ4,nO1,DQ4,OQ4,NQ4,LQ4,wQ4,MQ4,AQ4,PQ4,TQ4,EQ4,xz8,CQ4,uz8,dO1,IQ4,RQ4,kG0,h2;var zu=S(()=>{b0();O2();v5();f2=z.lazy(()=>z.union([z.null(),z.string(),z.number(),z.boolean(),z.record(z.string(),f2),z.array(f2)])),HK=z.record(z.string(),z.record(z.string(),f2)).optional().describe("Additional provider-specific options. Outer record keyed by provider name, inner by option key"),pO1=z.object({type:z.literal("text"),text:z.string().describe("The text content"),providerOptions:HK}),HQ4=z.object({type:z.literal("text"),text:z.string().describe("The text content"),providerMetadata:z.any().optional().describe("Additional provider-specific metadata")}),FQ4=z.string().describe("File data as URL string"),cO1=z.object({type:z.literal("file"),filename:z.string().optional().describe("Optional filename of the file"),data:FQ4,mediaType:z.string().describe("IANA media type of the file (e.g., image/png, audio/mp3)"),providerOptions:HK}),$Q4=z.object({type:z.literal("file"),mediaType:z.string().describe("IANA media type of the file (e.g., image/png, audio/mp3)"),data:z.string().describe("Generated file data as base64 encoded string")}),VQ4=z.object({type:z.literal("reasoning"),text:z.string().describe("The reasoning text"),providerOptions:HK}),qQ4=z.object({type:z.literal("reasoning"),text:z.string().describe("The reasoning text"),providerMetadata:z.any().optional().describe("Additional provider-specific metadata")}),zQ4=z.object({type:z.literal("tool-call"),toolCallId:z.string().describe("ID of the tool call, used to match with tool result"),toolName:z.string().describe("Name of the tool being called"),input:z.string().describe("Arguments of the tool call (JSON-serializable object matching tool input schema)"),providerExecuted:z.boolean().optional().describe("Whether the tool call will be executed by the provider"),providerOptions:HK}),BQ4=z.object({type:z.literal("tool-call"),toolCallId:z.string().describe("ID of the tool call"),toolName:z.string().describe("Name of the tool being called"),input:z.string().describe("Stringified JSON object with the tool call arguments"),providerExecuted:z.boolean().optional().describe("Whether the tool call will be executed by the provider"),providerMetadata:z.any().optional().describe("Additional provider-specific metadata")}),UQ4=z.union([z.object({type:z.literal("text"),value:z.string()}),z.object({type:z.literal("json"),value:f2}),z.object({type:z.literal("error-text"),value:z.string()}),z.object({type:z.literal("error-json"),value:f2}),z.object({type:z.literal("content"),value:z.array(z.union([z.object({type:z.literal("text"),text:z.string().describe("Text content")}),z.object({type:z.literal("media"),data:z.string().describe("Base-64 encoded media data"),mediaType:z.string().describe("IANA media type")})]))})]),nO1=z.object({type:z.literal("tool-result"),toolCallId:z.string().describe("ID of the tool call that this result is associated with"),toolName:z.string().describe("Name of the tool that generated this result"),output:UQ4.describe("Result of the tool call"),result:z.unknown().describe("Unknown result of the tool call"),providerOptions:HK}),DQ4=z.object({type:z.literal("tool-result"),toolCallId:z.string().describe("ID of the tool call that this result is associated with"),toolName:z.string().describe("Name of the tool that generated this result"),result:z.any().describe("Result of the tool call (JSON-serializable)"),isError:z.boolean().optional().describe("Whether the result is an error or error message"),providerExecuted:z.boolean().optional().describe("Whether the tool result was generated by the provider"),providerMetadata:z.any().optional().describe("Additional provider-specific metadata")}),OQ4=z.union([z.object({type:z.literal("source"),sourceType:z.literal("url"),id:z.string().describe("The ID of the source"),url:z.string().describe("The URL of the source"),title:z.string().optional().describe("The title of the source"),providerMetadata:z.any().optional().describe("Additional provider-specific metadata")}),z.object({type:z.literal("source"),sourceType:z.literal("document"),id:z.string().describe("The ID of the source"),mediaType:z.string().describe("IANA media type of the document (e.g., application/pdf)"),title:z.string().describe("The title of the document"),filename:z.string().optional().describe("Optional filename of the document"),providerMetadata:z.any().optional().describe("Additional provider-specific metadata")})]),NQ4=z.object({role:z.literal("system"),content:z.string().describe("System message content"),providerOptions:HK}),LQ4=z.object({role:z.literal("user"),content:z.array(z.union([pO1,cO1])).describe("User message content parts (text or file)"),providerOptions:HK}),wQ4=z.object({role:z.literal("assistant"),content:z.array(z.union([pO1,cO1,VQ4,zQ4,nO1])).describe("Assistant message content parts (text, file, reasoning, tool-call, or tool-result)"),providerOptions:HK}),MQ4=z.object({role:z.literal("tool"),content:z.array(nO1).describe("Tool message content (tool results)"),providerOptions:HK}),AQ4=z.union([NQ4,LQ4,wQ4,MQ4]),PQ4=z.array(AQ4).describe("A list of messages forming the prompt"),TQ4=z.object({prompt:PQ4.describe("A language model prompt is a standardized prompt type (array of messages with roles: system, user, assistant, tool)"),maxOutputTokens:z.number().optional().describe("Maximum number of tokens to generate"),temperature:z.number().optional().describe("Temperature setting. The range depends on the provider and model"),topP:z.number().optional().describe("Nucleus sampling parameter"),topK:z.number().optional().describe("Only sample from the top K options for each subsequent token. Used to remove long tail low probability responses"),presencePenalty:z.number().optional().describe("Presence penalty setting. It affects the likelihood of the model to repeat information that is already in the prompt"),frequencyPenalty:z.number().optional().describe("Frequency penalty setting. It affects the likelihood of the model to repeatedly use the same words or phrases"),seed:z.number().optional().describe("The seed (integer) to use for random sampling. If set and supported by the model, calls will generate deterministic results"),stopSequences:z.array(z.string()).optional().describe("Stop sequences. If set, the model will stop generating text when one of the stop sequences is generated"),responseFormat:z.union([z.object({type:z.literal("text")}),z.object({type:z.literal("json"),schema:z.any().optional().describe("JSON schema that the generated output should conform to"),name:z.string().optional().describe("Name of output that should be generated"),description:z.string().optional().describe("Description of the output that should be generated")})]).optional().describe("Response format. The output can either be text or JSON. Default is text"),tools:z.array(z.any()).optional().describe("The tools that are available for the model"),toolChoice:z.any().optional().describe("Specifies how the tool should be selected. Defaults to 'auto'"),includeRawChunks:z.boolean().optional().describe("Include raw chunks in the stream. Only applicable for streaming calls"),abortSignal:z.any().optional().describe("Abort signal for cancelling the operation"),providerOptions:z.any().optional().describe("Additional provider-specific options")}),EQ4=z.object({content:z.array(z.union([HQ4,$Q4,qQ4,BQ4,DQ4,OQ4])).describe("Ordered content that the model has generated (text, tool-calls, reasoning, files, sources)"),finishReason:z.enum(["stop","length","content-filter","tool-calls","error","other","unknown"]).describe("Reason why generation stopped"),usage:z.looseObject({inputTokens:z.number().optional(),outputTokens:z.number().optional(),totalTokens:z.number().optional(),reasoningTokens:z.number().optional()}).describe("Usage information for the language model call"),providerMetadata:z.any().optional().describe("Additional provider-specific metadata"),request:z.object({body:z.any().optional().describe("Request HTTP body sent to the provider API")}).optional().describe("Optional request information for telemetry and debugging"),response:z.object({id:z.string().optional().describe("ID for the generated response"),timestamp:z.iso.datetime().optional().describe("Timestamp for the start of the generated response"),modelId:z.string().optional().describe("The ID of the response model that was used"),headers:z.record(z.string(),z.string()).optional().describe("Response headers"),body:z.any().optional().describe("Response HTTP body")}).optional().describe("Optional response information for telemetry and debugging"),warnings:z.array(z.any()).describe("Warnings for the call, e.g. unsupported settings")}),xz8=z.object({stream:z.any().describe("ReadableStream of LanguageModelV2StreamPart"),request:z.object({body:z.any().optional().describe("Request HTTP body sent to the provider API")}).optional().describe("Optional request information for telemetry and debugging"),response:z.object({headers:z.record(z.string(),z.string()).optional().describe("Response headers")}).optional().describe("Optional response data")}),CQ4=z.object({supportedUrls:z.record(z.string(),z.array(z.string())).describe("Supported URL patterns by media type for the provider")}),uz8=z.object({modelId:z.string().describe("The ID of the model"),logo:z.string().nullable(),description:z.string().nullable(),capabilities:z.array(z.string()),limits:z.object({contextWindow:z.number(),maxOutputTokens:z.number()}).nullable(),costs:z.object({input:z.number(),output:z.number()}).nullable(),provider:z.enum(["openai","anthropic","google","x-ai","deepseek","openai-compatible","openrouter"]).nullable()}),dO1=z.object({modelId:z.string().describe("The ID of the model"),callOptions:TQ4}),IQ4=KO.extend({logo:z.string().nullable(),description:z.string().nullable(),capabilities:z.array(z.string()),limits:z.object({contextWindow:z.number(),maxOutputTokens:z.number()}).nullable(),costs:z.object({input:z.number(),output:z.number()}).nullable(),provider:z.enum(["openai","anthropic","google","xai","deepseek","openai-compatible","openrouter"]).nullable()}),RQ4=HO("llm",IQ4,{readOnly:!0}),kG0=[{name:"LLM_METADATA",inputSchema:z.object({modelId:z.string().describe("The ID of the model")}),outputSchema:CQ4},{name:"LLM_DO_STREAM",inputSchema:dO1,streamable:!0},{name:"LLM_DO_GENERATE",inputSchema:dO1,outputSchema:EQ4},...RQ4],h2=Yq(kG0)});function FO(){return!1}function Bu(Y,X){return Y===aQ.DEV_ASSETS(X)}function $O(Y,X){let Q=Fa(X,Y),J=new Date().toISOString();return{id:Q.id??aQ.DEV_ASSETS(Y),title:Q.title,description:Q.description??null,icon:Q.icon??null,app_name:Q.app_name??null,app_id:Q.app_id??null,organization_id:Y,created_by:"system",created_at:J,updated_at:J,connection_type:Q.connection_type,connection_url:Q.connection_url??null,connection_token:null,connection_headers:null,oauth_config:null,configuration_state:null,configuration_scopes:null,metadata:Q.metadata??null,tools:jQ4,bindings:["OBJECT_STORAGE"],status:"active"}}var jQ4;var Uu=S(()=>{Vu();eY();b0();jQ4=y2.map((Y)=>({name:Y.name,description:`${Y.name} operation for local file storage`,inputSchema:z.toJSONSchema(Y.inputSchema),outputSchema:z.toJSONSchema(Y.outputSchema)}))});function kQ4(Y){let X=[],Q=0;while(Q<Y.length){let J=Y[Q];if(J==="%")X.push(".*");else if(J==="_")X.push(".");else if(/[.*+?^${}()|[\]\\]/.test(J))X.push("\\"+J);else X.push(J);Q++}return X.join("")}function u3(Y){return typeof Y==="string"||typeof Y==="number"}function Du(Y,X){if("conditions"in X){let{operator:Z,conditions:H}=X;switch(Z){case"and":return H.every((F)=>Du(Y,F));case"or":return H.some((F)=>Du(Y,F));case"not":return!H.every((F)=>Du(Y,F));default:return!0}}let{field:Q,operator:J,value:G}=X,K=Q.join("."),W=vG0(Y,K);switch(J){case"eq":return W===G;case"gt":return u3(W)&&u3(G)&&W>G;case"gte":return u3(W)&&u3(G)&&W>=G;case"lt":return u3(W)&&u3(G)&&W<G;case"lte":return u3(W)&&u3(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=kQ4(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 vG0(Y,X){let Q=X.split("."),J=Y;for(let G of Q){if(J==null||typeof J!=="object")return;J=J[G]}return J}function vQ4(Y,X){return[...Y].sort((Q,J)=>{for(let G of X){let K=G.field.join("."),W=vG0(Q,K),Z=vG0(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 SQ4,_Q4,yQ4,_G0;var iO1=S(()=>{qu();lO1();v5();zu();Vu();eY();b0();k1();Uu();XK();SQ4={LLM:kG0,ASSISTANTS:mO1,OBJECT_STORAGE:y2};_Q4=ZK.extend({binding:z.union([z.object({}).passthrough(),z.string()]).optional(),include_virtual:z.boolean().optional().describe("Whether to include VIRTUAL connections in the results. Defaults to false.")}),yQ4=KK(kX),_G0=f0({name:"COLLECTION_CONNECTIONS_LIST",description:"List all connections in the organization with filtering, sorting, and pagination",inputSchema:_Q4,outputSchema:yQ4,handler:async(Y,X)=>{await X.access.check();let Q=z1(X),J=Y.binding?typeof Y.binding==="string"?(()=>{let q=SQ4[Y.binding.toUpperCase()];if(!q)throw Error(`Unknown binding: ${Y.binding}`);return q})():Y.binding:void 0,G=J?$u(J):void 0,K=await X.storage.connections.list(Q.id,{includeVirtual:Y.include_virtual??!1});if(FO()){let q=DJ(),B=aQ.DEV_ASSETS(Q.id);if(!K.some((D)=>D.id===B)){let D=$O(Q.id,q);K.unshift(D)}}let W=G?await Promise.all(K.map(async(q)=>{if(!q.tools||q.tools.length===0)return null;return G.isImplementedBy(q.tools.map((D)=>({name:D.name,inputSchema:D.inputSchema,outputSchema:D.outputSchema})))?q:null})).then((q)=>q.filter((B)=>B!==null)):K;if(Y.where)W=W.filter((q)=>Du(q,Y.where));if(Y.orderBy&&Y.orderBy.length>0)W=vQ4(W,Y.orderBy);let Z=W.length,H=Y.offset??0,F=Y.limit??100,$=W.slice(H,H+F),V=H+F<Z;return{items:$,totalCount:Z,hasMore:V}}})});var fQ4,yG0;var aO1=S(()=>{v5();k1();Uu();XK();fQ4=L2(kX),yG0=f0({name:"COLLECTION_CONNECTIONS_GET",description:"Get connection details by ID",inputSchema:N2,outputSchema:fQ4,handler:async(Y,X)=>{let Q=z1(X);if(await X.access.check(),FO()&&Bu(Y.id,Q.id))return{item:$O(Q.id,DJ())};let J=await X.storage.connections.findById(Y.id);if(!J||J.organization_id!==Q.id)return{item:null};return{item:J}}})});var Ou=(Y,X)=>{if(X===null||X===void 0)return;let Q=Y.replace(/\[(\w+)\]/g,".$1").split(".").filter(Boolean),J=X;for(let G of Q){if(J===null||J===void 0||typeof J!=="object")return;J=J[G]}return J};function rO1(Y){let X=Y.split("::");if(X.length!==2||!X[0]||!X[1])throw Error(`Invalid scope format: ${Y}. Expected format: "KEY::SCOPE"`);return X}function hQ4(Y){let X=Y.split("::");if(X.length!==2||!X[0]||!X[1])return null;return X}function bQ4(Y){if(typeof Y==="object"&&Y!==null&&"value"in Y){let X=Y.value;if(typeof X==="string")return X}return null}function fG0(Y,X){let Q={};if(!Y||!X)return Q;for(let J of X){if(J==="*"){Q["*"]=["*"];continue}let G=hQ4(J);if(!G)continue;let[K,W]=G,Z=Ou(K,Y),H=bQ4(Z);if(H){if(!Q[H])Q[H]=[];Q[H].push(W)}}return Q}function oO1(Y,X){let Q=fG0(Y,X);return new Set(Object.keys(Q).filter((J)=>J!=="*"))}var hG0=()=>{};class FK{db;vault;constructor(Y,X){this.db=Y;this.vault=X}async get(Y){let X=await this.db.selectFrom("downstream_tokens").selectAll().where("connectionId","=",Y).executeTakeFirst();if(!X)return null;return this.decryptToken(X)}async upsert(Y){let X=new Date().toISOString(),Q=await this.vault.encrypt(Y.accessToken),J=Y.refreshToken?await this.vault.encrypt(Y.refreshToken):null,G=Y.clientSecret?await this.vault.encrypt(Y.clientSecret):null;return await this.db.transaction().execute(async(K)=>{let W=await K.selectFrom("downstream_tokens").select(["id","createdAt"]).where("connectionId","=",Y.connectionId).executeTakeFirst();if(W)return await K.updateTable("downstream_tokens").set({accessToken:Q,refreshToken:J,scope:Y.scope,expiresAt:Y.expiresAt?.toISOString()??null,clientId:Y.clientId,clientSecret:G,tokenEndpoint:Y.tokenEndpoint,updatedAt:X}).where("id","=",W.id).execute(),{id:W.id,connectionId:Y.connectionId,accessToken:Y.accessToken,refreshToken:Y.refreshToken,scope:Y.scope,expiresAt:Y.expiresAt,createdAt:W.createdAt,updatedAt:X,clientId:Y.clientId,clientSecret:Y.clientSecret,tokenEndpoint:Y.tokenEndpoint};let Z=y4("dtok");return await K.insertInto("downstream_tokens").values({id:Z,connectionId:Y.connectionId,accessToken:Q,refreshToken:J,scope:Y.scope,expiresAt:Y.expiresAt?.toISOString()??null,clientId:Y.clientId,clientSecret:G,tokenEndpoint:Y.tokenEndpoint,createdAt:X,updatedAt:X}).execute(),{id:Z,connectionId:Y.connectionId,accessToken:Y.accessToken,refreshToken:Y.refreshToken,scope:Y.scope,expiresAt:Y.expiresAt,createdAt:X,updatedAt:X,clientId:Y.clientId,clientSecret:Y.clientSecret,tokenEndpoint:Y.tokenEndpoint}})}async delete(Y){await this.db.deleteFrom("downstream_tokens").where("connectionId","=",Y).execute()}isExpired(Y,X=0){if(!Y.expiresAt)return!1;let J=(Y.expiresAt instanceof Date?Y.expiresAt:new Date(Y.expiresAt)).getTime();if(Number.isNaN(J))return!0;return J-X<Date.now()}async decryptToken(Y){let X=await this.vault.decrypt(Y.accessToken),Q=Y.refreshToken?await this.vault.decrypt(Y.refreshToken):null,J=Y.clientSecret?await this.vault.decrypt(Y.clientSecret):null;return{id:Y.id,connectionId:Y.connectionId,accessToken:X,refreshToken:Q,scope:Y.scope,expiresAt:Y.expiresAt,createdAt:Y.createdAt,updatedAt:Y.updatedAt,clientId:Y.clientId,clientSecret:J,tokenEndpoint:Y.tokenEndpoint}}}var Nu=S(()=>{k5()});async function gQ4(Y,X,Q,J){for(let K of X){if(K==="*")continue;let[W]=rO1(K),Z=Ou(W,Y);if(Z===void 0||Z===null)throw Error(`Scope references key "${W}" but it's not present in state`)}let G=oO1(Y,X);for(let K of G){if(K.endsWith("_self"))continue;let W=await J.storage.connections.findById(K);if(!W||W.organization_id!==Q)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 xQ4,uQ4,bG0;var sO1=S(()=>{hG0();Nu();b0();k1();ax();XK();xQ4=z.object({id:z.string().describe("ID of the connection to update"),data:Hw.describe("Partial connection data to update")}),uQ4=z.object({item:kX.describe("The updated connection entity")});bG0=f0({name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update an existing MCP connection in the organization",inputSchema:xQ4,outputSchema:uQ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to update connection");let{id:G,data:K}=Y,W=await X.storage.connections.findById(G);if(!W||W.organization_id!==Q.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 A=fF(H);if(!A)throw Error("VIRTUAL connection requires connection_url in format: virtual://$virtual_mcp_id");let I=await X.storage.virtualMcps.findById(A);if(!I)throw Error(`Virtual MCP not found: ${A}`);if(I.organization_id!==Q.id)throw Error("Virtual MCP does not belong to the current organization");H=hF(A)}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 gQ4(F,$,Q.id,X)}let V=K.connection_token??W.connection_token;if(!V)try{let I=await new FK(X.db,X.vault).get(G);if(I?.accessToken)V=I.accessToken}catch{}let q=await XO({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),B=q?.length?q:null,D={...K,connection_url:H,tools:B,configuration_state:F,configuration_scopes:$,updated_by:J},O=await X.storage.connections.update(G,D);if((K.configuration_state!==void 0||K.configuration_scopes!==void 0)&&F&&$)try{let L=[];try{const A=PK(L,await X.createMCPProxy(G),1);await A.callTool({name:"ON_MCP_CONFIGURATION",arguments:{state:F,scopes:$}});await A.close().catch(console.error)}catch(w){var R=w,T=1}finally{var P=c3(L,R,T);P&&await P}}catch(A){console.error("Failed to invoke ON_MCP_CONFIGURATION callback",A)}return{item:O}}})});var xG0;var tO1=S(()=>{v5();k1();XK();xG0=f0({name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete a connection",inputSchema:w2,outputSchema:M2(kX),handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.connections.findById(Y.id);if(!J)throw Error(`Connection not found: ${Y.id}`);if(J.organization_id!==Q.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");return await X.storage.connections.delete(Y.id),{item:J}}})});var uG0;var eO1=S(()=>{b0();k1();uG0=f0({name:"CONNECTION_TEST",description:"Test connection health and latency",inputSchema:z.object({id:z.string()}),outputSchema:z.object({id:z.string(),healthy:z.boolean(),latencyMs:z.number()}),handler:async(Y,X)=>{let Q=z1(X);await X.access.check();let J=await X.storage.connections.findById(Y.id);if(!J||J.organization_id!==Q.id)throw Error("Connection not found");let G=await X.storage.connections.testConnection(Y.id);return{id:Y.id,...G}}})});var YN1=S(()=>{DO1();iO1();aO1();sO1();tO1();eO1()});import{sql as $4}from"kysely";function XN1(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 dQ4(Y,X){let Q=Y;for(let G=X.length;G>=1;G--){let K=`$${G}`;if(Q.includes(K))Q=Q.replaceAll(K,XN1(X[G-1]))}let J=[];for(let G=0;G<Q.length;G++)if(Q[G]==="?")J.push(G);for(let G=Math.min(J.length,X.length)-1;G>=0;G--){let K=J[G],W=XN1(X[G]);Q=Q.slice(0,K)+W+Q.slice(K+1)}return Q}function QN1(Y){return Y.replace(/-/g,"_")}function cQ4(Y){return`app_${QN1(Y)}`}function nQ4(Y){return`app_role_${QN1(Y)}`}function iQ4(Y){if(Y instanceof Error){let X=Y.message.toLowerCase(),Q=Y.code;return Q==="3F000"||Q==="42704"||Q==="22023"||X.includes("schema")&&X.includes("does not exist")||X.includes("role")&&X.includes("does not exist")}return!1}async function aQ4(Y,X,Q){if(await $4`CREATE SCHEMA IF NOT EXISTS ${$4.id(X)}`.execute(Y),!(await $4`
1195
1195
  SELECT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = ${Q}) as exists
1196
- `.execute(Y)).rows[0]?.exists)await $4`CREATE ROLE ${$4.id(Q)} NOLOGIN`.execute(Y);await $4`GRANT ${$4.id(Q)} TO CURRENT_USER`.execute(Y),await $4`GRANT USAGE, CREATE ON SCHEMA ${$4.id(X)} TO ${$4.id(Q)}`.execute(Y),await $4`GRANT ALL ON ALL TABLES IN SCHEMA ${$4.id(X)} TO ${$4.id(Q)}`.execute(Y),await $4`GRANT ALL ON ALL SEQUENCES IN SCHEMA ${$4.id(X)} TO ${$4.id(Q)}`.execute(Y),await $4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${$4.id(X)} GRANT ALL ON TABLES TO ${$4.id(Q)}`.execute(Y),await $4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${$4.id(X)} GRANT ALL ON SEQUENCES TO ${$4.id(Q)}`.execute(Y),await $4`REVOKE ALL ON SCHEMA public FROM ${$4.id(Q)}`.execute(Y)}async function rQ4(Y,X,Q,J){try{return await Y.transaction().execute(async(G)=>{return await $4`SET LOCAL ROLE ${$4.id(Q)}`.execute(G),await $4`SET LOCAL search_path TO ${$4.id(X)}`.execute(G),await $4.raw(J).execute(G)})}catch(G){if(iQ4(G))return await aQ4(Y,X,Q),await Y.transaction().execute(async(K)=>{return await $4`SET LOCAL ROLE ${$4.id(Q)}`.execute(K),await $4`SET LOCAL search_path TO ${$4.id(X)}`.execute(K),await $4.raw(J).execute(K)});throw G}}var lQ4,pQ4,JN1;var GN1=S(()=>{b0();k1();lQ4=z.object({results:z.array(z.unknown()).optional(),success:z.boolean().optional()});pQ4=z.object({sql:z.string().describe("The SQL query to run"),params:z.array(z.any()).describe("The parameters to pass to the SQL query").optional()});JN1=f0({name:"DATABASES_RUN_SQL",description:"Run a SQL query against the database",inputSchema:pQ4,outputSchema:z.object({result:z.array(lQ4)}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=dQ4(Y.sql,Y.params||[]);if(!X.connectionId)throw Error("Connection context required for database access");let J=cQ4(X.connectionId),G=nQ4(X.connectionId);return{result:[{results:(await rQ4(X.db,J,G,Q)).rows,success:!0}]}}})});var WN1,sQ4,ZN1;var $K=S(()=>{b0();qu();WN1=z.object({connectionId:z.string().optional().describe("Filter subscriptions by connection ID (optional)")}),sQ4=z.object({id:z.string().describe("Subscription ID"),connectionId:z.string().describe("Subscriber connection ID"),eventType:z.string().describe("Event type pattern"),publisher:z.string().nullable().describe("Publisher connection filter (null = all publishers)"),filter:z.string().nullable().describe("JSONPath filter expression"),enabled:z.boolean().describe("Whether subscription is enabled"),createdAt:z.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:z.string().datetime().describe("Updated timestamp (ISO 8601)")}),ZN1=z.object({subscriptions:z.array(sQ4).describe("List of subscriptions")})});var gG0;var KN1=S(()=>{k1();$K();gG0=f0({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.",inputSchema:A2,outputSchema:P2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to publish events. Use a connection-scoped token.");let G=await X.eventBus.publish(Q.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 mG0;var HN1=S(()=>{k1();$K();mG0=f0({name:"EVENT_SUBSCRIBE",description:"Subscribe to events of a specific type. The subscriber is automatically set to the caller's connection.",inputSchema:T2,outputSchema:E2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to subscribe. Use a connection-scoped token.");let G=await X.eventBus.subscribe(Q.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 lG0;var FN1=S(()=>{k1();$K();lG0=f0({name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events by removing a subscription.",inputSchema:R2,outputSchema:j2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to unsubscribe. Use a connection-scoped token.");let G=await X.eventBus.getSubscription(Q.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 X.eventBus.unsubscribe(Q.id,Y.subscriptionId)).success,subscriptionId:Y.subscriptionId}}})});var dG0;var $N1=S(()=>{k1();$K();dG0=f0({name:"EVENT_CANCEL",description:"Cancel a recurring event to stop future deliveries. Only the publisher can cancel their own events.",inputSchema:S2,outputSchema:k2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to cancel events. Use a connection-scoped token.");if(!await X.eventBus.getEvent(Q.id,Y.eventId))throw Error(`Event not found: ${Y.eventId}`);if(!(await X.eventBus.cancelEvent(Q.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 pG0;var VN1=S(()=>{k1();$K();pG0=f0({name:"EVENT_ACK",description:"Acknowledge delivery of an event. Call after successfully processing an event received via ON_EVENTS with retryAfter.",inputSchema:v2,outputSchema:_2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to acknowledge events. Use a connection-scoped token.");if(!(await X.eventBus.ackEvent(Q.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 cG0;var qN1=S(()=>{k1();$K();cG0=f0({name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions, optionally filtered by connection ID.",inputSchema:WN1,outputSchema:ZN1,handler:async(Y,X)=>{g0(X);let Q=z1(X);return await X.access.check(),{subscriptions:(await X.eventBus.listSubscriptions(Q.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 nG0;var zN1=S(()=>{k1();$K();nG0=f0({name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state. Creates new, deletes removed, updates changed filters. Subscriptions are identified by (eventType, publisher).",inputSchema:C2,outputSchema:I2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to sync subscriptions. Use a connection-scoped token.");let G=await X.eventBus.syncSubscriptions(Q.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 BN1=S(()=>{KN1();HN1();FN1();$N1();VN1();qN1();zN1();$K()});var VO=S(()=>{RS()});var eQ4,YJ4,iG0;var UN1=S(()=>{b0();k1();VO();eQ4=z.object({data:$w.describe("Data for the new virtual MCP")}),YJ4=z.object({item:rQ.describe("The created virtual MCP entity")}),iG0=f0({name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create a new MCP virtual MCP in the organization",inputSchema:eQ4,outputSchema:YJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to create virtual MCP");return{item:await X.storage.virtualMcps.create(Q.id,J,Y.data)}}})});function XJ4(Y){let X=[],Q=0;while(Q<Y.length){let J=Y[Q];if(J==="%")X.push(".*");else if(J==="_")X.push(".");else if(/[.*+?^${}()|[\]\\]/.test(J))X.push("\\"+J);else X.push(J);Q++}return X.join("")}function g3(Y){return typeof Y==="string"||typeof Y==="number"}function aG0(Y,X){let Q=X.split("."),J=Y;for(let G of Q){if(J==null||typeof J!=="object")return;J=J[G]}return J}function QJ4(Y,X){return Y.connections.some((Q)=>Q.connection_id===X)}function Lu(Y,X){if("conditions"in X){let{operator:Z,conditions:H}=X;switch(Z){case"and":return H.every((F)=>Lu(Y,F));case"or":return H.some((F)=>Lu(Y,F));case"not":return!H.every((F)=>Lu(Y,F));default:return!0}}let{field:Q,operator:J,value:G}=X,K=Q.join(".");if(K==="connection_id"){if(J!=="eq"||typeof G!=="string")return!1;return QJ4(Y,G)}let W=aG0(Y,K);switch(J){case"eq":return W===G;case"gt":return g3(W)&&g3(G)&&W>G;case"gte":return g3(W)&&g3(G)&&W>=G;case"lt":return g3(W)&&g3(G)&&W<G;case"lte":return g3(W)&&g3(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=XJ4(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 JJ4(Y,X){return[...Y].sort((Q,J)=>{for(let G of X){let K=G.field.join("."),W=aG0(Q,K),Z=aG0(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 GJ4,WJ4,rG0;var DN1=S(()=>{v5();k1();VO();GJ4=ZK,WJ4=KK(rQ),rG0=f0({name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List all MCP virtual MCPs in the organization",inputSchema:GJ4,outputSchema:WJ4,handler:async(Y,X)=>{await X.access.check();let Q=z1(X),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 X.storage.virtualMcps.listByConnectionId(Q.id,J):await X.storage.virtualMcps.list(Q.id);if(Y.where)K=K.filter((V)=>Lu(V,Y.where));if(Y.orderBy&&Y.orderBy.length>0)K=JJ4(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 ZJ4,KJ4,oG0;var ON1=S(()=>{b0();k1();VO();ZJ4=z.object({id:z.string().describe("ID of the virtual MCP to retrieve")}),KJ4=z.object({item:rQ.nullable().describe("The retrieved virtual MCP, or null if not found")}),oG0=f0({name:"COLLECTION_VIRTUAL_MCP_GET",description:"Get an MCP virtual MCP by ID",inputSchema:ZJ4,outputSchema:KJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.id);if(J&&J.organization_id!==Q.id)return{item:null};if(!J)return{item:null};return{item:J}}})});var HJ4,FJ4,sG0;var NN1=S(()=>{b0();k1();VO();HJ4=z.object({id:z.string().describe("ID of the virtual MCP to update"),data:Vw.describe("Partial virtual MCP data to update")}),FJ4=z.object({item:rQ.describe("The updated virtual MCP entity")}),sG0=f0({name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update an MCP virtual MCP",inputSchema:HJ4,outputSchema:FJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to update virtual MCP");let G=await X.storage.virtualMcps.findById(Y.id);if(!G)throw Error(`Virtual MCP not found: ${Y.id}`);if(G.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.id}`);return{item:await X.storage.virtualMcps.update(Y.id,J,Y.data)}}})});var $J4,VJ4,tG0;var LN1=S(()=>{b0();k1();VO();$J4=z.object({id:z.string().describe("ID of the virtual MCP to delete")}),VJ4=z.object({item:rQ.describe("The deleted virtual MCP entity")}),tG0=f0({name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete an MCP virtual MCP",inputSchema:$J4,outputSchema:VJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.id);if(!J)throw Error(`Virtual MCP not found: ${Y.id}`);if(J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.id}`);return await X.storage.virtualMcps.delete(Y.id),{item:J}}})});var wN1=S(()=>{UN1();DN1();ON1();NN1();LN1()});function m3(Y){if(!Y?._meta)return!1;return typeof Y._meta["mcp.mesh"]?.["tool.fn"]==="string"}function PN1(Y){return Y._meta["mcp.mesh"]["tool.fn"]}function b2(Y,X,Q,J){return{id:Y,name:X.name,description:X.description,inputSchema:X.inputSchema,outputSchema:X.outputSchema,annotations:X.annotations,code:X._meta["mcp.mesh"]["tool.fn"],connection_dependencies:X._meta.connectionDependencies??[],created_at:Q,updated_at:J}}var eG0,FD8,wW,MN1,AN1;var VK=S(()=>{b0();eG0=z.object({title:z.string().optional(),readOnlyHint:z.boolean().optional(),destructiveHint:z.boolean().optional(),idempotentHint:z.boolean().optional(),openWorldHint:z.boolean().optional()}),FD8=z.object({"tool.fn":z.string().describe("JavaScript ES module code that exports a default async function")}),wW=z.object({id:z.string().describe("Unique identifier for the virtual tool (auto-generated)"),name:z.string().min(1).max(255).describe("Tool name (must be unique within the Virtual MCP)"),description:z.string().optional().describe("Human-readable description of what the tool does"),inputSchema:z.record(z.string(),z.unknown()).describe("JSON Schema defining the tool's input parameters"),outputSchema:z.record(z.string(),z.unknown()).optional().describe("JSON Schema defining the tool's output (optional)"),annotations:eG0.optional().describe("MCP tool annotations"),code:z.string().describe("JavaScript ES module code. Must export default an async function: export default async (tools, args) => { ... }"),connection_dependencies:z.array(z.string()).describe("Connection IDs that this tool depends on (specified by the creator)"),created_at:z.string().describe("When the virtual tool was created"),updated_at:z.string().describe("When the virtual tool was last updated")}),MN1=z.object({name:z.string().min(1).max(255).describe("Tool name (must be unique within the Virtual MCP)"),description:z.string().optional().describe("Human-readable description"),inputSchema:z.record(z.string(),z.unknown()).describe("JSON Schema defining the tool's input parameters"),outputSchema:z.record(z.string(),z.unknown()).optional().describe("JSON Schema for output"),annotations:eG0.optional().describe("MCP tool annotations"),code:z.string().describe("JavaScript ES module code. Must export default an async function: export default async (tools, args) => { ... }"),connection_dependencies:z.array(z.string()).optional().describe("Connection IDs that this tool depends on. Creates indirect aggregations to prevent deletion of referenced connections.")}),AN1=z.object({name:z.string().min(1).max(255).optional().describe("New tool name"),description:z.string().nullable().optional().describe("New description (null to clear)"),inputSchema:z.record(z.string(),z.unknown()).optional().describe("New input schema"),outputSchema:z.record(z.string(),z.unknown()).nullable().optional().describe("New output schema (null to clear)"),annotations:eG0.nullable().optional().describe("New annotations (null to clear)"),code:z.string().optional().describe("New JavaScript code"),connection_dependencies:z.array(z.string()).optional().describe("Connection IDs that this tool depends on. Replaces existing dependencies if provided.")})});var zJ4,BJ4,Y70;var TN1=S(()=>{b0();k1();VK();zJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP to add the tool to"),data:MN1.describe("Virtual tool data")}),BJ4=z.object({item:wW.describe("The created virtual tool")}),Y70=f0({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.",inputSchema:zJ4,outputSchema:BJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=Y.data.connection_dependencies??[];return{item:await X.storage.virtualMcps.createVirtualTool(Y.virtual_mcp_id,Y.data,G)}}})});var UJ4,DJ4,X70;var EN1=S(()=>{b0();k1();VK();UJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP to list tools for"),limit:z.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:z.number().int().min(0).optional().describe("Number of items to skip")}),DJ4=z.object({items:z.array(wW).describe("Array of virtual tools"),totalCount:z.number().int().min(0).optional().describe("Total number of virtual tools"),hasMore:z.boolean().optional().describe("Whether there are more items available")}),X70=f0({name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List all virtual tools for a Virtual MCP",inputSchema:UJ4,outputSchema:DJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)return{items:[],totalCount:0,hasMore:!1};let G=await X.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 OJ4,NJ4,Q70;var CN1=S(()=>{b0();k1();VK();OJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP"),name:z.string().describe("Name of the virtual tool to retrieve")}),NJ4=z.object({item:wW.nullable().describe("The retrieved virtual tool, or null if not found")}),Q70=f0({name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"Get a virtual tool by name from a Virtual MCP",inputSchema:OJ4,outputSchema:NJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)return{item:null};return{item:await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name)}}})});var LJ4,wJ4,J70;var IN1=S(()=>{b0();k1();VK();LJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP"),name:z.string().describe("Current name of the virtual tool to update"),data:AN1.describe("Partial virtual tool data to update")}),wJ4=z.object({item:wW.describe("The updated virtual tool")}),J70=f0({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.",inputSchema:LJ4,outputSchema:wJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);if(!await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name))throw Error(`Virtual tool not found: ${Y.name}`);let K=Y.data.connection_dependencies;return{item:await X.storage.virtualMcps.updateVirtualTool(Y.virtual_mcp_id,Y.name,Y.data,K)}}})});var MJ4,AJ4,G70;var RN1=S(()=>{b0();k1();VK();MJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP"),name:z.string().describe("Name of the virtual tool to delete")}),AJ4=z.object({item:wW.describe("The deleted virtual tool")}),G70=f0({name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete a virtual tool from a Virtual MCP",inputSchema:MJ4,outputSchema:AJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name);if(!G)throw Error(`Virtual tool not found: ${Y.name}`);return await X.storage.virtualMcps.deleteVirtualTool(Y.virtual_mcp_id,Y.name),{item:G}}})});var jN1=S(()=>{TN1();EN1();CN1();IN1();RN1()});var TJ4,W70;var SN1=S(()=>{k1();b0();TJ4=z.object({id:z.string().optional().describe("Unique log identifier"),organizationId:z.string().describe("Organization ID"),connectionId:z.string().describe("Connection ID"),connectionTitle:z.string().describe("Connection display name"),toolName:z.string().describe("Name of the tool that was called"),input:z.record(z.string(),z.unknown()).describe("Redacted tool input"),output:z.record(z.string(),z.unknown()).describe("Redacted tool output"),isError:z.boolean().describe("Whether the call resulted in an error"),errorMessage:z.string().nullish().describe("Error message if applicable"),durationMs:z.number().describe("Call duration in milliseconds"),timestamp:z.string().describe("ISO 8601 timestamp of the call"),userId:z.string().nullish().describe("User who triggered the call"),requestId:z.string().describe("Unique request identifier"),userAgent:z.string().nullish().describe("Client identifier (x-mesh-client header)"),virtualMcpId:z.string().nullish().describe("Virtual MCP (Agent) ID if routed through an agent"),properties:z.record(z.string(),z.string()).nullish().describe("Custom key-value metadata attached to the log")}),W70=f0({name:"MONITORING_LOGS_LIST",description:"List monitoring logs for tool calls in the organization",inputSchema:z.object({connectionId:z.string().optional().describe("Filter by connection ID"),excludeConnectionIds:z.array(z.string()).optional().describe("Exclude logs from these connection IDs (e.g. system connections)"),virtualMcpId:z.string().optional().describe("Filter by Virtual MCP (Agent) ID"),toolName:z.string().optional().describe("Filter by tool name"),isError:z.boolean().optional().describe("Filter by error status"),startDate:z.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:z.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)"),limit:z.number().default(20).describe("Maximum number of results"),offset:z.number().default(0).describe("Offset for pagination"),properties:z.record(z.string(),z.string()).optional().describe("Filter by exact property key=value matches"),propertyKeys:z.array(z.string()).optional().describe("Filter by logs that have these property keys"),propertyPatterns:z.record(z.string(),z.string()).optional().describe("Filter by property value patterns (SQL LIKE, use % as wildcard)"),propertyInValues:z.record(z.string(),z.string()).optional().describe("Filter by exact match within comma-separated values (e.g., user_tags in 'Engineering')")}),outputSchema:z.object({logs:z.array(TJ4).describe("Array of monitoring logs"),total:z.number().describe("Total number of logs matching filters"),offset:z.number().describe("Current offset for pagination"),limit:z.number().describe("Current limit for pagination")}),handler:async(Y,X)=>{let Q=z1(X),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:Q.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 X.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 Z70;var kN1=S(()=>{k1();b0();Z70=f0({name:"MONITORING_STATS",description:"Get aggregated statistics for tool call monitoring",inputSchema:z.object({startDate:z.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:z.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)")}),outputSchema:z.object({totalCalls:z.number().describe("Total number of tool calls"),errorRate:z.number().describe("Error rate as a decimal (0 to 1)"),avgDurationMs:z.number().describe("Average call duration in milliseconds"),errorRatePercent:z.string().describe("Error rate as a percentage string")}),handler:async(Y,X)=>{let J={organizationId:z1(X).id,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0},G=await X.storage.monitoring.getStats(J);return{...G,errorRatePercent:(G.errorRate*100).toFixed(2)}}})});var vN1=S(()=>{SN1();kN1()});var K70;var _N1=S(()=>{b0();k1();K70=f0({name:"ORGANIZATION_CREATE",description:"Create a new organization",inputSchema:z.object({slug:z.string().min(1).max(50).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens"),name:z.string().min(1).max(255),description:z.string().optional()}),outputSchema:z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),members:z.array(z.any()).optional()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=g8(X);if(!Q)throw Error("User ID required to create organization");let J=await X.boundAuth.organization.create({name:Y.name,slug:Y.slug,metadata:Y.description?{description:Y.description}:void 0,userId:Q});if(!J)throw Error("Failed to create organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var H70;var yN1=S(()=>{b0();k1();H70=f0({name:"ORGANIZATION_LIST",description:"List all organizations user has access to",inputSchema:z.object({userId:z.string().optional()}),outputSchema:z.object({organizations:z.array(z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=g8(X),J=Y.userId||Q;if(!J)throw Error("User ID required to list organizations");return{organizations:(await X.boundAuth.organization.list(J)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt}))}}})});var F70;var fN1=S(()=>{b0();k1();F70=f0({name:"ORGANIZATION_GET",description:"Get organization details by slug or ID",inputSchema:z.object({}),outputSchema:z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),members:z.array(z.any()).optional(),invitations:z.array(z.any()).optional()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=await X.boundAuth.organization.get();if(!Q)throw Error("No active organization found");let J=new Date,G=Q.invitations?.filter((K)=>new Date(K.expiresAt)>J);return{...Q,invitations:G,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt}}})});var $70;var hN1=S(()=>{b0();k1();$70=f0({name:"ORGANIZATION_UPDATE",description:"Update an existing organization",inputSchema:z.object({id:z.string(),slug:z.string().min(1).max(50).regex(/^[a-z0-9-]+$/).optional(),name:z.string().min(1).max(255).optional(),description:z.string().optional()}),outputSchema:z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q={};if(Y.name)Q.name=Y.name;if(Y.slug)Q.slug=Y.slug;if(Y.description)Q.metadata={description:Y.description};let J=await X.boundAuth.organization.update({organizationId:Y.id,data:Q});if(!J)throw Error("Failed to update organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var V70;var bN1=S(()=>{b0();k1();V70=f0({name:"ORGANIZATION_DELETE",description:"Delete an organization",inputSchema:z.object({id:z.string()}),outputSchema:z.object({success:z.boolean(),id:z.string()}),handler:async(Y,X)=>{return g0(X),await X.access.check(),await X.boundAuth.organization.delete(Y.id),{success:!0,id:Y.id}}})});var x2;var q70=S(()=>{b0();x2=z.object({title:z.string(),url:z.string(),icon:z.string()})});var z70;var xN1=S(()=>{b0();k1();q70();z70=f0({name:"ORGANIZATION_SETTINGS_GET",description:"Get organization-level settings",inputSchema:z.object({}),outputSchema:z.object({organizationId:z.string(),sidebar_items:z.array(x2).nullable().optional(),enabled_plugins:z.array(z.string()).nullable().optional(),createdAt:z.string().datetime().optional().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().optional().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.storage.organizationSettings.get(Q);if(!J)return{organizationId:Q};return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var B70;var uN1=S(()=>{b0();k1();q70();B70=f0({name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization-level settings",inputSchema:z.object({organizationId:z.string(),sidebar_items:z.array(x2).optional(),enabled_plugins:z.array(z.string()).optional()}),outputSchema:z.object({organizationId:z.string(),sidebar_items:z.array(x2).nullable().optional(),enabled_plugins:z.array(z.string()).nullable().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{if(g0(X),await X.access.check(),X.organization&&X.organization.id!==Y.organizationId)throw Error("Cannot update settings for a different organization");let Q=await X.storage.organizationSettings.upsert(Y.organizationId,{sidebar_items:Y.sidebar_items,enabled_plugins:Y.enabled_plugins});return{...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}}})});var U70;var gN1=S(()=>{b0();k1();U70=f0({name:"ORGANIZATION_MEMBER_ADD",description:"Add a member to an organization",inputSchema:z.object({organizationId:z.string().optional(),userId:z.string(),role:z.array(z.string())}),outputSchema:z.object({id:z.string(),organizationId:z.string(),userId:z.string(),role:z.union([z.string(),z.array(z.string())]),createdAt:z.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=Y.organizationId||X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.boundAuth.organization.addMember({organizationId:Q,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 D70;var mN1=S(()=>{b0();k1();D70=f0({name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove a member from an organization",inputSchema:z.object({organizationId:z.string().optional(),memberIdOrEmail:z.string()}),outputSchema:z.object({success:z.boolean(),memberIdOrEmail:z.string()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=Y.organizationId||X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");return await X.boundAuth.organization.removeMember({organizationId:Q,memberIdOrEmail:Y.memberIdOrEmail}),{success:!0,memberIdOrEmail:Y.memberIdOrEmail}}})});var O70;var lN1=S(()=>{b0();k1();O70=f0({name:"ORGANIZATION_MEMBER_LIST",description:"List all members in an organization",inputSchema:z.object({limit:z.number().optional(),offset:z.number().optional()}),outputSchema:z.object({members:z.array(z.object({id:z.string(),organizationId:z.string(),userId:z.string(),role:z.string(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),user:z.object({id:z.string(),name:z.string(),email:z.string(),image:z.string().optional()}).optional()}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.boundAuth.organization.listMembers({organizationId:Q,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 N70;var dN1=S(()=>{b0();k1();N70=f0({name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update a member's role in an organization",inputSchema:z.object({organizationId:z.string().optional(),memberId:z.string(),role:z.array(z.string())}),outputSchema:z.object({id:z.string(),organizationId:z.string(),userId:z.string(),role:z.union([z.literal("admin"),z.literal("member"),z.literal("owner")]),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),user:z.object({email:z.string(),name:z.string(),image:z.string().optional()})}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=Y.organizationId||X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.boundAuth.organization.updateMemberRole({organizationId:Q,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 pN1=S(()=>{_N1();yN1();fN1();hN1();bN1();xN1();uN1();gN1();mN1();lN1();dN1()});var IJ4,wu,RJ4,Xq,cN1,Mu;var Qq=S(()=>{b0();IJ4=z.object({banner:z.string().nullable(),bannerColor:z.string().nullable(),icon:z.string().nullable(),themeColor:z.string().nullable()}),wu=z.object({banner:z.string().nullable().optional(),bannerColor:z.string().nullable().optional(),icon:z.string().nullable().optional(),themeColor:z.string().nullable().optional()}),RJ4=z.object({id:z.string(),title:z.string(),icon:z.string().nullable()}),Xq=z.object({id:z.string(),organizationId:z.string(),slug:z.string(),name:z.string(),description:z.string().nullable(),enabledPlugins:z.array(z.string()).nullable(),ui:IJ4.nullable(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().describe("ISO 8601 timestamp")}),cN1=Xq.omit({organizationId:!0}).extend({boundConnections:z.array(RJ4)}),Mu=z.object({id:z.string(),projectId:z.string(),pluginId:z.string(),connectionId:z.string().nullable(),settings:z.record(z.string(),z.unknown()).nullable(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().describe("ISO 8601 timestamp")})});var L70;var nN1=S(()=>{b0();k1();Qq();L70=f0({name:"PROJECT_LIST",description:"List all projects in an organization",inputSchema:z.object({organizationId:z.string().describe("Organization ID to list projects for")}),outputSchema:z.object({projects:z.array(cN1)}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=await X.storage.projects.list(Y.organizationId),J=Q.map((K)=>K.id),G=await X.storage.projectPluginConfigs.getBoundConnectionsForProjects(J);return{projects:Q.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 w70;var iN1=S(()=>{b0();k1();Qq();w70=f0({name:"PROJECT_GET",description:"Get a project by ID or slug",inputSchema:z.object({organizationId:z.string().describe("Organization ID"),projectId:z.string().optional().describe("Project ID (either this or slug required)"),slug:z.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:z.object({project:Xq.nullable()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=null;if(Y.projectId)Q=await X.storage.projects.get(Y.projectId);else if(Y.slug)Q=await X.storage.projects.getBySlug(Y.organizationId,Y.slug);if(!Q)return{project:null};return{project:{id:Q.id,organizationId:Q.organizationId,slug:Q.slug,name:Q.name,description:Q.description,enabledPlugins:Q.enabledPlugins,ui:Q.ui,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}}}})});var M70;var aN1=S(()=>{b0();eY();k1();Qq();M70=f0({name:"PROJECT_CREATE",description:"Create a new project in an organization",inputSchema:z.object({organizationId:z.string().describe("Organization ID"),slug:z.string().min(1).max(100).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens").describe("URL-friendly identifier"),name:z.string().min(1).max(200).describe("Display name"),description:z.string().max(1000).nullable().optional().describe("Project description"),enabledPlugins:z.array(z.string()).nullable().optional().describe("Plugin IDs to enable"),ui:wu.nullable().optional().describe("UI customization")}),outputSchema:z.object({project:Xq}),handler:async(Y,X)=>{g0(X),await X.access.check();let{organizationId:Q,slug:J,name:G,description:K,enabledPlugins:W,ui:Z}=Y;if(J===b5)throw Error(`Slug "${b5}" is reserved`);if(await X.storage.projects.getBySlug(Q,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 X.storage.projects.create({organizationId:Q,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 A70;var rN1=S(()=>{b0();k1();Qq();A70=f0({name:"PROJECT_UPDATE",description:"Update a project's details",inputSchema:z.object({projectId:z.string().describe("Project ID to update"),name:z.string().min(1).max(200).optional().describe("New display name"),description:z.string().max(1000).nullable().optional().describe("New description"),enabledPlugins:z.array(z.string()).nullable().optional().describe("Updated plugin IDs"),ui:wu.nullable().optional().describe("Updated UI customization")}),outputSchema:z.object({project:Xq.nullable()}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q,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 X.storage.projects.update(Q,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 P70;var oN1=S(()=>{b0();eY();k1();P70=f0({name:"PROJECT_DELETE",description:"Delete a project (cannot delete org-admin)",inputSchema:z.object({projectId:z.string().describe("Project ID to delete")}),outputSchema:z.object({success:z.boolean(),message:z.string().optional()}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q}=Y,J=await X.storage.projects.get(Q);if(!J)return{success:!1,message:"Project not found"};if(J.slug===b5)return{success:!1,message:"Cannot delete the org-admin project"};return{success:await X.storage.projects.delete(Q)}}})});var T70;var sN1=S(()=>{b0();k1();Qq();T70=f0({name:"PROJECT_PLUGIN_CONFIG_GET",description:"Get plugin configuration for a project",inputSchema:z.object({projectId:z.string().describe("Project ID"),pluginId:z.string().describe("Plugin ID")}),outputSchema:z.object({config:Mu.nullable()}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q,pluginId:J}=Y,G=await X.storage.projectPluginConfigs.get(Q,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 E70;var tN1=S(()=>{b0();k1();Qq();Uu();E70=f0({name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update or create plugin configuration for a project",inputSchema:z.object({projectId:z.string().describe("Project ID"),pluginId:z.string().describe("Plugin ID"),connectionId:z.string().nullable().optional().describe("MCP connection to bind"),settings:z.record(z.string(),z.unknown()).nullable().optional().describe("Plugin-specific settings")}),outputSchema:z.object({config:Mu}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q,pluginId:J,connectionId:G,settings:K}=Y,W=g8(X),Z=await X.storage.projects.get(Q);if(!Z)throw Error(`Project not found: ${Q}`);let H=G?await X.storage.connections.findById(G):null;if(G&&Z.organizationId&&!H&&FO()){if(Bu(G,Z.organizationId)){if(!W)throw Error("User ID required to create dev-assets connection");let $=$O(Z.organizationId,DJ());await X.storage.connections.create({...$,organization_id:Z.organizationId,created_by:W})}}let F=await X.storage.projectPluginConfigs.upsert(Q,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 eN1=S(()=>{nN1();iN1();aN1();rN1();oN1();sN1();tN1()});var C70;var YL1=S(()=>{b0();k1();C70=f0({name:"TAGS_LIST",description:"List all tags in an organization",inputSchema:z.object({}),outputSchema:z.object({tags:z.array(z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X);return{tags:(await X.storage.tags.listOrgTags(Q.id)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var I70;var XL1=S(()=>{b0();k1();I70=f0({name:"TAGS_CREATE",description:"Create a new tag in an organization",inputSchema:z.object({name:z.string().min(1).max(50).describe("Tag name")}),outputSchema:z.object({tag:z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")})}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X),J=await X.storage.tags.createTag(Q.id,Y.name);return{tag:{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():String(J.createdAt)}}}})});var R70;var QL1=S(()=>{b0();k1();R70=f0({name:"TAGS_DELETE",description:"Delete a tag from an organization (removes from all members)",inputSchema:z.object({tagId:z.string().describe("Tag ID to delete")}),outputSchema:z.object({success:z.boolean()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X),J=await X.storage.tags.getTag(Y.tagId);if(!J)throw Error("Tag not found");if(J.organizationId!==Q.id)throw Error("Tag does not belong to this organization");return await X.storage.tags.deleteTag(Y.tagId),{success:!0}}})});var j70;var JL1=S(()=>{b0();k1();j70=f0({name:"MEMBER_TAGS_GET",description:"Get tags assigned to a member",inputSchema:z.object({memberId:z.string().describe("Member ID")}),outputSchema:z.object({tags:z.array(z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,Q.id))throw Error(`Member not found in this organization: ${Y.memberId}`);return{tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var S70;var GL1=S(()=>{b0();k1();S70=f0({name:"MEMBER_TAGS_SET",description:"Set tags for a member (replaces all existing tags)",inputSchema:z.object({memberId:z.string().describe("Member ID"),tagIds:z.array(z.string()).describe("Array of tag IDs to assign")}),outputSchema:z.object({success:z.boolean(),tags:z.array(z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,Q.id))throw Error(`Member not found in this organization: ${Y.memberId}`);for(let K of Y.tagIds){let W=await X.storage.tags.getTag(K);if(!W)throw Error(`Tag not found: ${K}`);if(W.organizationId!==Q.id)throw Error(`Tag does not belong to this organization: ${K}`)}return await X.storage.tags.setMemberTags(Y.memberId,Y.tagIds),{success:!0,tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var WL1=S(()=>{YL1();XL1();QL1();JL1();GL1()});var ZL1,MW,KL1,HL1;var Jq=S(()=>{b0();ZL1=z.object({id:z.string().describe("Unique message ID"),threadId:z.string().describe("ID of the parent thread"),metadata:z.unknown().optional().describe("Optional message metadata"),parts:z.array(z.record(z.string(),z.unknown())).describe("Message content parts (AI SDK UIMessagePart format)"),role:z.enum(["user","assistant","system"]).describe("Message role"),createdAt:z.string().datetime().describe("Timestamp of creation"),updatedAt:z.string().datetime().describe("Timestamp of last update")}),MW=z.object({id:z.string().describe("Unique thread ID"),organizationId:z.string().describe("Organization this thread belongs to"),title:z.string().describe("Thread title"),description:z.string().nullable().describe("Thread description"),createdAt:z.string().datetime().describe("Timestamp of creation"),updatedAt:z.string().datetime().describe("Timestamp of last update"),hidden:z.boolean().optional().describe("Whether the thread is hidden"),createdBy:z.string().describe("User ID who created the thread"),updatedBy:z.string().nullable().describe("User ID who last updated the thread")}),KL1=z.object({id:z.string().optional().describe("Optional custom ID for the thread"),title:z.string().describe("Thread title"),description:z.string().nullish().describe("Thread description")}),HL1=z.object({title:z.string().optional().describe("New thread title"),description:z.string().nullish().describe("New thread description"),hidden:z.boolean().optional().describe("Whether the thread is hidden")})});var kJ4,vJ4,k70;var FL1=S(()=>{b0();k1();Jq();k5();kJ4=z.object({data:KL1.describe("Data for the new thread (id is auto-generated if not provided)")}),vJ4=z.object({item:MW.describe("The created thread entity")}),k70=f0({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread in the organization",inputSchema:kJ4,outputSchema:vJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to create thread");let G=Y.data.id??y4("thrd"),K=await X.storage.threads.create({id:G,organizationId:Q.id,title:Y.data.title,description:Y.data.description,createdBy:J});return{item:{...K,hidden:K.hidden??!1}}}})});var _J4,yJ4,v70;var $L1=S(()=>{v5();k1();Jq();b0();_J4=ZK.extend({where:z.object({created_by:z.string().optional()}).optional()}),yJ4=KK(MW),v70=f0({name:"COLLECTION_THREADS_LIST",description:"List all threads in the organization with filtering, sorting, and pagination",inputSchema:_J4,outputSchema:yJ4,handler:async(Y,X)=>{await X.access.check();let Q=X.auth.user?.id;if(!Q)throw Error("User ID required to list threads");let J=z1(X),G=Y.offset??0,K=Y.limit??100,{threads:W,total:Z}=await X.storage.threads.list(J.id,Q,{limit:K,offset:G}),H=G+K<Z;return{items:W.map((F)=>({...F,hidden:F.hidden??!1})),totalCount:Z,hasMore:H}}})});var fJ4,_70;var VL1=S(()=>{v5();k1();Jq();fJ4=L2(MW),_70=f0({name:"COLLECTION_THREADS_GET",description:"Get thread details by ID",inputSchema:N2,outputSchema:fJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.threads.get(Y.id);if(!J||J.organizationId!==Q.id)return{item:null};return{item:{...J,hidden:J.hidden??!1}}}})});var hJ4,bJ4,y70;var qL1=S(()=>{b0();k1();Jq();hJ4=z.object({id:z.string().describe("ID of the thread to update"),data:HL1.describe("Partial thread data to update")}),bJ4=z.object({item:MW.describe("The updated thread entity")}),y70=f0({name:"COLLECTION_THREADS_UPDATE",description:"Update an existing thread in the organization",inputSchema:hJ4,outputSchema:bJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to update thread");let{id:G,data:K}=Y,W=await X.storage.threads.get(G);if(!W||W.organizationId!==Q.id)throw Error("Thread not found in organization");let Z=await X.storage.threads.update(G,{title:K.title,description:K.description,hidden:K.hidden,updatedBy:J});return{item:{...Z,hidden:Z.hidden??!1}}}})});var f70;var zL1=S(()=>{v5();k1();Jq();f70=f0({name:"COLLECTION_THREADS_DELETE",description:"Delete a thread",inputSchema:w2,outputSchema:M2(MW),handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.threads.get(Y.id);if(!J)throw Error(`Thread not found: ${Y.id}`);if(J.organizationId!==Q.id)throw Error(`Thread not found: ${Y.id}`);return await X.storage.threads.delete(Y.id),{item:{...J,hidden:J.hidden??!1}}}})});function BL1(Y){if(!Y)return null;if("field"in Y&&Y.field[0]==="threadId"&&Y.operator==="eq")return String(Y.value);if("conditions"in Y)for(let X of Y.conditions){let Q=BL1(X);if(Q)return Q}return null}var xJ4,h70;var UL1=S(()=>{v5();k1();Jq();xJ4=KK(ZL1),h70=f0({name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List all messages for a specific thread",inputSchema:ZK,outputSchema:xJ4,handler:async(Y,X)=>{let Q=z1(X);await X.access.check();let J=BL1(Y.where);if(!J)throw Error("threadId filter is required in where clause");let G=await X.storage.threads.get(J);if(!G||G.organizationId!==Q.id)return{items:[],totalCount:0,hasMore:!1};let K=Y.offset??0,W=Y.limit??100,{messages:Z,total:H}=await X.storage.threads.listMessages(J,{limit:W,offset:K}),F=K+W<H;return{items:Z,totalCount:H,hasMore:F}}})});var DL1=S(()=>{FL1();$L1();VL1();qL1();zL1();UL1()});var gJ4,mJ4,b70;var OL1=S(()=>{b0();k1();gJ4=z.object({id:z.string().min(1)}),mJ4=z.object({user:z.object({id:z.string(),name:z.string(),email:z.string(),image:z.string().nullable()}).nullable()}),b70=f0({name:"USER_GET",description:"Get a user by id (restricted to shared organizations)",inputSchema:gJ4,outputSchema:mJ4,handler:async(Y,X)=>{await X.access.check(),g0(X);let Q=g8(X);if(!Q)throw Error("Authentication required");let J=await X.storage.users.findById(Y.id,Q);if(!J)return{user:null};return{user:{id:J.id,name:J.name,email:J.email,image:J.image??null}}}})});var NL1=S(()=>{OL1()});var wL1={};l1(wL1,{managementMCP:()=>x70,ALL_TOOLS:()=>LL1});var dJ4,pJ4,LL1,x70=async(Y)=>{let X=null;if(Y.organization)X=(await Y.storage.organizationSettings.get(Y.organization.id))?.enabled_plugins??null;let J=KD1(LL1,X).map((K)=>({name:K.name,description:K.description,inputSchema:K.inputSchema,outputSchema:K.outputSchema,handler:async(W)=>{return Y.access.setToolName(K.name),await K.execute(W,Y)}}));return FU1({name:"mcp-mesh-management",version:"1.0.0"}).withTools(J).build()};var u70=S(()=>{$U1();ex();ED1();UO1();YN1();GN1();BN1();wN1();jN1();vN1();pN1();eN1();WL1();DL1();NL1();dJ4=[K70,H70,F70,$70,V70,z70,B70,U70,D70,O70,N70,IG0,_G0,yG0,bG0,xG0,uG0,iG0,rG0,oG0,sG0,tG0,Y70,X70,Q70,J70,G70,JN1,W70,Z70,XG0,JG0,GG0,QG0,gG0,mG0,lG0,dG0,pG0,cG0,nG0,b70,TG0,EG0,CG0,k70,v70,_70,y70,f70,h70,C70,I70,R70,j70,S70,L70,w70,M70,A70,P70,T70,E70],pJ4=HD1(),LL1=[...dJ4,...pJ4]});function cJ4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (u70(),wL1));return X.map((Q)=>{return{name:Q.name,inputSchema:z.toJSONSchema(Q.inputSchema,{unrepresentable:"any"}),outputSchema:Q.outputSchema?z.toJSONSchema(Q.outputSchema,{unrepresentable:"any"}):void 0,description:Q.description}})},data:Ha(DJ(),Y)},{data:Ka()},{data:Za(Y)}]}async function ML1(Y,X){try{let Q=pV(),J=new cV(process.env.ENCRYPTION_KEY||""),G=new tT(Q.db,J),K=new eT(Q.db),W=cJ4(Y);try{await K.create({organizationId:Y,slug:b5,name:Aq,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 yG.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await XO({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:X,connection_token:Z.data.connection_token??H})}))}catch(Q){console.error("Error creating default MCP connections:",Q)}}var AL1=S(()=>{eY();oT();lx();M50();A50();ax();b0();qO()});var g70,Au;var Pu=S(()=>{g70=["owner","admin","user"],Au=["owner","admin"]});var nJ4=(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"}}}}]}},PL1=(Y)=>{if(Y.providerId==="microsoft")return nJ4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function iJ4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function aJ4(){let Y=Math.floor(Math.random()*EL1.length),X=Math.floor(Math.random()*TL1.length),Q=EL1[Y]??"deco",J=TL1[X]??"studio";return`${Q}-${J}`}var TL1,EL1,rJ4,oJ4,Tu,sJ4,tJ4,eJ4,CL1,O9,IL1=void 0,Y54,X54,Q54,yG;var qO=S(()=>{Yo();SI0();Dj0();le();V10();HS0();xy();DS0();oT();w50();KB1();AL1();Pu();TL1=["labs","agent","studio","workspace","systems","core","cloud","works"],EL1=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];rJ4=Object.values(nw()).map((Y)=>Y.map((X)=>X.name)).flat(),oJ4={...Ay,self:["*",...rJ4]},Tu=i7(oJ4),sJ4=Tu.newRole({self:["*"],...TA.statements}),tJ4=Tu.newRole({self:["*"],...TA.statements}),eJ4=Tu.newRole({self:["*"],...TA.statements}),CL1=Object.values(nw()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),O9=_A.auth;if(O9.inviteEmailProviderId&&O9.emailProviders&&O9.emailProviders.length>0){let Y=mx(O9.emailProviders,O9.inviteEmailProviderId);if(Y){let X=gx(Y);IL1=async(Q)=>{let J=Q.inviter.user?.name||Q.inviter.user?.email,G=`${DJ()}/auth/accept-invitation?invitationId=${Q.invitation.id}`;await X({to:Q.email,subject:`Invitation to join ${Q.organization.name}`,html:`
1196
+ `.execute(Y)).rows[0]?.exists)await $4`CREATE ROLE ${$4.id(Q)} NOLOGIN`.execute(Y);await $4`GRANT ${$4.id(Q)} TO CURRENT_USER`.execute(Y),await $4`GRANT USAGE, CREATE ON SCHEMA ${$4.id(X)} TO ${$4.id(Q)}`.execute(Y),await $4`GRANT ALL ON ALL TABLES IN SCHEMA ${$4.id(X)} TO ${$4.id(Q)}`.execute(Y),await $4`GRANT ALL ON ALL SEQUENCES IN SCHEMA ${$4.id(X)} TO ${$4.id(Q)}`.execute(Y),await $4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${$4.id(X)} GRANT ALL ON TABLES TO ${$4.id(Q)}`.execute(Y),await $4`ALTER DEFAULT PRIVILEGES IN SCHEMA ${$4.id(X)} GRANT ALL ON SEQUENCES TO ${$4.id(Q)}`.execute(Y),await $4`REVOKE ALL ON SCHEMA public FROM ${$4.id(Q)}`.execute(Y)}async function rQ4(Y,X,Q,J){try{return await Y.transaction().execute(async(G)=>{return await $4`SET LOCAL ROLE ${$4.id(Q)}`.execute(G),await $4`SET LOCAL search_path TO ${$4.id(X)}`.execute(G),await $4.raw(J).execute(G)})}catch(G){if(iQ4(G))return await aQ4(Y,X,Q),await Y.transaction().execute(async(K)=>{return await $4`SET LOCAL ROLE ${$4.id(Q)}`.execute(K),await $4`SET LOCAL search_path TO ${$4.id(X)}`.execute(K),await $4.raw(J).execute(K)});throw G}}var lQ4,pQ4,JN1;var GN1=S(()=>{b0();k1();lQ4=z.object({results:z.array(z.unknown()).optional(),success:z.boolean().optional()});pQ4=z.object({sql:z.string().describe("The SQL query to run"),params:z.array(z.any()).describe("The parameters to pass to the SQL query").optional()});JN1=f0({name:"DATABASES_RUN_SQL",description:"Run a SQL query against the database",inputSchema:pQ4,outputSchema:z.object({result:z.array(lQ4)}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=dQ4(Y.sql,Y.params||[]);if(!X.connectionId)throw Error("Connection context required for database access");let J=cQ4(X.connectionId),G=nQ4(X.connectionId);return{result:[{results:(await rQ4(X.db,J,G,Q)).rows,success:!0}]}}})});var WN1,sQ4,ZN1;var $K=S(()=>{b0();qu();WN1=z.object({connectionId:z.string().optional().describe("Filter subscriptions by connection ID (optional)")}),sQ4=z.object({id:z.string().describe("Subscription ID"),connectionId:z.string().describe("Subscriber connection ID"),eventType:z.string().describe("Event type pattern"),publisher:z.string().nullable().describe("Publisher connection filter (null = all publishers)"),filter:z.string().nullable().describe("JSONPath filter expression"),enabled:z.boolean().describe("Whether subscription is enabled"),createdAt:z.string().datetime().describe("Created timestamp (ISO 8601)"),updatedAt:z.string().datetime().describe("Updated timestamp (ISO 8601)")}),ZN1=z.object({subscriptions:z.array(sQ4).describe("List of subscriptions")})});var gG0;var KN1=S(()=>{k1();$K();gG0=f0({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.",inputSchema:A2,outputSchema:P2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to publish events. Use a connection-scoped token.");let G=await X.eventBus.publish(Q.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 mG0;var HN1=S(()=>{k1();$K();mG0=f0({name:"EVENT_SUBSCRIBE",description:"Subscribe to events of a specific type. The subscriber is automatically set to the caller's connection.",inputSchema:T2,outputSchema:E2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to subscribe. Use a connection-scoped token.");let G=await X.eventBus.subscribe(Q.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 lG0;var FN1=S(()=>{k1();$K();lG0=f0({name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events by removing a subscription.",inputSchema:R2,outputSchema:j2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to unsubscribe. Use a connection-scoped token.");let G=await X.eventBus.getSubscription(Q.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 X.eventBus.unsubscribe(Q.id,Y.subscriptionId)).success,subscriptionId:Y.subscriptionId}}})});var dG0;var $N1=S(()=>{k1();$K();dG0=f0({name:"EVENT_CANCEL",description:"Cancel a recurring event to stop future deliveries. Only the publisher can cancel their own events.",inputSchema:S2,outputSchema:k2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to cancel events. Use a connection-scoped token.");if(!await X.eventBus.getEvent(Q.id,Y.eventId))throw Error(`Event not found: ${Y.eventId}`);if(!(await X.eventBus.cancelEvent(Q.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 pG0;var VN1=S(()=>{k1();$K();pG0=f0({name:"EVENT_ACK",description:"Acknowledge delivery of an event. Call after successfully processing an event received via ON_EVENTS with retryAfter.",inputSchema:v2,outputSchema:_2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to acknowledge events. Use a connection-scoped token.");if(!(await X.eventBus.ackEvent(Q.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 cG0;var qN1=S(()=>{k1();$K();cG0=f0({name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions, optionally filtered by connection ID.",inputSchema:WN1,outputSchema:ZN1,handler:async(Y,X)=>{g0(X);let Q=z1(X);return await X.access.check(),{subscriptions:(await X.eventBus.listSubscriptions(Q.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 nG0;var zN1=S(()=>{k1();$K();nG0=f0({name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state. Creates new, deletes removed, updates changed filters. Subscriptions are identified by (eventType, publisher).",inputSchema:C2,outputSchema:I2,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=X.connectionId;if(!J)throw Error("Connection ID required to sync subscriptions. Use a connection-scoped token.");let G=await X.eventBus.syncSubscriptions(Q.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 BN1=S(()=>{KN1();HN1();FN1();$N1();VN1();qN1();zN1();$K()});var VO=S(()=>{RS()});var eQ4,YJ4,iG0;var UN1=S(()=>{b0();k1();VO();eQ4=z.object({data:$w.describe("Data for the new virtual MCP")}),YJ4=z.object({item:rQ.describe("The created virtual MCP entity")}),iG0=f0({name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create a new MCP virtual MCP in the organization",inputSchema:eQ4,outputSchema:YJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to create virtual MCP");return{item:await X.storage.virtualMcps.create(Q.id,J,Y.data)}}})});function XJ4(Y){let X=[],Q=0;while(Q<Y.length){let J=Y[Q];if(J==="%")X.push(".*");else if(J==="_")X.push(".");else if(/[.*+?^${}()|[\]\\]/.test(J))X.push("\\"+J);else X.push(J);Q++}return X.join("")}function g3(Y){return typeof Y==="string"||typeof Y==="number"}function aG0(Y,X){let Q=X.split("."),J=Y;for(let G of Q){if(J==null||typeof J!=="object")return;J=J[G]}return J}function QJ4(Y,X){return Y.connections.some((Q)=>Q.connection_id===X)}function Lu(Y,X){if("conditions"in X){let{operator:Z,conditions:H}=X;switch(Z){case"and":return H.every((F)=>Lu(Y,F));case"or":return H.some((F)=>Lu(Y,F));case"not":return!H.every((F)=>Lu(Y,F));default:return!0}}let{field:Q,operator:J,value:G}=X,K=Q.join(".");if(K==="connection_id"){if(J!=="eq"||typeof G!=="string")return!1;return QJ4(Y,G)}let W=aG0(Y,K);switch(J){case"eq":return W===G;case"gt":return g3(W)&&g3(G)&&W>G;case"gte":return g3(W)&&g3(G)&&W>=G;case"lt":return g3(W)&&g3(G)&&W<G;case"lte":return g3(W)&&g3(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=XJ4(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 JJ4(Y,X){return[...Y].sort((Q,J)=>{for(let G of X){let K=G.field.join("."),W=aG0(Q,K),Z=aG0(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 GJ4,WJ4,rG0;var DN1=S(()=>{v5();k1();VO();GJ4=ZK,WJ4=KK(rQ),rG0=f0({name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List all MCP virtual MCPs in the organization",inputSchema:GJ4,outputSchema:WJ4,handler:async(Y,X)=>{await X.access.check();let Q=z1(X),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 X.storage.virtualMcps.listByConnectionId(Q.id,J):await X.storage.virtualMcps.list(Q.id);if(Y.where)K=K.filter((V)=>Lu(V,Y.where));if(Y.orderBy&&Y.orderBy.length>0)K=JJ4(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 ZJ4,KJ4,oG0;var ON1=S(()=>{b0();k1();VO();ZJ4=z.object({id:z.string().describe("ID of the virtual MCP to retrieve")}),KJ4=z.object({item:rQ.nullable().describe("The retrieved virtual MCP, or null if not found")}),oG0=f0({name:"COLLECTION_VIRTUAL_MCP_GET",description:"Get an MCP virtual MCP by ID",inputSchema:ZJ4,outputSchema:KJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.id);if(J&&J.organization_id!==Q.id)return{item:null};if(!J)return{item:null};return{item:J}}})});var HJ4,FJ4,sG0;var NN1=S(()=>{b0();k1();VO();HJ4=z.object({id:z.string().describe("ID of the virtual MCP to update"),data:Vw.describe("Partial virtual MCP data to update")}),FJ4=z.object({item:rQ.describe("The updated virtual MCP entity")}),sG0=f0({name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update an MCP virtual MCP",inputSchema:HJ4,outputSchema:FJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to update virtual MCP");let G=await X.storage.virtualMcps.findById(Y.id);if(!G)throw Error(`Virtual MCP not found: ${Y.id}`);if(G.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.id}`);return{item:await X.storage.virtualMcps.update(Y.id,J,Y.data)}}})});var $J4,VJ4,tG0;var LN1=S(()=>{b0();k1();VO();$J4=z.object({id:z.string().describe("ID of the virtual MCP to delete")}),VJ4=z.object({item:rQ.describe("The deleted virtual MCP entity")}),tG0=f0({name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete an MCP virtual MCP",inputSchema:$J4,outputSchema:VJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.id);if(!J)throw Error(`Virtual MCP not found: ${Y.id}`);if(J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.id}`);return await X.storage.virtualMcps.delete(Y.id),{item:J}}})});var wN1=S(()=>{UN1();DN1();ON1();NN1();LN1()});function m3(Y){if(!Y?._meta)return!1;return typeof Y._meta["mcp.mesh"]?.["tool.fn"]==="string"}function PN1(Y){return Y._meta["mcp.mesh"]["tool.fn"]}function b2(Y,X,Q,J){return{id:Y,name:X.name,description:X.description,inputSchema:X.inputSchema,outputSchema:X.outputSchema,annotations:X.annotations,code:X._meta["mcp.mesh"]["tool.fn"],connection_dependencies:X._meta.connectionDependencies??[],created_at:Q,updated_at:J}}var eG0,FD8,wW,MN1,AN1;var VK=S(()=>{b0();eG0=z.object({title:z.string().optional(),readOnlyHint:z.boolean().optional(),destructiveHint:z.boolean().optional(),idempotentHint:z.boolean().optional(),openWorldHint:z.boolean().optional()}),FD8=z.object({"tool.fn":z.string().describe("JavaScript ES module code that exports a default async function")}),wW=z.object({id:z.string().describe("Unique identifier for the virtual tool (auto-generated)"),name:z.string().min(1).max(255).describe("Tool name (must be unique within the Virtual MCP)"),description:z.string().optional().describe("Human-readable description of what the tool does"),inputSchema:z.record(z.string(),z.unknown()).describe("JSON Schema defining the tool's input parameters"),outputSchema:z.record(z.string(),z.unknown()).optional().describe("JSON Schema defining the tool's output (optional)"),annotations:eG0.optional().describe("MCP tool annotations"),code:z.string().describe("JavaScript ES module code. Must export default an async function: export default async (tools, args) => { ... }"),connection_dependencies:z.array(z.string()).describe("Connection IDs that this tool depends on (specified by the creator)"),created_at:z.string().describe("When the virtual tool was created"),updated_at:z.string().describe("When the virtual tool was last updated")}),MN1=z.object({name:z.string().min(1).max(255).describe("Tool name (must be unique within the Virtual MCP)"),description:z.string().optional().describe("Human-readable description"),inputSchema:z.record(z.string(),z.unknown()).describe("JSON Schema defining the tool's input parameters"),outputSchema:z.record(z.string(),z.unknown()).optional().describe("JSON Schema for output"),annotations:eG0.optional().describe("MCP tool annotations"),code:z.string().describe("JavaScript ES module code. Must export default an async function: export default async (tools, args) => { ... }"),connection_dependencies:z.array(z.string()).optional().describe("Connection IDs that this tool depends on. Creates indirect aggregations to prevent deletion of referenced connections.")}),AN1=z.object({name:z.string().min(1).max(255).optional().describe("New tool name"),description:z.string().nullable().optional().describe("New description (null to clear)"),inputSchema:z.record(z.string(),z.unknown()).optional().describe("New input schema"),outputSchema:z.record(z.string(),z.unknown()).nullable().optional().describe("New output schema (null to clear)"),annotations:eG0.nullable().optional().describe("New annotations (null to clear)"),code:z.string().optional().describe("New JavaScript code"),connection_dependencies:z.array(z.string()).optional().describe("Connection IDs that this tool depends on. Replaces existing dependencies if provided.")})});var zJ4,BJ4,Y70;var TN1=S(()=>{b0();k1();VK();zJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP to add the tool to"),data:MN1.describe("Virtual tool data")}),BJ4=z.object({item:wW.describe("The created virtual tool")}),Y70=f0({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.",inputSchema:zJ4,outputSchema:BJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=Y.data.connection_dependencies??[];return{item:await X.storage.virtualMcps.createVirtualTool(Y.virtual_mcp_id,Y.data,G)}}})});var UJ4,DJ4,X70;var EN1=S(()=>{b0();k1();VK();UJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP to list tools for"),limit:z.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:z.number().int().min(0).optional().describe("Number of items to skip")}),DJ4=z.object({items:z.array(wW).describe("Array of virtual tools"),totalCount:z.number().int().min(0).optional().describe("Total number of virtual tools"),hasMore:z.boolean().optional().describe("Whether there are more items available")}),X70=f0({name:"COLLECTION_VIRTUAL_TOOLS_LIST",description:"List all virtual tools for a Virtual MCP",inputSchema:UJ4,outputSchema:DJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)return{items:[],totalCount:0,hasMore:!1};let G=await X.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 OJ4,NJ4,Q70;var CN1=S(()=>{b0();k1();VK();OJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP"),name:z.string().describe("Name of the virtual tool to retrieve")}),NJ4=z.object({item:wW.nullable().describe("The retrieved virtual tool, or null if not found")}),Q70=f0({name:"COLLECTION_VIRTUAL_TOOLS_GET",description:"Get a virtual tool by name from a Virtual MCP",inputSchema:OJ4,outputSchema:NJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)return{item:null};return{item:await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name)}}})});var LJ4,wJ4,J70;var IN1=S(()=>{b0();k1();VK();LJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP"),name:z.string().describe("Current name of the virtual tool to update"),data:AN1.describe("Partial virtual tool data to update")}),wJ4=z.object({item:wW.describe("The updated virtual tool")}),J70=f0({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.",inputSchema:LJ4,outputSchema:wJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);if(!await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name))throw Error(`Virtual tool not found: ${Y.name}`);let K=Y.data.connection_dependencies;return{item:await X.storage.virtualMcps.updateVirtualTool(Y.virtual_mcp_id,Y.name,Y.data,K)}}})});var MJ4,AJ4,G70;var RN1=S(()=>{b0();k1();VK();MJ4=z.object({virtual_mcp_id:z.string().describe("ID of the Virtual MCP"),name:z.string().describe("Name of the virtual tool to delete")}),AJ4=z.object({item:wW.describe("The deleted virtual tool")}),G70=f0({name:"COLLECTION_VIRTUAL_TOOLS_DELETE",description:"Delete a virtual tool from a Virtual MCP",inputSchema:MJ4,outputSchema:AJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.virtualMcps.findById(Y.virtual_mcp_id);if(!J||J.organization_id!==Q.id)throw Error(`Virtual MCP not found: ${Y.virtual_mcp_id}`);let G=await X.storage.virtualMcps.getVirtualTool(Y.virtual_mcp_id,Y.name);if(!G)throw Error(`Virtual tool not found: ${Y.name}`);return await X.storage.virtualMcps.deleteVirtualTool(Y.virtual_mcp_id,Y.name),{item:G}}})});var jN1=S(()=>{TN1();EN1();CN1();IN1();RN1()});var TJ4,W70;var SN1=S(()=>{k1();b0();TJ4=z.object({id:z.string().optional().describe("Unique log identifier"),organizationId:z.string().describe("Organization ID"),connectionId:z.string().describe("Connection ID"),connectionTitle:z.string().describe("Connection display name"),toolName:z.string().describe("Name of the tool that was called"),input:z.record(z.string(),z.unknown()).describe("Redacted tool input"),output:z.record(z.string(),z.unknown()).describe("Redacted tool output"),isError:z.boolean().describe("Whether the call resulted in an error"),errorMessage:z.string().nullish().describe("Error message if applicable"),durationMs:z.number().describe("Call duration in milliseconds"),timestamp:z.string().describe("ISO 8601 timestamp of the call"),userId:z.string().nullish().describe("User who triggered the call"),requestId:z.string().describe("Unique request identifier"),userAgent:z.string().nullish().describe("Client identifier (x-mesh-client header)"),virtualMcpId:z.string().nullish().describe("Virtual MCP (Agent) ID if routed through an agent"),properties:z.record(z.string(),z.string()).nullish().describe("Custom key-value metadata attached to the log")}),W70=f0({name:"MONITORING_LOGS_LIST",description:"List monitoring logs for tool calls in the organization",inputSchema:z.object({connectionId:z.string().optional().describe("Filter by connection ID"),excludeConnectionIds:z.array(z.string()).optional().describe("Exclude logs from these connection IDs (e.g. system connections)"),virtualMcpId:z.string().optional().describe("Filter by Virtual MCP (Agent) ID"),toolName:z.string().optional().describe("Filter by tool name"),isError:z.boolean().optional().describe("Filter by error status"),startDate:z.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:z.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)"),limit:z.number().default(20).describe("Maximum number of results"),offset:z.number().default(0).describe("Offset for pagination"),properties:z.record(z.string(),z.string()).optional().describe("Filter by exact property key=value matches"),propertyKeys:z.array(z.string()).optional().describe("Filter by logs that have these property keys"),propertyPatterns:z.record(z.string(),z.string()).optional().describe("Filter by property value patterns (SQL LIKE, use % as wildcard)"),propertyInValues:z.record(z.string(),z.string()).optional().describe("Filter by exact match within comma-separated values (e.g., user_tags in 'Engineering')")}),outputSchema:z.object({logs:z.array(TJ4).describe("Array of monitoring logs"),total:z.number().describe("Total number of logs matching filters"),offset:z.number().describe("Current offset for pagination"),limit:z.number().describe("Current limit for pagination")}),handler:async(Y,X)=>{let Q=z1(X),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:Q.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 X.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 Z70;var kN1=S(()=>{k1();b0();Z70=f0({name:"MONITORING_STATS",description:"Get aggregated statistics for tool call monitoring",inputSchema:z.object({startDate:z.string().datetime().optional().describe("Filter by start date (ISO 8601 datetime string)"),endDate:z.string().datetime().optional().describe("Filter by end date (ISO 8601 datetime string)")}),outputSchema:z.object({totalCalls:z.number().describe("Total number of tool calls"),errorRate:z.number().describe("Error rate as a decimal (0 to 1)"),avgDurationMs:z.number().describe("Average call duration in milliseconds"),errorRatePercent:z.string().describe("Error rate as a percentage string")}),handler:async(Y,X)=>{let J={organizationId:z1(X).id,startDate:Y.startDate?new Date(Y.startDate):void 0,endDate:Y.endDate?new Date(Y.endDate):void 0},G=await X.storage.monitoring.getStats(J);return{...G,errorRatePercent:(G.errorRate*100).toFixed(2)}}})});var vN1=S(()=>{SN1();kN1()});var K70;var _N1=S(()=>{b0();k1();K70=f0({name:"ORGANIZATION_CREATE",description:"Create a new organization",inputSchema:z.object({slug:z.string().min(1).max(50).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens"),name:z.string().min(1).max(255),description:z.string().optional()}),outputSchema:z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),members:z.array(z.any()).optional()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=g8(X);if(!Q)throw Error("User ID required to create organization");let J=await X.boundAuth.organization.create({name:Y.name,slug:Y.slug,metadata:Y.description?{description:Y.description}:void 0,userId:Q});if(!J)throw Error("Failed to create organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var H70;var yN1=S(()=>{b0();k1();H70=f0({name:"ORGANIZATION_LIST",description:"List all organizations user has access to",inputSchema:z.object({userId:z.string().optional()}),outputSchema:z.object({organizations:z.array(z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=g8(X),J=Y.userId||Q;if(!J)throw Error("User ID required to list organizations");return{organizations:(await X.boundAuth.organization.list(J)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():K.createdAt}))}}})});var F70;var fN1=S(()=>{b0();k1();F70=f0({name:"ORGANIZATION_GET",description:"Get organization details by slug or ID",inputSchema:z.object({}),outputSchema:z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),members:z.array(z.any()).optional(),invitations:z.array(z.any()).optional()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=await X.boundAuth.organization.get();if(!Q)throw Error("No active organization found");let J=new Date,G=Q.invitations?.filter((K)=>new Date(K.expiresAt)>J);return{...Q,invitations:G,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt}}})});var $70;var hN1=S(()=>{b0();k1();$70=f0({name:"ORGANIZATION_UPDATE",description:"Update an existing organization",inputSchema:z.object({id:z.string(),slug:z.string().min(1).max(50).regex(/^[a-z0-9-]+$/).optional(),name:z.string().min(1).max(255).optional(),description:z.string().optional()}),outputSchema:z.object({id:z.string(),name:z.string(),slug:z.string(),logo:z.string().nullable().optional(),metadata:z.any().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q={};if(Y.name)Q.name=Y.name;if(Y.slug)Q.slug=Y.slug;if(Y.description)Q.metadata={description:Y.description};let J=await X.boundAuth.organization.update({organizationId:Y.id,data:Q});if(!J)throw Error("Failed to update organization");return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt}}})});var V70;var bN1=S(()=>{b0();k1();V70=f0({name:"ORGANIZATION_DELETE",description:"Delete an organization",inputSchema:z.object({id:z.string()}),outputSchema:z.object({success:z.boolean(),id:z.string()}),handler:async(Y,X)=>{return g0(X),await X.access.check(),await X.boundAuth.organization.delete(Y.id),{success:!0,id:Y.id}}})});var x2;var q70=S(()=>{b0();x2=z.object({title:z.string(),url:z.string(),icon:z.string()})});var z70;var xN1=S(()=>{b0();k1();q70();z70=f0({name:"ORGANIZATION_SETTINGS_GET",description:"Get organization-level settings",inputSchema:z.object({}),outputSchema:z.object({organizationId:z.string(),sidebar_items:z.array(x2).nullable().optional(),enabled_plugins:z.array(z.string()).nullable().optional(),createdAt:z.string().datetime().optional().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().optional().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.storage.organizationSettings.get(Q);if(!J)return{organizationId:Q};return{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():J.createdAt,updatedAt:J.updatedAt instanceof Date?J.updatedAt.toISOString():J.updatedAt}}})});var B70;var uN1=S(()=>{b0();k1();q70();B70=f0({name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization-level settings",inputSchema:z.object({organizationId:z.string(),sidebar_items:z.array(x2).optional(),enabled_plugins:z.array(z.string()).optional()}),outputSchema:z.object({organizationId:z.string(),sidebar_items:z.array(x2).nullable().optional(),enabled_plugins:z.array(z.string()).nullable().optional(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{if(g0(X),await X.access.check(),X.organization&&X.organization.id!==Y.organizationId)throw Error("Cannot update settings for a different organization");let Q=await X.storage.organizationSettings.upsert(Y.organizationId,{sidebar_items:Y.sidebar_items,enabled_plugins:Y.enabled_plugins});return{...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}}})});var U70;var gN1=S(()=>{b0();k1();U70=f0({name:"ORGANIZATION_MEMBER_ADD",description:"Add a member to an organization",inputSchema:z.object({organizationId:z.string().optional(),userId:z.string(),role:z.array(z.string())}),outputSchema:z.object({id:z.string(),organizationId:z.string(),userId:z.string(),role:z.union([z.string(),z.array(z.string())]),createdAt:z.string().datetime().describe("ISO 8601 timestamp")}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=Y.organizationId||X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.boundAuth.organization.addMember({organizationId:Q,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 D70;var mN1=S(()=>{b0();k1();D70=f0({name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove a member from an organization",inputSchema:z.object({organizationId:z.string().optional(),memberIdOrEmail:z.string()}),outputSchema:z.object({success:z.boolean(),memberIdOrEmail:z.string()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=Y.organizationId||X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");return await X.boundAuth.organization.removeMember({organizationId:Q,memberIdOrEmail:Y.memberIdOrEmail}),{success:!0,memberIdOrEmail:Y.memberIdOrEmail}}})});var O70;var lN1=S(()=>{b0();k1();O70=f0({name:"ORGANIZATION_MEMBER_LIST",description:"List all members in an organization",inputSchema:z.object({limit:z.number().optional(),offset:z.number().optional()}),outputSchema:z.object({members:z.array(z.object({id:z.string(),organizationId:z.string(),userId:z.string(),role:z.string(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),user:z.object({id:z.string(),name:z.string(),email:z.string(),image:z.string().optional()}).optional()}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.boundAuth.organization.listMembers({organizationId:Q,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 N70;var dN1=S(()=>{b0();k1();N70=f0({name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update a member's role in an organization",inputSchema:z.object({organizationId:z.string().optional(),memberId:z.string(),role:z.array(z.string())}),outputSchema:z.object({id:z.string(),organizationId:z.string(),userId:z.string(),role:z.union([z.literal("admin"),z.literal("member"),z.literal("owner")]),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),user:z.object({email:z.string(),name:z.string(),image:z.string().optional()})}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=Y.organizationId||X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let J=await X.boundAuth.organization.updateMemberRole({organizationId:Q,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 pN1=S(()=>{_N1();yN1();fN1();hN1();bN1();xN1();uN1();gN1();mN1();lN1();dN1()});var IJ4,wu,RJ4,Xq,cN1,Mu;var Qq=S(()=>{b0();IJ4=z.object({banner:z.string().nullable(),bannerColor:z.string().nullable(),icon:z.string().nullable(),themeColor:z.string().nullable()}),wu=z.object({banner:z.string().nullable().optional(),bannerColor:z.string().nullable().optional(),icon:z.string().nullable().optional(),themeColor:z.string().nullable().optional()}),RJ4=z.object({id:z.string(),title:z.string(),icon:z.string().nullable()}),Xq=z.object({id:z.string(),organizationId:z.string(),slug:z.string(),name:z.string(),description:z.string().nullable(),enabledPlugins:z.array(z.string()).nullable(),ui:IJ4.nullable(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().describe("ISO 8601 timestamp")}),cN1=Xq.omit({organizationId:!0}).extend({boundConnections:z.array(RJ4)}),Mu=z.object({id:z.string(),projectId:z.string(),pluginId:z.string(),connectionId:z.string().nullable(),settings:z.record(z.string(),z.unknown()).nullable(),createdAt:z.string().datetime().describe("ISO 8601 timestamp"),updatedAt:z.string().datetime().describe("ISO 8601 timestamp")})});var L70;var nN1=S(()=>{b0();k1();Qq();L70=f0({name:"PROJECT_LIST",description:"List all projects in an organization",inputSchema:z.object({organizationId:z.string().describe("Organization ID to list projects for")}),outputSchema:z.object({projects:z.array(cN1)}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=await X.storage.projects.list(Y.organizationId),J=Q.map((K)=>K.id),G=await X.storage.projectPluginConfigs.getBoundConnectionsForProjects(J);return{projects:Q.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 w70;var iN1=S(()=>{b0();k1();Qq();w70=f0({name:"PROJECT_GET",description:"Get a project by ID or slug",inputSchema:z.object({organizationId:z.string().describe("Organization ID"),projectId:z.string().optional().describe("Project ID (either this or slug required)"),slug:z.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:z.object({project:Xq.nullable()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=null;if(Y.projectId)Q=await X.storage.projects.get(Y.projectId);else if(Y.slug)Q=await X.storage.projects.getBySlug(Y.organizationId,Y.slug);if(!Q)return{project:null};return{project:{id:Q.id,organizationId:Q.organizationId,slug:Q.slug,name:Q.name,description:Q.description,enabledPlugins:Q.enabledPlugins,ui:Q.ui,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():Q.createdAt,updatedAt:Q.updatedAt instanceof Date?Q.updatedAt.toISOString():Q.updatedAt}}}})});var M70;var aN1=S(()=>{b0();eY();k1();Qq();M70=f0({name:"PROJECT_CREATE",description:"Create a new project in an organization",inputSchema:z.object({organizationId:z.string().describe("Organization ID"),slug:z.string().min(1).max(100).regex(/^[a-z0-9-]+$/,"Slug must be lowercase alphanumeric with hyphens").describe("URL-friendly identifier"),name:z.string().min(1).max(200).describe("Display name"),description:z.string().max(1000).nullable().optional().describe("Project description"),enabledPlugins:z.array(z.string()).nullable().optional().describe("Plugin IDs to enable"),ui:wu.nullable().optional().describe("UI customization")}),outputSchema:z.object({project:Xq}),handler:async(Y,X)=>{g0(X),await X.access.check();let{organizationId:Q,slug:J,name:G,description:K,enabledPlugins:W,ui:Z}=Y;if(J===b5)throw Error(`Slug "${b5}" is reserved`);if(await X.storage.projects.getBySlug(Q,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 X.storage.projects.create({organizationId:Q,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 A70;var rN1=S(()=>{b0();k1();Qq();A70=f0({name:"PROJECT_UPDATE",description:"Update a project's details",inputSchema:z.object({projectId:z.string().describe("Project ID to update"),name:z.string().min(1).max(200).optional().describe("New display name"),description:z.string().max(1000).nullable().optional().describe("New description"),enabledPlugins:z.array(z.string()).nullable().optional().describe("Updated plugin IDs"),ui:wu.nullable().optional().describe("Updated UI customization")}),outputSchema:z.object({project:Xq.nullable()}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q,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 X.storage.projects.update(Q,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 P70;var oN1=S(()=>{b0();eY();k1();P70=f0({name:"PROJECT_DELETE",description:"Delete a project (cannot delete org-admin)",inputSchema:z.object({projectId:z.string().describe("Project ID to delete")}),outputSchema:z.object({success:z.boolean(),message:z.string().optional()}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q}=Y,J=await X.storage.projects.get(Q);if(!J)return{success:!1,message:"Project not found"};if(J.slug===b5)return{success:!1,message:"Cannot delete the org-admin project"};return{success:await X.storage.projects.delete(Q)}}})});var T70;var sN1=S(()=>{b0();k1();Qq();T70=f0({name:"PROJECT_PLUGIN_CONFIG_GET",description:"Get plugin configuration for a project",inputSchema:z.object({projectId:z.string().describe("Project ID"),pluginId:z.string().describe("Plugin ID")}),outputSchema:z.object({config:Mu.nullable()}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q,pluginId:J}=Y,G=await X.storage.projectPluginConfigs.get(Q,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 E70;var tN1=S(()=>{b0();k1();Qq();Uu();E70=f0({name:"PROJECT_PLUGIN_CONFIG_UPDATE",description:"Update or create plugin configuration for a project",inputSchema:z.object({projectId:z.string().describe("Project ID"),pluginId:z.string().describe("Plugin ID"),connectionId:z.string().nullable().optional().describe("MCP connection to bind"),settings:z.record(z.string(),z.unknown()).nullable().optional().describe("Plugin-specific settings")}),outputSchema:z.object({config:Mu}),handler:async(Y,X)=>{g0(X),await X.access.check();let{projectId:Q,pluginId:J,connectionId:G,settings:K}=Y,W=g8(X),Z=await X.storage.projects.get(Q);if(!Z)throw Error(`Project not found: ${Q}`);let H=G?await X.storage.connections.findById(G):null;if(G&&Z.organizationId&&!H&&FO()){if(Bu(G,Z.organizationId)){if(!W)throw Error("User ID required to create dev-assets connection");let $=$O(Z.organizationId,DJ());await X.storage.connections.create({...$,organization_id:Z.organizationId,created_by:W})}}let F=await X.storage.projectPluginConfigs.upsert(Q,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 eN1=S(()=>{nN1();iN1();aN1();rN1();oN1();sN1();tN1()});var C70;var YL1=S(()=>{b0();k1();C70=f0({name:"TAGS_LIST",description:"List all tags in an organization",inputSchema:z.object({}),outputSchema:z.object({tags:z.array(z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X);return{tags:(await X.storage.tags.listOrgTags(Q.id)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var I70;var XL1=S(()=>{b0();k1();I70=f0({name:"TAGS_CREATE",description:"Create a new tag in an organization",inputSchema:z.object({name:z.string().min(1).max(50).describe("Tag name")}),outputSchema:z.object({tag:z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")})}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X),J=await X.storage.tags.createTag(Q.id,Y.name);return{tag:{...J,createdAt:J.createdAt instanceof Date?J.createdAt.toISOString():String(J.createdAt)}}}})});var R70;var QL1=S(()=>{b0();k1();R70=f0({name:"TAGS_DELETE",description:"Delete a tag from an organization (removes from all members)",inputSchema:z.object({tagId:z.string().describe("Tag ID to delete")}),outputSchema:z.object({success:z.boolean()}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X),J=await X.storage.tags.getTag(Y.tagId);if(!J)throw Error("Tag not found");if(J.organizationId!==Q.id)throw Error("Tag does not belong to this organization");return await X.storage.tags.deleteTag(Y.tagId),{success:!0}}})});var j70;var JL1=S(()=>{b0();k1();j70=f0({name:"MEMBER_TAGS_GET",description:"Get tags assigned to a member",inputSchema:z.object({memberId:z.string().describe("Member ID")}),outputSchema:z.object({tags:z.array(z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,Q.id))throw Error(`Member not found in this organization: ${Y.memberId}`);return{tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var S70;var GL1=S(()=>{b0();k1();S70=f0({name:"MEMBER_TAGS_SET",description:"Set tags for a member (replaces all existing tags)",inputSchema:z.object({memberId:z.string().describe("Member ID"),tagIds:z.array(z.string()).describe("Array of tag IDs to assign")}),outputSchema:z.object({success:z.boolean(),tags:z.array(z.object({id:z.string(),organizationId:z.string(),name:z.string(),createdAt:z.string().describe("ISO 8601 timestamp")}))}),handler:async(Y,X)=>{g0(X),await X.access.check();let Q=z1(X);if(!await X.storage.tags.verifyMemberOrg(Y.memberId,Q.id))throw Error(`Member not found in this organization: ${Y.memberId}`);for(let K of Y.tagIds){let W=await X.storage.tags.getTag(K);if(!W)throw Error(`Tag not found: ${K}`);if(W.organizationId!==Q.id)throw Error(`Tag does not belong to this organization: ${K}`)}return await X.storage.tags.setMemberTags(Y.memberId,Y.tagIds),{success:!0,tags:(await X.storage.tags.getMemberTags(Y.memberId)).map((K)=>({...K,createdAt:K.createdAt instanceof Date?K.createdAt.toISOString():String(K.createdAt)}))}}})});var WL1=S(()=>{YL1();XL1();QL1();JL1();GL1()});var ZL1,MW,KL1,HL1;var Jq=S(()=>{b0();ZL1=z.object({id:z.string().describe("Unique message ID"),threadId:z.string().describe("ID of the parent thread"),metadata:z.unknown().optional().describe("Optional message metadata"),parts:z.array(z.record(z.string(),z.unknown())).describe("Message content parts (AI SDK UIMessagePart format)"),role:z.enum(["user","assistant","system"]).describe("Message role"),createdAt:z.string().datetime().describe("Timestamp of creation"),updatedAt:z.string().datetime().describe("Timestamp of last update")}),MW=z.object({id:z.string().describe("Unique thread ID"),organizationId:z.string().describe("Organization this thread belongs to"),title:z.string().describe("Thread title"),description:z.string().nullable().describe("Thread description"),createdAt:z.string().datetime().describe("Timestamp of creation"),updatedAt:z.string().datetime().describe("Timestamp of last update"),hidden:z.boolean().optional().describe("Whether the thread is hidden"),createdBy:z.string().describe("User ID who created the thread"),updatedBy:z.string().nullable().describe("User ID who last updated the thread")}),KL1=z.object({id:z.string().optional().describe("Optional custom ID for the thread"),title:z.string().describe("Thread title"),description:z.string().nullish().describe("Thread description")}),HL1=z.object({title:z.string().optional().describe("New thread title"),description:z.string().nullish().describe("New thread description"),hidden:z.boolean().optional().describe("Whether the thread is hidden")})});var kJ4,vJ4,k70;var FL1=S(()=>{b0();k1();Jq();k5();kJ4=z.object({data:KL1.describe("Data for the new thread (id is auto-generated if not provided)")}),vJ4=z.object({item:MW.describe("The created thread entity")}),k70=f0({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread in the organization",inputSchema:kJ4,outputSchema:vJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to create thread");let G=Y.data.id??y4("thrd"),K=await X.storage.threads.create({id:G,organizationId:Q.id,title:Y.data.title,description:Y.data.description,createdBy:J});return{item:{...K,hidden:K.hidden??!1}}}})});var _J4,yJ4,v70;var $L1=S(()=>{v5();k1();Jq();b0();_J4=ZK.extend({where:z.object({created_by:z.string().optional()}).optional()}),yJ4=KK(MW),v70=f0({name:"COLLECTION_THREADS_LIST",description:"List all threads in the organization with filtering, sorting, and pagination",inputSchema:_J4,outputSchema:yJ4,handler:async(Y,X)=>{await X.access.check();let Q=X.auth.user?.id;if(!Q)throw Error("User ID required to list threads");let J=z1(X),G=Y.offset??0,K=Y.limit??100,{threads:W,total:Z}=await X.storage.threads.list(J.id,Q,{limit:K,offset:G}),H=G+K<Z;return{items:W.map((F)=>({...F,hidden:F.hidden??!1})),totalCount:Z,hasMore:H}}})});var fJ4,_70;var VL1=S(()=>{v5();k1();Jq();fJ4=L2(MW),_70=f0({name:"COLLECTION_THREADS_GET",description:"Get thread details by ID",inputSchema:N2,outputSchema:fJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.threads.get(Y.id);if(!J||J.organizationId!==Q.id)return{item:null};return{item:{...J,hidden:J.hidden??!1}}}})});var hJ4,bJ4,y70;var qL1=S(()=>{b0();k1();Jq();hJ4=z.object({id:z.string().describe("ID of the thread to update"),data:HL1.describe("Partial thread data to update")}),bJ4=z.object({item:MW.describe("The updated thread entity")}),y70=f0({name:"COLLECTION_THREADS_UPDATE",description:"Update an existing thread in the organization",inputSchema:hJ4,outputSchema:bJ4,handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=g8(X);if(!J)throw Error("User ID required to update thread");let{id:G,data:K}=Y,W=await X.storage.threads.get(G);if(!W||W.organizationId!==Q.id)throw Error("Thread not found in organization");let Z=await X.storage.threads.update(G,{title:K.title,description:K.description,hidden:K.hidden,updatedBy:J});return{item:{...Z,hidden:Z.hidden??!1}}}})});var f70;var zL1=S(()=>{v5();k1();Jq();f70=f0({name:"COLLECTION_THREADS_DELETE",description:"Delete a thread",inputSchema:w2,outputSchema:M2(MW),handler:async(Y,X)=>{g0(X);let Q=z1(X);await X.access.check();let J=await X.storage.threads.get(Y.id);if(!J)throw Error(`Thread not found: ${Y.id}`);if(J.organizationId!==Q.id)throw Error(`Thread not found: ${Y.id}`);return await X.storage.threads.delete(Y.id),{item:{...J,hidden:J.hidden??!1}}}})});function BL1(Y){if(!Y)return null;if("field"in Y&&Y.field[0]==="threadId"&&Y.operator==="eq")return String(Y.value);if("conditions"in Y)for(let X of Y.conditions){let Q=BL1(X);if(Q)return Q}return null}var xJ4,h70;var UL1=S(()=>{v5();k1();Jq();xJ4=KK(ZL1),h70=f0({name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List all messages for a specific thread",inputSchema:ZK,outputSchema:xJ4,handler:async(Y,X)=>{let Q=z1(X);await X.access.check();let J=BL1(Y.where);if(!J)throw Error("threadId filter is required in where clause");let G=await X.storage.threads.get(J);if(!G||G.organizationId!==Q.id)return{items:[],totalCount:0,hasMore:!1};let K=Y.offset??0,W=Y.limit??100,{messages:Z,total:H}=await X.storage.threads.listMessages(J,{limit:W,offset:K}),F=K+W<H;return{items:Z,totalCount:H,hasMore:F}}})});var DL1=S(()=>{FL1();$L1();VL1();qL1();zL1();UL1()});var gJ4,mJ4,b70;var OL1=S(()=>{b0();k1();gJ4=z.object({id:z.string().min(1)}),mJ4=z.object({user:z.object({id:z.string(),name:z.string(),email:z.string(),image:z.string().nullable()}).nullable()}),b70=f0({name:"USER_GET",description:"Get a user by id (restricted to shared organizations)",inputSchema:gJ4,outputSchema:mJ4,handler:async(Y,X)=>{await X.access.check(),g0(X);let Q=g8(X);if(!Q)throw Error("Authentication required");let J=await X.storage.users.findById(Y.id,Q);if(!J)return{user:null};return{user:{id:J.id,name:J.name,email:J.email,image:J.image??null}}}})});var NL1=S(()=>{OL1()});var wL1={};l1(wL1,{managementMCP:()=>x70,ALL_TOOLS:()=>LL1});var dJ4,pJ4,LL1,x70=async(Y)=>{let X=null;if(Y.organization)X=(await Y.storage.organizationSettings.get(Y.organization.id))?.enabled_plugins??null;let J=KD1(LL1,X).map((K)=>({name:K.name,description:K.description,inputSchema:K.inputSchema,outputSchema:K.outputSchema,handler:async(W)=>{return Y.access.setToolName(K.name),await K.execute(W,Y)}}));return FU1({name:"mcp-mesh-management",version:"1.0.0"}).withTools(J).build()};var u70=S(()=>{$U1();ex();ED1();UO1();YN1();GN1();BN1();wN1();jN1();vN1();pN1();eN1();WL1();DL1();NL1();dJ4=[K70,H70,F70,$70,V70,z70,B70,U70,D70,O70,N70,IG0,_G0,yG0,bG0,xG0,uG0,iG0,rG0,oG0,sG0,tG0,Y70,X70,Q70,J70,G70,JN1,W70,Z70,XG0,JG0,GG0,QG0,gG0,mG0,lG0,dG0,pG0,cG0,nG0,b70,TG0,EG0,CG0,k70,v70,_70,y70,f70,h70,C70,I70,R70,j70,S70,L70,w70,M70,A70,P70,T70,E70],pJ4=HD1(),LL1=[...dJ4,...pJ4]});function cJ4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (u70(),wL1));return X.map((Q)=>{return{name:Q.name,inputSchema:z.toJSONSchema(Q.inputSchema,{unrepresentable:"any"}),outputSchema:Q.outputSchema?z.toJSONSchema(Q.outputSchema,{unrepresentable:"any"}):void 0,description:Q.description}})},data:Ha(DJ(),Y)},{data:Ka()},{data:Za(Y)}]}async function ML1(Y,X){try{let Q=pV(),J=new cV(process.env.ENCRYPTION_KEY||""),G=new tT(Q.db,J),K=new eT(Q.db),W=cJ4(Y);try{await K.create({organizationId:Y,slug:b5,name:Aq,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 yG.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await XO({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:X,connection_token:Z.data.connection_token??H})}))}catch(Q){console.error("Error creating default MCP connections:",Q)}}var AL1=S(()=>{eY();oT();lx();M50();A50();ax();b0();qO()});var g70,Au;var Pu=S(()=>{g70=["owner","admin","user"],Au=["owner","admin"]});var nJ4=(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"}}}}]}},PL1=(Y)=>{if(Y.providerId==="microsoft")return nJ4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function iJ4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function aJ4(){let Y=Math.floor(Math.random()*EL1.length),X=Math.floor(Math.random()*TL1.length),Q=EL1[Y]??"deco",J=TL1[X]??"studio";return`${Q}-${J}`}var TL1,EL1,rJ4,oJ4,Tu,sJ4,tJ4,eJ4,CL1,O9,IL1=void 0,Y54,X54,Q54,yG;var qO=S(()=>{Yo();SI0();Dj0();le();V10();HS0();xy();DS0();oT();w50();KB1();AL1();Pu();TL1=["labs","agent","studio","workspace","systems","core","cloud","works"],EL1=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];rJ4=Object.values(nw()).map((Y)=>Y.map((X)=>X.name)).flat(),oJ4={...Ay,self:["*",...rJ4]},Tu=i7(oJ4),sJ4=Tu.newRole({self:["*"],...TA.statements}),tJ4=Tu.newRole({self:["*"],...TA.statements}),eJ4=Tu.newRole({self:["*"],...TA.statements}),CL1=Object.values(nw()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),O9=_A.auth;if(O9.inviteEmailProviderId&&O9.emailProviders&&O9.emailProviders.length>0){let Y=mx(O9.emailProviders,O9.inviteEmailProviderId);if(Y){let X=gx(Y);IL1=async(Q)=>{let J=Q.inviter.user?.name||Q.inviter.user?.email,G=`${DJ()}/auth/accept-invitation?invitationId=${Q.invitation.id}&redirectTo=/`;await X({to:Q.email,subject:`Invitation to join ${Q.organization.name}`,html:`
1197
1197
  <h2>You've been invited!</h2>
1198
1198
  <p>${J} has invited you to join <strong>${Q.organization.name}</strong>.</p>
1199
1199
  <p><a href="${G}">Click here to accept the invitation</a></p>