decocms 2.186.7 → 2.186.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-CE4aMC_6.js → AlertCircle-BD5gSXQu.js} +1 -1
- package/dist/client/assets/{ArrowLeft-VzQjF5nf.js → ArrowLeft-DN3D0Zrv.js} +1 -1
- package/dist/client/assets/{ArrowUp-DVMY0e13.js → ArrowUp-D6ltkV3R.js} +1 -1
- package/dist/client/assets/{Check-BgcEZAFd.js → Check-Dczm9Dfw.js} +1 -1
- package/dist/client/assets/{ChevronDown-Ca93y5Zg.js → ChevronDown-CDxBhn_l.js} +1 -1
- package/dist/client/assets/{ChevronRight-iThFOnTS.js → ChevronRight-Dxvchjxo.js} +1 -1
- package/dist/client/assets/{ChevronUp-Dfrjh0kb.js → ChevronUp-BLNd6dNq.js} +1 -1
- package/dist/client/assets/{Container-BQWbDEy6.js → Container-CMPDG7Cp.js} +1 -1
- package/dist/client/assets/{Dataflow03-DdTzEDv9.js → Dataflow03-slF1Ax9G.js} +1 -1
- package/dist/client/assets/{FolderClosed-jb7WzUeW.js → FolderClosed-BKB_NgWm.js} +1 -1
- package/dist/client/assets/{Loading01-CrI0NwPE.js → Loading01-BVCg1O_G.js} +1 -1
- package/dist/client/assets/{Play-DSddPPya.js → Play-Bb4cvvVL.js} +1 -1
- package/dist/client/assets/{Plus-ltkKoqJz.js → Plus-DcVtqCMV.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-DN-y3At7.js → RefreshCcw01-Co0-i94o.js} +1 -1
- package/dist/client/assets/{SearchMd-CS43V34Y.js → SearchMd-CVvF1HpM.js} +1 -1
- package/dist/client/assets/{Settings01-ClJz1ULQ.js → Settings01-DpZ_tsoX.js} +1 -1
- package/dist/client/assets/{Trash01-fCw8HP0s.js → Trash01-CBP9WLeP.js} +1 -1
- package/dist/client/assets/{Type01-Dp2k0by5.js → Type01-CySkENi6.js} +1 -1
- package/dist/client/assets/{Upload01-3AVPYkeL.js → Upload01-BzGPegBj.js} +1 -1
- package/dist/client/assets/{User01-CKoZ8ZDH.js → User01-CItwHvE1.js} +1 -1
- package/dist/client/assets/{X-BNpME-HX.js → X-Dr-hR03I.js} +1 -1
- package/dist/client/assets/{XCircle-MpsZU5qt.js → XCircle-Z-JTmQ8v.js} +1 -1
- package/dist/client/assets/{XClose-DKDxXEaA.js → XClose-BLvk3pvY.js} +1 -1
- package/dist/client/assets/{Zap-kD49gPEF.js → Zap-CiHJmamA.js} +1 -1
- package/dist/client/assets/{agent-connections-preview-DusvXNLB.js → agent-connections-preview-BQSZMPrI.js} +1 -1
- package/dist/client/assets/{agent-detail-B-PecVBx.js → agent-detail-eyC4qU2J.js} +1 -1
- package/dist/client/assets/{agents-DTWgODy0.js → agents-DrhC84qH.js} +1 -1
- package/dist/client/assets/{ai-providers-logos-Bp_JBc4Z.js → ai-providers-logos-idzpcoUr.js} +1 -1
- package/dist/client/assets/{alert-dialog-DPu-w5FH.js → alert-dialog-Bke1xnyn.js} +1 -1
- package/dist/client/assets/{auth-catchall-CVoq5acq.js → auth-catchall-omtOF0fb.js} +1 -1
- package/dist/client/assets/{automation-detail-BtlNzqYH.js → automation-detail-Bc9ASowB.js} +1 -1
- package/dist/client/assets/{automations-B9MMi9MY.js → automations-Bp3tAuBH.js} +1 -1
- package/dist/client/assets/{avatar-DJ_eE6FL.js → avatar-BZ4Frci2.js} +1 -1
- package/dist/client/assets/{badge-Dg_rRuRo.js → badge-DGQ0gFlp.js} +1 -1
- package/dist/client/assets/{breadcrumb-B3Pzyfpg.js → breadcrumb-BBMvtdg-.js} +1 -1
- package/dist/client/assets/{card-CQTuw0Xi.js → card-CKN-JP9M.js} +1 -1
- package/dist/client/assets/{checkbox-pwwqVDt-.js → checkbox-Dzy6oaRF.js} +1 -1
- package/dist/client/assets/{collapsible-BpfdSPbv.js → collapsible-D84K6rP8.js} +1 -1
- package/dist/client/assets/{collection-detail-7hb0Mplz.js → collection-detail-w8yO-_Ye.js} +1 -1
- package/dist/client/assets/{collection-display-button-DgaN6ief.js → collection-display-button-ZvHBt_eA.js} +1 -1
- package/dist/client/assets/{collection-search-BxbLLE-D.js → collection-search-fzGK39qM.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-DhM52ivn.js → collection-table-wrapper-DsHGysPH.js} +1 -1
- package/dist/client/assets/{collection-tabs-B87Atjwc.js → collection-tabs-vUhndfXI.js} +1 -1
- package/dist/client/assets/{collections-pcWRi6G6.js → collections-BsFnKFn5.js} +1 -1
- package/dist/client/assets/{command-CIWQeRGP.js → command-BnzawGxz.js} +1 -1
- package/dist/client/assets/{connection-card-CM5AlZwH.js → connection-card-D7msIZJv.js} +1 -1
- package/dist/client/assets/{connection-detail-O3fmkpqe.js → connection-detail-D84CXhKZ.js} +1 -1
- package/dist/client/assets/{connections-BCkT2NPr.js → connections-CbWHLS_c.js} +1 -1
- package/dist/client/assets/constants-BqeudQjB.js +1 -0
- package/dist/client/assets/{constants-B7D0VCWO.js → constants-TLV7MTwP.js} +1 -1
- package/dist/client/assets/{context-IJmL4QO_.js → context-BSzlpoxW.js} +1 -1
- package/dist/client/assets/{create-organization-dialog-ixA2WoW7.js → create-organization-dialog-OZCitfn2.js} +1 -1
- package/dist/client/assets/{create-project-dialog-B6n_03Ug.js → create-project-dialog-RIITFpVV.js} +1 -1
- package/dist/client/assets/{danger-CYvp_RGb.js → danger-DuoByYJO.js} +1 -1
- package/dist/client/assets/{danger-zone-xpmW0-9o.js → danger-zone-CEP2ON89.js} +1 -1
- package/dist/client/assets/{dependencies-C9e_dQDy.js → dependencies-LZwXzbBO.js} +1 -1
- package/dist/client/assets/{dialog-Ce95gXqs.js → dialog-DCrLu7TC.js} +1 -1
- package/dist/client/assets/{drawer-ByM8CEL_.js → drawer-CwKj53Jm.js} +1 -1
- package/dist/client/assets/{dropdown-menu-BT7g2ayh.js → dropdown-menu-BK29e1o0.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-exCUjntN.js → dynamic-plugin-layout-C5CHlaVD.js} +1 -1
- package/dist/client/assets/{editable-task-title-wQy-5KA-.js → editable-task-title-HEFeF21g.js} +1 -1
- package/dist/client/assets/{empty-state-8546_PpL.js → empty-state-B8NhLY9v.js} +1 -1
- package/dist/client/assets/{empty-state-CjwgvmoI.js → empty-state-D4ck9NGY.js} +1 -1
- package/dist/client/assets/{env-vars-editor-Cn7u3DNm.js → env-vars-editor-CvqhjBEu.js} +1 -1
- package/dist/client/assets/{extract-connection-data-OUAaU9Od.js → extract-connection-data-NSojo21r.js} +1 -1
- package/dist/client/assets/{form-BxnLhCD_.js → form-DPsme8JL.js} +1 -1
- package/dist/client/assets/{general-CnJT7yxb.js → general-CPYyC5Rn.js} +1 -1
- package/dist/client/assets/{home-CVvG2Fqq.js → home-Cg6y-M7X.js} +1 -1
- package/dist/client/assets/{import-from-deco-dialog-Chrnp3Cw.js → import-from-deco-dialog-CBUqBAZP.js} +1 -1
- package/dist/client/assets/{index-CMA-66KF.js → index-2hR_U2H-.js} +1 -1
- package/dist/client/assets/{index-DXw26Swq.js → index-3WTtRDrt.js} +1 -1
- package/dist/client/assets/{index-DAKvcNkQ.js → index-BZyxukAe.js} +1 -1
- package/dist/client/assets/{index-CsLoKsqY.js → index-Bgix03M4.js} +1 -1
- package/dist/client/assets/{index-BcOdsrKl.js → index-BkAoKVx8.js} +1 -1
- package/dist/client/assets/{index-C-wrel8E.js → index-CoIN7QlF.js} +1 -1
- package/dist/client/assets/{index-DNarCA5m.js → index-CtkIjbbq.js} +1 -1
- package/dist/client/assets/{index-B62MiQAu.js → index-D49VqQ7Q.js} +2 -2
- package/dist/client/assets/{index-DrtlaMfG.js → index-D_CXrtwd.js} +1 -1
- package/dist/client/assets/{index-3yf2NnlI.js → index-Dg9iIj2F.js} +1 -1
- package/dist/client/assets/{index-DehDS4SM.js → index-DxaXuxCe.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-C4rkYsAc.js → infiniteQueryObserver-DiY9IZXI.js} +1 -1
- package/dist/client/assets/{input-BNSWRvAr.js → input-BoNWsfmK.js} +1 -1
- package/dist/client/assets/{integration-icon-BByVvYW2.js → integration-icon-ByIZ-Vgj.js} +1 -1
- package/dist/client/assets/{label-C-5U7XF4.js → label-DF2jcg2U.js} +1 -1
- package/dist/client/assets/{layout-DuIBVgOo.js → layout-CgN1mZAZ.js} +1 -1
- package/dist/client/assets/{layout-CxMMzlDg.js → layout-Dp8uiQPy.js} +1 -1
- package/dist/client/assets/{login-ayW5J8kp.js → login-EJWlcxg3.js} +1 -1
- package/dist/client/assets/{logo-upload-Cnlppzw5.js → logo-upload-D5UEFEut.js} +1 -1
- package/dist/client/assets/{mcp-app-renderer-C5hh7NUh.js → mcp-app-renderer-C8wEMNqP.js} +1 -1
- package/dist/client/assets/{mcp-server-card-3TrMzryK.js → mcp-server-card-xRGKpDYM.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-BHg2jU2j.js → mcp-server-detail-Dfcu5k0K.js} +2 -2
- package/dist/client/assets/{members-DR64AFBa.js → members-b1hYnwix.js} +1 -1
- package/dist/client/assets/{monaco-editor-0MGgMe6Z.js → monaco-editor-D1C0-UAW.js} +1 -1
- package/dist/client/assets/{monitoring-zjAHbr2Y.js → monitoring-DmCgdBgZ.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-edit-D0wDbirt.js → monitoring-dashboard-edit-DL4fVGYY.js} +1 -1
- package/dist/client/assets/{monitoring-dashboard-view-Cye--xow.js → monitoring-dashboard-view-BfDYcRJx.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-Br-gOcw_.js → monitoring-stats-row-Bzy3PCZQ.js} +1 -1
- package/dist/client/assets/{oauth-callback-C5qRKz1E.js → oauth-callback-N1SniIFs.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-Belxh9YS.js → oauth-callback-ai-provider-BZ8yDxr9.js} +1 -1
- package/dist/client/assets/{org-ai-providers-vLOcM2IN.js → org-ai-providers-DFHn6TCP.js} +1 -1
- package/dist/client/assets/{page-Bk-6gYjF.js → page-B721jXQm.js} +1 -1
- package/dist/client/assets/{page-D9taTz3x.js → page-BgKYb-6_.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-DwTx3Irb.js → plugin-empty-state-BIg-myPi.js} +1 -1
- package/dist/client/assets/{plugin-header-_SJ-AMks.js → plugin-header-CBfXQAQ5.js} +1 -1
- package/dist/client/assets/plugins-D7XVdEz7.js +1 -0
- package/dist/client/assets/{popover-CW4G5neq.js → popover-CvIauBBG.js} +1 -1
- package/dist/client/assets/{project-app-view-Cxge46GP.js → project-app-view-Wq81-D6Q.js} +1 -1
- package/dist/client/assets/{project-layout-CszLr05H.js → project-layout-ByRNQhjx.js} +1 -1
- package/dist/client/assets/{project-plugins-CB_lBTqe.js → project-plugins-8LQo3YBE.js} +1 -1
- package/dist/client/assets/{projects-list-BAFLJ8Ur.js → projects-list-CfdMQhGh.js} +1 -1
- package/dist/client/assets/{registry-layout-BFPpF2ab.js → registry-layout-BfWTztsz.js} +1 -1
- package/dist/client/assets/{registry-utils-DWGplsmC.js → registry-utils-Cz03qmOa.js} +1 -1
- package/dist/client/assets/{reset-password-D2kT9zWB.js → reset-password-Cj1A6uL-.js} +1 -1
- package/dist/client/assets/{resizable-DFwU4W6w.js → resizable-BceA9DHD.js} +1 -1
- package/dist/client/assets/{save-actions-CmbT6lbz.js → save-actions-BENpgKCD.js} +1 -1
- package/dist/client/assets/{scroll-area-DEb4D9kS.js → scroll-area-4KH7xRn7.js} +1 -1
- package/dist/client/assets/{select-BY6esNmT.js → select-DaOZXaTi.js} +1 -1
- package/dist/client/assets/{select-virtual-mcp-C6Eik732.js → select-virtual-mcp-CjfXEnho.js} +1 -1
- package/dist/client/assets/{shell-layout-BPQbdNig.js → shell-layout-85fLFVwf.js} +2 -2
- package/dist/client/assets/{sidebar-settings-LoxM-jfH.js → sidebar-settings-CvK0z-ir.js} +1 -1
- package/dist/client/assets/{skeleton-H6tvOoEj.js → skeleton-CLUePAN0.js} +1 -1
- package/dist/client/assets/{spinner-X15c9Qjw.js → spinner-7bhznOFa.js} +1 -1
- package/dist/client/assets/{store-invite-CbJMqLqm.js → store-invite-fWGyKl7o.js} +1 -1
- package/dist/client/assets/{switch-1W8o5vam.js → switch-yIP7Yj81.js} +1 -1
- package/dist/client/assets/{table-oKRuJlES.js → table-w828HACk.js} +1 -1
- package/dist/client/assets/{tabs-wloAa-G_.js → tabs-Du7uGFqP.js} +1 -1
- package/dist/client/assets/{task-status-DtA3vCfp.js → task-status-RaaIa42V.js} +1 -1
- package/dist/client/assets/{tasks-panel-CfTCpIaN.js → tasks-panel-CT_8gQvL.js} +1 -1
- package/dist/client/assets/tasks-x-XNinod.js +1 -0
- package/dist/client/assets/{textarea-Db5eGrte.js → textarea-D30IrLHN.js} +1 -1
- package/dist/client/assets/{time-range-picker-kvCom5E0.js → time-range-picker-DVyznax9.js} +1 -1
- package/dist/client/assets/{toggle-group-nuX--X8U.js → toggle-group-DN_3BuPh.js} +1 -1
- package/dist/client/assets/{tools-list-CzNHOfxQ.js → tools-list-BQiqsKN2.js} +1 -1
- package/dist/client/assets/{tooltip-Cz2tQy7f.js → tooltip-DJkxXViN.js} +1 -1
- package/dist/client/assets/{types-B85FeN8J.js → types-llndI7Ky.js} +1 -1
- package/dist/client/assets/{use-automations-Bmzs_h6Z.js → use-automations-DhJnP2CA.js} +1 -1
- package/dist/client/assets/{use-collections-Cw-CkhM5.js → use-collections-Dmxer7H8.js} +1 -1
- package/dist/client/assets/{use-connection-u5F7YTDM.js → use-connection-Yjy9d1tW.js} +1 -1
- package/dist/client/assets/{use-copy-DXoYLkGY.js → use-copy-DYNuGKRz.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-B6BY4hNy.js → use-create-virtual-mcp-CEBO__7d.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-BCAoqpbu.js → use-infinite-scroll-JQzncaIM.js} +1 -1
- package/dist/client/assets/{use-install-from-registry-Bh4CcElp.js → use-install-from-registry-Du1Xu864.js} +1 -1
- package/dist/client/assets/{use-list-state-J17yqbOy.js → use-list-state-BG8gUSh9.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-C4rv2YNo.js → use-mcp-prompts-DY_yf0WC.js} +1 -1
- package/dist/client/assets/{use-mcp-resources-C2RRZo8d.js → use-mcp-resources-BnmpykKD.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-CS9dH9Hk.js → use-mcp-tools-CmOfbC2t.js} +1 -1
- package/dist/client/assets/{use-members-L6twvwj_.js → use-members-BZM-R1qG.js} +1 -1
- package/dist/client/assets/{use-project-DmzlV8IR.js → use-project-W-5l7vWa.js} +1 -1
- package/dist/client/assets/{use-store-discovery-B_zVCnQi.js → use-store-discovery-DfcEdPeQ.js} +1 -1
- package/dist/client/assets/{use-view-mode-DDZQlalb.js → use-view-mode-BGEJ9JzM.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-BQ1ML2v_.js → use-virtual-mcp-2qhGJdPe.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-D8TjRj27.js +1 -0
- package/dist/client/assets/{useMutation-5tF0rOhi.js → useMutation-BTUmJffP.js} +1 -1
- package/dist/client/assets/useQuery-CvkH2gG1.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-DRfcYfXZ.js +1 -0
- package/dist/client/assets/{user-Wn7CHNY8.js → user-DXILGeu2.js} +1 -1
- package/dist/client/assets/{workflow-DGOWYrJv.js → workflow-CBGVBFDu.js} +1 -1
- package/dist/client/assets/{workflow-CehUk0kO.js → workflow-ClE3y6g8.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +231 -231
- package/package.json +1 -1
- package/dist/client/assets/constants-B_S2_Dfe.js +0 -1
- package/dist/client/assets/plugins-_-cF0kV-.js +0 -1
- package/dist/client/assets/tasks-DYQdfmG5.js +0 -1
- package/dist/client/assets/useInfiniteQuery-D_7z7Ekt.js +0 -1
- package/dist/client/assets/useQuery-Cr3Ibn6v.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-UikfpG9C.js +0 -1
- package/dist/server/node_modules/onetime/index.d.ts +0 -64
- package/dist/server/node_modules/onetime/index.js +0 -44
- package/dist/server/node_modules/onetime/license +0 -9
- package/dist/server/node_modules/onetime/package.json +0 -43
- package/dist/server/node_modules/onetime/readme.md +0 -94
- package/dist/server/node_modules/xtend/.jshintrc +0 -30
- package/dist/server/node_modules/xtend/LICENSE +0 -20
- package/dist/server/node_modules/xtend/README.md +0 -32
- package/dist/server/node_modules/xtend/immutable.js +0 -19
- package/dist/server/node_modules/xtend/mutable.js +0 -17
- package/dist/server/node_modules/xtend/package.json +0 -55
- package/dist/server/node_modules/xtend/test.js +0 -103
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as me,j as t,E as Pt,r as X,c as $t,x as Et,f as Ot,e as Lt,g as Vt,D as zt,F as et,v as Ft,t as Mt,b as Ut,B as $,y as Z,O as G,w as E,i as Bt,a as Rt,K as Ht}from"./index-B62MiQAu.js";import{g as Kt}from"./generate-id-Dyweu44Y.js";import{C as Xt}from"./collection-display-button-DgaN6ief.js";import{C as Wt}from"./collection-search-BxbLLE-D.js";import{C as Gt}from"./collection-tabs-B87Atjwc.js";import{C as Ne}from"./connection-card-CM5AlZwH.js";import{E as qt}from"./empty-state-8546_PpL.js";import{s as Ae,i as Qt,I as Ie,a as Yt}from"./integration-icon-BByVvYW2.js";import{u as tt,P as ae}from"./index-DNarCA5m.js";import{u as Jt,f as Zt,g as nt}from"./registry-utils-DWGplsmC.js";import{u as en}from"./use-infinite-scroll-BCAoqpbu.js";import{u as tn}from"./use-list-state-J17yqbOy.js";import{u as nn}from"./use-store-discovery-B_zVCnQi.js";import{g as ne}from"./connection-slug-Bw8dtz1U.js";import{s as sn}from"./slugify-CEUa2lfQ.js";import{f as Pe,a as $e,b as Ee,c as Oe,d as Le,e as Ve,A as ze,h as Fe}from"./alert-dialog-DPu-w5FH.js";import{B as on,a as rn,b as cn,c as ln}from"./breadcrumb-B3Pzyfpg.js";import{C as ct}from"./checkbox-pwwqVDt-.js";import{a as lt,D as at,b as dt,c as pt,e as ut,d as mt}from"./dialog-Ce95gXqs.js";import{D as an,a as dn,b as pn,c as un,d as mn,e as hn,f as xn}from"./drawer-ByM8CEL_.js";import{u as fn}from"./tooltip-Cz2tQy7f.js";import{D as Me,a as Ue,b as Be,c as pe}from"./dropdown-menu-BT7g2ayh.js";import{F as U,b as B,c as R,d as H,f as K,a as st}from"./form-BxnLhCD_.js";import{I as J}from"./input-BNSWRvAr.js";import{S as gn,a as jn,b as yn,c as vn,d as de}from"./select-BY6esNmT.js";import{T as Cn}from"./textarea-Db5eGrte.js";import{a as bn,b as ot}from"./use-connection-u5F7YTDM.js";import{u as Nn,a as Sn}from"./constants-B7D0VCWO.js";import{b as kn}from"./use-virtual-mcp-BQ1ML2v_.js";import{i as _n}from"./XCircle-MpsZU5qt.js";import{t as Tn}from"./ChevronDown-Ca93y5Zg.js";import{n as ue}from"./Container-BQWbDEy6.js";import{i as ht,s as xt}from"./RefreshCcw01-DN-y3At7.js";import{i as Se}from"./Loading01-CrI0NwPE.js";import{s as ft}from"./Plus-ltkKoqJz.js";import{s as gt}from"./Trash01-fCw8HP0s.js";import{s as jt}from"./XClose-DKDxXEaA.js";import{r as wn,E as Dn,c as An,e as yt}from"./env-vars-editor-Cn7u3DNm.js";import{e as In}from"./extract-connection-data-OUAaU9Od.js";import"./ArrowUp-DVMY0e13.js";import"./Check-BgcEZAFd.js";import"./Type01-Dp2k0by5.js";import"./badge-Dg_rRuRo.js";import"./SearchMd-CS43V34Y.js";import"./card-CQTuw0Xi.js";import"./AlertCircle-CE4aMC_6.js";import"./ArrowLeft-VzQjF5nf.js";import"./ChevronRight-iThFOnTS.js";import"./ChevronUp-Dfrjh0kb.js";import"./Play-DSddPPya.js";import"./Dataflow03-DdTzEDv9.js";import"./FolderClosed-jb7WzUeW.js";import"./Settings01-ClJz1ULQ.js";import"./Upload01-3AVPYkeL.js";import"./User01-CKoZ8ZDH.js";import"./X-BNpME-HX.js";import"./Zap-kD49gPEF.js";import"./useQuery-Cr3Ibn6v.js";import"./useMutation-5tF0rOhi.js";import"./workflow-DGOWYrJv.js";import"./collections-pcWRi6G6.js";import"./use-view-mode-DDZQlalb.js";import"./useInfiniteQuery-D_7z7Ekt.js";import"./infiniteQueryObserver-C4rkYsAc.js";import"./index-BcOdsrKl.js";import"./label-C-5U7XF4.js";import"./index-BdQq_4o_.js";import"./use-collections-Cw-CkhM5.js";import"./constants-B_S2_Dfe.js";function it(i){return ne(i)}function Pn(i){const e=new Map;for(const c of i){if(c.connection_type==="VIRTUAL")continue;const a=it(c),f=e.get(a);f?f.push(c):e.set(a,[c])}const o=[],d=new Set;for(const c of i){if(c.connection_type==="VIRTUAL")continue;const a=it(c);if(d.has(a))continue;d.add(a);const f=e.get(a),h=f[0];f.length===1?o.push({type:"single",connection:h}):o.push({type:"group",key:a,icon:h.icon,title:h.app_name?h.title.replace(/\s*\(\d+\)\s*$/,""):h.title,connections:f})}return o}function ke(i){const e=i.trim();if(!e)return"";try{const o=new URL(e),d=o.pathname.length>1?o.pathname.replace(/\/+$/,""):o.pathname;return`${o.origin}${d}`}catch{return e.replace(/\/+$/,"")}}function $n(i){const e=i.trim().split(/\s+/).filter(Boolean);if(e.length<2)return null;const o=e[0]?.toLowerCase();if(o!=="npx"&&o!=="bunx")return null;const c=e.slice(1).find(a=>!a.startsWith("-"));return c?{packageName:c}:null}function be(i){const{uiType:e}=i,o=ke(i.connectionUrl??"");if((e==="HTTP"||e==="SSE"||e==="Websocket")&&o===ke("https://api.githubcopilot.com/mcp/"))return{id:"github",title:"GitHub",description:"GitHub Copilot MCP",token:{label:"GitHub PAT",placeholder:"github_pat_…",helperText:"Paste a GitHub Personal Access Token (PAT)"}};const d=(i.npxPackage??"").trim();return e==="NPX"&&d==="@perplexity-ai/mcp-server"?{id:"perplexity",title:"Perplexity",description:"Perplexity MCP Server",envVarKeys:["PERPLEXITY_API_KEY"]}:null}function rt(i){if(i.registryItems.length===0||i.uiType!=="HTTP"&&i.uiType!=="SSE"&&i.uiType!=="Websocket")return null;const e=ke(i.connectionUrl??"");if(!e)return null;const o=i.registryItems.find(a=>(a.server?.remotes??[]).some(h=>ke(h.url??"")===e));if(!o)return null;const d=o.title||o.name||o.server?.title||o.server?.name||"",c=o.server?.description||o.description||o.summary||null;return d?{id:"registry",title:d,description:c}:null}function En(i,e){const o={command:"npx",args:["-y",i]},d=yt(e);return Object.keys(d).length>0&&(o.envVars=d),o}function On(i,e,o,d){const c={command:i};e.trim()&&(c.args=e.trim().split(/\s+/)),o?.trim()&&(c.cwd=o.trim());const a=yt(d);return Object.keys(a).length>0&&(c.envVars=a),c}function Ln(i){return i.command==="npx"}function Vn(i){return i.args?.find(e=>!e.startsWith("-"))??""}function zn(i){return{command:i.command,args:i.args?.join(" ")??"",cwd:i.cwd??""}}function Fn(i,e){switch(e.type){case"edit":return{mode:"editing",connection:e.connection};case"delete":return{mode:"deleting",connection:e.connection};case"force-delete":return{mode:"force-deleting",connection:e.connection,agentNames:e.agentNames};case"close":return{mode:"idle"}}}function Mn(i){const e=me.c(51),{group:o,onOpen:d,selectionMode:c,selectedIds:a,onToggleSelect:f}=i;let h;if(e[0]!==o.connections||e[1]!==a){let S;e[3]!==a?(S=oe=>a.has(oe.id),e[3]=a,e[4]=S):S=e[4],h=o.connections.every(S),e[0]=o.connections,e[1]=a,e[2]=h}else h=e[2];const g=h;let k;if(e[5]!==o.connections||e[6]!==a){let S;e[8]!==a?(S=oe=>a.has(oe.id),e[8]=a,e[9]=S):S=e[9],k=o.connections.some(S),e[5]=o.connections,e[6]=a,e[7]=k}else k=e[7];const y=k,m=`${o.connections.length} instances`;let b;e[10]!==o.icon||e[11]!==o.title||e[12]!==m?(b={title:o.title,icon:o.icon,description:m},e[10]=o.icon,e[11]=o.title,e[12]=m,e[13]=b):b=e[13];let x;e[14]!==g||e[15]!==o.connections||e[16]!==d||e[17]!==f||e[18]!==a||e[19]!==c?(x=()=>c?(()=>{for(const S of o.connections)g?a.has(S.id)&&f(S.id):a.has(S.id)||f(S.id)})():d(),e[14]=g,e[15]=o.connections,e[16]=d,e[17]=f,e[18]=a,e[19]=c,e[20]=x):x=e[20];const C=c&&g&&"ring-2 ring-primary",N=c&&y&&!g&&"ring-1 ring-primary/50";let A;e[21]!==C||e[22]!==N?(A=Z(C,N),e[21]=C,e[22]=N,e[23]=A):A=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(ue,{}),e[24]=I):I=e[24];let _;e[25]!==g||e[26]!==o.connections||e[27]!==f||e[28]!==a||e[29]!==c||e[30]!==y?(_=c?t.jsx(ct,{checked:g?!0:y?"indeterminate":!1,onCheckedChange:()=>{for(const S of o.connections)g?a.has(S.id)&&f(S.id):a.has(S.id)||f(S.id)}}):t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}),t.jsxs("span",{className:"text-xs text-muted-foreground font-normal tabular-nums",children:["x",o.connections.length]})]}),e[25]=g,e[26]=o.connections,e[27]=f,e[28]=a,e[29]=c,e[30]=y,e[31]=_):_=e[31];const L=c?"w-8 opacity-100":"w-0 opacity-0 group-hover:w-8 group-hover:opacity-100";let T;e[32]!==L?(T=Z("overflow-hidden transition-all duration-150 ease-out",L),e[32]=L,e[33]=T):T=e[33];let ee;e[34]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(Ue,{asChild:!0,children:t.jsx($,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Bn,children:t.jsx(ht,{size:20})})}),e[34]=ee):ee=e[34];let F;e[35]!==d?(F=S=>{S.stopPropagation(),d()},e[35]=d,e[36]=F):F=e[36];let te;e[37]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx(xt,{size:16}),e[37]=te):te=e[37];let M;e[38]!==F?(M=t.jsxs(Me,{children:[ee,t.jsx(Be,{align:"end",onClick:Un,children:t.jsxs(pe,{onClick:F,children:[te,"Open"]})})]}),e[38]=F,e[39]=M):M=e[39];let q;e[40]!==T||e[41]!==M?(q=t.jsx("div",{className:T,children:M}),e[40]=T,e[41]=M,e[42]=q):q=e[42];let W;e[43]!==_||e[44]!==q?(W=t.jsxs("div",{className:"flex items-center gap-1",children:[_,q]}),e[43]=_,e[44]=q,e[45]=W):W=e[45];let se;return e[46]!==W||e[47]!==b||e[48]!==x||e[49]!==A?(se=t.jsx(t.Fragment,{children:t.jsx(Ne,{connection:b,onClick:x,className:A,fallbackIcon:I,headerActionsAlwaysVisible:!0,headerActions:W})}),e[46]=W,e[47]=b,e[48]=x,e[49]=A,e[50]=se):se=e[50],se}function Un(i){return i.stopPropagation()}function Bn(i){return i.stopPropagation()}function Rn(i){const e=me.c(28),{count:o,total:d,onSelectAll:c,onDeselectAll:a,onDelete:f,onAddToAgent:h,onToggleStatus:g,onCancel:k}=i;if(o===0)return null;let y;e[0]!==o?(y=t.jsxs("div",{className:"text-xs text-muted-foreground pr-1 tabular-nums",children:[o," selected"]}),e[0]=o,e[1]=y):y=e[1];let m;e[2]!==o||e[3]!==a||e[4]!==c||e[5]!==d?(m=o<d?t.jsxs($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:c,children:["Select all (",d,")"]}):t.jsx($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:a,children:"Clear selection"}),e[2]=o,e[3]=a,e[4]=c,e[5]=d,e[6]=m):m=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(ft,{size:13}),e[7]=b):b=e[7];let x;e[8]!==h?(x=t.jsxs($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:h,children:[b,"Add to Agent"]}),e[8]=h,e[9]=x):x=e[9];let C;e[10]!==g?(C=t.jsx($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:()=>g("active"),children:"Enable"}),e[10]=g,e[11]=C):C=e[11];let N;e[12]!==g?(N=t.jsx($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:()=>g("inactive"),children:"Disable"}),e[12]=g,e[13]=N):N=e[13];let A;e[14]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(gt,{size:13}),e[14]=A):A=e[14];let I;e[15]!==f?(I=t.jsxs($,{variant:"destructive",size:"sm",className:"h-7 text-xs px-2",onClick:f,children:[A,"Delete"]}),e[15]=f,e[16]=I):I=e[16];let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx(jt,{size:13}),e[17]=_):_=e[17];let L;e[18]!==k?(L=t.jsx($,{variant:"ghost",size:"sm",className:"h-7 text-xs px-2",onClick:k,children:_}),e[18]=k,e[19]=L):L=e[19];let T;return e[20]!==y||e[21]!==L||e[22]!==m||e[23]!==x||e[24]!==C||e[25]!==N||e[26]!==I?(T=t.jsx("div",{className:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2",children:t.jsxs("div",{className:"rounded-xl border border-border bg-background/95 shadow-lg backdrop-blur px-3 py-2 flex items-center gap-2",children:[y,m,x,C,N,I,L]})}),e[20]=y,e[21]=L,e[22]=m,e[23]=x,e[24]=C,e[25]=N,e[26]=I,e[27]=T):T=e[27],T}function Hn(i){const e=me.c(25),{open:o,onOpenChange:d,agents:c,onConfirm:a}=i,[f,h]=X.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsxs(dt,{children:[t.jsx(pt,{children:"Add to Agent"}),t.jsx(ut,{children:"Select an agent to add the selected connections to."})]}),e[0]=g):g=e[0];let k;e[1]!==c||e[2]!==f?(k=c.length===0?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No agents found"}):c.map(_=>t.jsxs("button",{type:"button",onClick:()=>h(_.id),className:Z("flex items-center gap-3 w-full rounded-md px-3 py-2 text-left transition-colors",f===_.id?"bg-primary/10 ring-1 ring-primary":"hover:bg-muted/50"),children:[t.jsx(Ie,{icon:_.icon,name:_.title,size:"sm",className:"shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:_.title}),_.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:_.description})]})]},_.id)),e[1]=c,e[2]=f,e[3]=k):k=e[3];let y;e[4]!==k?(y=t.jsx("div",{className:"max-h-60 overflow-auto py-2 space-y-1",children:k}),e[4]=k,e[5]=y):y=e[5];let m;e[6]!==d?(m=t.jsx($,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e[6]=d,e[7]=m):m=e[7];const b=!f;let x;e[8]!==a||e[9]!==d||e[10]!==f?(x=()=>{f&&(a(f),d(!1),h(null))},e[8]=a,e[9]=d,e[10]=f,e[11]=x):x=e[11];let C;e[12]!==b||e[13]!==x?(C=t.jsx($,{disabled:b,onClick:x,children:"Add"}),e[12]=b,e[13]=x,e[14]=C):C=e[14];let N;e[15]!==m||e[16]!==C?(N=t.jsxs(mt,{children:[m,C]}),e[15]=m,e[16]=C,e[17]=N):N=e[17];let A;e[18]!==y||e[19]!==N?(A=t.jsxs(at,{className:"sm:max-w-[400px]",children:[g,y,N]}),e[18]=y,e[19]=N,e[20]=A):A=e[20];let I;return e[21]!==d||e[22]!==o||e[23]!==A?(I=t.jsx(lt,{open:o,onOpenChange:d,children:A}),e[21]=d,e[22]=o,e[23]=A,e[24]=I):I=e[24],I}function Kn(i){const e=me.c(20),{open:o,onOpenChange:d,count:c,onConfirm:a}=i,f=c!==1?"s":"";let h;e[0]!==c||e[1]!==f?(h=t.jsxs(Oe,{children:["Delete ",c," connection",f,"?"]}),e[0]=c,e[1]=f,e[2]=h):h=e[2];const g=c!==1?"s":"";let k;e[3]!==g?(k=t.jsxs(Le,{children:["This will permanently delete the selected connection",g,". This action cannot be undone."]}),e[3]=g,e[4]=k):k=e[4];let y;e[5]!==h||e[6]!==k?(y=t.jsxs(Ee,{children:[h,k]}),e[5]=h,e[6]=k,e[7]=y):y=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(ze,{children:"Cancel"}),e[8]=m):m=e[8];const b=c!==1?"s":"";let x;e[9]!==c||e[10]!==a||e[11]!==b?(x=t.jsxs(Ve,{children:[m,t.jsxs(Fe,{onClick:a,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:["Delete ",c," connection",b]})]}),e[9]=c,e[10]=a,e[11]=b,e[12]=x):x=e[12];let C;e[13]!==y||e[14]!==x?(C=t.jsxs($e,{children:[y,x]}),e[13]=y,e[14]=x,e[15]=C):C=e[15];let N;return e[16]!==d||e[17]!==o||e[18]!==C?(N=t.jsx(Pe,{open:o,onOpenChange:d,children:C}),e[16]=d,e[17]=o,e[18]=C,e[19]=N):N=e[19],N}function Xn(){const{org:i}=$t(),e=Et(),o=Ot(),d=Lt({strict:!1}),{data:c}=Vt.useSession(),{stdioEnabled:a}=zt(),f=fn(),h=tn({namespace:i.slug,resource:"connections"}),g=bn(),k=ot(h),y=ot(),[m,b]=X.useReducer(Fn,{mode:"idle"}),[x,C]=X.useState(new Set),N=x.size>0,[A,I]=X.useState(!1),[_,L]=X.useState(!1),[T,ee]=tt(et.connectionsTab(i.slug),n=>d.tab==="all"||d.tab==="connected"?d.tab:n??"all"),[F,te]=X.useState("ALL"),[M,q]=X.useState("ALL"),W=kn(),S=k.filter(n=>!(n.connection_type==="VIRTUAL"||F!=="ALL"&&n.connection_type!==F||M!=="ALL"&&n.status!==M)),oe=Pn(S),he=n=>{C(s=>{const r=new Set(s);return r.has(n)?r.delete(n):r.add(n),r})},xe=()=>{C(new Set)},Q=Jt(y).sort((n,s)=>{const r=n.app_name==="@deco/management-mcp",p=s.app_name==="@deco/management-mcp";return r&&!p?1:!r&&p?-1:0}),[ie,vt]=tt(et.selectedRegistry(i.slug),n=>n??""),Re=(ie?Q.find(n=>n.id===ie):void 0)??Q[0],_e=Re?.id??"",Ct=Zt(Re?.tools),re=nn({registryId:_e,listToolName:Ct}),Te=re.items,bt=en(re.loadMore,re.hasMore,re.isLoadingMore),He=new Set(y.filter(n=>n.connection_type!=="VIRTUAL"&&n.app_name).map(n=>n.app_name)),Y=h.search.toLowerCase(),Ke=T==="all"||Y?Te.filter(n=>{if(!Y)return!0;const s=n._meta?.["mcp.mesh"],r=[s?.friendly_name,n.server?.name,n.server?.title,n.name,n.title,n.id].filter(Boolean).join(" "),p=[s?.short_description,s?.mesh_description,n.server?.description,n.description].filter(Boolean).join(" ");return r.toLowerCase().includes(Y)||p.toLowerCase().includes(Y)}):[],fe=Ke.filter(n=>n.verified||n._meta?.["mcp.mesh"]?.verified||n.meta?.verified),ge=Ke.filter(n=>!n.verified&&!n._meta?.["mcp.mesh"]?.verified&&!n.meta?.verified),Nt=T==="all"&&!Y?[]:oe,Xe=n=>{const s=sn(n.name||n.title||n.server?.title||""),r=typeof n.id=="string"&&n.id.includes("/"),p=typeof n.server?.name=="string"&&n.server.name.includes("/"),j=r&&!p?n.id:n.server?.name||n.id||"";o({to:"/$org/$project/store/$appName",params:{org:i.slug,project:G,appName:s},search:{registryId:_e,serverName:j}})},[je,we]=X.useState(null),We=async n=>{if(!(!i||!c?.user?.id)){we(n.id);try{const s=In(n,i.id,c.user.id,{remoteIndex:0}),r=s.connection_type==="STDIO",p=!!s.connection_url,j=r&&s.connection_headers&&typeof s.connection_headers=="object"&&"command"in s.connection_headers;if(!p&&!j){E.error("This MCP Server cannot be connected: no connection method available"),we(null);return}const l=n.id??n.title,P=y.filter(z=>z.app_name===l||z.title===s.title);if(P.length>0){const z=s.title||"MCP Server";s.title=`${z} (${P.length+1})`}const{id:v}=await g.create.mutateAsync(s),D=new URL(`/mcp/${v}`,window.location.origin),Ce=await Bt({url:D.href,token:null});if(Ce.supportsOAuth&&!Ce.isAuthenticated){const{token:z,tokenInfo:O,error:Ze}=await Rt({connectionId:v});if(Ze||!z){E.error(`Authentication failed: ${Ze??"no token received"}`);return}else{if(O)try{(await fetch(`/api/connections/${v}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:O.accessToken,refreshToken:O.refreshToken,expiresIn:O.expiresIn,scope:O.scope,clientId:O.clientId,clientSecret:O.clientSecret,tokenEndpoint:O.tokenEndpoint})})).ok?await g.update.mutateAsync({id:v,data:{}}):await g.update.mutateAsync({id:v,data:{connection_token:z}})}catch{await g.update.mutateAsync({id:v,data:{connection_token:z}})}else await g.update.mutateAsync({id:v,data:{connection_token:z}});await e.invalidateQueries({queryKey:Ht.isMCPAuthenticated(D.href,null)}),E.success("Authentication successful")}}E.success("Connected successfully")}catch(s){E.error(`Failed to connect: ${s instanceof Error?s.message:String(s)}`)}finally{we(null)}}},Ge=d.action==="create",St=()=>{o({to:"/$org/$project/mcps",params:{org:i.slug,project:G},search:{action:"create"}})},qe=()=>{o({to:"/$org/$project/mcps",params:{org:i.slug,project:G},search:{}})},u=Ft({resolver:Mt(An),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),V=u.watch("ui_type"),Qe=u.watch("connection_url"),kt=u.watch("npx_package"),ce=be({uiType:V,connectionUrl:Qe??"",npxPackage:kt??""})??rt({uiType:V,connectionUrl:Qe??"",registryItems:Te}),w=m.mode==="editing"?m.connection:null;X.useEffect(()=>{if(w){const n=Ut(w.connection_headers)?w.connection_headers:null;if(n&&w.connection_type==="STDIO"){const s=wn(n.envVars);if(Ln(n)){const r=Vn(n);u.reset({title:w.title,description:w.description,icon:w.icon??null,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:r,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:s})}else{const r=zn(n);u.reset({title:w.title,description:w.description,icon:w.icon??null,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:r.command,stdio_args:r.args,stdio_cwd:r.cwd,env_vars:s})}}else u.reset({title:w.title,description:w.description,icon:w.icon??null,ui_type:w.connection_type,connection_url:w.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})}else u.reset({title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})},[w,u]);const le=Nn({connectionId:Sn,orgId:i.id}),ye=()=>{e.invalidateQueries({predicate:n=>{const s=n.queryKey;return s[1]===i.id&&s[3]==="collection"&&s[4]==="CONNECTIONS"}})},_t=async()=>{I(!1);const n=[...x];let s=0;for(const r of n)try{(await le.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:r,force:!0}})).isError||s++}catch{}ye(),E.success(`Deleted ${s} connection${s!==1?"s":""}`),xe()},Tt=async n=>{const s=[...x];let r=0;for(const p of s)try{await g.update.mutateAsync({id:p,data:{status:n}}),r++}catch{}ye(),E.success(`${n==="active"?"Enabled":"Disabled"} ${r} connection${r!==1?"s":""}`),xe()},wt=async n=>{const s=W.find(j=>j.id===n);if(!s||!le)return;const r=new Set(s.connections.map(j=>j.connection_id)),p=[...x].filter(j=>!r.has(j)).map(j=>({connection_id:j,selected_tools:null,selected_resources:null,selected_prompts:null}));if(p.length===0){E.info("All selected connections are already in that agent");return}try{await le.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:n,data:{connections:[...s.connections,...p]}}}),e.invalidateQueries({predicate:j=>{const l=j.queryKey;return l[1]===i.id&&l[3]==="collection"&&l[4]==="VIRTUAL_MCP"}}),E.success(`Added ${p.length} connection${p.length!==1?"s":""} to "${s.title}"`),xe()}catch{E.error("Failed to add connections to agent")}},Ye=n=>{const s=n.content;return Array.isArray(s)&&s[0]?.type==="text"&&typeof s[0].text=="string"?s[0].text:"Unknown error"},Dt=async()=>{if(m.mode!=="deleting")return;const n=m.connection;b({type:"close"});try{const s=await le.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:n.id}});if(s.isError){const r=Ye(s),p=r.replace(/^Error:\s*/,"");try{const j=JSON.parse(p);if(j.code==="CONNECTION_IN_USE"&&j.agentNames){b({type:"force-delete",connection:n,agentNames:j.agentNames.map(l=>`"${l}"`).join(", ")});return}}catch{}E.error(`Failed to delete connection: ${r}`);return}ye(),E.success("Connection deleted successfully")}catch(s){const r=s instanceof Error?s.message:String(s);E.error(`Failed to delete connection: ${r}`)}},At=async()=>{if(m.mode!=="force-deleting")return;const n=m.connection.id;b({type:"close"});try{const s=await le.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:n,force:!0}});if(s.isError){E.error(`Failed to delete connection: ${Ye(s)}`);return}ye(),E.success("Connection deleted successfully")}catch(s){const r=s instanceof Error?s.message:String(s);E.error(`Failed to delete connection: ${r}`)}},Je=async n=>{let s,r=null,p=null,j=null;if(n.ui_type==="NPX"?(s="STDIO",r="",j=En(n.npx_package||"",n.env_vars||[])):n.ui_type==="STDIO"?(s="STDIO",r="",j=On(n.stdio_command||"",n.stdio_args||"",n.stdio_cwd,n.env_vars||[])):(s=n.ui_type,r=n.connection_url||"",p=n.connection_token||null),w){await g.update.mutateAsync({id:w.id,data:{title:n.title,description:n.description||null,icon:n.icon??null,connection_type:s,connection_url:r,...p&&{connection_token:p},...j&&{connection_headers:j}}}),b({type:"close"}),u.reset();return}const l=Kt("conn");await g.create.mutateAsync({id:l,title:n.title,description:n.description||null,connection_type:s,connection_url:r,connection_token:p,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:c?.user?.id||"system",organization_id:i.id,icon:n.icon??null,app_name:null,app_id:null,connection_headers:j,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),qe(),u.reset(),o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne({app_name:null,connection_url:r,title:n.title,id:l})}})},De=n=>{n||(Ge?qe():b({type:"close"}),u.reset())},ve=n=>{const s=n.trim();if(!s)return;const r=!!u.formState.dirtyFields.title,p=!!u.formState.dirtyFields.description,j=!!u.formState.dirtyFields.env_vars,l=v=>{if(v&&(!r&&!u.getValues("title").trim()&&v.title&&u.setValue("title",v.title,{shouldDirty:!1}),!p&&!(u.getValues("description")??"").trim()&&v.description&&u.setValue("description",v.description,{shouldDirty:!1}),!j&&v.envVarKeys?.length)){const D=u.getValues("env_vars")??[],Ce=new Set(D.map(O=>O.key)),z=v.envVarKeys.filter(O=>!Ce.has(O));z.length>0&&u.setValue("env_vars",[...D,...z.map(O=>({key:O,value:""}))],{shouldDirty:!0})}},P=$n(s);if(P&&a){u.setValue("ui_type","NPX",{shouldDirty:!0}),u.setValue("npx_package",P.packageName,{shouldDirty:!0}),u.setValue("connection_url","",{shouldDirty:!0}),u.setValue("connection_token",null,{shouldDirty:!0}),l(be({uiType:"NPX",npxPackage:P.packageName}));return}if(s.startsWith("http://")||s.startsWith("https://")){const v=V==="HTTP"||V==="SSE"||V==="Websocket"?V:"HTTP";u.setValue("ui_type",v,{shouldDirty:!0}),u.setValue("connection_url",s,{shouldDirty:!0}),l(be({uiType:v,connectionUrl:s})??rt({uiType:v,connectionUrl:s,registryItems:Te}));return}V==="NPX"&&l(be({uiType:"NPX",npxPackage:s}))},It=t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs($,{variant:"outline",onClick:St,size:"sm",className:"h-7 w-7 px-0 sm:w-auto sm:px-3 rounded-lg text-sm font-medium",children:[t.jsx(ft,{size:14,className:"sm:hidden"}),t.jsx("span",{className:"hidden sm:inline",children:"Custom Connection"})]})});return t.jsx(t.Fragment,{children:t.jsxs(ae,{children:[(()=>{const n=w?"Edit Connection":"Create Connection",s=w?"Update the connection details below.":"Create a custom connection in your organization. Fill in the details below.",r=u.formState.isSubmitting?"Saving...":w?"Update Connection":"Create Connection",p=t.jsxs("div",{className:"grid gap-4",children:[t.jsx(U,{control:u.control,name:"ui_type",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Type *"}),t.jsxs(gn,{value:l.value,onValueChange:l.onChange,children:[t.jsx(H,{children:t.jsx(jn,{children:t.jsx(yn,{})})}),t.jsxs(vn,{children:[t.jsx(de,{value:"HTTP",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ae,{className:"w-4 h-4"}),"HTTP"]})}),t.jsx(de,{value:"SSE",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ae,{className:"w-4 h-4"}),"SSE"]})}),t.jsx(de,{value:"Websocket",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ae,{className:"w-4 h-4"}),"Websocket"]})}),a&&t.jsxs(t.Fragment,{children:[t.jsx(de,{value:"NPX",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(ue,{className:"w-4 h-4"}),"NPX Package"]})}),t.jsx(de,{value:"STDIO",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Qt,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),t.jsx(K,{})]})}),V==="NPX"&&t.jsx(U,{control:u.control,name:"npx_package",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"NPM Package *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"@perplexity-ai/mcp-server",...l,value:l.value??"",onPaste:P=>{const v=P.clipboardData.getData("text");v&&(P.preventDefault(),u.setValue("npx_package",v.trim(),{shouldDirty:!0}),ve(v))},onBlur:P=>{ve(P.target.value),l.onBlur()}})}),t.jsx(K,{})]})}),V==="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[t.jsx(U,{control:u.control,name:"stdio_command",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Command *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"node, bun, python...",...l,value:l.value??""})}),t.jsx(K,{})]})}),t.jsx(U,{control:u.control,name:"stdio_args",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Arguments"}),t.jsx(H,{children:t.jsx(J,{placeholder:"arg1 arg2 --flag value",...l,value:l.value??""})}),t.jsx(K,{})]})})]}),t.jsx(U,{control:u.control,name:"stdio_cwd",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Working Directory"}),t.jsx(H,{children:t.jsx(J,{placeholder:"/path/to/project (optional)",...l,value:l.value??""})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),t.jsx(K,{})]})})]}),(V==="NPX"||V==="STDIO")&&t.jsx(U,{control:u.control,name:"env_vars",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Environment Variables"}),t.jsx(H,{children:t.jsx(Dn,{value:l.value??[],onChange:l.onChange})}),t.jsx(K,{})]})}),V!=="NPX"&&V!=="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsx(U,{control:u.control,name:"connection_url",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"URL *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"https://example.com/mcp",...l,value:l.value??"",onPaste:P=>{const v=P.clipboardData.getData("text");v&&(P.preventDefault(),u.setValue("connection_url",v.trim(),{shouldDirty:!0}),ve(v))},onBlur:P=>{ve(P.target.value),l.onBlur()}})}),t.jsx(K,{})]})}),t.jsx(U,{control:u.control,name:"connection_token",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:ce?.token?.label??"Token (optional)"}),t.jsx(H,{children:t.jsx(J,{type:"password",placeholder:ce?.token?.placeholder??"Bearer token or API key",...l,value:l.value??""})}),ce?.token?.helperText&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[ce.token.helperText,ce.id==="github"&&t.jsxs(t.Fragment,{children:[" ","·"," ",t.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),t.jsx(K,{})]})})]}),t.jsx(U,{control:u.control,name:"title",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Name *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"My Connection",...l})}),t.jsx(K,{})]})}),t.jsx(U,{control:u.control,name:"description",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Description"}),t.jsx(H,{children:t.jsx(Cn,{placeholder:"A brief description of this connection",rows:3,...l,value:l.value??""})}),t.jsx(K,{})]})})]}),j=Ge||m.mode==="editing";return f?t.jsx(an,{open:j,onOpenChange:De,children:t.jsxs(dn,{className:"max-h-[90vh]",children:[t.jsx(pn,{className:"pb-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 text-left",children:[t.jsx(un,{children:n}),t.jsx(mn,{className:"mt-1",children:s})]}),t.jsx(hn,{asChild:!0,children:t.jsx($,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:t.jsx(jt,{size:16})})})]})}),t.jsx(st,{...u,children:t.jsxs("form",{onSubmit:u.handleSubmit(Je),children:[t.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:p}),t.jsx(xn,{children:t.jsx($,{type:"submit",disabled:u.formState.isSubmitting,className:"w-full",children:r})})]})})]})}):t.jsx(lt,{open:j,onOpenChange:De,children:t.jsxs(at,{className:"sm:max-w-[525px]",children:[t.jsxs(dt,{children:[t.jsx(pt,{children:n}),t.jsx(ut,{children:s})]}),t.jsx(st,{...u,children:t.jsxs("form",{onSubmit:u.handleSubmit(Je),children:[t.jsx("div",{className:"py-4",children:p}),t.jsxs(mt,{children:[t.jsx($,{type:"button",variant:"outline",onClick:()=>De(!1),children:"Cancel"}),t.jsx($,{type:"submit",disabled:u.formState.isSubmitting,className:"min-w-40",children:r})]})]})})]})})})(),t.jsx(Pe,{open:m.mode==="deleting",onOpenChange:n=>!n&&b({type:"close"}),children:t.jsxs($e,{children:[t.jsxs(Ee,{children:[t.jsx(Oe,{children:"Delete Connection?"}),t.jsxs(Le,{children:["This action cannot be undone. This will permanently delete"," ",t.jsx("span",{className:"font-medium text-foreground",children:m.mode==="deleting"&&m.connection.title}),"."]})]}),t.jsxs(Ve,{children:[t.jsx(ze,{children:"Cancel"}),t.jsx(Fe,{onClick:Dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),t.jsx(Pe,{open:m.mode==="force-deleting",onOpenChange:n=>!n&&b({type:"close"}),children:t.jsxs($e,{children:[t.jsxs(Ee,{children:[t.jsx(Oe,{children:"Connection Used by Agents"}),t.jsx(Le,{asChild:!0,children:t.jsxs("div",{children:[t.jsxs("p",{children:["The connection"," ",t.jsx("span",{className:"font-medium text-foreground",children:m.mode==="force-deleting"&&m.connection.title})," ","is currently used by the following agent(s):"," ",t.jsx("span",{className:"font-medium text-foreground",children:m.mode==="force-deleting"&&m.agentNames}),"."]}),t.jsx("p",{className:"mt-2",children:"Deleting this connection will remove it from those agents, which may impact existing workflows that depend on them."})]})})]}),t.jsxs(Ve,{children:[t.jsx(ze,{children:"Cancel"}),t.jsx(Fe,{onClick:At,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Anyway"})]})]})}),t.jsx(Kn,{open:A,onOpenChange:I,count:x.size,onConfirm:_t}),t.jsx(Hn,{open:_,onOpenChange:L,agents:W,onConfirm:wt}),t.jsxs(ae.Header,{children:[t.jsx(ae.Header.Left,{children:t.jsx(on,{children:t.jsx(rn,{children:t.jsx(cn,{children:t.jsx(ln,{children:"Connections"})})})})}),t.jsxs(ae.Header.Right,{children:[t.jsx(Xt,{sortKey:h.sortKey,sortDirection:h.sortDirection,onSort:h.handleSort,sortOptions:[{id:"title",label:"Name"},{id:"description",label:"Description"},{id:"connection_type",label:"Type"},{id:"updated_by",label:"Updated by"},{id:"updated_at",label:"Updated"}],filters:[{label:"Type",value:F,onChange:n=>te(n||"ALL"),options:[{id:"ALL",label:"All"},{id:"HTTP",label:"HTTP"},{id:"SSE",label:"SSE"},{id:"Websocket",label:"WebSocket"},{id:"STDIO",label:"STDIO"}]},{label:"Status",value:M,onChange:n=>q(n||"ALL"),options:[{id:"ALL",label:"All"},{id:"active",label:"Active"},{id:"inactive",label:"Inactive"},{id:"error",label:"Error"}]}]}),It]})]}),t.jsxs("div",{className:"flex flex-col gap-0",children:[t.jsx("div",{children:t.jsx(Wt,{value:h.search,onChange:h.setSearch,placeholder:"Search for a Connection...",onKeyDown:n=>{n.key==="Escape"&&(h.setSearch(""),n.target.blur())}})}),t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:[t.jsx(Gt,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:T,onTabChange:n=>ee(n)}),Q.length>0&&t.jsx("div",{className:Z(T!=="all"&&"invisible pointer-events-none"),children:t.jsxs(Me,{children:[t.jsx(Ue,{asChild:!0,children:t.jsxs($,{variant:"outline",size:"sm",className:"h-7 px-2 gap-1.5 text-sm font-normal",children:[(()=>{const n=Q.find(s=>s.id===(ie||Q[0]?.id))??Q[0];return t.jsxs(t.Fragment,{children:[t.jsx(Ie,{icon:n?.icon,name:n?.title??"",size:"2xs",className:"shrink-0 rounded-sm"}),t.jsx("span",{children:n?.title})]})})(),t.jsx(Tn,{size:14,className:"text-muted-foreground"})]})}),t.jsx(Be,{align:"end",children:Q.map(n=>t.jsxs(pe,{onClick:()=>vt(n.id),className:Z(ie===n.id||!ie&&n.id===Q[0]?.id?"bg-accent":""),children:[t.jsx(Ie,{icon:n.icon,name:n.title,size:"2xs",className:"shrink-0 rounded-sm"}),n.title]},n.id))})]})})]})]}),t.jsx(ae.Content,{children:t.jsx("div",{className:"flex-1 overflow-auto p-5",children:(Y?fe.length===0&&ge.length===0&&S.length===0:T==="all"?fe.length===0&&ge.length===0:S.length===0)?t.jsx(qt,{image:t.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:336,height:320,"aria-hidden":"true"}),title:"No Connections found",description:h.search?`No Connections match "${h.search}"`:"Create a connection to get started."}):t.jsxs("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4",children:[Nt.map(n=>{if(n.type==="group")return t.jsx(Mn,{group:n,onOpen:()=>{o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:n.key}})},selectionMode:N,selectedIds:x,onToggleSelect:he},n.key);const s=n.connection,r=x.has(s.id);return t.jsx(Ne,{connection:s,fallbackIcon:t.jsx(ue,{}),onClick:()=>N?he(s.id):o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(s)}}),className:Z(r&&"ring-2 ring-primary bg-primary/5"),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1",children:[N?t.jsx(ct,{checked:r,onCheckedChange:()=>he(s.id),onClick:p=>p.stopPropagation()}):t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}),t.jsx("div",{className:Z("overflow-hidden transition-all duration-150 ease-out",N?"w-8 opacity-100":"w-0 opacity-0 group-hover:w-8 group-hover:opacity-100"),children:t.jsxs(Me,{children:[t.jsx(Ue,{asChild:!0,children:t.jsx($,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:p=>p.stopPropagation(),children:t.jsx(ht,{size:20})})}),t.jsxs(Be,{align:"end",onClick:p=>p.stopPropagation(),children:[t.jsxs(pe,{onClick:p=>{p.stopPropagation(),o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(s)}})},children:[t.jsx(xt,{size:16}),"Open"]}),t.jsxs(pe,{onClick:p=>{p.stopPropagation(),he(s.id)},children:[t.jsx(Yt,{size:16}),"Select"]}),t.jsxs(pe,{variant:"destructive",onClick:p=>{p.stopPropagation(),b({type:"delete",connection:s})},children:[t.jsx(gt,{size:16}),"Delete"]})]})]})})]})},s.id)}),T==="all"&&fe.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx(_n,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),fe.map(n=>{const s=n.server?.name||n.name||n.id||"",r=He.has(s),p=n._meta?.["mcp.mesh"],j=p?.friendlyName||p?.friendly_name||n.server?.title||n.title||n.server?.name||n.name||n.id||"",l=n.server?.description||n.description||null,P=n.server?.icons?.[0]?.src||nt(n.server?.repository)||null,v=y.filter(D=>D.connection_type!=="VIRTUAL"&&D.app_name===s);return t.jsx(Ne,{connection:{title:j,description:l,icon:P},fallbackIcon:t.jsx(ue,{}),onClick:()=>{if(r){const D=v[0];D&&o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(D)}})}else Xe(n)},headerActionsAlwaysVisible:!0,headerActions:r?t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}):t.jsx($,{variant:"outline",size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",disabled:je!==null,onClick:D=>{D.stopPropagation(),We(n)},children:je===n.id?t.jsx(Se,{size:14,className:"animate-spin"}):"Connect"})},`catalog-${n.id}`)}),T==="all"&&ge.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),ge.map(n=>{const s=n.server?.name||n.name||n.id||"",r=He.has(s),p=n._meta?.["mcp.mesh"],j=p?.friendlyName||p?.friendly_name||n.server?.title||n.title||n.server?.name||n.name||n.id||"",l=n.server?.description||n.description||null,P=n.server?.icons?.[0]?.src||nt(n.server?.repository)||null,v=y.filter(D=>D.connection_type!=="VIRTUAL"&&D.app_name===s);return t.jsx(Ne,{connection:{title:j,description:l,icon:P},fallbackIcon:t.jsx(ue,{}),onClick:()=>{if(r){const D=v[0];D&&o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(D)}})}else Xe(n)},headerActionsAlwaysVisible:!0,headerActions:r?t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}):t.jsx($,{variant:"outline",size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",disabled:je!==null,onClick:D=>{D.stopPropagation(),We(n)},children:je===n.id?t.jsx(Se,{size:14,className:"animate-spin"}):"Connect"})},`catalog-${n.id}`)}),(T==="all"||Y)&&_e&&t.jsx("div",{ref:bt,className:"col-span-full h-4"}),(T==="all"||Y)&&re.isLoadingMore&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(Se,{size:24,className:"animate-spin text-muted-foreground"})})]})})}),N&&t.jsx(Rn,{count:x.size,total:S.length,onSelectAll:()=>{C(new Set(S.map(n=>n.id)))},onDeselectAll:()=>C(new Set),onDelete:()=>I(!0),onAddToAgent:()=>L(!0),onToggleStatus:Tt,onCancel:xe})]})})}function ao(){const i=me.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Pt,{children:t.jsx(X.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(Se,{size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(Xn,{})})}),i[0]=e):e=i[0],e}export{ao as default};
|
|
1
|
+
import{d as me,j as t,E as Pt,r as X,c as $t,x as Et,f as Ot,e as Lt,g as Vt,D as zt,F as et,v as Ft,t as Mt,b as Ut,B as $,y as Z,O as G,w as E,i as Bt,a as Rt,K as Ht}from"./index-D49VqQ7Q.js";import{g as Kt}from"./generate-id-Dyweu44Y.js";import{C as Xt}from"./collection-display-button-ZvHBt_eA.js";import{C as Wt}from"./collection-search-fzGK39qM.js";import{C as Gt}from"./collection-tabs-vUhndfXI.js";import{C as Ne}from"./connection-card-D7msIZJv.js";import{E as qt}from"./empty-state-B8NhLY9v.js";import{s as Ae,i as Qt,I as Ie,a as Yt}from"./integration-icon-ByIZ-Vgj.js";import{u as tt,P as ae}from"./index-CtkIjbbq.js";import{u as Jt,f as Zt,g as nt}from"./registry-utils-Cz03qmOa.js";import{u as en}from"./use-infinite-scroll-JQzncaIM.js";import{u as tn}from"./use-list-state-BG8gUSh9.js";import{u as nn}from"./use-store-discovery-DfcEdPeQ.js";import{g as ne}from"./connection-slug-Bw8dtz1U.js";import{s as sn}from"./slugify-CEUa2lfQ.js";import{f as Pe,a as $e,b as Ee,c as Oe,d as Le,e as Ve,A as ze,h as Fe}from"./alert-dialog-Bke1xnyn.js";import{B as on,a as rn,b as cn,c as ln}from"./breadcrumb-BBMvtdg-.js";import{C as ct}from"./checkbox-Dzy6oaRF.js";import{a as lt,D as at,b as dt,c as pt,e as ut,d as mt}from"./dialog-DCrLu7TC.js";import{D as an,a as dn,b as pn,c as un,d as mn,e as hn,f as xn}from"./drawer-CwKj53Jm.js";import{u as fn}from"./tooltip-DJkxXViN.js";import{D as Me,a as Ue,b as Be,c as pe}from"./dropdown-menu-BK29e1o0.js";import{F as U,b as B,c as R,d as H,f as K,a as st}from"./form-DPsme8JL.js";import{I as J}from"./input-BoNWsfmK.js";import{S as gn,a as jn,b as yn,c as vn,d as de}from"./select-DaOZXaTi.js";import{T as Cn}from"./textarea-D30IrLHN.js";import{a as bn,b as ot}from"./use-connection-Yjy9d1tW.js";import{u as Nn,a as Sn}from"./constants-TLV7MTwP.js";import{b as kn}from"./use-virtual-mcp-2qhGJdPe.js";import{i as _n}from"./XCircle-Z-JTmQ8v.js";import{t as Tn}from"./ChevronDown-CDxBhn_l.js";import{n as ue}from"./Container-CMPDG7Cp.js";import{i as ht,s as xt}from"./RefreshCcw01-Co0-i94o.js";import{i as Se}from"./Loading01-BVCg1O_G.js";import{s as ft}from"./Plus-DcVtqCMV.js";import{s as gt}from"./Trash01-CBP9WLeP.js";import{s as jt}from"./XClose-BLvk3pvY.js";import{r as wn,E as Dn,c as An,e as yt}from"./env-vars-editor-CvqhjBEu.js";import{e as In}from"./extract-connection-data-NSojo21r.js";import"./ArrowUp-D6ltkV3R.js";import"./Check-Dczm9Dfw.js";import"./Type01-CySkENi6.js";import"./badge-DGQ0gFlp.js";import"./SearchMd-CVvF1HpM.js";import"./card-CKN-JP9M.js";import"./AlertCircle-BD5gSXQu.js";import"./ArrowLeft-DN3D0Zrv.js";import"./ChevronRight-Dxvchjxo.js";import"./ChevronUp-BLNd6dNq.js";import"./Play-Bb4cvvVL.js";import"./Dataflow03-slF1Ax9G.js";import"./FolderClosed-BKB_NgWm.js";import"./Settings01-DpZ_tsoX.js";import"./Upload01-BzGPegBj.js";import"./User01-CItwHvE1.js";import"./X-Dr-hR03I.js";import"./Zap-CiHJmamA.js";import"./useQuery-CvkH2gG1.js";import"./useMutation-BTUmJffP.js";import"./workflow-CBGVBFDu.js";import"./collections-BsFnKFn5.js";import"./use-view-mode-BGEJ9JzM.js";import"./useInfiniteQuery-D8TjRj27.js";import"./infiniteQueryObserver-DiY9IZXI.js";import"./index-BkAoKVx8.js";import"./label-DF2jcg2U.js";import"./index-BdQq_4o_.js";import"./use-collections-Dmxer7H8.js";import"./constants-BqeudQjB.js";function it(i){return ne(i)}function Pn(i){const e=new Map;for(const c of i){if(c.connection_type==="VIRTUAL")continue;const a=it(c),f=e.get(a);f?f.push(c):e.set(a,[c])}const o=[],d=new Set;for(const c of i){if(c.connection_type==="VIRTUAL")continue;const a=it(c);if(d.has(a))continue;d.add(a);const f=e.get(a),h=f[0];f.length===1?o.push({type:"single",connection:h}):o.push({type:"group",key:a,icon:h.icon,title:h.app_name?h.title.replace(/\s*\(\d+\)\s*$/,""):h.title,connections:f})}return o}function ke(i){const e=i.trim();if(!e)return"";try{const o=new URL(e),d=o.pathname.length>1?o.pathname.replace(/\/+$/,""):o.pathname;return`${o.origin}${d}`}catch{return e.replace(/\/+$/,"")}}function $n(i){const e=i.trim().split(/\s+/).filter(Boolean);if(e.length<2)return null;const o=e[0]?.toLowerCase();if(o!=="npx"&&o!=="bunx")return null;const c=e.slice(1).find(a=>!a.startsWith("-"));return c?{packageName:c}:null}function be(i){const{uiType:e}=i,o=ke(i.connectionUrl??"");if((e==="HTTP"||e==="SSE"||e==="Websocket")&&o===ke("https://api.githubcopilot.com/mcp/"))return{id:"github",title:"GitHub",description:"GitHub Copilot MCP",token:{label:"GitHub PAT",placeholder:"github_pat_…",helperText:"Paste a GitHub Personal Access Token (PAT)"}};const d=(i.npxPackage??"").trim();return e==="NPX"&&d==="@perplexity-ai/mcp-server"?{id:"perplexity",title:"Perplexity",description:"Perplexity MCP Server",envVarKeys:["PERPLEXITY_API_KEY"]}:null}function rt(i){if(i.registryItems.length===0||i.uiType!=="HTTP"&&i.uiType!=="SSE"&&i.uiType!=="Websocket")return null;const e=ke(i.connectionUrl??"");if(!e)return null;const o=i.registryItems.find(a=>(a.server?.remotes??[]).some(h=>ke(h.url??"")===e));if(!o)return null;const d=o.title||o.name||o.server?.title||o.server?.name||"",c=o.server?.description||o.description||o.summary||null;return d?{id:"registry",title:d,description:c}:null}function En(i,e){const o={command:"npx",args:["-y",i]},d=yt(e);return Object.keys(d).length>0&&(o.envVars=d),o}function On(i,e,o,d){const c={command:i};e.trim()&&(c.args=e.trim().split(/\s+/)),o?.trim()&&(c.cwd=o.trim());const a=yt(d);return Object.keys(a).length>0&&(c.envVars=a),c}function Ln(i){return i.command==="npx"}function Vn(i){return i.args?.find(e=>!e.startsWith("-"))??""}function zn(i){return{command:i.command,args:i.args?.join(" ")??"",cwd:i.cwd??""}}function Fn(i,e){switch(e.type){case"edit":return{mode:"editing",connection:e.connection};case"delete":return{mode:"deleting",connection:e.connection};case"force-delete":return{mode:"force-deleting",connection:e.connection,agentNames:e.agentNames};case"close":return{mode:"idle"}}}function Mn(i){const e=me.c(51),{group:o,onOpen:d,selectionMode:c,selectedIds:a,onToggleSelect:f}=i;let h;if(e[0]!==o.connections||e[1]!==a){let S;e[3]!==a?(S=oe=>a.has(oe.id),e[3]=a,e[4]=S):S=e[4],h=o.connections.every(S),e[0]=o.connections,e[1]=a,e[2]=h}else h=e[2];const g=h;let k;if(e[5]!==o.connections||e[6]!==a){let S;e[8]!==a?(S=oe=>a.has(oe.id),e[8]=a,e[9]=S):S=e[9],k=o.connections.some(S),e[5]=o.connections,e[6]=a,e[7]=k}else k=e[7];const y=k,m=`${o.connections.length} instances`;let b;e[10]!==o.icon||e[11]!==o.title||e[12]!==m?(b={title:o.title,icon:o.icon,description:m},e[10]=o.icon,e[11]=o.title,e[12]=m,e[13]=b):b=e[13];let x;e[14]!==g||e[15]!==o.connections||e[16]!==d||e[17]!==f||e[18]!==a||e[19]!==c?(x=()=>c?(()=>{for(const S of o.connections)g?a.has(S.id)&&f(S.id):a.has(S.id)||f(S.id)})():d(),e[14]=g,e[15]=o.connections,e[16]=d,e[17]=f,e[18]=a,e[19]=c,e[20]=x):x=e[20];const C=c&&g&&"ring-2 ring-primary",N=c&&y&&!g&&"ring-1 ring-primary/50";let A;e[21]!==C||e[22]!==N?(A=Z(C,N),e[21]=C,e[22]=N,e[23]=A):A=e[23];let I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx(ue,{}),e[24]=I):I=e[24];let _;e[25]!==g||e[26]!==o.connections||e[27]!==f||e[28]!==a||e[29]!==c||e[30]!==y?(_=c?t.jsx(ct,{checked:g?!0:y?"indeterminate":!1,onCheckedChange:()=>{for(const S of o.connections)g?a.has(S.id)&&f(S.id):a.has(S.id)||f(S.id)}}):t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}),t.jsxs("span",{className:"text-xs text-muted-foreground font-normal tabular-nums",children:["x",o.connections.length]})]}),e[25]=g,e[26]=o.connections,e[27]=f,e[28]=a,e[29]=c,e[30]=y,e[31]=_):_=e[31];const L=c?"w-8 opacity-100":"w-0 opacity-0 group-hover:w-8 group-hover:opacity-100";let T;e[32]!==L?(T=Z("overflow-hidden transition-all duration-150 ease-out",L),e[32]=L,e[33]=T):T=e[33];let ee;e[34]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(Ue,{asChild:!0,children:t.jsx($,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:Bn,children:t.jsx(ht,{size:20})})}),e[34]=ee):ee=e[34];let F;e[35]!==d?(F=S=>{S.stopPropagation(),d()},e[35]=d,e[36]=F):F=e[36];let te;e[37]===Symbol.for("react.memo_cache_sentinel")?(te=t.jsx(xt,{size:16}),e[37]=te):te=e[37];let M;e[38]!==F?(M=t.jsxs(Me,{children:[ee,t.jsx(Be,{align:"end",onClick:Un,children:t.jsxs(pe,{onClick:F,children:[te,"Open"]})})]}),e[38]=F,e[39]=M):M=e[39];let q;e[40]!==T||e[41]!==M?(q=t.jsx("div",{className:T,children:M}),e[40]=T,e[41]=M,e[42]=q):q=e[42];let W;e[43]!==_||e[44]!==q?(W=t.jsxs("div",{className:"flex items-center gap-1",children:[_,q]}),e[43]=_,e[44]=q,e[45]=W):W=e[45];let se;return e[46]!==W||e[47]!==b||e[48]!==x||e[49]!==A?(se=t.jsx(t.Fragment,{children:t.jsx(Ne,{connection:b,onClick:x,className:A,fallbackIcon:I,headerActionsAlwaysVisible:!0,headerActions:W})}),e[46]=W,e[47]=b,e[48]=x,e[49]=A,e[50]=se):se=e[50],se}function Un(i){return i.stopPropagation()}function Bn(i){return i.stopPropagation()}function Rn(i){const e=me.c(28),{count:o,total:d,onSelectAll:c,onDeselectAll:a,onDelete:f,onAddToAgent:h,onToggleStatus:g,onCancel:k}=i;if(o===0)return null;let y;e[0]!==o?(y=t.jsxs("div",{className:"text-xs text-muted-foreground pr-1 tabular-nums",children:[o," selected"]}),e[0]=o,e[1]=y):y=e[1];let m;e[2]!==o||e[3]!==a||e[4]!==c||e[5]!==d?(m=o<d?t.jsxs($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:c,children:["Select all (",d,")"]}):t.jsx($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:a,children:"Clear selection"}),e[2]=o,e[3]=a,e[4]=c,e[5]=d,e[6]=m):m=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx(ft,{size:13}),e[7]=b):b=e[7];let x;e[8]!==h?(x=t.jsxs($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:h,children:[b,"Add to Agent"]}),e[8]=h,e[9]=x):x=e[9];let C;e[10]!==g?(C=t.jsx($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:()=>g("active"),children:"Enable"}),e[10]=g,e[11]=C):C=e[11];let N;e[12]!==g?(N=t.jsx($,{variant:"outline",size:"sm",className:"h-7 text-xs px-2",onClick:()=>g("inactive"),children:"Disable"}),e[12]=g,e[13]=N):N=e[13];let A;e[14]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(gt,{size:13}),e[14]=A):A=e[14];let I;e[15]!==f?(I=t.jsxs($,{variant:"destructive",size:"sm",className:"h-7 text-xs px-2",onClick:f,children:[A,"Delete"]}),e[15]=f,e[16]=I):I=e[16];let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx(jt,{size:13}),e[17]=_):_=e[17];let L;e[18]!==k?(L=t.jsx($,{variant:"ghost",size:"sm",className:"h-7 text-xs px-2",onClick:k,children:_}),e[18]=k,e[19]=L):L=e[19];let T;return e[20]!==y||e[21]!==L||e[22]!==m||e[23]!==x||e[24]!==C||e[25]!==N||e[26]!==I?(T=t.jsx("div",{className:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2",children:t.jsxs("div",{className:"rounded-xl border border-border bg-background/95 shadow-lg backdrop-blur px-3 py-2 flex items-center gap-2",children:[y,m,x,C,N,I,L]})}),e[20]=y,e[21]=L,e[22]=m,e[23]=x,e[24]=C,e[25]=N,e[26]=I,e[27]=T):T=e[27],T}function Hn(i){const e=me.c(25),{open:o,onOpenChange:d,agents:c,onConfirm:a}=i,[f,h]=X.useState(null);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsxs(dt,{children:[t.jsx(pt,{children:"Add to Agent"}),t.jsx(ut,{children:"Select an agent to add the selected connections to."})]}),e[0]=g):g=e[0];let k;e[1]!==c||e[2]!==f?(k=c.length===0?t.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No agents found"}):c.map(_=>t.jsxs("button",{type:"button",onClick:()=>h(_.id),className:Z("flex items-center gap-3 w-full rounded-md px-3 py-2 text-left transition-colors",f===_.id?"bg-primary/10 ring-1 ring-primary":"hover:bg-muted/50"),children:[t.jsx(Ie,{icon:_.icon,name:_.title,size:"sm",className:"shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:_.title}),_.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:_.description})]})]},_.id)),e[1]=c,e[2]=f,e[3]=k):k=e[3];let y;e[4]!==k?(y=t.jsx("div",{className:"max-h-60 overflow-auto py-2 space-y-1",children:k}),e[4]=k,e[5]=y):y=e[5];let m;e[6]!==d?(m=t.jsx($,{variant:"outline",onClick:()=>d(!1),children:"Cancel"}),e[6]=d,e[7]=m):m=e[7];const b=!f;let x;e[8]!==a||e[9]!==d||e[10]!==f?(x=()=>{f&&(a(f),d(!1),h(null))},e[8]=a,e[9]=d,e[10]=f,e[11]=x):x=e[11];let C;e[12]!==b||e[13]!==x?(C=t.jsx($,{disabled:b,onClick:x,children:"Add"}),e[12]=b,e[13]=x,e[14]=C):C=e[14];let N;e[15]!==m||e[16]!==C?(N=t.jsxs(mt,{children:[m,C]}),e[15]=m,e[16]=C,e[17]=N):N=e[17];let A;e[18]!==y||e[19]!==N?(A=t.jsxs(at,{className:"sm:max-w-[400px]",children:[g,y,N]}),e[18]=y,e[19]=N,e[20]=A):A=e[20];let I;return e[21]!==d||e[22]!==o||e[23]!==A?(I=t.jsx(lt,{open:o,onOpenChange:d,children:A}),e[21]=d,e[22]=o,e[23]=A,e[24]=I):I=e[24],I}function Kn(i){const e=me.c(20),{open:o,onOpenChange:d,count:c,onConfirm:a}=i,f=c!==1?"s":"";let h;e[0]!==c||e[1]!==f?(h=t.jsxs(Oe,{children:["Delete ",c," connection",f,"?"]}),e[0]=c,e[1]=f,e[2]=h):h=e[2];const g=c!==1?"s":"";let k;e[3]!==g?(k=t.jsxs(Le,{children:["This will permanently delete the selected connection",g,". This action cannot be undone."]}),e[3]=g,e[4]=k):k=e[4];let y;e[5]!==h||e[6]!==k?(y=t.jsxs(Ee,{children:[h,k]}),e[5]=h,e[6]=k,e[7]=y):y=e[7];let m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(ze,{children:"Cancel"}),e[8]=m):m=e[8];const b=c!==1?"s":"";let x;e[9]!==c||e[10]!==a||e[11]!==b?(x=t.jsxs(Ve,{children:[m,t.jsxs(Fe,{onClick:a,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:["Delete ",c," connection",b]})]}),e[9]=c,e[10]=a,e[11]=b,e[12]=x):x=e[12];let C;e[13]!==y||e[14]!==x?(C=t.jsxs($e,{children:[y,x]}),e[13]=y,e[14]=x,e[15]=C):C=e[15];let N;return e[16]!==d||e[17]!==o||e[18]!==C?(N=t.jsx(Pe,{open:o,onOpenChange:d,children:C}),e[16]=d,e[17]=o,e[18]=C,e[19]=N):N=e[19],N}function Xn(){const{org:i}=$t(),e=Et(),o=Ot(),d=Lt({strict:!1}),{data:c}=Vt.useSession(),{stdioEnabled:a}=zt(),f=fn(),h=tn({namespace:i.slug,resource:"connections"}),g=bn(),k=ot(h),y=ot(),[m,b]=X.useReducer(Fn,{mode:"idle"}),[x,C]=X.useState(new Set),N=x.size>0,[A,I]=X.useState(!1),[_,L]=X.useState(!1),[T,ee]=tt(et.connectionsTab(i.slug),n=>d.tab==="all"||d.tab==="connected"?d.tab:n??"all"),[F,te]=X.useState("ALL"),[M,q]=X.useState("ALL"),W=kn(),S=k.filter(n=>!(n.connection_type==="VIRTUAL"||F!=="ALL"&&n.connection_type!==F||M!=="ALL"&&n.status!==M)),oe=Pn(S),he=n=>{C(s=>{const r=new Set(s);return r.has(n)?r.delete(n):r.add(n),r})},xe=()=>{C(new Set)},Q=Jt(y).sort((n,s)=>{const r=n.app_name==="@deco/management-mcp",p=s.app_name==="@deco/management-mcp";return r&&!p?1:!r&&p?-1:0}),[ie,vt]=tt(et.selectedRegistry(i.slug),n=>n??""),Re=(ie?Q.find(n=>n.id===ie):void 0)??Q[0],_e=Re?.id??"",Ct=Zt(Re?.tools),re=nn({registryId:_e,listToolName:Ct}),Te=re.items,bt=en(re.loadMore,re.hasMore,re.isLoadingMore),He=new Set(y.filter(n=>n.connection_type!=="VIRTUAL"&&n.app_name).map(n=>n.app_name)),Y=h.search.toLowerCase(),Ke=T==="all"||Y?Te.filter(n=>{if(!Y)return!0;const s=n._meta?.["mcp.mesh"],r=[s?.friendly_name,n.server?.name,n.server?.title,n.name,n.title,n.id].filter(Boolean).join(" "),p=[s?.short_description,s?.mesh_description,n.server?.description,n.description].filter(Boolean).join(" ");return r.toLowerCase().includes(Y)||p.toLowerCase().includes(Y)}):[],fe=Ke.filter(n=>n.verified||n._meta?.["mcp.mesh"]?.verified||n.meta?.verified),ge=Ke.filter(n=>!n.verified&&!n._meta?.["mcp.mesh"]?.verified&&!n.meta?.verified),Nt=T==="all"&&!Y?[]:oe,Xe=n=>{const s=sn(n.name||n.title||n.server?.title||""),r=typeof n.id=="string"&&n.id.includes("/"),p=typeof n.server?.name=="string"&&n.server.name.includes("/"),j=r&&!p?n.id:n.server?.name||n.id||"";o({to:"/$org/$project/store/$appName",params:{org:i.slug,project:G,appName:s},search:{registryId:_e,serverName:j}})},[je,we]=X.useState(null),We=async n=>{if(!(!i||!c?.user?.id)){we(n.id);try{const s=In(n,i.id,c.user.id,{remoteIndex:0}),r=s.connection_type==="STDIO",p=!!s.connection_url,j=r&&s.connection_headers&&typeof s.connection_headers=="object"&&"command"in s.connection_headers;if(!p&&!j){E.error("This MCP Server cannot be connected: no connection method available"),we(null);return}const l=n.id??n.title,P=y.filter(z=>z.app_name===l||z.title===s.title);if(P.length>0){const z=s.title||"MCP Server";s.title=`${z} (${P.length+1})`}const{id:v}=await g.create.mutateAsync(s),D=new URL(`/mcp/${v}`,window.location.origin),Ce=await Bt({url:D.href,token:null});if(Ce.supportsOAuth&&!Ce.isAuthenticated){const{token:z,tokenInfo:O,error:Ze}=await Rt({connectionId:v});if(Ze||!z){E.error(`Authentication failed: ${Ze??"no token received"}`);return}else{if(O)try{(await fetch(`/api/connections/${v}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:O.accessToken,refreshToken:O.refreshToken,expiresIn:O.expiresIn,scope:O.scope,clientId:O.clientId,clientSecret:O.clientSecret,tokenEndpoint:O.tokenEndpoint})})).ok?await g.update.mutateAsync({id:v,data:{}}):await g.update.mutateAsync({id:v,data:{connection_token:z}})}catch{await g.update.mutateAsync({id:v,data:{connection_token:z}})}else await g.update.mutateAsync({id:v,data:{connection_token:z}});await e.invalidateQueries({queryKey:Ht.isMCPAuthenticated(D.href,null)}),E.success("Authentication successful")}}E.success("Connected successfully")}catch(s){E.error(`Failed to connect: ${s instanceof Error?s.message:String(s)}`)}finally{we(null)}}},Ge=d.action==="create",St=()=>{o({to:"/$org/$project/mcps",params:{org:i.slug,project:G},search:{action:"create"}})},qe=()=>{o({to:"/$org/$project/mcps",params:{org:i.slug,project:G},search:{}})},u=Ft({resolver:Mt(An),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),V=u.watch("ui_type"),Qe=u.watch("connection_url"),kt=u.watch("npx_package"),ce=be({uiType:V,connectionUrl:Qe??"",npxPackage:kt??""})??rt({uiType:V,connectionUrl:Qe??"",registryItems:Te}),w=m.mode==="editing"?m.connection:null;X.useEffect(()=>{if(w){const n=Ut(w.connection_headers)?w.connection_headers:null;if(n&&w.connection_type==="STDIO"){const s=wn(n.envVars);if(Ln(n)){const r=Vn(n);u.reset({title:w.title,description:w.description,icon:w.icon??null,ui_type:"NPX",connection_url:"",connection_token:null,npx_package:r,stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:s})}else{const r=zn(n);u.reset({title:w.title,description:w.description,icon:w.icon??null,ui_type:"STDIO",connection_url:"",connection_token:null,npx_package:"",stdio_command:r.command,stdio_args:r.args,stdio_cwd:r.cwd,env_vars:s})}}else u.reset({title:w.title,description:w.description,icon:w.icon??null,ui_type:w.connection_type,connection_url:w.connection_url??"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})}else u.reset({title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]})},[w,u]);const le=Nn({connectionId:Sn,orgId:i.id}),ye=()=>{e.invalidateQueries({predicate:n=>{const s=n.queryKey;return s[1]===i.id&&s[3]==="collection"&&s[4]==="CONNECTIONS"}})},_t=async()=>{I(!1);const n=[...x];let s=0;for(const r of n)try{(await le.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:r,force:!0}})).isError||s++}catch{}ye(),E.success(`Deleted ${s} connection${s!==1?"s":""}`),xe()},Tt=async n=>{const s=[...x];let r=0;for(const p of s)try{await g.update.mutateAsync({id:p,data:{status:n}}),r++}catch{}ye(),E.success(`${n==="active"?"Enabled":"Disabled"} ${r} connection${r!==1?"s":""}`),xe()},wt=async n=>{const s=W.find(j=>j.id===n);if(!s||!le)return;const r=new Set(s.connections.map(j=>j.connection_id)),p=[...x].filter(j=>!r.has(j)).map(j=>({connection_id:j,selected_tools:null,selected_resources:null,selected_prompts:null}));if(p.length===0){E.info("All selected connections are already in that agent");return}try{await le.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:n,data:{connections:[...s.connections,...p]}}}),e.invalidateQueries({predicate:j=>{const l=j.queryKey;return l[1]===i.id&&l[3]==="collection"&&l[4]==="VIRTUAL_MCP"}}),E.success(`Added ${p.length} connection${p.length!==1?"s":""} to "${s.title}"`),xe()}catch{E.error("Failed to add connections to agent")}},Ye=n=>{const s=n.content;return Array.isArray(s)&&s[0]?.type==="text"&&typeof s[0].text=="string"?s[0].text:"Unknown error"},Dt=async()=>{if(m.mode!=="deleting")return;const n=m.connection;b({type:"close"});try{const s=await le.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:n.id}});if(s.isError){const r=Ye(s),p=r.replace(/^Error:\s*/,"");try{const j=JSON.parse(p);if(j.code==="CONNECTION_IN_USE"&&j.agentNames){b({type:"force-delete",connection:n,agentNames:j.agentNames.map(l=>`"${l}"`).join(", ")});return}}catch{}E.error(`Failed to delete connection: ${r}`);return}ye(),E.success("Connection deleted successfully")}catch(s){const r=s instanceof Error?s.message:String(s);E.error(`Failed to delete connection: ${r}`)}},At=async()=>{if(m.mode!=="force-deleting")return;const n=m.connection.id;b({type:"close"});try{const s=await le.callTool({name:"COLLECTION_CONNECTIONS_DELETE",arguments:{id:n,force:!0}});if(s.isError){E.error(`Failed to delete connection: ${Ye(s)}`);return}ye(),E.success("Connection deleted successfully")}catch(s){const r=s instanceof Error?s.message:String(s);E.error(`Failed to delete connection: ${r}`)}},Je=async n=>{let s,r=null,p=null,j=null;if(n.ui_type==="NPX"?(s="STDIO",r="",j=En(n.npx_package||"",n.env_vars||[])):n.ui_type==="STDIO"?(s="STDIO",r="",j=On(n.stdio_command||"",n.stdio_args||"",n.stdio_cwd,n.env_vars||[])):(s=n.ui_type,r=n.connection_url||"",p=n.connection_token||null),w){await g.update.mutateAsync({id:w.id,data:{title:n.title,description:n.description||null,icon:n.icon??null,connection_type:s,connection_url:r,...p&&{connection_token:p},...j&&{connection_headers:j}}}),b({type:"close"}),u.reset();return}const l=Kt("conn");await g.create.mutateAsync({id:l,title:n.title,description:n.description||null,connection_type:s,connection_url:r,connection_token:p,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:c?.user?.id||"system",organization_id:i.id,icon:n.icon??null,app_name:null,app_id:null,connection_headers:j,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),qe(),u.reset(),o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne({app_name:null,connection_url:r,title:n.title,id:l})}})},De=n=>{n||(Ge?qe():b({type:"close"}),u.reset())},ve=n=>{const s=n.trim();if(!s)return;const r=!!u.formState.dirtyFields.title,p=!!u.formState.dirtyFields.description,j=!!u.formState.dirtyFields.env_vars,l=v=>{if(v&&(!r&&!u.getValues("title").trim()&&v.title&&u.setValue("title",v.title,{shouldDirty:!1}),!p&&!(u.getValues("description")??"").trim()&&v.description&&u.setValue("description",v.description,{shouldDirty:!1}),!j&&v.envVarKeys?.length)){const D=u.getValues("env_vars")??[],Ce=new Set(D.map(O=>O.key)),z=v.envVarKeys.filter(O=>!Ce.has(O));z.length>0&&u.setValue("env_vars",[...D,...z.map(O=>({key:O,value:""}))],{shouldDirty:!0})}},P=$n(s);if(P&&a){u.setValue("ui_type","NPX",{shouldDirty:!0}),u.setValue("npx_package",P.packageName,{shouldDirty:!0}),u.setValue("connection_url","",{shouldDirty:!0}),u.setValue("connection_token",null,{shouldDirty:!0}),l(be({uiType:"NPX",npxPackage:P.packageName}));return}if(s.startsWith("http://")||s.startsWith("https://")){const v=V==="HTTP"||V==="SSE"||V==="Websocket"?V:"HTTP";u.setValue("ui_type",v,{shouldDirty:!0}),u.setValue("connection_url",s,{shouldDirty:!0}),l(be({uiType:v,connectionUrl:s})??rt({uiType:v,connectionUrl:s,registryItems:Te}));return}V==="NPX"&&l(be({uiType:"NPX",npxPackage:s}))},It=t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs($,{variant:"outline",onClick:St,size:"sm",className:"h-7 w-7 px-0 sm:w-auto sm:px-3 rounded-lg text-sm font-medium",children:[t.jsx(ft,{size:14,className:"sm:hidden"}),t.jsx("span",{className:"hidden sm:inline",children:"Custom Connection"})]})});return t.jsx(t.Fragment,{children:t.jsxs(ae,{children:[(()=>{const n=w?"Edit Connection":"Create Connection",s=w?"Update the connection details below.":"Create a custom connection in your organization. Fill in the details below.",r=u.formState.isSubmitting?"Saving...":w?"Update Connection":"Create Connection",p=t.jsxs("div",{className:"grid gap-4",children:[t.jsx(U,{control:u.control,name:"ui_type",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Type *"}),t.jsxs(gn,{value:l.value,onValueChange:l.onChange,children:[t.jsx(H,{children:t.jsx(jn,{children:t.jsx(yn,{})})}),t.jsxs(vn,{children:[t.jsx(de,{value:"HTTP",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ae,{className:"w-4 h-4"}),"HTTP"]})}),t.jsx(de,{value:"SSE",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ae,{className:"w-4 h-4"}),"SSE"]})}),t.jsx(de,{value:"Websocket",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Ae,{className:"w-4 h-4"}),"Websocket"]})}),a&&t.jsxs(t.Fragment,{children:[t.jsx(de,{value:"NPX",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(ue,{className:"w-4 h-4"}),"NPX Package"]})}),t.jsx(de,{value:"STDIO",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Qt,{className:"w-4 h-4"}),"Custom Command"]})})]})]})]}),t.jsx(K,{})]})}),V==="NPX"&&t.jsx(U,{control:u.control,name:"npx_package",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"NPM Package *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"@perplexity-ai/mcp-server",...l,value:l.value??"",onPaste:P=>{const v=P.clipboardData.getData("text");v&&(P.preventDefault(),u.setValue("npx_package",v.trim(),{shouldDirty:!0}),ve(v))},onBlur:P=>{ve(P.target.value),l.onBlur()}})}),t.jsx(K,{})]})}),V==="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[t.jsx(U,{control:u.control,name:"stdio_command",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Command *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"node, bun, python...",...l,value:l.value??""})}),t.jsx(K,{})]})}),t.jsx(U,{control:u.control,name:"stdio_args",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Arguments"}),t.jsx(H,{children:t.jsx(J,{placeholder:"arg1 arg2 --flag value",...l,value:l.value??""})}),t.jsx(K,{})]})})]}),t.jsx(U,{control:u.control,name:"stdio_cwd",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Working Directory"}),t.jsx(H,{children:t.jsx(J,{placeholder:"/path/to/project (optional)",...l,value:l.value??""})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Directory where the command will be executed"}),t.jsx(K,{})]})})]}),(V==="NPX"||V==="STDIO")&&t.jsx(U,{control:u.control,name:"env_vars",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Environment Variables"}),t.jsx(H,{children:t.jsx(Dn,{value:l.value??[],onChange:l.onChange})}),t.jsx(K,{})]})}),V!=="NPX"&&V!=="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsx(U,{control:u.control,name:"connection_url",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"URL *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"https://example.com/mcp",...l,value:l.value??"",onPaste:P=>{const v=P.clipboardData.getData("text");v&&(P.preventDefault(),u.setValue("connection_url",v.trim(),{shouldDirty:!0}),ve(v))},onBlur:P=>{ve(P.target.value),l.onBlur()}})}),t.jsx(K,{})]})}),t.jsx(U,{control:u.control,name:"connection_token",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:ce?.token?.label??"Token (optional)"}),t.jsx(H,{children:t.jsx(J,{type:"password",placeholder:ce?.token?.placeholder??"Bearer token or API key",...l,value:l.value??""})}),ce?.token?.helperText&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[ce.token.helperText,ce.id==="github"&&t.jsxs(t.Fragment,{children:[" ","·"," ",t.jsx("a",{className:"text-foreground underline underline-offset-4 hover:text-foreground/80",href:"https://github.com/settings/personal-access-tokens",target:"_blank",rel:"noreferrer",children:"Open GitHub PAT settings"})]})]}),t.jsx(K,{})]})})]}),t.jsx(U,{control:u.control,name:"title",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Name *"}),t.jsx(H,{children:t.jsx(J,{placeholder:"My Connection",...l})}),t.jsx(K,{})]})}),t.jsx(U,{control:u.control,name:"description",render:({field:l})=>t.jsxs(B,{children:[t.jsx(R,{children:"Description"}),t.jsx(H,{children:t.jsx(Cn,{placeholder:"A brief description of this connection",rows:3,...l,value:l.value??""})}),t.jsx(K,{})]})})]}),j=Ge||m.mode==="editing";return f?t.jsx(an,{open:j,onOpenChange:De,children:t.jsxs(dn,{className:"max-h-[90vh]",children:[t.jsx(pn,{className:"pb-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"flex-1 text-left",children:[t.jsx(un,{children:n}),t.jsx(mn,{className:"mt-1",children:s})]}),t.jsx(hn,{asChild:!0,children:t.jsx($,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:t.jsx(jt,{size:16})})})]})}),t.jsx(st,{...u,children:t.jsxs("form",{onSubmit:u.handleSubmit(Je),children:[t.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:p}),t.jsx(xn,{children:t.jsx($,{type:"submit",disabled:u.formState.isSubmitting,className:"w-full",children:r})})]})})]})}):t.jsx(lt,{open:j,onOpenChange:De,children:t.jsxs(at,{className:"sm:max-w-[525px]",children:[t.jsxs(dt,{children:[t.jsx(pt,{children:n}),t.jsx(ut,{children:s})]}),t.jsx(st,{...u,children:t.jsxs("form",{onSubmit:u.handleSubmit(Je),children:[t.jsx("div",{className:"py-4",children:p}),t.jsxs(mt,{children:[t.jsx($,{type:"button",variant:"outline",onClick:()=>De(!1),children:"Cancel"}),t.jsx($,{type:"submit",disabled:u.formState.isSubmitting,className:"min-w-40",children:r})]})]})})]})})})(),t.jsx(Pe,{open:m.mode==="deleting",onOpenChange:n=>!n&&b({type:"close"}),children:t.jsxs($e,{children:[t.jsxs(Ee,{children:[t.jsx(Oe,{children:"Delete Connection?"}),t.jsxs(Le,{children:["This action cannot be undone. This will permanently delete"," ",t.jsx("span",{className:"font-medium text-foreground",children:m.mode==="deleting"&&m.connection.title}),"."]})]}),t.jsxs(Ve,{children:[t.jsx(ze,{children:"Cancel"}),t.jsx(Fe,{onClick:Dt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),t.jsx(Pe,{open:m.mode==="force-deleting",onOpenChange:n=>!n&&b({type:"close"}),children:t.jsxs($e,{children:[t.jsxs(Ee,{children:[t.jsx(Oe,{children:"Connection Used by Agents"}),t.jsx(Le,{asChild:!0,children:t.jsxs("div",{children:[t.jsxs("p",{children:["The connection"," ",t.jsx("span",{className:"font-medium text-foreground",children:m.mode==="force-deleting"&&m.connection.title})," ","is currently used by the following agent(s):"," ",t.jsx("span",{className:"font-medium text-foreground",children:m.mode==="force-deleting"&&m.agentNames}),"."]}),t.jsx("p",{className:"mt-2",children:"Deleting this connection will remove it from those agents, which may impact existing workflows that depend on them."})]})})]}),t.jsxs(Ve,{children:[t.jsx(ze,{children:"Cancel"}),t.jsx(Fe,{onClick:At,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Anyway"})]})]})}),t.jsx(Kn,{open:A,onOpenChange:I,count:x.size,onConfirm:_t}),t.jsx(Hn,{open:_,onOpenChange:L,agents:W,onConfirm:wt}),t.jsxs(ae.Header,{children:[t.jsx(ae.Header.Left,{children:t.jsx(on,{children:t.jsx(rn,{children:t.jsx(cn,{children:t.jsx(ln,{children:"Connections"})})})})}),t.jsxs(ae.Header.Right,{children:[t.jsx(Xt,{sortKey:h.sortKey,sortDirection:h.sortDirection,onSort:h.handleSort,sortOptions:[{id:"title",label:"Name"},{id:"description",label:"Description"},{id:"connection_type",label:"Type"},{id:"updated_by",label:"Updated by"},{id:"updated_at",label:"Updated"}],filters:[{label:"Type",value:F,onChange:n=>te(n||"ALL"),options:[{id:"ALL",label:"All"},{id:"HTTP",label:"HTTP"},{id:"SSE",label:"SSE"},{id:"Websocket",label:"WebSocket"},{id:"STDIO",label:"STDIO"}]},{label:"Status",value:M,onChange:n=>q(n||"ALL"),options:[{id:"ALL",label:"All"},{id:"active",label:"Active"},{id:"inactive",label:"Inactive"},{id:"error",label:"Error"}]}]}),It]})]}),t.jsxs("div",{className:"flex flex-col gap-0",children:[t.jsx("div",{children:t.jsx(Wt,{value:h.search,onChange:h.setSearch,placeholder:"Search for a Connection...",onKeyDown:n=>{n.key==="Escape"&&(h.setSearch(""),n.target.blur())}})}),t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:[t.jsx(Gt,{tabs:[{id:"all",label:"All"},{id:"connected",label:"Connected"}],activeTab:T,onTabChange:n=>ee(n)}),Q.length>0&&t.jsx("div",{className:Z(T!=="all"&&"invisible pointer-events-none"),children:t.jsxs(Me,{children:[t.jsx(Ue,{asChild:!0,children:t.jsxs($,{variant:"outline",size:"sm",className:"h-7 px-2 gap-1.5 text-sm font-normal",children:[(()=>{const n=Q.find(s=>s.id===(ie||Q[0]?.id))??Q[0];return t.jsxs(t.Fragment,{children:[t.jsx(Ie,{icon:n?.icon,name:n?.title??"",size:"2xs",className:"shrink-0 rounded-sm"}),t.jsx("span",{children:n?.title})]})})(),t.jsx(Tn,{size:14,className:"text-muted-foreground"})]})}),t.jsx(Be,{align:"end",children:Q.map(n=>t.jsxs(pe,{onClick:()=>vt(n.id),className:Z(ie===n.id||!ie&&n.id===Q[0]?.id?"bg-accent":""),children:[t.jsx(Ie,{icon:n.icon,name:n.title,size:"2xs",className:"shrink-0 rounded-sm"}),n.title]},n.id))})]})})]})]}),t.jsx(ae.Content,{children:t.jsx("div",{className:"flex-1 overflow-auto p-5",children:(Y?fe.length===0&&ge.length===0&&S.length===0:T==="all"?fe.length===0&&ge.length===0:S.length===0)?t.jsx(qt,{image:t.jsx("img",{src:"/emptystate-mcp.svg",alt:"",width:336,height:320,"aria-hidden":"true"}),title:"No Connections found",description:h.search?`No Connections match "${h.search}"`:"Create a connection to get started."}):t.jsxs("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4",children:[Nt.map(n=>{if(n.type==="group")return t.jsx(Mn,{group:n,onOpen:()=>{o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:n.key}})},selectionMode:N,selectedIds:x,onToggleSelect:he},n.key);const s=n.connection,r=x.has(s.id);return t.jsx(Ne,{connection:s,fallbackIcon:t.jsx(ue,{}),onClick:()=>N?he(s.id):o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(s)}}),className:Z(r&&"ring-2 ring-primary bg-primary/5"),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1",children:[N?t.jsx(ct,{checked:r,onCheckedChange:()=>he(s.id),onClick:p=>p.stopPropagation()}):t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}),t.jsx("div",{className:Z("overflow-hidden transition-all duration-150 ease-out",N?"w-8 opacity-100":"w-0 opacity-0 group-hover:w-8 group-hover:opacity-100"),children:t.jsxs(Me,{children:[t.jsx(Ue,{asChild:!0,children:t.jsx($,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:p=>p.stopPropagation(),children:t.jsx(ht,{size:20})})}),t.jsxs(Be,{align:"end",onClick:p=>p.stopPropagation(),children:[t.jsxs(pe,{onClick:p=>{p.stopPropagation(),o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(s)}})},children:[t.jsx(xt,{size:16}),"Open"]}),t.jsxs(pe,{onClick:p=>{p.stopPropagation(),he(s.id)},children:[t.jsx(Yt,{size:16}),"Select"]}),t.jsxs(pe,{variant:"destructive",onClick:p=>{p.stopPropagation(),b({type:"delete",connection:s})},children:[t.jsx(gt,{size:16}),"Delete"]})]})]})})]})},s.id)}),T==="all"&&fe.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx(_n,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"Verified"}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),fe.map(n=>{const s=n.server?.name||n.name||n.id||"",r=He.has(s),p=n._meta?.["mcp.mesh"],j=p?.friendlyName||p?.friendly_name||n.server?.title||n.title||n.server?.name||n.name||n.id||"",l=n.server?.description||n.description||null,P=n.server?.icons?.[0]?.src||nt(n.server?.repository)||null,v=y.filter(D=>D.connection_type!=="VIRTUAL"&&D.app_name===s);return t.jsx(Ne,{connection:{title:j,description:l,icon:P},fallbackIcon:t.jsx(ue,{}),onClick:()=>{if(r){const D=v[0];D&&o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(D)}})}else Xe(n)},headerActionsAlwaysVisible:!0,headerActions:r?t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}):t.jsx($,{variant:"outline",size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",disabled:je!==null,onClick:D=>{D.stopPropagation(),We(n)},children:je===n.id?t.jsx(Se,{size:14,className:"animate-spin"}):"Connect"})},`catalog-${n.id}`)}),T==="all"&&ge.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:"All connections"}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),ge.map(n=>{const s=n.server?.name||n.name||n.id||"",r=He.has(s),p=n._meta?.["mcp.mesh"],j=p?.friendlyName||p?.friendly_name||n.server?.title||n.title||n.server?.name||n.name||n.id||"",l=n.server?.description||n.description||null,P=n.server?.icons?.[0]?.src||nt(n.server?.repository)||null,v=y.filter(D=>D.connection_type!=="VIRTUAL"&&D.app_name===s);return t.jsx(Ne,{connection:{title:j,description:l,icon:P},fallbackIcon:t.jsx(ue,{}),onClick:()=>{if(r){const D=v[0];D&&o({to:"/$org/$project/mcps/$appSlug",params:{org:i.slug,project:G,appSlug:ne(D)}})}else Xe(n)},headerActionsAlwaysVisible:!0,headerActions:r?t.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"Connected"}):t.jsx($,{variant:"outline",size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",disabled:je!==null,onClick:D=>{D.stopPropagation(),We(n)},children:je===n.id?t.jsx(Se,{size:14,className:"animate-spin"}):"Connect"})},`catalog-${n.id}`)}),(T==="all"||Y)&&_e&&t.jsx("div",{ref:bt,className:"col-span-full h-4"}),(T==="all"||Y)&&re.isLoadingMore&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(Se,{size:24,className:"animate-spin text-muted-foreground"})})]})})}),N&&t.jsx(Rn,{count:x.size,total:S.length,onSelectAll:()=>{C(new Set(S.map(n=>n.id)))},onDeselectAll:()=>C(new Set),onDelete:()=>I(!0),onAddToAgent:()=>L(!0),onToggleStatus:Tt,onCancel:xe})]})})}function ao(){const i=me.c(1);let e;return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Pt,{children:t.jsx(X.Suspense,{fallback:t.jsx("div",{className:"flex h-full items-center justify-center",children:t.jsx(Se,{size:32,className:"animate-spin text-muted-foreground"})}),children:t.jsx(Xn,{})})}),i[0]=e):e=i[0],e}export{ao as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as o}from"./collections-BsFnKFn5.js";import{aR as t}from"./index-D49VqQ7Q.js";const m=t(o,{target:"draft-7"});export{m as B};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{cf as X,cg as ee,ch as te,by as se,ci as re,aD as d,aE as m,cj as oe,ck as ae,cl as ne,cm as I,cn as ie,co as A,cp as ce,cq as b,cr as le,cs as D,ct as ue,cu as de,cv as he,cw as N,bP as pe,cx as fe,cy as me,bu as Q,bF as _e,bL as ge,bJ as we,cz as ke,cA as Te,cB as ye,cC as q,cD as ve,cE as Se,bK as be,bG as Re,bH as Ce,bI as Ie,ce as Ee,cF as qe,cG as Pe,cH as Me,cI as $e,cJ as He,cK as Oe,cb as R,cc as P,cd as U,cL as Ae,bM as H,d as K,z as J}from"./index-B62MiQAu.js";const F={authConfig:()=>["authConfig"],threads:r=>["threads",r],virtualMcpThreads:(r,e)=>["threads",r,"virtual-mcp",e],thread:(r,e)=>["thread",r,e],threadMessages:(r,e)=>["thread-messages",r,e],messages:r=>["messages",r],organizations:()=>["organizations"],members:r=>[r,"members"],invitations:r=>[r,"invitations"],organizationRoles:r=>[r,"organization-roles"],connections:r=>[r,"connections"],connectionsByBinding:(r,e)=>[r,"connections",`binding:${e}`],connection:(r,e)=>[r,"connection",e],isMCPAuthenticated:(r,e)=>["is-mcp-authenticated",r,e],mcpTools:(r,e)=>["mcp","tools",r,e],mcpClient:(r,e,t,s)=>["mcp","client",r,e,t,s],mcpToolsList:r=>["mcp","client",r,"tools"],mcpResourcesList:r=>["mcp","client",r,"resources"],mcpPromptsList:r=>["mcp","client",r,"prompts"],mcpReadResource:(r,e)=>["mcp","client",r,"resource",e],mcpGetPrompt:(r,e,t)=>["mcp","client",r,"prompt",e,t],mcpToolCall:(r,e,t)=>["mcp","client",r,"tool-call",e,t],organizationSettings:r=>["organization-settings",r],activeOrganization:r=>["activeOrganization",r],modelsList:r=>["models-list",r],connectionCollections:r=>[r,"collections","discovery"],toolCall:(r,e,t)=>["tool-call",r,e,t],collectionItems:(r,e)=>["collection",r,e],collection:(r,e,t)=>[r,e,"collection",t],collectionItem:(r,e,t,s,o)=>[r,e,t,"collection",s,o],collectionList:(r,e,t,s,o)=>[r,e,t,"collection",s,"list",o],collectionListInfinite:(r,e,t,s,o)=>[r,e,t,"collection",s,"list-infinite",o],githubReadme:(r,e)=>["github-readme",r,e],monitoringStats:()=>["monitoring","stats"],monitoringLogs:r=>["monitoring","logs",r],monitoringLogsInfinite:(r,e)=>["monitoring","logs-infinite",r,e],virtualMcpPrompts:r=>["virtual-mcp",r,"prompts"],connectionPrompts:r=>["connection",r,"prompts"],connectionResources:r=>["connection",r,"resources"],user:r=>["user",r]};function $(r){return!!r._zod}function v(r,e){return $(r)?X(r,e):r.safeParse(e)}function G(r){if(!r)return;let e;if($(r)?e=r._zod?.def?.shape:e=r.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function De(r){if($(r)){const a=r._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const t=r._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=r.value;if(s!==void 0)return s}function S(r){return r==="completed"||r==="failed"||r==="cancelled"}function j(r){const t=G(r)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=De(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function V(r,e){const t=v(r,e);if(!t.success)throw t.error;return t.data}const Le=6e4;class xe{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(ee,t=>{this._oncancel(t)}),this.setNotificationHandler(te,t=>{this._onprogress(t)}),this.setRequestHandler(se,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(re,async(t,s)=>{const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new d(m.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(oe,async(t,s)=>{const o=async()=>{const a=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(a,s.sessionId);){if(i.type==="response"||i.type==="error"){const c=i.message,f=c.id,l=this._requestResolvers.get(f);if(l)if(this._requestResolvers.delete(f),i.type==="response")l(c);else{const u=c,h=new d(u.error.code,u.error.message,u.error.data);l(h)}else{const u=i.type==="response"?"Response":"Error";this._onerror(new Error(`${u} handler missing for request ${f}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(a,s.sessionId);if(!n)throw new d(m.InvalidParams,`Task not found: ${a}`);if(!S(n.status))return await this._waitForTaskUpdate(a,s.signal),await o();if(S(n.status)){const i=await this._taskStore.getTaskResult(a,s.sessionId);return this._clearTaskQueue(a),{...i,_meta:{...i._meta,[b]:{taskId:a}}}}return await o()};return await o()}),this.setRequestHandler(ae,async(t,s)=>{try{const{tasks:o,nextCursor:a}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:o,nextCursor:a,_meta:{}}}catch(o){throw new d(m.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ne,async(t,s)=>{try{const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new d(m.InvalidParams,`Task not found: ${t.params.taskId}`);if(S(o.status))throw new d(m.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const a=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!a)throw new d(m.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...a}}catch(o){throw o instanceof d?o:new d(m.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,o,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:a,onTimeout:o})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),d.fromError(m.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=a=>{s?.(a),this._onerror(a)};const o=this._transport?.onmessage;this._transport.onmessage=(a,n)=>{o?.(a,n),I(a)||ie(a)?this._onresponse(a):A(a)?this._onrequest(a,n):ce(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=d.fromError(m.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,a=e.params?._meta?.[b]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:m.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(u=>this._onerror(new Error(`Failed to enqueue error response: ${u}`))):o?.send(l).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=le(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,f={signal:n.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const u={relatedRequestId:e.id};a&&(u.relatedTask={taskId:a}),await this.notification(l,u)},sendRequest:async(l,u,h)=>{if(n.signal.aborted)throw new d(m.ConnectionClosed,"Request was cancelled");const _={...h,relatedRequestId:e.id};a&&!_.relatedTask&&(_.relatedTask={taskId:a});const k=_.relatedTask?.taskId??a;return k&&c&&await c.updateTaskStatus(k,"input_required"),await this.request(l,u,_)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,f)).then(async l=>{if(n.signal.aborted)return;const u={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:u,timestamp:Date.now()},o?.sessionId):await o?.send(u)},async l=>{if(n.signal.aborted)return;const u={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:m.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:u,timestamp:Date.now()},o?.sessionId):await o?.send(u)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,o=Number(t),a=this._progressHandlers.get(o);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(o),i=this._timeoutInfo.get(o);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),n(c);return}a(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),I(e))s(e);else{const n=new d(e.error.code,e.error.message,e.error.data);s(n)}return}const o=this._responseHandlers.get(t);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let a=!1;if(I(e)&&e.result&&typeof e.result=="object"){const n=e.result;if(n.task&&typeof n.task=="object"){const i=n.task;typeof i.taskId=="string"&&(a=!0,this._taskProgressTokens.set(i.taskId,t))}}if(a||this._progressHandlers.delete(t),I(e))o(e);else{const n=d.fromError(e.error.code,e.error.message,e.error.data);o(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:o}=s??{};if(!o){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof d?n:new d(m.InternalError,String(n))}}return}let a;try{const n=await this.request(e,D,s);if(n.task)a=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new d(m.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:a},s);if(yield{type:"taskStatus",task:i},S(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)}:i.status==="failed"?yield{type:"error",error:new d(m.InternalError,`Task ${a} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new d(m.InternalError,`Task ${a} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)};return}const c=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(f=>setTimeout(f,c)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof d?n:new d(m.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:o,resumptionToken:a,onresumptiontoken:n,task:i,relatedTask:c}=s??{};return new Promise((f,l)=>{const u=w=>{l(w)};if(!this._transport){u(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(w){u(w);return}s?.signal?.throwIfAborted();const h=this._requestMessageId++,_={...e,jsonrpc:"2.0",id:h};s?.onprogress&&(this._progressHandlers.set(h,s.onprogress),_.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),i&&(_.params={..._.params,task:i}),c&&(_.params={..._.params,_meta:{..._.params?._meta||{},[b]:c}});const k=w=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(w)}},{relatedRequestId:o,resumptionToken:a,onresumptiontoken:n}).catch(E=>this._onerror(new Error(`Failed to send cancellation: ${E}`)));const T=w instanceof d?w:new d(m.RequestTimeout,String(w));l(T)};this._responseHandlers.set(h,w=>{if(!s?.signal?.aborted){if(w instanceof Error)return l(w);try{const T=v(t,w.result);T.success?f(T.data):l(T.error)}catch(T){l(T)}}}),s?.signal?.addEventListener("abort",()=>{k(s?.signal?.reason)});const p=s?.timeout??Le,g=()=>k(d.fromError(m.RequestTimeout,"Request timed out",{timeout:p}));this._setupTimeout(h,p,s?.maxTotalTimeout,g,s?.resetTimeoutOnProgress??!1);const y=c?.taskId;if(y){const w=T=>{const E=this._responseHandlers.get(h);E?E(T):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,w),this._enqueueTaskMessage(y,{type:"request",message:_,timestamp:Date.now()}).catch(T=>{this._cleanupTimeout(h),l(T)})}else this._transport.send(_,{relatedRequestId:o,resumptionToken:a,onresumptiontoken:n}).catch(w=>{this._cleanupTimeout(h),l(w)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ue,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},de,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},he,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=t?.relatedTask?.taskId;if(s){const i={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[b]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:i,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let i={...e,jsonrpc:"2.0"};t?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[b]:t.relatedTask}}}),this._transport?.send(i,t).catch(c=>this._onerror(c))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[b]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=j(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(o,a)=>{const n=V(e,o);return Promise.resolve(t(n,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=j(e);this._notificationHandlers.set(s,o=>{const a=V(e,o);return Promise.resolve(t(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,o)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const o of s)if(o.type==="request"&&A(o.message)){const a=o.message.id,n=this._requestResolvers.get(a);n?(n(new d(m.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(e);o?.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,a)=>{if(t.aborted){a(new d(m.InvalidRequest,"Request cancelled"));return}const n=setTimeout(o,s);t.addEventListener("abort",()=>{clearTimeout(n),a(new d(m.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await s.createTask(o,e.id,{method:e.method,params:e.params},t)},getTask:async o=>{const a=await s.getTask(o,t);if(!a)throw new d(m.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(o,a,n)=>{await s.storeTaskResult(o,a,n,t);const i=await s.getTask(o,t);if(i){const c=N.parse({method:"notifications/tasks/status",params:i});await this.notification(c),S(i.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>s.getTaskResult(o,t),updateTaskStatus:async(o,a,n)=>{const i=await s.getTask(o,t);if(!i)throw new d(m.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(S(i.status))throw new d(m.InvalidParams,`Cannot update task "${o}" from terminal status "${i.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(o,a,n,t);const c=await s.getTask(o,t);if(c){const f=N.parse({method:"notifications/tasks/status",params:c});await this.notification(f),S(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>s.listTasks(o,t)}}}function z(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function Fe(r,e){const t={...r};for(const s in e){const o=s,a=e[o];if(a===void 0)continue;const n=t[o];z(n)&&z(a)?t[o]={...n,...a}:t[o]=a}return t}var Ne=fe();const Ue=pe(Ne);function je(){const r=new Ue({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return me(r),r}class Ve{constructor(e){this._ajv=e??je()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class ze{constructor(e){this._client=e}async*callToolStream(e,t=Q,s){const o=this._client,a={...s,task:s?.task??(o.isToolTask(e.name)?{}:void 0)},n=o.requestStream({method:"tools/call",params:e},t,a),i=o.getToolOutputValidator(e.name);for await(const c of n){if(c.type==="result"&&i){const f=c.result;if(!f.structuredContent&&!f.isError){yield{type:"error",error:new d(m.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(f.structuredContent)try{const l=i(f.structuredContent);if(!l.valid){yield{type:"error",error:new d(m.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof d){yield{type:"error",error:l};return}yield{type:"error",error:new d(m.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function We(r,e,t){if(!r)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!r.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function Qe(r,e,t){if(!r)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!r.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!r.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function M(r,e){if(!(!r||e===null||typeof e!="object")){if(r.type==="object"&&r.properties&&typeof r.properties=="object"){const t=e,s=r.properties;for(const o of Object.keys(s)){const a=s[o];t[o]===void 0&&Object.prototype.hasOwnProperty.call(a,"default")&&(t[o]=a.default),t[o]!==void 0&&M(a,t[o])}}if(Array.isArray(r.anyOf))for(const t of r.anyOf)typeof t!="boolean"&&M(t,e);if(Array.isArray(r.oneOf))for(const t of r.oneOf)typeof t!="boolean"&&M(t,e)}}function B(r){if(!r)return{supportsFormMode:!1,supportsUrlMode:!1};const e=r.form!==void 0,t=r.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let Y=class extends xe{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Ve,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",_e,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",ge,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",we,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new ze(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Fe(this._capabilities,e)}setRequestHandler(e,t){const o=G(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let a;if($(o)){const i=o;a=i._zod?.def?.value??i.value}else{const i=o;a=i._def?.value??i.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const n=a;if(n==="elicitation/create"){const i=async(c,f)=>{const l=v(Pe,c);if(!l.success){const w=l.error instanceof Error?l.error.message:String(l.error);throw new d(m.InvalidParams,`Invalid elicitation request: ${w}`)}const{params:u}=l.data;u.mode=u.mode??"form";const{supportsFormMode:h,supportsUrlMode:_}=B(this._capabilities.elicitation);if(u.mode==="form"&&!h)throw new d(m.InvalidParams,"Client does not support form-mode elicitation requests");if(u.mode==="url"&&!_)throw new d(m.InvalidParams,"Client does not support URL-mode elicitation requests");const k=await Promise.resolve(t(c,f));if(u.task){const w=v(D,k);if(!w.success){const T=w.error instanceof Error?w.error.message:String(w.error);throw new d(m.InvalidParams,`Invalid task creation result: ${T}`)}return w.data}const p=v(Me,k);if(!p.success){const w=p.error instanceof Error?p.error.message:String(p.error);throw new d(m.InvalidParams,`Invalid elicitation result: ${w}`)}const g=p.data,y=u.mode==="form"?u.requestedSchema:void 0;if(u.mode==="form"&&g.action==="accept"&&g.content&&y&&this._capabilities.elicitation?.form?.applyDefaults)try{M(y,g.content)}catch{}return g};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(c,f)=>{const l=v($e,c);if(!l.success){const g=l.error instanceof Error?l.error.message:String(l.error);throw new d(m.InvalidParams,`Invalid sampling request: ${g}`)}const{params:u}=l.data,h=await Promise.resolve(t(c,f));if(u.task){const g=v(D,h);if(!g.success){const y=g.error instanceof Error?g.error.message:String(g.error);throw new d(m.InvalidParams,`Invalid task creation result: ${y}`)}return g.data}const k=u.tools||u.toolChoice?He:Oe,p=v(k,h);if(!p.success){const g=p.error instanceof Error?p.error.message:String(p.error);throw new d(m.InvalidParams,`Invalid sampling result: ${g}`)}return p.data};return super.setRequestHandler(e,i)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:ke,capabilities:this._capabilities,clientInfo:this._clientInfo}},Te,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!ye.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){We(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&Qe(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},q,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},ve,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},q,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Se,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},be,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},Re,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},Ce,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Ie,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},q,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},q,t)}async callTool(e,t=Q,s){if(this.isToolTaskRequired(e.name))throw new d(m.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const o=await this.request({method:"tools/call",params:e},t,s),a=this.getToolOutputValidator(e.name);if(a){if(!o.structuredContent&&!o.isError)throw new d(m.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{const n=a(o.structuredContent);if(!n.valid)throw new d(m.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof d?n:new d(m.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const o=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,o)}const s=t.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(t.name),s==="required"&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},Ee,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,o){const a=qe.safeParse(s);if(!a.success)throw new Error(`Invalid ${e} listChanged options: ${a.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=a.data,{onChanged:c}=s,f=async()=>{if(!n){c(null,null);return}try{const u=await o();c(null,u)}catch(u){const h=u instanceof Error?u:new Error(String(u));c(h,null)}},l=()=>{if(i){const u=this._listChangedDebounceTimers.get(e);u&&clearTimeout(u);const h=setTimeout(f,i);this._listChangedDebounceTimers.set(e,h)}else f()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const it=Object.freeze(Object.defineProperty({__proto__:null,Client:Y,getSupportedElicitationModes:B},Symbol.toStringTag,{value:"Module"}));function L(r){return r?r instanceof Headers?Object.fromEntries(r.entries()):Array.isArray(r)?Object.fromEntries(r):{...r}:{}}function Ke(r=fetch,e){return e?async(t,s)=>{const o={...e,...s,headers:s?.headers?{...L(e.headers),...L(s.headers)}:e.headers};return r(t,o)}:r}class W extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function O(r){}function Je(r){if(typeof r=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=O,onError:t=O,onRetry:s=O,onComment:o}=r;let a="",n=!0,i,c="",f="";function l(p){const g=n?p.replace(/^\xEF\xBB\xBF/,""):p,[y,w]=Ge(`${a}${g}`);for(const T of y)u(T);a=w,n=!1}function u(p){if(p===""){_();return}if(p.startsWith(":")){o&&o(p.slice(p.startsWith(": ")?2:1));return}const g=p.indexOf(":");if(g!==-1){const y=p.slice(0,g),w=p[g+1]===" "?2:1,T=p.slice(g+w);h(y,T,p);return}h(p,"",p)}function h(p,g,y){switch(p){case"event":f=g;break;case"data":c=`${c}${g}
|
|
1
|
+
import{cf as X,cg as ee,ch as te,by as se,ci as re,aD as d,aE as m,cj as oe,ck as ae,cl as ne,cm as I,cn as ie,co as A,cp as ce,cq as b,cr as le,cs as D,ct as ue,cu as de,cv as he,cw as N,bP as pe,cx as fe,cy as me,bu as Q,bF as _e,bL as ge,bJ as we,cz as ke,cA as Te,cB as ye,cC as q,cD as ve,cE as Se,bK as be,bG as Re,bH as Ce,bI as Ie,ce as Ee,cF as qe,cG as Pe,cH as Me,cI as $e,cJ as He,cK as Oe,cb as R,cc as P,cd as U,cL as Ae,bM as H,d as K,z as J}from"./index-D49VqQ7Q.js";const F={authConfig:()=>["authConfig"],threads:r=>["threads",r],virtualMcpThreads:(r,e)=>["threads",r,"virtual-mcp",e],thread:(r,e)=>["thread",r,e],threadMessages:(r,e)=>["thread-messages",r,e],messages:r=>["messages",r],organizations:()=>["organizations"],members:r=>[r,"members"],invitations:r=>[r,"invitations"],organizationRoles:r=>[r,"organization-roles"],connections:r=>[r,"connections"],connectionsByBinding:(r,e)=>[r,"connections",`binding:${e}`],connection:(r,e)=>[r,"connection",e],isMCPAuthenticated:(r,e)=>["is-mcp-authenticated",r,e],mcpTools:(r,e)=>["mcp","tools",r,e],mcpClient:(r,e,t,s)=>["mcp","client",r,e,t,s],mcpToolsList:r=>["mcp","client",r,"tools"],mcpResourcesList:r=>["mcp","client",r,"resources"],mcpPromptsList:r=>["mcp","client",r,"prompts"],mcpReadResource:(r,e)=>["mcp","client",r,"resource",e],mcpGetPrompt:(r,e,t)=>["mcp","client",r,"prompt",e,t],mcpToolCall:(r,e,t)=>["mcp","client",r,"tool-call",e,t],organizationSettings:r=>["organization-settings",r],activeOrganization:r=>["activeOrganization",r],modelsList:r=>["models-list",r],connectionCollections:r=>[r,"collections","discovery"],toolCall:(r,e,t)=>["tool-call",r,e,t],collectionItems:(r,e)=>["collection",r,e],collection:(r,e,t)=>[r,e,"collection",t],collectionItem:(r,e,t,s,o)=>[r,e,t,"collection",s,o],collectionList:(r,e,t,s,o)=>[r,e,t,"collection",s,"list",o],collectionListInfinite:(r,e,t,s,o)=>[r,e,t,"collection",s,"list-infinite",o],githubReadme:(r,e)=>["github-readme",r,e],monitoringStats:()=>["monitoring","stats"],monitoringLogs:r=>["monitoring","logs",r],monitoringLogsInfinite:(r,e)=>["monitoring","logs-infinite",r,e],virtualMcpPrompts:r=>["virtual-mcp",r,"prompts"],connectionPrompts:r=>["connection",r,"prompts"],connectionResources:r=>["connection",r,"resources"],user:r=>["user",r]};function $(r){return!!r._zod}function v(r,e){return $(r)?X(r,e):r.safeParse(e)}function G(r){if(!r)return;let e;if($(r)?e=r._zod?.def?.shape:e=r.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function De(r){if($(r)){const a=r._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.values[0]}}const t=r._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const s=r.value;if(s!==void 0)return s}function S(r){return r==="completed"||r==="failed"||r==="cancelled"}function j(r){const t=G(r)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=De(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function V(r,e){const t=v(r,e);if(!t.success)throw t.error;return t.data}const Le=6e4;class xe{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(ee,t=>{this._oncancel(t)}),this.setNotificationHandler(te,t=>{this._onprogress(t)}),this.setRequestHandler(se,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(re,async(t,s)=>{const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new d(m.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(oe,async(t,s)=>{const o=async()=>{const a=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(a,s.sessionId);){if(i.type==="response"||i.type==="error"){const c=i.message,f=c.id,l=this._requestResolvers.get(f);if(l)if(this._requestResolvers.delete(f),i.type==="response")l(c);else{const u=c,h=new d(u.error.code,u.error.message,u.error.data);l(h)}else{const u=i.type==="response"?"Response":"Error";this._onerror(new Error(`${u} handler missing for request ${f}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(a,s.sessionId);if(!n)throw new d(m.InvalidParams,`Task not found: ${a}`);if(!S(n.status))return await this._waitForTaskUpdate(a,s.signal),await o();if(S(n.status)){const i=await this._taskStore.getTaskResult(a,s.sessionId);return this._clearTaskQueue(a),{...i,_meta:{...i._meta,[b]:{taskId:a}}}}return await o()};return await o()}),this.setRequestHandler(ae,async(t,s)=>{try{const{tasks:o,nextCursor:a}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:o,nextCursor:a,_meta:{}}}catch(o){throw new d(m.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ne,async(t,s)=>{try{const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new d(m.InvalidParams,`Task not found: ${t.params.taskId}`);if(S(o.status))throw new d(m.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const a=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!a)throw new d(m.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...a}}catch(o){throw o instanceof d?o:new d(m.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,o,a=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:a,onTimeout:o})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const s=Date.now()-t.startTime;if(t.maxTotalTimeout&&s>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),d.fromError(m.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:s});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const s=this.transport?.onerror;this._transport.onerror=a=>{s?.(a),this._onerror(a)};const o=this._transport?.onmessage;this._transport.onmessage=(a,n)=>{o?.(a,n),I(a)||ie(a)?this._onresponse(a):A(a)?this._onrequest(a,n):ce(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=d.fromError(m.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const s of e.values())s(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,t){const s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,a=e.params?._meta?.[b]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:m.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(u=>this._onerror(new Error(`Failed to enqueue error response: ${u}`))):o?.send(l).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=le(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,f={signal:n.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const u={relatedRequestId:e.id};a&&(u.relatedTask={taskId:a}),await this.notification(l,u)},sendRequest:async(l,u,h)=>{if(n.signal.aborted)throw new d(m.ConnectionClosed,"Request was cancelled");const _={...h,relatedRequestId:e.id};a&&!_.relatedTask&&(_.relatedTask={taskId:a});const k=_.relatedTask?.taskId??a;return k&&c&&await c.updateTaskStatus(k,"input_required"),await this.request(l,u,_)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,f)).then(async l=>{if(n.signal.aborted)return;const u={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:u,timestamp:Date.now()},o?.sessionId):await o?.send(u)},async l=>{if(n.signal.aborted)return;const u={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:m.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:u,timestamp:Date.now()},o?.sessionId):await o?.send(u)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,o=Number(t),a=this._progressHandlers.get(o);if(!a){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(o),i=this._timeoutInfo.get(o);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),n(c);return}a(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),I(e))s(e);else{const n=new d(e.error.code,e.error.message,e.error.data);s(n)}return}const o=this._responseHandlers.get(t);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let a=!1;if(I(e)&&e.result&&typeof e.result=="object"){const n=e.result;if(n.task&&typeof n.task=="object"){const i=n.task;typeof i.taskId=="string"&&(a=!0,this._taskProgressTokens.set(i.taskId,t))}}if(a||this._progressHandlers.delete(t),I(e))o(e);else{const n=d.fromError(e.error.code,e.error.message,e.error.data);o(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:o}=s??{};if(!o){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof d?n:new d(m.InternalError,String(n))}}return}let a;try{const n=await this.request(e,D,s);if(n.task)a=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new d(m.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:a},s);if(yield{type:"taskStatus",task:i},S(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)}:i.status==="failed"?yield{type:"error",error:new d(m.InternalError,`Task ${a} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new d(m.InternalError,`Task ${a} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},t,s)};return}const c=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(f=>setTimeout(f,c)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof d?n:new d(m.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:o,resumptionToken:a,onresumptiontoken:n,task:i,relatedTask:c}=s??{};return new Promise((f,l)=>{const u=w=>{l(w)};if(!this._transport){u(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(w){u(w);return}s?.signal?.throwIfAborted();const h=this._requestMessageId++,_={...e,jsonrpc:"2.0",id:h};s?.onprogress&&(this._progressHandlers.set(h,s.onprogress),_.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),i&&(_.params={..._.params,task:i}),c&&(_.params={..._.params,_meta:{..._.params?._meta||{},[b]:c}});const k=w=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(w)}},{relatedRequestId:o,resumptionToken:a,onresumptiontoken:n}).catch(E=>this._onerror(new Error(`Failed to send cancellation: ${E}`)));const T=w instanceof d?w:new d(m.RequestTimeout,String(w));l(T)};this._responseHandlers.set(h,w=>{if(!s?.signal?.aborted){if(w instanceof Error)return l(w);try{const T=v(t,w.result);T.success?f(T.data):l(T.error)}catch(T){l(T)}}}),s?.signal?.addEventListener("abort",()=>{k(s?.signal?.reason)});const p=s?.timeout??Le,g=()=>k(d.fromError(m.RequestTimeout,"Request timed out",{timeout:p}));this._setupTimeout(h,p,s?.maxTotalTimeout,g,s?.resetTimeoutOnProgress??!1);const y=c?.taskId;if(y){const w=T=>{const E=this._responseHandlers.get(h);E?E(T):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,w),this._enqueueTaskMessage(y,{type:"request",message:_,timestamp:Date.now()}).catch(T=>{this._cleanupTimeout(h),l(T)})}else this._transport.send(_,{relatedRequestId:o,resumptionToken:a,onresumptiontoken:n}).catch(w=>{this._cleanupTimeout(h),l(w)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ue,t)}async getTaskResult(e,t,s){return this.request({method:"tasks/result",params:e},t,s)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},de,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},he,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const s=t?.relatedTask?.taskId;if(s){const i={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[b]:t.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:i,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let i={...e,jsonrpc:"2.0"};t?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[b]:t.relatedTask}}}),this._transport?.send(i,t).catch(c=>this._onerror(c))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[b]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=j(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(o,a)=>{const n=V(e,o);return Promise.resolve(t(n,a))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const s=j(e);this._notificationHandlers.set(s,o=>{const a=V(e,o);return Promise.resolve(t(a))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,o)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const o of s)if(o.type==="request"&&A(o.message)){const a=o.message.id,n=this._requestResolvers.get(a);n?(n(new d(m.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(a)):this._onerror(new Error(`Resolver missing for request ${a} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(e);o?.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,a)=>{if(t.aborted){a(new d(m.InvalidRequest,"Request cancelled"));return}const n=setTimeout(o,s);t.addEventListener("abort",()=>{clearTimeout(n),a(new d(m.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await s.createTask(o,e.id,{method:e.method,params:e.params},t)},getTask:async o=>{const a=await s.getTask(o,t);if(!a)throw new d(m.InvalidParams,"Failed to retrieve task: Task not found");return a},storeTaskResult:async(o,a,n)=>{await s.storeTaskResult(o,a,n,t);const i=await s.getTask(o,t);if(i){const c=N.parse({method:"notifications/tasks/status",params:i});await this.notification(c),S(i.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>s.getTaskResult(o,t),updateTaskStatus:async(o,a,n)=>{const i=await s.getTask(o,t);if(!i)throw new d(m.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(S(i.status))throw new d(m.InvalidParams,`Cannot update task "${o}" from terminal status "${i.status}" to "${a}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(o,a,n,t);const c=await s.getTask(o,t);if(c){const f=N.parse({method:"notifications/tasks/status",params:c});await this.notification(f),S(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>s.listTasks(o,t)}}}function z(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)}function Fe(r,e){const t={...r};for(const s in e){const o=s,a=e[o];if(a===void 0)continue;const n=t[o];z(n)&&z(a)?t[o]={...n,...a}:t[o]=a}return t}var Ne=fe();const Ue=pe(Ne);function je(){const r=new Ue({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return me(r),r}class Ve{constructor(e){this._ajv=e??je()}getValidator(e){const t="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>t(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class ze{constructor(e){this._client=e}async*callToolStream(e,t=Q,s){const o=this._client,a={...s,task:s?.task??(o.isToolTask(e.name)?{}:void 0)},n=o.requestStream({method:"tools/call",params:e},t,a),i=o.getToolOutputValidator(e.name);for await(const c of n){if(c.type==="result"&&i){const f=c.result;if(!f.structuredContent&&!f.isError){yield{type:"error",error:new d(m.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(f.structuredContent)try{const l=i(f.structuredContent);if(!l.valid){yield{type:"error",error:new d(m.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof d){yield{type:"error",error:l};return}yield{type:"error",error:new d(m.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,s){return this._client.getTaskResult({taskId:e},t,s)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,s){return this._client.requestStream(e,t,s)}}function We(r,e,t){if(!r)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!r.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function Qe(r,e,t){if(!r)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!r.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!r.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function M(r,e){if(!(!r||e===null||typeof e!="object")){if(r.type==="object"&&r.properties&&typeof r.properties=="object"){const t=e,s=r.properties;for(const o of Object.keys(s)){const a=s[o];t[o]===void 0&&Object.prototype.hasOwnProperty.call(a,"default")&&(t[o]=a.default),t[o]!==void 0&&M(a,t[o])}}if(Array.isArray(r.anyOf))for(const t of r.anyOf)typeof t!="boolean"&&M(t,e);if(Array.isArray(r.oneOf))for(const t of r.oneOf)typeof t!="boolean"&&M(t,e)}}function B(r){if(!r)return{supportsFormMode:!1,supportsUrlMode:!1};const e=r.form!==void 0,t=r.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let Y=class extends xe{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Ve,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",_e,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",ge,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",we,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new ze(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Fe(this._capabilities,e)}setRequestHandler(e,t){const o=G(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let a;if($(o)){const i=o;a=i._zod?.def?.value??i.value}else{const i=o;a=i._def?.value??i.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const n=a;if(n==="elicitation/create"){const i=async(c,f)=>{const l=v(Pe,c);if(!l.success){const w=l.error instanceof Error?l.error.message:String(l.error);throw new d(m.InvalidParams,`Invalid elicitation request: ${w}`)}const{params:u}=l.data;u.mode=u.mode??"form";const{supportsFormMode:h,supportsUrlMode:_}=B(this._capabilities.elicitation);if(u.mode==="form"&&!h)throw new d(m.InvalidParams,"Client does not support form-mode elicitation requests");if(u.mode==="url"&&!_)throw new d(m.InvalidParams,"Client does not support URL-mode elicitation requests");const k=await Promise.resolve(t(c,f));if(u.task){const w=v(D,k);if(!w.success){const T=w.error instanceof Error?w.error.message:String(w.error);throw new d(m.InvalidParams,`Invalid task creation result: ${T}`)}return w.data}const p=v(Me,k);if(!p.success){const w=p.error instanceof Error?p.error.message:String(p.error);throw new d(m.InvalidParams,`Invalid elicitation result: ${w}`)}const g=p.data,y=u.mode==="form"?u.requestedSchema:void 0;if(u.mode==="form"&&g.action==="accept"&&g.content&&y&&this._capabilities.elicitation?.form?.applyDefaults)try{M(y,g.content)}catch{}return g};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(c,f)=>{const l=v($e,c);if(!l.success){const g=l.error instanceof Error?l.error.message:String(l.error);throw new d(m.InvalidParams,`Invalid sampling request: ${g}`)}const{params:u}=l.data,h=await Promise.resolve(t(c,f));if(u.task){const g=v(D,h);if(!g.success){const y=g.error instanceof Error?g.error.message:String(g.error);throw new d(m.InvalidParams,`Invalid task creation result: ${y}`)}return g.data}const k=u.tools||u.toolChoice?He:Oe,p=v(k,h);if(!p.success){const g=p.error instanceof Error?p.error.message:String(p.error);throw new d(m.InvalidParams,`Invalid sampling result: ${g}`)}return p.data};return super.setRequestHandler(e,i)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),e.sessionId===void 0)try{const s=await this.request({method:"initialize",params:{protocolVersion:ke,capabilities:this._capabilities,clientInfo:this._clientInfo}},Te,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!ye.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`);break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`);break}}assertTaskCapability(e){We(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&Qe(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},q,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},ve,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},q,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Se,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},be,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},Re,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},Ce,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Ie,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},q,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},q,t)}async callTool(e,t=Q,s){if(this.isToolTaskRequired(e.name))throw new d(m.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const o=await this.request({method:"tools/call",params:e},t,s),a=this.getToolOutputValidator(e.name);if(a){if(!o.structuredContent&&!o.isError)throw new d(m.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{const n=a(o.structuredContent);if(!n.valid)throw new d(m.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof d?n:new d(m.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const o=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,o)}const s=t.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(t.name),s==="required"&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const s=await this.request({method:"tools/list",params:e},Ee,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,o){const a=qe.safeParse(s);if(!a.success)throw new Error(`Invalid ${e} listChanged options: ${a.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=a.data,{onChanged:c}=s,f=async()=>{if(!n){c(null,null);return}try{const u=await o();c(null,u)}catch(u){const h=u instanceof Error?u:new Error(String(u));c(h,null)}},l=()=>{if(i){const u=this._listChangedDebounceTimers.get(e);u&&clearTimeout(u);const h=setTimeout(f,i);this._listChangedDebounceTimers.set(e,h)}else f()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const it=Object.freeze(Object.defineProperty({__proto__:null,Client:Y,getSupportedElicitationModes:B},Symbol.toStringTag,{value:"Module"}));function L(r){return r?r instanceof Headers?Object.fromEntries(r.entries()):Array.isArray(r)?Object.fromEntries(r):{...r}:{}}function Ke(r=fetch,e){return e?async(t,s)=>{const o={...e,...s,headers:s?.headers?{...L(e.headers),...L(s.headers)}:e.headers};return r(t,o)}:r}class W extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function O(r){}function Je(r){if(typeof r=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=O,onError:t=O,onRetry:s=O,onComment:o}=r;let a="",n=!0,i,c="",f="";function l(p){const g=n?p.replace(/^\xEF\xBB\xBF/,""):p,[y,w]=Ge(`${a}${g}`);for(const T of y)u(T);a=w,n=!1}function u(p){if(p===""){_();return}if(p.startsWith(":")){o&&o(p.slice(p.startsWith(": ")?2:1));return}const g=p.indexOf(":");if(g!==-1){const y=p.slice(0,g),w=p[g+1]===" "?2:1,T=p.slice(g+w);h(y,T,p);return}h(p,"",p)}function h(p,g,y){switch(p){case"event":f=g;break;case"data":c=`${c}${g}
|
|
2
2
|
`;break;case"id":i=g.includes("\0")?void 0:g;break;case"retry":/^\d+$/.test(g)?s(parseInt(g,10)):t(new W(`Invalid \`retry\` value: "${g}"`,{type:"invalid-retry",value:g,line:y}));break;default:t(new W(`Unknown field "${p.length>20?`${p.slice(0,20)}…`:p}"`,{type:"unknown-field",field:p,value:g,line:y}));break}}function _(){c.length>0&&e({id:i,event:f||void 0,data:c.endsWith(`
|
|
3
3
|
`)?c.slice(0,-1):c}),i=void 0,c="",f=""}function k(p={}){a&&p.consume&&u(a),n=!0,i=void 0,c="",f="",a=""}return{feed:l,reset:k}}function Ge(r){const e=[];let t="",s=0;for(;s<r.length;){const o=r.indexOf("\r",s),a=r.indexOf(`
|
|
4
4
|
`,s);let n=-1;if(o!==-1&&a!==-1?n=Math.min(o,a):o!==-1?o===r.length-1?n=-1:n=o:a!==-1&&(n=a),n===-1){t=r.slice(s);break}else{const i=r.slice(s,n);e.push(i),s=n+1,r[s-1]==="\r"&&r[s]===`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bZ as It,aR as _t,aP as D,q as d,b_ as oe,b$ as qe,aO as Et,bU as Tt,aK as St,aM as P,aV as K,aL as se,o as S,bp as h,aQ as L,c0 as At,c1 as w,aN as Mt,F as V,w as me,d as ze,r as z}from"./index-
|
|
1
|
+
import{bZ as It,aR as _t,aP as D,q as d,b_ as oe,b$ as qe,aO as Et,bU as Tt,aK as St,aM as P,aV as K,aL as se,o as S,bp as h,aQ as L,c0 as At,c1 as w,aN as Mt,F as V,w as me,d as ze,r as z}from"./index-D49VqQ7Q.js";import{E as wt,d as xt}from"./constants-TLV7MTwP.js";import{A as Te,D as de}from"./decopilot-events-Brt4gAR6.js";import"./index-2hR_U2H-.js";var ee;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function a(r){throw new Error}t.assertNever=a,t.arrayToEnum=r=>{const n={};for(const o of r)n[o]=o;return n},t.getValidEnumValues=r=>{const n=t.objectKeys(r).filter(i=>typeof r[r[i]]!="number"),o={};for(const i of n)o[i]=r[i];return t.objectValues(o)},t.objectValues=r=>t.objectKeys(r).map(function(n){return r[n]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const n=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&n.push(o);return n},t.find=(r,n)=>{for(const o of r)if(n(o))return o},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,n=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(n)}t.joinValues=s,t.jsonStringifyReplacer=(r,n)=>typeof n=="bigint"?n.toString():n})(ee||(ee={}));var Se;(function(t){t.mergeShapes=(e,a)=>({...e,...a})})(Se||(Se={}));ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);ee.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class le extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const a=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,a):this.__proto__=a,this.name="ZodError",this.issues=e}format(e){const a=e||function(n){return n.message},s={_errors:[]},r=n=>{for(const o of n.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(a(o));else{let i=s,u=0;for(;u<o.path.length;){const l=o.path[u];u===o.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(a(o))):i[l]=i[l]||{_errors:[]},i=i[l],u++}}};return r(this),s}static assert(e){if(!(e instanceof le))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=a=>a.message){const a=Object.create(null),s=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];a[n]=a[n]||[],a[n].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:a}}get formErrors(){return this.flatten()}}le.create=t=>new le(t);var Ae;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Ae||(Ae={}));var g;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(g||(g={}));var We="vercel.ai.error",Rt=Symbol.for(We),Me,we,F=class Ye extends(we=Error,Me=Rt,we){constructor({name:e,message:a,cause:s}){super(a),this[Me]=!0,this.name=e,this.cause=s}static isInstance(e){return Ye.hasMarker(e,We)}static hasMarker(e,a){const s=Symbol.for(a);return e!=null&&typeof e=="object"&&s in e&&typeof e[s]=="boolean"&&e[s]===!0}};function He(t){return t==null?"unknown error":typeof t=="string"?t:t instanceof Error?t.message:JSON.stringify(t)}var Ge="AI_InvalidArgumentError",Xe=`vercel.ai.error.${Ge}`,Nt=Symbol.for(Xe),xe,Re,Ot=class extends(Re=F,xe=Nt,Re){constructor({message:t,cause:e,argument:a}){super({name:Ge,message:t,cause:e}),this[xe]=!0,this.argument=a}static isInstance(t){return F.hasMarker(t,Xe)}},Qe="AI_JSONParseError",Ke=`vercel.ai.error.${Qe}`,Ct=Symbol.for(Ke),Ne,Oe,Ce=class extends(Oe=F,Ne=Ct,Oe){constructor({text:t,cause:e}){super({name:Qe,message:`JSON parsing failed: Text: ${t}.
|
|
2
2
|
Error message: ${He(e)}`,cause:e}),this[Ne]=!0,this.text=t}static isInstance(t){return F.hasMarker(t,Ke)}},et="AI_TypeValidationError",tt=`vercel.ai.error.${et}`,Pt=Symbol.for(tt),Pe,De,H=class ge extends(De=F,Pe=Pt,De){constructor({value:e,cause:a,context:s}){let r="Type validation failed";if(s?.field&&(r+=` for ${s.field}`),s?.entityName||s?.entityId){r+=" (";const n=[];s.entityName&&n.push(s.entityName),s.entityId&&n.push(`id: "${s.entityId}"`),r+=n.join(", "),r+=")"}super({name:et,message:`${r}: Value: ${JSON.stringify(e)}.
|
|
3
3
|
Error message: ${He(a)}`,cause:a}),this[Pe]=!0,this.value=e,this.context=s}static isInstance(e){return F.hasMarker(e,tt)}static wrap({value:e,cause:a,context:s}){var r,n,o;return ge.isInstance(a)&&a.value===e&&((r=a.context)==null?void 0:r.field)===s?.field&&((n=a.context)==null?void 0:n.entityName)===s?.entityName&&((o=a.context)==null?void 0:o.entityId)===s?.entityId?a:new ge({value:e,cause:a,context:s})}},re=({prefix:t,size:e=16,alphabet:a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:s="-"}={})=>{const r=()=>{const n=a.length,o=new Array(e);for(let i=0;i<e;i++)o[i]=a[Math.random()*n|0];return o.join("")};if(t==null)return r;if(a.includes(s))throw new Ot({argument:"separator",message:`The separator "${s}" must not be part of the alphabet "${a}".`});return()=>`${t}${s}${r()}`},Dt=re();function ke(t=globalThis){var e,a,s;return t.window?"runtime/browser":(e=t.navigator)!=null&&e.userAgent?`runtime/${t.navigator.userAgent.toLowerCase()}`:(s=(a=t.process)==null?void 0:a.versions)!=null&&s.node?`runtime/node.js/${t.process.version.substring(0)}`:t.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function q(t){if(t==null)return{};const e={};if(t instanceof Headers)t.forEach((a,s)=>{e[s.toLowerCase()]=a});else{Array.isArray(t)||(t=Object.entries(t));for(const[a,s]of t)s!=null&&(e[a.toLowerCase()]=s)}return e}function je(t,...e){const a=new Headers(q(t)),s=a.get("user-agent")||"";return a.set("user-agent",[s,...e].filter(Boolean).join(" ")),Object.fromEntries(a.entries())}var kt=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,jt=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function $e(t){const e=JSON.parse(t);return e===null||typeof e!="object"||kt.test(t)===!1&&jt.test(t)===!1?e:$t(e)}function $t(t){let e=[t];for(;e.length;){const a=e;e=[];for(const s of a){if(Object.prototype.hasOwnProperty.call(s,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(s,"constructor")&&s.constructor!==null&&typeof s.constructor=="object"&&Object.prototype.hasOwnProperty.call(s.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const r in s){const n=s[r];n&&typeof n=="object"&&e.push(n)}}}return t}function Zt(t){const{stackTraceLimit:e}=Error;try{Error.stackTraceLimit=0}catch{return $e(t)}try{return $e(t)}finally{Error.stackTraceLimit=e}}function Ie(t){if(t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")){t.additionalProperties=!1;const{properties:a}=t;if(a!=null)for(const s of Object.keys(a))a[s]=J(a[s])}t.items!=null&&(t.items=Array.isArray(t.items)?t.items.map(J):J(t.items)),t.anyOf!=null&&(t.anyOf=t.anyOf.map(J)),t.allOf!=null&&(t.allOf=t.allOf.map(J)),t.oneOf!=null&&(t.oneOf=t.oneOf.map(J));const{definitions:e}=t;if(e!=null)for(const a of Object.keys(e))e[a]=J(e[a]);return t}function J(t){return typeof t=="boolean"?t:Ie(t)}var Ft=Symbol("Let zodToJsonSchema decide on which parser to use"),Ze={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},Lt=t=>typeof t=="string"?{...Ze,name:t}:{...Ze,...t};function k(){return{}}function Ut(t,e){var a,s,r;const n={type:"array"};return(a=t.type)!=null&&a._def&&((r=(s=t.type)==null?void 0:s._def)==null?void 0:r.typeName)!==g.ZodAny&&(n.items=_(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&(n.minItems=t.minLength.value),t.maxLength&&(n.maxItems=t.maxLength.value),t.exactLength&&(n.minItems=t.exactLength.value,n.maxItems=t.exactLength.value),n}function Bt(t){const e={type:"integer",format:"int64"};if(!t.checks)return e;for(const a of t.checks)switch(a.kind){case"min":a.inclusive?e.minimum=a.value:e.exclusiveMinimum=a.value;break;case"max":a.inclusive?e.maximum=a.value:e.exclusiveMaximum=a.value;break;case"multipleOf":e.multipleOf=a.value;break}return e}function Vt(){return{type:"boolean"}}function at(t,e){return _(t.type._def,e)}var Jt=(t,e)=>_(t.innerType._def,e);function st(t,e,a){const s=a??e.dateStrategy;if(Array.isArray(s))return{anyOf:s.map((r,n)=>st(t,e,r))};switch(s){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return qt(t)}}var qt=t=>{const e={type:"integer",format:"unix-time"};for(const a of t.checks)switch(a.kind){case"min":e.minimum=a.value;break;case"max":e.maximum=a.value;break}return e};function zt(t,e){return{..._(t.innerType._def,e),default:t.defaultValue()}}function Wt(t,e){return e.effectStrategy==="input"?_(t.schema._def,e):k()}function Yt(t){return{type:"string",enum:Array.from(t.values)}}var Ht=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Gt(t,e){const a=[_(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),_(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(r=>!!r),s=[];return a.forEach(r=>{if(Ht(r))s.push(...r.allOf);else{let n=r;if("additionalProperties"in r&&r.additionalProperties===!1){const{additionalProperties:o,...i}=r;n=i}s.push(n)}}),s.length?{allOf:s}:void 0}function Xt(t){const e=typeof t.value;return e!=="bigint"&&e!=="number"&&e!=="boolean"&&e!=="string"?{type:Array.isArray(t.value)?"array":"object"}:{type:e==="bigint"?"integer":e,const:t.value}}var pe=void 0,$={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(pe===void 0&&(pe=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),pe),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function rt(t,e){const a={type:"string"};if(t.checks)for(const s of t.checks)switch(s.kind){case"min":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value;break;case"max":a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"email":switch(e.emailStrategy){case"format:email":Z(a,"email",s.message,e);break;case"format:idn-email":Z(a,"idn-email",s.message,e);break;case"pattern:zod":C(a,$.email,s.message,e);break}break;case"url":Z(a,"uri",s.message,e);break;case"uuid":Z(a,"uuid",s.message,e);break;case"regex":C(a,s.regex,s.message,e);break;case"cuid":C(a,$.cuid,s.message,e);break;case"cuid2":C(a,$.cuid2,s.message,e);break;case"startsWith":C(a,RegExp(`^${fe(s.value,e)}`),s.message,e);break;case"endsWith":C(a,RegExp(`${fe(s.value,e)}$`),s.message,e);break;case"datetime":Z(a,"date-time",s.message,e);break;case"date":Z(a,"date",s.message,e);break;case"time":Z(a,"time",s.message,e);break;case"duration":Z(a,"duration",s.message,e);break;case"length":a.minLength=typeof a.minLength=="number"?Math.max(a.minLength,s.value):s.value,a.maxLength=typeof a.maxLength=="number"?Math.min(a.maxLength,s.value):s.value;break;case"includes":{C(a,RegExp(fe(s.value,e)),s.message,e);break}case"ip":{s.version!=="v6"&&Z(a,"ipv4",s.message,e),s.version!=="v4"&&Z(a,"ipv6",s.message,e);break}case"base64url":C(a,$.base64url,s.message,e);break;case"jwt":C(a,$.jwt,s.message,e);break;case"cidr":{s.version!=="v6"&&C(a,$.ipv4Cidr,s.message,e),s.version!=="v4"&&C(a,$.ipv6Cidr,s.message,e);break}case"emoji":C(a,$.emoji(),s.message,e);break;case"ulid":{C(a,$.ulid,s.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{Z(a,"binary",s.message,e);break}case"contentEncoding:base64":{a.contentEncoding="base64";break}case"pattern:zod":{C(a,$.base64,s.message,e);break}}break}case"nanoid":C(a,$.nanoid,s.message,e)}return a}function fe(t,e){return e.patternStrategy==="escape"?Kt(t):t}var Qt=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Kt(t){let e="";for(let a=0;a<t.length;a++)Qt.has(t[a])||(e+="\\"),e+=t[a];return e}function Z(t,e,a,s){var r;t.format||(r=t.anyOf)!=null&&r.some(n=>n.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push({format:t.format}),delete t.format),t.anyOf.push({format:e,...a&&s.errorMessages&&{errorMessage:{format:a}}})):t.format=e}function C(t,e,a,s){var r;t.pattern||(r=t.allOf)!=null&&r.some(n=>n.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push({pattern:t.pattern}),delete t.pattern),t.allOf.push({pattern:Fe(e,s),...a&&s.errorMessages&&{errorMessage:{pattern:a}}})):t.pattern=Fe(e,s)}function Fe(t,e){var a;if(!e.applyRegexFlags||!t.flags)return t.source;const s={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},r=s.i?t.source.toLowerCase():t.source;let n="",o=!1,i=!1,u=!1;for(let l=0;l<r.length;l++){if(o){n+=r[l],o=!1;continue}if(s.i){if(i){if(r[l].match(/[a-z]/)){u?(n+=r[l],n+=`${r[l-2]}-${r[l]}`.toUpperCase(),u=!1):r[l+1]==="-"&&((a=r[l+2])!=null&&a.match(/[a-z]/))?(n+=r[l],u=!0):n+=`${r[l]}${r[l].toUpperCase()}`;continue}}else if(r[l].match(/[a-z]/)){n+=`[${r[l]}${r[l].toUpperCase()}]`;continue}}if(s.m){if(r[l]==="^"){n+=`(^|(?<=[\r
|
|
4
4
|
]))`;continue}else if(r[l]==="$"){n+=`($|(?=[\r
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as A,q as D,d as v,t as O,v as E,j as r,B as N,g as I}from"./index-
|
|
1
|
+
import{o as A,q as D,d as v,t as O,v as E,j as r,B as N,g as I}from"./index-D49VqQ7Q.js";import{A as M,a as L,b as R,c as T,d as $,e as q,f as B}from"./alert-dialog-Bke1xnyn.js";import{F as V,a as k,b as H,c as U,d as G,e as J,f as K}from"./form-DPsme8JL.js";import{I as P}from"./input-BoNWsfmK.js";import{S as Q}from"./spinner-7bhznOFa.js";import{u as W}from"./useMutation-BTUmJffP.js";function _(o){return o.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const X=A({name:D().min(2,"Organization name is required")});function se(o){const e=v.c(41),{open:a,onOpenChange:s}=o;let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j={resolver:O(X),defaultValues:{name:""}},e[0]=j):j=e[0];const t=E(j);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={mutationFn:Z,onSuccess:Y},e[1]=w):w=e[1];const i=W(w),z=i.error instanceof Error?i.error.message:i.error?"Failed to create organization.":null;let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r.jsxs(R,{children:[r.jsx(T,{children:"Create a new organization"}),r.jsx($,{children:"Set up a new organization to collaborate with others."})]}),e[2]=F):F=e[2];let n;if(e[3]!==i||e[4]!==t){let p;e[6]!==i?(p=b=>i.mutateAsync(b),e[6]=i,e[7]=p):p=e[7],n=t.handleSubmit(p),e[3]=i,e[4]=t,e[5]=n}else n=e[5];let l;e[8]!==t.formState.isSubmitting?(l=p=>{const{field:b}=p;return r.jsxs(H,{children:[r.jsx(U,{children:"Organization Name"}),r.jsx(G,{children:r.jsx(P,{...b,placeholder:"Acme Inc.",disabled:t.formState.isSubmitting})}),r.jsx(J,{children:"The name of your company or organization"}),b.value&&r.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Organization URL:"," ",r.jsxs("span",{className:"font-mono",children:[typeof window<"u"?globalThis.location.origin:"","/",_(b.value)]})]}),r.jsx(K,{})]})},e[8]=t.formState.isSubmitting,e[9]=l):l=e[9];let m;e[10]!==t.control||e[11]!==l?(m=r.jsx(V,{control:t.control,name:"name",render:l}),e[10]=t.control,e[11]=l,e[12]=m):m=e[12];let c;e[13]!==z?(c=z&&r.jsx("div",{className:"text-destructive text-sm mt-2",children:z}),e[13]=z,e[14]=c):c=e[14];let f;e[15]!==i||e[16]!==t?(f=()=>{i.reset(),t.reset()},e[15]=i,e[16]=t,e[17]=f):f=e[17];let g;e[18]!==t.formState.isSubmitting||e[19]!==f?(g=r.jsx(M,{disabled:t.formState.isSubmitting,onClick:f,children:"Cancel"}),e[18]=t.formState.isSubmitting,e[19]=f,e[20]=g):g=e[20];const y=!t.formState.isValid||t.formState.isSubmitting;let u;e[21]!==t.formState.isSubmitting?(u=t.formState.isSubmitting?r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(Q,{size:"xs"})," Creating..."]}):"Create Organization",e[21]=t.formState.isSubmitting,e[22]=u):u=e[22];let d;e[23]!==y||e[24]!==u?(d=r.jsx(N,{type:"submit",variant:"default",disabled:y,children:u}),e[23]=y,e[24]=u,e[25]=d):d=e[25];let S;e[26]!==d||e[27]!==g?(S=r.jsxs(q,{children:[g,d]}),e[26]=d,e[27]=g,e[28]=S):S=e[28];let h;e[29]!==S||e[30]!==n||e[31]!==m||e[32]!==c?(h=r.jsxs("form",{className:"space-y-6",onSubmit:n,autoComplete:"off",children:[m,c,S]}),e[29]=S,e[30]=n,e[31]=m,e[32]=c,e[33]=h):h=e[33];let x;e[34]!==t||e[35]!==h?(x=r.jsxs(L,{children:[F,r.jsx(k,{...t,children:h})]}),e[34]=t,e[35]=h,e[36]=x):x=e[36];let C;return e[37]!==s||e[38]!==a||e[39]!==x?(C=r.jsx(B,{open:a,onOpenChange:s,children:x}),e[37]=s,e[38]=a,e[39]=x,e[40]=C):C=e[40],C}function Y(o){const{orgSlug:e}=o;window.location.href=`/${e}`}async function Z(o){const e=_(o.name);if(!e)throw new Error("Organization slug is invalid");const a=await I.organization.create({name:o.name,slug:e});if(a?.error)throw new Error(a.error.message||"Failed to create organization");const s=a?.data?.slug??e;if(!s)throw new Error("Failed to create organization");return{orgSlug:s}}export{se as C};
|
package/dist/client/assets/{create-project-dialog-B6n_03Ug.js → create-project-dialog-RIITFpVV.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as A,j as e,y as R,c as k,f as L,x as M,r as T,v as z,w as B,K as V,O as p,B as D,o as q,q as j}from"./index-
|
|
1
|
+
import{d as A,j as e,y as R,c as k,f as L,x as M,r as T,v as z,w as B,K as V,O as p,B as D,o as q,q as j}from"./index-D49VqQ7Q.js";import{u as O}from"./useMutation-BTUmJffP.js";import{u as $,a as K}from"./constants-TLV7MTwP.js";import{a as U,D as G,b as J,c as Q,e as Y,d as H}from"./dialog-DCrLu7TC.js";import{a as W,F as v,b as F,c as N,d as S,f as w}from"./form-DPsme8JL.js";import{I}from"./input-BoNWsfmK.js";import{T as X}from"./textarea-D30IrLHN.js";import{L as Z}from"./label-DF2jcg2U.js";import{i as _,g as ee}from"./slug-DcxyEoi0.js";import{i as se}from"./Check-Dczm9Dfw.js";const te=["#3B82F6","#8B5CF6","#EC4899","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#06B6D4","#6366F1","#64748B","#000000"];function ne(f){const s=A.c(16),{value:r,onChange:o}=f;let i;s[0]!==o||s[1]!==r?(i=te.map(l=>e.jsx("button",{type:"button",onClick:()=>o(l),className:R("size-8 rounded-lg transition-all",r===l&&"ring-2 ring-offset-2 ring-primary"),style:{backgroundColor:l},children:r===l&&e.jsx(se,{className:"size-4 text-white mx-auto"})},l)),s[0]=o,s[1]=r,s[2]=i):i=s[2];let c;s[3]!==i?(c=e.jsx("div",{className:"grid grid-cols-6 gap-2",children:i}),s[3]=i,s[4]=c):c=s[4];const m=r??"#3B82F6";let u;s[5]!==o?(u=l=>o(l.target.value),s[5]=o,s[6]=u):u=s[6];let t;s[7]!==m||s[8]!==u?(t=e.jsx("input",{type:"color",value:m,onChange:u,className:"size-8 rounded cursor-pointer"}),s[7]=m,s[8]=u,s[9]=t):t=s[9];let a;s[10]===Symbol.for("react.memo_cache_sentinel")?(a=e.jsx("span",{className:"text-sm text-muted-foreground",children:"Custom color"}),s[10]=a):a=s[10];let d;s[11]!==t?(d=e.jsxs("div",{className:"flex items-center gap-2",children:[t,a]}),s[11]=t,s[12]=d):d=s[12];let g;return s[13]!==c||s[14]!==d?(g=e.jsxs("div",{className:"space-y-3",children:[c,d]}),s[13]=c,s[14]=d,s[15]=g):g=s[15],g}q({name:j().min(1,"Name is required").max(200),slug:j().min(1,"Slug is required").max(100),description:j().max(1e3).optional(),bannerColor:j().nullable().optional()});function xe({open:f,onOpenChange:s}){const{org:r}=k(),o=L(),i=M(),[c,m]=T.useState(!1),u=$({connectionId:K,orgId:r.id}),t=z({mode:"onChange",defaultValues:{name:"",slug:"",description:"",bannerColor:"#3B82F6"}}),a=O({mutationFn:async n=>{const h=await u.callTool({name:"PROJECT_CREATE",arguments:{organizationId:r.id,slug:n.slug,name:n.name,description:n.description||null,enabledPlugins:[],ui:{banner:null,bannerColor:n.bannerColor??null,icon:null,themeColor:n.bannerColor??null}}});return h.structuredContent??h},onSuccess:n=>{i.invalidateQueries({queryKey:V.projects(r.id)}),B.success("Project created successfully"),s(!1),t.reset({name:"",slug:"",description:"",bannerColor:"#3B82F6"}),m(!1),o({to:"/$org/$project",params:{org:r.slug,project:n.project.slug}})},onError:n=>{B.error("Failed to create project: "+(n instanceof Error?n.message:"Unknown error"))}}),d=async n=>{if(!_(n.slug)){t.setError("slug",{message:"Slug must be lowercase alphanumeric with hyphens only"});return}if(n.slug===p){t.setError("slug",{message:`"${p}" is a reserved slug`});return}await a.mutateAsync(n)},g=n=>{const h=n.target.value;if(t.setValue("name",h),!c){const P=ee(h);t.setValue("slug",P)}},l=n=>{m(!0),t.setValue("slug",n.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))},C=t.watch("bannerColor"),x=t.watch("slug"),b=t.watch("name"),y=x===p,E=x.length>0&&!_(x);return e.jsx(U,{open:f,onOpenChange:s,children:e.jsxs(G,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(J,{children:[e.jsx(Q,{children:"Create New Project"}),e.jsxs(Y,{children:["Set up a new project in ",r.name,". You can configure plugins and settings after creation."]})]}),e.jsx(W,{...t,children:e.jsxs("form",{onSubmit:t.handleSubmit(d),className:"space-y-6",children:[e.jsx("div",{className:"h-20 rounded-lg relative",style:{backgroundColor:C??"#3B82F6"},children:e.jsx("div",{className:"absolute -bottom-4 left-4",children:e.jsx("div",{className:"size-12 rounded-lg border-2 border-background flex items-center justify-center text-lg font-semibold text-white",style:{backgroundColor:C??"#3B82F6"},children:b?.charAt(0)?.toUpperCase()||"P"})})}),e.jsxs("div",{className:"space-y-2 pt-4",children:[e.jsx(Z,{children:"Banner Color"}),e.jsx(ne,{value:C??null,onChange:n=>t.setValue("bannerColor",n)})]}),e.jsx(v,{control:t.control,name:"name",render:()=>e.jsxs(F,{children:[e.jsx(N,{children:"Project Name *"}),e.jsx(S,{children:e.jsx(I,{value:b,onChange:g,placeholder:"My Awesome Project",autoFocus:!0,disabled:a.isPending})}),e.jsx(w,{})]})}),e.jsx(v,{control:t.control,name:"slug",render:()=>e.jsxs(F,{children:[e.jsx(N,{children:"Slug *"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:["/",r.slug,"/"]}),e.jsx(S,{children:e.jsx(I,{value:x,onChange:l,placeholder:"my-awesome-project",className:"flex-1",disabled:a.isPending})})]}),y&&e.jsxs("p",{className:"text-xs text-destructive",children:['"',p,'" is a reserved slug']}),E&&!y&&e.jsx("p",{className:"text-xs text-destructive",children:"Slug must be lowercase alphanumeric with hyphens only"}),e.jsx(w,{})]})}),e.jsx(v,{control:t.control,name:"description",render:({field:n})=>e.jsxs(F,{children:[e.jsx(N,{children:"Description"}),e.jsx(S,{children:e.jsx(X,{...n,placeholder:"What is this project for?",rows:2,disabled:a.isPending})}),e.jsx(w,{})]})}),e.jsxs(H,{children:[e.jsx(D,{type:"button",variant:"outline",onClick:()=>s(!1),disabled:a.isPending,children:"Cancel"}),e.jsx(D,{type:"submit",disabled:a.isPending||y||E||!b||!x,children:a.isPending?"Creating...":"Create Project"})]})]})})]})})}export{xe as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as o,j as r}from"./index-
|
|
1
|
+
import{d as o,j as r}from"./index-D49VqQ7Q.js";import{D as s}from"./danger-zone-CEP2ON89.js";import"./useMutation-BTUmJffP.js";import"./constants-TLV7MTwP.js";import"./input-BoNWsfmK.js";import"./alert-dialog-Bke1xnyn.js";function n(){const t=o.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsxs("div",{className:"flex flex-col gap-6",children:[r.jsxs("div",{children:[r.jsx("h2",{className:"text-base font-semibold text-foreground",children:"Danger Zone"}),r.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Irreversible and destructive actions."})]}),r.jsx(s,{})]}),t[0]=e):e=t[0],e}function d(){const t=o.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx(n,{}),t[0]=e):e=t[0],e}export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as B,c as G,f as J,x as Q,r as L,O as M,j as t,K as U,w as F,B as Z}from"./index-
|
|
1
|
+
import{d as B,c as G,f as J,x as Q,r as L,O as M,j as t,K as U,w as F,B as Z}from"./index-D49VqQ7Q.js";import{u as H}from"./useMutation-BTUmJffP.js";import{a as Y,u as z}from"./constants-TLV7MTwP.js";import{I as V}from"./input-BoNWsfmK.js";import{c as W,g as X,d as ee,b as te,A as se,e as le,h as ne,a as re,f as oe}from"./alert-dialog-Bke1xnyn.js";function fe(){const e=B.c(45),{org:n,project:s}=G(),S=J(),E=Q(),[x,R]=L.useState(""),[P,k]=L.useState(!1),K=s.slug===M;let h;e[0]!==n.id?(h={connectionId:Y,orgId:n.id},e[0]=n.id,e[1]=h):h=e[1];const I=z(h);let r;e[2]!==I||e[3]!==s.id?(r=async()=>{const l=await I.callTool({name:"PROJECT_DELETE",arguments:{projectId:s.id}});return l.structuredContent??l},e[2]=I,e[3]=s.id,e[4]=r):r=e[4];let o;e[5]!==S||e[6]!==n.id||e[7]!==n.slug||e[8]!==E?(o=l=>{l.success?(E.invalidateQueries({queryKey:U.projects(n.id)}),F.success("Project deleted"),S({to:"/$org/$project/projects",params:{org:n.slug,project:M}})):F.error(l.message??"Failed to delete project")},e[5]=S,e[6]=n.id,e[7]=n.slug,e[8]=E,e[9]=o):o=e[9];let p;e[10]!==r||e[11]!==o?(p={mutationFn:r,onSuccess:o,onError:ae},e[10]=r,e[11]=o,e[12]=p):p=e[12];const g=H(p);if(K)return null;const $=x===s.name;let j;e[13]!==g?(j=()=>{g.mutate()},e[13]=g,e[14]=j):j=e[14];const O=j;let b;e[15]===Symbol.for("react.memo_cache_sentinel")?(b=l=>{k(l),l||R("")},e[15]=b):b=e[15];const q=b;let D;e[16]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx("p",{className:"py-4 text-base font-semibold text-foreground border-b border-border",children:"Danger Zone"}),e[16]=D):D=e[16];let v;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"Delete Project"}),t.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:"Permanently delete this project and all its data. This action cannot be undone."})]}),e[17]=v):v=e[17];let _;e[18]===Symbol.for("react.memo_cache_sentinel")?(_=t.jsx(X,{asChild:!0,children:t.jsx(Z,{variant:"outline",className:"shrink-0 bg-destructive/10 text-destructive border-0 hover:bg-destructive/15 hover:text-destructive",children:"Delete Project"})}),e[18]=_):_=e[18];let a;e[19]!==s.name?(a=t.jsxs(W,{children:['Delete "',s.name,'"?']}),e[19]=s.name,e[20]=a):a=e[20];let y;e[21]===Symbol.for("react.memo_cache_sentinel")?(y=t.jsx(ee,{children:"This action cannot be undone. All project data will be permanently deleted."}),e[21]=y):y=e[21];let i;e[22]!==a?(i=t.jsxs(te,{children:[a,y]}),e[22]=a,e[23]=i):i=e[23];let c;e[24]!==s.name?(c=t.jsxs("p",{className:"text-sm mb-2",children:["Type ",t.jsx("strong",{children:s.name})," to confirm:"]}),e[24]=s.name,e[25]=c):c=e[25];let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=l=>R(l.target.value),e[26]=C):C=e[26];let d;e[27]!==x||e[28]!==s.name?(d=t.jsx(V,{value:x,onChange:C,placeholder:s.name}),e[27]=x,e[28]=s.name,e[29]=d):d=e[29];let m;e[30]!==c||e[31]!==d?(m=t.jsxs("div",{className:"py-4",children:[c,d]}),e[30]=c,e[31]=d,e[32]=m):m=e[32];let A;e[33]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(se,{children:"Cancel"}),e[33]=A):A=e[33];const T=!$||g.isPending,w=g.isPending?"Deleting...":"Delete Project";let u;e[34]!==O||e[35]!==T||e[36]!==w?(u=t.jsxs(le,{children:[A,t.jsx(ne,{onClick:O,disabled:T,className:"bg-destructive/10 text-destructive hover:bg-destructive/15 hover:text-destructive border-0",children:w})]}),e[34]=O,e[35]=T,e[36]=w,e[37]=u):u=e[37];let f;e[38]!==i||e[39]!==m||e[40]!==u?(f=t.jsxs(re,{children:[i,m,u]}),e[38]=i,e[39]=m,e[40]=u,e[41]=f):f=e[41];let N;return e[42]!==P||e[43]!==f?(N=t.jsxs("div",{className:"flex flex-col",children:[D,t.jsxs("div",{className:"flex items-center justify-between gap-6 py-4",children:[v,t.jsxs(oe,{open:P,onOpenChange:q,children:[_,f]})]})]}),e[42]=P,e[43]=f,e[44]=N):N=e[44],N}function ae(e){F.error("Failed to delete project: "+(e instanceof Error?e.message:"Unknown error"))}export{fe as D};
|