decocms 2.306.8 → 2.306.9
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-BTzXzMwa.js → AlertCircle-DJf7WJW3.js} +1 -1
- package/dist/client/assets/{ArrowNarrowLeft-D2yH9wXQ.js → ArrowNarrowLeft-zhth65sS.js} +1 -1
- package/dist/client/assets/{ArrowUpRight-Oalb5bG5.js → ArrowUpRight-B3qf65r_.js} +1 -1
- package/dist/client/assets/{Check-D4yu1L9M.js → Check-BA7p_1wq.js} +1 -1
- package/dist/client/assets/{CheckCircle-Ce90skz0.js → CheckCircle-Y9PieZLB.js} +1 -1
- package/dist/client/assets/{ChevronDown-BqGwceCn.js → ChevronDown-CHAav7qy.js} +1 -1
- package/dist/client/assets/{ChevronRight-BRV7Tdzz.js → ChevronRight-2ozRd8ql.js} +1 -1
- package/dist/client/assets/{ChevronUp-pbRiDYbB.js → ChevronUp-DiTrXBul.js} +1 -1
- package/dist/client/assets/{Container-Cf08ks6f.js → Container-C2bhieKl.js} +1 -1
- package/dist/client/assets/{DotsVertical-Cb1IeswQ.js → DotsVertical-EPasiNNs.js} +1 -1
- package/dist/client/assets/{LinkExternal01-DfeIVyGK.js → LinkExternal01-BPHdX5PH.js} +1 -1
- package/dist/client/assets/{Lock01-B6CuPSqy.js → Lock01-BGF0eORu.js} +1 -1
- package/dist/client/assets/{Palette-6MGVk9XZ.js → Palette-C_hdzDFv.js} +1 -1
- package/dist/client/assets/{Play-Z9TLXhXZ.js → Play-F9KGb4fS.js} +1 -1
- package/dist/client/assets/{Plus-BWFmeYbA.js → Plus-yWDQ_tpZ.js} +1 -1
- package/dist/client/assets/{RefreshCcw01-DdNBG9uq.js → RefreshCcw01-02Zm-r_b.js} +1 -1
- package/dist/client/assets/{SearchMd-Bk2WMaal.js → SearchMd-KthT6Z0D.js} +1 -1
- package/dist/client/assets/{Settings02-DV_JgL_i.js → Settings02-o9kWs5LM.js} +1 -1
- package/dist/client/assets/{Shield01-DabBYOJe.js → Shield01-C6IvOcka.js} +1 -1
- package/dist/client/assets/{Star01-EsNS3h_Z.js → Star01-DfneWwne.js} +1 -1
- package/dist/client/assets/{Sun-BSBNF16W.js → Sun-jEEtT5QL.js} +1 -1
- package/dist/client/assets/{Tool01-BLP2PhNo.js → Tool01-Ba51oSqA.js} +1 -1
- package/dist/client/assets/{Trash01-BrCWXUwU.js → Trash01-phS8Heeq.js} +1 -1
- package/dist/client/assets/{User01-YnNa4o8H.js → User01-ZJzkhpRI.js} +1 -1
- package/dist/client/assets/{Users03-ju7GWCNc.js → Users03-BpQp0OZp.js} +1 -1
- package/dist/client/assets/{X-Bwb7_m5v.js → X-C7tkmqiA.js} +1 -1
- package/dist/client/assets/{XCircle-CH3QyMaX.js → XCircle-D-iHz9mr.js} +1 -1
- package/dist/client/assets/{XClose-CWzVSlUZ.js → XClose-DGH-dkmK.js} +1 -1
- package/dist/client/assets/{Zap-ByRL5ggZ.js → Zap-B3d9PZiM.js} +1 -1
- package/dist/client/assets/{ZapSquare-DwXwFOB5.js → ZapSquare-zYT4mArq.js} +1 -1
- package/dist/client/assets/{accordion-DEfiI4_u.js → accordion-hHFtU32i.js} +1 -1
- package/dist/client/assets/{agent-icon-BWW-_spm.js → agent-icon-CJE3IrTn.js} +1 -1
- package/dist/client/assets/{agents-list-DtSKcauO.js → agents-list-vYYge1ev.js} +1 -1
- package/dist/client/assets/ai-providers-CqQQNPte.js +1 -0
- package/dist/client/assets/{alert-dialog-CIRyCiSh.js → alert-dialog-BX6tjxLQ.js} +1 -1
- package/dist/client/assets/{auth-catchall-DM2HSAyx.js → auth-catchall-tLsDaZib.js} +1 -1
- package/dist/client/assets/{automation-list-row-BZQnmXsD.js → automation-list-row-CcwE53y-.js} +1 -1
- package/dist/client/assets/{automations-BpoAkXQ6.js → automations-BESFBIp2.js} +1 -1
- package/dist/client/assets/{avatar-O6nD_RVH.js → avatar-qtN1d68D.js} +1 -1
- package/dist/client/assets/{badge-1GzX8YfJ.js → badge-B9X-6Gl1.js} +1 -1
- package/dist/client/assets/{brand-context-pSsdhU7u.js → brand-context-XewU7lcG.js} +1 -1
- package/dist/client/assets/{card-YRPYO7rK.js → card-BoqhySt6.js} +1 -1
- package/dist/client/assets/{chat-context-BXGy7Agh.js → chat-context-CKn0S8Zn.js} +1 -1
- package/dist/client/assets/{checkbox-BtvQbCay.js → checkbox-CsbRNJyh.js} +1 -1
- package/dist/client/assets/{collection-detail--ucxh4J-.js → collection-detail-CNKa10ok.js} +1 -1
- package/dist/client/assets/{collection-display-button-CMOfNtao.js → collection-display-button-DKtSFWra.js} +1 -1
- package/dist/client/assets/{collection-search-CYChlQpy.js → collection-search-B3qdCdab.js} +1 -1
- package/dist/client/assets/{collection-search-mbr97YEK.js → collection-search-Ce1lQnUu.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-BnAWIjfr.js → collection-table-wrapper-Bd9ZSFN9.js} +1 -1
- package/dist/client/assets/{collection-tabs-CkdgJkBV.js → collection-tabs-f6wZXNju.js} +1 -1
- package/dist/client/assets/{collections-BFntmLot.js → collections-DW4PTltg.js} +1 -1
- package/dist/client/assets/{command-Cbz_0bPm.js → command-COSC6-sU.js} +1 -1
- package/dist/client/assets/{connection-card-BLDKB8T1.js → connection-card-CZXyfhfz.js} +1 -1
- package/dist/client/assets/{connection-detail-BFIdeQRn.js → connection-detail-j7Z5rP7l.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-CSJOop0l.js → connection-form-helpers-BlYNQpCT.js} +1 -1
- package/dist/client/assets/{connections-BW08Tw6P.js → connections-BV8XJOt_.js} +1 -1
- package/dist/client/assets/{constants-O6TOd6Fi.js → constants-BVAyWr7s.js} +1 -1
- package/dist/client/assets/{constants-CyYXtNQt.js → constants-DGVET5nO.js} +1 -1
- package/dist/client/assets/{dialog-BapANLA4.js → dialog-Hnl5R_ro.js} +1 -1
- package/dist/client/assets/{domain-settings-BiGD_AWa.js → domain-settings-C-IlkGnr.js} +1 -1
- package/dist/client/assets/{drawer-DXfcxG35.js → drawer-Crup1SLH.js} +1 -1
- package/dist/client/assets/{dropdown-menu-8r0P5O89.js → dropdown-menu-V4M0HjsW.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-88jqqJ-n.js → dynamic-plugin-layout-8c6x-ky8.js} +1 -1
- package/dist/client/assets/{empty-state-CxaKSceI.js → empty-state-CZ3CJw7j.js} +1 -1
- package/dist/client/assets/{empty-state-D31vnJxY.js → empty-state-D5_lJgOy.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BAmE4x-0.js → extract-connection-data-em000wPy.js} +1 -1
- package/dist/client/assets/{features-Zs1cJ0se.js → features-DAVmQLQk.js} +1 -1
- package/dist/client/assets/{form-vm22t8bs.js → form-C7tw7wIR.js} +1 -1
- package/dist/client/assets/{general-DOQdXWNJ.js → general-DnnDmUeP.js} +1 -1
- package/dist/client/assets/{index-DSEbXUmT.js → index-BFRqxr4t.js} +1 -1
- package/dist/client/assets/{index-DnMFHGHl.js → index-BOzqanlB.js} +1 -1
- package/dist/client/assets/{index-C3KqPz7f.js → index-Bbymo0Ib.js} +1 -1
- package/dist/client/assets/index-Bg9RJYuW.js +1 -0
- package/dist/client/assets/{index-DCtZqQ0W.js → index-CA3OM7o_.js} +1 -1
- package/dist/client/assets/{index-CtJ1_vQP.js → index-CnknCe9i.js} +2 -2
- package/dist/client/assets/{index-4ADaRsb3.js → index-CoJ8j1Pw.js} +1 -1
- package/dist/client/assets/{index-BZSJm92U.js → index-DNL4AbVG.js} +1 -1
- package/dist/client/assets/{index-CZoa5Voq.js → index-DUQBUyCZ.js} +1 -1
- package/dist/client/assets/{index-B1K3k56c.js → index-DkII30Yp.js} +1 -1
- package/dist/client/assets/{index-Irwc0F9z.js → index-Dq2z-GHI.js} +1 -1
- package/dist/client/assets/{index-CDWEA7tA.js → index-DtUD0Pyz.js} +3 -3
- package/dist/client/assets/{index-cMeVTxue.js → index-HuDOZoSO.js} +1 -1
- package/dist/client/assets/{index-COg7cSsl.js → index-RIIjlnIA.js} +1 -1
- package/dist/client/assets/{index-CHlpZld0.js → index-XN9sCkdo.js} +1 -1
- package/dist/client/assets/{index-Dy9FasiB.js → index-pVdenInH.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-BORSReP2.js → infiniteQueryObserver-BpzCmbvi.js} +1 -1
- package/dist/client/assets/{input-DzKH4IoC.js → input-tSjlegEI.js} +1 -1
- package/dist/client/assets/{integration-icon-DZ1DDayM.js → integration-icon-BIIE53tx.js} +1 -1
- package/dist/client/assets/{label-B1j7QJO9.js → label-BPDMOqL-.js} +1 -1
- package/dist/client/assets/{layout-CgSQP9Dz.js → layout-CdewzpDg.js} +1 -1
- package/dist/client/assets/{lean-canvas-recruit-modal-CkuRnY-q.js → lean-canvas-recruit-modal-vF31gMjX.js} +1 -1
- package/dist/client/assets/{login-BFVakp9W.js → login-BoZD0ihV.js} +1 -1
- package/dist/client/assets/{members-BvtGRXTq.js → members-Cu6j2bC_.js} +1 -1
- package/dist/client/assets/{monaco-editor-DbLGolnd.js → monaco-editor-BkaEDfnn.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-Bs9q7htN.js → monitoring-stats-row-B4VSVC5f.js} +1 -1
- package/dist/client/assets/{oauth-callback-C2IfOXdE.js → oauth-callback-BZ22lnb7.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-DjdeIGJy.js → oauth-callback-ai-provider-DdNo-cUU.js} +1 -1
- package/dist/client/assets/{onboarding-qQL2AHJp.js → onboarding-BsxXp_91.js} +1 -1
- package/dist/client/assets/{org-layout-r-dIMXY7.js → org-layout-C5IzT9XM.js} +1 -1
- package/dist/client/assets/{org-plugin-layout-BdbYhknE.js → org-plugin-layout-rnBVYx1J.js} +1 -1
- package/dist/client/assets/{pair-BeVk0nw4.js → pair-CgrOS8jZ.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-tnsMkLWl.js → plugin-empty-state-DrUsi_Xi.js} +1 -1
- package/dist/client/assets/{plugin-header-DlR3Hsv1.js → plugin-header-CdV-nsX3.js} +1 -1
- package/dist/client/assets/{plugin-layout-j_5ixQWh.js → plugin-layout-CazyvxCF.js} +1 -1
- package/dist/client/assets/{popover-BoJSCjqj.js → popover-B72j1a-i.js} +1 -1
- package/dist/client/assets/{profile-DJw46v6U.js → profile-Cu0ySZu7.js} +1 -1
- package/dist/client/assets/{project-app-view-CqGwq86p.js → project-app-view-DrBetUBZ.js} +1 -1
- package/dist/client/assets/registry-BcpPcvh_.js +2 -0
- package/dist/client/assets/{registry-layout-CKKMYc0F.js → registry-layout-CjG7kzKY.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BOqEO0UW.js → required-auth-layout-DesCgYHR.js} +1 -1
- package/dist/client/assets/{reset-password-DC2CZqgK.js → reset-password-eRneDfhd.js} +1 -1
- package/dist/client/assets/{roles-B7M_sNQI.js → roles-BOPJuCtk.js} +1 -1
- package/dist/client/assets/{scroll-area-CVP2hanW.js → scroll-area-B7p5KGay.js} +1 -1
- package/dist/client/assets/{search-input-DBJx5Puk.js → search-input-BkMpxSNZ.js} +1 -1
- package/dist/client/assets/{select-BL-3WYG3.js → select-Cgq5fB25.js} +1 -1
- package/dist/client/assets/{select-model-CBeAOuD4.js → select-model-BrcDDMDY.js} +1 -1
- package/dist/client/assets/{settings-layout-D4-CafDE.js → settings-layout-DnlWM3l_.js} +1 -1
- package/dist/client/assets/{settings-section-sY44gYa3.js → settings-section-BnPqXFEQ.js} +1 -1
- package/dist/client/assets/{shell-layout-BRqsQqla.js → shell-layout-KvQC2n8R.js} +1 -1
- package/dist/client/assets/{skeleton-BWfslVYc.js → skeleton-DIbgbTEL.js} +1 -1
- package/dist/client/assets/{sso-CqR7Oikv.js → sso-CKV2Ny8h.js} +1 -1
- package/dist/client/assets/{store-QjnVaNvS.js → store-OiRvkTn1.js} +1 -1
- package/dist/client/assets/store-registry-CcoZihF8.js +2 -0
- package/dist/client/assets/{switch-ClIsCuo0.js → switch-DHlXaCRu.js} +1 -1
- package/dist/client/assets/{table-DLr2fSXp.js → table-DM5YCF_t.js} +1 -1
- package/dist/client/assets/{tabs-CEhOvCGw.js → tabs-DP8p-QKj.js} +1 -1
- package/dist/client/assets/{task-status-C-SQfZZK.js → task-status-RjLfrU9E.js} +1 -1
- package/dist/client/assets/{textarea-BQD2K7xE.js → textarea-BKxnYjv4.js} +1 -1
- package/dist/client/assets/{toggle-group-i71R22i3.js → toggle-group-BTIHjGuh.js} +1 -1
- package/dist/client/assets/{tools-list-CPm-Mx4D.js → tools-list-DltD98In.js} +1 -1
- package/dist/client/assets/{tooltip-BTEnXfpw.js → tooltip-VTeNtMCR.js} +1 -1
- package/dist/client/assets/{types-lb3PNUQc.js → types-DXN89wPs.js} +1 -1
- package/dist/client/assets/{use-ai-providers-BKH_isZv.js → use-ai-providers-Dn3Z7IEd.js} +1 -1
- package/dist/client/assets/{use-collections-VlH2NrqV.js → use-collections-CiD-L_rq.js} +1 -1
- package/dist/client/assets/{use-connection-M1xDmD9i.js → use-connection-JNwwjcGV.js} +1 -1
- package/dist/client/assets/{use-copy-DEJBJAsZ.js → use-copy-BC2pt5R_.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-BL0xa08p.js → use-create-virtual-mcp-BaV_MWOd.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-DJj5fuFt.js → use-debounced-autosave-BZkVf5Bt.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-Bb2NleBN.js → use-decopilot-events-CNFY9Cdo.js} +1 -1
- package/dist/client/assets/{use-delete-connection-Bib86QGR.js → use-delete-connection-B92EkvSW.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-D8nIolCd.js → use-infinite-scroll-DxHMXvd2.js} +1 -1
- package/dist/client/assets/{use-list-state-BYi_uUtE.js → use-list-state-CC6sLPth.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-CtUqFvLD.js → use-mcp-tools-CVArZMz4.js} +1 -1
- package/dist/client/assets/{use-members-CdkSabwq.js → use-members-DwBHQoXS.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-D91A1ehg.js → use-navigate-to-agent-CBT4EeEo.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-CANxngbZ.js → use-org-auth-client-Btoi24Ng.js} +1 -1
- package/dist/client/assets/{use-org-sso-KaCvgTMV.js → use-org-sso-BraRussC.js} +1 -1
- package/dist/client/assets/{use-organization-roles-BXlhN5BZ.js → use-organization-roles-D_UI-fW0.js} +1 -1
- package/dist/client/assets/{use-organization-settings-CCxU4osF.js → use-organization-settings-Dxy82qy3.js} +1 -1
- package/dist/client/assets/{use-registry-connections-CcXpK-ys.js → use-registry-connections-Dutuf-7C.js} +1 -1
- package/dist/client/assets/{use-status-sounds-Cwi7Sfh7.js → use-status-sounds-D0gU5bqv.js} +1 -1
- package/dist/client/assets/{use-tasks-D03EtFvf.js → use-tasks-dDV8jhdD.js} +1 -1
- package/dist/client/assets/{use-view-mode-CQIRYhjw.js → use-view-mode-CNrwjFk2.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-CX5iadV3.js → use-virtual-mcp-DYwCZbrQ.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-DgNRpfvJ.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-olKcjkDq.js +1 -0
- package/dist/client/assets/{user-C8zZ-7QW.js → user-kEnfgZB9.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-Cw5HKJog.js → view-mode-toggle-CrpJwZiO.js} +1 -1
- package/dist/client/assets/{workflow-Det6DT4b.js → workflow-BXznQ79f.js} +1 -1
- package/dist/client/assets/workflow-detail-DeJ9MrPo.js +1 -0
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +1 -8
- package/dist/server/node_modules/cli-boxes/boxes.json +82 -0
- package/dist/server/node_modules/cli-boxes/index.d.ts +127 -0
- package/dist/server/node_modules/cli-boxes/index.js +6 -0
- package/dist/server/node_modules/cli-boxes/license +9 -0
- package/dist/server/node_modules/cli-boxes/package.json +42 -0
- package/dist/server/node_modules/cli-boxes/readme.md +115 -0
- package/dist/server/node_modules/cli-spinners/index.d.ts +139 -0
- package/dist/server/node_modules/cli-spinners/index.js +11 -0
- package/dist/server/node_modules/cli-spinners/license +9 -0
- package/dist/server/node_modules/cli-spinners/package.json +56 -0
- package/dist/server/node_modules/cli-spinners/readme.md +74 -0
- package/dist/server/node_modules/cli-spinners/spinners.json +1697 -0
- package/dist/server/node_modules/{postgres-date/license → stack-utils/LICENSE.md} +1 -1
- package/dist/server/node_modules/stack-utils/index.js +344 -0
- package/dist/server/node_modules/stack-utils/package.json +39 -0
- package/dist/server/node_modules/stack-utils/readme.md +143 -0
- package/dist/server/server.js +0 -7
- package/package.json +1 -1
- package/dist/client/assets/ai-providers-Dmv17i-r.js +0 -1
- package/dist/client/assets/index-sD08ZTU7.js +0 -1
- package/dist/client/assets/registry-CRDkHUvw.js +0 -2
- package/dist/client/assets/store-registry-CEd7y-Xb.js +0 -2
- package/dist/client/assets/useInfiniteQuery-CgSxuvH6.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CH8re_uO.js +0 -1
- package/dist/client/assets/workflow-detail-BeFzNTls.js +0 -1
- package/dist/server/node_modules/postgres-bytea/index.js +0 -33
- package/dist/server/node_modules/postgres-bytea/license +0 -21
- package/dist/server/node_modules/postgres-bytea/package.json +0 -34
- package/dist/server/node_modules/postgres-bytea/readme.md +0 -34
- package/dist/server/node_modules/postgres-date/index.js +0 -116
- package/dist/server/node_modules/postgres-date/package.json +0 -33
- package/dist/server/node_modules/postgres-date/readme.md +0 -49
- package/dist/server/node_modules/postgres-interval/index.d.ts +0 -20
- package/dist/server/node_modules/postgres-interval/index.js +0 -125
- package/dist/server/node_modules/postgres-interval/license +0 -21
- package/dist/server/node_modules/postgres-interval/package.json +0 -36
- package/dist/server/node_modules/postgres-interval/readme.md +0 -48
- package/dist/server/node_modules/xtend/.jshintrc +0 -30
- package/dist/server/node_modules/xtend/LICENSE +0 -20
- package/dist/server/node_modules/xtend/README.md +0 -32
- package/dist/server/node_modules/xtend/immutable.js +0 -19
- package/dist/server/node_modules/xtend/mutable.js +0 -17
- package/dist/server/node_modules/xtend/package.json +0 -55
- package/dist/server/node_modules/xtend/test.js +0 -103
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-
|
|
2
|
-
import{o as ds,r as P,p as Ml,q as Il,e as H,s as ve,K as Bs,n as Uo,a as Vo,c as re,j as o,l as Ie,B as oe,E as Ht,b as Ci,v as oi,f as Bt,d as Jr,w as Al,x as pe,y as Bl,V as Pl,t as ye,z as Ko,C as Ll,D as $t,F as Ol,G as xn,L as zl,H as Li,I as Zs,J as ht,M as qo,P as $l,_ as Fl,Q as Go,R as Yo,T as Hl,g as Wl}from"./index-CtJ1_vQP.js";import{C as je,u as Ul,w as Vl,A as Kl,T as ql,a as Gl}from"./index-CHlpZld0.js";import{I as us}from"./integration-icon-DZ1DDayM.js";import{S as Pt,u as He,g as Xo,a as Jo}from"./constants-CyYXtNQt.js";import{u as Ct,a as Yl}from"./use-virtual-mcp-CX5iadV3.js";import{a as Xl}from"./Users03-ju7GWCNc.js";import{u as Zo,a as vt,b as Zr,c as fs,t as Jl,d as bn}from"./chat-context-BXGy7Agh.js";import{i as Ps}from"./AlertCircle-BTzXzMwa.js";import{i as Zl}from"./CheckCircle-Ce90skz0.js";import{n as Sn,a as Ql}from"./ZapSquare-DwXwFOB5.js";import{i as ec,a as tc,b as sc,c as ki,d as ic}from"./XCircle-CH3QyMaX.js";import{s as ls,i as rc}from"./XClose-CWzVSlUZ.js";import{c as nc,r as oc,p as Qo,f as yn,a as ac,F as lc,t as wn,M as Qr,G as ea,L as cc,i as hc,b as dc,d as uc,e as fc}from"./pair-BeVk0nw4.js";import{C as mc,a as Cn,b as kn,c as _c,d as pc,e as gc,f as vc}from"./command-Cbz_0bPm.js";import{P as Ws,a as Us,b as Vs}from"./popover-BoJSCjqj.js";import{i as Rs,a as pi,b as xc,c as bc,p as Ni,g as ji,d as en,e as ta,h as cr,f as Oi,j as Nn,A as jn,k as sa,l as Sc,m as yc,n as wc,t as Cc,o as kc,q as ai,r as ia,s as ra,u as na,v as En,w as Nc,x as Ds,y as jc,z as Ec,B as oa}from"./agent-icon-BWW-_spm.js";import{u as ms,a as Tc}from"./use-mcp-tools-CtUqFvLD.js";import{u as Rc,a as Dc}from"./use-ai-providers-BKH_isZv.js";import{g as Kt,c as Tn,u as Mc,b as hr,d as Ic,e as Ac,f as Bc,T as Pc}from"./index-cMeVTxue.js";import{u as Ei,i as Lc}from"./shell-layout-BRqsQqla.js";import{i as Oc,P as ct,u as zc,c as $c,d as Fc,e as Hc}from"./index-4ADaRsb3.js";import{u as aa,T as Ke,a as qe,b as Ge,c as Wc}from"./tooltip-BTEnXfpw.js";import{u as Uc}from"./use-status-sounds-Cwi7Sfh7.js";import{E as Ls}from"./empty-state-D31vnJxY.js";import{A as Vc,a as Kc,b as qc,c as Gc,R as la,d as Yc,e as Xc}from"./accordion-DEfiI4_u.js";import{u as Ti,a as tn,b as Jc}from"./use-connection-M1xDmD9i.js";import{g as Zc}from"./constants-O6TOd6Fi.js";import{u as Qc,g as eh}from"./types-lb3PNUQc.js";import{u as ca,G as th}from"./lean-canvas-recruit-modal-CkuRnY-q.js";import{U as ha}from"./user-C8zZ-7QW.js";import{T as sh,u as da}from"./tools-list-CPm-Mx4D.js";import{u as ih}from"./unwrap-tool-result-BYXdCQMg.js";import{s as ua,g as rh}from"./connection-slug-eyAPH6o3.js";import{A as fa,a as ma,b as _a,c as pa,d as ga,e as va,f as xa,g as ba}from"./alert-dialog-CIRyCiSh.js";import{D as nh,a as sn,b as rn,c as Sa,d as ya}from"./dialog-BapANLA4.js";import{C as oh,a as Rn}from"./card-YRPYO7rK.js";import{I as _s}from"./input-DzKH4IoC.js";import{L as Ms}from"./label-B1j7QJO9.js";import{S as ts,a as ss,b as is,c as rs,d as At}from"./select-BL-3WYG3.js";import{S as dr}from"./switch-ClIsCuo0.js";import{T as Dn}from"./textarea-BQD2K7xE.js";import{i as li}from"./Play-Z9TLXhXZ.js";import{s as cs}from"./Plus-BWFmeYbA.js";import{a as ah}from"./Settings02-DV_JgL_i.js";import{t as wa,i as lh}from"./Tool01-BLP2PhNo.js";import{s as ur}from"./Trash01-BrCWXUwU.js";import{u as Ca}from"./use-debounced-autosave-DJj5fuFt.js";import{S as ka}from"./scroll-area-CVP2hanW.js";import{i as Na,a as ch}from"./SearchMd-Bk2WMaal.js";import{C as hh}from"./collection-tabs-CkdgJkBV.js";import{C as dh}from"./checkbox-BtvQbCay.js";import{u as uh,T as zi,a as fh,b as mh,c as $i}from"./tabs-CEhOvCGw.js";import{D as _h,a as ph,b as gh}from"./drawer-DXfcxG35.js";import{i as Ri}from"./Check-D4yu1L9M.js";import{n as qt}from"./LinkExternal01-DfeIVyGK.js";import{S as vh}from"./index-DnMFHGHl.js";import{D as ns,a as os,b as as,c as wt,d as xh,e as bh,f as Sh}from"./dropdown-menu-8r0P5O89.js";import{t as fr}from"./ChevronDown-BqGwceCn.js";import{i as ja}from"./RefreshCcw01-DdNBG9uq.js";import{V as yh}from"./view-mode-toggle-Cw5HKJog.js";import{M as wh}from"./select-model-CBeAOuD4.js";import{u as Ks,a as Ch,b as kh,c as Nh,A as jh,d as Eh}from"./automation-list-row-BZQnmXsD.js";import{i as Os}from"./Zap-ByRL5ggZ.js";import{S as Th}from"./search-input-DBJx5Puk.js";import"./use-navigate-to-agent-D91A1ehg.js";import"./use-tasks-D03EtFvf.js";import"./use-collections-VlH2NrqV.js";import"./collection-search-mbr97YEK.js";import"./form-vm22t8bs.js";import"./Star01-EsNS3h_Z.js";import"./Lock01-B6CuPSqy.js";import"./X-Bwb7_m5v.js";import"./toggle-group-i71R22i3.js";import"./index-Dy9FasiB.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-BLDKB8T1.js";import"./use-registry-connections-CcXpK-ys.js";import"./use-organization-settings-CCxU4osF.js";import"./useInfiniteQuery-CgSxuvH6.js";import"./infiniteQueryObserver-BORSReP2.js";import"./extract-connection-data-BAmE4x-0.js";import"./Container-Cf08ks6f.js";import"./connection-form-helpers-CSJOop0l.js";import"./use-infinite-scroll-D8nIolCd.js";import"./useSuspenseInfiniteQuery-CH8re_uO.js";import"./badge-1GzX8YfJ.js";import"./ChevronRight-BRV7Tdzz.js";import"./use-decopilot-events-Bb2NleBN.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-DEJBJAsZ.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-BSBNF16W.js";import"./index-B1K3k56c.js";import"./ArrowNarrowLeft-D2yH9wXQ.js";import"./ArrowUpRight-Oalb5bG5.js";import"./ChevronUp-pbRiDYbB.js";import"./DotsVertical-Cb1IeswQ.js";import"./Palette-6MGVk9XZ.js";import"./Shield01-DabBYOJe.js";import"./User01-YnNa4o8H.js";import"./skeleton-BWfslVYc.js";import"./avatar-O6nD_RVH.js";import"./index-C3KqPz7f.js";import"./collection-search-CYChlQpy.js";import"./use-create-virtual-mcp-BL0xa08p.js";import"./task-status-C-SQfZZK.js";import"./required-auth-layout-BOqEO0UW.js";import"./use-org-sso-KaCvgTMV.js";import"./collections-BFntmLot.js";import"./settings-section-sY44gYa3.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Rh(t,e){const s=ds(e);return Dh({filters:{...t,status:"pending"}},s).length}function Mn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Dh(t={},e){const s=ds(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=Mn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=Ml(r.current,Mn(s,i.current));r.current!==a&&(r.current=a,Il.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Mh(t,e){const s=H.c(40),{org:i,locator:r}=ve();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Pt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=He(n),l=ds();let h;s[3]!==t||s[4]!==i.id?(h=Bs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Uo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(y.isError){const C=y.content,R=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(R)}return y.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Bs.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Vo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),P.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let y;return s[32]!==x?(y={status:"error",error:x},s[32]=x,s[33]=y):y=s[33],y}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function In(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Ih(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Ah(t){const e=H.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Bh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Bh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Ph(t){const e=H.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let y;return e[27]!==x||e[28]!==f?(y=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=y):y=e[29],y}function Lh(t){const e=H.c(19),{part:s}=t,i=s.input?.agent_id,r=Ct(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(us,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=re("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Ie,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(ec,{size:12,className:"text-destructive"}):c?o.jsx(Ps,{size:12,className:"text-warning"}):o.jsx(Zl,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Oh(t){const e=H.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=Zo(),{tasks:h,taskId:c}=vt(),{selectedModel:u,selectedVirtualMcp:d}=Zr();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=G=>G.id===c,e[17]=c,e[18]=N):N=e[18];const C=h.find(N),R=nc(l),E=[...l].reverse().find(Yh),A=E?.metadata?.usage,I=E?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,D=A?.contextTokens??A?.totalTokens??0,k=I&&I>0?(D/I*100).toFixed(1):null,w=l;let j;e[19]!==w?(j=w.filter(Gh).reduce(qh,0),e[19]=w,e[20]=j):j=e[20];const T=j,M=l;let B;e[21]!==M?(B=M.filter(Kh).reduce(Vh,0),e[21]=M,e[22]=B):B=e[22];const O=B,q=Math.max(0,R.totalTokens-T-O),U=l[0],F=l.at(-1),Z=U?.metadata?.created_at??C?.created_at,J=F?.metadata?.created_at??C?.updated_at,V=l.filter(Uh),$=l.flatMap(Hh),W=u?.modelId?Ih(u.modelId):"—",Q=d?.title??"Decopilot",L=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:V.length},{label:"Agent",value:Q},{label:"Model",value:W},{label:"Context Limit",value:I?vs(I):"—"},{label:"Session Tokens (billed)",value:R.totalTokens>0?vs(R.totalTokens):"0"},{label:"Usage",value:k!==null?`${k}%`:"—"},{label:"Input Tokens",value:R.inputTokens>0?vs(R.inputTokens):"0"},{label:"Output Tokens",value:R.outputTokens>0?vs(R.outputTokens):"0"},{label:"Reasoning Tokens",value:R.reasoningTokens>0?vs(R.reasoningTokens):"0"},{label:"Cost",value:R.cost>0?`$${R.cost<.001?R.cost.toFixed(6):R.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:In(Z)},{label:"Last Activity",value:In(J)}];if(!C&&V.length===0){let G;e[23]!==r?(G=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=G):G=e[24];let le;e[25]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=le):le=e[25];let ue;e[26]!==i?(ue=i?o.jsx(Sn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[le,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=fe):fe=e[31];let _e;e[32]!==G||e[33]!==de?(_e=o.jsxs("div",{className:G,children:[de,fe]}),e[32]=G,e[33]=de,e[34]=_e):_e=e[34],S=_e;break e}e[35]!==r?(v=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let se;e[37]===Symbol.for("react.memo_cache_sentinel")?(se=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=se):se=e[37];let ie;e[38]!==i?(ie=i?o.jsx(Sn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ie):ie=e[39],e[40]!==s||e[41]!==ie?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[se,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ie})]}),e[40]=s,e[41]=ie,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Fh)})]}),m=o.jsx(Ah,{items:L});let te;e[43]===Symbol.for("react.memo_cache_sentinel")?(te=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=te):te=e[43],e[44]!==O||e[45]!==q||e[46]!==T?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[te,o.jsx(Ph,{userTokens:T,assistantTokens:O,otherTokens:q})]}),e[44]=O,e[45]=q,e[46]=T,e[47]=p):p=e[47],g=V.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:V.map(G=>{const le=G.metadata?.created_at,ue=n?.id===G.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:G),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:re("shrink-0 font-medium",G.role==="user"?"text-chart-1":"text-chart-2"),children:G.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:G.id})]}),le&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(le).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[G.role==="assistant"&&(()=>{const de=G.metadata?._request;if(!de)return null;const fe=de.systemSections??[],_e=Math.max(1,...fe.map($h)),Ue=fe.reduce(zh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),fe.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Ue/4).toLocaleString()," ","tok"]})]}),fe.map(($e,Qe)=>{const at=$e.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Qe}`,ee=$e.chars/_e*100,Ne=Math.round($e.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:at}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Ne.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${ee}%`}})})]},Qe)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(G,null,2)})]})]},G.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let y;return e[54]!==v||e[55]!==b||e[56]!==x?(y=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=y):y=e[57],y}function zh(t,e){return t+e.chars}function $h(t){return t.chars}function Fh(t,e){return o.jsx(Lh,{part:t},e)}function Hh(t){return(t.parts??[]).filter(Wh)}function Wh(t){return t.type==="tool-subtask"}function Uh(t){return t.role!=="system"}function Vh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kh(t){return t.role==="assistant"}function qh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gh(t){return t.role==="user"}function Yh(t){return t.role==="assistant"&&t.metadata?.usage}const An=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Bn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Xh(){const t=An[Math.floor(Math.random()*An.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Jh(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Zh(t){const e=H.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=He(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:sd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ms(g);let x,y;e[11]!==r||e[12]!==a?(y=new Set(Object.keys(a?.[r]??{})),x=[...y].sort().map(td),e[11]=r,e[12]=a,e[13]=x,e[14]=y):(x=e[13],y=e[14]);const N=x;let C;if(e[15]!==v||e[16]!==y){const I=Array.isArray(v)?v:v?.branches??[];let D;e[18]!==y?(D=k=>!y.has(k.name),e[18]=y,e[19]=D):D=e[19],C=I.filter(ed).filter(D).map(Qh),e[15]=v,e[16]=y,e[17]=C}else C=e[17];const R=C,E=Array.isArray(v)?null:v?.default_branch??null;let A;return e[20]!==E||e[21]!==S||e[22]!==b||e[23]!==R||e[24]!==N?(A={yours:N,others:R,defaultBase:E,isLoading:b,isError:S},e[20]=E,e[21]=S,e[22]=b,e[23]=R,e[24]=N,e[25]=A):A=e[25],A}function Qh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ed(t){return typeof t.name=="string"}function td(t){return{name:t,source:"yours"}}function sd(t){return Jh(t)}function id(t){const e=H.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=Zh(_);let b;e[9]!==u?(b=T=>{u(T),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Rs,{className:"h-3.5 w-3.5"}),e[11]=y):y=e[11];let N;e[12]!==x?(N=o.jsx(Ws,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(pc,{placeholder:"Search branches…"}),e[14]=C):C=e[14];let R;e[15]!==S?(R=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(Xh()),children:"New"})]}),e[15]=S,e[16]=R):R=e[16];let E;e[17]!==v?(E=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=E):E=e[18];let A;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(A=!v&&!g&&m.length===0&&p.length===0&&o.jsx(mc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=A):A=e[23];let I;e[24]!==S||e[25]!==m?(I=m.length>0&&o.jsx(Cn,{heading:"Your branches",children:m.map(T=>o.jsxs(kn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name})]},T.name))}),e[24]=S,e[25]=m,e[26]=I):I=e[26];let D;e[27]!==p||e[28]!==S?(D=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(_c,{}),o.jsx(Cn,{heading:"Other branches in repo",children:p.map(T=>o.jsxs(kn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name}),T.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",T.author]})]},T.name))})]}),e[27]=p,e[28]=S,e[29]=D):D=e[29];let k;e[30]!==D||e[31]!==E||e[32]!==A||e[33]!==I?(k=o.jsxs(gc,{children:[E,A,I,D]}),e[30]=D,e[31]=E,e[32]=A,e[33]=I,e[34]=k):k=e[34];let w;e[35]!==k||e[36]!==R?(w=o.jsx(Us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(vc,{children:[R,k]})}),e[35]=k,e[36]=R,e[37]=w):w=e[37];let j;return e[38]!==d||e[39]!==w||e[40]!==N?(j=o.jsxs(Vs,{open:d,onOpenChange:f,children:[N,w]}),e[38]=d,e[39]=w,e[40]=N,e[41]=j):j=e[41],j}function rd(){const t=H.c(27),{org:e}=ve(),{selectedVirtualMcp:s}=Zr(),{data:i}=Ci.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=vt();let a;t[0]!==e.id?(a=Xo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Ct(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xl,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(us,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(id,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[24]=x):x=t[24];let y;return t[25]!==S?(y=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=y):y=t[26],y}function nd(){const t=H.c(26),{org:e}=ve(),s=Rc(),{isChatEmpty:i}=Zo(),[r,n]=P.useState("chat"),a=Ul();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Vl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(rd,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Oh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Ea(){const t=H.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ht,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(nd,{})})}),t[1]=s):s=t[1],s}async function od(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Ta=["VM_START"],Qs=new Map,ad=t=>`${t.virtualMcpId}::${t.branch??""}`,Fi=new Set,gi={mark:(t,e)=>Fi.add(`${t}::${e}`),clear:(t,e)=>Fi.delete(`${t}::${e}`),isStopped:(t,e)=>Fi.has(`${t}::${e}`)};function nn(t){const e=ds();return Vo({mutationKey:Ta,mutationFn:async s=>{s.branch&&gi.clear(s.virtualMcpId,s.branch);const i=ad(s),r=Qs.get(i);if(r)return r;const n=(async()=>(await od(t,"VM_START",s)).structuredContent)();Qs.set(i,n);try{return await n}finally{Qs.get(i)===n&&Qs.delete(i)}},onSuccess:()=>{oi(e)}})}function Ra(t,e){const s=H.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ta,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Rh(i)>0}const ld={settings:bc,automations:xc,env:pi,preview:tc,git:Rs};function Pn(t){const e=Ni(t);if(e.type==="icon"){const s=ji(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Hi(t){if(t.kind==="system")return{kind:"component",Component:ld[t.tabId]};const e=Pn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Pn(s.icon);return i||{kind:"fallback"}}function cd(t){const{org:e}=ve(),s=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),{data:i}=Al({queryKey:Bs.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Da(t){const e=H.c(8),s=Bt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jr(i),n=Ct(t.virtualMcpId),a=cd(t.taskId),{currentBranch:l}=vt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Kt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ti(m),{activeTab:g,mainOpen:v}=oc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(hd)}:null}),b=Qo(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const E of f){const A=yn(E.appId,E.toolName);x.set(A,{id:A,title:E.toolName,appId:E.appId,iconKey:E.toolName})}for(const E of d){const A=yn(E.connectionId,E.toolName);x.set(A,{id:A,title:E.label||E.toolName,appId:E.connectionId,iconKey:E.toolName,iconUrl:E.icon??null})}let y;e[2]!==p?(y=E=>({id:E.id,title:E.title,kind:"agent",icon:Hi({tabId:E.id,kind:"agent",appId:E.view.appId,connections:p})}),e[2]=p,e[3]=y):y=e[3];const N=[...u.map(y),...Array.from(x.values()).map(E=>({id:E.id,title:E.title,kind:"expanded",icon:Hi({tabId:E.iconKey,kind:"expanded",appId:E.appId,iconUrl:E.iconUrl,connections:p})})),...S.map(E=>({id:E.id,title:E.title,kind:"system",icon:Hi({tabId:E.id,kind:"system",connections:p})}))];let C;return e[4]!==g||e[5]!==v||e[6]!==s?(C=E=>{const A=ac({clickedId:E,activeTab:g,mainOpen:v});s({to:".",search:I=>({...I,main:A}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=C):C=e[7],{activeTab:g,mainOpen:v,setActiveTab:C,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:N}}function hd(t){return{id:t.id}}function Ma(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-app-view-DrBetUBZ.js","assets/index-CnknCe9i.js","assets/index-B_4-KoG_.css","assets/pair-CgrOS8jZ.js","assets/agent-icon-CJE3IrTn.js","assets/AlertCircle-DJf7WJW3.js","assets/Tool01-Ba51oSqA.js","assets/XClose-DGH-dkmK.js","assets/RefreshCcw01-02Zm-r_b.js","assets/ArrowNarrowLeft-zhth65sS.js","assets/XCircle-D-iHz9mr.js","assets/ArrowUpRight-B3qf65r_.js","assets/ZapSquare-zYT4mArq.js","assets/Users03-BpQp0OZp.js","assets/CheckCircle-Y9PieZLB.js","assets/Check-BA7p_1wq.js","assets/ChevronDown-CHAav7qy.js","assets/ChevronRight-2ozRd8ql.js","assets/ChevronUp-DiTrXBul.js","assets/DotsVertical-EPasiNNs.js","assets/Container-C2bhieKl.js","assets/Star01-DfneWwne.js","assets/Palette-C_hdzDFv.js","assets/SearchMd-KthT6Z0D.js","assets/index-CoJ8j1Pw.js","assets/tooltip-VTeNtMCR.js","assets/X-C7tkmqiA.js","assets/LinkExternal01-BPHdX5PH.js","assets/Lock01-BGF0eORu.js","assets/Sun-jEEtT5QL.js","assets/Play-F9KGb4fS.js","assets/Plus-yWDQ_tpZ.js","assets/Settings02-o9kWs5LM.js","assets/Shield01-C6IvOcka.js","assets/Trash01-phS8Heeq.js","assets/User01-ZJzkhpRI.js","assets/Zap-B3d9PZiM.js","assets/index-BOzqanlB.js","assets/use-copy-BC2pt5R_.js","assets/differenceInSeconds-NQ4PDo0z.js","assets/dialog-Hnl5R_ro.js","assets/content-blocks-o63cs2vh.js","assets/types-DXN89wPs.js","assets/constants-DGVET5nO.js","assets/chat-context-CKn0S8Zn.js","assets/use-virtual-mcp-DYwCZbrQ.js","assets/use-collections-CiD-L_rq.js","assets/use-ai-providers-Dn3Z7IEd.js","assets/use-decopilot-events-CNFY9Cdo.js","assets/create-sse-subscription-CxkOgzKf.js","assets/use-tasks-dDV8jhdD.js","assets/use-organization-settings-Dxy82qy3.js","assets/shell-layout-KvQC2n8R.js","assets/required-auth-layout-DesCgYHR.js","assets/use-org-sso-BraRussC.js","assets/integration-icon-BIIE53tx.js","assets/use-mcp-tools-CVArZMz4.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as ds,r as P,p as Ml,q as Il,e as H,s as ve,K as Bs,n as Uo,a as Vo,c as re,j as o,l as Ie,B as oe,E as Ht,b as Ci,v as oi,f as Bt,d as Jr,w as Al,x as pe,y as Bl,V as Pl,t as ye,z as Ko,C as Ll,D as $t,F as Ol,G as xn,L as zl,H as Li,I as Zs,J as ht,M as qo,P as $l,_ as Fl,Q as Go,R as Yo,T as Hl,g as Wl}from"./index-CnknCe9i.js";import{C as je,u as Ul,w as Vl,A as Kl,T as ql,a as Gl}from"./index-XN9sCkdo.js";import{I as us}from"./integration-icon-BIIE53tx.js";import{S as Pt,u as He,g as Xo,a as Jo}from"./constants-DGVET5nO.js";import{u as Ct,a as Yl}from"./use-virtual-mcp-DYwCZbrQ.js";import{a as Xl}from"./Users03-BpQp0OZp.js";import{u as Zo,a as vt,b as Zr,c as fs,t as Jl,d as bn}from"./chat-context-CKn0S8Zn.js";import{i as Ps}from"./AlertCircle-DJf7WJW3.js";import{i as Zl}from"./CheckCircle-Y9PieZLB.js";import{n as Sn,a as Ql}from"./ZapSquare-zYT4mArq.js";import{i as ec,a as tc,b as sc,c as ki,d as ic}from"./XCircle-D-iHz9mr.js";import{s as ls,i as rc}from"./XClose-DGH-dkmK.js";import{c as nc,r as oc,p as Qo,f as yn,a as ac,F as lc,t as wn,M as Qr,G as ea,L as cc,i as hc,b as dc,d as uc,e as fc}from"./pair-CgrOS8jZ.js";import{C as mc,a as Cn,b as kn,c as _c,d as pc,e as gc,f as vc}from"./command-COSC6-sU.js";import{P as Ws,a as Us,b as Vs}from"./popover-B72j1a-i.js";import{i as Rs,a as pi,b as xc,c as bc,p as Ni,g as ji,d as en,e as ta,h as cr,f as Oi,j as Nn,A as jn,k as sa,l as Sc,m as yc,n as wc,t as Cc,o as kc,q as ai,r as ia,s as ra,u as na,v as En,w as Nc,x as Ds,y as jc,z as Ec,B as oa}from"./agent-icon-CJE3IrTn.js";import{u as ms,a as Tc}from"./use-mcp-tools-CVArZMz4.js";import{u as Rc,a as Dc}from"./use-ai-providers-Dn3Z7IEd.js";import{g as Kt,c as Tn,u as Mc,b as hr,d as Ic,e as Ac,f as Bc,T as Pc}from"./index-HuDOZoSO.js";import{u as Ei,i as Lc}from"./shell-layout-KvQC2n8R.js";import{i as Oc,P as ct,u as zc,c as $c,d as Fc,e as Hc}from"./index-CoJ8j1Pw.js";import{u as aa,T as Ke,a as qe,b as Ge,c as Wc}from"./tooltip-VTeNtMCR.js";import{u as Uc}from"./use-status-sounds-D0gU5bqv.js";import{E as Ls}from"./empty-state-D5_lJgOy.js";import{A as Vc,a as Kc,b as qc,c as Gc,R as la,d as Yc,e as Xc}from"./accordion-hHFtU32i.js";import{u as Ti,a as tn,b as Jc}from"./use-connection-JNwwjcGV.js";import{g as Zc}from"./constants-BVAyWr7s.js";import{u as Qc,g as eh}from"./types-DXN89wPs.js";import{u as ca,G as th}from"./lean-canvas-recruit-modal-vF31gMjX.js";import{U as ha}from"./user-kEnfgZB9.js";import{T as sh,u as da}from"./tools-list-DltD98In.js";import{u as ih}from"./unwrap-tool-result-BYXdCQMg.js";import{s as ua,g as rh}from"./connection-slug-eyAPH6o3.js";import{A as fa,a as ma,b as _a,c as pa,d as ga,e as va,f as xa,g as ba}from"./alert-dialog-BX6tjxLQ.js";import{D as nh,a as sn,b as rn,c as Sa,d as ya}from"./dialog-Hnl5R_ro.js";import{C as oh,a as Rn}from"./card-BoqhySt6.js";import{I as _s}from"./input-tSjlegEI.js";import{L as Ms}from"./label-BPDMOqL-.js";import{S as ts,a as ss,b as is,c as rs,d as At}from"./select-Cgq5fB25.js";import{S as dr}from"./switch-DHlXaCRu.js";import{T as Dn}from"./textarea-BKxnYjv4.js";import{i as li}from"./Play-F9KGb4fS.js";import{s as cs}from"./Plus-yWDQ_tpZ.js";import{a as ah}from"./Settings02-o9kWs5LM.js";import{t as wa,i as lh}from"./Tool01-Ba51oSqA.js";import{s as ur}from"./Trash01-phS8Heeq.js";import{u as Ca}from"./use-debounced-autosave-BZkVf5Bt.js";import{S as ka}from"./scroll-area-B7p5KGay.js";import{i as Na,a as ch}from"./SearchMd-KthT6Z0D.js";import{C as hh}from"./collection-tabs-f6wZXNju.js";import{C as dh}from"./checkbox-CsbRNJyh.js";import{u as uh,T as zi,a as fh,b as mh,c as $i}from"./tabs-DP8p-QKj.js";import{D as _h,a as ph,b as gh}from"./drawer-Crup1SLH.js";import{i as Ri}from"./Check-BA7p_1wq.js";import{n as qt}from"./LinkExternal01-BPHdX5PH.js";import{S as vh}from"./index-BOzqanlB.js";import{D as ns,a as os,b as as,c as wt,d as xh,e as bh,f as Sh}from"./dropdown-menu-V4M0HjsW.js";import{t as fr}from"./ChevronDown-CHAav7qy.js";import{i as ja}from"./RefreshCcw01-02Zm-r_b.js";import{V as yh}from"./view-mode-toggle-CrpJwZiO.js";import{M as wh}from"./select-model-BrcDDMDY.js";import{u as Ks,a as Ch,b as kh,c as Nh,A as jh,d as Eh}from"./automation-list-row-CcwE53y-.js";import{i as Os}from"./Zap-B3d9PZiM.js";import{S as Th}from"./search-input-BkMpxSNZ.js";import"./use-navigate-to-agent-CBT4EeEo.js";import"./use-tasks-dDV8jhdD.js";import"./use-collections-CiD-L_rq.js";import"./collection-search-Ce1lQnUu.js";import"./form-C7tw7wIR.js";import"./Star01-DfneWwne.js";import"./Lock01-BGF0eORu.js";import"./X-C7tkmqiA.js";import"./toggle-group-BTIHjGuh.js";import"./index-pVdenInH.js";import"./question-004-sINsf4GQ.js";import"./ai-providers-logos-DD3qZ33J.js";import"./connection-card-CZXyfhfz.js";import"./use-registry-connections-Dutuf-7C.js";import"./use-organization-settings-Dxy82qy3.js";import"./useInfiniteQuery-DgNRpfvJ.js";import"./infiniteQueryObserver-BpzCmbvi.js";import"./extract-connection-data-em000wPy.js";import"./Container-C2bhieKl.js";import"./connection-form-helpers-BlYNQpCT.js";import"./use-infinite-scroll-DxHMXvd2.js";import"./useSuspenseInfiniteQuery-olKcjkDq.js";import"./badge-B9X-6Gl1.js";import"./ChevronRight-2ozRd8ql.js";import"./use-decopilot-events-CNFY9Cdo.js";import"./create-sse-subscription-CxkOgzKf.js";import"./use-copy-BC2pt5R_.js";import"./differenceInSeconds-NQ4PDo0z.js";import"./content-blocks-o63cs2vh.js";import"./Sun-jEEtT5QL.js";import"./index-DkII30Yp.js";import"./ArrowNarrowLeft-zhth65sS.js";import"./ArrowUpRight-B3qf65r_.js";import"./ChevronUp-DiTrXBul.js";import"./DotsVertical-EPasiNNs.js";import"./Palette-C_hdzDFv.js";import"./Shield01-C6IvOcka.js";import"./User01-ZJzkhpRI.js";import"./skeleton-DIbgbTEL.js";import"./avatar-qtN1d68D.js";import"./index-Bbymo0Ib.js";import"./collection-search-B3qdCdab.js";import"./use-create-virtual-mcp-BaV_MWOd.js";import"./task-status-RjLfrU9E.js";import"./required-auth-layout-DesCgYHR.js";import"./use-org-sso-BraRussC.js";import"./collections-DW4PTltg.js";import"./settings-section-BnPqXFEQ.js";import"./formatDistanceToNow-Cb2QZZJn.js";function Rh(t,e){const s=ds(e);return Dh({filters:{...t,status:"pending"}},s).length}function Mn(t,e){return t.findAll(e.filters).map(s=>e.select?e.select(s):s.state)}function Dh(t={},e){const s=ds(e).getMutationCache(),i=P.useRef(t),r=P.useRef(null);return r.current===null&&(r.current=Mn(s,t)),P.useEffect(()=>{i.current=t}),P.useSyncExternalStore(P.useCallback(n=>s.subscribe(()=>{const a=Ml(r.current,Mn(s,i.current));r.current!==a&&(r.current=a,Il.schedule(n))}),[s]),()=>r.current,()=>r.current)}function Mh(t,e){const s=H.c(40),{org:i,locator:r}=ve();let n;s[0]!==i.id||s[1]!==i.slug?(n={connectionId:Pt,orgId:i.id,orgSlug:i.slug},s[0]=i.id,s[1]=i.slug,s[2]=n):n=s[2];const a=He(n),l=ds();let h;s[3]!==t||s[4]!==i.id?(h=Bs.ensureTask(i.id,t),s[3]=t,s[4]=i.id,s[5]=h):h=s[5];let c;s[6]!==a||s[7]!==t?(c=async()=>(await a.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}})).structuredContent?.item??null,s[6]=a,s[7]=t,s[8]=c):c=s[8];const u=t.length>0;let d;s[9]!==h||s[10]!==c||s[11]!==u?(d={queryKey:h,queryFn:c,enabled:u,retry:!1,refetchOnWindowFocus:!1},s[9]=h,s[10]=c,s[11]=u,s[12]=d):d=s[12];const f=Uo(d);let _;s[13]!==a||s[14]!==e?(_=async x=>{const y=await a.callTool({name:"COLLECTION_THREADS_CREATE",arguments:{data:{id:x,virtual_mcp_id:e}}});if(y.isError){const C=y.content,R=Array.isArray(C)&&C[0]&&typeof C[0]=="object"?C[0].text??"Create failed":"Create failed";throw new Error(R)}return y.structuredContent.item},s[13]=a,s[14]=e,s[15]=_):_=s[15];let m;s[16]!==r||s[17]!==i.id||s[18]!==f||s[19]!==l?(m=()=>{l.invalidateQueries({predicate:x=>x.queryKey[1]===i.id&&x.queryKey[3]==="collection"&&x.queryKey[4]==="THREADS"}),l.invalidateQueries({queryKey:Bs.tasksPrefix(r)}),f.refetch()},s[16]=r,s[17]=i.id,s[18]=f,s[19]=l,s[20]=m):m=s[20];let p;s[21]!==_||s[22]!==m?(p={mutationFn:_,onSuccess:m},s[21]=_,s[22]=m,s[23]=p):p=s[23];const g=Vo(p);let v,b;if(s[24]!==g||s[25]!==t||s[26]!==f.data||s[27]!==f.isSuccess?(v=()=>{t&&(!f.isSuccess||f.data||g.isPending||g.variables!==t&&g.mutate(t))},b=[t,f.isSuccess,f.data,g],s[24]=g,s[25]=t,s[26]=f.data,s[27]=f.isSuccess,s[28]=v,s[29]=b):(v=s[28],b=s[29]),P.useEffect(v,b),!t){let x;return s[30]===Symbol.for("react.memo_cache_sentinel")?(x={status:"ready",task:null},s[30]=x):x=s[30],x}if(f.isLoading){let x;return s[31]===Symbol.for("react.memo_cache_sentinel")?(x={status:"loading"},s[31]=x):x=s[31],x}if(f.isError){const x=f.error;let y;return s[32]!==x?(y={status:"error",error:x},s[32]=x,s[33]=y):y=s[33],y}if(f.isSuccess&&f.data){let x;return s[34]!==f.data?(x={status:"ready",task:f.data},s[34]=f.data,s[35]=x):x=s[35],x}if(g.isPending||f.isSuccess&&!f.data){let x;return s[36]===Symbol.for("react.memo_cache_sentinel")?(x={status:"creating"},s[36]=x):x=s[36],x}if(g.isError){let x;return s[37]!==g.error?(x={status:"error",error:g.error},s[37]=g.error,s[38]=x):x=s[38],x}let S;return s[39]===Symbol.for("react.memo_cache_sentinel")?(S={status:"loading"},s[39]=S):S=s[39],S}function vs(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)}function In(t){if(!t)return"—";const e=typeof t=="string"?new Date(t):t;return isNaN(e.getTime())?"—":e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}function Ih(t){return t?t.replace(/-\d{8}(?:-[a-z0-9]+)*$/i,"").replace(/-/g," "):"—"}function Ah(t){const e=H.c(4),{items:s}=t;let i;e[0]!==s?(i=s.map(Bh),e[0]=s,e[1]=i):i=e[1];let r;return e[2]!==i?(r=o.jsx("div",{className:"grid grid-cols-2 gap-x-8 gap-y-6",children:i}),e[2]=i,e[3]=r):r=e[3],r}function Bh(t){return o.jsxs("div",{className:"flex flex-col gap-1 min-w-0",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:t.label}),o.jsx("span",{className:"text-sm text-foreground tabular-nums truncate",children:t.value})]},t.label)}function Ph(t){const e=H.c(30),{userTokens:s,assistantTokens:i,otherTokens:r}=t,n=s+i+r,a=n>0?s/n*100:0,l=n>0?i/n*100:0,h=n>0?r/n*100:0;let c;e[0]!==a?(c=a>0&&o.jsx("div",{className:"h-full bg-chart-1",style:{width:`${a}%`}}),e[0]=a,e[1]=c):c=e[1];let u;e[2]!==l?(u=l>0&&o.jsx("div",{className:"h-full bg-chart-2",style:{width:`${l}%`}}),e[2]=l,e[3]=u):u=e[3];let d;e[4]!==h?(d=h>0&&o.jsx("div",{className:"h-full bg-muted-foreground/30",style:{width:`${h}%`}}),e[4]=h,e[5]=d):d=e[5];let f;e[6]!==c||e[7]!==u||e[8]!==d?(f=o.jsxs("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-muted",children:[c,u,d]}),e[6]=c,e[7]=u,e[8]=d,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-1 shrink-0"}),e[10]=_):_=e[10];let m;e[11]!==a?(m=a.toFixed(1),e[11]=a,e[12]=m):m=e[12];let p;e[13]!==m?(p=o.jsxs("div",{className:"flex items-center gap-1.5",children:[_,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["User ",m,"%"]})]}),e[13]=m,e[14]=p):p=e[14];let g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-chart-2 shrink-0"}),e[15]=g):g=e[15];let v;e[16]!==l?(v=l.toFixed(1),e[16]=l,e[17]=v):v=e[17];let b;e[18]!==v?(b=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Assistant ",v,"%"]})]}),e[18]=v,e[19]=b):b=e[19];let S;e[20]!==h||e[21]!==r?(S=r>0&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-muted-foreground/30 shrink-0"}),o.jsxs("span",{className:"text-xs text-muted-foreground",children:["Other ",h.toFixed(1),"%"]})]}),e[20]=h,e[21]=r,e[22]=S):S=e[22];let x;e[23]!==b||e[24]!==S||e[25]!==p?(x=o.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:[p,b,S]}),e[23]=b,e[24]=S,e[25]=p,e[26]=x):x=e[26];let y;return e[27]!==x||e[28]!==f?(y=o.jsxs("div",{className:"flex flex-col gap-2",children:[f,x]}),e[27]=x,e[28]=f,e[29]=y):y=e[29],y}function Lh(t){const e=H.c(19),{part:s}=t,i=s.input?.agent_id,r=Ct(i),n=r?.title??"Subtask",a=r?.icon??null,l=s.state==="input-streaming"||s.state==="input-available"||s.state==="output-available"&&s.preliminary===!0,h=s.state==="output-error",c=s.state==="approval-requested";let u;e[0]!==a||e[1]!==n?(u=o.jsx(us,{icon:a,name:n,size:"xs",className:"size-6 rounded-md shrink-0"}),e[0]=a,e[1]=n,e[2]=u):u=e[2];const d=h?"text-destructive":"text-foreground";let f;e[3]!==d?(f=re("shrink-0 font-medium",d),e[3]=d,e[4]=f):f=e[4];let _;e[5]!==n||e[6]!==f?(_=o.jsx("span",{className:f,children:n}),e[5]=n,e[6]=f,e[7]=_):_=e[7];let m;e[8]!==s.input?(m=s.input?.prompt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"truncate text-muted-foreground",children:s.input.prompt})]}),e[8]=s.input,e[9]=m):m=e[9];let p;e[10]!==c||e[11]!==h||e[12]!==l?(p=o.jsx("span",{className:"ml-auto shrink-0",children:l?o.jsx(Ie,{size:12,className:"animate-spin text-muted-foreground"}):h?o.jsx(ec,{size:12,className:"text-destructive"}):c?o.jsx(Ps,{size:12,className:"text-warning"}):o.jsx(Zl,{size:12,className:"text-emerald-500"})}),e[10]=c,e[11]=h,e[12]=l,e[13]=p):p=e[13];let g;return e[14]!==u||e[15]!==_||e[16]!==m||e[17]!==p?(g=o.jsxs("div",{className:"flex items-center gap-2 text-xs min-w-0",children:[u,_,m,p]}),e[14]=u,e[15]=_,e[16]=m,e[17]=p,e[18]=g):g=e[18],g}function Oh(t){const e=H.c(58),{onClose:s,back:i,className:r}=t,[n,a]=P.useState(null),{messages:l}=Zo(),{tasks:h,taskId:c}=vt(),{selectedModel:u,selectedVirtualMcp:d}=Zr();let f,_,m,p,g,v,b,S;if(e[0]!==i||e[1]!==r||e[2]!==l||e[3]!==s||e[4]!==n?.id||e[5]!==u||e[6]!==d?.title||e[7]!==c||e[8]!==h){S=Symbol.for("react.early_return_sentinel");e:{let N;e[17]!==c?(N=G=>G.id===c,e[17]=c,e[18]=N):N=e[18];const C=h.find(N),R=nc(l),E=[...l].reverse().find(Yh),A=E?.metadata?.usage,I=E?.metadata?.modelLimits?.contextWindow??u?.limits?.contextWindow??null,D=A?.contextTokens??A?.totalTokens??0,k=I&&I>0?(D/I*100).toFixed(1):null,w=l;let j;e[19]!==w?(j=w.filter(Gh).reduce(qh,0),e[19]=w,e[20]=j):j=e[20];const T=j,M=l;let B;e[21]!==M?(B=M.filter(Kh).reduce(Vh,0),e[21]=M,e[22]=B):B=e[22];const O=B,q=Math.max(0,R.totalTokens-T-O),U=l[0],F=l.at(-1),Z=U?.metadata?.created_at??C?.created_at,J=F?.metadata?.created_at??C?.updated_at,V=l.filter(Uh),$=l.flatMap(Hh),W=u?.modelId?Ih(u.modelId):"—",Q=d?.title??"Decopilot",L=[{label:"Session",value:C?.title??"New chat"},{label:"Messages",value:V.length},{label:"Agent",value:Q},{label:"Model",value:W},{label:"Context Limit",value:I?vs(I):"—"},{label:"Session Tokens (billed)",value:R.totalTokens>0?vs(R.totalTokens):"0"},{label:"Usage",value:k!==null?`${k}%`:"—"},{label:"Input Tokens",value:R.inputTokens>0?vs(R.inputTokens):"0"},{label:"Output Tokens",value:R.outputTokens>0?vs(R.outputTokens):"0"},{label:"Reasoning Tokens",value:R.reasoningTokens>0?vs(R.reasoningTokens):"0"},{label:"Cost",value:R.cost>0?`$${R.cost<.001?R.cost.toFixed(6):R.cost.toFixed(4)}`:"$0.00"},{label:"Session Created",value:In(Z)},{label:"Last Activity",value:In(J)}];if(!C&&V.length===0){let G;e[23]!==r?(G=re("flex flex-col h-full w-full border-l border-border bg-background",r),e[23]=r,e[24]=G):G=e[24];let le;e[25]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[25]=le):le=e[25];let ue;e[26]!==i?(ue=i?o.jsx(Sn,{size:14,className:"text-muted-foreground"}):o.jsx(ls,{size:14,className:"text-muted-foreground"}),e[26]=i,e[27]=ue):ue=e[27];let de;e[28]!==s||e[29]!==ue?(de=o.jsxs("div",{className:"h-11 px-4 flex items-center justify-between shrink-0 border-b border-border/50",children:[le,o.jsx("button",{type:"button",onClick:s,className:"flex size-6 items-center justify-center rounded hover:bg-accent transition-colors",children:ue})]}),e[28]=s,e[29]=ue,e[30]=de):de=e[30];let fe;e[31]===Symbol.for("react.memo_cache_sentinel")?(fe=o.jsx("div",{className:"flex-1 flex items-center justify-center px-4 text-center",children:o.jsx("p",{className:"text-xs text-muted-foreground",children:"Start a conversation to see context"})}),e[31]=fe):fe=e[31];let _e;e[32]!==G||e[33]!==de?(_e=o.jsxs("div",{className:G,children:[de,fe]}),e[32]=G,e[33]=de,e[34]=_e):_e=e[34],S=_e;break e}e[35]!==r?(v=re("flex flex-col h-full w-full border-l border-border bg-background overflow-y-auto",r),e[35]=r,e[36]=v):v=e[36];let se;e[37]===Symbol.for("react.memo_cache_sentinel")?(se=o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Context"}),e[37]=se):se=e[37];let ie;e[38]!==i?(ie=i?o.jsx(Sn,{size:14}):o.jsx(ls,{size:14}),e[38]=i,e[39]=ie):ie=e[39],e[40]!==s||e[41]!==ie?(b=o.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between border-b border-border/50 px-4",children:[se,o.jsx("button",{type:"button",onClick:s,className:"flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:ie})]}),e[40]=s,e[41]=ie,e[42]=b):b=e[42],f="flex flex-col gap-8 p-6",_=$.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Subtasks"}),o.jsx("div",{className:"flex flex-col gap-1",children:$.map(Fh)})]}),m=o.jsx(Ah,{items:L});let te;e[43]===Symbol.for("react.memo_cache_sentinel")?(te=o.jsx("span",{className:"text-xs text-muted-foreground",children:"Context Breakdown"}),e[43]=te):te=e[43],e[44]!==O||e[45]!==q||e[46]!==T?(p=o.jsxs("div",{className:"flex flex-col gap-3",children:[te,o.jsx(Ph,{userTokens:T,assistantTokens:O,otherTokens:q})]}),e[44]=O,e[45]=q,e[46]=T,e[47]=p):p=e[47],g=V.length>0&&o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"Raw messages"}),o.jsx("div",{className:"flex flex-col gap-1",children:V.map(G=>{const le=G.metadata?.created_at,ue=n?.id===G.id;return o.jsxs("div",{className:"rounded-md border border-border/50 overflow-hidden",children:[o.jsxs("button",{type:"button",onClick:()=>a(ue?null:G),className:"flex items-center justify-between gap-2 px-3 py-2 text-xs hover:bg-accent/50 w-full text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:re("shrink-0 font-medium",G.role==="user"?"text-chart-1":"text-chart-2"),children:G.role}),o.jsx("span",{className:"text-muted-foreground",children:"•"}),o.jsx("span",{className:"truncate text-muted-foreground font-mono",children:G.id})]}),le&&o.jsx("span",{className:"shrink-0 text-muted-foreground tabular-nums",children:new Date(le).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})})]}),ue&&o.jsxs(o.Fragment,{children:[G.role==="assistant"&&(()=>{const de=G.metadata?._request;if(!de)return null;const fe=de.systemSections??[],_e=Math.max(1,...fe.map($h)),Ue=fe.reduce(zh,0);return o.jsxs("div",{className:"border-t border-border/50 px-3 py-2.5 text-xs space-y-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"font-medium text-foreground",children:"Request"}),o.jsxs("span",{className:"text-muted-foreground tabular-nums",children:[de.activeTools??0," / ",de.tools??0," ","tools active"]})]}),fe.length>0&&o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"text-muted-foreground",children:["System prompt"," ",o.jsxs("span",{className:"tabular-nums",children:["~",Math.round(Ue/4).toLocaleString()," ","tok"]})]}),fe.map(($e,Qe)=>{const at=$e.preview.match(/^<([a-z-]+)/i)?.[1]??`section ${Qe}`,ee=$e.chars/_e*100,Ne=Math.round($e.chars/4);return o.jsxs("div",{className:"space-y-0.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"font-mono text-foreground truncate",children:at}),o.jsxs("span",{className:"text-muted-foreground tabular-nums shrink-0",children:["~",Ne.toLocaleString()," tok"]})]}),o.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:"h-full rounded-full bg-chart-3",style:{width:`${ee}%`}})})]},Qe)})]})]})})(),o.jsx("pre",{className:"text-xs font-mono bg-muted px-3 py-2 overflow-auto whitespace-pre-wrap break-all border-t border-border/50 max-h-64",children:JSON.stringify(G,null,2)})]})]},G.id)})})]})}e[0]=i,e[1]=r,e[2]=l,e[3]=s,e[4]=n?.id,e[5]=u,e[6]=d?.title,e[7]=c,e[8]=h,e[9]=f,e[10]=_,e[11]=m,e[12]=p,e[13]=g,e[14]=v,e[15]=b,e[16]=S}else f=e[9],_=e[10],m=e[11],p=e[12],g=e[13],v=e[14],b=e[15],S=e[16];if(S!==Symbol.for("react.early_return_sentinel"))return S;let x;e[48]!==f||e[49]!==_||e[50]!==m||e[51]!==p||e[52]!==g?(x=o.jsxs("div",{className:f,children:[_,m,p,g]}),e[48]=f,e[49]=_,e[50]=m,e[51]=p,e[52]=g,e[53]=x):x=e[53];let y;return e[54]!==v||e[55]!==b||e[56]!==x?(y=o.jsxs("div",{className:v,children:[b,x]}),e[54]=v,e[55]=b,e[56]=x,e[57]=y):y=e[57],y}function zh(t,e){return t+e.chars}function $h(t){return t.chars}function Fh(t,e){return o.jsx(Lh,{part:t},e)}function Hh(t){return(t.parts??[]).filter(Wh)}function Wh(t){return t.type==="tool-subtask"}function Uh(t){return t.role!=="system"}function Vh(t,e){const s=e.metadata?.usage;return t+(s?.outputTokens??0)}function Kh(t){return t.role==="assistant"}function qh(t,e){const s=e.metadata?.usage;return t+(s?.inputTokens??0)}function Gh(t){return t.role==="user"}function Yh(t){return t.role==="assistant"&&t.metadata?.usage}const An=["amber","bold","bright","calm","crimson","coral","daring","deep","dusty","eager","faint","fierce","frozen","gentle","golden","grand","green","hollow","iron","ivory","keen","lasting","lunar","mellow","misty","noble","olive","pale","prime","quiet","rapid","rustic","serene","sharp","silver","sleek","solar","stark","still","swift","tawny","tender","thin","true","vast","velvet","warm","wild","young","zen"],Bn=["anchor","birch","brook","cedar","cliff","cove","crane","dune","echo","ember","falcon","fern","flint","forge","frost","glade","grove","harbor","hawk","iris","jade","lark","maple","marsh","mesa","opal","orbit","peak","pine","plume","quartz","rapids","reef","ridge","river","sage","shore","slate","spruce","stone","summit","thorn","tide","trail","vale","wren","aspen","delta","crest","spark"];function Xh(){const t=An[Math.floor(Math.random()*An.length)],e=Bn[Math.floor(Math.random()*Bn.length)];return`deco/${t}-${e}`}function Jh(t){const e=t;if(e.structuredContent)return e.structuredContent;const s=e.content?.find(i=>i.type==="text")?.text;if(s)try{return JSON.parse(s)}catch{return[]}return[]}function Zh(t){const e=H.c(26),{orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:a,owner:l,repo:h,enabled:c}=t,u=c===void 0?!0:c,d=n??null;let f;e[0]!==s||e[1]!==i||e[2]!==d?(f={connectionId:d,orgId:s,orgSlug:i},e[0]=s,e[1]=i,e[2]=d,e[3]=f):f=e[3];const _=He(f);let m;e[4]!==l||e[5]!==h?(m={owner:l,repo:h},e[4]=l,e[5]=h,e[6]=m):m=e[6];const p=u&&!!n&&!!l&&!!h;let g;e[7]!==_||e[8]!==m||e[9]!==p?(g={client:_,toolName:"list_branches",toolArguments:m,enabled:p,staleTime:3e4,select:sd},e[7]=_,e[8]=m,e[9]=p,e[10]=g):g=e[10];const{data:v,isLoading:b,isError:S}=ms(g);let x,y;e[11]!==r||e[12]!==a?(y=new Set(Object.keys(a?.[r]??{})),x=[...y].sort().map(td),e[11]=r,e[12]=a,e[13]=x,e[14]=y):(x=e[13],y=e[14]);const N=x;let C;if(e[15]!==v||e[16]!==y){const I=Array.isArray(v)?v:v?.branches??[];let D;e[18]!==y?(D=k=>!y.has(k.name),e[18]=y,e[19]=D):D=e[19],C=I.filter(ed).filter(D).map(Qh),e[15]=v,e[16]=y,e[17]=C}else C=e[17];const R=C,E=Array.isArray(v)?null:v?.default_branch??null;let A;return e[20]!==E||e[21]!==S||e[22]!==b||e[23]!==R||e[24]!==N?(A={yours:N,others:R,defaultBase:E,isLoading:b,isError:S},e[20]=E,e[21]=S,e[22]=b,e[23]=R,e[24]=N,e[25]=A):A=e[25],A}function Qh(t){return{name:t.name,source:"other",author:typeof t.commit?.author=="string"?t.commit.author:t.commit?.author?.login??null}}function ed(t){return typeof t.name=="string"}function td(t){return{name:t,source:"yours"}}function sd(t){return Jh(t)}function id(t){const e=H.c(42),{orgId:s,orgSlug:i,userId:r,connectionId:n,owner:a,repo:l,vmMap:h,value:c,onChange:u}=t,[d,f]=P.useState(!1);let _;e[0]!==n||e[1]!==d||e[2]!==s||e[3]!==i||e[4]!==a||e[5]!==l||e[6]!==r||e[7]!==h?(_={orgId:s,orgSlug:i,userId:r,connectionId:n,vmMap:h,owner:a,repo:l,enabled:d},e[0]=n,e[1]=d,e[2]=s,e[3]=i,e[4]=a,e[5]=l,e[6]=r,e[7]=h,e[8]=_):_=e[8];const{yours:m,others:p,isLoading:g,isError:v}=Zh(_);let b;e[9]!==u?(b=T=>{u(T),f(!1)},e[9]=u,e[10]=b):b=e[10];const S=b,x=c??"Select branch…";let y;e[11]===Symbol.for("react.memo_cache_sentinel")?(y=o.jsx(Rs,{className:"h-3.5 w-3.5"}),e[11]=y):y=e[11];let N;e[12]!==x?(N=o.jsx(Ws,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 font-mono text-xs",children:[y,o.jsx("span",{className:"max-w-[200px] truncate",children:x})]})}),e[12]=x,e[13]=N):N=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(pc,{placeholder:"Search branches…"}),e[14]=C):C=e[14];let R;e[15]!==S?(R=o.jsxs("div",{className:"flex items-center border-b pr-2 [&>[data-slot=command-input-wrapper]]:flex-1 [&>[data-slot=command-input-wrapper]]:border-b-0",children:[C,o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 shrink-0",onClick:()=>S(Xh()),children:"New"})]}),e[15]=S,e[16]=R):R=e[16];let E;e[17]!==v?(E=v&&o.jsx("div",{className:"p-3 text-xs text-muted-foreground",children:"Couldn't load branches from GitHub. You can still pick from your branches."}),e[17]=v,e[18]=E):E=e[18];let A;e[19]!==v||e[20]!==g||e[21]!==p.length||e[22]!==m.length?(A=!v&&!g&&m.length===0&&p.length===0&&o.jsx(mc,{children:"No branches found."}),e[19]=v,e[20]=g,e[21]=p.length,e[22]=m.length,e[23]=A):A=e[23];let I;e[24]!==S||e[25]!==m?(I=m.length>0&&o.jsx(Cn,{heading:"Your branches",children:m.map(T=>o.jsxs(kn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name})]},T.name))}),e[24]=S,e[25]=m,e[26]=I):I=e[26];let D;e[27]!==p||e[28]!==S?(D=p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx(_c,{}),o.jsx(Cn,{heading:"Other branches in repo",children:p.map(T=>o.jsxs(kn,{value:T.name,onSelect:()=>S(T.name),children:[o.jsx(Rs,{className:"mr-2 h-4 w-4"}),o.jsx("span",{className:"flex-1 truncate",children:T.name}),T.author&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["@",T.author]})]},T.name))})]}),e[27]=p,e[28]=S,e[29]=D):D=e[29];let k;e[30]!==D||e[31]!==E||e[32]!==A||e[33]!==I?(k=o.jsxs(gc,{children:[E,A,I,D]}),e[30]=D,e[31]=E,e[32]=A,e[33]=I,e[34]=k):k=e[34];let w;e[35]!==k||e[36]!==R?(w=o.jsx(Us,{className:"w-[min(420px,calc(100vw-2rem))] p-0",align:"start",children:o.jsxs(vc,{children:[R,k]})}),e[35]=k,e[36]=R,e[37]=w):w=e[37];let j;return e[38]!==d||e[39]!==w||e[40]!==N?(j=o.jsxs(Vs,{open:d,onOpenChange:f,children:[N,w]}),e[38]=d,e[39]=w,e[40]=N,e[41]=j):j=e[41],j}function rd(){const t=H.c(27),{org:e}=ve(),{selectedVirtualMcp:s}=Zr(),{data:i}=Ci.useSession(),{currentBranch:r,setCurrentTaskBranch:n}=vt();let a;t[0]!==e.id?(a=Xo(e.id),t[0]=e.id,t[1]=a):a=t[1];const h=s??a,c=Ct(h.id),u=i?.user?.id??"",d=c?.metadata?.githubRepo??null,f=!!d?.connectionId&&!!u;let _;t[2]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Xl,{size:32}),t[2]=_):_=t[2];let m;t[3]!==h.icon||t[4]!==h.title?(m=o.jsx(us,{icon:h.icon,name:h.title,size:"lg",fallbackIcon:_,className:"size-10 min-w-10 md:size-[60px]! md:min-w-[60px] rounded-xl md:rounded-[18px]!"}),t[3]=h.icon,t[4]=h.title,t[5]=m):m=t[5];let p;t[6]!==h.title?(p=o.jsx("h3",{className:"text-base md:text-xl font-medium text-foreground",children:h.title}),t[6]=h.title,t[7]=p):p=t[7];const g=h.description??"Ask anything about configuring model providers or using MCP Mesh.";let v;t[8]!==g?(v=o.jsx("div",{className:"text-muted-foreground text-center text-base max-w-md line-clamp-2",children:g}),t[8]=g,t[9]=v):v=t[9];let b;t[10]!==r||t[11]!==c?.metadata?.vmMap||t[12]!==d||t[13]!==e.id||t[14]!==e.slug||t[15]!==n||t[16]!==f||t[17]!==u?(b=f&&o.jsx("div",{className:"mt-2",children:o.jsx(id,{orgId:e.id,orgSlug:e.slug,userId:u,connectionId:d.connectionId,owner:d.owner,repo:d.name,vmMap:c?.metadata?.vmMap,value:r??void 0,onChange:n})}),t[10]=r,t[11]=c?.metadata?.vmMap,t[12]=d,t[13]=e.id,t[14]=e.slug,t[15]=n,t[16]=f,t[17]=u,t[18]=b):b=t[18];let S;t[19]!==m||t[20]!==p||t[21]!==v||t[22]!==b?(S=o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 md:gap-4 text-center",children:[m,p,v,b]}),t[19]=m,t[20]=p,t[21]=v,t[22]=b,t[23]=S):S=t[23];let x;t[24]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx("div",{className:"w-full max-w-3xl mx-auto",children:o.jsx(je.IceBreakers,{})}),t[24]=x):x=t[24];let y;return t[25]!==S?(y=o.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center gap-6 px-4",children:[S,x]}),t[25]=S,t[26]=y):y=t[26],y}function nd(){const t=H.c(26),{org:e}=ve(),s=Rc(),{isChatEmpty:i}=Zo(),[r,n]=P.useState("chat"),a=Ul();if(s.length===0){let S;return t[0]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(je,{className:"animate-in fade-in-0 duration-200",children:o.jsx(je.Main,{className:"flex flex-col items-center",children:o.jsx(je.EmptyState,{children:o.jsx(je.NoAiProviderEmptyState,{})})})}),t[0]=S):S=t[0],S}let l;t[1]!==a.hasDecoKey||t[2]!==a.hasOnlyDecoProvider||t[3]!==a.isLoading||t[4]!==a.isZeroBalance||t[5]!==i||t[6]!==e?(l=a.hasDecoKey&&a.isZeroBalance&&a.hasOnlyDecoProvider&&!a.isLoading&&i&&!Vl(e.id),t[1]=a.hasDecoKey,t[2]=a.hasOnlyDecoProvider,t[3]=a.isLoading,t[4]=a.isZeroBalance,t[5]=i,t[6]=e,t[7]=l):l=t[7];const h=l;let c;t[8]!==h?(c=h&&o.jsx(je.CreditsEmptyState,{}),t[8]=h,t[9]=c):c=t[9];const u=r!=="chat"?"opacity-0 pointer-events-none":"opacity-100";let d;t[10]!==u?(d=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",u),t[10]=u,t[11]=d):d=t[11];let f;t[12]!==i?(f=i?o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(rd,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}):o.jsxs(o.Fragment,{children:[o.jsx(je.Main,{children:o.jsx(je.Messages,{})}),o.jsx(je.Footer,{children:o.jsx(je.Input,{onOpenContextPanel:()=>n("context")})})]}),t[12]=i,t[13]=f):f=t[13];let _;t[14]!==d||t[15]!==f?(_=o.jsx("div",{className:d,children:f}),t[14]=d,t[15]=f,t[16]=_):_=t[16];const m=r==="context"?"opacity-100":"opacity-0 pointer-events-none";let p;t[17]!==m?(p=re("absolute inset-0 flex flex-col transition-opacity duration-100 ease-out",m),t[17]=m,t[18]=p):p=t[18];let g;t[19]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx(Oh,{back:!0,onClose:()=>n("chat")}),t[19]=g):g=t[19];let v;t[20]!==p?(v=o.jsx("div",{className:p,children:g}),t[20]=p,t[21]=v):v=t[21];let b;return t[22]!==c||t[23]!==_||t[24]!==v?(b=o.jsxs(je,{className:"relative overflow-hidden animate-in fade-in-0 duration-200",children:[c,_,v]}),t[22]=c,t[23]=_,t[24]=v,t[25]=b):b=t[25],b}function Ea(){const t=H.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(je.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(Ht,{fallback:e,children:o.jsx(P.Suspense,{fallback:o.jsx(je.Skeleton,{}),children:o.jsx(nd,{})})}),t[1]=s):s=t[1],s}async function od(t,e,s){const i=await t.callTool({name:e,arguments:s});if(i.isError){const r=i.content?.[0]?.text??`Tool ${e} failed without a message`;throw new Error(r)}return i}const Ta=["VM_START"],Qs=new Map,ad=t=>`${t.virtualMcpId}::${t.branch??""}`,Fi=new Set,gi={mark:(t,e)=>Fi.add(`${t}::${e}`),clear:(t,e)=>Fi.delete(`${t}::${e}`),isStopped:(t,e)=>Fi.has(`${t}::${e}`)};function nn(t){const e=ds();return Vo({mutationKey:Ta,mutationFn:async s=>{s.branch&&gi.clear(s.virtualMcpId,s.branch);const i=ad(s),r=Qs.get(i);if(r)return r;const n=(async()=>(await od(t,"VM_START",s)).structuredContent)();Qs.set(i,n);try{return await n}finally{Qs.get(i)===n&&Qs.delete(i)}},onSuccess:()=>{oi(e)}})}function Ra(t,e){const s=H.c(3);let i;return s[0]!==e||s[1]!==t?(i={mutationKey:Ta,predicate:n=>{if(!t)return!1;const a=n.state.variables;return!a||a.virtualMcpId!==t?!1:(a.branch??"")===(e??"")}},s[0]=e,s[1]=t,s[2]=i):i=s[2],Rh(i)>0}const ld={settings:bc,automations:xc,env:pi,preview:tc,git:Rs};function Pn(t){const e=Ni(t);if(e.type==="icon"){const s=ji(e.name);return s?{kind:"component",Component:s}:null}return e.type==="url"?{kind:"url",src:e.url}:null}function Hi(t){if(t.kind==="system")return{kind:"component",Component:ld[t.tabId]};const e=Pn(t.iconUrl);if(e)return e;if(!t.appId)return{kind:"fallback"};const s=t.connections.find(r=>r.id===t.appId);if(!s)return{kind:"fallback"};const i=Pn(s.icon);return i||{kind:"fallback"}}function cd(t){const{org:e}=ve(),s=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),{data:i}=Al({queryKey:Bs.threadMetadata(t),queryFn:async()=>{if(!s||!t)return null;try{const r=await s.callTool({name:"COLLECTION_THREADS_GET",arguments:{id:t}});return(r.structuredContent??r).item?.metadata??null}catch{return null}},staleTime:3e4});return i}function Da(t){const e=H.c(8),s=Bt();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={strict:!1},e[0]=i):i=e[0];const r=Jr(i),n=Ct(t.virtualMcpId),a=cd(t.taskId),{currentBranch:l}=vt(),h=n?.metadata?.ui??null,c=h?.layout??null,u=c?.tabs??[],d=h?.pinnedViews??[],f=a?.expanded_tools??[],_=!!(n&&Kt(n));let m;e[1]===Symbol.for("react.memo_cache_sentinel")?(m={includeVirtual:!0},e[1]=m):m=e[1];const p=Ti(m),{activeTab:g,mainOpen:v}=oc({mainParam:r.main,metadata:c?{defaultMainView:c.defaultMainView??null,tabs:u.map(hd)}:null}),b=Qo(g),S=[];_&&(S.push({id:"preview",title:"Preview"}),S.push({id:"env",title:"Terminal"}),S.push({id:"git",title:l??"git"})),S.push({id:"settings",title:"Settings"}),S.push({id:"automations",title:"Automations"});const x=new Map;for(const E of f){const A=yn(E.appId,E.toolName);x.set(A,{id:A,title:E.toolName,appId:E.appId,iconKey:E.toolName})}for(const E of d){const A=yn(E.connectionId,E.toolName);x.set(A,{id:A,title:E.label||E.toolName,appId:E.connectionId,iconKey:E.toolName,iconUrl:E.icon??null})}let y;e[2]!==p?(y=E=>({id:E.id,title:E.title,kind:"agent",icon:Hi({tabId:E.id,kind:"agent",appId:E.view.appId,connections:p})}),e[2]=p,e[3]=y):y=e[3];const N=[...u.map(y),...Array.from(x.values()).map(E=>({id:E.id,title:E.title,kind:"expanded",icon:Hi({tabId:E.iconKey,kind:"expanded",appId:E.appId,iconUrl:E.iconUrl,connections:p})})),...S.map(E=>({id:E.id,title:E.title,kind:"system",icon:Hi({tabId:E.id,kind:"system",connections:p})}))];let C;return e[4]!==g||e[5]!==v||e[6]!==s?(C=E=>{const A=ac({clickedId:E,activeTab:g,mainOpen:v});s({to:".",search:I=>({...I,main:A}),replace:!0})},e[4]=g,e[5]=v,e[6]=s,e[7]=C):C=e[7],{activeTab:g,mainOpen:v,setActiveTab:C,systemTabs:S,layoutTabs:u,expandedTools:f,automationTabParsed:b,tabs:N}}function hd(t){return{id:t.id}}function Ma(t){const{managerAgentId:e,managerName:s,kind:i,id:r,instructions:n}=t,a=` to improve the instructions of ${i} "${r}". Here are its current instructions.
|
|
3
3
|
<current_instructions>${n}</current_instructions>`;return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:"Use "},{type:"mention",attrs:{id:e,name:s,char:"@",metadata:{agentId:e,title:s}}},{type:"text",text:a}]}]}}function dd(t){const e=H.c(84),{value:s,onChange:i,onColorChange:r,name:n,size:a,className:l,avatarClassName:h,showHoverOverlay:c,disabled:u}=t,d=a===void 0?"lg":a,f=c===void 0?!0:c,_=u===void 0?!1:u,[m,p]=P.useState(!1),[g,v]=P.useState("icons"),[b,S]=P.useState(""),[x,y]=P.useState("blue");let N;e[0]!==s?(N=Ni(s),e[0]=s,e[1]=N):N=e[1];const C=N,R=C.type==="icon"||C.type==="url"&&C.color?C.color:x;let E;e[2]!==i||e[3]!==R?(E=ee=>{i(Oi(ee,R))},e[2]=i,e[3]=R,e[4]=E):E=e[4];const A=E;let I;e[5]!==i||e[6]!==r||e[7]!==C.name||e[8]!==C.type||e[9]!==C.url?(I=ee=>{y(ee),r?.(ee),C.type==="icon"?i(Oi(C.name,ee)):C.type==="url"&&i(Nn(C.url,ee))},e[5]=i,e[6]=r,e[7]=C.name,e[8]=C.type,e[9]=C.url,e[10]=I):I=e[10];const D=I;let k;e[11]!==i||e[12]!==R?(k=ee=>{i(Nn(ee,R)),p(!1)},e[11]=i,e[12]=R,e[13]=k):k=e[13];const w=k;let j;e[14]!==i||e[15]!==R?(j=()=>{const ee=en(),Ne=ee[Math.floor(Math.random()*ee.length)];i(Oi(Ne,R))},e[14]=i,e[15]=R,e[16]=j):j=e[16];const T=j;let M,B,O,q,U,F,Z,J;if(e[17]!==l||e[18]!==_||e[19]!==m||e[20]!==d){const ee={xs:"rounded-md",sm:"rounded-lg","sm+":"rounded-xl",md:"rounded-xl",lg:"rounded-2xl",xl:"rounded-2xl"};B=Vs,F=_?!1:m,Z=p,M=Ws,U=!0,J="button",O=_,q=re("relative group overflow-hidden",_?"cursor-default opacity-50":"cursor-pointer",ee[d],l),e[17]=l,e[18]=_,e[19]=m,e[20]=d,e[21]=M,e[22]=B,e[23]=O,e[24]=q,e[25]=U,e[26]=F,e[27]=Z,e[28]=J}else M=e[21],B=e[22],O=e[23],q=e[24],U=e[25],F=e[26],Z=e[27],J=e[28];let V;e[29]!==h||e[30]!==n||e[31]!==d||e[32]!==s?(V=o.jsx(jn,{icon:s,name:n,size:d,className:h}),e[29]=h,e[30]=n,e[31]=d,e[32]=s,e[33]=V):V=e[33];let $;e[34]!==_||e[35]!==f?($=f&&!_&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(sa,{size:16,className:"text-white"})}),e[34]=_,e[35]=f,e[36]=$):$=e[36];let W;e[37]!==O||e[38]!==q||e[39]!==V||e[40]!==$||e[41]!==J?(W=o.jsxs("button",{type:J,disabled:O,className:q,children:[V,$]}),e[37]=O,e[38]=q,e[39]=V,e[40]=$,e[41]=J,e[42]=W):W=e[42];let Q;e[43]!==M||e[44]!==U||e[45]!==W?(Q=o.jsx(M,{asChild:U,children:W}),e[43]=M,e[44]=U,e[45]=W,e[46]=Q):Q=e[46];let L;e[47]!==n||e[48]!==s?(L=o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(jn,{icon:s,name:n,size:"xl"})}),e[47]=n,e[48]=s,e[49]=L):L=e[49];let se;e[50]===Symbol.for("react.memo_cache_sentinel")?(se=()=>v("icons"),e[50]=se):se=e[50];const ie=g==="icons"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let te;e[51]!==ie?(te=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ie),e[51]=ie,e[52]=te):te=e[52];let G;e[53]!==te?(G=o.jsx("button",{type:"button",onClick:se,className:te,children:"Icons"}),e[53]=te,e[54]=G):G=e[54];let le;e[55]===Symbol.for("react.memo_cache_sentinel")?(le=()=>v("upload"),e[55]=le):le=e[55];const ue=g==="upload"?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground";let de;e[56]!==ue?(de=re("px-3 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",ue),e[56]=ue,e[57]=de):de=e[57];let fe;e[58]!==de?(fe=o.jsx("button",{type:"button",onClick:le,className:de,children:"Upload"}),e[58]=de,e[59]=fe):fe=e[59];let _e;e[60]===Symbol.for("react.memo_cache_sentinel")?(_e=o.jsx("div",{className:"flex-1"}),e[60]=_e):_e=e[60];let Ue;e[61]!==G||e[62]!==fe?(Ue=o.jsxs("div",{className:"flex items-center border-b border-border px-3",children:[G,fe,_e]}),e[61]=G,e[62]=fe,e[63]=Ue):Ue=e[63];let $e;e[64]!==D||e[65]!==T||e[66]!==A||e[67]!==w||e[68]!==C.name||e[69]!==C.type||e[70]!==b||e[71]!==R||e[72]!==g?($e=g==="icons"?o.jsx(_d,{search:b,onSearchChange:S,selectedColor:R,onColorChange:D,onSelectIcon:A,onRandom:T,currentIconName:C.type==="icon"?C.name:null}):o.jsx(pd,{onUpload:w}),e[64]=D,e[65]=T,e[66]=A,e[67]=w,e[68]=C.name,e[69]=C.type,e[70]=b,e[71]=R,e[72]=g,e[73]=$e):$e=e[73];let Qe;e[74]!==L||e[75]!==Ue||e[76]!==$e?(Qe=o.jsx(Us,{align:"start",className:"w-80 p-0",onOpenAutoFocus:ud,children:o.jsxs("div",{className:"flex flex-col",children:[L,Ue,$e]})}),e[74]=L,e[75]=Ue,e[76]=$e,e[77]=Qe):Qe=e[77];let at;return e[78]!==B||e[79]!==F||e[80]!==Z||e[81]!==Q||e[82]!==Qe?(at=o.jsxs(B,{open:F,onOpenChange:Z,children:[Q,Qe]}),e[78]=B,e[79]=F,e[80]=Z,e[81]=Q,e[82]=Qe,e[83]=at):at=e[83],at}function ud(t){return t.preventDefault()}function fd(t){const e=H.c(27),{selectedColor:s,onColorChange:i}=t,[r,n]=P.useState(!1);let a,l,h,c,u,d,f;if(e[0]!==r||e[1]!==s){const b=ta(s);l=Vs,d=r,f=n,a=Ws,u=!0,h="button",c=re("h-6 w-6 rounded-full shrink-0 ring-2 ring-offset-2 ring-offset-background transition-all cursor-pointer hover:scale-110",b.dot,"ring-foreground/20"),e[0]=r,e[1]=s,e[2]=a,e[3]=l,e[4]=h,e[5]=c,e[6]=u,e[7]=d,e[8]=f}else a=e[2],l=e[3],h=e[4],c=e[5],u=e[6],d=e[7],f=e[8];let _;e[9]!==h||e[10]!==c?(_=o.jsx("button",{type:h,className:c,title:"Change color"}),e[9]=h,e[10]=c,e[11]=_):_=e[11];let m;e[12]!==a||e[13]!==u||e[14]!==_?(m=o.jsx(a,{asChild:u,children:_}),e[12]=a,e[13]=u,e[14]=_,e[15]=m):m=e[15];let p;e[16]!==i||e[17]!==s?(p=yc.map(b=>o.jsx("button",{type:"button",onClick:()=>{i(b.name),n(!1)},className:re("h-5 w-5 rounded-full transition-all shrink-0 cursor-pointer",b.dot,s===b.name?"ring-2 ring-offset-1 ring-offset-background ring-foreground/30 scale-110":"hover:scale-110"),title:b.name},b.name)),e[16]=i,e[17]=s,e[18]=p):p=e[18];let g;e[19]!==p?(g=o.jsx(Us,{align:"start",side:"right",sideOffset:8,className:"w-auto p-2",onOpenAutoFocus:md,children:o.jsx("div",{className:"grid grid-cols-4 gap-1",children:p})}),e[19]=p,e[20]=g):g=e[20];let v;return e[21]!==l||e[22]!==d||e[23]!==f||e[24]!==m||e[25]!==g?(v=o.jsxs(l,{open:d,onOpenChange:f,children:[m,g]}),e[21]=l,e[22]=d,e[23]=f,e[24]=m,e[25]=g,e[26]=v):v=e[26],v}function md(t){return t.preventDefault()}function _d(t){const e=H.c(44),{search:s,onSearchChange:i,selectedColor:r,onColorChange:n,onSelectIcon:a,onRandom:l,currentIconName:h}=t;let c,u,d,f,_,m,p;if(e[0]!==h||e[1]!==n||e[2]!==l||e[3]!==i||e[4]!==a||e[5]!==s||e[6]!==r){const x=en(),y=ta(r);u=s.trim()?x.filter(D=>{const k=cr(D),w=s.toLowerCase();return k.includes(w)||D.toLowerCase().includes(w)}):x,m="flex flex-col";let N;e[14]===Symbol.for("react.memo_cache_sentinel")?(N=o.jsx(Na,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[14]=N):N=e[14];let C;e[15]!==i?(C=D=>i(D.target.value),e[15]=i,e[16]=C):C=e[16];let R;e[17]!==s||e[18]!==C?(R=o.jsxs("div",{className:"relative flex-1",children:[N,o.jsx(_s,{value:s,onChange:C,placeholder:"Filter...",className:"h-8 text-xs pl-7"})]}),e[17]=s,e[18]=C,e[19]=R):R=e[19];let E;e[20]===Symbol.for("react.memo_cache_sentinel")?(E=o.jsx(Sc,{size:14,className:"text-muted-foreground"}),e[20]=E):E=e[20];let A;e[21]!==l?(A=o.jsx("button",{type:"button",onClick:l,className:"h-8 w-8 flex items-center justify-center rounded-md border border-border hover:bg-accent transition-colors shrink-0",title:"Random icon",children:E}),e[21]=l,e[22]=A):A=e[22];let I;e[23]!==n||e[24]!==r?(I=o.jsx(fd,{selectedColor:r,onColorChange:n}),e[23]=n,e[24]=r,e[25]=I):I=e[25],e[26]!==A||e[27]!==I||e[28]!==R?(p=o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[R,A,I]}),e[26]=A,e[27]=I,e[28]=R,e[29]=p):p=e[29],c=ka,_="h-56",d="grid grid-cols-9 gap-0.5 px-2 pb-2",f=u.map(D=>{const k=ji(D);return k?o.jsx("button",{type:"button",onClick:()=>a(D),className:re("h-8 w-8 flex items-center justify-center rounded-md transition-colors cursor-pointer",h===D?re(y.bg,y.text):re(y.text,"hover:bg-accent")),title:D,children:o.jsx(k,{size:18})},D):null}),e[0]=h,e[1]=n,e[2]=l,e[3]=i,e[4]=a,e[5]=s,e[6]=r,e[7]=c,e[8]=u,e[9]=d,e[10]=f,e[11]=_,e[12]=m,e[13]=p}else c=e[7],u=e[8],d=e[9],f=e[10],_=e[11],m=e[12],p=e[13];let g;e[30]!==d||e[31]!==f?(g=o.jsx("div",{className:d,children:f}),e[30]=d,e[31]=f,e[32]=g):g=e[32];let v;e[33]!==u.length?(v=u.length===0&&o.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No icons found"}),e[33]=u.length,e[34]=v):v=e[34];let b;e[35]!==c||e[36]!==_||e[37]!==g||e[38]!==v?(b=o.jsxs(c,{className:_,children:[g,v]}),e[35]=c,e[36]=_,e[37]=g,e[38]=v,e[39]=b):b=e[39];let S;return e[40]!==m||e[41]!==p||e[42]!==b?(S=o.jsxs("div",{className:m,children:[p,b]}),e[40]=m,e[41]=p,e[42]=b,e[43]=S):S=e[43],S}function pd(t){const e=H.c(27),{onUpload:s}=t,i=P.useRef(null);let r;e[0]!==s?(r=N=>{const C=N.target.files?.[0];if(!C)return;if(C.size>2097152){pe.error("Image must be smaller than 2MB"),N.target.value="";return}const R=new FileReader;R.onerror=()=>{pe.error("Failed to read image file"),i.current&&(i.current.value="")},R.onloadend=()=>{R.readyState===FileReader.DONE&&R.result&&s(R.result),i.current&&(i.current.value="")},R.readAsDataURL(C)},e[0]=s,e[1]=r):r=e[1];const n=r,[a,l]=P.useState("");let h;e[2]!==s||e[3]!==a?(h=()=>{const N=a.trim();N&&(s(N),l(""))},e[2]=s,e[3]=a,e[4]=h):h=e[4];const c=h;let u;e[5]!==n?(u=o.jsx("input",{type:"file",ref:i,className:"hidden",accept:"image/*",onChange:n}),e[5]=n,e[6]=u):u=e[6];let d;e[7]===Symbol.for("react.memo_cache_sentinel")?(d=()=>i.current?.click(),e[7]=d):d=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=o.jsxs("button",{type:"button",onClick:d,className:"h-24 rounded-lg border-2 border-dashed border-border hover:border-foreground/50 hover:bg-accent/50 transition-colors flex flex-col items-center justify-center gap-2 text-muted-foreground hover:text-foreground",children:[o.jsx(sc,{size:20}),o.jsx("span",{className:"text-xs",children:"Click to upload an image (max 2MB)"})]}),e[8]=f):f=e[8];let _;e[9]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),e[9]=_):_=e[9];let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=N=>l(N.target.value),e[10]=m):m=e[10];let p;e[11]!==c?(p=N=>{N.key==="Enter"&&(N.preventDefault(),c())},e[11]=c,e[12]=p):p=e[12];let g;e[13]!==a||e[14]!==p?(g=o.jsx(_s,{value:a,onChange:m,placeholder:"Paste image URL...",className:"h-8 text-xs flex-1",onKeyDown:p}),e[13]=a,e[14]=p,e[15]=g):g=e[15];let v;e[16]!==a?(v=a.trim(),e[16]=a,e[17]=v):v=e[17];const b=!v;let S;e[18]!==c||e[19]!==b?(S=o.jsx(oe,{variant:"outline",size:"sm",className:"h-8 px-3 text-xs shrink-0",onClick:c,disabled:b,children:"Apply"}),e[18]=c,e[19]=b,e[20]=S):S=e[20];let x;e[21]!==S||e[22]!==g?(x=o.jsxs("div",{className:"flex items-center gap-1.5",children:[g,S]}),e[21]=S,e[22]=g,e[23]=x):x=e[23];let y;return e[24]!==x||e[25]!==u?(y=o.jsxs("div",{className:"flex flex-col gap-3 p-4",children:[u,f,_,x]}),e[24]=x,e[25]=u,e[26]=y):y=e[26],y}function gd(t){const e=H.c(5),{value:s}=t;let i;if(e[0]!==s){i=Symbol.for("react.early_return_sentinel");e:{const n=Ni(s);if(n.type==="icon"){const a=ji(n.name);if(a){let l;e[2]!==a?(l=o.jsx(a,{size:16,className:"text-muted-foreground"}),e[2]=a,e[3]=l):l=e[3],i=l;break e}}}e[0]=s,e[1]=i}else i=e[1];if(i!==Symbol.for("react.early_return_sentinel"))return i;let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx(Oc,{size:16,className:"text-muted-foreground"}),e[4]=r):r=e[4],r}function vd(t){const e=H.c(66),{value:s,onChange:i,className:r,disabled:n}=t,[a,l]=P.useState(!1),[h,c]=P.useState("");let u;e[0]!==s?(u=Ni(s),e[0]=s,e[1]=u):u=e[1];const d=u,f=d.type==="icon"?d.name:null;let _,m,p,g,v,b,S,x,y,N,C,R,E,A,I;if(e[2]!==r||e[3]!==f||e[4]!==n||e[5]!==i||e[6]!==a||e[7]!==h||e[8]!==s){const B=en();g=h.trim()?B.filter(V=>{const $=h.toLowerCase();return cr(V).includes($)||V.toLowerCase().includes($)}):B,p=Vs,v=n?!1:a,b=l;const O=n?"cursor-default opacity-50":"cursor-pointer hover:bg-accent";let q;e[24]!==r||e[25]!==O?(q=re("size-7 shrink-0 rounded-md transition-colors flex items-center justify-center",O,r),e[24]=r,e[25]=O,e[26]=q):q=e[26];let U;e[27]!==s?(U=o.jsx(gd,{value:s}),e[27]=s,e[28]=U):U=e[28],e[29]!==n||e[30]!==q||e[31]!==U?(S=o.jsx(Ws,{asChild:!0,children:o.jsx("button",{type:"button",disabled:n,className:q,children:U})}),e[29]=n,e[30]=q,e[31]=U,e[32]=S):S=e[32],m=Us,E="start",A="w-64 p-0",I=xd,C="flex flex-col";let F;e[33]===Symbol.for("react.memo_cache_sentinel")?(F=o.jsx(Na,{size:14,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none"}),e[33]=F):F=e[33];let Z;e[34]===Symbol.for("react.memo_cache_sentinel")?(Z=V=>c(V.target.value),e[34]=Z):Z=e[34],e[35]!==h?(R=o.jsx("div",{className:"px-2 py-2",children:o.jsxs("div",{className:"relative",children:[F,o.jsx(_s,{value:h,onChange:Z,placeholder:"Filter...",className:"h-7 text-xs pl-7"})]})}),e[35]=h,e[36]=R):R=e[36],_=ka,N="h-48",x="grid grid-cols-8 gap-0.5 px-2 pb-2";let J;e[37]!==f||e[38]!==i?(J=V=>{const $=ji(V);return $?o.jsx("button",{type:"button",onClick:()=>{i(`icon://${V}`),l(!1)},className:re("h-7 w-7 flex items-center justify-center rounded-md transition-colors cursor-pointer",f===V?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),title:cr(V),children:o.jsx($,{size:16})},V):null},e[37]=f,e[38]=i,e[39]=J):J=e[39],y=g.map(J),e[2]=r,e[3]=f,e[4]=n,e[5]=i,e[6]=a,e[7]=h,e[8]=s,e[9]=_,e[10]=m,e[11]=p,e[12]=g,e[13]=v,e[14]=b,e[15]=S,e[16]=x,e[17]=y,e[18]=N,e[19]=C,e[20]=R,e[21]=E,e[22]=A,e[23]=I}else _=e[9],m=e[10],p=e[11],g=e[12],v=e[13],b=e[14],S=e[15],x=e[16],y=e[17],N=e[18],C=e[19],R=e[20],E=e[21],A=e[22],I=e[23];let D;e[40]!==x||e[41]!==y?(D=o.jsx("div",{className:x,children:y}),e[40]=x,e[41]=y,e[42]=D):D=e[42];let k;e[43]!==g.length?(k=g.length===0&&o.jsx("div",{className:"flex items-center justify-center py-6 text-xs text-muted-foreground",children:"No icons found"}),e[43]=g.length,e[44]=k):k=e[44];let w;e[45]!==_||e[46]!==D||e[47]!==k||e[48]!==N?(w=o.jsxs(_,{className:N,children:[D,k]}),e[45]=_,e[46]=D,e[47]=k,e[48]=N,e[49]=w):w=e[49];let j;e[50]!==w||e[51]!==C||e[52]!==R?(j=o.jsxs("div",{className:C,children:[R,w]}),e[50]=w,e[51]=C,e[52]=R,e[53]=j):j=e[53];let T;e[54]!==m||e[55]!==j||e[56]!==E||e[57]!==A||e[58]!==I?(T=o.jsx(m,{align:E,className:A,onOpenAutoFocus:I,children:j}),e[54]=m,e[55]=j,e[56]=E,e[57]=A,e[58]=I,e[59]=T):T=e[59];let M;return e[60]!==p||e[61]!==v||e[62]!==b||e[63]!==S||e[64]!==T?(M=o.jsxs(p,{open:v,onOpenChange:b,children:[S,T]}),e[60]=p,e[61]=v,e[62]=b,e[63]=S,e[64]=T,e[65]=M):M=e[65],M}function xd(t){return t.preventDefault()}function ci(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"flex items-center justify-center h-32",children:o.jsx(Ie,{className:"animate-spin text-muted-foreground",size:24})}),t[0]=e):e=t[0],e}function Wi(t){return({error:e})=>e?.message?.includes("Method not found")||e?.code===-32601?o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:t})}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center h-full p-6 text-center space-y-4",children:[o.jsx("div",{className:"bg-destructive/10 p-3 rounded-full",children:o.jsx(Bl,{className:"h-6 w-6 text-destructive"})}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("h3",{className:"text-lg font-medium",children:"Something went wrong"}),o.jsx("p",{className:"text-sm text-muted-foreground max-w-xs mx-auto",children:e?.message?e.message.length>200?`${e.message.slice(0,200)}...`:e.message:"An unexpected error occurred"})]})]})}function bd(t){const e=H.c(23),{item:s,isSelected:i,onToggle:r,disabled:n}=t,a=n?"cursor-not-allowed opacity-50":"cursor-pointer",l=i?"bg-accent/25":"hover:bg-muted/50";let h;e[0]!==a||e[1]!==l?(h=re("flex items-start gap-3 p-4 rounded-lg transition-colors",a,l),e[0]=a,e[1]=l,e[2]=h):h=e[2];let c;e[3]!==s.name?(c=o.jsx("p",{className:"text-sm font-medium leading-none truncate",children:s.name}),e[3]=s.name,e[4]=c):c=e[4];let u;e[5]!==s.tags?(u=s.tags&&o.jsx("span",{className:"shrink-0",children:s.tags}),e[5]=s.tags,e[6]=u):u=e[6];let d;e[7]!==c||e[8]!==u?(d=o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c,u]}),e[7]=c,e[8]=u,e[9]=d):d=e[9];let f;e[10]!==s.description?(f=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e[10]=s.description,e[11]=f):f=e[11];let _;e[12]!==d||e[13]!==f?(_=o.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[d,f]}),e[12]=d,e[13]=f,e[14]=_):_=e[14];let m;e[15]!==n||e[16]!==i||e[17]!==r?(m=o.jsx(dh,{checked:i,onCheckedChange:r,disabled:n,className:"mt-0.5"}),e[15]=n,e[16]=i,e[17]=r,e[18]=m):m=e[18];let p;return e[19]!==h||e[20]!==_||e[21]!==m?(p=o.jsxs("label",{className:h,children:[_,m]}),e[19]=h,e[20]=_,e[21]=m,e[22]=p):p=e[22],p}function on(t){const e=H.c(13),{items:s,selections:i,onToggle:r,emptyMessage:n,disabled:a}=t;let l,h,c;if(e[0]!==a||e[1]!==n||e[2]!==s||e[3]!==r||e[4]!==i){c=Symbol.for("react.early_return_sentinel");e:{const d=s.map(Sd);if(s.length===0){let f;e[8]!==n?(f=o.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 space-y-1",children:o.jsx("div",{className:"flex items-center justify-center h-32 text-sm text-muted-foreground",children:n})}),e[8]=n,e[9]=f):f=e[9],c=f;break e}l="flex-1 overflow-auto px-4 py-3 space-y-1",h=s.map(f=>o.jsx(bd,{item:f,isSelected:i===null||i?.includes(f.id),onToggle:()=>r(f.id,d),disabled:a},f.id))}e[0]=a,e[1]=n,e[2]=s,e[3]=r,e[4]=i,e[5]=l,e[6]=h,e[7]=c}else l=e[5],h=e[6],c=e[7];if(c!==Symbol.for("react.early_return_sentinel"))return c;let u;return e[10]!==l||e[11]!==h?(u=o.jsx("div",{className:l,children:h}),e[10]=l,e[11]=h,e[12]=u):u=e[12],u}function Sd(t){return t.id}function yd(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=He(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Tc(c);let d;e[6]!==u.tools?(d=u.tools.map(wd),e[6]=u.tools,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(on,{items:f,selections:i,onToggle:r,emptyMessage:"No tools available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function wd(t){return{id:t.name,name:t.name,description:t.description,tags:o.jsx(sh,{annotations:t.annotations,_meta:t._meta})}}function Cd(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=He(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=Qc(c);let d;e[6]!==u.resources?(d=u.resources.map(kd),e[6]=u.resources,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(on,{items:f,selections:i,onToggle:r,emptyMessage:"No resources available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function kd(t){return{id:t.name||t.uri,name:t.name||t.uri,description:t.description}}function Nd(t){const e=H.c(13),{connectionId:s,selections:i,onToggle:r,disabled:n}=t,{org:a}=ve();let l;e[0]!==s||e[1]!==a.id||e[2]!==a.slug?(l={connectionId:s,orgId:a.id,orgSlug:a.slug},e[0]=s,e[1]=a.id,e[2]=a.slug,e[3]=l):l=e[3];const h=He(l);let c;e[4]!==h?(c={client:h},e[4]=h,e[5]=c):c=e[5];const{data:u}=uh(c);let d;e[6]!==u.prompts?(d=u.prompts.map(jd),e[6]=u.prompts,e[7]=d):d=e[7];const f=d;let _;return e[8]!==n||e[9]!==f||e[10]!==r||e[11]!==i?(_=o.jsx(on,{items:f,selections:i,onToggle:r,emptyMessage:"No prompts available",disabled:n}),e[8]=n,e[9]=f,e[10]=r,e[11]=i,e[12]=_):_=e[12],_}function jd(t){return{id:t.name,name:t.name,description:t.description}}function Ed(t){const e=H.c(54),{currentConnection:s,activeTab:i,selectedId:r,formData:n,toggleTool:a,toggleResource:l,togglePrompt:h,toggleAllTools:c,toggleAllResources:u,toggleAllPrompts:d,onTabChange:f}=t,_=n[r],m=i==="tools"?_?.tools===null:i==="resources"?_?.resources===null:_?.prompts===null;let p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==u||e[4]!==c?(p=()=>{i==="tools"?c(r):i==="resources"?u(r):d(r)},e[0]=i,e[1]=r,e[2]=d,e[3]=u,e[4]=c,e[5]=p):p=e[5];const g=p;let v;e[6]!==s.icon||e[7]!==s.title?(v=o.jsx(us,{icon:s.icon,name:s.title,size:"sm",className:"shrink-0"}),e[6]=s.icon,e[7]=s.title,e[8]=v):v=e[8];let b;e[9]!==s.title?(b=o.jsx("h2",{className:"text-base font-semibold truncate",children:s.title}),e[9]=s.title,e[10]=b):b=e[10];let S;e[11]!==s.description?(S=s.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description}),e[11]=s.description,e[12]=S):S=e[12];let x;e[13]!==b||e[14]!==S?(x=o.jsxs("div",{className:"flex-1 min-w-0",children:[b,S]}),e[13]=b,e[14]=S,e[15]=x):x=e[15];let y;e[16]!==v||e[17]!==x?(y=o.jsx("div",{className:"px-6 pt-5 pb-4 shrink-0",children:o.jsxs("div",{className:"flex items-center gap-3",children:[v,x]})}),e[16]=v,e[17]=x,e[18]=y):y=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=[{id:"tools",label:"Tools"},{id:"resources",label:"Resources"},{id:"prompts",label:"Prompts"}],e[19]=N):N=e[19];let C;e[20]!==f?(C=M=>f(M),e[20]=f,e[21]=C):C=e[21];let R;e[22]!==i||e[23]!==C?(R=o.jsx(hh,{tabs:N,activeTab:i,onTabChange:C}),e[22]=i,e[23]=C,e[24]=R):R=e[24];const E=m?"Deselect all":"Select all";let A;e[25]!==g||e[26]!==E?(A=o.jsx("button",{type:"button",onClick:g,className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:E}),e[25]=g,e[26]=E,e[27]=A):A=e[27];let I;e[28]!==A||e[29]!==R?(I=o.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-t border-border shrink-0",children:[R,A]}),e[28]=A,e[29]=R,e[30]=I):I=e[30];let D;e[31]!==i||e[32]!==n||e[33]!==r||e[34]!==a?(D=i==="tools"&&o.jsx(Ht,{fallback:Wi("Tools not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(yd,{connectionId:r,selections:n[r]?n[r].tools:[],onToggle:(M,B)=>a(r,M,B)})})}),e[31]=i,e[32]=n,e[33]=r,e[34]=a,e[35]=D):D=e[35];let k;e[36]!==i||e[37]!==n||e[38]!==r||e[39]!==l?(k=i==="resources"&&o.jsx(Ht,{fallback:Wi("Resources not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(Cd,{connectionId:r,selections:n[r]?n[r].resources:[],onToggle:(M,B)=>l(r,M,B)})})}),e[36]=i,e[37]=n,e[38]=r,e[39]=l,e[40]=k):k=e[40];let w;e[41]!==i||e[42]!==n||e[43]!==r||e[44]!==h?(w=i==="prompts"&&o.jsx(Ht,{fallback:Wi("Prompts not supported by this server"),children:o.jsx(P.Suspense,{fallback:o.jsx(ci,{}),children:o.jsx(Nd,{connectionId:r,selections:n[r]?n[r].prompts:[],onToggle:(M,B)=>h(r,M,B)})})}),e[41]=i,e[42]=n,e[43]=r,e[44]=h,e[45]=w):w=e[45];let j;e[46]!==D||e[47]!==k||e[48]!==w?(j=o.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[D,k,w]}),e[46]=D,e[47]=k,e[48]=w,e[49]=j):j=e[49];let T;return e[50]!==I||e[51]!==j||e[52]!==y?(T=o.jsxs(o.Fragment,{children:[y,I,j]}),e[50]=I,e[51]=j,e[52]=y,e[53]=T):T=e[53],T}function Td(t){const e=H.c(11),{connectionId:s,onAuthenticate:i,children:r}=t;let n;e[0]!==s?(n={connectionId:s},e[0]=s,e[1]=n):n=e[1];const a=da(n);if(a.supportsOAuth&&!a.isAuthenticated){let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center justify-center size-12 rounded-full bg-muted",children:o.jsx(wc,{size:22,className:"text-muted-foreground"})}),e[2]=c):c=e[2];let u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsxs("div",{className:"space-y-1",children:[o.jsx("p",{className:"text-sm font-medium",children:"Authorization required"}),o.jsx("p",{className:"text-xs text-muted-foreground max-w-xs",children:"This connection needs to be authorized before you can configure its tools and resources."})]}),e[3]=u):u=e[3];let d;e[4]!==s||e[5]!==i?(d=i&&o.jsx(oe,{variant:"outline",size:"sm",onClick:()=>i(s),children:"Authorize"}),e[4]=s,e[5]=i,e[6]=d):d=e[6];let f;return e[7]!==d?(f=o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[c,u,d]}),e[7]=d,e[8]=f):f=e[8],f}let h;return e[9]!==r?(h=o.jsx(o.Fragment,{children:r}),e[9]=r,e[10]=h):h=e[10],h}function Rd(t){const e={};for(const s of t)e[s.connection_id]={tools:s.selected_tools,resources:s.selected_resources??null,prompts:s.selected_prompts??null};return e}function Ln(t){return Object.entries(t).map(([e,s])=>({connection_id:e,selected_tools:s.tools,selected_resources:s.resources,selected_prompts:s.prompts}))}function Dd(t,e){return e.type==="SET_ACTIVE_TAB"?{...t,activeTab:e.payload}:t}function Md(t){const e=H.c(49),{open:s,onOpenChange:i,selectedId:r,form:n,connections:a,onAuthenticate:l}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={activeTab:"tools"},e[0]=h):h=e[0];const[c,u]=P.useReducer(Dd,h),d=tn(r??"");let f;e[1]!==a?(f=a??[],e[1]=a,e[2]=f):f=e[2];let _;e[3]!==f?(_=Rd(f),e[3]=f,e[4]=_):_=e[4];const m=_;let p;e[5]!==n||e[6]!==m?(p=(F,Z,J,V)=>{const $=m[F]?.[Z];let W;$===null?W=V.filter(L=>L!==J):$?.includes(J)?W=$.filter(L=>L!==J):(W=[...$??[],J],W.length===V.length&&(W=null));const Q={...m};Q[F]?Q[F]={...Q[F]}:Q[F]={tools:null,resources:null,prompts:null},Q[F][Z]=W,n.setValue("connections",Ln(Q),{shouldDirty:!0,shouldTouch:!0})},e[5]=n,e[6]=m,e[7]=p):p=e[7];const g=p;let v;e[8]!==n||e[9]!==m?(v=(F,Z)=>{const V=m[F]?.[Z]===null?[]:null,$={...m};$[F]?$[F]={...$[F]}:$[F]={tools:null,resources:null,prompts:null},$[F][Z]=V,n.setValue("connections",Ln($),{shouldDirty:!0,shouldTouch:!0})},e[8]=n,e[9]=m,e[10]=v):v=e[10];const b=v;let S;e[11]!==g?(S=(F,Z,J)=>g(F,"tools",Z,J),e[11]=g,e[12]=S):S=e[12];const x=S;let y;e[13]!==g?(y=(F,Z,J)=>g(F,"resources",Z,J),e[13]=g,e[14]=y):y=e[14];const N=y;let C;e[15]!==g?(C=(F,Z,J)=>g(F,"prompts",Z,J),e[15]=g,e[16]=C):C=e[16];const R=C;let E;e[17]!==b?(E=F=>b(F,"tools"),e[17]=b,e[18]=E):E=e[18];const A=E;let I;e[19]!==b?(I=F=>b(F,"resources"),e[19]=b,e[20]=I):I=e[20];const D=I;let k;e[21]!==b?(k=F=>b(F,"prompts"),e[21]=b,e[22]=k):k=e[22];const w=k;if(!r||!d)return null;let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(ci,{}),e[23]=j):j=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=F=>u({type:"SET_ACTIVE_TAB",payload:F}),e[24]=T):T=e[24];let M;e[25]!==d||e[26]!==c.activeTab||e[27]!==m||e[28]!==r||e[29]!==w||e[30]!==D||e[31]!==A||e[32]!==R||e[33]!==N||e[34]!==x?(M=o.jsx(Ed,{currentConnection:d,activeTab:c.activeTab,selectedId:r,formData:m,toggleTool:x,toggleResource:N,togglePrompt:R,toggleAllTools:A,toggleAllResources:D,toggleAllPrompts:w,onTabChange:T},r),e[25]=d,e[26]=c.activeTab,e[27]=m,e[28]=r,e[29]=w,e[30]=D,e[31]=A,e[32]=R,e[33]=N,e[34]=x,e[35]=M):M=e[35];let B;e[36]!==l||e[37]!==r||e[38]!==M?(B=o.jsx(P.Suspense,{fallback:j,children:o.jsx(Td,{connectionId:r,onAuthenticate:l,children:M})}),e[36]=l,e[37]=r,e[38]=M,e[39]=B):B=e[39];let O;e[40]!==i?(O=o.jsx(nh,{className:"px-6 py-4 border-t border-border shrink-0",children:o.jsx(oe,{variant:"outline",onClick:()=>i(!1),children:"Done"})}),e[40]=i,e[41]=O):O=e[41];let q;e[42]!==B||e[43]!==O?(q=o.jsxs(sn,{className:"sm:max-w-2xl h-[75vh] max-h-[75vh] flex flex-col p-0 gap-0 overflow-hidden w-[95vw]",children:[B,O]}),e[42]=B,e[43]=O,e[44]=q):q=e[44];let U;return e[45]!==i||e[46]!==s||e[47]!==q?(U=o.jsx(rn,{open:s,onOpenChange:i,children:q}),e[45]=i,e[46]=s,e[47]=q,e[48]=U):U=e[48],U}const Ui={tools:null,resources:null,prompts:null},Id=Pl.pick({status:!0,title:!0,description:!0,icon:!0,metadata:!0,connections:!0});function Ad(t){const s=new TextEncoder().encode(t),i=Array.from(s,r=>String.fromCharCode(r)).join("");return btoa(i)}function Bd(t){const e=H.c(11),{url:s,agentId:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i||e[1]!==s?(a=async()=>{ye("agent_connect_action",{agent_id:i,action:"copy_url"}),await navigator.clipboard.writeText(s),n(!0),pe.success("Agent URL copied to clipboard"),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=a):a=e[2];const l=a;let h;e[3]!==r?(h=r?o.jsx(Ri,{size:20,className:"text-green-600"}):o.jsx(ki,{size:20}),e[3]=r,e[4]=h):h=e[4];const c=r?"Copied!":"Copy URL";let u;e[5]!==c?(u=o.jsx("span",{className:"text-xs font-medium",children:c}),e[5]=c,e[6]=u):u=e[6];let d;return e[7]!==l||e[8]!==h||e[9]!==u?(d=o.jsxs(oe,{type:"button",variant:"outline",onClick:l,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[h,u]}),e[7]=l,e[8]=h,e[9]=u,e[10]=d):d=e[10],d}function Pd(t){const e=H.c(8),{url:s,serverName:i,agentId:r}=t;let n;e[0]!==r||e[1]!==i||e[2]!==s?(n=()=>{ye("agent_connect_action",{agent_id:r,action:"install_cursor"});const u=ua(i),f=Ad(JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Cursor"}},null,2)),_=`cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(u)}&config=${encodeURIComponent(f)}`;window.open(_,"_blank"),pe.success("Opening Cursor...")},e[0]=r,e[1]=i,e[2]=s,e[3]=n):n=e[3];const a=n;let l,h;e[4]===Symbol.for("react.memo_cache_sentinel")?(l=o.jsx("img",{src:"/logos/cursor.svg",alt:"Cursor",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(11%) sepia(8%) saturate(785%) hue-rotate(1deg) brightness(95%) contrast(89%)"}}),h=o.jsx("span",{className:"text-xs font-medium",children:"Install on Cursor"}),e[4]=l,e[5]=h):(l=e[4],h=e[5]);let c;return e[6]!==a?(c=o.jsxs(oe,{type:"button",variant:"outline",onClick:a,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[l,h]}),e[6]=a,e[7]=c):c=e[7],c}function Ld(t){const e=H.c(12),{url:s,serverName:i,agentId:r}=t,[n,a]=P.useState(!1);let l;e[0]!==r||e[1]!==i||e[2]!==s?(l=async()=>{ye("agent_connect_action",{agent_id:r,action:"install_claude_code"});const _=ua(i),p=JSON.stringify({type:"http",url:s,headers:{"x-mesh-client":"Claude Code"}},null,2),g=`claude mcp add-json "${_}" '${p.replace(/'/g,"'\\''")}' --scope user`;await navigator.clipboard.writeText(g),a(!0),pe.success("Claude Code command copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=r,e[1]=i,e[2]=s,e[3]=l):l=e[3];const h=l;let c;e[4]!==n?(c=n?o.jsx(Ri,{size:20,className:"text-green-600"}):o.jsx("img",{src:"/logos/Claude Code.svg",alt:"Claude Code",className:"h-5 w-5",style:{filter:"brightness(0) saturate(100%) invert(55%) sepia(31%) saturate(1264%) hue-rotate(331deg) brightness(92%) contrast(86%)"}}),e[4]=n,e[5]=c):c=e[5];const u=n?"Copied!":"Install on Claude Code";let d;e[6]!==u?(d=o.jsx("span",{className:"text-xs font-medium",children:u}),e[6]=u,e[7]=d):d=e[7];let f;return e[8]!==h||e[9]!==c||e[10]!==d?(f=o.jsxs(oe,{type:"button",variant:"outline",onClick:h,className:"h-auto py-3 px-4 flex flex-col items-center gap-2",children:[c,d]}),e[8]=h,e[9]=c,e[10]=d,e[11]=f):f=e[11],f}function Od({virtualMcp:t}){const{org:e}=ve(),s=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),[i,r]=P.useState(null),[n,a]=P.useState(!1),[l,h]=P.useState(!1),c=t.id,u=t.title||`agent-${c.slice(0,8)}`,d=i?`bunx @decocms/typegen@latest --mcp ${c} --key ${i} --output client.ts`:`bunx @decocms/typegen@latest --mcp ${c} --key <api-key> --output client.ts`,f=async()=>{a(!0);try{const p=(await s.callTool({name:"API_KEY_CREATE",arguments:{name:`typegen-${u}`,permissions:{[c]:["*"]}}})).structuredContent?.key;if(!p)throw new Error("No key in response");r(p),ye("agent_typegen_key_generated",{agent_id:c})}catch{ye("agent_typegen_key_failed",{agent_id:c}),pe.error("Failed to generate API key")}finally{a(!1)}},_=async()=>{ye("agent_connect_action",{agent_id:c,action:"typegen_copy_command",has_api_key:!!i}),await navigator.clipboard.writeText(d),h(!0),pe.success("Command copied to clipboard"),setTimeout(()=>h(!1),2e3)};return o.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"flex flex-col gap-0.5",children:[o.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Generate typed client"}),o.jsxs("p",{className:"text-xs text-muted-foreground",children:["Introspects this agent and writes a typed"," ",o.jsx("code",{className:"font-mono",children:"client.ts"})," you can import directly."]})]}),!i&&o.jsxs(oe,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:f,disabled:n,children:[n?o.jsx(Ie,{size:14,className:"animate-spin"}):o.jsx(ch,{size:14}),o.jsx("span",{children:n?"Generating…":"Generate API key"})]})]}),i&&o.jsx("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-700",children:"Store this key securely — it won't be shown again."}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Generate client"}),o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx("code",{className:"min-w-0 flex-1 break-all font-mono text-xs text-muted-foreground",children:d}),o.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:_,children:l?o.jsx(Ri,{size:12,className:"text-green-600"}):o.jsx(ki,{size:12})})]})}),o.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Runtime variables"}),o.jsx(zd,{apiKey:i,agentId:c})]})}function zd(t){const e=H.c(21),{apiKey:s,agentId:i}=t,[r,n]=P.useState(!1),a=window.location.origin,l=s?`MESH_API_KEY=${s}`:"MESH_API_KEY=<api-key>",h=`MESH_BASE_URL=${a}`,c=`${l}
|
|
4
4
|
${h}`;let u;e[0]!==i||e[1]!==s||e[2]!==c?(u=async()=>{ye("agent_connect_action",{agent_id:i,action:"typegen_copy_env",has_api_key:!!s}),await navigator.clipboard.writeText(c),n(!0),setTimeout(()=>n(!1),2e3)},e[0]=i,e[1]=s,e[2]=c,e[3]=u):u=e[3];const d=u,f=!s;let _;e[4]!==f?(_=re({"opacity-50":f}),e[4]=f,e[5]=_):_=e[5];let m;e[6]!==l||e[7]!==_?(m=o.jsx("span",{className:_,children:l}),e[6]=l,e[7]=_,e[8]=m):m=e[8];let p,g;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx("br",{}),g=o.jsx("span",{children:h}),e[9]=p,e[10]=g):(p=e[9],g=e[10]);let v;e[11]!==m?(v=o.jsxs("code",{className:"min-w-0 flex-1 font-mono text-xs text-muted-foreground",children:[m,p,g]}),e[11]=m,e[12]=v):v=e[12];let b;e[13]!==r?(b=r?o.jsx(Ri,{size:12,className:"text-green-600"}):o.jsx(ki,{size:12}),e[13]=r,e[14]=b):b=e[14];let S;e[15]!==d||e[16]!==b?(S=o.jsx(oe,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0",onClick:d,children:b}),e[15]=d,e[16]=b,e[17]=S):S=e[17];let x;return e[18]!==v||e[19]!==S?(x=o.jsx("div",{className:"rounded-md border border-input bg-muted/50 px-3 py-2.5",children:o.jsxs("div",{className:"flex items-start gap-2",children:[v,S]})}),e[18]=v,e[19]=S,e[20]=x):x=e[20],x}function $d(t){const e=H.c(3),{virtualMcp:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"h-20 animate-pulse rounded-md bg-muted"}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(Od,{virtualMcp:s})}),e[1]=s,e[2]=r):r=e[2],r}function Fd(t){const e=H.c(37),{open:s,onOpenChange:i,virtualMcp:r}=t,{org:n}=ve(),a=`/api/${n.slug}/mcp/virtual-mcp/${r.id}`;let l;e[0]!==a?(l=new URL(a,window.location.origin),e[0]=a,e[1]=l):l=e[1];const h=l;let c;e[2]!==r.id||e[3]!==r.title?(c=r.title||`agent-${r.id?.slice(0,8)??"default"}`,e[2]=r.id,e[3]=r.title,e[4]=c):c=e[4];const u=c,d=aa();let f;e[5]!==r.id||e[6]!==h.href?(f=o.jsx(Bd,{url:h.href,agentId:r.id}),e[5]=r.id,e[6]=h.href,e[7]=f):f=e[7];let _,m;e[8]!==u||e[9]!==r.id||e[10]!==h.href?(_=o.jsx(Pd,{url:h.href,serverName:u,agentId:r.id}),m=o.jsx(Ld,{url:h.href,serverName:u,agentId:r.id}),e[8]=u,e[9]=r.id,e[10]=h.href,e[11]=_,e[12]=m):(_=e[11],m=e[12]);let p;e[13]!==f||e[14]!==_||e[15]!==m?(p=o.jsx("div",{className:"flex flex-col gap-3 pt-2",children:o.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[f,_,m]})}),e[13]=f,e[14]=_,e[15]=m,e[16]=p):p=e[16];let g;e[17]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"border-t border-border"}),e[17]=g):g=e[17];let v;e[18]!==r?(v=o.jsx($d,{virtualMcp:r}),e[18]=r,e[19]=v):v=e[19];let b;e[20]!==p||e[21]!==v?(b=o.jsxs("div",{className:"flex flex-col gap-6",children:[p,g,v]}),e[20]=p,e[21]=v,e[22]=b):b=e[22];const S=b;if(d){let C;e[23]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(_h,{className:"mt-4 mb-4 text-base font-semibold",children:"Connect"}),e[23]=C):C=e[23];let R;e[24]!==S?(R=o.jsx(ph,{children:o.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-6 [touch-action:pan-y]",children:[C,S]})}),e[24]=S,e[25]=R):R=e[25];let E;return e[26]!==i||e[27]!==s||e[28]!==R?(E=o.jsx(gh,{open:s,onOpenChange:i,children:R}),e[26]=i,e[27]=s,e[28]=R,e[29]=E):E=e[29],E}let x;e[30]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Sa,{children:o.jsx(ya,{children:"Connect"})}),e[30]=x):x=e[30];let y;e[31]!==S?(y=o.jsxs(sn,{className:"max-h-[80vh] overflow-y-auto sm:max-w-2xl",children:[x,S]}),e[31]=S,e[32]=y):y=e[32];let N;return e[33]!==i||e[34]!==s||e[35]!==y?(N=o.jsx(rn,{open:s,onOpenChange:i,children:y}),e[33]=i,e[34]=s,e[35]=y,e[36]=N):N=e[36],N}function Hd(t,e){switch(e.type){case"SET_SHARE_DIALOG_OPEN":return{...t,shareDialogOpen:e.payload};case"SET_ADD_DIALOG_OPEN":return{...t,addDialogOpen:e.payload};case"OPEN_SETTINGS":return{...t,settingsDialogOpen:!0,settingsConnectionId:e.payload};case"CLOSE_SETTINGS":return{...t,settingsDialogOpen:!1,settingsConnectionId:null};default:return t}}function Wd(t){const e=H.c(22),{connection_id:s,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}=t,c=tn(s),{org:u}=ve();if(!c)return null;let d;e[0]!==c?(d=rh(c),e[0]=c,e[1]=d):d=e[1];const f=d;let _;e[2]!==s?(_=o.jsx(qd,{connection_id:s}),e[2]=s,e[3]=_):_=e[3];let m;e[4]!==c.app_name||e[5]!==c.connection_type||e[6]!==c.description||e[7]!==c.icon||e[8]!==c.title||e[9]!==s||e[10]!==a||e[11]!==h||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==u.slug||e[16]!==f||e[17]!==i?(m=o.jsx(Kd,{connection_id:s,connectionTitle:c.title,connectionDescription:c.description,connectionIcon:c.icon,connectionType:c.connection_type,slug:f,orgSlug:u.slug,appName:c.app_name,usedConnectionIds:i,onOpenSettings:r,onRemove:n,onAuthenticate:a,onSwitchInstance:l,onNewInstance:h}),e[4]=c.app_name,e[5]=c.connection_type,e[6]=c.description,e[7]=c.icon,e[8]=c.title,e[9]=s,e[10]=a,e[11]=h,e[12]=r,e[13]=n,e[14]=l,e[15]=u.slug,e[16]=f,e[17]=i,e[18]=m):m=e[18];let p;return e[19]!==_||e[20]!==m?(p=o.jsx(P.Suspense,{fallback:_,children:m}),e[19]=_,e[20]=m,e[21]=p):p=e[21],p}const On="__new_instance__";async function Ud(t,e){const s=t?.idToken??null;if(s){const r=zn(s);if(r)return r}const i=t?.userinfoEndpoint??null;if(i)try{const r=await fetch(i,{headers:{Authorization:`Bearer ${e}`}});if(r.ok){const n=await r.json(),a=typeof n.email=="string"?n.email:typeof n.upn=="string"?n.upn:typeof n.preferred_username=="string"?n.preferred_username:null;if(a)return a}}catch{}return zn(e)}function zn(t){try{const e=t.split(".");if(e.length===3&&e[1]){const s=JSON.parse(atob(e[1].replace(/-/g,"+").replace(/_/g,"/")));if(typeof s.email=="string")return s.email;if(typeof s.upn=="string")return s.upn;if(typeof s.preferred_username=="string")return s.preferred_username}}catch{}return null}function Vd(t){const e=H.c(23),{appName:s,connectionId:i,usedConnectionIds:r,onSwitchInstance:n,onNewInstance:a}=t;let l;e[0]!==s?(l={filters:[{column:"app_name",value:s}]},e[0]=s,e[1]=l):l=e[1];const h=Ti(l);if(h.length<=1)return null;let c;e[2]!==i||e[3]!==a||e[4]!==n?(c=p=>{p===On?a?.():n(i,p)},e[2]=i,e[3]=a,e[4]=n,e[5]=c):c=e[5];let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(ss,{size:"sm",className:"w-auto text-xs gap-1 px-2 shadow-none",children:o.jsx(is,{})}),e[6]=u):u=e[6];let d;if(e[7]!==i||e[8]!==h||e[9]!==r){let p;e[11]!==i||e[12]!==r?(p=g=>o.jsx(At,{value:g.id,className:"text-xs",disabled:g.id!==i&&r.has(g.id),children:g.title},g.id),e[11]=i,e[12]=r,e[13]=p):p=e[13],d=h.map(p),e[7]=i,e[8]=h,e[9]=r,e[10]=d}else d=e[10];let f;e[14]!==a?(f=a&&o.jsx(At,{value:On,className:"text-xs text-muted-foreground",children:"+ New instance"}),e[14]=a,e[15]=f):f=e[15];let _;e[16]!==d||e[17]!==f?(_=o.jsxs(rs,{children:[d,f]}),e[16]=d,e[17]=f,e[18]=_):_=e[18];let m;return e[19]!==i||e[20]!==c||e[21]!==_?(m=o.jsxs(ts,{value:i,onValueChange:c,children:[u,_]}),e[19]=i,e[20]=c,e[21]=_,e[22]=m):m=e[22],m}function Kd(t){const e=H.c(55),{connection_id:s,connectionTitle:i,connectionDescription:r,connectionIcon:n,connectionType:a,slug:l,orgSlug:h,appName:c,usedConnectionIds:u,onOpenSettings:d,onRemove:f,onAuthenticate:_,onSwitchInstance:m,onNewInstance:p}=t;let g;e[0]!==s?(g={connectionId:s},e[0]=s,e[1]=g):g=e[1];const v=da(g),S=!(a==="VIRTUAL")&&v.supportsOAuth&&!v.isAuthenticated,x=S?"border-destructive/50 bg-destructive/5":"border-border";let y;e[2]!==x?(y=re("rounded-xl border overflow-hidden transition-colors",x),e[2]=x,e[3]=y):y=e[3];let N;e[4]!==h||e[5]!==l?(N={org:h,appSlug:l},e[4]=h,e[5]=l,e[6]=N):N=e[6];let C;e[7]!==n||e[8]!==i?(C=o.jsx(us,{icon:n,name:i,size:"sm",className:"shrink-0"}),e[7]=n,e[8]=i,e[9]=C):C=e[9];let R;e[10]!==i?(R=o.jsx("p",{className:"text-sm font-medium truncate",children:i}),e[10]=i,e[11]=R):R=e[11];let E;e[12]!==r||e[13]!==S?(E=S?o.jsx("span",{className:"text-xs text-destructive font-medium",children:"Needs authorization"}):r&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r}),e[12]=r,e[13]=S,e[14]=E):E=e[14];let A;e[15]!==R||e[16]!==E?(A=o.jsxs("div",{className:"flex-1 min-w-0",children:[R,E]}),e[15]=R,e[16]=E,e[17]=A):A=e[17];let I;e[18]!==s||e[19]!==S||e[20]!==_?(I=S?o.jsx(oe,{variant:"outline",size:"sm",className:"h-7 text-xs shrink-0",onClick:V=>{V.preventDefault(),V.stopPropagation(),_(s)},children:"Authorize"}):o.jsxs(Ke,{delayDuration:0,children:[o.jsx(qe,{asChild:!0,children:o.jsx("span",{className:"inline-flex items-center justify-center rounded-md h-7 w-7 hover:bg-accent text-muted-foreground shrink-0 transition-colors",children:o.jsx(ah,{size:16})})}),o.jsx(Ge,{side:"bottom",children:"Connection settings"})]}),e[18]=s,e[19]=S,e[20]=_,e[21]=I):I=e[21];let D;e[22]!==N||e[23]!==C||e[24]!==A||e[25]!==I?(D=o.jsxs(zl,{to:"/$org/settings/connections/$appSlug",params:N,className:"flex items-center gap-3 px-4 py-3 cursor-pointer hover:bg-muted/50 transition-colors",children:[C,A,I]}),e[22]=N,e[23]=C,e[24]=A,e[25]=I,e[26]=D):D=e[26];let k;e[27]!==c||e[28]!==s||e[29]!==p||e[30]!==m||e[31]!==u?(k=c&&o.jsx(Vd,{appName:c,connectionId:s,usedConnectionIds:u,onSwitchInstance:m,onNewInstance:p}),e[27]=c,e[28]=s,e[29]=p,e[30]=m,e[31]=u,e[32]=k):k=e[32];let w;e[33]===Symbol.for("react.memo_cache_sentinel")?(w=o.jsx(kc,{size:13}),e[33]=w):w=e[33];let j;e[34]!==d?(j=o.jsx(qe,{asChild:!0,children:o.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:d,"aria-label":"Configure resources",children:w})}),e[34]=d,e[35]=j):j=e[35];let T;e[36]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsx(Ge,{side:"bottom",children:"Configure resources"}),e[36]=T):T=e[36];let M;e[37]!==j?(M=o.jsxs(Ke,{delayDuration:0,children:[j,T]}),e[37]=j,e[38]=M):M=e[38];let B;e[39]===Symbol.for("react.memo_cache_sentinel")?(B=o.jsx(ls,{size:13}),e[39]=B):B=e[39];let O;e[40]!==f?(O=o.jsx(qe,{asChild:!0,children:o.jsx(oe,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:f,"aria-label":"Remove connection",children:B})}),e[40]=f,e[41]=O):O=e[41];let q;e[42]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(Ge,{side:"bottom",children:"Remove"}),e[42]=q):q=e[42];let U;e[43]!==O?(U=o.jsxs(Ke,{delayDuration:0,children:[O,q]}),e[43]=O,e[44]=U):U=e[44];let F;e[45]!==M||e[46]!==U?(F=o.jsxs("div",{className:"flex items-center gap-0.5 ml-auto",children:[M,U]}),e[45]=M,e[46]=U,e[47]=F):F=e[47];let Z;e[48]!==k||e[49]!==F?(Z=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-t border-border bg-muted/25",children:[k,F]}),e[48]=k,e[49]=F,e[50]=Z):Z=e[50];let J;return e[51]!==D||e[52]!==Z||e[53]!==y?(J=o.jsxs("div",{className:y,children:[D,Z]}),e[51]=D,e[52]=Z,e[53]=y,e[54]=J):J=e[54],J}function qd(t){const e=H.c(17),{connection_id:s}=t,i=tn(s);if(!i){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(Ia,{}),e[0]=d):d=e[0],d}let r;e[1]!==i.icon||e[2]!==i.title?(r=o.jsx(us,{icon:i.icon,name:i.title,size:"sm",className:"shrink-0"}),e[1]=i.icon,e[2]=i.title,e[3]=r):r=e[3];let n;e[4]!==i.title?(n=o.jsx("p",{className:"text-sm font-medium truncate",children:i.title}),e[4]=i.title,e[5]=n):n=e[5];let a;e[6]!==i.description?(a=i.description&&o.jsx("p",{className:"text-xs text-muted-foreground truncate",children:i.description}),e[6]=i.description,e[7]=a):a=e[7];let l;e[8]!==n||e[9]!==a?(l=o.jsxs("div",{className:"flex-1 min-w-0",children:[n,a]}),e[8]=n,e[9]=a,e[10]=l):l=e[10];let h;e[11]!==r||e[12]!==l?(h=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[r,l]}),e[11]=r,e[12]=l,e[13]=h):h=e[13];let c;e[14]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})}),e[14]=c):c=e[14];let u;return e[15]!==h?(u=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[h,c]}),e[15]=h,e[16]=u):u=e[16],u}function Ia(){const t=H.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx("div",{className:"size-8 rounded-md bg-muted animate-pulse shrink-0"}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e,o.jsxs("div",{className:"flex-1 space-y-1.5",children:[o.jsx("div",{className:"h-4 w-32 rounded bg-muted animate-pulse"}),o.jsx("div",{className:"h-3 w-48 rounded bg-muted animate-pulse"})]})]}),t[1]=s):s=t[1];let i;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsxs("div",{className:"rounded-xl border border-border overflow-hidden",children:[s,o.jsx("div",{className:"flex items-center px-4 py-2 border-t border-border bg-muted/25",children:o.jsx("div",{className:"h-5 w-20 rounded bg-muted animate-pulse"})})]}),t[2]=i):i=t[2],i}function Gd({virtualMcpId:t,form:e,debouncedSave:s,flushAndSave:i}){const{org:r}=ve(),n=He({connectionId:Pt,orgId:r.id,orgSlug:r.slug}),a=Ct(t),l=(a?.connections??[]).map(w=>w.connection_id).sort(),{data:h}=Uo({queryKey:Bs.projectConnectionDetails(t,l),enabled:l.length>0,queryFn:async()=>await Promise.all(l.map(async j=>{try{const T=await n.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:j}}),{item:M}=ih(T),B=(M?.tools??[]).filter(O=>!!eh(O._meta)).map(O=>({name:O.name,description:O.description}));return{fetchOk:!0,id:j,title:M?.title??j,icon:M?.icon??null,uiTools:B}}catch{return{fetchOk:!1,id:j,title:j,icon:null,uiTools:[]}}}))}),c=(h??[]).filter(w=>w.uiTools.length>0),u=new Set(lc),d=e.watch("metadata.ui.pinnedViews")??[],f=e.watch("metadata.ui.layout")??null,_=f?.defaultMainView??null,m=f?.chatDefaultOpen??!1,p=!_||_.type==="chat"?"chat":_.type==="instructions"||_.type==="connections"||_.type==="layout"?"settings":u.has(_.type)?_.type:`${_.type}:${_.id??""}:${_.toolName??""}`,g=w=>{const[j,T,M]=w.split(":");return j?j==="chat"?{type:j}:u.has(j)?{type:j}:j==="ext-apps"&&T?{type:"ext-apps",id:T,toolName:M||void 0}:null:null},v=w=>{e.setValue("metadata.ui.pinnedViews",w,{shouldDirty:!0})},b=w=>{e.setValue("metadata.ui.layout",{...f,...w},{shouldDirty:!0})},S=P.useRef(!1);if(h&&h.length>0&&!S.current){S.current=!0;const w=new Set((h??[]).filter(M=>M.fetchOk).map(M=>M.id)),j=new Set(c.flatMap(M=>M.uiTools.map(B=>`${M.id}:${B.name}`))),T=d.filter(M=>!w.has(M.connectionId)||j.has(`${M.connectionId}:${M.toolName}`));T.length!==d.length&&(v(T),_?.type==="ext-apps"&&!T.some(M=>M.connectionId===_.id&&M.toolName===_.toolName)&&b({defaultMainView:{type:"chat"}}),s())}const x=(w,j)=>{if(d.some(M=>M.connectionId===w&&M.toolName===j)){const M=d.filter(O=>!(O.connectionId===w&&O.toolName===j));v(M);const B=`ext-apps:${w}:${j}`;p===B&&b({defaultMainView:{type:"chat"}})}else v([...d,{connectionId:w,toolName:j,label:wn(j),icon:null}]);i()},y=(w,j,T)=>{v(d.map(M=>M.connectionId===w&&M.toolName===j?{...M,label:T}:M)),s()},N=()=>{i()},C=(w,j,T)=>{v(d.map(M=>M.connectionId===w&&M.toolName===j?{...M,icon:T}:M)),i()},R=w=>{b({defaultMainView:g(w)}),i()},E=l.length===0,A=h&&c.length===0,I=!!Kt(a),D=[{value:"chat",label:"Chat"},{value:"settings",label:"Settings"},{value:"automations",label:"Automations"}];I&&(D.push({value:"env",label:"Terminal"}),D.push({value:"preview",label:"Preview"}));for(const w of d)D.push({value:`ext-apps:${w.connectionId}:${w.toolName}`,label:w.label||w.toolName});const k=c.length>0||E||A;return o.jsxs("div",{className:"flex flex-col gap-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsx("h2",{className:"text-sm font-medium text-foreground",children:"Layout"})}),o.jsxs(oh,{className:"p-6 gap-5",children:[o.jsxs(Rn,{className:"p-0 space-y-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Main view"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"What users see when they first open this agent."})]}),o.jsxs(ts,{value:p,onValueChange:R,children:[o.jsx(ss,{className:"w-44 h-8 text-sm capitalize shrink-0",children:o.jsx(is,{})}),o.jsx(rs,{children:D.map(w=>o.jsx(At,{value:w.value,className:"capitalize",children:w.label},w.value))})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Show chat"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Display the chat panel alongside the main view."})]}),o.jsxs(Ke,{delayDuration:0,children:[o.jsx(qe,{asChild:!0,children:o.jsx("span",{className:"shrink-0",children:o.jsx(dr,{checked:p==="chat"?!0:m,disabled:p==="chat",onCheckedChange:w=>{b({chatDefaultOpen:w}),i()}})})}),p==="chat"&&o.jsx(Ge,{side:"top",children:"Chat is always shown when it is the default view"})]})]})]}),k&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border -mx-6"}),o.jsxs(Rn,{className:"p-0 space-y-3",children:[o.jsx("div",{className:"flex items-center justify-between gap-4",children:o.jsxs("div",{className:"space-y-0.5 min-w-0",children:[o.jsx(Ms,{className:"font-normal text-foreground",children:"Pinned views"}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface interactive tools as top-level tabs in the agent."})]})}),E&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"Add a connection above to configure pinned views."}),A&&!E&&o.jsx("p",{className:"text-xs text-muted-foreground",children:"None of the connected servers expose interactive tools."}),c.length>0&&o.jsx("div",{className:"space-y-4 pt-1",children:c.map((w,j)=>o.jsxs("div",{children:[j>0&&o.jsx("div",{className:"border-t border-border -mx-6 mb-4"}),o.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[o.jsx(us,{icon:w.icon,name:w.title,size:"xs",className:"shrink-0"}),o.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.title})]}),o.jsx("div",{className:"space-y-1.5",children:w.uiTools.map(T=>{const M=d.some(O=>O.connectionId===w.id&&O.toolName===T.name),B=d.find(O=>O.connectionId===w.id&&O.toolName===T.name);return o.jsxs("div",{className:re("flex items-center justify-between gap-3 px-3 py-2 rounded-lg border transition-colors",M?"bg-accent/40 border-border":"bg-transparent border-border"),children:[o.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[o.jsx(vd,{value:B?.icon??null,onChange:O=>C(w.id,T.name,O),disabled:!M}),o.jsx(_s,{value:M&&B?B.label:wn(T.name),onChange:O=>y(w.id,T.name,O.target.value),onBlur:N,className:"h-7 text-sm w-40",disabled:!M,readOnly:!M})]}),o.jsx(dr,{checked:M,onCheckedChange:()=>x(w.id,T.name)})]},T.name)})})]},w.id))})]})]})]})]})}function Yd({virtualMcp:t,hideOwnTitle:e}){const{org:s}=ve(),i=Yl(),r=Jc(),n=ds(),a=He({connectionId:Pt,orgId:s.id,orgSlug:s.slug}),l=Ko({resolver:Ll(Id),defaultValues:t}),h=l.watch("connections"),c=!!Kt(t),[u,d]=P.useReducer(Hd,{shareDialogOpen:!1,addDialogOpen:!1,settingsDialogOpen:!1,settingsConnectionId:null}),[f,_]=P.useState(!1),[m,p]=P.useState(!1),{createNewTask:g,setChatOpen:v}=Ei(),{sendMessage:b}=fs(),S=ca(),x=async()=>{if(m)return;const L=l.getValues("metadata.instructions");if(L?.trim()){p(!0);try{D(),ye("agent_instructions_improve_clicked",{agent_id:t.id,instructions_length:L.length}),await S(["studio-agent-manager"]),v(!0),await b({tiptapDoc:Ma({managerAgentId:Jo.AGENT_MANAGER(s.id),managerName:"Agent Manager",kind:"agent",id:t.id,instructions:L})})}finally{p(!1)}}},y=()=>{D(),ye("agent_test_clicked",{agent_id:t.id}),g()},N=P.useRef(null),C=P.useRef(new Set),R=P.useRef(0),E=P.useRef(null),A=P.useRef(null),I=3e4,D=()=>{A.current&&(clearTimeout(A.current),A.current=null),N.current!==null&&(ye("agent_updated",{agent_id:t.id,fields:Array.from(C.current),instructions_length:E.current,save_count:R.current,edit_duration_ms:Date.now()-N.current}),N.current=null,C.current=new Set,R.current=0,E.current=null)},k=async()=>{const L=Object.keys(l.formState.dirtyFields);if(L.length===0)return;const se=L.includes("metadata"),ie=l.getValues(),te=await i.update.mutateAsync({id:t.id,data:ie});N.current===null&&(N.current=Date.now());for(const G of L)C.current.add(G);R.current+=1,se&&(E.current=ie.metadata?.instructions?.length??0),A.current&&clearTimeout(A.current),A.current=setTimeout(D,I),l.reset(te)},{schedule:w,flush:j}=Ca({save:k}),T=()=>{ye("connections_dialog_opened",{source:"agent_settings",mode:"add"}),d({type:"SET_ADD_DIALOG_OPEN",payload:!0})},M=async L=>{const se=l.getValues("connections");if(se.some(G=>G.connection_id===L))return;l.setValue("connections",[...se,{connection_id:L,selected_tools:Ui.tools,selected_resources:Ui.resources,selected_prompts:Ui.prompts}],{shouldDirty:!0}),w(),d({type:"SET_ADD_DIALOG_OPEN",payload:!1});const ie=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin),te=await xn({url:ie.href,token:null,orgId:s.id});te.supportsOAuth&&!te.isAuthenticated&&await F(L)},B=L=>{const ie=l.getValues("connections").filter(te=>te.connection_id!==L);l.setValue("connections",ie,{shouldDirty:!0}),w()},O=(L,se)=>{const ie=l.getValues("connections");if(ie.some(te=>te.connection_id===se)){pe.error("This instance is already added to the agent");return}l.setValue("connections",ie.map(te=>te.connection_id===L?{...te,connection_id:se}:te),{shouldDirty:!0}),w()},q=async L=>{if(l.getValues("connections").find(ie=>ie.connection_id===L))try{const ie=await a.callTool({name:"COLLECTION_CONNECTIONS_GET",arguments:{id:L}}),{item:te}=ie.structuredContent??{};if(!te)return;const G=te.title.replace(/\s*\(.*?\)\s*$/,""),le=Zc("conn"),ue=`${G} (${Date.now().toString(36).slice(-4)})`;await r.create.mutateAsync({id:le,title:ue,description:te.description??null,connection_type:te.connection_type,connection_url:te.connection_url??null,connection_token:null,icon:te.icon??null,app_name:te.app_name??null,app_id:te.app_id??null,connection_headers:te.connection_headers??null});const de=new URL(`/api/${s.slug}/mcp/${le}`,window.location.origin),fe=await xn({url:de.href,token:null,orgId:s.id});if(fe.supportsOAuth&&!fe.isAuthenticated){const _e=await F(le);if(!_e){await r.delete.mutateAsync(le);return}await r.update.mutateAsync({id:le,data:{title:`${G} (${_e})`}})}O(L,le),pe.success("New instance created")}catch(ie){console.error("Failed to create instance:",ie),pe.error("Failed to create instance")}},U=L=>{d({type:"OPEN_SETTINGS",payload:L})},F=async L=>{const{token:se,tokenInfo:ie,error:te}=await Ol({connectionId:L,orgSlug:s.slug,scope:"offline_access"});if(te||!se)return pe.error(`Authentication failed: ${te}`),null;if(ie)try{const le=await fetch(`/api/${s.slug}/connections/${L}/oauth-token`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({accessToken:ie.accessToken,refreshToken:ie.refreshToken,expiresIn:ie.expiresIn,scope:ie.scope,clientId:ie.clientId,clientSecret:ie.clientSecret,tokenEndpoint:ie.tokenEndpoint})});if(!le.ok)console.error("Failed to save OAuth token:",await le.text()),await r.update.mutateAsync({id:L,data:{connection_token:se}});else try{await r.update.mutateAsync({id:L,data:{}})}catch(ue){console.warn("Failed to refresh connection tools after OAuth:",ue)}}catch(le){console.error("Error saving OAuth token:",le),await r.update.mutateAsync({id:L,data:{connection_token:se}})}else await r.update.mutateAsync({id:L,data:{connection_token:se}});const G=new URL(`/api/${s.slug}/mcp/${L}`,window.location.origin);return await n.invalidateQueries({queryKey:Bs.isMCPAuthenticated(G.href,null)}),pe.success("Authentication successful"),Ud(ie,se)},Z=()=>{const L=l.getValues("metadata.instructions")??"",se=`<role>
|
|
5
5
|
Define who this agent is and what it specializes in.
|
|
@@ -179,4 +179,4 @@ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){t
|
|
|
179
179
|
`,e)}paste(t){this._core.paste(t)}refresh(t,e){this._verifyIntegers(t,e),this._core.refresh(t,e)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(t){this._addonManager.loadAddon(this,t)}static get strings(){return{get promptLabel(){return mr.get()},set promptLabel(t){mr.set(t)},get tooMuchOutput(){return _r.get()},set tooMuchOutput(t){_r.set(t)}}}_verifyIntegers(...t){for(ut of t)if(ut===1/0||isNaN(ut)||ut%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...t){for(ut of t)if(ut&&(ut===1/0||isNaN(ut)||ut%1!==0||ut<0))throw new Error("This API only accepts positive integers")}};var Sp=2,yp=1,wp=class{activate(t){this._terminal=t}dispose(){}fit(){let t=this.proposeDimensions();if(!t||!this._terminal||isNaN(t.cols)||isNaN(t.rows))return;let e=this._terminal._core;(this._terminal.rows!==t.rows||this._terminal.cols!==t.cols)&&(e._renderService.clear(),this._terminal.resize(t.cols,t.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let t=this._terminal._core._renderService.dimensions;if(t.css.cell.width===0||t.css.cell.height===0)return;let e=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,u=r-h-e;return{cols:Math.max(Sp,Math.floor(u/t.css.cell.width)),rows:Math.max(yp,Math.floor(c/t.css.cell.height))}}};function Cp({source:t,onReady:e,onSelectionChange:s,className:i}){const r=P.useRef(null),n=P.useRef(null),a=P.useRef(s);a.current=s;const l=Gt(),h=P.useRef(t);return h.current=t,Uu((c,u)=>{c===h.current&&n.current?.write(u)}),P.useEffect(()=>{const c=r.current;if(!c)return;const u=getComputedStyle(document.documentElement),d=v=>u.getPropertyValue(v).trim()||void 0,f=new bp({allowTransparency:!1,fontFamily:d("--font-mono")||"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",fontSize:12.5,lineHeight:1.5,scrollback:5e3,cursorBlink:!1,disableStdin:!0,theme:{background:d("--sidebar")||d("--card")||d("--background")||"#1e1e1e",cursor:"transparent",foreground:d("--foreground")||"#d4d4d4",selectionBackground:d("--accent"),selectionForeground:d("--accent-foreground"),black:d("--muted"),red:d("--destructive"),green:d("--success"),yellow:d("--warning"),blue:d("--chart-1"),magenta:d("--chart-3"),cyan:d("--chart-5"),white:d("--foreground"),brightBlack:d("--muted-foreground"),brightRed:d("--destructive"),brightGreen:d("--success"),brightYellow:d("--warning"),brightBlue:d("--chart-1"),brightMagenta:d("--chart-3"),brightCyan:d("--chart-5"),brightWhite:d("--foreground")}}),_=new wp;f.loadAddon(_),f.open(c),_.fit();const m=l.getBuffer(t);m&&f.write(m),n.current=f,e?.(f);const p=f.onSelectionChange(()=>{const v=!!f.getSelection();a.current?.(v,()=>f.getSelection())}),g=new ResizeObserver(()=>{_.fit()});return g.observe(c),()=>{p.dispose(),g.disconnect(),n.current=null,f.dispose()}},[]),o.jsx("div",{ref:r,className:re("overflow-hidden bg-sidebar px-4 py-3 [&_.xterm]:h-full [&_.xterm-screen]:min-h-full [&_.xterm-viewport]:overscroll-contain",i)})}function kp(){const t=H.c(2),s=vn()?.entity;let i;return t[0]!==s?(i=Kt(s),t[0]=s,t[1]=i):i=t[1],i}const Np={npm:{install:"npm install",run:t=>`npm run ${t}`,runtime:"node"},pnpm:{install:"pnpm install",run:t=>`pnpm run ${t}`,runtime:"node"},yarn:{install:"yarn install",run:t=>`yarn run ${t}`,runtime:"node"},bun:{install:"bun install",run:t=>`bun run ${t}`,runtime:"bun"},deno:{install:"deno install",run:t=>`deno task ${t}`,runtime:"deno"}},Lo=["dev","start"];function jp({daemonOpen:t=!1}){const{org:e}=ve(),s=vn(),i=ds(),{data:r}=Ci.useSession(),{currentBranch:n,setCurrentTaskBranch:a}=vt(),l=r?.user?.id,h=s?.entity?.metadata,c=l&&n?h?.vmMap?.[l]?.[n]:void 0,u=c&&n?{previewUrl:c.previewUrl,vmId:c.vmId,branch:n,runnerKind:c.runnerKind}:null,[d,f]=P.useState(null),[_,m]=P.useState(""),[p,g]=P.useState(""),[v,b]=P.useState(!1),[S,x]=P.useState(new Set),y=P.useRef(!1),N=P.useRef(Date.now()),[C,R]=P.useState("setup"),[E,A]=P.useState([]),I=P.useRef(new Map),{sendMessage:D}=fs(),{setChatOpen:k}=Ei(),[w,j]=P.useState(!1),T=P.useRef(null),M=Y=>{R(Y),j(!1),T.current=null},B=(Y,ne,Re)=>{Y===C&&(j(ne),T.current=ne?Re:null)},O=()=>{const Y=T.current?.();if(!Y)return;k(!0),D({parts:[{type:"text",text:`<server-logs>
|
|
180
180
|
${Y}
|
|
181
181
|
</server-logs>`}]}),I.current.get(C)?.clearSelection()},q=He({connectionId:Pt,orgId:e.id,orgSlug:e.slug}),U=Gt(),F=Ra(s?.entity?.id,n??void 0),Z=U.suspended?"suspended":U.notFound?"creating":u?"running":F?"creating":"idle",J=d??Z;P.useEffect(()=>{d==="creating"&&Z==="running"&&f(null),d==="stopping"&&Z==="idle"&&f(null)},[Z,d]);const V=nn(q),{mutate:$,isPending:W}=V,Q=s?.entity?.id,L=U.notFound?c?.vmId??null:null,se=P.useRef(null);P.useEffect(()=>{if(!L||!Q||W||se.current===L)return;se.current=L;const Y={virtualMcpId:Q};n&&(Y.branch=n),$(Y,{onError:ne=>{console.error("[env] reprovision VM_START failed",ne)}})},[L,Q,n,W,$]);const ie=P.useRef(!1);P.useEffect(()=>{if(U.scripts.length>0&&!ie.current){ie.current=!0;for(const Y of Lo)if(U.scripts.includes(Y)){A([Y]),M(Y);break}}},[U.scripts]);const te=async(Y,ne)=>{const Re=await q.callTool({name:Y,arguments:ne}),Je=Re.content;if(Je?.[0]?.text?.startsWith("Error:"))throw new Error(Je[0].text);return Re.structuredContent??Re},G=async Y=>{if(!(v||!u||!Q||!n)){b(!0);try{const ne=new URLSearchParams({virtualMcpId:Q,branch:n}).toString(),Re=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/exec/${encodeURIComponent(Y)}?${ne}`,{method:"POST"});if(!Re.ok)throw new Error(`Exec failed: ${Re.statusText}`);x(Je=>{const jt=new Set(Je);return jt.delete(Y),jt})}finally{b(!1)}}},le=async Y=>{if(!(v||!u||!Q||!n)){b(!0);try{const ne=new URLSearchParams({virtualMcpId:Q,branch:n}).toString(),Re=await fetch(`/api/${encodeURIComponent(e.slug)}/vm-exec/kill/${encodeURIComponent(Y)}?${ne}`,{method:"POST"});if(!Re.ok)throw new Error(`Kill failed: ${Re.statusText}`);x(Je=>new Set(Je).add(Y))}finally{b(!1)}}},ue=Y=>{E.includes(Y)||A(ne=>[...ne,Y]),M(Y),G(Y)},de=async()=>{if(!y.current){y.current=!0,s?.entity?.id&&n&&gi.clear(s.entity.id,n),N.current=Date.now(),f("creating"),m("Connecting..."),g(""),ie.current=!1,A([]),M("setup");try{if(!s?.entity)throw new Error("No virtual MCP context");const Y={virtualMcpId:s.entity.id};n&&(Y.branch=n);const ne=await te("VM_START",Y);if(!ne.vmId||!ne.branch)throw new Error("Invalid VM response — missing fields");n||a(ne.branch),m(""),oi(i)}catch(Y){f("error"),g(Y instanceof Error?Y.message:"Failed to start VM")}finally{y.current=!1}}},fe=async()=>{const Y=u?.branch??n;f("stopping");const ne=s?.entity?.id;if(ne&&Y&&gi.mark(ne,Y),ne&&Y)try{await q.callTool({name:"VM_DELETE",arguments:{virtualMcpId:ne,branch:Y}})}catch{}oi(i)},_e=kp(),Ue=s?.entity?.metadata?.runtime,$e="__none__",Qe=Object.keys(Np),at=async(Y,ne)=>{if(s?.entity)try{await q.callTool({name:"COLLECTION_VIRTUAL_MCP_UPDATE",arguments:{id:s.entity.id,data:{metadata:{runtime:{...Ue,[Y]:ne}}}}}),oi(i)}catch{pe.error("Failed to update setting")}};if(J==="idle"||J==="stopping"){const Y=J==="stopping";return o.jsx("div",{className:"flex flex-col items-center justify-center w-full h-full p-6",children:o.jsxs("div",{className:"flex flex-col gap-4 w-full max-w-xs",children:[_e&&o.jsxs("a",{href:`https://github.com/${_e.owner}/${_e.name}`,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors",children:[o.jsx(th,{size:24}),o.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[o.jsxs("span",{className:"text-sm font-medium truncate",children:[_e.owner,"/",_e.name]}),o.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["github.com/",_e.owner,"/",_e.name]})]}),o.jsx(qt,{size:14,className:"text-muted-foreground shrink-0"})]}),o.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-2 w-full",children:[o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-runtime",className:"text-xs font-medium",children:"Runtime"}),o.jsxs(ts,{value:Ue?.selected??$e,onValueChange:ne=>at("selected",ne===$e?null:ne),children:[o.jsx(ss,{id:"env-runtime",className:"w-28",children:o.jsx(is,{placeholder:"None"})}),o.jsxs(rs,{children:[o.jsx(At,{value:$e,children:"None"}),Qe.map(ne=>o.jsx(At,{value:ne,children:ne},ne))]})]})]}),o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(Ms,{htmlFor:"env-port",className:"text-xs font-medium",children:"Port"}),o.jsx(_s,{id:"env-port",placeholder:"3001",className:"w-20 h-8",defaultValue:Ue?.port??"",onBlur:ne=>at("port",ne.target.value||null)})]}),o.jsxs(oe,{onClick:de,disabled:Y,children:[Y?o.jsx(Ie,{size:14,className:"animate-spin"}):o.jsx(li,{size:14}),Y?"Stopping...":"Run"]})]})]})})}if(J==="creating"){const Y=U.notFound?"Sandbox was stopped, we're restarting it…":_;return o.jsxs("div",{className:"flex flex-col items-center justify-center w-full h-full gap-4",children:[o.jsx(Ie,{size:24,className:"animate-spin text-muted-foreground"}),o.jsx("p",{className:"text-sm text-muted-foreground",children:Y}),o.jsx(cc,{since:N.current})]})}if(J==="error")return o.jsx(za,{errorMsg:p,onRetry:de});if(J==="suspended")return o.jsx(Oa,{onResume:de});const ee=["setup",...E,...t?["daemon"]:[]],Ne=U.scripts.filter(Y=>!E.includes(Y));return o.jsx("div",{className:"flex flex-col w-full h-full",children:o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex h-12 items-center border-b border-border px-2 shrink-0",children:[ee.map(Y=>o.jsx("button",{type:"button",onClick:()=>M(Y),className:re("flex items-center h-full px-3 text-sm whitespace-nowrap border-b-2 mb-[-1px] capitalize transition-all hover:text-foreground",C===Y?"text-foreground border-primary":"text-muted-foreground border-transparent"),children:Y},Y)),Ne.length>0&&o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",className:"flex items-center h-full px-2 text-muted-foreground hover:text-foreground transition-colors",children:o.jsx(cs,{size:14})})}),o.jsx(as,{align:"start",children:Ne.map(Y=>o.jsx(wt,{onClick:()=>ue(Y),children:Y},Y))})]}),o.jsx("div",{className:"flex-1 flex justify-center",children:u?.vmId&&o.jsxs("div",{className:"flex items-center",children:[o.jsxs(Ke,{children:[o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 rounded-l bg-muted px-1.5 py-0.5 text-[10px] font-mono text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors border-r border-border/50",onClick:()=>navigator.clipboard.writeText(u?.vmId??""),children:u.vmId})}),o.jsx(Ge,{side:"bottom",children:"Copy VM ID"})]}),o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",className:"shrink-0 self-stretch rounded-r bg-muted px-0.5 text-[10px] text-muted-foreground cursor-pointer hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(fr,{size:10})})}),o.jsx(as,{align:"center",children:o.jsxs(wt,{onClick:fe,children:[o.jsx(En,{size:12}),"Stop Server"]})})]})]})}),o.jsxs("div",{className:"flex items-center gap-1",children:[w&&o.jsxs("button",{type:"button",onClick:O,className:"flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[o.jsx(Nc,{size:12}),"Add to chat"]}),C!=="setup"&&C!=="daemon"&&E.includes(C)&&(()=>{const Y=Lo.includes(C),ne=U.appStatus?.status==="up"||U.appStatus?.status==="starting",Re=Y?ne:U.activeProcesses.includes(C)&&!S.has(C),Je=()=>G(C),jt=()=>le(C);return o.jsxs("div",{className:"flex items-center",children:[o.jsxs("button",{type:"button",disabled:v,onClick:Je,className:re("flex items-center gap-1 border border-border px-2 py-1 text-xs font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",Re?"rounded-l-md border-r-0":"rounded-md"),children:[v?o.jsx(Ie,{size:12,className:"animate-spin"}):o.jsx(li,{size:12}),v?"Running...":Re?"Restart":"Run"]}),Re&&o.jsxs(ns,{children:[o.jsx(os,{asChild:!0,children:o.jsx("button",{type:"button",disabled:v,className:"flex items-center self-stretch rounded-r-md border border-border px-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors disabled:opacity-50",children:o.jsx(fr,{size:12})})}),o.jsx(as,{align:"end",children:o.jsxs(wt,{onClick:jt,children:[o.jsx(En,{size:12}),Y?"Stop":"Stop Process"]})})]})]})})()]})]}),o.jsx("div",{className:"flex-1 overflow-hidden",children:ee.map(Y=>o.jsx("div",{className:re("h-full",C===Y?"block":"hidden"),children:U.hasData(Y)||Y==="setup"||Y==="daemon"?o.jsx(Cp,{source:Y,onReady:ne=>{I.current.set(Y,ne)},onSelectionChange:(ne,Re)=>B(Y,ne,Re),className:"h-full"}):o.jsx(Ls,{className:"h-full",image:null,title:`Script "${Y}" not running`,description:`Click Run to start "${Y}".`,actions:o.jsxs(oe,{variant:"outline",size:"sm",disabled:v,onClick:()=>G(Y),children:[v?o.jsx(Ie,{size:14,className:"animate-spin"}):o.jsx(li,{size:14}),"Run"]})})},Y))})]})})}function Ep(t){const e=H.c(1);let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=o.jsx(jp,{}),e[0]=s):s=e[0],s}function As(t){const e=t.trim().split(/\s+/);return e.length!==5?!1:e.every(s=>/^[\d*/,-]+$/.test(s))}function Tp(t){if(!t)return"Unknown schedule";const e=t.trim();if(e==="* * * * *")return"Every minute";if(e==="0 * * * *")return"Every hour";if(e==="0 0 * * *")return"Every day";if(e==="0 0 * * 1")return"Every week";const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return`Every ${s[1]} minutes`;const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return`Every ${i[1]} hours`;const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const l=parseInt(r[1]??"1");return l%7===0?`Every ${l/7} weeks`:`Every ${l} days`}const n=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+\*$/);if(n){const l=(n[2]??"0").padStart(2,"0"),h=(n[1]??"0").padStart(2,"0");return`Every day at ${l}:${h} UTC`}const a=e.match(/^(\d+)\s+(\d+)\s+\*\s+\*\s+(\d)$/);if(a){const h=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][parseInt(a[3]??"0")]??"day",c=(a[2]??"0").padStart(2,"0"),u=(a[1]??"0").padStart(2,"0");return`Every ${h} at ${c}:${u} UTC`}return t}function Rp(t,e){const s=Math.max(1,t);switch(e){case"minutes":return s===1?"* * * * *":`*/${s} * * * *`;case"hours":return s===1?"0 * * * *":`0 */${s} * * *`;case"days":return s===1?"0 0 * * *":`0 0 */${s} * *`;case"weeks":return s===1?"0 0 * * 1":`0 0 */${s*7} * *`}}function Dp(t){const e=t.trim();if(e==="* * * * *")return{count:1,unit:"minutes"};if(e==="0 * * * *")return{count:1,unit:"hours"};if(e==="0 0 * * *")return{count:1,unit:"days"};if(e==="0 0 * * 1")return{count:1,unit:"weeks"};const s=e.match(/^\*\/(\d+)\s+\*\s+\*\s+\*\s+\*$/);if(s)return{count:parseInt(s[1]),unit:"minutes"};const i=e.match(/^0\s+\*\/(\d+)\s+\*\s+\*\s+\*$/);if(i)return{count:parseInt(i[1]),unit:"hours"};const r=e.match(/^0\s+0\s+\*\/(\d+)\s+\*\s+\*$/);if(r){const n=parseInt(r[1]);return n%7===0?{count:n/7,unit:"weeks"}:{count:n,unit:"days"}}return null}function Mp(t,e){return e===1?{minutes:"minute",hours:"hour",days:"day",weeks:"week"}[t]??t:t}const Ip=[{label:"Minute",cron:"* * * * *"},{label:"Hour",cron:"0 * * * *"},{label:"Day",cron:"0 0 * * *"},{label:"Week",cron:"0 0 * * 1"}];function Ap(t){const e=H.c(33),{automationId:s,open:i,onOpenChange:r,onCustomSelect:n,onEventSelect:a}=t,{triggerAdd:l}=Ks(),[h,c]=P.useState(!1),u=i??h;let d;e[0]!==r?(d=I=>{r?r(I):c(I)},e[0]=r,e[1]=d):d=e[1];const f=d;let _;e[2]!==l||e[3]!==s||e[4]!==f?(_=async I=>{try{await l.mutateAsync({automation_id:s,type:"cron",cron_expression:I}),pe.success("Starter added"),f(!1)}catch(D){const k=D,w=k instanceof Error?k.message:"Failed to add starter";pe.error(w)}},e[2]=l,e[3]=s,e[4]=f,e[5]=_):_=e[5];const m=_;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=o.jsx(os,{asChild:!0,children:o.jsxs(oe,{variant:"outline",size:"sm",children:[o.jsx(cs,{size:14}),"Add Starter"]})}),e[6]=p):p=e[6];let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsxs(xh,{className:"gap-2.5",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),"Every..."]}),e[7]=g):g=e[7];let v;e[8]!==l||e[9]!==m?(v=Ip.map(I=>o.jsxs(wt,{className:"gap-2.5",onSelect:()=>m(I.cron),disabled:l.isPending,children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),"Every ",I.label]},I.cron)),e[8]=l,e[9]=m,e[10]=v):v=e[10];let b;e[11]!==v?(b=o.jsxs(bh,{children:[g,o.jsx(Sh,{className:"w-[160px]",children:v})]}),e[11]=v,e[12]=b):b=e[12];let S;e[13]!==f||e[14]!==n?(S=()=>{f(!1),n?.()},e[13]=f,e[14]=n,e[15]=S):S=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),e[16]=x):x=e[16];let y;e[17]!==S?(y=o.jsxs(wt,{className:"gap-2.5",onSelect:S,children:[x,"Custom (cron)"]}),e[17]=S,e[18]=y):y=e[18];let N;e[19]!==f||e[20]!==a?(N=()=>{f(!1),a?.()},e[19]=f,e[20]=a,e[21]=N):N=e[21];let C;e[22]===Symbol.for("react.memo_cache_sentinel")?(C=o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),e[22]=C):C=e[22];let R;e[23]!==N?(R=o.jsxs(wt,{className:"gap-2.5",onSelect:N,children:[C,"Event"]}),e[23]=N,e[24]=R):R=e[24];let E;e[25]!==R||e[26]!==b||e[27]!==y?(E=o.jsxs(as,{align:"end",className:"w-[200px]",children:[b,y,R]}),e[25]=R,e[26]=b,e[27]=y,e[28]=E):E=e[28];let A;return e[29]!==f||e[30]!==u||e[31]!==E?(A=o.jsxs(ns,{open:u,onOpenChange:f,children:[p,E]}),e[29]=f,e[30]=u,e[31]=E,e[32]=A):A=e[32],A}function Bp(t){const e=H.c(60),{trigger:s,automationId:i,connectionName:r}=t,{triggerAdd:n,triggerRemove:a}=Ks(),[l,h]=P.useState(!1);let c;e[0]!==s.cron_expression?(c=s.cron_expression?Dp(s.cron_expression):null,e[0]=s.cron_expression,e[1]=c):c=e[1];const u=c,[d,f]=P.useState(u?.count??1),[_,m]=P.useState(!1),[p,g]=P.useState(s.cron_expression??""),v=a.isPending||n.isPending,b=s.type==="cron";let S;e[2]!==i||e[3]!==a||e[4]!==s.id?(S=async()=>{try{await a.mutateAsync({trigger_id:s.id,automation_id:i}),pe.success("Starter removed")}catch{pe.error("Failed to remove starter")}h(!1)},e[2]=i,e[3]=a,e[4]=s.id,e[5]=S):S=e[5];const x=S;let y;e[6]!==n||e[7]!==i||e[8]!==p||e[9]!==a||e[10]!==s.cron_expression||e[11]!==s.id?(y=async()=>{const U=p.trim();if(!U||!As(U)||U===s.cron_expression){m(!1),g(s.cron_expression??"");return}try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:U}),await a.mutateAsync({trigger_id:s.id,automation_id:i}),m(!1)}catch{pe.error("Failed to update starter"),g(s.cron_expression??""),m(!1)}},e[6]=n,e[7]=i,e[8]=p,e[9]=a,e[10]=s.cron_expression,e[11]=s.id,e[12]=y):y=e[12];const N=y;let C;e[13]!==n||e[14]!==i||e[15]!==u||e[16]!==a||e[17]!==s.cron_expression||e[18]!==s.id?(C=async U=>{if(!u)return;const F=Math.max(1,U),Z=Rp(F,u.unit);if(Z!==s.cron_expression)try{await n.mutateAsync({automation_id:i,type:"cron",cron_expression:Z}),await a.mutateAsync({trigger_id:s.id,automation_id:i})}catch{pe.error("Failed to update starter"),f(u.count)}},e[13]=n,e[14]=i,e[15]=u,e[16]=a,e[17]=s.cron_expression,e[18]=s.id,e[19]=C):C=e[19];const R=C;let E;e[20]!==b?(E=b?o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}):o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),e[20]=b,e[21]=E):E=e[21];let A;e[22]!==r||e[23]!==d||e[24]!==p||e[25]!==R||e[26]!==N||e[27]!==u||e[28]!==b||e[29]!==_||e[30]!==v||e[31]!==s.cron_expression||e[32]!==s.event_type||e[33]!==s.params?(A=u&&b?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-sm text-muted-foreground",children:"Every"}),o.jsx("input",{type:"number",min:1,value:d,onChange:U=>f(parseInt(U.target.value)||1),onBlur:()=>R(d),onKeyDown:U=>{U.key==="Enter"&&U.target.blur(),U.key==="Escape"&&f(u.count)},disabled:v,className:"w-12 text-center text-sm h-7 border border-border rounded-md bg-background px-1 focus:outline-none focus:ring-1 focus:ring-ring"}),o.jsx("span",{className:"text-sm",children:Mp(u.unit,d)})]}):b&&_?o.jsxs(o.Fragment,{children:[o.jsx("input",{type:"text",value:p,onChange:U=>g(U.target.value),onBlur:N,onKeyDown:U=>{U.key==="Enter"&&U.target.blur(),U.key==="Escape"&&(m(!1),g(s.cron_expression??""))},className:"flex-1 text-sm font-mono bg-transparent outline-none",autoFocus:!0}),p&&!As(p)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"})]}):o.jsxs("div",{className:"flex flex-col gap-0.5 flex-1 min-w-0",children:[o.jsx("span",{className:"text-sm font-mono text-xs text-muted-foreground truncate",children:b?Tp(s.cron_expression??""):`${s.event_type}${r?` · ${r}`:""}`}),!b&&s.params&&Object.keys(s.params).length>0&&o.jsx("span",{className:"text-xs text-muted-foreground/60 truncate",children:Object.entries(s.params).map(Pp).join(", ")})]}),e[22]=r,e[23]=d,e[24]=p,e[25]=R,e[26]=N,e[27]=u,e[28]=b,e[29]=_,e[30]=v,e[31]=s.cron_expression,e[32]=s.event_type,e[33]=s.params,e[34]=A):A=e[34];let I;e[35]!==v?(I=v&&o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground"}),e[35]=v,e[36]=I):I=e[36];let D;e[37]!==u||e[38]!==b||e[39]!==_||e[40]!==s.cron_expression?(D=b&&!u&&!_&&o.jsx(oe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>{g(s.cron_expression??""),m(!0)},children:o.jsx(lh,{size:13,className:"text-muted-foreground"})}),e[37]=u,e[38]=b,e[39]=_,e[40]=s.cron_expression,e[41]=D):D=e[41];let k;e[42]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(oe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>h(!0),children:o.jsx(ls,{size:13,className:"text-muted-foreground"})}),e[42]=k):k=e[42];let w;e[43]!==I||e[44]!==D?(w=o.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[I,D,k]}),e[43]=I,e[44]=D,e[45]=w):w=e[45];let j;e[46]!==w||e[47]!==E||e[48]!==A?(j=o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[E,A,w]}),e[46]=w,e[47]=E,e[48]=A,e[49]=j):j=e[49];let T;e[50]===Symbol.for("react.memo_cache_sentinel")?(T=o.jsxs(_a,{children:[o.jsx(pa,{children:"Remove Starter"}),o.jsx(ga,{children:"Are you sure you want to remove this starter?"})]}),e[50]=T):T=e[50];let M;e[51]===Symbol.for("react.memo_cache_sentinel")?(M=o.jsx(xa,{children:"Cancel"}),e[51]=M):M=e[51];let B;e[52]!==x?(B=o.jsxs(ma,{children:[T,o.jsxs(va,{children:[M,o.jsx(ba,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),e[52]=x,e[53]=B):B=e[53];let O;e[54]!==l||e[55]!==B?(O=o.jsx(fa,{open:l,onOpenChange:h,children:B}),e[54]=l,e[55]=B,e[56]=O):O=e[56];let q;return e[57]!==j||e[58]!==O?(q=o.jsxs(o.Fragment,{children:[j,O]}),e[57]=j,e[58]=O,e[59]=q):q=e[59],q}function Pp(t){const[e,s]=t;return`${e}: ${s}`}function Lp(t){const e=H.c(55),{automationId:s,onDone:i}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={binding:"TRIGGER"},e[0]=r):r=e[0];const n=Ti(r),[a,l]=P.useState(),[h,c]=P.useState();let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u={},e[1]=u):u=e[1];const[d,f]=P.useState(u),{triggerAdd:_}=Ks(),{data:m,isLoading:p}=Ch(a);let g,v,b,S,x,y;if(e[2]!==_||e[3]!==s||e[4]!==a||e[5]!==h||e[6]!==p||e[7]!==i||e[8]!==d||e[9]!==n||e[10]!==m){const R=m?.find(B=>B.type===h);let E;e[17]!==_||e[18]!==s||e[19]!==a||e[20]!==h||e[21]!==i||e[22]!==d?(E=async()=>{if(!(!a||!h))try{await _.mutateAsync({automation_id:s,type:"event",event_type:h,connection_id:a,params:d}),ye("automation_trigger_added",{automation_id:s,trigger_type:"event",connection_id:a,event_type:h}),pe.success("Event trigger added"),i()}catch{pe.error("Failed to add event trigger")}},e[17]=_,e[18]=s,e[19]=a,e[20]=h,e[21]=i,e[22]=d,e[23]=E):E=e[23],g=E,v="flex flex-col gap-3 px-3 py-3 rounded-lg border border-border bg-background";let A,I;e[24]===Symbol.for("react.memo_cache_sentinel")?(I=o.jsx(Os,{size:14,className:"text-muted-foreground shrink-0"}),A=o.jsx("span",{className:"text-sm font-medium",children:"Event trigger"}),e[24]=A,e[25]=I):(A=e[24],I=e[25]);let D;e[26]===Symbol.for("react.memo_cache_sentinel")?(D=o.jsx(ls,{size:13}),e[26]=D):D=e[26],e[27]!==i?(b=o.jsxs("div",{className:"flex items-center gap-2",children:[I,A,o.jsx("button",{type:"button",className:"ml-auto shrink-0 p-0.5 rounded text-muted-foreground hover:text-foreground",onClick:i,children:D})]}),e[27]=i,e[28]=b):b=e[28];const k=a??"";let w;e[29]===Symbol.for("react.memo_cache_sentinel")?(w=B=>{l(B),c(void 0),f({})},e[29]=w):w=e[29];let j;e[30]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(ss,{className:"w-full",children:o.jsx(is,{placeholder:"Select connection..."})}),e[30]=j):j=e[30];let T;e[31]!==n?(T=n.length===0?o.jsx("div",{className:"px-2 py-3 text-center text-xs text-muted-foreground",children:"No connections with trigger support"}):n.map($p),e[31]=n,e[32]=T):T=e[32];let M;e[33]!==T?(M=o.jsx(rs,{children:T}),e[33]=T,e[34]=M):M=e[34],e[35]!==k||e[36]!==M?(S=o.jsxs(ts,{value:k,onValueChange:w,children:[j,M]}),e[35]=k,e[36]=M,e[37]=S):S=e[37],e[38]!==a||e[39]!==h||e[40]!==p||e[41]!==m?(x=a&&o.jsxs(ts,{value:h??"",onValueChange:B=>{c(B),f({})},children:[o.jsx(ss,{className:"w-full",children:p?o.jsxs("span",{className:"flex items-center gap-2 text-muted-foreground",children:[o.jsx(Ie,{size:13,className:"animate-spin"}),"Loading events..."]}):o.jsx(is,{placeholder:"Select event type...",children:h??"Select event type..."})}),o.jsx(rs,{children:m?.map(zp)})]}),e[38]=a,e[39]=h,e[40]=p,e[41]=m,e[42]=x):x=e[42],y=R?.paramsSchema&&Object.keys(R.paramsSchema).length>0&&o.jsx("div",{className:"flex flex-col gap-2",children:Object.entries(R.paramsSchema).map(B=>{const[O,q]=B;return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsxs("label",{className:"text-xs text-muted-foreground",children:[O,q.description&&o.jsxs("span",{className:"text-muted-foreground/60",children:[" ","— ",q.description]})]}),q.enum?o.jsxs(ts,{value:d[O]??"",onValueChange:U=>f(F=>({...F,[O]:U})),children:[o.jsx(ss,{className:"w-full",children:o.jsx(is,{placeholder:`Select ${O}...`})}),o.jsx(rs,{children:q.enum.map(Op)})]}):o.jsx("input",{type:"text",value:d[O]??"",onChange:U=>f(F=>({...F,[O]:U.target.value})),placeholder:q.description??O,className:"text-sm border border-border rounded-md bg-background px-2 py-1.5 focus:outline-none focus:ring-1 focus:ring-ring"})]},O)})}),e[2]=_,e[3]=s,e[4]=a,e[5]=h,e[6]=p,e[7]=i,e[8]=d,e[9]=n,e[10]=m,e[11]=g,e[12]=v,e[13]=b,e[14]=S,e[15]=x,e[16]=y}else g=e[11],v=e[12],b=e[13],S=e[14],x=e[15],y=e[16];let N;e[43]!==_||e[44]!==a||e[45]!==h||e[46]!==g?(N=a&&h&&o.jsx(oe,{size:"sm",onClick:g,disabled:_.isPending,children:_.isPending?o.jsx(Ie,{size:13,className:"animate-spin"}):"Add trigger"}),e[43]=_,e[44]=a,e[45]=h,e[46]=g,e[47]=N):N=e[47];let C;return e[48]!==v||e[49]!==b||e[50]!==S||e[51]!==x||e[52]!==y||e[53]!==N?(C=o.jsxs("div",{className:v,children:[b,S,x,y,N]}),e[48]=v,e[49]=b,e[50]=S,e[51]=x,e[52]=y,e[53]=N,e[54]=C):C=e[54],C}function Op(t){return o.jsx(At,{value:t,children:t},t)}function zp(t){return o.jsx(At,{value:t.type,children:o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{children:t.type}),o.jsx("span",{className:"text-xs text-muted-foreground",children:t.description})]})},t.type)}function $p(t){return o.jsx(At,{value:t.id,children:t.title},t.id)}function Fp({automationId:t,automation:e,onBack:s,onDelete:i}){const r=e.virtual_mcp_id,{org:n}=ve(),{update:a,triggerAdd:l}=Ks(),h=Ti(),c=new Map(h.map(ee=>[ee.id,ee.title])),{createTaskWithMessage:u}=vt(),{setModel:d,credentialId:f,selectedModel:_}=Zr(),{setChatOpen:m}=Ei(),{sendMessage:p}=fs(),g=ca(),[v,b]=$l(),S=e.messages?.[0]?.metadata?.tiptapDoc??void 0,[x,y]=P.useState(S),[N,C]=P.useState(!1),[R,E]=P.useState(!1),[A,I]=P.useState(""),[D,k]=P.useState(!1),[w,j]=P.useState(!1),T=P.useRef(!1),M=P.useRef(!1),B=P.useRef(S),O=async()=>{if(w)return;const Ne=bn(x).filter(Y=>Y.type==="text").map(Y=>Y.text).join(`
|
|
182
|
-
`);if(Ne.trim()){j(!0);try{le(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Ne.length}),await g(["studio-automation-manager"]),m(!0),await p({tiptapDoc:Ma({managerAgentId:Jo.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Ne})})}finally{j(!1)}}},q=e.models?.credentialId||f||"",U=e.models?.thinking?.id||_?.modelId||"",F=Ko({defaultValues:{name:e.name,active:e.active,credential_id:q,model_id:U}}),Z=F.watch("active"),J=F.watch("credential_id"),V=F.watch("model_id"),{models:$,isLoading:W}=Dc(J||void 0),Q=$.find(ee=>ee.modelId===V)??null,L=P.useRef(null),se=P.useRef(new Set),ie=P.useRef(0),te=P.useRef(null),G=3e4,le=()=>{te.current&&(clearTimeout(te.current),te.current=null),L.current!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(se.current),save_count:ie.current,edit_duration_ms:Date.now()-L.current}),L.current=null,se.current=new Set,ie.current=0)},ue=P.useRef(new Set),de=ee=>{ue.current.add(ee)},fe=async()=>{const ee=Array.from(ue.current);if(!(ee.length>0)&&!M.current)return!0;const Y=M.current;M.current=!1,ue.current=new Set;const ne=F.getValues(),Re=B.current;try{const Je=ne.credential_id&&ne.model_id?ne.credential_id:"",jt=ne.credential_id&&ne.model_id?ne.model_id:"",Rl={id:t,name:ne.name,active:ne.active,models:{credentialId:Je,thinking:{id:jt}},messages:Jl(Re),temperature:0};await a.mutateAsync(Rl),L.current===null&&(L.current=Date.now());for(const Dl of ee)se.current.add(Dl);return Y&&se.current.add("messages"),ie.current+=1,te.current&&clearTimeout(te.current),te.current=setTimeout(le,G),Je!==ne.credential_id&&F.setValue("credential_id",Je),jt!==ne.model_id&&F.setValue("model_id",jt),!0}catch{M.current=!0;for(const Je of ee)ue.current.add(Je);return!1}},{schedule:_e,flush:Ue}=Ca({save:fe}),$e=ee=>{ee&&de(ee),_e()},Qe=ee=>{if(B.current=ee,y(ee),!T.current){T.current=!0;return}M.current=!0,_e()},at=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const ee=await Ue();if(le(),!ee)return;if(!x){pe.error("No instructions configured for this automation");return}Q&&J&&d({...Q,keyId:J}),b({...v,toolApprovalLevel:"auto"});const Ne=bn(x);u({message:{tiptapDoc:x,parts:Ne},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(oe,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(ja,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx($t,{control:F.control,name:"name",render:({field:ee})=>o.jsx(_s,{...ee,onChange:Ne=>{ee.onChange(Ne),$e("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(ur,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx($t,{control:F.control,name:"active",render:({field:ee})=>o.jsx(dr,{checked:ee.value,onCheckedChange:Ne=>{ee.onChange(Ne),de("active"),setTimeout(()=>Ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Z?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ha,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Ap,{automationId:t,open:N,onOpenChange:C,onCustomSelect:()=>{E(!0),k(!1),I("")},onEventSelect:()=>{k(!0),E(!1)}})]}),e.triggers.length===0&&!R?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ee=>o.jsx(Bp,{trigger:ee,automationId:t,connectionName:ee.connection_id?c.get(ee.connection_id):void 0},ee.id))}),R&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:A,onChange:ee=>I(ee.target.value),onBlur:async()=>{const ee=A.trim();if(!(!ee||!As(ee)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:ee}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),E(!1),I("")}catch{pe.error("Failed to add starter")}},onKeyDown:async ee=>{const Ne=A.trim();ee.key==="Enter"&&Ne&&As(Ne)&&ee.target.blur(),ee.key==="Escape"&&(E(!1),I(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),A&&!As(A)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{E(!1),I("")},children:o.jsx(ls,{size:13})})]}),D&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Lp,{automationId:t,onDone:()=>k(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!x,onClick:O,children:[o.jsx(wa,{size:13}),"Improve"]})]}),o.jsx(ql,{tiptapDoc:x,setTiptapDoc:Qe,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Gl,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(wh,{model:Q,isLoading:W,credentialId:J||null,onCredentialChange:ee=>{F.setValue("credential_id",ee??""),F.setValue("model_id",""),de("credential_id"),de("model_id"),_e()},onModelChange:ee=>{F.setValue("model_id",ee.modelId),$e("model_id")},placeholder:"Model"}),o.jsxs(Ke,{children:[o.jsx(qe,{asChild:!0,children:o.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:at,disabled:!r,children:[o.jsx(rc,{size:16}),"Test"]})}),o.jsx(Ge,{children:"Test Automation"})]})]})]})})]})]})]})}function Hp(t){const e=H.c(5),{tabId:s}=t;let i;e[0]!==s?(i=Qo(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ct,{children:o.jsx(ct.Content,{children:o.jsx(ct.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Wp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Wp(t){const e=H.c(8),{id:s}=t,i=Bt(),{data:r,isLoading:n}=kh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Up,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Fp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Up(t){return{...t,main:"automations"}}function Vp(t){const e=H.c(20),{virtualMcpId:s}=t,i=Bt(),{data:r}=Nh(s),n=r===void 0?[]:r,{create:a}=Ks(),[l,h]=P.useState(""),c=l.toLowerCase(),u=n.filter(A=>A.name.toLowerCase().includes(c));let d;e[0]!==i?(d=A=>i({to:".",search:I=>({...I,main:"automation:"+A}),replace:!0}),e[0]=i,e[1]=d):d=e[1];const f=d,_=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const A=await a.mutateAsync(Eh(s));f(A.id)},m=ct,p=ct,g=ct;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ct.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(Th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let y;e[7]!==b||e[8]!==x?(y=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=y):y=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):u.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(A=>o.jsx(jh,{automation:A,onClick:()=>f(A.id)},A.id))});let C;e[10]!==N||e[11]!==g.Body||e[12]!==y?(C=o.jsxs(g.Body,{children:[y,N]}),e[10]=N,e[11]=g.Body,e[12]=y,e[13]=C):C=e[13];let R;e[14]!==C||e[15]!==p.Content?(R=o.jsx(p.Content,{children:C}),e[14]=C,e[15]=p.Content,e[16]=R):R=e[16];let E;return e[17]!==m||e[18]!==R?(E=o.jsx(m,{children:R}),e[17]=m,e[18]=R,e[19]=E):E=e[19],E}function Kp(t){const e=H.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(Vp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Oo=P.lazy(()=>Fl(()=>import("./project-app-view-CqGwq86p.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function qp(t){const e=H.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Da(r);if(hc(n)){let m;return e[3]!==i?(m=o.jsx($n,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Eu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(Kp,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Ep,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(df,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Hp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=dc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Oo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Oo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx($n,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function Gp(t){const e=H.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Yo.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=Go(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function Yp(t){const e=H.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Tn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=Yo.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=Go(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const A=d.current;if(!A)return;const I=Tn(r,n),D=I.chat>0&&I.chat<100?u:I.chat,k=I.chat>0&&I.chat<100?100-u:I.main;A.setLayout([D,k])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ea,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(Gp,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Yc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[18]=y):y=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=N):N=e[19];let C;e[20]!==i||e[21]!==s?(C=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ht,{children:o.jsx(qp,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=C):C=e[22];let R;e[23]!==h.main||e[24]!==C?(R=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[23]=h.main,e[24]=C,e[25]=R):R=e[25];let E;return e[26]!==R||e[27]!==m||e[28]!==b?(E=o.jsxs(Xc,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,R]},m),e[26]=R,e[27]=m,e[28]=b,e[29]=E):E=e[29],E}const ar="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",zo="bg-sidebar-accent text-sidebar-foreground",lr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Xp(t){const e=H.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Mc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?zo:lr;let u;e[3]!==c?(u=re(ar,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(jc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ge,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ke,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?zo:lr;let v;e[16]!==g?(v=re(ar,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ec,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ge,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let y;e[24]!==S?(y=o.jsxs(Ke,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=y):y=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==N?(C=re("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=C):C=e[27];const R=!l,E=l?0:-1,A=!l,I=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let D;e[28]!==I?(D=re(ar,lr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",I),e[28]=I,e[29]=D):D=e[29];let k;e[30]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(sa,{size:16}),e[30]=k):k=e[30];let w;e[31]!==r||e[32]!==R||e[33]!==E||e[34]!==A||e[35]!==D?(w=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:R,tabIndex:E,"aria-hidden":A,className:D,children:k})}),e[31]=r,e[32]=R,e[33]=E,e[34]=A,e[35]=D,e[36]=w):w=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(Ge,{side:"bottom",children:"New task"}),e[37]=j):j=e[37];let T;e[38]!==w?(T=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ke,{delayDuration:300,children:[w,j]})}),e[38]=w,e[39]=T):T=e[39];let M;e[40]!==C||e[41]!==T?(M=o.jsx("div",{className:C,children:T}),e[40]=C,e[41]=T,e[42]=M):M=e[42];let B;return e[43]!==y||e[44]!==M||e[45]!==m?(B=o.jsxs(o.Fragment,{children:[m,y,M]}),e[43]=y,e[44]=M,e[45]=m,e[46]=B):B=e[46],B}function Jp(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function Zp(t){const e=H.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Qp,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function Qp(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function eg(t){const e=H.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Ws,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(tg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Us,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Vs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function tg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const sg=6;function ig(t){const e=H.c(20),{virtualMcpId:s,taskId:i}=t,r=Bt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Da(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=uc({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:y}=Jp(a,S,sg);d=y,u=N=>{const C=a.find(E=>E.id===N),R=S===N&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:C?.kind??null,was_active:R}),N==="automations"){const E=fc({activeTab:l,mainOpen:h});r({to:".",search:A=>({...A,main:E}),replace:!0});return}c(N)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(Zp,{title:N.title,icon:N.icon,active:v(N),onClick:()=>u(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(eg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function rg(t){const e=H.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=re("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Hl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function ng(t){const e=H.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(gu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(pu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(oe,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(fr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(os,{asChild:!0,children:o.jsx(oe,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(as,{align:"end",children:o.jsx(wt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ns,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const og=new Set(["failure","timed_out","cancelled","action_required"]);function ag(t){return t.status==="completed"&&og.has(t.conclusion)}function lg(t){return t.status==="queued"||t.status==="in_progress"}function cg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(ag).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(lg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function hg(){return Gt().branchStatus}const dg=6e4,ug=3e4;function fg(t){const e=H.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=He(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:dg,refetchIntervalInBackground:!1,staleTime:ug,select:mg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ms(l)}function mg(t){const e=qs(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function _g(t){const e=H.c(42),{virtualMcpId:s}=t,{org:i}=ve(),r=Ct(s),{currentBranch:n}=vt(),a=fs(),l=r?.metadata?.githubRepo??null,h=hg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=Aa(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const y=Pa(x),N=l?.connectionId??"",C=l?.owner??"",R=l?.name??"",E=p&&p.state==="open"?p.number:null;let A;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==C||e[18]!==R||e[19]!==E?(A={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:C,repo:R,prNumber:E},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=C,e[18]=R,e[19]=E,e[20]=A):A=e[20];const I=fg(A);if(!l?.connectionId||!n)return null;let D;e[21]!==h||e[22]!==y.data||e[23]!==p||e[24]!==m.isPending||e[25]!==I.data?(D=cg({branchStatus:h,pr:p,checks:y.data??[],reviews:I.data??null,loading:m.isPending}),e[21]=h,e[22]=y.data,e[23]=p,e[24]=m.isPending,e[25]=I.data,e[26]=D):D=e[26];const k=D;let w;e[27]!==a?(w=F=>a.sendMessage({parts:[{type:"text",text:F}]}),e[27]=a,e[28]=w):w=e[28];const j=w,T=a.isStreaming;let M;e[29]!==n||e[30]!==k||e[31]!==T||e[32]!==p||e[33]!==j?(M=F=>{if(!T)switch(F){case"commit-and-push":{j(lu({branch:n}));return}case"create-pr":{j(cu({branch:n}));return}case"reopen":{p&&j(hu({prNumber:p.number}));return}case"rebase":{j(du({branch:n}));return}case"fix-checks":{p&&j(fu({prNumber:p.number,failingChecks:k.meta?.failingChecks??[]}));return}case"mark-ready":{p&&j(mu({prNumber:p.number}));return}case"resolve-comments":{p&&j(_u({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=k,e[31]=T,e[32]=p,e[33]=j,e[34]=M):M=e[34];const B=M;let O;e[35]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(rg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=O):O=e[35];const q=p?.number;let U;return e[36]!==k||e[37]!==T||e[38]!==B||e[39]!==j||e[40]!==q?(U=o.jsxs(o.Fragment,{children:[O,o.jsx(pg,{button:k,isStreaming:T,onActivate:B,prNumber:q,send:j})]}),e[36]=k,e[37]=T,e[38]=B,e[39]=j,e[40]=q,e[41]=U):U=e[41],U}function pg(t){const e=H.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(ng,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx($o,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(vh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(oe,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx($o,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function $o(t){const e=H.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(qe,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Ge,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Wc,{children:o.jsxs(Ke,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function gg(t){const e=H.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(hr.Right,{children:o.jsx(_g,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Qt=P.createContext(null);function vn(){return P.use(Qt)}function Fo(t){const e=H.c(7),{children:s}=t,{taskId:i}=vt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ea,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ht,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Ho(t){const e=H.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function vg(t){const e=H.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Ql,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Wo(t){const e=H.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ve(),{currentBranch:l}=vt(),{data:h}=Ci.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Pt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=He(u),{mutate:f}=nn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:xg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Wu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function xg(t){console.error("[auto-start-vm] failed:",t)}function bg(){const t=H.c(96),e=aa(),s=Bt(),{org:i}=ve(),r=Ic()?.tasksOpen??!1;Uc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Wl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Jr(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??Xo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Mh(a.taskId??"",d),_=Ct(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Kt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=Ac(g,S),{setOpenMobile:y,openMobile:N}=zc(),C=y,R=P.useRef(null);let E,A;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const V=$=>{Lc($)&&$.shiftKey&&$.code==="KeyS"&&!$.repeat&&($.preventDefault(),R.current?.())};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},A=[],t[12]=E,t[13]=A):(E=t[12],A=t[13]),P.useEffect(E,A);const I=d;let D;t[14]!==_||t[15]!==d?(D={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=D):D=t[16];const k=D;if(f.status==="creating"||f.status==="loading"){let V;t[17]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Ie,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=V):V=t[17];let $;return t[18]!==k?($=o.jsx(Qt,{value:k,children:V}),t[18]=k,t[19]=$):$=t[19],$}if(f.status==="error"){let V;t[20]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=V):V=t[20];let $;t[21]!==f.error.message?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[V,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=$):$=t[22];let W;return t[23]!==k||t[24]!==$?(W=o.jsx(Qt,{value:k,children:$}),t[23]=k,t[24]=$,t[25]=W):W=t[25],W}if(!_){let V;t[26]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx(Ps,{size:48,className:"text-muted-foreground"}),t[26]=V):V=t[26];const $=`The agent "${d}" does not exist in this organization.`;let W;t[27]!==s||t[28]!==l?(W=o.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=W):W=t[29];let Q;t[30]!==$||t[31]!==W?(Q=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Ls,{image:V,title:"Agent not found",description:$,actions:W})})}),t[30]=$,t[31]=W,t[32]=Q):Q=t[32];let L;return t[33]!==k||t[34]!==Q?(L=o.jsx(Qt,{value:k,children:Q}),t[33]=k,t[34]=Q,t[35]=L):L=t[35],L}if(e){let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx($c,{className:"sr-only",children:"Navigation"}),t[36]=V):V=t[36];let $;t[37]!==C?($=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Bc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=$):$=t[38];let W;t[39]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Pc,{})}),t[39]=W):W=t[39];let Q;t[40]!==$?(Q=o.jsxs(Fc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[V,o.jsxs("div",{className:"flex h-full",children:[$,W]})]}),t[40]=$,t[41]=Q):Q=t[41];let L;t[42]!==N||t[43]!==C||t[44]!==Q?(L=o.jsx(Hc,{open:N,onOpenChange:C,children:Q}),t[42]=N,t[43]=C,t[44]=Q,t[45]=L):L=t[45];const se=L,ie=_?.metadata?.vmMap;let te;t[46]!==x.createNewTask?(te=o.jsx(Ho,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=te):te=t[47];let G;t[48]!==C?(G=o.jsx(vg,{onOpenSidebar:()=>C(!0)}),t[48]=C,t[49]=G):G=t[49];let le;t[50]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Fo,{})}),t[50]=le):le=t[50];let ue;t[51]!==b||t[52]!==se||t[53]!==ie||t[54]!==te||t[55]!==G||t[56]!==d?(ue=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:ie,children:[te,G,le,se]}),t[51]=b,t[52]=se,t[53]=ie,t[54]=te,t[55]=G,t[56]=d,t[57]=ue):ue=t[57];let de;t[58]!==I||t[59]!==ue?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:I,children:ue},I)}),t[58]=I,t[59]=ue,t[60]=de):de=t[60];let fe;return t[61]!==k||t[62]!==de?(fe=o.jsx(Qt,{value:k,children:de}),t[61]=k,t[62]=de,t[63]=fe):fe=t[63],fe}const w=r?void 0:x.createNewTask;let j;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==w?(j=o.jsx(hr.Toggles,{children:o.jsx(Xp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:w})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=w,t[67]=j):j=t[67];let T;t[68]!==x.taskId||t[69]!==d?(T=o.jsx(hr.Tabs,{children:o.jsx(ig,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=T):T=t[70];const M=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(gg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Ho,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let q;t[75]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(Fo,{}),t[75]=q):q=t[75];let U;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(U=o.jsx(Yp,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:q}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=U):U=t[80];let F;t[81]!==b||t[82]!==M||t[83]!==B||t[84]!==O||t[85]!==U||t[86]!==d?(F=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:M,children:[B,O,U]}),t[81]=b,t[82]=M,t[83]=B,t[84]=O,t[85]=U,t[86]=d,t[87]=F):F=t[87];let Z;t[88]!==I||t[89]!==T||t[90]!==F?(Z=o.jsxs(je.Provider,{virtualMcpId:I,children:[T,F]},I),t[88]=I,t[89]=T,t[90]=F,t[91]=Z):Z=t[91];let J;return t[92]!==k||t[93]!==j||t[94]!==Z?(J=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Qt,{value:k,children:[j,Z]})}),t[92]=k,t[93]=j,t[94]=Z,t[95]=J):J=t[95],J}function E1(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(bg,{})}),t[0]=e):e=t[0],e}export{E1 as default,vn as useInsetContext};
|
|
182
|
+
`);if(Ne.trim()){j(!0);try{le(),ye("automation_improve_clicked",{automation_id:t,agent_id:r,instructions_length:Ne.length}),await g(["studio-automation-manager"]),m(!0),await p({tiptapDoc:Ma({managerAgentId:Jo.AUTOMATION_MANAGER(n.id),managerName:"Automation Manager",kind:"automation",id:t,instructions:Ne})})}finally{j(!1)}}},q=e.models?.credentialId||f||"",U=e.models?.thinking?.id||_?.modelId||"",F=Ko({defaultValues:{name:e.name,active:e.active,credential_id:q,model_id:U}}),Z=F.watch("active"),J=F.watch("credential_id"),V=F.watch("model_id"),{models:$,isLoading:W}=Dc(J||void 0),Q=$.find(ee=>ee.modelId===V)??null,L=P.useRef(null),se=P.useRef(new Set),ie=P.useRef(0),te=P.useRef(null),G=3e4,le=()=>{te.current&&(clearTimeout(te.current),te.current=null),L.current!==null&&(ye("automation_updated",{automation_id:t,agent_id:r,fields:Array.from(se.current),save_count:ie.current,edit_duration_ms:Date.now()-L.current}),L.current=null,se.current=new Set,ie.current=0)},ue=P.useRef(new Set),de=ee=>{ue.current.add(ee)},fe=async()=>{const ee=Array.from(ue.current);if(!(ee.length>0)&&!M.current)return!0;const Y=M.current;M.current=!1,ue.current=new Set;const ne=F.getValues(),Re=B.current;try{const Je=ne.credential_id&&ne.model_id?ne.credential_id:"",jt=ne.credential_id&&ne.model_id?ne.model_id:"",Rl={id:t,name:ne.name,active:ne.active,models:{credentialId:Je,thinking:{id:jt}},messages:Jl(Re),temperature:0};await a.mutateAsync(Rl),L.current===null&&(L.current=Date.now());for(const Dl of ee)se.current.add(Dl);return Y&&se.current.add("messages"),ie.current+=1,te.current&&clearTimeout(te.current),te.current=setTimeout(le,G),Je!==ne.credential_id&&F.setValue("credential_id",Je),jt!==ne.model_id&&F.setValue("model_id",jt),!0}catch{M.current=!0;for(const Je of ee)ue.current.add(Je);return!1}},{schedule:_e,flush:Ue}=Ca({save:fe}),$e=ee=>{ee&&de(ee),_e()},Qe=ee=>{if(B.current=ee,y(ee),!T.current){T.current=!0;return}M.current=!0,_e()},at=async()=>{ye("automation_test_clicked",{automation_id:t,agent_id:r});const ee=await Ue();if(le(),!ee)return;if(!x){pe.error("No instructions configured for this automation");return}Q&&J&&d({...Q,keyId:J}),b({...v,toolApprovalLevel:"auto"});const Ne=bn(x);u({message:{tiptapDoc:x,parts:Ne},virtualMcpId:r||void 0})};return o.jsxs(o.Fragment,{children:[s&&o.jsx("div",{className:"flex items-center pb-4 shrink-0",children:o.jsxs(oe,{variant:"ghost",size:"sm",onClick:s,children:[o.jsx(ja,{size:14}),"Back to list"]})}),o.jsxs("div",{className:"flex flex-col gap-8",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-4",children:[o.jsx($t,{control:F.control,name:"name",render:({field:ee})=>o.jsx(_s,{...ee,onChange:Ne=>{ee.onChange(Ne),$e("name")},placeholder:"Automation name",className:"border border-transparent shadow-none px-0 text-lg font-medium h-auto focus-visible:ring-0 focus-visible:border-border bg-transparent flex-1",style:{boxShadow:"none"}})}),i&&o.jsx(oe,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive shrink-0",onClick:i,children:o.jsx(ur,{size:14})})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx($t,{control:F.control,name:"active",render:({field:ee})=>o.jsx(dr,{checked:ee.value,onCheckedChange:Ne=>{ee.onChange(Ne),de("active"),setTimeout(()=>Ue(),0)},className:"cursor-pointer"})}),o.jsx("span",{className:"text-sm text-muted-foreground",children:Z?"Active":"Inactive"}),o.jsx("span",{className:"text-muted-foreground/50 text-sm",children:"·"}),o.jsx(ha,{id:e.created_by,size:"2xs",className:"text-sm text-muted-foreground"})]})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Starter"}),o.jsx(Ap,{automationId:t,open:N,onOpenChange:C,onCustomSelect:()=>{E(!0),k(!1),I("")},onEventSelect:()=>{k(!0),E(!1)}})]}),e.triggers.length===0&&!R?o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-6 text-center",children:o.jsxs("p",{className:"text-sm text-muted-foreground",children:["When should this automation run?"," ",o.jsx("button",{type:"button",className:"text-foreground underline underline-offset-2 cursor-pointer hover:text-foreground/80 transition-colors",onClick:()=>C(!0),children:"Add a starter"})," ","to get going."]})}):o.jsx("div",{className:"flex flex-col gap-2",children:e.triggers.map(ee=>o.jsx(Bp,{trigger:ee,automationId:t,connectionName:ee.connection_id?c.get(ee.connection_id):void 0},ee.id))}),R&&o.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-border bg-background group",children:[o.jsx(Ds,{size:14,className:"text-muted-foreground shrink-0"}),o.jsx("input",{type:"text",value:A,onChange:ee=>I(ee.target.value),onBlur:async()=>{const ee=A.trim();if(!(!ee||!As(ee)))try{await l.mutateAsync({automation_id:t,type:"cron",cron_expression:ee}),ye("automation_trigger_added",{automation_id:t,trigger_type:"cron"}),pe.success("Starter added"),E(!1),I("")}catch{pe.error("Failed to add starter")}},onKeyDown:async ee=>{const Ne=A.trim();ee.key==="Enter"&&Ne&&As(Ne)&&ee.target.blur(),ee.key==="Escape"&&(E(!1),I(""))},placeholder:"0 9 * * 1-5",className:"flex-1 text-sm font-mono bg-transparent outline-none placeholder:text-muted-foreground/40",autoFocus:!0}),A&&!As(A)&&o.jsx("span",{className:"text-xs text-muted-foreground/60 shrink-0",children:"invalid"}),l.isPending&&o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground shrink-0"}),o.jsx("button",{type:"button",className:"shrink-0 p-0.5 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-foreground transition-opacity",onClick:()=>{E(!1),I("")},children:o.jsx(ls,{size:13})})]}),D&&o.jsx(P.Suspense,{fallback:o.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 rounded-lg border border-border bg-background",children:[o.jsx(Ie,{size:13,className:"animate-spin text-muted-foreground"}),o.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading connections..."})]}),children:o.jsx(Lp,{automationId:t,onDone:()=>k(!1)})})]}),o.jsxs("div",{className:"flex flex-col gap-2.5",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsx("span",{className:"text-xs font-semibold text-muted-foreground/60",children:"Instructions"}),o.jsxs(oe,{variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:w||!x,onClick:O,children:[o.jsx(wa,{size:13}),"Improve"]})]}),o.jsx(ql,{tiptapDoc:x,setTiptapDoc:Qe,placeholder:"What should this automation do?",children:o.jsxs("div",{className:"rounded-xl border border-border min-h-[120px] flex flex-col",children:[o.jsx(Gl,{virtualMcpId:r||null,className:"max-h-[45vh]"}),o.jsxs("div",{className:"flex items-center justify-end gap-1.5 p-2.5",children:[o.jsx(wh,{model:Q,isLoading:W,credentialId:J||null,onCredentialChange:ee=>{F.setValue("credential_id",ee??""),F.setValue("model_id",""),de("credential_id"),de("model_id"),_e()},onModelChange:ee=>{F.setValue("model_id",ee.modelId),$e("model_id")},placeholder:"Model"}),o.jsxs(Ke,{children:[o.jsx(qe,{asChild:!0,children:o.jsxs(oe,{type:"button",variant:"default",className:"h-8 gap-1.5 rounded-md px-3 text-sm font-medium",onClick:at,disabled:!r,children:[o.jsx(rc,{size:16}),"Test"]})}),o.jsx(Ge,{children:"Test Automation"})]})]})]})})]})]})]})}function Hp(t){const e=H.c(5),{tabId:s}=t;let i;e[0]!==s?(i=Qo(s),e[0]=s,e[1]=i):i=e[1];const r=i;if(!r)return null;let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=n):n=e[2];let a;return e[3]!==r.id?(a=o.jsx(ct,{children:o.jsx(ct.Content,{children:o.jsx(ct.Body,{children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(Wp,{id:r.id})})})})}),e[3]=r.id,e[4]=a):a=e[4],a}function Wp(t){const e=H.c(8),{id:s}=t,i=Bt(),{data:r,isLoading:n}=kh(s);let a;e[0]!==i?(a=()=>i({to:".",search:Up,replace:!0}),e[0]=i,e[1]=a):a=e[1];const l=a;if(n){let c;return e[2]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[2]=c):c=e[2],c}if(!r){let c;return e[3]===Symbol.for("react.memo_cache_sentinel")?(c=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Automation not found"}),e[3]=c):c=e[3],c}let h;return e[4]!==r||e[5]!==s||e[6]!==l?(h=o.jsx(Fp,{automationId:s,automation:r,onBack:l}),e[4]=r,e[5]=s,e[6]=l,e[7]=h):h=e[7],h}function Up(t){return{...t,main:"automations"}}function Vp(t){const e=H.c(20),{virtualMcpId:s}=t,i=Bt(),{data:r}=Nh(s),n=r===void 0?[]:r,{create:a}=Ks(),[l,h]=P.useState(""),c=l.toLowerCase(),u=n.filter(A=>A.name.toLowerCase().includes(c));let d;e[0]!==i?(d=A=>i({to:".",search:I=>({...I,main:"automation:"+A}),replace:!0}),e[0]=i,e[1]=d):d=e[1];const f=d,_=async()=>{if(a.isPending)return;ye("automation_new_clicked",{virtual_mcp_id:s,existing_count:n.length});const A=await a.mutateAsync(Eh(s));f(A.id)},m=ct,p=ct,g=ct;let v;e[2]===Symbol.for("react.memo_cache_sentinel")?(v=o.jsx(ct.Title,{children:"Automations"}),e[2]=v):v=e[2];const b=n.length>0&&o.jsx(Th,{value:l,onChange:h,placeholder:"Search automations...",className:"w-full md:w-[375px]"});let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(cs,{size:14}),e[3]=S):S=e[3];let x;e[4]!==a.isPending||e[5]!==_?(x=o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[S,"New automation"]}),e[4]=a.isPending,e[5]=_,e[6]=x):x=e[6];let y;e[7]!==b||e[8]!==x?(y=o.jsxs("div",{className:"flex flex-col gap-6",children:[v,o.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[b,x]})]}),e[7]=b,e[8]=x,e[9]=y):y=e[9];const N=n.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations yet",description:"Create your first automation to run this agent on a schedule or in response to events.",actions:o.jsxs(oe,{size:"sm",onClick:_,disabled:a.isPending,children:[o.jsx(cs,{size:14}),"New automation"]})})}):u.length===0?o.jsx("div",{className:"flex items-center justify-center py-20",children:o.jsx(Ls,{image:o.jsx(Os,{size:48,className:"text-muted-foreground"}),title:"No automations found",description:`No automations match "${l}"`})}):o.jsx("div",{className:"mt-6 rounded-xl border border-border overflow-hidden",children:u.map(A=>o.jsx(jh,{automation:A,onClick:()=>f(A.id)},A.id))});let C;e[10]!==N||e[11]!==g.Body||e[12]!==y?(C=o.jsxs(g.Body,{children:[y,N]}),e[10]=N,e[11]=g.Body,e[12]=y,e[13]=C):C=e[13];let R;e[14]!==C||e[15]!==p.Content?(R=o.jsx(p.Content,{children:C}),e[14]=C,e[15]=p.Content,e[16]=R):R=e[16];let E;return e[17]!==m||e[18]!==R?(E=o.jsx(m,{children:R}),e[17]=m,e[18]=R,e[19]=E):E=e[19],E}function Kp(t){const e=H.c(3),{virtualMcpId:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx(P.Suspense,{fallback:i,children:o.jsx(Vp,{virtualMcpId:s})}),e[1]=s,e[2]=r):r=e[2],r}const Oo=P.lazy(()=>Fl(()=>import("./project-app-view-DrBetUBZ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56])).then(t=>({default:t.AppViewContent})));function qp(t){const e=H.c(43),{taskId:s,virtualMcpId:i}=t;let r;e[0]!==s||e[1]!==i?(r={virtualMcpId:i,taskId:s},e[0]=s,e[1]=i,e[2]=r):r=e[2];const{activeTab:n,layoutTabs:a,expandedTools:l,automationTabParsed:h}=Da(r);if(hc(n)){let m;return e[3]!==i?(m=o.jsx($n,{virtualMcpId:i}),e[3]=i,e[4]=m):m=e[4],m}if(n==="git"){let m;return e[5]!==i?(m=o.jsx(Eu,{virtualMcpId:i}),e[5]=i,e[6]=m):m=e[6],m}if(n==="automations"){let m;return e[7]!==i?(m=o.jsx(Kp,{virtualMcpId:i}),e[7]=i,e[8]=m):m=e[8],m}if(n==="env"){let m;return e[9]!==i?(m=o.jsx(Ep,{virtualMcpId:i}),e[9]=i,e[10]=m):m=e[10],m}if(n==="preview"){let m;return e[11]!==i?(m=o.jsx(df,{virtualMcpId:i}),e[11]=i,e[12]=m):m=e[12],m}if(h){let m;return e[13]!==n?(m=o.jsx(Hp,{tabId:n}),e[13]=n,e[14]=m):m=e[14],m}let c;e[15]!==n?(c=dc(n),e[15]=n,e[16]=c):c=e[16];const u=c;if(u){let m;if(e[17]!==l||e[18]!==u.connectionId||e[19]!==u.toolName){let S;e[21]!==u.connectionId||e[22]!==u.toolName?(S=x=>x.appId===u.connectionId&&x.toolName===u.toolName,e[21]=u.connectionId,e[22]=u.toolName,e[23]=S):S=e[23],m=l.find(S),e[17]=l,e[18]=u.connectionId,e[19]=u.toolName,e[20]=m}else m=e[20];const p=m;let g;e[24]===Symbol.for("react.memo_cache_sentinel")?(g=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[24]=g):g=e[24];const v=p?.args;let b;return e[25]!==n||e[26]!==u.connectionId||e[27]!==u.toolName||e[28]!==v?(b=o.jsx(P.Suspense,{fallback:g,children:o.jsx(Oo,{connectionId:u.connectionId,toolName:u.toolName,args:v},n)}),e[25]=n,e[26]=u.connectionId,e[27]=u.toolName,e[28]=v,e[29]=b):b=e[29],b}let d;if(e[30]!==n||e[31]!==a){let m;e[33]!==n?(m=p=>p.id===n,e[33]=n,e[34]=m):m=e[34],d=a.find(m),e[30]=n,e[31]=a,e[32]=d}else d=e[32];const f=d;if(f){let m;e[35]===Symbol.for("react.memo_cache_sentinel")?(m=o.jsx("div",{className:"h-full w-full flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),e[35]=m):m=e[35];let p;return e[36]!==n||e[37]!==f.id||e[38]!==f.view.appId||e[39]!==f.view.args?(p=o.jsx(P.Suspense,{fallback:m,children:o.jsx(Oo,{connectionId:f.view.appId,toolName:f.id,args:f.view.args},n)}),e[36]=n,e[37]=f.id,e[38]=f.view.appId,e[39]=f.view.args,e[40]=p):p=e[40],p}let _;return e[41]!==i?(_=o.jsx($n,{virtualMcpId:i}),e[41]=i,e[42]=_):_=e[42],_}function Gp(t){const e=H.c(7),{children:s,defaultSize:i}=t,[,r]=P.useTransition();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=Yo.decoChatPanelWidth(),e[0]=n):n=e[0];const[a,l]=Go(n,45),h=i>0&&i<100?a:i;let c;e[1]!==l?(c=f=>r(()=>{f>0&&f<100&&l(f)}),e[1]=l,e[2]=c):c=e[2];const u=c;let d;return e[3]!==s||e[4]!==h||e[5]!==u?(d=o.jsx(la,{defaultSize:h,minSize:20,collapsible:!0,collapsedSize:0,className:"min-w-0 overflow-hidden bg-sidebar",onResize:u,order:1,children:s}),e[3]=s,e[4]=h,e[5]=u,e[6]=d):d=e[6],d}function Yp(t){const e=H.c(30),{virtualMcpId:s,taskId:i,chatOpen:r,mainOpen:n,chatContent:a}=t;let l;e[0]!==r||e[1]!==n?(l=Tn(r,n),e[0]=r,e[1]=n,e[2]=l):l=e[2];const h=l;let c;e[3]===Symbol.for("react.memo_cache_sentinel")?(c=Yo.decoChatPanelWidth(),e[3]=c):c=e[3];const[u]=Go(c,45),d=P.useRef(null);let f,_;e[4]!==r||e[5]!==n||e[6]!==u?(f=()=>{const A=d.current;if(!A)return;const I=Tn(r,n),D=I.chat>0&&I.chat<100?u:I.chat,k=I.chat>0&&I.chat<100?100-u:I.main;A.setLayout([D,k])},_=[r,n,u],e[4]=r,e[5]=n,e[6]=u,e[7]=f,e[8]=_):(f=e[7],_=e[8]),P.useEffect(f,_);const m=`${s}-${i}`;let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p={overflow:"visible"},e[9]=p):p=e[9];let g;e[10]!==a?(g=a??o.jsx(Ea,{}),e[10]=a,e[11]=g):g=e[11];let v;e[12]!==g?(v=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:"h-full bg-background rounded-[0.75rem] overflow-hidden card-shadow",children:g})}),e[12]=g,e[13]=v):v=e[13];let b;e[14]!==h.chat||e[15]!==v?(b=o.jsx(Gp,{defaultSize:h.chat,children:v}),e[14]=h.chat,e[15]=v,e[16]=b):b=e[16];let S;e[17]===Symbol.for("react.memo_cache_sentinel")?(S=o.jsx(Yc,{className:"bg-sidebar"}),e[17]=S):S=e[17];const x=h.main;let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y={overflow:"visible"},e[18]=y):y=e[18];let N;e[19]===Symbol.for("react.memo_cache_sentinel")?(N=re("flex flex-col h-full min-h-0 bg-background overflow-hidden","card-shadow","transition-[border-radius] duration-200 ease-[var(--ease-out-quart)]","rounded-[0.75rem]"),e[19]=N):N=e[19];let C;e[20]!==i||e[21]!==s?(C=o.jsx("div",{className:"h-full p-0.5 pt-0.25",children:o.jsx("div",{className:N,children:o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Ht,{children:o.jsx(qp,{taskId:i,virtualMcpId:s})})})})}),e[20]=i,e[21]=s,e[22]=C):C=e[22];let R;e[23]!==h.main||e[24]!==C?(R=o.jsx(la,{className:"min-w-0 flex flex-col",order:2,defaultSize:x,style:y,collapsible:!0,collapsedSize:0,minSize:20,children:C}),e[23]=h.main,e[24]=C,e[25]=R):R=e[25];let E;return e[26]!==R||e[27]!==m||e[28]!==b?(E=o.jsxs(Xc,{ref:d,direction:"horizontal",className:"flex-1 min-h-0 pb-1 pr-1 pl-0 pt-0",style:p,children:[b,S,R]},m),e[26]=R,e[27]=m,e[28]=b,e[29]=E):E=e[29],E}const ar="flex size-7 shrink-0 items-center justify-center rounded-md transition-colors",zo="bg-sidebar-accent text-sidebar-foreground",lr="text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";function Xp(t){const e=H.c(47),{chatOpen:s,toggleChat:i,onNewTask:r}=t,{tasksOpen:n,toggleTasks:a}=Mc(),l=!!r;let h;e[0]!==n||e[1]!==a?(h=()=>{ye("agent_toolbar_toggled",{button:"tasks",next_state:n?"closed":"open"}),a()},e[0]=n,e[1]=a,e[2]=h):h=e[2];const c=n?zo:lr;let u;e[3]!==c?(u=re(ar,c),e[3]=c,e[4]=u):u=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=o.jsx(jc,{size:16}),e[5]=d):d=e[5];let f;e[6]!==h||e[7]!==u||e[8]!==n?(f=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:h,"aria-pressed":n,className:u,children:d})}),e[6]=h,e[7]=u,e[8]=n,e[9]=f):f=e[9];let _;e[10]===Symbol.for("react.memo_cache_sentinel")?(_=o.jsx(Ge,{side:"bottom",children:"Tasks"}),e[10]=_):_=e[10];let m;e[11]!==f?(m=o.jsxs(Ke,{delayDuration:300,children:[f,_]}),e[11]=f,e[12]=m):m=e[12];let p;e[13]!==s||e[14]!==i?(p=()=>{ye("agent_toolbar_toggled",{button:"chat",next_state:s?"closed":"open"}),i()},e[13]=s,e[14]=i,e[15]=p):p=e[15];const g=s?zo:lr;let v;e[16]!==g?(v=re(ar,g),e[16]=g,e[17]=v):v=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=o.jsx(Ec,{size:16}),e[18]=b):b=e[18];let S;e[19]!==s||e[20]!==v||e[21]!==p?(S=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:p,"aria-pressed":s,className:v,children:b})}),e[19]=s,e[20]=v,e[21]=p,e[22]=S):S=e[22];let x;e[23]===Symbol.for("react.memo_cache_sentinel")?(x=o.jsx(Ge,{side:"bottom",children:"Chat"}),e[23]=x):x=e[23];let y;e[24]!==S?(y=o.jsxs(Ke,{delayDuration:300,children:[S,x]}),e[24]=S,e[25]=y):y=e[25];const N=l?"grid-cols-[1fr]":"grid-cols-[0fr]";let C;e[26]!==N?(C=re("grid transition-[grid-template-columns] duration-200 ease-[var(--ease-out-quart)]",N),e[26]=N,e[27]=C):C=e[27];const R=!l,E=l?0:-1,A=!l,I=l?"translate-x-0 opacity-100":"-translate-x-2 opacity-0";let D;e[28]!==I?(D=re(ar,lr,"transition-[transform,opacity] duration-200 ease-[var(--ease-out-quart)] will-change-transform",I),e[28]=I,e[29]=D):D=e[29];let k;e[30]===Symbol.for("react.memo_cache_sentinel")?(k=o.jsx(sa,{size:16}),e[30]=k):k=e[30];let w;e[31]!==r||e[32]!==R||e[33]!==E||e[34]!==A||e[35]!==D?(w=o.jsx(qe,{asChild:!0,children:o.jsx("button",{type:"button",onClick:r,disabled:R,tabIndex:E,"aria-hidden":A,className:D,children:k})}),e[31]=r,e[32]=R,e[33]=E,e[34]=A,e[35]=D,e[36]=w):w=e[36];let j;e[37]===Symbol.for("react.memo_cache_sentinel")?(j=o.jsx(Ge,{side:"bottom",children:"New task"}),e[37]=j):j=e[37];let T;e[38]!==w?(T=o.jsx("div",{className:"overflow-hidden",children:o.jsxs(Ke,{delayDuration:300,children:[w,j]})}),e[38]=w,e[39]=T):T=e[39];let M;e[40]!==C||e[41]!==T?(M=o.jsx("div",{className:C,children:T}),e[40]=C,e[41]=T,e[42]=M):M=e[42];let B;return e[43]!==y||e[44]!==M||e[45]!==m?(B=o.jsxs(o.Fragment,{children:[m,y,M]}),e[43]=y,e[44]=M,e[45]=m,e[46]=B):B=e[46],B}function Jp(t,e,s){if(t.length<=s)return{visible:t,overflow:[]};const i=t.slice(0,s),r=t.slice(s);if(e==null)return{visible:i,overflow:r};if(i.some(d=>d.id===e))return{visible:i,overflow:r};const a=r.findIndex(d=>d.id===e);if(a===-1)return{visible:i,overflow:r};const l=i[i.length-1],h=r[a],c=[...i.slice(0,-1),h],u=[l,...r.slice(0,a),...r.slice(a+1)];return{visible:c,overflow:u}}function Zp(t){const e=H.c(13),{title:s,icon:i,active:r,onClick:n}=t,a=r?"bg-sidebar-accent text-sidebar-foreground":"text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-foreground";let l;e[0]!==a?(l=re("shrink-0 flex items-center gap-1.5 h-8 rounded-md px-2","[transition:background-color_180ms_ease,color_180ms_ease]",a),e[0]=a,e[1]=l):l=e[1];let h;e[2]!==i?(h=o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(Qp,{icon:i})}),e[2]=i,e[3]=h):h=e[3];let c;e[4]!==s?(c=o.jsx("span",{className:"whitespace-nowrap text-sm font-medium leading-none",children:s}),e[4]=s,e[5]=c):c=e[5];let u;return e[6]!==r||e[7]!==n||e[8]!==l||e[9]!==h||e[10]!==c||e[11]!==s?(u=o.jsxs("button",{type:"button",onClick:n,"aria-pressed":r,"aria-label":s,className:l,children:[h,c]}),e[6]=r,e[7]=n,e[8]=l,e[9]=h,e[10]=c,e[11]=s,e[12]=u):u=e[12],u}function Qp(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}function eg(t){const e=H.c(13),{overflow:s,onSelect:i}=t,[r,n]=P.useState(!1);let a;e[0]!==i?(a=f=>{n(!1),i(f)},e[0]=i,e[1]=a):a=e[1];const l=a;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=o.jsx(Ws,{asChild:!0,children:o.jsx("button",{type:"button",title:"More tabs","aria-label":"More tabs",className:"shrink-0 flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:o.jsx(ia,{className:"size-4"})})}),e[2]=h):h=e[2];let c;if(e[3]!==l||e[4]!==s){let f;e[6]!==l?(f=_=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>l(_.id),className:"w-full flex items-center gap-2 px-3 py-2 rounded-md hover:bg-accent text-sm text-foreground",children:[o.jsx("span",{className:"flex size-5 items-center justify-center shrink-0",children:o.jsx(tg,{icon:_.icon})}),o.jsx("span",{className:"truncate",children:_.title})]})},_.id),e[6]=l,e[7]=f):f=e[7],c=s.map(f),e[3]=l,e[4]=s,e[5]=c}else c=e[5];let u;e[8]!==c?(u=o.jsx(Us,{align:"end",className:"w-56 p-1",children:o.jsx("ul",{className:"flex flex-col",children:c})}),e[8]=c,e[9]=u):u=e[9];let d;return e[10]!==r||e[11]!==u?(d=o.jsxs(Vs,{open:r,onOpenChange:n,children:[h,u]}),e[10]=r,e[11]=u,e[12]=d):d=e[12],d}function tg(t){const e=H.c(5),{icon:s}=t;if(s.kind==="component"){const{Component:r}=s;let n;return e[0]!==r?(n=o.jsx(r,{className:"size-4"}),e[0]=r,e[1]=n):n=e[1],n}if(s.kind==="url"){let r;return e[2]!==s.src?(r=o.jsx("img",{src:s.src,alt:"",className:"size-4 rounded-sm object-cover"}),e[2]=s.src,e[3]=r):r=e[3],r}let i;return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(oa,{className:"size-4"}),e[4]=i):i=e[4],i}const sg=6;function ig(t){const e=H.c(20),{virtualMcpId:s,taskId:i}=t,r=Bt();let n;e[0]!==i||e[1]!==s?(n={virtualMcpId:s,taskId:i},e[0]=i,e[1]=s,e[2]=n):n=e[2];const{tabs:a,activeTab:l,mainOpen:h,setActiveTab:c}=Da(n);let u,d,f,_;if(e[3]!==l||e[4]!==h||e[5]!==r||e[6]!==c||e[7]!==a||e[8]!==s){const g=uc({activeTab:l,mainOpen:h}),v=N=>N.id==="automations"?g:h&&N.id===l,S=a.find(N=>v(N))?.id??null,{visible:x,overflow:y}=Jp(a,S,sg);d=y,u=N=>{const C=a.find(E=>E.id===N),R=S===N&&h;if(ye("main_panel_tab_clicked",{virtual_mcp_id:s,tab_id:N,tab_kind:C?.kind??null,was_active:R}),N==="automations"){const E=fc({activeTab:l,mainOpen:h});r({to:".",search:A=>({...A,main:E}),replace:!0});return}c(N)},f="flex items-center min-w-0 ml-auto gap-0.5",_=x.map(N=>o.jsx(Zp,{title:N.title,icon:N.icon,active:v(N),onClick:()=>u(N.id)},N.id)),e[3]=l,e[4]=h,e[5]=r,e[6]=c,e[7]=a,e[8]=s,e[9]=u,e[10]=d,e[11]=f,e[12]=_}else u=e[9],d=e[10],f=e[11],_=e[12];let m;e[13]!==u||e[14]!==d?(m=d.length>0&&o.jsx(eg,{overflow:d,onSelect:u}),e[13]=u,e[14]=d,e[15]=m):m=e[15];let p;return e[16]!==f||e[17]!==_||e[18]!==m?(p=o.jsxs("div",{className:f,children:[_,m]}),e[16]=f,e[17]=_,e[18]=m,e[19]=p):p=e[19],p}function rg(t){const e=H.c(12);let s,i,r,n;e[0]!==t?({className:s,orientation:r,decorative:n,...i}=t,e[0]=t,e[1]=s,e[2]=i,e[3]=r,e[4]=n):(s=e[1],i=e[2],r=e[3],n=e[4]);const a=r===void 0?"horizontal":r,l=n===void 0?!0:n;let h;e[5]!==s?(h=re("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=h):h=e[6];let c;return e[7]!==l||e[8]!==a||e[9]!==i||e[10]!==h?(c=o.jsx(Hl,{"data-slot":"separator-root",decorative:l,orientation:a,className:h,...i}),e[7]=l,e[8]=a,e[9]=i,e[10]=h,e[11]=c):c=e[11],c}function ng(t){const e=H.c(20),{prNumber:s,disabled:i,send:r}=t;let n;e[0]!==s||e[1]!==r?(n=()=>r(gu({prNumber:s})),e[0]=s,e[1]=r,e[2]=n):n=e[2];const a=n;let l;e[3]!==s||e[4]!==r?(l=()=>r(pu({prNumber:s})),e[3]=s,e[4]=r,e[5]=l):l=e[5];const h=l;let c;e[6]!==i||e[7]!==a?(c=o.jsx(oe,{size:"sm",variant:"success",className:"rounded-r-none border-r border-success-foreground/20",disabled:i,onClick:a,children:"Publish"}),e[6]=i,e[7]=a,e[8]=c):c=e[8];let u;e[9]===Symbol.for("react.memo_cache_sentinel")?(u=o.jsx(fr,{className:"h-3.5 w-3.5"}),e[9]=u):u=e[9];let d;e[10]!==i?(d=o.jsx(os,{asChild:!0,children:o.jsx(oe,{size:"sm",variant:"success",className:"rounded-l-none px-2",disabled:i,"aria-label":"More actions",children:u})}),e[10]=i,e[11]=d):d=e[11];let f;e[12]!==h?(f=o.jsx(as,{align:"end",children:o.jsx(wt,{onClick:h,children:"Review"})}),e[12]=h,e[13]=f):f=e[13];let _;e[14]!==d||e[15]!==f?(_=o.jsxs(ns,{children:[d,f]}),e[14]=d,e[15]=f,e[16]=_):_=e[16];let m;return e[17]!==c||e[18]!==_?(m=o.jsxs("div",{className:"inline-flex items-stretch rounded-md",children:[c,_]}),e[17]=c,e[18]=_,e[19]=m):m=e[19],m}const og=new Set(["failure","timed_out","cancelled","action_required"]);function ag(t){return t.status==="completed"&&og.has(t.conclusion)}function lg(t){return t.status==="queued"||t.status==="in_progress"}function cg(t){const{branchStatus:e,pr:s,checks:i,reviews:r,loading:n}=t;if(!e||n)return{label:"Loading…",disabled:!0,loading:!0,variant:"outline",tooltip:"Loading branch and pull request status"};switch(e.kind){case"initializing":return{label:"Starting sandbox…",disabled:!0,loading:!0,variant:"outline",tooltip:"Waiting for the sandbox daemon to come online"};case"cloning":return{label:"Cloning repo…",disabled:!0,loading:!0,variant:"outline",tooltip:"Cloning the project repository"};case"clone-failed":return{label:"Clone failed",disabled:!0,variant:"outline",tooltip:e.error||"git clone failed — see setup logs"};case"checking-out":return{label:`Switching to ${e.to}…`,disabled:!0,loading:!0,variant:"outline",tooltip:`Checking out ${e.to}`};case"checkout-failed":return{label:"Checkout failed",disabled:!0,variant:"outline",tooltip:e.error||"git checkout failed — see setup logs"}}const a=e;if(a.workingTreeDirty||a.unpushed>0)return{label:"Save changes",action:"commit-and-push",variant:"default",tooltip:"Commit and push local changes"};if(s?.merged)return!!a.headSha&&!!s.headSha&&a.headSha!==s.headSha?{label:"Continue",action:"create-pr",variant:"special",tooltip:"Open a new PR with the latest commits"}:{label:"Published",disabled:!0,variant:"outline",tooltip:`PR #${s.number} merged into ${s.base}`};if(a.aheadOfBase>0){if(s&&s.state==="closed"&&!s.merged)return{label:"Reopen",action:"reopen",variant:"default",tooltip:`Reopen PR #${s.number}`};if(!s)return{label:"Submit for review",action:"create-pr",variant:"default",tooltip:`Open a PR for ${a.branch} → ${a.base}`};if((r?.mergeableState??"unknown")==="dirty")return{label:`Sync with ${s.base}`,action:"rebase",variant:"default",tooltip:`Resolve conflicts with ${s.base} before merging`};const c=i.filter(ag).map(f=>f.name);if(c.length>0)return{label:"Fix tests",action:"fix-checks",variant:"default",tooltip:`Failing: ${c.join(", ")}`,meta:{failingChecks:c}};const u=i.filter(lg);if(u.length>0)return{label:"Running tests…",disabled:!0,loading:!0,variant:"outline",tooltip:`Waiting on ${u.length} check${u.length===1?"":"s"} to finish`};if(r?.draft)return{label:"Mark ready",action:"mark-ready",variant:"default",tooltip:"Mark draft PR ready for review"};const d=r?.unresolvedConversations??0;return d>0?{label:"Address feedback",action:"resolve-comments",variant:"default",tooltip:`${d} unresolved conversation${d===1?"":"s"}`}:r?.missingRequiredApprovals?{label:"Awaiting review",disabled:!0,variant:"outline",tooltip:"Waiting for required approvals"}:{label:"Publish",action:"merge-split",variant:"success",tooltip:`Squash-merge PR #${s.number} into ${s.base}`}}return{label:"Up to date",disabled:!0,variant:"outline",tooltip:`Branch is in sync with ${a.base}`}}function hg(){return Gt().branchStatus}const dg=6e4,ug=3e4;function fg(t){const e=H.c(12);let s;e[0]!==t.connectionId||e[1]!==t.orgId||e[2]!==t.orgSlug?(s={connectionId:t.connectionId,orgId:t.orgId,orgSlug:t.orgSlug},e[0]=t.connectionId,e[1]=t.orgId,e[2]=t.orgSlug,e[3]=s):s=e[3];const i=He(s),r=t.prNumber??0;let n;e[4]!==t.owner||e[5]!==t.repo||e[6]!==r?(n={method:"get",owner:t.owner,repo:t.repo,pullNumber:r},e[4]=t.owner,e[5]=t.repo,e[6]=r,e[7]=n):n=e[7];const a=!!t.prNumber;let l;return e[8]!==i||e[9]!==n||e[10]!==a?(l={client:i,toolName:"pull_request_read",toolArguments:n,enabled:a,refetchInterval:dg,refetchIntervalInBackground:!1,staleTime:ug,select:mg},e[8]=i,e[9]=n,e[10]=a,e[11]=l):l=e[11],ms(l)}function mg(t){const e=qs(t);if(!e)return null;const s=e.mergeable_state??"unknown",i=!!(e.draft??!1),r=Number(e.review_comments??0),n=s==="blocked"&&r>0?r:0;return{draft:i,mergeableState:s,unresolvedConversations:n,missingRequiredApprovals:s==="blocked"&&n===0}}function _g(t){const e=H.c(42),{virtualMcpId:s}=t,{org:i}=ve(),r=Ct(s),{currentBranch:n}=vt(),a=fs(),l=r?.metadata?.githubRepo??null,h=hg(),c=l?.connectionId??"",u=l?.owner??"",d=l?.name??"",f=n??null;let _;e[0]!==i.id||e[1]!==i.slug||e[2]!==c||e[3]!==u||e[4]!==d||e[5]!==f?(_={orgId:i.id,orgSlug:i.slug,connectionId:c,owner:u,repo:d,branch:f},e[0]=i.id,e[1]=i.slug,e[2]=c,e[3]=u,e[4]=d,e[5]=f,e[6]=_):_=e[6];const m=Aa(_),p=m.data??null,g=l?.connectionId??"",v=l?.owner??"",b=l?.name??"",S=p&&p.state==="open"?p.number:null;let x;e[7]!==i.id||e[8]!==i.slug||e[9]!==g||e[10]!==v||e[11]!==b||e[12]!==S?(x={orgId:i.id,orgSlug:i.slug,connectionId:g,owner:v,repo:b,prNumber:S},e[7]=i.id,e[8]=i.slug,e[9]=g,e[10]=v,e[11]=b,e[12]=S,e[13]=x):x=e[13];const y=Pa(x),N=l?.connectionId??"",C=l?.owner??"",R=l?.name??"",E=p&&p.state==="open"?p.number:null;let A;e[14]!==i.id||e[15]!==i.slug||e[16]!==N||e[17]!==C||e[18]!==R||e[19]!==E?(A={orgId:i.id,orgSlug:i.slug,connectionId:N,owner:C,repo:R,prNumber:E},e[14]=i.id,e[15]=i.slug,e[16]=N,e[17]=C,e[18]=R,e[19]=E,e[20]=A):A=e[20];const I=fg(A);if(!l?.connectionId||!n)return null;let D;e[21]!==h||e[22]!==y.data||e[23]!==p||e[24]!==m.isPending||e[25]!==I.data?(D=cg({branchStatus:h,pr:p,checks:y.data??[],reviews:I.data??null,loading:m.isPending}),e[21]=h,e[22]=y.data,e[23]=p,e[24]=m.isPending,e[25]=I.data,e[26]=D):D=e[26];const k=D;let w;e[27]!==a?(w=F=>a.sendMessage({parts:[{type:"text",text:F}]}),e[27]=a,e[28]=w):w=e[28];const j=w,T=a.isStreaming;let M;e[29]!==n||e[30]!==k||e[31]!==T||e[32]!==p||e[33]!==j?(M=F=>{if(!T)switch(F){case"commit-and-push":{j(lu({branch:n}));return}case"create-pr":{j(cu({branch:n}));return}case"reopen":{p&&j(hu({prNumber:p.number}));return}case"rebase":{j(du({branch:n}));return}case"fix-checks":{p&&j(fu({prNumber:p.number,failingChecks:k.meta?.failingChecks??[]}));return}case"mark-ready":{p&&j(mu({prNumber:p.number}));return}case"resolve-comments":{p&&j(_u({prNumber:p.number}));return}case"merge-split":return}},e[29]=n,e[30]=k,e[31]=T,e[32]=p,e[33]=j,e[34]=M):M=e[34];const B=M;let O;e[35]===Symbol.for("react.memo_cache_sentinel")?(O=o.jsx(rg,{orientation:"vertical",className:"mx-2 data-[orientation=vertical]:h-5"}),e[35]=O):O=e[35];const q=p?.number;let U;return e[36]!==k||e[37]!==T||e[38]!==B||e[39]!==j||e[40]!==q?(U=o.jsxs(o.Fragment,{children:[O,o.jsx(pg,{button:k,isStreaming:T,onActivate:B,prNumber:q,send:j})]}),e[36]=k,e[37]=T,e[38]=B,e[39]=j,e[40]=q,e[41]=U):U=e[41],U}function pg(t){const e=H.c(21),{button:s,isStreaming:i}=t,r=!!s.disabled||i,n=i?"Chat is running":s.tooltip??null;if(s.action==="merge-split"&&t.prNumber!=null){let u;e[0]!==r||e[1]!==t.prNumber||e[2]!==t.send?(u=o.jsx(ng,{prNumber:t.prNumber,disabled:r,send:t.send}),e[0]=r,e[1]=t.prNumber,e[2]=t.send,e[3]=u):u=e[3];let d;return e[4]!==u||e[5]!==n?(d=o.jsx($o,{label:n,children:u}),e[4]=u,e[5]=n,e[6]=d):d=e[6],d}let a;e[7]!==s.action||e[8]!==t?(a=()=>t.onActivate(s.action),e[7]=s.action,e[8]=t,e[9]=a):a=e[9];let l;e[10]!==s.loading?(l=s.loading?o.jsx(vh,{size:"xs",variant:"default"}):null,e[10]=s.loading,e[11]=l):l=e[11];let h;e[12]!==s.label||e[13]!==s.variant||e[14]!==r||e[15]!==a||e[16]!==l?(h=o.jsxs(oe,{size:"sm",variant:s.variant,disabled:r,onClick:a,children:[l,s.label]}),e[12]=s.label,e[13]=s.variant,e[14]=r,e[15]=a,e[16]=l,e[17]=h):h=e[17];let c;return e[18]!==h||e[19]!==n?(c=o.jsx($o,{label:n,children:h}),e[18]=h,e[19]=n,e[20]=c):c=e[20],c}function $o(t){const e=H.c(9),{label:s,children:i}=t;if(!s){let l;return e[0]!==i?(l=o.jsx(o.Fragment,{children:i}),e[0]=i,e[1]=l):l=e[1],l}let r;e[2]!==i?(r=o.jsx(qe,{asChild:!0,children:o.jsx("span",{children:i})}),e[2]=i,e[3]=r):r=e[3];let n;e[4]!==s?(n=o.jsx(Ge,{children:s}),e[4]=s,e[5]=n):n=e[5];let a;return e[6]!==r||e[7]!==n?(a=o.jsx(Wc,{children:o.jsxs(Ke,{children:[r,n]})}),e[6]=r,e[7]=n,e[8]=a):a=e[8],a}function gg(t){const e=H.c(2),{virtualMcp:s}=t;if(!!!(s.metadata?.githubRepo??null)?.connectionId)return null;let n;return e[0]!==s.id?(n=o.jsx(hr.Right,{children:o.jsx(_g,{virtualMcpId:s.id})}),e[0]=s.id,e[1]=n):n=e[1],n}const Qt=P.createContext(null);function vn(){return P.use(Qt)}function Fo(t){const e=H.c(7),{children:s}=t,{taskId:i}=vt();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=o.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"Something went wrong loading the chat. Try refreshing."}),e[0]=r):r=e[0];let n;e[1]===Symbol.for("react.memo_cache_sentinel")?(n=o.jsx(je.Skeleton,{}),e[1]=n):n=e[1];let a;e[2]!==s?(a=s??o.jsx(Ea,{}),e[2]=s,e[3]=a):a=e[3];let l;return e[4]!==a||e[5]!==i?(l=o.jsx(Ht,{fallback:r,children:o.jsx(P.Suspense,{fallback:n,children:o.jsx(je.ActiveTaskProvider,{taskId:i,children:a})})}),e[4]=a,e[5]=i,e[6]=l):l=e[6],l}function Ho(t){const e=H.c(3),{onNewTaskRef:s,createNewTask:i}=t;let r;return e[0]!==i||e[1]!==s?(r=()=>(s.current=i,()=>{s.current=null}),e[0]=i,e[1]=s,e[2]=r):r=e[2],P.useLayoutEffect(r),null}function vg(t){const e=H.c(3),{onOpenSidebar:s}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o.jsx(Ql,{size:20}),e[0]=i):i=e[0];let r;return e[1]!==s?(r=o.jsx("div",{className:"shrink-0 flex items-center justify-between px-3 h-12 bg-background border-b border-border",children:o.jsx("button",{type:"button",onClick:s,className:"flex size-8 items-center justify-center rounded-md text-foreground/60 hover:bg-accent hover:text-foreground transition-colors","aria-label":"Open menu",children:i})}),e[1]=s,e[2]=r):r=e[2],r}function Wo(t){const e=H.c(16),{virtualMcpId:s,hasActiveGithubRepo:i,vmMap:r,children:n}=t,{org:a}=ve(),{currentBranch:l}=vt(),{data:h}=Ci.useSession(),c=h?.user?.id;let u;e[0]!==a.id||e[1]!==a.slug?(u={connectionId:Pt,orgId:a.id,orgSlug:a.slug},e[0]=a.id,e[1]=a.slug,e[2]=u):u=e[2];const d=He(u),{mutate:f}=nn(d);let _;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=new Set,e[3]=_):_=e[3];const m=P.useRef(_);let p,g;e[4]!==l||e[5]!==i||e[6]!==f||e[7]!==c||e[8]!==s||e[9]!==r?(p=()=>{if(i&&c&&l){if(r?.[c]?.[l]){m.current.add(l);return}m.current.has(l)||(m.current.add(l),f({virtualMcpId:s,branch:l},{onError:xg}))}},g=[i,c,l,r,s,f],e[4]=l,e[5]=i,e[6]=f,e[7]=c,e[8]=s,e[9]=r,e[10]=p,e[11]=g):(p=e[10],g=e[11]),P.useEffect(p,g);const v=l??null;let b;return e[12]!==n||e[13]!==v||e[14]!==s?(b=o.jsx(Wu,{virtualMcpId:s,branch:v,children:n}),e[12]=n,e[13]=v,e[14]=s,e[15]=b):b=e[15],b}function xg(t){console.error("[auto-start-vm] failed:",t)}function bg(){const t=H.c(96),e=aa(),s=Bt(),{org:i}=ve(),r=Ic()?.tasksOpen??!1;Uc(i.slug);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={strict:!1},t[0]=n):n=t[0];const a=Wl(n),l=a.org??"";let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h={strict:!1},t[1]=h):h=t[1];const c=Jr(h);let u;t[2]!==i.id||t[3]!==c.virtualmcpid?(u=c.virtualmcpid??Xo(i.id).id,t[2]=i.id,t[3]=c.virtualmcpid,t[4]=u):u=t[4];const d=u,f=Mh(a.taskId??"",d),_=Ct(d),m=_?.metadata?.ui?.layout??null;let p;t[5]!==m?(p=m?{defaultMainView:m.defaultMainView??null,chatDefaultOpen:m.chatDefaultOpen??null}:null,t[5]=m,t[6]=p):p=t[6];const g=p;let v;t[7]!==_?(v=_&&Kt(_),t[7]=_,t[8]=v):v=t[8];const b=!!v;let S;t[9]!==l||t[10]!==d?(S={virtualMcpId:d,orgSlug:l,isAgentRoute:!0},t[9]=l,t[10]=d,t[11]=S):S=t[11];const x=Ac(g,S),{setOpenMobile:y,openMobile:N}=zc(),C=y,R=P.useRef(null);let E,A;t[12]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{const V=$=>{Lc($)&&$.shiftKey&&$.code==="KeyS"&&!$.repeat&&($.preventDefault(),R.current?.())};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},A=[],t[12]=E,t[13]=A):(E=t[12],A=t[13]),P.useEffect(E,A);const I=d;let D;t[14]!==_||t[15]!==d?(D={virtualMcpId:d,entity:_},t[14]=_,t[15]=d,t[16]=D):D=t[16];const k=D;if(f.status==="creating"||f.status==="loading"){let V;t[17]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex h-full items-center justify-center bg-background card-shadow rounded-[0.75rem] text-sm text-muted-foreground",children:[o.jsx(Ie,{className:"size-4 animate-spin mr-2"}),"Creating task…"]})}),t[17]=V):V=t[17];let $;return t[18]!==k?($=o.jsx(Qt,{value:k,children:V}),t[18]=k,t[19]=$):$=t[19],$}if(f.status==="error"){let V;t[20]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx("div",{className:"font-medium",children:"Task unavailable"}),t[20]=V):V=t[20];let $;t[21]!==f.error.message?($=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsxs("div",{className:"flex flex-col h-full items-center justify-center gap-2 bg-background card-shadow rounded-[0.75rem] p-8 text-sm",children:[V,o.jsx("div",{className:"text-muted-foreground",children:f.error.message})]})}),t[21]=f.error.message,t[22]=$):$=t[22];let W;return t[23]!==k||t[24]!==$?(W=o.jsx(Qt,{value:k,children:$}),t[23]=k,t[24]=$,t[25]=W):W=t[25],W}if(!_){let V;t[26]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx(Ps,{size:48,className:"text-muted-foreground"}),t[26]=V):V=t[26];const $=`The agent "${d}" does not exist in this organization.`;let W;t[27]!==s||t[28]!==l?(W=o.jsx(oe,{variant:"outline",onClick:()=>s({to:"/$org",params:{org:l}}),children:"Go to organization home"}),t[27]=s,t[28]=l,t[29]=W):W=t[29];let Q;t[30]!==$||t[31]!==W?(Q=o.jsx("div",{className:"flex-1 min-h-0 pr-1.5 pb-1.5 overflow-hidden",children:o.jsx("div",{className:"flex flex-col h-full bg-background overflow-hidden card-shadow rounded-[0.75rem]",children:o.jsx(Ls,{image:V,title:"Agent not found",description:$,actions:W})})}),t[30]=$,t[31]=W,t[32]=Q):Q=t[32];let L;return t[33]!==k||t[34]!==Q?(L=o.jsx(Qt,{value:k,children:Q}),t[33]=k,t[34]=Q,t[35]=L):L=t[35],L}if(e){let V;t[36]===Symbol.for("react.memo_cache_sentinel")?(V=o.jsx($c,{className:"sr-only",children:"Navigation"}),t[36]=V):V=t[36];let $;t[37]!==C?($=o.jsx("div",{className:"w-14 shrink-0 bg-sidebar flex flex-col items-center border-r border-border overflow-y-auto group/sidebar","data-state":"collapsed",children:o.jsx(Bc,{onClose:()=>C(!1)})}),t[37]=C,t[38]=$):$=t[38];let W;t[39]===Symbol.for("react.memo_cache_sentinel")?(W=o.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:o.jsx(Pc,{})}),t[39]=W):W=t[39];let Q;t[40]!==$?(Q=o.jsxs(Fc,{side:"left",hideCloseButton:!0,className:"w-[calc(100vw-3rem)] sm:max-w-md! p-0",children:[V,o.jsxs("div",{className:"flex h-full",children:[$,W]})]}),t[40]=$,t[41]=Q):Q=t[41];let L;t[42]!==N||t[43]!==C||t[44]!==Q?(L=o.jsx(Hc,{open:N,onOpenChange:C,children:Q}),t[42]=N,t[43]=C,t[44]=Q,t[45]=L):L=t[45];const se=L,ie=_?.metadata?.vmMap;let te;t[46]!==x.createNewTask?(te=o.jsx(Ho,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[46]=x.createNewTask,t[47]=te):te=t[47];let G;t[48]!==C?(G=o.jsx(vg,{onOpenSidebar:()=>C(!0)}),t[48]=C,t[49]=G):G=t[49];let le;t[50]===Symbol.for("react.memo_cache_sentinel")?(le=o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:o.jsx(Fo,{})}),t[50]=le):le=t[50];let ue;t[51]!==b||t[52]!==se||t[53]!==ie||t[54]!==te||t[55]!==G||t[56]!==d?(ue=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:ie,children:[te,G,le,se]}),t[51]=b,t[52]=se,t[53]=ie,t[54]=te,t[55]=G,t[56]=d,t[57]=ue):ue=t[57];let de;t[58]!==I||t[59]!==ue?(de=o.jsx("div",{className:"flex flex-col flex-1 bg-background min-h-0",children:o.jsx(je.Provider,{virtualMcpId:I,children:ue},I)}),t[58]=I,t[59]=ue,t[60]=de):de=t[60];let fe;return t[61]!==k||t[62]!==de?(fe=o.jsx(Qt,{value:k,children:de}),t[61]=k,t[62]=de,t[63]=fe):fe=t[63],fe}const w=r?void 0:x.createNewTask;let j;t[64]!==x.chatOpen||t[65]!==x.toggleChat||t[66]!==w?(j=o.jsx(hr.Toggles,{children:o.jsx(Xp,{chatOpen:x.chatOpen,toggleChat:x.toggleChat,onNewTask:w})}),t[64]=x.chatOpen,t[65]=x.toggleChat,t[66]=w,t[67]=j):j=t[67];let T;t[68]!==x.taskId||t[69]!==d?(T=o.jsx(hr.Tabs,{children:o.jsx(ig,{virtualMcpId:d,taskId:x.taskId})}),t[68]=x.taskId,t[69]=d,t[70]=T):T=t[70];const M=_?.metadata?.vmMap;let B;t[71]!==_?(B=o.jsx(gg,{virtualMcp:_}),t[71]=_,t[72]=B):B=t[72];let O;t[73]!==x.createNewTask?(O=o.jsx(Ho,{onNewTaskRef:R,createNewTask:x.createNewTask}),t[73]=x.createNewTask,t[74]=O):O=t[74];let q;t[75]===Symbol.for("react.memo_cache_sentinel")?(q=o.jsx(Fo,{}),t[75]=q):q=t[75];let U;t[76]!==x.chatOpen||t[77]!==x.mainOpen||t[78]!==x.taskId||t[79]!==d?(U=o.jsx(Yp,{virtualMcpId:d,taskId:x.taskId,chatOpen:x.chatOpen,mainOpen:x.mainOpen,chatContent:q}),t[76]=x.chatOpen,t[77]=x.mainOpen,t[78]=x.taskId,t[79]=d,t[80]=U):U=t[80];let F;t[81]!==b||t[82]!==M||t[83]!==B||t[84]!==O||t[85]!==U||t[86]!==d?(F=o.jsxs(Wo,{virtualMcpId:d,hasActiveGithubRepo:b,vmMap:M,children:[B,O,U]}),t[81]=b,t[82]=M,t[83]=B,t[84]=O,t[85]=U,t[86]=d,t[87]=F):F=t[87];let Z;t[88]!==I||t[89]!==T||t[90]!==F?(Z=o.jsxs(je.Provider,{virtualMcpId:I,children:[T,F]},I),t[88]=I,t[89]=T,t[90]=F,t[91]=Z):Z=t[91];let J;return t[92]!==k||t[93]!==j||t[94]!==Z?(J=o.jsx("div",{className:"flex-1 min-w-0 flex flex-col",children:o.jsxs(Qt,{value:k,children:[j,Z]})}),t[92]=k,t[93]=j,t[94]=Z,t[95]=J):J=t[95],J}function E1(){const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=o.jsx(P.Suspense,{fallback:o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ie,{size:20,className:"animate-spin text-muted-foreground"})}),children:o.jsx(bg,{})}),t[0]=e):e=t[0],e}export{E1 as default,vn as useInsetContext};
|