decocms 4.248.2 → 4.248.4
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-DYa65h7M.js → AlertCircle-BJLsdJJB.js} +1 -1
- package/dist/client/assets/{AreaChart-Z7000aGF.js → AreaChart-DPRb077p.js} +1 -1
- package/dist/client/assets/{ArrowLeft-D0sSJGyh.js → ArrowLeft-BpINHsGO.js} +1 -1
- package/dist/client/assets/{ArrowUp-DaPuMC6J.js → ArrowUp-BCnJIsa2.js} +1 -1
- package/dist/client/assets/{Check-ErA_74IV.js → Check-DYWCAvRe.js} +1 -1
- package/dist/client/assets/{CheckCircle-CiRCtOI3.js → CheckCircle-CZfdFD75.js} +1 -1
- package/dist/client/assets/{ChevronDown-Dgga4a4Q.js → ChevronDown-Dm7RFEzi.js} +1 -1
- package/dist/client/assets/{ChevronRight-Cf-ty0tK.js → ChevronRight-DfFDfMiT.js} +1 -1
- package/dist/client/assets/{ChevronSelectorVertical-BS9Eaphx.js → ChevronSelectorVertical-BrPFZOd6.js} +1 -1
- package/dist/client/assets/{ChevronUp-DOEAI0tE.js → ChevronUp-YRlpUnbI.js} +1 -1
- package/dist/client/assets/{Copy01-C8DEngph.js → Copy01-B7kE9119.js} +1 -1
- package/dist/client/assets/{CreditCard01-LLnESWWX.js → CreditCard01-BBWGD6ln.js} +1 -1
- package/dist/client/assets/{DotsVertical-B9Mg1LjT.js → DotsVertical-Ds_DhNTo.js} +1 -1
- package/dist/client/assets/{Download01-CKTo0VS3.js → Download01-CtExxOFo.js} +1 -1
- package/dist/client/assets/{Eye-C-IIbq0b.js → Eye-Bkw_HSyr.js} +1 -1
- package/dist/client/assets/{FilterLines-BmuWDJhh.js → FilterLines-CdBZbJbR.js} +1 -1
- package/dist/client/assets/{Globe01-AGteY5p8.js → Globe01-CbzTjXVx.js} +1 -1
- package/dist/client/assets/{Globe04-B6IxAzhj.js → Globe04-5uq9vA8E.js} +1 -1
- package/dist/client/assets/{HardDrive-Bxx1_cqg.js → HardDrive-DLZzUCJy.js} +1 -1
- package/dist/client/assets/{Key01-Du0R52Fs.js → Key01-WP13V6P8.js} +1 -1
- package/dist/client/assets/{LinkExternal01-lwDudDKU.js → LinkExternal01-DWP8dcJA.js} +1 -1
- package/dist/client/assets/{LockUnlocked01-ChTbbG9p.js → LockUnlocked01-BsAWOf6A.js} +1 -1
- package/dist/client/assets/{LogOut01-VHtvJ8Vp.js → LogOut01-DUJGO4hF.js} +1 -1
- package/dist/client/assets/{Monitor01-DA25Iq0R.js → Monitor01-DZgvR7bI.js} +1 -1
- package/dist/client/assets/{Palette-yngNVQ4n.js → Palette-BRlImZFI.js} +1 -1
- package/dist/client/assets/{Play-CsQhzYUI.js → Play-xBrWdkON.js} +1 -1
- package/dist/client/assets/{Plus-Cf4b1bNp.js → Plus-DKhcQWfb.js} +1 -1
- package/dist/client/assets/{SearchLg-CIhGyLjl.js → SearchLg-BzZYCybQ.js} +1 -1
- package/dist/client/assets/{SearchMd-B1dsuEY7.js → SearchMd-C-eFE6qY.js} +1 -1
- package/dist/client/assets/{Settings02-zoYBf2Q9.js → Settings02-DsPup1VS.js} +1 -1
- package/dist/client/assets/{Share07-KO4nWaTW.js → Share07-_7OUHtSc.js} +1 -1
- package/dist/client/assets/{Shield01-EKP5VJCL.js → Shield01-BMGrPJL4.js} +1 -1
- package/dist/client/assets/{Stars01-BgC1nyVS.js → Stars01-DyPW1NZ3.js} +1 -1
- package/dist/client/assets/{Stars02-D7QMgn6_.js → Stars02-CsRg1_DW.js} +1 -1
- package/dist/client/assets/{Sun-CH0lCvO4.js → Sun-lLrEGeIB.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-ByrC3JZW.js → SwitchHorizontal01-Buwrdn2y.js} +1 -1
- package/dist/client/assets/{Tool01-BjJidQ3c.js → Tool01-Dg67-JKv.js} +1 -1
- package/dist/client/assets/{Tool02-Bs7nBBx_.js → Tool02-_e_W6rPa.js} +1 -1
- package/dist/client/assets/{Trash01-C4UDDTjr.js → Trash01-649gpHj9.js} +1 -1
- package/dist/client/assets/{TrendUp01-BQO_JaWi.js → TrendUp01-CSEGC0U8.js} +1 -1
- package/dist/client/assets/{Upload01-k3Mh0fZU.js → Upload01-DjDsiYUt.js} +1 -1
- package/dist/client/assets/{User01-m6vclzYC.js → User01-Dlgu2BER.js} +1 -1
- package/dist/client/assets/{UserSquare-1p4hY8NI.js → UserSquare-BS_e8Pjv.js} +1 -1
- package/dist/client/assets/{Users01-CWeSTta9.js → Users01-C7EqAQaR.js} +1 -1
- package/dist/client/assets/{Users03-a8f_wZmP.js → Users03-DvaTkZMF.js} +1 -1
- package/dist/client/assets/{XCircle-3TmYYaVT.js → XCircle-Cn5WdVId.js} +1 -1
- package/dist/client/assets/{XClose-BO1_8YHD.js → XClose-DyI1k_z6.js} +1 -1
- package/dist/client/assets/{YAxis-DrM-OWWa.js → YAxis-BOx2DF1X.js} +1 -1
- package/dist/client/assets/{Zap-BUA1_Jut.js → Zap-D44l2tlW.js} +1 -1
- package/dist/client/assets/{ZapSquare-8U0SgWLp.js → ZapSquare-DUHD_nc-.js} +1 -1
- package/dist/client/assets/{access-gate-D3zAqPzH.js → access-gate-D_1GlcS4.js} +1 -1
- package/dist/client/assets/agent-icon-BhfneAwy.js +1 -0
- package/dist/client/assets/agents-list-BUvHAwfb.js +1 -0
- package/dist/client/assets/ai-providers-lRapbKCn.js +6 -0
- package/dist/client/assets/{alert-DSZ984JY.js → alert-CuEsZrDf.js} +1 -1
- package/dist/client/assets/{alert-dialog-BBUALe3i.js → alert-dialog-fRZZzq2b.js} +2 -2
- package/dist/client/assets/api-keys-DOxIXB_j.js +1 -0
- package/dist/client/assets/app-editor-C_guf21J.js +1 -0
- package/dist/client/assets/{auth-CS2cT5wl.js → auth-CsyM6wOp.js} +1 -1
- package/dist/client/assets/{auth-catchall-Bs5rDKB8.js → auth-catchall-B-WhgvT0.js} +1 -1
- package/dist/client/assets/{auth-entry-B7mR5g8T.js → auth-entry-CQkyABOA.js} +1 -1
- package/dist/client/assets/{auth-split-layout-CxqUA4_R.js → auth-split-layout-vT7dwNTB.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-CB658Lpc.js → authenticate-and-persist-oauth-D5NQEgY8.js} +1 -1
- package/dist/client/assets/{automation-list-row-DqAvOKpL.js → automation-list-row-BDX5Zyot.js} +1 -1
- package/dist/client/assets/{automation-runs-C7VPpqIt.js → automation-runs-DTPprHYR.js} +16 -16
- package/dist/client/assets/automations-CkB3kyG0.js +1 -0
- package/dist/client/assets/{avatar-md-XNPuR.js → avatar-DeFAeBFl.js} +1 -1
- package/dist/client/assets/{badge-BR2WgVsV.js → badge-BNu531uc.js} +1 -1
- package/dist/client/assets/{block-document-yl-Al_kf.js → block-document-x1IV3qey.js} +1 -1
- package/dist/client/assets/buckets-J-wFqi2h.js +1 -0
- package/dist/client/assets/bulk-category-panel-CEdqKYSP.js +1 -0
- package/dist/client/assets/{capability-load-error-BornUXv-.js → capability-load-error-DUMl4Cfr.js} +1 -1
- package/dist/client/assets/{cards-B5pz2XNy.js → cards-CL2vc4-W.js} +1 -1
- package/dist/client/assets/category-editor-NdAWtsih.js +1 -0
- package/dist/client/assets/{chart-Dw43HBj2.js → chart-CArbD1Z5.js} +3 -3
- package/dist/client/assets/chat-context-C-y8N43p.js +35 -0
- package/dist/client/assets/{checkbox-CNnFytxt.js → checkbox-D3MLpBTA.js} +1 -1
- package/dist/client/assets/choose-editor-2qYKfGsR.js +1 -0
- package/dist/client/assets/{cli-auth-success-B37XVEcm.js → cli-auth-success-CDGc5a3I.js} +1 -1
- package/dist/client/assets/collection-detail-C2cTonBC.js +1 -0
- package/dist/client/assets/collection-display-button-jiE_9-7-.js +1 -0
- package/dist/client/assets/collection-search-CNrn5ZLG.js +1 -0
- package/dist/client/assets/{collection-table-wrapper-C12GS9C3.js → collection-table-wrapper-C4xZgp9x.js} +1 -1
- package/dist/client/assets/{collection-tabs-Dfa_vQOq.js → collection-tabs-Dg_azfZv.js} +1 -1
- package/dist/client/assets/{command-CXX8Roxa.js → command-BlvzBYcm.js} +1 -1
- package/dist/client/assets/commerce-onboarding-D0tGx8Lj.js +1 -0
- package/dist/client/assets/connect-D3748pCj.js +8 -0
- package/dist/client/assets/connection-CeBlIp_O.js +1 -0
- package/dist/client/assets/connection-card-B5D9qN3O.js +1 -0
- package/dist/client/assets/connection-detail-DuwCDpDs.js +1 -0
- package/dist/client/assets/connection-form-helpers-B3UcqYZu.js +1 -0
- package/dist/client/assets/connections-Dm3ee4Hu.js +1 -0
- package/dist/client/assets/{decopilot-sse-pool-BbcmZgTF.js → decopilot-sse-pool-DvpyeiPr.js} +1 -1
- package/dist/client/assets/dialog-CuqXnWbf.js +1 -0
- package/dist/client/assets/domain-settings-fQdlB2tF.js +1 -0
- package/dist/client/assets/{drawer-9chetton.js → drawer-Dw47OmQ9.js} +1 -1
- package/dist/client/assets/{dropdown-menu-Dhjx8BUz.js → dropdown-menu-Cg8GO9Ey.js} +1 -1
- package/dist/client/assets/{empty-state-BHXPcV6D.js → empty-state-DgtjDyl7.js} +1 -1
- package/dist/client/assets/{extract-connection-data-DyM1tiNg.js → extract-connection-data-CFDQblVE.js} +1 -1
- package/dist/client/assets/{file-explorer-CGdZE7j0.js → file-explorer-BKaBUpVr.js} +2 -2
- package/dist/client/assets/{file-type-icon-jL53noJP.js → file-type-icon-BfTCeyA7.js} +1 -1
- package/dist/client/assets/{form-Cb2ftegM.js → form-gSf7rSoB.js} +1 -1
- package/dist/client/assets/general-fQ-9F_8c.js +1 -0
- package/dist/client/assets/{github-repo-picker-B0itW_sn.js → github-repo-picker-DxNDjsxj.js} +1 -1
- package/dist/client/assets/{hooks-BasSX9U3.js → hooks-IJLcrm9m.js} +5 -5
- package/dist/client/assets/{index-CJWr9N0v.js → index-BXFmp3WW.js} +1 -1
- package/dist/client/assets/index-BoZK85Tz.js +1 -0
- package/dist/client/assets/index-C-W5dASy.js +235 -0
- package/dist/client/assets/{index-BnYSClvU.js → index-CTd9wjzr.js} +37 -37
- package/dist/client/assets/{index-BHhk6DR8.js → index-CZyJSpiW.js} +2 -2
- package/dist/client/assets/{index-ZiQvvnOE.js → index-DkaFt-ER.js} +1 -1
- package/dist/client/assets/index-E5NqaLsL.js +1 -0
- package/dist/client/assets/index-JZrhswCW.js +1 -0
- package/dist/client/assets/index-redirect-BARimKaN.js +1 -0
- package/dist/client/assets/{index-BGLk9CX0.js → index-rmUjTFsu.js} +2 -2
- package/dist/client/assets/infra-billing-CsjaugX6.js +1 -0
- package/dist/client/assets/{input-7l72-E74.js → input-BPzKKVIm.js} +1 -1
- package/dist/client/assets/{integration-icon-9hdQMmio.js → integration-icon-0pMS4e0x.js} +1 -1
- package/dist/client/assets/invite-member-dialog-DncQfqgo.js +1 -0
- package/dist/client/assets/{label-Di7XD03t.js → label-Cy4ljnv_.js} +1 -1
- package/dist/client/assets/layout-DH8wLQcr.js +1 -0
- package/dist/client/assets/{login-B01_8Sdh.js → login-CYjOmWQU.js} +1 -1
- package/dist/client/assets/{mcp-oauth-_naDcGdv.js → mcp-oauth-D5NqWvPJ.js} +1 -1
- package/dist/client/assets/members-2QPdx0w5.js +1 -0
- package/dist/client/assets/{monaco-editor-DgD9evL7.js → monaco-editor-SX25UZKO.js} +4 -4
- package/dist/client/assets/{monitoring-stats-row-B0BLM1my.js → monitoring-stats-row-DOzTz31T.js} +1 -1
- package/dist/client/assets/{multi-select-BLNYHoGy.js → multi-select-DQX6uGgz.js} +1 -1
- package/dist/client/assets/{oauth-callback-BqBCpIME.js → oauth-callback-Bl1uQrp-.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-DA5Wl5SM.js → oauth-callback-ai-provider-D6vkHSiC.js} +1 -1
- package/dist/client/assets/{onboarding-px_II1bW.js → onboarding-DLUW7rwC.js} +1 -1
- package/dist/client/assets/{org-layout-DFED5zNf.js → org-layout-CHqCDI-6.js} +1 -1
- package/dist/client/assets/{organization-choice-IrwqMfm_.js → organization-choice-C665vOEP.js} +1 -1
- package/dist/client/assets/orgs-B8XetzAm.js +1 -0
- package/dist/client/assets/{page-seo-form-Cm5Qv5ak.js → page-seo-form-BqksEx3f.js} +1 -1
- package/dist/client/assets/{popover-CfGL7saO.js → popover-CKC_v_FI.js} +1 -1
- package/dist/client/assets/post-editor-D0V_cWUV.js +1 -0
- package/dist/client/assets/{primitives-DIc8lbRG.js → primitives-C4dJYS7T.js} +1 -1
- package/dist/client/assets/profile-CUktqNbW.js +1 -0
- package/dist/client/assets/project-app-view-DQXGeh0y.js +1 -0
- package/dist/client/assets/record-editor-D5yY3Dz9.js +1 -0
- package/dist/client/assets/redirect-editor-BEdHUyBe.js +1 -0
- package/dist/client/assets/registry-BWnBGVZj.js +2 -0
- package/dist/client/assets/{registry-layout-t9OiEUok.js → registry-layout-1Qslk_W6.js} +4 -4
- package/dist/client/assets/{reports-B-JkBTXv.js → reports-Bvrg-uin.js} +1 -1
- package/dist/client/assets/require-capability-DR7Mbbou.js +1 -0
- package/dist/client/assets/{required-auth-layout-DgjkQLI6.js → required-auth-layout-C7iO_f_Y.js} +1 -1
- package/dist/client/assets/{reset-password-C_dZ8Eqo.js → reset-password-D5H5T765.js} +1 -1
- package/dist/client/assets/roles-D4n1d-tX.js +1 -0
- package/dist/client/assets/{search-input-DsWKOK9t.js → search-input-vt9k7znl.js} +1 -1
- package/dist/client/assets/secrets-saGLdJQ9.js +1 -0
- package/dist/client/assets/{sections-editor-hTI5vt6I.js → sections-editor-dlfE05iX.js} +2 -2
- package/dist/client/assets/select-CX1EQjk0.js +1 -0
- package/dist/client/assets/{select-model-Dqz5FPx4.js → select-model-By0_2E97.js} +2 -2
- package/dist/client/assets/self-tool-result-wLzQezsb.js +1 -0
- package/dist/client/assets/seo-editor-BgJ2ySZq.js +1 -0
- package/dist/client/assets/settings-layout-_qKXk5vn.js +1 -0
- package/dist/client/assets/shell-controls-DUgcifyl.js +1 -0
- package/dist/client/assets/shell-layout-BGunSaDG.js +1 -0
- package/dist/client/assets/{spinner-glqojFDA.js → spinner-DQUJXeRb.js} +1 -1
- package/dist/client/assets/sso-DNeFyj4s.js +1 -0
- package/dist/client/assets/store-CLnACfV7.js +1 -0
- package/dist/client/assets/store-registry-CYcCjiAW.js +2 -0
- package/dist/client/assets/switch-080KuP0Z.js +1 -0
- package/dist/client/assets/synced-repos-CQQV9Zjv.js +1 -0
- package/dist/client/assets/{tab-id-CYxMrTRp.js → tab-id-BMHIgJVu.js} +1 -1
- package/dist/client/assets/{table-_DZMZF7n.js → table-DxRhe_5K.js} +1 -1
- package/dist/client/assets/tabs-Dt2F-lST.js +1 -0
- package/dist/client/assets/tasks-BaA9DyLn.js +1 -0
- package/dist/client/assets/textarea-C50htUTR.js +1 -0
- package/dist/client/assets/toggle-group-CT4Q_c7z.js +1 -0
- package/dist/client/assets/{toolbar-DEkBOfzd.js → toolbar-nEkAKWTR.js} +1 -1
- package/dist/client/assets/{track-C3SQxOl4.js → track-BifnyqN6.js} +1 -1
- package/dist/client/assets/{types-Dh-L4V2P.js → types-DZVMpxej.js} +4 -4
- package/dist/client/assets/use-ai-providers-Chs1tcQD.js +1 -0
- package/dist/client/assets/use-api-keys-Djf4Eh5p.js +1 -0
- package/dist/client/assets/use-automations-CmpL_Mom.js +1 -0
- package/dist/client/assets/{use-autosave-P4ije4un.js → use-autosave-D5h0ivOe.js} +1 -1
- package/dist/client/assets/{use-clock-tick-yZZNkqhy.js → use-clock-tick-Cad8pAZ9.js} +1 -1
- package/dist/client/assets/use-commerce-diagnostic-CRHEo45Z.js +1 -0
- package/dist/client/assets/use-connection-DzUFG_BF.js +1 -0
- package/dist/client/assets/{use-copy-BGwAE5Xe.js → use-copy-B43wL_o8.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-B5mSvVFn.js → use-create-virtual-mcp-CTvxs6s1.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-BDvfPMkV.js → use-debounced-autosave-DSiZvyT9.js} +1 -1
- package/dist/client/assets/{use-debounced-value-UZPGD-zb.js → use-debounced-value-Dq1JGl41.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-8dmobXlE.js → use-decopilot-events-ka0F1PHR.js} +1 -1
- package/dist/client/assets/use-delete-connection-CySUkdqd.js +1 -0
- package/dist/client/assets/{use-deployment-admin-tOuWllrn.js → use-deployment-admin-BQBai7bt.js} +1 -1
- package/dist/client/assets/use-file-configs-B6WrrXgQ.js +1 -0
- package/dist/client/assets/{use-infinite-scroll-Dzm35RNS.js → use-infinite-scroll-4H8mlAbs.js} +1 -1
- package/dist/client/assets/use-join-requests-eJo_jJba.js +1 -0
- package/dist/client/assets/{use-mcp-client-DFoPNyXR.js → use-mcp-client-PMt78ucZ.js} +7 -7
- package/dist/client/assets/use-mcp-tools-BgEqxU0u.js +1 -0
- package/dist/client/assets/use-members-CzhU7i-s.js +1 -0
- package/dist/client/assets/{use-navigate-to-agent-CX93JJ-W.js → use-navigate-to-agent-DpqkGd8j.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-CiGZ-xlx.js → use-org-auth-client-DCF2a5iN.js} +1 -1
- package/dist/client/assets/use-org-repo-syncs-t5rFG9d3.js +1 -0
- package/dist/client/assets/{use-org-sso-CHwTj_pK.js → use-org-sso-DmTf_LfQ.js} +1 -1
- package/dist/client/assets/{use-organization-roles-ChU_RgEA.js → use-organization-roles-7NQcUwh1.js} +1 -1
- package/dist/client/assets/use-organization-settings-BQYM8ne1.js +1 -0
- package/dist/client/assets/{use-registry-connections-BvzfOtMr.js → use-registry-connections-CrLBfd4m.js} +1 -1
- package/dist/client/assets/use-secrets-2hVFkyTr.js +1 -0
- package/dist/client/assets/{use-section-preview-base-CYcMtPj5.js → use-section-preview-base-CnPY0DDc.js} +1 -1
- package/dist/client/assets/{use-status-sounds-BWK3t0nt.js → use-status-sounds-u8GHDfsk.js} +1 -1
- package/dist/client/assets/use-tags-C5qFTaG8.js +1 -0
- package/dist/client/assets/use-view-mode-DWyYPm90.js +1 -0
- package/dist/client/assets/{use-virtual-mcp-BbdjNQ1e.js → use-virtual-mcp-eZtpf4bS.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-UhiHP148.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-Cf9qli1T.js +1 -0
- package/dist/client/assets/users-j4gaj7Zx.js +1 -0
- package/dist/client/assets/variant-calendar-DvHJ9GeI.js +1 -0
- package/dist/client/assets/view-mode-toggle-DdFZltId.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -1
- package/dist/server/server.js +1 -1
- package/package.json +1 -1
- package/dist/client/assets/ArrowUpRight-Dv9QvAW5.js +0 -1
- package/dist/client/assets/LayoutLeft-BKrrf1xY.js +0 -1
- package/dist/client/assets/X-IBBjQPfk.js +0 -1
- package/dist/client/assets/agent-icon-vjhOL9u6.js +0 -1
- package/dist/client/assets/agents-list-DJeAJ_3a.js +0 -1
- package/dist/client/assets/ai-providers-DmqZvdDR.js +0 -6
- package/dist/client/assets/api-keys-DEdlM0o6.js +0 -1
- package/dist/client/assets/app-editor-DGG6hIQW.js +0 -1
- package/dist/client/assets/automations-QJpsEj6l.js +0 -1
- package/dist/client/assets/buckets-D7AznYZl.js +0 -1
- package/dist/client/assets/bulk-category-panel-Aw08g8MP.js +0 -1
- package/dist/client/assets/card-IdHCmi8B.js +0 -1
- package/dist/client/assets/category-editor-BLU7MJ_a.js +0 -1
- package/dist/client/assets/chat-context-Df1gS1sI.js +0 -35
- package/dist/client/assets/choose-editor-BGNNx0rr.js +0 -1
- package/dist/client/assets/collection-detail-CdVhmMD8.js +0 -1
- package/dist/client/assets/collection-display-button-DpaZ3d0j.js +0 -1
- package/dist/client/assets/collection-search-BQLruUQ4.js +0 -1
- package/dist/client/assets/commerce-onboarding-BOD-_HLG.js +0 -1
- package/dist/client/assets/connect-VrBLOQz7.js +0 -8
- package/dist/client/assets/connection-D6NWrsFQ.js +0 -1
- package/dist/client/assets/connection-card-2s-BDhzN.js +0 -1
- package/dist/client/assets/connection-detail-rH7mQov2.js +0 -1
- package/dist/client/assets/connection-form-helpers-BahPv0zc.js +0 -1
- package/dist/client/assets/connections-X1ffPxSi.js +0 -1
- package/dist/client/assets/dialog-B0pGkX2q.js +0 -1
- package/dist/client/assets/domain-settings-CBmnQIJo.js +0 -1
- package/dist/client/assets/general-DdO_16ZO.js +0 -1
- package/dist/client/assets/index-BVEEZvKv.js +0 -1
- package/dist/client/assets/index-CkEYKazi.js +0 -1
- package/dist/client/assets/index-DBsyf30G.js +0 -1
- package/dist/client/assets/index-DTCr2n-a.js +0 -235
- package/dist/client/assets/index-mAaX9S9j.js +0 -1
- package/dist/client/assets/index-redirect-D24SfTyt.js +0 -1
- package/dist/client/assets/infra-billing-DCiyfS8M.js +0 -1
- package/dist/client/assets/invite-member-dialog-CEZXV_r9.js +0 -1
- package/dist/client/assets/layout-HxxUtI_4.js +0 -1
- package/dist/client/assets/members-C7m7k6Aj.js +0 -1
- package/dist/client/assets/orgs-Ba0nF6qS.js +0 -1
- package/dist/client/assets/post-editor-yBvya3yr.js +0 -1
- package/dist/client/assets/profile-ZEjk6oqp.js +0 -1
- package/dist/client/assets/project-app-view-Ba53vvVz.js +0 -1
- package/dist/client/assets/record-editor-B2rcuwQk.js +0 -1
- package/dist/client/assets/redirect-editor-C-iqitv1.js +0 -1
- package/dist/client/assets/registry-BShVgR7c.js +0 -2
- package/dist/client/assets/require-capability-BganaMDA.js +0 -1
- package/dist/client/assets/roles-CPT4_Zim.js +0 -1
- package/dist/client/assets/secrets-Cm0Tre0I.js +0 -1
- package/dist/client/assets/select-BRuvjhJw.js +0 -1
- package/dist/client/assets/self-tool-result-mEKHKLZ8.js +0 -1
- package/dist/client/assets/seo-editor-DaIHsMkg.js +0 -1
- package/dist/client/assets/settings-layout-Hxpekzl7.js +0 -1
- package/dist/client/assets/settings-section-BS9eoASN.js +0 -1
- package/dist/client/assets/settings-subnav-D-pYtn7v.js +0 -1
- package/dist/client/assets/shell-controls-BhWnmqdm.js +0 -1
- package/dist/client/assets/shell-layout-B7KEX529.js +0 -1
- package/dist/client/assets/sidebar-Z1Ar8Iq1.js +0 -1
- package/dist/client/assets/skeleton-BvZK-LJN.js +0 -1
- package/dist/client/assets/sso-CZzvOl_H.js +0 -1
- package/dist/client/assets/store-4VNI89Jx.js +0 -1
- package/dist/client/assets/store-registry-5DQx43Zm.js +0 -2
- package/dist/client/assets/studio-tools-BBCHIrbu.js +0 -1
- package/dist/client/assets/switch-BAlslK2J.js +0 -1
- package/dist/client/assets/synced-repos-BYuo6K5k.js +0 -1
- package/dist/client/assets/tabs-DeNiwmVV.js +0 -1
- package/dist/client/assets/tasks-BohHzFrx.js +0 -1
- package/dist/client/assets/textarea-DkNj8yms.js +0 -1
- package/dist/client/assets/toggle-group-Do3gb8uy.js +0 -1
- package/dist/client/assets/tooltip-Dt_WUeQs.js +0 -1
- package/dist/client/assets/use-ai-providers-DwZngUHl.js +0 -1
- package/dist/client/assets/use-api-keys-DrlFtOsW.js +0 -1
- package/dist/client/assets/use-automations-BqX_0zG2.js +0 -1
- package/dist/client/assets/use-capability-U_kO9pjO.js +0 -1
- package/dist/client/assets/use-commerce-diagnostic-DL4B4X1w.js +0 -1
- package/dist/client/assets/use-connection-D7--TeDa.js +0 -1
- package/dist/client/assets/use-delete-connection-CP8NWsvL.js +0 -1
- package/dist/client/assets/use-file-configs-CgH1G4FU.js +0 -1
- package/dist/client/assets/use-join-requests-CW8P-2hM.js +0 -1
- package/dist/client/assets/use-mcp-tools-ByMlhxuh.js +0 -1
- package/dist/client/assets/use-members-DpAa0K8W.js +0 -1
- package/dist/client/assets/use-mobile-DxjazlC8.js +0 -1
- package/dist/client/assets/use-org-repo-syncs-CugnYvLM.js +0 -1
- package/dist/client/assets/use-organization-settings-kcm-WdX5.js +0 -1
- package/dist/client/assets/use-secrets-CAbcEA8g.js +0 -1
- package/dist/client/assets/use-settings-tabs-qdqtthwY.js +0 -1
- package/dist/client/assets/use-tags-Bcd_6z1e.js +0 -1
- package/dist/client/assets/use-view-mode-cgBHRzHt.js +0 -1
- package/dist/client/assets/useInfiniteQuery-CMi-ILZI.js +0 -1
- package/dist/client/assets/useRouterState-B0WmwZ8z.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-Cw5NEgMj.js +0 -1
- package/dist/client/assets/users-CAr233Ns.js +0 -1
- package/dist/client/assets/variant-calendar--Tz37I5S.js +0 -1
- package/dist/client/assets/view-mode-toggle-ChvR0gk0.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as z,b as G,j as t,C as xn,aj as bn,B as ye,r as V,bq as vn,d as at,w as jn,n as Q,a as Te,t as X,y as yn,k as Ve,a5 as Vt,M as Ut,q as K,_ as qt,Z as Kt,Y as Cn,H as le,f as rt,u as lt,a8 as Me,a9 as Pe,ab as Oe,L as _n,G as wn,ao as Nn,ap as Sn,R as Ct,I as kn,K as Ue,p as In,av as ct,o as He,bn as Dn,b2 as An}from"./index-C-W5dASy.js";import{i as Wt}from"./ChevronRight-DfFDfMiT.js";import{aH as Tn,S as Mn,A as qe,e as Pn,s as gt,az as On,aI as Fn,aJ as zn}from"./agent-icon-BhfneAwy.js";import{t as _t}from"./ChevronDown-Dm7RFEzi.js";import{a as dt,i as $n,e as Ln,S as Qt,W as Bn,C as Xt,g as En}from"./constants-BSYv1IkQ.js";import{u as Rn,a as wt}from"./use-virtual-mcp-eZtpf4bS.js";import{a as Xe,b as Nt,P as St}from"./popover-CKC_v_FI.js";import{i as st}from"./Check-DYWCAvRe.js";import{s as Ke}from"./Plus-DKhcQWfb.js";import{i as Yt}from"./SearchMd-C-eFE6qY.js";import{s as Jt}from"./XClose-DyI1k_z6.js";import{C as Gn,d as Pt}from"./self-tool-result-wLzQezsb.js";import{T as kt}from"./toolbar-nEkAKWTR.js";import{D as Zt,a as en,b as tn,c as Hn,g as Vn,e as Un,f as qn}from"./drawer-Dw47OmQ9.js";import{a as Kn,G as Wn}from"./github-repo-picker-DxNDjsxj.js";import{g as Qn,a as nn,u as ut,c as Xn}from"./hooks-IJLcrm9m.js";import{u as Yn,g as Jn,a as Zn,b as es}from"./use-navigate-to-agent-DpqkGd8j.js";import{b as ts,a as sn,g as ns}from"./agent-capabilities-C4tLW0Za.js";import{u as ft,f as ss}from"./shell-layout-BGunSaDG.js";import{f as os}from"./reusable-new-chat-CouMjkYR.js";import{C as is}from"./collection-search-CNrn5ZLG.js";import{g as as,a as rs,b as ls,e as cs}from"./extract-connection-data-CFDQblVE.js";import{u as on,a as an,g as ds,C as ht}from"./connection-card-B5D9qN3O.js";import{e as It,d as Dt,a as At,b as Tt,h as rn,c as us}from"./dialog-CuqXnWbf.js";import{d as pe,a as xe,e as be,b as ve,c as je,F as Ot}from"./form-gSf7rSoB.js";import{I as Le}from"./input-BPzKKVIm.js";import{S as fs,a as ms,b as gs,c as hs,d as Qe}from"./select-CX1EQjk0.js";import{T as ps}from"./textarea-C50htUTR.js";import{b as ln}from"./use-connection-DzUFG_BF.js";import{n as tt,i as pt}from"./Tool02-_e_W6rPa.js";import{c as xs,i as Je,a as Ft,E as bs,p as vs,b as js,d as ys}from"./connection-form-helpers-B3UcqYZu.js";import{a as xt}from"./authenticate-and-persist-oauth-D5NQEgY8.js";import{g as Cs}from"./connection-slug-eyAPH6o3.js";import{C as _s}from"./collection-tabs-Dg_azfZv.js";import{u as zt}from"./use-infinite-scroll-4H8mlAbs.js";import{B as Ze}from"./badge-BNu531uc.js";import{u as ws}from"./useSuspenseInfiniteQuery-Cf9qli1T.js";import{u as Ns,m as $t}from"./use-mcp-client-PMt78ucZ.js";import{g as ot}from"./metadata-dUsYcpuu.js";import{u as Ss}from"./use-ai-providers-Chs1tcQD.js";import{i as ks}from"./FilterLines-CdBZbJbR.js";import{a as Is,T as Ds}from"./toggle-group-CT4Q_c7z.js";import{d as As,a as Ts,c as Ms,b as Ps,C as Os,e as Fs}from"./command-BlvzBYcm.js";import{i as cn}from"./Zap-D44l2tlW.js";import{c as zs,d as $s,b as Ls,f as Bs,g as Es,e as Rs,a as Gs,A as Hs}from"./alert-dialog-fRZZzq2b.js";import{n as Vs}from"./Stars02-CsRg1_DW.js";import{g as Us,u as qs,S as Ks}from"./use-clock-tick-Cad8pAZ9.js";import{a as Ws}from"./format-time-BnbuEtat.js";import{f as Qs}from"./tab-id-BMHIgJVu.js";const Xs="https://decoims.com/image?src=decocms%2F06b54678-5335-4671-b63a-e13d9e541155%2Fagataesteves.png&quality=original&fit=cover&width=160&height=160";function Ys(){const n=z.c(13),e=G();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx("img",{src:"/logos/summit/monte-carlo.svg",alt:"Monte Carlo",className:"h-14 w-[112px] shrink-0 self-start object-contain object-left brightness-0 invert"}),n[0]=s):s=n[0];let i;n[1]!==e?(i=e("routes.commerceOnboarding.connectModal.quote"),n[1]=e,n[2]=i):i=n[2];let a;n[3]!==i?(a=t.jsxs("blockquote",{className:"text-lg font-medium leading-[1.45] lg:text-xl",children:["“",i,"”"]}),n[3]=i,n[4]=a):a=n[4];let o;n[5]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("img",{src:Xs,alt:"",className:"size-10 shrink-0 rounded-full object-cover",loading:"lazy"}),n[5]=o):o=n[5];let r;n[6]!==e?(r=e("routes.commerceOnboarding.connectModal.quoteAuthor"),n[6]=e,n[7]=r):r=n[7];let l;n[8]!==r?(l=t.jsxs("figcaption",{className:"flex items-center gap-2.5",children:[o,t.jsx("span",{className:"text-base font-medium",children:r})]}),n[8]=r,n[9]=l):l=n[9];let c;return n[10]!==a||n[11]!==l?(c=t.jsxs("div",{className:"relative flex flex-col gap-8 text-white",children:[s,a,l]}),n[10]=a,n[11]=l,n[12]=c):c=n[12],c}function Js(){const n=z.c(19),e=G();let s;n[0]!==e?(s=e("routes.commerceOnboarding.connectModal.trustRevoke"),n[0]=e,n[1]=s):s=n[1];let i;n[2]!==s?(i={Icon:Tn,label:s},n[2]=s,n[3]=i):i=n[3];let a;n[4]!==e?(a=e("routes.commerceOnboarding.connectModal.trustEncrypted"),n[4]=e,n[5]=a):a=n[5];let o;n[6]!==a?(o={Icon:xn,label:a},n[6]=a,n[7]=o):o=n[7];let r;n[8]!==e?(r=e("routes.commerceOnboarding.connectModal.trustNeverSold"),n[8]=e,n[9]=r):r=n[9];let l;n[10]!==r?(l={Icon:Mn,label:r},n[10]=r,n[11]=l):l=n[11];let c;n[12]!==i||n[13]!==o||n[14]!==l?(c=[i,o,l],n[12]=i,n[13]=o,n[14]=l,n[15]=c):c=n[15];const d=c;let f;n[16]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx("div",{className:"h-px w-full bg-white/15"}),n[16]=f):f=n[16];let m;return n[17]!==d?(m=t.jsxs("div",{className:"relative flex flex-col gap-2.5 text-white",children:[f,t.jsx("ul",{className:"mt-1 flex flex-col gap-2.5",children:d.map(Zs)})]}),n[17]=d,n[18]=m):m=n[18],m}function Zs(n){const{Icon:e,label:s}=n;return t.jsxs("li",{className:"flex items-center gap-2.5 text-[13px] leading-tight text-white/70",children:[t.jsx(e,{className:"size-4 shrink-0 opacity-85"}),s]},s)}function ba(n){const e=z.c(22),{siteHost:s,footer:i,onClose:a,children:o}=n,r=G(),l=s?`https://www.google.com/s2/favicons?domain=${s}&sz=128`:null;let c;e[0]!==a||e[1]!==r?(c=a&&t.jsx("button",{type:"button",onClick:a,"aria-label":r("routes.commerceOnboarding.connectModal.close"),className:"absolute right-3 top-3 z-10 flex size-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:bg-black/10 hover:text-foreground lg:text-white/80 lg:hover:bg-white/15 lg:hover:text-white",children:t.jsx(bn,{size:18})}),e[0]=a,e[1]=r,e[2]=c):c=e[2];let d,f;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("img",{src:"/logos/deco logo.svg",alt:"Deco",className:"size-7 shrink-0 dark:hidden"}),f=t.jsx("img",{src:"/logos/deco logo negative.svg",alt:"Deco",className:"hidden size-7 shrink-0 dark:block"}),e[3]=d,e[4]=f):(d=e[3],f=e[4]);let m;e[5]!==l||e[6]!==s?(m=s&&t.jsxs(t.Fragment,{children:[t.jsx(Wt,{size:16,className:"shrink-0 text-foreground/25"}),l&&t.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center overflow-hidden rounded bg-white",children:t.jsx("img",{src:l,alt:"",className:"size-full"})}),t.jsx("span",{className:"truncate text-[15px] leading-tight text-muted-foreground",children:s})]}),e[5]=l,e[6]=s,e[7]=m):m=e[7];let u;e[8]!==m?(u=t.jsxs("div",{className:"flex items-center gap-2",children:[d,f,m]}),e[8]=m,e[9]=u):u=e[9];let p;e[10]!==i?(p=t.jsx("div",{className:"flex shrink-0 flex-col gap-3",children:i}),e[10]=i,e[11]=p):p=e[11];let y;e[12]!==o||e[13]!==u||e[14]!==p?(y=t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-8 bg-background p-6 lg:p-8",children:[u,o,p]}),e[12]=o,e[13]=u,e[14]=p,e[15]=y):y=e[15];let x,g;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx("img",{src:"https://decoims.com/image?src=decocms%2F8191643a-1947-4c30-afb4-36b8073c90fb%2Fbg-quote.png&quality=original&fit=cover&width=880",alt:"",className:"absolute inset-0 size-full object-cover"}),g=t.jsx("div",{className:"absolute inset-0 bg-black/20"}),e[16]=x,e[17]=g):(x=e[16],g=e[17]);let h;e[18]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsxs("aside",{className:"relative hidden shrink-0 overflow-hidden lg:flex lg:w-[440px] lg:flex-col lg:p-14",children:[x,g,t.jsxs("div",{className:"relative z-10 flex h-full flex-col",children:[t.jsx("div",{className:"flex-1"}),t.jsx(Ys,{}),t.jsx("div",{className:"flex-1"}),t.jsx(Js,{})]})]}),e[18]=h):h=e[18];let b;return e[19]!==c||e[20]!==y?(b=t.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col lg:flex-row",children:[c,y,h]}),e[19]=c,e[20]=y,e[21]=b):b=e[21],b}function va(n){const e=z.c(5),{ready:s,pending:i,label:a,onClick:o,children:r}=n,l=i||!s,c=s&&!i?r:null;let d;return e[0]!==a||e[1]!==o||e[2]!==l||e[3]!==c?(d=t.jsxs(ye,{type:"button",size:"lg",className:"h-auto min-h-12 w-full whitespace-normal rounded-lg py-3 text-center text-base font-medium leading-tight",onClick:o,disabled:l,children:[a,c]}),e[0]=a,e[1]=o,e[2]=l,e[3]=c,e[4]=d):d=e[4],d}function dn(){const n=V.useContext(vn),{data:e,refetch:s}=n.hooks.useListUserInvitations();return{invitations:(e??[]).filter(a=>a.status==="pending"&&new Date(a.expiresAt)>new Date),refetch:()=>s?.()}}function eo(n){let e=0;for(let i=0;i<n.length;i++)e=n.charCodeAt(i)+((e<<5)-e);const s=Math.abs(e)%360;return{backgroundColor:`hsl(${s} 55% 70%)`,color:`hsl(${s} 55% 20%)`}}function Mt(n){const e=z.c(13),{org:s,size:i}=n,a=i===void 0?"sm":i,o=a==="xs"?"size-5":"size-6",r=a==="xs"?"text-[9px]":"text-xs";let l;e[0]!==o?(l=Q(o,"shrink-0 rounded-md flex items-center justify-center border border-border/50 overflow-hidden"),e[0]=o,e[1]=l):l=e[1];let c;e[2]!==s.logo||e[3]!==s.name?(c=s.logo?void 0:eo(s.name),e[2]=s.logo,e[3]=s.name,e[4]=c):c=e[4];let d;e[5]!==s.logo||e[6]!==s.name||e[7]!==r?(d=s.logo?t.jsx("img",{src:s.logo,alt:"",className:"size-full object-cover"}):t.jsx("span",{className:Q("font-semibold leading-none",r),children:s.name.slice(0,2).toUpperCase()}),e[5]=s.logo,e[6]=s.name,e[7]=r,e[8]=d):d=e[8];let f;return e[9]!==l||e[10]!==c||e[11]!==d?(f=t.jsx("div",{className:l,style:c,children:d}),e[9]=l,e[10]=c,e[11]=d,e[12]=f):f=e[12],f}function to({invitation:n,onChanged:e}){const s=G(),[i,a]=V.useState(!1),o=n.organizationName??s("header.orgSwitcher.unknownOrganization"),r=async()=>{a(!0);try{const d=await Te.organization.acceptInvitation({invitationId:n.id});if(d.error){X.error(d.error.message),a(!1);return}}catch{X.error(s("header.orgSwitcher.failedToAcceptInvitation")),a(!1);return}X.success(s("header.orgSwitcher.joined",{name:o})),yn();let c;try{c=(await Te.organization.getFullOrganization({query:{organizationId:n.organizationId}}))?.data?.slug}catch{}window.location.href=c?`/${c}`:"/"},l=async()=>{a(!0);try{const c=await Te.organization.rejectInvitation({invitationId:n.id});if(c.error){X.error(c.error.message),a(!1);return}X.success(s("header.orgSwitcher.invitationDeclined")),a(!1),e()}catch{X.error(s("header.orgSwitcher.failedToDeclineInvitation")),a(!1)}};return t.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-dashed border-border px-3 py-2.5",children:[t.jsx(Mt,{org:{name:o},size:"sm"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"truncate text-sm font-medium",children:o}),t.jsx("p",{className:"truncate text-xs text-muted-foreground",children:s("header.orgSwitcher.invitedToJoin")})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(ye,{size:"sm",variant:"default",className:"h-7 text-xs",onClick:r,disabled:i,children:s("header.orgSwitcher.accept")}),t.jsx(ye,{size:"icon",variant:"ghost",className:"size-7 text-muted-foreground",onClick:l,disabled:i,"aria-label":s("header.orgSwitcher.declineInvitationTo",{name:o}),children:t.jsx(Jt,{size:14})})]})]})}function no(n){const e=z.c(32),{orgParam:s,onSelectOrg:i,onCreateOrg:a}=n,o=G(),{data:r}=jn(),{invitations:l,refetch:c}=dn();let d;e[0]!==s?(d=(P,D)=>P.slug===s?-1:D.slug===s?1:P.name.localeCompare(D.name),e[0]=s,e[1]=d):d=e[1];const f=[...r??[]].sort(d),[m,u]=V.useState(""),p=m.toLowerCase(),y=p?f.filter(P=>P.name.toLowerCase().includes(p)||P.slug.toLowerCase().includes(p)):f;let x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(Yt,{size:16,className:"shrink-0 text-muted-foreground/60"}),e[2]=x):x=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=P=>u(P.target.value),e[3]=g):g=e[3];let h;e[4]!==m?(h=P=>P.key==="Escape"&&m&&u(""),e[4]=m,e[5]=h):h=e[5];let b;e[6]!==o?(b=o("header.orgSwitcher.searchOrganizations"),e[6]=o,e[7]=b):b=e[7];let j;e[8]!==m||e[9]!==h||e[10]!==b?(j=t.jsx("input",{"data-org-switcher-search":!0,autoFocus:!0,type:"text",value:m,onChange:g,onKeyDown:h,placeholder:b,className:"flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"}),e[8]=m,e[9]=h,e[10]=b,e[11]=j):j=e[11];let C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Ke,{size:16}),e[12]=C):C=e[12];let w;e[13]!==a?(w=t.jsx("button",{type:"button",onClick:a,className:"flex items-center justify-center size-7 rounded-md text-muted-foreground hover:bg-accent/50 hover:text-foreground transition-colors",children:C}),e[13]=a,e[14]=w):w=e[14];let I;e[15]!==j||e[16]!==w?(I=t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border/50",children:[x,j,w]}),e[15]=j,e[16]=w,e[17]=I):I=e[17];const M="flex-1 min-h-0 overflow-y-auto p-1.5 flex flex-col gap-1";let v;e[18]!==l||e[19]!==m||e[20]!==c?(v=!m&&l.map(P=>t.jsx(to,{invitation:P,onChanged:c},P.id)),e[18]=l,e[19]=m,e[20]=c,e[21]=v):v=e[21];const N=y.length===0&&t.jsx("p",{className:"px-3 py-4 text-sm text-muted-foreground/60 text-center",children:m?o("header.orgSwitcher.noOrganizationsMatch",{query:m}):o("header.orgSwitcher.noOrganizationsAvailable")});let A;e[22]!==i||e[23]!==s?(A=P=>t.jsxs("button",{type:"button",onClick:()=>i(P.slug),className:Q("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",P.slug===s?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50"),children:[t.jsx(Mt,{org:P,size:"sm"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("p",{className:"text-sm font-medium truncate",children:P.name}),t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:P.slug})]}),P.slug===s&&t.jsx(st,{size:14,className:"ml-auto text-muted-foreground shrink-0"})]},P.id),e[22]=i,e[23]=s,e[24]=A):A=e[24];const S=y.map(A);let _;e[25]!==v||e[26]!==N||e[27]!==S?(_=t.jsxs("div",{className:M,children:[v,N,S]}),e[25]=v,e[26]=N,e[27]=S,e[28]=_):_=e[28];let T;return e[29]!==_||e[30]!==I?(T=t.jsxs(t.Fragment,{children:[I,_]}),e[29]=_,e[30]=I,e[31]=T):T=e[31],T}function so(n){const e=z.c(22),{trigger:s,orgParam:i,align:a,side:o}=n,r=a===void 0?"start":a,l=o===void 0?"bottom":o,c=at(),[d,f]=V.useState(!1),[m,u]=V.useState(!1);let p;e[0]!==s?(p=t.jsx(Xe,{asChild:!0,children:s}),e[0]=s,e[1]=p):p=e[1];const y=String(d);let x;e[2]!==c?(x=I=>{f(!1),c({to:"/$org",params:{org:I}})},e[2]=c,e[3]=x):x=e[3];let g;e[4]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{f(!1),u(!0)},e[4]=g):g=e[4];let h;e[5]!==i||e[6]!==y||e[7]!==x?(h=t.jsx(no,{orgParam:i,onSelectOrg:x,onCreateOrg:g},y),e[5]=i,e[6]=y,e[7]=x,e[8]=h):h=e[8];let b;e[9]!==r||e[10]!==l||e[11]!==h?(b=t.jsx(Nt,{side:l,align:r,sideOffset:8,collisionPadding:16,className:"w-[300px] p-0 flex flex-col max-h-[440px]",onOpenAutoFocus:io,onCloseAutoFocus:oo,children:h}),e[9]=r,e[10]=l,e[11]=h,e[12]=b):b=e[12];let j;e[13]!==d||e[14]!==p||e[15]!==b?(j=t.jsxs(St,{open:d,onOpenChange:f,children:[p,b]}),e[13]=d,e[14]=p,e[15]=b,e[16]=j):j=e[16];let C;e[17]!==m?(C=t.jsx(Gn,{open:m,onOpenChange:u}),e[17]=m,e[18]=C):C=e[18];let w;return e[19]!==C||e[20]!==j?(w=t.jsxs(t.Fragment,{children:[j,C]}),e[19]=C,e[20]=j,e[21]=w):w=e[21],w}function oo(n){return n.preventDefault()}function io(n){n.preventDefault(),n.currentTarget?.querySelector("[data-org-switcher-search]")?.focus()}function ao(n){const e=z.c(21),{value:s,onChange:i,placeholder:a,onKeyDown:o,className:r,isSearching:l,disabled:c}=n,d=a===void 0?"Search...":a;let f;e[0]!==r?(f=Q("shrink-0 w-full border-b border-border h-12",r),e[0]=r,e[1]=f):f=e[1];const m=c?"cursor-not-allowed opacity-50":"cursor-text";let u;e[2]!==m?(u=Q("flex items-center gap-2.5 h-12 px-4",m),e[2]=m,e[3]=u):u=e[3];let p;e[4]!==l?(p=l?t.jsx(Ve,{size:16,className:"animate-spin text-muted-foreground shrink-0"}):t.jsx(Yt,{size:16,className:"text-muted-foreground shrink-0"}),e[4]=l,e[5]=p):p=e[5];let y;e[6]!==i?(y=b=>i(b.target.value),e[6]=i,e[7]=y):y=e[7];let x;e[8]!==c||e[9]!==o||e[10]!==d||e[11]!==y||e[12]!==s?(x=t.jsx("input",{type:"text",value:s,onChange:y,onKeyDown:o,placeholder:d,disabled:c,className:"flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none"}),e[8]=c,e[9]=o,e[10]=d,e[11]=y,e[12]=s,e[13]=x):x=e[13];let g;e[14]!==u||e[15]!==p||e[16]!==x?(g=t.jsxs("label",{className:u,children:[p,x]}),e[14]=u,e[15]=p,e[16]=x,e[17]=g):g=e[17];let h;return e[18]!==f||e[19]!==g?(h=t.jsx("div",{className:f,children:g}),e[18]=f,e[19]=g,e[20]=h):h=e[20],h}function ro(n,e,s){if(!s)return null;const i=Qn(n,e);return i?i.threads.get().find(o=>o.id===s)?.branch??null:null}function lo(n){const e=z.c(6),{value:s,onChange:i}=n,a=G();let o;e[0]!==a?(o=a("sidebar.agentsSection.searchAgents"),e[0]=a,e[1]=o):o=e[1];let r;return e[2]!==i||e[3]!==o||e[4]!==s?(r=t.jsx(ao,{value:s,onChange:i,placeholder:o}),e[2]=i,e[3]=o,e[4]=s,e[5]=r):r=e[5],r}function co(){const n=z.c(4),e=G();let s;n[0]!==e?(s=e("sidebar.agentsSection.noAgentsFound"),n[0]=e,n[1]=s):s=n[1];let i;return n[2]!==s?(i=t.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:s}),n[2]=s,n[3]=i):i=n[3],i}function uo(n){const e=z.c(10),{org:s,onClose:i}=n,a=G();let o;e[0]!==s.slug?(o={org:s.slug},e[0]=s.slug,e[1]=o):o=e[1];let r;e[2]!==i?(r=()=>i(),e[2]=i,e[3]=r):r=e[3];let l;e[4]!==a?(l=a("sidebar.agentsSection.seeAllAgents"),e[4]=a,e[5]=l):l=e[5];let c;return e[6]!==o||e[7]!==r||e[8]!==l?(c=t.jsx("div",{className:"border-t border-border px-3 py-2.5",children:t.jsx(_n,{to:"/$org/settings/agents",params:o,onClick:r,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center justify-center",children:l})}),e[6]=o,e[7]=r,e[8]=l,e[9]=c):c=e[9],c}function fo(){const n=z.c(4),e=G();let s;n[0]!==e?(s=e("sidebar.agentsSection.agents"),n[0]=e,n[1]=s):s=n[1];let i;return n[2]!==s?(i=t.jsx(un,{children:s}),n[2]=s,n[3]=i):i=n[3],i}function mo(n){const e=z.c(11),{onImportFromGithub:s}=n,i=G();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(Wn,{className:"size-3.5"}),e[0]=a):a=e[0];let o;e[1]!==i?(o=i("sidebar.agentsSection.import"),e[1]=i,e[2]=o):o=e[2];let r;e[3]!==s||e[4]!==o?(r=t.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[a,o]}),e[3]=s,e[4]=o,e[5]=r):r=e[5];let l;e[6]!==i?(l=i("sidebar.agentsSection.codeAgents"),e[6]=i,e[7]=l):l=e[7];let c;return e[8]!==r||e[9]!==l?(c=t.jsx(un,{action:r,children:l}),e[8]=r,e[9]=l,e[10]=c):c=e[10],c}function go(n){const e=z.c(11),{setOpen:s,emptyCtaClass:i}=n,a=G();let o;e[0]!==a?(o=a("sidebar.agentsSection.browseAgents"),e[0]=a,e[1]=o):o=e[1];let r;e[2]!==i?(r=Q(i),e[2]=i,e[3]=r):r=e[3];let l;e[4]!==s?(l=()=>{K("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},e[4]=s,e[5]=l):l=e[5];let c;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Ke,{className:"size-4"}),e[6]=c):c=e[6];let d;return e[7]!==o||e[8]!==r||e[9]!==l?(d=t.jsx(kt,{"aria-label":o,className:r,onClick:l,children:c}),e[7]=o,e[8]=r,e[9]=l,e[10]=d):d=e[10],d}function ho(n){const e=z.c(17),{setOpen:s,highlightEmpty:i,emptyCtaClass:a}=n,o=G();let r;e[0]!==i||e[1]!==o?(r=i?void 0:o("sidebar.agentsSection.browseAgents"),e[0]=i,e[1]=o,e[2]=r):r=e[2];let l;e[3]!==a?(l=Q(a),e[3]=a,e[4]=l):l=e[4];let c;e[5]!==s?(c=()=>{K("agent_browser_opened",{surface:"mobile_drawer"}),s(!0)},e[5]=s,e[6]=c):c=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx(Ke,{}),e[7]=d):d=e[7];let f;e[8]!==o?(f=o("sidebar.agentsSection.newAgent"),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==f?(m=t.jsx("span",{children:f}),e[10]=f,e[11]=m):m=e[11];let u;return e[12]!==r||e[13]!==l||e[14]!==c||e[15]!==m?(u=t.jsx(qt,{children:t.jsxs(Kt,{tooltip:r,className:l,onClick:c,children:[d,m]})}),e[12]=r,e[13]=l,e[14]=c,e[15]=m,e[16]=u):u=e[16],u}function po(){const n=z.c(4),e=G();let s;n[0]!==e?(s=e("sidebar.agentsSection.browseAgents"),n[0]=e,n[1]=s):s=n[1];let i;return n[2]!==s?(i=t.jsx(tn,{className:"sr-only",children:s}),n[2]=s,n[3]=i):i=n[3],i}function xo(n){const e=z.c(8),{emptyCtaClass:s}=n,i=G();let a;e[0]!==i?(a=i("sidebar.agentsSection.browseAgents"),e[0]=i,e[1]=a):a=e[1];let o;e[2]!==s?(o=Q(s),e[2]=s,e[3]=o):o=e[3];let r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(Ke,{className:"size-4"}),e[4]=r):r=e[4];let l;return e[5]!==a||e[6]!==o?(l=t.jsx(kt,{"aria-label":a,className:o,children:r}),e[5]=a,e[6]=o,e[7]=l):l=e[7],l}function bo(n){const e=z.c(19),{wrapEmptyHint:s,highlightEmpty:i,emptyCtaClass:a}=n,o=G();let r;e[0]!==i||e[1]!==o?(r=i?void 0:o("sidebar.agentsSection.browseAgents"),e[0]=i,e[1]=o,e[2]=r):r=e[2];let l;e[3]!==a?(l=Q(a),e[3]=a,e[4]=l):l=e[4];let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Ke,{}),e[5]=c):c=e[5];let d;e[6]!==o?(d=o("sidebar.agentsSection.newAgent"),e[6]=o,e[7]=d):d=e[7];let f;e[8]!==d?(f=t.jsx("span",{children:d}),e[8]=d,e[9]=f):f=e[9];let m;e[10]!==r||e[11]!==l||e[12]!==f?(m=t.jsx(Xe,{asChild:!0,children:t.jsxs(Kt,{tooltip:r,className:l,children:[c,f]})}),e[10]=r,e[11]=l,e[12]=f,e[13]=m):m=e[13];let u;e[14]!==m||e[15]!==s?(u=s(m),e[14]=m,e[15]=s,e[16]=u):u=e[16];let p;return e[17]!==u?(p=t.jsx(qt,{children:u}),e[17]=u,e[18]=p):p=e[18],p}function vo(n){const e=z.c(9),{children:s}=n,i=G();let a;e[0]!==s?(a=t.jsx(Me,{asChild:!0,children:s}),e[0]=s,e[1]=a):a=e[1];let o;e[2]!==i?(o=i("sidebar.agentsSection.selectAnExistingAgent"),e[2]=i,e[3]=o):o=e[3];let r;e[4]!==o?(r=t.jsx(Pe,{side:"right",sideOffset:8,children:o}),e[4]=o,e[5]=r):r=e[5];let l;return e[6]!==a||e[7]!==r?(l=t.jsxs(Oe,{defaultOpen:!0,delayDuration:0,children:[a,r]}),e[6]=a,e[7]=r,e[8]=l):l=e[8],l}function jo(n){const e=at(),{create:s}=nn(),{locator:i}=le(),a=rt({strict:!1}),o=lt({strict:!1});return async r=>{const l=crypto.randomUUID(),c=r===o.virtualmcpid?ro(n,i,a.taskId??""):null;try{await s({id:l,virtual_mcp_id:r,...c?{branch:c}:{}})}catch{}e({to:"/$org/$taskId",params:{org:n,taskId:l},search:{virtualmcpid:r}})}}function bt(n){const e=z.c(20),{agent:s,selected:i,onClick:a}=n,o=i?"bg-accent text-accent-foreground":"text-foreground hover:bg-accent/50";let r;e[0]!==o?(r=Q("flex items-center gap-3 px-3 py-2.5 rounded-md text-sm text-left w-full transition-colors",o),e[0]=o,e[1]=r):r=e[1];let l;e[2]!==s.icon||e[3]!==s.title?(l=t.jsx(qe,{icon:s.icon,name:s.title,size:"xs",className:"shrink-0"}),e[2]=s.icon,e[3]=s.title,e[4]=l):l=e[4];let c;e[5]!==s.title?(c=t.jsx("p",{className:"text-sm font-medium truncate",children:s.title}),e[5]=s.title,e[6]=c):c=e[6];let d;e[7]!==s.description?(d=s.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[7]=s.description,e[8]=d):d=e[8];let f;e[9]!==c||e[10]!==d?(f=t.jsxs("div",{className:"flex-1 min-w-0",children:[c,d]}),e[9]=c,e[10]=d,e[11]=f):f=e[11];let m;e[12]!==i?(m=i&&t.jsx(st,{size:14,className:"ml-auto text-muted-foreground shrink-0"}),e[12]=i,e[13]=m):m=e[13];let u;return e[14]!==a||e[15]!==r||e[16]!==l||e[17]!==f||e[18]!==m?(u=t.jsxs("button",{type:"button",onClick:a,className:r,children:[l,f,m]}),e[14]=a,e[15]=r,e[16]=l,e[17]=f,e[18]=m,e[19]=u):u=e[19],u}function un(n){const e=z.c(5),{children:s,action:i}=n;let a;e[0]!==s?(a=t.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:s}),e[0]=s,e[1]=a):a=e[1];let o;return e[2]!==i||e[3]!==a?(o=t.jsxs("div",{className:"flex items-center justify-between px-3 pb-1 pt-2",children:[a,i]}),e[2]=i,e[3]=a,e[4]=o):o=e[4],o}function yo(n){const e=z.c(23),{onClose:s,onSelectAgent:i,selectedAgentId:a,onImportFromGithub:o}=n,[r,l]=V.useState(""),c=Rn(),d=c??[],{org:f}=le(),{data:m}=Te.useSession(),u=m?.user?.id??"anon",p=Jn(c),y=Zn(),x=jo(f.slug),g=ts(c),h=r.toLowerCase(),b=d.filter(No).filter(E=>!g.has(E.id)).filter(wo).filter(E=>!r||E.title.toLowerCase().includes(h)),j=b.filter(_o),C=b.filter(Co),w=dt(f.id),I=!r||w.title.toLowerCase().includes(h),M=!!(i&&I);let v;e[0]!==s||e[1]!==i?(v=()=>{i?.(null),s(),l("")},e[0]=s,e[1]=i,e[2]=v):v=e[2];const N=v,A=E=>{if(i){i(E.id),s(),l("");return}es({orgId:f.id,userId:u},E.id,p),y(),s(),l(""),x(E.id)},S="flex flex-col max-h-[min(640px,80dvh)]";let _;e[3]!==r?(_=t.jsx(lo,{value:r,onChange:l}),e[3]=r,e[4]=_):_=e[4];const T="overflow-y-auto flex-1 min-h-0 p-1.5 flex flex-col gap-0.5",P=i&&I&&w&&t.jsx(bt,{agent:w,selected:!a||a===w.id,onClick:N}),D=(j.length>0||!r)&&t.jsx(mo,{onImportFromGithub:o}),F=j.map(E=>t.jsx(bt,{agent:E,selected:i?a===E.id:void 0,onClick:()=>A(E)},E.id)),L=C.length>0&&t.jsx(fo,{}),O=C.map(E=>t.jsx(bt,{agent:E,selected:i?a===E.id:void 0,onClick:()=>A(E)},E.id));let $;e[5]!==M||e[6]!==r||e[7]!==b.length?($=b.length===0&&!M&&r&&t.jsx(co,{}),e[5]=M,e[6]=r,e[7]=b.length,e[8]=$):$=e[8];let U;e[9]!==$||e[10]!==P||e[11]!==D||e[12]!==F||e[13]!==L||e[14]!==O?(U=t.jsxs("div",{className:T,children:[P,D,F,L,O,$]}),e[9]=$,e[10]=P,e[11]=D,e[12]=F,e[13]=L,e[14]=O,e[15]=U):U=e[15];let R;e[16]!==s||e[17]!==f?(R=t.jsx(uo,{org:f,onClose:s}),e[16]=s,e[17]=f,e[18]=R):R=e[18];let q;return e[19]!==U||e[20]!==R||e[21]!==_?(q=t.jsxs("div",{className:S,children:[_,U,R]}),e[19]=U,e[20]=R,e[21]=_,e[22]=q):q=e[22],q}function Co(n){return!sn(n.metadata)}function _o(n){return sn(n.metadata)}function wo(n){return!Ln(n.id)}function No(n){return!$n(n.id)}function So(n){const e=z.c(31);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{compact:i,trigger:a,onSelectAgent:o,selectedAgentId:r,side:l,align:c}=s,d=i===void 0?!1:i,f=l===void 0?"right":l,m=c===void 0?"start":c,[u,p]=V.useState(!1),[y,x]=V.useState(!1),g=Vt(),{setOpenMobile:h}=Ut(),b=Yn(),j=b?"border border-border":void 0;let C;e[2]!==b?(C=D=>b?t.jsx(vo,{children:D}):D,e[2]=b,e[3]=C):C=e[3];const w=C;let I;e[4]!==g||e[5]!==h?(I=()=>{p(!1),g&&h(!1)},e[4]=g,e[5]=h,e[6]=I):I=e[6];const M=I;let v;e[7]!==M?(v=()=>{M(),x(!0)},e[7]=M,e[8]=v):v=e[8];const N=v;let A;e[9]!==M||e[10]!==N||e[11]!==o||e[12]!==u||e[13]!==r?(A=u&&t.jsx(V.Suspense,{fallback:t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(Cn,{className:"h-4 w-24"})}),children:t.jsx(yo,{onClose:M,onSelectAgent:o,selectedAgentId:r,onImportFromGithub:N})}),e[9]=M,e[10]=N,e[11]=o,e[12]=u,e[13]=r,e[14]=A):A=e[14];const S=A;let _;e[15]!==m||e[16]!==d||e[17]!==j||e[18]!==b||e[19]!==g||e[20]!==u||e[21]!==S||e[22]!==f||e[23]!==a||e[24]!==w?(_=g?t.jsxs(t.Fragment,{children:[a?t.jsx("button",{type:"button",onClick:()=>p(!0),className:"contents",children:a}):d?w(t.jsx(go,{setOpen:p,emptyCtaClass:j})):t.jsx(ho,{setOpen:p,highlightEmpty:b,emptyCtaClass:j}),t.jsx(Zt,{open:u,onOpenChange:p,direction:"bottom",children:t.jsxs(en,{className:"max-h-[85dvh] p-0",children:[t.jsx(po,{}),S]})})]}):t.jsxs(St,{open:u,onOpenChange:D=>{D&&!u&&K("agent_browser_opened",{surface:"desktop_popover"}),p(D)},children:[a?t.jsx(Xe,{asChild:!0,children:a}):d?w(t.jsx(Xe,{asChild:!0,children:t.jsx(xo,{emptyCtaClass:j})})):t.jsx(bo,{wrapEmptyHint:w,highlightEmpty:b,emptyCtaClass:j}),t.jsx(Nt,{className:"w-[380px] p-0 overflow-hidden",side:f,align:m,children:S})]}),e[15]=m,e[16]=d,e[17]=j,e[18]=b,e[19]=g,e[20]=u,e[21]=S,e[22]=f,e[23]=a,e[24]=w,e[25]=_):_=e[25];let T;e[26]!==y?(T=t.jsx(Kn,{open:y,onOpenChange:x,mode:"agent"}),e[26]=y,e[27]=T):T=e[27];let P;return e[28]!==T||e[29]!==_?(P=t.jsxs(t.Fragment,{children:[_,T]}),e[28]=T,e[29]=_,e[30]=P):P=e[30],P}const ko="inline-flex items-center gap-1.5 min-w-0 rounded-md pl-1 pr-2 py-1.5 text-sm text-foreground hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50";function Io(n){const e=z.c(29),{agentId:s,fallback:i,onOpenHome:a,onPick:o}=n,r=G(),l=wt(s)??i??null;let c,d,f,m,u;e[0]!==l?.title||e[1]!==a||e[2]!==r?(u=l?.title??r("header.shellBreadcrumb.superAgentDefaultName"),m="flex min-w-0 items-center gap-0",c="button",d=a,f=r("header.shellBreadcrumb.openAgentHome",{name:u}),e[0]=l?.title,e[1]=a,e[2]=r,e[3]=c,e[4]=d,e[5]=f,e[6]=m,e[7]=u):(c=e[3],d=e[4],f=e[5],m=e[6],u=e[7]);const p=l?.icon??null;let y;e[8]!==p||e[9]!==u?(y=t.jsx(qe,{icon:p,name:u,size:"xs"}),e[8]=p,e[9]=u,e[10]=y):y=e[10];let x;e[11]!==c||e[12]!==d||e[13]!==f||e[14]!==y?(x=t.jsx("button",{type:c,onClick:d,"aria-label":f,className:"flex items-center shrink-0 rounded-md p-1 hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:y}),e[11]=c,e[12]=d,e[13]=f,e[14]=y,e[15]=x):x=e[15];let g;e[16]!==u?(g=t.jsx("span",{className:"truncate font-medium max-w-[8rem]",children:u}),e[16]=u,e[17]=g):g=e[17];let h;e[18]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(_t,{size:14,className:"shrink-0 text-muted-foreground opacity-70"}),e[18]=h):h=e[18];let b;e[19]!==g?(b=t.jsxs("button",{type:"button",className:ko,children:[g,h]}),e[19]=g,e[20]=b):b=e[20];let j;e[21]!==s||e[22]!==o||e[23]!==b?(j=t.jsx(So,{side:"bottom",align:"start",selectedAgentId:s,onSelectAgent:o,trigger:b}),e[21]=s,e[22]=o,e[23]=b,e[24]=j):j=e[24];let C;return e[25]!==j||e[26]!==m||e[27]!==x?(C=t.jsxs("div",{className:m,children:[x,j]}),e[25]=j,e[26]=m,e[27]=x,e[28]=C):C=e[28],C}function ja(n){const e=z.c(30);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{showName:i}=s,a=G(),{org:o}=le(),{state:r,isMobile:l}=Ut(),c=dn().invitations.length>0,d=r==="collapsed"||l;let f;e[2]!==c||e[3]!==o.name||e[4]!==a?(f=c?a("header.shellBreadcrumb.switchOrganizationPendingInvitation",{name:o.name}):a("header.shellBreadcrumb.switchOrganization",{name:o.name}),e[2]=c,e[3]=o.name,e[4]=a,e[5]=f):f=e[5];let m;e[6]!==o?(m=t.jsx(Mt,{org:o,size:"sm"}),e[6]=o,e[7]=m):m=e[7];let u;e[8]!==c||e[9]!==d?(u=c&&t.jsx("span",{className:Q("absolute -right-1 size-2.5 rounded-full bg-destructive ring-2 ring-background",d?"-top-1":"top-1/2 -translate-y-1/2")}),e[8]=c,e[9]=d,e[10]=u):u=e[10];let p;e[11]!==m||e[12]!==u?(p=t.jsxs("span",{className:"relative inline-flex",children:[m,u]}),e[11]=m,e[12]=u,e[13]=p):p=e[13];let y;e[14]!==o.name||e[15]!==i?(y=i&&t.jsx("span",{className:"truncate text-sm font-medium text-foreground max-w-[10rem]",children:o.name}),e[14]=o.name,e[15]=i,e[16]=y):y=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=t.jsx(_t,{size:14,className:"shrink-0 text-muted-foreground opacity-70"}),e[17]=x):x=e[17];let g;e[18]!==f||e[19]!==p||e[20]!==y?(g=t.jsx(Me,{asChild:!0,children:t.jsxs("button",{type:"button","aria-label":f,className:"flex items-center gap-1.5 shrink-0 rounded-lg pl-[5px] pr-1.5 py-1.5 hover:bg-accent/60 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:[p,y,x]})}),e[18]=f,e[19]=p,e[20]=y,e[21]=g):g=e[21];let h;e[22]!==o.slug||e[23]!==g?(h=t.jsx(so,{orgParam:o.slug,trigger:g}),e[22]=o.slug,e[23]=g,e[24]=h):h=e[24];let b;e[25]!==o.name?(b=t.jsx(Pe,{side:"bottom",children:o.name}),e[25]=o.name,e[26]=b):b=e[26];let j;return e[27]!==b||e[28]!==h?(j=t.jsxs(Oe,{children:[h,b]}),e[27]=b,e[28]=h,e[29]=j):j=e[29],j}function ya(n){const e=z.c(22);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{onNavigate:i}=s,{org:a}=le();let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},e[2]=o):o=e[2];const r=rt(o);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l={strict:!1},e[3]=l):l=e[3];const c=lt(l),{threads:d}=ut(),{data:f}=Te.useSession(),{setTaskId:m,createNewTask:u}=ft();let p;e[4]!==a.id?(p=dt(a.id),e[4]=a.id,e[5]=p):p=e[5];const y=p,x=y.id,g=r.taskId?c.virtualmcpid??x:x;let h;e[6]!==u||e[7]!==x||e[8]!==i||e[9]!==f?.user?.id||e[10]!==m||e[11]!==d?(h=M=>{const v=M??x,N=os(d,v,f?.user?.id);N?m(N.id,v):u(v),i?.()},e[6]=u,e[7]=x,e[8]=i,e[9]=f?.user?.id,e[10]=m,e[11]=d,e[12]=h):h=e[12];const b=h;let j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx("span",{className:"h-5 w-24 rounded bg-muted animate-pulse"}),e[13]=j):j=e[13];const C=g===x?y:void 0;let w;e[14]!==g||e[15]!==b?(w=()=>b(g),e[14]=g,e[15]=b,e[16]=w):w=e[16];let I;return e[17]!==g||e[18]!==b||e[19]!==C||e[20]!==w?(I=t.jsx(V.Suspense,{fallback:j,children:t.jsx(Io,{agentId:g,fallback:C,onOpenHome:w,onPick:b})}),e[17]=g,e[18]=b,e[19]=C,e[20]=w,e[21]=I):I=e[21],I}function Ca(){const n=z.c(24),e=G(),{org:s}=le();let i;n[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},n[0]=i):i=n[0];const a=rt(i);let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o={strict:!1},n[1]=o):o=n[1];const r=lt(o),{threads:l}=ut(),{createNewTask:c}=ft();let d;n[2]!==s.id?(d=dt(s.id),n[2]=s.id,n[3]=d):d=n[3];const f=d.id,m=a.taskId?r.virtualmcpid??f:f;let u;n[4]!==a.taskId||n[5]!==l?(u=(a.taskId?l.find(I=>I.id===a.taskId)?.branch:null)??null,n[4]=a.taskId,n[5]=l,n[6]=u):u=n[6];const p=u;let y;n[7]!==m||n[8]!==c||n[9]!==p?(y=()=>{c(m,p)},n[7]=m,n[8]=c,n[9]=p,n[10]=y):y=n[10];const x=y;let g;n[11]!==e?(g=e("sidebar.taskGroupsList.newChat"),n[11]=e,n[12]=g):g=n[12];let h;n[13]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Pn,{size:16}),n[13]=h):h=n[13];let b;n[14]!==x||n[15]!==g?(b=t.jsx(Me,{asChild:!0,children:t.jsx("button",{type:"button",onClick:x,"aria-label":g,className:"flex shrink-0 items-center rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:h})}),n[14]=x,n[15]=g,n[16]=b):b=n[16];let j;n[17]!==e?(j=e("sidebar.taskGroupsList.newChat"),n[17]=e,n[18]=j):j=n[18];let C;n[19]!==j?(C=t.jsx(Pe,{side:"bottom",children:j}),n[19]=j,n[20]=C):C=n[20];let w;return n[21]!==b||n[22]!==C?(w=t.jsxs(Oe,{children:[b,C]}),n[21]=b,n[22]=C,n[23]=w):w=n[23],w}function Do({open:n,onOpenChange:e,onCreated:s}){const i=G(),{org:a}=le(),{data:o}=Te.useSession(),{stdioEnabled:r}=wn(),l=Vt(),c=ln(),d=on(),m=an(d,"").items,u=Nn({resolver:Sn(xs),defaultValues:{title:"",description:null,icon:null,ui_type:"HTTP",connection_url:"",connection_token:null,npx_package:"",stdio_command:"",stdio_args:"",stdio_cwd:"",env_vars:[]}}),p=u.watch("ui_type"),y=u.watch("connection_url"),x=u.watch("npx_package"),g=Je({uiType:p,connectionUrl:y??"",npxPackage:x??""})??Ft({uiType:p,connectionUrl:y??"",registryItems:m}),h=v=>{const N=v.trim();if(!N)return;const A=!!u.formState.dirtyFields.title,S=!!u.formState.dirtyFields.description,_=!!u.formState.dirtyFields.env_vars,T=D=>{if(D&&(!A&&!u.getValues("title").trim()&&D.title&&u.setValue("title",D.title,{shouldDirty:!1}),!S&&!(u.getValues("description")??"").trim()&&D.description&&u.setValue("description",D.description,{shouldDirty:!1}),!_&&D.envVarKeys?.length)){const F=u.getValues("env_vars")??[],L=new Set(F.map($=>$.key)),O=D.envVarKeys.filter($=>!L.has($));O.length>0&&u.setValue("env_vars",[...F,...O.map($=>({key:$,value:""}))],{shouldDirty:!0})}},P=vs(N);if(P&&r){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}),T(Je({uiType:"NPX",npxPackage:P.packageName}));return}if(N.startsWith("http://")||N.startsWith("https://")){const D=p==="HTTP"||p==="SSE"||p==="Websocket"?p:"HTTP";u.setValue("ui_type",D,{shouldDirty:!0}),u.setValue("connection_url",N,{shouldDirty:!0}),T(Je({uiType:D,connectionUrl:N})??Ft({uiType:D,connectionUrl:N,registryItems:m}));return}p==="NPX"&&T(Je({uiType:"NPX",npxPackage:N}))},b=v=>{v||u.reset(),e(v)},j=async v=>{let N,A=null,S=null,_=null;v.ui_type==="NPX"?(N="STDIO",A="",_=js(v.npx_package||"",v.env_vars||[])):v.ui_type==="STDIO"?(N="STDIO",A="",_=ys(v.stdio_command||"",v.stdio_args||"",v.stdio_cwd,v.env_vars||[])):(N=v.ui_type,A=v.connection_url||"",S=v.connection_token||null);const T=as("conn");try{await c.create.mutateAsync({id:T,title:v.title,description:v.description||null,connection_type:N,connection_url:A,connection_token:S,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),created_by:o?.user?.id||"system",organization_id:a.id,icon:v.icon??null,app_name:null,app_id:null,connection_headers:_,oauth_config:null,configuration_state:null,metadata:null,tools:null,bindings:null,status:"inactive"}),u.reset(),e(!1),s?.(T)}catch{X.error(i("connections.createConnectionDialog.failedToCreateConnection"))}},C=i("connections.createConnectionDialog.title"),w=i("connections.createConnectionDialog.description"),I=u.formState.isSubmitting?i("connections.createConnectionDialog.saving"):i("connections.createConnectionDialog.createButton"),M=t.jsxs("div",{className:"grid gap-4",children:[t.jsx(pe,{control:u.control,name:"ui_type",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.typeLabel")}),t.jsxs(fs,{value:v.value,onValueChange:v.onChange,children:[t.jsx(ve,{children:t.jsx(ms,{children:t.jsx(gs,{})})}),t.jsxs(hs,{children:[t.jsx(Qe,{value:"HTTP",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(gt,{className:"w-4 h-4"}),i("connections.createConnectionDialog.httpType")]})}),t.jsx(Qe,{value:"SSE",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(gt,{className:"w-4 h-4"}),i("connections.createConnectionDialog.sseType")]})}),t.jsx(Qe,{value:"Websocket",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(gt,{className:"w-4 h-4"}),i("connections.createConnectionDialog.websocketType")]})}),r&&t.jsxs(t.Fragment,{children:[t.jsx(Qe,{value:"NPX",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(tt,{className:"w-4 h-4"}),i("connections.createConnectionDialog.npxPackageType")]})}),t.jsx(Qe,{value:"STDIO",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(On,{className:"w-4 h-4"}),i("connections.createConnectionDialog.customCommandType")]})})]})]})]}),t.jsx(je,{})]})}),p==="NPX"&&t.jsx(pe,{control:u.control,name:"npx_package",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.npmPackageLabel")}),t.jsx(ve,{children:t.jsx(Le,{placeholder:i("connections.createConnectionDialog.npmPackagePlaceholder"),...v,value:v.value??"",onPaste:N=>{const A=N.clipboardData.getData("text");A&&(N.preventDefault(),u.setValue("npx_package",A.trim(),{shouldDirty:!0}),h(A))},onBlur:N=>{h(N.target.value),v.onBlur()}})}),t.jsx(je,{})]})}),p==="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 items-start",children:[t.jsx(pe,{control:u.control,name:"stdio_command",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.commandLabel")}),t.jsx(ve,{children:t.jsx(Le,{placeholder:i("connections.createConnectionDialog.commandPlaceholder"),...v,value:v.value??""})}),t.jsx(je,{})]})}),t.jsx(pe,{control:u.control,name:"stdio_args",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.argumentsLabel")}),t.jsx(ve,{children:t.jsx(Le,{placeholder:i("connections.createConnectionDialog.argumentsPlaceholder"),...v,value:v.value??""})}),t.jsx(je,{})]})})]}),t.jsx(pe,{control:u.control,name:"stdio_cwd",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.workingDirectoryLabel")}),t.jsx(ve,{children:t.jsx(Le,{placeholder:i("connections.createConnectionDialog.workingDirectoryPlaceholder"),...v,value:v.value??""})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:i("connections.createConnectionDialog.workingDirectoryDescription")}),t.jsx(je,{})]})})]}),(p==="NPX"||p==="STDIO")&&t.jsx(pe,{control:u.control,name:"env_vars",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.environmentVariablesLabel")}),t.jsx(ve,{children:t.jsx(bs,{value:v.value??[],onChange:v.onChange})}),t.jsx(je,{})]})}),p!=="NPX"&&p!=="STDIO"&&t.jsxs(t.Fragment,{children:[t.jsx(pe,{control:u.control,name:"connection_url",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.urlLabel")}),t.jsx(ve,{children:t.jsx(Le,{placeholder:i("connections.createConnectionDialog.urlPlaceholder"),...v,value:v.value??"",onPaste:N=>{const A=N.clipboardData.getData("text");A&&(N.preventDefault(),u.setValue("connection_url",A.trim(),{shouldDirty:!0}),h(A))},onBlur:N=>{h(N.target.value),v.onBlur()}})}),t.jsx(je,{})]})}),t.jsx(pe,{control:u.control,name:"connection_token",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:g?.token?.label??i("connections.createConnectionDialog.tokenLabelDefault")}),t.jsx(ve,{children:t.jsx(Le,{type:"password",placeholder:g?.token?.placeholder??i("connections.createConnectionDialog.tokenPlaceholderDefault"),className:"ph-no-capture",...v,value:v.value??""})}),g?.token?.helperText&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[g.token.helperText,g.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:i("connections.createConnectionDialog.openGitHubPatSettings")})]})]}),t.jsx(je,{})]})})]}),t.jsx(pe,{control:u.control,name:"title",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.nameLabel")}),t.jsx(ve,{children:t.jsx(Le,{placeholder:i("connections.createConnectionDialog.namePlaceholder"),...v})}),t.jsx(je,{})]})}),t.jsx(pe,{control:u.control,name:"description",render:({field:v})=>t.jsxs(xe,{children:[t.jsx(be,{children:i("connections.createConnectionDialog.descriptionLabel")}),t.jsx(ve,{children:t.jsx(ps,{placeholder:i("connections.createConnectionDialog.descriptionPlaceholder"),rows:3,...v,value:v.value??""})}),t.jsx(je,{})]})})]});return l?t.jsx(Zt,{open:n,onOpenChange:b,children:t.jsxs(en,{className:"max-h-[90vh]",children:[t.jsx(Hn,{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(tn,{children:C}),t.jsx(Vn,{className:"mt-1",children:w})]}),t.jsx(Un,{asChild:!0,children:t.jsx(ye,{variant:"ghost",size:"icon",className:"shrink-0 -mt-1",children:t.jsx(Jt,{size:16})})})]})}),t.jsx(Ot,{...u,children:t.jsxs("form",{onSubmit:u.handleSubmit(j),children:[t.jsx("div",{className:"overflow-y-auto px-4 pb-4",children:M}),t.jsx(qn,{children:t.jsx(ye,{type:"submit",disabled:u.formState.isSubmitting,className:"w-full",children:I})})]})})]})}):t.jsx(It,{open:n,onOpenChange:b,children:t.jsxs(Dt,{className:"sm:max-w-[525px]",children:[t.jsxs(At,{children:[t.jsx(Tt,{children:C}),t.jsx(rn,{children:w})]}),t.jsx(Ot,{...u,children:t.jsxs("form",{onSubmit:u.handleSubmit(j),children:[t.jsx("div",{className:"py-4",children:M}),t.jsxs(us,{children:[t.jsx(ye,{type:"button",variant:"outline",onClick:()=>b(!1),children:i("connections.createConnectionDialog.cancelButton")}),t.jsx(ye,{type:"submit",disabled:u.formState.isSubmitting,className:"min-w-40",children:I})]})]})})]})})}function Ao(n){const e=z.c(72),{mode:s,agentId:i,addedConnectionIds:a,onAdd:o,onCloneAndAdd:r,onConnectAndAdd:l,connectingItemId:c,search:d,onCreateConnection:f,onBrowseNavigate:m,defaultTab:u}=n,p=s===void 0?"add":s,y=u===void 0?"connected":u,x=G(),{org:g}=le(),h=V.useDeferredValue(d),b=d!==h;let j;e[0]!==h?(j=h.trim().toLowerCase(),e[0]=h,e[1]=j):j=e[1];const C=j;let w;e[2]!==y?(w=k=>k??y,e[2]=y,e[3]=w):w=e[3];const[I,M]=Ct(kn.connectionsTab(g.slug)+(y==="all"?":home-modal":":agent-modal"),w);let v;e[4]!==I||e[5]!==M?(v=k=>{k!==I&&K("connections_dialog_tab_changed",{to_tab:k}),M(k)},e[4]=I,e[5]=M,e[6]=v):v=e[6];const N=v;let A;e[7]!==g.id||e[8]!==g.slug?(A={connectionId:Qt,orgId:g.id,orgSlug:g.slug},e[7]=g.id,e[8]=g.slug,e[9]=A):A=e[9];const S=Ns(A),_=h?.trim().split(/\s+/).filter(Boolean)??[],T=_.length>0?{operator:"or",conditions:_.flatMap(Lo)}:void 0,P={...T&&{where:T},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:0},D=JSON.stringify(P),{data:F,fetchNextPage:L,hasNextPage:O,isFetchingNextPage:$}=ws({queryKey:Ue.collectionListInfinite(S,g.id,"","CONNECTIONS",D),queryFn:async k=>{const{pageParam:B}=k,Z=B===void 0?0:B;return(await S.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...T&&{where:T},orderBy:[{field:["updated_at"],direction:"asc"}],limit:100,offset:Z}})).structuredContent},initialPageParam:0,getNextPageParam:zo,staleTime:3e4}),U=F?.pages.flatMap(Fo)??[],R=ds(U),q=new Set(U.filter(Oo).map(Po)),E=on(),Y=an(E,h),ee=zt(Y.loadMore,Y.hasMore,Y.isLoadingMore),te=zt(L,O??!1,$),H=I==="all"||!!C,J=H?Y.items.filter(k=>{const B=rs(k);if(B&&q.has(B))return!1;if(!C)return!0;const Z=ot(k._meta),ue=[k.title,k.description,k.name,k.server?.title,k.server?.description,k.server?.name,Z?.friendly_name,Z?.friendlyName].filter(Boolean).join(" ").toLowerCase();return _.some(he=>ue.includes(he.toLowerCase()))}):[],ne=J.filter(Mo),W=J.filter(To);let Ne;e[10]!==a?(Ne=k=>k.some(B=>a.has(B.id)),e[10]=a,e[11]=Ne):Ne=e[11];const Be=Ne;let Ce;e[12]!==a||e[13]!==i||e[14]!==c||e[15]!==Be||e[16]!==p||e[17]!==o||e[18]!==m||e[19]!==r||e[20]!==x?(Ce=(k,B,Z,ue,he)=>{const Ye=Be(he),Ge=he.find($e=>!a.has($e.id)),ce=he[0];if(p==="browse"){const $e=Cs(ce);return t.jsx(ht,{connection:{title:B,icon:Z,description:he.length>1?`${he.length} instances`:ue??void 0},fallbackIcon:t.jsx(tt,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs(Ze,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[t.jsx(st,{size:11})," ",x("virtualMcp.connectionDialogContent.connected")]}),onClick:()=>{K("connection_browse_clicked",{app_name:ce.app_name??null,connection_id:ce.id,instances_count:he.length}),m?.($e)}},k)}return t.jsx(ht,{connection:{title:B,icon:Z,description:ue},fallbackIcon:t.jsx(tt,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[Ye&&t.jsxs(Ze,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[t.jsx(st,{size:11})," ",x("virtualMcp.connectionDialogContent.added")]}),t.jsx(ye,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:$e=>{$e.stopPropagation(),Ge?(K("connection_add_clicked",{action:"use_existing",app_name:ce.app_name??null,connection_id:Ge.id}),i&&K("agent_connection_attached",{agent_id:i,connection_id:Ge.id,app_name:ce.app_name??null,mode:"existing"}),o(Ge.id)):(K("connection_add_clicked",{action:"clone",app_name:ce.app_name??null,base_connection_id:ce.id}),r(ce))},children:x("virtualMcp.connectionDialogContent.add")})]})},k)},e[12]=a,e[13]=i,e[14]=c,e[15]=Be,e[16]=p,e[17]=o,e[18]=m,e[19]=r,e[20]=x,e[21]=Ce):Ce=e[21];const Ee=Ce;let _e;e[22]!==c||e[23]!==p||e[24]!==l||e[25]!==x?(_e=k=>{const B=ot(k._meta),Z=B?.friendlyName||B?.friendly_name||k.server?.title||k.title||k.server?.name||k.name||k.id||"",ue=k.server?.description||k.description||null,he=k.server?.icons?.[0]?.src||ls(k.server?.repository)||null,Ye=B?.official===!0,Ge=B?.verified===!0,ce=B?.owner==="deco";return t.jsx(ht,{connection:{title:Z,description:ue,icon:he},fallbackIcon:t.jsx(tt,{}),headerActionsAlwaysVisible:!0,headerActions:t.jsxs("div",{className:"flex items-center gap-1.5",children:[ce&&t.jsxs(Oe,{children:[t.jsx(Me,{asChild:!0,children:t.jsx("span",{className:"inline-flex items-center justify-center size-5 rounded-md bg-muted shrink-0",children:t.jsx("img",{src:"/logos/deco logo.svg",alt:x("virtualMcp.connectionDialogContent.madeByDeco"),className:"size-3"})})}),t.jsx(Pe,{children:x("virtualMcp.connectionDialogContent.builtByDeco")})]}),!ce&&Ye&&t.jsxs(Oe,{children:[t.jsx(Me,{asChild:!0,children:t.jsx(Ze,{variant:"outline",size:"icon",children:t.jsx(pt,{})})}),t.jsx(Pe,{children:x("virtualMcp.connectionDialogContent.builtByOfficial")})]}),!ce&&!Ye&&Ge&&t.jsxs(Oe,{children:[t.jsx(Me,{asChild:!0,children:t.jsx(Ze,{variant:"outline",size:"icon",children:t.jsx(pt,{})})}),t.jsx(Pe,{children:x("virtualMcp.connectionDialogContent.verifiedByDeco")})]}),t.jsx(ye,{variant:"outline",size:"sm",className:"h-7 px-3 text-xs font-medium",disabled:c!==null,onClick:$e=>{$e.stopPropagation(),K("connection_add_clicked",{action:"connect_new",registry_item_id:k.id,app_name:B?.friendlyName||k.server?.name||k.name||null}),l(k)},children:c===k.id?t.jsx(Ve,{size:14,className:"animate-spin"}):x(p==="browse"?"virtualMcp.connectionDialogContent.connect":"virtualMcp.connectionDialogContent.add")})]})},`catalog-${k.id}`)},e[22]=c,e[23]=p,e[24]=l,e[25]=x,e[26]=_e):_e=e[26];const We=_e;let se;e[27]!==I||e[28]!==N||e[29]!==f||e[30]!==C||e[31]!==x?(se=!C&&t.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border shrink-0",children:[t.jsx(_s,{tabs:[{id:"all",label:x("virtualMcp.connectionDialogContent.tabAll")},{id:"connected",label:x("virtualMcp.connectionDialogContent.tabConnected")}],activeTab:I,onTabChange:k=>N(k)}),t.jsxs(ye,{variant:"outline",size:"sm",className:"h-7 px-2 text-sm",onClick:()=>{K("connections_dialog_custom_clicked"),f()},children:[t.jsx(Ke,{size:12}),x("virtualMcp.connectionDialogContent.customConnection")]})]}),e[27]=I,e[28]=N,e[29]=f,e[30]=C,e[31]=x,e[32]=se):se=e[32];const Se=b&&"opacity-50 pointer-events-none";let oe;e[33]!==Se?(oe=Q("flex-1 overflow-auto p-5 transition-opacity duration-150",Se),e[33]=Se,e[34]=oe):oe=e[34];const Re="grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-4";let ke;e[35]!==Ee?(ke=k=>{if(k.type==="group")return Ee(k.key,k.title,k.icon,null,k.connections);const B=k.connection;return Ee(B.id,B.title,B.icon,B.description??null,[B])},e[35]=Ee,e[36]=ke):ke=e[36];const Ie=R.map(ke);let fe;e[37]!==te?(fe=t.jsx("div",{ref:te,className:"col-span-full h-1"}),e[37]=te,e[38]=fe):fe=e[38];let de;e[39]!==$?(de=$&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(Ve,{size:24,className:"animate-spin text-muted-foreground"})}),e[39]=$,e[40]=de):de=e[40];const Fe=H&&ne.length>0&&t.jsxs("div",{className:"col-span-full flex items-center gap-2 mt-2",children:[t.jsx(pt,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-sm font-medium text-muted-foreground whitespace-nowrap",children:x("virtualMcp.connectionDialogContent.sectionVerified")}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),De=H&&ne.map(We),ze=H&&W.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:x("virtualMcp.connectionDialogContent.sectionAllConnections")}),t.jsx("div",{className:"flex-1 h-px bg-border"})]}),Ae=H&&W.map(We);let me;e[41]!==ee||e[42]!==E||e[43]!==H?(me=H&&E.length>0&&t.jsx("div",{ref:ee,className:"col-span-full h-1"}),e[41]=ee,e[42]=E,e[43]=H,e[44]=me):me=e[44];let ie;e[45]!==Y.isLoadingMore||e[46]!==H?(ie=H&&Y.isLoadingMore&&t.jsx("div",{className:"col-span-full flex justify-center py-6",children:t.jsx(Ve,{size:24,className:"animate-spin text-muted-foreground"})}),e[45]=Y.isLoadingMore,e[46]=H,e[47]=ie):ie=e[47];let ge;e[48]!==Ie||e[49]!==fe||e[50]!==de||e[51]!==Fe||e[52]!==De||e[53]!==ze||e[54]!==Ae||e[55]!==me||e[56]!==ie?(ge=t.jsxs("div",{className:Re,children:[Ie,fe,de,Fe,De,ze,Ae,me,ie]}),e[48]=Ie,e[49]=fe,e[50]=de,e[51]=Fe,e[52]=De,e[53]=ze,e[54]=Ae,e[55]=me,e[56]=ie,e[57]=ge):ge=e[57];let ae;e[58]!==I||e[59]!==R.length||e[60]!==W||e[61]!==d||e[62]!==x||e[63]!==ne?(ae=R.length===0&&ne.length===0&&W.length===0&&t.jsx("div",{className:"flex items-center justify-center h-48 text-sm text-muted-foreground",children:d?x("virtualMcp.connectionDialogContent.emptyStateSearchNoMatch",{search:d}):x(I==="connected"?"virtualMcp.connectionDialogContent.emptyStateNoConnectionsYet":"virtualMcp.connectionDialogContent.emptyStateNoConnectionsAvailable")}),e[58]=I,e[59]=R.length,e[60]=W,e[61]=d,e[62]=x,e[63]=ne,e[64]=ae):ae=e[64];let re;e[65]!==oe||e[66]!==ge||e[67]!==ae?(re=t.jsxs("div",{className:oe,children:[ge,ae]}),e[65]=oe,e[66]=ge,e[67]=ae,e[68]=re):re=e[68];let we;return e[69]!==se||e[70]!==re?(we=t.jsxs(t.Fragment,{children:[se,re]}),e[69]=se,e[70]=re,e[71]=we):we=e[71],we}function To(n){return!n.verified&&!ot(n._meta)?.verified&&!n.meta?.verified}function Mo(n){return n.verified||ot(n._meta)?.verified||n.meta?.verified}function Po(n){return n.app_name}function Oo(n){return n.app_name}function Fo(n){return n?.items??[]}function zo(n,e){if(n?.hasMore)return e.reduce($o,0)}function $o(n,e){return n+(e?.items?.length??0)}function Lo(n){return[{field:["title"],operator:"contains",value:n},{field:["description"],operator:"contains",value:n}]}function _a({open:n,onOpenChange:e,defaultTab:s,initialSearch:i="",...a}){const o=G(),r=a.mode??"add",l="agentId"in a?a.agentId:void 0,c="addedConnectionIds"in a?a.addedConnectionIds??new Set:new Set,d="onAdd"in a&&a.onAdd?a.onAdd:S=>{},f=(S,_,T)=>{l&&K("agent_connection_attached",{agent_id:l,connection_id:S,app_name:_,mode:T})},[m,u]=V.useState(null),[p,y]=V.useState(i),[x,g]=V.useState(!1),{org:h}=le(),{data:b}=Te.useSession(),j=ln(),C=In(),w=at(),I=S=>{e(!1),w({to:"/$org/settings/connections/$appSlug",params:{org:h.slug,appSlug:S}})},M=()=>{C.invalidateQueries({predicate:S=>{const _=S.queryKey;return _[1]===h.id&&_[3]==="collection"&&_[4]==="CONNECTIONS"}})},v=async(S,_)=>{K("connection_oauth_succeeded",{connection_id:S,flow:_});const T=new URL(`/api/${h.slug}/mcp/${S}`,window.location.origin);await C.invalidateQueries({queryKey:Ue.isMCPAuthenticated(T.href,null)}),M()},N=async S=>{u(S.app_name??S.id);try{const T=`${S.title.replace(/\s*\(\d+\)\s*$/,"")} (${Date.now().toString(36).slice(-4)})`,D=(await j.create.mutateAsync({title:T,description:S.description??null,connection_type:S.connection_type,connection_url:S.connection_url??null,connection_token:null,icon:S.icon??null,app_name:S.app_name??null,app_id:S.app_id??null,connection_headers:S.connection_headers??null})).id,F=await xt({connectionId:D,orgId:h.id,orgSlug:h.slug,persistFallback:L=>j.update.mutateAsync({id:D,data:{connection_token:L}}).then(()=>{})});if(F.ran&&!F.ok){K("connection_oauth_failed",{connection_id:D,flow:"clone",error:F.error??"no_token"}),X.error(o("virtualMcp.addConnectionDialog.authenticationFailedError",{error:F.error??"no token received"})),await j.delete.mutateAsync(D);return}F.ran&&await v(D,"clone"),f(D,S.app_name??null,"clone"),d(D)}catch(_){console.error("Failed to add connection:",_),X.error(o("virtualMcp.addConnectionDialog.failedToAddConnection"))}finally{u(null)}},A=async S=>{if(!(!h||!b?.user?.id)){u(S.id);try{const _=cs(S,h.id,b.user.id,{remoteIndex:0}),T=_.connection_type==="STDIO",P=!!_.connection_url,D=T&&_.connection_headers&&typeof _.connection_headers=="object"&&"command"in _.connection_headers;if(!P&&!D){X.error(o("virtualMcp.addConnectionDialog.mcpServerConnectionError")),u(null);return}const{id:F}=await j.create.mutateAsync(_),L=await xt({connectionId:F,orgId:h.id,orgSlug:h.slug,persistFallback:O=>j.update.mutateAsync({id:F,data:{connection_token:O}}).then(()=>{})});if(L.ran&&!L.ok){K("connection_oauth_failed",{connection_id:F,flow:"connect_new",error:L.error??"no_token"}),X.warning(o("virtualMcp.addConnectionDialog.signInFailedTitle"),{description:o("virtualMcp.addConnectionDialog.signInFailedDescription",{error:L.error??"no token received"})}),f(F,_.app_name??null,"new"),d(F);return}L.ran?(await v(F,"connect_new"),X.success(o("virtualMcp.addConnectionDialog.connectedAuthenticated"))):X.success(o("virtualMcp.addConnectionDialog.connected")),f(F,_.app_name??null,"new"),d(F)}catch(_){console.error("Failed to connect:",_),X.error(o("virtualMcp.addConnectionDialog.failedToConnect"))}finally{u(null)}}};return t.jsxs(It,{open:n,onOpenChange:e,children:[t.jsxs(Dt,{className:"sm:max-w-5xl h-[85vh] max-h-[85vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[t.jsx(At,{className:"px-6 pt-5 pb-0 shrink-0",children:t.jsx(Tt,{className:"text-base font-semibold",children:o(r==="browse"?"virtualMcp.addConnectionDialog.connectionsTitle":"virtualMcp.addConnectionDialog.addConnectionTitle")})}),t.jsx("div",{className:"pt-3 shrink-0",children:t.jsx(is,{value:p,onChange:y,placeholder:o("virtualMcp.addConnectionDialog.searchConnectionsPlaceholder")})}),t.jsx(V.Suspense,{fallback:t.jsx("div",{className:"flex-1 flex items-center justify-center",children:t.jsx(Ve,{size:24,className:"animate-spin text-muted-foreground"})}),children:t.jsx(Ao,{mode:r,agentId:l,addedConnectionIds:c,onAdd:d,onCloneAndAdd:N,onConnectAndAdd:A,connectingItemId:m,search:p,onCreateConnection:()=>g(!0),onBrowseNavigate:I,defaultTab:s})})]}),t.jsx(Do,{open:x,onOpenChange:g,onCreated:async S=>{g(!1);const _=await xt({connectionId:S,orgId:h.id,orgSlug:h.slug,persistFallback:T=>j.update.mutateAsync({id:S,data:{connection_token:T}}).then(()=>{})});if(_.ran&&!_.ok){K("connection_oauth_failed",{connection_id:S,flow:"custom_create",error:_.error??"no_token"}),X.warning(o("virtualMcp.addConnectionDialog.signInFailedTitle"),{description:o("virtualMcp.addConnectionDialog.signInFailedDescription",{error:_.error??"no token received"})}),f(S,null,"custom"),d(S),e(!1);return}_.ran&&await v(S,"custom_create"),f(S,null,"custom"),d(S),e(!1)}})]})}const Lt=new Map;function wa(){const{org:n}=le(),e=ct(),s=Ss(),i=s.find(g=>g.providerId==="deco"),{data:a,isLoading:o,refetch:r,isFetching:l}=He({queryKey:Ue.aiProviderCredits(n.id,"deco"),enabled:!!i,staleTime:6e4,queryFn:async()=>{try{return await e.call("AI_PROVIDER_CREDITS",{providerId:"deco"})}catch{return null}}}),c=a?.balanceCents??null,d=c!=null?c/100:null,f=V.useRef(new Map);if(c!=null){const g=Lt.get(n.id);f.current.get(n.id)&&g!=null&&c>g&&K("credits_topped_up_detected",{organization_id:n.id,delta_cents:c-g,previous_balance_cents:g,new_balance_cents:c}),Lt.set(n.id,c),f.current.set(n.id,!0)}const m=!!i,u=c!=null&&c>0,p=c!=null&&c===0,y=c!=null&&c===200,x=s.length>0&&s.every(g=>g.providerId==="deco");return{hasDecoKey:m,decoKeyId:i?.id??null,balanceCents:c,balanceDollars:d,hasCredits:u,isZeroBalance:p,isInitialFreeCredit:y,hasOnlyDecoProvider:x,isLoading:o,isFetching:l,refetch:r}}function vt(n){const e=z.c(13),{label:s,value:i,onChange:a,options:o}=n;let r;e[0]!==s?(r=t.jsx("span",{className:"text-sm text-muted-foreground",children:s}),e[0]=s,e[1]=r):r=e[1];let l;e[2]!==a?(l=m=>m&&a(m),e[2]=a,e[3]=l):l=e[3];let c;e[4]!==o?(c=o.map(Bo),e[4]=o,e[5]=c):c=e[5];let d;e[6]!==l||e[7]!==c||e[8]!==i?(d=t.jsx(Ds,{type:"single",size:"sm",value:i,onValueChange:l,className:"gap-0.5 rounded-lg border border-border bg-muted/50 p-0.5",children:c}),e[6]=l,e[7]=c,e[8]=i,e[9]=d):d=e[9];let f;return e[10]!==r||e[11]!==d?(f=t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r,d]}),e[10]=r,e[11]=d,e[12]=f):f=e[12],f}function Bo(n){return t.jsxs(Is,{value:n.value,className:"h-6 gap-1.5 rounded-md border border-transparent px-2 text-xs font-medium text-muted-foreground hover:bg-transparent data-[state=on]:border-border data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm",children:[n.icon,n.label]},n.value)}function Na(n){const e=z.c(91),{panel:s,className:i}=n,a=i===void 0?"md:size-[34px] rounded-lg":i,o=G();let r;e[0]!==o?(r=o("sidebar.taskGroupsList.filterChats"),e[0]=o,e[1]=r):r=e[1];let l;e[2]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx(ks,{size:16}),e[2]=l):l=e[2];let c;e[3]!==s.filtersActive?(c=s.filtersActive&&t.jsx("span",{className:"absolute right-1 top-1 size-1.5 rounded-full bg-primary ring-2 ring-sidebar"}),e[3]=s.filtersActive,e[4]=c):c=e[4];let d;e[5]!==a||e[6]!==s.filtersActive||e[7]!==r||e[8]!==c?(d=t.jsx(Me,{asChild:!0,children:t.jsx(Xe,{asChild:!0,children:t.jsxs(kt,{"aria-label":r,active:s.filtersActive,className:a,children:[l,c]})})}),e[5]=a,e[6]=s.filtersActive,e[7]=r,e[8]=c,e[9]=d):d=e[9];let f;e[10]!==o?(f=o("sidebar.taskGroupsList.filterChats"),e[10]=o,e[11]=f):f=e[11];let m;e[12]!==f?(m=t.jsx(Pe,{side:"bottom",children:f}),e[12]=f,e[13]=m):m=e[13];let u;e[14]!==d||e[15]!==m?(u=t.jsxs(Oe,{children:[d,m]}),e[14]=d,e[15]=m,e[16]=u):u=e[16];let p;e[17]!==o?(p=o("sidebar.taskGroupsList.filterView"),e[17]=o,e[18]=p):p=e[18];const y=s.groupBy;let x;e[19]!==s?(x=W=>{K("tasks_panel_group_by_changed",{to_value:W}),s.setGroupBy(W)},e[19]=s,e[20]=x):x=e[20];let g;e[21]!==o?(g=o("sidebar.taskGroupsList.viewList"),e[21]=o,e[22]=g):g=e[22];let h;e[23]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Fn,{size:13}),e[23]=h):h=e[23];let b;e[24]!==g?(b={value:"flat",label:g,icon:h},e[24]=g,e[25]=b):b=e[25];let j;e[26]!==o?(j=o("sidebar.taskGroupsList.viewStatus"),e[26]=o,e[27]=j):j=e[27];let C;e[28]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(zn,{size:13}),e[28]=C):C=e[28];let w;e[29]!==j?(w={value:"status",label:j,icon:C},e[29]=j,e[30]=w):w=e[30];let I;e[31]!==b||e[32]!==w?(I=[b,w],e[31]=b,e[32]=w,e[33]=I):I=e[33];let M;e[34]!==s.groupBy||e[35]!==x||e[36]!==I||e[37]!==p?(M=t.jsx(vt,{label:p,value:y,onChange:x,options:I}),e[34]=s.groupBy,e[35]=x,e[36]=I,e[37]=p,e[38]=M):M=e[38];let v;e[39]!==o?(v=o("sidebar.taskGroupsList.filterType"),e[39]=o,e[40]=v):v=e[40];const N=s.typeFilter;let A;e[41]!==s?(A=W=>{K("tasks_panel_filter_changed",{to_value:W}),s.setTypeFilter(W)},e[41]=s,e[42]=A):A=e[42];let S;e[43]!==o?(S=o("sidebar.taskGroupsList.typeAll"),e[43]=o,e[44]=S):S=e[44];let _;e[45]!==S?(_={value:"all",label:S},e[45]=S,e[46]=_):_=e[46];let T;e[47]!==o?(T=o("sidebar.taskGroupsList.typeChats"),e[47]=o,e[48]=T):T=e[48];let P;e[49]!==T?(P={value:"manual",label:T},e[49]=T,e[50]=P):P=e[50];let D;e[51]!==o?(D=o("sidebar.taskGroupsList.typeAuto"),e[51]=o,e[52]=D):D=e[52];let F;e[53]!==D?(F={value:"automation",label:D},e[53]=D,e[54]=F):F=e[54];let L;e[55]!==_||e[56]!==P||e[57]!==F?(L=[_,P,F],e[55]=_,e[56]=P,e[57]=F,e[58]=L):L=e[58];let O;e[59]!==s.typeFilter||e[60]!==v||e[61]!==A||e[62]!==L?(O=t.jsx(vt,{label:v,value:N,onChange:A,options:L}),e[59]=s.typeFilter,e[60]=v,e[61]=A,e[62]=L,e[63]=O):O=e[63];let $;e[64]!==o?($=o("sidebar.taskGroupsList.filterScope"),e[64]=o,e[65]=$):$=e[65];const U=s.showAll?"team":"mine";let R;e[66]!==s?(R=W=>s.setShowAll(W==="team"),e[66]=s,e[67]=R):R=e[67];let q;e[68]!==o?(q=o("sidebar.taskGroupsList.scopeMine"),e[68]=o,e[69]=q):q=e[69];let E;e[70]!==q?(E={value:"mine",label:q},e[70]=q,e[71]=E):E=e[71];let Y;e[72]!==o?(Y=o("sidebar.taskGroupsList.scopeTeam"),e[72]=o,e[73]=Y):Y=e[73];let ee;e[74]!==Y?(ee={value:"team",label:Y},e[74]=Y,e[75]=ee):ee=e[75];let te;e[76]!==E||e[77]!==ee?(te=[E,ee],e[76]=E,e[77]=ee,e[78]=te):te=e[78];let H;e[79]!==$||e[80]!==U||e[81]!==R||e[82]!==te?(H=t.jsx(vt,{label:$,value:U,onChange:R,options:te}),e[79]=$,e[80]=U,e[81]=R,e[82]=te,e[83]=H):H=e[83];let J;e[84]!==M||e[85]!==O||e[86]!==H?(J=t.jsxs(Nt,{align:"start",className:"w-64 flex flex-col gap-3 p-3",children:[M,O,H]}),e[84]=M,e[85]=O,e[86]=H,e[87]=J):J=e[87];let ne;return e[88]!==J||e[89]!==u?(ne=t.jsxs(St,{children:[u,J]}),e[88]=J,e[89]=u,e[90]=ne):ne=e[90],ne}function Eo(n){const e=z.c(9),{virtualMcpId:s,size:i,showAutomationBadge:a}=n,o=i===void 0?"sm":i,r=G();let l;e[0]!==o||e[1]!==s?(l=s?t.jsx(Ro,{virtualMcpId:s,size:o}):t.jsx(qe,{icon:null,name:"?",size:o}),e[0]=o,e[1]=s,e[2]=l):l=e[2];let c;e[3]!==a||e[4]!==r?(c=a&&t.jsx("span",{"aria-label":r("tasksPanel.mcpAvatar.automationTriggered"),className:"absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-full bg-blue-500 border border-blue-600 text-white",children:t.jsx(cn,{size:10,className:"text-white"})}),e[3]=a,e[4]=r,e[5]=c):c=e[5];let d;return e[6]!==l||e[7]!==c?(d=t.jsxs("div",{className:"relative shrink-0",children:[l,c]}),e[6]=l,e[7]=c,e[8]=d):d=e[8],d}function Ro(n){const e=z.c(6),{virtualMcpId:s,size:i}=n,a=wt(s);if(!a){let l;return e[0]!==i?(l=t.jsx(qe,{icon:null,name:"?",size:i}),e[0]=i,e[1]=l):l=e[1],l}const o=a.icon??null;let r;return e[2]!==a.title||e[3]!==i||e[4]!==o?(r=t.jsx(qe,{icon:o,name:a.title,size:i}),e[2]=a.title,e[3]=i,e[4]=o,e[5]=r):r=e[5],r}function Go(n){const e=z.c(51),{open:s,onOpenChange:i}=n,[a,o]=V.useState(""),{org:r}=le(),{setTaskId:l}=ft(),c=ct(),d=G();let f,m,u;e[0]!==r.id||e[1]!==a?(u=a.trim(),m=He,f=Ue.globalSearch(r.id,u),e[0]=r.id,e[1]=a,e[2]=f,e[3]=m,e[4]=u):(f=e[2],m=e[3],u=e[4]);let p;e[5]!==c||e[6]!==u?(p=async()=>await c.call("GLOBAL_SEARCH",{query:u,limit:u?20:10}),e[5]=c,e[6]=u,e[7]=p):p=e[7];let y;e[8]!==s||e[9]!==f||e[10]!==p?(y={queryKey:f,enabled:s,queryFn:p,staleTime:1e4},e[8]=s,e[9]=f,e[10]=p,e[11]=y):y=e[11];const{data:x,isFetching:g}=m(y);let h;e[12]!==x?.items?(h=x?.items??[],e[12]=x?.items,e[13]=h):h=e[13];const b=h;let j;e[14]!==i?(j=O=>{O||o(""),i(O)},e[14]=i,e[15]=j):j=e[15];const C=j;let w;e[16]!==C||e[17]!==l?(w=O=>{C(!1),l(O.id,O.virtual_mcp_id??void 0)},e[16]=C,e[17]=l,e[18]=w):w=e[18];const I=w;let M;e[19]!==d?(M=d("tasksPanel.globalSearchDialog.title"),e[19]=d,e[20]=M):M=e[20];let v;e[21]!==M?(v=t.jsx(Tt,{children:M}),e[21]=M,e[22]=v):v=e[22];let N;e[23]!==d?(N=d("tasksPanel.globalSearchDialog.description"),e[23]=d,e[24]=N):N=e[24];let A;e[25]!==N?(A=t.jsx(rn,{children:N}),e[25]=N,e[26]=A):A=e[26];let S;e[27]!==A||e[28]!==v?(S=t.jsxs(At,{className:"sr-only",children:[v,A]}),e[27]=A,e[28]=v,e[29]=S):S=e[29];let _;e[30]!==d?(_=d("tasksPanel.globalSearchDialog.placeholder"),e[30]=d,e[31]=_):_=e[31];let T;e[32]!==a||e[33]!==_?(T=t.jsx(Os,{value:a,onValueChange:o,placeholder:_}),e[32]=a,e[33]=_,e[34]=T):T=e[34];let P;e[35]!==I||e[36]!==g||e[37]!==b||e[38]!==d||e[39]!==u?(P=t.jsx(As,{children:g&&b.length===0?t.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:d("tasksPanel.globalSearchDialog.searching")}):b.length===0?t.jsx(Ts,{children:d("tasksPanel.globalSearchDialog.noResults")}):t.jsx(Ms,{heading:u?void 0:d("tasksPanel.globalSearchDialog.recent"),children:b.map(O=>O.type==="thread"?t.jsxs(Ps,{value:`thread:${O.id}:${O.title}`,onSelect:()=>I(O),className:"gap-2.5",children:[t.jsx(Eo,{virtualMcpId:O.virtual_mcp_id,size:"xs"}),t.jsx("div",{className:"flex-1 min-w-0",children:t.jsx("div",{className:"text-sm text-foreground truncate",children:O.title||d("tasksPanel.globalSearchDialog.untitledChat")})}),t.jsx("span",{className:"text-xs text-muted-foreground shrink-0",children:new Date(O.updated_at).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]},`thread:${O.id}`):null)})}),e[35]=I,e[36]=g,e[37]=b,e[38]=d,e[39]=u,e[40]=P):P=e[40];let D;e[41]!==T||e[42]!==P?(D=t.jsxs(Fs,{shouldFilter:!1,className:"[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:[T,P]}),e[41]=T,e[42]=P,e[43]=D):D=e[43];let F;e[44]!==S||e[45]!==D?(F=t.jsxs(Dt,{className:"overflow-hidden p-0",closeButtonClassName:"hidden",children:[S,D]}),e[44]=S,e[45]=D,e[46]=F):F=e[46];let L;return e[47]!==C||e[48]!==s||e[49]!==F?(L=t.jsx(It,{open:s,onOpenChange:C,children:F}),e[47]=C,e[48]=s,e[49]=F,e[50]=L):L=e[50],L}function Ho(n){const e=z.c(43),{branch:s,onOutcome:i}=n,a=G();let o;e[0]!==i?(o=M=>{M||i("cancel")},e[0]=i,e[1]=o):o=e[1];let r;e[2]!==a?(r=a("sidebar.archiveWorktreeDialog.title"),e[2]=a,e[3]=r):r=e[3];let l;e[4]!==r?(l=t.jsx(zs,{children:r}),e[4]=r,e[5]=l):l=e[5];let c;e[6]!==a?(c=a("sidebar.archiveWorktreeDialog.stopsAndDeletesBefore"),e[6]=a,e[7]=c):c=e[7];let d;e[8]!==s?(d=t.jsx("span",{className:"font-mono",children:s}),e[8]=s,e[9]=d):d=e[9];let f;e[10]!==a?(f=a("sidebar.archiveWorktreeDialog.stopsAndDeletesAfter"),e[10]=a,e[11]=f):f=e[11];let m;e[12]!==c||e[13]!==d||e[14]!==f?(m=t.jsxs($s,{children:[c," ",d," ",f]}),e[12]=c,e[13]=d,e[14]=f,e[15]=m):m=e[15];let u;e[16]!==l||e[17]!==m?(u=t.jsxs(Ls,{children:[l,m]}),e[16]=l,e[17]=m,e[18]=u):u=e[18];let p;e[19]!==i?(p=()=>i("cancel"),e[19]=i,e[20]=p):p=e[20];let y;e[21]!==a?(y=a("sidebar.archiveWorktreeDialog.cancel"),e[21]=a,e[22]=y):y=e[22];let x;e[23]!==y||e[24]!==p?(x=t.jsx(Bs,{onClick:p,children:y}),e[23]=y,e[24]=p,e[25]=x):x=e[25];let g;e[26]===Symbol.for("react.memo_cache_sentinel")?(g=Q(Dn({variant:"destructive"})),e[26]=g):g=e[26];let h;e[27]!==i?(h=()=>i("confirm"),e[27]=i,e[28]=h):h=e[28];let b;e[29]!==a?(b=a("sidebar.archiveWorktreeDialog.confirm"),e[29]=a,e[30]=b):b=e[30];let j;e[31]!==h||e[32]!==b?(j=t.jsx(Es,{className:g,onClick:h,children:b}),e[31]=h,e[32]=b,e[33]=j):j=e[33];let C;e[34]!==x||e[35]!==j?(C=t.jsxs(Rs,{children:[x,j]}),e[34]=x,e[35]=j,e[36]=C):C=e[36];let w;e[37]!==C||e[38]!==u?(w=t.jsxs(Gs,{children:[u,C]}),e[37]=C,e[38]=u,e[39]=w):w=e[39];let I;return e[40]!==o||e[41]!==w?(I=t.jsx(Hs,{open:!0,onOpenChange:o,children:w}),e[40]=o,e[41]=w,e[42]=I):I=e[42],I}function Vo(n,e,s){if(!s)return;const i=n.findIndex(a=>a.id===e);if(i!==-1){for(let a=i+1;a<n.length;a++){const o=n[a];if(o?.created_by===s)return o}for(let a=i-1;a>=0;a--){const o=n[a];if(o?.created_by===s)return o}}}function Uo(n){return n==="ephemeral"||n.startsWith("thread:")}function fn(n){const e=z.c(45),{task:s,isActive:i,onClick:a,onArchive:o,showAutomationBadge:r,showAgentIcon:l,hideStatusIdle:c,indented:d}=n,f=G(),m=Us(s.status),u=m.icon,p=s.metadata?.kind==="tool_call_run",y=wt(p?void 0:s.virtual_mcp_id);let x;e[0]!==y?(x=ns(y),e[0]=y,e[1]=x):x=e[1];const g=x;qs(6e4);const h=r||!!s.trigger_id,b=s.id,j="button",C=0;let w;e[2]!==a?(w=R=>{R.target===R.currentTarget&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),a())},e[2]=a,e[3]=w):w=e[3];const I=d?"-ml-4 pl-6":"pl-[7px]",M=i?"bg-accent text-accent-foreground":"hover:bg-accent/60";let v;e[4]!==I||e[5]!==M?(v=Q("group/row flex items-center gap-2 py-1.5 rounded-md cursor-pointer transition-colors",I,"focus-visible:outline-none focus-visible:inset-ring-2 focus-visible:inset-ring-ring/50",M),e[4]=I,e[5]=M,e[6]=v):v=e[6];let N;e[7]!==p||e[8]!==l||e[9]!==y?.icon||e[10]!==y?.title?(N=l&&!p&&t.jsx(qe,{icon:y?.icon??null,name:y?.title??"?",size:"2xs"}),e[7]=p,e[8]=l,e[9]=y?.icon,e[10]=y?.title,e[11]=N):N=e[11];let A;e[12]!==h||e[13]!==f?(A=h&&t.jsx(cn,{size:12,"aria-label":f("tasksPanel.taskRow.automationTriggered"),className:"shrink-0 text-blue-500"}),e[12]=h,e[13]=f,e[14]=A):A=e[14];let S;e[15]!==f||e[16]!==s.title?(S=s.title||f("tasksPanel.taskRow.untitledTask"),e[15]=f,e[16]=s.title,e[17]=S):S=e[17];let _;e[18]!==S?(_=t.jsx("div",{className:"text-sm text-foreground truncate",children:S}),e[18]=S,e[19]=_):_=e[19];let T;e[20]!==A||e[21]!==_?(T=t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[A,_]}),e[20]=A,e[21]=_,e[22]=T):T=e[22];let P;e[23]!==g||e[24]!==i||e[25]!==s.branch||e[26]!==s.updated_at?(P=s.updated_at&&t.jsxs("div",{className:Q("flex items-center gap-1 text-[11px] min-w-0",i?"text-accent-foreground/70":"text-muted-foreground/60"),children:[s.branch&&!Uo(s.branch)?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"truncate font-mono",children:s.branch}),t.jsx("span",{className:"shrink-0",children:"·"})]}):g?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"truncate",children:[g.owner,"/",g.name]}),t.jsx("span",{className:"shrink-0",children:"·"})]}):null,t.jsx("span",{className:"shrink-0",children:Ws(new Date(s.updated_at))})]}),e[23]=g,e[24]=i,e[25]=s.branch,e[26]=s.updated_at,e[27]=P):P=e[27];let D;e[28]!==T||e[29]!==P?(D=t.jsxs("div",{className:"flex-1 min-w-0",children:[T,P]}),e[28]=T,e[29]=P,e[30]=D):D=e[30];const F="shrink-0 grid [grid-template-areas:'slot'] items-center justify-items-center",L=!c&&t.jsx("span",{className:Q("[grid-area:slot] flex size-8 items-center justify-center pointer-events-none transition-opacity",o&&"group-hover/row:opacity-0"),"aria-label":f("tasksPanel.taskRow.statusLabel",{status:m.label}),children:t.jsx(u,{size:14,className:Q(m.iconClassName,s.status==="in_progress"&&"animate-spin")})});let O;e[31]!==o||e[32]!==f?(O=o&&t.jsxs(Oe,{children:[t.jsx(Me,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":f("tasksPanel.taskRow.archiveTask"),onClick:R=>{R.stopPropagation(),o()},className:"[grid-area:slot] opacity-0 pointer-events-none group-hover/row:opacity-100 group-hover/row:pointer-events-auto focus-visible:opacity-100 focus-visible:pointer-events-auto transition-opacity flex size-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50",children:t.jsx(An,{size:14})})}),t.jsx(Pe,{side:"right",children:f("tasksPanel.taskRow.archive")})]}),e[31]=o,e[32]=f,e[33]=O):O=e[33];let $;e[34]!==L||e[35]!==O?($=t.jsxs("div",{className:F,children:[L,O]}),e[34]=L,e[35]=O,e[36]=$):$=e[36];let U;return e[37]!==a||e[38]!==D||e[39]!==$||e[40]!==w||e[41]!==v||e[42]!==N||e[43]!==s.id?(U=t.jsxs("div",{"data-task-id":b,role:j,tabIndex:C,onClick:a,onKeyDown:w,className:v,children:[N,D,$]}),e[37]=a,e[38]=D,e[39]=$,e[40]=w,e[41]=v,e[42]=N,e[43]=s.id,e[44]=U):U=e[44],U}const Bt=["requires_action","in_progress","failed","expired","completed"];function qo(n){const e=new Map(Bt.map(s=>[s,[]]));for(const s of n){const i=s.status??"completed";(e.get(i)??e.get("completed")).push(s)}return Bt.map(s=>({status:s,threads:e.get(s)}))}const Ko="sidebar.group.expanded.";function Wo(n,e){const s=z.c(3),[i,a]=Ct(`${Ko}${n}`,e);let o;return s[0]!==i||s[1]!==a?(o=[i,a],s[0]=i,s[1]=a,s[2]=o):o=s[2],o}function mn(n){const e=z.c(18),{onClick:s,isFetching:i,indented:a}=n,o=G();let r;e[0]!==o?(r=o("sidebar.showMoreButton.ariaLabel"),e[0]=o,e[1]=r):r=e[1];const l=a?"-ml-4 pl-6 pr-2":"px-2";let c;e[2]!==l?(c=Q("flex items-center gap-2 py-1.5 rounded-md text-sm text-muted-foreground",l,"hover:bg-accent/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50","transition-colors disabled:cursor-progress disabled:opacity-60"),e[2]=l,e[3]=c):c=e[3];let d;e[4]!==i?(d=i&&t.jsx(Ve,{size:14,className:"animate-spin"}),e[4]=i,e[5]=d):d=e[5];let f;e[6]!==i||e[7]!==o?(f=o(i?"sidebar.showMoreButton.loading":"sidebar.showMoreButton.showMore"),e[6]=i,e[7]=o,e[8]=f):f=e[8];let m;e[9]!==f?(m=t.jsx("span",{children:f}),e[9]=f,e[10]=m):m=e[10];let u;return e[11]!==i||e[12]!==s||e[13]!==r||e[14]!==c||e[15]!==d||e[16]!==m?(u=t.jsxs("button",{type:"button","aria-label":r,onClick:s,disabled:i,className:c,children:[d,m]}),e[11]=i,e[12]=s,e[13]=r,e[14]=c,e[15]=d,e[16]=m,e[17]=u):u=e[17],u}function Qo(n,e,s,i){return[n,e,s,i.type,i.member,i.currentUserId??""].join("|")}function Xo(n){return n.member==="mine"&&!n.currentUserId}const gn=4;let nt=0;const yt=[];function Yo(){for(;nt<gn&&yt.length>0;){const n=yt.shift();n&&n()}}function hn(n){return new Promise((e,s)=>{const i=()=>{nt++,n().then(e,s).finally(()=>{nt--,Yo()})};nt<gn?i():yt.push(i)})}const mt=10;function Et(n,e,s,i,a){const o={hidden:!1};i.member==="mine"&&i.currentUserId&&(o.created_by=i.currentUserId),i.type==="automation"&&(o.has_trigger=!0),i.type==="manual"&&(o.has_trigger=!1);const r={where:o,limit:a,offset:s,orderBy:[{field:["updated_at"],direction:"desc"}]};return r.status=e,r}function Jo(n,e,s,i){let a=0;for(const o of n)pn(o,e,s,i)&&a++;return a}function jt(n,e,s,i){return Jo(n,e,s,i)}function Zo(n,e){return!!(n>=mt||n===0&&e)}function Rt(n,e){return n<e}function ei(n,e){return e===!1?!1:e===!0?!0:n}function pn(n,e,s,i){return!(n.hidden||(n.status??"completed")!==s||i.member==="mine"&&i.currentUserId&&n.created_by!==i.currentUserId||i.type==="automation"&&!n.trigger_id||i.type==="manual"&&n.trigger_id)}const it=new Map,et=new Map;function ti(n,e){return e?n>=mt?!0:null:!1}function Gt(n){return it.get(n)}function ni(n,e){it.set(n,e)}function si(n,e,s){const i=it.get(n);if(i!==void 0){s(i);return}let a=et.get(n);a||(a=hn(e).then(o=>(it.set(n,o),et.delete(n),o)).catch(()=>(et.delete(n),Promise.reject(new Error("group probe failed")))),et.set(n,a)),a.then(s,()=>s(!1))}function Ht(n){const e=n,s=Array.isArray(e.items)?e.items:[];return{items:s,hasMore:e.hasMore??s.length===mt,totalCount:typeof e.totalCount=="number"?e.totalCount:void 0}}function oi(n,e,s,i,a){let o=0;for(const r of n)e.has(r.id)||pn(r,s,i,a)&&o++;return o}function ii(n,e,s,i){const a=z.c(8),{org:o}=le(),r=Qo(o.id,n,e,s);let l;a[0]!==s?(l=Xo(s),a[0]=s,a[1]=l):l=a[1];const c=l,[d,f]=V.useState({isFetching:!1,isProbing:!1,identity:r,probeSubscribedIdentity:null,serverHasMore:null});d.identity!==r&&f({isFetching:!1,isProbing:!1,identity:r,probeSubscribedIdentity:null,serverHasMore:null});const m=Xn(),{threads:u,hasMore:p}=ut(),y=jt(u,n,e,s),x=Zo(y,p),g=ti(y,p),h=ct();if(d.identity===r&&d.serverHasMore===null){const M=g??Gt(r);M!==void 0&&f({isFetching:!1,isProbing:!1,identity:r,probeSubscribedIdentity:d.probeSubscribedIdentity,serverHasMore:M})}!c&&d.identity===r&&d.serverHasMore===null&&g===null&&Gt(r)===void 0&&d.probeSubscribedIdentity!==r&&(f(M=>M.identity===r?{...M,isProbing:!0,probeSubscribedIdentity:r}:M),si(r,async()=>{const M=Et(n,e,0,s,1),v=await h.call("COLLECTION_THREADS_LIST",M),{totalCount:N}=Ht(v),A=jt(m.threads.get(),n,e,s);return N===void 0?!1:Rt(A,N)},M=>{f(v=>v.identity!==r?v:{...v,isProbing:!1,serverHasMore:M})}));const j=async function(){if(d.isFetching||d.isProbing||c)return;const v=r;f(N=>N.identity===v?{...N,isFetching:!0}:N);try{const N=jt(u,n,e,s),A=Et(n,e,N,s,mt),S=await hn(()=>h.call("COLLECTION_THREADS_LIST",A)),{items:_,hasMore:T,totalCount:P}=Ht(S),D=new Set(u.map(ai)),F=oi(_,D,n,e,s),L=N;m.mergeThreads(_),f(O=>{if(O.identity!==v)return O;let $;return P!==void 0?$=Rt(L+F,P):$=_.length===0||F===0?!1:T,ni(v,$),{...O,isFetching:!1,serverHasMore:$}})}catch(N){const A=N,S=A instanceof Error?A.message:String(A);X.error(`Could not load more tasks: ${S}`),f(_=>_.identity===v?{..._,isFetching:!1}:_)}},C=d.isFetching||d.isProbing,w=!c&&!C&&ei(x,d.serverHasMore);let I;return a[2]!==C||a[3]!==j||a[4]!==w||a[5]!==d.isProbing||a[6]!==d.serverHasMore?(I={hasMore:w,isFetching:C,isProbing:d.isProbing,serverHasMore:d.serverHasMore,loadMore:j},a[2]=C,a[3]=j,a[4]=w,a[5]=d.isProbing,a[6]=d.serverHasMore,a[7]=I):I=a[7],I}function ai(n){return n.id}function ri(n){const e=z.c(20),{status:s,threads:i,activeTaskId:a,onSelectTask:o,onArchiveTask:r,canArchive:l,filters:c}=n,{isFetching:d,isProbing:f,loadMore:m,hasMore:u,serverHasMore:p}=ii("status",s,c),[y,x]=V.useState(!1);!y&&i.length===0&&p===!0&&!d&&!f&&(x(!0),queueMicrotask(()=>{m()}));let g;if(e[0]!==a||e[1]!==l||e[2]!==c||e[3]!==r||e[4]!==o||e[5]!==i){let j;e[7]!==a||e[8]!==l||e[9]!==c||e[10]!==r||e[11]!==o?(j=C=>t.jsx(fn,{task:C,isActive:a===C.id,onClick:()=>o(C),onArchive:l&&C.created_by===c.currentUserId?()=>r(C):void 0,showAutomationBadge:!!C.trigger_id,showAgentIcon:!0,hideStatusIdle:!0,indented:!0},C.id),e[7]=a,e[8]=l,e[9]=c,e[10]=r,e[11]=o,e[12]=j):j=e[12],g=i.map(j),e[0]=a,e[1]=l,e[2]=c,e[3]=r,e[4]=o,e[5]=i,e[6]=g}else g=e[6];let h;e[13]!==u||e[14]!==d||e[15]!==m?(h=(u||d)&&t.jsx(mn,{onClick:()=>{m()},isFetching:d,indented:!0}),e[13]=u,e[14]=d,e[15]=m,e[16]=h):h=e[16];let b;return e[17]!==g||e[18]!==h?(b=t.jsxs(t.Fragment,{children:[g,h]}),e[17]=g,e[18]=h,e[19]=b):b=e[19],b}function li(n){const e=z.c(36),{status:s,threads:i,activeTaskId:a,onSelectTask:o,onArchiveTask:r,canArchive:l,filters:c}=n,d=Ks[s],f=d.icon,[m,u]=Wo(`status-${s}`,!1);let p;e[0]!==m||e[1]!==u?(p=function(){u(!m)},e[0]=m,e[1]=u,e[2]=p):p=e[2];const y=p;let x;e[3]!==y?(x=v=>{v.target===v.currentTarget&&(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),y())},e[3]=y,e[4]=x):x=e[4];let g;e[5]!==f||e[6]!==d.iconClassName?(g=t.jsx("span",{className:"absolute inset-0 flex items-center justify-center transition-opacity group-hover/group:opacity-0",children:t.jsx(f,{size:12,className:d.iconClassName})}),e[5]=f,e[6]=d.iconClassName,e[7]=g):g=e[7];let h;e[8]!==m?(h=t.jsx("span",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground opacity-0 transition-opacity group-hover/group:opacity-100",children:m?t.jsx(_t,{size:14}):t.jsx(Wt,{size:14})}),e[8]=m,e[9]=h):h=e[9];let b;e[10]!==g||e[11]!==h?(b=t.jsxs("div",{className:"relative size-5 shrink-0 flex items-center justify-center",children:[g,h]}),e[10]=g,e[11]=h,e[12]=b):b=e[12];let j;e[13]!==d.label?(j=t.jsx("span",{className:"flex-1 truncate",children:d.label}),e[13]=d.label,e[14]=j):j=e[14];let C;e[15]!==i.length?(C=t.jsx("div",{className:"size-5 shrink-0 flex items-center justify-center",children:t.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:i.length})}),e[15]=i.length,e[16]=C):C=e[16];let w;e[17]!==m||e[18]!==y||e[19]!==x||e[20]!==b||e[21]!==j||e[22]!==C?(w=t.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":m,onClick:y,onKeyDown:x,className:"group/group flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-medium text-foreground cursor-pointer hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 transition-colors",children:[b,j,C]}),e[17]=m,e[18]=y,e[19]=x,e[20]=b,e[21]=j,e[22]=C,e[23]=w):w=e[23];let I;e[24]!==a||e[25]!==l||e[26]!==m||e[27]!==c||e[28]!==r||e[29]!==o||e[30]!==s||e[31]!==i?(I=m&&t.jsx("div",{className:"flex flex-col gap-0.5 pb-1 pl-4",children:t.jsx(ri,{status:s,threads:i,activeTaskId:a,onSelectTask:o,onArchiveTask:r,canArchive:l,filters:c})}),e[24]=a,e[25]=l,e[26]=m,e[27]=c,e[28]=r,e[29]=o,e[30]=s,e[31]=i,e[32]=I):I=e[32];let M;return e[33]!==w||e[34]!==I?(M=t.jsxs("div",{className:"flex flex-col gap-0.5",children:[w,I]}),e[33]=w,e[34]=I,e[35]=M):M=e[35],M}function ci(n){const e=z.c(38),{threads:s,groupBy:i,activeTaskId:a,onSelectTask:o,onArchiveTask:r,filters:l,hasMore:c,isFetchingMore:d,onLoadMore:f,filtersActive:m}=n;if(s.length===0&&!c&&!d){let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Vs,{className:"size-6 opacity-60"}),e[0]=g):g=e[0];const h=m?"No chats match your filters":"No chats yet";let b;return e[1]!==h?(b=t.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 px-4 py-12 text-center text-muted-foreground",children:[g,t.jsx("p",{className:"text-sm",children:h})]}),e[1]=h,e[2]=b):b=e[2],b}const u=s.length>1||c;if(i==="status"){let g;if(e[3]!==a||e[4]!==u||e[5]!==l||e[6]!==r||e[7]!==o||e[8]!==s){let b;e[10]!==a||e[11]!==u||e[12]!==l||e[13]!==r||e[14]!==o?(b=j=>t.jsx(li,{status:j.status,threads:j.threads,activeTaskId:a,onSelectTask:o,onArchiveTask:r,canArchive:u,filters:l},j.status),e[10]=a,e[11]=u,e[12]=l,e[13]=r,e[14]=o,e[15]=b):b=e[15],g=qo(s).map(b),e[3]=a,e[4]=u,e[5]=l,e[6]=r,e[7]=o,e[8]=s,e[9]=g}else g=e[9];let h;return e[16]!==g?(h=t.jsx(t.Fragment,{children:g}),e[16]=g,e[17]=h):h=e[17],h}let p;if(e[18]!==a||e[19]!==u||e[20]!==l||e[21]!==r||e[22]!==o||e[23]!==s){let g;e[25]!==a||e[26]!==u||e[27]!==l||e[28]!==r||e[29]!==o?(g=h=>t.jsx(fn,{task:h,isActive:a===h.id,onClick:()=>o(h),onArchive:u&&h.created_by===l.currentUserId?()=>r(h):void 0,showAutomationBadge:!!h.trigger_id,showAgentIcon:!0},h.id),e[25]=a,e[26]=u,e[27]=l,e[28]=r,e[29]=o,e[30]=g):g=e[30],p=s.map(g),e[18]=a,e[19]=u,e[20]=l,e[21]=r,e[22]=o,e[23]=s,e[24]=p}else p=e[24];let y;e[31]!==c||e[32]!==d||e[33]!==f?(y=(c||d)&&t.jsx(mn,{onClick:f,isFetching:d}),e[31]=c,e[32]=d,e[33]=f,e[34]=y):y=e[34];let x;return e[35]!==p||e[36]!==y?(x=t.jsxs(t.Fragment,{children:[p,y]}),e[35]=p,e[36]=y,e[37]=x):x=e[37],x}function di(n,e){return null}function ui(n,e){return n.some(s=>s.id!==e.taskId&&!s.hidden&&s.branch===e.branch&&s.virtual_mcp_id===e.virtualMcpId)}const fi=["archive","reclaim-worktree"],mi=[];function gi(n){return n==="confirm"?fi:mi}function Sa(n){const e=z.c(11),{panel:s}=n;let i;return e[0]!==s.activeTaskId||e[1]!==s.archiveTask||e[2]!==s.filters||e[3]!==s.filtersActive||e[4]!==s.groupBy||e[5]!==s.hasMore||e[6]!==s.isFetchingMore||e[7]!==s.loadMore||e[8]!==s.selectTask||e[9]!==s.threads?(i=t.jsx(ci,{threads:s.threads,groupBy:s.groupBy,activeTaskId:s.activeTaskId,onSelectTask:s.selectTask,onArchiveTask:s.archiveTask,filters:s.filters,hasMore:s.hasMore,isFetchingMore:s.isFetchingMore,onLoadMore:s.loadMore,filtersActive:s.filtersActive}),e[0]=s.activeTaskId,e[1]=s.archiveTask,e[2]=s.filters,e[3]=s.filtersActive,e[4]=s.groupBy,e[5]=s.hasMore,e[6]=s.isFetchingMore,e[7]=s.loadMore,e[8]=s.selectTask,e[9]=s.threads,e[10]=i):i=e[10],i}function ka(n){const e=z.c(82);let s;e[0]!==n?(s=n===void 0?{}:n,e[0]=n,e[1]=s):s=e[1];const{onNavigate:i}=s,a=G(),{data:o}=Te.useSession(),r=o?.user?.id,{org:l}=le();let c;e[2]!==l.id?(c=dt(l.id),e[2]=l.id,e[3]=c):c=e[3];const d=c.id,{threads:f,hasMore:m,isFetchingMore:u,fetchNextPage:p}=ut(),y=f.filter(bi),{hide:x,setScope:g}=nn(),h=at(),b=ct(),{setTaskId:j,createNewTask:C}=ft();let w;e[4]===Symbol.for("react.memo_cache_sentinel")?(w={strict:!1},e[4]=w):w=e[4];const I=rt(w);let M;e[5]===Symbol.for("react.memo_cache_sentinel")?(M={strict:!1},e[5]=M):M=e[5];const v=lt(M),N=I.taskId??null;let A;e[6]!==N||e[7]!==f||e[8]!==v.virtualmcpid?(A=v.virtualmcpid??f.find(k=>k.id===N)?.virtual_mcp_id??null,e[6]=N,e[7]=f,e[8]=v.virtualmcpid,e[9]=A):A=e[9];const S=A;let _;e[10]!==i?(_=()=>{i?.()},e[10]=i,e[11]=_):_=e[11];const T=_,P=[...y].sort(xi),[D,F]=V.useState("all"),[L,O]=V.useState("flat"),[$,U]=Ct("sidebar-threads-scope-all",!1),[R,q]=V.useState(!1),[E,Y]=V.useState(!1);let ee;e[12]!==q?(ee=()=>{K("tasks_panel_search_opened"),Y(!0),q(!0)},e[12]=q,e[13]=ee):ee=e[13];const te=ee,[H,J]=V.useState(null),ne=r??null;let W;e[14]!==ne||e[15]!==D?(W={type:D,member:"mine",currentUserId:ne},e[14]=ne,e[15]=D,e[16]=W):W=e[16];const Ne=W,Be={};$||(Be.created_by="me"),g(Be);let Ce;e[17]!==r?(Ce=k=>r?k.filter(B=>B.created_by===r):[],e[17]=r,e[18]=Ce):Ce=e[18];const Ee=Ce;let _e;e[19]!==D?(_e=k=>D==="automation"?k.filter(pi):D==="manual"?k.filter(hi):k,e[19]=D,e[20]=_e):_e=e[20];const We=_e,se=We($?P:Ee(P));let Se;e[21]!==N||e[22]!==T||e[23]!==r||e[24]!==x||e[25]!==h||e[26]!==l.slug||e[27]!==j||e[28]!==se?(Se=k=>{const B=k.id===N,Z=x(k.id);if(ss(k.id),!B)return Z;const ue=Vo(se,k.id,r);return T(),ue?j(ue.id,ue.virtual_mcp_id):h({to:"/$org",params:{org:l.slug}}),Z},e[21]=N,e[22]=T,e[23]=r,e[24]=x,e[25]=h,e[26]=l.slug,e[27]=j,e[28]=se,e[29]=Se):Se=e[29];const oe=Se;let Re;e[30]!==b||e[31]!==a?(Re=async k=>{try{await b.call("SANDBOX_DELETE",{virtualMcpId:k.virtualMcpId,branch:k.branch,sandboxProviderKind:"user-desktop",removeWorktree:!0})}catch{X.error(a("sidebar.archiveWorktreeDialog.reclaimFailed",{branch:k.branch}))}},e[30]=b,e[31]=a,e[32]=Re):Re=e[32];const ke=Re;let Ie;e[33]!==f||e[34]!==oe||e[35]!==r||e[36]!==J?(Ie=k=>{if(r&&k.created_by&&k.created_by!==r)return;const B=di();if(!B||ui(f,B)){oe(k);return}J({task:k,target:B})},e[33]=f,e[34]=oe,e[35]=r,e[36]=J,e[37]=Ie):Ie=e[37];const fe=Ie;let de;e[38]!==oe||e[39]!==H||e[40]!==ke||e[41]!==J?(de=k=>{const B=H;B&&(J(null),(async()=>{for(const Z of gi(k))if(Z==="archive")try{await oe(B.task)}catch{return}else await ke(B.target)})())},e[38]=oe,e[39]=H,e[40]=ke,e[41]=J,e[42]=de):de=e[42];const Fe=de;let De;e[43]!==T||e[44]!==j?(De=k=>{T(),j(k.id,k.virtual_mcp_id)},e[43]=T,e[44]=j,e[45]=De):De=e[45];const ze=De;let Ae;e[46]!==S||e[47]!==N||e[48]!==f||e[49]!==T||e[50]!==C||e[51]!==d?(Ae=()=>{const k=S??d,B=f.find(Z=>Z.id===N)?.branch??null;K("sidebar_new_thread_clicked",{virtual_mcp_id:k}),T(),C(k,B)},e[46]=S,e[47]=N,e[48]=f,e[49]=T,e[50]=C,e[51]=d,e[52]=Ae):Ae=e[52];const me=Ae;let ie;e[53]!==p?(ie=()=>{p()},e[53]=p,e[54]=ie):ie=e[54];const ge=L!=="flat"||D!=="all"||$;let ae;e[55]!==Fe||e[56]!==H?(ae=H?t.jsx(Ho,{branch:H.target.branch,onOutcome:Fe}):null,e[55]=Fe,e[56]=H,e[57]=ae):ae=e[57];let re;e[58]!==E||e[59]!==R||e[60]!==q?(re=E?t.jsx(Go,{open:R,onOpenChange:q}):null,e[58]=E,e[59]=R,e[60]=q,e[61]=re):re=e[61];let we;return e[62]!==N||e[63]!==fe||e[64]!==Ne||e[65]!==L||e[66]!==m||e[67]!==u||e[68]!==me||e[69]!==te||e[70]!==ze||e[71]!==O||e[72]!==U||e[73]!==F||e[74]!==$||e[75]!==ie||e[76]!==ge||e[77]!==ae||e[78]!==re||e[79]!==D||e[80]!==se?(we={threads:se,activeTaskId:N,filters:Ne,hasMore:m,isFetchingMore:u,loadMore:ie,groupBy:L,setGroupBy:O,typeFilter:D,setTypeFilter:F,showAll:$,setShowAll:U,filtersActive:ge,selectTask:ze,archiveTask:fe,newThread:me,openSearch:te,reclaimDialog:ae,searchDialog:re},e[62]=N,e[63]=fe,e[64]=Ne,e[65]=L,e[66]=m,e[67]=u,e[68]=me,e[69]=te,e[70]=ze,e[71]=O,e[72]=U,e[73]=F,e[74]=$,e[75]=ie,e[76]=ge,e[77]=ae,e[78]=re,e[79]=D,e[80]=se,e[81]=we):we=e[81],we}function hi(n){return!n.trigger_id}function pi(n){return!!n.trigger_id}function xi(n,e){return(e.updated_at??"").localeCompare(n.updated_at??"")}function bi(n){return!n.hidden}function vi(n){return n?n.run_in_progress?"generating":n.scanned_at?"ready":"none":"none"}const ji=2e4;function yi(n){if(typeof n!="string"||!n)return null;try{return new URL(n).hostname||null}catch{return null}}function Ia(){const n=z.c(17),{org:e}=le(),s=Bn.COMMERCE_DISCOVERY(e.id);let i;n[0]!==e.id||n[1]!==e.slug?(i=$t({connectionId:Qt,orgId:e.id,orgSlug:e.slug}),n[0]=e.id,n[1]=e.slug,n[2]=i):i=n[2];const{data:a}=He(i),r=He({queryKey:Ue.commerceDiscoveryConnection(e.id,s),enabled:!!a,retry:!1,staleTime:6e4,queryFn:async()=>{if(!a)throw new Error("selfClient not ready");const j=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:s}});return Pt(j)}}).data?.item??null,{data:l}=He({...$t({connectionId:s,orgId:e.id,orgSlug:e.slug}),enabled:!!r}),c=Ue.commerceDiscoveryDiagnostic(e.id,s),d=!!l;let f;n[3]!==l?(f=async()=>{if(!l)throw new Error("cdClient not ready");const j=await l.callTool({name:Xt,arguments:{}});return Pt(j).diagnostic??null},n[3]=l,n[4]=f):f=n[4];let m;n[5]!==c||n[6]!==d||n[7]!==f?(m={queryKey:c,enabled:d,retry:1,refetchInterval:Ci,queryFn:f},n[5]=c,n[6]=d,n[7]=f,n[8]=m):m=n[8];const u=He(m),p=u.data??null,y=u.isSuccess,x=r?.metadata?.siteUrl;let g;n[9]!==x?(g=yi(x),n[9]=x,n[10]=g):g=n[10];const h=l??null;let b;return n[11]!==s||n[12]!==u.isSuccess||n[13]!==p||n[14]!==g||n[15]!==h?(b={diagnostic:p,isSuccess:y,host:g,connectionId:s,cdClient:h},n[11]=s,n[12]=u.isSuccess,n[13]=p,n[14]=g,n[15]=h,n[16]=b):b=n[16],b}function Ci(n){return n.state.status!=="error"&&vi(n.state.data)==="generating"?ji:!1}function Da(n,e){return{to:"/$org/$taskId",params:{org:n.slug,taskId:crypto.randomUUID()},search:{virtualmcpid:En(n.id),main:Qs(e,Xt)}}}export{ya as A,ba as C,Ca as N,ja as O,Na as T,va as a,_a as b,ka as c,so as d,Mt as e,Sa as f,Ia as g,vi as h,Da as i,wa as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as f,H as C,bQ as A,eN as O,bP as S}from"./index-C-W5dASy.js";import{u as I}from"./use-mcp-client-PMt78ucZ.js";import{S as N}from"./constants-BSYv1IkQ.js";function E(t){const o=f.c(20);let i;o[0]!==t?(i=t===void 0?{}:t,o[0]=t,o[1]=i):i=o[1];const n=i;let l,s,c,d;o[2]!==n?({binding:l,includeVirtual:c,slug:d,...s}=n,o[2]=n,o[3]=l,o[4]=s,o[5]=c,o[6]=d):(l=o[3],s=o[4],c=o[5],d=o[6]);let e;o[7]!==l||o[8]!==s.additionalToolArgs||o[9]!==c||o[10]!==d?(e={...s.additionalToolArgs},l!==void 0&&(e.binding=l),c!==void 0&&(e.include_virtual=c),d!==void 0&&(e.slug=d),o[7]=l,o[8]=s.additionalToolArgs,o[9]=c,o[10]=d,o[11]=e):e=o[11];let r;o[12]!==e?(r=Object.keys(e).length>0?e:void 0,o[12]=e,o[13]=r):r=o[13];let g;o[14]!==s||o[15]!==r?(g={...s,additionalToolArgs:r},o[14]=s,o[15]=r,o[16]=g):g=o[16];const m=g,{org:u}=C();let a;o[17]!==u.id||o[18]!==u.slug?(a={connectionId:N,orgId:u.id,orgSlug:u.slug},o[17]=u.id,o[18]=u.slug,o[19]=a):a=o[19];const p=I(a);return O(u.id,"CONNECTIONS",p,m)}function P(t){const o=f.c(3),{org:i}=C();let n;o[0]!==i.id||o[1]!==i.slug?(n={connectionId:N,orgId:i.id,orgSlug:i.slug},o[0]=i.id,o[1]=i.slug,o[2]=n):n=o[2];const l=I(n);return S(i.id,"CONNECTIONS",t,l)}function _(){const t=f.c(3),{org:o}=C();let i;t[0]!==o.id||t[1]!==o.slug?(i={connectionId:N,orgId:o.id,orgSlug:o.slug},t[0]=o.id,t[1]=o.slug,t[2]=i):i=t[2];const n=I(i);return A(o.id,"CONNECTIONS",n)}export{P as a,_ as b,E as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as i,r as n}from"./index-
|
|
1
|
+
import{c as i,r as n}from"./index-C-W5dASy.js";function p(){const e=i.c(3),[s,a]=n.useState(!1);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=async c=>{await navigator.clipboard.writeText(c),a(!0),setTimeout(()=>a(!1),2e3)},e[0]=t):t=e[0];const r=t;let o;return e[1]!==s?(o={handleCopy:r,copied:s},e[1]=s,e[2]=o):o=e[2],o}export{p as u};
|
package/dist/client/assets/{use-create-virtual-mcp-B5mSvVFn.js → use-create-virtual-mcp-CTvxs6s1.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as g}from"./index-
|
|
1
|
+
import{c as g}from"./index-C-W5dASy.js";import{b as f}from"./use-virtual-mcp-eZtpf4bS.js";import{c as p}from"./use-navigate-to-agent-DpqkGd8j.js";function A(i){const e=g.c(9);let n;e[0]!==i?(n=i===void 0?{}:i,e[0]=i,e[1]=n):n=e[1];const d=n,{navigateOnCreate:u}=d,c=u===void 0?!1:u,t=f(),r=p();let s;e[2]!==t.create||e[3]!==c||e[4]!==r?(s=async()=>{const l=await t.create.mutateAsync({title:"New Agent",description:"AI-driven assistant designed to handle specific tasks",status:"active",connections:[],pinned:!1});return c&&r(l.id,{search:{main:"instructions"}}),{id:l.id,virtualMcp:l}},e[2]=t.create,e[3]=c,e[4]=r,e[5]=s):s=e[5];const o=s;let a;return e[6]!==t.create.isPending||e[7]!==o?(a={createVirtualMCP:o,isCreating:t.create.isPending},e[6]=t.create.isPending,e[7]=o,e[8]=a):a=e[8],a}export{A as u};
|
package/dist/client/assets/{use-debounced-autosave-BDvfPMkV.js → use-debounced-autosave-DSiZvyT9.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as u}from"./index-
|
|
1
|
+
import{r as u}from"./index-C-W5dASy.js";function l({save:t,delayMs:n=1e3}){const e=u.useRef(t);e.current=t;const r=u.useRef(null),c=()=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{r.current=null,e.current()},n)},o=()=>(r.current&&(clearTimeout(r.current),r.current=null),e.current());return u.useEffect(()=>()=>{r.current&&(clearTimeout(r.current),r.current=null,e.current())},[]),{schedule:c,flush:o}}export{l as u};
|
package/dist/client/assets/{use-debounced-value-UZPGD-zb.js → use-debounced-value-Dq1JGl41.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as m,r as n}from"./index-
|
|
1
|
+
import{c as m,r as n}from"./index-C-W5dASy.js";function p(e,o){const t=m.c(4),[s,u]=n.useState(e);let c,r;return t[0]!==o||t[1]!==e?(c=()=>{const i=setTimeout(()=>u(e),o);return()=>clearTimeout(i)},r=[e,o],t[0]=o,t[1]=e,t[2]=c,t[3]=r):(c=t[2],r=t[3]),n.useEffect(c,r),s}export{p as u};
|
package/dist/client/assets/{use-decopilot-events-8dmobXlE.js → use-decopilot-events-ka0F1PHR.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s}from"./index-
|
|
1
|
+
import{r as s}from"./index-C-W5dASy.js";import{d as R,c as u}from"./decopilot-sse-pool-DvpyeiPr.js";const f=()=>0;function g(E){const{orgSlug:t,taskId:a,enabled:n=!0,onStep:o,onFinish:S,onTaskStatus:i}=E,l=s.useRef({taskId:a,onStep:o,onFinish:S,onTaskStatus:i});l.current={taskId:a,onStep:o,onFinish:S,onTaskStatus:i};const c=s.useRef(null),p=s.useRef(n),b=s.useRef(t);(!c.current||p.current!==n||b.current!==t)&&(p.current=n,b.current=t,c.current=d=>{if(!n||!t)return()=>{};const k=T=>{let e;try{e=JSON.parse(T.data)}catch{return}const r=l.current;if(!(r.taskId&&e.subject!==r.taskId)){switch(e.type){case u.STEP:r.onStep?.(e);break;case u.FINISH:r.onFinish?.(e);break;case u.THREAD_STATUS:r.onTaskStatus?.(e);break}d()}};return R.subscribe(t,k)}),s.useSyncExternalStore(c.current,f,f)}export{g as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as oe,b as le,j as n,H as se,p as ie,av as ce,r as re,t as Y,bN as ae,bO as de}from"./index-C-W5dASy.js";import{c as z,d as G,b as V,f as X,g as Z,e as ee,a as te,A as ne}from"./alert-dialog-fRZZzq2b.js";function ge(B){const e=oe.c(86),{deleteState:s,cancelDelete:a,confirmDelete:d,confirmForceDelete:c}=B,t=le(),k=s.mode==="deleting";let m;e[0]!==a?(m=W=>{W||a()},e[0]=a,e[1]=m):m=e[1];let u;e[2]!==t?(u=t("common.deleteConnectionDialogs.title"),e[2]=t,e[3]=u):u=e[3];let D;e[4]!==u?(D=n.jsx(z,{children:u}),e[4]=u,e[5]=D):D=e[5];let C;e[6]!==t?(C=t("common.deleteConnectionDialogs.description"),e[6]=t,e[7]=C):C=e[7];const w=s.mode==="deleting"&&s.connection.title;let o;e[8]!==w?(o=n.jsx("span",{className:"font-medium text-foreground",children:w}),e[8]=w,e[9]=o):o=e[9];let l;e[10]!==C||e[11]!==o?(l=n.jsxs(G,{children:[C," ",o,"."]}),e[10]=C,e[11]=o,e[12]=l):l=e[12];let i;e[13]!==D||e[14]!==l?(i=n.jsxs(V,{children:[D,l]}),e[13]=D,e[14]=l,e[15]=i):i=e[15];let f;e[16]!==t?(f=t("common.deleteConnectionDialogs.cancel"),e[16]=t,e[17]=f):f=e[17];let r;e[18]!==f?(r=n.jsx(X,{children:f}),e[18]=f,e[19]=r):r=e[19];let g;e[20]!==t?(g=t("common.deleteConnectionDialogs.delete"),e[20]=t,e[21]=g):g=e[21];let x;e[22]!==d||e[23]!==g?(x=n.jsx(Z,{onClick:d,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:g}),e[22]=d,e[23]=g,e[24]=x):x=e[24];let h;e[25]!==r||e[26]!==x?(h=n.jsxs(ee,{children:[r,x]}),e[25]=r,e[26]=x,e[27]=h):h=e[27];let j;e[28]!==h||e[29]!==i?(j=n.jsxs(te,{children:[i,h]}),e[28]=h,e[29]=i,e[30]=j):j=e[30];let N;e[31]!==k||e[32]!==j||e[33]!==m?(N=n.jsx(ne,{open:k,onOpenChange:m,children:j}),e[31]=k,e[32]=j,e[33]=m,e[34]=N):N=e[34];const J=s.mode==="force-deleting";let p;e[35]!==a?(p=W=>{W||a()},e[35]=a,e[36]=p):p=e[36];let E;e[37]!==t?(E=t("common.deleteConnectionDialogs.forceDeleteTitle"),e[37]=t,e[38]=E):E=e[38];let y;e[39]!==E?(y=n.jsx(z,{children:E}),e[39]=E,e[40]=y):y=e[40];let O;e[41]!==t?(O=t("common.deleteConnectionDialogs.forceDeleteDescription"),e[41]=t,e[42]=O):O=e[42];const M=s.mode==="force-deleting"&&s.connection.title;let v;e[43]!==M?(v=n.jsx("span",{className:"font-medium text-foreground",children:M}),e[43]=M,e[44]=v):v=e[44];let S;e[45]!==t?(S=t("common.deleteConnectionDialogs.isUsedByAgents"),e[45]=t,e[46]=S):S=e[46];const P=s.mode==="force-deleting"&&s.agentNames;let T;e[47]!==P?(T=n.jsx("span",{className:"font-medium text-foreground",children:P}),e[47]=P,e[48]=T):T=e[48];let A;e[49]!==O||e[50]!==v||e[51]!==S||e[52]!==T?(A=n.jsxs("p",{children:[O," ",v," ",S," ",T,"."]}),e[49]=O,e[50]=v,e[51]=S,e[52]=T,e[53]=A):A=e[53];let _;e[54]!==t?(_=t("common.deleteConnectionDialogs.forceDeleteWarning"),e[54]=t,e[55]=_):_=e[55];let b;e[56]!==_?(b=n.jsx("p",{className:"mt-2",children:_}),e[56]=_,e[57]=b):b=e[57];let F;e[58]!==A||e[59]!==b?(F=n.jsx(G,{asChild:!0,children:n.jsxs("div",{children:[A,b]})}),e[58]=A,e[59]=b,e[60]=F):F=e[60];let I;e[61]!==y||e[62]!==F?(I=n.jsxs(V,{children:[y,F]}),e[61]=y,e[62]=F,e[63]=I):I=e[63];let L;e[64]!==t?(L=t("common.deleteConnectionDialogs.cancel"),e[64]=t,e[65]=L):L=e[65];let R;e[66]!==L?(R=n.jsx(X,{children:L}),e[66]=L,e[67]=R):R=e[67];let q;e[68]!==t?(q=t("common.deleteConnectionDialogs.deleteAnyway"),e[68]=t,e[69]=q):q=e[69];let U;e[70]!==c||e[71]!==q?(U=n.jsx(Z,{onClick:c,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:q}),e[70]=c,e[71]=q,e[72]=U):U=e[72];let H;e[73]!==R||e[74]!==U?(H=n.jsxs(ee,{children:[R,U]}),e[73]=R,e[74]=U,e[75]=H):H=e[75];let K;e[76]!==I||e[77]!==H?(K=n.jsxs(te,{children:[I,H]}),e[76]=I,e[77]=H,e[78]=K):K=e[78];let $;e[79]!==J||e[80]!==p||e[81]!==K?($=n.jsx(ne,{open:J,onOpenChange:p,children:K}),e[79]=J,e[80]=p,e[81]=K,e[82]=$):$=e[82];let Q;return e[83]!==N||e[84]!==$?(Q=n.jsxs(n.Fragment,{children:[N,$]}),e[83]=N,e[84]=$,e[85]=Q):Q=e[85],Q}function ue({onSuccess:B}={}){const{org:e}=se(),s=ie(),a=ce(),[d,c]=re.useState({mode:"idle"}),t=()=>{s.invalidateQueries({predicate:o=>{const l=o.queryKey;return l[1]===e.id&&l[3]==="collection"&&l[4]==="CONNECTIONS"}})},k=o=>{ae(o),s.invalidateQueries({predicate:l=>l.queryKey[1]===de&&l.queryKey[3]===o})},m=o=>{t(),k(o),Y.success("Connection deleted successfully"),c({mode:"idle"}),B?.()};return{deleteState:d,requestDelete:o=>{c({mode:"deleting",connection:o})},cancelDelete:()=>{c({mode:"idle"})},confirmDelete:async()=>{if(d.mode!=="deleting")return;const o=d.connection;c({mode:"idle"});try{await a.call("COLLECTION_CONNECTIONS_DELETE",{id:o.id}),m(o.id)}catch(l){const i=l instanceof Error?l.message:String(l),f=i.replace(/^Error:\s*/,"");try{const r=JSON.parse(f);if(r.code==="CONNECTION_IN_USE"&&r.agentNames){c({mode:"force-deleting",connection:o,agentNames:r.agentNames.map(g=>`"${g}"`).join(", ")});return}}catch{}Y.error(`Failed to delete connection: ${i}`)}},confirmForceDelete:async()=>{if(d.mode!=="force-deleting")return;const o=d.connection.id;c({mode:"idle"});try{await a.call("COLLECTION_CONNECTIONS_DELETE",{id:o,force:!0}),m(o)}catch(l){const i=l instanceof Error?l.message:String(l);Y.error(`Failed to delete connection: ${i}`)}}}}export{ge as D,ue as u};
|
package/dist/client/assets/{use-deployment-admin-tOuWllrn.js → use-deployment-admin-BQBai7bt.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as s,
|
|
1
|
+
import{c as s,o as m,K as c}from"./index-C-W5dASy.js";function l(){const e=s.c(5);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={queryKey:c.deploymentAdminMe(),queryFn:d,staleTime:1/0,retry:2},e[0]=t):t=e[0];const{data:a,isLoading:i}=m(t),r=a==="admin",o=a==="unverified";let n;return e[1]!==i||e[2]!==r||e[3]!==o?(n={isAdmin:r,loading:i,needsEmailVerification:o},e[1]=i,e[2]=r,e[3]=o,e[4]=n):n=e[4],n}async function d(){const e=await fetch("/api/_admin/me",{credentials:"include"});if(e.status>=500)throw new Error(`admin/me request failed: ${e.status}`);return e.ok?"admin":(await e.json().catch(u)).error==="email_not_verified"?"unverified":"denied"}function u(){return{}}export{l as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as u,H as c,av as r,K as a,o as y,z as F,p as C,e as d}from"./index-C-W5dASy.js";function E(){const e=u.c(7),{org:n}=c(),o=r();let i;e[0]!==n.id?(i=a.fileConfigs(n.id),e[0]=n.id,e[1]=i):i=e[1];let t;e[2]!==o?(t=()=>o.call("FILE_CONFIG_LIST",{}),e[2]=o,e[3]=t):t=e[3];let s;e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6];const{data:l}=F(s);return l.configs}function I(){const e=u.c(7),{org:n}=c(),o=r();let i;e[0]!==n.id?(i=a.fileConfigs(n.id),e[0]=n.id,e[1]=i):i=e[1];let t;e[2]!==o?(t=()=>o.call("FILE_CONFIG_LIST",{}),e[2]=o,e[3]=t):t=e[3];let s;return e[4]!==i||e[5]!==t?(s={queryKey:i,staleTime:6e4,queryFn:t},e[4]=i,e[5]=t,e[6]=s):s=e[6],y(s)}function m(){const e=u.c(8),{org:n}=c(),o=r(),i=C();let t;e[0]!==o?(t=f=>o.call("FILE_CONFIG_CREATE",{...f}),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==n||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:a.fileConfigs(n.id)})},e[2]=n,e[3]=i,e[4]=s):s=e[4];let l;return e[5]!==t||e[6]!==s?(l={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=l):l=e[7],d(l)}function q(){const e=u.c(8),{org:n}=c(),o=r(),i=C();let t;e[0]!==o?(t=f=>o.call("FILE_CONFIG_DELETE",{id:f}),e[0]=o,e[1]=t):t=e[1];let s;e[2]!==n||e[3]!==i?(s=()=>{i.invalidateQueries({queryKey:a.fileConfigs(n.id)})},e[2]=n,e[3]=i,e[4]=s):s=e[4];let l;return e[5]!==t||e[6]!==s?(l={mutationFn:t,onSuccess:s},e[5]=t,e[6]=s,e[7]=l):l=e[7],d(l)}export{E as a,m as b,q as c,I as u};
|
package/dist/client/assets/{use-infinite-scroll-Dzm35RNS.js → use-infinite-scroll-4H8mlAbs.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{bt as l,eP as d,eQ as v,r as i}from"./index-C-W5dASy.js";var b=class extends l{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,u=super.createResult(e,t),{isFetching:r,isRefetching:h,isError:a,isRefetchError:P}=u,s=n.fetchMeta?.fetchMore?.direction,o=a&&s==="forward",g=r&&s==="forward",c=a&&s==="backward",f=r&&s==="backward";return{...u,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:v(t,n.data),hasPreviousPage:d(t,n.data),isFetchNextPageError:o,isFetchingNextPage:g,isFetchPreviousPageError:c,isFetchingPreviousPage:f,isRefetchError:P&&!o&&!c,isRefetching:h&&!g&&!f}}};function p(e,t,n=!1,u){const r=i.useRef(null),h=i.useRef(null),a=i.useRef(e),P=i.useRef(t),s=i.useRef(n),o=i.useRef(u);a.current=e,P.current=t,s.current=n,o.current=u;const[g]=i.useState(()=>c=>{h.current=c,r.current&&(r.current.disconnect(),r.current=null),c&&queueMicrotask(()=>{if(h.current!==c)return;const f=new IntersectionObserver(R=>{R[0]?.isIntersecting&&P.current&&!s.current&&a.current()},{root:o.current?.current??null,rootMargin:"0px 0px 200px 0px"});f.observe(c),r.current=f})});return g}export{b as I,p as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as g,H as N,av as O,bF as _,K as y,o as v,p as A,e as I,t as q}from"./index-C-W5dASy.js";function Q(){const e=g.c(10),{org:a}=N(),u=O(),{capabilities:r,isPrivileged:c}=_(),d=c||!!r["members:manage"];let t;e[0]!==a.id?(t=y.organizationJoinRequests(a.id),e[0]=a.id,e[1]=t):t=e[1];let s;e[2]!==u?(s=()=>u.call("ORGANIZATION_JOIN_REQUEST_LIST",{}),e[2]=u,e[3]=s):s=e[3];const o=!!a.id&&d;let i;e[4]!==t||e[5]!==s||e[6]!==o?(i={queryKey:t,queryFn:s,enabled:o},e[4]=t,e[5]=s,e[6]=o,e[7]=i):i=e[7];const{data:l}=v(i);let n;return e[8]!==l?.requests?(n=l?.requests??[],e[8]=l?.requests,e[9]=n):n=e[9],n}function b(){const e=g.c(21),{org:a,locator:u}=N(),r=O(),c=A();let d;e[0]!==u||e[1]!==a||e[2]!==c?(d=()=>{c.invalidateQueries({queryKey:y.organizationJoinRequests(a.id)}),c.invalidateQueries({queryKey:y.members(u)})},e[0]=u,e[1]=a,e[2]=c,e[3]=d):d=e[3];const t=d;let s;e[4]!==r?(s=R=>r.call("ORGANIZATION_JOIN_REQUEST_APPROVE",{requestId:R}),e[4]=r,e[5]=s):s=e[5];let o;e[6]!==t?(o=()=>{t(),q.success("Request approved")},e[6]=t,e[7]=o):o=e[7];let i;e[8]!==s||e[9]!==o?(i={mutationFn:s,onSuccess:o,onError:T},e[8]=s,e[9]=o,e[10]=i):i=e[10];const l=I(i);let n;e[11]!==r?(n=R=>r.call("ORGANIZATION_JOIN_REQUEST_DENY",{requestId:R}),e[11]=r,e[12]=n):n=e[12];let f;e[13]!==t?(f=()=>{t(),q.success("Request denied")},e[13]=t,e[14]=f):f=e[14];let m;e[15]!==n||e[16]!==f?(m={mutationFn:n,onSuccess:f,onError:S},e[15]=n,e[16]=f,e[17]=m):m=e[17];const E=I(m);let p;return e[18]!==l||e[19]!==E?(p={approve:l,deny:E},e[18]=l,e[19]=E,e[20]=p):p=e[20],p}function S(e){return q.error(e instanceof Error?e.message:"Failed to deny")}function T(e){return q.error(e instanceof Error?e.message:"Failed to approve")}export{b as a,Q as u};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{dd as le,de as ue,df as de,cf as he,dg as fe,bU as _,bV as g,dh as pe,di as me,dj as _e,dk as M,dl as we,dm as D,dn as ge,dp as q,dq as Te,dr as L,ds as ye,dt as ve,du as ke,dv as J,by as Se,bA as Ce,bv as be,ca as te,cm as Re,cs as Ie,cq as Ee,cE as qe,dw as Pe,dx as $e,dy as A,dz as Me,dA as Ae,cr as He,cn as Oe,co as Ue,cp as xe,bw as Ne,dB as je,dC as Fe,dD as De,ch as Le,dE as Ve,dF as ze,cA as U,dG as Qe,bu as N,c as se,x as re,K as z}from"./index-DTCr2n-a.js";import{S as Je}from"./constants-BSYv1IkQ.js";import{U as P,a as H,e as W}from"./auth-CS2cT5wl.js";function x(a){return!!a._zod}function b(a,e){return x(a)?le(a,e):a.safeParse(e)}function oe(a){if(!a)return;let e;if(x(a)?e=a._zod?.def?.shape:e=a.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function We(a){if(x(a)){const o=a._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const t=a._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=a.value;if(s!==void 0)return s}function R(a){return a==="completed"||a==="failed"||a==="cancelled"}function K(a){const t=oe(a)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=We(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function G(a,e){const t=b(a,e);if(!t.success)throw t.error;return t.data}const Ke=6e4;class Ge{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(ue,t=>{this._oncancel(t)}),this.setNotificationHandler(de,t=>{this._onprogress(t)}),this.setRequestHandler(he,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(fe,async(t,s)=>{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(g.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(pe,async(t,s)=>{const r=async()=>{const o=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(i.type==="response"||i.type==="error"){const u=i.message,p=u.id,l=this._requestResolvers.get(p);if(l)if(this._requestResolvers.delete(p),i.type==="response")l(u);else{const d=u,f=new _(d.error.code,d.error.message,d.error.data);l(f)}else{const d=i.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${p}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(o,s.sessionId);if(!n)throw new _(g.InvalidParams,`Task not found: ${o}`);if(!R(n.status))return await this._waitForTaskUpdate(o,s.signal),await r();if(R(n.status)){const i=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...i,_meta:{...i._meta,[q]:{taskId:o}}}}return await r()};return await r()}),this.setRequestHandler(me,async(t,s)=>{try{const{tasks:r,nextCursor:o}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new _(g.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(_e,async(t,s)=>{try{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(g.InvalidParams,`Task not found: ${t.params.taskId}`);if(R(r.status))throw new _(g.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new _(g.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...o}}catch(r){throw r instanceof _?r:new _(g.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,r,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:r})}_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),_.fromError(g.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=o=>{s?.(o),this._onerror(o)};const r=this._transport?.onmessage;this._transport.onmessage=(o,n)=>{r?.(o,n),M(o)||we(o)?this._onresponse(o):D(o)?this._onrequest(o,n):ge(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},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._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=_.fromError(g.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,r=this._transport,o=e.params?._meta?.[q]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:g.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=Te(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,p={signal:n.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(n.signal.aborted)throw new _(g.ConnectionClosed,"Request was cancelled");const m={...f,relatedRequestId:e.id};o&&!m.relatedTask&&(m.relatedTask={taskId:o});const T=m.relatedTask?.taskId??o;return T&&u&&await u.updateTaskStatus(T,"input_required"),await this.request(l,d,m)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,p)).then(async l=>{if(n.signal.aborted)return;const d={result:l,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)},async l=>{if(n.signal.aborted)return;const d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:g.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===n&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,r=Number(t),o=this._progressHandlers.get(r);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),n(u);return}o(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),M(e))s(e);else{const n=new _(e.error.code,e.error.message,e.error.data);s(n)}return}const r=this._responseHandlers.get(t);if(r===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 o=!1;if(M(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"&&(o=!0,this._taskProgressTokens.set(i.taskId,t))}}if(o||this._progressHandlers.delete(t),M(e))r(e);else{const n=_.fromError(e.error.code,e.error.message,e.error.data);r(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:r}=s??{};if(!r){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof _?n:new _(g.InternalError,String(n))}}return}let o;try{const n=await this.request(e,L,s);if(n.task)o=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new _(g.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:i},R(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)}:i.status==="failed"?yield{type:"error",error:new _(g.InternalError,`Task ${o} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new _(g.InternalError,`Task ${o} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)};return}const u=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(p=>setTimeout(p,u)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof _?n:new _(g.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n,task:i,relatedTask:u}=s??{};return new Promise((p,l)=>{const d=c=>{l(c)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(c){d(c);return}s?.signal?.throwIfAborted();const f=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:f};s?.onprogress&&(this._progressHandlers.set(f,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),i&&(m.params={...m.params,task:i}),u&&(m.params={...m.params,_meta:{...m.params?._meta||{},[q]:u}});const T=c=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(c)}},{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(k=>this._onerror(new Error(`Failed to send cancellation: ${k}`)));const w=c instanceof _?c:new _(g.RequestTimeout,String(c));l(w)};this._responseHandlers.set(f,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return l(c);try{const w=b(t,c.result);w.success?p(w.data):l(w.error)}catch(w){l(w)}}}),s?.signal?.addEventListener("abort",()=>{T(s?.signal?.reason)});const y=s?.timeout??Ke,v=()=>T(_.fromError(g.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(f,y,s?.maxTotalTimeout,v,s?.resetTimeoutOnProgress??!1);const h=u?.taskId;if(h){const c=w=>{const k=this._responseHandlers.get(f);k?k(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,c),this._enqueueTaskMessage(h,{type:"request",message:m,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),l(w)})}else this._transport.send(m,{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(c=>{this._cleanupTimeout(f),l(c)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ye,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},ve,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},ke,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||{},[q]: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||{},[q]:t.relatedTask}}}),this._transport?.send(i,t).catch(u=>this._onerror(u))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[q]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=K(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,o)=>{const n=G(e,r);return Promise.resolve(t(n,o))})}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=K(e);this._notificationHandlers.set(s,r=>{const o=G(e,r);return Promise.resolve(t(o))})}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 r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const r of s)if(r.type==="request"&&D(r.message)){const o=r.message.id,n=this._requestResolvers.get(o);n?(n(new _(g.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(e);r?.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,o)=>{if(t.aborted){o(new _(g.InvalidRequest,"Request cancelled"));return}const n=setTimeout(r,s);t.addEventListener("abort",()=>{clearTimeout(n),o(new _(g.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async r=>{if(!e)throw new Error("No request provided");return await s.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async r=>{const o=await s.getTask(r,t);if(!o)throw new _(g.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(r,o,n)=>{await s.storeTaskResult(r,o,n,t);const i=await s.getTask(r,t);if(i){const u=J.parse({method:"notifications/tasks/status",params:i});await this.notification(u),R(i.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>s.getTaskResult(r,t),updateTaskStatus:async(r,o,n)=>{const i=await s.getTask(r,t);if(!i)throw new _(g.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(R(i.status))throw new _(g.InvalidParams,`Cannot update task "${r}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(r,o,n,t);const u=await s.getTask(r,t);if(u){const p=J.parse({method:"notifications/tasks/status",params:u});await this.notification(p),R(u.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>s.listTasks(r,t)}}}function B(a){return a!==null&&typeof a=="object"&&!Array.isArray(a)}function Be(a,e){const t={...a};for(const s in e){const r=s,o=e[r];if(o===void 0)continue;const n=t[r];B(n)&&B(o)?t[r]={...n,...o}:t[r]=o}return t}var Ze=Ce();const Ye=Se(Ze);function Xe(){const a=new Ye({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return be(a),a}class et{constructor(e){this._ajv=e??Xe()}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 tt{constructor(e){this._client=e}async*callToolStream(e,t=te,s){const r=this._client,o={...s,task:s?.task??(r.isToolTask(e.name)?{}:void 0)},n=r.requestStream({method:"tools/call",params:e},t,o),i=r.getToolOutputValidator(e.name);for await(const u of n){if(u.type==="result"&&i){const p=u.result;if(!p.structuredContent&&!p.isError){yield{type:"error",error:new _(g.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(p.structuredContent)try{const l=i(p.structuredContent);if(!l.valid){yield{type:"error",error:new _(g.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof _){yield{type:"error",error:l};return}yield{type:"error",error:new _(g.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield u}}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 st(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!a.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function rt(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!a.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!a.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function O(a,e){if(!(!a||e===null||typeof e!="object")){if(a.type==="object"&&a.properties&&typeof a.properties=="object"){const t=e,s=a.properties;for(const r of Object.keys(s)){const o=s[r];t[r]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(t[r]=o.default),t[r]!==void 0&&O(o,t[r])}}if(Array.isArray(a.anyOf))for(const t of a.anyOf)typeof t!="boolean"&&O(t,e);if(Array.isArray(a.oneOf))for(const t of a.oneOf)typeof t!="boolean"&&O(t,e)}}function ot(a){if(!a)return{supportsFormMode:!1,supportsUrlMode:!1};const e=a.form!==void 0,t=a.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let at=class extends Ge{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 et,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Re,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ie,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Ee,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new tt(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Be(this._capabilities,e)}setRequestHandler(e,t){const r=oe(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let o;if(x(r)){const i=r;o=i._zod?.def?.value??i.value}else{const i=r;o=i._def?.value??i.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");const n=o;if(n==="elicitation/create"){const i=async(u,p)=>{const l=b(Fe,u);if(!l.success){const c=l.error instanceof Error?l.error.message:String(l.error);throw new _(g.InvalidParams,`Invalid elicitation request: ${c}`)}const{params:d}=l.data;d.mode=d.mode??"form";const{supportsFormMode:f,supportsUrlMode:m}=ot(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new _(g.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new _(g.InvalidParams,"Client does not support URL-mode elicitation requests");const T=await Promise.resolve(t(u,p));if(d.task){const c=b(L,T);if(!c.success){const w=c.error instanceof Error?c.error.message:String(c.error);throw new _(g.InvalidParams,`Invalid task creation result: ${w}`)}return c.data}const y=b(De,T);if(!y.success){const c=y.error instanceof Error?y.error.message:String(y.error);throw new _(g.InvalidParams,`Invalid elicitation result: ${c}`)}const v=y.data,h=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&v.action==="accept"&&v.content&&h&&this._capabilities.elicitation?.form?.applyDefaults)try{O(h,v.content)}catch{}return v};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(u,p)=>{const l=b(Le,u);if(!l.success){const v=l.error instanceof Error?l.error.message:String(l.error);throw new _(g.InvalidParams,`Invalid sampling request: ${v}`)}const{params:d}=l.data,f=await Promise.resolve(t(u,p));if(d.task){const v=b(L,f);if(!v.success){const h=v.error instanceof Error?v.error.message:String(v.error);throw new _(g.InvalidParams,`Invalid task creation result: ${h}`)}return v.data}const T=d.tools||d.toolChoice?Ve:ze,y=b(T,f);if(!y.success){const v=y.error instanceof Error?y.error.message:String(y.error);throw new _(g.InvalidParams,`Invalid sampling result: ${v}`)}return y.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:qe,capabilities:this._capabilities,clientInfo:this._clientInfo}},Pe,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!$e.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){st(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&rt(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},A,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Me,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},A,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Ae,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},He,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},Oe,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},Ue,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},xe,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},A,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},A,t)}async callTool(e,t=te,s){if(this.isToolTaskRequired(e.name))throw new _(g.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const r=await this.request({method:"tools/call",params:e},t,s),o=this.getToolOutputValidator(e.name);if(o){if(!r.structuredContent&&!r.isError)throw new _(g.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{const n=o(r.structuredContent);if(!n.valid)throw new _(g.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof _?n:new _(g.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return r}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 r=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,r)}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},Ne,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,r){const o=je.safeParse(s);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=o.data,{onChanged:u}=s,p=async()=>{if(!n){u(null,null);return}try{const d=await r();u(null,d)}catch(d){const f=d instanceof Error?d:new Error(String(d));u(f,null)}},l=()=>{if(i){const d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);const f=setTimeout(p,i);this._listChangedDebounceTimers.set(e,f)}else p()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const j=a=>[{type:"text",text:a}];function nt(a){const e=U(a,typeof window<"u"?window.location.origin:void 0);if(!e)throw new Error("RestSelfClient requires either studioUrl or a browser environment.");const t={"Content-Type":"application/json",Accept:"application/json",...a.token?{Authorization:`Bearer ${a.token}`}:{}},s=u=>new URL(`/api/${encodeURIComponent(a.orgSlug)}${u}`,e).href,r=async u=>{let p;try{p=await fetch(s(`/tools/${encodeURIComponent(u.name)}`),{method:"POST",headers:t,credentials:"include",body:JSON.stringify(u.arguments??{})})}catch(d){const f=d instanceof Error?d.message:"Network error";return{content:j(f),isError:!0}}if(!p.ok){let d=`${u.name} failed (${p.status})`;try{const f=await p.json();f?.error&&(d=f.error)}catch{}return{content:j(d),isError:!0}}const l=await p.json().catch(()=>({}));return{content:j(typeof l=="string"?l:JSON.stringify(l)),structuredContent:l}},o=async()=>{const u=await fetch(s("/tools"),{method:"GET",headers:t,credentials:"include"});return u.ok?await u.json():{tools:[]}},n=u=>()=>Promise.reject(new Error(`RestSelfClient: ${u} is not supported over REST for the self connection`));return{callTool:r,listTools:o,listPrompts:n("listPrompts"),getPrompt:n("getPrompt"),listResources:n("listResources"),readResource:n("readResource"),listResourceTemplates:n("listResourceTemplates"),close:()=>Promise.resolve(),toJSON:()=>a.toJSONString}}function V(a){return a?a instanceof Headers?Object.fromEntries(a.entries()):Array.isArray(a)?Object.fromEntries(a):{...a}:{}}function it(a=fetch,e){return e?async(t,s)=>{const r={...e,...s,headers:s?.headers?{...V(e.headers),...V(s.headers)}:e.headers};return a(t,r)}:a}class Z 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}}const Y=10,ct=13,I=32;function F(a){}function lt(a){if(typeof a=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=F,onError:t=F,onRetry:s=F,onComment:r}=a,o=[];let n=!0,i,u="",p=0,l;function d(h){if(n&&(n=!1,h.charCodeAt(0)===239&&h.charCodeAt(1)===187&&h.charCodeAt(2)===191&&(h=h.slice(3))),o.length===0){const k=f(h);k!==""&&o.push(k);return}if(h.indexOf(`
|
|
1
|
+
import{dX as le,dY as ue,dZ as de,cS as he,d_ as fe,cv as _,cw as g,d$ as pe,e0 as me,e1 as _e,e2 as M,e3 as we,e4 as D,e5 as ge,e6 as q,e7 as Te,e8 as L,e9 as ye,ea as ke,eb as ve,ec as J,c9 as Se,cb as Ce,c6 as be,cN as te,cZ as Re,d3 as Ie,d1 as Ee,dn as qe,ed as Pe,ee as $e,ef as A,eg as Me,eh as Ae,d2 as He,c_ as Oe,c$ as Ue,d0 as xe,c7 as Ne,ei as je,ej as Fe,ek as De,cU as Le,el as Ve,em as ze,dj as U,en as Qe,c5 as N,c as se,z as re,K as z}from"./index-C-W5dASy.js";import{S as Je}from"./constants-BSYv1IkQ.js";import{U as P,a as H,e as W}from"./auth-CsyM6wOp.js";function x(a){return!!a._zod}function b(a,e){return x(a)?le(a,e):a.safeParse(e)}function oe(a){if(!a)return;let e;if(x(a)?e=a._zod?.def?.shape:e=a.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function We(a){if(x(a)){const o=a._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}const t=a._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=a.value;if(s!==void 0)return s}function R(a){return a==="completed"||a==="failed"||a==="cancelled"}function K(a){const t=oe(a)?.method;if(!t)throw new Error("Schema is missing a method literal");const s=We(t);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function G(a,e){const t=b(a,e);if(!t.success)throw t.error;return t.data}const Ke=6e4;class Ge{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(ue,t=>{this._oncancel(t)}),this.setNotificationHandler(de,t=>{this._onprogress(t)}),this.setRequestHandler(he,t=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(fe,async(t,s)=>{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(g.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(pe,async(t,s)=>{const r=async()=>{const o=t.params.taskId;if(this._taskMessageQueue){let i;for(;i=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(i.type==="response"||i.type==="error"){const u=i.message,p=u.id,l=this._requestResolvers.get(p);if(l)if(this._requestResolvers.delete(p),i.type==="response")l(u);else{const d=u,f=new _(d.error.code,d.error.message,d.error.data);l(f)}else{const d=i.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${p}`))}continue}await this._transport?.send(i.message,{relatedRequestId:s.requestId})}}const n=await this._taskStore.getTask(o,s.sessionId);if(!n)throw new _(g.InvalidParams,`Task not found: ${o}`);if(!R(n.status))return await this._waitForTaskUpdate(o,s.signal),await r();if(R(n.status)){const i=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...i,_meta:{...i._meta,[q]:{taskId:o}}}}return await r()};return await r()}),this.setRequestHandler(me,async(t,s)=>{try{const{tasks:r,nextCursor:o}=await this._taskStore.listTasks(t.params?.cursor,s.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new _(g.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(_e,async(t,s)=>{try{const r=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!r)throw new _(g.InvalidParams,`Task not found: ${t.params.taskId}`);if(R(r.status))throw new _(g.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(t.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(t.params.taskId);const o=await this._taskStore.getTask(t.params.taskId,s.sessionId);if(!o)throw new _(g.InvalidParams,`Task not found after cancellation: ${t.params.taskId}`);return{_meta:{},...o}}catch(r){throw r instanceof _?r:new _(g.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,s,r,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:r})}_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),_.fromError(g.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=o=>{s?.(o),this._onerror(o)};const r=this._transport?.onmessage;this._transport.onmessage=(o,n)=>{r?.(o,n),M(o)||we(o)?this._onresponse(o):D(o)?this._onrequest(o,n):ge(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},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._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(const s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();const t=_.fromError(g.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,r=this._transport,o=e.params?._meta?.[q]?.taskId;if(s===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:g.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const i=Te(e.params)?e.params.task:void 0,u=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,p={signal:n.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(n.signal.aborted)return;const d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(n.signal.aborted)throw new _(g.ConnectionClosed,"Request was cancelled");const m={...f,relatedRequestId:e.id};o&&!m.relatedTask&&(m.relatedTask={taskId:o});const T=m.relatedTask?.taskId??o;return T&&u&&await u.updateTaskStatus(T,"input_required"),await this.request(l,d,m)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:o,taskStore:u,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,p)).then(async l=>{if(n.signal.aborted)return;const d={result:l,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)},async l=>{if(n.signal.aborted)return;const d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:g.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===n&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...s}=e.params,r=Number(t),o=this._progressHandlers.get(r);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}const n=this._responseHandlers.get(r),i=this._timeoutInfo.get(r);if(i&&n&&i.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(u){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),n(u);return}o(s)}_onresponse(e){const t=Number(e.id),s=this._requestResolvers.get(t);if(s){if(this._requestResolvers.delete(t),M(e))s(e);else{const n=new _(e.error.code,e.error.message,e.error.data);s(n)}return}const r=this._responseHandlers.get(t);if(r===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 o=!1;if(M(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"&&(o=!0,this._taskProgressTokens.set(i.taskId,t))}}if(o||this._progressHandlers.delete(t),M(e))r(e);else{const n=_.fromError(e.error.code,e.error.message,e.error.data);r(n)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,s){const{task:r}=s??{};if(!r){try{yield{type:"result",result:await this.request(e,t,s)}}catch(n){yield{type:"error",error:n instanceof _?n:new _(g.InternalError,String(n))}}return}let o;try{const n=await this.request(e,L,s);if(n.task)o=n.task.taskId,yield{type:"taskCreated",task:n.task};else throw new _(g.InternalError,"Task creation did not return a task");for(;;){const i=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:i},R(i.status)){i.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)}:i.status==="failed"?yield{type:"error",error:new _(g.InternalError,`Task ${o} failed`)}:i.status==="cancelled"&&(yield{type:"error",error:new _(g.InternalError,`Task ${o} was cancelled`)});return}if(i.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},t,s)};return}const u=i.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(p=>setTimeout(p,u)),s?.signal?.throwIfAborted()}}catch(n){yield{type:"error",error:n instanceof _?n:new _(g.InternalError,String(n))}}}request(e,t,s){const{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n,task:i,relatedTask:u}=s??{};return new Promise((p,l)=>{const d=c=>{l(c)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(c){d(c);return}s?.signal?.throwIfAborted();const f=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:f};s?.onprogress&&(this._progressHandlers.set(f,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),i&&(m.params={...m.params,task:i}),u&&(m.params={...m.params,_meta:{...m.params?._meta||{},[q]:u}});const T=c=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(c)}},{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const w=c instanceof _?c:new _(g.RequestTimeout,String(c));l(w)};this._responseHandlers.set(f,c=>{if(!s?.signal?.aborted){if(c instanceof Error)return l(c);try{const w=b(t,c.result);w.success?p(w.data):l(w.error)}catch(w){l(w)}}}),s?.signal?.addEventListener("abort",()=>{T(s?.signal?.reason)});const y=s?.timeout??Ke,k=()=>T(_.fromError(g.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(f,y,s?.maxTotalTimeout,k,s?.resetTimeoutOnProgress??!1);const h=u?.taskId;if(h){const c=w=>{const v=this._responseHandlers.get(f);v?v(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,c),this._enqueueTaskMessage(h,{type:"request",message:m,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),l(w)})}else this._transport.send(m,{relatedRequestId:r,resumptionToken:o,onresumptiontoken:n}).catch(c=>{this._cleanupTimeout(f),l(c)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ye,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},ke,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},ve,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||{},[q]: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||{},[q]:t.relatedTask}}}),this._transport?.send(i,t).catch(u=>this._onerror(u))});return}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[q]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const s=K(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(r,o)=>{const n=G(e,r);return Promise.resolve(t(n,o))})}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=K(e);this._notificationHandlers.set(s,r=>{const o=G(e,r);return Promise.resolve(t(o))})}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 r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,s,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(e,t);for(const r of s)if(r.type==="request"&&D(r.message)){const o=r.message.id,n=this._requestResolvers.get(o);n?(n(new _(g.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let s=this._options?.defaultTaskPollInterval??1e3;try{const r=await this._taskStore?.getTask(e);r?.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,o)=>{if(t.aborted){o(new _(g.InvalidRequest,"Request cancelled"));return}const n=setTimeout(r,s);t.addEventListener("abort",()=>{clearTimeout(n),o(new _(g.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async r=>{if(!e)throw new Error("No request provided");return await s.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async r=>{const o=await s.getTask(r,t);if(!o)throw new _(g.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(r,o,n)=>{await s.storeTaskResult(r,o,n,t);const i=await s.getTask(r,t);if(i){const u=J.parse({method:"notifications/tasks/status",params:i});await this.notification(u),R(i.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>s.getTaskResult(r,t),updateTaskStatus:async(r,o,n)=>{const i=await s.getTask(r,t);if(!i)throw new _(g.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(R(i.status))throw new _(g.InvalidParams,`Cannot update task "${r}" from terminal status "${i.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(r,o,n,t);const u=await s.getTask(r,t);if(u){const p=J.parse({method:"notifications/tasks/status",params:u});await this.notification(p),R(u.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>s.listTasks(r,t)}}}function Z(a){return a!==null&&typeof a=="object"&&!Array.isArray(a)}function Ze(a,e){const t={...a};for(const s in e){const r=s,o=e[r];if(o===void 0)continue;const n=t[r];Z(n)&&Z(o)?t[r]={...n,...o}:t[r]=o}return t}var Be=Ce();const Ye=Se(Be);function Xe(){const a=new Ye({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return be(a),a}class et{constructor(e){this._ajv=e??Xe()}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 tt{constructor(e){this._client=e}async*callToolStream(e,t=te,s){const r=this._client,o={...s,task:s?.task??(r.isToolTask(e.name)?{}:void 0)},n=r.requestStream({method:"tools/call",params:e},t,o),i=r.getToolOutputValidator(e.name);for await(const u of n){if(u.type==="result"&&i){const p=u.result;if(!p.structuredContent&&!p.isError){yield{type:"error",error:new _(g.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(p.structuredContent)try{const l=i(p.structuredContent);if(!l.valid){yield{type:"error",error:new _(g.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof _){yield{type:"error",error:l};return}yield{type:"error",error:new _(g.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield u}}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 st(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!a.tools?.call)throw new Error(`${t} does not support task creation for tools/call (required for ${e})`);break}}function rt(a,e,t){if(!a)throw new Error(`${t} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!a.sampling?.createMessage)throw new Error(`${t} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!a.elicitation?.create)throw new Error(`${t} does not support task creation for elicitation/create (required for ${e})`);break}}function O(a,e){if(!(!a||e===null||typeof e!="object")){if(a.type==="object"&&a.properties&&typeof a.properties=="object"){const t=e,s=a.properties;for(const r of Object.keys(s)){const o=s[r];t[r]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(t[r]=o.default),t[r]!==void 0&&O(o,t[r])}}if(Array.isArray(a.anyOf))for(const t of a.anyOf)typeof t!="boolean"&&O(t,e);if(Array.isArray(a.oneOf))for(const t of a.oneOf)typeof t!="boolean"&&O(t,e)}}function ot(a){if(!a)return{supportsFormMode:!1,supportsUrlMode:!1};const e=a.form!==void 0,t=a.url!==void 0;return{supportsFormMode:e||!e&&!t,supportsUrlMode:t}}let at=class extends Ge{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 et,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Re,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ie,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Ee,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new tt(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Ze(this._capabilities,e)}setRequestHandler(e,t){const r=oe(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let o;if(x(r)){const i=r;o=i._zod?.def?.value??i.value}else{const i=r;o=i._def?.value??i.value}if(typeof o!="string")throw new Error("Schema method literal must be a string");const n=o;if(n==="elicitation/create"){const i=async(u,p)=>{const l=b(Fe,u);if(!l.success){const c=l.error instanceof Error?l.error.message:String(l.error);throw new _(g.InvalidParams,`Invalid elicitation request: ${c}`)}const{params:d}=l.data;d.mode=d.mode??"form";const{supportsFormMode:f,supportsUrlMode:m}=ot(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new _(g.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new _(g.InvalidParams,"Client does not support URL-mode elicitation requests");const T=await Promise.resolve(t(u,p));if(d.task){const c=b(L,T);if(!c.success){const w=c.error instanceof Error?c.error.message:String(c.error);throw new _(g.InvalidParams,`Invalid task creation result: ${w}`)}return c.data}const y=b(De,T);if(!y.success){const c=y.error instanceof Error?y.error.message:String(y.error);throw new _(g.InvalidParams,`Invalid elicitation result: ${c}`)}const k=y.data,h=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&k.action==="accept"&&k.content&&h&&this._capabilities.elicitation?.form?.applyDefaults)try{O(h,k.content)}catch{}return k};return super.setRequestHandler(e,i)}if(n==="sampling/createMessage"){const i=async(u,p)=>{const l=b(Le,u);if(!l.success){const k=l.error instanceof Error?l.error.message:String(l.error);throw new _(g.InvalidParams,`Invalid sampling request: ${k}`)}const{params:d}=l.data,f=await Promise.resolve(t(u,p));if(d.task){const k=b(L,f);if(!k.success){const h=k.error instanceof Error?k.error.message:String(k.error);throw new _(g.InvalidParams,`Invalid task creation result: ${h}`)}return k.data}const T=d.tools||d.toolChoice?Ve:ze,y=b(T,f);if(!y.success){const k=y.error instanceof Error?y.error.message:String(y.error);throw new _(g.InvalidParams,`Invalid sampling result: ${k}`)}return y.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:qe,capabilities:this._capabilities,clientInfo:this._clientInfo}},Pe,t);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!$e.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){st(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&rt(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},A,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Me,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},A,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Ae,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},He,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},Oe,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},Ue,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},xe,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},A,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},A,t)}async callTool(e,t=te,s){if(this.isToolTaskRequired(e.name))throw new _(g.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const r=await this.request({method:"tools/call",params:e},t,s),o=this.getToolOutputValidator(e.name);if(o){if(!r.structuredContent&&!r.isError)throw new _(g.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(r.structuredContent)try{const n=o(r.structuredContent);if(!n.valid)throw new _(g.InvalidParams,`Structured content does not match the tool's output schema: ${n.errorMessage}`)}catch(n){throw n instanceof _?n:new _(g.InvalidParams,`Failed to validate structured content: ${n instanceof Error?n.message:String(n)}`)}}return r}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 r=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,r)}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},Ne,t);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,t,s,r){const o=je.safeParse(s);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:n,debounceMs:i}=o.data,{onChanged:u}=s,p=async()=>{if(!n){u(null,null);return}try{const d=await r();u(null,d)}catch(d){const f=d instanceof Error?d:new Error(String(d));u(f,null)}},l=()=>{if(i){const d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);const f=setTimeout(p,i);this._listChangedDebounceTimers.set(e,f)}else p()};this.setNotificationHandler(t,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};const j=a=>[{type:"text",text:a}];function nt(a){const e=U(a,typeof window<"u"?window.location.origin:void 0);if(!e)throw new Error("RestSelfClient requires either studioUrl or a browser environment.");const t={"Content-Type":"application/json",Accept:"application/json",...a.token?{Authorization:`Bearer ${a.token}`}:{}},s=u=>new URL(`/api/${encodeURIComponent(a.orgSlug)}${u}`,e).href,r=async u=>{let p;try{p=await fetch(s(`/tools/${encodeURIComponent(u.name)}`),{method:"POST",headers:t,credentials:"include",body:JSON.stringify(u.arguments??{})})}catch(d){const f=d instanceof Error?d.message:"Network error";return{content:j(f),isError:!0}}if(!p.ok){let d=`${u.name} failed (${p.status})`;try{const f=await p.json();f?.error&&(d=f.error)}catch{}return{content:j(d),isError:!0}}const l=await p.json().catch(()=>({}));return{content:j(typeof l=="string"?l:JSON.stringify(l)),structuredContent:l}},o=async()=>{const u=await fetch(s("/tools"),{method:"GET",headers:t,credentials:"include"});return u.ok?await u.json():{tools:[]}},n=u=>()=>Promise.reject(new Error(`RestSelfClient: ${u} is not supported over REST for the self connection`));return{callTool:r,listTools:o,listPrompts:n("listPrompts"),getPrompt:n("getPrompt"),listResources:n("listResources"),readResource:n("readResource"),listResourceTemplates:n("listResourceTemplates"),close:()=>Promise.resolve(),toJSON:()=>a.toJSONString}}function V(a){return a?a instanceof Headers?Object.fromEntries(a.entries()):Array.isArray(a)?Object.fromEntries(a):{...a}:{}}function it(a=fetch,e){return e?async(t,s)=>{const r={...e,...s,headers:s?.headers?{...V(e.headers),...V(s.headers)}:e.headers};return a(t,r)}:a}class B 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}}const Y=10,ct=13,I=32;function F(a){}function lt(a){if(typeof a=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:e=F,onError:t=F,onRetry:s=F,onComment:r}=a,o=[];let n=!0,i,u="",p=0,l;function d(h){if(n&&(n=!1,h.charCodeAt(0)===239&&h.charCodeAt(1)===187&&h.charCodeAt(2)===191&&(h=h.slice(3))),o.length===0){const v=f(h);v!==""&&o.push(v);return}if(h.indexOf(`
|
|
2
2
|
`)===-1&&h.indexOf("\r")===-1){o.push(h);return}o.push(h);const c=o.join("");o.length=0;const w=f(c);w!==""&&o.push(w)}function f(h){let c=0;if(h.indexOf("\r")===-1){let w=h.indexOf(`
|
|
3
3
|
`,c);for(;w!==-1;){if(c===w){p>0&&e({id:i,event:l,data:u}),i=void 0,u="",p=0,l=void 0,c=w+1,w=h.indexOf(`
|
|
4
|
-
`,c);continue}const
|
|
4
|
+
`,c);continue}const v=h.charCodeAt(c);if(X(h,c,v)){const S=h.charCodeAt(c+5)===I?c+6:c+5,C=h.slice(S,w);if(p===0&&h.charCodeAt(w+1)===Y){e({id:i,event:l,data:C}),i=void 0,u="",l=void 0,c=w+2,w=h.indexOf(`
|
|
5
5
|
`,c);continue}u=p===0?C:`${u}
|
|
6
|
-
${C}`,p++}else ee(h,c,
|
|
7
|
-
`,c)}return h.slice(c)}for(;c<h.length;){const w=h.indexOf("\r",c),
|
|
8
|
-
`,c);let S=-1;if(w!==-1&&
|
|
9
|
-
${Q}`,p++;return}if(ee(h,c,
|
|
10
|
-
${c}`,p++;break;case"id":i=c.includes("\0")?void 0:c;break;case"retry":/^\d+$/.test(c)?s(parseInt(c,10)):t(new Z(`Invalid \`retry\` value: "${c}"`,{type:"invalid-retry",value:c,line:w}));break;default:t(new Z(`Unknown field "${h.length>20?`${h.slice(0,20)}…`:h}"`,{type:"unknown-field",field:h,value:c,line:w}));break}}function y(){p>0&&e({id:i,event:l,data:u}),i=void 0,u="",p=0,l=void 0}function v(h={}){if(h.consume&&o.length>0){const c=o.join("");m(c,0,c.length)}n=!0,i=void 0,u="",p=0,l=void 0,o.length=0}return{feed:d,reset:v}}function X(a,e,t){return t===100&&a.charCodeAt(e+1)===97&&a.charCodeAt(e+2)===116&&a.charCodeAt(e+3)===97&&a.charCodeAt(e+4)===58}function ee(a,e,t){return t===101&&a.charCodeAt(e+1)===118&&a.charCodeAt(e+2)===101&&a.charCodeAt(e+3)===110&&a.charCodeAt(e+4)===116&&a.charCodeAt(e+5)===58}class ut extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let r;super({start(o){r=lt({onEvent:n=>{o.enqueue(n)},onError(n){e==="terminate"?o.error(n):typeof e=="function"&&e(n)},onRetry:t,onComment:s})},transform(o){r.feed(o)}})}}const dt={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class $ extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}let ht=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=it(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??dt}async _authThenStart(){if(!this._authProvider)throw new P("No auth provider");let e;try{e=await H(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(t){throw this.onerror?.(t),t}if(e!=="AUTHORIZED")throw new P;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=V(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){const{resumptionToken:t}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),t&&s.set("last-event-id",t);const r=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new $(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),r)}_scheduleReconnection(e,t=0){const s=this._reconnectionOptions.maxRetries;if(t>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(o=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,s){if(!e)return;const{onresumptiontoken:r,replayMessageId:o}=t;let n,i=!1,u=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new ut({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){const{value:m,done:T}=await l.read();if(T)break;if(m.id&&(n=m.id,i=!0,r?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{const y=N.parse(JSON.parse(m.data));M(y)&&(u=!0,o!==void 0&&(y.id=o)),this.onmessage?.(y)}catch(y){this.onerror?.(y)}}(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:o},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:o},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new P("No auth provider");if(await H(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{const{resumptionToken:s,onresumptiontoken:r}=t||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:D(e)?e.id:void 0}).catch(f=>this.onerror?.(f));return}const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const n={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._url,n),u=i.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!i.ok){const f=await i.text().catch(()=>null);if(i.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new $(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:m,scope:T}=W(i);if(this._resourceMetadataUrl=m,this._scope=T,await H(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P;return this._hasCompletedAuthFlow=!0,this.send(e)}if(i.status===403&&this._authProvider){const{resourceMetadataUrl:m,scope:T,error:y}=W(i);if(y==="insufficient_scope"){const v=i.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===v)throw new $(403,"Server returned 403 after trying upscoping");if(T&&(this._scope=T),m&&(this._resourceMetadataUrl=m),this._lastUpscopingHeader=v??void 0,await H(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new P;return this.send(e)}}throw new $(i.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,i.status===202){await i.body?.cancel(),Qe(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}const l=(Array.isArray(e)?e:[e]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,d=i.headers.get("content-type");if(l)if(d?.includes("text/event-stream"))this._handleSseStream(i.body,{onresumptiontoken:r},!1);else if(d?.includes("application/json")){const f=await i.json(),m=Array.isArray(f)?f.map(T=>N.parse(T)):[N.parse(f)];for(const T of m)this.onmessage?.(T)}else throw await i.body?.cancel(),new $(-1,`Unexpected content type: ${d}`);else await i.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,t);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new $(s.status,`Failed to terminate session: ${s.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};class ft extends ht{constructor(e,t){super(e,t)}send(e,t){const s=pt(e);return s?.type==="emit"?(this.onmessage?.(s.message),Promise.resolve()):s?.type==="suppress"?Promise.resolve():super.send(e,t)}}function pt(a){const e=a;if(!e||typeof e!="object"||!("method"in e))return null;switch(e.method){case"initialize":{const t=e?.params?.protocolVersion;return t?{type:"emit",message:{result:{protocolVersion:t,capabilities:{tools:{},resources:{},prompts:{},tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}},serverInfo:{name:"studio-virtual-mcp",version:"1.0.0"}},jsonrpc:e.jsonrpc??"2.0",id:e.id}}:null}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}const mt={name:"studio-sdk",version:"1.0.0"};function _t(a,e,t){const s=t??(typeof window<"u"?window.location.origin:void 0);if(!s)throw new Error("MCP client requires either studioUrl or a browser environment.");const r=`/api/${encodeURIComponent(e)}`,o=a?`${r}/mcp/${a}`:`${r}/mcp`;return new URL(o,s).href}async function ae({connectionId:a,orgId:e,orgSlug:t,token:s,studioUrl:r,meshUrl:o,mcpUrl:n}){const i=U({studioUrl:r,meshUrl:o}),u=z.mcpClient(e,a??"self",s??"",n??i??"");if(!n&&(!a||a===Je))return nt({orgSlug:t,token:s,studioUrl:i,toJSONString:`mcp-client:${u.join(":")}`});const p=n??_t(a,t,i),l=new at(mt,{capabilities:{tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}}}),d=new ft(new URL(p),{requestInit:{headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream",...s?{Authorization:`Bearer ${s}`}:{}}}});return await l.connect(d),l.toJSON=()=>`mcp-client:${u.join(":")}`,l}function wt(a){const{connectionId:e,token:t,studioUrl:s,meshUrl:r,mcpUrl:o,orgId:n}=a,i=U({studioUrl:s,meshUrl:r});return{queryKey:z.mcpClient(n,e??"self",t??"",o??i??""),queryFn:()=>ae(a),staleTime:1/0,gcTime:6e4}}function St(a){const e=se.c(2);let t;e[0]!==a?(t=wt(a),e[0]=a,e[1]=t):t=e[1];const{data:s}=re(t);return s}function Ct(a){const e=se.c(19),{connectionId:t,orgId:s,orgSlug:r,token:o,studioUrl:n,meshUrl:i,mcpUrl:u}=a;let p;e[0]!==i||e[1]!==n?(p=U({studioUrl:n,meshUrl:i}),e[0]=i,e[1]=n,e[2]=p):p=e[2];const l=p;let d;e[3]!==t||e[4]!==u||e[5]!==s||e[6]!==l||e[7]!==o?(d=t!==void 0?z.mcpClient(s,t??"self",o??"",u??l??""):["mcp","client","skip",s],e[3]=t,e[4]=u,e[5]=s,e[6]=l,e[7]=o,e[8]=d):d=e[8];const f=d;let m;e[9]!==t||e[10]!==u||e[11]!==s||e[12]!==r||e[13]!==l||e[14]!==o?(m=async()=>t===void 0?null:ae({connectionId:t,orgId:s,orgSlug:r,token:o,studioUrl:l,mcpUrl:u}),e[9]=t,e[10]=u,e[11]=s,e[12]=r,e[13]=l,e[14]=o,e[15]=m):m=e[15];let T;e[16]!==f||e[17]!==m?(T={queryKey:f,queryFn:m,staleTime:1/0,gcTime:6e4},e[16]=f,e[17]=m,e[18]=T):T=e[18];const{data:y}=re(T);return y??null}export{Ye as A,at as C,Ge as P,ht as S,Ct as a,lt as b,ae as c,it as d,wt as m,V as n,St as u};
|
|
6
|
+
${C}`,p++}else ee(h,c,v)?l=h.slice(h.charCodeAt(c+6)===I?c+7:c+6,w)||void 0:m(h,c,w);c=w+1,w=h.indexOf(`
|
|
7
|
+
`,c)}return h.slice(c)}for(;c<h.length;){const w=h.indexOf("\r",c),v=h.indexOf(`
|
|
8
|
+
`,c);let S=-1;if(w!==-1&&v!==-1?S=w<v?w:v:w!==-1?w===h.length-1?S=-1:S=w:v!==-1&&(S=v),S===-1)break;m(h,c,S),c=S+1,h.charCodeAt(c-1)===ct&&h.charCodeAt(c)===Y&&c++}return h.slice(c)}function m(h,c,w){if(c===w){y();return}const v=h.charCodeAt(c);if(X(h,c,v)){const E=h.charCodeAt(c+5)===I?c+6:c+5,Q=h.slice(E,w);u=p===0?Q:`${u}
|
|
9
|
+
${Q}`,p++;return}if(ee(h,c,v)){l=h.slice(h.charCodeAt(c+6)===I?c+7:c+6,w)||void 0;return}if(v===105&&h.charCodeAt(c+1)===100&&h.charCodeAt(c+2)===58){const E=h.slice(h.charCodeAt(c+3)===I?c+4:c+3,w);i=E.includes("\0")?void 0:E;return}if(v===58){if(r){const E=h.slice(c,w);r(E.slice(h.charCodeAt(c+1)===I?2:1))}return}const S=h.slice(c,w),C=S.indexOf(":");if(C===-1){T(S,"",S);return}const ne=S.slice(0,C),ie=S.charCodeAt(C+1)===I?2:1,ce=S.slice(C+ie);T(ne,ce,S)}function T(h,c,w){switch(h){case"event":l=c||void 0;break;case"data":u=p===0?c:`${u}
|
|
10
|
+
${c}`,p++;break;case"id":i=c.includes("\0")?void 0:c;break;case"retry":/^\d+$/.test(c)?s(parseInt(c,10)):t(new B(`Invalid \`retry\` value: "${c}"`,{type:"invalid-retry",value:c,line:w}));break;default:t(new B(`Unknown field "${h.length>20?`${h.slice(0,20)}…`:h}"`,{type:"unknown-field",field:h,value:c,line:w}));break}}function y(){p>0&&e({id:i,event:l,data:u}),i=void 0,u="",p=0,l=void 0}function k(h={}){if(h.consume&&o.length>0){const c=o.join("");m(c,0,c.length)}n=!0,i=void 0,u="",p=0,l=void 0,o.length=0}return{feed:d,reset:k}}function X(a,e,t){return t===100&&a.charCodeAt(e+1)===97&&a.charCodeAt(e+2)===116&&a.charCodeAt(e+3)===97&&a.charCodeAt(e+4)===58}function ee(a,e,t){return t===101&&a.charCodeAt(e+1)===118&&a.charCodeAt(e+2)===101&&a.charCodeAt(e+3)===110&&a.charCodeAt(e+4)===116&&a.charCodeAt(e+5)===58}class ut extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let r;super({start(o){r=lt({onEvent:n=>{o.enqueue(n)},onError(n){e==="terminate"?o.error(n):typeof e=="function"&&e(n)},onRetry:t,onComment:s})},transform(o){r.feed(o)}})}}const dt={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class $ extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}let ht=class{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=it(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??dt}async _authThenStart(){if(!this._authProvider)throw new P("No auth provider");let e;try{e=await H(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(t){throw this.onerror?.(t),t}if(e!=="AUTHORIZED")throw new P;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=V(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){const{resumptionToken:t}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),t&&s.set("last-event-id",t);const r=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!r.ok){if(await r.body?.cancel(),r.status===401&&this._authProvider)return await this._authThenStart();if(r.status===405)return;throw new $(r.status,`Failed to open SSE stream: ${r.statusText}`)}this._handleSseStream(r.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),r)}_scheduleReconnection(e,t=0){const s=this._reconnectionOptions.maxRetries;if(t>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}const r=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(o=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`)),this._scheduleReconnection(e,t+1)})},r)}_handleSseStream(e,t,s){if(!e)return;const{onresumptiontoken:r,replayMessageId:o}=t;let n,i=!1,u=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new ut({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){const{value:m,done:T}=await l.read();if(T)break;if(m.id&&(n=m.id,i=!0,r?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{const y=N.parse(JSON.parse(m.data));M(y)&&(u=!0,o!==void 0&&(y.id=o)),this.onmessage?.(y)}catch(y){this.onerror?.(y)}}(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:o},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||i)&&!u&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:r,replayMessageId:o},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new P("No auth provider");if(await H(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{const{resumptionToken:s,onresumptiontoken:r}=t||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:D(e)?e.id:void 0}).catch(f=>this.onerror?.(f));return}const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const n={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:this._abortController?.signal},i=await(this._fetch??fetch)(this._url,n),u=i.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!i.ok){const f=await i.text().catch(()=>null);if(i.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new $(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:m,scope:T}=W(i);if(this._resourceMetadataUrl=m,this._scope=T,await H(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new P;return this._hasCompletedAuthFlow=!0,this.send(e)}if(i.status===403&&this._authProvider){const{resourceMetadataUrl:m,scope:T,error:y}=W(i);if(y==="insufficient_scope"){const k=i.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===k)throw new $(403,"Server returned 403 after trying upscoping");if(T&&(this._scope=T),m&&(this._resourceMetadataUrl=m),this._lastUpscopingHeader=k??void 0,await H(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new P;return this.send(e)}}throw new $(i.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,i.status===202){await i.body?.cancel(),Qe(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}const l=(Array.isArray(e)?e:[e]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,d=i.headers.get("content-type");if(l)if(d?.includes("text/event-stream"))this._handleSseStream(i.body,{onresumptiontoken:r},!1);else if(d?.includes("application/json")){const f=await i.json(),m=Array.isArray(f)?f.map(T=>N.parse(T)):[N.parse(f)];for(const T of m)this.onmessage?.(T)}else throw await i.body?.cancel(),new $(-1,`Unexpected content type: ${d}`);else await i.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,t);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new $(s.status,`Failed to terminate session: ${s.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};class ft extends ht{constructor(e,t){super(e,t)}send(e,t){const s=pt(e);return s?.type==="emit"?(this.onmessage?.(s.message),Promise.resolve()):s?.type==="suppress"?Promise.resolve():super.send(e,t)}}function pt(a){const e=a;if(!e||typeof e!="object"||!("method"in e))return null;switch(e.method){case"initialize":{const t=e?.params?.protocolVersion;return t?{type:"emit",message:{result:{protocolVersion:t,capabilities:{tools:{},resources:{},prompts:{},tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}},serverInfo:{name:"studio-virtual-mcp",version:"1.0.0"}},jsonrpc:e.jsonrpc??"2.0",id:e.id}}:null}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}const mt={name:"studio-sdk",version:"1.0.0"};function _t(a,e,t){const s=t??(typeof window<"u"?window.location.origin:void 0);if(!s)throw new Error("MCP client requires either studioUrl or a browser environment.");const r=`/api/${encodeURIComponent(e)}`,o=a?`${r}/mcp/${a}`:`${r}/mcp`;return new URL(o,s).href}async function ae({connectionId:a,orgId:e,orgSlug:t,token:s,studioUrl:r,meshUrl:o,mcpUrl:n}){const i=U({studioUrl:r,meshUrl:o}),u=z.mcpClient(e,a??"self",s??"",n??i??"");if(!n&&(!a||a===Je))return nt({orgSlug:t,token:s,studioUrl:i,toJSONString:`mcp-client:${u.join(":")}`});const p=n??_t(a,t,i),l=new at(mt,{capabilities:{tasks:{list:{},cancel:{},requests:{tool:{call:{}}}}}}),d=new ft(new URL(p),{requestInit:{headers:{"Content-Type":"application/json",Accept:"application/json, text/event-stream",...s?{Authorization:`Bearer ${s}`}:{}}}});return await l.connect(d),l.toJSON=()=>`mcp-client:${u.join(":")}`,l}function wt(a){const{connectionId:e,token:t,studioUrl:s,meshUrl:r,mcpUrl:o,orgId:n}=a,i=U({studioUrl:s,meshUrl:r});return{queryKey:z.mcpClient(n,e??"self",t??"",o??i??""),queryFn:()=>ae(a),staleTime:1/0,gcTime:6e4}}function St(a){const e=se.c(2);let t;e[0]!==a?(t=wt(a),e[0]=a,e[1]=t):t=e[1];const{data:s}=re(t);return s}function Ct(a){const e=se.c(19),{connectionId:t,orgId:s,orgSlug:r,token:o,studioUrl:n,meshUrl:i,mcpUrl:u}=a;let p;e[0]!==i||e[1]!==n?(p=U({studioUrl:n,meshUrl:i}),e[0]=i,e[1]=n,e[2]=p):p=e[2];const l=p;let d;e[3]!==t||e[4]!==u||e[5]!==s||e[6]!==l||e[7]!==o?(d=t!==void 0?z.mcpClient(s,t??"self",o??"",u??l??""):["mcp","client","skip",s],e[3]=t,e[4]=u,e[5]=s,e[6]=l,e[7]=o,e[8]=d):d=e[8];const f=d;let m;e[9]!==t||e[10]!==u||e[11]!==s||e[12]!==r||e[13]!==l||e[14]!==o?(m=async()=>t===void 0?null:ae({connectionId:t,orgId:s,orgSlug:r,token:o,studioUrl:l,mcpUrl:u}),e[9]=t,e[10]=u,e[11]=s,e[12]=r,e[13]=l,e[14]=o,e[15]=m):m=e[15];let T;e[16]!==f||e[17]!==m?(T={queryKey:f,queryFn:m,staleTime:1/0,gcTime:6e4},e[16]=f,e[17]=m,e[18]=T):T=e[18];const{data:y}=re(T);return y??null}export{Ye as A,at as C,Ge as P,ht as S,Ct as a,lt as b,ae as c,it as d,wt as m,V as n,St as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as m,o as p,z as q,K as T}from"./index-C-W5dASy.js";function C(n){const e=m.c(12);let t,o;e[0]!==n?({client:t,...o}=n,e[0]=n,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let s;e[5]!==t?(s=async()=>await t.listTools(),e[5]=t,e[6]=s):s=e[6];const r=o.staleTime??3e4;let i;return e[7]!==o||e[8]!==l||e[9]!==s||e[10]!==r?(i={...o,queryKey:l,queryFn:s,staleTime:r,retry:!1},e[7]=o,e[8]=l,e[9]=s,e[10]=r,e[11]=i):i=e[11],q(i)}function K(n){const e=m.c(12);let t,o;e[0]!==n?({client:t,...o}=n,e[0]=n,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let l;e[3]!==t?(l=T.mcpToolsList(t),e[3]=t,e[4]=l):l=e[4];let s;e[5]!==t?(s=async()=>await t.listTools(),e[5]=t,e[6]=s):s=e[6];const r=o.staleTime??3e4;let i;return e[7]!==o||e[8]!==l||e[9]!==s||e[10]!==r?(i={...o,queryKey:l,queryFn:s,staleTime:r,retry:!1},e[7]=o,e[8]=l,e[9]=s,e[10]=r,e[11]=i):i=e[11],p(i)}function O(n){const e=m.c(21);let t,o,l,s;e[0]!==n?({client:t,toolName:s,toolArguments:l,...o}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=l,e[4]=s):(t=e[1],o=e[2],l=e[3],s=e[4]);let r,i,u;if(e[5]!==t||e[6]!==o||e[7]!==l||e[8]!==s){const f=JSON.stringify(l??{});u=q,r=o,i=T.mcpToolCall(t,s,f),e[5]=t,e[6]=o,e[7]=l,e[8]=s,e[9]=r,e[10]=i,e[11]=u}else r=e[9],i=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==s?(a=async()=>await t.callTool({name:s,arguments:l}),e[12]=t,e[13]=l,e[14]=s,e[15]=a):a=e[15];const y=o.staleTime??3e4;let c;return e[16]!==r||e[17]!==i||e[18]!==a||e[19]!==y?(c={...r,queryKey:i,queryFn:a,staleTime:y,retry:!1},e[16]=r,e[17]=i,e[18]=a,e[19]=y,e[20]=c):c=e[20],u(c)}function w(n){const e=m.c(21);let t,o,l,s;e[0]!==n?({client:t,toolName:s,toolArguments:l,...o}=n,e[0]=n,e[1]=t,e[2]=o,e[3]=l,e[4]=s):(t=e[1],o=e[2],l=e[3],s=e[4]);let r,i,u;if(e[5]!==t||e[6]!==o||e[7]!==l||e[8]!==s){const f=JSON.stringify(l??{});u=p,r=o,i=T.mcpToolCall(t,s,f),e[5]=t,e[6]=o,e[7]=l,e[8]=s,e[9]=r,e[10]=i,e[11]=u}else r=e[9],i=e[10],u=e[11];let a;e[12]!==t||e[13]!==l||e[14]!==s?(a=async()=>await t.callTool({name:s,arguments:l}),e[12]=t,e[13]=l,e[14]=s,e[15]=a):a=e[15];const y=o.staleTime??3e4;let c;return e[16]!==r||e[17]!==i||e[18]!==a||e[19]!==y?(c={...r,queryKey:i,queryFn:a,staleTime:y,retry:!1},e[16]=r,e[17]=i,e[18]=a,e[19]=y,e[20]=c):c=e[20],u(c)}export{K as a,C as b,O as c,w as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c,H as m,z as b,o as M,K as f}from"./index-C-W5dASy.js";import{u as y}from"./use-org-auth-client-DCF2a5iN.js";const p=300*1e3;function d(){const t=c.c(7),{locator:e}=m(),r=y();let o;t[0]!==e?(o=f.members(e),t[0]=e,t[1]=o):o=t[1];let s;t[2]!==r?(s=()=>r.organization.listMembers(),t[2]=r,t[3]=s):s=t[3];let n;return t[4]!==o||t[5]!==s?(n={queryKey:o,queryFn:s},t[4]=o,t[5]=s,t[6]=n):n=t[6],b(n)}function q(t){const e=c.c(10);let r;e[0]!==t?(r=t===void 0?{}:t,e[0]=t,e[1]=r):r=e[1];const{enabled:o}=r,s=o===void 0?!0:o,{locator:n}=m(),a=y();let u;e[2]!==n?(u=f.members(n),e[2]=n,e[3]=u):u=e[3];let i;e[4]!==a?(i=()=>a.organization.listMembers(),e[4]=a,e[5]=i):i=e[5];let l;return e[6]!==s||e[7]!==u||e[8]!==i?(l={queryKey:u,queryFn:i,staleTime:p,enabled:s},e[6]=s,e[7]=u,e[8]=i,e[9]=l):l=e[9],M(l)}export{d as a,q as u};
|