agentroam-runtime-darwin-arm64 0.2.0-preview.82 → 0.2.0-preview.83
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/manifest.json +2 -2
- package/package.json +1 -1
- package/runtime/.next/BUILD_ID +1 -1
- package/runtime/.next/app-build-manifest.json +19 -18
- package/runtime/.next/app-path-routes-manifest.json +1 -1
- package/runtime/.next/build-manifest.json +7 -7
- package/runtime/.next/prerender-manifest.json +1 -1
- package/runtime/.next/react-loadable-manifest.json +4 -4
- package/runtime/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app/_not-found.html +1 -1
- package/runtime/.next/server/app/_not-found.rsc +1 -1
- package/runtime/.next/server/app/api/engine-threads.body +1 -1
- package/runtime/.next/server/app/api/update/check/route.js +1 -1
- package/runtime/.next/server/app/api/update/install/route.js +1 -1
- package/runtime/.next/server/app/api/update/status/route.js +1 -1
- package/runtime/.next/server/app/web/page.js +4 -4
- package/runtime/.next/server/app/web/page_client-reference-manifest.js +1 -1
- package/runtime/.next/server/app-paths-manifest.json +39 -39
- package/runtime/.next/server/middleware-build-manifest.js +1 -1
- package/runtime/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/runtime/.next/server/pages/404.html +1 -1
- package/runtime/.next/server/pages/500.html +1 -1
- package/runtime/.next/server/server-reference-manifest.json +1 -1
- package/runtime/.next/static/chunks/20.2eb9bc3a5b4d410b.js +1 -0
- package/runtime/.next/static/chunks/325-0818ba5a4060a0e8.js +1 -0
- package/runtime/.next/static/chunks/34.c7dbf7ffc8914be9.js +1 -0
- package/runtime/.next/static/chunks/686.7b5c444243fcf29a.js +1 -0
- package/runtime/.next/static/chunks/app/web/page-8adf166584b0088e.js +1 -0
- package/runtime/.next/static/chunks/{webpack-f51a057f833e73eb.js → webpack-040c7a20dd455025.js} +1 -1
- package/runtime/.next/static/css/645d4c94ea111811.css +1 -0
- package/runtime/lib/tunnel-control.mjs +1 -1
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/MacOS/agentroam-remote-desktop +0 -0
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/Resources/agentroam-component.json +1 -1
- package/runtime/native/Support.noindex/AgentRoam Remote Desktop.app/Contents/_CodeSignature/CodeResources +2 -2
- package/runtime/node_modules/.package-lock.json +3 -3
- package/runtime/node_modules/@agent/core/dist/index.js +10 -3
- package/runtime/node_modules/@agent/native-runtime/dist/index.js +55 -24
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.cjs +41 -10
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.cjs +9 -9
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.min.mjs +10 -10
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.mjs +41 -10
- package/runtime/node_modules/mediabunny/dist/bundles/mediabunny.node.cjs +41 -10
- package/runtime/node_modules/mediabunny/dist/modules/src/isobmff/isobmff-demuxer.js +50 -11
- package/runtime/node_modules/mediabunny/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/runtime/node_modules/mediabunny/dist/modules/src/version.js +1 -1
- package/runtime/node_modules/mediabunny/package.json +1 -1
- package/runtime/node_modules/mediabunny/src/isobmff/isobmff-demuxer.ts +59 -13
- package/runtime/node_modules/mediabunny/src/metadata.ts +1 -0
- package/runtime/node_modules/mediabunny/src/version.ts +1 -1
- package/runtime/package-lock.json +3 -3
- package/runtime/webapp/dist/assets/AIHubView-HV2FIroL.js +1 -0
- package/runtime/webapp/dist/assets/{AgentManager-B8TTqJaL.js → AgentManager-C4zPGI-Y.js} +1 -1
- package/runtime/webapp/dist/assets/AiHubPane-CEjQjdqT.js +1 -0
- package/runtime/webapp/dist/assets/App-CS2wVlfV.js +68 -0
- package/runtime/webapp/dist/assets/{BrowserLivePanel-DnzJOz5w.js → BrowserLivePanel-BwtEM-IV.js} +2 -2
- package/runtime/webapp/dist/assets/CalendarPage-DY8pZK7d.js +1 -0
- package/runtime/webapp/dist/assets/{CalendarView-QXZbXnXA.js → CalendarView-CuBzp-g8.js} +3 -3
- package/runtime/webapp/dist/assets/CollaborationCreateDialog-DsXkxAd1.js +1 -0
- package/runtime/webapp/dist/assets/CollaborationDashboard-CvE5vaOh.js +1 -0
- package/runtime/webapp/dist/assets/{CollaborationPage-B2mIAc-h.js → CollaborationPage-Cjeo60S0.js} +2 -2
- package/runtime/webapp/dist/assets/{FilePreview-BCEiERA1.js → FilePreview-CyXKv1Cu.js} +5 -5
- package/runtime/webapp/dist/assets/{FileTree-CMbs1Gj3.js → FileTree-DNI9VhEp.js} +2 -2
- package/runtime/webapp/dist/assets/FileWorkspaceDrawer-DRluuYWn.js +1 -0
- package/runtime/webapp/dist/assets/FlowStudioPane-CKlzxza_.js +5 -0
- package/runtime/webapp/dist/assets/HostProjectPicker-CjlxN2ct.js +1 -0
- package/runtime/webapp/dist/assets/{LSPServerList-COMVmsvb.js → LSPServerList-BbAS_sm-.js} +1 -1
- package/runtime/webapp/dist/assets/{MCPServerList-C_juD6B4.js → MCPServerList-DkVUlKEJ.js} +1 -1
- package/runtime/webapp/dist/assets/{MemoryViewer-Et2vysSN.js → MemoryViewer-Ywl80xth.js} +1 -1
- package/runtime/webapp/dist/assets/NewSessionWindow-B4H26X5c.js +1 -0
- package/runtime/webapp/dist/assets/RemoteDesktopPage-B4q2I23i.js +1 -0
- package/runtime/webapp/dist/assets/{RemoteDesktopTabBridge-BFzNwpUn.js → RemoteDesktopTabBridge-B_cCKi7K.js} +1 -1
- package/runtime/webapp/dist/assets/{RunningSessionsIcon-D_cOqmmk.js → RunningSessionsIcon-Cz8_524L.js} +1 -1
- package/runtime/webapp/dist/assets/{SessionDashboard-yjdEKypJ.js → SessionDashboard-DXPSvNsY.js} +2 -2
- package/runtime/webapp/dist/assets/{SessionDashboardBridge-Kc_1Et9r.js → SessionDashboardBridge-7BjKdfN8.js} +1 -1
- package/runtime/webapp/dist/assets/{SettingsPanel-t26XhKHP.js → SettingsPanel-C78O9_ho.js} +1 -1
- package/runtime/webapp/dist/assets/{SkillManager-nZU7b1sc.js → SkillManager-BdkBUxhH.js} +1 -1
- package/runtime/webapp/dist/assets/{TaskPaneTerminal-BPaCKman.js → TaskPaneTerminal-B2WKBysj.js} +1 -1
- package/runtime/webapp/dist/assets/{TerminalPane-CiIpI1Id.js → TerminalPane-CxGcN85G.js} +1 -1
- package/runtime/webapp/dist/assets/TodoPage-CdzjZR2O.js +1 -0
- package/runtime/webapp/dist/assets/{abnfDiagram-VCTEODGH-DmKjGVfG.js → abnfDiagram-VCTEODGH-DFIXyU71.js} +1 -1
- package/runtime/webapp/dist/assets/{arc-D6bpvBke.js → arc-CLpaLEla.js} +1 -1
- package/runtime/webapp/dist/assets/{architectureDiagram-5GKGNRK7-NEKc2BYf.js → architectureDiagram-5GKGNRK7-Df8T0lx0.js} +1 -1
- package/runtime/webapp/dist/assets/{blockDiagram-I7D4REHJ-V6G00twZ.js → blockDiagram-I7D4REHJ-jCoyPZhV.js} +1 -1
- package/runtime/webapp/dist/assets/{c4Diagram-7LVT6UL2-CojA33V5.js → c4Diagram-7LVT6UL2-DsZuTCuo.js} +1 -1
- package/runtime/webapp/dist/assets/{calendar-days-DXE_2mLa.js → calendar-days-BIRmYMrW.js} +1 -1
- package/runtime/webapp/dist/assets/channel-0IyV-PVi.js +1 -0
- package/runtime/webapp/dist/assets/{check-UipgMBET.js → check-DCU8YHqr.js} +1 -1
- package/runtime/webapp/dist/assets/{chevron-down-Dvinwg2S.js → chevron-down-BUEiUZA7.js} +1 -1
- package/runtime/webapp/dist/assets/{chevron-right-BGU3tcLA.js → chevron-right-B_ITnckH.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-2Q5K7J3B-DObpPEgk.js → chunk-2Q5K7J3B-BEZp3wuG.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-5VM5RSS4-PaTzAg6w.js → chunk-5VM5RSS4-BGGDhFwD.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-F27PBJKO-Pn4gut94.js → chunk-F27PBJKO-Mqzm4ODE.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-IMKFNOWR-nRaVFzK9.js → chunk-IMKFNOWR-DtnGgUQJ.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-JWPE2WC7-CxssjKKN.js → chunk-JWPE2WC7-By3kXE4y.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-POPQ4Y6H-CweDXr-B.js → chunk-POPQ4Y6H-BTHuMHN1.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-SVP7TREG-C7T3FGE-.js → chunk-SVP7TREG-BeWH1pvB.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-TICWLB2K-Nc0H-0_V.js → chunk-TICWLB2K-oiekJTZh.js} +1 -1
- package/runtime/webapp/dist/assets/{chunk-XXDRQBXY-D_GQGF5g.js → chunk-XXDRQBXY-B7CKqUBs.js} +1 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-Dm5zwUmQ.js +1 -0
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-Dm5zwUmQ.js +1 -0
- package/runtime/webapp/dist/assets/{client-Bb0hpbIR.js → client-BpqlZTm2.js} +1 -1
- package/runtime/webapp/dist/assets/{codeSyntax-DHonp3tF.js → codeSyntax-GjP28nDI.js} +1 -1
- package/runtime/webapp/dist/assets/{collaboration-e_iziKU1.js → collaboration-CYS2Soeh.js} +1 -1
- package/runtime/webapp/dist/assets/{composer-file-routing-CWyT7leB.js → composer-file-routing-DHdpFYk8.js} +2 -2
- package/runtime/webapp/dist/assets/{cose-bilkent-JH36ORCC-Ac_FBan4.js → cose-bilkent-JH36ORCC-BmhhO76e.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefin-OW5HDTMX-vr6c389q.js → cynefin-OW5HDTMX-BesIxLGS.js} +1 -1
- package/runtime/webapp/dist/assets/{cynefinDiagram-5FMLGOSQ-sXmUCrp_.js → cynefinDiagram-5FMLGOSQ-DdF6XhwX.js} +1 -1
- package/runtime/webapp/dist/assets/{dagre-GXQ25YYZ-B0DmGxDv.js → dagre-GXQ25YYZ-CxUfRr5w.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-S7CK7UJ4-Dn-2jJ6S.js → diagram-S7CK7UJ4-zSD7nygh.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-UQ7AKVKN-BcasYsju.js → diagram-UQ7AKVKN-CgirUu7t.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VSXAHHWV-DCgGkc82.js → diagram-VSXAHHWV-CkI9kDpP.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-VX7I27RA-Cjs0Ny4i.js → diagram-VX7I27RA-ZfbGJBGR.js} +1 -1
- package/runtime/webapp/dist/assets/{diagram-Z3DM3KII-0nyddp0v.js → diagram-Z3DM3KII-CA44IJP4.js} +1 -1
- package/runtime/webapp/dist/assets/{ebnfDiagram-PWID7BFC-By7gCUsz.js → ebnfDiagram-PWID7BFC-CVwSxyot.js} +1 -1
- package/runtime/webapp/dist/assets/{erDiagram-RLTQ6QDP-DdwBp45A.js → erDiagram-RLTQ6QDP-DwjlVHEs.js} +1 -1
- package/runtime/webapp/dist/assets/{file-types-nujx8XUw.js → file-types-Dj25tuty.js} +1 -1
- package/runtime/webapp/dist/assets/{flowDiagram-HODETNUW-DbOwRaT9.js → flowDiagram-HODETNUW-CEt0pwA8.js} +1 -1
- package/runtime/webapp/dist/assets/{ganttDiagram-EL5Y4UJY-CG8obc7O.js → ganttDiagram-EL5Y4UJY-CNsj7gWS.js} +1 -1
- package/runtime/webapp/dist/assets/{gitGraphDiagram-WWUBYQGX-ru6aSu_g.js → gitGraphDiagram-WWUBYQGX-ERbll1_Q.js} +1 -1
- package/runtime/webapp/dist/assets/{history-DaBh5_SJ.js → history-DTS97eAH.js} +1 -1
- package/runtime/webapp/dist/assets/{image-plus-Cm9jq1yo.js → image-plus-BmlwMe18.js} +1 -1
- package/runtime/webapp/dist/assets/index-C30NoLsn.js +500 -0
- package/runtime/webapp/dist/assets/{index-BAGzBXQc.css → index-COFV-DUC.css} +1 -1
- package/runtime/webapp/dist/assets/{infoDiagram-27XIBGKW-Crx1iSbW.js → infoDiagram-27XIBGKW-BiMEmJW5.js} +1 -1
- package/runtime/webapp/dist/assets/{ishikawaDiagram-5VMMS53U-ClQPMEk5.js → ishikawaDiagram-5VMMS53U-CPlJXmF2.js} +1 -1
- package/runtime/webapp/dist/assets/{journeyDiagram-3NMN7TZE-DHso2Xht.js → journeyDiagram-3NMN7TZE-DJJ-qvlw.js} +1 -1
- package/runtime/webapp/dist/assets/{kanban-definition-UXKFOSKX-D6psIAhv.js → kanban-definition-UXKFOSKX-PHmavvDJ.js} +1 -1
- package/runtime/webapp/dist/assets/{layout-B6AVZ9v9.js → layout-DH5OfcVL.js} +1 -1
- package/runtime/webapp/dist/assets/{linear-CEZOUjlB.js → linear-DQek-QDQ.js} +1 -1
- package/runtime/webapp/dist/assets/{list-todo-D9ChIz0f.js → list-todo-DULblcsU.js} +1 -1
- package/runtime/webapp/dist/assets/{locate-fixed-2R48MVg_.js → locate-fixed-B3zScPI-.js} +1 -1
- package/runtime/webapp/dist/assets/{mermaid.core-DH0df9xk.js → mermaid.core-D6eHnLLU.js} +5 -5
- package/runtime/webapp/dist/assets/{mindmap-definition-YA3MSWOX-QWt8leZC.js → mindmap-definition-YA3MSWOX-D0TkZusX.js} +1 -1
- package/runtime/webapp/dist/assets/{mobileViewport-CKvpvxYc.js → mobileViewport-BhIxH-zP.js} +1 -1
- package/runtime/webapp/dist/assets/{new-session-window-CiRwM3Od.js → new-session-window-bxVA-U3Y.js} +56 -56
- package/runtime/webapp/dist/assets/page-DyPXAvyj.js +86 -0
- package/runtime/webapp/dist/assets/{pause-ddt7BLlm.js → pause-C793N3J1.js} +1 -1
- package/runtime/webapp/dist/assets/{pegDiagram-XKGWAZYB-JNBt0nDx.js → pegDiagram-XKGWAZYB-DMIjPBzH.js} +1 -1
- package/runtime/webapp/dist/assets/{pieDiagram-E7YTZNPT-g0hnDqNp.js → pieDiagram-E7YTZNPT-DctF47JZ.js} +1 -1
- package/runtime/webapp/dist/assets/{pin-BTP5lC_c.js → pin-BLVakDSL.js} +1 -1
- package/runtime/webapp/dist/assets/{quadrantDiagram-AXDQQJYC-mLZASjSm.js → quadrantDiagram-AXDQQJYC-JnwbWWwT.js} +1 -1
- package/runtime/webapp/dist/assets/{railroadDiagram-O6MQD6OU-CAXNAZhB.js → railroadDiagram-O6MQD6OU-DcpHMNVP.js} +1 -1
- package/runtime/webapp/dist/assets/{requirementDiagram-BXWQKSXE-BC8y1ZXE.js → requirementDiagram-BXWQKSXE-C-fRbIOI.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-ccw-CHFTy38a.js → rotate-ccw-CyZK_Om1.js} +1 -1
- package/runtime/webapp/dist/assets/{rotate-cw-CFCtRFDl.js → rotate-cw-ChAt9mcI.js} +1 -1
- package/runtime/webapp/dist/assets/{sankeyDiagram-P5KCCOFB-Boi5NPjT.js → sankeyDiagram-P5KCCOFB-Sb34Y9Ep.js} +1 -1
- package/runtime/webapp/dist/assets/{send-CzCncLlt.js → send-DlrISC4K.js} +1 -1
- package/runtime/webapp/dist/assets/{sequenceDiagram-WJ2MYXX4-D4ccoVEB.js → sequenceDiagram-WJ2MYXX4-BeHoOpkJ.js} +1 -1
- package/runtime/webapp/dist/assets/{session-dashboard-C0KfSCDl.js → session-dashboard-D1JY1ka0.js} +1 -1
- package/runtime/webapp/dist/assets/{session-tree-CTzXmV6R.js → session-tree-Q-jABJNB.js} +1 -1
- package/runtime/webapp/dist/assets/{shield-check-Da6EGdIt.js → shield-check-Bzd1i1OQ.js} +1 -1
- package/runtime/webapp/dist/assets/{sizeCapture-INFHLROL-Cd5jIVgK.js → sizeCapture-INFHLROL-DspvE2eQ.js} +1 -1
- package/runtime/webapp/dist/assets/{stateDiagram-D77RDMKH-DXlmaNwu.js → stateDiagram-D77RDMKH-oBIvmRy9.js} +1 -1
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-DXD2F0in.js +1 -0
- package/runtime/webapp/dist/assets/{swimlanes-42K2YHIH-DyhRB_e0.js → swimlanes-42K2YHIH-CAdrbVmI.js} +1 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-CXpNu-5Z.js +8 -0
- package/runtime/webapp/dist/assets/{timeline-definition-24CTP7MA-Bkfs9Mi-.js → timeline-definition-24CTP7MA-BtWjc4KI.js} +1 -1
- package/runtime/webapp/dist/assets/{trash-2-C682LDDA.js → trash-2-DwFoTvHX.js} +1 -1
- package/runtime/webapp/dist/assets/{types-CfOuS-6l.js → types-COzZsLPY.js} +1 -1
- package/runtime/webapp/dist/assets/{use-session-activity-C9Cn92Hj.js → use-session-activity-BRhj0V5U.js} +1 -1
- package/runtime/webapp/dist/assets/{vennDiagram-4TSXK5OY-APWT64sw.js → vennDiagram-4TSXK5OY-Be4H6PYr.js} +1 -1
- package/runtime/webapp/dist/assets/{wardleyDiagram-VM6X3IG4-H7xLoxwM.js → wardleyDiagram-VM6X3IG4-COVxCAu8.js} +1 -1
- package/runtime/webapp/dist/assets/{web-CT8e03DV.js → web-BdMHTzmo.js} +1 -1
- package/runtime/webapp/dist/assets/{web-DG022HwJ.js → web-Qg6ZVe1T.js} +1 -1
- package/runtime/webapp/dist/assets/{loader-circle-CAHZbD5s.js → x-CoIXF2eL.js} +2 -2
- package/runtime/webapp/dist/assets/{xychartDiagram-S5SC5T6Z-DIrxZ4UJ.js → xychartDiagram-S5SC5T6Z-J_S9eMK9.js} +1 -1
- package/runtime/webapp/dist/assets/{zoom-out-CRN76HNZ.js → zoom-out-C10hb0zX.js} +1 -1
- package/runtime/webapp/dist/index.html +2 -2
- package/runtime/.next/static/chunks/106.b2050e53421795af.js +0 -1
- package/runtime/.next/static/chunks/20.7bd5212774091396.js +0 -1
- package/runtime/.next/static/chunks/34.40a88b70750502fb.js +0 -1
- package/runtime/.next/static/chunks/753-90c7dd1ba08be9be.js +0 -1
- package/runtime/.next/static/chunks/app/web/page-f008ab6dfeab7ce7.js +0 -1
- package/runtime/webapp/dist/assets/AIHubView-CNKanNZa.js +0 -1
- package/runtime/webapp/dist/assets/AiHubPane-Coyn3P-J.js +0 -1
- package/runtime/webapp/dist/assets/App-BGIGpBp3.js +0 -68
- package/runtime/webapp/dist/assets/CalendarPage-D0oaq2_l.js +0 -1
- package/runtime/webapp/dist/assets/CollaborationCreateDialog-CE8OML-A.js +0 -1
- package/runtime/webapp/dist/assets/CollaborationDashboard-CV18iiBO.js +0 -1
- package/runtime/webapp/dist/assets/FileWorkspaceDrawer-BxFS-0sF.js +0 -1
- package/runtime/webapp/dist/assets/FlowStudioPane-CVP0Q6zR.js +0 -5
- package/runtime/webapp/dist/assets/HostProjectPicker-DUUgM2Cm.js +0 -1
- package/runtime/webapp/dist/assets/NewSessionWindow-DwJhkRJd.js +0 -1
- package/runtime/webapp/dist/assets/RemoteDesktopPage-Cqsea4X7.js +0 -1
- package/runtime/webapp/dist/assets/TodoPage-CG__S6_l.js +0 -1
- package/runtime/webapp/dist/assets/channel-D66Qxmo0.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-ZZMXUADV-BAX0-S6b.js +0 -1
- package/runtime/webapp/dist/assets/classDiagram-v2-VYDZK3BY-BAX0-S6b.js +0 -1
- package/runtime/webapp/dist/assets/index-YrEOkxAg.js +0 -500
- package/runtime/webapp/dist/assets/page-Cd9ci9uo.js +0 -86
- package/runtime/webapp/dist/assets/stateDiagram-v2-MP3YSRHH-Dh6coc1l.js +0 -1
- package/runtime/webapp/dist/assets/swimlanesDiagram-VR7AAH4N-BzriATjP.js +0 -8
- /package/runtime/.next/static/{_rMvYWpbWkNWrFkCQx3rK → XwGGZtJQeU5VoGqV-1dyI}/_buildManifest.js +0 -0
- /package/runtime/.next/static/{_rMvYWpbWkNWrFkCQx3rK → XwGGZtJQeU5VoGqV-1dyI}/_ssgManifest.js +0 -0
- /package/runtime/.next/static/chunks/{183-dbd3e343da4ba103.js → 183-5019797f0b42210b.js} +0 -0
- /package/runtime/.next/static/chunks/{3cc391f0-4ff886cecc4d6d79.js → 3cc391f0-6cd083946ece156d.js} +0 -0
- /package/runtime/.next/static/chunks/app/_not-found/{page-c0fc9b6684d4f0ca.js → page-cffe4d626dcef5fd.js} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./CalendarView-CuBzp-g8.js","./index-C30NoLsn.js","./index-COFV-DUC.css","./calendar-days-BIRmYMrW.js","./x-CoIXF2eL.js","./chevron-right-B_ITnckH.js","./locate-fixed-B3zScPI-.js","./list-todo-DULblcsU.js","./chevron-down-BUEiUZA7.js","./check-DCU8YHqr.js","./pause-C793N3J1.js","./CalendarView-BjjC_t12.css","./CollaborationDashboard-CvE5vaOh.js","./CollaborationTabBridge-Dxq4G1Uk.js","./CollaborationCreateDialog-DsXkxAd1.js","./types-COzZsLPY.js","./HostProjectPicker-CjlxN2ct.js","./file-types-Dj25tuty.js","./trash-2-DwFoTvHX.js","./client-BpqlZTm2.js","./session-tree-Q-jABJNB.js","./collaboration-CYS2Soeh.js","./collaboration-B0IRHmY_.css","./SessionDashboardBridge-7BjKdfN8.js","./CollaborationDashboard-CCXC6JuQ.css","./CollaborationPage-Cjeo60S0.js","./composer-file-routing-DHdpFYk8.js","./shield-check-Bzd1i1OQ.js","./history-DTS97eAH.js","./image-plus-BmlwMe18.js","./SessionDashboard-DXPSvNsY.js","./session-dashboard-D1JY1ka0.js","./session-dashboard-BZIyuFTU.css","./use-session-activity-BRhj0V5U.js","./SessionDashboard-CAYVDT8Z.css","./BrowserLivePanel-BwtEM-IV.js","./RemoteDesktopTabBridge-B_cCKi7K.js","./zoom-out-C10hb0zX.js","./rotate-ccw-CyZK_Om1.js","./TaskPaneTerminal-B2WKBysj.js","./TerminalPane-CxGcN85G.js","./mobileViewport-BhIxH-zP.js","./TerminalPane-6GBZ9nXN.css","./AIHubView-HV2FIroL.js","./new-session-window-bxVA-U3Y.js","./RunningSessionsIcon-Cz8_524L.js","./new-session-window-DIU2v1uh.css","./send-DlrISC4K.js","./SettingsPanel-C78O9_ho.js","./rotate-cw-ChAt9mcI.js","./pin-BLVakDSL.js","./MCPServerList-DkVUlKEJ.js","./MemoryViewer-Ywl80xth.js","./SkillManager-BdkBUxhH.js","./AgentManager-C4zPGI-Y.js","./LSPServerList-BbAS_sm-.js","./FileWorkspaceDrawer-DRluuYWn.js","./FilePreview-CyXKv1Cu.js","./FilePreview-B7Ab2X_E.css","./FileTree-DNI9VhEp.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as $e,ao as po,i as hn,r,a as Ke,j as e,k as Xt,L as bt,U as fo,l as dt,an as Ce,h as Nn,R as Vr,A as Pn,n as Ts,v as zt,ag as Ur,u as Ee,ap as hs,aq as Kr,ar as Gr,as as ho,at as go,z as mo,y as wo,o as bo,au as mr,a9 as xo,av as yo,aw as vo,ax as ko}from"./index-C30NoLsn.js";import{t as So,b as jo,d as Ss,e as Co,f as _t,g as Io,h as gs,i as wr,j as Ao,k as br,l as To,s as Eo,m as No,n as Po,o as Ro,p as Lo,q as ms,v as Do,w as Oo,x as ws,y as _o,z as xr,A as yr,B as vr,c as zo,M as Mo,D as Wo,T as $o,E as Bo,F as Ho,G as Fo,H as qo,I as Yr,L as kr,J as Vo,K as Uo,N as Ko,O as bs,Q as Go,R as Tn,U as Gt,V as Sr,W as Yo,X as Xo,u as Jo,S as Qo,C as Zo,Y as ea,Z as ta,_ as na,$ as sa,a0 as ra,a1 as ia,a2 as oa,a3 as aa}from"./new-session-window-bxVA-U3Y.js";import{c as xt,A as Xr}from"./client-BpqlZTm2.js";import{i as zn,m as Yt,c as fn,a as ca,b as Mn,S as Jr,d as Qr,u as la,r as da,e as ua,f as pa,o as fa,g as Rn,s as Ln,h as Dn,j as jr,k as ha}from"./session-tree-Q-jABJNB.js";import{T as Cr}from"./composer-file-routing-DHdpFYk8.js";import{u as gn,S as Zr,C as ga}from"./CollaborationCreateDialog-DsXkxAd1.js";import{u as ei,b as ma}from"./use-session-activity-BRhj0V5U.js";import{L as wa,D as ba,p as ti}from"./session-dashboard-D1JY1ka0.js";import{X as Mt}from"./x-CoIXF2eL.js";import{S as Wn,i as xa}from"./file-types-Dj25tuty.js";import{C as Ir}from"./chevron-down-BUEiUZA7.js";import{L as ya}from"./list-todo-DULblcsU.js";import{C as Es}from"./calendar-days-BIRmYMrW.js";import{M as va}from"./RunningSessionsIcon-Cz8_524L.js";import{A as ka,T as Sa}from"./trash-2-DwFoTvHX.js";import{R as ni}from"./rotate-cw-ChAt9mcI.js";import{E as si}from"./RemoteDesktopTabBridge-B_cCKi7K.js";import{P as ja}from"./pin-BLVakDSL.js";import{U as Ca}from"./collaboration-CYS2Soeh.js";import{C as Ia}from"./chevron-right-B_ITnckH.js";import{S as Aa,c as pn,a as Ta,r as Ar}from"./SessionDashboardBridge-7BjKdfN8.js";import{a as Ea,f as Na}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{C as Pa}from"./check-DCU8YHqr.js";import{H as Ra}from"./HostProjectPicker-CjlxN2ct.js";import{H as La}from"./history-DTS97eAH.js";/**
|
|
3
|
+
* @license lucide-react v0.468.0 - ISC
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the ISC license.
|
|
6
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/const Da=$e("BellRing",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]);/**
|
|
8
|
+
* @license lucide-react v0.468.0 - ISC
|
|
9
|
+
*
|
|
10
|
+
* This source code is licensed under the ISC license.
|
|
11
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
12
|
+
*/const Oa=$e("Bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);/**
|
|
13
|
+
* @license lucide-react v0.468.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/const _a=$e("CalendarCheck2",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 14V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h8",key:"bce9hv"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m16 20 2 2 4-4",key:"13tcca"}]]);/**
|
|
18
|
+
* @license lucide-react v0.468.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const za=$e("ClockAlert",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["path",{d:"M16 21.16a10 10 0 1 1 5-13.516",key:"cxo92l"}],["path",{d:"M20 11.5v6",key:"2ei3xq"}],["path",{d:"M20 21.5h.01",key:"1r2dzp"}]]);/**
|
|
23
|
+
* @license lucide-react v0.468.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/const Ma=$e("Columns4",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7.5 3v18",key:"w0wo6v"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M16.5 3v18",key:"10tjh1"}]]);/**
|
|
28
|
+
* @license lucide-react v0.468.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const Wa=$e("FolderTree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]);/**
|
|
33
|
+
* @license lucide-react v0.468.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const Tr=$e("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/**
|
|
38
|
+
* @license lucide-react v0.468.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const $a=$e("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
|
|
43
|
+
* @license lucide-react v0.468.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const Ba=$e("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
|
|
48
|
+
* @license lucide-react v0.468.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const Ha=$e("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
|
53
|
+
* @license lucide-react v0.468.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const Fa=$e("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
58
|
+
* @license lucide-react v0.468.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const qa=$e("MessageSquarePlus",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M9 10h6",key:"9gxzsh"}]]);/**
|
|
63
|
+
* @license lucide-react v0.468.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const Va=$e("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);function Ua(n,s){if(Object.is(n,s))return!0;if(typeof n!="object"||n===null||typeof s!="object"||s===null)return!1;if(n instanceof Map&&s instanceof Map){if(n.size!==s.size)return!1;for(const[i,c]of n)if(!Object.is(c,s.get(i)))return!1;return!0}if(n instanceof Set&&s instanceof Set){if(n.size!==s.size)return!1;for(const i of n)if(!s.has(i))return!1;return!0}const a=Object.keys(n);if(a.length!==Object.keys(s).length)return!1;for(const i of a)if(!Object.prototype.hasOwnProperty.call(s,i)||!Object.is(n[i],s[i]))return!1;return!0}const{useRef:Ka}=po;function Ga(n){const s=Ka();return a=>{const i=n(a);return Ua(s.current,i)?s.current:s.current=i}}const js="agentroam:task-pane-notification";function Ya(n){return!window.dispatchEvent(new CustomEvent(js,{cancelable:!0,detail:{sessionId:n}}))}const ri="agentroam.all-sessions.v2",Xa=20;function On(n){try{const s=n??(typeof window>"u"?void 0:window.localStorage),a=JSON.parse((s==null?void 0:s.getItem(ri))??"null");return!oi(a)||a.version!==2||!Array.isArray(a.data)||!a.data.every(ai)||typeof a.total!="number"||!Number.isSafeInteger(a.total)||a.total<a.data.length?null:{data:a.data,total:a.total}}catch{return null}}function Ja(n,s){const a=zn(n.data.slice(0,Xa),[...n.data,...n.ancestors??[]]);ii({data:a,total:n.total},s)}function ii(n,s){try{const a=s??(typeof window>"u"?void 0:window.localStorage);a==null||a.setItem(ri,JSON.stringify({version:2,...n}))}catch{}}function Qa(n,s){const a=On(s);if(!a)return;const i=new Set(n),c=a.data.filter(u=>!i.has(u.id));ii({data:c,total:Math.max(c.length,a.total-i.size)},s)}function oi(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function ai(n){return oi(n)&&typeof n.id=="string"&&hn(n.agentType)&&typeof n.title=="string"&&typeof n.cwd=="string"&&typeof n.updated=="string"&&(n.completedAt===void 0||typeof n.completedAt=="string")&&typeof n.status=="string"&&["idle","running","completed","failed"].includes(n.status)&&typeof n.canResume=="boolean"&&(n.projectId===void 0||typeof n.projectId=="string")&&(n.parentSessionId===void 0||typeof n.parentSessionId=="string")&&(n.readOnly===void 0||typeof n.readOnly=="boolean")&&(n.occupancy===void 0||typeof n.occupancy=="string"&&["available","owned-by-customer-agent","owned-externally"].includes(n.occupancy))}const ci="agentroam.task-session-catalog.v1",xs=30,Er=100;function Za(){try{const n=JSON.parse(window.localStorage.getItem(ci)??"null");return!n||!Array.isArray(n.rows)||!n.rows.every(ai)||!Number.isSafeInteger(n.count)||n.count<0||n.count>n.rows.length?null:{rows:n.rows,count:n.count}}catch{return null}}function ec({rows:n,count:s}){try{window.localStorage.setItem(ci,JSON.stringify({rows:n,count:s}))}catch{}}async function tc(n,s,a,i){const c=async(l,f)=>{i.throwIfAborted();const v=await n(l,f);if(i.throwIfAborted(),l&&(v.nextCursor===l||v.nextCursor&&!v.data.length))throw new Error("会话分页标记无效,请刷新");return v};if(a&&s.cursor)try{const l=await c(s.cursor,xs);return{rows:Yt(s.rows,fn(l)),count:s.count+l.data.length,cursor:l.nextCursor}}catch(l){if(!ca(l))throw l}const u=Math.max(xs,s.count+(a?xs:0));let h=await c(void 0,Math.min(u,Er));if(h.refreshing)return{...s,rows:Yt(s.rows,fn(h)),refreshing:!0};let m=h.data.length,p=fn(h);for(;m<u&&h.nextCursor;)h=await c(h.nextCursor,Math.min(u-m,Er)),m+=h.data.length,p=Yt(p,fn(h));return{rows:p,count:m,cursor:h.nextCursor}}function Nr(n,s){const a=s.trim().toLocaleLowerCase(),i=n.filter(c=>`${c.title} ${c.cwd} ${c.agentType}`.toLocaleLowerCase().includes(a));return zn(i,n)}function nc(n){var a,i;const s=new Map;for(const c of n){const{session:u}=c,h=s.get(u.agentType)??{folders:new Map,sessionCount:0},m=((a=u.cwd)==null?void 0:a.trim())||"未指定文件夹",p=((i=u.cwd)==null?void 0:i.trim())||"__unknown__",l=h.folders.get(p);l?l.sessions.push(c):h.folders.set(p,{key:`${u.agentType}:${p}`,label:m,sessions:[c]}),h.sessionCount+=1,s.set(u.agentType,h)}return[...s].map(([c,u])=>({key:c,label:Xr[c]??c,folders:[...u.folders.values()],sessionCount:u.sessionCount}))}function sc({session:n,currentId:s,openIds:a,onChoose:i}){return e.jsxs("button",{type:"button",className:"task-picker-item",disabled:n.id===s,onClick:()=>i(n),children:[e.jsx(Jr,{session:n,active:n.id===s}),e.jsx(Xt,{agentType:n.agentType,size:20}),e.jsxs("span",{className:"task-picker-item-text",children:[e.jsx("strong",{children:n.title||"未命名任务"}),e.jsxs("small",{children:[Xr[n.agentType]," · ",n.cwd||"未指定目录"]})]}),e.jsx("em",{children:n.id===s?"当前任务":a.has(n.id)?"已在分屏":n.status==="running"?"进行中":""})]})}function rc({currentId:n,openIds:s,knownSessions:a=[],onChoose:i,onClose:c}){const[u,h]=r.useState(""),[m,p]=r.useState("grouped"),[l,f]=r.useState(new Set),[v,E]=r.useState(new Set),C=gn(),w=ei(),k=r.useMemo(()=>new Map(w==null?void 0:w.sessions.map(D=>[D.id,D])),[w]),[y]=r.useState(()=>{var D;return Za()??{rows:((D=On())==null?void 0:D.data)??[],count:0}}),O=r.useRef(y),P=r.useRef({...y,cursor:null}),[F,Q]=r.useState(P.current),ce=r.useMemo(()=>Yt(F.rows,Nr(a,u)),[F.rows,a,u]),[te,M]=r.useState(!0),[W,z]=r.useState(null),K=r.useRef(null),le=r.useRef(!1),ne=r.useRef(null),se=r.useRef(),re=r.useRef(c);re.current=c;const Ae=async(D,G=!1)=>{if(K.current)return;window.clearTimeout(se.current);const X=new AbortController;K.current=X,le.current=G,M(!0),z(null);try{const V=await tc((R,ue)=>xt({action:"sessionCatalog",query:D,cursor:R,limit:ue,backgroundRefresh:!R},{signal:X.signal}),P.current,G,X.signal);if(X.signal.aborted)return;P.current=V,Q(V),!D&&!V.refreshing&&(O.current=V,ec(V)),V.refreshing&&(se.current=window.setTimeout(()=>{Ae(D,G)},2e3))}catch(V){if(!X.signal.aborted){Q(ue=>ue.refreshing?{...ue,refreshing:!1}:ue);const R=V instanceof Error?V.message:"无法加载任务";z(/timeout|timed out/i.test(R)?"任务列表更新超时,请重试":R)}}finally{K.current===X&&(K.current=null,M(!1))}};r.useEffect(()=>{var X;const D=document.activeElement;(X=ne.current)==null||X.focus();const G=V=>{V.key==="Escape"&&(V.preventDefault(),V.stopPropagation(),re.current())};return document.addEventListener("keydown",G,!0),()=>{document.removeEventListener("keydown",G,!0),D!=null&&D.isConnected&&D.focus()}},[]),r.useEffect(()=>{const D=u.trim(),G=O.current;P.current={rows:Nr(G.rows,D),count:D?0:G.count,cursor:null},Q(P.current),M(!0),z(null);const X=window.setTimeout(()=>{Ae(D)},D?200:0);return()=>{var V;window.clearTimeout(X),window.clearTimeout(se.current),(V=K.current)==null||V.abort(),K.current=null}},[u]);const{cursor:de,refreshing:_}=F,Z=r.useMemo(()=>Mn(ce),[ce]),Se=r.useMemo(()=>nc(Z),[Z]),Te=({session:D,children:G})=>{const X=C.expandedIds.has(D.id),V=k.get(D.id),R=V&&(V.status==="running"||V.updated>=D.updated)?{...D,...V}:D;return e.jsxs("div",{children:[e.jsxs("div",{className:"task-picker-session-row",children:[e.jsx(sc,{session:R,currentId:n,openIds:s,onChoose:i}),G.length>0&&e.jsx(Zr,{title:D.title,expanded:X,onToggle:()=>C.toggle(D.id)})]}),X&&G.length>0&&e.jsx("div",{className:"task-picker-session-children",role:"group","aria-label":`${D.title}的子会话`,children:G.map(Te)})]},D.id)},ve=(D,G)=>{D(X=>{const V=new Set(X);return V.has(G)?V.delete(G):V.add(G),V})};return Ke.createPortal(e.jsx("div",{className:"task-picker-backdrop",onPointerDown:D=>{D.target===D.currentTarget&&c()},children:e.jsxs("section",{className:"task-picker",role:"dialog","aria-modal":"true","aria-label":"选择分屏任务",onKeyDown:D=>{if(D.key!=="Tab")return;const G=Array.from(D.currentTarget.querySelectorAll("button:not(:disabled), input")),X=G[0],V=G.at(-1);D.shiftKey&&document.activeElement===X?(D.preventDefault(),V==null||V.focus()):!D.shiftKey&&document.activeElement===V&&(D.preventDefault(),X==null||X.focus())},children:[e.jsxs("header",{children:[e.jsx("h2",{children:"选择任务"}),e.jsxs("div",{className:"task-picker-header-actions",children:[e.jsxs("div",{className:"task-picker-view-toggle",role:"group","aria-label":"任务排列方式",children:[e.jsxs("button",{type:"button",className:`task-picker-view-button${m==="grouped"?" is-active":""}`,"aria-pressed":m==="grouped",onClick:()=>p("grouped"),children:[e.jsx(Wa,{size:14,"aria-hidden":"true"}),"分组"]}),e.jsxs("button",{type:"button",className:`task-picker-view-button${m==="list"?" is-active":""}`,"aria-pressed":m==="list",onClick:()=>p("list"),children:[e.jsx(wa,{size:14,"aria-hidden":"true"}),"列表"]})]}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:c,"aria-label":"关闭任务选择",children:e.jsx(Mt,{size:18})})]})]}),e.jsxs("label",{className:"task-picker-search",children:[e.jsx(Wn,{size:16,"aria-hidden":"true"}),e.jsx("input",{ref:ne,value:u,onChange:D=>h(D.target.value),placeholder:"搜索任务、目录或 Agent","aria-label":"搜索分屏任务"})]}),W&&e.jsxs("div",{className:"task-picker-error",role:"alert",children:[W,e.jsx("button",{type:"button",onClick:()=>void Ae(u.trim(),le.current),children:"重试"})]}),e.jsxs("div",{className:"task-picker-list","aria-busy":!Z.length&&(te||_),children:[m==="list"?Z.map(Te):Se.map(D=>{const G=l.has(D.key);return e.jsxs("section",{className:`task-picker-agent-group${G?" is-collapsed":""}`,"aria-label":`${D.label}任务`,children:[e.jsxs("button",{type:"button",className:"task-picker-group-header","aria-expanded":!G,onClick:()=>ve(f,D.key),children:[e.jsx(Ir,{size:15,className:`task-picker-chevron${G?" is-collapsed":""}`,"aria-hidden":"true"}),e.jsx(Xt,{agentType:D.key,size:18}),e.jsx("strong",{children:D.label}),e.jsxs("small",{children:[D.sessionCount," 个任务"]})]}),!G&&e.jsx("div",{className:"task-picker-agent-content",children:D.folders.map(X=>{const V=v.has(X.key);return e.jsxs("section",{className:`task-picker-folder-group${V?" is-collapsed":""}`,"aria-label":`${D.label} · ${X.label}`,children:[e.jsxs("button",{type:"button",className:"task-picker-folder-header","aria-expanded":!V,onClick:()=>ve(E,X.key),children:[e.jsx(Ir,{size:14,className:`task-picker-chevron${V?" is-collapsed":""}`,"aria-hidden":"true"}),e.jsx(xa,{size:15,"aria-hidden":"true"}),e.jsx("span",{title:X.label,children:X.label}),e.jsx("small",{children:X.sessions.length})]}),!V&&e.jsx("div",{className:"task-picker-folder-items",children:X.sessions.map(Te)})]},X.key)})})]},D.key)}),!te&&!_&&!Z.length&&!W&&e.jsx("p",{className:"task-picker-empty",children:"没有找到任务,试试其他关键词"}),(te||_)&&e.jsxs("p",{className:"task-picker-empty",role:"status",children:[e.jsx(bt,{size:16,className:"task-split-spinner"}),Z.length?"显示已有任务,正在后台更新…":"正在加载任务…"]}),de&&!_&&e.jsx("button",{className:"task-picker-more",type:"button",disabled:te,onClick:()=>void Ae(u.trim(),!0),children:"加载更多任务"})]})]})}),document.body)}function ic({node:n,renderPane:s,onResize:a,onSwap:i,maximizedPaneId:c}){const u=r.useRef(null),[h,m]=r.useState({width:0,height:0}),p=r.useRef(null),l=r.useRef(null),[f,v]=r.useState(null),E=So(n,h.width,h.height);r.useLayoutEffect(()=>{const w=u.current;if(!w)return;const k=()=>m(O=>O.width===w.clientWidth&&O.height===w.clientHeight?O:{width:w.clientWidth,height:w.clientHeight});k();const y=new ResizeObserver(k);return y.observe(w),window.addEventListener("resize",k),()=>{y.disconnect(),window.removeEventListener("resize",k)}},[]);const C=(w,k)=>{const y=l.current;!y||y.pointerId!==w.pointerId||(l.current=null,v(null),w.currentTarget.hasPointerCapture(w.pointerId)&&w.currentTarget.releasePointerCapture(w.pointerId),k&&y.moved&&y.target&&(i==null||i(y.source,y.target)))};return e.jsxs("div",{ref:u,className:`task-split-layout${f?" is-reordering":""}`,onKeyDown:w=>{if(w.key!=="Escape"||!l.current)return;const k=l.current;l.current=null,v(null),w.stopPropagation(),k.element.hasPointerCapture(k.pointerId)&&k.element.releasePointerCapture(k.pointerId)},children:[E.panes.map(({paneId:w,rect:k})=>e.jsxs("div",{"data-task-slot":w,className:`task-split-pane${(f==null?void 0:f.source)===w?" is-moving":""}${(f==null?void 0:f.target)===w?" is-drop-target":""}`,style:c?{left:0,top:0,width:"100%",height:"100%",display:c===w?"flex":"none"}:{left:k.x,top:k.y,width:k.width,height:k.height},onPointerDownCapture:y=>{const O=y.target;y.button!==0||!i||c||E.panes.length<2||!O.closest(".chat-top-bar")||O.closest("button, input, textarea, select, a, [role='button'], [contenteditable='true']")||(y.preventDefault(),l.current={source:w,target:null,pointerId:y.pointerId,x:y.clientX,y:y.clientY,moved:!1,element:y.currentTarget},y.currentTarget.setPointerCapture(y.pointerId))},onPointerMove:y=>{var ce,te;const O=l.current,P=(ce=u.current)==null?void 0:ce.getBoundingClientRect();if(!O||O.pointerId!==y.pointerId||!P||!O.moved&&Math.hypot(y.clientX-O.x,y.clientY-O.y)<6)return;O.moved=!0;const F=y.clientX-P.left,Q=y.clientY-P.top;O.target=((te=E.panes.find(M=>M.paneId!==O.source&&F>=M.rect.x&&F<M.rect.x+M.rect.width&&Q>=M.rect.y&&Q<M.rect.y+M.rect.height))==null?void 0:te.paneId)??null,v(M=>(M==null?void 0:M.source)===O.source&&M.target===O.target?M:{source:O.source,target:O.target})},onPointerUp:y=>C(y,!0),onPointerCancel:y=>C(y,!1),onLostPointerCapture:y=>C(y,!1),children:[s(w),(f==null?void 0:f.target)===w&&e.jsx("span",{className:"task-pane-swap-hint",role:"status",children:"松开交换位置"})]},w)),E.separators.map(w=>e.jsx("div",{className:`task-split-separator task-split-separator--${w.axis}`,style:{left:w.rect.x,top:w.rect.y,width:w.rect.width,height:w.rect.height,display:c?"none":void 0},role:"separator",tabIndex:0,"aria-label":w.axis==="columns"?"调整左右任务宽度":"调整上下任务高度","aria-orientation":w.axis==="columns"?"vertical":"horizontal","aria-valuemin":10,"aria-valuemax":90,"aria-valuenow":Math.round(w.ratio*100),onPointerDown:k=>{if(k.button!==0)return;k.preventDefault();const y=w.axis==="columns";p.current={id:w.id,coordinate:y?k.clientX:k.clientY,ratio:w.ratio,extent:w.extent,columns:y},k.currentTarget.setPointerCapture(k.pointerId)},onPointerMove:k=>{const y=p.current;y&&a(y.id,jo(y.ratio,(y.columns?k.clientX:k.clientY)-y.coordinate,y.extent))},onPointerUp:k=>{p.current=null,k.currentTarget.hasPointerCapture(k.pointerId)&&k.currentTarget.releasePointerCapture(k.pointerId)},onPointerCancel:()=>{p.current=null},onLostPointerCapture:()=>{p.current=null},onDoubleClick:()=>a(w.id,.5),onKeyDown:k=>{const y=w.axis==="columns"?["ArrowLeft","ArrowRight"]:["ArrowUp","ArrowDown"];k.key===y[0]||k.key===y[1]?(k.preventDefault(),a(w.id,w.ratio+(k.key===y[0]?-.05:.05))):(k.key==="Home"||k.key==="End")&&(k.preventDefault(),a(w.id,k.key==="Home"?.1:.9))}},w.id))]})}const oc={"remote-desktop":va,groups:fo,dashboard:$a,calendar:Es,terminal:Co};function Pr({onTask:n,onDraft:s,onSurface:a}){return e.jsxs("div",{className:"task-pane-choices",children:[e.jsxs("button",{type:"button",onClick:n,children:[e.jsx(ya,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"选择任务"})]}),e.jsxs("button",{type:"button",onClick:s,children:[e.jsx(qa,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:"新建会话"})]}),Object.keys(Ss).map(i=>{const c=oc[i];return e.jsxs("button",{type:"button",onClick:()=>a(i),children:[e.jsx(c,{size:17,"aria-hidden":"true"}),e.jsx("span",{children:Ss[i]})]},i)})]})}const ac=r.lazy(()=>Ce(()=>import("./CalendarView-CuBzp-g8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url)),cc=r.lazy(()=>Ce(()=>import("./CollaborationDashboard-CvE5vaOh.js"),__vite__mapDeps([12,1,2,13,14,15,16,17,4,18,5,19,20,21,22,8,23,24]),import.meta.url)),lc=r.lazy(()=>Ce(()=>import("./CollaborationPage-Cjeo60S0.js"),__vite__mapDeps([25,1,2,26,4,23,27,19,21,22,15,13,28,29,9]),import.meta.url)),dc=r.lazy(()=>Ce(()=>import("./SessionDashboard-DXPSvNsY.js"),__vite__mapDeps([30,1,2,23,31,32,20,19,33,21,22,4,8,27,10,34]),import.meta.url)),uc=r.lazy(()=>Ce(()=>Promise.resolve().then(()=>Mc),void 0,import.meta.url)),pc=r.lazy(()=>Ce(()=>import("./BrowserLivePanel-BwtEM-IV.js"),__vite__mapDeps([35,1,2,8,36,37,38,4]),import.meta.url)),fc=r.lazy(()=>Ce(()=>import("./TaskPaneTerminal-B2WKBysj.js"),__vite__mapDeps([39,1,2,40,41,36,42]),import.meta.url)),hc=async(n,s)=>{var a;if(!((a=window.agentApi)!=null&&a.calendarOverview))throw new Error("当前服务不支持日历,请更新共享服务。");return window.agentApi.calendarOverview({from:n,to:s})};function gc({kind:n,paneId:s,focused:a,cwd:i,onOpenSession:c,onNewSession:u,onChangeContent:h,onSelectSurface:m,onViewAgent:p,active:l=!0}){var E;const[f,v]=r.useState(null);return r.useEffect(()=>{v(null)},[n]),e.jsxs("div",{className:"task-pane-surface","data-pane-surface":n,children:[f&&e.jsxs("nav",{className:"task-pane-group-navigation","aria-label":"群聊导航",children:[e.jsxs("button",{type:"button",onClick:()=>v(null),children:[e.jsx(ka,{size:14,"aria-hidden":"true"}),n==="dashboard"?"返回 Dashboard":"返回群聊列表"]}),e.jsx("span",{title:f.title,children:f.title})]}),e.jsx("div",{className:"task-pane-surface-body",children:e.jsx(r.Suspense,{fallback:e.jsx(_t,{label:"正在打开面板"}),children:f?e.jsx(lc,{groupId:f.id,initialDiscussionId:f.discussionId},`${f.id}:${f.discussionId??""}`):n==="calendar"?e.jsx(ac,{loadOverview:hc}):n==="terminal"?e.jsx(fc,{paneId:s,active:l,focused:a}):n==="remote-desktop"&&dt()?e.jsx(pc,{open:!0,active:l,embedded:!0,onClose:h}):n==="remote-desktop"?e.jsx("div",{className:"task-pane-remote-desktop",children:typeof window<"u"&&typeof((E=window.agentApi)==null?void 0:E.desktopLiveGetStatus)=="function"?e.jsx(uc,{}):e.jsxs("div",{className:"task-pane-surface-unavailable",children:[e.jsx("p",{children:"当前客户端不支持远程桌面。"}),e.jsx("button",{type:"button",onClick:h,children:"选择其他内容"})]})}):n==="groups"?e.jsx(cc,{cwd:i,onOpen:C=>v({id:C.id,title:C.name}),onViewDashboard:()=>m("dashboard")}):e.jsx(dc,{onOpenGroup:C=>v({id:C.group.id,title:C.group.name,discussionId:C.discussionId}),onOpenSession:c,onNewSession:u,onViewAgent:p,onViewGroups:()=>m("groups")})})})]})}function li(n){try{const s=new URL(n);return s.protocol==="http:"||s.protocol==="https:"?s.toString():null}catch{return null}}function mc(n,s){const a="allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox",i=li(n);return i&&s&&s!=="null"&&new URL(i).origin!==s?`${a} allow-same-origin`:a}function wc({paneId:n,url:s,visible:a=!0,onFocus:i}){const c=li(s),u=mc(s,typeof window>"u"?void 0:window.location.origin),[h,m]=r.useState(0),[p,l]=r.useState("loading");r.useEffect(()=>{l("loading");const v=window.setTimeout(()=>l(E=>E==="loading"?"waiting":E),15e3);return()=>window.clearTimeout(v)},[s,h]);const f=()=>m(v=>v+1);return e.jsxs("div",{className:"task-pane-web-page task-pane-web-page--browser","aria-label":"网页","aria-hidden":!a,style:{visibility:a?void 0:"hidden"},onFocusCapture:i,onPointerDownCapture:i,children:[e.jsxs("div",{className:"task-pane-web-address",children:[e.jsx("span",{title:s,children:s}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"刷新网页",title:"刷新网页",disabled:!c,onClick:f,children:e.jsx(ni,{size:14})}),c&&e.jsx("a",{className:"ui-icon-button",href:c,target:"_blank",rel:"noopener noreferrer","aria-label":"在新标签页打开",title:"在新标签页打开",children:e.jsx(si,{size:14})})]}),e.jsx("div",{className:"task-pane-web-embedding-note",children:"若网站限制内嵌或页面无法登录,请在新标签页打开。"}),e.jsxs("div",{className:"task-pane-web-content","aria-busy":!!(c&&p==="loading"),children:[c&&e.jsx("iframe",{className:"task-pane-web-frame",src:c,title:`网页:${s}`,sandbox:u,referrerPolicy:"no-referrer",onLoad:()=>l("loaded"),onError:()=>l("error")},`${n}:${s}:${h}`),(!c||p==="error")&&e.jsxs("div",{className:"task-pane-web-status",role:"alert",children:[e.jsx("span",{children:c?"网页未能载入,请重试或在新标签页打开。":"只能预览 HTTP 或 HTTPS 网页。"}),c&&e.jsx("button",{type:"button",onClick:f,children:"重试"})]}),c&&p==="loading"&&e.jsxs("div",{className:"task-pane-web-status task-pane-web-status--loading",role:"status",children:[e.jsx(bt,{className:"task-split-spinner",size:20}),e.jsx("span",{children:"正在载入网页…"})]}),c&&p==="waiting"&&e.jsxs("div",{className:"task-pane-web-waiting",role:"status",children:[e.jsx("span",{children:"网页仍在载入,可继续等待或重试。"}),e.jsx("button",{type:"button",onClick:f,children:"重试"})]})]})]})}const bc='dialog[open], [aria-modal="true"], [data-task-page-overlay], .collab-desktop-overlay, .appearance-panel, .header-action-menu-panel, .composer-workspace-picker-menu--portal, .composer-agent-picker-menu, .composer-model-menu';function xc({paneId:n,url:s,visible:a=!0,onFocus:i}){const c=typeof window>"u"?void 0:window.agentApi,u=typeof(c==null?void 0:c.taskPageOpen)=="function",h=r.useRef(null),m=r.useRef(i);m.current=i;const[p,l]=r.useState("loading"),f=r.useRef({visible:a,state:p});f.current={visible:a,state:p};const v=r.useRef(""),E=r.useRef(()=>{}),C=r.useCallback(async()=>{if(!u||!c){l("error");return}l("loading");const w=await c.taskPageOpen(n,s).catch(()=>({ok:!1}));l(w.ok?"ready":"error")},[c,u,n,s]);return r.useEffect(()=>{if(!u||!c){l("error");return}const w=c.onHubEvent(k=>{var y;k.siteId===`task-pane-${n}`&&(k.type==="focused"&&((y=m.current)==null||y.call(m)),k.type==="loading"&&l("loading"),k.type==="loaded"&&l("ready"),k.type==="load-failed"&&l("error"))});return()=>{w(),c.taskPageClose(n)}},[c,u,n]),r.useEffect(()=>{C()},[C]),r.useEffect(()=>{if(!u||!c||!h.current)return;const w=h.current;let k=0;const y=()=>{const Q=w.getBoundingClientRect(),ce=Math.max(0,Q.left),te=Math.max(0,Q.top),M=Math.max(0,Math.min(window.innerWidth,Q.right)-ce),W=Math.max(0,Math.min(window.innerHeight,Q.bottom)-te),z=Array.from(document.querySelectorAll(bc)).some(ne=>{if(!ne.getClientRects().length||getComputedStyle(ne).visibility==="hidden")return!1;if(ne.matches('dialog[open], [aria-modal="true"]'))return!0;const se=ne.getBoundingClientRect();return se.left<ce+M&&se.right>ce&&se.top<te+W&&se.bottom>te}),K=f.current.visible&&f.current.state==="ready"&&w.getClientRects().length>0&&getComputedStyle(w).visibility==="visible"&&!w.closest('[inert], [aria-hidden="true"]')&&M>0&&W>0&&!z?{x:ce,y:te,width:M,height:W}:null,le=JSON.stringify(K);v.current!==le&&(v.current=le,c.taskPageSetBounds(n,K))},O=()=>{cancelAnimationFrame(k),k=requestAnimationFrame(y)};E.current=O;const P=new ResizeObserver(O);P.observe(w);const F=new MutationObserver(O);return F.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class","open","aria-hidden","hidden","inert"]}),window.addEventListener("resize",O),window.addEventListener("scroll",O,!0),O(),()=>{P.disconnect(),F.disconnect(),cancelAnimationFrame(k),window.removeEventListener("resize",O),window.removeEventListener("scroll",O,!0),E.current=()=>{},v.current="",c.taskPageSetBounds(n,null)}},[c,u,n]),r.useEffect(()=>{E.current()},[p,a]),e.jsxs("div",{className:"task-pane-web-page","aria-label":"网页","aria-busy":p==="loading",children:[e.jsxs("div",{className:"task-pane-web-address",children:[e.jsx("span",{title:s,children:s}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"刷新网页",title:"刷新网页",onClick:()=>{if(p==="error"){C();return}c==null||c.taskPageReload(n)},children:e.jsx(ni,{size:14})}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"在浏览器中打开",title:"在浏览器中打开",onClick:()=>{c==null||c.openExternal(s)},children:e.jsx(si,{size:14})})]}),e.jsx("div",{ref:h,className:"task-pane-web-content",children:p!=="ready"&&e.jsxs("div",{className:"task-pane-web-status",role:p==="error"?"alert":"status",children:[p==="loading"?e.jsx(bt,{className:"task-split-spinner",size:20}):null,e.jsx("span",{children:p==="loading"?"正在打开网页…":u?"无法打开网页":"请重启桌面端以启用内嵌网页"}),p==="error"&&u&&e.jsx("button",{type:"button",onClick:()=>{C()},children:"重试"})]})})]})}function yc(n){return dt()?e.jsx(wc,{...n}):e.jsx(xc,{...n})}function vc({enabled:n,children:s,onFocusSession:a,onNavigateSession:i,onSessionCreated:c,onOpenCalendar:u,onSplitChange:h}){var _e,et,ut,$t;const[m,p]=r.useState(!1),[l,f]=r.useState(null),[v,E]=r.useState(null),[C,w]=r.useState(null),[k,y]=r.useState(null),O=r.useRef(null),[P,F]=r.useState(!1),[Q,ce]=r.useState(null),[te,M]=r.useState({}),W=r.useRef(new Map),z=r.useRef(l);z.current=l;const K=r.useRef(m);K.current=m;const le=r.useRef(null),ne=r.useRef(0),se=r.useRef(!1),re=r.useRef(new Map),Ae=r.useRef(0),de=r.useRef({onFocusSession:a,onNavigateSession:i,onSessionCreated:c});de.current={onFocusSession:a,onNavigateSession:i,onSessionCreated:c};const _=r.useRef(s.props.selectedSessionId),Z=r.useRef(s.props.focusComposerNonce),Se=r.useRef(s.props);Se.current=s.props,r.useEffect(()=>{h==null||h(n&&m)},[n,m,h]);const Te=g=>{if(le.current)try{g?localStorage.setItem(le.current,Ro(g)):localStorage.removeItem(le.current)}catch{}};r.useEffect(()=>{if(!n||!m||!l)return;const g=window.setTimeout(()=>Te(l),180);return()=>window.clearTimeout(g)},[n,m,l]),r.useEffect(()=>()=>{ne.current++,re.current.clear()},[]),r.useEffect(()=>{n||(Te(z.current),ne.current++,re.current.clear(),se.current=!1,K.current=!1,p(!1),F(!1),M({}),w(null),y(null),E(null))},[n]),r.useEffect(()=>{if(!k)return;const g=S=>{if(S.key==="Escape"){S.preventDefault(),y(null);return}if(S.key!=="Tab")return;const j=Array.from(document.querySelectorAll(".task-content-picker button:not(:disabled)")),A=j[0],T=j[j.length-1];S.shiftKey&&document.activeElement===A?(S.preventDefault(),T==null||T.focus()):!S.shiftKey&&document.activeElement===T&&(S.preventDefault(),A==null||A.focus())};return document.addEventListener("keydown",g),()=>{var S;document.removeEventListener("keydown",g),(S=O.current)!=null&&S.isConnected&&O.current.focus({preventScroll:!0})}},[k]),r.useEffect(()=>{if(!n||!m)return;const g=S=>{var T,$;if(S.defaultPrevented||se.current||!K.current||!z.current||!dt()&&!((T=window.agentApi)!=null&&T.taskPageOpen))return;const j=($=S.detail)==null?void 0:$.url;if(typeof j!="string")return;const A=Lo(z.current,j);A&&(S.preventDefault(),re.current.delete(A.activePaneId),W.current.delete(A.activePaneId),M(B=>({...B,[A.activePaneId]:!1})),z.current=A,f(A),E(null))};return window.addEventListener(Cr,g),()=>window.removeEventListener(Cr,g)},[n,m]);const ve=r.useCallback(g=>{const S=z.current,j=S==null?void 0:S.panes.find(T=>T.id===g);if(!S||!j||S.activePaneId===g)return;const A={...S,activePaneId:g};z.current=A,f(A),E(T=>T?g:null),j.session&&(_.current=j.session.id,de.current.onFocusSession(j.session))},[]),D=(g,S,j)=>{const A=z.current;if(!A||!A.panes.some(B=>B.id===g))return;const T=A.panes.find(B=>{var ae;return((ae=B.session)==null?void 0:ae.id)===S.id&&B.id!==g});if(T){ve(T.id);return}const $=Ho(A,g,S,j);z.current=$,f($),A.activePaneId===g&&(_.current=S.id,de.current.onFocusSession(S))},G=async(g,S,j)=>{var T;if(!K.current||se.current)return;const A=++Ae.current;if(re.current.set(g,A),j){M($=>({...$,[g]:!1})),D(g,j);return}M($=>({...$,[g]:!0})),ce(null);try{const $=await ms(S);return re.current.get(g)!==A||!K.current||!$.session||!((T=z.current)!=null&&T.panes.some(B=>B.id===g))?void 0:(D(g,$.session,$.initialHistory),$.session)}catch($){K.current&&re.current.get(g)===A&&ce($ instanceof Error?$.message:"无法更换任务")}finally{re.current.get(g)===A&&M($=>({...$,[g]:!1}))}};r.useEffect(()=>{if(!n||!m)return;const g=S=>{var B;const j=(B=S.detail)==null?void 0:B.sessionId,A=z.current;if(S.defaultPrevented||!j||!A||se.current||!K.current)return;S.preventDefault();const T=A.activePaneId,$=++Ae.current;re.current.set(T,$),M(ae=>({...ae,[T]:!0})),ce(null),ms({id:j}).then(ae=>{if(!K.current||re.current.get(T)!==$||!ae.session||!z.current)return;const ye=Do(z.current,T,ae.session,ae.initialHistory);z.current=ye,f(ye),ye.activePaneId===T&&(_.current=ae.session.id,de.current.onFocusSession(ae.session))}).catch(ae=>{K.current&&re.current.get(T)===$&&ce(ae instanceof Error?ae.message:"无法打开通知会话")}).finally(()=>{re.current.get(T)===$&&M(ae=>({...ae,[T]:!1}))})};return window.addEventListener(js,g),()=>window.removeEventListener(js,g)},[n,m]);const X=async(g=!1)=>{var j,A,T,$;const S=++ne.current;se.current=!0,w(null),y(null),re.current.clear(),M({}),K.current=!0,p(!0),F(!0),ce(null),E(null),_.current=Se.current.selectedSessionId;try{if(dt())le.current=`agentroam:web-task-split:v1:${window.location.origin}${window.location.pathname}`;else{const q=await window.sharedServiceApi.status(),be=((j=q.selected)==null?void 0:j.dataDir)??((A=q.selected)==null?void 0:A.instanceId);if(!be)throw new Error("请先连接 AgentRoam 服务");le.current=`agentroam:desktop-task-split:v1:${be}`}let B=g?null:z.current;if(!g&&!B)try{B=Oo(JSON.parse(localStorage.getItem(le.current)||"null"))}catch{}if(!B){const q=await xt({action:"dashboard"});if(q.discoveryError)throw new Error(q.discoveryError);const be=[...new Map(q.agents.flatMap(Ne=>Ne.sessions).filter(Ne=>Ne.status!=="completed"&&Ne.status!=="failed").map(Ne=>[Ne.id,ws(Ne)])).values()],He=Se.current.sessionSummary;!be.length&&He&&be.push(He);const Me=be.map(Ne=>({id:crypto.randomUUID(),session:Ne}));for(;Me.length<2;)Me.push({id:crypto.randomUUID(),session:null});B={panes:Me,layout:br(Me.map(Ne=>Ne.id)),activePaneId:((T=Me.find(Ne=>{var Le;return((Le=Ne.session)==null?void 0:Le.id)===(He==null?void 0:He.id)}))==null?void 0:T.id)??Me[0].id}}const ae=await Promise.allSettled(B.panes.map(async q=>q.session?{...q,...await ms(q.session)}:q));if(S!==ne.current||!K.current)return;let ye=0;const ee=ae.map((q,be)=>q.status==="fulfilled"?q.value:(ye++,B.panes[be])),ie={...B,panes:ee};z.current=ie,f(ie);const ze=($=ee.find(q=>q.id===ie.activePaneId))==null?void 0:$.session;ze&&de.current.onFocusSession(ze),ye&&ce(`${ye} 个任务暂未加载完成,可在对应格重试或更换任务`)}catch(B){S===ne.current&&K.current&&ce(B instanceof Error?B.message:"无法打开任务分屏")}finally{S===ne.current&&K.current&&(se.current=!1,F(!1))}},V=()=>{var S,j;Te(z.current),ne.current++,se.current=!1,re.current.clear(),M({}),F(!1),K.current=!1,p(!1),w(null),y(null),E(null);const g=(j=(S=z.current)==null?void 0:S.panes.find(A=>{var T;return A.id===((T=z.current)==null?void 0:T.activePaneId)}))==null?void 0:j.session;g&&de.current.onNavigateSession(g)};if(r.useEffect(()=>{if(!n||!m||P)return;const g=s.props.selectedSessionId,S=s.props.sessionSummary;if(!g||g===_.current||(S==null?void 0:S.id)!==g||!z.current)return;_.current=g;const j=z.current.panes.find(A=>{var T;return((T=A.session)==null?void 0:T.id)===g});j?ve(j.id):G(z.current.activePaneId,S,S)},[n,m,P,s.props.selectedSessionId,s.props.sessionSummary,ve]),r.useEffect(()=>{Z.current!==s.props.focusComposerNonce&&(Z.current=s.props.focusComposerNonce,m&&(Te(z.current),ne.current++,re.current.clear(),M({}),K.current=!1,p(!1),w(null),y(null)))},[s.props.focusComposerNonce,m]),!n)return s;const R=async g=>{const S=C;if(w(null),!m||S==="single"){de.current.onNavigateSession(ws(g));return}const j=z.current;if(!j||!S)return;const A=j.panes.find(B=>{var ae;return((ae=B.session)==null?void 0:ae.id)===g.id});if(A){ve(A.id);return}let T=S;if(S==="add"){const B=_o(j,ws(g),crypto.randomUUID());z.current=B.state,f(B.state),E(null),T=B.paneId}const $=await G(T,g);$&&la.getState().markViewed($.id,Date.now())},ue=g=>{var A;const S=z.current;if(!S)return;const j=Fo(S,g);if(j!==S){if(re.current.delete(g),M(T=>({...T,[g]:!1})),w(T=>T===g?null:T),y(T=>T===g?null:T),z.current=j,f(j),(!j||j.layout!==S.layout)&&(W.current.delete(g),E(T=>T===g?null:T)),!j){V();return}if(Te(j),S.activePaneId===g){const T=(A=j.panes.find($=>$.id===j.activePaneId))==null?void 0:A.session;T&&(_.current=T.id,de.current.onFocusSession(T))}}},U=s.props,Be=dt(),Ie=Be&&window.parent!==window,Y=l==null?void 0:l.panes.find(g=>g.id===l.activePaneId),rt=((_e=Y==null?void 0:Y.session)==null?void 0:_e.agentType)??((et=Y==null?void 0:Y.draft)==null?void 0:et.agentType),je=(g,S)=>f(j=>j&&vr(j,g,S)),ke=(g,S)=>{var T;if(se.current)return;if(dt()&&S&&"surface"in S&&S.surface==="remote-desktop"){const $=(T=z.current)==null?void 0:T.panes.find(B=>B.id!==g&&B.surface==="remote-desktop");if($){y(null),ve($.id);return}}re.current.delete(g),W.current.delete(g),M($=>({...$,[g]:!1}));const j=z.current;if(!j)return;const A=xr(j,g,S);z.current=A,f(A),y(null)},Re=(g,S)=>{if(se.current)return;const j=z.current,A=j==null?void 0:j.panes.find(B=>B.surface===g);if(A){ve(A.id);return}const T=j==null?void 0:j.panes.find(B=>B.id===j.activePaneId),$=T&&yr(T)?T:j==null?void 0:j.panes.find(yr);if($)ke($.id,{surface:g});else if(S)S();else if(j){const B=wr(j,crypto.randomUUID()),ae=xr(B,B.activePaneId,{surface:g});z.current=ae,f(ae),E(null)}},Oe=g=>{var T,$,B;const S=z.current;if(se.current||!S)return;const j=Se.current;re.current.delete(g),W.current.delete(g),M(ae=>({...ae,[g]:!1}));const A=vr(S,g,{agentType:((T=j.sessionSummary)==null?void 0:T.agentType)??j.activeAgentType??"customer-agent",projectId:(($=j.sessionSummary)==null?void 0:$.projectId)??j.selectedProjectId??null,cwd:((B=j.sessionSummary)==null?void 0:B.cwd)??j.workspacePath??"",workspaceSource:j.workspaceSource},!0);z.current=A,f(A),y(null)},Wt=g=>{var ae,ye;const S=l==null?void 0:l.panes.find(ee=>ee.id===g);if(!S)return null;let j=W.current.get(g);j||(j=zo(),W.current.set(g,j));const A=S.session,T=S.draft,$=S.surface?Ss[S.surface]:S.webUrl?"网页":(A==null?void 0:A.title)||(T?"新建会话":"空面板"),B=e.jsxs("div",{className:"task-pane-controls",children:[e.jsx("button",{type:"button",className:"ui-icon-button",onClick:ee=>{O.current=ee.currentTarget,y(g)},title:"切换面板内容","aria-label":"切换面板内容",children:e.jsx(Tr,{size:15})}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>E(ee=>ee===g?null:g),title:v===g?"恢复分屏":"放大此格","aria-label":v===g?"恢复分屏":"放大此格",children:v===g?e.jsx(Mo,{size:15}):e.jsx(Wo,{size:15})}),e.jsx("button",{type:"button",className:"ui-icon-button",onClick:()=>ue(g),title:(ae=S.history)!=null&&ae.length?"关闭当前内容,返回上一项":"移除此格(任务继续运行)","aria-label":(ye=S.history)!=null&&ye.length?"关闭当前内容,返回上一项":"移除此格",children:e.jsx(Mt,{size:16})})]});return e.jsxs("section",{className:`task-pane${(l==null?void 0:l.activePaneId)===g?" is-active":""}${v===g?" is-maximized":""}`,"data-task-pane":g,"data-task-session":(A==null?void 0:A.id)??"","data-pane-content":S.surface??(S.webUrl?"web":A||T?"task":"empty"),"aria-label":$,onPointerDownCapture:()=>ve(g),onFocusCapture:()=>ve(g),children:[S.surface||S.webUrl?e.jsxs("div",{className:"task-pane-feature",children:[e.jsxs("header",{className:"chat-top-bar task-pane-feature-header",children:[e.jsx("strong",{children:$}),B]}),S.surface?e.jsx(gc,{kind:S.surface,paneId:g,focused:(l==null?void 0:l.activePaneId)===g,cwd:U.workspacePath??void 0,active:!v||v===g,onOpenSession:ee=>{G(g,ee)},onNewSession:()=>Oe(g),onChangeContent:()=>y(g),onViewAgent:()=>w(g),onSelectSurface:ee=>ke(g,{surface:ee})}):e.jsx(yc,{paneId:g,url:S.webUrl,visible:!v||v===g,onFocus:()=>ve(g)})]}):A||T?e.jsx($o,{draft:T,onDraftChange:ee=>je(g,ee),children:r.cloneElement(s,{agentStore:j,desktopTaskPane:!0,desktopTaskOwnsSession:ee=>{var ze;if(!K.current)return!1;const ie=((ze=z.current)==null?void 0:ze.panes)??[];return ie.some(q=>{var be;return q.id===g&&((be=q.session)==null?void 0:be.id)===ee})||!ie.some(q=>{var be;return((be=q.session)==null?void 0:be.id)===ee})},activeAgentType:(A==null?void 0:A.agentType)??T.agentType,selectedProjectId:(A==null?void 0:A.projectId)??(T==null?void 0:T.projectId)??null,selectedSessionId:(A==null?void 0:A.id)??null,sessionSummary:A??void 0,sessionTitle:(A==null?void 0:A.title)??"新建会话",workspacePath:(A==null?void 0:A.cwd)??T.cwd,workspaceSource:void 0,initialSessionHistory:Bo(S,U.initialSessionHistory),onToggleSidebar:void 0,onReplaceTask:()=>w(g),paneControls:B,headerAppActions:void 0,onOpenTaskSplit:void 0,onSelectAgent:void 0,onSelectWorkspace:void 0,onPickWorkspaceFolder:void 0,voiceCommand:(l==null?void 0:l.activePaneId)===g?U.voiceCommand:null,focusComposerNonce:T?1:void 0,onSelectSession:(ee,ie)=>{G(g,{id:ee},ie)},onSessionCreated:(ee,ie)=>{var ze,q;G(g,{id:ee},ie),ie&&((q=(ze=de.current).onSessionCreated)==null||q.call(ze,ie))},onParallelSessionSelected:ee=>{G(g,ee,ee)}})}):e.jsxs("div",{className:"task-pane-empty",children:[e.jsx("div",{className:"task-pane-empty-controls",children:B}),e.jsx(gs,{size:24,"aria-hidden":"true"}),e.jsx("p",{children:"选择这一列要展示的内容"}),e.jsx(Pr,{onTask:()=>w(g),onDraft:()=>Oe(g),onSurface:ee=>ke(g,{surface:ee})}),e.jsx("small",{children:"消息中的网页链接也会在空面板中打开"})]}),te[g]&&e.jsxs("div",{className:"task-pane-loading",role:"status",children:[e.jsx(bt,{size:20,className:"task-split-spinner"}),"正在更换任务…"]})]},g)};return e.jsxs(e.Fragment,{children:[m?e.jsxs("div",{className:"desktop-task-workspace",children:[e.jsxs("header",{className:"task-workspace-toolbar",children:[U.onToggleSidebar&&e.jsx("button",{className:"ui-icon-button",type:"button",onClick:U.onToggleSidebar,"aria-label":"切换任务侧栏",children:e.jsx(Io,{size:17})}),e.jsxs("span",{className:"task-workspace-label",children:[e.jsx(gs,{size:16}),"任务分屏",l?e.jsx("small",{children:l.panes.length}):null]}),e.jsxs("div",{className:"task-workspace-tools",children:[u&&e.jsxs("button",{type:"button",onClick:()=>Re("calendar",u),title:"日历与待办","aria-label":"打开日历与待办",children:[e.jsx(Es,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"日历 / 待办"})]}),e.jsxs("button",{type:"button",onClick:()=>w("add"),disabled:P||!l,title:"添加任务","aria-label":"添加分屏任务",children:[e.jsx(Nn,{size:16}),e.jsx("span",{children:"添加任务"})]}),e.jsxs("button",{type:"button",onClick:()=>{E(null),f(g=>g&&wr(g,crypto.randomUUID()))},disabled:P||!l,title:"在最右侧新增一列,保留现有布局比例","aria-label":"新增一列",children:[e.jsx(gs,{size:16}),e.jsx("span",{children:"新增一列"})]}),e.jsxs("button",{type:"button",onClick:()=>{E(null),f(g=>g&&Ao(g,()=>crypto.randomUUID()))},disabled:P||!l,title:"四列布局,空位会保留给新任务","aria-label":"四列布局","aria-pressed":(l==null?void 0:l.layoutMode)==="four-columns",children:[e.jsx(Ma,{size:16}),e.jsx("span",{children:"四列"})]}),e.jsx("button",{type:"button",onClick:()=>{E(null),f(g=>g&&{...g,layoutMode:void 0,layout:br(g.panes.map(S=>S.id))})},disabled:P||!l,title:"重新等分","aria-label":"重新等分任务",children:e.jsx(Tr,{size:16})}),e.jsx("button",{type:"button",onClick:()=>{X(!0)},disabled:P,title:"重新载入进行中任务","aria-label":"重新载入进行中任务",children:e.jsx(Vr,{size:16,className:P?"task-split-spinner":void 0})}),e.jsxs("button",{type:"button",onClick:V,title:"退出任务分屏","aria-label":"退出任务分屏",children:[e.jsx(Ha,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"退出分屏"})]})]}),U.onOpenSettings&&U.onHideToBackground&&U.onToggleAppearance&&e.jsx(To,{appActions:U.headerAppActions,appearanceOpen:!!U.appearanceOpen,settingsOpen:!!U.settingsOpen,showSettings:!Be||rt==="customer-agent",onHideToBackground:U.onHideToBackground,onToggleAppearance:U.onToggleAppearance,onOpenSettings:U.onOpenSettings,onOpenSessionDashboard:Ie?void 0:()=>Re("dashboard",U.onOpenSessionDashboard),onOpenCollaborationDashboard:Ie?void 0:()=>Re("groups",U.onOpenCollaborationDashboard),onOpenDesktopLive:Ie?void 0:()=>Re("remote-desktop",U.onOpenDesktopLive),desktopLiveOpen:U.desktopLiveOpen,onToggleFiles:U.onToggleFiles,filesOpen:U.fileDrawerOpen,onOpenHub:U.onOpenHub})]}),Q&&e.jsxs("div",{className:"task-workspace-error",role:"alert",children:[e.jsx("span",{children:Q}),e.jsx("button",{type:"button",onClick:()=>{X()},children:"重试"})]}),e.jsxs("div",{className:"task-workspace-layout",children:[P&&!l?e.jsxs("div",{className:"task-workspace-loading",role:"status",children:[e.jsx(bt,{className:"task-split-spinner",size:22}),"正在载入任务分屏…"]}):l?e.jsx("div",{className:`task-workspace-tree${v?" has-maximized-task":""}`,"data-maximized-pane":v??void 0,ref:g=>{g&&(g.inert=P)},"aria-hidden":P||void 0,children:e.jsx(ic,{node:l.layout,renderPane:Wt,maximizedPaneId:v,onResize:(g,S)=>f(j=>j&&{...j,layout:Po(j.layout,g,S)}),onSwap:(g,S)=>f(j=>{if(!j)return j;const A=Eo(j.layout,g,S);if(A===j.layout)return j;const T=new Map(j.panes.map($=>[$.id,$]));return{...j,layout:A,panes:No(A).map($=>T.get($))}})})}):null,P&&l&&e.jsxs("div",{className:"task-workspace-loading task-workspace-loading--overlay",role:"status",children:[e.jsx(bt,{className:"task-split-spinner",size:22}),"正在重新载入…"]})]})]}):r.cloneElement(s,{onOpenTaskSplit:()=>{X()},onReplaceTask:()=>w("single")}),C&&e.jsx(rc,{currentId:C==="single"?U.selectedSessionId??void 0:($t=(ut=l==null?void 0:l.panes.find(g=>g.id===C))==null?void 0:ut.session)==null?void 0:$t.id,openIds:new Set(m?(l==null?void 0:l.panes.flatMap(g=>g.session?[g.session.id]:[]))??[]:[]),knownSessions:[...U.sessionSummary?[U.sessionSummary]:[],...(l==null?void 0:l.panes.flatMap(g=>g.session?[g.session]:[]))??[]].map(Qr),onChoose:g=>{R(g)},onClose:()=>w(null)}),m&&k&&Ke.createPortal(e.jsx("div",{className:"task-picker-backdrop",onClick:g=>{g.target===g.currentTarget&&y(null)},children:e.jsxs("section",{className:"task-picker task-content-picker",role:"dialog","aria-modal":"true","aria-label":"选择面板内容",onKeyDown:g=>{g.key==="Escape"&&y(null)},children:[e.jsxs("header",{children:[e.jsx("h2",{children:"选择面板内容"}),e.jsx("button",{type:"button",className:"ui-icon-button","aria-label":"关闭内容选择",autoFocus:!0,onClick:()=>y(null),children:e.jsx(Mt,{size:18})})]}),e.jsx(Pr,{onTask:()=>{w(k),y(null)},onDraft:()=>Oe(k),onSurface:g=>ke(k,{surface:g})}),e.jsx("button",{type:"button",className:"task-pane-clear",onClick:()=>ke(k,null),children:"清空此面板"})]})}),document.body)]})}function _n({session:n,deleteLabel:s="删除会话",onSelect:a,onToggleChildren:i,onPin:c,onDelete:u}){var h,m;return e.jsxs("div",{className:`sidebar-row sidebar-session-row${n.child?" sidebar-session-row--child":""}${n.active?" sidebar-row-active":""}`,children:[e.jsxs("button",{type:"button",className:"sidebar-session-button",onClick:a,"aria-pressed":n.active,title:[n.title,n.workspacePath].filter(Boolean).join(`
|
|
68
|
+
`),children:[e.jsx(Jr,{session:n,visualState:n.visualState,statusLabel:n.statusLabel,active:n.active}),e.jsx("span",{className:"sidebar-session-title",children:n.title}),n.agentType&&e.jsx("span",{className:"sidebar-session-agent",role:"img","aria-label":Pn[n.agentType],title:Pn[n.agentType],children:e.jsx(Xt,{agentType:n.agentType,size:18})}),((h=n.compatibility)==null?void 0:h.status)==="checking"&&e.jsx("span",{className:"sidebar-session-compatibility",title:`Codex ${n.compatibility.producerVersion??"未知版本"} 会话兼容性待验证,打开会话时检查`,"aria-label":"会话兼容性待验证,打开会话时检查",children:e.jsx(qo,{size:13,"aria-hidden":"true"})}),((m=n.compatibility)==null?void 0:m.status)==="incompatible"&&e.jsx("span",{className:"sidebar-session-compatibility",title:n.compatibility.reason??"Codex 版本不兼容","aria-label":"Codex 版本不兼容",children:e.jsx(Yr,{size:13,"aria-hidden":"true"})}),n.occupiedExternally&&e.jsx("span",{className:"sidebar-session-lock",title:"原客户端正在使用,只读","aria-label":"原客户端正在使用,只读",children:e.jsx(Ba,{size:13,"aria-hidden":"true"})})]}),i&&e.jsx(Zr,{title:n.title,expanded:!!n.expanded,onToggle:i}),c&&!n.child&&e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),c()},title:n.pinned?"取消置顶":"置顶会话","aria-label":`${n.pinned?"取消置顶":"置顶会话"}:${n.title}`,"aria-pressed":!!n.pinned,className:`sidebar-session-pin sidebar-row-action ui-icon-button ui-icon-button--small${n.pinned?" sidebar-row-action--accent":""}`,children:e.jsx(ja,{size:14,"aria-hidden":"true"})}),n.canDelete&&u&&e.jsx("button",{type:"button",onClick:p=>{p.stopPropagation();const l=p.currentTarget.getBoundingClientRect();u({top:l.top,left:l.left,width:l.width,height:l.height})},title:s,"aria-label":`${s}:${n.title}`,className:"sidebar-session-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",children:e.jsx(Sa,{size:14,"aria-hidden":"true"})})]})}function di({loading:n,error:s,onRefresh:a,subject:i="目录"}){const c=n?`正在加载${i}`:s?`${i}加载失败,点击重试`:`刷新${i}`;return e.jsxs("button",{type:"button",disabled:n,onClick:a,title:s&&!n?`${c}:${s}`:c,"aria-label":c,"aria-busy":n,className:"ui-icon-button sidebar-directory-refresh",children:[e.jsx(Vr,{size:17,className:n?"animate-spin":void 0,"aria-hidden":"true"}),s&&!n&&e.jsx(Yr,{size:10,className:"sidebar-directory-refresh-error","aria-hidden":"true"})]})}function kc(n){const s=Ts(),a=r.useRef(n.deletedSessionIds);a.current=n.deletedSessionIds;const i=ei(),[c]=r.useState(()=>On()),[u,h]=r.useState((c==null?void 0:c.data)??[]),[m,p]=r.useState((c==null?void 0:c.total)??0),[l,f]=r.useState(c!==null),[v,E]=r.useState(""),[C,w]=r.useState(""),k=gn(),[y,O]=r.useState(null),[P,F]=r.useState(!1),[Q,ce]=r.useState(!1),[te,M]=r.useState(null),W=r.useRef(null),z=r.useRef(""),K=r.useRef(`${n.revision}:${n.runningSessionId}`),le=r.useRef({query:"",rows:(c==null?void 0:c.data)??[],cursor:null,expanded:!1}),ne=r.useRef(null),se=r.useRef(null),re=r.useRef(new Map),Ae=r.useRef(null);n.pendingSession&&n.pendingSession.id!==Ae.current&&(Ae.current=n.pendingSession.id,re.current.set(n.pendingSession.id,Qr(n.pendingSession)),re.current.size>20&&re.current.delete(re.current.keys().next().value)),r.useEffect(()=>{const R=window.setTimeout(()=>w(v.trim()),250);return()=>window.clearTimeout(R)},[v]);const de=r.useCallback(async R=>{var Be,Ie;if(!zt()||!R&&(W.current||!le.current.cursor)||W.current&&!W.current.signal.aborted&&z.current===C)return;R&&((Be=W.current)==null||Be.abort());const ue=new AbortController;W.current=ue,z.current=C;const U=le.current;if(F(!0),M(null),R&&U.query!==C){const Y=C?null:On();le.current={query:C,rows:(Y==null?void 0:Y.data)??[],cursor:null,expanded:!1},h((Y==null?void 0:Y.data)??[]),p((Y==null?void 0:Y.total)??0),O(null),f(Y!==null)}try{let Y;if(R){const ke=ne.current;if((ke==null?void 0:ke.query)===C)Y=await ke.promise;else{const Re=xt({action:"sessionCatalog",query:C,limit:20,backgroundRefresh:!0},{signal:ue.signal}),Oe={query:C,promise:Re};ne.current=Oe;try{Y=await Re}finally{ne.current===Oe&&(ne.current=null)}}if(ue.signal.aborted)return}else Y=await da(ke=>xt({action:"sessionCatalog",query:C,limit:20,cursor:ke},{signal:ue.signal}),ue.signal,U.cursor??void 0);for(const ke of Y.data)re.current.delete(ke.id);const rt=fn(Y),je=R&&U.query===C?Y.refreshing?{rows:Yt(U.rows,rt),cursor:U.cursor??Y.nextCursor}:ua(U,Y):{rows:R?rt:Yt(U.rows,rt),cursor:Y.nextCursor};if(le.current={query:C,...je,expanded:!R||U.query===C&&U.expanded},h(je.rows),p(Y.total),O(je.cursor),f(!1),R&&ce(Y.refreshing===!0),R&&!C&&!Y.refreshing){const ke=new Set(a.current);Ja({...Y,data:Y.data.filter(Re=>!ke.has(Re.id)),ancestors:(Ie=Y.ancestors)==null?void 0:Ie.filter(Re=>!ke.has(Re.id))})}R&&U.query!==C&&se.current&&(se.current.scrollTop=0)}catch(Y){ue.signal.aborted||(ce(!1),M(Y instanceof Error?Y.message:"会话加载失败"))}finally{W.current===ue&&(W.current=null,F(!1))}},[C]);r.useEffect(()=>{if(!s)return;const R=`${n.revision}:${n.runningSessionId}`,ue=K.current!==R;K.current=R,(ue||le.current.query!==C||!W.current)&&de(!0);const U=()=>{zt()&&!W.current&&de(!0)},Be=window.setInterval(U,15e3);return window.addEventListener("focus",U),()=>{var Ie;(Ie=W.current)==null||Ie.abort(),ne.current=null,window.clearInterval(Be),window.removeEventListener("focus",U)}},[s,de,C,n.revision,n.runningSessionId]),r.useEffect(()=>{if(!s||!Q)return;const R=window.setInterval(()=>{de(!0)},2e3);return()=>window.clearInterval(R)},[s,Q,de]),r.useEffect(()=>{const R=se.current;s&&!P&&!te&&y&&R&&R.scrollTop>0&&R.scrollHeight-R.scrollTop-R.clientHeight<120&&de(!1)},[s,te,de,P,y]);const _=[...n.needsInput,...n.runningSessionId?[n.runningSessionId]:[]],Z=ma(pa(u,[...re.current.values()],C),i,C),Se=fa(Z,n.pinnedIds,_),Te=v.trim().toLocaleLowerCase(),ve=r.useMemo(()=>new Set(n.deletedSessionIds),[n.deletedSessionIds]),D=Se.filter(R=>!ve.has(R.id)),G=Mn(D),X=r.useMemo(()=>new Set(n.pinnedIds),[n.pinnedIds]),V=({session:R,children:ue})=>{const U=n.needsInput.includes(R.id)?"needs-input":n.runningSessionId===R.id?"running":R.status==="failed"?"error":R.status==="completed"?"idle":R.status,Be=Dn(U),Ie=!!R.parentSessionId,Y=k.expandedIds.has(R.id);return e.jsxs("div",{className:"sidebar-session-tree",children:[e.jsx(_n,{session:{id:R.id,title:R.title,agentType:R.agentType,workspacePath:R.cwd,visualState:Be,statusLabel:Rn[Be],completedAt:Ln(R),active:n.selectedSessionId===R.id,pinned:X.has(R.id),child:Ie,expanded:Y,occupiedExternally:R.agentType!=="codex"&&R.occupancy==="owned-externally",canDelete:U!=="running"&&U!=="needs-input"},onSelect:()=>n.onSelect(R),onPin:Ie?void 0:()=>n.onPin(R.id),onToggleChildren:ue.length?()=>k.toggle(R.id):void 0,deleteLabel:Ie?"删除子会话":void 0,onDelete:rt=>n.onDelete(R,rt)}),Y&&ue.length>0&&e.jsx("div",{className:"all-sessions-children",role:"group","aria-label":`${R.title}的子会话`,children:ue.map(V)})]},R.id)};return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"sidebar-search-field all-sessions-search",children:[e.jsx(Wn,{size:15,"aria-hidden":"true"}),e.jsx("input",{"aria-label":"搜索所有 Agent 的会话",placeholder:"搜索会话或目录",value:v,onChange:R=>E(R.target.value)})]}),e.jsxs("div",{className:"sidebar-project-toolbar",children:[e.jsxs("div",{className:"sidebar-project-heading",children:[e.jsx("span",{className:"sidebar-project-title",children:"所有会话"}),e.jsx("span",{className:"sidebar-project-count",children:C?m:Math.max(m,Z.length)})]}),e.jsxs("div",{className:"sidebar-project-actions",children:[e.jsx("span",{className:"all-sessions-sort-label",children:"进行中优先"}),e.jsx(di,{loading:P,error:te,subject:"所有会话",onRefresh:()=>void de(!0)})]})]}),e.jsxs("div",{ref:se,className:"app-sidebar-scroll all-sessions-list","aria-label":"所有 Agent 会话","aria-busy":(P||Q)&&!l&&!G.length,onScroll:R=>{const ue=R.currentTarget;ue.scrollTop>0&&ue.scrollHeight-ue.scrollTop-ue.clientHeight<120&&de(!1)},children:[te&&e.jsxs("div",{role:"alert",className:"sidebar-load-error",children:[e.jsx("span",{children:te}),e.jsx("button",{onClick:()=>void de(!0),children:"重试"})]}),(P||Q)&&!G.length&&!l&&e.jsx("p",{className:"all-sessions-empty",role:"status",children:"正在加载所有会话…"}),(!P||l)&&!Q&&!te&&!G.length&&e.jsx("p",{className:"all-sessions-empty",children:Te?"没有匹配的会话":"暂无会话,开始一个新任务吧"}),G.map(V),y&&e.jsx("button",{className:"all-sessions-more",disabled:P,onClick:()=>void de(!1),children:P?"正在加载…":"加载更早的会话"}),Q&&G.length>0?e.jsx("p",{className:"sidebar-cache-state",role:"status",children:"正在后台同步会话…"}):l&&e.jsx("p",{className:"sidebar-cache-state",role:"status",children:P?"显示缓存,正在后台更新…":"当前显示缓存"})]})]})}function Sc({cursor:n,expanded:s,loading:a,error:i,nestedScroll:c,projectName:u,onLoadMore:h}){const m=r.useRef(null),p=r.useRef(null),l=r.useRef(h);if(l.current=h,r.useEffect(()=>{const v=m.current;if(!v||!n||!s||a||i||typeof IntersectionObserver>"u")return;const E=v.closest(c?".sidebar-project-sessions":".app-sidebar-scroll");if(!E)return;const C=new IntersectionObserver(w=>{!w.some(k=>k.isIntersecting)||p.current===n||(p.current=n,l.current())},{root:E,rootMargin:"0px 0px 80px 0px"});return C.observe(v),()=>C.disconnect()},[n,s,a,i,c]),!n)return null;const f=a?"正在加载历史会话...":i?"重试加载历史会话":"加载更早的会话";return e.jsxs("button",{ref:m,type:"button",className:"sidebar-session-load-more","aria-label":`${u}:${f}`,"aria-busy":a,disabled:a,title:i,onClick:()=>{p.current=n,h()},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,flexShrink:0,minHeight:36,padding:"6px 10px",border:0,background:"transparent",color:i?"var(--danger)":"var(--text-muted)",fontSize:11,cursor:a?"default":"pointer"},children:[a&&e.jsx(bt,{size:12,className:"animate-spin","aria-hidden":"true"}),f]})}function jc({refreshKey:n,onOpen:s}){const[a,i]=r.useState([]),c=r.useCallback(()=>{xt({action:"groups"}).then(i).catch(()=>{})},[]);return r.useEffect(()=>{c()},[c,n]),e.jsx(e.Fragment,{children:a.length>0&&e.jsxs("div",{className:"collab-group-list","aria-label":"协作群",children:[e.jsx("span",{className:"collab-eyebrow",children:"协作群"}),a.map(u=>e.jsxs("button",{title:u.name,onClick:()=>s(u),children:[e.jsx(Ca,{size:15}),e.jsx("span",{children:u.name}),e.jsx(Ia,{size:14})]},u.id))]})})}function Cc({onOpen:n}){var k,y,O;const s=Ts(),[a,i]=r.useState([]),[c,u]=r.useState(()=>new Set),h=a.length,m=a.some(P=>!c.has(P)),[p,l]=r.useState(""),[f,v]=r.useState(null),E=r.useRef(async()=>{}),C=r.useRef(new Set);r.useEffect(()=>{if(!s)return;let P=!0,F=!1;try{C.current=new Set(JSON.parse(localStorage.getItem("agentroam:supervision-notifications")??"[]"))}catch{}const Q=async()=>{if(!(F||!zt())){F=!0;try{const te=await xt({action:"supervisionAlerts"});if(!P)return;i(te.filter(W=>W.incident.status==="waiting").map(W=>W.incident.id)),v(W=>W?te.find(z=>z.incident.id===W.incident.id&&z.incident.status==="waiting")??null:null);const M=te.filter(W=>!C.current.has(`${W.incident.id}:${W.incident.status}`));if(M.length){const W=M.at(-1);l(`${W.groupName} · ${W.incident.status==="waiting"?"需要你决策":W.incident.kind==="handoff"?"交接已衔接":W.incident.kind==="delivery"?"交付已确认":"异常已恢复"}`);const z=M.find(K=>K.incident.status==="waiting"&&K.target);z&&v(K=>K??z);for(const K of M)C.current.add(`${K.incident.id}:${K.incident.status}`);C.current=new Set([...C.current].slice(-300));try{localStorage.setItem("agentroam:supervision-notifications",JSON.stringify([...C.current]))}catch{}}}catch{}finally{F=!1}}};E.current=Q,Q();const ce=setInterval(()=>{Q()},7e3);return()=>{P=!1,clearInterval(ce)}},[s]),r.useEffect(()=>{if(!p||m)return;const P=setTimeout(()=>l(""),1e4);return()=>clearTimeout(P)},[p,m]);const w=()=>{u(P=>new Set([...P,...a])),v(null),l("")};return!m&&!p?null:e.jsxs("aside",{className:`supervision-notice${f?" is-expanded":""}`,"aria-label":"监工提醒",role:"status",children:[e.jsxs("div",{className:"supervision-notice-heading",children:[e.jsxs("button",{onClick:n,children:[e.jsx(Oa,{size:16}),e.jsx("span",{children:m?`监工有 ${h} 项待你决策`:p})]}),e.jsx("button",{"aria-label":"关闭监工提醒",onClick:w,children:e.jsx(Mt,{size:14})})]}),(f==null?void 0:f.target)&&e.jsxs("div",{className:"session-dashboard supervision-notice-content",children:[e.jsxs("strong",{children:[f.groupName," · ",f.incident.sessionTitle]}),e.jsx(ba,{text:f.incident.message,options:((k=f.incident.question)==null?void 0:k.options)??f.incident.options,recommendation:f.incident.recommendation,multiSelect:(y=f.incident.question)==null?void 0:y.multiSelect,sourceOnly:(O=f.incident.question)==null?void 0:O.requiresSource,onSource:()=>ti({kind:"session",session:f.target}),onAnswer:async(P,F)=>{await xt({action:"answerSupervision",groupId:f.incident.groupId,incidentId:f.incident.id,answer:P,selectedIndices:F}),v(null),l(""),await E.current()}})]})]})}function Ic(n,s){const a=new URLSearchParams(n),i=a.get("session"),u=(i!=null&&i.startsWith("runtime:")?i.split(":")[1]:void 0)??a.get("agent");return{agentType:hn(u)?u:s,explicit:!!(i||a.get("newSession")==="1"||hn(u))}}function Ac(n,s){const a=s==null?void 0:s.sessions.find(u=>u.id===n.id&&u.agentType===n.agentType);if(!a||!s)return;const i=s.workspaces.find(u=>u.agentType===n.agentType&&(u.workspaceId===a.projectId||u.roots.includes(a.cwd)));if(!i)return;const c={...a,title:n.title||a.title,projectId:i.workspaceId};return{session:c,snapshot:{workspaces:s.workspaces.filter(u=>u.agentType===n.agentType),sessions:[...s.sessions.filter(u=>u.agentType===n.agentType&&u.id!==n.id),c]}}}async function Tc(n,s,a,i){a.throwIfAborted();const c=await n.getSession(s.id,s.agentType==="codex"?{limit:kr,view:"core"}:{limit:kr},{signal:a});a.throwIfAborted();const u=c;if(u!=null&&u.threadKey&&u.activeSessionId===c.id&&(s={...s,id:c.id,agentType:c.agentType}),!(c!=null&&c.id)||c.id!==s.id||c.agentType!==s.agentType)throw new Error("原会话身份不匹配,请刷新看板后重试");const h={workspaces:(i==null?void 0:i.workspaces.filter(F=>F.agentType===s.agentType))??[],sessions:(i==null?void 0:i.sessions.filter(F=>F.agentType===s.agentType&&F.id!==s.id))??[]},m=i==null?void 0:i.sessions.find(F=>F.id===s.id),p=c.projectId??(m==null?void 0:m.projectId)??s.projectId,l=()=>h.workspaces.find(F=>F.workspaceId===p)??h.workspaces.find(F=>F.roots.includes(c.cwd||s.cwd));let f=l(),v=null;const E=new Set;for(;!f;){const F=await n.listAgentWorkspaces(s.agentType,{cursor:v,limit:200});if(a.throwIfAborted(),F.stale)throw new Error("会话目录待刷新,请重试");if(h.workspaces=[...new Map([...h.workspaces,...F.data].map(Q=>[Q.workspaceId,Q])).values()],f=l(),v=F.nextCursor,f||!v)break;if(E.has(v))throw new Error("会话目录加载中断,请重试");E.add(v)}const C=(f==null?void 0:f.workspaceId)??p??`session-${c.id}`;f||h.workspaces.push({agentType:s.agentType,workspaceId:C,roots:[c.cwd||s.cwd],name:(c.cwd||s.cwd).split(/[\\/]/).filter(Boolean).at(-1)||"会话工作区",order:h.workspaces.length,source:"derived",canCreateSession:!1});const{messages:w,events:k,history:y,...O}=c,P={...O,cwd:c.cwd||s.cwd,projectId:C};return h.sessions.push(P),{session:P,snapshot:h,initialHistory:{sessionId:P.id,detail:c}}}function Ec({groups:n,dashboardVisible:s,sessionDashboardVisible:a,activeId:i,onSelect:c,onClose:u}){const h=[{id:"assistant",name:"智能助手",closable:!1},...a?[{id:"sessions",name:"Dashboard",closable:!0}]:[],...s?[{id:"dashboard",name:"群聊列表",closable:!0}]:[],...n.map(m=>({id:m.id,name:m.name,closable:!0}))];return e.jsxs("nav",{className:"collab-desktop-tabs","aria-label":"工作页签",children:[h.map(m=>e.jsxs("div",{className:`collab-desktop-tab${i===m.id?" is-active":""}`,children:[e.jsx("button",{type:"button","aria-current":i===m.id?"page":void 0,onClick:()=>c(m.id),children:m.name}),m.closable&&e.jsx("button",{type:"button",className:"collab-desktop-tab-close","aria-label":`关闭${m.name}`,title:`关闭${m.name}页签`,onClick:()=>u(m.id),children:e.jsx(Mt,{size:13,"aria-hidden":"true"})})]},m.id)),e.jsx("div",{className:"collab-desktop-tabs-drag-space","aria-hidden":"true"}),i!=="assistant"&&e.jsx(Ur,{iconOnly:!0,className:"ui-icon-button"})]})}function Nc(){const[n,s]=r.useState(null);r.useEffect(()=>{const u=window.agentApi;if(!(u!=null&&u.desktopLiveGetStatus)||!(u!=null&&u.onDesktopLiveStatus))return;let h=!0;u.desktopLiveGetStatus().then(p=>{h&&s(p)}).catch(()=>{});const m=u.onDesktopLiveStatus(p=>s(p));return()=>{h=!1,m()}},[]);const a=n==null?void 0:n.controlState;if(!((n==null?void 0:n.enabled)&&a!==null&&a!==void 0&&a!=="agent-controlled"))return null;const c=a==="return-requested"||a==="resyncing";return e.jsxs("div",{className:"desktop-live-control-banner",role:"status",style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 10px)",left:"50%",transform:"translateX(-50%)",zIndex:1300,display:"flex",alignItems:"center",gap:8,padding:"7px 14px",borderRadius:999,border:"1px solid rgba(251,191,36,0.45)",background:"rgba(69,49,10,0.92)",color:"#fcd34d",fontSize:13,fontWeight:600,backdropFilter:"blur(8px)",pointerEvents:"none"},children:[e.jsx("span",{"aria-hidden":"true",children:"●"}),c?"正在结束远程控制":"正在被远程控制"]})}function Ns(n,s){return n.map((a,i)=>({session:a,index:i})).sort((a,i)=>s(a.session,i.session)||a.index-i.index).map(({session:a})=>a)}function Pc(n){return Ns(n,(s,a)=>a.created.localeCompare(s.created))}function Cs(n,s){return s==="codex"?[...n]:Pc(n)}function Is(n,s){return Ns(n,(a,i)=>Number(s(i))-Number(s(a)))}function Rc(n,s){return Ns(n,(a,i)=>Number(s(i))-Number(s(a)))}const ys={projectId:null,sessionId:null};function As(n){return typeof n=="string"&&n.trim()?n.trim():null}function En(n){return{projectId:As(n),sessionId:null}}function Rr(n,s){return{projectId:As(n),sessionId:As(s)}}function Lc(n){return n.agentType==="customer-agent"?`确定永久删除会话“${n.title}”吗?此操作不可恢复。`:n.agentType==="codex"?`确定归档 Codex 会话“${n.title}”并从 AgentRoam 中移除吗?可在 Codex 的已归档会话中恢复。`:`确定从 AgentRoam 中移除会话“${n.title}”吗?原生客户端中的历史记录会保留。`}function Dc(n,s){const a=new Set(s);return{...n,selectedSessionId:n.selectedSessionId&&a.has(n.selectedSessionId)?null:n.selectedSessionId,sessions:Object.fromEntries(Object.entries(n.sessions).map(([i,c])=>[i,{...c,data:c.data.filter(u=>!a.has(u.id))}]))}}function Oc(n,s){const a=new Set(s);let i=!1;const c=Object.fromEntries(Object.entries(n).map(([u,h])=>{const m=h.filter(p=>!a.has(p.id));return m.length!==h.length&&(i=!0),[u,m.length===h.length?h:m]}));return i?c:n}function _c(n,s,a,i){const c=[i,...(s[i]??[]).map(m=>m.id)],u=new Set(c),h=Object.fromEntries(Object.entries(s).flatMap(([m,p])=>{if(u.has(m))return[];const l=p.filter(f=>!u.has(f.id));return[[m,l.length===p.length?p:l]]}));return{sessionsByProject:Oc(n,c),childSessionsByParent:h,otherLocalSessions:a.filter(m=>!u.has(m.id)),removedIds:c}}const zc={fontSize:13,fontWeight:600,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:14},Lr={display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"8px 12px",borderRadius:"var(--radius-sm)",border:"1px solid var(--border-subtle)",background:"var(--bg-surface)",fontSize:13};function ui({onboarding:n=!1}){const s=typeof window>"u"?void 0:window.agentApi,a=!!(s!=null&&s.desktopLiveGetStatus),[i,c]=r.useState(null),[u,h]=r.useState(!1),[m,p]=r.useState(null),[l,f]=r.useState(!0);r.useEffect(()=>{if(!(s!=null&&s.desktopLiveGetStatus)||!(s!=null&&s.onDesktopLiveStatus))return;let y=!0;s.desktopLiveSetup().then(P=>{y&&(c(P.status),f(P.supported))}).catch(()=>{});const O=s.onDesktopLiveStatus(P=>c(P));return()=>{y=!1,O()}},[s]);const v=async()=>{if(s!=null&&s.desktopLiveRecheck)try{c(await s.desktopLiveRecheck()),p(null)}catch(y){p(y instanceof Error?y.message:String(y))}};r.useEffect(()=>{if(!a||!l)return;let y=!0,O=!1;const P=async()=>{if(!O){O=!0;try{const Q=await s.desktopLiveRecheck();y&&c(Q)}catch{}finally{O=!1}}};window.addEventListener("focus",P);const F=i!=null&&i.enabled&&(i.permissionScreen!=="granted"||i.accessibilityTrusted!==!0)?window.setInterval(P,3e3):void 0;return()=>{y=!1,window.removeEventListener("focus",P),F&&window.clearInterval(F)}},[s,a,l,i==null?void 0:i.enabled,i==null?void 0:i.permissionScreen,i==null?void 0:i.accessibilityTrusted]);const E=async y=>{if(s){h(!0);try{c(await s.desktopLiveSetEnabled(!0)),await s.desktopLiveOpenPermission(y),p(null)}catch(O){p(O instanceof Error?O.message:String(O))}finally{h(!1)}}};if(!a)return null;const C=async()=>{if(s!=null&&s.desktopLiveSetEnabled){h(!0);try{c(await s.desktopLiveSetEnabled(!(i!=null&&i.enabled))),p(null)}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(!1)}}},w=(i==null?void 0:i.permissionScreen)==="granted",k=(i==null?void 0:i.accessibilityTrusted)===!0;return e.jsxs("section",{className:"desktop-permission-settings",children:[e.jsx("h3",{style:zc,children:n?"设置桌面端权限":"桌面直播与远程控制"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-muted)",margin:"0 0 14px",lineHeight:1.6},children:n?"欢迎使用 AgentRoam。请为桌面端开启以下系统权限,完成后手机即可查看电脑画面;允许辅助功能后还可操作鼠标和键盘。":"开启后,已配对手机可查看电脑画面,并在授予辅助功能权限后操作鼠标和键盘。"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("button",{type:"button",onClick:()=>void C(),disabled:u||!l,style:{padding:"7px 16px",borderRadius:"var(--radius-sm)",border:`1px solid ${i!=null&&i.enabled?"rgba(244,63,94,0.35)":"var(--accent)"}`,background:i!=null&&i.enabled?"rgba(244,63,94,0.1)":"var(--accent-dim)",color:i!=null&&i.enabled?"var(--danger)":"var(--accent)",fontSize:13,fontWeight:600,cursor:"pointer"},children:u?"处理中…":i!=null&&i.enabled?n?"暂停手机查看":"关闭桌面直播":n?"开启手机查看":"开启桌面直播"}),(i==null?void 0:i.enabled)&&e.jsx("span",{style:{fontSize:12,color:i.sessionOnline?"var(--success)":"var(--text-muted)"},children:i.sessionOnline?"● 已连接,可从手机查看":"○ 未连接"})]}),!l&&e.jsx("p",{role:"status",children:"当前远程桌面仅支持 macOS,其他桌面功能可正常使用。"}),l&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("div",{className:"desktop-permission-row",style:Lr,children:[e.jsx("span",{children:"屏幕录制(画面采集)"}),e.jsx("span",{style:{color:w?"var(--success)":"var(--danger)",fontWeight:600},children:w?"已授权":"未授权"}),!w&&e.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:u,onClick:()=>void E("screen"),children:"去授权"})]}),e.jsxs("div",{className:"desktop-permission-row",style:Lr,children:[e.jsx("span",{children:"辅助功能(键鼠控制)"}),e.jsx("span",{style:{color:k?"var(--success)":"var(--danger)",fontWeight:600},children:(i==null?void 0:i.accessibilityTrusted)===null?"待检测":k?"已授权":"未授权"}),!k&&e.jsx("button",{type:"button",className:"ui-quiet-button desktop-permission-button",disabled:u,onClick:()=>void E("accessibility"),children:"去授权"})]})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginTop:14,fontSize:12,color:"var(--text-muted)",lineHeight:1.6},children:"点击「去授权」,在系统设置中允许 AgentRoam Remote Desktop,返回后会自动检测。"}),e.jsxs("details",{className:"desktop-permission-more",children:[e.jsx("summary",{children:"更多操作"}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void v(),children:"重新检测"}),!w&&e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:()=>void(s==null?void 0:s.desktopLiveRestart()),children:"重启桌面端"})]})]})]}),m&&e.jsx("p",{role:"alert",style:{color:"var(--danger)"},children:m}),(i==null?void 0:i.error)&&e.jsx("div",{style:{marginTop:10,fontSize:12,color:"var(--danger)"},role:"alert",children:i.error})]})}const Mc=Object.freeze(Object.defineProperty({__proto__:null,default:ui},Symbol.toStringTag,{value:"Module"}));function Wc({onClose:n}){const s=r.useRef(null);return r.useEffect(()=>{var a;(a=s.current)==null||a.showModal()},[]),Ke.createPortal(e.jsx("dialog",{ref:s,"aria-label":"桌面直播与远程控制",onCancel:n,onClick:a=>{a.target===a.currentTarget&&n()},style:{width:"min(680px, calc(100vw - 48px))",maxHeight:"calc(100vh - 48px)",padding:0,margin:"auto",inset:0,overflowY:"auto",color:"var(--text-primary)",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)"},children:e.jsxs("div",{style:{padding:24},children:[e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:e.jsx("button",{type:"button",onClick:n,"aria-label":"关闭桌面直播设置",className:"ui-icon-button ui-icon-button--close",children:"×"})}),e.jsx(ui,{}),e.jsx("div",{className:"desktop-permission-footer",children:e.jsx("button",{type:"button",className:"ui-quiet-button",onClick:n,children:"关闭"})})]})}),document.body)}function $c({trigger:n,heardText:s}){const[a,i]=r.useState(!1);return r.useEffect(()=>{if(n<=0)return;i(!0);const c=setTimeout(()=>i(!1),2400);return()=>clearTimeout(c)},[n]),a?Ke.createPortal(e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:3e4,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:22,background:"radial-gradient(circle at 50% 50%, var(--accent-glow), transparent 60%)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",animation:"fadeIn 0.3s var(--ease-out)",pointerEvents:"none",WebkitAppRegion:"no-drag"},children:[e.jsxs("div",{style:{position:"relative",width:120,height:120},children:[[0,.45,.9].map(c=>e.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",border:"2px solid var(--accent)",animation:`wakeRing 1.6s ${c}s var(--ease-out) infinite`}},c)),e.jsx("div",{style:{position:"absolute",inset:30,borderRadius:"50%",background:"var(--accent)",display:"flex",alignItems:"center",justifyContent:"center",animation:"wakeCore 1.6s var(--ease-out) infinite"},children:e.jsxs("svg",{width:"26",height:"26",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-inverse)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),e.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})]}),e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",letterSpacing:"0.12em",animation:"wakeText 0.9s var(--ease-out) both",fontFamily:"var(--font-display)"},children:"已唤醒 · 随时待命"}),s&&e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",maxWidth:320,textAlign:"center",animation:"fadeIn 0.6s var(--ease-out) 0.3s both"},children:["“",s.slice(0,40),"”"]})]},n),document.body):null}const Bc={completion:{label:"会话已完成",sound:"completion.wav"},approval:{label:"需要确认",sound:"approval.wav"},todo_reminder:{label:"待办提醒",sound:"reminder.wav"},todo_execution:{label:"定时待办",sound:"scheduled.wav"},todo_attention:{label:"待办需关注",sound:"attention.wav"},todo_error:{label:"待办执行异常",sound:"error.wav"}};function Hc(n){let s=n.kind;return n.kind==="todo_execution"&&(n.title==="定时待办执行未完成"?s="todo_error":(n.title==="定时待办错过执行"||n.title==="定时待办需要核实")&&(s="todo_attention")),{type:s,...Bc[s]}}function Dr(n,s=180){const a=n.replace(/```[^\n]*\n?[\s\S]*?(?:```|$)/g," ").replace(/~~~[^\n]*\n?[\s\S]*?(?:~~~|$)/g," ").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[([^\]]+)\]\((?:[^)(]|\([^)]*\))*\)/g,"$1").replace(/`(?:\/|~\/|[A-Za-z]:\\)[^`]*`/g," ").replace(/(?:file:\/\/\/|\/(?:Users|home|tmp|private|var|Applications|Volumes)\/|~\/|[A-Za-z]:\\)[^\s<>`"',。;、))]+/g," ").replace(/^\s{0,3}(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)/gm,"").replace(/(\*\*|__|~~)([\s\S]*?)\1/g,"$2").replace(/(^|\s)[*_]([^\s*_][^*_]*?)[*_](?=\s|[,。!?,.!?]|$)/g,"$1$2").replace(/`+/g,"").replace(/\s+/g," ").replace(/\s+([,。;、)])/g,"$1").trim(),i=Array.from(a);return i.length>s?`${i.slice(0,s-1).join("")}…`:a}const Fc={completion:Uo,approval:Fa,todo_reminder:Da,todo_execution:_a,todo_attention:za,todo_error:Vo},qc=new Set(["会话已完成","会话完成","任务完成","任务已完成","运行已结束","运行结束","已完成"]);function Vc({items:n,onOpen:s,onDismiss:a,onClearAll:i}){return n.length===0?null:e.jsxs("aside",{className:"notification-toasts","aria-label":"通知",children:[n.length>1&&i&&e.jsx("button",{type:"button",className:"notification-toasts__clear",title:"全部标为已读并清除",onClick:c=>{c.stopPropagation(),i()},children:"全部清除"}),n.slice(0,3).map(c=>{const{type:u,label:h}=Hc(c),m=Fc[u],p=Dr(c.title,100)||h,l=c.kind!=="completion"||!qc.has(p.replace(/[\s。.!!::]+/g,"")),f=Dr(c.body)||"点击查看详细内容";return e.jsxs("article",{className:`notification-toast notification-toast--${u}`,"data-notification-id":c.id,"data-notification-type":u,children:[e.jsxs("button",{type:"button",className:"notification-toast__content","aria-label":`${l?p:h},打开查看`,onClick:()=>s(c),children:[e.jsx("span",{className:"notification-toast__icon","aria-hidden":"true",children:e.jsx(m,{size:15,strokeWidth:1.8})}),e.jsxs("span",{className:"notification-toast__body",role:"status",children:[e.jsxs("span",{className:"notification-toast__meta",children:[e.jsx("span",{children:h}),e.jsx("span",{className:"notification-toast__dot","aria-hidden":"true"}),e.jsx("span",{className:"notification-toast__unread",children:"未读"})]}),l&&e.jsx("strong",{className:"notification-toast__title",children:p}),e.jsx("span",{className:"notification-toast__summary",children:f})]})]}),e.jsx("button",{type:"button",className:"notification-toast__close","aria-label":"关闭通知并标为已读",title:"关闭并标为已读",onClick:v=>{v.stopPropagation(),a(c)},children:e.jsx(Mt,{size:14,"aria-hidden":"true"})})]},c.id)})]})}const Or="agentroam.notification-read-pending.v1";function _r(n){if(!n.serviceId||!n.ownerId)throw new Error("通知来源缺失");return JSON.stringify([n.serviceId,n.ownerId])}function Uc(n,s){return n.kind==="completion"?(s==null?void 0:s.completionEnabled)!==!1:n.kind==="approval"?(s==null?void 0:s.approvalEnabled)!==!1:(s==null?void 0:s.todoEnabled)!==!1}class Kc{constructor(s,a,i=()=>{}){this.api=s,this.storage=a,this.warn=i,this.scope="",this.items=[],this.consumed=new Map,this.listeners=new Set,this.pending={};try{const c=JSON.parse((a==null?void 0:a.getItem(Or))??"{}");if(c&&typeof c=="object"&&!Array.isArray(c))for(const[u,h]of Object.entries(c))Array.isArray(h)&&(this.pending[u]=h.filter(m=>typeof m=="string"))}catch(c){this.warn(c)}}subscribe(s){return this.listeners.add(s),s(this.items),()=>{this.listeners.delete(s)}}publish(s){this.items=s,this.listeners.forEach(a=>a(s))}save(){var s;try{(s=this.storage)==null||s.setItem(Or,JSON.stringify(this.pending))}catch(a){this.warn(a)}}refresh(){return this.refreshing?this.refreshing:(this.refreshing=this.refreshOnce().finally(()=>{this.refreshing=void 0}),this.refreshing)}async refreshOnce(){try{const s=await this.api.list();this.scope=_r(s);const a=new Set([...this.pending[this.scope]??[],...this.consumed.get(this.scope)??[]]);this.publish(s.items.filter(i=>i.ownerId===s.ownerId&&!i.readAt&&!i.dismissedAt&&!a.has(i.id)&&Uc(i,s.preferences)).sort((i,c)=>c.createdAt-i.createdAt)),await this.syncReads(this.scope)}catch(s){this.warn(s)}}consume(s){return this.consumeItems([s])}consumeAll(){return this.consumeItems(this.items)}consumeItems(s){var u;if(!this.scope||!s.length)return Promise.resolve();const a=new Set(s.filter(h=>this.items.some(m=>m.id===h.id&&m.ownerId===h.ownerId)).map(h=>h.id));if(!a.size)return Promise.resolve();const i=this.scope,c=(u=this.pending)[i]??(u[i]=[]);for(const h of a)c.includes(h)||c.push(h);return this.save(),this.publish(this.items.filter(h=>!a.has(h.id))),this.syncReads(i)}syncReads(s){return this.syncing?this.syncing:(this.syncing=this.flushReads(s).finally(()=>{this.syncing=void 0}),this.syncing)}async flushReads(s){var a;try{for(;(a=this.pending[s])!=null&&a.length;){const i=await this.api.list();if(_r(i)!==s)return;const c=this.pending[s][0];i.items.some(m=>m.id===c&&(m.readAt||m.dismissedAt))||await this.api.read(c,{serviceId:i.serviceId,ownerId:i.ownerId});const h=this.consumed.get(s)??new Set;h.add(c),this.consumed.set(s,h),this.pending[s]=this.pending[s].filter(m=>m!==c),this.pending[s].length||delete this.pending[s],this.save()}}catch(i){this.warn(i)}}}function Gc(n){const[s,a]=r.useState([]),i=r.useRef();r.useEffect(()=>{var v;if(!n||!((v=window.agentApi)!=null&&v.notificationList)||!window.agentApi.notificationRead)return;let h;try{h=window.localStorage}catch{}const m=new Kc({list:async()=>await window.agentApi.notificationList(),read:(E,C)=>window.agentApi.notificationRead(E,C)},h,E=>console.warn("[notifications] read synchronization failed",E));i.current=m;const p=m.subscribe(a),l=()=>{m.refresh()};l();const f=window.setInterval(l,3e3);return window.addEventListener("focus",l),()=>{window.clearInterval(f),window.removeEventListener("focus",l),p(),i.current===m&&(i.current=void 0)}},[n]);const c=r.useCallback(h=>{var m;(m=i.current)==null||m.consume(h)},[]),u=r.useCallback(()=>{var h;(h=i.current)==null||h.consumeAll()},[]);return{items:s,consume:c,clearAll:u}}const Yc=[{value:"classic",description:"横向切换 Agent,按目录浏览"},{value:"agent-rail",description:"竖向 Agent 栏,聚焦当前工作区"},{value:"all-sessions",description:"汇总所有 Agent 的会话"}],Xc=typeof window>"u"?r.useEffect:r.useLayoutEffect;function Jc({value:n}){return e.jsxs("svg",{className:"sidebar-layout-preview",viewBox:"0 0 48 36",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"1",y:"1",width:"46",height:"34",rx:"5",stroke:"currentColor",strokeOpacity:".3"}),n==="classic"?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 8h16M6 20h13M6 25h10M6 30h12",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"}),[7,13,19,25,31,37].map(s=>e.jsx("rect",{x:s,y:"12",width:"4",height:"4",rx:"1",fill:"currentColor",opacity:".7"},s))]}):n==="agent-rail"?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 8h28M14 13v21",stroke:"currentColor",strokeOpacity:".3",strokeWidth:"2",strokeLinecap:"round"}),[16,22,28].map(s=>e.jsx("rect",{x:"6",y:s,width:"4",height:"4",rx:"1",fill:"currentColor",opacity:".7"},s)),e.jsx("path",{d:"M20 17h18M20 23h12M20 29h15",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M6 8h22",stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"}),[16,22,28].map((s,a)=>e.jsxs("g",{children:[e.jsx("circle",{cx:"7",cy:s,r:"1.5",fill:"currentColor",opacity:".7"}),e.jsx("path",{d:`M12 ${s}h${a===1?18:25}`,stroke:"currentColor",strokeOpacity:".55",strokeWidth:"2",strokeLinecap:"round"})]},s))]})]})}function pi(){const n=Ee(f=>f.navigationLayout),s=Ee(f=>f.setNavigationLayout),[a,i]=r.useState(!1),[c,u]=r.useState({top:0,left:0}),h=r.useRef(null),m=r.useRef(null),p=r.useId();Xc(()=>{var v,E;if(!a)return;const f=()=>{var y;const C=(y=h.current)==null?void 0:y.getBoundingClientRect();if(!C||!m.current)return;const{offsetWidth:w,offsetHeight:k}=m.current;u({top:Math.max(8,Math.min(C.bottom+8,window.innerHeight-k-8)),left:Math.max(8,Math.min(C.right-w,window.innerWidth-w-8))})};return f(),(E=(v=m.current)==null?void 0:v.querySelector('[aria-checked="true"]'))==null||E.focus(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[a]),r.useEffect(()=>{if(!a)return;const f=v=>{var C,w;const E=v.target;!((C=h.current)!=null&&C.contains(E))&&!((w=m.current)!=null&&w.contains(E))&&i(!1)};return document.addEventListener("pointerdown",f),()=>document.removeEventListener("pointerdown",f)},[a]);const l=f=>{var w,k,y;f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),i(!1),(w=h.current)==null||w.focus());const v=Array.from(((k=m.current)==null?void 0:k.querySelectorAll('[role="menuitemradio"]'))??[]),E=v.indexOf(document.activeElement),C=f.key==="ArrowDown"?(E+1)%v.length:f.key==="ArrowUp"?(E+v.length-1)%v.length:f.key==="Home"?0:f.key==="End"?v.length-1:null;C!==null&&(f.preventDefault(),(y=v[C])==null||y.focus())};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:h,type:"button",className:"sidebar-layout-trigger","aria-label":"切换侧栏布局",title:`切换布局 · 当前:${hs[n]}`,"aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?p:void 0,onClick:()=>i(f=>!f),onKeyDown:f=>{(f.key==="ArrowDown"||f.key==="ArrowUp")&&(f.preventDefault(),i(!0))},children:e.jsx(Va,{size:18,"aria-hidden":"true"})}),a&&Ke.createPortal(e.jsxs("div",{ref:m,id:p,role:"menu","aria-label":"侧栏布局",className:"sidebar-layout-menu",style:{position:"fixed",...c},onKeyDown:l,onBlur:f=>{var E;const v=f.relatedTarget;v&&!f.currentTarget.contains(v)&&!((E=h.current)!=null&&E.contains(v))&&i(!1)},children:[e.jsx("div",{className:"sidebar-layout-menu-title","aria-hidden":"true",children:"侧栏布局"}),Yc.map(f=>e.jsxs("button",{type:"button",role:"menuitemradio","aria-label":hs[f.value],"aria-checked":n===f.value,className:"sidebar-layout-option",onClick:()=>{i(!1),s(f.value),requestAnimationFrame(()=>{var v;return(v=document.querySelector(".sidebar-layout-trigger"))==null?void 0:v.focus()})},children:[e.jsx(Jc,{value:f.value}),e.jsxs("span",{className:"sidebar-layout-option-copy",children:[e.jsx("span",{children:hs[f.value]}),e.jsx("small",{children:f.description})]}),n===f.value&&e.jsx(Pa,{size:16,"aria-hidden":"true"})]},f.value))]}),document.body)]})}function Qc({value:n,health:s,onClose:a}){const i=s.find(h=>h.agentType===n),c=(i==null?void 0:i.available)===!1?"unavailable":i!=null&&i.available||n==="customer-agent"?"ready":"checking",u=c==="ready"?"本机已连接":c==="checking"?"正在检查运行时":"运行时暂不可用";return e.jsxs("header",{className:"sidebar-agent-header",children:[e.jsx("span",{className:"sidebar-agent-header-icon",children:e.jsx(Xt,{agentType:n,size:23})}),e.jsxs("div",{className:"sidebar-agent-header-identity",children:[e.jsx("span",{className:"sidebar-agent-header-name",title:Pn[n],children:Pn[n]}),e.jsxs("span",{className:`sidebar-agent-header-status is-${c}`,title:i==null?void 0:i.error,children:[e.jsx("i",{"aria-hidden":"true"}),u]})]}),e.jsxs("div",{className:"sidebar-agent-header-actions",children:[e.jsx(pi,{}),e.jsx("button",{type:"button",className:"ui-icon-button sidebar-agent-header-close",onClick:a,"aria-label":"收起会话列表",title:"收起会话列表",children:e.jsx(Mt,{size:18,"aria-hidden":"true"})})]})]})}async function Zc(n,s,a){async function i(f){const v=[],E=new Set;let C=null;do{a.throwIfAborted();const w=await f(C);if(a.throwIfAborted(),w.stale)throw new Error("会话列表待刷新,请重试");if(v.push(...w.data),C=w.nextCursor,C&&E.has(C))throw new Error("会话列表加载中断,请重试");C&&E.add(C)}while(C);return v}const c=await i(f=>n.listAgentWorkspaces(s,{cursor:f,limit:200})),u=[...new Map(c.map(f=>[f.workspaceId,f])).values()],h=new Array(u.length);let m=0;await Promise.all(Array.from({length:Math.min(4,u.length)},async()=>{for(;m<u.length;){const f=m++,v=u[f];h[f]=(await i(E=>n.listAgentWorkspaceSessions(s,v.workspaceId,{cursor:E,limit:200}))).map(E=>({...E,projectId:v.workspaceId}))}}));const p=new Set,l=h.flat().filter(f=>p.has(f.id)?!1:(p.add(f.id),!0));return{workspaces:u,sessions:l}}function el({hidden:n,value:s,health:a,selectedSessionId:i,getActivity:c,onChange:u,onNewSession:h,onSelect:m}){const[p,l]=r.useState(null),[f,v]=r.useState(null),[E,C]=r.useState(!1),[w,k]=r.useState(null),[y,O]=r.useState(""),P=gn(),[F,Q]=r.useState(0),ce=r.useRef(),te=r.useRef(null),M=r.useRef(new Map),W=()=>clearTimeout(ce.current),z=()=>{W(),l(null)},K=()=>{W(),ce.current=setTimeout(()=>l(null),180)};r.useEffect(()=>()=>clearTimeout(ce.current),[]);const le=!!(p&&Kr(a).includes(p.agentType));r.useEffect(()=>{(n||!le)&&l(null)},[n,le]),r.useEffect(()=>{if(!p||n||!le)return;const _=new AbortController;return O(""),v(M.current.get(p.agentType)??null),k(null),C(!0),Zc(window.agentApi,p.agentType,_.signal).then(Z=>{_.signal.aborted||(M.current.set(p.agentType,Z),v(Z))}).catch(Z=>{_.signal.aborted||k(Z instanceof Error?Z.message:"会话加载失败,请重试")}).finally(()=>{_.signal.aborted||C(!1)}),()=>_.abort()},[p==null?void 0:p.agentType,le,n,F]);const ne=Is((f==null?void 0:f.sessions)??[],_=>{const Z=c(_);return Z==="running"||Z==="needs-input"}),se=y.trim().toLocaleLowerCase(),re=Mn(se?zn(ne.filter(_=>_.title.toLocaleLowerCase().includes(se)),ne):ne),Ae=({session:_,children:Z})=>{const Se=Dn(c(_)),Te=P.expandedIds.has(_.id);return e.jsxs("div",{children:[e.jsx(_n,{session:{id:_.id,title:_.title,visualState:Se,statusLabel:Rn[Se],occupiedExternally:_.occupancy==="owned-externally",completedAt:Ln(_),canDelete:!1,active:s===(p==null?void 0:p.agentType)&&i===_.id,compatibility:_.compatibility,child:!!_.parentSessionId,expanded:Te},onToggleChildren:Z.length?()=>P.toggle(_.id):void 0,onSelect:()=>{f&&m(_,f),z()}}),Te&&Z.length>0&&e.jsx("div",{className:"sidebar-session-children",role:"group","aria-label":`${_.title}的子会话`,children:Z.map(Ae)})]},_.id)},de=_=>{var Se;const Z=_.relatedTarget;!_.currentTarget.contains(Z)&&!((Se=te.current)!=null&&Se.contains(Z))&&K()};return e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"sidebar-agent-rail","aria-label":"Agent 快捷栏","aria-hidden":n,ref:_=>{_&&(_.inert=n)},onPointerEnter:W,onPointerLeave:K,onBlur:de,onKeyDown:_=>{_.key==="Escape"&&z()},children:e.jsx(Gr,{vertical:!0,value:s,health:a,onChange:u,onPreview:(_,Z,Se)=>{W(),(p==null?void 0:p.agentType)!==_&&(v(null),P.collapseAll()),l({agentType:_,label:Z,top:Math.max(56,Math.min(Se.top,window.innerHeight-380))})}})}),!n&&le&&p&&Ke.createPortal(e.jsxs("div",{ref:te,className:"agent-session-flyout",style:{top:p.top,maxHeight:Math.min(600,window.innerHeight-p.top-12)},role:"dialog","aria-label":`${p.label} 会话`,onPointerEnter:W,onPointerLeave:K,onFocus:W,onBlur:de,onKeyDown:_=>{_.key==="Escape"&&z()},children:[e.jsxs("header",{children:[e.jsx(Xt,{agentType:p.agentType,size:20}),e.jsx("strong",{children:p.label}),e.jsxs("span",{children:["会话 ",(f==null?void 0:f.sessions.length)??""]}),e.jsxs("button",{type:"button",className:"agent-session-flyout-new","aria-label":`新建 ${p.label} 会话`,title:"在小窗口中新建会话",onClick:()=>{h(p.agentType),z()},children:[e.jsx(Nn,{size:14,"aria-hidden":"true"}),e.jsx("span",{children:"新建会话"})]})]}),e.jsxs("label",{className:"agent-session-flyout-search",children:[e.jsx(Wn,{size:15,"aria-hidden":"true"}),e.jsx("input",{"aria-label":`搜索 ${p.label} 会话`,placeholder:"搜索会话",value:y,onChange:_=>O(_.target.value)})]}),e.jsxs("div",{className:"agent-session-flyout-list","aria-busy":E,children:[re.map(Ae),E&&e.jsxs("p",{className:"agent-session-flyout-message",role:"status",children:[e.jsx(bt,{size:15,className:"spin"}),"正在加载会话…"]}),w&&e.jsxs("p",{className:"agent-session-flyout-message",role:"alert",children:[w,e.jsx("button",{type:"button",onClick:()=>Q(_=>_+1),children:"重试"})]}),!E&&!w&&!re.length&&e.jsx("p",{className:"agent-session-flyout-message",children:y?"没有匹配的会话":"暂无会话"})]})]}),document.body)]})}function zr({onOpenCalendar:n}){return e.jsx("div",{className:"desktop-app-actions",role:"toolbar","aria-label":"应用快捷操作",children:e.jsx("button",{type:"button",className:"ui-icon-button desktop-app-action desktop-app-action--calendar",onClick:n,title:"智能体日历","aria-label":"打开日历",children:e.jsx(Es,{size:17,"aria-hidden":"true"})})})}const vs=264,Mr=126;function tl(n){const s=typeof window>"u"?1024:window.innerWidth,a=typeof window>"u"?768:window.innerHeight,i=Math.max(8,Math.min(n.left+n.width-vs,s-vs-8)),c=n.top+n.height+7,u=c+Mr<=a-8?c:Math.max(8,n.top-Mr-7);return{left:i,top:u,width:vs}}function Wr({title:n,message:s,anchor:a,mobile:i,pending:c,onCancel:u,onConfirm:h}){const m=p=>p.stopPropagation();return e.jsx("div",{className:`sidebar-delete-confirmation-layer${i?" is-mobile":""}`,onClick:c?void 0:u,children:e.jsxs("div",{className:"sidebar-delete-confirmation",role:"alertdialog","aria-modal":"true","aria-labelledby":"sidebar-delete-confirmation-title","aria-describedby":"sidebar-delete-confirmation-message",style:i?void 0:tl(a),onClick:m,children:[e.jsx("strong",{id:"sidebar-delete-confirmation-title",children:n??"删除会话"}),e.jsx("p",{id:"sidebar-delete-confirmation-message",children:s}),e.jsxs("div",{className:"sidebar-delete-confirmation-actions",children:[e.jsx("button",{type:"button",onClick:u,disabled:c,children:"取消"}),e.jsx("button",{type:"button",className:"is-danger",onClick:h,disabled:c,children:c?"正在删除...":"删除"})]})]})})}function nl({message:n,type:s}){return n?Ke.createPortal(e.jsxs("div",{className:`app-action-notice is-${s}`,role:s==="error"?"alert":"status","aria-live":s==="error"?"assertive":"polite",children:[e.jsx("span",{className:"app-action-notice-mark","aria-hidden":"true",children:s==="success"?"✓":s==="info"?"i":"!"}),e.jsx("span",{children:n})]}),document.body):null}function fi(){const n=window;return n.SpeechRecognition??n.webkitSpeechRecognition??null}function sl(){if(typeof window>"u")return null;const n=window.agentApi;return typeof(n==null?void 0:n.dictationStart)!="function"||typeof n.dictationStop!="function"||typeof n.onDictation!="function"||typeof n.onDictationError!="function"?null:n}function rl(){return sl()!==null||fi()!==null}function il(n){var h;const s=fi();if(!s)return(h=n.onError)==null||h.call(n,"当前环境不支持语音唤醒"),null;let a=!1,i=null,c=null;const u=()=>{if(!a){i=new s,i.lang=n.lang??"zh-CN",i.continuous=!0,i.interimResults=!0,i.onresult=m=>{var f,v,E;const p=m.results[m.results.length-1],l=(v=(f=p==null?void 0:p[0])==null?void 0:f.transcript)==null?void 0:v.trim();l&&(p.isFinal&&((E=n.onHeard)==null||E.call(n,l)),l.includes(n.wakeWord)&&n.onWake(l))},i.onerror=m=>{var p;m.error==="not-allowed"&&((p=n.onError)==null||p.call(n,"麦克风权限被拒绝,语音唤醒已停用"),a=!0)},i.onend=()=>{a||(c=setTimeout(u,400))};try{i.start()}catch{c=setTimeout(u,800)}}};return u(),{stop:()=>{a=!0,c&&clearTimeout(c);try{i==null||i.abort()}catch{}}}}function ol(n){return n.startsWith("/")||/^[A-Za-z]:[\\/]/.test(n)||/^\\\\[^\\/]+[\\/][^\\/]+/.test(n)}function al(n,s){if(s.webShell||s.isInvalid||!s.supported)return null;const a=n.description;return!a||/[\0\r\n]/.test(a)||!ol(a)?null:a}function cl(n){return{request:(s,a)=>n.fileWorkspaceRequest(s,a),subscribe:(s,a)=>s!=="fs:event"?()=>{}:n.onFileWorkspaceEvent(a)}}function ll({authoritativeStatus:n,locallyRunning:s,needsInput:a,stale:i}){return n==="failed"||n==="error"?"error":i&&!s?"stale":s||n==="running"?a?"needs-input":"running":"idle"}function dl(n,s){const a=new Set;n&&a.add(n);for(const i of s)i&&a.add(i);return[...a]}function ul(n,s,a){return[...n].filter(i=>!s.has(i)&&!a.has(i))}const $r=220,Br=480,pl=180;function fl(){const[n,s]=r.useState(300),[a,i]=r.useState(!1),[c,u]=r.useState(!1),h=r.useRef(null),m=r.useCallback(w=>{w.button!==0||!w.isPrimary||(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),h.current={pointerId:w.pointerId,startX:w.clientX,startWidth:n,target:w.currentTarget},u(!0))},[n]),p=r.useCallback(w=>{const k=h.current;if(!k||w.pointerId!==k.pointerId)return;const y=k.startWidth+w.clientX-k.startX,O=y<=pl;i(O),s(O?k.startWidth:Math.min(Br,Math.max($r,y)))},[]),l=r.useCallback(()=>{const w=h.current;w&&(h.current=null,u(!1),w.target.hasPointerCapture(w.pointerId)&&w.target.releasePointerCapture(w.pointerId))},[]),f=r.useCallback(w=>{var k;w.pointerId===((k=h.current)==null?void 0:k.pointerId)&&l()},[l]),v=r.useCallback(w=>{p(w),f(w)},[p,f]);r.useEffect(()=>{if(c)return window.addEventListener("pointerup",v),window.addEventListener("pointercancel",f),window.addEventListener("blur",l),()=>{window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",f),window.removeEventListener("blur",l)}},[c,v,f,l]);const E=r.useCallback(w=>{w.key==="Enter"?(w.preventDefault(),i(!0)):(w.key==="ArrowLeft"||w.key==="ArrowRight")&&(w.preventDefault(),s(k=>Math.min(Br,Math.max($r,k+(w.key==="ArrowLeft"?-20:20)))))},[]),C=r.useCallback(()=>i(w=>!w),[]);return{width:n,collapsed:a,dragging:c,toggle:C,resizeProps:{onPointerDown:m,onPointerMove:p,onPointerUp:v,onPointerCancel:f,onLostPointerCapture:f,onKeyDown:E}}}const hl=r.lazy(()=>Ce(()=>import("./CollaborationDashboard-CvE5vaOh.js"),__vite__mapDeps([12,1,2,13,14,15,16,17,4,18,5,19,20,21,22,8,23,24]),import.meta.url)),gl=r.lazy(()=>Ce(()=>import("./SessionDashboard-DXPSvNsY.js"),__vite__mapDeps([30,1,2,23,31,32,20,19,33,21,22,4,8,27,10,34]),import.meta.url)),ml=r.lazy(()=>Ce(()=>import("./CollaborationPage-Cjeo60S0.js"),__vite__mapDeps([25,1,2,26,4,23,27,19,21,22,15,13,28,29,9]),import.meta.url)),wl=r.lazy(()=>Ce(()=>import("./AIHubView-HV2FIroL.js"),__vite__mapDeps([43,1,2,44,26,4,36,9,45,18,17,7,5,8,20,37,38,33,19,16,46,47]),import.meta.url)),bl=r.lazy(()=>Ce(()=>import("./CalendarView-CuBzp-g8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]),import.meta.url)),xl=async(n,s)=>{const a=window.agentApi;if(!(a!=null&&a.calendarOverview))throw new Error("当前服务不支持日历,请更新共享服务。");return a.calendarOverview({from:n,to:s})},yl=r.lazy(()=>Ce(()=>import("./SettingsPanel-C78O9_ho.js"),__vite__mapDeps([48,1,2,44,26,4,36,9,45,18,17,7,5,8,20,37,38,33,19,16,46,14,15,21,22,31,23,32,3,49,50,13,28]),import.meta.url)),vl=r.lazy(()=>Ce(()=>import("./MCPServerList-DkVUlKEJ.js"),__vite__mapDeps([51,1,2]),import.meta.url)),kl=r.lazy(()=>Ce(()=>import("./MemoryViewer-Ywl80xth.js"),__vite__mapDeps([52,1,2]),import.meta.url)),Sl=r.lazy(()=>Ce(()=>import("./SkillManager-BdkBUxhH.js"),__vite__mapDeps([53,1,2]),import.meta.url)),jl=r.lazy(()=>Ce(()=>import("./AgentManager-C4zPGI-Y.js"),__vite__mapDeps([54,1,2,44,26,4,36,9,45,18,17,7,5,8,20,37,38,33,19,16,46]),import.meta.url)),Cl=r.lazy(()=>Ce(()=>import("./LSPServerList-BbAS_sm-.js"),__vite__mapDeps([55,1,2]),import.meta.url)),Il=r.lazy(()=>Ce(()=>import("./FileWorkspaceDrawer-DRluuYWn.js"),__vite__mapDeps([56,1,2,57,38,18,9,4,58,59,17,6,8,5]),import.meta.url));function Hr(n,s){var c;const a={},i={};for(const[u,h]of Object.entries(n)){const m=h.data;a[u]=Cs(m.filter(p=>!p.parentSessionId),s);for(const p of m.filter(l=>l.parentSessionId))(i[c=p.parentSessionId]??(i[c]=[])).push(p)}for(const u of Object.values(i))u.sort((h,m)=>h.created.localeCompare(m.created));return{roots:a,children:i,projectIds:new Set(Object.entries(n).filter(([,u])=>u.loaded).map(([u])=>u))}}function Al(n,s,a){return n==="codex"&&(s==null?void 0:s.canCreateSession)!==!1?!0:a}function ks(n){return{id:n.workspaceId,name:n.name,description:n.roots[0]??"",created:n.updatedAt??"",updated:n.updatedAt??"",agentType:n.agentType,source:n.source,canCreateSession:n.canCreateSession}}function Fr(){return e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4h8v2"}),e.jsx("path",{d:"M19 6l-1 14H6L5 6"}),e.jsx("path",{d:"M10 11v5M14 11v5"})]})}function qr(n,s){s&&n.detail>0&&n.currentTarget.blur()}function Tl(){const n=document.activeElement;n instanceof HTMLElement&&(n.matches("input, textarea, select")||n.isContentEditable)&&n.blur()}function El(){var ar,cr,lr,dr;const[n]=r.useState(Ko),[s]=r.useState(()=>Ic(typeof window>"u"?"":window.location.search,n.activeAgent)),a=s.agentType,i=n.agents[a]??bs(),[c]=r.useState(()=>Hr(i.sessions,a)),u=r.useRef(n),[h,m]=r.useState(a),p=r.useRef(h);p.current=h;const[l,f]=r.useState(i.workspaces.map(ks)),[v,E]=r.useState(i.nextCursor),[C,w]=r.useState(i.watermark),[k,y]=r.useState(!1),[O,P]=r.useState(!1),[F,Q]=r.useState(null),[ce,te]=r.useState(!1),[M,W]=r.useState(c.roots),[z,K]=r.useState(""),[le,ne]=r.useState(!1),[se,re]=r.useState(null),[Ae,de]=r.useState(!1),[_,Z]=r.useState(null);r.useEffect(()=>{if(!le||!window.agentApi)return;let t=!1;return de(!0),Z(null),window.agentApi.listSessions().then(o=>{t||re({agentType:h,sessions:o})}).catch(o=>{t||Z(o instanceof Error?o.message:"会话搜索加载失败")}).finally(()=>{t||de(!1)}),()=>{t=!0}},[le,h]);const[Se,Te]=r.useState(10),[ve,D]=r.useState(null),[G,X]=r.useState(!1),[V,R]=r.useState(null),[ue,U]=r.useState(!1),[Be,Ie]=r.useState(0),[Y,rt]=r.useState([]),[je,ke]=r.useState([]),Re=Ts(),[Oe,Wt]=r.useState(c.children),_e=r.useRef(M),et=r.useRef(Oe);_e.current=M,et.current=Oe;const[ut,$t]=r.useState(c.projectIds),[g,S]=r.useState(new Set),[j,A]=r.useState({}),[T,$]=r.useState(new Set),[B,ae]=r.useState(Object.fromEntries(Object.entries(i.sessions).map(([t,o])=>[t,o.nextCursor]))),ye=r.useRef(new Map),ee=r.useRef(new Map),[ie,ze]=r.useState(i.selectedWorkspaceId),[q,be]=r.useState(()=>s.explicit||Ee.getState().navigationLayout==="all-sessions"?null:i.selectedSessionId),[He,Me]=r.useState(null),Ne=r.useRef(null);Ne.current=He;const[Le,hi]=r.useState(null),yt=r.useRef(null),Ps=r.useRef(0);yt.current=Le;const mn=r.useCallback(async()=>{const t=++Ps.current;try{const o=await Go();return t!==Ps.current?yt.current:(yt.current=o,hi(o),o)}catch{return yt.current}},[]);r.useEffect(()=>{mn();let t=!1;const o=()=>{!zt()||t||(t=!0,mn().finally(()=>{t=!1}))},d=window.setInterval(o,3e4);return window.addEventListener("focus",o),()=>{window.clearInterval(d),window.removeEventListener("focus",o)}},[mn]),r.useEffect(()=>{if(!q)return;const t=Le==null?void 0:Le.get(q);if(!t||t.currentSessionId===q)return;const o=Tn(t);o&&(Me(o),Jt(void 0),be(o.id))},[Le,q]);const Ge=r.useRef(ie),tt=r.useRef(q);Ge.current=ie,tt.current=q;const $n=gn(),Bn=gn(),[pt,vt]=r.useState(new Set(i.expandedWorkspaceIds)),[kt,Rs]=r.useState(new Set),[Ls,wn]=r.useState(!1),[Ds,Os]=r.useState(!1),[Bt,St]=r.useState(!1),[Ht,nt]=r.useState(!1),[gi,_s]=r.useState(),[mi,zs]=r.useState(0),Hn=()=>{St(!1),_s(void 0),zs(t=>t+1),nt(!0)};r.useEffect(()=>{var x,I;let t=0;const o=N=>{var J;if(!N.taskId&&!N.sessionId)return;const H=++t;if(Je(!1),Xe(!1),Ye(null),St(!1),N.taskId)(J=We.current)==null||J.abort(),We.current=null,it.current=null,It(null),_s(N.taskId),nt(!0),zs(fe=>fe+1);else if(N.sessionId){if(nt(!1),Ya(N.sessionId))return;window.agentApi.getSession(N.sessionId,{limit:1}).then(fe=>{if(H!==t)return;const ge=fe;Qe.current({kind:"session",session:{id:ge.id,agentType:ge.agentType??"customer-agent",title:ge.title,cwd:ge.cwd??"",projectId:ge.projectId??void 0}})}).catch(()=>{})}},d=N=>o(N.detail);window.addEventListener("agentroam:notification-open",d);const b=(I=(x=window.agentApi)==null?void 0:x.onNotificationOpen)==null?void 0:I.call(x,o);return()=>{t++,window.removeEventListener("agentroam:notification-open",d),b==null||b()}},[]),r.useEffect(()=>{nt(!1)},[q,ie]);const[Ms,Fn]=r.useState([]),[Fe,Ye]=r.useState(null),[jt,Xe]=r.useState(!1),[Ws,qn]=r.useState(!1),[Ct,Je]=r.useState(!1),[$s,bn]=r.useState(!1);r.useEffect(()=>{var t,o;(o=(t=window.agentApi)==null?void 0:t.setNotificationVisible)==null||o.call(t,{sessionId:!Ht&&!Bt&&!Ct&&!jt&&!Fe?q??void 0:void 0})},[q,Ht,Bt,Ct,jt,Fe]);const[wi,bi]=r.useState(0),[xi,yi]=r.useState(!1),[vi,Jt]=r.useState(),[Qt,It]=r.useState(null),Zt=r.useRef(null),[ki,Si]=r.useState({}),Qe=r.useRef(()=>{}),We=r.useRef(null),it=r.useRef(null),ji=r.useCallback((t,o)=>{const d=it.current;!d||d.sessionId!==t||d.seed!==o||We.current!==d.controller||d.controller.signal.aborted||(it.current=null,We.current=null,It(null),window.parent!==window&&window.parent.postMessage({type:Aa,sessionId:t},window.location.origin))},[]),Ci=r.useRef(`${Date.now()}-${Math.random().toString(36).slice(2)}`),Vn=$s||Ws||Ms.length>0,Un=()=>{if(nt(!1),dt()&&window.parent!==window){window.parent.postMessage({type:pn,intent:{kind:"dashboard"}},window.location.origin);return}bn(!0),Je(!0),Xe(!1),Ye(null)},Kn=()=>{nt(!1),qn(!0),Xe(!0),Ye(null),Je(!1)},[Ii,Gn]=r.useState(!1),[Bs,Hs]=r.useState(0),xn=t=>{dt()&&window.parent!==window?window.parent.postMessage({type:Ea,groupId:t.id,title:t.name},window.location.origin):(Je(!1),Xe(!1),Fn(o=>o.some(d=>d.id===t.id)?o:[...o,t]),Ye(t.id))},[At,Ai]=r.useState("settings"),Fs=Gt(t=>t.setTodos),en=Ee(t=>t.skin),ot=Ee(t=>t.layout),Ft=Ee(t=>t.navigationLayout),Ze=Ft==="all-sessions",Tt=Ee(t=>t.wakeEnabled),Et=Ee(t=>t.wakeWord),Ti=Ee(t=>t.setSkin),tn=Ee(t=>t.setLayout),Ei=Ee(t=>t.setWakeEnabled),Ni=Ee(t=>t.setWakeWord),ft=Ee(t=>t.runningFirst),Pi=Ee(t=>t.setRunningFirst),qs=Ee(t=>t.pinnedSessionIds),Yn=Ee(t=>t.togglePinnedSession),Ri=Ee(t=>t.removePinnedSessions),nn=new Set(qs),Xn=Gt(t=>t.runningSessionId),Jn=Gt(Ga(t=>Object.entries(t.messagesBySession).filter(([,o])=>ha(o)).map(([o])=>o))),sn=r.useCallback((t,o=t.projectId)=>ll({authoritativeStatus:t.status,locallyRunning:Xn===t.id,needsInput:Jn.includes(t.id),stale:!!(t.agentType===h&&o&&(T.has(o)||j[o]))}),[h,j,Xn,Jn,T]),Vs=r.useCallback(t=>{const o=sn(t);return o==="running"||o==="needs-input"},[sn]),Li=()=>{vt(new Set),$n.collapseAll()},Di=()=>{const t=l.filter(d=>!kt.has(d.id)),o=t.map(d=>d.id);vt(new Set(o));for(const d of t){const b=d.id;if(qe.current.has(b))continue;const x=mt.current.has(b),I=Al(p.current,d,x);Ve(b,{refresh:I,background:x})}},pe=dt(),qt=Gc(!pe);r.useEffect(()=>{if(!pe||window.parent===window)return;const t=o=>{Na(o,window.location.origin,window.parent)&&Gn(!0)};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[pe]);const Oi=ho(),_i=go(),xe=pe&&Oi,[Nt,at]=r.useState(!1),[rn,Qn]=r.useState(!1),[zi,Zn]=r.useState("files"),[Us,es]=r.useState(null),[Mi,Ks]=r.useState(null),ct=r.useMemo(()=>{var t;return!pe&&typeof((t=window.agentApi)==null?void 0:t.fileWorkspaceRequest)=="function"?cl(window.agentApi):null},[pe]),Wi=r.useCallback(async t=>{if(pe){mo(t);return}if(ct){if(t.startsWith("~/")){const{home:o}=await ct.request("hello"),d=wo(t,null,o);if(!d)return;t=d}Zn("files"),Qn(!0),es(t),Ks(o=>bo(t)?null:{path:t,requestId:((o==null?void 0:o.requestId)??0)+1})}},[ct,pe]);r.useEffect(()=>{es(null),Ks(null)},[ie]);const[yn,ts]=r.useState(!1),[vn,Gs]=r.useState(null),[$i,Ys]=r.useState(0),[Bi,Xs]=r.useState(void 0),ht=r.useRef(null),Pt=r.useRef(!1),[Hi,Js]=r.useState(null),Vt=r.useRef(null),ns=r.useRef(!1),gt=r.useRef(l);gt.current=l;const ss=r.useRef(kt);ss.current=kt;const mt=r.useRef(ut);mt.current=ut;const qe=r.useRef(g);qe.current=g;const on=r.useRef(null);r.useEffect(()=>{document.documentElement.setAttribute("data-skin",en)},[en]),r.useEffect(()=>{document.body.classList.toggle("layout-compact",ot==="compact")},[ot]),r.useEffect(()=>{var b;const t=l.map((x,I)=>({agentType:h,workspaceId:x.id,name:x.name,roots:x.description?[x.description]:[],order:I,updatedAt:x.updated||void 0,source:x.source??(x.agentType==="claude-code"?"derived":"native"),canCreateSession:x.canCreateSession})),o=Object.fromEntries(l.map(x=>[x.id,{data:jr(M[x.id]??[],Oe),nextCursor:B[x.id]??null,loaded:ut.has(x.id)}])),d={...u.current,version:2,activeAgent:h,agents:{...u.current.agents,[h]:{workspaces:t,nextCursor:v,watermark:C,expandedWorkspaceIds:[...pt],selectedWorkspaceId:ie,selectedSessionId:q,sidebarScrollTop:((b=on.current)==null?void 0:b.scrollTop)??0,sessions:o}}};u.current=d,Sr(d)},[h,Oe,pt,ut,l,ie,q,B,M,v,C]);const kn=r.useCallback(()=>{if(!window.agentApi||!Tt||Pt.current||ht.current)return;const t=()=>{rl()&&!ht.current&&(ht.current=il({wakeWord:Et,onWake:o=>{var d;Xs(o),Ys(b=>b+1),(d=window.agentApi)==null||d.showWindow()},onError:o=>console.warn("[wake]",o)}))};typeof window.agentApi.wakeStart=="function"?(Pt.current=!0,window.agentApi.wakeStart(Et).then(o=>{o.ok||(Pt.current=!1,t())}).catch(()=>{Pt.current=!1,t()})):t()},[Tt,Et]);r.useEffect(()=>{var t;if((t=window.agentApi)!=null&&t.onWake)return window.agentApi.onWake(o=>{Pt.current=!1,Xs(o),Ys(d=>d+1)})},[]),r.useEffect(()=>{var t;if((t=window.agentApi)!=null&&t.onWakeAiHub)return window.agentApi.onWakeAiHub(()=>{nt(!1),St(!0),tn("focus")})},[]),r.useEffect(()=>{var t;if((t=window.agentApi)!=null&&t.onWakeCommand)return window.agentApi.onWakeCommand(o=>{var I;const d=((o==null?void 0:o.text)||"").trim();if(!d)return;const b=Vt.current&&Date.now()<Vt.current.until?Vt.current:null;if(b){b.until=Date.now()+9e4,be(b.sessionId),(I=window.agentApi)==null||I.wakeConversation(!0),Js({text:d,projectId:null,sessionId:b.sessionId,nonce:Date.now()}),he(`语音追问:${d.length>40?d.slice(0,40)+"…":d}`),Pe("success"),setTimeout(()=>he(null),4e3);return}const x=gt.current.find(N=>N.name&&d.includes(N.name)&&!ss.current.has(N.id));x&&(ze(x.id),vt(N=>{const H=new Set(N);return H.add(x.id),H})),be(null),ns.current=!0,Js({text:d,projectId:(x==null?void 0:x.id)??null,nonce:Date.now()}),he(`语音指令:${d.length>40?d.slice(0,40)+"…":d}${x?`(项目:${x.name})`:""}`),Pe("success"),setTimeout(()=>he(null),4e3)})},[]);const Fi=r.useCallback(async()=>{window.agentApi&&(kn(),await window.agentApi.hideWindow())},[kn]),qi=r.useCallback(t=>{wn(!1),Gs({right:t.right,bottom:t.bottom}),ts(o=>!o)},[]),Vi=r.useCallback(()=>{ts(!1),wn(t=>!t)},[]);r.useEffect(()=>{if(!yn)return;const t=()=>{const d=document.querySelector(".chat-header-action--appearance");if(!d)return;const b=d.getBoundingClientRect();Gs(x=>(x==null?void 0:x.right)===b.right&&x.bottom===b.bottom?x:{right:b.right,bottom:b.bottom})},o=window.requestAnimationFrame(t);return window.addEventListener("resize",t),()=>{window.cancelAnimationFrame(o),window.removeEventListener("resize",t)}},[ot,yn]),r.useEffect(()=>{window.agentApi&&kn()},[kn]),r.useEffect(()=>{const t=()=>{var o;(o=ht.current)==null||o.stop(),ht.current=null};return window.addEventListener("focus",t),()=>window.removeEventListener("focus",t)},[]),r.useEffect(()=>{var t,o;Tt||((t=ht.current)==null||t.stop(),ht.current=null,Pt.current=!1,(o=window.agentApi)==null||o.wakeStop())},[Tt]),r.useEffect(()=>{!Tt||!window.agentApi||Pt.current&&window.agentApi.wakeStart(Et)},[Et]),r.useEffect(()=>()=>{var t;(t=ht.current)==null||t.stop()},[]);const Ui=[...Object.values(M).flat(),...Object.values(Oe).flat()],Qs=Yo((se==null?void 0:se.agentType)===h?se.sessions:[],Ui,h).map(t=>{var o;return{...t,projectId:t.projectId??((o=l.find(d=>d.description===t.cwd))==null?void 0:o.id)}}),rs=Rc(Qs,t=>nn.has(t.id)),Ki=Object.entries(M).flatMap(([t,o])=>o.filter(d=>nn.has(d.id)).map(d=>({projectId:t,session:d,created:d.created}))),Zs=Cs(Ki,h),er=ft?Is(Zs,({session:t})=>Vs(t)):Zs,Gi=Qs,Yi=r.useMemo(()=>Object.fromEntries(Object.entries(M).map(([t,o])=>[t,Xo(o,Le)])),[M,Le]),wt=z.trim().toLowerCase(),an=wt?rs.filter(t=>t.title.toLowerCase().includes(wt)||(t.cwd||"").toLowerCase().includes(wt)):null,cn=le?Mn(an?zn(an,rs):rs):[],Rt=q?Gi.find(t=>t.id===q)??((He==null?void 0:He.id)===q?He:void 0)??(Le!=null&&Le.get(q)?Tn(Le.get(q)):void 0):void 0,Xi=Rt==null?void 0:Rt.title,Ut=(Rt==null?void 0:Rt.cwd)||((ar=l.find(t=>t.id===ie))==null?void 0:ar.description)||null,is=l.filter(t=>!kt.has(t.id)).map(t=>t.id),Ji=[...l.filter(t=>!kt.has(t.id)),...l.filter(t=>kt.has(t.id))],Lt=is.length>0&&is.every(t=>!pt.has(t)),{width:Sn,collapsed:Kt,dragging:os,toggle:jn,resizeProps:Qi}=fl(),Dt=!xe&&(Kt||ot==="focus"),[Zi,he]=r.useState(null),[eo,Pe]=r.useState("success"),De=t=>{var b;nt(!1);const o=t.sessionId?(b=yt.current)==null?void 0:b.get(t.sessionId):void 0,d=o?Tn(o):void 0;d&&(t={...t,sessionId:d.id},Me(d)),Ge.current=t.projectId,tt.current=t.sessionId,ze(t.projectId),be(t.sessionId),t.sessionId||Fs([])},Ot=(t,o=!1)=>{var H;if(t===p.current&&!o)return;const d=p.current,b=u.current.agents[d];b&&(u.current={...u.current,agents:{...u.current.agents,[d]:{...b,sidebarScrollTop:((H=on.current)==null?void 0:H.scrollTop)??b.sidebarScrollTop}}});const x=u.current.agents[t]??bs(),I=Hr(x.sessions,t),N=x.workspaces.map(ks);p.current=t,gt.current=N,m(t),f(N),E(x.nextCursor),w(x.watermark),y(!1),P(!1),Q(null),_e.current=I.roots,et.current=I.children,W(I.roots),Wt(I.children),$t(I.projectIds),mt.current=I.projectIds,S(new Set),qe.current=new Set,A({}),$(new Set),ae(Object.fromEntries(Object.entries(x.sessions).map(([J,fe])=>[J,fe.nextCursor]))),vt(new Set(x.expandedWorkspaceIds)),Rs(new Set),De({projectId:x.selectedWorkspaceId,sessionId:x.selectedSessionId}),window.requestAnimationFrame(()=>{on.current&&(on.current.scrollTop=x.sidebarScrollTop)}),Ze||st(t,{refresh:x.workspaces.length>0,since:x.watermark,refreshLoadedSessions:!Ze})},ln=(t,o)=>{var fe,ge;(fe=We.current)==null||fe.abort(),We.current=null,it.current=null,It(null),Jt(void 0);const d=t??p.current,b=Ut;d!==p.current&&Ot(d);const x=u.current.agents[d],I=(x==null?void 0:x.workspaces)??[],N=b?I.find(L=>{var me;return L.canCreateSession!==!1&&((me=L.roots)==null?void 0:me.includes(b))}):void 0,H=x!=null&&x.selectedWorkspaceId&&I.some(L=>L.canCreateSession!==!1&&L.workspaceId===x.selectedWorkspaceId)?x.selectedWorkspaceId:void 0,J=o??(N==null?void 0:N.workspaceId)??H??((ge=I.find(L=>L.canCreateSession!==!1))==null?void 0:ge.workspaceId)??null;Zt.current=o||N||!b?null:{agentType:d,preferredPath:b},De({projectId:J,sessionId:null}),Gt.setState({sessionId:null,messages:[]}),Je(!1),bn(!1),Xe(!1),Ye(null),St(!1),ot==="focus"&&tn("standard"),bi(L=>L+1),xe&&at(!1)};r.useEffect(()=>{const t=Zt.current;if(!t)return;if(q!==null){Zt.current=null;return}if(h!==t.agentType)return;const o=t.preferredPath?l.find(d=>d.canCreateSession!==!1&&d.description===t.preferredPath):void 0;o&&(Zt.current=null,o.id!==ie&&De(En(o.id)))},[h,l,ie,q]);const as=(t,o,d=!1)=>{const b=u.current.agents[t.agentType]??bs();u.current={...u.current,agents:{...u.current.agents,[t.agentType]:{...b,workspaces:o.workspaces,nextCursor:d?b.nextCursor:null,selectedWorkspaceId:t.projectId??null,selectedSessionId:t.id,expandedWorkspaceIds:[...new Set([...b.expandedWorkspaceIds,...t.projectId?[t.projectId]:[]])],sessions:Object.fromEntries(o.workspaces.map(x=>{var I,N;return[x.workspaceId,{data:o.sessions.filter(H=>H.projectId===x.workspaceId),loaded:d?((I=b.sessions[x.workspaceId])==null?void 0:I.loaded)??!1:!0,nextCursor:d?((N=b.sessions[x.workspaceId])==null?void 0:N.nextCursor)??null:null}]}))}}},Ot(t.agentType,!0),Je(!1),Xe(!1),Ye(null),xe&&at(!1)};Qe.current=t=>{var d;if(pe&&window.parent!==window&&["dashboard","groups","group"].includes(t.kind)){window.parent.postMessage({type:pn,intent:t},window.location.origin);return}(d=We.current)==null||d.abort(),it.current=null;const o=new AbortController;We.current=o,It(t.kind==="session"?t.session:null),t.kind==="session"&&(Je(!1),Xe(!1),Ye(null),St(!1),xe&&at(!1)),(async()=>{if(t.kind==="dashboard"){Un();return}if(t.kind==="groups"){Kn();return}if(t.kind==="new-session"){ln();return}if(t.kind==="group"){const ge=t.discussionId,L=await xt({action:"group",groupId:t.groupId});Si(me=>({...me,[L.id]:ge})),xn(L);return}if(t.kind==="session"){const ge=yt.current,L=ge==null?void 0:ge.get(t.session.id),me=L?Tn(L):void 0;me&&(t={...t,session:{...t.session,...me}})}const b=t.kind==="agent"?t.agentType:t.session.agentType,x=je.some(ge=>ge.agentType===b)?je:await window.agentApi.getRuntimeHealth();if(o.signal.aborted)return;x!==je&&ke(x);const I=mr(b,x);if(I)throw new Error(I);if(t.kind==="agent"){Ot(t.agentType),Je(!1),Xe(!1),Ye(null),K(""),ne(!1),ot==="focus"&&tn("standard"),Kt&&jn(),xe&&at(!0);return}const N=u.current.agents[t.session.agentType],H=N?{workspaces:N.workspaces,sessions:Object.values(N.sessions).flatMap(ge=>ge.data)}:void 0,J=tt.current!==t.session.id&&Gt.getState().getMessagesForSession(t.session.id).length>0?Ac(t.session,H):void 0;if(J){Jt(void 0),it.current={controller:o,sessionId:J.session.id},as(J.session,J.snapshot,!0),It(null);return}const fe=await Tc(window.agentApi,t.session,o.signal,H);o.signal.aborted||(Jt(fe.initialHistory),as(fe.session,fe.snapshot,!0),it.current={controller:o,sessionId:fe.session.id,seed:fe.initialHistory})})().catch(b=>{o.signal.aborted||b instanceof Error&&b.name==="AbortError"||(he(b instanceof Error?b.message:"打开会话失败"),Pe("error"),setTimeout(()=>he(null),5e3))}).finally(()=>{var b;We.current===o&&((b=it.current)==null?void 0:b.controller)!==o&&(We.current=null,It(null))})},r.useEffect(()=>{document.body.dataset.agentroamChatNavigation="ready";const t=I=>{const N=Ar({data:{type:pn,intent:I.detail},origin:window.location.origin,source:window},window.location.origin,window);N&&Qe.current(N)},o=I=>{const N=Ar(I,window.location.origin,window.parent!==window?window.parent:null);N&&Qe.current(N)};window.addEventListener(pn,t),window.addEventListener("message",o),window.parent!==window&&window.parent.postMessage({type:Ta,instanceId:Ci.current},window.location.origin);const d=new URLSearchParams(location.search),b=d.get("session"),x=d.get("agent");return b?window.agentApi.getSession(b,b.startsWith("runtime:codex:")?{limit:1,view:"core"}:{limit:1}).then(I=>{const N=I;N.id&&hn(N.agentType)&&Qe.current({kind:"session",session:N})}).catch(I=>{he(I instanceof Error?I.message:"原会话不可访问"),Pe("error")}):d.get("newSession")==="1"?ln():hn(x)&&Qe.current({kind:"agent",agentType:x}),()=>{var I;delete document.body.dataset.agentroamChatNavigation,(I=We.current)==null||I.abort(),window.removeEventListener(pn,t),window.removeEventListener("message",o)}},[]);const[tr,nr]=r.useState([]),Cn=r.useCallback(t=>{nr(o=>o.filter(d=>d.id!==t))},[]),cs=r.useCallback(t=>{const o=crypto.randomUUID();nr(d=>[...d,{...t,id:o}]),setTimeout(()=>Cn(o),12e3)},[Cn]);async function st(t=p.current,o={}){if(!window.agentApi)return;const d=(ee.current.get(t)??0)+1;ee.current.set(t,d),y(!0),Q(null);try{const b=await window.agentApi.listAgentWorkspaces(t,{cursor:o.cursor,limit:50,refresh:o.refresh,since:o.refresh?o.since??C:null});if(p.current!==t||ee.current.get(t)!==d)return;const x=gt.current.map((L,me)=>({agentType:t,workspaceId:L.id,name:L.name,roots:L.description?[L.description]:[],order:me,updatedAt:L.updated,source:L.source??(t==="claude-code"?"derived":"native"),canCreateSession:L.canCreateSession})),N=ta(x,b,!o.cursor,tt.current?Ge.current:null).map(ks);gt.current=N,f(N),E(b.nextCursor),w(b.watermark),P(b.stale===!0);const H=new Set(N.map(L=>L.id)),J=Ge.current;J&&!H.has(J)&&De(ys);const fe=new Set([...mt.current].filter(L=>H.has(L)));if(J&&H.has(J)&&fe.add(J),W(L=>Object.fromEntries(Object.entries(L).filter(([me])=>H.has(me)))),$t(L=>{const me=new Set([...L].filter(oe=>H.has(oe)));return mt.current=me,me}),S(L=>{const me=new Set([...L].filter(oe=>H.has(oe)));return qe.current=me,me}),A(L=>Object.fromEntries(Object.entries(L).filter(([me])=>H.has(me)))),Ze)return;const ge=new Set;if(await Promise.all(N.map(async L=>{L.description&&!await window.agentApi.checkProjectPath(L.description)&&ge.add(L.id)})),p.current!==t||ee.current.get(t)!==d)return;if(Rs(ge),o.refreshLoadedSessions!==!1&&!Ze)for(const L of fe)ge.has(L)||qe.current.has(L)||Ve(L,{refresh:!0,background:!0})}catch(b){if(p.current!==t||ee.current.get(t)!==d)return;gt.current.length>0&&P(!0),Q(b instanceof Error?b.message:"目录加载失败")}finally{p.current===t&&ee.current.get(t)===d&&y(!1)}}async function Ve(t,o={}){var N;const d=window.agentApi;if(!d||na((N=u.current.agents[p.current])==null?void 0:N.workspaces.find(H=>H.workspaceId===t))||!o.force&&(o.cursor||o.background)&&qe.current.has(t))return;const b=p.current,x=`${b}:${t}`,I=(ye.current.get(x)??0)+1;ye.current.set(x,I),S(H=>{const J=new Set(H).add(t);return qe.current=J,J}),A(H=>{if(!(t in H))return H;const J={...H};return delete J[t],J});try{const H=await d.listAgentWorkspaceSessions(b,t,{cursor:o.cursor,limit:20,refresh:o.refresh});if(p.current!==b||ye.current.get(x)!==I)return;const J=_e.current[t]??[],fe=o.pendingSession?{...o.pendingSession,projectId:t}:void 0,ge=fe?[fe,...J.filter(oe=>oe.id!==fe.id)]:J,L=jr(ge,et.current),me=oe=>{var fr,hr,gr;if(p.current!==b||ye.current.get(x)!==I)return;const lt=sa(L,oe,!o.cursor,Ge.current===t?tt.current:null).map(we=>({...we,projectId:we.projectId??t})),fs=Cs(lt.filter(we=>!we.parentSessionId),b),In=Ge.current,dn=tt.current,ur=ra(fs,fe);In===t&&dn&&((fr=Ne.current)==null?void 0:fr.id)!==dn&&!((hr=yt.current)!=null&&hr.has(dn))&&!lt.some(we=>we.id===dn)&&!ur.some(we=>we.id===dn)&&De(ys);const un={};for(const we of lt.filter(Ue=>Ue.parentSessionId))(un[gr=we.parentSessionId]??(un[gr]=[])).push(we);for(const we of Object.values(un))we.sort((Ue,uo)=>Ue.created.localeCompare(uo.created));ae(we=>({...we,[t]:ia(L,oe,!o.cursor,we[t])})),$(we=>{const Ue=new Set(we);return oe.stale?Ue.add(t):Ue.delete(t),Ue});const pr={..._e.current,[t]:ur},An={...et.current};for(const we of L)delete An[we.id];for(const[we,Ue]of Object.entries(un))An[we]=Ue;_e.current=pr,et.current=An,W(pr),Wt(An),$t(we=>{const Ue=new Set(we).add(t);return mt.current=Ue,Ue})};if(me(H),o.refresh&&!o.cursor){const oe=await oa(L,H,lt=>d.listAgentWorkspaceSessions(b,t,{cursor:lt,limit:200,refresh:!1}),fe==null?void 0:fe.id);oe!==H&&me(oe)}}catch(H){if(ye.current.get(x)!==I)return;$(J=>new Set(J).add(t)),A(J=>({...J,[t]:H instanceof Error?H.message:"会话加载失败"}))}finally{ye.current.get(x)===I&&S(H=>{const J=new Set(H);return J.delete(t),qe.current=J,J})}}const to=async t=>{if(!window.agentApi)return;const o=await window.agentApi.listChildSessions(t);Wt(d=>({...d,[t]:o.sort((b,x)=>b.created<x.created?-1:1)}))},ls=xi&&!Bt&&!Ht&&!Ct&&!jt&&!Fe,no=(t,o)=>{const d=gt.current.find(b=>b.id===t);if(!(!d||d.canCreateSession===!1)){if(ls){ds(o,d.description||void 0);return}ln(o,t)}},ds=(t=p.current,o=Ut||void 0)=>{aa({agentType:t,workspacePath:o}).catch(d=>{he(d instanceof Error?d.message:"无法打开新会话窗口,请重试"),Pe("error")})},sr=()=>{ls?ds():ti({kind:"new-session"})};r.useEffect(()=>{var t;window.agentApi&&(st(p.current,{refresh:(((t=u.current.agents[p.current])==null?void 0:t.workspaces.length)??0)>0}),Jo.getState().loadFromSystem())},[]),r.useEffect(()=>{if(!Re||!window.agentApi)return;let t=!1,o;const d=async()=>{let b=3e4;try{const x=await window.agentApi.getRuntimeHealth();t||ke(x)}catch{b=3e3}finally{t||(o=window.setTimeout(d,b))}};return d(),()=>{t=!0,window.clearTimeout(o)}},[Re]),r.useEffect(()=>{if(!je.length||tt.current||!mr(p.current,je))return;const[t]=Kr(je);t&&Ot(t)},[je]),r.useEffect(()=>{if(Ze)return;const t=window.setInterval(()=>{!zt()||k||st(h,{refresh:!0,since:C,refreshLoadedSessions:!1})},15e3);return()=>window.clearInterval(t)},[h,Ze,k,C]),r.useEffect(()=>{if(!window.agentApi||Ze)return;let t=!1;const o=()=>{if(t||!zt())return;const I=dl(ie,pt),N=ul(I,ss.current,qe.current);for(const H of N)Ve(H,{refresh:!0,background:mt.current.has(H)})},d=()=>{zt()&&o()};xe&&Nt&&o();const b=window.setInterval(o,1e4);window.addEventListener("focus",o),window.addEventListener("pageshow",o),document.addEventListener("visibilitychange",d);const x=pe&&window.parent!==window?window.parent:null;return x==null||x.addEventListener("focus",o),x==null||x.addEventListener("pageshow",o),()=>{t=!0,window.clearInterval(b),window.removeEventListener("focus",o),window.removeEventListener("pageshow",o),document.removeEventListener("visibilitychange",d),x==null||x.removeEventListener("focus",o),x==null||x.removeEventListener("pageshow",o)}},[h,Ze,pt,ie,xe,Nt,pe]),r.useEffect(()=>{if(!ie||!window.agentApi)return;const t=l.find(d=>d.id===ie),o=t==null?void 0:t.description;o&&window.agentApi.setProjectWorkingDir(o)},[ie,l]);const so=t=>{De(En(t));const o=!pt.has(t);if(vt(d=>{const b=new Set(d);return o?b.add(t):b.delete(t),b}),o){const d=mt.current.has(t);Ve(t,{refresh:!0,background:d,force:!0})}},rr=async t=>{if(!window.agentApi)throw new Error("agentApi 未就绪,请重启应用");const o=t.replace(/\\/g,"/"),d=o.split("/").filter(Boolean),b=d[d.length-1]||o||"导入的项目",x=await window.agentApi.importAgentWorkspace(p.current,o,b);await st(p.current,{refresh:!0,refreshLoadedSessions:!1}),De(En(x.workspace.workspaceId)),await Ve(x.workspace.workspaceId,{refresh:!0}),vt(I=>{const N=new Set(I);return N.add(x.workspace.workspaceId),N}),he(x.existing?"该文件夹已在当前 Agent 的目录中":`已导入:${x.workspace.name}`),Pe(x.existing?"info":"success"),setTimeout(()=>he(null),3e3)},ir=async()=>{try{if(!window.agentApi){he("agentApi 未就绪,请重启应用"),Pe("error");return}if(pe){te(!0);return}const t=await window.agentApi.openFileDialog();if(console.log("[import] selectedPath:",t),!t)return;await rr(t)}catch(t){console.error("[import] error:",t),he(t instanceof Error?t.message:String(t)),Pe("error"),setTimeout(()=>he(null),5e3)}},ro=async t=>{if(window.agentApi)try{await window.agentApi.deleteProject(t),ie===t&&(ze(null),be(null),Fs([])),he("项目删除成功"),Pe("success"),setTimeout(()=>he(null),2500),await st()}catch(o){he(o instanceof Error?o.message:"项目删除失败"),Pe("error"),setTimeout(()=>he(null),4e3)}},io=(t,o,d)=>{var I;const b=(I=window.agentApi)==null?void 0:I.showDirectoryContextMenu,x=al(o,{isInvalid:d,supported:typeof b=="function",webShell:pe});!x||!b||(t.preventDefault(),b(x).catch(N=>{he(N instanceof Error?N.message:"无法打开当前文件夹"),Pe("error"),setTimeout(()=>he(null),4e3)}))},us=(t,o)=>{D({session:t,anchor:o})},oo=(t,o)=>{const d=o.getBoundingClientRect();R({project:t,agentType:p.current,anchor:{top:d.top,left:d.left,width:d.width,height:d.height}})},ao=async()=>{if(!window.agentApi||!V||ue)return;const{project:t,agentType:o}=V;U(!0);try{await window.agentApi.removeInvalidAgentWorkspace(o,t.id),p.current===o&&Ge.current===t.id&&De(ys),he(`已移除失效目录「${t.name}」`),Pe("success"),setTimeout(()=>he(null),2500),p.current===o&&await st(o,{refresh:!0})}catch(d){he(d instanceof Error?d.message:"目录删除失败"),Pe("error"),setTimeout(()=>he(null),4e3)}finally{U(!1),R(null)}},co=async()=>{if(!window.agentApi||!ve||G)return;const{session:t}=ve;X(!0);try{await window.agentApi.deleteSession(t.id);const o=t.projectId??Ge.current,d=t.agentType;if(o){const I=`${d}:${o}`;ye.current.set(I,(ye.current.get(I)??0)+1)}const b=_c(_e.current,et.current,[],t.id);rt(I=>[...new Set([...I,...b.removedIds])]),Qa(b.removedIds),_e.current=b.sessionsByProject,et.current=b.childSessionsByParent,W(b.sessionsByProject),Wt(b.childSessionsByParent),Ri(b.removedIds);const x=u.current.agents[d];if(x){const I={...u.current,agents:{...u.current.agents,[d]:Dc(x,b.removedIds)}};u.current=I,Sr(I)}tt.current&&b.removedIds.includes(tt.current)&&De({projectId:Ge.current,sessionId:null}),he("会话删除成功"),Pe("success"),setTimeout(()=>he(null),2500),D(null),Ie(I=>I+1),o&&d===p.current&&Ve(o,{refresh:!0,background:!0})}catch(o){he(o instanceof Error?o.message:"会话删除失败"),Pe("error"),setTimeout(()=>he(null),4e3)}finally{X(!1)}},lo=[{id:"settings",label:"设置"},{id:"mcp",label:"MCP"},{id:"memory",label:"记忆"},{id:"skill",label:"技能"},{id:"agent",label:"智能体"},{id:"lsp",label:"LSP"}],ps=(t,o)=>{const d=q===t.id,b=Dn(sn(t,o)),x=Oe[t.id]??[],I=!!t.parentSessionId,N=$n.expandedIds.has(t.id);return e.jsxs("div",{className:"sidebar-session-tree",children:[e.jsx(_n,{session:{id:t.id,title:t.title,visualState:b,statusLabel:Rn[b],completedAt:Ln(t),occupiedExternally:t.agentType!=="codex"&&t.occupancy==="owned-externally",canDelete:t.canDelete,active:d,child:I,expanded:N,compatibility:t.compatibility,pinned:nn.has(t.id)},onSelect:()=>{xe&&at(!1),De(Rr(o,t.id))},onToggleChildren:x.length?()=>$n.toggle(t.id):void 0,onPin:I?void 0:()=>Yn(t.id),deleteLabel:I?"删除子会话":void 0,onDelete:H=>us(t,H)}),N&&x.length>0&&e.jsx("div",{className:"sidebar-session-children",role:"group","aria-label":`${t.title}的子会话`,children:x.map(H=>ps(H,o))})]},t.id)},or=({session:t,children:o})=>{const d=Dn(sn(t)),b=Bn.expandedIds.has(t.id);return e.jsxs("div",{children:[e.jsx(_n,{session:{id:t.id,title:t.title,visualState:d,statusLabel:Rn[d],completedAt:Ln(t),occupiedExternally:t.agentType!=="codex"&&t.occupancy==="owned-externally",canDelete:t.canDelete,active:q===t.id,child:!!t.parentSessionId,expanded:b,compatibility:t.compatibility,pinned:nn.has(t.id)},onSelect:()=>{const x=t.projectId&&l.some(I=>I.id===t.projectId)?t.projectId:null;De(Rr(x,t.id)),ne(!1),xe&&at(!1)},onPin:t.parentSessionId?void 0:()=>Yn(t.id),onToggleChildren:o.length?()=>Bn.toggle(t.id):void 0,onDelete:x=>us(t,x)}),b&&o.length>0&&e.jsx("div",{className:"sidebar-session-children",role:"group","aria-label":`${t.title}的子会话`,children:o.map(or)})]},t.id)};return e.jsx(xo,{api:window.agentApi,enabled:document.body.dataset.nativeApp!=="1"&&(!pe||window.parent===window),product:pe?"AgentRoam CLI":"AgentRoam",scope:pe?"cli":"desktop",hint:pe?"更新期间电脑服务会短暂重启":void 0,children:e.jsxs("div",{className:`app-shell${Dt?" is-sidebar-collapsed":""}${os?" is-sidebar-dragging":""}${Vn?" has-workspace-tabs":""}`,"data-desktop-platform":!pe&&/Mac/.test(navigator.platform)?"darwin":void 0,style:{display:"flex",height:pe?"100dvh":"100vh",width:"100vw",background:"var(--bg-deepest)",position:"relative",overflow:"hidden",boxSizing:"border-box",paddingTop:Vn?52:0},children:[e.jsx(Cc,{onOpen:Un}),Ii&&Ke.createPortal(e.jsx(ga,{cwd:Ut||void 0,health:je,onClose:()=>Gn(!1),onCreated:t=>{Gn(!1),Hs(o=>o+1),xn(t)}}),document.body),Vn&&e.jsx(Ec,{groups:Ms,dashboardVisible:Ws,sessionDashboardVisible:$s,activeId:Ct?"sessions":jt?"dashboard":Fe??"assistant",onSelect:t=>{Je(t==="sessions"),Xe(t==="dashboard"),Ye(["assistant","dashboard","sessions"].includes(t)?null:t)},onClose:t=>{t==="sessions"?(bn(!1),Je(!1)):t==="dashboard"?(qn(!1),Xe(!1)):(Fn(o=>o.filter(d=>d.id!==t)),Fe===t&&Ye(null))}}),(Fe||jt||Ct)&&e.jsx("div",{className:"collab-desktop-overlay",children:e.jsx("div",{className:"collab-desktop-body",children:e.jsx(r.Suspense,{fallback:e.jsx(_t,{label:"正在打开工作区"}),children:Ct?e.jsx(gl,{onNewSession:sr,onOpenGroup:t=>Qe.current({kind:"group",groupId:t.group.id,title:t.group.name,discussionId:t.discussionId}),onOpenSession:t=>Qe.current({kind:"session",session:t}),onViewAgent:t=>Qe.current({kind:"agent",agentType:t}),onViewGroups:Kn,onClose:()=>{Je(!1),bn(!1)}}):jt?e.jsx(hl,{cwd:Ut||void 0,onOpen:xn,onClose:()=>{Xe(!1),qn(!1)},onChanged:(t,o)=>{Hs(d=>d+1),Fn(d=>o?d.map(b=>b.id===t?o:b):d.filter(b=>b.id!==t)),!o&&Fe===t&&Ye(null)}}):Fe&&e.jsx(ml,{groupId:Fe,initialDiscussionId:ki[Fe]},`${Fe}-${Bs}`)})})}),e.jsx(Nc,{}),!xe&&e.jsx(el,{hidden:!Dt,value:h,health:je,selectedSessionId:q,getActivity:sn,onChange:Ot,onSelect:as,onNewSession:t=>{ls?ds(t):ln(t)}}),xe&&Nt&&e.jsx("div",{className:"mobile-drawer-scrim",onClick:()=>at(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,.45)",zIndex:1150}}),xe&&!Nt&&e.jsx("button",{className:"mobile-drawer-toggle",onClick:()=>at(!0),"aria-label":"会话列表","aria-expanded":!1,style:{position:"fixed",top:"calc(env(safe-area-inset-top) + 8px)",left:10,zIndex:1250,width:34,height:34,borderRadius:9,border:"1px solid var(--border-default)",background:"var(--bg-glass, rgba(18,20,28,.82))",color:"var(--text-secondary)",display:"grid",placeItems:"center",backdropFilter:"blur(8px)",WebkitAppRegion:"no-drag",cursor:"pointer"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M3 6h18M3 12h18M3 18h18"})})}),e.jsx("div",{className:"app-accent-glow",style:{position:"absolute",top:"-120px",left:"-80px",width:320,height:320,borderRadius:"50%",background:"radial-gradient(circle, var(--accent-glow) 0%, transparent 70%)",pointerEvents:"none",zIndex:0}}),ot!=="focus"&&e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:`app-sidebar${Ft==="agent-rail"?" has-agent-navigation":""}${Ze?" has-all-sessions":""}`,id:"workspace-sidebar","aria-hidden":Dt||xe&&!Nt,ref:t=>{t&&(t.inert=Dt||xe&&!Nt)},style:{width:Sn,flexShrink:0,marginLeft:Dt?-Sn:0,display:"flex",flexDirection:"column",background:"var(--bg-surface)",borderRight:"1px solid var(--border-subtle)",padding:pe?"12px 0 0":"56px 0 0",position:"relative",zIndex:10,overflow:"hidden",...xe?{position:"fixed",top:0,bottom:0,left:0,width:"min(82vw, 320px)",zIndex:1200,transform:Nt?"translateX(0)":"translateX(-103%)",transition:"transform .24s ease",boxShadow:"12px 0 32px rgba(0,0,0,.5)",padding:"calc(env(safe-area-inset-top) + 12px) 0 0"}:{}},children:[!pe&&e.jsx("div",{className:"sidebar-window-drag-region","aria-hidden":"true"}),Ft==="agent-rail"?e.jsx(Qc,{value:h,health:je,onClose:()=>{xe?at(!1):jn()}}):e.jsx("div",{className:"app-sidebar-brand",style:{padding:"0 20px 10px"},children:e.jsxs("div",{className:"sidebar-brand-row",children:[e.jsx("div",{className:"sidebar-brand-mark","aria-hidden":"true",children:e.jsx(Xt,{agentType:"customer-agent",size:24})}),e.jsx("span",{className:"sidebar-brand-name",children:"AgentRoam"}),e.jsxs("div",{className:"sidebar-brand-actions",children:[e.jsx(pi,{}),!pe&&Ft==="classic"&&e.jsx(zr,{onOpenCalendar:Hn})]})]})}),Ze?e.jsx(kc,{deletedSessionIds:Y,selectedSessionId:q,pendingSession:He,runningSessionId:Xn,needsInput:Jn,pinnedIds:qs,revision:Be,onSelect:t=>Qe.current({kind:"session",session:t}),onPin:Yn,onDelete:us}):e.jsxs(e.Fragment,{children:[e.jsx(Gr,{vertical:Ft==="agent-rail",value:h,health:je,onChange:Ot}),e.jsxs("button",{type:"button",className:"sidebar-search-field",onClick:()=>{Bn.collapseAll(),ne(!0),Te(10)},title:"搜索会话","aria-label":"搜索会话",children:[e.jsx(Wn,{size:15,"aria-hidden":"true"}),e.jsx("span",{children:"搜索会话"}),e.jsx("kbd",{children:"⌘ K"})]}),e.jsxs("div",{className:"sidebar-project-toolbar",children:[e.jsxs("div",{className:"sidebar-project-heading",children:[e.jsx("span",{className:"sidebar-project-title",children:"目录"}),e.jsx("span",{className:"sidebar-project-count","aria-label":`${l.length} 个目录`,children:l.length})]}),e.jsxs("div",{className:"sidebar-project-actions",children:[e.jsx("button",{type:"button",onClick:t=>{Lt?Di():Li(),qr(t,Lt)},title:Lt?"展开全部目录":"折叠全部目录","aria-label":Lt?"展开全部目录":"折叠全部目录","aria-pressed":Lt,disabled:is.length===0,className:`ui-icon-button sidebar-collapse-all${Lt?" is-active":""}`,children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:Lt?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m7 6 5 5 5-5"}),e.jsx("path",{d:"m7 13 5 5 5-5"})]}):e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"m17 11-5-5-5 5"}),e.jsx("path",{d:"m17 18-5-5-5 5"})]})})}),e.jsx("button",{type:"button",onClick:t=>{Pi(!ft),qr(t,ft)},title:ft?"按新建时间排序":"进行中会话优先","aria-label":ft?"按新建时间排序":"进行中会话优先","aria-pressed":ft,className:`ui-icon-button sidebar-session-sort${ft?" is-active":""}`,children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M3 6h10M3 12h7M3 18h4"}),e.jsx("path",{d:"m15 9 3-3 3 3M18 6v12"})]})}),e.jsx(di,{loading:k,error:l.length>0?null:F,onRefresh:()=>void st(h,{refresh:!0})}),e.jsx("button",{type:"button",onClick:()=>void ir(),title:"导入目录","aria-label":"导入目录",className:"ui-icon-button",children:e.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]})]}),e.jsx("div",{ref:on,className:"app-sidebar-scroll",onPointerDownCapture:Tl,onScroll:t=>{const o=t.currentTarget;if(o.scrollHeight-o.scrollTop-o.clientHeight<120&&v&&!k&&st(h,{cursor:v}),xe){const b=o.getBoundingClientRect(),x=o.querySelectorAll("[data-sidebar-project-id]");for(const I of x){const N=I.dataset.sidebarProjectId;if(!N||!pt.has(N))continue;const H=I.getBoundingClientRect();if(H.bottom<b.top||H.bottom>b.bottom+120)continue;const J=B[N];J&&!qe.current.has(N)&&Ve(N,{cursor:J})}}},style:{minHeight:0,flex:1,overflow:"auto",padding:"0 10px"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,marginBottom:12},children:[er.length>0&&e.jsxs("section",{className:"sidebar-pinned-section","aria-label":"置顶会话",children:[e.jsx("div",{className:"sidebar-pinned-heading",children:"置顶"}),er.map(({projectId:t,session:o})=>ps(o,t))]}),Ji.map(t=>{var me;const o=ie===t.id&&q===null,d=pt.has(t.id),b=ut.has(t.id),x=g.has(t.id),I=j[t.id],N=Yi[t.id]??[],H=N.filter(oe=>!nn.has(oe.id)),fe=ft?Is(H,Vs):H,ge=fe.length>10,L=kt.has(t.id);return e.jsxs("div",{className:"sidebar-project-block","data-sidebar-project-id":t.id,"aria-busy":x,children:[e.jsxs("div",{className:`sidebar-row sidebar-project-row${L?" sidebar-project-row--invalid":""} ${o&&!L?"sidebar-row-active":""}`,onContextMenu:oe=>io(oe,t,L),style:{paddingRight:4},children:[e.jsxs("button",{className:"sidebar-project-button",onClick:()=>{L||so(t.id)},disabled:L,"aria-expanded":d,"aria-pressed":o,title:L?`路径不存在:${t.description}`:t.name,style:{flex:1,display:"flex",alignItems:"center",gap:8,minWidth:0,padding:"8px 10px",border:"none",background:"transparent",color:L?"var(--text-muted)":o?"var(--accent)":"var(--text-secondary)",fontSize:13,fontWeight:o&&!L?600:400,cursor:L?"not-allowed":"pointer",textAlign:"left",transition:"color 0.15s"},children:[L?e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:.6},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}):t.canCreateSession===!1?e.jsx(La,{size:13,"aria-hidden":"true",style:{flexShrink:0,opacity:o?1:.5}}):e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,opacity:o?1:.5},children:d?e.jsx("path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6A2 2 0 0 1 18.46 20H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"}):e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.name})]}),h==="customer-agent"&&!pe&&!L&&t.canCreateSession!==!1?e.jsx("button",{onClick:oe=>{oe.stopPropagation(),ro(t.id)},title:"删除目录","aria-label":`删除目录:${t.name}`,className:"sidebar-project-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",style:{flexShrink:0},children:e.jsx(Fr,{})}):L?e.jsx("button",{onClick:oe=>{oe.stopPropagation(),oo(t,oe.currentTarget)},title:"删除失效目录","aria-label":`删除失效目录:${t.name}`,className:"sidebar-project-delete sidebar-row-action ui-icon-button ui-icon-button--small ui-icon-button--danger",style:{flexShrink:0},children:e.jsx(Fr,{})}):null,!L&&t.canCreateSession!==!1&&e.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),no(t.id,h)},title:`在 ${t.name} 中新建会话`,"aria-label":`在 ${t.name} 中新建会话`,disabled:L||((me=je.find(oe=>oe.agentType===h))==null?void 0:me.available)===!1,className:"sidebar-runtime-create sidebar-project-add-action ui-icon-button ui-icon-button--small",children:e.jsx(Nn,{size:13,"aria-hidden":"true"})})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gridTemplateRows:d?"minmax(0, 1fr)":"minmax(0, 0fr)",overflow:"clip",opacity:d?1:0,transition:"grid-template-rows 0.45s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease"},children:e.jsxs("div",{className:"sidebar-project-sessions",onScroll:oe=>{const lt=oe.currentTarget,fs=lt.scrollHeight-lt.scrollTop-lt.clientHeight<80,In=B[t.id];fs&&In&&!x&&Ve(t.id,{cursor:In})},style:{display:"flex",flexDirection:"column",minHeight:0,gap:1,marginTop:2,paddingLeft:10,paddingBottom:4,...ge&&!xe?{maxHeight:280,overflowY:"auto"}:{}},children:[fe.map(oe=>ps(oe,t.id)),x&&!b&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"正在加载会话..."}),I&&!B[t.id]&&e.jsxs("div",{title:I,style:{display:"flex",alignItems:"center",gap:8,color:"var(--danger)",fontSize:11,padding:"4px 10px"},children:[e.jsx("span",{style:{flex:1},children:"会话加载失败"}),e.jsx("button",{type:"button",onClick:()=>void Ve(t.id,{refresh:b,background:b}),style:{border:0,background:"transparent",color:"inherit",fontSize:11,cursor:"pointer",padding:0},children:"重试"})]}),T.has(t.id)&&!I&&e.jsx("div",{className:"sidebar-cache-state",children:"显示缓存,会话将在下次刷新时更新"}),N.length===0&&b&&!x&&!I&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:11,padding:"4px 10px",opacity:.7},children:"暂无会话"}),e.jsx(Sc,{cursor:B[t.id]??null,expanded:d&&b&&!L,loading:x,error:I,nestedScroll:ge&&!xe,projectName:t.name,onLoadMore:()=>{const oe=B[t.id];oe&&Ve(t.id,{cursor:oe})}})]})})]},t.id)}),l.length===0&&k&&e.jsx("div",{className:"sidebar-directory-skeleton","aria-hidden":"true",children:[0,1,2].map(t=>e.jsxs("div",{children:[e.jsx("span",{}),e.jsx("span",{})]},t))}),l.length===0&&!k&&!F&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"24px 10px",textAlign:"center",opacity:.7},children:"暂无目录"}),F&&l.length>0&&e.jsxs("div",{className:"sidebar-cache-state sidebar-cache-state--action",role:"status",title:F,children:[e.jsx("span",{children:"当前显示缓存目录"}),!k&&e.jsx("button",{type:"button",onClick:()=>void st(h,{refresh:!0}),children:"重试"})]}),O&&!F&&e.jsx("div",{className:"sidebar-cache-state",children:"当前显示缓存目录"}),F&&l.length===0&&e.jsxs("div",{className:"sidebar-load-error",title:F,children:[e.jsx("span",{children:"目录加载失败"}),e.jsx("button",{type:"button",onClick:()=>void st(h,{refresh:!1}),children:"重试"})]})]})})]}),e.jsxs("div",{className:"sidebar-bottom-action",children:[!Ze&&e.jsx(jc,{refreshKey:Bs,onOpen:xn}),e.jsxs("button",{type:"button",className:"sidebar-new-session-primary",title:"新建会话",onClick:sr,children:[e.jsx(Nn,{size:16,"aria-hidden":"true"}),e.jsx("span",{children:"新建会话"})]})]})]}),ve&&e.jsx(Wr,{message:Lc(ve.session),anchor:ve.anchor,mobile:xe,pending:G,onCancel:()=>D(null),onConfirm:()=>void co()}),V&&e.jsx(Wr,{title:"删除失效目录",message:`目录「${V.project.name}」的路径(${V.project.description||"未知"})已不存在。确定从目录列表移除?历史会话记录会保留。`,anchor:V.anchor,mobile:xe,pending:ue,onCancel:()=>R(null),onConfirm:()=>void ao()}),!xe&&e.jsx("div",{className:`app-sidebar-resizer${os?" is-dragging":""}`,...Qi,role:"separator","aria-label":"调整目录与会话列表宽度","aria-controls":"workspace-sidebar","aria-orientation":"vertical","aria-valuemin":220,"aria-valuemax":480,"aria-valuenow":Sn,tabIndex:Kt?-1:0,hidden:Kt&&!os,style:{left:Kt?0:Sn}}),le&&e.jsx("div",{onClick:()=>ne(!1),style:{position:"fixed",inset:0,zIndex:1300,background:"rgba(17,24,39,0.34)",backdropFilter:"blur(2px)",WebkitBackdropFilter:"blur(2px)",display:"flex",alignItems:"flex-start",justifyContent:"center",padding:"12vh 16px 16px"},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{width:"min(560px, 100%)",maxHeight:"64vh",display:"flex",flexDirection:"column",borderRadius:12,border:"1px solid var(--border-default)",background:"var(--bg-surface)",boxShadow:"0 18px 48px rgba(17,24,39,0.28)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:10,borderBottom:"1px solid var(--border-subtle)"},children:e.jsx("input",{autoFocus:!0,value:z,onChange:t=>K(t.target.value),onKeyDown:t=>{t.key==="Escape"&&ne(!1)},placeholder:"搜索所有会话(标题或目录)…","aria-label":"搜索所有会话",style:{width:"100%",padding:"9px 12px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-glass)",color:"var(--text-primary)",fontSize:14,outline:"none",fontFamily:"var(--font-body)",boxSizing:"border-box"}})}),e.jsxs("div",{style:{overflowY:"auto",padding:8},children:[Ae&&e.jsx("div",{role:"status",children:"正在加载所有会话"}),_&&e.jsx("div",{role:"alert",children:_}),wt&&an&&an.length>0&&e.jsxs("div",{style:{padding:"4px 10px 3px",fontSize:9,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-muted)"},children:[an.length," 个结果"]}),!Ae&&!_&&wt&&cn.length===0&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"无匹配会话"}),!Ae&&!_&&!wt&&cn.length===0&&e.jsx("div",{style:{color:"var(--text-muted)",fontSize:12,padding:"16px 10px",textAlign:"center",opacity:.7},children:"暂无会话"}),(wt?cn:cn.slice(0,Se)).map(or),!wt&&cn.length>Se&&e.jsx("button",{type:"button",onClick:()=>Te(t=>t+10),style:{width:"100%",padding:"8px 10px",border:0,borderTop:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-muted)",fontSize:12,cursor:"pointer",textAlign:"center"},children:"更多…"})]})]})})]}),e.jsx(nl,{message:Zi,type:eo}),e.jsx(Qo,{viewedSessionId:Ht||Bt||Ct||jt||Fe||Qt?null:q}),e.jsxs("main",{className:`app-main${ct?" file-workspace-capable":""}${rn&&ct?" file-workspace-open":""}${rn&&ct&&Us?" file-workspace-preview-open":""}`,style:{flex:1,minWidth:0,marginLeft:Dt?56:0,overflow:"hidden",background:"var(--bg-workspace)",position:"relative",zIndex:5},children:[e.jsx("div",{className:"app-chat-surface","aria-hidden":Qt?!0:void 0,ref:t=>{t&&(t.inert=!!Qt)},style:{height:"100%",paddingTop:0,display:Bt||Ht?"none":void 0,background:"var(--chat-history-bg)"},children:e.jsx(vc,{onSplitChange:yi,enabled:_i||!pe&&!yo(),onOpenCalendar:Hn,onFocusSession:t=>{tt.current=t.id,Ge.current=t.projectId??null,Me(t),be(t.id),ze(t.projectId??null)},onNavigateSession:t=>Qe.current({kind:"session",session:t}),onSessionCreated:t=>{if(t.projectId&&t.agentType===p.current){const o=t.projectId;W(d=>({...d,[o]:[t,...(d[o]??[]).filter(b=>b.id!==t.id)]}))}Ie(o=>o+1)},children:e.jsx(Zo,{sidebarCollapsed:Dt,onToggleSidebar:xe?void 0:()=>{ot==="focus"?(tn("standard"),Kt&&jn()):jn()},onOpenCollaborationDashboard:pe?void 0:Kn,onOpenSessionDashboard:pe?void 0:Un,activeAgentType:h,selectedProjectId:ie,selectedSessionId:q,sessionTitle:Xi,sessionSummary:Rt,initialSessionHistory:vi,sessionNavigationPending:!!Qt,onSessionHistorySettled:ji,workspacePath:Ut,workspaceSource:(cr=l.find(t=>t.id===ie))==null?void 0:cr.source,runtimeHealth:je,onSelectAgent:ln,workspaces:l.map(t=>({id:t.id,name:t.name,path:t.description,canCreateSession:t.canCreateSession})),onSelectWorkspace:t=>{Zt.current=null,De(En(t)),vt(o=>new Set(o).add(t))},onPickWorkspaceFolder:()=>void ir(),focusComposerNonce:wi,voiceCommand:Hi,onOpenSettings:Vi,settingsOpen:Ls,desktopLiveOpen:Ds,fileDrawerOpen:rn,onOpenArtifact:Wi,onToggleFiles:ct?()=>{Qn(t=>!t),Zn("files")}:void 0,onOpenDesktopLive:!pe&&((lr=window.agentApi)!=null&&lr.desktopLiveGetStatus)?()=>Os(!0):void 0,onHideToBackground:()=>void Fi(),onOpenHub:(dr=window.agentApi)!=null&&dr.hubGetConfig?()=>{nt(!1),St(!0)}:void 0,headerAppActions:!pe&&Ft!=="classic"?e.jsx(zr,{onOpenCalendar:Hn}):void 0,onToggleAppearance:qi,appearanceOpen:yn,hideToBackgroundTitle:Tt?`隐藏到后台(说“${Et}”唤醒)`:"隐藏到后台",onSessionCreated:(t,o)=>{var b;Me(o??null);const d=Ge.current;if(d&&o){const x=`${o.agentType}:${d}`;ye.current.set(x,(ye.current.get(x)??0)+1),qe.current.delete(d),S(new Set(qe.current));const I={..._e.current,[d]:[{...o,projectId:d},...(_e.current[d]??[]).filter(N=>N.id!==t)]};_e.current=I,W(I)}De({projectId:d,sessionId:t}),Ie(x=>x+1),ns.current&&(ns.current=!1,Vt.current={sessionId:t,until:Date.now()+9e4},(b=window.agentApi)==null||b.wakeConversation(!0)),d&&p.current==="customer-agent"&&Ve(d,{pendingSession:o,background:!0})},onSubSessionCreated:async t=>{await to(t)},onSelectSession:(t,o)=>{o&&Me(o),be(t),mn()},onParallelSessionSelected:t=>{var d;(d=We.current)==null||d.abort(),We.current=null,it.current=null,It(null),Jt(void 0),p.current!==t.agentType&&Ot(t.agentType),Me(t);const o=t.projectId&>.current.some(b=>b.id===t.projectId)?t.projectId:null;De({projectId:o,sessionId:t.id}),Gt.getState().setSessionId(t.id),Ie(b=>b+1)},onSubAgentEvent:t=>{t.type==="started"?cs({type:"info",title:"子会话已启动",body:`${t.agentName}:${t.task.slice(0,60)}`,sessionId:t.subSessionId}):t.type==="completed"?cs({type:"success",title:"子会话已完成",body:`${t.agentName}:${t.task.slice(0,60)}`,sessionId:t.subSessionId}):cs({type:"error",title:"子会话出错",body:`${t.agentName}:${t.task.slice(0,60)}`,sessionId:t.subSessionId})},onMessageSent:(t,o)=>{W(d=>{const b={};for(const[x,I]of Object.entries(d))b[x]=I.map(N=>N.id===t?{...N,title:o.slice(0,60)||N.title}:N);return b})},onRunComplete:async(t,o)=>{var I;const d=Vt.current,b=ea(d,o);Vt.current=b,b!==d&&((I=window.agentApi)==null||I.wakeConversation(!0));const x=t||ie;x&&await Ve(x,{refresh:!0,background:!0})}})})}),Ht&&e.jsx(r.Suspense,{fallback:e.jsx(_t,{label:"正在打开日历"}),children:e.jsx(bl,{loadOverview:xl,onClose:()=>nt(!1),initialTaskId:gi,focusKey:mi})}),Qt&&e.jsx(_t,{className:"session-navigation-loading"}),Bt&&e.jsx(r.Suspense,{fallback:e.jsx(_t,{label:"正在打开 AI Hub"}),children:e.jsx(wl,{conversationId:q,onExit:()=>St(!1)})}),ct&&rn&&e.jsx(r.Suspense,{fallback:e.jsx(_t,{label:"正在打开文件"}),children:e.jsx(Il,{open:rn,tab:zi,gateway:ct,cwd:Ut,selectedPath:Us,revealRequest:Mi,onTabChange:Zn,onSelectPath:es,onClose:()=>Qn(!1)})})]}),Ds&&e.jsx(Wc,{onClose:()=>Os(!1)}),Ls&&Ke.createPortal(e.jsx("div",{"data-task-page-overlay":"",onClick:()=>wn(!1),style:{position:"fixed",inset:0,zIndex:10001,background:"rgba(17,24,39,0.18)",display:"flex",alignItems:"center",justifyContent:"center",animation:"fadeIn 0.2s var(--ease-out)",WebkitAppRegion:"no-drag"},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),style:{width:"min(920px, calc(100vw - 48px))",height:"min(760px, calc(100vh - 48px))",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)",boxShadow:"var(--shadow-md)",overflow:"hidden",display:"flex",flexDirection:"column",animation:"fadeInUp 0.25s var(--ease-out)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid var(--border-subtle)",padding:"8px 10px",background:"var(--bg-deepest)"},children:[e.jsx("div",{style:{display:"flex",gap:6},children:lo.map(t=>e.jsx("button",{onClick:()=>Ai(t.id),className:`settings-tab ${At===t.id?"settings-tab-active":""}`,children:t.label},t.id))}),e.jsx("button",{onClick:()=>wn(!1),title:"关闭",className:"ui-icon-button ui-icon-button--close ui-icon-button--danger",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsxs(r.Suspense,{fallback:e.jsx(_t,{label:"正在打开设置"}),children:[At==="settings"&&e.jsxs(e.Fragment,{children:[pe&&document.body.dataset.nativeApp!=="1"&&e.jsx("div",{className:"update-settings-control",children:e.jsx(Ur,{})}),e.jsx(yl,{})]}),At==="mcp"&&e.jsx(vl,{}),At==="memory"&&e.jsx(kl,{}),At==="skill"&&e.jsx(Sl,{}),At==="agent"&&e.jsx(jl,{}),At==="lsp"&&e.jsx(Cl,{})]})})]})}),document.body),e.jsx("div",{className:"noise-overlay"}),yn&&vn&&Ke.createPortal(e.jsx("div",{"data-task-page-overlay":"",onClick:()=>ts(!1),style:{position:"fixed",inset:0,zIndex:1e4,WebkitAppRegion:"no-drag"},children:e.jsxs("div",{onClick:t=>t.stopPropagation(),className:"appearance-panel",style:{position:"absolute",left:Math.max(12,Math.min(vn.right-320,window.innerWidth-332)),top:vn.bottom+8,width:320,maxHeight:`calc(100vh - ${vn.bottom+20}px)`,overflowY:"auto",background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"16px",display:"flex",flexDirection:"column",gap:16,animation:"fadeInUp 0.2s var(--ease-out)",backdropFilter:"blur(14px)",WebkitBackdropFilter:"blur(14px)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"皮肤"}),e.jsx("div",{className:"appearance-choices",children:vo.map(t=>e.jsxs("button",{onClick:()=>Ti(t.id),className:`appearance-choice ${en===t.id?"appearance-choice-active":""}`,children:[e.jsx("span",{className:"appearance-swatch",style:{background:`linear-gradient(135deg, ${t.preview[0]} 55%, ${t.preview[1]} 55%)`}}),e.jsx("span",{className:"appearance-choice-label",style:{fontWeight:en===t.id?600:400},children:t.label}),en===t.id&&e.jsx("svg",{className:"appearance-choice-check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"m5 12 4 4L19 6"})})]},t.id))})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:8},children:"布局"}),e.jsx("div",{className:"appearance-segmented",children:ko.map(t=>e.jsx("button",{onClick:()=>tn(t.id),title:t.description,className:`appearance-segment ${ot===t.id?"appearance-segment-active":""}`,children:t.label},t.id))})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,borderTop:"1px solid var(--border-subtle)",paddingTop:12},children:[e.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.08em"},children:"语音"}),e.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,color:"var(--text-secondary)",cursor:"pointer"},children:["隐藏后语音唤醒",e.jsx("input",{className:"appearance-switch",type:"checkbox",checked:Tt,onChange:t=>Ei(t.target.checked)})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,color:"var(--text-secondary)"},children:[e.jsx("span",{style:{flexShrink:0},children:"唤醒词"}),e.jsx("input",{value:Et,onChange:t=>Ni(t.target.value||"小智"),style:{flex:1,padding:"4px 8px",borderRadius:6,border:"1px solid var(--border-default)",background:"var(--bg-deep)",color:"var(--text-primary)",fontSize:12}})]})]})]})}),document.body),e.jsx(Ra,{open:ce,onCancel:()=>te(!1),onConfirm:async t=>{await rr(t),te(!1)}}),e.jsx($c,{trigger:$i,heardText:Bi}),qt.items.length>0&&Ke.createPortal(e.jsx(Vc,{items:qt.items,onDismiss:qt.consume,onClearAll:qt.clearAll,onOpen:t=>{qt.consume(t),window.dispatchEvent(new CustomEvent("agentroam:notification-open",{detail:t}))}}),document.body),tr.length>0&&qt.items.length===0&&Ke.createPortal(e.jsx("div",{style:{position:"fixed",bottom:24,right:24,zIndex:2e4,display:"flex",flexDirection:"column",gap:10,alignItems:"flex-end",pointerEvents:"none"},children:tr.map(t=>e.jsxs("div",{style:{pointerEvents:"auto",width:320,background:"var(--bg-surface)",border:`1px solid ${t.type==="error"?"rgba(220,38,38,0.25)":t.type==="success"?"rgba(5,150,105,0.25)":"var(--border-default)"}`,borderLeft:`3px solid ${t.type==="error"?"var(--danger)":t.type==="success"?"var(--success)":"var(--accent)"}`,borderRadius:"var(--radius-md)",boxShadow:"var(--shadow-md)",padding:"12px 14px",animation:"fadeInUp 0.22s var(--ease-out)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:t.type==="error"?"var(--danger)":t.type==="success"?"var(--success)":"var(--accent)",display:"flex",alignItems:"center",gap:5},children:[t.type==="error"?"✕":t.type==="success"?"✓":"◎"," ",t.title]}),e.jsx("button",{onClick:()=>Cn(t.id),title:"关闭",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",fontSize:14,lineHeight:1,padding:"2px 4px",borderRadius:4,transition:"color 0.15s"},onMouseEnter:o=>o.currentTarget.style.color="var(--text-primary)",onMouseLeave:o=>o.currentTarget.style.color="var(--text-muted)",children:"×"})]}),e.jsx("p",{style:{margin:0,fontSize:12,color:"var(--text-secondary)",lineHeight:1.5,wordBreak:"break-all"},children:t.body}),t.sessionId&&e.jsx("button",{onClick:()=>{be(t.sessionId),Cn(t.id)},style:{marginTop:8,padding:"4px 10px",fontSize:11,fontWeight:500,background:"var(--accent-dim)",color:"var(--accent)",border:"1px solid var(--border-glow)",borderRadius:6,cursor:"pointer",transition:"background 0.15s",WebkitAppRegion:"no-drag"},onMouseEnter:o=>o.currentTarget.style.background="var(--accent-glow)",onMouseLeave:o=>o.currentTarget.style.background="var(--accent-dim)",children:"进入会话 →"})]},t.id))}),document.body)]})})}const td=Object.freeze(Object.defineProperty({__proto__:null,default:El},Symbol.toStringTag,{value:"Module"}));export{nl as A,td as a};
|