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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as $,r as l,j as e,w as me,N as Ae,A as pe,
|
|
1
|
+
import{c as $,r as l,j as e,w as me,N as Ae,A as pe,x as De,R as Ee}from"./index-C30NoLsn.js";import{C as $e}from"./calendar-days-BIRmYMrW.js";import{X as xe}from"./x-CoIXF2eL.js";import{C as Te}from"./chevron-right-B_ITnckH.js";import{L as Me}from"./locate-fixed-B3zScPI-.js";import{L as ge}from"./list-todo-DULblcsU.js";import{C as Le}from"./chevron-down-BUEiUZA7.js";import{C as fe}from"./check-DCU8YHqr.js";import{P as ze}from"./pause-C793N3J1.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -18,7 +18,7 @@ import{c as $,r as l,j as e,w as me,N as Ae,A as pe,X as xe,x as De,R as Ee}from
|
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const je=$("Repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);/**
|
|
22
22
|
* @license lucide-react v0.468.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
@@ -28,4 +28,4 @@ import{c as $,r as l,j as e,w as me,N as Ae,A as pe,X as xe,x as De,R as Ee}from
|
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Fe=$("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),B=["customer-agent","codex","claude","workbuddy","zcode","opencode","deepseek"],Z={"customer-agent":"AgentRoam",codex:"Codex",claude:"Claude Code",workbuddy:"WorkBuddy",zcode:"ZCode",opencode:"OpenCode",deepseek:"DeepSeek"};function I(s){const a=new Date(s),m=`${a.getMonth()+1}`.padStart(2,"0"),x=`${a.getDate()}`.padStart(2,"0");return`${a.getFullYear()}-${m}-${x}`}function _e({detail:s,onSave:a,onClose:m}){const{task:x,schedule:i}=s,g=i.trigger.kind==="cron",[j,p]=l.useState(i.target.agentType),[v,F]=l.useState(()=>{if(i.trigger.kind==="cron")return i.trigger.expression;const u=new Date(i.trigger.at);return new Date(u.getTime()-u.getTimezoneOffset()*6e4).toISOString().slice(0,19)}),[T,Y]=l.useState(i.enabled),[A,M]=l.useState([]),[f,r]=l.useState(!1),[D,w]=l.useState("");l.useEffect(()=>{var h,b;let u=!0;return(b=(h=window.agentApi)==null?void 0:h.getRuntimeHealth)==null||b.call(h).then(E=>{u&&M(E.filter(N=>!N.available).map(N=>N.agentType))}).catch(()=>{}),()=>{u=!1}},[]);async function C(u){if(u.preventDefault(),f)return;const h=g?{kind:"cron",expression:v.trim()}:{kind:"once",at:new Date(v).getTime()};if(h.kind==="once"&&(!Number.isFinite(h.at)||T&&h.at<=Date.now())){w("请选择有效的未来执行时间");return}r(!0),w("");const b=i.target,E=j===b.agentType?void 0:{agentType:j,cwd:b.cwd,permissionMode:b.permissionMode},N=h.kind==="once"&&i.trigger.kind==="once"?h.at!==i.trigger.at:h.kind==="cron"&&i.trigger.kind==="cron"&&h.expression!==i.trigger.expression;try{await a({type:"schedule",taskId:x.id,expectedVersion:x.version,enabled:T,...E?{target:E}:{},...N?{trigger:h}:{}})}catch(L){w(L instanceof Error?L.message:"执行计划保存失败")}finally{r(!1)}}return e.jsxs("form",{className:"cal-schedule-editor",onSubmit:C,"aria-label":"编辑执行计划",children:[e.jsxs("label",{children:["执行 Agent",e.jsxs("select",{value:j,onChange:u=>p(u.target.value),disabled:f,children:[!me(i.target.agentType)&&e.jsx("option",{value:i.target.agentType,children:i.target.agentType}),Ae.map(u=>e.jsx("option",{value:u,disabled:A.includes(u)&&u!==i.target.agentType,children:pe[u]},u))]})]}),e.jsxs("label",{children:[g?`执行规则(${i.timeZone})`:"执行时间(本地时间)",e.jsx("input",{type:g?"text":"datetime-local",step:g?void 0:1,value:v,required:!0,disabled:f,onChange:u=>F(u.target.value)})]}),e.jsxs("label",{className:"cal-schedule-enabled",children:[e.jsx("input",{type:"checkbox",checked:T,disabled:f,onChange:u=>Y(u.target.checked)}),"启用执行计划"]}),D&&e.jsx("p",{role:"alert",children:D}),e.jsxs("div",{className:"cal-schedule-actions",children:[e.jsx("button",{type:"button",className:"cal-nav-btn",onClick:m,disabled:f,children:"取消"}),e.jsx("button",{type:"submit",className:"cal-nav-btn",disabled:f,children:f?"保存中":"保存"})]})]})}const ue=["一","二","三","四","五","六","日"],Ue={upcoming:"待执行",paused:"已暂停",completed:"已完成",failed:"失败",overdue:"已过期",pending:"待处理","in-progress":"进行中",unscheduled:"未排期"},Oe=3e4;function Ve(s){const a=new Date(s);return a.setHours(0,0,0,0),a.getTime()}function V(s){const a=new Date(s);return`${`${a.getHours()}`.padStart(2,"0")}:${`${a.getMinutes()}`.padStart(2,"0")}`}function Ye(s,a){return`${s}年${a+1}月`}function he({task:s,schedule:a,reminders:m,executions:x}){var g,j;return s.dueAt!==void 0?s.dueAt:a!=null&&a.enabled&&a.nextFireAt!==null?a.nextFireAt:s.status==="completed"&&(a==null?void 0:a.trigger.kind)==="once"?a.trigger.at:(a&&((g=x.find(p=>p.scheduleId===a.id&&(s.status==="completed"||p.generation===a.generation)))==null?void 0:g.scheduledAt))??((j=m.find(p=>p.enabled&&p.nextFireAt!==null))==null?void 0:j.nextFireAt)??void 0}function qe(s,a){const m=new Date(s,a,1),x=(m.getDay()+6)%7,i=Ve(m.getTime())-x*864e5;return Array.from({length:42},(g,j)=>{const p=i+j*864e5,v=new Date(p);return{key:I(p),day:v.getDate(),inMonth:v.getMonth()===a,ms:p}})}function Ge({kind:s,size:a=12}){return s==="cron"?e.jsx(fe,{size:a,"aria-hidden":"true"}):s==="run"?e.jsx(Fe,{size:a,"aria-hidden":"true"}):e.jsx(Ie,{size:a,"aria-hidden":"true"})}function ke({state:s}){return s==="completed"?e.jsx(je,{size:12,className:"cal-mark is-done",role:"img","aria-label":"已完成"}):s==="failed"?e.jsx(xe,{size:12,className:"cal-mark is-fail","aria-label":"失败"}):s==="in-progress"?e.jsx("span",{className:"cal-pulse","aria-label":"进行中"}):s==="paused"?e.jsx(ze,{size:11,className:"cal-mark is-pause","aria-label":"已暂停"}):null}function ve({source:s,executionAgentType:a}){return!a||a==="customer-agent"?{tone:s,label:Z[s]}:me(a)?{tone:a==="claude-code"?"claude":a==="deepseek-harness"?"deepseek":a,label:pe[a]}:{tone:s,label:a}}function He({entry:s,onClick:a,highlighted:m}){const x=`cal-chip kind-${s.kind} is-${s.state}${m?" is-highlight":""}`,{tone:i,label:g}=ve(s),j=`${g} · ${s.title}`,p=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cal-chip-dot","aria-hidden":"true"}),e.jsx("span",{className:"cal-chip-time",children:s.kind==="todo"?s.dueAt?V(s.dueAt):"待办":V(s.at)}),e.jsx("span",{className:"cal-chip-title",children:s.title}),e.jsx(ke,{state:s.state}),s.state==="overdue"&&e.jsx("span",{className:"cal-tag is-overdue",children:"过期"}),s.state==="paused"&&e.jsx("span",{className:"cal-tag is-paused",children:"暂停"})]});return a?e.jsx("button",{type:"button",className:x,"data-source":i,onClick:a,title:j,children:p}):e.jsx("div",{className:x,"data-source":i,title:j,children:p})}function Ke({entry:s,highlighted:a,onEditSchedule:m}){const{tone:x,label:i}=ve(s);return e.jsxs("article",{className:`cal-entry is-${s.state}${a?" is-highlight":""}`,"data-source":x,"data-task-id":s.taskId,children:[e.jsxs("div",{className:"cal-entry-top",children:[e.jsx("span",{className:"cal-entry-src",children:i}),e.jsx("span",{className:`cal-entry-state is-${s.state}`,children:Ue[s.state]??s.state}),e.jsxs("span",{className:"cal-entry-time",children:[e.jsx(Ge,{kind:s.kind}),s.kind==="todo"?s.dueAt?V(s.dueAt):"无截止":V(s.at)]})]}),e.jsx("h4",{className:`cal-entry-title ${s.state==="completed"?"is-struck":""}`,children:s.title}),e.jsxs("div",{className:"cal-entry-meta",children:[s.scheduleLabel&&e.jsxs("span",{className:"cal-meta-pill",children:[e.jsx(Re,{size:11}),s.scheduleLabel]}),s.recurring&&e.jsxs("span",{className:"cal-meta-pill",children:[e.jsx(fe,{size:11}),"循环"]}),s.sessionTitle&&e.jsxs("span",{className:"cal-meta-pill",title:s.sessionTitle,children:[e.jsx(ge,{size:11}),s.sessionTitle]})]}),s.executedAt!==void 0&&e.jsxs("p",{className:"cal-entry-detail",children:["执行记录:",new Date(s.executedAt).toLocaleString("zh-CN",{hour12:!1})]}),s.kind==="cron"&&s.state==="overdue"&&e.jsx("p",{className:"cal-entry-detail",children:"计划时间已过,未找到执行结果;不代表执行成功或失败。"}),s.detail&&e.jsx("p",{className:"cal-entry-detail",children:s.detail}),s.cwd&&e.jsx("p",{className:"cal-entry-cwd",title:s.cwd,children:s.cwd}),m&&e.jsx("button",{type:"button",className:"cal-nav-btn cal-edit-schedule",onClick:m,children:"编辑执行计划"})]})}function tt({loadOverview:s,onClose:a,initialTaskId:m,focusKey:x=0}){const[i,g]=l.useState([]),[j,p]=l.useState(""),[v,F]=l.useState(""),[T,Y]=l.useState(""),[A,M]=l.useState(null),f=l.useRef(0),r=typeof window>"u"?void 0:window.agentApi,D=new Date,w=I(D.getTime()),[C,u]=l.useState({year:D.getFullYear(),month:D.getMonth()}),[h,b]=l.useState(null),[E,N]=l.useState(!0),[L,_]=l.useState(""),[be,X]=l.useState(!1),[q,S]=l.useState(w),[U,J]=l.useState(()=>new Set(B)),[G,H]=l.useState(!0),Q=l.useRef({from:"",to:""}),z=l.useRef(!0),O=l.useRef(0),ee=l.useCallback(async t=>{const n=++O.current;J(c=>new Set([...c,"customer-agent"])),F(t);try{const c=r!=null&&r.todoGet?await r.todoGet(t):void 0;if(n!==O.current)return;const o=c&&he(c);if(o!==void 0){const d=new Date(o);u({year:d.getFullYear(),month:d.getMonth()}),S(I(o))}else H(!0)}catch{n===O.current&&H(!0)}},[r]);l.useEffect(()=>(m&&ee(m),()=>{O.current++}),[m,x,ee]);const K=l.useMemo(()=>qe(C.year,C.month),[C]),te=K[0].key,se=K[41].key;Q.current={from:te,to:se};const y=l.useCallback(async t=>{var o;const{from:n,to:c}=Q.current;t==="initial"?N(!0):X(!0);try{const d=typeof window>"u"?void 0:window.agentApi,[R,k]=await Promise.all([s(n,c),(o=d==null?void 0:d.todoList)==null?void 0:o.call(d,{limit:200}).catch(()=>{})]);if(!z.current)return;k&&g(k.items.filter(re=>re.task.status!=="cancelled"&&he(re)===void 0)),b(R),_("")}catch(d){if(!z.current)return;_(d instanceof Error?d.message:"日历加载失败")}finally{z.current&&(N(!1),X(!1))}},[s]);l.useEffect(()=>{z.current=!0,y("initial");const t=setInterval(()=>{document.visibilityState==="visible"&&y("refresh")},Oe),n=()=>{document.visibilityState==="visible"&&y("refresh")};return document.addEventListener("visibilitychange",n),()=>{z.current=!1,clearInterval(t),document.removeEventListener("visibilitychange",n)}},[y,te,se]);const ae=t=>{u(n=>{const c=new Date(n.year,n.month+t,1);return{year:c.getFullYear(),month:c.getMonth()}})},ne=()=>{const t=new Date;u({year:t.getFullYear(),month:t.getMonth()}),S(I(t.getTime()))},ce=l.useMemo(()=>{const t=new Map;if(!h)return t;for(const[n,c]of Object.entries(h.days)){const o=c.filter(d=>d.kind!=="todo"&&U.has(d.source));o.length&&t.set(n,o)}return t},[h,U]),P=ce.get(q)??[],le=l.useMemo(()=>h?B.filter(t=>{var n;return!((n=h.sources[t])!=null&&n.ok)}).map(t=>{var n;return{source:t,error:((n=h.sources[t])==null?void 0:n.error)??""}}):[],[h]),Ne=t=>{J(n=>{const c=new Set(n);return c.has(t)?c.delete(t):c.add(t),c})},W=new Date(`${q}T00:00:00`),ye=`${W.getMonth()+1} 月 ${W.getDate()} 日 · 周${ue[(W.getDay()+6)%7]}`,we=async t=>{var n;p(t.task.id);try{const c=await((n=r==null?void 0:r.todoCommand)==null?void 0:n.call(r,{type:"complete",taskId:t.task.id,expectedVersion:t.task.version},crypto.randomUUID()));c&&g(o=>o.map(d=>d.task.id===c.task.id?c:d)),await y("refresh")}catch(c){_(c instanceof Error?c.message:"待办更新失败")}finally{p("")}},Ce=async t=>{var c;const n=++f.current;try{const o=await((c=r==null?void 0:r.todoGet)==null?void 0:c.call(r,t));n===f.current&&(o!=null&&o.schedule)&&M({...o,schedule:o.schedule})}catch(o){n===f.current&&_(o instanceof Error?o.message:"读取执行计划失败")}},ie=()=>{f.current++,M(null)},Se=async t=>{var o;if(!(r!=null&&r.todoCommand))throw new Error("当前服务不支持编辑待办");const n=await r.todoCommand(t,crypto.randomUUID());ie();const c=(o=n.schedule)==null?void 0:o.nextFireAt;if(c!=null){const d=new Date(c);u({year:d.getFullYear(),month:d.getMonth()}),S(I(c)),F(n.task.id)}await y("refresh")};return e.jsxs("div",{className:"cal-root",children:[e.jsx("div",{className:"cal-aurora","aria-hidden":"true"}),e.jsxs("header",{className:"cal-header",children:[e.jsxs("div",{className:"cal-title",children:[e.jsx("span",{className:"cal-title-icon",children:e.jsx($e,{size:20,"aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h1",{children:"智能体日历"}),e.jsx("p",{children:"定时任务与待办"})]})]}),e.jsxs("div",{className:"cal-nav",children:[a&&e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"返回聊天",title:"返回聊天",onClick:a,children:e.jsx(xe,{size:17})}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"上个月",onClick:()=>ae(-1),children:e.jsx(De,{size:17})}),e.jsx("button",{type:"button",className:"cal-month",onClick:ne,title:"回到今天",children:Ye(C.year,C.month)}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"下个月",onClick:()=>ae(1),children:e.jsx(Te,{size:17})}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"回到今天",title:"回到今天",onClick:ne,children:e.jsx(Me,{size:17})}),e.jsx("button",{type:"button",className:`cal-refresh ${be?"is-spinning":""}`,"aria-label":"刷新",title:"刷新",onClick:()=>void y("refresh"),children:e.jsx(Ee,{size:17})})]})]}),e.jsx("div",{className:"cal-filters",children:e.jsx("div",{className:"cal-sources",role:"group","aria-label":"按来源筛选",children:B.map(t=>{var n;return e.jsxs("button",{type:"button","data-source":t,className:`cal-source-chip ${U.has(t)?"is-on":"is-off"}`,onClick:()=>Ne(t),"aria-pressed":U.has(t),children:[e.jsx("span",{className:"cal-source-dot","aria-hidden":"true"}),Z[t],h&&e.jsx("span",{className:"cal-source-n",children:((n=h.sources[t])==null?void 0:n.entries)||0})]},t)})})}),le.length>0&&e.jsx("div",{className:"cal-source-errors",role:"status",children:le.map(({source:t,error:n})=>e.jsxs("span",{className:"cal-source-error","data-source":t,title:n,children:[e.jsx(de,{size:12}),Z[t]," 读取异常"]},t))}),L&&e.jsxs("div",{className:"cal-error",role:"alert",children:[e.jsx(de,{size:16}),L,e.jsx("button",{type:"button",onClick:()=>void y("initial"),children:"重试"})]}),e.jsxs("div",{className:"cal-body",children:[e.jsxs("div",{className:"cal-grid-wrap",children:[e.jsx("div",{className:"cal-weekdays",children:ue.map(t=>e.jsxs("span",{className:t==="六"||t==="日"?"is-weekend":"",children:["周",t]},t))}),E&&!h?e.jsx("div",{className:"cal-grid is-skeleton",children:Array.from({length:42},(t,n)=>e.jsxs("div",{className:"cal-cell cal-skeleton-cell",children:[e.jsx("span",{className:"cal-skel-bar"}),e.jsx("span",{className:"cal-skel-bar is-short"})]},n))}):e.jsx("div",{className:"cal-grid",children:K.map(t=>{const n=ce.get(t.key)??[],c=n.slice(0,3),o=n.length-c.length,d=n.some(k=>k.state==="overdue"),R=`cal-cell ${t.inMonth?"":"is-other"} ${t.key===w?"is-today":""} ${t.key===q?"is-selected":""} ${d?"has-overdue":""}`;return e.jsxs("div",{className:R,role:"button",tabIndex:0,onClick:()=>S(t.key),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),S(t.key))},children:[e.jsxs("div",{className:"cal-cell-head",children:[e.jsx("span",{className:"cal-cell-date",children:t.day}),t.key===w&&e.jsx("span",{className:"cal-today-pill",children:"今天"}),n.length>0&&e.jsx("span",{className:"cal-cell-n",children:n.length})]}),e.jsxs("div",{className:"cal-chips",children:[c.map(k=>e.jsx(He,{entry:k,highlighted:k.taskId===v,onClick:()=>S(t.key)},k.id)),o>0&&e.jsxs("button",{type:"button",className:"cal-more",onClick:()=>S(t.key),children:["+",o," 更多"]})]})]},t.key)})})]}),e.jsxs("aside",{className:"cal-detail",children:[e.jsxs("div",{className:"cal-detail-head",children:[e.jsx("h2",{children:ye}),e.jsxs("span",{className:"cal-detail-n",children:[P.length," 项"]})]}),e.jsx("div",{className:"cal-detail-list",children:P.length===0?e.jsxs("div",{className:"cal-empty",children:[e.jsx(oe,{size:28,strokeWidth:1.4}),e.jsx("p",{children:"这一天没有安排"}),e.jsx("small",{children:"点击其他日期查看安排与提醒"})]}):P.map(t=>{var n;return e.jsx(Ke,{entry:t,highlighted:t.taskId===v,onEditSchedule:r!=null&&r.todoGet&&r.todoCommand&&t.taskId&&((n=t.scheduleRef)!=null&&n.startsWith("agentroam:todo_execution_schedules:"))?()=>void Ce(t.taskId):void 0},t.id)})})]})]}),e.jsxs("section",{className:`cal-unscheduled ${G?"is-open":""}`,children:[e.jsxs("button",{type:"button",className:"cal-unscheduled-head",onClick:()=>H(t=>!t),"aria-expanded":G,children:[e.jsx(ge,{size:16}),e.jsx("span",{children:"无日期待办"}),e.jsxs("span",{className:"cal-unscheduled-n",children:[i.length," 项"]}),e.jsx(Le,{size:16,className:"cal-unscheduled-chev"})]}),G&&e.jsxs("div",{className:"cal-unscheduled-body",children:[i.length>0&&e.jsx("div",{className:"cal-unsched-schedule-list",children:i.map(t=>{var d;const n=T===t.task.id,c=t.task.status==="completed",o=t.task.status==="in_progress"?"进行中":t.task.status==="failed"?"执行失败":"";return e.jsxs("div",{className:`cal-unsched-schedule ${t.task.id===v?"is-highlight":""}`,"data-source":"customer-agent",children:[e.jsxs("div",{className:"cal-unsched-row",children:[c?e.jsx(ke,{state:"completed"}):e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":`完成 ${t.task.title}`,disabled:!!j,onClick:()=>void we(t),children:e.jsx(je,{size:13})}),e.jsx("button",{type:"button",className:`cal-unsched-title${c?" is-struck":""}`,"aria-expanded":n,title:n?"收起详情":"查看详情",onClick:()=>Y(n?"":t.task.id),children:t.task.title})]}),o&&e.jsx("p",{children:o}),n&&e.jsxs("div",{className:"cal-unsched-expand",children:[t.task.description&&e.jsx("p",{children:t.task.description}),((d=t.schedule)==null?void 0:d.enabled)&&e.jsxs("p",{children:["下次执行:",t.schedule.nextFireAt?new Date(t.schedule.nextFireAt).toLocaleString("zh-CN",{hour12:!1}):"—"," · ",t.schedule.target.agentType]}),t.reminders.some(R=>R.enabled)&&e.jsx("p",{children:"已设置提醒"}),(r==null?void 0:r.todoCommand)&&t.schedule&&!c&&e.jsx("button",{type:"button",className:"cal-nav-btn cal-edit-schedule",onClick:()=>M({...t,schedule:t.schedule}),children:"编辑执行计划"})]})]},t.task.id)})}),i.length===0&&e.jsxs("div",{className:"cal-empty is-inline",children:[e.jsx(oe,{size:24,strokeWidth:1.4}),e.jsx("p",{children:"没有无日期待办"})]})]})]}),A&&e.jsx("div",{className:"cal-schedule-overlay",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cal-schedule-title",className:"cal-schedule-dialog",children:[e.jsx("h2",{id:"cal-schedule-title",children:A.task.title}),e.jsx(_e,{detail:A,onSave:Se,onClose:ie},A.task.id)]})})]})}export{Ke as EntryRow,tt as default,he as personalTodoCalendarTime};
|
|
31
|
+
*/const Fe=$("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),B=["customer-agent","codex","claude","workbuddy","zcode","opencode","deepseek"],Z={"customer-agent":"AgentRoam",codex:"Codex",claude:"Claude Code",workbuddy:"WorkBuddy",zcode:"ZCode",opencode:"OpenCode",deepseek:"DeepSeek"};function I(s){const a=new Date(s),m=`${a.getMonth()+1}`.padStart(2,"0"),x=`${a.getDate()}`.padStart(2,"0");return`${a.getFullYear()}-${m}-${x}`}function _e({detail:s,onSave:a,onClose:m}){const{task:x,schedule:i}=s,g=i.trigger.kind==="cron",[f,p]=l.useState(i.target.agentType),[v,F]=l.useState(()=>{if(i.trigger.kind==="cron")return i.trigger.expression;const u=new Date(i.trigger.at);return new Date(u.getTime()-u.getTimezoneOffset()*6e4).toISOString().slice(0,19)}),[T,Y]=l.useState(i.enabled),[A,M]=l.useState([]),[j,r]=l.useState(!1),[D,w]=l.useState("");l.useEffect(()=>{var h,b;let u=!0;return(b=(h=window.agentApi)==null?void 0:h.getRuntimeHealth)==null||b.call(h).then(E=>{u&&M(E.filter(N=>!N.available).map(N=>N.agentType))}).catch(()=>{}),()=>{u=!1}},[]);async function C(u){if(u.preventDefault(),j)return;const h=g?{kind:"cron",expression:v.trim()}:{kind:"once",at:new Date(v).getTime()};if(h.kind==="once"&&(!Number.isFinite(h.at)||T&&h.at<=Date.now())){w("请选择有效的未来执行时间");return}r(!0),w("");const b=i.target,E=f===b.agentType?void 0:{agentType:f,cwd:b.cwd,permissionMode:b.permissionMode},N=h.kind==="once"&&i.trigger.kind==="once"?h.at!==i.trigger.at:h.kind==="cron"&&i.trigger.kind==="cron"&&h.expression!==i.trigger.expression;try{await a({type:"schedule",taskId:x.id,expectedVersion:x.version,enabled:T,...E?{target:E}:{},...N?{trigger:h}:{}})}catch(L){w(L instanceof Error?L.message:"执行计划保存失败")}finally{r(!1)}}return e.jsxs("form",{className:"cal-schedule-editor",onSubmit:C,"aria-label":"编辑执行计划",children:[e.jsxs("label",{children:["执行 Agent",e.jsxs("select",{value:f,onChange:u=>p(u.target.value),disabled:j,children:[!me(i.target.agentType)&&e.jsx("option",{value:i.target.agentType,children:i.target.agentType}),Ae.map(u=>e.jsx("option",{value:u,disabled:A.includes(u)&&u!==i.target.agentType,children:pe[u]},u))]})]}),e.jsxs("label",{children:[g?`执行规则(${i.timeZone})`:"执行时间(本地时间)",e.jsx("input",{type:g?"text":"datetime-local",step:g?void 0:1,value:v,required:!0,disabled:j,onChange:u=>F(u.target.value)})]}),e.jsxs("label",{className:"cal-schedule-enabled",children:[e.jsx("input",{type:"checkbox",checked:T,disabled:j,onChange:u=>Y(u.target.checked)}),"启用执行计划"]}),D&&e.jsx("p",{role:"alert",children:D}),e.jsxs("div",{className:"cal-schedule-actions",children:[e.jsx("button",{type:"button",className:"cal-nav-btn",onClick:m,disabled:j,children:"取消"}),e.jsx("button",{type:"submit",className:"cal-nav-btn",disabled:j,children:j?"保存中":"保存"})]})]})}const ue=["一","二","三","四","五","六","日"],Ue={upcoming:"待执行",paused:"已暂停",completed:"已完成",failed:"失败",overdue:"已过期",pending:"待处理","in-progress":"进行中",unscheduled:"未排期"},Oe=3e4;function Ve(s){const a=new Date(s);return a.setHours(0,0,0,0),a.getTime()}function V(s){const a=new Date(s);return`${`${a.getHours()}`.padStart(2,"0")}:${`${a.getMinutes()}`.padStart(2,"0")}`}function Ye(s,a){return`${s}年${a+1}月`}function he({task:s,schedule:a,reminders:m,executions:x}){var g,f;return s.dueAt!==void 0?s.dueAt:a!=null&&a.enabled&&a.nextFireAt!==null?a.nextFireAt:s.status==="completed"&&(a==null?void 0:a.trigger.kind)==="once"?a.trigger.at:(a&&((g=x.find(p=>p.scheduleId===a.id&&(s.status==="completed"||p.generation===a.generation)))==null?void 0:g.scheduledAt))??((f=m.find(p=>p.enabled&&p.nextFireAt!==null))==null?void 0:f.nextFireAt)??void 0}function qe(s,a){const m=new Date(s,a,1),x=(m.getDay()+6)%7,i=Ve(m.getTime())-x*864e5;return Array.from({length:42},(g,f)=>{const p=i+f*864e5,v=new Date(p);return{key:I(p),day:v.getDate(),inMonth:v.getMonth()===a,ms:p}})}function Ge({kind:s,size:a=12}){return s==="cron"?e.jsx(je,{size:a,"aria-hidden":"true"}):s==="run"?e.jsx(Fe,{size:a,"aria-hidden":"true"}):e.jsx(Ie,{size:a,"aria-hidden":"true"})}function ke({state:s}){return s==="completed"?e.jsx(fe,{size:12,className:"cal-mark is-done",role:"img","aria-label":"已完成"}):s==="failed"?e.jsx(xe,{size:12,className:"cal-mark is-fail","aria-label":"失败"}):s==="in-progress"?e.jsx("span",{className:"cal-pulse","aria-label":"进行中"}):s==="paused"?e.jsx(ze,{size:11,className:"cal-mark is-pause","aria-label":"已暂停"}):null}function ve({source:s,executionAgentType:a}){return!a||a==="customer-agent"?{tone:s,label:Z[s]}:me(a)?{tone:a==="claude-code"?"claude":a==="deepseek-harness"?"deepseek":a,label:pe[a]}:{tone:s,label:a}}function He({entry:s,onClick:a,highlighted:m}){const x=`cal-chip kind-${s.kind} is-${s.state}${m?" is-highlight":""}`,{tone:i,label:g}=ve(s),f=`${g} · ${s.title}`,p=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cal-chip-dot","aria-hidden":"true"}),e.jsx("span",{className:"cal-chip-time",children:s.kind==="todo"?s.dueAt?V(s.dueAt):"待办":V(s.at)}),e.jsx("span",{className:"cal-chip-title",children:s.title}),e.jsx(ke,{state:s.state}),s.state==="overdue"&&e.jsx("span",{className:"cal-tag is-overdue",children:"过期"}),s.state==="paused"&&e.jsx("span",{className:"cal-tag is-paused",children:"暂停"})]});return a?e.jsx("button",{type:"button",className:x,"data-source":i,onClick:a,title:f,children:p}):e.jsx("div",{className:x,"data-source":i,title:f,children:p})}function Ke({entry:s,highlighted:a,onEditSchedule:m}){const{tone:x,label:i}=ve(s);return e.jsxs("article",{className:`cal-entry is-${s.state}${a?" is-highlight":""}`,"data-source":x,"data-task-id":s.taskId,children:[e.jsxs("div",{className:"cal-entry-top",children:[e.jsx("span",{className:"cal-entry-src",children:i}),e.jsx("span",{className:`cal-entry-state is-${s.state}`,children:Ue[s.state]??s.state}),e.jsxs("span",{className:"cal-entry-time",children:[e.jsx(Ge,{kind:s.kind}),s.kind==="todo"?s.dueAt?V(s.dueAt):"无截止":V(s.at)]})]}),e.jsx("h4",{className:`cal-entry-title ${s.state==="completed"?"is-struck":""}`,children:s.title}),e.jsxs("div",{className:"cal-entry-meta",children:[s.scheduleLabel&&e.jsxs("span",{className:"cal-meta-pill",children:[e.jsx(Re,{size:11}),s.scheduleLabel]}),s.recurring&&e.jsxs("span",{className:"cal-meta-pill",children:[e.jsx(je,{size:11}),"循环"]}),s.sessionTitle&&e.jsxs("span",{className:"cal-meta-pill",title:s.sessionTitle,children:[e.jsx(ge,{size:11}),s.sessionTitle]})]}),s.executedAt!==void 0&&e.jsxs("p",{className:"cal-entry-detail",children:["执行记录:",new Date(s.executedAt).toLocaleString("zh-CN",{hour12:!1})]}),s.kind==="cron"&&s.state==="overdue"&&e.jsx("p",{className:"cal-entry-detail",children:"计划时间已过,未找到执行结果;不代表执行成功或失败。"}),s.detail&&e.jsx("p",{className:"cal-entry-detail",children:s.detail}),s.cwd&&e.jsx("p",{className:"cal-entry-cwd",title:s.cwd,children:s.cwd}),m&&e.jsx("button",{type:"button",className:"cal-nav-btn cal-edit-schedule",onClick:m,children:"编辑执行计划"})]})}function st({loadOverview:s,onClose:a,initialTaskId:m,focusKey:x=0}){const[i,g]=l.useState([]),[f,p]=l.useState(""),[v,F]=l.useState(""),[T,Y]=l.useState(""),[A,M]=l.useState(null),j=l.useRef(0),r=typeof window>"u"?void 0:window.agentApi,D=new Date,w=I(D.getTime()),[C,u]=l.useState({year:D.getFullYear(),month:D.getMonth()}),[h,b]=l.useState(null),[E,N]=l.useState(!0),[L,_]=l.useState(""),[be,X]=l.useState(!1),[q,S]=l.useState(w),[U,J]=l.useState(()=>new Set(B)),[G,H]=l.useState(!0),Q=l.useRef({from:"",to:""}),z=l.useRef(!0),O=l.useRef(0),ee=l.useCallback(async t=>{const n=++O.current;J(c=>new Set([...c,"customer-agent"])),F(t);try{const c=r!=null&&r.todoGet?await r.todoGet(t):void 0;if(n!==O.current)return;const o=c&&he(c);if(o!==void 0){const d=new Date(o);u({year:d.getFullYear(),month:d.getMonth()}),S(I(o))}else H(!0)}catch{n===O.current&&H(!0)}},[r]);l.useEffect(()=>(m&&ee(m),()=>{O.current++}),[m,x,ee]);const K=l.useMemo(()=>qe(C.year,C.month),[C]),te=K[0].key,se=K[41].key;Q.current={from:te,to:se};const y=l.useCallback(async t=>{var o;const{from:n,to:c}=Q.current;t==="initial"?N(!0):X(!0);try{const d=typeof window>"u"?void 0:window.agentApi,[R,k]=await Promise.all([s(n,c),(o=d==null?void 0:d.todoList)==null?void 0:o.call(d,{limit:200}).catch(()=>{})]);if(!z.current)return;k&&g(k.items.filter(re=>re.task.status!=="cancelled"&&he(re)===void 0)),b(R),_("")}catch(d){if(!z.current)return;_(d instanceof Error?d.message:"日历加载失败")}finally{z.current&&(N(!1),X(!1))}},[s]);l.useEffect(()=>{z.current=!0,y("initial");const t=setInterval(()=>{document.visibilityState==="visible"&&y("refresh")},Oe),n=()=>{document.visibilityState==="visible"&&y("refresh")};return document.addEventListener("visibilitychange",n),()=>{z.current=!1,clearInterval(t),document.removeEventListener("visibilitychange",n)}},[y,te,se]);const ae=t=>{u(n=>{const c=new Date(n.year,n.month+t,1);return{year:c.getFullYear(),month:c.getMonth()}})},ne=()=>{const t=new Date;u({year:t.getFullYear(),month:t.getMonth()}),S(I(t.getTime()))},ce=l.useMemo(()=>{const t=new Map;if(!h)return t;for(const[n,c]of Object.entries(h.days)){const o=c.filter(d=>d.kind!=="todo"&&U.has(d.source));o.length&&t.set(n,o)}return t},[h,U]),P=ce.get(q)??[],le=l.useMemo(()=>h?B.filter(t=>{var n;return!((n=h.sources[t])!=null&&n.ok)}).map(t=>{var n;return{source:t,error:((n=h.sources[t])==null?void 0:n.error)??""}}):[],[h]),Ne=t=>{J(n=>{const c=new Set(n);return c.has(t)?c.delete(t):c.add(t),c})},W=new Date(`${q}T00:00:00`),ye=`${W.getMonth()+1} 月 ${W.getDate()} 日 · 周${ue[(W.getDay()+6)%7]}`,we=async t=>{var n;p(t.task.id);try{const c=await((n=r==null?void 0:r.todoCommand)==null?void 0:n.call(r,{type:"complete",taskId:t.task.id,expectedVersion:t.task.version},crypto.randomUUID()));c&&g(o=>o.map(d=>d.task.id===c.task.id?c:d)),await y("refresh")}catch(c){_(c instanceof Error?c.message:"待办更新失败")}finally{p("")}},Ce=async t=>{var c;const n=++j.current;try{const o=await((c=r==null?void 0:r.todoGet)==null?void 0:c.call(r,t));n===j.current&&(o!=null&&o.schedule)&&M({...o,schedule:o.schedule})}catch(o){n===j.current&&_(o instanceof Error?o.message:"读取执行计划失败")}},ie=()=>{j.current++,M(null)},Se=async t=>{var o;if(!(r!=null&&r.todoCommand))throw new Error("当前服务不支持编辑待办");const n=await r.todoCommand(t,crypto.randomUUID());ie();const c=(o=n.schedule)==null?void 0:o.nextFireAt;if(c!=null){const d=new Date(c);u({year:d.getFullYear(),month:d.getMonth()}),S(I(c)),F(n.task.id)}await y("refresh")};return e.jsxs("div",{className:"cal-root",children:[e.jsx("div",{className:"cal-aurora","aria-hidden":"true"}),e.jsxs("header",{className:"cal-header",children:[e.jsxs("div",{className:"cal-title",children:[e.jsx("span",{className:"cal-title-icon",children:e.jsx($e,{size:20,"aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h1",{children:"智能体日历"}),e.jsx("p",{children:"定时任务与待办"})]})]}),e.jsxs("div",{className:"cal-nav",children:[a&&e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"返回聊天",title:"返回聊天",onClick:a,children:e.jsx(xe,{size:17})}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"上个月",onClick:()=>ae(-1),children:e.jsx(De,{size:17})}),e.jsx("button",{type:"button",className:"cal-month",onClick:ne,title:"回到今天",children:Ye(C.year,C.month)}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"下个月",onClick:()=>ae(1),children:e.jsx(Te,{size:17})}),e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":"回到今天",title:"回到今天",onClick:ne,children:e.jsx(Me,{size:17})}),e.jsx("button",{type:"button",className:`cal-refresh ${be?"is-spinning":""}`,"aria-label":"刷新",title:"刷新",onClick:()=>void y("refresh"),children:e.jsx(Ee,{size:17})})]})]}),e.jsx("div",{className:"cal-filters",children:e.jsx("div",{className:"cal-sources",role:"group","aria-label":"按来源筛选",children:B.map(t=>{var n;return e.jsxs("button",{type:"button","data-source":t,className:`cal-source-chip ${U.has(t)?"is-on":"is-off"}`,onClick:()=>Ne(t),"aria-pressed":U.has(t),children:[e.jsx("span",{className:"cal-source-dot","aria-hidden":"true"}),Z[t],h&&e.jsx("span",{className:"cal-source-n",children:((n=h.sources[t])==null?void 0:n.entries)||0})]},t)})})}),le.length>0&&e.jsx("div",{className:"cal-source-errors",role:"status",children:le.map(({source:t,error:n})=>e.jsxs("span",{className:"cal-source-error","data-source":t,title:n,children:[e.jsx(de,{size:12}),Z[t]," 读取异常"]},t))}),L&&e.jsxs("div",{className:"cal-error",role:"alert",children:[e.jsx(de,{size:16}),L,e.jsx("button",{type:"button",onClick:()=>void y("initial"),children:"重试"})]}),e.jsxs("div",{className:"cal-body",children:[e.jsxs("div",{className:"cal-grid-wrap",children:[e.jsx("div",{className:"cal-weekdays",children:ue.map(t=>e.jsxs("span",{className:t==="六"||t==="日"?"is-weekend":"",children:["周",t]},t))}),E&&!h?e.jsx("div",{className:"cal-grid is-skeleton",children:Array.from({length:42},(t,n)=>e.jsxs("div",{className:"cal-cell cal-skeleton-cell",children:[e.jsx("span",{className:"cal-skel-bar"}),e.jsx("span",{className:"cal-skel-bar is-short"})]},n))}):e.jsx("div",{className:"cal-grid",children:K.map(t=>{const n=ce.get(t.key)??[],c=n.slice(0,3),o=n.length-c.length,d=n.some(k=>k.state==="overdue"),R=`cal-cell ${t.inMonth?"":"is-other"} ${t.key===w?"is-today":""} ${t.key===q?"is-selected":""} ${d?"has-overdue":""}`;return e.jsxs("div",{className:R,role:"button",tabIndex:0,onClick:()=>S(t.key),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),S(t.key))},children:[e.jsxs("div",{className:"cal-cell-head",children:[e.jsx("span",{className:"cal-cell-date",children:t.day}),t.key===w&&e.jsx("span",{className:"cal-today-pill",children:"今天"}),n.length>0&&e.jsx("span",{className:"cal-cell-n",children:n.length})]}),e.jsxs("div",{className:"cal-chips",children:[c.map(k=>e.jsx(He,{entry:k,highlighted:k.taskId===v,onClick:()=>S(t.key)},k.id)),o>0&&e.jsxs("button",{type:"button",className:"cal-more",onClick:()=>S(t.key),children:["+",o," 更多"]})]})]},t.key)})})]}),e.jsxs("aside",{className:"cal-detail",children:[e.jsxs("div",{className:"cal-detail-head",children:[e.jsx("h2",{children:ye}),e.jsxs("span",{className:"cal-detail-n",children:[P.length," 项"]})]}),e.jsx("div",{className:"cal-detail-list",children:P.length===0?e.jsxs("div",{className:"cal-empty",children:[e.jsx(oe,{size:28,strokeWidth:1.4}),e.jsx("p",{children:"这一天没有安排"}),e.jsx("small",{children:"点击其他日期查看安排与提醒"})]}):P.map(t=>{var n;return e.jsx(Ke,{entry:t,highlighted:t.taskId===v,onEditSchedule:r!=null&&r.todoGet&&r.todoCommand&&t.taskId&&((n=t.scheduleRef)!=null&&n.startsWith("agentroam:todo_execution_schedules:"))?()=>void Ce(t.taskId):void 0},t.id)})})]})]}),e.jsxs("section",{className:`cal-unscheduled ${G?"is-open":""}`,children:[e.jsxs("button",{type:"button",className:"cal-unscheduled-head",onClick:()=>H(t=>!t),"aria-expanded":G,children:[e.jsx(ge,{size:16}),e.jsx("span",{children:"无日期待办"}),e.jsxs("span",{className:"cal-unscheduled-n",children:[i.length," 项"]}),e.jsx(Le,{size:16,className:"cal-unscheduled-chev"})]}),G&&e.jsxs("div",{className:"cal-unscheduled-body",children:[i.length>0&&e.jsx("div",{className:"cal-unsched-schedule-list",children:i.map(t=>{var d;const n=T===t.task.id,c=t.task.status==="completed",o=t.task.status==="in_progress"?"进行中":t.task.status==="failed"?"执行失败":"";return e.jsxs("div",{className:`cal-unsched-schedule ${t.task.id===v?"is-highlight":""}`,"data-source":"customer-agent",children:[e.jsxs("div",{className:"cal-unsched-row",children:[c?e.jsx(ke,{state:"completed"}):e.jsx("button",{type:"button",className:"cal-nav-btn","aria-label":`完成 ${t.task.title}`,disabled:!!f,onClick:()=>void we(t),children:e.jsx(fe,{size:13})}),e.jsx("button",{type:"button",className:`cal-unsched-title${c?" is-struck":""}`,"aria-expanded":n,title:n?"收起详情":"查看详情",onClick:()=>Y(n?"":t.task.id),children:t.task.title})]}),o&&e.jsx("p",{children:o}),n&&e.jsxs("div",{className:"cal-unsched-expand",children:[t.task.description&&e.jsx("p",{children:t.task.description}),((d=t.schedule)==null?void 0:d.enabled)&&e.jsxs("p",{children:["下次执行:",t.schedule.nextFireAt?new Date(t.schedule.nextFireAt).toLocaleString("zh-CN",{hour12:!1}):"—"," · ",t.schedule.target.agentType]}),t.reminders.some(R=>R.enabled)&&e.jsx("p",{children:"已设置提醒"}),(r==null?void 0:r.todoCommand)&&t.schedule&&!c&&e.jsx("button",{type:"button",className:"cal-nav-btn cal-edit-schedule",onClick:()=>M({...t,schedule:t.schedule}),children:"编辑执行计划"})]})]},t.task.id)})}),i.length===0&&e.jsxs("div",{className:"cal-empty is-inline",children:[e.jsx(oe,{size:24,strokeWidth:1.4}),e.jsx("p",{children:"没有无日期待办"})]})]})]}),A&&e.jsx("div",{className:"cal-schedule-overlay",children:e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"cal-schedule-title",className:"cal-schedule-dialog",children:[e.jsx("h2",{id:"cal-schedule-title",children:A.task.title}),e.jsx(_e,{detail:A,onSave:Se,onClose:ie},A.task.id)]})})]})}export{Ke as EntryRow,st as default,he as personalTodoCalendarTime};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as n,k as H,h as U,l as K}from"./index-C30NoLsn.js";import{C as V,a as Y}from"./types-COzZsLPY.js";import{H as Z}from"./HostProjectPicker-CjlxN2ct.js";import{c as L,A as P}from"./client-BpqlZTm2.js";import{C as G}from"./chevron-right-B_ITnckH.js";import{c as q,b as ee,S as _}from"./session-tree-Q-jABJNB.js";import{X as O}from"./x-CoIXF2eL.js";import{S as te}from"./file-types-Dj25tuty.js";import{U as ae}from"./collaboration-CYS2Soeh.js";import{F as se}from"./trash-2-DwFoTvHX.js";import{C as Q}from"./chevron-down-BUEiUZA7.js";function le({title:r,expanded:s,onToggle:c}){const g=`${s?"收起":"展开"}子会话:${r}`;return e.jsx("button",{type:"button",className:"sidebar-session-toggle ui-icon-button ui-icon-button--small","aria-label":g,title:g,"aria-expanded":s,onClick:c,children:e.jsx(G,{size:15,className:`sidebar-session-disclosure${s?" is-expanded":""}`,"aria-hidden":"true"})})}function re(){const[r,s]=n.useState(()=>new Set);function c(g){s(S=>{const h=new Set(S);return h.has(g)?h.delete(g):h.add(g),h})}return{expandedIds:r,toggle:c,collapseAll:()=>s(new Set)}}function ne(r,s){return[...new Map([...r,...s].map(c=>[c.id,c])).values()]}function oe({value:r,onChange:s}){const[c,g]=n.useState(""),S=re(),[h,w]=n.useState({data:[],nextCursor:null,total:0}),[x,v]=n.useState(!0),[u,b]=n.useState(""),[l,d]=n.useState(0),i=n.useRef(0),j=n.useRef(!1);n.useEffect(()=>{const t=++i.current;let o=!0;j.current=!0,v(!0),b(""),w({data:[],nextCursor:null,total:0});const p=setTimeout(()=>{L({action:"sessionCatalog",query:c,limit:20}).then(f=>{o&&t===i.current&&w({...f,data:q(f)})}).catch(f=>{o&&t===i.current&&b(f instanceof Error?f.message:"无法加载会话")}).finally(()=>{o&&t===i.current&&(j.current=!1,v(!1))})},c?200:0);return()=>{o=!1,clearTimeout(p)}},[c,l]);const y=async()=>{if(j.current||!h.nextCursor)return;const t=i.current;j.current=!0,v(!0),b("");try{const o=await L({action:"sessionCatalog",query:c,limit:20,cursor:h.nextCursor});t===i.current&&w(p=>({...o,data:ne(p.data,q(o))}))}catch(o){t===i.current&&b(o instanceof Error?o.message:"加载更多失败")}finally{t===i.current&&(j.current=!1,v(!1))}},A=new Set(r.map(t=>t.id)),C=ee(h.data),z=new Map(h.data.map(t=>[t.id,t])),N=({session:t,children:o})=>{const p=S.expandedIds.has(t.id);return e.jsxs("div",{children:[e.jsxs("div",{className:"collab-monitor-entry",children:[e.jsxs("label",{className:"collab-monitor-row",children:[e.jsx("input",{type:"checkbox","aria-label":`关联${t.title}`,checked:A.has(t.id),disabled:!A.has(t.id)&&r.length>=200,onChange:f=>s(f.target.checked?[...r,{id:t.id,agentType:t.agentType,title:t.title,cwd:t.cwd,projectId:t.projectId}]:r.filter(D=>D.id!==t.id))}),e.jsx(H,{agentType:t.agentType,size:18}),e.jsx(_,{session:t}),e.jsxs("span",{className:"collab-monitor-row-text",children:[e.jsx("strong",{children:t.title}),e.jsxs("small",{children:[P[t.agentType]," · ",t.cwd]})]}),e.jsx("em",{className:t.status==="running"?"is-running":"",children:t.status==="running"?"运行中":t.status==="failed"?"异常":t.status==="completed"?"已完成":"空闲"})]}),o.length>0&&e.jsx(le,{title:t.title,expanded:p,onToggle:()=>S.toggle(t.id)})]}),p&&o.length>0&&e.jsx("div",{className:"collab-monitor-children",role:"group","aria-label":`${t.title}的子会话`,children:o.map(N)})]},t.id)};return e.jsxs("section",{className:"collab-monitor-picker","aria-label":"关联原始会话",children:[e.jsx("div",{className:"collab-monitor-heading",children:e.jsxs("strong",{children:["关联原始会话 ",e.jsxs("small",{children:["选填 · 已选 ",r.length]})]})}),e.jsx("p",{className:"collab-muted",children:"运行中的在前。关联后作为监控对象,恢复或交接时才介入。"}),r.length>0&&e.jsx("div",{className:"collab-monitor-selected","aria-label":"已选会话",children:r.map(t=>e.jsxs("span",{title:`${P[t.agentType]} · ${t.cwd}`,children:[e.jsx(H,{agentType:t.agentType,size:14}),e.jsx(_,{session:z.get(t.id)??t}),e.jsx("span",{children:t.title}),e.jsx("button",{type:"button","aria-label":`取消关联${t.title}`,onClick:()=>s(r.filter(o=>o.id!==t.id)),children:e.jsx(O,{size:13})})]},t.id))}),e.jsxs("label",{className:"collab-monitor-search",children:[e.jsx(te,{size:15}),e.jsx("input",{"aria-label":"搜索所有原始会话",placeholder:"搜索所有会话的标题、目录或 Agent",value:c,onChange:t=>g(t.target.value)})]}),e.jsxs("div",{className:"collab-monitor-results","aria-label":"原始会话候选","aria-busy":x,onScroll:t=>{const o=t.currentTarget;o.scrollHeight-o.scrollTop-o.clientHeight<64&&y()},children:[C.map(N),!x&&!u&&!C.length&&e.jsx("p",{className:"collab-muted",children:c?"没有匹配的会话":"暂无可接入会话"}),x&&e.jsx("p",{className:"collab-muted",role:"status",children:"正在加载会话…"}),h.nextCursor&&!u&&e.jsx("button",{type:"button",className:"collab-monitor-more",disabled:x,onClick:()=>void y(),children:"加载更多会话"})]}),u&&e.jsxs("p",{className:"collab-error",role:"alert",children:[u," ",e.jsx("button",{type:"button",onClick:()=>d(t=>t+1),children:"重新加载"})]})]})}function I({children:r,...s}){return e.jsxs("span",{className:"collab-select",children:[e.jsx("select",{...s,children:r}),e.jsx(Q,{size:16,"aria-hidden":"true"})]})}function M(r){return{id:crypto.randomUUID(),name:r===0?"群主":`成员 ${r}`,agentType:"codex",role:""}}function ce({member:r,index:s,owner:c,supervisor:g,health:S,onChange:h,onRemove:w}){const[x,v]=n.useState([]),[u,b]=n.useState([]);return n.useEffect(()=>{let l=!0;return v([]),b([]),r.agentType==="customer-agent"?(window.agentApi.getSettings().then(d=>{l&&b(d.profiles.map(({id:i,name:j,modelId:y})=>({id:i,name:j,modelId:y})))}).catch(()=>{}),()=>{l=!1}):(window.agentApi.listAgentModels(r.agentType).then(d=>{l&&v(d.models)}).catch(()=>{}),()=>{l=!1})},[r.agentType]),e.jsxs("fieldset",{className:"collab-member-editor",children:[e.jsxs("legend",{children:[c?e.jsx(V,{size:14}):e.jsx(ae,{size:14}),c?"群主":`成员 ${s}`,g?" · 监工":""]}),w&&e.jsx("button",{type:"button",className:"collab-remove","aria-label":`移除${r.name}`,onClick:w,children:e.jsx(O,{size:16})}),e.jsxs("div",{className:"collab-editor-fields",children:[e.jsxs("label",{children:["名称",e.jsx("input",{value:r.name,maxLength:100,onChange:l=>h({...r,name:l.target.value}),required:!0})]}),e.jsxs("label",{children:["Agent",e.jsx(I,{value:r.agentType,onChange:l=>h({...r,agentType:l.target.value,model:void 0,profileId:void 0}),children:Y.map(l=>{var d,i;return e.jsxs("option",{value:l,disabled:((d=S.find(j=>j.agentType===l))==null?void 0:d.available)===!1,children:[P[l],((i=S.find(j=>j.agentType===l))==null?void 0:i.available)===!1?" · 不可用":""]},l)})})]}),e.jsxs("label",{className:"collab-model-field",children:["模型",r.agentType==="customer-agent"?e.jsxs(I,{value:r.profileId||"",onChange:l=>{const d=u.find(i=>i.id===l.target.value);h({...r,profileId:d==null?void 0:d.id,model:d?{id:d.modelId}:void 0})},children:[e.jsx("option",{value:"",children:"沿用默认模型"}),u.map(l=>e.jsxs("option",{value:l.id,children:[l.name," · ",l.modelId]},l.id))]}):e.jsxs(I,{value:r.model?`${r.model.providerID||""}|${r.model.id}`:"",onChange:l=>{const d=x.find(i=>`${i.providerID||""}|${i.id}`===l.target.value);h({...r,model:d?{id:d.id,...d.providerID?{providerID:d.providerID}:{}}:void 0})},children:[e.jsx("option",{value:"",children:"沿用默认模型"}),x.map(l=>e.jsxs("option",{value:`${l.providerID||""}|${l.id}`,children:[l.displayName||l.id,l.providerDisplayName?` · ${l.providerDisplayName}`:""]},`${l.providerID}|${l.id}`))]})]})]}),e.jsxs("details",{className:"collab-role-options",open:g||void 0,children:[e.jsxs("summary",{children:[e.jsx("span",{children:"定位与职责"}),e.jsx("span",{className:"collab-muted",children:r.role.trim()?"已设置":c?"默认安排与汇总":"留空由群主分配"}),e.jsx(Q,{size:14})]}),e.jsx("textarea",{"aria-label":`${c?"群主":`成员 ${s}`}的定位与职责(选填)`,rows:2,maxLength:8e3,value:r.role,placeholder:g?"重点看什么:异常暂停、任务交接和交付。允许怎么处理:原任务内自动恢复、继续、协调交接;业务取舍或无法恢复时提醒我决策。":c?"负责拆解目标、分配任务、验收和汇总成果":"例如:负责实现接口;留空由群主自动分配",onChange:l=>h({...r,role:l.target.value})}),g&&e.jsx("p",{className:"collab-muted",children:"在职责中写明关注内容、判断标准、允许的恢复与交接,以及何时提醒你或等待决策。"})]})]})}function ve({cwd:r,initialGroup:s,health:c,onClose:g,onCreated:S}){var F;const[h,w]=n.useState((s==null?void 0:s.name)||""),[x,v]=n.useState((s==null?void 0:s.cwd)||r||""),[u,b]=n.useState(()=>s?structuredClone(s.members):[M(0),M(1)]),[l,d]=n.useState((s==null?void 0:s.ownerId)||u[0].id),[i,j]=n.useState((s==null?void 0:s.maxParallel)||3),[y,A]=n.useState(()=>{var a;return structuredClone(((a=s==null?void 0:s.monitoring)==null?void 0:a.targets)??[])}),[C,z]=n.useState(s?((F=s.monitoring)==null?void 0:F.supervisorId)??"":u[0].id),[N,t]=n.useState(!1),[o,p]=n.useState(""),[f,D]=n.useState(!1),[W,R]=n.useState(!!(s!=null&&s.cwd)),[k,B]=n.useState(!1),X=async()=>{if(p(""),K()){D(!0);return}B(!0);try{const a=await window.agentApi.openFileDialog();a&&(v(a),R(!0))}catch(a){p(a instanceof Error?a.message:"无法选择工作目录")}finally{B(!1)}};return n.useEffect(()=>{const a=m=>{m.key==="Escape"&&!N&&!f&&!k&&g()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[g,N,f,k]),e.jsxs("div",{className:"collab-modal-backdrop",onMouseDown:a=>{a.target===a.currentTarget&&!N&&g()},children:[e.jsxs("form",{className:"collab-create",role:"dialog","aria-modal":"true","aria-labelledby":"collab-create-title",onSubmit:async a=>{a.preventDefault(),t(!0),p("");try{if(!x.trim())throw new Error("请先选择工作目录");const m=u.find($=>{var E;return((E=c.find(J=>J.agentType===$.agentType))==null?void 0:E.available)===!1});if(m&&!s)throw new Error(`${m.name} 选择的 Agent 当前不可用`);const T=await L({...s?{action:"updateGroup",groupId:s.id}:{action:"createGroup"},group:{name:h.trim()||"协作群",cwd:x.trim(),ownerId:l,members:u,maxParallel:Math.min(i,u.length),...y.length?{monitoring:{targets:y,...C?{supervisorId:C}:{}}}:{}}});S(T)}catch(m){p(m instanceof Error?m.message:String(m))}finally{t(!1)}},children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("span",{className:"collab-eyebrow",children:"一起完成一件事"}),e.jsx("h2",{id:"collab-create-title",children:s?"修改协作群":"拉个协作群"})]}),e.jsx("button",{type:"button","aria-label":"关闭群设置",onClick:g,disabled:N,children:e.jsx(O,{size:20})})]}),e.jsxs("div",{className:"collab-create-scroll",children:[e.jsxs("div",{className:"collab-group-fields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"群名称"}),e.jsx("input",{autoFocus:!0,value:h,maxLength:100,placeholder:"例如:产品开发小组",onChange:a=>w(a.target.value)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"工作目录"}),e.jsxs("button",{type:"button",className:"collab-directory-picker","aria-label":"选择工作目录","aria-haspopup":"dialog","aria-expanded":f,title:x||"选择工作目录",disabled:N||k,onClick:()=>void X(),children:[e.jsx(se,{size:16,"aria-hidden":"true"}),e.jsx("span",{className:x?void 0:"collab-muted",children:k?"正在选择…":x||"选择工作目录"}),e.jsx(U,{size:16,"aria-hidden":"true"})]})]})]}),e.jsx("p",{className:"collab-create-hint collab-muted",children:s?"配置保存后用于新讨论,已有讨论和聊天记录保留。":"Agent 可重复加入,职责留空由群主分配。"}),u.map((a,m)=>e.jsx(ce,{member:a,index:m,owner:a.id===l,supervisor:y.length>0&&a.id===C,health:c,onChange:T=>b($=>$.map(E=>E.id===T.id?T:E)),onRemove:a.id!==l&&u.length>2?()=>{a.id===C&&z(""),b(T=>T.filter($=>$.id!==a.id))}:void 0},a.id)),e.jsxs("div",{className:"collab-create-actions",children:[e.jsxs("label",{children:["群主",e.jsx(I,{value:l,onChange:a=>d(a.target.value),children:u.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))})]}),e.jsxs("button",{type:"button",disabled:u.length>=20,onClick:()=>b(a=>[...a,M(a.length)]),children:[e.jsx(U,{size:16}),"添加成员"]}),e.jsxs("label",{children:["最多同时工作",e.jsx(I,{value:Math.min(i,u.length),onChange:a=>j(Number(a.target.value)),children:u.map((a,m)=>e.jsxs("option",{value:m+1,children:[m+1," 人"]},m+1))})]})]}),e.jsx(oe,{value:y,onChange:A}),y.length>0&&e.jsxs("label",{className:"collab-supervisor-select",children:["监工",e.jsxs(I,{"aria-label":"选择监工成员",value:C,onChange:a=>z(a.target.value),children:[e.jsx("option",{value:"",children:"仅关联,不启用监工"}),u.map(a=>e.jsxs("option",{value:a.id,children:[a.name," · ",P[a.agentType]]},a.id))]}),e.jsx("small",{className:"collab-muted",children:"复用该成员的 Agent、模型和职责,关闭看板后继续监管。"})]})]}),o&&e.jsx("p",{className:"collab-error",role:"alert",children:o}),e.jsxs("footer",{children:[e.jsx("span",{className:"collab-muted",children:"职责可以留空,发送任务后由群主分配。"}),e.jsx("button",{className:"collab-primary",disabled:N||k||!x.trim(),type:"submit",children:N?"正在保存…":s?"保存修改":"创建并打开群"})]})]}),e.jsx(Z,{open:f,initialPath:W?x:void 0,onCancel:()=>D(!1),onConfirm:a=>{v(a),R(!0),D(!1),p("")}})]})}export{ve as C,le as S,re as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,u as O,j as e,R as P,h as S,k as $,a as g}from"./index-C30NoLsn.js";import{C as _,a as B,b as G}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{C as M}from"./CollaborationCreateDialog-DsXkxAd1.js";import{c as R,A as z}from"./client-BpqlZTm2.js";import{p as H}from"./SessionDashboardBridge-7BjKdfN8.js";import{U as T}from"./collaboration-CYS2Soeh.js";import{X as U}from"./x-CoIXF2eL.js";import{S as Y,i as q}from"./file-types-Dj25tuty.js";import{P as F,T as Q}from"./trash-2-DwFoTvHX.js";import{C as X}from"./types-COzZsLPY.js";import{A as J}from"./session-tree-Q-jABJNB.js";import"./HostProjectPicker-CjlxN2ct.js";import"./chevron-right-B_ITnckH.js";import"./chevron-down-BUEiUZA7.js";function K(){const[u,m]=t.useState([]),[x,h]=t.useState(!0),[f,o]=t.useState(""),l=t.useRef(0),r=t.useCallback(async()=>{const n=++l.current;h(!0);try{const i=await R({action:"groups"});l.current===n&&(m(i),o(""))}catch(i){l.current===n&&o(i instanceof Error?i.message:String(i))}finally{l.current===n&&h(!1)}},[]);return t.useEffect(()=>{r();const n=()=>{r()};return window.addEventListener("focus",n),()=>{l.current++,window.removeEventListener("focus",n)}},[r]),{groups:u,loading:x,error:f,refresh:r}}function me({onOpen:u,onChanged:m,onClose:x,onViewDashboard:h,cwd:f}){const{groups:o,loading:l,error:r,refresh:n}=K(),[i,L]=t.useState(""),[c,b]=t.useState(null),[j,w]=t.useState(null),[p,y]=t.useState(!1),[v,N]=t.useState(""),[D,I]=t.useState([]),E=O(s=>s.skin);t.useEffect(()=>{!l&&window.parent!==window&&window.parent.postMessage({type:_},window.location.origin)},[l]),t.useEffect(()=>{document.documentElement.setAttribute("data-skin",E)},[E]),t.useEffect(()=>{let s=!0;return window.agentApi.getRuntimeHealth().then(a=>{s&&I(a)}).catch(()=>{}),()=>{s=!1}},[]);const C=s=>{u?u(s):window.parent!==window?window.parent.postMessage({type:B,groupId:s.id,title:s.name},window.location.origin):location.assign(`?view=collaboration&groupId=${encodeURIComponent(s.id)}`)},A=(s,a)=>{m==null||m(s,a),window.parent!==window&&window.parent.postMessage({type:G,groupId:s,...a?{title:a.name}:{deleted:!0}},window.location.origin),n()},k=o.filter(s=>`${s.name} ${s.cwd} ${s.members.map(a=>a.name).join(" ")}`.toLowerCase().includes(i.trim().toLowerCase()));return e.jsxs("main",{className:"collab-dashboard",children:[e.jsxs("header",{className:"collab-dashboard-heading",children:[e.jsxs("div",{children:[e.jsx("span",{className:"collab-eyebrow",children:"协作空间"}),e.jsxs("h1",{children:["群聊列表 ",e.jsx("small",{children:o.length})]}),e.jsx("p",{className:"collab-muted",children:"找到你的群,继续上次的协作。"})]}),e.jsxs("div",{className:"collab-dashboard-tools",children:[e.jsx("button",{onClick:()=>h?h():H({kind:"dashboard"}),children:"Dashboard"}),e.jsx("button",{"aria-label":"刷新群列表",title:"刷新群列表",disabled:l,onClick:()=>void n(),children:e.jsx(P,{size:17})}),e.jsxs("button",{className:"collab-primary",onClick:()=>b("new"),children:[e.jsx(S,{size:17}),"新增群聊"]}),x&&e.jsx("button",{"aria-label":"关闭群看板",onClick:x,children:e.jsx(U,{size:18})})]})]}),e.jsxs("label",{className:"collab-dashboard-search",children:[e.jsx(Y,{size:17}),e.jsx("input",{"aria-label":"搜索群聊",placeholder:"搜索群名、成员或工作目录",value:i,onChange:s=>L(s.target.value)})]}),r&&e.jsxs("div",{className:"collab-error",role:"alert",children:[r,e.jsx("button",{onClick:()=>void n(),children:"重试"})]}),l&&o.length===0?e.jsx("div",{className:"collab-dashboard-empty",role:"status",children:"正在加载已保存的群…"}):!r&&k.length===0?e.jsxs("div",{className:"collab-dashboard-empty",children:[e.jsx(T,{size:32}),e.jsx("h2",{children:i?"没有找到匹配的群":"还没有协作群"}),e.jsx("p",{children:i?"换个关键词试试。":"选一位群主和成员,一起完成任务。"}),!i&&e.jsxs("button",{className:"collab-primary",onClick:()=>b("new"),children:[e.jsx(S,{size:16}),"新建第一个群"]})]}):e.jsx("section",{className:"collab-dashboard-grid","aria-label":"已保存的群聊","aria-busy":l,children:k.map(s=>{const a=s.members.find(d=>d.id===s.ownerId);return e.jsxs("article",{className:"collab-group-card",children:[e.jsxs("div",{className:"collab-card-heading",children:[e.jsxs("button",{className:"collab-card-title",onClick:()=>C(s),title:s.name,children:[e.jsx(T,{size:20}),e.jsx("h2",{children:s.name})]}),e.jsxs("div",{className:"collab-card-actions",children:[e.jsx("button",{"aria-label":`修改${s.name}`,title:"修改群设置",onClick:()=>b(s),children:e.jsx(F,{size:16})}),e.jsx("button",{"aria-label":`删除${s.name}`,title:"删除群聊",onClick:()=>{N(""),w(s)},children:e.jsx(Q,{size:16})})]})]}),e.jsxs("p",{className:"collab-card-owner",children:[e.jsx(X,{size:14}),e.jsxs("span",{children:["群主 · ",a==null?void 0:a.name]}),e.jsx("span",{className:"collab-muted",children:a&&z[a.agentType]})]}),e.jsxs("div",{className:"collab-card-members","aria-label":`${s.members.length} 名群成员`,children:[s.members.slice(0,7).map(d=>e.jsx("span",{title:`${d.name} · ${z[d.agentType]}`,children:e.jsx($,{agentType:d.agentType,size:18})},d.id)),e.jsxs("small",{children:[s.members.length," 人 · 最多 ",s.maxParallel," 人并行"]})]}),e.jsxs("p",{className:"collab-card-path",title:s.cwd,children:[e.jsx(q,{size:14}),e.jsx("span",{children:s.cwd})]}),e.jsxs("footer",{children:[e.jsxs("time",{dateTime:s.createdAt,children:[new Date(s.createdAt).toLocaleDateString("zh-CN")," 创建"]}),e.jsxs("button",{onClick:()=>C(s),children:["进入群聊",e.jsx(J,{size:16})]})]})]},s.id)})}),c&&g.createPortal(e.jsx(M,{cwd:f,initialGroup:c==="new"?void 0:c,health:D,onClose:()=>b(null),onCreated:s=>{const a=c==="new";b(null),A(s.id,s),a&&C(s)}},c==="new"?"new":c.id),document.body),j&&g.createPortal(e.jsx("div",{className:"collab-modal-backdrop",children:e.jsxs("section",{className:"collab-delete-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"collab-delete-title","aria-describedby":"collab-delete-description",children:[e.jsxs("h2",{id:"collab-delete-title",children:["删除“",j.name,"”?"]}),e.jsx("p",{id:"collab-delete-description",children:"删除后将停止监工并取消关联定时任务,原始业务会话和工作目录文件会保留。进行中的协作需要先停止。"}),v&&e.jsx("p",{className:"collab-error",role:"alert",children:v}),e.jsxs("footer",{children:[e.jsx("button",{autoFocus:!0,disabled:p,onClick:()=>w(null),children:"取消"}),e.jsx("button",{className:"collab-delete-confirm",disabled:p,onClick:async()=>{y(!0),N("");try{await R({action:"deleteGroup",groupId:j.id}),A(j.id),w(null)}catch(s){N(s instanceof Error?s.message:String(s))}finally{y(!1)}},children:p?"正在删除…":"确认删除"})]})]})}),document.body)]})}export{me as default};
|
package/runtime/webapp/dist/assets/{CollaborationPage-B2mIAc-h.js → CollaborationPage-Cjeo60S0.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as Re,r as o,j as e,y as Ce,z as Le,k as W,n as Ae,v as Ie,
|
|
1
|
+
import{c as Re,r as o,j as e,y as Ce,z as Le,k as W,n as Ae,v as Ie,B as Pe,u as Oe,L as xe,h as je,M as Fe,D as Be}from"./index-C30NoLsn.js";import{i as _e,r as Ue,p as Ge,a as He,M as We,S as Ye}from"./composer-file-routing-DHdpFYk8.js";import{p as Ke}from"./SessionDashboardBridge-7BjKdfN8.js";import{S as Ve}from"./shield-check-Bzd1i1OQ.js";import{A as Z,c as R,D as ve}from"./client-BpqlZTm2.js";import{U as X}from"./collaboration-CYS2Soeh.js";import{X as Te}from"./x-CoIXF2eL.js";import{b as ie,C as Ze}from"./types-COzZsLPY.js";import{c as Je}from"./CollaborationTabBridge-Dxq4G1Uk.js";import{H as Qe}from"./history-DTS97eAH.js";import{I as Xe}from"./image-plus-BmlwMe18.js";import{C as et}from"./check-DCU8YHqr.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const tt=Re("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]),st=8;function nt(s,u){return s.split(/(\[[^\]\n]+\]\([^\n)]+\))/g).flatMap(r=>{const a=Ge(r),m=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(r);if(!m||a.some(f=>f.type==="artifact"||f.type==="link"))return a;const p=m[2].trim().replace(/^<|>$/g,"");if(/^[A-Za-z][\w+.-]*:/.test(p)&&!/^[A-Za-z]:[\\/]/.test(p))return a;const n=Ce(p,u);return n?[{type:"artifact",label:m[1],path:n,raw:r}]:a})}function le({text:s,cwd:u}){const r=o.useId(),a=o.useRef(null),[m,p]=o.useState(!1),[n,f]=o.useState(!1);return o.useEffect(()=>{const c=a.current;if(!c)return;const l=()=>{const A=Number.parseFloat(getComputedStyle(c).lineHeight);p(c.scrollHeight>A*st+1)};l();const h=new ResizeObserver(l);return h.observe(c),()=>h.disconnect()},[s]),e.jsxs(e.Fragment,{children:[e.jsx("div",{id:r,ref:a,className:"collab-message-text","data-collapsed":!n,children:nt(s,u).map((c,l)=>{if(c.type==="text")return c.value;if(c.type==="code")return e.jsx("code",{children:c.value},l);if(c.type==="link")return e.jsx("a",{href:c.href,target:"_blank",rel:"noopener noreferrer",onClick:A=>{_e(A)&&Ue(c.href)&&A.preventDefault()},children:c.label},l);const h=Ce(c.path,u);return h?e.jsx("button",{type:"button",className:"collab-message-path",title:c.line?`${h}:${c.line}`:h,"aria-label":`查看文件:${c.label}`,onClick:()=>{Le(h)||window.agentApi.openExternal(/^https?:\/\//i.test(h)?h:`file://${h}`)},children:c.label},l):c.raw})}),m&&e.jsx("button",{type:"button",className:"collab-message-toggle","aria-expanded":n,"aria-controls":r,onClick:()=>f(c=>!c),children:n?"收起":"展开全文"})]})}function at({group:s}){var r;if(!((r=s.monitoring)!=null&&r.targets.length))return null;const u=s.members.find(a=>{var m;return a.id===((m=s.monitoring)==null?void 0:m.supervisorId)});return e.jsxs("div",{className:"collab-supervision-summary",children:[e.jsxs("div",{children:[e.jsx(Ve,{size:14}),e.jsxs("span",{children:[u?`监工 · ${u.name}`:"已关联"," · ",s.monitoring.targets.length," 条原始会话"]})]}),e.jsx("button",{onClick:()=>Ke({kind:"dashboard"}),children:"查看监工与决策"})]})}function ye(s,u,r){var f,c;const a=r==="sender"?s.senderAgentType:s.recipientAgentType;if(a)return a;const m=s[r];if(!m||m==="你"||m===u.name)return;const p=s.direction==="received"?"sender":s.direction==="sent"?"recipient":void 0;if(r===p){const l=((f=u.monitoring)==null?void 0:f.targets.filter(h=>(s.sessionId?h.id===s.sessionId:h.title===m)&&(m===s.sessionTitle||m===h.title)))??[];if(l.length===1)return l[0].agentType}const n=u.members.filter(l=>l.name===m);if(n.length===1)return n[0].agentType;if(m==="监工")return(c=u.members.find(l=>{var h;return l.id===((h=u.monitoring)==null?void 0:h.supervisorId)}))==null?void 0:c.agentType}function rt({message:s,group:u}){const r=ye(s,u,"sender"),a=ye(s,u,"recipient"),m=r?`${s.sender} · ${Z[r]}`:s.sender,p=a?`${s.recipient} · ${Z[a]}`:s.recipient,n=s.sender==="你"&&!r,f=s.direction==="received"?"收到消息":s.direction==="sent"?"发出消息":"监工动态";return e.jsxs("article",{className:`collab-message collab-supervision-message is-${s.direction}`,"data-supervision-message":s.id,"aria-label":`${f}:${s.title}`,children:[e.jsx("span",{className:`collab-avatar collab-supervision-avatar${n?" collab-avatar--user":""}`,role:"img","aria-label":m,title:m,children:r?e.jsx(W,{agentType:r,size:20}):n?"你":e.jsx(X,{size:18,"aria-hidden":"true"})}),e.jsxs("div",{className:"collab-message-body",children:[e.jsxs("div",{className:"collab-supervision-message-heading",children:[e.jsx("strong",{children:s.title}),e.jsx("span",{children:s.historical?"历史监工记录":f})]}),e.jsxs("div",{className:"collab-supervision-message-route","aria-label":`${s.sender}${s.recipient?` → ${s.recipient}`:""}`,children:[e.jsxs("span",{className:"collab-supervision-participant",title:m,children:[r&&e.jsx(W,{agentType:r,size:13}),e.jsx("span",{children:s.sender})]}),s.recipient&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsxs("span",{className:"collab-supervision-participant",title:p,children:[a&&e.jsx(W,{agentType:a,size:13}),e.jsx("span",{children:s.recipient})]})]})]}),s.sessionTitle&&e.jsxs("div",{className:"collab-supervision-message-source",title:s.sessionTitle,children:["来源会话:",s.sessionTitle]}),e.jsx(le,{text:s.content,cwd:s.cwd||u.cwd})]}),e.jsx("time",{dateTime:s.createdAt,title:new Date(s.createdAt).toLocaleString("zh-CN"),children:new Date(s.createdAt).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})})]})}function we(s,u){return[...new Map([...s,...u].map(r=>[r.id,r])).values()].sort((r,a)=>r.createdAt.localeCompare(a.createdAt)||(r.sequence??0)-(a.sequence??0)||r.id.localeCompare(a.id))}function it(s,u){return[...s.filter(r=>r.kind!=="progress").map(r=>({kind:"discussion",message:r})),...u.map(r=>({kind:"supervision",message:r}))].sort((r,a)=>r.message.createdAt.localeCompare(a.message.createdAt)||(r.kind==="supervision"&&a.kind==="supervision"?(r.message.sequence??0)-(a.message.sequence??0):0)||r.message.id.localeCompare(a.message.id))}function lt(s){const u=Ae(),[r,a]=o.useState([]),[m,p]=o.useState(""),[n,f]=o.useState(!0),[c,l]=o.useState(!1),[h,A]=o.useState(null),k=o.useRef({groupId:s,generation:0,latest:0,before:null,loaded:!1,older:!1});o.useEffect(()=>{const i={groupId:s,generation:k.current.generation+1,latest:0,before:null,loaded:!1,older:!1};k.current=i,a([]),p(""),A(null),f(!0),l(!1)},[s]),o.useEffect(()=>{if(!u)return;const i=k.current;let v=!0,j=!1;const w=async()=>{if(!(j||!s||!Ie())){j=!0;try{const N=await R({action:"supervisionMessages",groupId:s,limit:100,...i.loaded?{afterSequence:i.latest}:{}});if(!v)return;a(z=>we(z,N.messages)),i.loaded||(i.before=N.nextBefore,A(N.nextBefore)),i.latest=Math.max(i.latest,N.latestSequence),i.loaded=!0,p("")}catch(N){v&&p(`监工消息加载失败:${N instanceof Error?N.message:String(N)}`)}finally{j=!1,v&&f(!1)}}};w();const D=setInterval(()=>{w()},2e3);return()=>{v=!1,clearInterval(D)}},[u,s]);const $=o.useCallback(async()=>{const i=k.current;if(!(i.groupId!==s||i.before===null||i.older)){i.older=!0,l(!0);try{const v=await R({action:"supervisionMessages",groupId:s,beforeSequence:i.before,limit:100});if(k.current!==i)return;a(j=>we(j,v.messages)),i.before=v.nextBefore,A(v.nextBefore),p("")}catch(v){k.current===i&&p(`历史监工消息加载失败:${v instanceof Error?v.message:String(v)}`)}finally{i.older=!1,k.current===i&&l(!1)}}},[s]);return{messages:r,error:m,loading:n,loadingOlder:c,hasOlder:h!==null,loadOlder:$}}function Ne({images:s,onPreview:u,onRemove:r}){return s.length?e.jsx("div",{className:`collab-images${r?" is-draft":""}`,"aria-label":r?"待发送图片":"消息图片",children:s.map((a,m)=>e.jsxs("div",{className:"collab-image",children:[e.jsx("button",{type:"button",className:"collab-image-preview","aria-label":`查看图片 ${m+1}`,onClick:()=>u(a),children:e.jsx("img",{src:a,alt:`图片 ${m+1}`,loading:"lazy"})}),r&&e.jsx("button",{type:"button",className:"collab-image-remove","aria-label":`移除图片 ${m+1}`,onClick:()=>r(m),children:e.jsx(Te,{size:13})})]},m))}):null}const Se=10,ct=20*1024*1024;function ot(s){if(s===void 0)return;if(!Array.isArray(s)||s.length>Se)throw new ie(`每条消息最多添加 ${Se} 张图片`);let u=0;for(const r of s){if(typeof r!="string"||!/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(r))throw new ie("图片格式无效,仅支持 JPG、PNG、GIF 和 WebP");u+=r.length}if(u>ct)throw new ie("图片总大小超过限制,请减少图片或压缩后重试")}const Q={text:"",images:[]};function dt(s,u,r){const a=`${s}:${u||"new"}`,[m,p]=o.useState({}),[n,f]=o.useState({}),c=o.useRef(),l=m[a]??Q,h=$=>{p(i=>({...i,[a]:$(i[a]??Q)}))},A=async $=>{if($.length){f(i=>({...i,[a]:(i[a]??0)+1}));try{const i=await He($,async v=>{const j=await Pe(v);return new Promise((w,D)=>{const N=new FileReader;N.onload=()=>w(String(N.result)),N.onerror=()=>D(new Error("无法读取图片")),N.readAsDataURL(j)})});(i.attachments.length||i.unsupportedImages.length||i.failedImages.length)&&r("无法添加部分图片,仅支持 JPG、PNG、GIF 和 WebP。"),i.images.length&&h(v=>({...v,images:[...v.images,...i.images]}))}catch(i){r(i instanceof Error?i.message:"无法添加图片")}finally{f(i=>({...i,[a]:Math.max(0,(i[a]??1)-1)}))}}},k=async $=>{var j;if(n[a]||!l.text.trim()&&!l.images.length)return!1;try{ot(l.images)}catch(w){return r(w instanceof Error?w.message:"图片无效"),!1}(((j=c.current)==null?void 0:j.key)!==a||c.current.draft!==l)&&(c.current={key:a,draft:l,id:crypto.randomUUID()});let i=a;return await $(l.text,c.current.id,l.images,w=>{var D;i=`${s}:${w}`,p(N=>({...N,[a]:Q,[i]:N[a]??l})),((D=c.current)==null?void 0:D.draft)===l&&(c.current.key=i)})?(p(w=>w[i]===l?{...w,[i]:Q}:w),!0):!1};return{draft:l.text,images:l.images,reading:!!n[a],addImages:A,submit:k,setDraft:$=>h(i=>({...i,text:$})),removeImage:$=>h(i=>({...i,images:i.images.filter((v,j)=>j!==$)}))}}function ut(s,u){const r=Ae(),[a,m]=o.useState(null),[p,n]=o.useState([]),[f,c]=o.useState(null),[l,h]=o.useState(null),[A,k]=o.useState(""),[$,i]=o.useState(!1),v=o.useRef(0),j=o.useRef(null),w=o.useRef(!1),D=o.useRef(null),N=()=>{v.current++,i(!0)},z=()=>{v.current--,i(v.current>0)},y=o.useRef({groupId:s,selected:f,revision:-1});y.current.groupId=s,y.current.selected=f;const O=o.useCallback(g=>{y.current.selected=g,y.current.revision=-1,c(g),h(null),k("");try{g&&localStorage.setItem(`collaboration:${s}:discussion`,g)}catch{}},[s]),P=o.useCallback(async()=>{const g=await R({action:"discussions",groupId:s});return y.current.groupId===s&&n(g),g},[s]);o.useEffect(()=>{let g=!0;return m(null),n([]),O(null),Promise.all([R({action:"group",groupId:s}),P()]).then(([x,E])=>{var C,T;if(!g)return;m(x);let I=null;try{I=localStorage.getItem(`collaboration:${s}:discussion`)}catch{}I=u||new URLSearchParams(window.location.search).get("discussionId")||I,O(((C=E.find(M=>M.id===I))==null?void 0:C.id)||((T=E[0])==null?void 0:T.id)||null)}).catch(x=>{g&&k(x.message)}),()=>{g=!1}},[s,P,O,u]),o.useEffect(()=>{if(!r||!f)return;let g=!0,x=!1;const E=async()=>{if(!(x||!Ie())){x=!0;try{const C=await R({action:"discussion",discussionId:f,afterRevision:y.current.revision<0?void 0:y.current.revision});if(!g||y.current.selected!==f)return;if(!("unchanged"in C)&&C.revision>=y.current.revision&&(y.current.revision=C.revision,h(C),await P()),D.current){const T=D.current;k(M=>M===T?"":M),D.current=null}}catch(C){g&&(D.current=C instanceof Error?C.message:String(C),k(D.current))}finally{x=!1}}};E();const I=setInterval(()=>{E()},1200);return()=>{g=!1,clearInterval(I)}},[r,f,P]);const Y=()=>(j.current||(N(),j.current=(async()=>{const g=await R({action:"createDiscussion",groupId:s});return y.current.groupId!==s?null:(O(g.id),y.current.revision=g.revision,h(g),await P(),g)})().finally(()=>{j.current=null,z()})),j.current),F=async g=>{if(!(!r||!f)){N();try{const x=await R({action:g,discussionId:f});y.current.selected===f&&x.revision>=y.current.revision&&(y.current.revision=x.revision,h(x))}catch(x){k(x instanceof Error?x.message:String(x))}finally{z()}}},K=async g=>{if(!(!f||(l==null?void 0:l.mode)===g)){N();try{const x=await R({action:"setMode",discussionId:f,mode:g});y.current.selected===f&&x.revision>=y.current.revision&&(y.current.revision=x.revision,h(x))}catch(x){k(x instanceof Error?x.message:String(x))}finally{z()}}},ee=async(g,x,E,I)=>{var C;if(w.current)return!1;w.current=!0,N(),k("");try{const T=f||((C=await Y())==null?void 0:C.id);if(!T)return!1;f||I==null||I(T);const M=await R({action:"send",discussionId:T,text:g,messageId:x,...E!=null&&E.length?{images:E}:{}});return y.current.selected===T&&M.revision>=y.current.revision&&(y.current.revision=M.revision,h(M)),await P(),!0}catch(T){return k(T instanceof Error?T.message:String(T)),!1}finally{w.current=!1,z()}},J=async(g,x)=>{const E=await R({action:"updateRole",groupId:s,memberId:g,role:x});y.current.groupId===s&&m(E)};return{group:l!=null&&l.groupSnapshot&&a?{...l.groupSnapshot,name:a.name}:a,history:p,selected:f,discussion:l,error:A,busy:$,select:O,create:Y,act:F,setMode:K,send:ee,setError:k,updateRole:J}}function ke({member:s,isUser:u=!1,isOwner:r=!1}){const a=u?"你":s?`${s.name} · ${Z[s.agentType]}${r?" · 群主":""}`:"协作动态";return e.jsxs("span",{className:`collab-avatar${u?" collab-avatar--user":""}`,role:"img","aria-label":a,title:a,children:[u?"你":s?e.jsx(W,{agentType:s.agentType,size:20}):e.jsx(X,{size:18,"aria-hidden":"true"}),r&&e.jsx(Ze,{className:"collab-avatar-crown",size:13,"aria-hidden":"true"})]})}function ft({message:s,discussionId:u,onError:r}){var c;const[a,m]=o.useState(""),[p,n]=o.useState(!1);if(!s.question||s.question.resolved)return e.jsxs("span",{className:"collab-muted",children:[e.jsx(et,{size:12})," 已处理"]});const f=async(l,h)=>{n(!0);try{await R({action:"answer",discussionId:u,questionId:s.question.id,answer:l,...h===void 0?{}:{selectedIndices:[h]}})}catch(A){r(A instanceof Error?A.message:String(A))}finally{n(!1)}};return e.jsxs("div",{className:"collab-question",children:[(c=s.question.options)==null?void 0:c.map((l,h)=>e.jsx("button",{disabled:p,onClick:()=>{f(l.label,h)},title:l.description,children:l.label},h)),e.jsxs("form",{onSubmit:l=>{l.preventDefault(),a.trim()&&f(a)},children:[e.jsx("input",{"aria-label":"回答成员问题",value:a,onChange:l=>m(l.target.value),placeholder:"输入回复"}),e.jsx("button",{disabled:p||!a.trim(),children:"回复"})]})]})}function Ct({groupId:s,initialDiscussionId:u}){var pe,ge;const r=s||new URLSearchParams(location.search).get("groupId")||"",{group:a,history:m,selected:p,discussion:n,error:f,busy:c,select:l,create:h,act:A,setMode:k,send:$,setError:i,updateRole:v}=ut(r,u),j=lt(r),{draft:w,setDraft:D,images:N,reading:z,addImages:y,removeImage:O,submit:P}=dt(r,p,i),[Y,F]=o.useState(!1),[K,ee]=o.useState(null),[J,g]=o.useState(null),x=o.useRef(null),E=o.useRef(null),[I,C]=o.useState(null),[T,M]=o.useState(0),ce=Oe(t=>t.skin);o.useEffect(()=>{document.documentElement.setAttribute("data-skin",ce)},[ce]);const oe=!!f||!!a&&(!p||!!n);o.useEffect(()=>{oe&&window.parent!==window&&window.parent.postMessage({type:Je,groupId:r},window.location.origin)},[oe,r]);const de=o.useRef(null),te=o.useRef(null),G=o.useRef(!0);if(o.useEffect(()=>{var t;G.current&&((t=de.current)==null||t.scrollIntoView({block:"end"}))},[n==null?void 0:n.messages.length,j.messages.length,p]),o.useEffect(()=>{G.current=!0},[p]),!a)return e.jsx("div",{className:"collab-loading",children:f?e.jsx("p",{role:"alert",children:f}):e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"collab-spin"}),"正在打开协作群…"]})});const L=a.members.find(t=>t.id===a.ownerId),B=((n==null?void 0:n.mode)??"task-graph")==="chat",_=I?a.members.filter(t=>`${t.name} ${t.id}`.toLowerCase().includes(I.query.toLowerCase())):[],$e=(t,d)=>{const S=/(?:^|\s)@([^\s@]{0,30})$/.exec(t.slice(0,d));C(S?{query:S[1],start:d-S[1].length-1}:null),M(0)},ue=t=>{const d=E.current;if(!I||!d)return;const S=d.selectionStart??w.length,q=`@${t.name} `;D(w.slice(0,I.start)+q+w.slice(S)),C(null),requestAnimationFrame(()=>{d.focus();const U=I.start+q.length;d.setSelectionRange(U,U)})},V=(n==null?void 0:n.tasks.filter(t=>t.status==="running"))||[],se=(n==null?void 0:n.status)==="running"?n.tasks.filter(t=>t.status==="queued"):[],ne=se.filter(t=>t.result==="等待工作目录空闲"),ae=(n==null?void 0:n.planning)||(n==null?void 0:n.status)==="running"&&n.ownerPending&&V.length===0,H=!ae&&V.length===0&&se.length>0,Ee=ne.length>0?`${ne.length} 个任务等待工作目录空闲,空闲后会自动继续。`:"任务排队中,等待前置任务完成。",fe=H?ne.length>0?"等待工作目录空闲":"任务排队中":n?je[n.status]:"准备好了",re=it((n==null?void 0:n.messages)??[],j.messages),De=t=>{l(t),F(!1),C(null),G.current=!0},me=async()=>{var t;try{await h()&&(F(!1),C(null),(t=E.current)==null||t.focus())}catch(d){i(d instanceof Error?d.message:String(d))}},he=async()=>{c||z||await P($)&&(C(null),G.current=!0)};return e.jsxs("div",{className:"collab-page",children:[e.jsx(We,{image:J?{src:J,alt:"群聊图片"}:null,onClose:()=>g(null)}),Y&&e.jsx("button",{className:"collab-drawer-mask","aria-label":"关闭成员栏",onClick:()=>F(!1)}),e.jsxs("aside",{className:`collab-sidebar${Y?" is-open":""}`,children:[e.jsxs("header",{className:"collab-sidebar-heading",children:[e.jsx("div",{className:"collab-group-icon",children:e.jsx(X,{size:22})}),e.jsxs("div",{children:[e.jsxs("span",{className:"collab-eyebrow",children:["协作群 · ",a.members.length," 人"]}),e.jsx("h2",{children:a.name})]}),e.jsx("button",{className:"collab-mobile-close","aria-label":"收起群成员",onClick:()=>F(!1),children:e.jsx(Te,{size:18})})]}),e.jsxs("div",{className:"collab-roster","aria-label":"群成员",children:[e.jsx("span",{className:"collab-section-label",children:"群成员"}),[L,...a.members.filter(t=>t.id!==L.id)].map(t=>{var be;const d=V.find(b=>b.memberId===t.id),S=t.id===L.id&&(n==null?void 0:n.planning),q=se.find(b=>b.memberId===t.id),ze=(n==null?void 0:n.messages.some(b=>b.memberId===t.id&&b.question&&!b.question.resolved))?"等待你回复":S?"正在安排":d?"正在执行":q?q.result==="等待工作目录空闲"?"等待目录空闲":"排队中":"空闲";return e.jsxs("div",{className:`collab-roster-member${S||d?" is-working":""}`,children:[e.jsxs("button",{onClick:()=>ee(b=>b===t.id?null:t.id),"aria-expanded":K===t.id,children:[e.jsx(ke,{member:t,isOwner:t.id===L.id}),e.jsxs("span",{className:"collab-member-name",children:[e.jsx("strong",{children:t.name}),e.jsx("small",{children:Z[t.agentType]})]}),e.jsx("span",{className:"collab-member-status",children:ze})]}),e.jsx("p",{className:K===t.id?"is-expanded":void 0,children:t.role||(n==null?void 0:n.roles[t.id])||"等待群主分配定位"}),K===t.id&&e.jsxs("div",{className:"collab-member-detail",children:[e.jsx("small",{children:((be=t.model)==null?void 0:be.id)||"默认模型"}),e.jsxs("form",{className:"collab-role-form",onSubmit:b=>{b.preventDefault();const Me=new FormData(b.currentTarget).get("role");v(t.id,String(Me||"")).catch(qe=>i(qe.message))},children:[e.jsxs("label",{children:["定位与职责",e.jsx("textarea",{name:"role",defaultValue:t.role,rows:3,maxLength:8e3,placeholder:"留空由群主分配"},t.role)]}),e.jsx("button",{type:"submit",children:"保存职责"})]}),n==null?void 0:n.tasks.filter(b=>b.memberId===t.id).map(b=>e.jsxs("div",{children:[b.title,e.jsx("span",{children:b.status==="completed"?"已完成":b.status==="running"?"执行中":b.status==="queued"?"等待依赖或空闲":b.status==="failed"?"失败":b.status==="cancelled"?"已取消":"已中断"}),b.result&&e.jsxs("details",{children:[e.jsx("summary",{children:"查看结果"}),e.jsx(le,{text:b.result,cwd:b.cwd||a.cwd})]})]},b.id)),n==null?void 0:n.messages.filter(b=>b.memberId===t.id&&b.kind==="progress").slice(-20).map(b=>e.jsx("small",{children:b.content},b.id))]})]},t.id)})]}),e.jsxs("section",{className:"collab-history","aria-label":"群聊记录",children:[e.jsxs("header",{children:[e.jsxs("span",{className:"collab-section-label",children:[e.jsx(Qe,{size:13}),"群聊记录"]}),e.jsx("button",{disabled:c,"aria-label":"新建群讨论",title:"新讨论",onClick:()=>{me()},children:e.jsx(xe,{size:17})})]}),e.jsx("div",{className:"collab-history-list",children:m.length?m.map(t=>e.jsxs("button",{className:p===t.id?"is-selected":"","aria-current":p===t.id?"page":void 0,onClick:()=>{De(t.id)},children:[e.jsx("strong",{children:t.title}),e.jsxs("span",{children:[e.jsx("time",{children:new Date(t.updatedAt).toLocaleDateString("zh-CN",{month:"short",day:"numeric"})}),e.jsx("small",{children:je[t.status]})]})]},t.id)):e.jsx("p",{className:"collab-muted",children:(pe=a.monitoring)!=null&&pe.targets.length?"监工动态持续保存在群内,普通讨论会列在这里。":"发送第一条任务,记录会保存在这里。"})})]}),e.jsxs("footer",{className:"collab-sidebar-footer",title:a.cwd,children:[e.jsx(at,{group:a}),a.cwd]})]}),e.jsxs("main",{className:"collab-conversation",children:[e.jsxs("header",{className:"collab-conversation-heading",children:[e.jsx("button",{className:"collab-mobile-menu","aria-label":"展开群成员和群聊记录",onClick:()=>F(!0),children:e.jsx(Fe,{size:20})}),e.jsxs("div",{className:"collab-discussion-title",children:[e.jsx("h1",{children:(n==null?void 0:n.title)||((ge=a.monitoring)!=null&&ge.targets.length?"监工动态":"开始一起做事")}),e.jsx("span",{className:"collab-discussion-status","data-status":H?"queued":(n==null?void 0:n.status)||"idle",role:"status","aria-label":fe,title:fe})]}),e.jsxs("div",{className:"collab-heading-actions",children:[n&&e.jsxs("div",{className:"collab-mode-toggle",role:"group","aria-label":"讨论模式",children:[e.jsx("button",{"aria-pressed":!B,disabled:c||!B,title:"每条消息交给群主安排;@成员 仍直接指派",onClick:()=>{k("task-graph")},children:"编排"}),e.jsx("button",{"aria-pressed":B,disabled:c||B,title:"@成员直接指派 · @群主安排分工 · 无 @ 静默",onClick:()=>{k("chat")},children:"@直聊"})]}),n&&["running","waiting"].includes(n.status)&&e.jsx("button",{className:"collab-heading-stop",disabled:c,onClick:()=>{A("stop")},children:e.jsxs("span",{className:"collab-heading-action-content",children:[e.jsx(Ye,{size:12,fill:"currentColor",strokeWidth:0}),"停止"]})}),n&&["waiting","interrupted","stopped"].includes(n.status)&&e.jsx("button",{className:"collab-heading-resume",disabled:c,onClick:()=>{A("resume")},children:e.jsx("span",{className:"collab-heading-action-content",children:"继续协作"})}),e.jsx("button",{className:"collab-heading-new",disabled:c,onClick:()=>{me()},children:e.jsxs("span",{className:"collab-heading-action-content",children:[e.jsx(xe,{size:14}),"新讨论"]})})]})]}),e.jsxs("div",{ref:te,className:"collab-messages",onScroll:()=>{const t=te.current;t&&(G.current=t.scrollHeight-t.scrollTop-t.clientHeight<120)},children:[j.error&&e.jsx("p",{className:"collab-error",role:"alert",children:j.error}),j.hasOlder&&e.jsx("button",{className:"collab-supervision-load",disabled:j.loadingOlder,onClick:async()=>{G.current=!1;const t=te.current,d=(t==null?void 0:t.scrollHeight)??0;await j.loadOlder(),requestAnimationFrame(()=>{t&&(t.scrollTop+=t.scrollHeight-d)})},children:j.loadingOlder?"正在加载…":"查看更早的监工消息"}),j.loading&&!re.length&&e.jsx("p",{className:"collab-muted",role:"status",children:"正在加载群内消息…"}),!re.length&&!j.loading&&e.jsxs("div",{className:"collab-empty",children:[e.jsx("span",{className:"collab-empty-icon",children:e.jsx(X,{size:34})}),e.jsx("h2",{children:"把目标交给这个群。"}),e.jsx("p",{children:B?e.jsxs(e.Fragment,{children:["在群里 @ 成员直接做事,或 @群主 让它拆解安排。",e.jsx("br",{}),"没有 @ 的消息不会触发回应。"]}):e.jsxs(e.Fragment,{children:[L.name,"会安排分工,成员会在这里汇报进展。",e.jsx("br",{}),"@某位成员可直接指派;不 @ 则由",L.name,"安排。"]})}),e.jsx("div",{className:"collab-empty-members",children:a.members.map(t=>e.jsxs("span",{children:[e.jsx(W,{agentType:t.agentType,size:17}),t.name]},t.id))})]}),re.map(t=>{var q;if(t.kind==="supervision")return e.jsx(rt,{message:t.message,group:a},`supervision:${t.message.id}`);const d=t.message,S=a.members.find(U=>U.id===d.memberId);return e.jsxs("article",{className:`collab-message collab-message--${d.kind}`,children:[e.jsx(ke,{member:S,isUser:d.kind==="user",isOwner:d.kind!=="user"&&(S==null?void 0:S.id)===L.id}),e.jsxs("div",{className:"collab-message-body",children:[e.jsx(Ne,{images:d.images??[],onPreview:g}),e.jsx(le,{text:d.content,cwd:((q=n==null?void 0:n.tasks.find(U=>U.id===d.taskId))==null?void 0:q.cwd)||a.cwd}),d.kind==="question"&&p&&e.jsx(ft,{message:d,discussionId:p,onError:i})]}),e.jsx("time",{dateTime:d.createdAt,children:new Date(d.createdAt).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})})]},`discussion:${d.id}`)}),(ae||V.length>0||H)&&e.jsxs("div",{className:`collab-live-status${H?" is-queued":""}`,role:"status",children:[H?e.jsx(tt,{size:14,"aria-hidden":"true"}):e.jsx(ve,{size:14,className:"collab-spin","aria-hidden":"true"}),e.jsx("span",{children:ae?`${L.name}正在安排下一步`:H?Ee:V.map(t=>{var d;return`${(d=a.members.find(S=>S.id===t.memberId))==null?void 0:d.name}:${t.title}`}).join(" · ")})]}),e.jsx("div",{ref:de})]}),e.jsxs("div",{className:"collab-composer-area",children:[f&&e.jsx("p",{className:"collab-error",role:"alert",children:f}),e.jsxs("div",{className:"collab-composer",children:[e.jsx(Ne,{images:N,onPreview:g,onRemove:O}),e.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,"aria-label":"选择群聊图片",onChange:t=>{const d=Array.from(t.target.files??[]);t.target.value="",y(d)}}),I&&_.length>0&&e.jsx("ul",{className:"collab-mention-list",role:"listbox","aria-label":"选择要提及的成员",children:_.map((t,d)=>e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":d===T,className:d===T?"is-active":"",title:t.id===L.id?"提及群主:触发一轮安排":`指派给 ${t.name}`,onMouseDown:S=>{S.preventDefault(),ue(t)},children:[e.jsx(W,{agentType:t.agentType,size:15}),e.jsx("span",{children:t.name}),e.jsx("small",{children:t.id===L.id?"群主 · 安排分工":Z[t.agentType]})]})},t.id))}),e.jsx("textarea",{ref:E,"aria-label":"发送群消息",value:w,placeholder:B?"@成员 或 @群主,说说要做什么…":"告诉群主,你想完成什么…",rows:3,onPaste:t=>{const d=Array.from(t.clipboardData.items).filter(S=>S.type.startsWith("image/")).flatMap(S=>{const q=S.getAsFile();return q?[q]:[]});d.length&&(t.preventDefault(),y(d))},onChange:t=>{D(t.target.value),$e(t.target.value,t.target.selectionStart??t.target.value.length)},onBlur:()=>C(null),onKeyDown:t=>{const d=_[T];if(I&&_.length>0&&d){if(t.key==="ArrowDown"||t.key==="ArrowUp"){t.preventDefault(),M(S=>t.key==="ArrowDown"?(S+1)%_.length:(S-1+_.length)%_.length);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),ue(d);return}if(t.key==="Escape"){t.preventDefault(),C(null);return}}t.key==="Enter"&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),he())}}),e.jsxs("footer",{children:[e.jsx("button",{type:"button",className:"collab-add-image","aria-label":"添加群聊图片",title:"添加图片",disabled:c||z,onClick:()=>{var t;return(t=x.current)==null?void 0:t.click()},children:e.jsx(Xe,{size:18})}),e.jsx("span",{children:z?"正在处理图片…":w.includes("@")?"@成员 直接指派,不打扰群主;@群主 触发一轮安排":B?"chat 模式:@成员 直接指派 · @群主 安排分工 · 无 @ 不会回应":(n==null?void 0:n.status)==="running"?"补充要求会交给群主继续安排":"由群主安排分工与并行"}),e.jsx("button",{"aria-label":"发送群消息",className:"collab-primary",disabled:c||z||!w.trim()&&!N.length||(n==null?void 0:n.status)==="stopping",onClick:()=>{he()},children:e.jsx(Be,{size:20})})]})]}),e.jsx("small",{className:"collab-composer-hint",children:"Enter 发送 · Shift+Enter 换行 · 群聊记录自动保存"})]})]})]})}export{Ct as default};
|
|
6
|
+
*/const tt=Re("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]),st=8;function nt(s,u){return s.split(/(\[[^\]\n]+\]\([^\n)]+\))/g).flatMap(r=>{const a=Ge(r),m=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(r);if(!m||a.some(f=>f.type==="artifact"||f.type==="link"))return a;const p=m[2].trim().replace(/^<|>$/g,"");if(/^[A-Za-z][\w+.-]*:/.test(p)&&!/^[A-Za-z]:[\\/]/.test(p))return a;const n=Ce(p,u);return n?[{type:"artifact",label:m[1],path:n,raw:r}]:a})}function le({text:s,cwd:u}){const r=o.useId(),a=o.useRef(null),[m,p]=o.useState(!1),[n,f]=o.useState(!1);return o.useEffect(()=>{const c=a.current;if(!c)return;const l=()=>{const A=Number.parseFloat(getComputedStyle(c).lineHeight);p(c.scrollHeight>A*st+1)};l();const h=new ResizeObserver(l);return h.observe(c),()=>h.disconnect()},[s]),e.jsxs(e.Fragment,{children:[e.jsx("div",{id:r,ref:a,className:"collab-message-text","data-collapsed":!n,children:nt(s,u).map((c,l)=>{if(c.type==="text")return c.value;if(c.type==="code")return e.jsx("code",{children:c.value},l);if(c.type==="link")return e.jsx("a",{href:c.href,target:"_blank",rel:"noopener noreferrer",onClick:A=>{_e(A)&&Ue(c.href)&&A.preventDefault()},children:c.label},l);const h=Ce(c.path,u);return h?e.jsx("button",{type:"button",className:"collab-message-path",title:c.line?`${h}:${c.line}`:h,"aria-label":`查看文件:${c.label}`,onClick:()=>{Le(h)||window.agentApi.openExternal(/^https?:\/\//i.test(h)?h:`file://${h}`)},children:c.label},l):c.raw})}),m&&e.jsx("button",{type:"button",className:"collab-message-toggle","aria-expanded":n,"aria-controls":r,onClick:()=>f(c=>!c),children:n?"收起":"展开全文"})]})}function at({group:s}){var r;if(!((r=s.monitoring)!=null&&r.targets.length))return null;const u=s.members.find(a=>{var m;return a.id===((m=s.monitoring)==null?void 0:m.supervisorId)});return e.jsxs("div",{className:"collab-supervision-summary",children:[e.jsxs("div",{children:[e.jsx(Ve,{size:14}),e.jsxs("span",{children:[u?`监工 · ${u.name}`:"已关联"," · ",s.monitoring.targets.length," 条原始会话"]})]}),e.jsx("button",{onClick:()=>Ke({kind:"dashboard"}),children:"查看监工与决策"})]})}function ye(s,u,r){var f,c;const a=r==="sender"?s.senderAgentType:s.recipientAgentType;if(a)return a;const m=s[r];if(!m||m==="你"||m===u.name)return;const p=s.direction==="received"?"sender":s.direction==="sent"?"recipient":void 0;if(r===p){const l=((f=u.monitoring)==null?void 0:f.targets.filter(h=>(s.sessionId?h.id===s.sessionId:h.title===m)&&(m===s.sessionTitle||m===h.title)))??[];if(l.length===1)return l[0].agentType}const n=u.members.filter(l=>l.name===m);if(n.length===1)return n[0].agentType;if(m==="监工")return(c=u.members.find(l=>{var h;return l.id===((h=u.monitoring)==null?void 0:h.supervisorId)}))==null?void 0:c.agentType}function rt({message:s,group:u}){const r=ye(s,u,"sender"),a=ye(s,u,"recipient"),m=r?`${s.sender} · ${Z[r]}`:s.sender,p=a?`${s.recipient} · ${Z[a]}`:s.recipient,n=s.sender==="你"&&!r,f=s.direction==="received"?"收到消息":s.direction==="sent"?"发出消息":"监工动态";return e.jsxs("article",{className:`collab-message collab-supervision-message is-${s.direction}`,"data-supervision-message":s.id,"aria-label":`${f}:${s.title}`,children:[e.jsx("span",{className:`collab-avatar collab-supervision-avatar${n?" collab-avatar--user":""}`,role:"img","aria-label":m,title:m,children:r?e.jsx(W,{agentType:r,size:20}):n?"你":e.jsx(X,{size:18,"aria-hidden":"true"})}),e.jsxs("div",{className:"collab-message-body",children:[e.jsxs("div",{className:"collab-supervision-message-heading",children:[e.jsx("strong",{children:s.title}),e.jsx("span",{children:s.historical?"历史监工记录":f})]}),e.jsxs("div",{className:"collab-supervision-message-route","aria-label":`${s.sender}${s.recipient?` → ${s.recipient}`:""}`,children:[e.jsxs("span",{className:"collab-supervision-participant",title:m,children:[r&&e.jsx(W,{agentType:r,size:13}),e.jsx("span",{children:s.sender})]}),s.recipient&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsxs("span",{className:"collab-supervision-participant",title:p,children:[a&&e.jsx(W,{agentType:a,size:13}),e.jsx("span",{children:s.recipient})]})]})]}),s.sessionTitle&&e.jsxs("div",{className:"collab-supervision-message-source",title:s.sessionTitle,children:["来源会话:",s.sessionTitle]}),e.jsx(le,{text:s.content,cwd:s.cwd||u.cwd})]}),e.jsx("time",{dateTime:s.createdAt,title:new Date(s.createdAt).toLocaleString("zh-CN"),children:new Date(s.createdAt).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})})]})}function we(s,u){return[...new Map([...s,...u].map(r=>[r.id,r])).values()].sort((r,a)=>r.createdAt.localeCompare(a.createdAt)||(r.sequence??0)-(a.sequence??0)||r.id.localeCompare(a.id))}function it(s,u){return[...s.filter(r=>r.kind!=="progress").map(r=>({kind:"discussion",message:r})),...u.map(r=>({kind:"supervision",message:r}))].sort((r,a)=>r.message.createdAt.localeCompare(a.message.createdAt)||(r.kind==="supervision"&&a.kind==="supervision"?(r.message.sequence??0)-(a.message.sequence??0):0)||r.message.id.localeCompare(a.message.id))}function lt(s){const u=Ae(),[r,a]=o.useState([]),[m,p]=o.useState(""),[n,f]=o.useState(!0),[c,l]=o.useState(!1),[h,A]=o.useState(null),k=o.useRef({groupId:s,generation:0,latest:0,before:null,loaded:!1,older:!1});o.useEffect(()=>{const i={groupId:s,generation:k.current.generation+1,latest:0,before:null,loaded:!1,older:!1};k.current=i,a([]),p(""),A(null),f(!0),l(!1)},[s]),o.useEffect(()=>{if(!u)return;const i=k.current;let v=!0,j=!1;const w=async()=>{if(!(j||!s||!Ie())){j=!0;try{const N=await R({action:"supervisionMessages",groupId:s,limit:100,...i.loaded?{afterSequence:i.latest}:{}});if(!v)return;a(z=>we(z,N.messages)),i.loaded||(i.before=N.nextBefore,A(N.nextBefore)),i.latest=Math.max(i.latest,N.latestSequence),i.loaded=!0,p("")}catch(N){v&&p(`监工消息加载失败:${N instanceof Error?N.message:String(N)}`)}finally{j=!1,v&&f(!1)}}};w();const D=setInterval(()=>{w()},2e3);return()=>{v=!1,clearInterval(D)}},[u,s]);const $=o.useCallback(async()=>{const i=k.current;if(!(i.groupId!==s||i.before===null||i.older)){i.older=!0,l(!0);try{const v=await R({action:"supervisionMessages",groupId:s,beforeSequence:i.before,limit:100});if(k.current!==i)return;a(j=>we(j,v.messages)),i.before=v.nextBefore,A(v.nextBefore),p("")}catch(v){k.current===i&&p(`历史监工消息加载失败:${v instanceof Error?v.message:String(v)}`)}finally{i.older=!1,k.current===i&&l(!1)}}},[s]);return{messages:r,error:m,loading:n,loadingOlder:c,hasOlder:h!==null,loadOlder:$}}function Ne({images:s,onPreview:u,onRemove:r}){return s.length?e.jsx("div",{className:`collab-images${r?" is-draft":""}`,"aria-label":r?"待发送图片":"消息图片",children:s.map((a,m)=>e.jsxs("div",{className:"collab-image",children:[e.jsx("button",{type:"button",className:"collab-image-preview","aria-label":`查看图片 ${m+1}`,onClick:()=>u(a),children:e.jsx("img",{src:a,alt:`图片 ${m+1}`,loading:"lazy"})}),r&&e.jsx("button",{type:"button",className:"collab-image-remove","aria-label":`移除图片 ${m+1}`,onClick:()=>r(m),children:e.jsx(Te,{size:13})})]},m))}):null}const Se=10,ct=20*1024*1024;function ot(s){if(s===void 0)return;if(!Array.isArray(s)||s.length>Se)throw new ie(`每条消息最多添加 ${Se} 张图片`);let u=0;for(const r of s){if(typeof r!="string"||!/^data:image\/(?:png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(r))throw new ie("图片格式无效,仅支持 JPG、PNG、GIF 和 WebP");u+=r.length}if(u>ct)throw new ie("图片总大小超过限制,请减少图片或压缩后重试")}const Q={text:"",images:[]};function dt(s,u,r){const a=`${s}:${u||"new"}`,[m,p]=o.useState({}),[n,f]=o.useState({}),c=o.useRef(),l=m[a]??Q,h=$=>{p(i=>({...i,[a]:$(i[a]??Q)}))},A=async $=>{if($.length){f(i=>({...i,[a]:(i[a]??0)+1}));try{const i=await He($,async v=>{const j=await Pe(v);return new Promise((w,D)=>{const N=new FileReader;N.onload=()=>w(String(N.result)),N.onerror=()=>D(new Error("无法读取图片")),N.readAsDataURL(j)})});(i.attachments.length||i.unsupportedImages.length||i.failedImages.length)&&r("无法添加部分图片,仅支持 JPG、PNG、GIF 和 WebP。"),i.images.length&&h(v=>({...v,images:[...v.images,...i.images]}))}catch(i){r(i instanceof Error?i.message:"无法添加图片")}finally{f(i=>({...i,[a]:Math.max(0,(i[a]??1)-1)}))}}},k=async $=>{var j;if(n[a]||!l.text.trim()&&!l.images.length)return!1;try{ot(l.images)}catch(w){return r(w instanceof Error?w.message:"图片无效"),!1}(((j=c.current)==null?void 0:j.key)!==a||c.current.draft!==l)&&(c.current={key:a,draft:l,id:crypto.randomUUID()});let i=a;return await $(l.text,c.current.id,l.images,w=>{var D;i=`${s}:${w}`,p(N=>({...N,[a]:Q,[i]:N[a]??l})),((D=c.current)==null?void 0:D.draft)===l&&(c.current.key=i)})?(p(w=>w[i]===l?{...w,[i]:Q}:w),!0):!1};return{draft:l.text,images:l.images,reading:!!n[a],addImages:A,submit:k,setDraft:$=>h(i=>({...i,text:$})),removeImage:$=>h(i=>({...i,images:i.images.filter((v,j)=>j!==$)}))}}function ut(s,u){const r=Ae(),[a,m]=o.useState(null),[p,n]=o.useState([]),[f,c]=o.useState(null),[l,h]=o.useState(null),[A,k]=o.useState(""),[$,i]=o.useState(!1),v=o.useRef(0),j=o.useRef(null),w=o.useRef(!1),D=o.useRef(null),N=()=>{v.current++,i(!0)},z=()=>{v.current--,i(v.current>0)},y=o.useRef({groupId:s,selected:f,revision:-1});y.current.groupId=s,y.current.selected=f;const O=o.useCallback(g=>{y.current.selected=g,y.current.revision=-1,c(g),h(null),k("");try{g&&localStorage.setItem(`collaboration:${s}:discussion`,g)}catch{}},[s]),P=o.useCallback(async()=>{const g=await R({action:"discussions",groupId:s});return y.current.groupId===s&&n(g),g},[s]);o.useEffect(()=>{let g=!0;return m(null),n([]),O(null),Promise.all([R({action:"group",groupId:s}),P()]).then(([x,E])=>{var C,T;if(!g)return;m(x);let I=null;try{I=localStorage.getItem(`collaboration:${s}:discussion`)}catch{}I=u||new URLSearchParams(window.location.search).get("discussionId")||I,O(((C=E.find(M=>M.id===I))==null?void 0:C.id)||((T=E[0])==null?void 0:T.id)||null)}).catch(x=>{g&&k(x.message)}),()=>{g=!1}},[s,P,O,u]),o.useEffect(()=>{if(!r||!f)return;let g=!0,x=!1;const E=async()=>{if(!(x||!Ie())){x=!0;try{const C=await R({action:"discussion",discussionId:f,afterRevision:y.current.revision<0?void 0:y.current.revision});if(!g||y.current.selected!==f)return;if(!("unchanged"in C)&&C.revision>=y.current.revision&&(y.current.revision=C.revision,h(C),await P()),D.current){const T=D.current;k(M=>M===T?"":M),D.current=null}}catch(C){g&&(D.current=C instanceof Error?C.message:String(C),k(D.current))}finally{x=!1}}};E();const I=setInterval(()=>{E()},1200);return()=>{g=!1,clearInterval(I)}},[r,f,P]);const Y=()=>(j.current||(N(),j.current=(async()=>{const g=await R({action:"createDiscussion",groupId:s});return y.current.groupId!==s?null:(O(g.id),y.current.revision=g.revision,h(g),await P(),g)})().finally(()=>{j.current=null,z()})),j.current),F=async g=>{if(!(!r||!f)){N();try{const x=await R({action:g,discussionId:f});y.current.selected===f&&x.revision>=y.current.revision&&(y.current.revision=x.revision,h(x))}catch(x){k(x instanceof Error?x.message:String(x))}finally{z()}}},K=async g=>{if(!(!f||(l==null?void 0:l.mode)===g)){N();try{const x=await R({action:"setMode",discussionId:f,mode:g});y.current.selected===f&&x.revision>=y.current.revision&&(y.current.revision=x.revision,h(x))}catch(x){k(x instanceof Error?x.message:String(x))}finally{z()}}},ee=async(g,x,E,I)=>{var C;if(w.current)return!1;w.current=!0,N(),k("");try{const T=f||((C=await Y())==null?void 0:C.id);if(!T)return!1;f||I==null||I(T);const M=await R({action:"send",discussionId:T,text:g,messageId:x,...E!=null&&E.length?{images:E}:{}});return y.current.selected===T&&M.revision>=y.current.revision&&(y.current.revision=M.revision,h(M)),await P(),!0}catch(T){return k(T instanceof Error?T.message:String(T)),!1}finally{w.current=!1,z()}},J=async(g,x)=>{const E=await R({action:"updateRole",groupId:s,memberId:g,role:x});y.current.groupId===s&&m(E)};return{group:l!=null&&l.groupSnapshot&&a?{...l.groupSnapshot,name:a.name}:a,history:p,selected:f,discussion:l,error:A,busy:$,select:O,create:Y,act:F,setMode:K,send:ee,setError:k,updateRole:J}}function ke({member:s,isUser:u=!1,isOwner:r=!1}){const a=u?"你":s?`${s.name} · ${Z[s.agentType]}${r?" · 群主":""}`:"协作动态";return e.jsxs("span",{className:`collab-avatar${u?" collab-avatar--user":""}`,role:"img","aria-label":a,title:a,children:[u?"你":s?e.jsx(W,{agentType:s.agentType,size:20}):e.jsx(X,{size:18,"aria-hidden":"true"}),r&&e.jsx(Ze,{className:"collab-avatar-crown",size:13,"aria-hidden":"true"})]})}function ft({message:s,discussionId:u,onError:r}){var c;const[a,m]=o.useState(""),[p,n]=o.useState(!1);if(!s.question||s.question.resolved)return e.jsxs("span",{className:"collab-muted",children:[e.jsx(et,{size:12})," 已处理"]});const f=async(l,h)=>{n(!0);try{await R({action:"answer",discussionId:u,questionId:s.question.id,answer:l,...h===void 0?{}:{selectedIndices:[h]}})}catch(A){r(A instanceof Error?A.message:String(A))}finally{n(!1)}};return e.jsxs("div",{className:"collab-question",children:[(c=s.question.options)==null?void 0:c.map((l,h)=>e.jsx("button",{disabled:p,onClick:()=>{f(l.label,h)},title:l.description,children:l.label},h)),e.jsxs("form",{onSubmit:l=>{l.preventDefault(),a.trim()&&f(a)},children:[e.jsx("input",{"aria-label":"回答成员问题",value:a,onChange:l=>m(l.target.value),placeholder:"输入回复"}),e.jsx("button",{disabled:p||!a.trim(),children:"回复"})]})]})}function Ct({groupId:s,initialDiscussionId:u}){var pe,ge;const r=s||new URLSearchParams(location.search).get("groupId")||"",{group:a,history:m,selected:p,discussion:n,error:f,busy:c,select:l,create:h,act:A,setMode:k,send:$,setError:i,updateRole:v}=ut(r,u),j=lt(r),{draft:w,setDraft:D,images:N,reading:z,addImages:y,removeImage:O,submit:P}=dt(r,p,i),[Y,F]=o.useState(!1),[K,ee]=o.useState(null),[J,g]=o.useState(null),x=o.useRef(null),E=o.useRef(null),[I,C]=o.useState(null),[T,M]=o.useState(0),ce=Oe(t=>t.skin);o.useEffect(()=>{document.documentElement.setAttribute("data-skin",ce)},[ce]);const oe=!!f||!!a&&(!p||!!n);o.useEffect(()=>{oe&&window.parent!==window&&window.parent.postMessage({type:Je,groupId:r},window.location.origin)},[oe,r]);const de=o.useRef(null),te=o.useRef(null),G=o.useRef(!0);if(o.useEffect(()=>{var t;G.current&&((t=de.current)==null||t.scrollIntoView({block:"end"}))},[n==null?void 0:n.messages.length,j.messages.length,p]),o.useEffect(()=>{G.current=!0},[p]),!a)return e.jsx("div",{className:"collab-loading",children:f?e.jsx("p",{role:"alert",children:f}):e.jsxs(e.Fragment,{children:[e.jsx(xe,{className:"collab-spin"}),"正在打开协作群…"]})});const L=a.members.find(t=>t.id===a.ownerId),B=((n==null?void 0:n.mode)??"task-graph")==="chat",_=I?a.members.filter(t=>`${t.name} ${t.id}`.toLowerCase().includes(I.query.toLowerCase())):[],$e=(t,d)=>{const S=/(?:^|\s)@([^\s@]{0,30})$/.exec(t.slice(0,d));C(S?{query:S[1],start:d-S[1].length-1}:null),M(0)},ue=t=>{const d=E.current;if(!I||!d)return;const S=d.selectionStart??w.length,q=`@${t.name} `;D(w.slice(0,I.start)+q+w.slice(S)),C(null),requestAnimationFrame(()=>{d.focus();const U=I.start+q.length;d.setSelectionRange(U,U)})},V=(n==null?void 0:n.tasks.filter(t=>t.status==="running"))||[],se=(n==null?void 0:n.status)==="running"?n.tasks.filter(t=>t.status==="queued"):[],ne=se.filter(t=>t.result==="等待工作目录空闲"),ae=(n==null?void 0:n.planning)||(n==null?void 0:n.status)==="running"&&n.ownerPending&&V.length===0,H=!ae&&V.length===0&&se.length>0,Ee=ne.length>0?`${ne.length} 个任务等待工作目录空闲,空闲后会自动继续。`:"任务排队中,等待前置任务完成。",fe=H?ne.length>0?"等待工作目录空闲":"任务排队中":n?ve[n.status]:"准备好了",re=it((n==null?void 0:n.messages)??[],j.messages),De=t=>{l(t),F(!1),C(null),G.current=!0},me=async()=>{var t;try{await h()&&(F(!1),C(null),(t=E.current)==null||t.focus())}catch(d){i(d instanceof Error?d.message:String(d))}},he=async()=>{c||z||await P($)&&(C(null),G.current=!0)};return e.jsxs("div",{className:"collab-page",children:[e.jsx(We,{image:J?{src:J,alt:"群聊图片"}:null,onClose:()=>g(null)}),Y&&e.jsx("button",{className:"collab-drawer-mask","aria-label":"关闭成员栏",onClick:()=>F(!1)}),e.jsxs("aside",{className:`collab-sidebar${Y?" is-open":""}`,children:[e.jsxs("header",{className:"collab-sidebar-heading",children:[e.jsx("div",{className:"collab-group-icon",children:e.jsx(X,{size:22})}),e.jsxs("div",{children:[e.jsxs("span",{className:"collab-eyebrow",children:["协作群 · ",a.members.length," 人"]}),e.jsx("h2",{children:a.name})]}),e.jsx("button",{className:"collab-mobile-close","aria-label":"收起群成员",onClick:()=>F(!1),children:e.jsx(Te,{size:18})})]}),e.jsxs("div",{className:"collab-roster","aria-label":"群成员",children:[e.jsx("span",{className:"collab-section-label",children:"群成员"}),[L,...a.members.filter(t=>t.id!==L.id)].map(t=>{var be;const d=V.find(b=>b.memberId===t.id),S=t.id===L.id&&(n==null?void 0:n.planning),q=se.find(b=>b.memberId===t.id),ze=(n==null?void 0:n.messages.some(b=>b.memberId===t.id&&b.question&&!b.question.resolved))?"等待你回复":S?"正在安排":d?"正在执行":q?q.result==="等待工作目录空闲"?"等待目录空闲":"排队中":"空闲";return e.jsxs("div",{className:`collab-roster-member${S||d?" is-working":""}`,children:[e.jsxs("button",{onClick:()=>ee(b=>b===t.id?null:t.id),"aria-expanded":K===t.id,children:[e.jsx(ke,{member:t,isOwner:t.id===L.id}),e.jsxs("span",{className:"collab-member-name",children:[e.jsx("strong",{children:t.name}),e.jsx("small",{children:Z[t.agentType]})]}),e.jsx("span",{className:"collab-member-status",children:ze})]}),e.jsx("p",{className:K===t.id?"is-expanded":void 0,children:t.role||(n==null?void 0:n.roles[t.id])||"等待群主分配定位"}),K===t.id&&e.jsxs("div",{className:"collab-member-detail",children:[e.jsx("small",{children:((be=t.model)==null?void 0:be.id)||"默认模型"}),e.jsxs("form",{className:"collab-role-form",onSubmit:b=>{b.preventDefault();const Me=new FormData(b.currentTarget).get("role");v(t.id,String(Me||"")).catch(qe=>i(qe.message))},children:[e.jsxs("label",{children:["定位与职责",e.jsx("textarea",{name:"role",defaultValue:t.role,rows:3,maxLength:8e3,placeholder:"留空由群主分配"},t.role)]}),e.jsx("button",{type:"submit",children:"保存职责"})]}),n==null?void 0:n.tasks.filter(b=>b.memberId===t.id).map(b=>e.jsxs("div",{children:[b.title,e.jsx("span",{children:b.status==="completed"?"已完成":b.status==="running"?"执行中":b.status==="queued"?"等待依赖或空闲":b.status==="failed"?"失败":b.status==="cancelled"?"已取消":"已中断"}),b.result&&e.jsxs("details",{children:[e.jsx("summary",{children:"查看结果"}),e.jsx(le,{text:b.result,cwd:b.cwd||a.cwd})]})]},b.id)),n==null?void 0:n.messages.filter(b=>b.memberId===t.id&&b.kind==="progress").slice(-20).map(b=>e.jsx("small",{children:b.content},b.id))]})]},t.id)})]}),e.jsxs("section",{className:"collab-history","aria-label":"群聊记录",children:[e.jsxs("header",{children:[e.jsxs("span",{className:"collab-section-label",children:[e.jsx(Qe,{size:13}),"群聊记录"]}),e.jsx("button",{disabled:c,"aria-label":"新建群讨论",title:"新讨论",onClick:()=>{me()},children:e.jsx(je,{size:17})})]}),e.jsx("div",{className:"collab-history-list",children:m.length?m.map(t=>e.jsxs("button",{className:p===t.id?"is-selected":"","aria-current":p===t.id?"page":void 0,onClick:()=>{De(t.id)},children:[e.jsx("strong",{children:t.title}),e.jsxs("span",{children:[e.jsx("time",{children:new Date(t.updatedAt).toLocaleDateString("zh-CN",{month:"short",day:"numeric"})}),e.jsx("small",{children:ve[t.status]})]})]},t.id)):e.jsx("p",{className:"collab-muted",children:(pe=a.monitoring)!=null&&pe.targets.length?"监工动态持续保存在群内,普通讨论会列在这里。":"发送第一条任务,记录会保存在这里。"})})]}),e.jsxs("footer",{className:"collab-sidebar-footer",title:a.cwd,children:[e.jsx(at,{group:a}),a.cwd]})]}),e.jsxs("main",{className:"collab-conversation",children:[e.jsxs("header",{className:"collab-conversation-heading",children:[e.jsx("button",{className:"collab-mobile-menu","aria-label":"展开群成员和群聊记录",onClick:()=>F(!0),children:e.jsx(Fe,{size:20})}),e.jsxs("div",{className:"collab-discussion-title",children:[e.jsx("h1",{children:(n==null?void 0:n.title)||((ge=a.monitoring)!=null&&ge.targets.length?"监工动态":"开始一起做事")}),e.jsx("span",{className:"collab-discussion-status","data-status":H?"queued":(n==null?void 0:n.status)||"idle",role:"status","aria-label":fe,title:fe})]}),e.jsxs("div",{className:"collab-heading-actions",children:[n&&e.jsxs("div",{className:"collab-mode-toggle",role:"group","aria-label":"讨论模式",children:[e.jsx("button",{"aria-pressed":!B,disabled:c||!B,title:"每条消息交给群主安排;@成员 仍直接指派",onClick:()=>{k("task-graph")},children:"编排"}),e.jsx("button",{"aria-pressed":B,disabled:c||B,title:"@成员直接指派 · @群主安排分工 · 无 @ 静默",onClick:()=>{k("chat")},children:"@直聊"})]}),n&&["running","waiting"].includes(n.status)&&e.jsx("button",{className:"collab-heading-stop",disabled:c,onClick:()=>{A("stop")},children:e.jsxs("span",{className:"collab-heading-action-content",children:[e.jsx(Ye,{size:12,fill:"currentColor",strokeWidth:0}),"停止"]})}),n&&["waiting","interrupted","stopped"].includes(n.status)&&e.jsx("button",{className:"collab-heading-resume",disabled:c,onClick:()=>{A("resume")},children:e.jsx("span",{className:"collab-heading-action-content",children:"继续协作"})}),e.jsx("button",{className:"collab-heading-new",disabled:c,onClick:()=>{me()},children:e.jsxs("span",{className:"collab-heading-action-content",children:[e.jsx(je,{size:14}),"新讨论"]})})]})]}),e.jsxs("div",{ref:te,className:"collab-messages",onScroll:()=>{const t=te.current;t&&(G.current=t.scrollHeight-t.scrollTop-t.clientHeight<120)},children:[j.error&&e.jsx("p",{className:"collab-error",role:"alert",children:j.error}),j.hasOlder&&e.jsx("button",{className:"collab-supervision-load",disabled:j.loadingOlder,onClick:async()=>{G.current=!1;const t=te.current,d=(t==null?void 0:t.scrollHeight)??0;await j.loadOlder(),requestAnimationFrame(()=>{t&&(t.scrollTop+=t.scrollHeight-d)})},children:j.loadingOlder?"正在加载…":"查看更早的监工消息"}),j.loading&&!re.length&&e.jsx("p",{className:"collab-muted",role:"status",children:"正在加载群内消息…"}),!re.length&&!j.loading&&e.jsxs("div",{className:"collab-empty",children:[e.jsx("span",{className:"collab-empty-icon",children:e.jsx(X,{size:34})}),e.jsx("h2",{children:"把目标交给这个群。"}),e.jsx("p",{children:B?e.jsxs(e.Fragment,{children:["在群里 @ 成员直接做事,或 @群主 让它拆解安排。",e.jsx("br",{}),"没有 @ 的消息不会触发回应。"]}):e.jsxs(e.Fragment,{children:[L.name,"会安排分工,成员会在这里汇报进展。",e.jsx("br",{}),"@某位成员可直接指派;不 @ 则由",L.name,"安排。"]})}),e.jsx("div",{className:"collab-empty-members",children:a.members.map(t=>e.jsxs("span",{children:[e.jsx(W,{agentType:t.agentType,size:17}),t.name]},t.id))})]}),re.map(t=>{var q;if(t.kind==="supervision")return e.jsx(rt,{message:t.message,group:a},`supervision:${t.message.id}`);const d=t.message,S=a.members.find(U=>U.id===d.memberId);return e.jsxs("article",{className:`collab-message collab-message--${d.kind}`,children:[e.jsx(ke,{member:S,isUser:d.kind==="user",isOwner:d.kind!=="user"&&(S==null?void 0:S.id)===L.id}),e.jsxs("div",{className:"collab-message-body",children:[e.jsx(Ne,{images:d.images??[],onPreview:g}),e.jsx(le,{text:d.content,cwd:((q=n==null?void 0:n.tasks.find(U=>U.id===d.taskId))==null?void 0:q.cwd)||a.cwd}),d.kind==="question"&&p&&e.jsx(ft,{message:d,discussionId:p,onError:i})]}),e.jsx("time",{dateTime:d.createdAt,children:new Date(d.createdAt).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})})]},`discussion:${d.id}`)}),(ae||V.length>0||H)&&e.jsxs("div",{className:`collab-live-status${H?" is-queued":""}`,role:"status",children:[H?e.jsx(tt,{size:14,"aria-hidden":"true"}):e.jsx(xe,{size:14,className:"collab-spin","aria-hidden":"true"}),e.jsx("span",{children:ae?`${L.name}正在安排下一步`:H?Ee:V.map(t=>{var d;return`${(d=a.members.find(S=>S.id===t.memberId))==null?void 0:d.name}:${t.title}`}).join(" · ")})]}),e.jsx("div",{ref:de})]}),e.jsxs("div",{className:"collab-composer-area",children:[f&&e.jsx("p",{className:"collab-error",role:"alert",children:f}),e.jsxs("div",{className:"collab-composer",children:[e.jsx(Ne,{images:N,onPreview:g,onRemove:O}),e.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,"aria-label":"选择群聊图片",onChange:t=>{const d=Array.from(t.target.files??[]);t.target.value="",y(d)}}),I&&_.length>0&&e.jsx("ul",{className:"collab-mention-list",role:"listbox","aria-label":"选择要提及的成员",children:_.map((t,d)=>e.jsx("li",{children:e.jsxs("button",{type:"button",role:"option","aria-selected":d===T,className:d===T?"is-active":"",title:t.id===L.id?"提及群主:触发一轮安排":`指派给 ${t.name}`,onMouseDown:S=>{S.preventDefault(),ue(t)},children:[e.jsx(W,{agentType:t.agentType,size:15}),e.jsx("span",{children:t.name}),e.jsx("small",{children:t.id===L.id?"群主 · 安排分工":Z[t.agentType]})]})},t.id))}),e.jsx("textarea",{ref:E,"aria-label":"发送群消息",value:w,placeholder:B?"@成员 或 @群主,说说要做什么…":"告诉群主,你想完成什么…",rows:3,onPaste:t=>{const d=Array.from(t.clipboardData.items).filter(S=>S.type.startsWith("image/")).flatMap(S=>{const q=S.getAsFile();return q?[q]:[]});d.length&&(t.preventDefault(),y(d))},onChange:t=>{D(t.target.value),$e(t.target.value,t.target.selectionStart??t.target.value.length)},onBlur:()=>C(null),onKeyDown:t=>{const d=_[T];if(I&&_.length>0&&d){if(t.key==="ArrowDown"||t.key==="ArrowUp"){t.preventDefault(),M(S=>t.key==="ArrowDown"?(S+1)%_.length:(S-1+_.length)%_.length);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),ue(d);return}if(t.key==="Escape"){t.preventDefault(),C(null);return}}t.key==="Enter"&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),he())}}),e.jsxs("footer",{children:[e.jsx("button",{type:"button",className:"collab-add-image","aria-label":"添加群聊图片",title:"添加图片",disabled:c||z,onClick:()=>{var t;return(t=x.current)==null?void 0:t.click()},children:e.jsx(Xe,{size:18})}),e.jsx("span",{children:z?"正在处理图片…":w.includes("@")?"@成员 直接指派,不打扰群主;@群主 触发一轮安排":B?"chat 模式:@成员 直接指派 · @群主 安排分工 · 无 @ 不会回应":(n==null?void 0:n.status)==="running"?"补充要求会交给群主继续安排":"由群主安排分工与并行"}),e.jsx("button",{"aria-label":"发送群消息",className:"collab-primary",disabled:c||z||!w.trim()&&!N.length||(n==null?void 0:n.status)==="stopping",onClick:()=>{he()},children:e.jsx(Be,{size:20})})]})]}),e.jsx("small",{className:"collab-composer-hint",children:"Enter 发送 · Shift+Enter 换行 · 群聊记录自动保存"})]})]})]})}export{Ct as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./codeSyntax-
|
|
2
|
-
import{c as Ie,r,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./codeSyntax-GjP28nDI.js","./index-C30NoLsn.js","./index-COFV-DUC.css","./rotate-ccw-CyZK_Om1.js","./trash-2-DwFoTvHX.js","./check-DCU8YHqr.js","./x-CoIXF2eL.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as Ie,r,an as _t,j as t,o as de,L as Z,ay as It,R as Te}from"./index-C30NoLsn.js";import{R as Dt}from"./rotate-ccw-CyZK_Om1.js";import{P as Ht}from"./trash-2-DwFoTvHX.js";import{C as rt}from"./check-DCU8YHqr.js";import{X as Wt}from"./x-CoIXF2eL.js";/**
|
|
3
3
|
* @license lucide-react v0.468.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
@@ -16,6 +16,6 @@ import{c as Ie,r,aj as _t,j as t,o as de,av as It,X as Dt,R as Te}from"./index-Y
|
|
|
16
16
|
* See the LICENSE file in the root directory of this source tree.
|
|
17
17
|
*/const Ft=Ie("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),At=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function Ot(e){if(!e.trim())return{rows:[],added:0,removed:0};const n=[];let l=0,a=0,x=!1,g=0,c=0;for(const f of e.replace(/\n$/,"").split(`
|
|
18
18
|
`)){const k=f.match(At);if(k){l=Number(k[1]),a=Number(k[2]),x=!0,n.push({kind:"hunk",text:f,oldLine:null,newLine:null});continue}if(!x){!f.startsWith("diff --git ")&&!f.startsWith("index ")&&!f.startsWith("--- ")&&!f.startsWith("+++ ")&&n.push({kind:"meta",text:f,oldLine:null,newLine:null});continue}f.startsWith("+")?(n.push({kind:"added",text:f.slice(1),oldLine:null,newLine:a}),a+=1,g+=1):f.startsWith("-")?(n.push({kind:"removed",text:f.slice(1),oldLine:l,newLine:null}),l+=1,c+=1):f.startsWith(" ")?(n.push({kind:"context",text:f.slice(1),oldLine:l,newLine:a}),l+=1,a+=1):n.push({kind:"note",text:f,oldLine:null,newLine:null})}return{rows:n,added:g,removed:c}}const it=256*1024,mn=16*1024,Bt={java:"java",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",tsx:"typescript",json:"json",py:"python",sh:"bash",bash:"bash",zsh:"bash",css:"css",scss:"scss",html:"xml",htm:"xml",xml:"xml",vue:"xml",svelte:"xml",astro:"xml",yml:"yaml",yaml:"yaml",toml:"ini",env:"ini",sql:"sql",c:"c",h:"c",cpp:"cpp",hpp:"cpp",go:"go",rs:"rust",kt:"kotlin",rb:"ruby",md:"markdown",markdown:"markdown",mdown:"markdown",mkdn:"markdown",mdx:"markdown",dockerfile:"dockerfile",gradle:"groovy",properties:"properties",graphql:"graphql",proto:"protobuf"};function Ut(e){var a;const n=((a=e.split(/[/\\]/).pop())==null?void 0:a.toLowerCase())??"";if(n==="dockerfile"||n.startsWith("dockerfile."))return"dockerfile";if(n===".env"||n.startsWith(".env."))return"ini";if(n===".bashrc"||n===".zshrc")return"bash";const l=n.includes(".")?n.slice(n.lastIndexOf(".")+1):"";return Bt[l]??null}function Xt(e){const n=[""];for(const l of e){const a=l.split(`
|
|
19
|
-
`);n[n.length-1]+=a[0];for(let x=1;x<a.length;x+=1)n.push(a[x])}return n}function $t({path:e,chunks:n,fileSize:l}){const[a,x]=r.useState(null),g=Ut(e),c=n.length>0&&g!==null&&(l===void 0||l<=it)&&n.reduce((
|
|
20
|
-
`:"";return t.jsxs(r.Fragment,{children:[t.jsx("span",{className:"file-code-line-number","aria-hidden":"true","data-line-number":u+1}),k?t.jsx("span",{className:"file-code-line-content",dangerouslySetInnerHTML:{__html:k[u]+C}}):t.jsxs("span",{className:"file-code-line-content",children:[
|
|
21
|
-
`))}const R=r.useCallback((i,o)=>{const s=++p.current,d=Re(i);if(U.current=!1,P(),X.current=null,g([]),f(null),y(""),C(null),T(null),fe(null),K(0),ee(null),te(null),ne(!1),D(null),re(null),ie(!1),pe(!0),Fe(null),xe("unavailable"),ge(!1),be(null),ve("file"),we(!1),ke(!1),O(!1),A(""),H(null),B(!1),b("initial-loading"),W.current=!1,oe.current=0,Se.current=new TextDecoder("utf-8",{fatal:!1}),de(i)){X.current=i,f(i);return}a("fs:watch",{path:on(i)}).catch(()=>{}),o==="text"?(Qe(i,s),$(i,!0,s),d&&Ee.current&&q(i,s)):o==="image"||o==="video"||o==="audio"||o==="pdf"?q(i,s):o==="hex"&&(a("fs:stat",{path:i}).then(h=>{s===p.current&&C(h)}).catch(()=>{}),Ze(i,s))},[$,Ze,q,Qe,P,a]);r.useEffect(()=>{if(e)return Ee.current=!1,Be(!1),R(e,m),()=>{p.current++,U.current=!1,P()}},[e]),r.useEffect(()=>{let i=null;const o=s=>{const d=s.detail;!d||d!==e||(i!==null&&window.clearTimeout(i),i=window.setTimeout(()=>{m==="text"&&W.current?B(!0):e&&R(e,m)},350))};return window.addEventListener("file-changed",o),()=>{window.removeEventListener("file-changed",o),i!==null&&window.clearTimeout(i)}},[e,m,R]),r.useEffect(()=>{W.current=w},[w]),r.useEffect(()=>{if(z!=="initial-loading"){He(!1);return}const i=window.setTimeout(()=>He(!0),120);return()=>window.clearTimeout(i)},[e,z]),r.useEffect(()=>{const i=Ge.current,o=qe.current;if(!i||!o||!e||m!=="text"||me||w||F!=="file"||z!=="ready"||ue)return;const s=new IntersectionObserver(d=>{d.some(h=>h.isIntersecting)&&$(e)},{root:o,rootMargin:"0px 0px 360px 0px"});return s.observe(i),()=>s.disconnect()},[w,me,m,$,ue,e,z,F]);const Ke=r.useCallback((i,o)=>{const s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=Q(o),d.style.display="none",document.body.appendChild(d),d.click(),d.remove(),window.setTimeout(()=>URL.revokeObjectURL(s),1e3)},[]),St=r.useCallback(async()=>{if(!e||v!==null||j!==null)return;if(de(e)){window.open(e,"_blank","noopener,noreferrer");return}const i=e;ee(null),D(null),ne(!1),te(0);try{const o=await Me(i,a,te);Ke(o,i),ne(!0),window.setTimeout(()=>ne(!1),1500)}catch(o){ee((o==null?void 0:o.message)??String(o))}finally{te(null)}},[Ke,v,e,a,j]),jt=r.useCallback(async()=>{if(!e||j!==null||v!==null)return;const i=e;ee(null),D(null),ie(!1);const o=ct(navigator,window.isSecureContext);if(o==="insecure-context"){D("当前页面是 HTTP,手机 Chrome 仅允许 HTTPS 页面分享文件,请改用 HTTPS 地址后重试");return}if(o==="unsupported-browser"){D("当前浏览器不支持分享文件,请使用最新版手机 Chrome 或系统浏览器");return}re(0);try{const s=await Me(i,a,re),d=new File([s],Q(i),{type:dt(i),lastModified:(u==null?void 0:u.mtime)??Date.now()}),h=await ft(d,navigator);h==="unsupported"?D("当前浏览器不支持分享此文件类型,请使用下载按钮"):h==="shared"&&(ie(!0),window.setTimeout(()=>ie(!1),1500))}catch(s){D((s==null?void 0:s.message)??String(s))}finally{re(null)}},[v,u==null?void 0:u.mtime,e,a,j]),ae=r.useCallback(async(i,o)=>{const s=await a("fs:inspect-text",{path:i},6e4);return o!==p.current?null:(C({size:s.size,mtime:s.mtime}),xe(s.diffStatus),Fe(s.patch),we(!s.tooLarge&&s.validUtf8),s)},[a]),Et=r.useCallback(async()=>{if(!e||ye)return;const i=p.current;ke(!0),H(null);try{const o=await ae(e,i);if(!o)return;if(o.tooLarge||o.data===null)throw new Error("文件超过 8M,无法在线编辑");if(!o.validUtf8)throw new Error("此文件不是有效的 UTF-8 文本,无法在线编辑");const s=new TextDecoder("utf-8",{fatal:!1}).decode(De(o.data));g([s]),K(o.size),oe.current=o.size,pe(!0),A(s),B(!1),W.current=!0,O(!0)}catch(o){i===p.current&&H(o.message??String(o))}finally{i===p.current&&ke(!1)}},[ye,ae,e]),et=r.useCallback(async()=>{if(!e||he||(ve("diff"),se!==null))return;const i=p.current;ge(!0),be(null);try{await ae(e,i)}catch(o){i===p.current&&be(o.message??String(o))}finally{i===p.current&&ge(!1)}},[he,ae,se,e]),Ct=r.useCallback(()=>{if(!e)return;const i=!M;Ee.current=i,Be(i),i&&!c&&q(e,p.current)},[q,c,e,M]),G=r.useCallback(i=>{X.current===i&&(T(null),b("ready"))},[]),Y=r.useCallback(i=>{X.current===i&&(T("文件预览加载失败,请重试"),b("error"))},[]),Lt=r.useCallback(()=>{e&&R(e,m)},[m,e,R]),zt=r.useCallback(()=>{L!==I&&!window.confirm("放弃未保存的修改?")||(W.current=!1,O(!1),A(""),H(null),B(!1))},[L,I]),Tt=r.useCallback(()=>{w&&L!==I&&!window.confirm("放弃未保存的修改并关闭预览?")||(p.current++,P(),l())},[L,w,l,P,I]),Mt=r.useCallback(()=>{e&&(W.current=!1,O(!1),A(""),R(e,"text"))},[e,R]),Rt=r.useCallback(async()=>{if(!(!e||!u||_||L===I)){Xe(!0),H(null);try{await a("fs:write-text",{path:e,content:L,expectedSize:u.size,expectedMtime:u.mtime},6e4),W.current=!1,O(!1),A(""),R(e,"text")}catch(i){H((i==null?void 0:i.message)??String(i))}finally{Xe(!1)}}},[L,u,e,a,_,R,I]),V=r.useMemo(()=>Ot(se??""),[se]);if(!e)return null;const tt=((u==null?void 0:u.size)??0)>en,Le=!tt&&(Ae==="changed"||Ae==="untracked"),nt=m==="text"&&Ue&&z!=="initial-loading"&&!ye&&!S;return t.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"var(--ui-term-col-bg, #101014)",color:"var(--ui-text, #e8e8ee)",colorScheme:"var(--ui-color-scheme, dark)",accentColor:"var(--ui-tab-accent, #7aa2f7)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",background:"var(--ui-tree-bg, #121218)",flexShrink:0},children:[t.jsx("span",{className:"pv-name",style:{minWidth:0,flex:"1 1 auto",fontSize:12.5,color:"var(--ui-text, #e8e8ee)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Q(e)}),u&&t.jsx("span",{style:{fontSize:10.5,color:"var(--ui-history-meta, #666)",flexShrink:0},children:ze(u.size)}),w?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:zt,disabled:_,style:N,"aria-label":"取消编辑",title:"取消编辑",children:t.jsx(Ht,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:Rt,disabled:_||L===I,style:{...N,color:"var(--ui-tab-accent, #7aa2f7)",opacity:_||L===I?.55:1},"aria-label":_?"正在保存":"保存修改",title:_?"正在保存":"保存修改",children:_?t.jsx(Z,{className:"tree-spin",size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(Nt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]}):t.jsxs(t.Fragment,{children:[m==="text"&&t.jsx("button",{type:"button",onClick:Et,disabled:!nt,style:{...N,opacity:nt?1:.45},"aria-label":"编辑文件",title:tt?"文件超过 8M,无法在线编辑":Ue?"编辑文件":"此文件不可编辑",children:t.jsx(Wt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:St,disabled:v!==null||j!==null,style:{...N,opacity:v!==null||j!==null?.72:1},"aria-label":Ce?"打开原始地址":v===null?"下载到当前设备":`正在下载 ${v}%`,title:Ce?"打开原始地址":v===null?"下载到当前设备":`正在下载 ${v}%`,children:v!==null?t.jsx(Z,{className:"tree-spin",size:15,strokeWidth:1.8,"aria-hidden":"true"}):bt?t.jsx(rt,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(It,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),!Ce&&t.jsx("button",{type:"button",onClick:jt,disabled:j!==null||v!==null,style:{...N,opacity:j!==null||v!==null?.72:1},"aria-label":"分享文件",title:j===null?"分享文件":`正在准备 ${j}%`,children:j!==null?t.jsx(Z,{className:"tree-spin",size:15,strokeWidth:1.8,"aria-hidden":"true"}):vt?t.jsx(rt,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(Ft,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),Je&&t.jsx("button",{type:"button",onClick:Ct,"aria-pressed":M,style:{...N,...M?{color:"var(--ui-tab-accent, #7aa2f7)",borderColor:"var(--ui-tab-accent, #7aa2f7)"}:{}},"aria-label":M?"退出浏览器预览":"浏览器预览",title:M?"退出浏览器预览":Ye?"在浏览器中预览渲染效果":Ve?"预览 Markdown 排版效果":"在浏览器中查看原始文件",children:t.jsx(Pt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]}),t.jsx("button",{type:"button",onClick:Tt,style:N,"aria-label":"关闭预览",title:"关闭预览",children:t.jsx(Dt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]}),m==="text"&&Le&&!w&&!M&&t.jsxs("div",{style:{display:"flex",alignItems:"center",minHeight:34,padding:"0 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",background:"var(--ui-tree-bg, #121218)",flexShrink:0},children:[t.jsxs("div",{role:"tablist","aria-label":"文件预览模式",style:{display:"inline-flex",gap:2,padding:2,border:"1px solid var(--ui-panel-input-border, #333)",borderRadius:6,background:"var(--ui-muted-surface, #1b1b22)"},children:[t.jsx(st,{active:F==="diff",onClick:et,children:"变更"}),t.jsx(st,{active:F==="file",onClick:()=>ve("file"),children:"文件"})]}),t.jsxs("span",{style:{marginLeft:9,display:"inline-flex",gap:7,fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:10.5},children:[V.added>0&&t.jsxs("span",{style:{color:"var(--ui-success, #059669)"},children:["+",V.added]}),V.removed>0&&t.jsxs("span",{style:{color:"var(--ui-error, #dc2626)"},children:["-",V.removed]})]})]}),Ne&&t.jsxs("div",{role:"alert",style:{flexShrink:0,padding:"8px 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",background:"var(--ui-tree-bg, #121218)",color:"var(--ui-error, #f7768e)",fontSize:12.5,lineHeight:1.5},children:["分享失败:",Ne]}),t.jsxs("div",{ref:qe,className:"pv-body",style:{position:"relative",flex:1,minHeight:0,overflow:"auto",background:"var(--ui-term-col-bg, #101014)",WebkitOverflowScrolling:"touch"},children:[Pe&&t.jsxs("div",{style:{padding:"10px 14px 0",color:"var(--ui-error, #f7768e)",fontSize:12.5},children:["下载失败:",Pe]}),$e&&t.jsx("div",{role:"alert",style:{padding:"10px 14px",color:"var(--ui-error, #f7768e)",fontSize:12.5},children:$e}),wt&&w&&t.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",color:"var(--ui-error, #f7768e)",fontSize:12},children:[t.jsx("span",{style:{flex:1},children:"文件已在其他位置更新"}),t.jsxs("button",{type:"button",onClick:Mt,style:_e,children:[t.jsx(Te,{size:13,strokeWidth:1.8,"aria-hidden":"true"}),"重新加载"]})]}),c&&!S&&m==="image"&&t.jsx("img",{src:c,alt:e,onLoad:()=>G(c),onError:()=>Y(c),style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",display:"block",margin:"0 auto"}}),c&&!S&&m==="video"&&t.jsx("video",{src:c,controls:!0,playsInline:!0,preload:"metadata",onLoadedMetadata:()=>G(c),onError:()=>Y(c),style:{maxWidth:"100%",maxHeight:"100%",display:"block",margin:"0 auto"}}),c&&!S&&m==="audio"&&t.jsx("div",{style:{display:"grid",placeItems:"center",height:"100%"},children:t.jsx("audio",{src:c,controls:!0,autoPlay:!0,onLoadedMetadata:()=>G(c),onError:()=>Y(c),style:{width:"min(420px, 88%)"}})}),c&&!S&&m==="pdf"&&t.jsx("iframe",{src:c,title:e,onLoad:()=>G(c),onError:()=>Y(c),style:{width:"100%",height:"100%",border:"none"}}),c&&!S&&m==="text"&&Je&&M&&!w&&t.jsx("iframe",{src:yt?`${c}/${encodeURIComponent(Q(e))}`:c,sandbox:Jt,title:e,onLoad:()=>G(c),onError:()=>Y(c),style:{width:"100%",height:"100%",border:"none",background:"#fff"}}),m==="text"&&w&&!S&&t.jsx("textarea",{value:L,onChange:i=>A(i.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-label":`编辑 ${Q(e)}`,style:{width:"100%",minHeight:"100%",boxSizing:"border-box",resize:"none",margin:0,padding:"12px 14px calc(env(safe-area-inset-bottom) + 36px)",border:0,outline:0,background:"var(--ui-term-col-bg, #101014)",color:"var(--ui-history-item-text, var(--ui-text, #d6d6de))",fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:12,lineHeight:1.5,tabSize:2}}),m==="text"&&!w&&!S&&Le&&F==="diff"&&(Oe?t.jsx(ce,{label:Oe,actionLabel:"重试",onAction:()=>void et(),tone:"error"}):he?t.jsx(ce,{label:"正在加载变更"}):t.jsx(an,{rows:V.rows})),(m==="hex"||m==="text"&&!w&&!M&&(!Le||F==="file"))&&!S&&t.jsxs(t.Fragment,{children:[t.jsx("pre",{style:{margin:0,padding:"11px 13px calc(env(safe-area-inset-bottom) + 36px)",fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:m==="hex"?10.5:12,lineHeight:1.45,color:m==="hex"?"var(--ui-muted-text, #9aa)":"var(--ui-history-item-text, var(--ui-text, #d6d6de))",whiteSpace:m==="hex"?"pre":"pre-wrap",wordBreak:m==="hex"?"normal":"break-word"},children:m==="hex"?k:t.jsx($t,{path:e,chunks:x,fileSize:u==null?void 0:u.size})}),m==="text"&&!me&&t.jsxs("div",{ref:Ge,role:"status","aria-live":"polite",style:{minHeight:44,padding:"0 14px calc(env(safe-area-inset-bottom) + 8px)",display:"flex",alignItems:"center",justifyContent:"center",gap:7,color:"var(--ui-history-meta, #666)",fontSize:11.5},children:[z==="loading-more"&&t.jsx(Z,{className:"tree-spin",size:14,strokeWidth:1.8,"aria-hidden":"true",style:{color:"var(--ui-tab-accent, #7aa2f7)"}}),ue?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"加载失败"}),t.jsxs("button",{type:"button",onClick:()=>$(e),style:_e,children:[t.jsx(Te,{size:13,strokeWidth:1.8,"aria-hidden":"true"}),"重试"]})]}):t.jsx("span",{children:z==="loading-more"?"正在加载更多":`${ze(We)} / ${ze((u==null?void 0:u.size)??We)}`})]})]}),gt&&z==="initial-loading"&&t.jsx(ce,{label:"正在加载文件"}),S&&z==="error"&&t.jsx(ce,{label:S,actionLabel:"重试",onAction:Lt,tone:"error"})]})]})}function Q(e){return e.slice(e.lastIndexOf("/")+1)||e}function on(e){const n=e.lastIndexOf("/");return n>0?e.slice(0,n):"/"}function ze(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}K`:`${(e/1024/1024).toFixed(1)}M`}const N={width:28,height:28,borderRadius:7,border:"1px solid var(--ui-panel-input-border, #333)",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--ui-muted-surface, #1b1b22)",color:"var(--ui-muted-text, #ccc)",flexShrink:0,cursor:"pointer",WebkitAppRegion:"no-drag"},_e={minHeight:28,padding:"0 9px",borderRadius:6,border:"1px solid var(--ui-panel-input-border, #333)",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--ui-muted-surface, #1b1b22)",color:"var(--ui-muted-text, #ccc)",cursor:"pointer",fontSize:11};function ce({label:e,actionLabel:n,onAction:l,tone:a="muted"}){return t.jsxs("div",{role:a==="error"?"alert":"status",style:{position:"absolute",inset:0,minHeight:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,color:a==="error"?"var(--ui-error, #f7768e)":"var(--ui-muted-text, #9aa)",fontSize:12.5},children:[a!=="error"&&t.jsx(Z,{className:"tree-spin",size:18,strokeWidth:1.8,"aria-hidden":"true",style:{color:"var(--ui-tab-accent, #7aa2f7)"}}),t.jsx("span",{children:e}),n&&l&&t.jsxs("button",{type:"button",onClick:l,style:_e,children:[t.jsx(Te,{size:13,strokeWidth:1.8,"aria-hidden":"true"}),n]})]})}function st({active:e,onClick:n,children:l}){return t.jsx("button",{type:"button",role:"tab","aria-selected":e,onClick:n,style:{minWidth:48,height:24,padding:"0 9px",border:0,borderRadius:4,background:e?"var(--ui-tab-accent, #7aa2f7)":"transparent",color:e?"var(--ui-tab-active-text, #fff)":"var(--ui-muted-text, #9aa)",fontSize:11,fontWeight:600,cursor:"pointer"},children:l})}function an({rows:e}){return t.jsx("div",{style:{minWidth:"100%",width:"max-content",paddingBottom:"calc(env(safe-area-inset-bottom) + 36px)",fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:11.5,lineHeight:1.55},children:e.map((n,l)=>{const a=n.kind==="added",x=n.kind==="removed",g=n.kind==="hunk"||n.kind==="meta"||n.kind==="note",c=a?"color-mix(in srgb, var(--ui-success, #059669) 12%, transparent)":x?"color-mix(in srgb, var(--ui-error, #dc2626) 11%, transparent)":n.kind==="hunk"?"color-mix(in srgb, var(--ui-tab-accent, #7aa2f7) 10%, transparent)":"transparent",f=a?"var(--ui-success, #059669)":x?"var(--ui-error, #dc2626)":g?"var(--ui-muted-text, #9aa)":"var(--ui-history-item-text, var(--ui-text, #d6d6de))";return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"42px 42px 22px minmax(0, 1fr)",minHeight:18,background:c,color:f},children:[t.jsx("span",{style:ot,children:n.oldLine??""}),t.jsx("span",{style:ot,children:n.newLine??""}),t.jsx("span",{style:{textAlign:"center",userSelect:"none",color:f},children:a?"+":x?"-":" "}),t.jsx("span",{style:{padding:"0 12px 0 6px",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:n.text||" "})]},`${n.kind}-${l}`)})})}const ot={padding:"0 6px",borderRight:"1px solid var(--ui-tree-border, #222)",color:"var(--ui-history-meta, #666)",textAlign:"right",userSelect:"none"},pn=Object.freeze(Object.defineProperty({__proto__:null,MAX_CLIENT_DOWNLOAD_BYTES:lt,decodeTextChunk:mt,default:sn,isBrowserPreviewPath:Re,isHtmlPreviewPath:pt,isMarkdownPreviewPath:xt,kindOf:ht,mimeTypeForPath:dt,nativeFileShareReadiness:ct,readFileForClientDownload:Me,shareFileWithNativePicker:ft},Symbol.toStringTag,{value:"Module"}));export{sn as F,it as M,mn as a,pn as b,Ut as c};
|
|
19
|
+
`);n[n.length-1]+=a[0];for(let x=1;x<a.length;x+=1)n.push(a[x])}return n}function $t({path:e,chunks:n,fileSize:l}){const[a,x]=r.useState(null),g=Ut(e),c=n.length>0&&g!==null&&(l===void 0||l<=it)&&n.reduce((w,u)=>w+u.length,0)<=it;r.useEffect(()=>{if(!c)return;let w=!1;return _t(async()=>{const{highlightCodeLines:u}=await import("./codeSyntax-GjP28nDI.js");return{highlightCodeLines:u}},__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(({highlightCodeLines:u})=>{w||x(()=>u)}).catch(()=>{}),()=>{w=!0}},[c]);const f=r.useMemo(()=>Xt(n),[n]),k=r.useMemo(()=>c&&a?a(e,n.join("")):null,[n,c,a,e]);return t.jsx("code",{className:"file-code-preview","data-language":g??void 0,children:f.map((w,u)=>{const C=u<f.length-1?`
|
|
20
|
+
`:"";return t.jsxs(r.Fragment,{children:[t.jsx("span",{className:"file-code-line-number","aria-hidden":"true","data-line-number":u+1}),k?t.jsx("span",{className:"file-code-line-content",dangerouslySetInnerHTML:{__html:k[u]+C}}):t.jsxs("span",{className:"file-code-line-content",children:[w,C]})]},u)})})}const at=new Set(["ts","tsx","js","jsx","mjs","cjs","json","md","markdown","mdown","mkdn","mdx","css","scss","html","htm","xml","yml","yaml","toml","sh","zsh","bash","py","rb","go","rs","java","kt","c","h","cpp","hpp","sql","env","gitignore","dockerfile","txt","log","conf","properties","gradle","lock","csv","vue","svelte","astro","graphql","prisma","proto"]),qt=new Set(["png","jpg","jpeg","gif","webp","bmp","ico","svg"]),Gt=new Set(["html","htm"]),Yt=new Set(["md","markdown","mdown","mkdn","mdx"]),Vt=new Set(at),Jt="allow-scripts allow-popups allow-forms allow-modals",Qt=new Set(["mp4","webm","mov","m4v"]),Zt=new Set(["mp3","wav","m4a","aac","ogg","flac"]),Kt=new Set(["pdf"]),en=8*1024*1024,tn=4096,nn=512*1024,lt=256*1024*1024,rn={aac:"audio/aac",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",gif:"image/gif",html:"text/html",jpeg:"image/jpeg",jpg:"image/jpeg",json:"application/json",m4a:"audio/mp4",m4v:"video/mp4",md:"text/markdown",mov:"video/quicktime",mp3:"audio/mpeg",mp4:"video/mp4",ogg:"audio/ogg",pdf:"application/pdf",png:"image/png",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",svg:"image/svg+xml",tar:"application/x-tar",txt:"text/plain",wav:"audio/wav",webm:"video/webm",webp:"image/webp",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"application/xml",zip:"application/zip"};function ct(e,n){return n?!e.share||!e.canShare?"unsupported-browser":"ready":"insecure-context"}function dt(e){const n=ut(e);return rn[n]??"application/octet-stream"}function ut(e){var l;return((l=(de(e)?new URL(e).pathname:e).split(".").pop())==null?void 0:l.toLowerCase())??""}async function ft(e,n){var l;if(!n.share||!((l=n.canShare)!=null&&l.call(n,{files:[e]})))return"unsupported";try{return await n.share({files:[e],title:e.name}),"shared"}catch(a){if(a&&typeof a=="object"&&"name"in a&&a.name==="AbortError")return"cancelled";throw a}}function De(e){return Uint8Array.from(atob(e),n=>n.charCodeAt(0))}function mt(e,n,l){return e.decode(De(n),{stream:!l})}async function Me(e,n,l=()=>{},a=nn){const x=await n("fs:stat",{path:e});if(x.dir)throw new Error("文件夹不能下载");if(x.size>lt)throw new Error("文件超过 256M,请通过终端传输");const g=[];let c=0;do{const f=await n("fs:read",{path:e,offset:c,length:a},6e4),k=De(f.data);if(k.byteLength!==f.bytes)throw new Error("文件分块长度不一致,请重试");g.push(k.slice().buffer);const w=f.offset+f.bytes;if(!f.eof&&w<=c)throw new Error("文件下载未取得进展,请重试");if(c=w,l(x.size===0?100:Math.min(100,Math.round(c/x.size*100))),f.eof)break}while(c<x.size);return new Blob(g,{type:"application/octet-stream"})}function pt(e){var l;const n=((l=e.split(".").pop())==null?void 0:l.toLowerCase())??"";return Gt.has(n)}function xt(e){var l;const n=((l=e.split(".").pop())==null?void 0:l.toLowerCase())??"";return Yt.has(n)}function Re(e){var l;const n=((l=e.split(".").pop())==null?void 0:l.toLowerCase())??"";return Vt.has(n)}function ht(e){const n=ut(e);return at.has(n)||!e.includes(".")?"text":qt.has(n)?"image":Qt.has(n)?"video":Zt.has(n)?"audio":Kt.has(n)?"pdf":"hex"}function sn({path:e,gateway:n,onClose:l}){const a=n.request,[x,g]=r.useState([]),[c,f]=r.useState(null),[k,w]=r.useState(""),[u,C]=r.useState(null),[z,b]=r.useState("initial-loading"),[gt,He]=r.useState(!1),[We,K]=r.useState(0),[ue,fe]=r.useState(null),[S,T]=r.useState(null),[Pe,ee]=r.useState(null),[v,te]=r.useState(null),[bt,ne]=r.useState(!1),[Ne,D]=r.useState(null),[j,re]=r.useState(null),[vt,ie]=r.useState(!1),[me,pe]=r.useState(!0),[se,Fe]=r.useState(null),[Ae,xe]=r.useState("unavailable"),[he,ge]=r.useState(!1),[Oe,be]=r.useState(null),[F,ve]=r.useState("file"),[M,Be]=r.useState(!1),[Ue,ye]=r.useState(!1),[we,ke]=r.useState(!1),[y,O]=r.useState(!1),[L,A]=r.useState(""),[_,Xe]=r.useState(!1),[$e,H]=r.useState(null),[yt,B]=r.useState(!1),qe=r.useRef(null),Ge=r.useRef(null),oe=r.useRef(0),W=r.useRef(!1),p=r.useRef(0),U=r.useRef(!1),Se=r.useRef(new TextDecoder("utf-8",{fatal:!1})),je=r.useRef(null),X=r.useRef(null),Ee=r.useRef(!1),m=e?ht(e):"unsupported",Ce=e?de(e):!1,Ye=e?pt(e):!1,Ve=e?xt(e):!1,wt=Ye||Ve,Je=e?Re(e):!1,I=r.useMemo(()=>x.join(""),[x]),P=r.useCallback(()=>{const i=je.current;je.current=null,i&&a("fs:preview-close",{ticketId:i}).catch(()=>{})},[a]),$=r.useCallback(async(i,o=!1,s=p.current)=>{if(!U.current){U.current=!0,b(o?"initial-loading":"loading-more"),fe(null);try{const d=o?0:oe.current,h=await a("fs:read",{path:i,offset:d,length:256*1024});if(s!==p.current)return;const J=h.offset+h.bytes;if(!h.eof&&J<=d)throw new Error("文件加载未取得进展,请重试");o&&(Se.current=new TextDecoder("utf-8",{fatal:!1}));const le=mt(Se.current,h.data,h.eof);oe.current=J,pe(h.eof),K(J),g(E=>o?[le]:[...E,le]),C(E=>({size:h.size,mtime:(E==null?void 0:E.mtime)??0})),T(null),b("ready")}catch(d){if(s!==p.current)return;const h=d.message??String(d);o?(T(h),b("error")):(fe(h),b("ready"))}finally{s===p.current&&(U.current=!1)}}},[a]),Qe=r.useCallback(async(i,o)=>{try{const s=await a("fs:inspect-text-status",{path:i});if(o!==p.current)return;C({size:s.size,mtime:s.mtime}),xe(s.diffStatus),ye(!s.tooLarge),B(!1),H(null)}catch{}},[a]),q=r.useCallback(async(i,o=p.current)=>{P(),b("initial-loading"),T(null);try{const s=await a("fs:preview-open",{path:i});if(o!==p.current){a("fs:preview-close",{ticketId:s.ticketId}).catch(()=>{});return}je.current=s.ticketId,X.current=s.url,f(s.url),C({size:s.size,mtime:s.mtime})}catch(s){if(o!==p.current)return;T(s.message??String(s)),b("error")}},[P,a]),Ze=r.useCallback(async(i,o=p.current)=>{b("initial-loading"),T(null);try{const s=await a("fs:read",{path:i,offset:0,length:tn});if(o!==p.current)return;kt(s.data),K(s.bytes),C(d=>({size:s.size,mtime:(d==null?void 0:d.mtime)??0})),b("ready")}catch(s){if(o!==p.current)return;T(s.message??String(s)),b("error")}},[a]);function kt(i){const o=atob(i),s=[];for(let d=0;d+16<=o.length||d===0;d+=16){const h=o.slice(d,d+16),J=[...h].map(E=>E.charCodeAt(0).toString(16).padStart(2,"0")).join(" ").padEnd(47," "),le=[...h].map(E=>E.charCodeAt(0)>=32&&E.charCodeAt(0)<127?E:".").join("");if(s.push(`${d.toString(16).padStart(8,"0")} ${J} |${le}|`),d+16>o.length)break}w(s.join(`
|
|
21
|
+
`))}const R=r.useCallback((i,o)=>{const s=++p.current,d=Re(i);if(U.current=!1,P(),X.current=null,g([]),f(null),w(""),C(null),T(null),fe(null),K(0),ee(null),te(null),ne(!1),D(null),re(null),ie(!1),pe(!0),Fe(null),xe("unavailable"),ge(!1),be(null),ve("file"),ye(!1),ke(!1),O(!1),A(""),H(null),B(!1),b("initial-loading"),W.current=!1,oe.current=0,Se.current=new TextDecoder("utf-8",{fatal:!1}),de(i)){X.current=i,f(i);return}a("fs:watch",{path:on(i)}).catch(()=>{}),o==="text"?(Qe(i,s),$(i,!0,s),d&&Ee.current&&q(i,s)):o==="image"||o==="video"||o==="audio"||o==="pdf"?q(i,s):o==="hex"&&(a("fs:stat",{path:i}).then(h=>{s===p.current&&C(h)}).catch(()=>{}),Ze(i,s))},[$,Ze,q,Qe,P,a]);r.useEffect(()=>{if(e)return Ee.current=!1,Be(!1),R(e,m),()=>{p.current++,U.current=!1,P()}},[e]),r.useEffect(()=>{let i=null;const o=s=>{const d=s.detail;!d||d!==e||(i!==null&&window.clearTimeout(i),i=window.setTimeout(()=>{m==="text"&&W.current?B(!0):e&&R(e,m)},350))};return window.addEventListener("file-changed",o),()=>{window.removeEventListener("file-changed",o),i!==null&&window.clearTimeout(i)}},[e,m,R]),r.useEffect(()=>{W.current=y},[y]),r.useEffect(()=>{if(z!=="initial-loading"){He(!1);return}const i=window.setTimeout(()=>He(!0),120);return()=>window.clearTimeout(i)},[e,z]),r.useEffect(()=>{const i=Ge.current,o=qe.current;if(!i||!o||!e||m!=="text"||me||y||F!=="file"||z!=="ready"||ue)return;const s=new IntersectionObserver(d=>{d.some(h=>h.isIntersecting)&&$(e)},{root:o,rootMargin:"0px 0px 360px 0px"});return s.observe(i),()=>s.disconnect()},[y,me,m,$,ue,e,z,F]);const Ke=r.useCallback((i,o)=>{const s=URL.createObjectURL(i),d=document.createElement("a");d.href=s,d.download=Q(o),d.style.display="none",document.body.appendChild(d),d.click(),d.remove(),window.setTimeout(()=>URL.revokeObjectURL(s),1e3)},[]),St=r.useCallback(async()=>{if(!e||v!==null||j!==null)return;if(de(e)){window.open(e,"_blank","noopener,noreferrer");return}const i=e;ee(null),D(null),ne(!1),te(0);try{const o=await Me(i,a,te);Ke(o,i),ne(!0),window.setTimeout(()=>ne(!1),1500)}catch(o){ee((o==null?void 0:o.message)??String(o))}finally{te(null)}},[Ke,v,e,a,j]),jt=r.useCallback(async()=>{if(!e||j!==null||v!==null)return;const i=e;ee(null),D(null),ie(!1);const o=ct(navigator,window.isSecureContext);if(o==="insecure-context"){D("当前页面是 HTTP,手机 Chrome 仅允许 HTTPS 页面分享文件,请改用 HTTPS 地址后重试");return}if(o==="unsupported-browser"){D("当前浏览器不支持分享文件,请使用最新版手机 Chrome 或系统浏览器");return}re(0);try{const s=await Me(i,a,re),d=new File([s],Q(i),{type:dt(i),lastModified:(u==null?void 0:u.mtime)??Date.now()}),h=await ft(d,navigator);h==="unsupported"?D("当前浏览器不支持分享此文件类型,请使用下载按钮"):h==="shared"&&(ie(!0),window.setTimeout(()=>ie(!1),1500))}catch(s){D((s==null?void 0:s.message)??String(s))}finally{re(null)}},[v,u==null?void 0:u.mtime,e,a,j]),ae=r.useCallback(async(i,o)=>{const s=await a("fs:inspect-text",{path:i},6e4);return o!==p.current?null:(C({size:s.size,mtime:s.mtime}),xe(s.diffStatus),Fe(s.patch),ye(!s.tooLarge&&s.validUtf8),s)},[a]),Et=r.useCallback(async()=>{if(!e||we)return;const i=p.current;ke(!0),H(null);try{const o=await ae(e,i);if(!o)return;if(o.tooLarge||o.data===null)throw new Error("文件超过 8M,无法在线编辑");if(!o.validUtf8)throw new Error("此文件不是有效的 UTF-8 文本,无法在线编辑");const s=new TextDecoder("utf-8",{fatal:!1}).decode(De(o.data));g([s]),K(o.size),oe.current=o.size,pe(!0),A(s),B(!1),W.current=!0,O(!0)}catch(o){i===p.current&&H(o.message??String(o))}finally{i===p.current&&ke(!1)}},[we,ae,e]),et=r.useCallback(async()=>{if(!e||he||(ve("diff"),se!==null))return;const i=p.current;ge(!0),be(null);try{await ae(e,i)}catch(o){i===p.current&&be(o.message??String(o))}finally{i===p.current&&ge(!1)}},[he,ae,se,e]),Ct=r.useCallback(()=>{if(!e)return;const i=!M;Ee.current=i,Be(i),i&&!c&&q(e,p.current)},[q,c,e,M]),G=r.useCallback(i=>{X.current===i&&(T(null),b("ready"))},[]),Y=r.useCallback(i=>{X.current===i&&(T("文件预览加载失败,请重试"),b("error"))},[]),Lt=r.useCallback(()=>{e&&R(e,m)},[m,e,R]),zt=r.useCallback(()=>{L!==I&&!window.confirm("放弃未保存的修改?")||(W.current=!1,O(!1),A(""),H(null),B(!1))},[L,I]),Tt=r.useCallback(()=>{y&&L!==I&&!window.confirm("放弃未保存的修改并关闭预览?")||(p.current++,P(),l())},[L,y,l,P,I]),Mt=r.useCallback(()=>{e&&(W.current=!1,O(!1),A(""),R(e,"text"))},[e,R]),Rt=r.useCallback(async()=>{if(!(!e||!u||_||L===I)){Xe(!0),H(null);try{await a("fs:write-text",{path:e,content:L,expectedSize:u.size,expectedMtime:u.mtime},6e4),W.current=!1,O(!1),A(""),R(e,"text")}catch(i){H((i==null?void 0:i.message)??String(i))}finally{Xe(!1)}}},[L,u,e,a,_,R,I]),V=r.useMemo(()=>Ot(se??""),[se]);if(!e)return null;const tt=((u==null?void 0:u.size)??0)>en,Le=!tt&&(Ae==="changed"||Ae==="untracked"),nt=m==="text"&&Ue&&z!=="initial-loading"&&!we&&!S;return t.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",background:"var(--ui-term-col-bg, #101014)",color:"var(--ui-text, #e8e8ee)",colorScheme:"var(--ui-color-scheme, dark)",accentColor:"var(--ui-tab-accent, #7aa2f7)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",background:"var(--ui-tree-bg, #121218)",flexShrink:0},children:[t.jsx("span",{className:"pv-name",style:{minWidth:0,flex:"1 1 auto",fontSize:12.5,color:"var(--ui-text, #e8e8ee)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Q(e)}),u&&t.jsx("span",{style:{fontSize:10.5,color:"var(--ui-history-meta, #666)",flexShrink:0},children:ze(u.size)}),y?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:zt,disabled:_,style:N,"aria-label":"取消编辑",title:"取消编辑",children:t.jsx(Dt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:Rt,disabled:_||L===I,style:{...N,color:"var(--ui-tab-accent, #7aa2f7)",opacity:_||L===I?.55:1},"aria-label":_?"正在保存":"保存修改",title:_?"正在保存":"保存修改",children:_?t.jsx(Z,{className:"tree-spin",size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(Nt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]}):t.jsxs(t.Fragment,{children:[m==="text"&&t.jsx("button",{type:"button",onClick:Et,disabled:!nt,style:{...N,opacity:nt?1:.45},"aria-label":"编辑文件",title:tt?"文件超过 8M,无法在线编辑":Ue?"编辑文件":"此文件不可编辑",children:t.jsx(Ht,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),t.jsx("button",{type:"button",onClick:St,disabled:v!==null||j!==null,style:{...N,opacity:v!==null||j!==null?.72:1},"aria-label":Ce?"打开原始地址":v===null?"下载到当前设备":`正在下载 ${v}%`,title:Ce?"打开原始地址":v===null?"下载到当前设备":`正在下载 ${v}%`,children:v!==null?t.jsx(Z,{className:"tree-spin",size:15,strokeWidth:1.8,"aria-hidden":"true"}):bt?t.jsx(rt,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(It,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),!Ce&&t.jsx("button",{type:"button",onClick:jt,disabled:j!==null||v!==null,style:{...N,opacity:j!==null||v!==null?.72:1},"aria-label":"分享文件",title:j===null?"分享文件":`正在准备 ${j}%`,children:j!==null?t.jsx(Z,{className:"tree-spin",size:15,strokeWidth:1.8,"aria-hidden":"true"}):vt?t.jsx(rt,{size:15,strokeWidth:1.8,"aria-hidden":"true"}):t.jsx(Ft,{size:15,strokeWidth:1.8,"aria-hidden":"true"})}),Je&&t.jsx("button",{type:"button",onClick:Ct,"aria-pressed":M,style:{...N,...M?{color:"var(--ui-tab-accent, #7aa2f7)",borderColor:"var(--ui-tab-accent, #7aa2f7)"}:{}},"aria-label":M?"退出浏览器预览":"浏览器预览",title:M?"退出浏览器预览":Ye?"在浏览器中预览渲染效果":Ve?"预览 Markdown 排版效果":"在浏览器中查看原始文件",children:t.jsx(Pt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]}),t.jsx("button",{type:"button",onClick:Tt,style:N,"aria-label":"关闭预览",title:"关闭预览",children:t.jsx(Wt,{size:15,strokeWidth:1.8,"aria-hidden":"true"})})]}),m==="text"&&Le&&!y&&!M&&t.jsxs("div",{style:{display:"flex",alignItems:"center",minHeight:34,padding:"0 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",background:"var(--ui-tree-bg, #121218)",flexShrink:0},children:[t.jsxs("div",{role:"tablist","aria-label":"文件预览模式",style:{display:"inline-flex",gap:2,padding:2,border:"1px solid var(--ui-panel-input-border, #333)",borderRadius:6,background:"var(--ui-muted-surface, #1b1b22)"},children:[t.jsx(st,{active:F==="diff",onClick:et,children:"变更"}),t.jsx(st,{active:F==="file",onClick:()=>ve("file"),children:"文件"})]}),t.jsxs("span",{style:{marginLeft:9,display:"inline-flex",gap:7,fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:10.5},children:[V.added>0&&t.jsxs("span",{style:{color:"var(--ui-success, #059669)"},children:["+",V.added]}),V.removed>0&&t.jsxs("span",{style:{color:"var(--ui-error, #dc2626)"},children:["-",V.removed]})]})]}),Ne&&t.jsxs("div",{role:"alert",style:{flexShrink:0,padding:"8px 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",background:"var(--ui-tree-bg, #121218)",color:"var(--ui-error, #f7768e)",fontSize:12.5,lineHeight:1.5},children:["分享失败:",Ne]}),t.jsxs("div",{ref:qe,className:"pv-body",style:{position:"relative",flex:1,minHeight:0,overflow:"auto",background:"var(--ui-term-col-bg, #101014)",WebkitOverflowScrolling:"touch"},children:[Pe&&t.jsxs("div",{style:{padding:"10px 14px 0",color:"var(--ui-error, #f7768e)",fontSize:12.5},children:["下载失败:",Pe]}),$e&&t.jsx("div",{role:"alert",style:{padding:"10px 14px",color:"var(--ui-error, #f7768e)",fontSize:12.5},children:$e}),yt&&y&&t.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--ui-tree-border, #222)",color:"var(--ui-error, #f7768e)",fontSize:12},children:[t.jsx("span",{style:{flex:1},children:"文件已在其他位置更新"}),t.jsxs("button",{type:"button",onClick:Mt,style:_e,children:[t.jsx(Te,{size:13,strokeWidth:1.8,"aria-hidden":"true"}),"重新加载"]})]}),c&&!S&&m==="image"&&t.jsx("img",{src:c,alt:e,onLoad:()=>G(c),onError:()=>Y(c),style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",display:"block",margin:"0 auto"}}),c&&!S&&m==="video"&&t.jsx("video",{src:c,controls:!0,playsInline:!0,preload:"metadata",onLoadedMetadata:()=>G(c),onError:()=>Y(c),style:{maxWidth:"100%",maxHeight:"100%",display:"block",margin:"0 auto"}}),c&&!S&&m==="audio"&&t.jsx("div",{style:{display:"grid",placeItems:"center",height:"100%"},children:t.jsx("audio",{src:c,controls:!0,autoPlay:!0,onLoadedMetadata:()=>G(c),onError:()=>Y(c),style:{width:"min(420px, 88%)"}})}),c&&!S&&m==="pdf"&&t.jsx("iframe",{src:c,title:e,onLoad:()=>G(c),onError:()=>Y(c),style:{width:"100%",height:"100%",border:"none"}}),c&&!S&&m==="text"&&Je&&M&&!y&&t.jsx("iframe",{src:wt?`${c}/${encodeURIComponent(Q(e))}`:c,sandbox:Jt,title:e,onLoad:()=>G(c),onError:()=>Y(c),style:{width:"100%",height:"100%",border:"none",background:"#fff"}}),m==="text"&&y&&!S&&t.jsx("textarea",{value:L,onChange:i=>A(i.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off","aria-label":`编辑 ${Q(e)}`,style:{width:"100%",minHeight:"100%",boxSizing:"border-box",resize:"none",margin:0,padding:"12px 14px calc(env(safe-area-inset-bottom) + 36px)",border:0,outline:0,background:"var(--ui-term-col-bg, #101014)",color:"var(--ui-history-item-text, var(--ui-text, #d6d6de))",fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:12,lineHeight:1.5,tabSize:2}}),m==="text"&&!y&&!S&&Le&&F==="diff"&&(Oe?t.jsx(ce,{label:Oe,actionLabel:"重试",onAction:()=>void et(),tone:"error"}):he?t.jsx(ce,{label:"正在加载变更"}):t.jsx(an,{rows:V.rows})),(m==="hex"||m==="text"&&!y&&!M&&(!Le||F==="file"))&&!S&&t.jsxs(t.Fragment,{children:[t.jsx("pre",{style:{margin:0,padding:"11px 13px calc(env(safe-area-inset-bottom) + 36px)",fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:m==="hex"?10.5:12,lineHeight:1.45,color:m==="hex"?"var(--ui-muted-text, #9aa)":"var(--ui-history-item-text, var(--ui-text, #d6d6de))",whiteSpace:m==="hex"?"pre":"pre-wrap",wordBreak:m==="hex"?"normal":"break-word"},children:m==="hex"?k:t.jsx($t,{path:e,chunks:x,fileSize:u==null?void 0:u.size})}),m==="text"&&!me&&t.jsxs("div",{ref:Ge,role:"status","aria-live":"polite",style:{minHeight:44,padding:"0 14px calc(env(safe-area-inset-bottom) + 8px)",display:"flex",alignItems:"center",justifyContent:"center",gap:7,color:"var(--ui-history-meta, #666)",fontSize:11.5},children:[z==="loading-more"&&t.jsx(Z,{className:"tree-spin",size:14,strokeWidth:1.8,"aria-hidden":"true",style:{color:"var(--ui-tab-accent, #7aa2f7)"}}),ue?t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"加载失败"}),t.jsxs("button",{type:"button",onClick:()=>$(e),style:_e,children:[t.jsx(Te,{size:13,strokeWidth:1.8,"aria-hidden":"true"}),"重试"]})]}):t.jsx("span",{children:z==="loading-more"?"正在加载更多":`${ze(We)} / ${ze((u==null?void 0:u.size)??We)}`})]})]}),gt&&z==="initial-loading"&&t.jsx(ce,{label:"正在加载文件"}),S&&z==="error"&&t.jsx(ce,{label:S,actionLabel:"重试",onAction:Lt,tone:"error"})]})]})}function Q(e){return e.slice(e.lastIndexOf("/")+1)||e}function on(e){const n=e.lastIndexOf("/");return n>0?e.slice(0,n):"/"}function ze(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}K`:`${(e/1024/1024).toFixed(1)}M`}const N={width:28,height:28,borderRadius:7,border:"1px solid var(--ui-panel-input-border, #333)",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--ui-muted-surface, #1b1b22)",color:"var(--ui-muted-text, #ccc)",flexShrink:0,cursor:"pointer",WebkitAppRegion:"no-drag"},_e={minHeight:28,padding:"0 9px",borderRadius:6,border:"1px solid var(--ui-panel-input-border, #333)",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:5,background:"var(--ui-muted-surface, #1b1b22)",color:"var(--ui-muted-text, #ccc)",cursor:"pointer",fontSize:11};function ce({label:e,actionLabel:n,onAction:l,tone:a="muted"}){return t.jsxs("div",{role:a==="error"?"alert":"status",style:{position:"absolute",inset:0,minHeight:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,color:a==="error"?"var(--ui-error, #f7768e)":"var(--ui-muted-text, #9aa)",fontSize:12.5},children:[a!=="error"&&t.jsx(Z,{className:"tree-spin",size:18,strokeWidth:1.8,"aria-hidden":"true",style:{color:"var(--ui-tab-accent, #7aa2f7)"}}),t.jsx("span",{children:e}),n&&l&&t.jsxs("button",{type:"button",onClick:l,style:_e,children:[t.jsx(Te,{size:13,strokeWidth:1.8,"aria-hidden":"true"}),n]})]})}function st({active:e,onClick:n,children:l}){return t.jsx("button",{type:"button",role:"tab","aria-selected":e,onClick:n,style:{minWidth:48,height:24,padding:"0 9px",border:0,borderRadius:4,background:e?"var(--ui-tab-accent, #7aa2f7)":"transparent",color:e?"var(--ui-tab-active-text, #fff)":"var(--ui-muted-text, #9aa)",fontSize:11,fontWeight:600,cursor:"pointer"},children:l})}function an({rows:e}){return t.jsx("div",{style:{minWidth:"100%",width:"max-content",paddingBottom:"calc(env(safe-area-inset-bottom) + 36px)",fontFamily:'"SF Mono", Menlo, Consolas, monospace',fontSize:11.5,lineHeight:1.55},children:e.map((n,l)=>{const a=n.kind==="added",x=n.kind==="removed",g=n.kind==="hunk"||n.kind==="meta"||n.kind==="note",c=a?"color-mix(in srgb, var(--ui-success, #059669) 12%, transparent)":x?"color-mix(in srgb, var(--ui-error, #dc2626) 11%, transparent)":n.kind==="hunk"?"color-mix(in srgb, var(--ui-tab-accent, #7aa2f7) 10%, transparent)":"transparent",f=a?"var(--ui-success, #059669)":x?"var(--ui-error, #dc2626)":g?"var(--ui-muted-text, #9aa)":"var(--ui-history-item-text, var(--ui-text, #d6d6de))";return t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"42px 42px 22px minmax(0, 1fr)",minHeight:18,background:c,color:f},children:[t.jsx("span",{style:ot,children:n.oldLine??""}),t.jsx("span",{style:ot,children:n.newLine??""}),t.jsx("span",{style:{textAlign:"center",userSelect:"none",color:f},children:a?"+":x?"-":" "}),t.jsx("span",{style:{padding:"0 12px 0 6px",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:n.text||" "})]},`${n.kind}-${l}`)})})}const ot={padding:"0 6px",borderRight:"1px solid var(--ui-tree-border, #222)",color:"var(--ui-history-meta, #666)",textAlign:"right",userSelect:"none"},pn=Object.freeze(Object.defineProperty({__proto__:null,MAX_CLIENT_DOWNLOAD_BYTES:lt,decodeTextChunk:mt,default:sn,isBrowserPreviewPath:Re,isHtmlPreviewPath:pt,isMarkdownPreviewPath:xt,kindOf:ht,mimeTypeForPath:dt,nativeFileShareReadiness:ct,readFileForClientDownload:Me,shareFileWithNativePicker:ft},Symbol.toStringTag,{value:"Module"}));export{sn as F,it as M,mn as a,pn as b,Ut as c};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as ue,r as o,j as t,
|
|
1
|
+
import{c as ue,r as o,j as t,L as _,P as fe}from"./index-C30NoLsn.js";import{S as pe,i as T,F as me,D as he,P as xe,a as je,b as be,c as ze,d as ve,N as ge,e as Fe,f as Ne,g as ke,h as ye,j as $e}from"./file-types-Dj25tuty.js";import{L as Ie}from"./locate-fixed-B3zScPI-.js";import{X as Le}from"./x-CoIXF2eL.js";import{C as S}from"./chevron-down-BUEiUZA7.js";import{C as ee}from"./chevron-right-B_ITnckH.js";import{F as te}from"./trash-2-DwFoTvHX.js";/**
|
|
2
2
|
* @license lucide-react v0.468.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Re=ue("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);function b(a){const f=/^(?:[A-Za-z]:[\\/]|\\\\)/.test(a)?a.replaceAll("\\","/"):a,i=/^\/\/[^/]+\/[^/]+/.test(f),l=f.replace(/\/{2,}/g,"/");return/^[A-Za-z]:\/$/.test(l)||l==="/"?l:(i?"/":"")+l.replace(/\/+$/,"")}function M(a){const f=b(a),i=f.lastIndexOf("/");return i===2&&/^[A-Za-z]:\//.test(f)?f.slice(0,3):i<=0?"/":f.slice(0,i)}function se(a,f){const i=b(a),l=b(f);return i.startsWith(l.endsWith("/")?l:`${l}/`)}function De(a,f){const i=b(a);if(!se(f,i))return[];const l=M(f);if(l===i)return[i];const u=l.slice(i.length+(i.endsWith("/")?0:1)),L=[i];let z=i;for(const k of u.split("/").filter(Boolean))z=z.endsWith("/")?z+k:`${z}/${k}`,L.push(z);return L}const Ee={code:{icon
|
|
6
|
+
*/const Re=ue("CornerDownLeft",[["polyline",{points:"9 10 4 15 9 20",key:"r3jprv"}],["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}]]);function b(a){const f=/^(?:[A-Za-z]:[\\/]|\\\\)/.test(a)?a.replaceAll("\\","/"):a,i=/^\/\/[^/]+\/[^/]+/.test(f),l=f.replace(/\/{2,}/g,"/");return/^[A-Za-z]:\/$/.test(l)||l==="/"?l:(i?"/":"")+l.replace(/\/+$/,"")}function M(a){const f=b(a),i=f.lastIndexOf("/");return i===2&&/^[A-Za-z]:\//.test(f)?f.slice(0,3):i<=0?"/":f.slice(0,i)}function se(a,f){const i=b(a),l=b(f);return i.startsWith(l.endsWith("/")?l:`${l}/`)}function De(a,f){const i=b(a);if(!se(f,i))return[];const l=M(f);if(l===i)return[i];const u=l.slice(i.length+(i.endsWith("/")?0:1)),L=[i];let z=i;for(const k of u.split("/").filter(Boolean))z=z.endsWith("/")?z+k:`${z}/${k}`,L.push(z);return L}const Ee={code:{icon:ye,color:"#7aa2f7",label:"代码文件"},style:{icon:fe,color:"#bb9af7",label:"样式文件"},image:{icon:ke,color:"#9ece6a",label:"图片文件"},video:{icon:Ne,color:"#f7768e",label:"视频文件"},audio:{icon:Fe,color:"#c099ff",label:"音频文件"},markdown:{icon:ge,color:"#73daca",label:"Markdown 文件"},text:{icon:ve,color:"#a9b1d6",label:"文本文件"},json:{icon:ze,color:"#e0af68",label:"JSON 文件"},archive:{icon:be,color:"#ff9e64",label:"压缩文件"},spreadsheet:{icon:je,color:"#9ece6a",label:"表格文件"},presentation:{icon:xe,color:"#f7768e",label:"演示文件"},database:{icon:he,color:"#2ac3de",label:"数据库文件"},file:{icon:me,color:"#c8c8d0",label:"文件"}};function we(a){return Ee[$e(a)]}function re(a){return a<1024?`${a}B`:a<1024*1024?`${(a/1024).toFixed(1)}K`:a<1024*1024*1024?`${(a/1024/1024).toFixed(1)}M`:`${(a/1024/1024/1024).toFixed(1)}G`}function Ze({gateway:a,onOpenFile:f,selectedPath:i,ready:l,cwd:u,followCwd:L,initialRoot:z,initialFollow:k=!0,onTreeStateChange:p,revealRequest:g}){const I=a.request,B=a.subscribe,[F,ne]=o.useState(null),[w,A]=o.useState(""),[O,P]=o.useState(""),[ae,R]=o.useState(!k),[W,ie]=o.useState(""),v=o.useRef(new Map),y=o.useRef(null),Z=o.useRef(null),C=o.useRef(0),H=o.useRef(0),[,le]=o.useState(0),D=()=>le(e=>e+1),N=o.useCallback(async(e,r)=>{const n={path:e,depth:r,expanded:!0,children:null,loading:!0};v.current.set(e,n),D();try{const s=await I("fs:list",{path:e});n.children=s.entries,I("fs:watch",{path:e}).catch(()=>{})}catch(s){n.children=[],n.error=(s==null?void 0:s.message)??"read failed"}return n.loading=!1,D(),n},[I]),$=!!L&&!ae,j=o.useCallback(e=>{const r=b(e);y.current=r,v.current.clear(),ne({path:r,depth:0,expanded:!1,children:null,loading:!1}),P(r)},[]);o.useEffect(()=>{!l||!u||!$||y.current!==b(u)&&(j(u),p==null||p(u,!0))},[l,u,$,j]),o.useEffect(()=>{!l||!z||k||y.current||(R(!0),j(z))},[l,z,k,j]),o.useEffect(()=>{l&&I("hello").then(e=>{ie(e.home),$&&!u&&!y.current&&j(e.home)}).catch(()=>{})},[l,u,$,I,j]);const J=()=>{let e=O.trim();e&&(e==="~"?e=W||u||"/":e.startsWith("~/")?e=`${W||u||""}${e.slice(1)}`:e.startsWith("/")||(e=`${u||(F==null?void 0:F.path)||W||"/"}/${e}`),e=e.replace(/\/+/g,"/"),R(!0),j(e),p==null||p(e,!1))},ce=()=>{R(!1),u&&(j(u),p==null||p(u,!0))},K=o.useCallback(async e=>{let r=v.current.get(e);r||(r={path:e,depth:0,expanded:!1,children:null,loading:!1},v.current.set(e,r)),r.expanded?r.expanded=!1:(r.expanded=!0,!r.children&&!r.loading&&await N(e,r.depth)),D()},[N]),V=o.useCallback(async(e,r)=>{let n=v.current.get(e);n?!n.children&&!n.loading&&await N(e,r):n=await N(e,r),n.expanded=!0,D()},[N]),G=o.useCallback(async({path:e,requestId:r,rootAtParent:n})=>{const s=b(e),c=M(s);let m=y.current;(n||!m||!se(s,m))&&(m=c,R(!0),y.current!==m&&j(m),p==null||p(m,!1)),A("");const E=De(m,s);for(let x=0;x<E.length;x+=1){if(C.current!==r)return;await V(E[x],x)}const h=()=>{var Y;if(C.current!==r)return;const x=Array.from(((Y=Z.current)==null?void 0:Y.querySelectorAll("[data-tree-path]"))??[]).find(de=>de.dataset.treePath===s);x==null||x.scrollIntoView({block:"center",inline:"nearest"})};requestAnimationFrame(()=>requestAnimationFrame(h))},[j,p,V]);o.useEffect(()=>{!l||!g||H.current!==g.requestId&&(H.current=g.requestId,C.current=g.requestId,G(g))},[l,G,g==null?void 0:g.requestId]),o.useEffect(()=>B("fs:event",e=>{for(const r of e.events??[]){const n=b(r.path);i&&n===b(i)&&window.dispatchEvent(new CustomEvent("file-changed",{detail:i}));const s=M(n),c=v.current.get(s);c!=null&&c.expanded&&c.children&&!c.loading&&N(s,c.depth).catch(()=>{})}}),[B,i,N]);const X=(e,r)=>e.endsWith("/")?e+r:`${e}/${r}`,oe=i&&b(i),q=w.trim().toLowerCase(),Q=(e,r)=>{var c;if(!q||r.name.toLowerCase().includes(q))return!0;if(!r.dir)return!1;const n=X(e,r.name),s=(c=v.current.get(n))==null?void 0:c.children;return(s==null?void 0:s.some(m=>Q(n,m)))??!1},U=(e,r,n)=>r.filter(s=>Q(e,s)).map(s=>{const c=X(e,s.name);if(s.dir){const h=v.current.get(c),x=(h==null?void 0:h.expanded)??!1;return t.jsxs("div",{children:[t.jsxs("div",{className:"tree-row",onClick:()=>K(c),style:{paddingLeft:6+n*12},children:[t.jsx("span",{className:"tree-disclosure","aria-hidden":"true",children:h!=null&&h.loading?t.jsx(_,{className:"tree-spin",size:13}):x?t.jsx(S,{size:13}):t.jsx(ee,{size:13})}),t.jsx("span",{className:"tree-entry-icon tree-folder-icon","aria-hidden":"true",children:x?t.jsx(te,{size:16}):t.jsx(T,{size:16})}),t.jsx("span",{className:"tree-entry-name",children:s.name})]}),x&&(h.error?t.jsx("div",{className:"tree-error",role:"alert",style:{paddingLeft:22+n*12},children:h.error}):h.children?U(c,h.children,n+1):t.jsx("div",{className:"tree-row",style:{paddingLeft:22+n*12,color:"#556"},children:"…"}))]},c)}const m=we(s.name),E=m.icon;return t.jsxs("div",{className:"tree-row","data-tree-path":c,"data-selected":c===oe?"1":void 0,onClick:()=>f(c),title:`${m.label} · ${c} · ${re(s.size)}`,style:{paddingLeft:6+n*12},children:[t.jsx("span",{className:"tree-disclosure","aria-hidden":"true"}),t.jsx("span",{className:"tree-entry-icon",style:{color:m.color},"aria-hidden":"true",children:t.jsx(E,{size:16,strokeWidth:1.8})}),t.jsx("span",{className:"tree-entry-name",children:s.name}),t.jsx("span",{className:"tree-size",children:re(s.size)})]},c)});if(!F)return t.jsx("div",{style:{padding:14,fontSize:12,color:"#556"},children:$?l?"等待终端目录…":"连接中…":"…"});const d=v.current.get(F.path);return t.jsxs("div",{className:"tree-scroll",ref:Z,children:[t.jsxs("div",{className:"tree-location",children:[t.jsx("input",{value:O,onChange:e=>P(e.target.value),onKeyDown:e=>{e.key==="Enter"&&J()},placeholder:"输入目录路径","aria-label":"文件树目录路径",spellCheck:!1}),t.jsx("button",{tabIndex:-1,onClick:J,title:"定位目录","aria-label":"定位目录",children:t.jsx(Re,{size:14,"aria-hidden":"true"})}),t.jsx("button",{tabIndex:-1,onClick:ce,title:"跟随终端目录","aria-label":"跟随终端目录","data-active":$?"1":void 0,children:t.jsx(Ie,{size:14,"aria-hidden":"true"})})]}),t.jsxs("div",{className:"tree-filter",children:[t.jsx(pe,{size:14,"aria-hidden":"true"}),t.jsx("input",{value:w,onChange:e=>A(e.target.value),placeholder:"筛选已加载文件","aria-label":"筛选文件树"}),w&&t.jsx("button",{tabIndex:-1,onClick:()=>A(""),"aria-label":"清除筛选",children:t.jsx(Le,{size:13,"aria-hidden":"true"})})]}),t.jsxs("div",{className:"tree-row",onClick:()=>K(F.path),children:[t.jsx("span",{className:"tree-disclosure","aria-hidden":"true",children:d!=null&&d.loading?t.jsx(_,{className:"tree-spin",size:13}):d!=null&&d.expanded?t.jsx(S,{size:13}):t.jsx(ee,{size:13})}),t.jsx("span",{className:"tree-entry-icon tree-folder-icon","aria-hidden":"true",children:d!=null&&d.expanded?t.jsx(te,{size:16}):t.jsx(T,{size:16})}),t.jsx("span",{className:"tree-entry-name",style:{direction:"rtl",textAlign:"left"},children:F.path})]}),(d==null?void 0:d.expanded)&&(d.error?t.jsx("div",{className:"tree-error",role:"alert",children:d.error}):d.children?U(F.path,d.children,1):t.jsx("div",{className:"tree-row",style:{paddingLeft:24,color:"#556"},children:"…"}))]})}export{Ze as default};
|