@saluzi/saluzi-edu 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +56 -56
- package/dist/rcs-web/assets/{AdminPanel-XUPCFYy3.js → AdminPanel-CpzAO2vZ.js} +1 -1
- package/dist/rcs-web/assets/{ArtifactView-DNXqmMry.js → ArtifactView-CEyKbOJh.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ArtifactsGallery-TqoBn1Gk.js → dist/rcs-web/assets/ArtifactsGallery-B_JcCYh1.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Claim-DiftF6v2.js → dist/rcs-web/assets/Claim-CGxjGaui.js} +1 -1
- package/dist/rcs-web/assets/{Dashboard-jHKJZ6t_.js → Dashboard-DCq-h_y9.js} +2 -2
- package/dist/rcs-web/assets/{Join-BwIxg7cf.js → Join-BM43XjA0.js} +1 -1
- package/dist/rcs-web/assets/{Login-B3RpkrIW.js → Login-CPx4Dc28.js} +1 -1
- package/dist/rcs-web/assets/{Register-D-P_EHZt.js → Register-BV3xfUvd.js} +1 -1
- package/dist/rcs-web/assets/SessionDetail-DgMDo7Ge.js +88 -0
- package/dist/rcs-web/assets/{SessionVisibilityBadge-1GnXHTQ2.js → SessionVisibilityBadge-CvqFRTea.js} +1 -1
- package/dist/rcs-web/assets/{Setup-Dgwde_jD.js → Setup-GfWdRpvh.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-BfoPJPl3.js → ShareLanding-BuEXTqqz.js} +1 -1
- package/dist/rcs-web/assets/{TeamCreate-B_Us0Z-O.js → TeamCreate-DalKoyLy.js} +1 -1
- package/dist/rcs-web/assets/{TeamDetail-CRfnzqpF.js → TeamDetail-DevkNiHQ.js} +2 -2
- package/dist/rcs-web/assets/{TeamList-Bp9gOv8_.js → TeamList-B1pHxRaK.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-G2gI007X.js → TeamSettings-DWnEJMTx.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-Df2D_8d5.js → UserSearchInput-DgktGnh2.js} +1 -1
- package/dist/rcs-web/assets/{UserSettings-D4fd1xf3.js → UserSettings-DPhvsn9k.js} +1 -1
- package/dist/rcs-web/assets/{arc-CBGdsIh-.js → arc-C7foUDWz.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-DorxkDDi.js → dist/rcs-web/assets/architectureDiagram-3BPJPVTR-BzsYecpv.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-D2NfI8QU.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-D4BSEcZT.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-D8POOSxc.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-CIap7aYJ.js} +1 -1
- package/dist/rcs-web/assets/channel-69qfoCOr.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-94J74-8z.js → chunk-2J33WTMH-s9V4oCUf.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-BBcpBLxW.js → chunk-4BX2VUAB-CJrYwRaR.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-BnVNN6wz.js → chunk-55IACEB6-D8swZDnP.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BFA9U6Tt.js → dist/rcs-web/assets/chunk-727SXJPM-vJ6LjIbB.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-CbXGEiY2.js → dist/rcs-web/assets/chunk-AQP2D5EJ-COrMlHZr.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-CzvDBtBa.js → chunk-FMBD7UC4-0lUT-961.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-sjvYji_m.js → chunk-ND2GUHAM-BWqVDbg4.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-WiDDkzYa.js → chunk-QZHKN3VN-CfeMmsaw.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DihFTUAb.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DihFTUAb.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-Bx7lAeeI.js → code-block-IT6T5CEO-FipRU7Gt.js} +1 -1
- package/dist/rcs-web/assets/{copy-CM8iJdCD.js → copy-RtDWH7m7.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-CC3LEak7.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-wlwIwiSf.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-2AKIj2nY.js → dagre-BM42HDAG-FlvB-WBQ.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-D7x_-74x.js → diagram-2AECGRRQ-Dd5G25-Q.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-BM5476us.js → diagram-5GNKFQAL-CnS79Wiq.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-DS18dM8U.js → diagram-KO2AKTUF-oeffrVzV.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-BGetNvFW.js → diagram-LMA3HP47-Dc4rRllI.js} +1 -1
- package/dist/rcs-web/assets/{diagram-OG6HWLK6-ChYQZDqt.js → diagram-OG6HWLK6-QYKwztsm.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/dialog-DYv3nFNt.js → dist/rcs-web/assets/dialog-C6bSop75.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-HnXSUhgQ.js → dist/rcs-web/assets/erDiagram-TEJ5UH35-CFoDAbeH.js} +1 -1
- package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-B_hKhp1A.js → flowDiagram-I6XJVG4X-zOHsjkHO.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-8wN2M_TF.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-DmdYR8vQ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-fPAxO3fb.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-ChNq0nxK.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-BcwXADoa.js → infoDiagram-5YYISTIA-CTOfXwsH.js} +1 -1
- package/dist/rcs-web/assets/{ishikawaDiagram-YF4QCWOH-_12LFXDQ.js → ishikawaDiagram-YF4QCWOH-AbFaqfWq.js} +1 -1
- package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-BQauj_0q.js → journeyDiagram-JHISSGLW-BZ5YDbY5.js} +1 -1
- package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-DGngaCZy.js → kanban-definition-UN3LZRKU-2ujiDLTJ.js} +1 -1
- package/dist/rcs-web/assets/{linear-9Tvqv7kO.js → linear-hvc2NcTZ.js} +1 -1
- package/dist/rcs-web/assets/{main-CRNlYxLI.js → main-2KqxLOVo.js} +4 -4
- package/dist/rcs-web/assets/main-Blk5Y8OW.css +1 -0
- package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-2wv7TFHR.js → dist/rcs-web/assets/mermaid-VLURNSYL-CjE066pc.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-BsvpTs-b.js → mermaid.core-D0z5iBed.js} +5 -5
- package/{packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-D0-ESz0i.js → dist/rcs-web/assets/mindmap-definition-RKZ34NQL-DN_a_x4Q.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-DCWjJaQM.js → pieDiagram-4H26LBE5-EaZYytph.js} +1 -1
- package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-uSBEAi2X.js → quadrantDiagram-W4KKPZXB-BbYaZQ_j.js} +1 -1
- package/dist/rcs-web/assets/{refresh-cw-kJbb11GS.js → refresh-cw-2QNtciSF.js} +1 -1
- package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-WUpK9KLE.js → requirementDiagram-4Y6WPE33-sQpG_uMR.js} +1 -1
- package/dist/rcs-web/assets/{sankeyDiagram-5OEKKPKP-D0H9ppQi.js → sankeyDiagram-5OEKKPKP-Dk-ywMbO.js} +1 -1
- package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-DQNjsp_9.js → sequenceDiagram-3UESZ5HK-B8kXKWV0.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-DJwnYmKo.js → stateDiagram-AJRCARHV-BIjc-tAY.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-DvUiurqW.js → stateDiagram-v2-BHNVJYJU-BjJyk52d.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-gknKo8gT.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-9Myr5rlZ.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-DB2f8KRG.js → vennDiagram-CIIHVFJN-B_0p3XFw.js} +1 -1
- package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-C0IQ4e5h.js → wardleyDiagram-YWT4CUSO-JKVEgrM5.js} +1 -1
- package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-DKeWjAUB.js → xychartDiagram-2RQKCTM6-DUPPleBK.js} +1 -1
- package/dist/rcs-web/index.html +2 -2
- package/package.json +1 -1
- package/packages/remote-control-server/src/__tests__/control-watchdog.test.ts +129 -0
- package/packages/remote-control-server/src/__tests__/routes.test.ts +41 -0
- package/packages/remote-control-server/src/__tests__/sse-writer.test.ts +39 -4
- package/packages/remote-control-server/src/__tests__/work-dispatch.test.ts +44 -0
- package/packages/remote-control-server/src/__tests__/ws-handler.test.ts +185 -1
- package/packages/remote-control-server/src/routes/web/sessions.ts +5 -1
- package/packages/remote-control-server/src/services/disconnect-monitor.ts +5 -0
- package/packages/remote-control-server/src/services/transport.ts +89 -0
- package/packages/remote-control-server/src/services/work-dispatch.ts +56 -1
- package/packages/remote-control-server/src/transport/sse-writer.ts +16 -2
- package/packages/remote-control-server/src/transport/ws-handler.ts +85 -20
- package/packages/remote-control-server/web/dist/assets/{AdminPanel-XUPCFYy3.js → AdminPanel-CpzAO2vZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ArtifactView-DNXqmMry.js → ArtifactView-CEyKbOJh.js} +1 -1
- package/{dist/rcs-web/assets/ArtifactsGallery-TqoBn1Gk.js → packages/remote-control-server/web/dist/assets/ArtifactsGallery-B_JcCYh1.js} +1 -1
- package/{dist/rcs-web/assets/Claim-DiftF6v2.js → packages/remote-control-server/web/dist/assets/Claim-CGxjGaui.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Dashboard-jHKJZ6t_.js → Dashboard-DCq-h_y9.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{Join-BwIxg7cf.js → Join-BM43XjA0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Login-B3RpkrIW.js → Login-CPx4Dc28.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Register-D-P_EHZt.js → Register-BV3xfUvd.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-DgMDo7Ge.js +88 -0
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-1GnXHTQ2.js → SessionVisibilityBadge-CvqFRTea.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Setup-Dgwde_jD.js → Setup-GfWdRpvh.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-BfoPJPl3.js → ShareLanding-BuEXTqqz.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamCreate-B_Us0Z-O.js → TeamCreate-DalKoyLy.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamDetail-CRfnzqpF.js → TeamDetail-DevkNiHQ.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{TeamList-Bp9gOv8_.js → TeamList-B1pHxRaK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-G2gI007X.js → TeamSettings-DWnEJMTx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-Df2D_8d5.js → UserSearchInput-DgktGnh2.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSettings-D4fd1xf3.js → UserSettings-DPhvsn9k.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-CBGdsIh-.js → arc-C7foUDWz.js} +1 -1
- package/{dist/rcs-web/assets/architectureDiagram-3BPJPVTR-DorxkDDi.js → packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-BzsYecpv.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-D2NfI8QU.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-D4BSEcZT.js} +1 -1
- package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-D8POOSxc.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-CIap7aYJ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-69qfoCOr.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-94J74-8z.js → chunk-2J33WTMH-s9V4oCUf.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-BBcpBLxW.js → chunk-4BX2VUAB-CJrYwRaR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BnVNN6wz.js → chunk-55IACEB6-D8swZDnP.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-BFA9U6Tt.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-vJ6LjIbB.js} +1 -1
- package/{dist/rcs-web/assets/chunk-AQP2D5EJ-CbXGEiY2.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-COrMlHZr.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-CzvDBtBa.js → chunk-FMBD7UC4-0lUT-961.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-sjvYji_m.js → chunk-ND2GUHAM-BWqVDbg4.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-WiDDkzYa.js → chunk-QZHKN3VN-CfeMmsaw.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DihFTUAb.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DihFTUAb.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-Bx7lAeeI.js → code-block-IT6T5CEO-FipRU7Gt.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-CM8iJdCD.js → copy-RtDWH7m7.js} +1 -1
- package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-CC3LEak7.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-wlwIwiSf.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-2AKIj2nY.js → dagre-BM42HDAG-FlvB-WBQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-D7x_-74x.js → diagram-2AECGRRQ-Dd5G25-Q.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-BM5476us.js → diagram-5GNKFQAL-CnS79Wiq.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-DS18dM8U.js → diagram-KO2AKTUF-oeffrVzV.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-BGetNvFW.js → diagram-LMA3HP47-Dc4rRllI.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-ChYQZDqt.js → diagram-OG6HWLK6-QYKwztsm.js} +1 -1
- package/{dist/rcs-web/assets/dialog-DYv3nFNt.js → packages/remote-control-server/web/dist/assets/dialog-C6bSop75.js} +1 -1
- package/{dist/rcs-web/assets/erDiagram-TEJ5UH35-HnXSUhgQ.js → packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-CFoDAbeH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-B_hKhp1A.js → flowDiagram-I6XJVG4X-zOHsjkHO.js} +1 -1
- package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-8wN2M_TF.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-DmdYR8vQ.js} +1 -1
- package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-fPAxO3fb.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-ChNq0nxK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-BcwXADoa.js → infoDiagram-5YYISTIA-CTOfXwsH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ishikawaDiagram-YF4QCWOH-_12LFXDQ.js → ishikawaDiagram-YF4QCWOH-AbFaqfWq.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-BQauj_0q.js → journeyDiagram-JHISSGLW-BZ5YDbY5.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-DGngaCZy.js → kanban-definition-UN3LZRKU-2ujiDLTJ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-9Tvqv7kO.js → linear-hvc2NcTZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-CRNlYxLI.js → main-2KqxLOVo.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/main-Blk5Y8OW.css +1 -0
- package/{dist/rcs-web/assets/mermaid-VLURNSYL-2wv7TFHR.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-CjE066pc.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-BsvpTs-b.js → mermaid.core-D0z5iBed.js} +5 -5
- package/{dist/rcs-web/assets/mindmap-definition-RKZ34NQL-D0-ESz0i.js → packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-DN_a_x4Q.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-DCWjJaQM.js → pieDiagram-4H26LBE5-EaZYytph.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-uSBEAi2X.js → quadrantDiagram-W4KKPZXB-BbYaZQ_j.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{refresh-cw-kJbb11GS.js → refresh-cw-2QNtciSF.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-WUpK9KLE.js → requirementDiagram-4Y6WPE33-sQpG_uMR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{sankeyDiagram-5OEKKPKP-D0H9ppQi.js → sankeyDiagram-5OEKKPKP-Dk-ywMbO.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-DQNjsp_9.js → sequenceDiagram-3UESZ5HK-B8kXKWV0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-DJwnYmKo.js → stateDiagram-AJRCARHV-BIjc-tAY.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-DvUiurqW.js → stateDiagram-v2-BHNVJYJU-BjJyk52d.js} +1 -1
- package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-gknKo8gT.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-9Myr5rlZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-DB2f8KRG.js → vennDiagram-CIIHVFJN-B_0p3XFw.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-C0IQ4e5h.js → wardleyDiagram-YWT4CUSO-JKVEgrM5.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-DKeWjAUB.js → xychartDiagram-2RQKCTM6-DUPPleBK.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +2 -2
- package/dist/rcs-web/assets/SessionDetail-DpDoV99q.js +0 -88
- package/dist/rcs-web/assets/channel-CtQd38gZ.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DAkylD2J.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DAkylD2J.js +0 -1
- package/dist/rcs-web/assets/main-C11d2HlT.css +0 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-DpDoV99q.js +0 -88
- package/packages/remote-control-server/web/dist/assets/channel-CtQd38gZ.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DAkylD2J.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DAkylD2J.js +0 -1
- package/packages/remote-control-server/web/dist/assets/main-C11d2HlT.css +0 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var vs=Object.defineProperty;var _s=(n,t,s)=>t in n?vs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var T=(n,t,s)=>_s(n,typeof t!="symbol"?t+"":t,s);import{e as c,j as e}from"./vendor-DE_-CLIE.js";import{ai as D,a1 as Ss,aq as jt,ap as wt,as as Cs,ar as et,ac as Es,am as Z,ab as W,a4 as Ts,a9 as Ms,az as Rs,z as Bt,g as kt,al as Ht,L as pe,G as As,aj as Re,d as he,S as tt,M as $s,v as Is,X as qs,y as Ps,ak as H,ag as xe,ax as Nt,a5 as Ds,Q as Os,a8 as Us,aC as Wt,aw as v,A as Fs,an as Ls,at as Bs,au as Hs,J as Ws,ay as zs,b as Ks,W as vt,a6 as Qs,E as zt,P as Vs,F as Gs,c as Ys,C as Js,a0 as Xs,D as Zs,a as en,r as Ae,t as $e,x as tn,f as Ie,e as qe,s as Pe,p as sn,B as nn}from"./main-2KqxLOVo.js";import{g as rn}from"./workerType-Bd-zteMi.js";import{D as fe,a as ge,c as ye,d as be,b as an}from"./dialog-C6bSop75.js";import{R as on}from"./refresh-cw-2QNtciSF.js";import{C as ln}from"./copy-RtDWH7m7.js";import{E as cn,A as dn}from"./ArtifactsGallery-B_JcCYh1.js";import{S as un}from"./SessionVisibilityBadge-CvqFRTea.js";import{U as mn}from"./UserSearchInput-DgktGnh2.js";import{S as xn,b as pn}from"./notifications-D9_SRqI0.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
|
|
2
|
+
* @license lucide-react v0.555.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const hn=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],fn=D("activity",hn);/**
|
|
7
|
+
* @license lucide-react v0.555.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const gn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],yn=D("arrow-left",gn);/**
|
|
12
|
+
* @license lucide-react v0.555.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const bn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Kt=D("chevron-right",bn);/**
|
|
17
|
+
* @license lucide-react v0.555.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const jn=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Qt=D("cpu",jn);/**
|
|
22
|
+
* @license lucide-react v0.555.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const wn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],kn=D("gauge",wn);/**
|
|
27
|
+
* @license lucide-react v0.555.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Nn=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],vn=D("hash",Nn);/**
|
|
32
|
+
* @license lucide-react v0.555.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const _n=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Sn=D("info",_n);/**
|
|
37
|
+
* @license lucide-react v0.555.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const Cn=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Vt=D("message-circle-question-mark",Cn);/**
|
|
42
|
+
* @license lucide-react v0.555.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const En=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],Tn=D("message-square-text",En);/**
|
|
47
|
+
* @license lucide-react v0.555.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Mn=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Rn=D("play",Mn);/**
|
|
52
|
+
* @license lucide-react v0.555.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const An=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Gt=D("plug",An);/**
|
|
57
|
+
* @license lucide-react v0.555.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const $n=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],In=D("server-cog",$n);/**
|
|
62
|
+
* @license lucide-react v0.555.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const qn=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Yt=D("settings-2",qn);/**
|
|
67
|
+
* @license lucide-react v0.555.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const Pn=[["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"}]],Dn=D("share-2",Pn);/**
|
|
72
|
+
* @license lucide-react v0.555.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const On=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Un=D("shield-check",On);/**
|
|
77
|
+
* @license lucide-react v0.555.0 - ISC
|
|
78
|
+
*
|
|
79
|
+
* This source code is licensed under the ISC license.
|
|
80
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
+
*/const Fn=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ln=D("triangle-alert",Fn);function Jt(){return{tasks:{}}}const _t=3e4;function Me(n){const t=n.trim();if(!t)return"agent";const s=t.split(/\s+/).slice(0,2).join(" ");return s.length>40?s.slice(0,40)+"…":s}function Bn(n,t){var l,m,b,h,g,j,N,E,u,i,p,y;const s=t.subtype;if(s!=="task_started"&&s!=="task_progress"&&s!=="task_notification")return n;const r=t.task_id;if(!r)return n;const o=Date.now(),d=n.tasks[r];if(s==="task_started"){if(d)return{tasks:{...n.tasks,[r]:{...d,description:t.description??d.description,name:Me(t.description??d.description),taskType:t.task_type??d.taskType,workflowName:t.workflow_name??d.workflowName,prompt:t.prompt??d.prompt,toolUseId:t.tool_use_id??d.toolUseId,status:"running",startTime:o,evictAfter:void 0}}};const f=t.description??"";return{tasks:{...n.tasks,[r]:{taskId:r,name:Me(f),description:f,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:o}}}}if(s==="task_progress"){if(!d){const f=t.description??"";return{tasks:{...n.tasks,[r]:{taskId:r,name:Me(f),description:f,toolUseId:t.tool_use_id,status:"running",startTime:o,tokenCount:(l=t.usage)==null?void 0:l.total_tokens,toolUseCount:(m=t.usage)==null?void 0:m.tool_uses,durationMs:(b=t.usage)==null?void 0:b.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...n.tasks,[r]:{...d,description:t.description??d.description,tokenCount:((h=t.usage)==null?void 0:h.total_tokens)??d.tokenCount,toolUseCount:((g=t.usage)==null?void 0:g.tool_uses)??d.toolUseCount,durationMs:((j=t.usage)==null?void 0:j.duration_ms)??d.durationMs,lastToolName:t.last_tool_name??d.lastToolName,summary:t.summary??d.summary}}}}return d?{tasks:{...n.tasks,[r]:{...d,status:t.status??"completed",endTime:o,finalSummary:t.summary??d.finalSummary,outputFile:t.output_file??d.outputFile,tokenCount:((i=t.usage)==null?void 0:i.total_tokens)??d.tokenCount,toolUseCount:((p=t.usage)==null?void 0:p.tool_uses)??d.toolUseCount,durationMs:((y=t.usage)==null?void 0:y.duration_ms)??d.durationMs,evictAfter:o+_t}}}:{tasks:{...n.tasks,[r]:{taskId:r,name:Me(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:o,endTime:o,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(E=t.usage)==null?void 0:E.tool_uses,durationMs:(u=t.usage)==null?void 0:u.duration_ms,evictAfter:o+_t}}}}function Hn(n,t=Date.now()){return Object.values(n.tasks).filter(s=>s.evictAfter===void 0||s.evictAfter>t).sort((s,r)=>s.startTime-r.startTime)}function Wn(n){if(!n||typeof n!="object"||Array.isArray(n))return null;const t=n,s={file_search:t.file_search===!0,clear:t.clear===!0,set_max_thinking_tokens:t.set_max_thinking_tokens===!0,get_context_usage:t.get_context_usage===!0,stop_task:t.stop_task===!0,set_model:t.set_model===!0,set_permission_mode:t.set_permission_mode===!0,interrupt:t.interrupt===!0,end_session:t.end_session===!0,mcp_management:t.mcp_management===!0,remote_settings:t.remote_settings===!0,rewind:t.rewind===!0,set_effort:t.set_effort===!0,side_question:t.side_question===!0};return Object.values(s).some(Boolean)?s:null}function St(n,t){const s=[];if(Array.isArray(n)){for(const r of n){if(!r||typeof r!="object")continue;const o=r;if(typeof o.name!="string"||!o.name)continue;const d=o.type==="prompt"||o.type==="local"||o.type==="local-jsx"?o.type:void 0;s.push({name:o.name,...typeof o.description=="string"&&o.description?{description:o.description}:{},...typeof o.argumentHint=="string"&&o.argumentHint?{argumentHint:o.argumentHint}:{},...d?{type:d}:{}})}if(s.length>0)return s}if(Array.isArray(t))for(const r of t)typeof r=="string"&&r&&s.push({name:r});return s}function Ct(n){const t=n.raw&&typeof n.raw=="object"&&!Array.isArray(n.raw)?n.raw:n,s=St(t.slash_command_details??n.slash_command_details,t.slash_commands??n.slash_commands),r=St(t.skill_details??n.skill_details,t.skills??n.skills),o=Wn(t.remote_capabilities??n.remote_capabilities);return s.length===0&&r.length===0&&!o?null:{commands:s,skills:r,capabilities:o}}class zn{constructor(t){T(this,"listeners",new Set);T(this,"stateListeners",new Set);T(this,"eventSource",null);T(this,"sessionId",null);T(this,"_lastSeqNum",0);T(this,"lastFrameAt",0);T(this,"firstEventAfterOpen",!1);T(this,"watchdogTimer",null);T(this,"reconnectTimer",null);T(this,"reconnectAttempts",0);T(this,"_state","idle");T(this,"opts");this.opts={stallThresholdMs:45e3,watchdogTickMs:5e3,reconnectBaseDelayMs:1e3,reconnectMaxDelayMs:15e3,maxReconnectAttempts:6,...t}}get state(){return this._state}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onStateChange(t){return this.stateListeners.add(t),()=>this.stateListeners.delete(t)}connect(t){this.stopReconnectTimer(),this.reconnectAttempts=0,this.sessionId=t,this.openStream()}openStream(){if(this.closeStream(),!this.sessionId)return;this.setState("connecting");const t=this._lastSeqNum>0?`/web/sessions/${this.sessionId}/events?fromSeqNum=${this._lastSeqNum}`:`/web/sessions/${this.sessionId}/events`,s=new EventSource(t,{withCredentials:!0});this.eventSource=s,this.lastFrameAt=Date.now(),this.firstEventAfterOpen=!0,s.addEventListener("open",()=>{this.lastFrameAt=Date.now(),this.reconnectAttempts=0,this.firstEventAfterOpen=!0,this.setState("open")}),s.addEventListener("ping",()=>{this.lastFrameAt=Date.now()}),s.addEventListener("message",r=>{this.lastFrameAt=Date.now();try{const o=JSON.parse(r.data);if(this.firstEventAfterOpen&&(this.firstEventAfterOpen=!1,typeof o.seqNum=="number"&&o.seqNum<this._lastSeqNum&&(this._lastSeqNum=o.seqNum-1,this.notifyResync())),o.seqNum!==void 0&&o.seqNum<=this._lastSeqNum)return;o.seqNum!==void 0&&(this._lastSeqNum=o.seqNum);for(const d of this.listeners)d(o)}catch{}}),s.addEventListener("error",()=>{s.readyState===EventSource.CLOSED&&this.scheduleReconnect()}),this.startWatchdog()}disconnect(){this.sessionId=null,this.stopReconnectTimer(),this.closeStream(),this._lastSeqNum=0,this.reconnectAttempts=0,this.setState("idle")}closeStream(){this.stopWatchdog(),this.eventSource&&(this.eventSource.close(),this.eventSource=null)}startWatchdog(){this.stopWatchdog(),this.watchdogTimer=setInterval(()=>{const t=this.eventSource;!t||t.readyState!==EventSource.OPEN||Date.now()-this.lastFrameAt<=this.opts.stallThresholdMs||this.scheduleReconnect()},this.opts.watchdogTickMs)}stopWatchdog(){this.watchdogTimer&&(clearInterval(this.watchdogTimer),this.watchdogTimer=null)}stopReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}scheduleReconnect(){if(this.reconnectTimer||!this.sessionId)return;if(this.closeStream(),this.reconnectAttempts++,this.reconnectAttempts>this.opts.maxReconnectAttempts){this.setState("failed");return}this.setState("reconnecting");const t=Math.min(this.opts.reconnectBaseDelayMs*2**(this.reconnectAttempts-1),this.opts.reconnectMaxDelayMs),s=Math.max(0,t+t*.25*(2*Math.random()-1));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnect()},s)}async reconnect(){this.sessionId&&(await Rs(),this.sessionId&&this.openStream())}setState(t){if(this._state!==t){this._state=t;for(const s of this.stateListeners)s(t,{})}}notifyResync(){for(const t of this.stateListeners)t(this._state,{resync:!0})}}const ee=new zn;function Et(n){if(typeof n.content=="string")return n.content;if(n.message&&typeof n.message=="object"){const t=n.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(s=>s.type==="text"&&typeof s.text=="string").map(s=>s.text).join("")}return""}function Tt(n,t){for(let s=n.length-1;s>=0;s--){const r=n[s];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return s}return-1}const Xe="streaming-";function Kn(n){const t=n.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const s=[];for(const r of t.content)if((r==null?void 0:r.type)==="thinking"){const o=typeof r.thinking=="string"&&r.thinking||typeof r.text=="string"&&r.text||"";o&&s.push(o)}return s.join("")}function Mt(n){return n.filter(t=>typeof t.subject=="string"&&t.subject).map(t=>({content:t.subject,priority:"medium",status:t.status==="completed"?"completed":t.status==="in_progress"?"in_progress":"pending"}))}function Rt(n){if(!n||typeof n!="object")return"";const t=n;if(typeof t.target_event_id=="string"&&t.target_event_id)return t.target_event_id;const s=t.raw;if(s&&typeof s=="object"&&!Array.isArray(s)){const r=s.target_event_id;if(typeof r=="string"&&r)return r}return""}class Qn{constructor(t,s,r){T(this,"sessionId");T(this,"setEntries");T(this,"unsub",null);T(this,"unsubState",null);T(this,"onStatusChange");T(this,"onError");T(this,"onPermissionRequest");T(this,"onModelsStateChange");T(this,"onSubagentUpdate");T(this,"onControlResponse");T(this,"onPermissionModeChange");T(this,"onUsageChange");T(this,"onElicitationRequest");T(this,"onWorkerInfoChange");T(this,"subagentState",Jt());T(this,"seenUuids",new Set);T(this,"seenToolCallIds",new Set);T(this,"pendingControlRequests",new Map);T(this,"turnEnded",!1);T(this,"userSinceTurnEnd",!1);T(this,"closed",!1);this.sessionId=t,this.setEntries=s,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate,this.onControlResponse=r==null?void 0:r.onControlResponse,this.onPermissionModeChange=r==null?void 0:r.onPermissionModeChange,this.onUsageChange=r==null?void 0:r.onUsageChange,this.onElicitationRequest=r==null?void 0:r.onElicitationRequest,this.onWorkerInfoChange=r==null?void 0:r.onWorkerInfoChange}markClosed(){this.closed=!0}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var g,j,N,E,u;const{events:t}=await Ss(this.sessionId);if(!t||t.length===0)return;const s=[];let r=null;const o=()=>{r&&(s.push(r),r=null)};for(const i of t){const p=i.payload||{},y=p.uuid;if(typeof y=="string"&&y&&this.seenUuids.add(y),i.type==="tool_use"){const f=p.tool_call_id;typeof f=="string"&&f&&this.seenToolCallIds.add(f)}if(i.type==="user"){if(i.direction==="inbound")continue;o();const f=Et(p);f&&s.push({type:"user_message",id:i.id||`hist-user-${s.length}`,content:f})}else if(i.type==="assistant"){o();const f=Et(p);if(jt(f))continue;const w=[],C=p.message;if(C&&typeof C=="object"&&Array.isArray(C.content)){for(const A of C.content)if(A.type==="tool_use"){const $=A.id;$&&this.seenToolCallIds.add($),w.push({type:"tool_call",toolCall:{id:$||`hist-tool-${s.length}`,title:A.name||"tool",status:"complete",rawInput:A.input||{}}})}}if(f||w.length>0){r={type:"assistant_message",id:i.id||`hist-asst-${s.length}`,chunks:f?[{type:"message",text:f}]:[]},s.push(r);for(const A of w)s.push(A);r=null}}else if(i.type==="conversation_rewound"){const f=Rt(p);if(f){const w=s.findIndex(C=>wt(C)===f);w>=0&&(s.length=w)}}else if(i.type==="tool_use"){const f=p,w={type:"tool_call",toolCall:{id:f.tool_call_id||`hist-tool-${s.length}`,title:f.tool_name||"tool",status:"complete",rawInput:f.tool_input||{}}};s.push(w)}else if(i.type==="tool_result"){const f=p,w=Tt(s,f.tool_call_id||"");if(w>=0){const C=s[w];s[w]={type:"tool_call",toolCall:{...C.toolCall,rawOutput:{output:f.content||f.output||""}}}}}}o();let d=null;for(const i of t){if(i.type!=="task_state")continue;const p=i.payload||{};Array.isArray(p.tasks)&&(d=p.tasks)}if(d&&d.length>0){const i=Mt(d);i.length>0&&s.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:i})}this.setEntries(s);let l=null,m=null,b=null,h=null;for(const i of t){const p=i.payload||{};if(i.type==="user"?h="user":(i.type==="result"||i.type==="result_success"||i.type==="interrupt")&&(h="turn_end"),i.type==="system"&&(p.subtype==="init"||((g=p.raw)==null?void 0:g.subtype)==="init")&&(m=Ct(p)),i.type==="models_state"){const y=p.raw,f=y&&typeof y=="object"?y.models_state:p.models_state;f&&Array.isArray(f.availableModels)&&typeof f.currentModelId=="string"&&(l=f)}else if(i.type==="result"||i.type==="result_success"){const y=p.usage,f=typeof p.total_cost_usd=="number"?p.total_cost_usd:null;(y||f!==null)&&(b={inputTokens:((y==null?void 0:y.input_tokens)??0)+((y==null?void 0:y.cache_read_input_tokens)??0)+((y==null?void 0:y.cache_creation_input_tokens)??0),outputTokens:(y==null?void 0:y.output_tokens)??0,totalCostUsd:f})}}l&&((j=this.onModelsStateChange)==null||j.call(this,l)),m&&((N=this.onWorkerInfoChange)==null||N.call(this,m)),b&&((E=this.onUsageChange)==null||E.call(this,b)),this.turnEnded=h==="turn_end",this.userSinceTurnEnd=h==="user",this.turnEnded&&!this.closed&&((u=this.onStatusChange)==null||u.call(this,"idle"))}connectSSE(){ee.connect(this.sessionId),this.unsub=ee.onEvent(t=>this.handleEvent(t)),this.unsubState=ee.onStateChange((t,s)=>{s.resync&&!this.closed&&this.loadHistory().catch(()=>{})})}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),this.unsubState&&(this.unsubState(),this.unsubState=null),ee.disconnect()}handleEvent(t){var o,d,l,m,b,h,g,j,N,E;const s=t.type,r=t.payload||{};switch(s){case"user":{this.userSinceTurnEnd=!0;break}case"assistant":{const u=r.uuid;if(typeof u=="string"&&u){if(this.seenUuids.has(u))break;this.seenUuids.add(u)}const i=typeof r.content=="string"?r.content:"";if(jt(i))break;const p=Kn(r);this.setEntries(f=>{const w=f[f.length-1];if((w==null?void 0:w.type)==="assistant_message"&&w.id.startsWith(Xe))return[...f.slice(0,-1),{...w,id:`assistant-${Date.now()}`,chunks:[...p?[{type:"thought",text:p}]:[],{type:"message",text:i}]}];if((w==null?void 0:w.type)==="assistant_message"){const C=w.chunks[w.chunks.length-1];return(C==null?void 0:C.type)==="message"?[...f.slice(0,-1),{...w,chunks:[...w.chunks.slice(0,-1),{type:"message",text:C.text+i}]}]:[...f.slice(0,-1),{...w,chunks:[...w.chunks,{type:"message",text:i}]}]}if(i&&i.trim()||p){const C={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...p?[{type:"thought",text:p}]:[],...i?[{type:"message",text:i}]:[]]};return[...f,C]}return f});const y=r.message;if(y&&typeof y=="object"&&Array.isArray(y.content)){const f=y.content.filter(w=>w.type==="tool_use");for(const w of f){const C=w.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(C))continue;this.seenToolCallIds.add(C);const A={id:C,title:w.name||"tool",status:"running",rawInput:w.input||{}};this.setEntries($=>[...$,{type:"tool_call",toolCall:A}])}}break}case"tool_use":{const u=r,i=u.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(i))break;this.seenToolCallIds.add(i);const p={id:i,title:u.tool_name||"tool",status:"running",rawInput:u.tool_input||{}};this.setEntries(y=>[...y,{type:"tool_call",toolCall:p}]);break}case"tool_result":{const u=r,i=u.tool_call_id||"";this.setEntries(p=>{const y=Tt(p,i);if(y<0)return p;const f=p[y];return p.map((w,C)=>C===y?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:u.content||u.output||""}}}:w)});break}case"control_request":case"permission_request":{const u=r.request;if(u&&u.subtype==="can_use_tool"){const i=r.request_id||"",p=u.tool_name||"unknown",y=u.input||u.tool_input||{},f=u.description||"",w=Array.isArray(u.permission_suggestions)?u.permission_suggestions:[];this.setEntries(C=>{const A=[...C].reverse().findIndex($=>$.type==="tool_call");if(A>=0){const $=C.length-1-A,F=C[$];if(F.toolCall.status==="running")return C.map((V,G)=>G===$?{type:"tool_call",toolCall:{...F.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:i,options:[]}}}:V)}return C}),(o=this.onPermissionRequest)==null||o.call(this,{requestId:i,toolName:p,toolInput:y,description:f,suggestions:w})}else u&&u.subtype==="elicitation"&&((d=this.onElicitationRequest)==null||d.call(this,{requestId:r.request_id||"",serverName:u.mcp_server_name||"",message:u.message||"",mode:u.mode==="url"?"url":"form",url:typeof u.url=="string"?u.url:void 0,requestedSchema:u.requested_schema||void 0}));break}case"conversation_rewound":{const u=Rt(r);u&&this.setEntries(i=>{const p=i.findIndex(y=>wt(y)===u);return p===-1?i:i.slice(0,p)});break}case"session_status":{if(Cs(r)){this.setEntries([]);break}if(typeof r.status=="string"){if(et(r.status))this.closed=!0;else if(this.closed)break;if(r.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(l=this.onStatusChange)==null||l.call(this,r.status)}break}case"error":{const u=String(r.message||r.content||"Unknown error");(m=this.onError)==null||m.call(this,u);break}case"models_state":{const u=r.raw,i=typeof u=="object"&&u!==null?u.models_state:r.models_state;i&&Array.isArray(i.availableModels)&&typeof i.currentModelId=="string"&&((b=this.onModelsStateChange)==null||b.call(this,i));break}case"system":{const u=r.raw,i=u&&typeof u=="object"?u:r,p=typeof i.subtype=="string"?i.subtype:void 0;if(p==="task_started"||p==="task_progress"||p==="task_notification"){const f={subtype:p,task_id:typeof i.task_id=="string"?i.task_id:void 0,tool_use_id:typeof i.tool_use_id=="string"?i.tool_use_id:void 0,description:typeof i.description=="string"?i.description:void 0,task_type:typeof i.task_type=="string"?i.task_type:void 0,workflow_name:typeof i.workflow_name=="string"?i.workflow_name:void 0,prompt:typeof i.prompt=="string"?i.prompt:void 0,usage:i.usage&&typeof i.usage=="object"?i.usage:void 0,last_tool_name:typeof i.last_tool_name=="string"?i.last_tool_name:void 0,summary:typeof i.summary=="string"?i.summary:void 0,status:i.status==="completed"||i.status==="failed"||i.status==="stopped"?i.status:void 0,output_file:typeof i.output_file=="string"?i.output_file:void 0};this.subagentState=Bn(this.subagentState,f)}const y=typeof i.permissionMode=="string"?i.permissionMode:typeof r.permissionMode=="string"?r.permissionMode:null;if(y&&((h=this.onPermissionModeChange)==null||h.call(this,y)),p==="init"){const f=Ct(r);f&&((g=this.onWorkerInfoChange)==null||g.call(this,f))}break}case"control_response":{const u=r.response;if(u&&typeof u=="object"){const i=typeof u.request_id=="string"?u.request_id:"",p=typeof u.subtype=="string"?u.subtype:"";if(i){(j=this.onControlResponse)==null||j.call(this,{subtype:p,requestId:i,error:typeof u.error=="string"?u.error:void 0});const y=this.pendingControlRequests.get(i);y&&(this.pendingControlRequests.delete(i),y({data:p==="success"&&u.response&&typeof u.response=="object"?u.response:null,...p==="error"&&typeof u.error=="string"?{error:u.error}:{}}))}}break}case"stream_event":{const u=r.event;if(!u||typeof u.type!="string")break;if(u.type==="content_block_delta"){const i=u.delta;if(!i||typeof i.type!="string")break;const p=i.type==="text_delta"?"message":i.type==="thinking_delta"?"thought":null;if(!p)break;const y=i.text??i.thinking;if(typeof y!="string"||!y)break;this.appendStreamingDelta(p,y)}break}case"partial_assistant":{const u=typeof r.content=="string"?r.content:"";u&&this.appendStreamingDelta("message",u);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,this.closed||(N=this.onStatusChange)==null||N.call(this,"idle");const u=r.usage,i=typeof r.total_cost_usd=="number"?r.total_cost_usd:null;if(u||i!==null){const p=((u==null?void 0:u.input_tokens)??0)+((u==null?void 0:u.cache_read_input_tokens)??0)+((u==null?void 0:u.cache_creation_input_tokens)??0);(E=this.onUsageChange)==null||E.call(this,{inputTokens:p,outputTokens:(u==null?void 0:u.output_tokens)??0,totalCostUsd:i})}break}case"task_state":{const u=Array.isArray(r.tasks)?r.tasks:[];if(u.length===0)break;const i=Mt(u);if(i.length===0)break;this.setEntries(p=>[...p.filter(f=>f.type!=="plan"),{type:"plan",id:`plan-${r.task_list_id||Date.now()}`,entries:i}]);break}}}appendStreamingDelta(t,s){this.setEntries(r=>{const o=r[r.length-1];if((o==null?void 0:o.type)==="assistant_message"&&o.id.startsWith(Xe)){const l=o.chunks[o.chunks.length-1];return(l==null?void 0:l.type)===t?[...r.slice(0,-1),{...o,chunks:[...o.chunks.slice(0,-1),{type:t,text:l.text+s}]}]:[...r.slice(0,-1),{...o,chunks:[...o.chunks,{type:t,text:s}]}]}const d={type:"assistant_message",id:`${Xe}${Date.now()}`,chunks:[{type:t,text:s}]};return[...r,d]})}async sendMessage(t,s,r){var h;const o=s&&s.length>0,d=r&&r.length>0;if(!t.trim()&&!o&&!d)return;const l={type:"user_message",id:`user-${Date.now()}`,content:t,images:o?s:void 0,attachments:d?r:void 0};this.setEntries(g=>[...g,l]);const m=[];if(t&&m.push({type:"text",text:t}),o)for(const g of s)m.push({type:"image",source:{type:"base64",media_type:g.mimeType,data:g.data}});if(d){for(const g of r)if(g.kind==="text"||g.kind==="table"){const j=`📎 ${g.name}${g.size!=null?` (${Vn(g.size)})`:""}`,N=g.textContent||"(空文件)";m.push({type:"text",text:`${j}
|
|
82
|
+
\`\`\`
|
|
83
|
+
${N}
|
|
84
|
+
\`\`\``})}else if(g.kind==="directory"){const j=`📁 目录: ${g.name}${g.files!=null?` (${g.files.length} 个文件)`:""}`,N=g.textContent||"(空目录)";m.push({type:"text",text:`${j}
|
|
85
|
+
${N}`})}}const b=m.length===1&&m[0].type==="text"?m[0].text||t:m.length>0?m:t;try{const g=await Es(this.sessionId,{type:"user",uuid:Z(),content:t,message:{content:b}}),j=(h=g==null?void 0:g.event)==null?void 0:h.id;j&&this.setEntries(N=>N.map(E=>E.type==="user_message"&&E.id===l.id?{...E,id:j}:E))}catch(g){throw this.setEntries(j=>j.filter(N=>!(N.type==="user_message"&&N.id===l.id))),g}}async respondPermission(t,s,r){await W(this.sessionId,{type:"permission_response",approved:s,request_id:t,...r}),this.setEntries(o=>o.map(d=>{var l;return d.type!=="tool_call"||((l=d.toolCall.permissionRequest)==null?void 0:l.requestId)!==t?d:{type:"tool_call",toolCall:{...d.toolCall,status:s?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(s=>s.type!=="tool_call"||s.toolCall.status!=="running"&&s.toolCall.status!=="waiting_for_confirmation"?s:{type:"tool_call",toolCall:{...s.toolCall,status:"canceled",permissionRequest:void 0}})),await Ts(this.sessionId)}async setPermissionMode(t){const s=Z();return await W(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_permission_mode",mode:t}}),s}async controlRoundTrip(t,s=8e3){const r=Z(),o=new Promise(l=>{this.pendingControlRequests.set(r,l)}),d=setTimeout(()=>{const l=this.pendingControlRequests.get(r);l&&(this.pendingControlRequests.delete(r),l({data:null,error:"timeout"}))},s);try{return await W(this.sessionId,{type:"control_request",request_id:r,request:t}),await o}catch(l){throw this.pendingControlRequests.delete(r),l}finally{clearTimeout(d)}}async searchFiles(t,s=20){const r=await this.controlRoundTrip({subtype:"file_search",query:t,limit:s});try{if(!r.data||!Array.isArray(r.data.suggestions))return[];const o=[];for(const d of r.data.suggestions)d&&typeof d=="object"&&typeof d.path=="string"&&o.push(d.path);return o}catch{return[]}}async respondElicitation(t,s,r){await W(this.sessionId,{type:"permission_response",approved:s==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:s,...r?{content:r}:{}}}})}async askSideQuestion(t){const s=await this.controlRoundTrip({subtype:"side_question",question:t},12e4);if(s.error||!s.data)return null;const r=s.data.response;return typeof r=="string"?r:null}async setEffort(t){const s=Z();return await W(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),s}async setThinkingBudget(t){const s=Z();return await W(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_max_thinking_tokens",max_thinking_tokens:t}}),s}async getContextUsage(){const t=await this.controlRoundTrip({subtype:"get_context_usage"});try{if(!t.data)return null;const s=t.data.totalTokens,r=t.data.rawMaxTokens,o=t.data.percentage;if(typeof s!="number"||typeof r!="number")return null;const d=t.data.categories,l=Array.isArray(d)?d.filter(m=>!!m&&typeof m=="object"&&typeof m.name=="string").map(m=>({name:m.name,tokens:typeof m.tokens=="number"?m.tokens:0,...m.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:r,percentage:typeof o=="number"?o:0,...typeof t.data.model=="string"&&t.data.model?{model:t.data.model}:{},...l&&l.length>0?{categories:l}:{}}}catch{return null}}async stopSubagent(t){const s=await this.controlRoundTrip({subtype:"stop_task",task_id:t});try{return s.error?{ok:!1,error:s.error==="timeout"?"停止请求超时":s.error}:{ok:!0}}catch{return{ok:!1,error:"停止请求失败"}}}async getMcpServers(){var o;const s=(o=(await this.controlRoundTrip({subtype:"mcp_status"})).data)==null?void 0:o.mcpServers;if(!Array.isArray(s))return[];const r=[];for(const d of s){if(!d||typeof d!="object")continue;const l=d;if(typeof l.name!="string"||!l.name)continue;const m=l.status;if(m!=="connected"&&m!=="failed"&&m!=="needs-auth"&&m!=="pending"&&m!=="disabled")continue;const b=l.serverInfo,h=l.config;r.push({name:l.name,status:m,...b&&typeof b.name=="string"&&typeof b.version=="string"?{serverInfo:{name:b.name,version:b.version}}:{},...typeof l.error=="string"&&l.error?{error:l.error}:{},...typeof(h==null?void 0:h.url)=="string"&&h.url?{url:h.url}:{},...Array.isArray(l.tools)?{toolCount:l.tools.length}:{}})}return r}async toggleMcpServer(t,s){const r=await this.controlRoundTrip({subtype:"mcp_toggle",serverName:t,enabled:s},15e3);return r.error?{ok:!1,error:r.error==="timeout"?"请求超时":r.error}:{ok:!0}}async reconnectMcpServer(t){const s=await this.controlRoundTrip({subtype:"mcp_reconnect",serverName:t},2e4);return s.error?{ok:!1,error:s.error==="timeout"?"请求超时":s.error}:{ok:!0}}async getRemoteSettings(){const s=(await this.controlRoundTrip({subtype:"get_settings"})).data;if(!s)return null;const r=s.applied,o=s.effective&&typeof s.effective=="object"&&!Array.isArray(s.effective)?s.effective:{},d=s.sources,l=[];if(Array.isArray(d))for(const m of d){if(!m||typeof m!="object")continue;const b=m;typeof b.source=="string"&&l.push({source:b.source,settings:b.settings&&typeof b.settings=="object"&&!Array.isArray(b.settings)?b.settings:{}})}return{applied:{model:typeof(r==null?void 0:r.model)=="string"?r.model:null,effort:typeof(r==null?void 0:r.effort)=="string"?r.effort:null},effective:o,sources:l}}async applyFlagSettings(t){const s=await this.controlRoundTrip({subtype:"apply_flag_settings",settings:t},15e3);return s.error?{ok:!1,error:s.error==="timeout"?"请求超时":s.error}:{ok:!0}}async rewindToMessage(t){await Ms(this.sessionId,t)}async endSession(t){await W(this.sessionId,{type:"control_request",request_id:Z(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function Vn(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function Gn(n){if(!n)return"never";const t=Math.max(0,Date.now()-n);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function Yn(n){return n?Date.now()-n<6e4:!1}function Jn({onClose:n,session:t,liveStatus:s,pendingPermissions:r,onInterrupt:o,onDelete:d,onEndSession:l}){const[m,b]=c.useState(!1),h=async()=>{await navigator.clipboard.writeText(t.id),b(!0),setTimeout(()=>b(!1),1500)},[g,j]=c.useState(!1),N=async()=>{if(!(!l||g)&&window.confirm("结束 worker 会话?正在进行的回合将被中止,会话随后归档。")){j(!0);try{await l(),n()}catch{j(!1)}}},E=r.length,u=t.worker,i=t.work_item,p=t.environment;return e.jsx(fe,{open:!0,onOpenChange:y=>{y||n()},children:e.jsxs(ge,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(ye,{children:e.jsx(be,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(fn,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bt,{status:s||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:u&&(Yn(u.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[u&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(kt,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Gn(u.last_heartbeat_at)})]}),p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Qt,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:p.machine_name||p.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(kt,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Ht(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(pe,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),E>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[E," permission request",E>1?"s":""," awaiting your approval"]}):e.jsx("p",{className:"text-xs text-text-muted",children:"No pending actions"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(In,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:o,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),l&&e.jsx("button",{onClick:N,disabled:g,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"通知 worker 中止在途回合并退出,随后归档会话",children:g?"Ending…":"End session"}),e.jsxs("button",{onClick:d,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(As,{className:"mr-1 inline h-3 w-3"}),"Delete"]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(vn,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:h,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:m?"✓":"⧉"})]})]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Spawn mode"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:i.spawn_mode??"default"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Work state"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:i.state})]})]}),t.source&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:t.source})]}),p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:p.worker_type})]})]})]})]})]})})}const Xn={connected:"bg-status-success/15 text-status-success",failed:"bg-status-error/15 text-status-error","needs-auth":"bg-status-warning/15 text-status-warning",pending:"bg-status-active/15 text-status-active",disabled:"bg-surface-3 text-text-muted"},Zn={connected:"已连接",failed:"失败","needs-auth":"待认证",pending:"连接中",disabled:"已禁用"};function er({onClose:n,fetchServers:t,onToggle:s,onReconnect:r}){const[o,d]=c.useState(null),[l,m]=c.useState(null),[b,h]=c.useState(null),[g,j]=c.useState(null),N=c.useCallback(async()=>{h(null),j(null);try{const i=await t();d(i),m(null)}catch(i){Re("[McpPanel] fetch failed",i),m("获取 MCP 状态失败 — worker 可能不支持")}},[t]);c.useEffect(()=>{N()},[N]);const E=async i=>{const p=i.status==="disabled";h(`toggle:${i.name}`),j(null);try{const y=await s(i.name,p);y.ok||j(y.error||"切换失败")}finally{await N()}},u=async i=>{h(`reconnect:${i.name}`),j(null);try{const p=await r(i.name);p.ok||j(p.error||"重连失败")}finally{await N()}};return e.jsx(fe,{open:!0,onOpenChange:i=>{i||n()},children:e.jsxs(ge,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(ye,{children:e.jsxs(be,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Gt,{className:"h-4 w-4"}),"MCP 服务器"]})}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[g&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:g}),o===null&&!l&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(pe,{className:"h-3.5 w-3.5 animate-spin"}),"加载 MCP 状态…"]}),l&&e.jsx("p",{className:"text-xs text-status-error",children:l}),o!==null&&o.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:"没有配置 MCP 服务器"}),o==null?void 0:o.map(i=>{const p=b===`toggle:${i.name}`,y=b===`reconnect:${i.name}`,f=i.status==="disabled";return e.jsx("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-text-primary",children:i.name}),e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium ${Xn[i.status]}`,children:Zn[i.status]})]}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:[i.serverInfo?`${i.serverInfo.name} v${i.serverInfo.version}`:i.url||"stdio",i.toolCount!==void 0&&` · ${i.toolCount} 工具`]}),i.error&&e.jsx("div",{className:"mt-1 truncate text-xs text-status-error",title:i.error,children:i.error})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void u(i),disabled:y||f,className:"rounded-md p-1.5 text-text-muted hover:bg-surface-3 hover:text-text-primary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:"重连",children:e.jsx(on,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`})}),e.jsx("button",{type:"button",role:"switch","aria-checked":!f,onClick:()=>void E(i),disabled:p,className:`relative h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${f?"bg-surface-3":"bg-brand"}`,title:f?"启用":"禁用",children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${f?"left-0.5":"left-4.5"}`})})]})]})},i.name)})]})]})})}function tr(n){if(n==null)return"(未设置)";if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}function At(n){if(n==null)return"(未设置)";if(typeof n=="object")try{return JSON.stringify(n,null,2)}catch{return String(n)}return String(n)}function sr({onClose:n,fetchSettings:t,onApply:s}){const[r,o]=c.useState(null),[d,l]=c.useState(null),[m,b]=c.useState(""),[h,g]=c.useState(null),[j,N]=c.useState(null),[E,u]=c.useState(null),[i,p]=c.useState(!1),y=c.useCallback(async()=>{g(null),N(null),u(null),p(!1);try{const _=await t();o(_),l(_?null:"获取设置失败 — worker 可能不支持")}catch(_){Re("[SettingsDrawer] fetch failed",_),l("获取设置失败 — worker 可能不支持")}},[t]);c.useEffect(()=>{y()},[y]);const f=c.useMemo(()=>r?Object.entries(r.effective).filter(([,_])=>_!==void 0).sort(([_],[O])=>_.localeCompare(O)):[],[r]),w=c.useMemo(()=>{const _=m.trim().toLowerCase();return _?f.filter(([O,L])=>`${O} ${tr(L)}`.toLowerCase().includes(_)):f},[f,m]),C=_=>typeof _[1]=="boolean",A=c.useMemo(()=>w.filter(C),[w]),$=c.useMemo(()=>w.filter(_=>!C(_)),[w]),F=c.useMemo(()=>E===null?null:f.find(([_])=>_===E)??null,[f,E]),V=async()=>{if(F)try{await navigator.clipboard.writeText(At(F[1])),p(!0),window.setTimeout(()=>p(!1),1500)}catch(_){Re("[SettingsDrawer] copy failed",_)}},G=async(_,O)=>{g(_),N(null);try{const L=await s({[_]:!O});L.ok||N(L.error||"写入失败")}finally{await y()}};return e.jsx(fe,{open:!0,onOpenChange:_=>{_||n()},children:e.jsxs(ge,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(ye,{children:e.jsxs(be,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Yt,{className:"h-4 w-4"}),"会话设置"]})}),e.jsxs("div",{className:"mt-3 space-y-4 text-sm",children:[j&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:j}),r===null&&!d&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(pe,{className:"h-3.5 w-3.5 animate-spin"}),"加载设置…"]}),d&&e.jsx("p",{className:"text-xs text-status-error",children:d}),r&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:"模型"}),e.jsx("code",{className:"font-mono text-text-secondary",children:r.applied.model||"(默认)"})]}),r.applied.effort&&e.jsxs("div",{className:"mt-1 flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:"Effort"}),e.jsx("code",{className:"font-mono text-text-secondary",children:r.applied.effort})]}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-text-muted",children:"布尔开关写入会话级 flag 层(apply_flag_settings);只读项点击查看详情。"})]}),F?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>{u(null),p(!1)},className:"flex items-center gap-1.5 text-xs text-text-muted transition-colors hover:text-text-primary",children:[e.jsx(yn,{className:"h-3.5 w-3.5"}),"返回设置列表"]}),e.jsx("div",{className:"break-all font-mono text-xs font-medium text-text-primary",children:F[0]}),e.jsx("pre",{className:"max-h-[60vh] overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 p-3 font-mono text-[11px] leading-relaxed text-text-secondary",children:At(F[1])}),e.jsxs("button",{type:"button",onClick:()=>void V(),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary",children:[i?e.jsx(he,{className:"h-3.5 w-3.5 text-status-success"}):e.jsx(ln,{className:"h-3.5 w-3.5"}),i?"已复制":"复制值"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2.5 py-1.5",children:[e.jsx(tt,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{value:m,onChange:_=>b(_.target.value),placeholder:"搜索设置项…",className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"})]}),w.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:"没有匹配的设置项"}),A.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-text-muted",children:["可设置(",A.length,")"]}),A.map(([_,O])=>{const L=h===_;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2",children:[e.jsx("div",{className:"truncate font-mono text-xs text-text-primary",children:_}),e.jsx("button",{type:"button",role:"switch","aria-checked":O,disabled:L,onClick:()=>void G(_,O),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${O?"bg-brand":"bg-surface-3"}`,title:O?"关闭(写入 false)":"开启(写入 true)",children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${O?"left-4.5":"left-0.5"}`})})]},_)})]}),$.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsxs("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-text-muted",children:["只读(",$.length,")"]}),$.map(([_])=>e.jsxs("button",{type:"button",onClick:()=>u(_),className:"flex w-full items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2 text-left transition-colors hover:bg-surface-3",title:"查看详情",children:[e.jsx("span",{className:"truncate font-mono text-xs text-text-primary",children:_}),e.jsx(Kt,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"})]},_))]})]})]})]})]})})}function nr({onClose:n,onAsk:t}){const[s,r]=c.useState([]),[o,d]=c.useState(""),[l,m]=c.useState(!1),b=async()=>{const h=o.trim();if(!h||l)return;const g=Date.now();r(j=>[...j,{id:g,question:h,answer:null}]),d(""),m(!0);try{const j=await t(h);r(N=>N.map(E=>E.id===g?{...E,answer:j??"没有获得回答(超时或 worker 不支持)",error:j===null}:E))}finally{m(!1)}};return e.jsx(fe,{open:!0,onOpenChange:h=>{h||n()},children:e.jsxs(ge,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-[26rem] h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md flex flex-col",children:[e.jsx(ye,{children:e.jsxs(be,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Vt,{className:"h-4 w-4"}),"旁路提问"]})}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-text-muted",children:"针对当前会话上下文提问,不进入主对话、不消耗会话历史 — 适合「这个会话干了什么」式的快速核对。"}),e.jsxs("div",{className:"mt-3 flex-1 space-y-4 overflow-y-auto",children:[s.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:"还没有提问。在下方输入你的问题。"}),s.map(h=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-br-md border border-user-bubble-border bg-user-bubble px-4 py-2 text-sm text-text-primary",children:h.question})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:24,height:24,className:"object-contain",draggable:!1})}),e.jsx("div",{className:"min-w-0 flex-1 pt-1 text-sm text-text-primary",children:h.answer===null?e.jsxs("span",{className:"chat-typing-indicator inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):e.jsx("div",{className:h.error?"text-status-error":"",children:e.jsx($s,{children:h.answer})})})]})]},h.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:o,onChange:h=>d(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),b())},rows:Math.min(4,Math.max(1,o.split(`
|
|
86
|
+
`).length)),placeholder:"问点什么…",disabled:l,className:"flex-1 resize-none rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none disabled:opacity-50"}),e.jsx("button",{type:"button",onClick:()=>void b(),disabled:l||!o.trim(),className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-brand text-white transition-colors hover:bg-brand-light disabled:opacity-40 disabled:cursor-not-allowed",title:"提问(Enter)",children:l?e.jsx(pe,{className:"h-4 w-4 animate-spin"}):e.jsx(Is,{className:"h-4 w-4"})})]})]})})}const $t="rcs:subagent-panel:collapsed";function rr(n){if(n<1e3)return"0s";const t=Math.floor(n/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;if(s<60)return r?`${s}m${r}s`:`${s}m`;const o=Math.floor(s/60),d=s%60;return d?`${o}h${d}m`:`${o}h`}function ar(n){return n===void 0||n<=0?"":n<1e3?`${n}`:n<1e6?`${(n/1e3).toFixed(n<1e4?1:0)}k`:`${(n/1e6).toFixed(1)}M`}function or({status:n}){return n==="running"?e.jsx(pe,{className:"h-3 w-3 animate-spin text-brand"}):n==="completed"?e.jsx(Rn,{className:"h-3 w-3 text-status-success"}):n==="failed"||n==="stopped"?e.jsx(Ps,{className:"h-3 w-3 text-status-error"}):null}function ir({task:n,onStopTask:t}){const s=n.status==="running",r=s?n.durationMs??Date.now()-n.startTime:(n.endTime??Date.now())-n.startTime,o=ar(n.tokenCount),d=n.toolUseCount!==void 0&&n.toolUseCount>0?`${n.toolUseCount} tool${n.toolUseCount>1?"s":""}`:"",l=n.summary||n.description||"(no description)";return e.jsxs("div",{className:"group/task flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(or,{status:n.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:n.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:rr(r)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:l}),(o||d||n.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[o&&e.jsxs("span",{children:["↕ ",o," tok"]}),d&&e.jsxs("span",{children:["· ",d]}),n.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",n.lastToolName]})]}),!s&&n.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:n.finalSummary})]}),s&&t&&e.jsx("button",{type:"button",onClick:()=>t(n.taskId),title:"停止此任务",className:"mt-0.5 flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:bg-status-error/10 hover:text-status-error focus:opacity-100 group-hover/task:opacity-100",children:e.jsx(qs,{className:"h-3.5 w-3.5"})})]})}function lr({state:n,onStopTask:t}){const[s,r]=c.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem($t)==="1"}catch{return!1}}),o=()=>{r(h=>{const g=!h;try{window.localStorage.setItem($t,g?"1":"0")}catch{}return g})},[,d]=c.useState(0);c.useEffect(()=>{const h=Object.values(n.tasks).some(N=>N.status==="running"),g=Object.values(n.tasks).some(N=>N.status!=="running"&&N.evictAfter!==void 0);if(!h&&!g)return;const j=setInterval(()=>{d(N=>N+1)},1e3);return()=>clearInterval(j)},[n]);const l=Hn(n);if(l.length===0)return null;const m=l.filter(h=>h.status==="running").length,b=m>0?`${m} running`:`${l.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:o,"aria-expanded":!s,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Kt,{className:`h-3 w-3 transition-transform ${s?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:b})]}),!s&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:l.map(h=>e.jsx(ir,{task:h,onStopTask:t},h.taskId))})]})})}function It(n,t){var o;const s=(o=t==null?void 0:t.find(d=>d.type==="addRules"||d.type==="replaceRules"))==null?void 0:o.rules,r=s==null?void 0:s[0];return r!=null&&r.ruleContent?`${r.toolName}(${r.ruleContent})`:r!=null&&r.toolName?r.toolName:n}function cr({requestId:n,toolName:t,toolInput:s,description:r,suggestions:o,onApprove:d,onApproveAlways:l,onReject:m}){const b=typeof s=="string"?s:JSON.stringify(s,null,2),h=Array.isArray(o)&&o.length>0;return e.jsxs("div",{className:"rounded-xl border border-warning-border/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-warning-border/15 text-warning-text",children:e.jsx(Ln,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:H(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:H(t)}),t!=="AskUserQuestion"&&e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:Nt(b,500)}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:d,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),h&&l&&e.jsxs("button",{onClick:l,className:"flex items-center gap-1.5 rounded-lg border border-brand/40 bg-brand/10 px-4 py-2 text-sm font-medium text-brand hover:bg-brand/20 transition-colors",title:`允许并记住规则:${It(t,o)}`,children:[e.jsx(Un,{className:"h-3.5 w-3.5"}),"Always allow ",Nt(It(t,o),40)]}),e.jsx("button",{onClick:m,className:"rounded-lg bg-status-error/20 px-4 py-2 text-sm font-medium text-status-error hover:bg-status-error/30 transition-colors",children:"Reject"})]})]})}function dr({questions:n,description:t,onSubmit:s,onSkip:r}){const[o,d]=c.useState({}),[l,m]=c.useState({}),[b,h]=c.useState(0),g=(u,i,p)=>{if(p){const y=o[u]||[],f=y.includes(i)?y.filter(w=>w!==i):[...y,i];d({...o,[u]:f})}else d({...o,[u]:i})},j=u=>{var p;const i=(p=l[u])==null?void 0:p.trim();i&&(d({...o,[u]:i}),m({...l,[u]:""}))},N=()=>{var i,p;const u={};for(const[y,f]of Object.entries(o)){const w=n[parseInt(y,10)];w&&(typeof f=="number"?u[y]=((p=(i=w.options)==null?void 0:i[f])==null?void 0:p.label)||String(f):Array.isArray(f)?u[y]=f.map(C=>{var A,$;return(($=(A=w.options)==null?void 0:A[C])==null?void 0:$.label)||String(C)}):u[y]=f)}s(u)};if(n.length<=1){const u=n[0]||{question:t,options:[],multiSelect:!1},i=u.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:H(t||u.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(u.options||[]).map((p,y)=>{const f=i?(o[0]||[]).includes(y):o[0]===y;return e.jsxs("button",{onClick:()=>g(0,y,i),className:xe("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",f?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:H(p.label)}),p.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:H(p.description)})]},y)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:l[0]||"",onChange:p=>m({...l,0:p.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:p=>p.key==="Enter"&&j(0)}),e.jsx("button",{onClick:()=>j(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const E=n[b];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:H(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:n.map((u,i)=>e.jsx("button",{onClick:()=>h(i),className:xe("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",b===i?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:u.header||`Q${i+1}`},i))}),E&&e.jsx(ur,{question:E,qIdx:b,answers:o,otherTexts:l,onSelect:g,onOtherTextChange:(u,i)=>m({...l,[u]:i}),onOtherSubmit:j}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[b+1," / ",n.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function ur({question:n,qIdx:t,answers:s,otherTexts:r,onSelect:o,onOtherTextChange:d,onOtherSubmit:l}){const m=n.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:H(n.question)}),e.jsxs("div",{className:"space-y-2",children:[(n.options||[]).map((b,h)=>{const g=m?(s[t]||[]).includes(h):s[t]===h;return e.jsxs("button",{onClick:()=>o(t,h,m),className:xe("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",g?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:H(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:H(b.description)})]},h)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:b=>d(t,b.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:b=>b.key==="Enter"&&l(t)}),e.jsx("button",{onClick:()=>l(t),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function mr({planContent:n,description:t,onSubmit:s}){const[r,o]=c.useState(null),[d,l]=c.useState(""),m=!n||!n.trim(),b=()=>{r&&s(r,r==="no"?d:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(he,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:m?"Exit plan mode?":"Ready to code?"})]}),!m&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:xr(n)}}),e.jsx("div",{className:"space-y-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(me,{selected:r==="yes-default",onClick:()=>o("yes-default"),label:"Yes"}),e.jsx(me,{selected:r==="no",onClick:()=>o("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{selected:r==="yes-accept-edits",onClick:()=>o("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(me,{selected:r==="yes-default",onClick:()=>o("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(me,{selected:r==="no",onClick:()=>o("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:d,onChange:h=>l(h.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:b,disabled:!r,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function me({selected:n,onClick:t,label:s,desc:r}){return e.jsxs("button",{onClick:t,className:xe("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",n?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:xe("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",n?"border-brand bg-brand text-white":"border-border"),children:n&&"✓"}),e.jsx("span",{className:"font-medium",children:s})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:r})]})}function xr(n){let t=H(n);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(s,r,o)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${o.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function pr({request:n,onSubmit:t}){const s=hr(n.requestedSchema),r=fr(n.requestedSchema),[o,d]=c.useState({}),l=s.length===0||r.every(m=>(o[m]??"").trim()!=="");return n.mode==="url"&&n.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(qt,{serverName:n.serverName,message:n.message}),e.jsxs("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 flex w-full items-center justify-between rounded-lg border border-border bg-surface-2 px-4 py-2.5 text-sm text-brand hover:bg-brand/10 transition-colors",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:n.url}),e.jsx(cn,{className:"ml-2 h-4 w-4 flex-shrink-0"})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:()=>t("accept"),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"完成"}),e.jsx("button",{onClick:()=>t("cancel"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"取消"})]})]}):e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(qt,{serverName:n.serverName,message:n.message}),s.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:s.map(({name:m,prop:b})=>e.jsxs("label",{className:"block",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-medium text-text-primary",children:m}),r.includes(m)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:"必填"})]}),b.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:H(b.description)}),e.jsx("input",{type:b.type==="number"?"number":"text",value:o[m]??"",onChange:h=>d(g=>({...g,[m]:h.target.value})),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]},m))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const m={};for(const{name:b,prop:h}of s){const g=(o[b]??"").trim();g&&(m[b]=h.type==="number"?Number(g):g)}t("accept",m)},disabled:!l,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"提交"}),e.jsx("button",{onClick:()=>t("decline"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"拒绝"})]})]})}function qt({serverName:n,message:t}){return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(Tn,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-sm font-semibold text-text-primary",children:["MCP 请求输入 ",e.jsx("span",{className:"font-mono text-xs text-text-muted",children:H(n)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:H(t)})]})}function hr(n){const t=n==null?void 0:n.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,s])=>s&&typeof s=="object").map(([s,r])=>({name:s,prop:r}))}function fr(n){const t=n==null?void 0:n.required;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function gr(n){const[t,s]=c.useState([]),[r,o]=c.useState(!0),[d,l]=c.useState(null),m=c.useCallback(async()=>{o(!0),l(null);try{const g=await Ds(n);s(g)}catch(g){l(g instanceof Error?g.message:"Failed to load shares")}finally{o(!1)}},[n]);c.useEffect(()=>{m()},[m]);const b=c.useCallback(async g=>{l(null);try{const j=await Os(n,g);return await m(),j}catch(j){throw l(j instanceof Error?j.message:"Failed to create share"),j}},[n,m]),h=c.useCallback(async g=>{l(null);try{await Us(n,g),await m()}catch(j){throw l(j instanceof Error?j.message:"Failed to revoke share"),j}},[n,m]);return{shares:t,isLoading:r,error:d,createShare:b,revokeShare:h,refresh:m}}function yr({open:n,onClose:t,sessionId:s,sessionTitle:r}){Wt();const{shares:o,isLoading:d,error:l,createShare:m,revokeShare:b}=gr(s),[h,g]=c.useState("user"),[j,N]=c.useState(""),[E,u]=c.useState(""),[i,p]=c.useState("read"),[y,f]=c.useState(""),[w,C]=c.useState(!1),[A,$]=c.useState(null),[F,V]=c.useState(""),[G,_]=c.useState(!1),[O,L]=c.useState(!1);c.useEffect(()=>{n&&(g("user"),N(""),u(""),p("read"),f(""),C(!1),$(null),V(""),_(!1),L(!1))},[n]);const z=async()=>{C(!0),V(""),$(null);try{const M={grantedTo:h==="user"?{userId:j.trim()}:{teamId:E.trim()},permission:i};y.trim()&&(M.expiresAt=y.trim());const Oe=await m(M);$(`${window.location.origin}/code/s/${Oe.shareToken}`)}catch(M){V(M instanceof Error?M.message:"Failed to create share")}finally{C(!1)}},De=async M=>{try{await b(M)}catch{}},ne=async()=>{if(!A)return;L(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(A),_(!0),setTimeout(()=>_(!1),2e3);return}}catch{}const M=document.createElement("textarea");M.value=A,M.style.position="fixed",M.style.opacity="0",document.body.appendChild(M),M.select();try{document.execCommand("copy"),_(!0),setTimeout(()=>_(!1),2e3)}catch{L(!0)}document.body.removeChild(M)};return e.jsx(fe,{open:n,onOpenChange:M=>{M||t()},children:e.jsxs(ge,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(ye,{children:e.jsxs(be,{className:"font-display text-lg font-semibold text-text-primary",children:[v("share.title"),r?`: ${r}`:""]})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:v("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>g("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${h==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:v("share.user")}),e.jsx("button",{onClick:()=>g("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${h==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:v("share.team")})]}),h==="user"?e.jsx(mn,{onSelect:N,placeholder:v("share.userIdPlaceholder"),actionLabel:v("share.selectUser")}):e.jsx("input",{type:"text",value:E,onChange:M=>u(M.target.value),placeholder:v("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),h==="user"&&j&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[v("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:j})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:v("share.permission")}),e.jsxs("select",{value:i,onChange:M=>p(M.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"read",children:v("share.permissionRead")}),e.jsx("option",{value:"write",children:v("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:v("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:y,onChange:M=>f(M.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none"})]}),(F||l)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:F||l}),A&&e.jsxs("div",{className:"rounded-md bg-surface-2 px-3 py-2",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-1",children:v("share.linkCreated")}),e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs text-text-primary",children:A}),e.jsx("button",{onClick:ne,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:G?v("share.copied"):v("share.copy")})]}),O&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:v("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:v("share.existingShares")}),d?e.jsx("p",{className:"text-sm text-text-muted",children:v("share.loading")}):o.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:v("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:o.map(M=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md bg-surface-2 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:M.granted_to_user||M.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[M.permission==="write"?v("share.permissionWrite"):v("share.permissionRead"),M.expires_at?` · expires ${M.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>De(M.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:v("share.revoke")})]},M.id))})]})]}),e.jsxs(an,{children:[e.jsx("button",{onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:v("common.close")}),e.jsx("button",{onClick:z,disabled:w||(h==="user"?!j.trim():!E.trim()),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:w?v("common.creating"):v("share.createShare")})]})]})})}class br{constructor(t,s,r,o){T(this,"pending",null);this.current=t,this.apply=s,this.send=r,this.onError=o}set(t){if(t===this.current)return;const s=this.current;this.current=t,this.pending={requestId:null,previous:s},this.apply(t);try{Promise.resolve(this.send(t)).then(r=>{this.pending&&(this.pending.requestId=r)}).catch(r=>{this.rollback(s,Pt(r),"send")})}catch(r){this.rollback(s,Pt(r),"send")}}handleControlResponse(t){const s=this.pending;if(!s||s.requestId!==t.requestId)return!1;const{previous:r}=s;return this.pending=null,t.subtype==="error"&&this.rollback(r,t.error??"","response"),!0}sync(t){t!==this.current&&(this.current=t,this.apply(t),this.pending=null)}adoptExternal(t){this.pending||t!==this.current&&(this.current=t)}getCurrent(){return this.current}rollback(t,s,r){var o;this.pending=null,this.current=t,this.apply(t),s&&((o=this.onError)==null||o.call(this,s,r))}}function Pt(n){return n instanceof Error?n.message:String(n)}function Ze(n){const t=c.useRef(n);t.current=n;const s=c.useRef(null);s.current||(s.current=new br(n.value,o=>t.current.apply(o),o=>t.current.send(o),(o,d)=>{var l,m;return(m=(l=t.current).onError)==null?void 0:m.call(l,o,d)}));const r=s.current;return c.useEffect(()=>{r.adoptExternal(n.value)}),c.useMemo(()=>({set:o=>r.set(o),handleControlResponse:o=>r.handleControlResponse(o),sync:o=>r.sync(o)}),[r])}const Xt="rcs_context_usage_";function Zt(){try{if(typeof localStorage<"u")return localStorage}catch{}return null}function Dt(){return{totalTokens:0,rawMaxTokens:0,percentage:0}}function jr(n){if(!n||typeof n!="object"||Array.isArray(n))return null;const t=n,{totalTokens:s,rawMaxTokens:r,percentage:o}=t;if(typeof s!="number"||typeof r!="number"||typeof o!="number")return null;const d=t.categories,l=Array.isArray(d)?d.filter(m=>!!m&&typeof m=="object"&&typeof m.name=="string").map(m=>({name:m.name,tokens:typeof m.tokens=="number"?m.tokens:0,...m.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:r,percentage:o,...typeof t.model=="string"&&t.model?{model:t.model}:{},...l&&l.length>0?{categories:l}:{}}}function wr(n,t=Zt()){if(!t||!n)return null;try{const s=t.getItem(Xt+n);return s?jr(JSON.parse(s)):null}catch{return null}}function kr(n,t,s=Zt()){if(!(!s||!n))try{s.setItem(Xt+n,JSON.stringify(t))}catch{}}function Nr(n){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${n}`}function vr(n){const t=Nr(n),s=Ls(),r=s?{proxyUrl:t,token:s}:{proxyUrl:t};return new Fs(r)}const te=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],Ot="rcs_permission_mode";function se(n){return n<1e3?String(n):n<1e6?`${(n/1e3).toFixed(1)}k`:`${(n/1e6).toFixed(1)}M`}function _r(n){const t=te.findIndex(s=>s.value===n);return te[(t+1+te.length)%te.length].value}const st=[{value:"off",label:"关闭思考",tokens:null,description:"不使用扩展思考"},{value:"on",label:"默认思考",tokens:0,description:"开启,使用默认预算"},{value:"8192",label:"8k",tokens:8192,description:"8192 tokens"},{value:"16384",label:"16k",tokens:16384,description:"16384 tokens"},{value:"32768",label:"32k",tokens:32768,description:"32768 tokens"}],Ut="rcs_thinking_budget",nt=[{value:"auto",effort:void 0,label:"自动",description:"使用模型默认 effort"},{value:"low",effort:"low",label:"low",description:"低推理力度"},{value:"medium",effort:"medium",label:"medium",description:"中推理力度"},{value:"high",effort:"high",label:"high",description:"高推理力度"},{value:"xhigh",effort:"xhigh",label:"xhigh",description:"超高推理力度"},{value:"max",effort:"max",label:"max",description:"最大推理力度"}],Ft="rcs_effort";function Sr(n){return n!=null&&n.capabilities?n.capabilities:n?{file_search:!0,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!0,stop_task:!0,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!0,mcp_management:!0,remote_settings:!0,rewind:!0,set_effort:!0,side_question:!0}:{file_search:!1,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!1,stop_task:!1,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!1,mcp_management:!1,remote_settings:!1,rewind:!1,set_effort:!1,side_question:!1}}function Cr({budget:n,onBudgetChange:t,disabled:s}){const[r,o]=c.useState(!1),d=st.find(l=>l.value===n);return e.jsxs(Ae,{open:r,onOpenChange:o,children:[e.jsx($e,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"思考预算",children:[e.jsx(nn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(d==null?void 0:d.label)??"思考"}),r?e.jsx(Ie,{className:"h-3 w-3"}):e.jsx(qe,{className:"h-3 w-3"})]})}),e.jsx(Pe,{className:"w-64 p-1",align:"start",children:st.map(l=>e.jsxs("button",{type:"button",onClick:()=>{t(l.value,l.tokens),o(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:n===l.value&&e.jsx(he,{className:"h-3.5 w-3.5 text-brand"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:l.label}),e.jsx("div",{className:"text-xs text-text-muted",children:l.description})]})]},l.value))})]})}function Er({effort:n,onEffortChange:t,disabled:s}){const[r,o]=c.useState(!1),d=nt.find(l=>l.value===n);return e.jsxs(Ae,{open:r,onOpenChange:o,children:[e.jsx($e,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"Effort 档位",children:[e.jsx(kn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(d==null?void 0:d.label)??"自动"}),r?e.jsx(Ie,{className:"h-3 w-3"}):e.jsx(qe,{className:"h-3 w-3"})]})}),e.jsx(Pe,{className:"w-64 p-1",align:"start",children:nt.map(l=>e.jsxs("button",{type:"button",onClick:()=>{t(l.value),o(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:n===l.value&&e.jsx(he,{className:"h-3.5 w-3.5 text-brand"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:l.label}),e.jsx("div",{className:"text-xs text-text-muted",children:l.description})]})]},l.value))})]})}const Lt=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function Tr({usage:n}){const t=Math.min(100,Math.max(0,n.percentage)),s=t>=80,r=(n.categories??[]).filter(l=>!l.isDeferred),o=(n.categories??[]).filter(l=>l.isDeferred),d=[`上下文用量:${se(n.totalTokens)} / ${se(n.rawMaxTokens)} tokens${n.model?` · ${n.model}`:""}`,...r.slice(0,8).map(l=>`${l.name}: ${se(l.tokens)}`),...o.slice(0,3).map(l=>`${l.name}(延迟加载): ${se(l.tokens)}`)];return e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",title:d.join(`
|
|
87
|
+
`),children:[e.jsx("span",{className:"relative flex h-1.5 w-16 overflow-hidden rounded-full bg-surface-3",children:r.length>0?r.map((l,m)=>e.jsx("span",{className:s&&m===0?"bg-status-warning":Lt[m%Lt.length],style:{width:`${Math.min(100,Math.max(0,l.tokens/n.rawMaxTokens*100))}%`}},l.name)):e.jsx("span",{className:`absolute inset-y-0 left-0 rounded-full transition-all ${s?"bg-status-warning":"bg-brand/70"}`,style:{width:`${t}%`}})}),e.jsxs("span",{children:[t,"%"]})]})}function Mr({models:n,currentModelId:t,onSelect:s,disabled:r}){const[o,d]=c.useState(!1),l=n.find(h=>h.modelId===t)??null,m=n.length>0,b=async h=>{s(h.modelId),d(!1)};return e.jsxs(Ae,{open:o,onOpenChange:m?d:void 0,children:[e.jsx($e,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:r||!m,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"选择模型",children:[e.jsx(Qt,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(l==null?void 0:l.name)??t??"选择模型"}),o?e.jsx(Ie,{className:"h-3 w-3"}):e.jsx(qe,{className:"h-3 w-3"})]})}),e.jsx(Pe,{className:"w-72 p-0",align:"start",children:e.jsx(sn,{models:n,currentModelId:t,onSelect:b,showSearch:n.length>5})})]})}function Rr({mode:n,onModeChange:t,disabled:s}){const[r,o]=c.useState(!1),d=te.find(l=>l.value===n);return e.jsxs(Ae,{open:r,onOpenChange:o,children:[e.jsx($e,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"权限模式(Shift+Tab 循环)",children:[e.jsx(tn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(d==null?void 0:d.label)??n}),r?e.jsx(Ie,{className:"h-3 w-3"}):e.jsx(qe,{className:"h-3 w-3"})]})}),e.jsx(Pe,{className:"w-64 p-1",align:"start",children:te.map(l=>e.jsxs("button",{type:"button",onClick:()=>{t(l.value),o(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:n===l.value&&e.jsx(he,{className:"h-3.5 w-3.5 text-brand"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:l.label}),e.jsx("div",{className:"text-xs text-text-muted",children:l.description})]})]},l.value))})]})}function Qr({sessionId:n,onSessionLoaded:t}){Wt();const[s,r]=c.useState(null),[o,d]=c.useState(null),[l,m]=c.useState(""),[b,h]=c.useState(!1),[g,j]=c.useState(!1),[N,E]=c.useState(!1),[u,i]=c.useState(!1),[p,y]=c.useState(!1),[f,w]=c.useState(""),[C,A]=c.useState(0),$=c.useRef(null),[F,V]=c.useState({text:"",nonce:0}),[G,_]=c.useState(!1),[O,L]=c.useState(!1),[z,De]=c.useState(!1),[ne,M]=c.useState(0),[Oe,es]=c.useState(0),[re,je]=c.useState([]),[K,we]=c.useState(!1),[ae,J]=c.useState([]),[B,Ue]=c.useState(null),[ts,ss]=c.useState(()=>Jt()),[Q,ns]=c.useState(null),[rt,rs]=c.useState(()=>localStorage.getItem(Ut)||"off"),[as,at]=c.useState(()=>wr(n)),[Fe,Le]=c.useState(!0),[oe,os]=c.useState(null),[ke,ot]=c.useState(null),[Ne,ve]=c.useState([]),[it,Be]=c.useState(!1),[He,lt]=c.useState(""),We=c.useRef(null),[_e,is]=c.useState(()=>localStorage.getItem(Ot)||"default"),[ct,dt]=c.useState(null),ie=c.useRef(null),[ut,mt]=c.useState(null),le=c.useRef(null),ce=c.useRef(null),xt=c.useRef(re);xt.current=re;const Se=c.useRef(t);Se.current=t;const Ce=c.useRef(null);Ce.current||(Ce.current=new xn(pn()));const pt=c.useRef(n);pt.current=(s==null?void 0:s.title)||n,c.useEffect(()=>{var a;(a=Ce.current)==null||a.reset()},[n]);const Y=c.useCallback(a=>{dt(a),ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>dt(null),5e3)},[]),X=c.useCallback(a=>{mt(a),le.current&&clearTimeout(le.current),le.current=setTimeout(()=>mt(null),5e3)},[]),Ee=Ze({value:_e,apply:a=>{is(a);try{localStorage.setItem(Ot,a)}catch{}},send:a=>{const x=ce.current;return x?x.setPermissionMode(a):Promise.reject(new Error("adapter not ready"))},onError:(a,x)=>{console.error("[SessionDetail] set permission mode failed:",a),Y(x==="send"?`模式切换请求发送失败: ${a}`:a||"模式切换失败")}}),ze=c.useCallback(a=>Ee.set(a),[Ee]),Ke=Ze({value:rt,apply:a=>{rs(a);try{localStorage.setItem(Ut,a)}catch{}},send:a=>{var k;const x=ce.current;if(!x)return Promise.reject(new Error("adapter not ready"));const S=((k=st.find(I=>I.value===a))==null?void 0:k.tokens)??null;return x.setThinkingBudget(S)},onError:(a,x)=>{console.error("[SessionDetail] set thinking budget failed:",a),Y(x==="send"?`思考预算请求发送失败: ${a}`:a||"思考预算切换失败")}}),R=c.useMemo(()=>new Qn(n,je,{onStatusChange:a=>{var x;d(a),we(a==="running"||a==="requires_action"),(x=Ce.current)==null||x.onStatus(a,pt.current)},onError:a=>{console.error("[RCSChatAdapter] error:",a)},onPermissionRequest:a=>{J(x=>x.some(S=>S.requestId===a.requestId)?x:[...x,a])},onModelsStateChange:a=>{Ue(a)},onSubagentUpdate:a=>{ss(a)},onControlResponse:a=>{Ke.handleControlResponse(a)||Ee.handleControlResponse(a)},onPermissionModeChange:a=>{Ee.sync(a)},onUsageChange:a=>{os(x=>({inputTokens:Math.max((x==null?void 0:x.inputTokens)??0,a.inputTokens),outputTokens:Math.max((x==null?void 0:x.outputTokens)??0,a.outputTokens),totalCostUsd:a.totalCostUsd??(x==null?void 0:x.totalCostUsd)??null}))},onWorkerInfoChange:a=>{ns(x=>JSON.stringify(x)===JSON.stringify(a)?x:a)},onElicitationRequest:a=>{ot(a)}}),[n,Y]);c.useEffect(()=>(ce.current=R,()=>{R.disconnect()}),[R]);const U=c.useMemo(()=>Sr(Q),[Q]),Qe=c.useMemo(()=>Bs((Q==null?void 0:Q.commands)??[],(Q==null?void 0:Q.skills)??[]),[Q]),de=c.useMemo(()=>Hs(re,f),[re,f]),ls=c.useCallback(a=>Ke.set(a),[Ke]),[ht,cs]=c.useState(()=>localStorage.getItem(Ft)||"auto"),ds=Ze({value:ht,apply:a=>{cs(a);try{localStorage.setItem(Ft,a)}catch{}},send:a=>{var k;const x=ce.current;if(!x)return Promise.reject(new Error("adapter not ready"));const S=(k=nt.find(I=>I.value===a))==null?void 0:k.effort;return x.setEffort(S)},onError:(a,x)=>{console.error("[SessionDetail] set effort failed:",a),Y(x==="send"?`Effort 切换请求发送失败: ${a}`:a||"Effort 切换失败")}}),Ve=c.useCallback(()=>{var a;U.get_context_usage&&((a=ce.current)==null||a.getContextUsage().then(x=>{x&&(at(x),kr(n,x))}).catch(()=>{}).finally(()=>Le(!1)))},[U,n]);c.useEffect(()=>{if(!U.get_context_usage)return;K||Ve();const a=setInterval(Ve,6e4);return()=>clearInterval(a)},[U,K,Ve]),c.useEffect(()=>{Q&&!U.get_context_usage&&Le(!1)},[Q,U]),c.useEffect(()=>{if(!Fe)return;const a=setTimeout(()=>Le(!1),1e4);return()=>clearTimeout(a)},[Fe]);const ft=c.useRef(z);ft.current=z,c.useEffect(()=>ee.onEvent(x=>{x.type!=="artifact_created"&&x.type!=="artifact_updated"||(ft.current&&es(S=>S+1),M(S=>S+1))}),[]);const[ue,us]=c.useState("idle");c.useEffect(()=>ee.onStateChange(x=>us(x)),[]),c.useEffect(()=>{z&&M(0)},[z]),c.useEffect(()=>{let a=!1;async function x(){var S;m("");try{const k=await Xs(n);if(a)return;r(k),d(k.status),et(k.status)&&R.markClosed(),we(k.status==="running"||k.status==="requires_action"),(S=Se.current)==null||S.call(Se,k)}catch(k){if(a)return;m(k instanceof Error?k.message:v("session.loadFailed"));return}try{await R.init()}catch(k){console.warn("Failed to init adapter:",k)}}return x(),()=>{a=!0}},[n,R]);const q=et(o),P=(s==null?void 0:s.access_level)==="read",gt=as??(Fe&&!q&&!P?Dt():null),Ge=c.useCallback(()=>{je([]),at(Dt()),Ws(n).catch(a=>{console.warn("[SessionDetail] Failed to clear session history:",a)})},[n]),Te=c.useCallback(async a=>{const x=a.text.trim(),S=a.images&&a.images.length>0||a.attachments&&a.attachments.length>0;if(!x&&!S||q)return;const k=await zs(x,{sessionId:n,availableCommands:Qe,availableModels:(B==null?void 0:B.availableModels)??[],currentModel:B?{modelId:B.currentModelId,name:B.currentModelId}:null,supportsImages:!0,entries:xt.current,setModel:async I=>{await W(n,{type:"control_request",request:{subtype:"set_model",model:I}}),Ue(Je=>Je&&{...Je,currentModelId:I})},onNewSession:()=>{je([])}}).catch(()=>null);if(k){if(Re("[SessionDetail] local command result",k),"clearEntries"in k&&k.clearEntries){Ge();return}if("newSession"in k&&k.newSession){Ge();return}if("userEntry"in k){je(I=>[...I,k.userEntry,k.cmdEntry]);return}}we(!0);try{await R.sendMessage(x,a.images,a.attachments)}catch(I){if(console.error("Send failed:",I),I instanceof Ks&&I.type==="session_closed"){d("archived"),R.markClosed(),X(v("session.closedSendBlocked"));return}X(`${v("session.sendFailed")}${I instanceof Error?`: ${I.message}`:""}`)}},[R,q,n,B,Qe,Ge,X]),ms=c.useCallback(a=>{if(K){ve(x=>[...x,a]);return}Te(a)},[K,Te]),Ye=c.useRef(!1);c.useEffect(()=>{if(q){ve(x=>x.length>0?[]:x);return}if(K||Ne.length===0||Ye.current)return;const a=Ne[0];a&&(Ye.current=!0,ve(x=>x.slice(1)),Te(a).finally(()=>{Ye.current=!1}))},[K,Ne,Te,q]);const xs=c.useCallback((a,x)=>{if(K)return;const S=x==="edit"?"回退到这条消息并编辑?":"回退到这条消息?";window.confirm(`${S}
|
|
88
|
+
之后的对话将移除,已修改的文件将恢复到当时的状态(若有快照)。`)&&R.rewindToMessage(a.id).then(()=>{x==="edit"&&a.content&&V(k=>({text:a.content,nonce:k.nonce+1}))}).catch(k=>{console.error("[SessionDetail] rewind failed:",k),X(`回退失败: ${k instanceof Error?k.message:String(k)}`)})},[K,X]),ps=c.useCallback(a=>{const x=de.orderedMatchIds;if(x.length===0)return;const S=(a%x.length+x.length)%x.length;A(S);const k=x[S],I=document.querySelector(`[data-entry-id="${CSS.escape(k)}"]`);I==null||I.scrollIntoView({block:"center",behavior:"smooth"})},[de]),yt=c.useCallback(async()=>{try{await R.interrupt()}catch(a){console.error("Interrupt failed:",a)}finally{we(!1)}},[R]),hs=c.useCallback(()=>{ze(_r(_e))},[ze,_e]);c.useEffect(()=>()=>{ie.current&&clearTimeout(ie.current),le.current&&clearTimeout(le.current)},[]);const fs=c.useCallback(async()=>{if(s&&window.confirm(v("dashboard.confirmDelete").replace("{id}",s.title||s.id)))try{await vt(s.id),window.location.href="/code/"}catch(a){alert(a instanceof Error?a.message:v("dashboard.deleteFailed"))}},[s]),gs=c.useCallback(async a=>{try{await R.respondPermission(a,!0)}catch(x){console.error("Failed to approve:",x)}J(x=>x.filter(S=>S.requestId!==a))},[R]),ys=c.useCallback(async(a,x)=>{try{await R.respondPermission(a,!0,{updated_permissions:x})}catch(S){console.error("Failed to approve with rules:",S)}J(S=>S.filter(k=>k.requestId!==a))},[R]),bs=c.useCallback(async(a,x)=>{const S=ke;if(ot(null),!!S)try{await R.respondElicitation(S.requestId,a,x)}catch(k){console.error("Failed to submit elicitation:",k)}},[ke,R]),js=c.useCallback(()=>{!s||P||(lt(s.title||""),Be(!0),setTimeout(()=>{var a,x;(a=We.current)==null||a.focus(),(x=We.current)==null||x.select()},0))},[s,P]),bt=c.useCallback(async()=>{const a=He.trim();if(Be(!1),!(!s||!a||a===s.title))try{const x=await Qs(s.id,a);r(S=>S&&{...S,title:x.title??a})}catch(x){console.error("Rename failed:",x),alert(x instanceof Error?x.message:"重命名失败")}},[s,He]),ws=c.useCallback(async a=>{try{await R.respondPermission(a,!1)}catch(x){console.error("Failed to reject:",x)}J(x=>x.filter(S=>S.requestId!==a))},[R]),ks=c.useCallback(async(a,x,S)=>{try{await W(n,{type:"permission_response",approved:!0,request_id:a,updated_input:{questions:S,answers:x}})}catch(k){console.error("Failed to submit answers:",k)}J(k=>k.filter(I=>I.requestId!==a))},[n]),Ns=c.useCallback(async(a,x,S)=>{try{x==="no"?await W(n,{type:"permission_response",approved:!1,request_id:a,...S?{message:S}:{}}):await W(n,{type:"permission_response",approved:!0,request_id:a,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[x]||"default",destination:"session"}]})}catch(k){console.error("Failed to submit plan response:",k)}J(k=>k.filter(I=>I.requestId!==a))},[n]);return l?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-status-error",children:l}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:v("session.backToDashboard")})]})}):s?s.source==="acp"&&s.environment_id?e.jsx($r,{sessionId:n,agentId:s.environment_id}):e.jsx(zt,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx("div",{className:"border-b bg-surface-1 px-4 py-3",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[it?e.jsx("input",{ref:We,value:He,onChange:a=>lt(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing?(a.preventDefault(),bt()):a.key==="Escape"&&(a.preventDefault(),Be(!1))},onBlur:()=>void bt(),maxLength:200,className:"w-full max-w-md rounded-lg border border-brand/50 bg-surface-2 px-2.5 py-1 font-display text-lg font-semibold text-text-primary focus:outline-none focus:ring-2 focus:ring-brand/30"}):e.jsxs("h2",{className:"group/title flex min-w-0 items-center gap-1.5 font-display text-lg font-semibold text-text-primary",children:[e.jsx("span",{className:"truncate",children:s.title||s.id}),!P&&!q&&e.jsx("button",{type:"button",onClick:js,className:"flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:text-text-primary group-hover/title:opacity-100",title:"重命名会话",children:e.jsx(Vs,{className:"h-3.5 w-3.5"})})]}),s.visibility&&!it&&e.jsx(un,{visibility:s.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var S;const a=s.source==="acp"?"acp":(S=s.environment)==null?void 0:S.worker_type,x=rn(a);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${x.colorClass}`,children:x.fullLabel})})(),o&&e.jsx(Bt,{status:o}),e.jsx("span",{className:"text-xs text-text-muted",children:Ht(s.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>De(!z),className:`relative flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${z?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:v("artifacts.title"),children:[e.jsx(Gs,{className:"h-3.5 w-3.5"}),ne>0&&!z&&e.jsx("span",{className:"absolute -right-1.5 -top-1.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-status-active px-1 text-[10px] font-bold text-white",children:ne>9?"9+":ne})]}),U.side_question&&!q&&!P&&e.jsx("button",{onClick:()=>i(!u),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${u?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"旁路提问 — 针对会话上下文提问,不进入主对话",children:e.jsx(Vt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>{const a=!p;y(a),a?setTimeout(()=>{var x;return(x=$.current)==null?void 0:x.focus()},0):(w(""),A(0))},className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${p?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"搜索会话内容",children:e.jsx(tt,{className:"h-3.5 w-3.5"})}),U.mcp_management&&!q&&!P&&e.jsx("button",{onClick:()=>j(!g),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${g?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"MCP 服务器",children:e.jsx(Gt,{className:"h-3.5 w-3.5"})}),U.remote_settings&&!q&&!P&&e.jsx("button",{onClick:()=>E(!N),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${N?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"会话设置",children:e.jsx(Yt,{className:"h-3.5 w-3.5"})}),!P&&(s==null?void 0:s.access_level)!=="write"&&e.jsx("button",{onClick:()=>L(!0),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:v("session.share"),children:e.jsx(Dn,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>_(!G),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:v("session.info"),children:e.jsx(Sn,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>h(!b),className:"flex items-center gap-1 rounded-md px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",children:[v("session.tasks"),ae.length>0&&e.jsx("span",{className:"ml-1 rounded-full bg-status-warning px-1.5 py-0.5 text-[10px] font-medium text-white",children:ae.length})]})]})]}),G&&e.jsxs("div",{className:"mt-2 rounded-md bg-surface-2 px-3 py-2 text-xs text-text-muted space-y-1 font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:v("session.metaSession")})," ",s.id]}),s.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:v("session.metaEnvironment")})," ",s.environment_id]})]})]})}),(ue==="reconnecting"||ue==="failed")&&e.jsxs("div",{className:`flex items-center justify-center gap-2 px-4 py-1.5 text-xs font-medium ${ue==="failed"?"bg-status-error/10 text-status-error":"bg-status-warning/10 text-status-warning"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${ue==="failed"?"bg-status-error":"animate-pulse bg-status-warning"}`}),ue==="failed"?v("session.sseFailed"):v("session.sseReconnecting")]}),z&&e.jsx("div",{className:"border-b bg-surface-1 px-4 py-4",children:e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(dn,{sessionId:n,embedded:!0,refreshTick:Oe})})}),p&&e.jsx("div",{className:"border-b bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto flex max-w-3xl items-center gap-2",children:[e.jsx(tt,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{ref:$,value:f,onChange:a=>{w(a.target.value),A(0)},onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing?(a.preventDefault(),ps(f&&a.shiftKey?C-1:C+1)):a.key==="Escape"&&(a.preventDefault(),y(!1),w(""))},placeholder:"搜索会话内容…",className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),f.trim()&&e.jsx("span",{className:"flex-shrink-0 font-mono text-[11px] text-text-muted",children:de.orderedMatchIds.length===0?"无结果":`${C+1}/${de.orderedMatchIds.length}`})]})}),e.jsx(Ys,{entries:re,isLoading:K,emptyTitle:v("session.emptyTitle"),emptyDescription:v("session.emptyDescription"),searchMatchIds:f.trim()?de.matchIds:void 0,onRewindEntry:U.rewind&&!q&&!P&&!K?(a,x)=>xs(a,x):void 0}),e.jsx(lr,{state:ts,onStopTask:U.stop_task?a=>{R.stopSubagent(a).then(x=>{x.ok||X(x.error||"停止任务失败")})}:void 0}),ae.length>0&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl space-y-3",children:ae.map(a=>e.jsx(Ar,{request:a,onApprove:()=>gs(a.requestId),onApproveAlways:a.suggestions&&a.suggestions.length>0?()=>ys(a.requestId,a.suggestions??[]):void 0,onReject:()=>ws(a.requestId),onSubmitAnswers:ks,onSubmitPlan:Ns},a.requestId))})}),ke&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(pr,{request:ke,onSubmit:bs})})}),ut&&e.jsx("div",{className:"mx-auto max-w-3xl w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:ut})}),ct&&e.jsx("div",{className:"mx-auto max-w-3xl w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:ct})}),e.jsxs("div",{className:"max-w-3xl mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Rr,{mode:_e,onModeChange:ze,disabled:q||P}),e.jsx(Mr,{models:(B==null?void 0:B.availableModels)??[],currentModelId:(B==null?void 0:B.currentModelId)??null,onSelect:a=>{W(n,{type:"control_request",request:{subtype:"set_model",model:a}}),Ue(x=>x&&{...x,currentModelId:a})},disabled:q||P}),U.set_max_thinking_tokens&&e.jsx(Cr,{budget:rt,onBudgetChange:ls,disabled:q||P}),U.set_effort&&e.jsx(Er,{effort:ht,onEffortChange:a=>ds.set(a),disabled:q||P})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[gt&&e.jsx(Tr,{usage:gt}),oe&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:"会话累计用量(input 含缓存读写)",children:[se(oe.inputTokens)," in / ",se(oe.outputTokens)," out",oe.totalCostUsd!=null&&` · $${oe.totalCostUsd.toFixed(2)}`]})]})]}),e.jsx(Js,{onSubmit:ms,isLoading:K,onInterrupt:yt,onCycleMode:hs,disabled:q||P,placeholder:q?v("session.closed"):P?v("session.readOnly"):v("session.inputPlaceholder"),supportsAttachments:!0,commands:Qe,queueWhileLoading:!0,queuedCount:Ne.length,onDequeue:a=>ve(x=>x.filter((S,k)=>k!==a)),onSearchFiles:U.file_search?a=>R.searchFiles(a):void 0,historyKey:n,draftOverride:F}),g&&e.jsx(er,{onClose:()=>j(!1),fetchServers:()=>R.getMcpServers(),onToggle:(a,x)=>R.toggleMcpServer(a,x),onReconnect:a=>R.reconnectMcpServer(a)}),N&&e.jsx(sr,{onClose:()=>E(!1),fetchSettings:()=>R.getRemoteSettings(),onApply:a=>R.applyFlagSettings(a)}),u&&e.jsx(nr,{onClose:()=>i(!1),onAsk:a=>R.askSideQuestion(a)}),b&&s&&e.jsx(Jn,{onClose:()=>h(!1),session:s,liveStatus:o,pendingPermissions:ae,onInterrupt:yt,onDelete:fs,onEndSession:U.end_session&&!q&&!P?async()=>{await R.endSession("ended from web"),await vt(s.id),window.location.href="/code/"}:void 0}),e.jsx(yr,{open:O,onClose:()=>L(!1),sessionId:s.id,sessionTitle:s.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:v("session.loading")})})}function Ar({request:n,onApprove:t,onApproveAlways:s,onReject:r,onSubmitAnswers:o,onSubmitPlan:d}){const l=n.toolName,m=n.toolInput,b=n.description||"";if(l==="AskUserQuestion"){const h=m.questions||[];return e.jsx(dr,{requestId:n.requestId,questions:h,description:b,onSubmit:g=>o(n.requestId,g,h),onSkip:r})}if(l==="ExitPlanMode"){const h=m.plan||"";return e.jsx(mr,{requestId:n.requestId,planContent:h,description:b,onSubmit:(g,j)=>d(n.requestId,g,j)})}return e.jsx(cr,{requestId:n.requestId,toolName:l,toolInput:m,description:b,suggestions:n.suggestions,onApprove:t,onApproveAlways:s,onReject:r})}function $r({sessionId:n,agentId:t}){const[s,r]=c.useState(null),[o,d]=c.useState("disconnected"),[l,m]=c.useState(null),b=c.useRef(null);return c.useEffect(()=>{const h=vr(t);return h.setConnectionStateHandler((g,j)=>{d(g),m(j||null)}),b.current=h,r(h),h.connect().catch(g=>{g instanceof Zs||(m(g.message),d("error"))}),()=>{h.disconnect(),b.current=null,r(null),d("disconnected")}},[t]),e.jsx(zt,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[l&&o==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:l}),o==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-text-muted text-sm",children:v("session.connectingAgent")})]})}),o==="error"&&!s&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:v("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:l})]})}),s&&o==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(en,{client:s,agentId:t})})]})})}export{Qr as SessionDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{ai as c,U as n,ag as i}from"./main-
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{ai as c,U as n,ag as i}from"./main-2KqxLOVo.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aB as v,aw as t}from"./main-2KqxLOVo.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function q({onSuccess:p,onAlreadyDone:b}){const{setup:f}=v(),[n,h]=r.useState(""),[l,y]=r.useState(""),[a,g]=r.useState(""),[d,w]=r.useState(""),[i,o]=r.useState(""),[c,m]=r.useState(!1),j=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==d){o(t("auth.setup.passwordMismatch"));return}m(!0);try{await f(n,l,a),p()}catch(x){const u=x instanceof Error?x.message:"Setup failed";if(u.includes("already")||u.includes("409")){b();return}o(u)}finally{m(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.setup.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.setup.description")})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.apiKey")}),e.jsx("input",{type:"password",value:n,onChange:s=>h(s.target.value),required:!0,autoComplete:"off",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.username")}),e.jsx("input",{type:"text",value:l,onChange:s=>y(s.target.value),required:!0,autoComplete:"username",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.confirmPassword")}),e.jsx("input",{type:"password",value:d,onChange:s=>w(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),i&&e.jsx("p",{className:"text-sm text-status-error",children:i}),e.jsx("button",{type:"submit",disabled:c,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:c?t("common.loading"):t("auth.setup.submit")})]})]})})}export{q as Setup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{a7 as m,b as h}from"./main-
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{a7 as m,b as h}from"./main-2KqxLOVo.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){const[t,r]=d.useState("loading"),[i,a]=d.useState(""),l=(typeof window<"u"?window.location.pathname:"").match(/\/code\/s\/([^/?]+)/),o=l?l[1]:null;return d.useEffect(()=>{if(!o){r("invalid"),a("Share link is invalid — no token found.");return}if(!o.startsWith("shr_")){r("invalid"),a("Invalid share token format.");return}let n=!1;async function c(){try{const s=await m(o);if(n)return;window.location.href=`/code/${s.id}`}catch(s){if(n)return;s instanceof h?s.status===401&&s.message.toLowerCase().includes("expired")?(r("expired"),a("This share has expired.")):s.status===404?s.message.toLowerCase().includes("session")?(r("not_found"),a("Session not found.")):(r("invalid"),a("Share not found or has been revoked.")):s.status===403?(r("invalid"),a("You do not have permission to access this share.")):(r("error"),a(s.message||"Failed to resolve share.")):(r("error"),a(s instanceof Error?s.message:"Failed to resolve share."))}}return c(),()=>{n=!0}},[o]),d.useEffect(()=>{if(t!=="loading"&&t!=="error"){const n=setTimeout(()=>{window.location.href="/code"},3e3);return()=>clearTimeout(n)}},[t]),t==="loading"?e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{children:"Resolving share link..."})]})}):e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-primary",children:e.jsxs("div",{className:"text-center max-w-md px-4",children:[t==="expired"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Share Expired"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share has expired."})]}),t==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Invalid Share"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share link is invalid or has been revoked."})]}),t==="not_found"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Not Found"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"The session could not be found."})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Error"}),e.jsx("p",{className:"text-status-error mb-4",children:i})]}),e.jsx("a",{href:"/code",className:"text-brand hover:underline",children:"← Back to Dashboard"})]})})}export{j as ShareLanding};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{aC as f,aD as y,aw as r}from"./main-2KqxLOVo.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function S(){f();const{createTeam:u}=y(),[o,p]=a.useState(""),[s,c]=a.useState(""),[i,b]=a.useState(""),[m,l]=a.useState(null),[d,x]=a.useState(!1),h=t=>{p(t),s||c(t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-"))},g=async t=>{t.preventDefault(),l(null),x(!0);try{const n=await u({name:o,slug:s,description:i||void 0});window.location.href=`/teams/${n.slug}`}catch(n){l(n instanceof Error?n.message:"Failed to create team")}finally{x(!1)}};return e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsx("h1",{className:"mb-10 font-display text-2xl font-semibold tracking-tight text-text-primary",children:r("team.create.title")}),e.jsxs("form",{onSubmit:g,className:"max-w-md space-y-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.name")}),e.jsx("input",{id:"name",type:"text",required:!0,value:o,onChange:t=>h(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"Engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.nameHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"slug",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.slug")}),e.jsx("input",{id:"slug",type:"text",required:!0,value:s,onChange:t=>c(t.target.value),pattern:"^[a-z0-9-]{3,32}$",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.slugHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.description")}),e.jsx("textarea",{id:"description",value:i,onChange:t=>b(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",rows:3})]}),m&&e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded-md border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2 transition-colors",children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:d||!o||!s,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:d?r("common.creating"):r("team.create.submit")})]})]})]})})}export{S as TeamCreate};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{ai as H,H as T,
|
|
1
|
+
import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{ai as H,H as T,aC as P,aw as i,d as B,X as G,z,$ as I,ae as W,ad as q,aB as X,w as Y,ag as J,j as K,o as Q,P as V,k as Z,m as ee,l as M,n as te,G as se}from"./main-2KqxLOVo.js";import{U as ae}from"./UserSearchInput-DgktGnh2.js";import{C as D}from"./copy-RtDWH7m7.js";import{g as ne}from"./workerType-Bd-zteMi.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
|
|
2
2
|
* @license lucide-react v0.555.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=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],ie=H("user-plus",re);function O(a){const[m,r]=n.useState([]),[w,j]=n.useState(!1),c=n.useCallback(async()=>{if(a){j(!0);try{const u=await T("GET",`/web/teams/${a}/members`);r(u)}catch{r([])}finally{j(!1)}}},[a]);n.useEffect(()=>{c()},[c]);const h=n.useCallback(async(u,f)=>{await T("POST",`/web/teams/${a}/members`,{userId:u,role:f}),await c()},[a,c]),x=n.useCallback(async u=>{await T("DELETE",`/web/teams/${a}/members/${u}`),await c()},[a,c]),l=n.useCallback(async(u,f)=>{await T("PATCH",`/web/teams/${a}/members/${u}`,{role:f}),await c()},[a,c]);return{members:m,isLoading:w,addMember:h,removeMember:x,updateRole:l,refetch:c}}function oe(a){const[m,r]=n.useState([]),w=n.useCallback(async c=>{if(!a)return null;const h=await T("POST",`/web/teams/${a}/invitations`,c);return r(x=>[...x,h]),h},[a]),j=n.useCallback(async c=>{a&&(await T("DELETE",`/web/teams/${a}/invitations/${c}`),r(h=>h.filter(x=>x.token!==c)))},[a]);return{invitations:m,createInvitation:w,revokeInvitation:j}}function ce({teamId:a,canManage:m}){P();const{invitations:r,createInvitation:w,revokeInvitation:j}=oe(a),{addMember:c}=O(a),[h,x]=n.useState(!1),[l,u]=n.useState(null),[f,E]=n.useState("member"),[d,g]=n.useState(!1),[y,b]=n.useState("member"),[v,L]=n.useState(null),[_,$]=n.useState(!1),[s,t]=n.useState(!1),[p,N]=n.useState(!1),S=async()=>{x(!0);try{const o=await w({role:f,expiresIn:86400,maxUses:5});o&&u(o.token||o.inviteToken||null)}catch{}finally{x(!1)}},A=async()=>{if(!l)return;const o=`${window.location.origin}/join?invite=${l}`;let k=!1;try{navigator.clipboard&&window.isSecureContext&&(await navigator.clipboard.writeText(o),k=!0)}catch{}if(!k){const C=document.createElement("textarea");C.value=o,C.style.position="fixed",C.style.top="0",C.style.opacity="0",document.body.appendChild(C),C.focus(),C.select(),C.setSelectionRange(0,o.length);try{k=document.execCommand("copy")}catch{k=!1}document.body.removeChild(C)}k?(N(!1),t(!0),setTimeout(()=>t(!1),2e3)):(t(!1),N(!0),setTimeout(()=>N(!1),4e3))},R=async o=>{$(!0),L(null);try{await c(o,y),g(!1)}catch(k){L(k instanceof Error?k.message:"Failed to add user")}finally{$(!1)}};return e.jsxs("div",{className:"space-y-5",children:[m&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",value:f,onChange:o=>E(o.target.value),children:[e.jsx("option",{value:"member",children:i("invitation.member")}),e.jsx("option",{value:"admin",children:i("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:S,disabled:h,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:opacity-50",children:h?i("invitation.creating"):i("invitation.create")}),e.jsxs("button",{type:"button",onClick:()=>g(!d),className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2",title:i("invitation.addExistingHint"),children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),i("invitation.addExisting")]})]}),d&&m&&e.jsxs("div",{className:"space-y-3 rounded border border-border bg-surface-2 p-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:i("invitation.addExistingHint")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("select",{className:"rounded border border-border bg-surface-1 px-2 py-1.5 text-sm",value:y,onChange:o=>b(o.target.value),children:[e.jsx("option",{value:"member",children:i("invitation.member")}),e.jsx("option",{value:"admin",children:i("invitation.admin")})]})}),v&&e.jsx("p",{className:"text-xs text-destructive",children:v}),e.jsx(ae,{onSelect:R,actionDisabled:_,placeholder:i("invitation.searchUser")})]}),l&&e.jsxs("div",{className:"space-y-1.5 rounded border border-accent/40 bg-accent/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-xs text-text-primary break-all",children:`${window.location.origin}/join?invite=${l}`}),e.jsx("button",{type:"button",onClick:A,className:s?"text-status-active":"text-text-muted hover:text-text-primary",title:s?i("share.copied"):i("share.copy"),children:s?e.jsx(B,{className:"h-4 w-4"}):e.jsx(D,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>u(null),className:"text-text-muted hover:text-text-primary",children:e.jsx(G,{className:"h-4 w-4"})})]}),s&&e.jsx("p",{className:"text-xs text-status-active",children:i("share.copied")}),p&&e.jsx("p",{className:"text-xs text-status-error",children:i("share.copyFailed")})]}),r.length>0&&e.jsx("ul",{className:"space-y-2",children:r.map(o=>e.jsxs("li",{className:"flex items-center justify-between rounded border border-border/60 bg-surface-2 p-2 text-sm",children:[e.jsxs("span",{className:"text-text-muted",children:[o.role," — expires ",new Date(o.expiresAt).toLocaleDateString()]}),m&&e.jsx("button",{type:"button",onClick:()=>j(o.token),className:"text-sm text-destructive hover:underline",children:i("invitation.revoke")})]},o.token))})]})}function le({teamId:a,canManage:m}){const[r,w]=n.useState([]),[j,c]=n.useState(!0),[h,x]=n.useState(null),[l,u]=n.useState(""),[f,E]=n.useState(null),[d,g]=n.useState(!1),y=async()=>{try{const s=await I();w(s||[])}catch(s){x(s instanceof Error?s.message:"Failed to load environments")}finally{c(!1)}};n.useEffect(()=>{y()},[]);const b=n.useMemo(()=>r.filter(s=>s.team_id===a),[r,a]),v=n.useMemo(()=>r.filter(s=>!s.team_id),[r]),L=async()=>{if(l){E(null);try{await q(l,a),u(""),await y()}catch(s){E(s instanceof Error?s.message:"Failed to link environment")}}},_=async s=>{if(window.confirm("Unlink this environment from the team? It will revert to personal scope.")){E(null);try{await W(a,s),await y()}catch(t){E(t instanceof Error?t.message:"Failed to unlink environment")}}},$=async()=>{const s=`slz rc --team-id ${a}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(s),g(!0),setTimeout(()=>g(!1),2e3);return}}catch{}const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),g(!0),setTimeout(()=>g(!1),2e3)}catch{}document.body.removeChild(t)};return j?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading environments..."}):h?e.jsx("p",{className:"text-sm text-destructive",children:h}):e.jsxs("div",{className:"space-y-8",children:[e.jsx("ul",{className:"space-y-3",children:b.length===0?e.jsx("li",{className:"text-sm text-text-muted",children:"No environments linked to this team yet."}):b.map(s=>{const t=ne(s.worker_type);return e.jsxs("li",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:s.machine_name||s.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${t.colorClass}`,children:t.shortLabel}),e.jsx(z,{status:s.status}),m&&e.jsx("button",{type:"button",onClick:()=>_(s.id),className:"ml-2 text-xs text-text-muted underline-offset-2 transition-colors hover:text-destructive hover:underline",children:"Unlink"})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-text-muted",children:[s.directory||""," ",s.branch?`· ${s.branch}`:""]})]},s.id)})}),m&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Register a new worker to this team:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"rounded-md border border-border bg-surface-2 px-3 py-1.5 font-mono text-xs text-text-primary",children:["slz rc --team-id ",a]}),e.jsx("button",{type:"button",onClick:$,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy command",children:e.jsx(D,{className:"h-3.5 w-3.5"})}),d&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"})]})]}),v.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Link an existing personal environment:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:l,onChange:s=>u(s.target.value),className:"max-w-md rounded-md border border-border bg-surface-2 px-3 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"",children:"Select environment..."}),v.map(s=>e.jsxs("option",{value:s.id,children:[s.machine_name||s.id," ",s.branch?`· ${s.branch}`:""]},s.id))]}),e.jsx("button",{type:"button",onClick:L,disabled:!l,className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:"Link"})]})]}),f&&e.jsx("p",{className:"text-sm text-destructive",children:f})]})]})}async function de(a){try{const m=a.startsWith("team_")?`/web/teams/${a}`:`/web/teams/by-slug/${a}`;return await T("GET",m)}catch{return null}}const me={owner:"team.member.roleOwner",admin:"team.member.roleAdmin",member:"team.member.roleMember"},U={owner:"border-brand/30 bg-brand/10 text-brand",admin:"border-accent/30 bg-accent/10 text-accent",member:"border-border/60 bg-surface-2 text-text-muted"};function F(a){return i(me[a]||"team.member.roleMember")}function ve(){P();const a=window.location.pathname.split("/"),m=a[a.length-1]||"",[r,w]=n.useState(null),[j,c]=n.useState(!0),[h,x]=n.useState(!1),{members:l,isLoading:u,updateRole:f,removeMember:E}=O((r==null?void 0:r.id)||null),{user:d}=X(),[g,y]=n.useState("");if(n.useEffect(()=>{m&&(c(!0),de(m).then(t=>{w(t),c(!1)}))},[m]),j)return e.jsx("div",{className:"px-6 py-16 text-sm text-text-muted",children:"Loading..."});if(!r)return e.jsx("div",{className:"px-6 py-16 sm:px-10",children:e.jsxs("div",{className:"max-w-3xl",children:[e.jsx("p",{className:"text-text-muted",children:"Team not found."}),e.jsx("a",{href:"/teams",className:"text-accent hover:underline",children:"Back to teams"})]})});const b=l.find(t=>t.user_id===(d==null?void 0:d.userId)),v=(d==null?void 0:d.role)==="admin"||(b==null?void 0:b.role)==="owner"||(b==null?void 0:b.role)==="admin",L=(d==null?void 0:d.role)==="admin"||(b==null?void 0:b.role)==="owner",_=async()=>{const t=r.id;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(t),x(!0),setTimeout(()=>x(!1),2e3);return}}catch{}const p=document.createElement("textarea");p.value=t,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select();try{document.execCommand("copy"),x(!0),setTimeout(()=>x(!1),2e3)}catch{}document.body.removeChild(p)},$=async(t,p)=>{if(t.role!==p){y("");try{await f(t.user_id,p)}catch(N){y(N instanceof Error?N.message:i("team.member.updateFailed"))}}},s=async t=>{const p=t.username||t.user_id;if(window.confirm(i("team.member.removeConfirm").replace("{name}",p))){y("");try{await E(t.user_id)}catch(S){y(S instanceof Error?S.message:i("team.member.updateFailed"))}}};return e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:r.name}),e.jsxs("p",{className:"mt-2 font-mono text-xs text-text-muted",children:["/",r.slug]}),r.description&&e.jsx("p",{className:"mt-5 max-w-2xl text-sm leading-relaxed text-text-muted",children:r.description}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx("code",{className:"font-mono text-xs text-text-muted",children:r.id}),e.jsx("button",{type:"button",onClick:_,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy team ID",children:e.jsx(D,{className:"h-3.5 w-3.5"})}),h&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"}),v&&e.jsx("a",{href:`/teams/${r.slug}/settings`,className:"ml-1 text-text-muted transition-colors hover:text-text-primary","aria-label":"Team settings",title:"Team settings",children:e.jsx(Y,{className:"h-4 w-4"})})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("div",{className:"mb-6 flex items-baseline justify-between",children:e.jsxs("h2",{className:"text-sm font-medium text-text-primary",children:[i("team.detail.members")," (",l.length,")"]})}),g&&e.jsx("div",{className:"mb-4 rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:g}),u?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading members..."}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No members."}):e.jsx("ul",{className:"space-y-2",children:l.map(t=>{const p=t.user_id===(d==null?void 0:d.userId),N=t.role==="owner"||t.role==="admin",S=v&&(!N||L),A=S&&!(t.role==="owner"&&l.filter(o=>o.role==="owner").length<=1),R=["owner","admin","member"];return e.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-xl border border-border bg-surface-1 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.username||t.user_id}),p&&e.jsx("span",{className:"text-xs text-text-muted",children:i("team.member.you")}),e.jsx("span",{className:J("shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium",U[t.role]||U.member),children:F(t.role)})]}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-text-muted",children:t.user_id})]}),v&&e.jsxs(K,{children:[e.jsx(Q,{asChild:!0,children:e.jsx("button",{type:"button",disabled:!S,className:"shrink-0 rounded-md p-1.5 text-text-muted transition-colors hover:bg-surface-2 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent","aria-label":i("team.member.changeRole"),title:i("team.member.changeRole"),children:e.jsx(V,{className:"h-4 w-4"})})}),e.jsxs(Z,{align:"end",className:"w-48",children:[e.jsx(ee,{className:"text-xs text-text-muted",children:i("team.member.changeRole")}),R.map(o=>e.jsxs(M,{onSelect:()=>$(t,o),className:"flex items-center justify-between",children:[e.jsx("span",{children:F(o)}),t.role===o&&e.jsx(B,{className:"h-3.5 w-3.5 text-brand"})]},o)),e.jsx(te,{}),e.jsxs(M,{variant:"destructive",disabled:!A,onSelect:()=>s(t),className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i("team.member.remove")})]})]})]})]},t.user_id)})})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:i("team.detail.environments")}),e.jsx(le,{teamId:r.id,canManage:v})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:i("team.detail.invitations")}),e.jsx(ce,{teamId:r.id,canManage:v})]})]})}export{ve as TeamDetail};
|
|
6
|
+
*/const re=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],ie=H("user-plus",re);function O(a){const[m,r]=n.useState([]),[w,j]=n.useState(!1),c=n.useCallback(async()=>{if(a){j(!0);try{const u=await T("GET",`/web/teams/${a}/members`);r(u)}catch{r([])}finally{j(!1)}}},[a]);n.useEffect(()=>{c()},[c]);const h=n.useCallback(async(u,f)=>{await T("POST",`/web/teams/${a}/members`,{userId:u,role:f}),await c()},[a,c]),x=n.useCallback(async u=>{await T("DELETE",`/web/teams/${a}/members/${u}`),await c()},[a,c]),l=n.useCallback(async(u,f)=>{await T("PATCH",`/web/teams/${a}/members/${u}`,{role:f}),await c()},[a,c]);return{members:m,isLoading:w,addMember:h,removeMember:x,updateRole:l,refetch:c}}function oe(a){const[m,r]=n.useState([]),w=n.useCallback(async c=>{if(!a)return null;const h=await T("POST",`/web/teams/${a}/invitations`,c);return r(x=>[...x,h]),h},[a]),j=n.useCallback(async c=>{a&&(await T("DELETE",`/web/teams/${a}/invitations/${c}`),r(h=>h.filter(x=>x.token!==c)))},[a]);return{invitations:m,createInvitation:w,revokeInvitation:j}}function ce({teamId:a,canManage:m}){P();const{invitations:r,createInvitation:w,revokeInvitation:j}=oe(a),{addMember:c}=O(a),[h,x]=n.useState(!1),[l,u]=n.useState(null),[f,E]=n.useState("member"),[d,g]=n.useState(!1),[y,b]=n.useState("member"),[v,L]=n.useState(null),[_,$]=n.useState(!1),[s,t]=n.useState(!1),[p,N]=n.useState(!1),S=async()=>{x(!0);try{const o=await w({role:f,expiresIn:86400,maxUses:5});o&&u(o.token||o.inviteToken||null)}catch{}finally{x(!1)}},R=async()=>{if(!l)return;const o=`${window.location.origin}/join?invite=${l}`;let k=!1;try{navigator.clipboard&&window.isSecureContext&&(await navigator.clipboard.writeText(o),k=!0)}catch{}if(!k){const C=document.createElement("textarea");C.value=o,C.style.position="fixed",C.style.top="0",C.style.opacity="0",document.body.appendChild(C),C.focus(),C.select(),C.setSelectionRange(0,o.length);try{k=document.execCommand("copy")}catch{k=!1}document.body.removeChild(C)}k?(N(!1),t(!0),setTimeout(()=>t(!1),2e3)):(t(!1),N(!0),setTimeout(()=>N(!1),4e3))},A=async o=>{$(!0),L(null);try{await c(o,y),g(!1)}catch(k){L(k instanceof Error?k.message:"Failed to add user")}finally{$(!1)}};return e.jsxs("div",{className:"space-y-5",children:[m&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",value:f,onChange:o=>E(o.target.value),children:[e.jsx("option",{value:"member",children:i("invitation.member")}),e.jsx("option",{value:"admin",children:i("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:S,disabled:h,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:opacity-50",children:h?i("invitation.creating"):i("invitation.create")}),e.jsxs("button",{type:"button",onClick:()=>g(!d),className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2",title:i("invitation.addExistingHint"),children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),i("invitation.addExisting")]})]}),d&&m&&e.jsxs("div",{className:"space-y-3 rounded border border-border bg-surface-2 p-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:i("invitation.addExistingHint")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("select",{className:"rounded border border-border bg-surface-1 px-2 py-1.5 text-sm",value:y,onChange:o=>b(o.target.value),children:[e.jsx("option",{value:"member",children:i("invitation.member")}),e.jsx("option",{value:"admin",children:i("invitation.admin")})]})}),v&&e.jsx("p",{className:"text-xs text-destructive",children:v}),e.jsx(ae,{onSelect:A,actionDisabled:_,placeholder:i("invitation.searchUser")})]}),l&&e.jsxs("div",{className:"space-y-1.5 rounded border border-accent/40 bg-accent/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-xs text-text-primary break-all",children:`${window.location.origin}/join?invite=${l}`}),e.jsx("button",{type:"button",onClick:R,className:s?"text-status-active":"text-text-muted hover:text-text-primary",title:s?i("share.copied"):i("share.copy"),children:s?e.jsx(B,{className:"h-4 w-4"}):e.jsx(D,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>u(null),className:"text-text-muted hover:text-text-primary",children:e.jsx(G,{className:"h-4 w-4"})})]}),s&&e.jsx("p",{className:"text-xs text-status-active",children:i("share.copied")}),p&&e.jsx("p",{className:"text-xs text-status-error",children:i("share.copyFailed")})]}),r.length>0&&e.jsx("ul",{className:"space-y-2",children:r.map(o=>e.jsxs("li",{className:"flex items-center justify-between rounded border border-border/60 bg-surface-2 p-2 text-sm",children:[e.jsxs("span",{className:"text-text-muted",children:[o.role," — expires ",new Date(o.expiresAt).toLocaleDateString()]}),m&&e.jsx("button",{type:"button",onClick:()=>j(o.token),className:"text-sm text-destructive hover:underline",children:i("invitation.revoke")})]},o.token))})]})}function le({teamId:a,canManage:m}){const[r,w]=n.useState([]),[j,c]=n.useState(!0),[h,x]=n.useState(null),[l,u]=n.useState(""),[f,E]=n.useState(null),[d,g]=n.useState(!1),y=async()=>{try{const s=await I();w(s||[])}catch(s){x(s instanceof Error?s.message:"Failed to load environments")}finally{c(!1)}};n.useEffect(()=>{y()},[]);const b=n.useMemo(()=>r.filter(s=>s.team_id===a),[r,a]),v=n.useMemo(()=>r.filter(s=>!s.team_id),[r]),L=async()=>{if(l){E(null);try{await q(l,a),u(""),await y()}catch(s){E(s instanceof Error?s.message:"Failed to link environment")}}},_=async s=>{if(window.confirm("Unlink this environment from the team? It will revert to personal scope.")){E(null);try{await W(a,s),await y()}catch(t){E(t instanceof Error?t.message:"Failed to unlink environment")}}},$=async()=>{const s=`slz rc --team-id ${a}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(s),g(!0),setTimeout(()=>g(!1),2e3);return}}catch{}const t=document.createElement("textarea");t.value=s,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy"),g(!0),setTimeout(()=>g(!1),2e3)}catch{}document.body.removeChild(t)};return j?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading environments..."}):h?e.jsx("p",{className:"text-sm text-destructive",children:h}):e.jsxs("div",{className:"space-y-8",children:[e.jsx("ul",{className:"space-y-3",children:b.length===0?e.jsx("li",{className:"text-sm text-text-muted",children:"No environments linked to this team yet."}):b.map(s=>{const t=ne(s.worker_type);return e.jsxs("li",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:s.machine_name||s.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${t.colorClass}`,children:t.shortLabel}),e.jsx(z,{status:s.status}),m&&e.jsx("button",{type:"button",onClick:()=>_(s.id),className:"ml-2 text-xs text-text-muted underline-offset-2 transition-colors hover:text-destructive hover:underline",children:"Unlink"})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-text-muted",children:[s.directory||""," ",s.branch?`· ${s.branch}`:""]})]},s.id)})}),m&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Register a new worker to this team:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"rounded-md border border-border bg-surface-2 px-3 py-1.5 font-mono text-xs text-text-primary",children:["slz rc --team-id ",a]}),e.jsx("button",{type:"button",onClick:$,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy command",children:e.jsx(D,{className:"h-3.5 w-3.5"})}),d&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"})]})]}),v.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Link an existing personal environment:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:l,onChange:s=>u(s.target.value),className:"max-w-md rounded-md border border-border bg-surface-2 px-3 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"",children:"Select environment..."}),v.map(s=>e.jsxs("option",{value:s.id,children:[s.machine_name||s.id," ",s.branch?`· ${s.branch}`:""]},s.id))]}),e.jsx("button",{type:"button",onClick:L,disabled:!l,className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:"Link"})]})]}),f&&e.jsx("p",{className:"text-sm text-destructive",children:f})]})]})}async function de(a){try{const m=a.startsWith("team_")?`/web/teams/${a}`:`/web/teams/by-slug/${a}`;return await T("GET",m)}catch{return null}}const me={owner:"team.member.roleOwner",admin:"team.member.roleAdmin",member:"team.member.roleMember"},U={owner:"border-brand/30 bg-brand/10 text-brand",admin:"border-accent/30 bg-accent/10 text-accent",member:"border-border/60 bg-surface-2 text-text-muted"};function F(a){return i(me[a]||"team.member.roleMember")}function ve(){P();const a=window.location.pathname.split("/"),m=a[a.length-1]||"",[r,w]=n.useState(null),[j,c]=n.useState(!0),[h,x]=n.useState(!1),{members:l,isLoading:u,updateRole:f,removeMember:E}=O((r==null?void 0:r.id)||null),{user:d}=X(),[g,y]=n.useState("");if(n.useEffect(()=>{m&&(c(!0),de(m).then(t=>{w(t),c(!1)}))},[m]),j)return e.jsx("div",{className:"px-6 py-16 text-sm text-text-muted",children:"Loading..."});if(!r)return e.jsx("div",{className:"px-6 py-16 sm:px-10",children:e.jsxs("div",{className:"max-w-3xl",children:[e.jsx("p",{className:"text-text-muted",children:"Team not found."}),e.jsx("a",{href:"/teams",className:"text-accent hover:underline",children:"Back to teams"})]})});const b=l.find(t=>t.user_id===(d==null?void 0:d.userId)),v=(d==null?void 0:d.role)==="admin"||(b==null?void 0:b.role)==="owner"||(b==null?void 0:b.role)==="admin",L=(d==null?void 0:d.role)==="admin"||(b==null?void 0:b.role)==="owner",_=async()=>{const t=r.id;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(t),x(!0),setTimeout(()=>x(!1),2e3);return}}catch{}const p=document.createElement("textarea");p.value=t,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select();try{document.execCommand("copy"),x(!0),setTimeout(()=>x(!1),2e3)}catch{}document.body.removeChild(p)},$=async(t,p)=>{if(t.role!==p){y("");try{await f(t.user_id,p)}catch(N){y(N instanceof Error?N.message:i("team.member.updateFailed"))}}},s=async t=>{const p=t.username||t.user_id;if(window.confirm(i("team.member.removeConfirm").replace("{name}",p))){y("");try{await E(t.user_id)}catch(S){y(S instanceof Error?S.message:i("team.member.updateFailed"))}}};return e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:r.name}),e.jsxs("p",{className:"mt-2 font-mono text-xs text-text-muted",children:["/",r.slug]}),r.description&&e.jsx("p",{className:"mt-5 max-w-2xl text-sm leading-relaxed text-text-muted",children:r.description}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx("code",{className:"font-mono text-xs text-text-muted",children:r.id}),e.jsx("button",{type:"button",onClick:_,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy team ID",children:e.jsx(D,{className:"h-3.5 w-3.5"})}),h&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"}),v&&e.jsx("a",{href:`/teams/${r.slug}/settings`,className:"ml-1 text-text-muted transition-colors hover:text-text-primary","aria-label":"Team settings",title:"Team settings",children:e.jsx(Y,{className:"h-4 w-4"})})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("div",{className:"mb-6 flex items-baseline justify-between",children:e.jsxs("h2",{className:"text-sm font-medium text-text-primary",children:[i("team.detail.members")," (",l.length,")"]})}),g&&e.jsx("div",{className:"mb-4 rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:g}),u?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading members..."}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No members."}):e.jsx("ul",{className:"space-y-2",children:l.map(t=>{const p=t.user_id===(d==null?void 0:d.userId),N=t.role==="owner"||t.role==="admin",S=v&&(!N||L),R=S&&!(t.role==="owner"&&l.filter(o=>o.role==="owner").length<=1),A=["owner","admin","member"];return e.jsxs("li",{className:"flex items-center justify-between gap-3 rounded-xl border border-border bg-surface-1 px-4 py-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.username||t.user_id}),p&&e.jsx("span",{className:"text-xs text-text-muted",children:i("team.member.you")}),e.jsx("span",{className:J("shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium",U[t.role]||U.member),children:F(t.role)})]}),e.jsx("div",{className:"mt-0.5 truncate font-mono text-xs text-text-muted",children:t.user_id})]}),v&&e.jsxs(K,{children:[e.jsx(Q,{asChild:!0,children:e.jsx("button",{type:"button",disabled:!S,className:"shrink-0 rounded-md p-1.5 text-text-muted transition-colors hover:bg-surface-2 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent","aria-label":i("team.member.changeRole"),title:i("team.member.changeRole"),children:e.jsx(V,{className:"h-4 w-4"})})}),e.jsxs(Z,{align:"end",className:"w-48",children:[e.jsx(ee,{className:"text-xs text-text-muted",children:i("team.member.changeRole")}),A.map(o=>e.jsxs(M,{onSelect:()=>$(t,o),className:"flex items-center justify-between",children:[e.jsx("span",{children:F(o)}),t.role===o&&e.jsx(B,{className:"h-3.5 w-3.5 text-brand"})]},o)),e.jsx(te,{}),e.jsxs(M,{variant:"destructive",disabled:!R,onSelect:()=>s(t),className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:i("team.member.remove")})]})]})]})]},t.user_id)})})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:i("team.detail.environments")}),e.jsx(le,{teamId:r.id,canManage:v})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:i("team.detail.invitations")}),e.jsx(ce,{teamId:r.id,canManage:v})]})]})}export{ve as TeamDetail};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{aD as l,q as a}from"./main-2KqxLOVo.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function c(){const{myTeams:t,isLoading:i}=l();return i?e.jsx("div",{className:"px-6 py-20 sm:px-10",children:e.jsxs("div",{className:"max-w-4xl",children:[e.jsx("div",{className:"h-8 w-32 animate-pulse rounded bg-surface-2"}),e.jsx("div",{className:"mt-12 space-y-10",children:[0,1,2].map(s=>e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-2"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-surface-2"})]},s))})]})}):e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary sm:text-4xl",children:"Teams"}),e.jsx("p",{className:"mt-3 text-sm text-text-muted",children:t.length===0?"Create your first team to start collaborating.":`${t.length} ${t.length===1?"team":"teams"}`})]}),t.length===0?e.jsx("div",{className:"py-8",children:e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-2 rounded-md bg-accent px-5 py-2.5 text-sm font-medium text-white transition-all hover:bg-accent/90 active:translate-y-px",children:[e.jsx(a,{className:"h-4 w-4"}),"Create team"]})}):e.jsx("ul",{className:"space-y-10",children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:`/teams/${s.slug}`,className:"group block",children:[e.jsxs("div",{className:"flex items-baseline gap-4",children:[e.jsx("h2",{className:"font-display text-xl font-medium tracking-tight text-text-primary transition-colors group-hover:text-accent",children:s.name}),e.jsxs("span",{className:"font-mono text-xs text-text-muted",children:["/",s.slug]})]}),s.description?e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-text-muted",children:s.description}):e.jsx("p",{className:"mt-2 text-sm italic text-text-muted/60",children:"No description"})]})},s.id))}),t.length>0&&e.jsx("div",{className:"mt-16",children:e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-2 rounded-md border border-border px-4 py-2 text-sm font-medium text-text-primary transition-all hover:bg-surface-2 active:translate-y-px",children:[e.jsx(a,{className:"h-4 w-4"}),"New team"]})})]})}export{c as TeamList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{H as c}from"./main-
|
|
1
|
+
import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{H as c}from"./main-2KqxLOVo.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";async function j(s){try{const r=s.startsWith("team_")?`/web/teams/${s}`:`/web/teams/by-slug/${s}`;return await c("GET",r)}catch{return null}}async function w(s,r){await c("PATCH",`/web/teams/${s}`,r)}async function N(s){await c("DELETE",`/web/teams/${s}`)}function k(){const s=window.location.pathname.split("/"),r=s[s.length-2]||"",[a,h]=n.useState(null),[b,y]=n.useState(!0),[i,m]=n.useState(""),[l,d]=n.useState(""),[u,o]=n.useState(null),[x,p]=n.useState(!1);n.useEffect(()=>{r&&j(r).then(t=>{t&&(h(t),m(t.name),d(t.description||"")),y(!1)})},[r]);const g=async t=>{if(t.preventDefault(),!!a){o(null),p(!0);try{await w(a.id,{name:i,description:l}),window.location.href=`/teams/${a.slug}`}catch(f){o(f instanceof Error?f.message:"Failed to update")}finally{p(!1)}}},v=async()=>{if(a&&window.confirm("Delete this team? Environments must be transferred first."))try{await N(a.id),window.location.href="/teams"}catch(t){o(t instanceof Error?t.message:"Failed to delete")}};return b?e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading..."}):a?e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsxs("header",{className:"mb-12",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:a.name}),e.jsxs("p",{className:"mt-1 font-mono text-xs text-text-muted",children:["/",a.slug]})]}),e.jsxs("form",{onSubmit:g,className:"mb-16 max-w-md space-y-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-2",children:"Team Name"}),e.jsx("input",{id:"name",type:"text",required:!0,value:i,onChange:t=>m(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-2",children:"Description"}),e.jsx("textarea",{id:"description",value:l,onChange:t=>d(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",rows:3})]}),u&&e.jsx("p",{className:"text-sm text-destructive",children:u}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded-md border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2 transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:x||!i,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:x?"Saving...":"Save Changes"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-sm font-medium text-destructive",children:"Delete team"}),e.jsx("p",{className:"mb-4 text-sm text-text-muted",children:"Deleting a team requires all environments to be transferred first."}),e.jsx("button",{type:"button",onClick:v,className:"rounded-md border border-destructive/60 px-4 py-2 text-sm font-medium text-destructive hover:bg-destructive/10 transition-colors",children:"Delete Team"})]})]})}):e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-8",children:[e.jsx("p",{className:"text-text-muted",children:"Team not found."}),e.jsx("a",{href:"/teams",className:"text-accent hover:underline",children:"Back to teams"})]})}export{k as TeamSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a,j as t}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as a,j as t}from"./vendor-DE_-CLIE.js";import{aC as v,aw as l,H as S}from"./main-2KqxLOVo.js";function U({onSelect:o,excludeUserIds:x=[],placeholder:u,actionLabel:m,actionDisabled:h=!1,className:p}){v();const[n,c]=a.useState(""),[b,s]=a.useState([]),[i,d]=a.useState(!1),f=async e=>{if(c(e),e.trim().length<2){s([]);return}d(!0);try{const N=await S("GET",`/web/users/search?q=${encodeURIComponent(e.trim())}`);s(N)}catch{s([])}finally{d(!1)}},y=e=>{o(e),c(""),s([])},r=b.filter(e=>!x.includes(e.id)),g=m??l("invitation.add"),j=u??l("invitation.searchUser");return t.jsxs("div",{className:p,children:[t.jsx("input",{type:"text",value:n,onChange:e=>f(e.target.value),placeholder:j,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),i&&t.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Searching..."}),r.length>0&&t.jsx("ul",{className:"mt-2 divide-y divide-border rounded border border-border bg-surface-1",children:r.map(e=>t.jsxs("li",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-text-primary",children:e.username}),t.jsx("div",{className:"truncate font-mono text-xs text-text-muted",children:e.id})]}),t.jsx("button",{type:"button",onClick:()=>y(e.id),disabled:h,className:"rounded bg-accent px-2 py-1 text-xs text-white hover:bg-accent/90 disabled:opacity-50",children:g})]},e.id))}),n.trim().length>=2&&r.length===0&&!i&&t.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"No users found."})]})}export{U};
|