@saluzi/saluzi-edu 0.2.68 → 0.2.69
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 +221 -203
- package/dist/rcs-web/assets/{AdminPanel-94uchXH7.js → AdminPanel-Ox9LWuFz.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ArtifactView-CT0Fu4U5.js → dist/rcs-web/assets/ArtifactView-B7a8Khfb.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ArtifactsGallery-DgK1CSno.js → dist/rcs-web/assets/ArtifactsGallery-CnV0vYtl.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Claim-C7V1Q01Y.js → dist/rcs-web/assets/Claim-Ck2lSDQo.js} +1 -1
- package/dist/rcs-web/assets/{Dashboard-NLM7Kgm8.js → Dashboard-C60GVEEA.js} +1 -1
- package/dist/rcs-web/assets/{Join-BhjsvbAP.js → Join-B-PK9ZgC.js} +1 -1
- package/dist/rcs-web/assets/{Login-DRFE4F-F.js → Login-DQ6FPOKM.js} +1 -1
- package/dist/rcs-web/assets/{Register-FgLOFB4h.js → Register-U7f5H-s4.js} +1 -1
- package/dist/rcs-web/assets/{SessionDetail-3P77L-sJ.js → SessionDetail-_9-CUGIK.js} +3 -3
- package/dist/rcs-web/assets/{SessionVisibilityBadge-raEV1sW8.js → SessionVisibilityBadge-DCKNddif.js} +1 -1
- package/dist/rcs-web/assets/{Setup-DDJHMu0z.js → Setup-DdUvqcnS.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-DG5JbaWg.js → ShareLanding-BIZozDi0.js} +1 -1
- package/dist/rcs-web/assets/{TeamCreate-D_AnatYF.js → TeamCreate-DTEQa91s.js} +1 -1
- package/dist/rcs-web/assets/{TeamDetail-C1FFiAj2.js → TeamDetail-DSbAaI5T.js} +1 -1
- package/dist/rcs-web/assets/{TeamList-tfsnwvZG.js → TeamList-B8CkSRFk.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-FeTuY9_I.js → TeamSettings-afAMifTT.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-Bu3RXDYh.js → UserSearchInput-CCwTLowu.js} +1 -1
- package/dist/rcs-web/assets/{UserSettings-BrjmELAZ.js → UserSettings-BS14QbPw.js} +1 -1
- package/dist/rcs-web/assets/{arc-Di9w8tGK.js → arc-D92zl5sb.js} +1 -1
- package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-FT-IsfVA.js → architectureDiagram-3BPJPVTR-BFS0ptEo.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DryBvbP3.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-BcDcn0zW.js} +1 -1
- package/dist/rcs-web/assets/{c4Diagram-AAUBKEIU-HWAmxH56.js → c4Diagram-AAUBKEIU-CfTZRvdU.js} +1 -1
- package/dist/rcs-web/assets/channel-YxmbxUMR.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-AdjHpC7B.js → chunk-2J33WTMH-D7uMaXAF.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-CpZ-59LR.js → chunk-4BX2VUAB-Cl8kGA_R.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-BBSmURaz.js → chunk-55IACEB6-B4zl1V4D.js} +1 -1
- package/dist/rcs-web/assets/{chunk-727SXJPM-1k6tgn8s.js → chunk-727SXJPM-DlSsa2cu.js} +1 -1
- package/dist/rcs-web/assets/{chunk-AQP2D5EJ-im0ij4Kj.js → chunk-AQP2D5EJ-C1rrenok.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-Cs3z8_hw.js → chunk-FMBD7UC4-DyKwyEWK.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-BA9iE2wc.js → chunk-ND2GUHAM-1AD_FvlP.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-DbvzoKsw.js → chunk-QZHKN3VN-EdHsPut0.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-BGm2vpEN.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-BGm2vpEN.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-wgmiR0vF.js → code-block-IT6T5CEO-CFM8l45C.js} +1 -1
- package/dist/rcs-web/assets/{copy-BD6qrRfd.js → copy-CxPcy5Mr.js} +1 -1
- package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-DT4C5Yz2.js → cose-bilkent-S5V4N54A-DIM61nZa.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-CRf1H6Hv.js → dagre-BM42HDAG-kszq2R0H.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-BChRpS-u.js → diagram-2AECGRRQ-CYJKb2wC.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-BicbIYus.js → diagram-5GNKFQAL-Czogc4aD.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-DCfQNjGq.js → diagram-KO2AKTUF-CkIjVAxE.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-mMyd4aUd.js → diagram-LMA3HP47-DGjTtYRO.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-DUWhyWTm.js → dist/rcs-web/assets/diagram-OG6HWLK6-CG5exhuD.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/dialog-DympH6_o.js → dist/rcs-web/assets/dialog-BU8x6OfJ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-DnBH3GMK.js → dist/rcs-web/assets/erDiagram-TEJ5UH35-BXY3YoP3.js} +1 -1
- package/dist/rcs-web/assets/{external-link-J-x6ty1h.js → external-link-BlJ3ree6.js} +1 -1
- package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-Ba7lo6ds.js → flowDiagram-I6XJVG4X-C6V4IR9e.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-CKkj67eu.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-BuvlJCin.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-205YdSRe.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-BWi6Gk9P.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-CpPvGigJ.js → infoDiagram-5YYISTIA-C4E3g5J9.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-D0ZEWQy7.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-RwMP4JwJ.js} +1 -1
- package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-DVl0M9a7.js → journeyDiagram-JHISSGLW-C3EZeQ-B.js} +1 -1
- package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-Dkr8uJC-.js → kanban-definition-UN3LZRKU-EFaG-oyy.js} +1 -1
- package/dist/rcs-web/assets/{linear-CIdvseqY.js → linear-zW0xy8Vx.js} +1 -1
- package/dist/rcs-web/assets/{main-B8hkVvfg.js → main-Cmt5Bx4n.js} +15 -15
- package/dist/rcs-web/assets/{mermaid-VLURNSYL-DdTSeoZS.js → mermaid-VLURNSYL-DWAG6oY9.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-CtvzCSq2.js → mermaid.core-BaQbfV6b.js} +5 -5
- package/{packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-CMlDCaV_.js → dist/rcs-web/assets/mindmap-definition-RKZ34NQL-mV3CmTd-.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-C6xMizTL.js → pieDiagram-4H26LBE5-b6H9mmnO.js} +1 -1
- package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-D6epraE1.js → quadrantDiagram-W4KKPZXB-BRD9QNPh.js} +1 -1
- package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-BHmML6bk.js → requirementDiagram-4Y6WPE33-CyhGkHSk.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-CIKij54Y.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-Dc7zSCp0.js} +1 -1
- package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-CY0y5zdR.js → sequenceDiagram-3UESZ5HK-5xTDzgqj.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-FBhNz1Lc.js → stateDiagram-AJRCARHV-CM5SjDk5.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-m7ruBTu5.js → stateDiagram-v2-BHNVJYJU-BVU9LVsH.js} +1 -1
- package/dist/rcs-web/assets/{timeline-definition-PNZ67QCA-CJopHs1x.js → timeline-definition-PNZ67QCA-DbLe-_KB.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/vennDiagram-CIIHVFJN-DF_uHOP7.js → dist/rcs-web/assets/vennDiagram-CIIHVFJN-CE3RaCv3.js} +1 -1
- package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-DQmjIZJA.js → wardleyDiagram-YWT4CUSO-Bl3rIzYJ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-v8zL-j4G.js → dist/rcs-web/assets/xychartDiagram-2RQKCTM6-BdfXvNSc.js} +1 -1
- package/dist/rcs-web/index.html +1 -1
- package/package.json +1 -1
- package/packages/remote-control-server/web/dist/assets/{AdminPanel-94uchXH7.js → AdminPanel-Ox9LWuFz.js} +1 -1
- package/{dist/rcs-web/assets/ArtifactView-CT0Fu4U5.js → packages/remote-control-server/web/dist/assets/ArtifactView-B7a8Khfb.js} +1 -1
- package/{dist/rcs-web/assets/ArtifactsGallery-DgK1CSno.js → packages/remote-control-server/web/dist/assets/ArtifactsGallery-CnV0vYtl.js} +1 -1
- package/{dist/rcs-web/assets/Claim-C7V1Q01Y.js → packages/remote-control-server/web/dist/assets/Claim-Ck2lSDQo.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Dashboard-NLM7Kgm8.js → Dashboard-C60GVEEA.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Join-BhjsvbAP.js → Join-B-PK9ZgC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Login-DRFE4F-F.js → Login-DQ6FPOKM.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Register-FgLOFB4h.js → Register-U7f5H-s4.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{SessionDetail-3P77L-sJ.js → SessionDetail-_9-CUGIK.js} +3 -3
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-raEV1sW8.js → SessionVisibilityBadge-DCKNddif.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Setup-DDJHMu0z.js → Setup-DdUvqcnS.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-DG5JbaWg.js → ShareLanding-BIZozDi0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamCreate-D_AnatYF.js → TeamCreate-DTEQa91s.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamDetail-C1FFiAj2.js → TeamDetail-DSbAaI5T.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamList-tfsnwvZG.js → TeamList-B8CkSRFk.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-FeTuY9_I.js → TeamSettings-afAMifTT.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-Bu3RXDYh.js → UserSearchInput-CCwTLowu.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSettings-BrjmELAZ.js → UserSettings-BS14QbPw.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-Di9w8tGK.js → arc-D92zl5sb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-FT-IsfVA.js → architectureDiagram-3BPJPVTR-BFS0ptEo.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DryBvbP3.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-BcDcn0zW.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{c4Diagram-AAUBKEIU-HWAmxH56.js → c4Diagram-AAUBKEIU-CfTZRvdU.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-YxmbxUMR.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-AdjHpC7B.js → chunk-2J33WTMH-D7uMaXAF.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-CpZ-59LR.js → chunk-4BX2VUAB-Cl8kGA_R.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BBSmURaz.js → chunk-55IACEB6-B4zl1V4D.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-727SXJPM-1k6tgn8s.js → chunk-727SXJPM-DlSsa2cu.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-im0ij4Kj.js → chunk-AQP2D5EJ-C1rrenok.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-Cs3z8_hw.js → chunk-FMBD7UC4-DyKwyEWK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-BA9iE2wc.js → chunk-ND2GUHAM-1AD_FvlP.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-DbvzoKsw.js → chunk-QZHKN3VN-EdHsPut0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-BGm2vpEN.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-BGm2vpEN.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-wgmiR0vF.js → code-block-IT6T5CEO-CFM8l45C.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-BD6qrRfd.js → copy-CxPcy5Mr.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-DT4C5Yz2.js → cose-bilkent-S5V4N54A-DIM61nZa.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-CRf1H6Hv.js → dagre-BM42HDAG-kszq2R0H.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-BChRpS-u.js → diagram-2AECGRRQ-CYJKb2wC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-BicbIYus.js → diagram-5GNKFQAL-Czogc4aD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-DCfQNjGq.js → diagram-KO2AKTUF-CkIjVAxE.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-mMyd4aUd.js → diagram-LMA3HP47-DGjTtYRO.js} +1 -1
- package/{dist/rcs-web/assets/diagram-OG6HWLK6-DUWhyWTm.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-CG5exhuD.js} +1 -1
- package/{dist/rcs-web/assets/dialog-DympH6_o.js → packages/remote-control-server/web/dist/assets/dialog-BU8x6OfJ.js} +1 -1
- package/{dist/rcs-web/assets/erDiagram-TEJ5UH35-DnBH3GMK.js → packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-BXY3YoP3.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{external-link-J-x6ty1h.js → external-link-BlJ3ree6.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-Ba7lo6ds.js → flowDiagram-I6XJVG4X-C6V4IR9e.js} +1 -1
- package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-CKkj67eu.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-BuvlJCin.js} +1 -1
- package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-205YdSRe.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-BWi6Gk9P.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-CpPvGigJ.js → infoDiagram-5YYISTIA-C4E3g5J9.js} +1 -1
- package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-D0ZEWQy7.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-RwMP4JwJ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-DVl0M9a7.js → journeyDiagram-JHISSGLW-C3EZeQ-B.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-Dkr8uJC-.js → kanban-definition-UN3LZRKU-EFaG-oyy.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-CIdvseqY.js → linear-zW0xy8Vx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-B8hkVvfg.js → main-Cmt5Bx4n.js} +15 -15
- package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-DdTSeoZS.js → mermaid-VLURNSYL-DWAG6oY9.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-CtvzCSq2.js → mermaid.core-BaQbfV6b.js} +5 -5
- package/{dist/rcs-web/assets/mindmap-definition-RKZ34NQL-CMlDCaV_.js → packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-mV3CmTd-.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-C6xMizTL.js → pieDiagram-4H26LBE5-b6H9mmnO.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-D6epraE1.js → quadrantDiagram-W4KKPZXB-BRD9QNPh.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-BHmML6bk.js → requirementDiagram-4Y6WPE33-CyhGkHSk.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-CIKij54Y.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-Dc7zSCp0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-CY0y5zdR.js → sequenceDiagram-3UESZ5HK-5xTDzgqj.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-FBhNz1Lc.js → stateDiagram-AJRCARHV-CM5SjDk5.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-m7ruBTu5.js → stateDiagram-v2-BHNVJYJU-BVU9LVsH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{timeline-definition-PNZ67QCA-CJopHs1x.js → timeline-definition-PNZ67QCA-DbLe-_KB.js} +1 -1
- package/{dist/rcs-web/assets/vennDiagram-CIIHVFJN-DF_uHOP7.js → packages/remote-control-server/web/dist/assets/vennDiagram-CIIHVFJN-CE3RaCv3.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-DQmjIZJA.js → wardleyDiagram-YWT4CUSO-Bl3rIzYJ.js} +1 -1
- package/{dist/rcs-web/assets/xychartDiagram-2RQKCTM6-v8zL-j4G.js → packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-BdfXvNSc.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +1 -1
- package/dist/rcs-web/assets/channel-N4W03sy5.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-CcBgewcu.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-CcBgewcu.js +0 -1
- package/packages/remote-control-server/web/dist/assets/channel-N4W03sy5.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-CcBgewcu.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-CcBgewcu.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{aq as c,ar as o,Q as m,al as s,ae as l,x as u}from"./main-
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{aq as c,ar as o,Q as m,al as s,ae as l,x as u}from"./main-Cmt5Bx4n.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){c();const[a,i]=d.useState([]),{myTeams:r,isLoading:x}=o(),n=d.useCallback(async()=>{try{const t=await m();i(t||[])}catch(t){console.error("Admin: failed to load sessions",t)}},[]);return d.useEffect(()=>{n()},[n]),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8",children:[e.jsx("h1",{className:"mb-6 font-display text-2xl font-semibold text-text-primary",children:s("admin.title")}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.teams")," (",r.length,")"]}),x?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("common.loading")}):r.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noTeams")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("a",{href:`/teams/${t.slug}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium text-text-primary",children:t.name}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:t.slug})]}),e.jsx("span",{className:"text-xs text-text-muted",children:l(new Date(t.created_at).getTime()/1e3)})]},t.id))})]}),e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.sessions")," (",a.length,")"]}),a.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noSessions")}):e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("a",{href:`/code/${t.id}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",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.title||t.id}),e.jsx("span",{className:"rounded-full bg-surface-2 px-2 py-0.5 text-xs text-text-muted",children:t.source||"unknown"})]}),e.jsx("div",{className:"truncate text-xs text-text-muted",children:t.id})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-3",children:[e.jsx(u,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:l(t.updated_at||t.created_at)})]})]},t.id))})]})]})})}export{j as AdminPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ab as y,aq as b,V as j,al as s,K as N,aa as v,z as w}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ab as y,aq as b,V as j,al as s,K as N,aa as v,z as w}from"./main-Cmt5Bx4n.js";import{C as g}from"./copy-CxPcy5Mr.js";import{E as k}from"./external-link-BlJ3ree6.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.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as i,j as e}from"./vendor-DE_-CLIE.js";import{aq as D,W as L,al as a,K as R,aa as B,F as M,g as K,z as A,p as S,H as P}from"./main-
|
|
1
|
+
import{e as i,j as e}from"./vendor-DE_-CLIE.js";import{aq as D,W as L,al as a,K as R,aa as B,F as M,g as K,z as A,p as S,H as P}from"./main-Cmt5Bx4n.js";import{D as H,a as F,c as O,d as _,b as z}from"./dialog-BU8x6OfJ.js";import{E as $}from"./external-link-BlJ3ree6.js";import{C as q}from"./copy-CxPcy5Mr.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";const v=`body { font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; max-width: 860px; margin: 2rem auto; padding: 0 1rem; color: #1a1a1a; }
|
|
2
2
|
h1 { font-size: 22px; } h1, h2 { color: #1a1a1a; }
|
|
3
3
|
.badge { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 500; }
|
|
4
4
|
.badge.ok { background: #dcfce7; color: #166534; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{E as u,Q as f}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{E as u,Q as f}from"./main-Cmt5Bx4n.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";const v=2e3,N=3e4;function E(){const c=window.location.pathname.split("/"),i=c[c.length-1]||"",[s,n]=r.useState("idle"),[m,l]=r.useState(null),[a,d]=r.useState(null);return r.useEffect(()=>{if(!i||!i.startsWith("clm_")){l("Invalid claim token"),n("error");return}n("claiming"),u(i).then(t=>{d(t.environment_id),n("waiting")}).catch(t=>{l(t instanceof Error?t.message:"Claim failed"),n("error")})},[i]),r.useEffect(()=>{if(s!=="waiting"||!a)return;let t=!1;const x=Date.now(),o=setInterval(()=>{if(Date.now()-x>N){clearInterval(o),t||n("timeout");return}f().then(h=>{t||(h||[]).some(p=>p.environment_id===a)&&(clearInterval(o),window.location.href="/code/")}).catch(()=>{})},v);return()=>{t=!0,clearInterval(o)}},[s,a]),s==="claiming"?e.jsx("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:e.jsx("p",{className:"text-sm text-text-muted",children:"Claiming environment..."})}):s==="error"?e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsx("a",{href:"/code",className:"mt-4 inline-block text-accent hover:underline",children:"Back to dashboard"})]}):s==="waiting"||s==="timeout"?e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-10",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:"Environment claimed"}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:"You are now the owner of this environment."})]}),e.jsxs("div",{className:"space-y-4",children:[a&&e.jsx("p",{className:"font-mono text-xs text-text-muted",children:a}),s==="waiting"?e.jsxs("p",{className:"text-sm text-text-muted",children:["Waiting for the worker to create a session",e.jsx("span",{className:"animate-pulse",children:"…"})]}):e.jsx("p",{className:"text-sm text-text-muted",children:"The worker has not created a session yet — it may be offline or stopped. The session will appear on the dashboard once the worker connects."}),e.jsx("a",{href:"/code",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 transition-colors",children:"Go to dashboard"})]})]}):e.jsx("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:e.jsx("p",{className:"text-sm text-text-muted",children:"Claiming environment..."})})}export{E as Claim};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,e as l}from"./vendor-DE_-CLIE.js";import{ab as O,a9 as _,ar as E,ap as T,x as F,aq as L,al as a,ae as A,q as $,s as W,e as q,r as H,d as P,ah as V,I as Q,Q as R,Y as U,N as Y}from"./main-
|
|
1
|
+
import{j as e,e as l}from"./vendor-DE_-CLIE.js";import{ab as O,a9 as _,ar as E,ap as T,x as F,aq as L,al as a,ae as A,q as $,s as W,e as q,r as H,d as P,ah as V,I as Q,Q as R,Y as U,N as Y}from"./main-Cmt5Bx4n.js";import{g as D}from"./workerType-Bd-zteMi.js";import{S as Z}from"./SessionVisibilityBadge-DCKNddif.js";import{D as z,a as G,c as J,d as K,b as X}from"./dialog-BU8x6OfJ.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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ap as v,al as t}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ap as v,al as t}from"./main-Cmt5Bx4n.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function E({onSuccess:b,onInvalidInvite:l}){const{join:h}=v(),[u,f]=r.useState(""),[d,j]=r.useState(""),[o,w]=r.useState(""),[c,g]=r.useState(""),[m,n]=r.useState(""),[x,p]=r.useState(!1);r.useEffect(()=>{const a=new URLSearchParams(window.location.search).get("invite");a?f(a):l()},[l]);const y=async s=>{if(s.preventDefault(),n(""),o.length<8){n(t("auth.setup.passwordTooShort"));return}if(o!==c){n(t("auth.setup.passwordMismatch"));return}p(!0);try{await h(u,d,o),b()}catch(a){const i=a instanceof Error?a.message:"Join failed";if(i.includes("Invalid invitation")||i.includes("expired")||i.includes("already used")){l();return}n(i)}finally{p(!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.join.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.join.welcome")}),e.jsx("p",{className:"mt-1 text-sm text-text-muted",children:t("auth.join.description")})]}),e.jsxs("form",{onSubmit:y,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.join.username")}),e.jsx("input",{type:"text",value:d,onChange:s=>j(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,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.join.password")}),e.jsx("input",{type:"password",value:o,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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:c,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"})]}),m&&e.jsx("p",{className:"text-sm text-status-error",children:m}),e.jsx("button",{type:"submit",disabled:x||!u,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:x?t("common.loading"):t("auth.join.submit")})]})]})})}export{E as Join};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ap as f,al as t}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ap as f,al as t}from"./main-Cmt5Bx4n.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function N({onSuccess:d,onNavigateRegister:c}){const{login:m,registrationAllowed:x}=f(),[a,p]=r.useState(""),[o,b]=r.useState(""),[l,n]=r.useState(""),[i,u]=r.useState(!1),h=async s=>{s.preventDefault(),n(""),u(!0);try{await m(a,o),d()}catch{n(t("auth.login.failed"))}finally{u(!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.login.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.login.description")})]}),e.jsxs("form",{onSubmit:h,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.login.username")}),e.jsx("input",{type:"text",value:a,onChange:s=>p(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,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.login.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>b(s.target.value),required:!0,autoComplete:"current-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"})]}),l&&e.jsx("p",{className:"text-sm text-status-error",children:l}),e.jsx("button",{type:"submit",disabled:i,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:i?t("common.loading"):t("auth.login.submit")})]}),x&&e.jsx("button",{type:"button",onClick:c,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.login.register")})]})})}export{N as Login};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ap as y,al as t}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ap as y,al as t}from"./main-Cmt5Bx4n.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function S({onSuccess:m,onBack:x}){const{register:p}=y(),[n,b]=r.useState(""),[a,h]=r.useState(""),[l,f]=r.useState(""),[i,o]=r.useState(""),[u,d]=r.useState(!1),g=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==l){o(t("auth.setup.passwordMismatch"));return}d(!0);try{await p(n,a),m()}catch(c){o(c instanceof Error?c.message:t("auth.register.failed"))}finally{d(!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.register.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.register.description")})]}),e.jsxs("form",{onSubmit:g,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.login.username")}),e.jsx("input",{type:"text",value:n,onChange:s=>b(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,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.login.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>h(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.join.confirmPassword")}),e.jsx("input",{type:"password",value:l,onChange:s=>f(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:u,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:u?t("common.loading"):t("auth.register.submit")})]}),e.jsx("button",{type:"button",onClick:x,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.register.backToLogin")})]})})}export{S as Register};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var lt=Object.defineProperty;var ct=(s,t,r)=>t in s?lt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var T=(s,t,r)=>ct(s,typeof t!="symbol"?t+"":t,r);import{e as u,j as e}from"./vendor-DE_-CLIE.js";import{ab as P,_ as dt,aj as ut,a5 as mt,af as pe,a4 as
|
|
1
|
+
var lt=Object.defineProperty;var ct=(s,t,r)=>t in s?lt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var T=(s,t,r)=>ct(s,typeof t!="symbol"?t+"":t,r);import{e as u,j as e}from"./vendor-DE_-CLIE.js";import{ab as P,_ as dt,aj as ut,a5 as mt,af as pe,a4 as O,$ as xt,x as Pe,g as ve,ae as qe,L as De,z as pt,w as ht,ad as $,a9 as J,d as Ue,am as _e,a0 as ft,J as yt,a3 as gt,aq as Oe,al as k,A as bt,ag as jt,G as wt,an as kt,ac as Nt,N as vt,a1 as _t,y as Fe,P as St,F as Ct,c as Mt,C as Et,R as Se,Z as Tt,ai as Rt,D as At,a as $t,q as Le,s as He,v as It,f as ze,e as Be,r as Ve,M as Pt}from"./main-Cmt5Bx4n.js";import{g as qt}from"./workerType-Bd-zteMi.js";import{D as We,a as Qe,c as Ge,d as Ke,b as Dt}from"./dialog-BU8x6OfJ.js";import{E as Ut}from"./external-link-BlJ3ree6.js";import{S as Ot}from"./SessionVisibilityBadge-DCKNddif.js";import{U as Ft}from"./UserSearchInput-CCwTLowu.js";import{ArtifactsGallery as Lt}from"./ArtifactsGallery-CnV0vYtl.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";import"./copy-CxPcy5Mr.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -53,8 +53,8 @@ var lt=Object.defineProperty;var ct=(s,t,r)=>t in s?lt(s,t,{enumerable:!0,config
|
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const is=[["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"}]],ls=P("triangle-alert",is);function Je(){return{tasks:{}}}const Ce=3e4;function re(s){const t=s.trim();if(!t)return"agent";const r=t.split(/\s+/).slice(0,2).join(" ");return r.length>40?r.slice(0,40)+"…":r}function cs(s,t){var d,x,p,m,g,j,w,_,a,o,f,y;const r=t.subtype;if(r!=="task_started"&&r!=="task_progress"&&r!=="task_notification")return s;const n=t.task_id;if(!n)return s;const l=Date.now(),c=s.tasks[n];if(r==="task_started"){if(c)return{tasks:{...s.tasks,[n]:{...c,description:t.description??c.description,name:re(t.description??c.description),taskType:t.task_type??c.taskType,workflowName:t.workflow_name??c.workflowName,prompt:t.prompt??c.prompt,toolUseId:t.tool_use_id??c.toolUseId,status:"running",startTime:l,evictAfter:void 0}}};const b=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:re(b),description:b,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:l}}}}if(r==="task_progress"){if(!c){const b=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:re(b),description:b,toolUseId:t.tool_use_id,status:"running",startTime:l,tokenCount:(d=t.usage)==null?void 0:d.total_tokens,toolUseCount:(x=t.usage)==null?void 0:x.tool_uses,durationMs:(p=t.usage)==null?void 0:p.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[n]:{...c,description:t.description??c.description,tokenCount:((m=t.usage)==null?void 0:m.total_tokens)??c.tokenCount,toolUseCount:((g=t.usage)==null?void 0:g.tool_uses)??c.toolUseCount,durationMs:((j=t.usage)==null?void 0:j.duration_ms)??c.durationMs,lastToolName:t.last_tool_name??c.lastToolName,summary:t.summary??c.summary}}}}return c?{tasks:{...s.tasks,[n]:{...c,status:t.status??"completed",endTime:l,finalSummary:t.summary??c.finalSummary,outputFile:t.output_file??c.outputFile,tokenCount:((o=t.usage)==null?void 0:o.total_tokens)??c.tokenCount,toolUseCount:((f=t.usage)==null?void 0:f.tool_uses)??c.toolUseCount,durationMs:((y=t.usage)==null?void 0:y.duration_ms)??c.durationMs,evictAfter:l+Ce}}}:{tasks:{...s.tasks,[n]:{taskId:n,name:re(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:l,endTime:l,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(w=t.usage)==null?void 0:w.total_tokens,toolUseCount:(_=t.usage)==null?void 0:_.tool_uses,durationMs:(a=t.usage)==null?void 0:a.duration_ms,evictAfter:l+Ce}}}}function ds(s,t=Date.now()){return Object.values(s.tasks).filter(r=>r.evictAfter===void 0||r.evictAfter>t).sort((r,n)=>r.startTime-n.startTime)}class us{constructor(){T(this,"listeners",new Set);T(this,"eventSource",null);T(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const r=`/web/sessions/${t}/events`,n=new EventSource(r,{withCredentials:!0});this.eventSource=n,n.addEventListener("message",l=>{try{const c=JSON.parse(l.data);if(c.seqNum!==void 0&&c.seqNum<=this._lastSeqNum)return;c.seqNum!==void 0&&(this._lastSeqNum=c.seqNum);for(const d of this.listeners)d(c)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const he=new us;function Me(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(r=>r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("")}return""}function Ee(s,t){for(let r=s.length-1;r>=0;r--){const n=s[r];if(n&&n.type==="tool_call"&&n.toolCall.id===t)return r}return-1}const fe="streaming-";function ms(s){const t=s.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const r=[];for(const n of t.content)if((n==null?void 0:n.type)==="thinking"){const l=typeof n.thinking=="string"&&n.thinking||typeof n.text=="string"&&n.text||"";l&&r.push(l)}return r.join("")}function Te(s){return s.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"}))}class xs{constructor(t,r,n){T(this,"sessionId");T(this,"setEntries");T(this,"unsub",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,"subagentState",Je());T(this,"seenUuids",new Set);T(this,"seenToolCallIds",new Set);T(this,"pendingControlRequests",new Map);T(this,"turnEnded",!1);T(this,"userSinceTurnEnd",!1);this.sessionId=t,this.setEntries=r,this.onStatusChange=n==null?void 0:n.onStatusChange,this.onError=n==null?void 0:n.onError,this.onPermissionRequest=n==null?void 0:n.onPermissionRequest,this.onModelsStateChange=n==null?void 0:n.onModelsStateChange,this.onSubagentUpdate=n==null?void 0:n.onSubagentUpdate,this.onControlResponse=n==null?void 0:n.onControlResponse,this.onPermissionModeChange=n==null?void 0:n.onPermissionModeChange,this.onUsageChange=n==null?void 0:n.onUsageChange,this.onElicitationRequest=n==null?void 0:n.onElicitationRequest}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var m,g,j;const{events:t}=await dt(this.sessionId);if(!t||t.length===0)return;const r=[];let n=null;const l=()=>{n&&(r.push(n),n=null)};for(const w of t){const _=w.payload||{},a=_.uuid;if(typeof a=="string"&&a&&this.seenUuids.add(a),w.type==="tool_use"){const o=_.tool_call_id;typeof o=="string"&&o&&this.seenToolCallIds.add(o)}if(w.type==="user"){if(w.direction==="inbound")continue;l();const o=Me(_);o&&r.push({type:"user_message",id:w.id||`hist-user-${r.length}`,content:o})}else if(w.type==="assistant"){l();const o=Me(_),f=[],y=_.message;if(y&&typeof y=="object"&&Array.isArray(y.content)){for(const b of y.content)if(b.type==="tool_use"){const N=b.id;N&&this.seenToolCallIds.add(N),f.push({type:"tool_call",toolCall:{id:N||`hist-tool-${r.length}`,title:b.name||"tool",status:"complete",rawInput:b.input||{}}})}}if(o||f.length>0){n={type:"assistant_message",id:w.id||`hist-asst-${r.length}`,chunks:o?[{type:"message",text:o}]:[]},r.push(n);for(const b of f)r.push(b);n=null}}else if(w.type==="tool_use"){const o=_,f={type:"tool_call",toolCall:{id:o.tool_call_id||`hist-tool-${r.length}`,title:o.tool_name||"tool",status:"complete",rawInput:o.tool_input||{}}};r.push(f)}else if(w.type==="tool_result"){const o=_,f=Ee(r,o.tool_call_id||"");if(f>=0){const y=r[f];r[f]={type:"tool_call",toolCall:{...y.toolCall,rawOutput:{output:o.content||o.output||""}}}}}}l();let c=null;for(const w of t){if(w.type!=="task_state")continue;const _=w.payload||{};Array.isArray(_.tasks)&&(c=_.tasks)}if(c&&c.length>0){const w=Te(c);w.length>0&&r.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:w})}this.setEntries(r);let d=null,x=null,p=null;for(const w of t){const _=w.payload||{};if(w.type==="user"?p="user":(w.type==="result"||w.type==="result_success"||w.type==="interrupt")&&(p="turn_end"),w.type==="models_state"){const a=_.raw,o=a&&typeof a=="object"?a.models_state:_.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&(d=o)}else if(w.type==="result"||w.type==="result_success"){const a=_.usage,o=typeof _.total_cost_usd=="number"?_.total_cost_usd:null;(a||o!==null)&&(x={inputTokens:((a==null?void 0:a.input_tokens)??0)+((a==null?void 0:a.cache_read_input_tokens)??0)+((a==null?void 0:a.cache_creation_input_tokens)??0),outputTokens:(a==null?void 0:a.output_tokens)??0,totalCostUsd:o})}}d&&((m=this.onModelsStateChange)==null||m.call(this,d)),x&&((g=this.onUsageChange)==null||g.call(this,x)),this.turnEnded=p==="turn_end",this.userSinceTurnEnd=p==="user",this.turnEnded&&((j=this.onStatusChange)==null||j.call(this,"idle"))}connectSSE(){he.connect(this.sessionId),this.unsub=he.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),he.disconnect()}handleEvent(t){var c,d,x,p,m,g,j,w,_;const r=t.type,n=t.payload||{},l=JSON.stringify(t);if(!/Remote Control connecting/i.test(l))switch(r){case"user":{this.userSinceTurnEnd=!0;break}case"assistant":{const a=n.uuid;if(typeof a=="string"&&a){if(this.seenUuids.has(a))break;this.seenUuids.add(a)}const o=typeof n.content=="string"?n.content:"",f=ms(n);this.setEntries(b=>{const N=b[b.length-1];if((N==null?void 0:N.type)==="assistant_message"&&N.id.startsWith(fe))return[...b.slice(0,-1),{...N,id:`assistant-${Date.now()}`,chunks:[...f?[{type:"thought",text:f}]:[],{type:"message",text:o}]}];if((N==null?void 0:N.type)==="assistant_message"){const M=N.chunks[N.chunks.length-1];return(M==null?void 0:M.type)==="message"?[...b.slice(0,-1),{...N,chunks:[...N.chunks.slice(0,-1),{type:"message",text:M.text+o}]}]:[...b.slice(0,-1),{...N,chunks:[...N.chunks,{type:"message",text:o}]}]}if(o&&o.trim()||f){const M={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...f?[{type:"thought",text:f}]:[],...o?[{type:"message",text:o}]:[]]};return[...b,M]}return b});const y=n.message;if(y&&typeof y=="object"&&Array.isArray(y.content)){const b=y.content.filter(N=>N.type==="tool_use");for(const N of b){const M=N.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(M))continue;this.seenToolCallIds.add(M);const A={id:M,title:N.name||"tool",status:"running",rawInput:N.input||{}};this.setEntries(E=>[...E,{type:"tool_call",toolCall:A}])}}break}case"tool_use":{const a=n,o=a.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(o))break;this.seenToolCallIds.add(o);const f={id:o,title:a.tool_name||"tool",status:"running",rawInput:a.tool_input||{}};this.setEntries(y=>[...y,{type:"tool_call",toolCall:f}]);break}case"tool_result":{const a=n,o=a.tool_call_id||"";this.setEntries(f=>{const y=Ee(f,o);if(y<0)return f;const b=f[y];return f.map((N,M)=>M===y?{type:"tool_call",toolCall:{...b.toolCall,status:"complete",rawOutput:{output:a.content||a.output||""}}}:N)});break}case"control_request":case"permission_request":{const a=n.request;if(a&&a.subtype==="can_use_tool"){const o=n.request_id||"",f=a.tool_name||"unknown",y=a.input||a.tool_input||{},b=a.description||"",N=Array.isArray(a.permission_suggestions)?a.permission_suggestions:[];this.setEntries(M=>{const A=[...M].reverse().findIndex(E=>E.type==="tool_call");if(A>=0){const E=M.length-1-A,D=M[E];if(D.toolCall.status==="running")return M.map((H,W)=>W===E?{type:"tool_call",toolCall:{...D.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:o,options:[]}}}:H)}return M}),(c=this.onPermissionRequest)==null||c.call(this,{requestId:o,toolName:f,toolInput:y,description:b,suggestions:N})}else a&&a.subtype==="elicitation"&&((d=this.onElicitationRequest)==null||d.call(this,{requestId:n.request_id||"",serverName:a.mcp_server_name||"",message:a.message||"",mode:a.mode==="url"?"url":"form",url:typeof a.url=="string"?a.url:void 0,requestedSchema:a.requested_schema||void 0}));break}case"session_status":{if(ut(n)){this.setEntries([]);break}if(typeof n.status=="string"){if(n.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(x=this.onStatusChange)==null||x.call(this,n.status)}break}case"error":{const a=String(n.message||n.content||"Unknown error");(p=this.onError)==null||p.call(this,a);break}case"models_state":{const a=n.raw,o=typeof a=="object"&&a!==null?a.models_state:n.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&((m=this.onModelsStateChange)==null||m.call(this,o));break}case"system":{const a=n.raw,o=a&&typeof a=="object"?a:n,f=typeof o.subtype=="string"?o.subtype:void 0;if(f==="task_started"||f==="task_progress"||f==="task_notification"){const b={subtype:f,task_id:typeof o.task_id=="string"?o.task_id:void 0,tool_use_id:typeof o.tool_use_id=="string"?o.tool_use_id:void 0,description:typeof o.description=="string"?o.description:void 0,task_type:typeof o.task_type=="string"?o.task_type:void 0,workflow_name:typeof o.workflow_name=="string"?o.workflow_name:void 0,prompt:typeof o.prompt=="string"?o.prompt:void 0,usage:o.usage&&typeof o.usage=="object"?o.usage:void 0,last_tool_name:typeof o.last_tool_name=="string"?o.last_tool_name:void 0,summary:typeof o.summary=="string"?o.summary:void 0,status:o.status==="completed"||o.status==="failed"||o.status==="stopped"?o.status:void 0,output_file:typeof o.output_file=="string"?o.output_file:void 0};this.subagentState=cs(this.subagentState,b)}const y=typeof o.permissionMode=="string"?o.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;y&&((g=this.onPermissionModeChange)==null||g.call(this,y));break}case"control_response":{const a=n.response;if(a&&typeof a=="object"){const o=typeof a.request_id=="string"?a.request_id:"",f=typeof a.subtype=="string"?a.subtype:"";if(o){(j=this.onControlResponse)==null||j.call(this,{subtype:f,requestId:o,error:typeof a.error=="string"?a.error:void 0});const y=this.pendingControlRequests.get(o);y&&(this.pendingControlRequests.delete(o),y(f==="success"&&a.response&&typeof a.response=="object"?a.response:null))}}break}case"stream_event":{const a=n.event;if(!a||typeof a.type!="string")break;if(a.type==="content_block_delta"){const o=a.delta;if(!o||typeof o.type!="string")break;const f=o.type==="text_delta"?"message":o.type==="thinking_delta"?"thought":null;if(!f)break;const y=o.text??o.thinking;if(typeof y!="string"||!y)break;this.appendStreamingDelta(f,y)}break}case"partial_assistant":{const a=typeof n.content=="string"?n.content:"";a&&this.appendStreamingDelta("message",a);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,(w=this.onStatusChange)==null||w.call(this,"idle");const a=n.usage,o=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(a||o!==null){const f=((a==null?void 0:a.input_tokens)??0)+((a==null?void 0:a.cache_read_input_tokens)??0)+((a==null?void 0:a.cache_creation_input_tokens)??0);(_=this.onUsageChange)==null||_.call(this,{inputTokens:f,outputTokens:(a==null?void 0:a.output_tokens)??0,totalCostUsd:o})}break}case"task_state":{const a=Array.isArray(n.tasks)?n.tasks:[];if(a.length===0)break;const o=Te(a);if(o.length===0)break;this.setEntries(f=>[...f.filter(b=>b.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:o}]);break}}}appendStreamingDelta(t,r){this.setEntries(n=>{const l=n[n.length-1];if((l==null?void 0:l.type)==="assistant_message"&&l.id.startsWith(fe)){const d=l.chunks[l.chunks.length-1];return(d==null?void 0:d.type)===t?[...n.slice(0,-1),{...l,chunks:[...l.chunks.slice(0,-1),{type:t,text:d.text+r}]}]:[...n.slice(0,-1),{...l,chunks:[...l.chunks,{type:t,text:r}]}]}const c={type:"assistant_message",id:`${fe}${Date.now()}`,chunks:[{type:t,text:r}]};return[...n,c]})}async sendMessage(t,r,n){const l=r&&r.length>0,c=n&&n.length>0;if(!t.trim()&&!l&&!c)return;const d={type:"user_message",id:`user-${Date.now()}`,content:t,images:l?r:void 0,attachments:c?n:void 0};this.setEntries(m=>[...m,d]);const x=[];if(t&&x.push({type:"text",text:t}),l)for(const m of r)x.push({type:"image",source:{type:"base64",media_type:m.mimeType,data:m.data}});if(c){for(const m of n)if(m.kind==="text"||m.kind==="table"){const g=`📎 ${m.name}${m.size!=null?` (${ps(m.size)})`:""}`,j=m.textContent||"(空文件)";x.push({type:"text",text:`${g}
|
|
56
|
+
*/const is=[["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"}]],ls=P("triangle-alert",is);function Je(){return{tasks:{}}}const Ce=3e4;function re(s){const t=s.trim();if(!t)return"agent";const r=t.split(/\s+/).slice(0,2).join(" ");return r.length>40?r.slice(0,40)+"…":r}function cs(s,t){var d,x,p,m,g,j,w,_,a,o,f,y;const r=t.subtype;if(r!=="task_started"&&r!=="task_progress"&&r!=="task_notification")return s;const n=t.task_id;if(!n)return s;const l=Date.now(),c=s.tasks[n];if(r==="task_started"){if(c)return{tasks:{...s.tasks,[n]:{...c,description:t.description??c.description,name:re(t.description??c.description),taskType:t.task_type??c.taskType,workflowName:t.workflow_name??c.workflowName,prompt:t.prompt??c.prompt,toolUseId:t.tool_use_id??c.toolUseId,status:"running",startTime:l,evictAfter:void 0}}};const b=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:re(b),description:b,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:l}}}}if(r==="task_progress"){if(!c){const b=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:re(b),description:b,toolUseId:t.tool_use_id,status:"running",startTime:l,tokenCount:(d=t.usage)==null?void 0:d.total_tokens,toolUseCount:(x=t.usage)==null?void 0:x.tool_uses,durationMs:(p=t.usage)==null?void 0:p.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[n]:{...c,description:t.description??c.description,tokenCount:((m=t.usage)==null?void 0:m.total_tokens)??c.tokenCount,toolUseCount:((g=t.usage)==null?void 0:g.tool_uses)??c.toolUseCount,durationMs:((j=t.usage)==null?void 0:j.duration_ms)??c.durationMs,lastToolName:t.last_tool_name??c.lastToolName,summary:t.summary??c.summary}}}}return c?{tasks:{...s.tasks,[n]:{...c,status:t.status??"completed",endTime:l,finalSummary:t.summary??c.finalSummary,outputFile:t.output_file??c.outputFile,tokenCount:((o=t.usage)==null?void 0:o.total_tokens)??c.tokenCount,toolUseCount:((f=t.usage)==null?void 0:f.tool_uses)??c.toolUseCount,durationMs:((y=t.usage)==null?void 0:y.duration_ms)??c.durationMs,evictAfter:l+Ce}}}:{tasks:{...s.tasks,[n]:{taskId:n,name:re(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:l,endTime:l,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(w=t.usage)==null?void 0:w.total_tokens,toolUseCount:(_=t.usage)==null?void 0:_.tool_uses,durationMs:(a=t.usage)==null?void 0:a.duration_ms,evictAfter:l+Ce}}}}function ds(s,t=Date.now()){return Object.values(s.tasks).filter(r=>r.evictAfter===void 0||r.evictAfter>t).sort((r,n)=>r.startTime-n.startTime)}class us{constructor(){T(this,"listeners",new Set);T(this,"eventSource",null);T(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const r=`/web/sessions/${t}/events`,n=new EventSource(r,{withCredentials:!0});this.eventSource=n,n.addEventListener("message",l=>{try{const c=JSON.parse(l.data);if(c.seqNum!==void 0&&c.seqNum<=this._lastSeqNum)return;c.seqNum!==void 0&&(this._lastSeqNum=c.seqNum);for(const d of this.listeners)d(c)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const he=new us;function Me(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(r=>r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("")}return""}function Ee(s,t){for(let r=s.length-1;r>=0;r--){const n=s[r];if(n&&n.type==="tool_call"&&n.toolCall.id===t)return r}return-1}const fe="streaming-";function ms(s){const t=s.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const r=[];for(const n of t.content)if((n==null?void 0:n.type)==="thinking"){const l=typeof n.thinking=="string"&&n.thinking||typeof n.text=="string"&&n.text||"";l&&r.push(l)}return r.join("")}function Te(s){return s.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"}))}class xs{constructor(t,r,n){T(this,"sessionId");T(this,"setEntries");T(this,"unsub",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,"subagentState",Je());T(this,"seenUuids",new Set);T(this,"seenToolCallIds",new Set);T(this,"pendingControlRequests",new Map);T(this,"turnEnded",!1);T(this,"userSinceTurnEnd",!1);this.sessionId=t,this.setEntries=r,this.onStatusChange=n==null?void 0:n.onStatusChange,this.onError=n==null?void 0:n.onError,this.onPermissionRequest=n==null?void 0:n.onPermissionRequest,this.onModelsStateChange=n==null?void 0:n.onModelsStateChange,this.onSubagentUpdate=n==null?void 0:n.onSubagentUpdate,this.onControlResponse=n==null?void 0:n.onControlResponse,this.onPermissionModeChange=n==null?void 0:n.onPermissionModeChange,this.onUsageChange=n==null?void 0:n.onUsageChange,this.onElicitationRequest=n==null?void 0:n.onElicitationRequest}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var m,g,j;const{events:t}=await dt(this.sessionId);if(!t||t.length===0)return;const r=[];let n=null;const l=()=>{n&&(r.push(n),n=null)};for(const w of t){if(/Remote Control connecting/i.test(JSON.stringify(w)))continue;const _=w.payload||{},a=_.uuid;if(typeof a=="string"&&a&&this.seenUuids.add(a),w.type==="tool_use"){const o=_.tool_call_id;typeof o=="string"&&o&&this.seenToolCallIds.add(o)}if(w.type==="user"){if(w.direction==="inbound")continue;l();const o=Me(_);o&&r.push({type:"user_message",id:w.id||`hist-user-${r.length}`,content:o})}else if(w.type==="assistant"){l();const o=Me(_),f=[],y=_.message;if(y&&typeof y=="object"&&Array.isArray(y.content)){for(const b of y.content)if(b.type==="tool_use"){const N=b.id;N&&this.seenToolCallIds.add(N),f.push({type:"tool_call",toolCall:{id:N||`hist-tool-${r.length}`,title:b.name||"tool",status:"complete",rawInput:b.input||{}}})}}if(o||f.length>0){n={type:"assistant_message",id:w.id||`hist-asst-${r.length}`,chunks:o?[{type:"message",text:o}]:[]},r.push(n);for(const b of f)r.push(b);n=null}}else if(w.type==="tool_use"){const o=_,f={type:"tool_call",toolCall:{id:o.tool_call_id||`hist-tool-${r.length}`,title:o.tool_name||"tool",status:"complete",rawInput:o.tool_input||{}}};r.push(f)}else if(w.type==="tool_result"){const o=_,f=Ee(r,o.tool_call_id||"");if(f>=0){const y=r[f];r[f]={type:"tool_call",toolCall:{...y.toolCall,rawOutput:{output:o.content||o.output||""}}}}}}l();let c=null;for(const w of t){if(w.type!=="task_state")continue;const _=w.payload||{};Array.isArray(_.tasks)&&(c=_.tasks)}if(c&&c.length>0){const w=Te(c);w.length>0&&r.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:w})}this.setEntries(r);let d=null,x=null,p=null;for(const w of t){const _=w.payload||{};if(w.type==="user"?p="user":(w.type==="result"||w.type==="result_success"||w.type==="interrupt")&&(p="turn_end"),w.type==="models_state"){const a=_.raw,o=a&&typeof a=="object"?a.models_state:_.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&(d=o)}else if(w.type==="result"||w.type==="result_success"){const a=_.usage,o=typeof _.total_cost_usd=="number"?_.total_cost_usd:null;(a||o!==null)&&(x={inputTokens:((a==null?void 0:a.input_tokens)??0)+((a==null?void 0:a.cache_read_input_tokens)??0)+((a==null?void 0:a.cache_creation_input_tokens)??0),outputTokens:(a==null?void 0:a.output_tokens)??0,totalCostUsd:o})}}d&&((m=this.onModelsStateChange)==null||m.call(this,d)),x&&((g=this.onUsageChange)==null||g.call(this,x)),this.turnEnded=p==="turn_end",this.userSinceTurnEnd=p==="user",this.turnEnded&&((j=this.onStatusChange)==null||j.call(this,"idle"))}connectSSE(){he.connect(this.sessionId),this.unsub=he.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),he.disconnect()}handleEvent(t){var c,d,x,p,m,g,j,w,_;const r=t.type,n=t.payload||{},l=JSON.stringify(t);if(!/Remote Control connecting/i.test(l))switch(r){case"user":{this.userSinceTurnEnd=!0;break}case"assistant":{const a=n.uuid;if(typeof a=="string"&&a){if(this.seenUuids.has(a))break;this.seenUuids.add(a)}const o=typeof n.content=="string"?n.content:"",f=ms(n);this.setEntries(b=>{const N=b[b.length-1];if((N==null?void 0:N.type)==="assistant_message"&&N.id.startsWith(fe))return[...b.slice(0,-1),{...N,id:`assistant-${Date.now()}`,chunks:[...f?[{type:"thought",text:f}]:[],{type:"message",text:o}]}];if((N==null?void 0:N.type)==="assistant_message"){const M=N.chunks[N.chunks.length-1];return(M==null?void 0:M.type)==="message"?[...b.slice(0,-1),{...N,chunks:[...N.chunks.slice(0,-1),{type:"message",text:M.text+o}]}]:[...b.slice(0,-1),{...N,chunks:[...N.chunks,{type:"message",text:o}]}]}if(o&&o.trim()||f){const M={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...f?[{type:"thought",text:f}]:[],...o?[{type:"message",text:o}]:[]]};return[...b,M]}return b});const y=n.message;if(y&&typeof y=="object"&&Array.isArray(y.content)){const b=y.content.filter(N=>N.type==="tool_use");for(const N of b){const M=N.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(M))continue;this.seenToolCallIds.add(M);const R={id:M,title:N.name||"tool",status:"running",rawInput:N.input||{}};this.setEntries(E=>[...E,{type:"tool_call",toolCall:R}])}}break}case"tool_use":{const a=n,o=a.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(o))break;this.seenToolCallIds.add(o);const f={id:o,title:a.tool_name||"tool",status:"running",rawInput:a.tool_input||{}};this.setEntries(y=>[...y,{type:"tool_call",toolCall:f}]);break}case"tool_result":{const a=n,o=a.tool_call_id||"";this.setEntries(f=>{const y=Ee(f,o);if(y<0)return f;const b=f[y];return f.map((N,M)=>M===y?{type:"tool_call",toolCall:{...b.toolCall,status:"complete",rawOutput:{output:a.content||a.output||""}}}:N)});break}case"control_request":case"permission_request":{const a=n.request;if(a&&a.subtype==="can_use_tool"){const o=n.request_id||"",f=a.tool_name||"unknown",y=a.input||a.tool_input||{},b=a.description||"",N=Array.isArray(a.permission_suggestions)?a.permission_suggestions:[];this.setEntries(M=>{const R=[...M].reverse().findIndex(E=>E.type==="tool_call");if(R>=0){const E=M.length-1-R,D=M[E];if(D.toolCall.status==="running")return M.map((H,W)=>W===E?{type:"tool_call",toolCall:{...D.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:o,options:[]}}}:H)}return M}),(c=this.onPermissionRequest)==null||c.call(this,{requestId:o,toolName:f,toolInput:y,description:b,suggestions:N})}else a&&a.subtype==="elicitation"&&((d=this.onElicitationRequest)==null||d.call(this,{requestId:n.request_id||"",serverName:a.mcp_server_name||"",message:a.message||"",mode:a.mode==="url"?"url":"form",url:typeof a.url=="string"?a.url:void 0,requestedSchema:a.requested_schema||void 0}));break}case"session_status":{if(ut(n)){this.setEntries([]);break}if(typeof n.status=="string"){if(n.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(x=this.onStatusChange)==null||x.call(this,n.status)}break}case"error":{const a=String(n.message||n.content||"Unknown error");(p=this.onError)==null||p.call(this,a);break}case"models_state":{const a=n.raw,o=typeof a=="object"&&a!==null?a.models_state:n.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&((m=this.onModelsStateChange)==null||m.call(this,o));break}case"system":{const a=n.raw,o=a&&typeof a=="object"?a:n,f=typeof o.subtype=="string"?o.subtype:void 0;if(f==="task_started"||f==="task_progress"||f==="task_notification"){const b={subtype:f,task_id:typeof o.task_id=="string"?o.task_id:void 0,tool_use_id:typeof o.tool_use_id=="string"?o.tool_use_id:void 0,description:typeof o.description=="string"?o.description:void 0,task_type:typeof o.task_type=="string"?o.task_type:void 0,workflow_name:typeof o.workflow_name=="string"?o.workflow_name:void 0,prompt:typeof o.prompt=="string"?o.prompt:void 0,usage:o.usage&&typeof o.usage=="object"?o.usage:void 0,last_tool_name:typeof o.last_tool_name=="string"?o.last_tool_name:void 0,summary:typeof o.summary=="string"?o.summary:void 0,status:o.status==="completed"||o.status==="failed"||o.status==="stopped"?o.status:void 0,output_file:typeof o.output_file=="string"?o.output_file:void 0};this.subagentState=cs(this.subagentState,b)}const y=typeof o.permissionMode=="string"?o.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;y&&((g=this.onPermissionModeChange)==null||g.call(this,y));break}case"control_response":{const a=n.response;if(a&&typeof a=="object"){const o=typeof a.request_id=="string"?a.request_id:"",f=typeof a.subtype=="string"?a.subtype:"";if(o){(j=this.onControlResponse)==null||j.call(this,{subtype:f,requestId:o,error:typeof a.error=="string"?a.error:void 0});const y=this.pendingControlRequests.get(o);y&&(this.pendingControlRequests.delete(o),y(f==="success"&&a.response&&typeof a.response=="object"?a.response:null))}}break}case"stream_event":{const a=n.event;if(!a||typeof a.type!="string")break;if(a.type==="content_block_delta"){const o=a.delta;if(!o||typeof o.type!="string")break;const f=o.type==="text_delta"?"message":o.type==="thinking_delta"?"thought":null;if(!f)break;const y=o.text??o.thinking;if(typeof y!="string"||!y)break;this.appendStreamingDelta(f,y)}break}case"partial_assistant":{const a=typeof n.content=="string"?n.content:"";a&&this.appendStreamingDelta("message",a);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,(w=this.onStatusChange)==null||w.call(this,"idle");const a=n.usage,o=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(a||o!==null){const f=((a==null?void 0:a.input_tokens)??0)+((a==null?void 0:a.cache_read_input_tokens)??0)+((a==null?void 0:a.cache_creation_input_tokens)??0);(_=this.onUsageChange)==null||_.call(this,{inputTokens:f,outputTokens:(a==null?void 0:a.output_tokens)??0,totalCostUsd:o})}break}case"task_state":{const a=Array.isArray(n.tasks)?n.tasks:[];if(a.length===0)break;const o=Te(a);if(o.length===0)break;this.setEntries(f=>[...f.filter(b=>b.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:o}]);break}}}appendStreamingDelta(t,r){this.setEntries(n=>{const l=n[n.length-1];if((l==null?void 0:l.type)==="assistant_message"&&l.id.startsWith(fe)){const d=l.chunks[l.chunks.length-1];return(d==null?void 0:d.type)===t?[...n.slice(0,-1),{...l,chunks:[...l.chunks.slice(0,-1),{type:t,text:d.text+r}]}]:[...n.slice(0,-1),{...l,chunks:[...l.chunks,{type:t,text:r}]}]}const c={type:"assistant_message",id:`${fe}${Date.now()}`,chunks:[{type:t,text:r}]};return[...n,c]})}async sendMessage(t,r,n){const l=r&&r.length>0,c=n&&n.length>0;if(!t.trim()&&!l&&!c)return;const d={type:"user_message",id:`user-${Date.now()}`,content:t,images:l?r:void 0,attachments:c?n:void 0};this.setEntries(m=>[...m,d]);const x=[];if(t&&x.push({type:"text",text:t}),l)for(const m of r)x.push({type:"image",source:{type:"base64",media_type:m.mimeType,data:m.data}});if(c){for(const m of n)if(m.kind==="text"||m.kind==="table"){const g=`📎 ${m.name}${m.size!=null?` (${ps(m.size)})`:""}`,j=m.textContent||"(空文件)";x.push({type:"text",text:`${g}
|
|
57
57
|
\`\`\`
|
|
58
58
|
${j}
|
|
59
59
|
\`\`\``})}else if(m.kind==="directory"){const g=`📁 目录: ${m.name}${m.files!=null?` (${m.files.length} 个文件)`:""}`,j=m.textContent||"(空目录)";x.push({type:"text",text:`${g}
|
|
60
|
-
${j}`})}}const p=x.length===1&&x[0].type==="text"?x[0].text||t:x.length>0?x:t;await mt(this.sessionId,{type:"user",uuid:pe(),content:t,message:{content:p}})}async respondPermission(t,r,n){await F(this.sessionId,{type:"permission_response",approved:r,request_id:t,...n}),this.setEntries(l=>l.map(c=>{var d;return c.type!=="tool_call"||((d=c.toolCall.permissionRequest)==null?void 0:d.requestId)!==t?c:{type:"tool_call",toolCall:{...c.toolCall,status:r?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(r=>r.type!=="tool_call"||r.toolCall.status!=="running"&&r.toolCall.status!=="waiting_for_confirmation"?r:{type:"tool_call",toolCall:{...r.toolCall,status:"canceled",permissionRequest:void 0}})),await xt(this.sessionId)}async setPermissionMode(t){const r=pe();return await F(this.sessionId,{type:"control_request",request_id:r,request:{subtype:"set_permission_mode",mode:t}}),r}async searchFiles(t,r=20){const n=pe(),l=new Promise(d=>{this.pendingControlRequests.set(n,d)});await F(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"file_search",query:t,limit:r}});const c=setTimeout(()=>{const d=this.pendingControlRequests.get(n);d&&(this.pendingControlRequests.delete(n),d(null))},8e3);try{const d=await l;if(!d||!Array.isArray(d.suggestions))return[];const x=[];for(const p of d.suggestions)p&&typeof p=="object"&&typeof p.path=="string"&&x.push(p.path);return x}finally{clearTimeout(c)}}async respondElicitation(t,r,n){await F(this.sessionId,{type:"permission_response",approved:r==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:r,...n?{content:n}:{}}}})}}function ps(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function hs(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);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 fs(s){return s?Date.now()-s<6e4:!1}function ys({onClose:s,session:t,liveStatus:r,pendingPermissions:n,onInterrupt:l,onDelete:c}){const[d,x]=u.useState(!1),p=async()=>{await navigator.clipboard.writeText(t.id),x(!0),setTimeout(()=>x(!1),1500)},m=n.length,g=t.worker,j=t.work_item,w=t.environment;return e.jsx(We,{open:!0,onOpenChange:_=>{_||s()},children:e.jsxs(Qe,{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(Ge,{children:e.jsx(Ke,{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(zt,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{status:r||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:g&&(fs(g.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[g&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:hs(g.last_heartbeat_at)})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Ye,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:w.machine_name||w.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:qe(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(De,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),m>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[m," permission request",m>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(ss,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:l,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"}),e.jsxs("button",{onClick:c,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(pt,{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(Gt,{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:p,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:d?"✓":"⧉"})]})]}),j&&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:j.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:j.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})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:w.worker_type})]})]})]})]})]})})}const Ae="rcs:subagent-panel:collapsed";function gs(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60),n=t%60;if(r<60)return n?`${r}m${n}s`:`${r}m`;const l=Math.floor(r/60),c=r%60;return c?`${l}h${c}m`:`${l}h`}function bs(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function js({status:s}){return s==="running"?e.jsx(De,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(es,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(ht,{className:"h-3 w-3 text-status-error"}):null}function ws({task:s}){const t=s.status==="running",r=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,n=bs(s.tokenCount),l=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",c=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"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(js,{status:s.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:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:gs(r)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:c}),(n||l||s.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:[n&&e.jsxs("span",{children:["↕ ",n," tok"]}),l&&e.jsxs("span",{children:["· ",l]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function ks({state:s}){const[t,r]=u.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ae)==="1"}catch{return!1}}),n=()=>{r(p=>{const m=!p;try{window.localStorage.setItem(Ae,m?"1":"0")}catch{}return m})},[,l]=u.useState(0);u.useEffect(()=>{const p=Object.values(s.tasks).some(j=>j.status==="running"),m=Object.values(s.tasks).some(j=>j.status!=="running"&&j.evictAfter!==void 0);if(!p&&!m)return;const g=setInterval(()=>{l(j=>j+1)},1e3);return()=>clearInterval(g)},[s]);const c=ds(s);if(c.length===0)return null;const d=c.filter(p=>p.status==="running").length,x=d>0?`${d} running`:`${c.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:n,"aria-expanded":!t,"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(Vt,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:x})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:c.map(p=>e.jsx(ws,{task:p},p.taskId))})]})})}function Re(s,t){var l;const r=(l=t==null?void 0:t.find(c=>c.type==="addRules"||c.type==="replaceRules"))==null?void 0:l.rules,n=r==null?void 0:r[0];return n!=null&&n.ruleContent?`${n.toolName}(${n.ruleContent})`:n!=null&&n.toolName?n.toolName:s}function Ns({requestId:s,toolName:t,toolInput:r,description:n,suggestions:l,onApprove:c,onApproveAlways:d,onReject:x}){const p=typeof r=="string"?r:JSON.stringify(r,null,2),m=Array.isArray(l)&&l.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(ls,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),n&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:$(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:_e(p,500)}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:c,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),m&&d&&e.jsxs("button",{onClick:d,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:`允许并记住规则:${Re(t,l)}`,children:[e.jsx(os,{className:"h-3.5 w-3.5"}),"Always allow ",_e(Re(t,l),40)]}),e.jsx("button",{onClick:x,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 vs({questions:s,description:t,onSubmit:r,onSkip:n}){const[l,c]=u.useState({}),[d,x]=u.useState({}),[p,m]=u.useState(0),g=(a,o,f)=>{if(f){const y=l[a]||[],b=y.includes(o)?y.filter(N=>N!==o):[...y,o];c({...l,[a]:b})}else c({...l,[a]:o})},j=a=>{var f;const o=(f=d[a])==null?void 0:f.trim();o&&(c({...l,[a]:o}),x({...d,[a]:""}))},w=()=>{var o,f;const a={};for(const[y,b]of Object.entries(l)){const N=s[parseInt(y,10)];N&&(typeof b=="number"?a[y]=((f=(o=N.options)==null?void 0:o[b])==null?void 0:f.label)||String(b):Array.isArray(b)?a[y]=b.map(M=>{var A,E;return((E=(A=N.options)==null?void 0:A[M])==null?void 0:E.label)||String(M)}):a[y]=b)}r(a)};if(s.length<=1){const a=s[0]||{question:t,options:[],multiSelect:!1},o=a.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:$(t||a.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(a.options||[]).map((f,y)=>{const b=o?(l[0]||[]).includes(y):l[0]===y;return e.jsxs("button",{onClick:()=>g(0,y,o),className:J("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",b?"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:$(f.label)}),f.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(f.description)})]},y)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:d[0]||"",onChange:f=>x({...d,0:f.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:f=>f.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:w,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:n,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const _=s[p];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:$(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((a,o)=>e.jsx("button",{onClick:()=>m(o),className:J("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",p===o?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:a.header||`Q${o+1}`},o))}),_&&e.jsx(_s,{question:_,qIdx:p,answers:l,otherTexts:d,onSelect:g,onOtherTextChange:(a,o)=>x({...d,[a]:o}),onOtherSubmit:j}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[p+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:w,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:n,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function _s({question:s,qIdx:t,answers:r,otherTexts:n,onSelect:l,onOtherTextChange:c,onOtherSubmit:d}){const x=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((p,m)=>{const g=x?(r[t]||[]).includes(m):r[t]===m;return e.jsxs("button",{onClick:()=>l(t,m,x),className:J("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:$(p.label)}),p.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(p.description)})]},m)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:p=>c(t,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"&&d(t)}),e.jsx("button",{onClick:()=>d(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 Ss({planContent:s,description:t,onSubmit:r}){const[n,l]=u.useState(null),[c,d]=u.useState(""),x=!s||!s.trim(),p=()=>{n&&r(n,n==="no"?c: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(Ue,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:x?"Exit plan mode?":"Ready to code?"})]}),!x&&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:Cs(s)}}),e.jsx("div",{className:"space-y-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Y,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes"}),e.jsx(Y,{selected:n==="no",onClick:()=>l("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{selected:n==="yes-accept-edits",onClick:()=>l("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(Y,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(Y,{selected:n==="no",onClick:()=>l("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),n==="no"&&e.jsx("textarea",{value:c,onChange:m=>d(m.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:p,disabled:!n,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 Y({selected:s,onClick:t,label:r,desc:n}){return e.jsxs("button",{onClick:t,className:J("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"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:J("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:r})]}),n&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:n})]})}function Cs(s){let t=$(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(r,n,l)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${l.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 Ms({request:s,onSubmit:t}){const r=Es(s.requestedSchema),n=Ts(s.requestedSchema),[l,c]=u.useState({}),d=r.length===0||n.every(x=>(l[x]??"").trim()!=="");return s.mode==="url"&&s.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx($e,{serverName:s.serverName,message:s.message}),e.jsxs("a",{href:s.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:s.url}),e.jsx(Ut,{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($e,{serverName:s.serverName,message:s.message}),r.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:r.map(({name:x,prop:p})=>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:x}),n.includes(x)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:"必填"})]}),p.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:$(p.description)}),e.jsx("input",{type:p.type==="number"?"number":"text",value:l[x]??"",onChange:m=>c(g=>({...g,[x]:m.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"})]},x))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const x={};for(const{name:p,prop:m}of r){const g=(l[p]??"").trim();g&&(x[p]=m.type==="number"?Number(g):g)}t("accept",x)},disabled:!d,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 $e({serverName:s,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(Xt,{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:$(s)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:$(t)})]})}function Es(s){const t=s==null?void 0:s.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,r])=>r&&typeof r=="object").map(([r,n])=>({name:r,prop:n}))}function Ts(s){const t=s==null?void 0:s.required;return Array.isArray(t)?t.filter(r=>typeof r=="string"):[]}function As(s){const[t,r]=u.useState([]),[n,l]=u.useState(!0),[c,d]=u.useState(null),x=u.useCallback(async()=>{l(!0),d(null);try{const g=await ft(s);r(g)}catch(g){d(g instanceof Error?g.message:"Failed to load shares")}finally{l(!1)}},[s]);u.useEffect(()=>{x()},[x]);const p=u.useCallback(async g=>{d(null);try{const j=await yt(s,g);return await x(),j}catch(j){throw d(j instanceof Error?j.message:"Failed to create share"),j}},[s,x]),m=u.useCallback(async g=>{d(null);try{await gt(s,g),await x()}catch(j){throw d(j instanceof Error?j.message:"Failed to revoke share"),j}},[s,x]);return{shares:t,isLoading:n,error:c,createShare:p,revokeShare:m,refresh:x}}function Rs({open:s,onClose:t,sessionId:r,sessionTitle:n}){Fe();const{shares:l,isLoading:c,error:d,createShare:x,revokeShare:p}=As(r),[m,g]=u.useState("user"),[j,w]=u.useState(""),[_,a]=u.useState(""),[o,f]=u.useState("read"),[y,b]=u.useState(""),[N,M]=u.useState(!1),[A,E]=u.useState(null),[D,H]=u.useState(""),[W,I]=u.useState(!1),[oe,O]=u.useState(!1);u.useEffect(()=>{s&&(g("user"),w(""),a(""),f("read"),b(""),M(!1),E(null),H(""),I(!1),O(!1))},[s]);const X=async()=>{M(!0),H(""),E(null);try{const S={grantedTo:m==="user"?{userId:j.trim()}:{teamId:_.trim()},permission:o};y.trim()&&(S.expiresAt=y.trim());const G=await x(S);E(`${window.location.origin}/code/s/${G.shareToken}`)}catch(S){H(S instanceof Error?S.message:"Failed to create share")}finally{M(!1)}},B=async S=>{try{await p(S)}catch{}},Q=async()=>{if(!A)return;O(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(A),I(!0),setTimeout(()=>I(!1),2e3);return}}catch{}const S=document.createElement("textarea");S.value=A,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select();try{document.execCommand("copy"),I(!0),setTimeout(()=>I(!1),2e3)}catch{O(!0)}document.body.removeChild(S)};return e.jsx(We,{open:s,onOpenChange:S=>{S||t()},children:e.jsxs(Qe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ge,{children:e.jsxs(Ke,{className:"font-display text-lg font-semibold text-text-primary",children:[k("share.title"),n?`: ${n}`:""]})}),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:k("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 ${m==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:k("share.user")}),e.jsx("button",{onClick:()=>g("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${m==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:k("share.team")})]}),m==="user"?e.jsx(Ot,{onSelect:w,placeholder:k("share.userIdPlaceholder"),actionLabel:k("share.selectUser")}):e.jsx("input",{type:"text",value:_,onChange:S=>a(S.target.value),placeholder:k("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"}),m==="user"&&j&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[k("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:k("share.permission")}),e.jsxs("select",{value:o,onChange:S=>f(S.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:k("share.permissionRead")}),e.jsx("option",{value:"write",children:k("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:k("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:y,onChange:S=>b(S.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"})]}),(D||d)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:D||d}),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:k("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:Q,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:W?k("share.copied"):k("share.copy")})]}),oe&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:k("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:k("share.existingShares")}),c?e.jsx("p",{className:"text-sm text-text-muted",children:k("share.loading")}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:k("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:l.map(S=>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:S.granted_to_user||S.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[S.permission==="write"?k("share.permissionWrite"):k("share.permissionRead"),S.expires_at?` · expires ${S.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>B(S.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:k("share.revoke")})]},S.id))})]})]}),e.jsxs(Dt,{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:k("common.close")}),e.jsx("button",{onClick:X,disabled:N||(m==="user"?!j.trim():!_.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:N?k("common.creating"):k("share.createShare")})]})]})})}function $s(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Is(s){const t=$s(s),r=jt(),n=r?{proxyUrl:t,token:r}:{proxyUrl:t};return new bt(n)}const V=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],ae="rcs_permission_mode";function Ie(s){return s<1e3?String(s):s<1e6?`${(s/1e3).toFixed(1)}k`:`${(s/1e6).toFixed(1)}M`}function Ps(s){const t=V.findIndex(r=>r.value===s);return V[(t+1+V.length)%V.length].value}function qs({models:s,currentModelId:t,onSelect:r,disabled:n}){const[l,c]=u.useState(!1),d=s.find(m=>m.modelId===t)??null,x=s.length>0,p=async m=>{r(m.modelId),c(!1)};return e.jsxs(Le,{open:l,onOpenChange:x?c:void 0,children:[e.jsx(He,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n||!x,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(Ye,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(d==null?void 0:d.name)??t??"选择模型"}),l?e.jsx(ze,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(Ve,{className:"w-72 p-0",align:"start",children:e.jsx(Pt,{models:s,currentModelId:t,onSelect:p,showSearch:s.length>5})})]})}function Ds({mode:s,onModeChange:t,disabled:r}){const[n,l]=u.useState(!1),c=V.find(d=>d.value===s);return e.jsxs(Le,{open:n,onOpenChange:l,children:[e.jsx(He,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:r,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(It,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??s}),n?e.jsx(ze,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(Ve,{className:"w-64 p-1",align:"start",children:V.map(d=>e.jsxs("button",{type:"button",onClick:()=>{t(d.value),l(!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:s===d.value&&e.jsx(Ue,{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:d.label}),e.jsx("div",{className:"text-xs text-text-muted",children:d.description})]})]},d.value))})]})}function Xs({sessionId:s,onSessionLoaded:t}){Fe();const[r,n]=u.useState(null),[l,c]=u.useState(null),[d,x]=u.useState(""),[p,m]=u.useState(!1),[g,j]=u.useState(!1),[w,_]=u.useState(!1),[a,o]=u.useState(!1),[f,y]=u.useState([]),[b,N]=u.useState(!1),[M,A]=u.useState([]),[E,D]=u.useState(null),[H,W]=u.useState(()=>Je()),[I,oe]=u.useState(null),[O,X]=u.useState(null),[B,Q]=u.useState([]),[S,G]=u.useState(!1),[ie,ye]=u.useState(""),le=u.useRef(null),[ce,Z]=u.useState(()=>localStorage.getItem(ae)||"default"),[ge,be]=u.useState(null),K=u.useRef(null),U=u.useRef(ce);U.current=ce;const ee=u.useRef(null),je=u.useRef(null),we=u.useRef(f);we.current=f;const te=u.useRef(t);te.current=t;const se=u.useCallback(i=>{be(i),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>be(null),5e3)},[]),de=u.useCallback(i=>{var C;if(i===U.current)return;const h=U.current;U.current=i,Z(i);try{localStorage.setItem(ae,i)}catch{}(C=je.current)==null||C.setPermissionMode(i).then(v=>{ee.current={requestId:v,previous:h}}).catch(v=>{console.error("[SessionDetail] set permission mode failed:",v),se(`模式切换请求发送失败: ${v instanceof Error?v.message:String(v)}`),U.current=h,Z(h)})},[se]),R=u.useMemo(()=>new xs(s,y,{onStatusChange:i=>{c(i),N(i==="running"||i==="requires_action")},onError:i=>{console.error("[RCSChatAdapter] error:",i)},onPermissionRequest:i=>{A(h=>h.some(C=>C.requestId===i.requestId)?h:[...h,i])},onModelsStateChange:i=>{D(i)},onSubagentUpdate:i=>{W(i)},onControlResponse:i=>{const h=ee.current;if(!(!h||h.requestId!==i.requestId)&&(ee.current=null,i.subtype==="error")){U.current=h.previous,Z(h.previous);try{localStorage.setItem(ae,h.previous)}catch{}se(i.error||"模式切换失败")}},onPermissionModeChange:i=>{if(i!==U.current){U.current=i,Z(i);try{localStorage.setItem(ae,i)}catch{}ee.current=null}},onUsageChange:i=>{oe(h=>({inputTokens:Math.max((h==null?void 0:h.inputTokens)??0,i.inputTokens),outputTokens:Math.max((h==null?void 0:h.outputTokens)??0,i.outputTokens),totalCostUsd:i.totalCostUsd??(h==null?void 0:h.totalCostUsd)??null}))},onElicitationRequest:i=>{X(i)}}),[s,se]);u.useEffect(()=>(je.current=R,()=>{R.disconnect()}),[R]),u.useEffect(()=>{let i=!1;async function h(){var C;x("");try{const v=await Tt(s);if(i)return;n(v),c(v.status),N(v.status==="running"||v.status==="requires_action"),(C=te.current)==null||C.call(te,v)}catch(v){if(i)return;x(v instanceof Error?v.message:k("session.loadFailed"));return}try{await R.init()}catch(v){console.warn("Failed to init adapter:",v)}}return h(),()=>{i=!0}},[s,R]);const z=At(l),L=(r==null?void 0:r.access_level)==="read",ue=u.useCallback(()=>{y([]),wt(s).catch(i=>{console.warn("[SessionDetail] Failed to clear session history:",i)})},[s]),ne=u.useCallback(async i=>{const h=i.text.trim(),C=i.images&&i.images.length>0||i.attachments&&i.attachments.length>0;if(!h&&!C||z)return;const v=await kt(h,{sessionId:s,availableCommands:Se,availableModels:(E==null?void 0:E.availableModels)??[],currentModel:E?{modelId:E.currentModelId,name:E.currentModelId}:null,supportsImages:!0,entries:we.current,setModel:async q=>{await F(s,{type:"control_request",request:{subtype:"set_model",model:q}}),D(xe=>xe&&{...xe,currentModelId:q})},onNewSession:()=>{y([])}}).catch(()=>null);if(v){if(Nt("[SessionDetail] local command result",v),"clearEntries"in v&&v.clearEntries){ue();return}if("newSession"in v&&v.newSession){ue();return}if("userEntry"in v){y(q=>[...q,v.userEntry,v.cmdEntry]);return}}N(!0);try{await R.sendMessage(h,i.images,i.attachments)}catch(q){console.error("Send failed:",q)}},[R,z,s,E,ue]),Xe=u.useCallback(i=>{if(b){Q(h=>[...h,i]);return}ne(i)},[b,ne]),me=u.useRef(!1);u.useEffect(()=>{if(b||B.length===0||me.current)return;const i=B[0];i&&(me.current=!0,Q(h=>h.slice(1)),ne(i).finally(()=>{me.current=!1}))},[b,B,ne]);const ke=u.useCallback(async()=>{try{await R.interrupt()}catch(i){console.error("Interrupt failed:",i)}finally{N(!1)}},[R]),Ze=u.useCallback(()=>{de(Ps(U.current))},[de]);u.useEffect(()=>()=>{K.current&&clearTimeout(K.current)},[]);const et=u.useCallback(async()=>{if(r&&window.confirm(k("dashboard.confirmDelete").replace("{id}",r.title||r.id)))try{await vt(r.id),window.location.href="/code/"}catch(i){alert(i instanceof Error?i.message:k("dashboard.deleteFailed"))}},[r]),tt=u.useCallback(async i=>{try{await R.respondPermission(i,!0)}catch(h){console.error("Failed to approve:",h)}A(h=>h.filter(C=>C.requestId!==i))},[R]),st=u.useCallback(async(i,h)=>{try{await R.respondPermission(i,!0,{updated_permissions:h})}catch(C){console.error("Failed to approve with rules:",C)}A(C=>C.filter(v=>v.requestId!==i))},[R]),nt=u.useCallback(async(i,h)=>{const C=O;if(X(null),!!C)try{await R.respondElicitation(C.requestId,i,h)}catch(v){console.error("Failed to submit elicitation:",v)}},[O,R]),rt=u.useCallback(()=>{!r||L||(ye(r.title||""),G(!0),setTimeout(()=>{var i,h;(i=le.current)==null||i.focus(),(h=le.current)==null||h.select()},0))},[r,L]),Ne=u.useCallback(async()=>{const i=ie.trim();if(G(!1),!(!r||!i||i===r.title))try{const h=await _t(r.id,i);n(C=>C&&{...C,title:h.title??i})}catch(h){console.error("Rename failed:",h),alert(h instanceof Error?h.message:"重命名失败")}},[r,ie]),at=u.useCallback(async i=>{try{await R.respondPermission(i,!1)}catch(h){console.error("Failed to reject:",h)}A(h=>h.filter(C=>C.requestId!==i))},[R]),ot=u.useCallback(async(i,h,C)=>{try{await F(s,{type:"permission_response",approved:!0,request_id:i,updated_input:{questions:C,answers:h}})}catch(v){console.error("Failed to submit answers:",v)}A(v=>v.filter(q=>q.requestId!==i))},[s]),it=u.useCallback(async(i,h,C)=>{try{h==="no"?await F(s,{type:"permission_response",approved:!1,request_id:i,...C?{message:C}:{}}):await F(s,{type:"permission_response",approved:!0,request_id:i,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[h]||"default",destination:"session"}]})}catch(v){console.error("Failed to submit plan response:",v)}A(v=>v.filter(q=>q.requestId!==i))},[s]);return d?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:d}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:k("session.backToDashboard")})]})}):r?r.source==="acp"&&r.environment_id?e.jsx(Fs,{sessionId:s,agentId:r.environment_id}):e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:r.title||r.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:[S?e.jsx("input",{ref:le,value:ie,onChange:i=>ye(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.nativeEvent.isComposing?(i.preventDefault(),Ne()):i.key==="Escape"&&(i.preventDefault(),G(!1))},onBlur:()=>void Ne(),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:r.title||r.id}),!L&&!z&&e.jsx("button",{type:"button",onClick:rt,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(St,{className:"h-3.5 w-3.5"})})]}),r.visibility&&!S&&e.jsx(Ft,{visibility:r.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var C;const i=r.source==="acp"?"acp":(C=r.environment)==null?void 0:C.worker_type,h=qt(i);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${h.colorClass}`,children:h.fullLabel})})(),l&&e.jsx(Pe,{status:l}),e.jsx("span",{className:"text-xs text-text-muted",children:qe(r.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(!a),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${a?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:k("artifacts.title"),children:e.jsx(Ct,{className:"h-3.5 w-3.5"})}),!L&&(r==null?void 0:r.access_level)!=="write"&&e.jsx("button",{onClick:()=>_(!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:k("session.share"),children:e.jsx(rs,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>j(!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:k("session.info"),children:e.jsx(Yt,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>m(!p),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:[k("session.tasks"),M.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:M.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:k("session.metaSession")})," ",r.id]}),r.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:k("session.metaEnvironment")})," ",r.environment_id]})]})]})}),a&&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(Lt,{sessionId:s,embedded:!0})})}),e.jsx(Mt,{entries:f,isLoading:b,emptyTitle:k("session.emptyTitle"),emptyDescription:k("session.emptyDescription")}),e.jsx(ks,{state:H}),M.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:M.map(i=>e.jsx(Us,{request:i,onApprove:()=>tt(i.requestId),onApproveAlways:i.suggestions&&i.suggestions.length>0?()=>st(i.requestId,i.suggestions??[]):void 0,onReject:()=>at(i.requestId),onSubmitAnswers:ot,onSubmitPlan:it},i.requestId))})}),O&&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(Ms,{request:O,onSubmit:nt})})}),ge&&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:ge})}),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(Ds,{mode:ce,onModeChange:de,disabled:z||L}),e.jsx(qs,{models:(E==null?void 0:E.availableModels)??[],currentModelId:(E==null?void 0:E.currentModelId)??null,onSelect:i=>{F(s,{type:"control_request",request:{subtype:"set_model",model:i}}),D(h=>h&&{...h,currentModelId:i})},disabled:z||L})]}),I&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:"会话累计用量(input 含缓存读写)",children:[Ie(I.inputTokens)," in / ",Ie(I.outputTokens)," out",I.totalCostUsd!=null&&` · $${I.totalCostUsd.toFixed(2)}`]})]}),e.jsx(Et,{onSubmit:Xe,isLoading:b,onInterrupt:ke,onCycleMode:Ze,disabled:z||L,placeholder:z?k("session.closed"):L?k("session.readOnly"):k("session.inputPlaceholder"),supportsAttachments:!0,commands:Se,queueWhileLoading:!0,queuedCount:B.length,onDequeue:i=>Q(h=>h.filter((C,v)=>v!==i)),onSearchFiles:i=>R.searchFiles(i)}),p&&r&&e.jsx(ys,{onClose:()=>m(!1),session:r,liveStatus:l,pendingPermissions:M,onInterrupt:ke,onDelete:et}),e.jsx(Rs,{open:w,onClose:()=>_(!1),sessionId:r.id,sessionTitle:r.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:k("session.loading")})})}function Us({request:s,onApprove:t,onApproveAlways:r,onReject:n,onSubmitAnswers:l,onSubmitPlan:c}){const d=s.toolName,x=s.toolInput,p=s.description||"";if(d==="AskUserQuestion"){const m=x.questions||[];return e.jsx(vs,{requestId:s.requestId,questions:m,description:p,onSubmit:g=>l(s.requestId,g,m),onSkip:n})}if(d==="ExitPlanMode"){const m=x.plan||"";return e.jsx(Ss,{requestId:s.requestId,planContent:m,description:p,onSubmit:(g,j)=>c(s.requestId,g,j)})}return e.jsx(Ns,{requestId:s.requestId,toolName:d,toolInput:x,description:p,suggestions:s.suggestions,onApprove:t,onApproveAlways:r,onReject:n})}function Fs({sessionId:s,agentId:t}){const[r,n]=u.useState(null),[l,c]=u.useState("disconnected"),[d,x]=u.useState(null),p=u.useRef(null);return u.useEffect(()=>{const m=Is(t);return m.setConnectionStateHandler((g,j)=>{c(g),x(j||null)}),p.current=m,n(m),m.connect().catch(g=>{g instanceof Rt||(x(g.message),c("error"))}),()=>{m.disconnect(),p.current=null,n(null),c("disconnected")}},[t]),e.jsx(Oe,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[d&&l==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:d}),l==="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:k("session.connectingAgent")})]})}),l==="error"&&!r&&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:k("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:d})]})}),r&&l==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx($t,{client:r,agentId:t})})]})})}export{Xs as SessionDetail};
|
|
60
|
+
${j}`})}}const p=x.length===1&&x[0].type==="text"?x[0].text||t:x.length>0?x:t;await mt(this.sessionId,{type:"user",uuid:pe(),content:t,message:{content:p}})}async respondPermission(t,r,n){await O(this.sessionId,{type:"permission_response",approved:r,request_id:t,...n}),this.setEntries(l=>l.map(c=>{var d;return c.type!=="tool_call"||((d=c.toolCall.permissionRequest)==null?void 0:d.requestId)!==t?c:{type:"tool_call",toolCall:{...c.toolCall,status:r?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(r=>r.type!=="tool_call"||r.toolCall.status!=="running"&&r.toolCall.status!=="waiting_for_confirmation"?r:{type:"tool_call",toolCall:{...r.toolCall,status:"canceled",permissionRequest:void 0}})),await xt(this.sessionId)}async setPermissionMode(t){const r=pe();return await O(this.sessionId,{type:"control_request",request_id:r,request:{subtype:"set_permission_mode",mode:t}}),r}async searchFiles(t,r=20){const n=pe(),l=new Promise(d=>{this.pendingControlRequests.set(n,d)});await O(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"file_search",query:t,limit:r}});const c=setTimeout(()=>{const d=this.pendingControlRequests.get(n);d&&(this.pendingControlRequests.delete(n),d(null))},8e3);try{const d=await l;if(!d||!Array.isArray(d.suggestions))return[];const x=[];for(const p of d.suggestions)p&&typeof p=="object"&&typeof p.path=="string"&&x.push(p.path);return x}finally{clearTimeout(c)}}async respondElicitation(t,r,n){await O(this.sessionId,{type:"permission_response",approved:r==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:r,...n?{content:n}:{}}}})}}function ps(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function hs(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);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 fs(s){return s?Date.now()-s<6e4:!1}function ys({onClose:s,session:t,liveStatus:r,pendingPermissions:n,onInterrupt:l,onDelete:c}){const[d,x]=u.useState(!1),p=async()=>{await navigator.clipboard.writeText(t.id),x(!0),setTimeout(()=>x(!1),1500)},m=n.length,g=t.worker,j=t.work_item,w=t.environment;return e.jsx(We,{open:!0,onOpenChange:_=>{_||s()},children:e.jsxs(Qe,{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(Ge,{children:e.jsx(Ke,{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(zt,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pe,{status:r||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:g&&(fs(g.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[g&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:hs(g.last_heartbeat_at)})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Ye,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:w.machine_name||w.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ve,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:qe(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(De,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),m>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[m," permission request",m>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(ss,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:l,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"}),e.jsxs("button",{onClick:c,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(pt,{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(Gt,{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:p,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:d?"✓":"⧉"})]})]}),j&&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:j.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:j.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})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:w.worker_type})]})]})]})]})]})})}const Re="rcs:subagent-panel:collapsed";function gs(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60),n=t%60;if(r<60)return n?`${r}m${n}s`:`${r}m`;const l=Math.floor(r/60),c=r%60;return c?`${l}h${c}m`:`${l}h`}function bs(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function js({status:s}){return s==="running"?e.jsx(De,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(es,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(ht,{className:"h-3 w-3 text-status-error"}):null}function ws({task:s}){const t=s.status==="running",r=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,n=bs(s.tokenCount),l=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",c=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"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(js,{status:s.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:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:gs(r)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:c}),(n||l||s.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:[n&&e.jsxs("span",{children:["↕ ",n," tok"]}),l&&e.jsxs("span",{children:["· ",l]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function ks({state:s}){const[t,r]=u.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Re)==="1"}catch{return!1}}),n=()=>{r(p=>{const m=!p;try{window.localStorage.setItem(Re,m?"1":"0")}catch{}return m})},[,l]=u.useState(0);u.useEffect(()=>{const p=Object.values(s.tasks).some(j=>j.status==="running"),m=Object.values(s.tasks).some(j=>j.status!=="running"&&j.evictAfter!==void 0);if(!p&&!m)return;const g=setInterval(()=>{l(j=>j+1)},1e3);return()=>clearInterval(g)},[s]);const c=ds(s);if(c.length===0)return null;const d=c.filter(p=>p.status==="running").length,x=d>0?`${d} running`:`${c.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:n,"aria-expanded":!t,"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(Vt,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:x})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:c.map(p=>e.jsx(ws,{task:p},p.taskId))})]})})}function Ae(s,t){var l;const r=(l=t==null?void 0:t.find(c=>c.type==="addRules"||c.type==="replaceRules"))==null?void 0:l.rules,n=r==null?void 0:r[0];return n!=null&&n.ruleContent?`${n.toolName}(${n.ruleContent})`:n!=null&&n.toolName?n.toolName:s}function Ns({requestId:s,toolName:t,toolInput:r,description:n,suggestions:l,onApprove:c,onApproveAlways:d,onReject:x}){const p=typeof r=="string"?r:JSON.stringify(r,null,2),m=Array.isArray(l)&&l.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(ls,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),n&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:$(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:_e(p,500)}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:c,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),m&&d&&e.jsxs("button",{onClick:d,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:`允许并记住规则:${Ae(t,l)}`,children:[e.jsx(os,{className:"h-3.5 w-3.5"}),"Always allow ",_e(Ae(t,l),40)]}),e.jsx("button",{onClick:x,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 vs({questions:s,description:t,onSubmit:r,onSkip:n}){const[l,c]=u.useState({}),[d,x]=u.useState({}),[p,m]=u.useState(0),g=(a,o,f)=>{if(f){const y=l[a]||[],b=y.includes(o)?y.filter(N=>N!==o):[...y,o];c({...l,[a]:b})}else c({...l,[a]:o})},j=a=>{var f;const o=(f=d[a])==null?void 0:f.trim();o&&(c({...l,[a]:o}),x({...d,[a]:""}))},w=()=>{var o,f;const a={};for(const[y,b]of Object.entries(l)){const N=s[parseInt(y,10)];N&&(typeof b=="number"?a[y]=((f=(o=N.options)==null?void 0:o[b])==null?void 0:f.label)||String(b):Array.isArray(b)?a[y]=b.map(M=>{var R,E;return((E=(R=N.options)==null?void 0:R[M])==null?void 0:E.label)||String(M)}):a[y]=b)}r(a)};if(s.length<=1){const a=s[0]||{question:t,options:[],multiSelect:!1},o=a.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:$(t||a.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(a.options||[]).map((f,y)=>{const b=o?(l[0]||[]).includes(y):l[0]===y;return e.jsxs("button",{onClick:()=>g(0,y,o),className:J("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",b?"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:$(f.label)}),f.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(f.description)})]},y)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:d[0]||"",onChange:f=>x({...d,0:f.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:f=>f.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:w,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:n,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const _=s[p];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:$(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((a,o)=>e.jsx("button",{onClick:()=>m(o),className:J("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",p===o?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:a.header||`Q${o+1}`},o))}),_&&e.jsx(_s,{question:_,qIdx:p,answers:l,otherTexts:d,onSelect:g,onOtherTextChange:(a,o)=>x({...d,[a]:o}),onOtherSubmit:j}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[p+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:w,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:n,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function _s({question:s,qIdx:t,answers:r,otherTexts:n,onSelect:l,onOtherTextChange:c,onOtherSubmit:d}){const x=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((p,m)=>{const g=x?(r[t]||[]).includes(m):r[t]===m;return e.jsxs("button",{onClick:()=>l(t,m,x),className:J("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:$(p.label)}),p.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(p.description)})]},m)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:p=>c(t,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"&&d(t)}),e.jsx("button",{onClick:()=>d(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 Ss({planContent:s,description:t,onSubmit:r}){const[n,l]=u.useState(null),[c,d]=u.useState(""),x=!s||!s.trim(),p=()=>{n&&r(n,n==="no"?c: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(Ue,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:x?"Exit plan mode?":"Ready to code?"})]}),!x&&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:Cs(s)}}),e.jsx("div",{className:"space-y-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(Y,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes"}),e.jsx(Y,{selected:n==="no",onClick:()=>l("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{selected:n==="yes-accept-edits",onClick:()=>l("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(Y,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(Y,{selected:n==="no",onClick:()=>l("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),n==="no"&&e.jsx("textarea",{value:c,onChange:m=>d(m.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:p,disabled:!n,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 Y({selected:s,onClick:t,label:r,desc:n}){return e.jsxs("button",{onClick:t,className:J("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"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:J("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:r})]}),n&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:n})]})}function Cs(s){let t=$(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(r,n,l)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${l.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 Ms({request:s,onSubmit:t}){const r=Es(s.requestedSchema),n=Ts(s.requestedSchema),[l,c]=u.useState({}),d=r.length===0||n.every(x=>(l[x]??"").trim()!=="");return s.mode==="url"&&s.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx($e,{serverName:s.serverName,message:s.message}),e.jsxs("a",{href:s.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:s.url}),e.jsx(Ut,{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($e,{serverName:s.serverName,message:s.message}),r.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:r.map(({name:x,prop:p})=>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:x}),n.includes(x)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:"必填"})]}),p.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:$(p.description)}),e.jsx("input",{type:p.type==="number"?"number":"text",value:l[x]??"",onChange:m=>c(g=>({...g,[x]:m.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"})]},x))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const x={};for(const{name:p,prop:m}of r){const g=(l[p]??"").trim();g&&(x[p]=m.type==="number"?Number(g):g)}t("accept",x)},disabled:!d,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 $e({serverName:s,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(Xt,{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:$(s)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:$(t)})]})}function Es(s){const t=s==null?void 0:s.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,r])=>r&&typeof r=="object").map(([r,n])=>({name:r,prop:n}))}function Ts(s){const t=s==null?void 0:s.required;return Array.isArray(t)?t.filter(r=>typeof r=="string"):[]}function Rs(s){const[t,r]=u.useState([]),[n,l]=u.useState(!0),[c,d]=u.useState(null),x=u.useCallback(async()=>{l(!0),d(null);try{const g=await ft(s);r(g)}catch(g){d(g instanceof Error?g.message:"Failed to load shares")}finally{l(!1)}},[s]);u.useEffect(()=>{x()},[x]);const p=u.useCallback(async g=>{d(null);try{const j=await yt(s,g);return await x(),j}catch(j){throw d(j instanceof Error?j.message:"Failed to create share"),j}},[s,x]),m=u.useCallback(async g=>{d(null);try{await gt(s,g),await x()}catch(j){throw d(j instanceof Error?j.message:"Failed to revoke share"),j}},[s,x]);return{shares:t,isLoading:n,error:c,createShare:p,revokeShare:m,refresh:x}}function As({open:s,onClose:t,sessionId:r,sessionTitle:n}){Oe();const{shares:l,isLoading:c,error:d,createShare:x,revokeShare:p}=Rs(r),[m,g]=u.useState("user"),[j,w]=u.useState(""),[_,a]=u.useState(""),[o,f]=u.useState("read"),[y,b]=u.useState(""),[N,M]=u.useState(!1),[R,E]=u.useState(null),[D,H]=u.useState(""),[W,I]=u.useState(!1),[oe,F]=u.useState(!1);u.useEffect(()=>{s&&(g("user"),w(""),a(""),f("read"),b(""),M(!1),E(null),H(""),I(!1),F(!1))},[s]);const X=async()=>{M(!0),H(""),E(null);try{const S={grantedTo:m==="user"?{userId:j.trim()}:{teamId:_.trim()},permission:o};y.trim()&&(S.expiresAt=y.trim());const G=await x(S);E(`${window.location.origin}/code/s/${G.shareToken}`)}catch(S){H(S instanceof Error?S.message:"Failed to create share")}finally{M(!1)}},B=async S=>{try{await p(S)}catch{}},Q=async()=>{if(!R)return;F(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(R),I(!0),setTimeout(()=>I(!1),2e3);return}}catch{}const S=document.createElement("textarea");S.value=R,S.style.position="fixed",S.style.opacity="0",document.body.appendChild(S),S.select();try{document.execCommand("copy"),I(!0),setTimeout(()=>I(!1),2e3)}catch{F(!0)}document.body.removeChild(S)};return e.jsx(We,{open:s,onOpenChange:S=>{S||t()},children:e.jsxs(Qe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ge,{children:e.jsxs(Ke,{className:"font-display text-lg font-semibold text-text-primary",children:[k("share.title"),n?`: ${n}`:""]})}),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:k("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 ${m==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:k("share.user")}),e.jsx("button",{onClick:()=>g("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${m==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:k("share.team")})]}),m==="user"?e.jsx(Ft,{onSelect:w,placeholder:k("share.userIdPlaceholder"),actionLabel:k("share.selectUser")}):e.jsx("input",{type:"text",value:_,onChange:S=>a(S.target.value),placeholder:k("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"}),m==="user"&&j&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[k("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:k("share.permission")}),e.jsxs("select",{value:o,onChange:S=>f(S.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:k("share.permissionRead")}),e.jsx("option",{value:"write",children:k("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:k("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:y,onChange:S=>b(S.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"})]}),(D||d)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:D||d}),R&&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:k("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:R}),e.jsx("button",{onClick:Q,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:W?k("share.copied"):k("share.copy")})]}),oe&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:k("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:k("share.existingShares")}),c?e.jsx("p",{className:"text-sm text-text-muted",children:k("share.loading")}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:k("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:l.map(S=>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:S.granted_to_user||S.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[S.permission==="write"?k("share.permissionWrite"):k("share.permissionRead"),S.expires_at?` · expires ${S.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>B(S.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:k("share.revoke")})]},S.id))})]})]}),e.jsxs(Dt,{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:k("common.close")}),e.jsx("button",{onClick:X,disabled:N||(m==="user"?!j.trim():!_.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:N?k("common.creating"):k("share.createShare")})]})]})})}function $s(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Is(s){const t=$s(s),r=jt(),n=r?{proxyUrl:t,token:r}:{proxyUrl:t};return new bt(n)}const V=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],ae="rcs_permission_mode";function Ie(s){return s<1e3?String(s):s<1e6?`${(s/1e3).toFixed(1)}k`:`${(s/1e6).toFixed(1)}M`}function Ps(s){const t=V.findIndex(r=>r.value===s);return V[(t+1+V.length)%V.length].value}function qs({models:s,currentModelId:t,onSelect:r,disabled:n}){const[l,c]=u.useState(!1),d=s.find(m=>m.modelId===t)??null,x=s.length>0,p=async m=>{r(m.modelId),c(!1)};return e.jsxs(Le,{open:l,onOpenChange:x?c:void 0,children:[e.jsx(He,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n||!x,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(Ye,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(d==null?void 0:d.name)??t??"选择模型"}),l?e.jsx(ze,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(Ve,{className:"w-72 p-0",align:"start",children:e.jsx(Pt,{models:s,currentModelId:t,onSelect:p,showSearch:s.length>5})})]})}function Ds({mode:s,onModeChange:t,disabled:r}){const[n,l]=u.useState(!1),c=V.find(d=>d.value===s);return e.jsxs(Le,{open:n,onOpenChange:l,children:[e.jsx(He,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:r,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(It,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??s}),n?e.jsx(ze,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(Ve,{className:"w-64 p-1",align:"start",children:V.map(d=>e.jsxs("button",{type:"button",onClick:()=>{t(d.value),l(!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:s===d.value&&e.jsx(Ue,{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:d.label}),e.jsx("div",{className:"text-xs text-text-muted",children:d.description})]})]},d.value))})]})}function Xs({sessionId:s,onSessionLoaded:t}){Oe();const[r,n]=u.useState(null),[l,c]=u.useState(null),[d,x]=u.useState(""),[p,m]=u.useState(!1),[g,j]=u.useState(!1),[w,_]=u.useState(!1),[a,o]=u.useState(!1),[f,y]=u.useState([]),[b,N]=u.useState(!1),[M,R]=u.useState([]),[E,D]=u.useState(null),[H,W]=u.useState(()=>Je()),[I,oe]=u.useState(null),[F,X]=u.useState(null),[B,Q]=u.useState([]),[S,G]=u.useState(!1),[ie,ye]=u.useState(""),le=u.useRef(null),[ce,Z]=u.useState(()=>localStorage.getItem(ae)||"default"),[ge,be]=u.useState(null),K=u.useRef(null),U=u.useRef(ce);U.current=ce;const ee=u.useRef(null),je=u.useRef(null),we=u.useRef(f);we.current=f;const te=u.useRef(t);te.current=t;const se=u.useCallback(i=>{be(i),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>be(null),5e3)},[]),de=u.useCallback(i=>{var C;if(i===U.current)return;const h=U.current;U.current=i,Z(i);try{localStorage.setItem(ae,i)}catch{}(C=je.current)==null||C.setPermissionMode(i).then(v=>{ee.current={requestId:v,previous:h}}).catch(v=>{console.error("[SessionDetail] set permission mode failed:",v),se(`模式切换请求发送失败: ${v instanceof Error?v.message:String(v)}`),U.current=h,Z(h)})},[se]),A=u.useMemo(()=>new xs(s,y,{onStatusChange:i=>{c(i),N(i==="running"||i==="requires_action")},onError:i=>{console.error("[RCSChatAdapter] error:",i)},onPermissionRequest:i=>{R(h=>h.some(C=>C.requestId===i.requestId)?h:[...h,i])},onModelsStateChange:i=>{D(i)},onSubagentUpdate:i=>{W(i)},onControlResponse:i=>{const h=ee.current;if(!(!h||h.requestId!==i.requestId)&&(ee.current=null,i.subtype==="error")){U.current=h.previous,Z(h.previous);try{localStorage.setItem(ae,h.previous)}catch{}se(i.error||"模式切换失败")}},onPermissionModeChange:i=>{if(i!==U.current){U.current=i,Z(i);try{localStorage.setItem(ae,i)}catch{}ee.current=null}},onUsageChange:i=>{oe(h=>({inputTokens:Math.max((h==null?void 0:h.inputTokens)??0,i.inputTokens),outputTokens:Math.max((h==null?void 0:h.outputTokens)??0,i.outputTokens),totalCostUsd:i.totalCostUsd??(h==null?void 0:h.totalCostUsd)??null}))},onElicitationRequest:i=>{X(i)}}),[s,se]);u.useEffect(()=>(je.current=A,()=>{A.disconnect()}),[A]),u.useEffect(()=>{let i=!1;async function h(){var C;x("");try{const v=await Tt(s);if(i)return;n(v),c(v.status),N(v.status==="running"||v.status==="requires_action"),(C=te.current)==null||C.call(te,v)}catch(v){if(i)return;x(v instanceof Error?v.message:k("session.loadFailed"));return}try{await A.init()}catch(v){console.warn("Failed to init adapter:",v)}}return h(),()=>{i=!0}},[s,A]);const z=Rt(l),L=(r==null?void 0:r.access_level)==="read",ue=u.useCallback(()=>{y([]),wt(s).catch(i=>{console.warn("[SessionDetail] Failed to clear session history:",i)})},[s]),ne=u.useCallback(async i=>{const h=i.text.trim(),C=i.images&&i.images.length>0||i.attachments&&i.attachments.length>0;if(!h&&!C||z)return;const v=await kt(h,{sessionId:s,availableCommands:Se,availableModels:(E==null?void 0:E.availableModels)??[],currentModel:E?{modelId:E.currentModelId,name:E.currentModelId}:null,supportsImages:!0,entries:we.current,setModel:async q=>{await O(s,{type:"control_request",request:{subtype:"set_model",model:q}}),D(xe=>xe&&{...xe,currentModelId:q})},onNewSession:()=>{y([])}}).catch(()=>null);if(v){if(Nt("[SessionDetail] local command result",v),"clearEntries"in v&&v.clearEntries){ue();return}if("newSession"in v&&v.newSession){ue();return}if("userEntry"in v){y(q=>[...q,v.userEntry,v.cmdEntry]);return}}N(!0);try{await A.sendMessage(h,i.images,i.attachments)}catch(q){console.error("Send failed:",q)}},[A,z,s,E,ue]),Xe=u.useCallback(i=>{if(b){Q(h=>[...h,i]);return}ne(i)},[b,ne]),me=u.useRef(!1);u.useEffect(()=>{if(b||B.length===0||me.current)return;const i=B[0];i&&(me.current=!0,Q(h=>h.slice(1)),ne(i).finally(()=>{me.current=!1}))},[b,B,ne]);const ke=u.useCallback(async()=>{try{await A.interrupt()}catch(i){console.error("Interrupt failed:",i)}finally{N(!1)}},[A]),Ze=u.useCallback(()=>{de(Ps(U.current))},[de]);u.useEffect(()=>()=>{K.current&&clearTimeout(K.current)},[]);const et=u.useCallback(async()=>{if(r&&window.confirm(k("dashboard.confirmDelete").replace("{id}",r.title||r.id)))try{await vt(r.id),window.location.href="/code/"}catch(i){alert(i instanceof Error?i.message:k("dashboard.deleteFailed"))}},[r]),tt=u.useCallback(async i=>{try{await A.respondPermission(i,!0)}catch(h){console.error("Failed to approve:",h)}R(h=>h.filter(C=>C.requestId!==i))},[A]),st=u.useCallback(async(i,h)=>{try{await A.respondPermission(i,!0,{updated_permissions:h})}catch(C){console.error("Failed to approve with rules:",C)}R(C=>C.filter(v=>v.requestId!==i))},[A]),nt=u.useCallback(async(i,h)=>{const C=F;if(X(null),!!C)try{await A.respondElicitation(C.requestId,i,h)}catch(v){console.error("Failed to submit elicitation:",v)}},[F,A]),rt=u.useCallback(()=>{!r||L||(ye(r.title||""),G(!0),setTimeout(()=>{var i,h;(i=le.current)==null||i.focus(),(h=le.current)==null||h.select()},0))},[r,L]),Ne=u.useCallback(async()=>{const i=ie.trim();if(G(!1),!(!r||!i||i===r.title))try{const h=await _t(r.id,i);n(C=>C&&{...C,title:h.title??i})}catch(h){console.error("Rename failed:",h),alert(h instanceof Error?h.message:"重命名失败")}},[r,ie]),at=u.useCallback(async i=>{try{await A.respondPermission(i,!1)}catch(h){console.error("Failed to reject:",h)}R(h=>h.filter(C=>C.requestId!==i))},[A]),ot=u.useCallback(async(i,h,C)=>{try{await O(s,{type:"permission_response",approved:!0,request_id:i,updated_input:{questions:C,answers:h}})}catch(v){console.error("Failed to submit answers:",v)}R(v=>v.filter(q=>q.requestId!==i))},[s]),it=u.useCallback(async(i,h,C)=>{try{h==="no"?await O(s,{type:"permission_response",approved:!1,request_id:i,...C?{message:C}:{}}):await O(s,{type:"permission_response",approved:!0,request_id:i,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[h]||"default",destination:"session"}]})}catch(v){console.error("Failed to submit plan response:",v)}R(v=>v.filter(q=>q.requestId!==i))},[s]);return d?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:d}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:k("session.backToDashboard")})]})}):r?r.source==="acp"&&r.environment_id?e.jsx(Os,{sessionId:s,agentId:r.environment_id}):e.jsx(Fe,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:r.title||r.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:[S?e.jsx("input",{ref:le,value:ie,onChange:i=>ye(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.nativeEvent.isComposing?(i.preventDefault(),Ne()):i.key==="Escape"&&(i.preventDefault(),G(!1))},onBlur:()=>void Ne(),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:r.title||r.id}),!L&&!z&&e.jsx("button",{type:"button",onClick:rt,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(St,{className:"h-3.5 w-3.5"})})]}),r.visibility&&!S&&e.jsx(Ot,{visibility:r.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var C;const i=r.source==="acp"?"acp":(C=r.environment)==null?void 0:C.worker_type,h=qt(i);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${h.colorClass}`,children:h.fullLabel})})(),l&&e.jsx(Pe,{status:l}),e.jsx("span",{className:"text-xs text-text-muted",children:qe(r.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(!a),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${a?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:k("artifacts.title"),children:e.jsx(Ct,{className:"h-3.5 w-3.5"})}),!L&&(r==null?void 0:r.access_level)!=="write"&&e.jsx("button",{onClick:()=>_(!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:k("session.share"),children:e.jsx(rs,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>j(!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:k("session.info"),children:e.jsx(Yt,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>m(!p),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:[k("session.tasks"),M.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:M.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:k("session.metaSession")})," ",r.id]}),r.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:k("session.metaEnvironment")})," ",r.environment_id]})]})]})}),a&&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(Lt,{sessionId:s,embedded:!0})})}),e.jsx(Mt,{entries:f,isLoading:b,emptyTitle:k("session.emptyTitle"),emptyDescription:k("session.emptyDescription")}),e.jsx(ks,{state:H}),M.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:M.map(i=>e.jsx(Us,{request:i,onApprove:()=>tt(i.requestId),onApproveAlways:i.suggestions&&i.suggestions.length>0?()=>st(i.requestId,i.suggestions??[]):void 0,onReject:()=>at(i.requestId),onSubmitAnswers:ot,onSubmitPlan:it},i.requestId))})}),F&&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(Ms,{request:F,onSubmit:nt})})}),ge&&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:ge})}),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(Ds,{mode:ce,onModeChange:de,disabled:z||L}),e.jsx(qs,{models:(E==null?void 0:E.availableModels)??[],currentModelId:(E==null?void 0:E.currentModelId)??null,onSelect:i=>{O(s,{type:"control_request",request:{subtype:"set_model",model:i}}),D(h=>h&&{...h,currentModelId:i})},disabled:z||L})]}),I&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:"会话累计用量(input 含缓存读写)",children:[Ie(I.inputTokens)," in / ",Ie(I.outputTokens)," out",I.totalCostUsd!=null&&` · $${I.totalCostUsd.toFixed(2)}`]})]}),e.jsx(Et,{onSubmit:Xe,isLoading:b,onInterrupt:ke,onCycleMode:Ze,disabled:z||L,placeholder:z?k("session.closed"):L?k("session.readOnly"):k("session.inputPlaceholder"),supportsAttachments:!0,commands:Se,queueWhileLoading:!0,queuedCount:B.length,onDequeue:i=>Q(h=>h.filter((C,v)=>v!==i)),onSearchFiles:i=>A.searchFiles(i)}),p&&r&&e.jsx(ys,{onClose:()=>m(!1),session:r,liveStatus:l,pendingPermissions:M,onInterrupt:ke,onDelete:et}),e.jsx(As,{open:w,onClose:()=>_(!1),sessionId:r.id,sessionTitle:r.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:k("session.loading")})})}function Us({request:s,onApprove:t,onApproveAlways:r,onReject:n,onSubmitAnswers:l,onSubmitPlan:c}){const d=s.toolName,x=s.toolInput,p=s.description||"";if(d==="AskUserQuestion"){const m=x.questions||[];return e.jsx(vs,{requestId:s.requestId,questions:m,description:p,onSubmit:g=>l(s.requestId,g,m),onSkip:n})}if(d==="ExitPlanMode"){const m=x.plan||"";return e.jsx(Ss,{requestId:s.requestId,planContent:m,description:p,onSubmit:(g,j)=>c(s.requestId,g,j)})}return e.jsx(Ns,{requestId:s.requestId,toolName:d,toolInput:x,description:p,suggestions:s.suggestions,onApprove:t,onApproveAlways:r,onReject:n})}function Os({sessionId:s,agentId:t}){const[r,n]=u.useState(null),[l,c]=u.useState("disconnected"),[d,x]=u.useState(null),p=u.useRef(null);return u.useEffect(()=>{const m=Is(t);return m.setConnectionStateHandler((g,j)=>{c(g),x(j||null)}),p.current=m,n(m),m.connect().catch(g=>{g instanceof At||(x(g.message),c("error"))}),()=>{m.disconnect(),p.current=null,n(null),c("disconnected")}},[t]),e.jsx(Fe,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[d&&l==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:d}),l==="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:k("session.connectingAgent")})]})}),l==="error"&&!r&&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:k("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:d})]})}),r&&l==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx($t,{client:r,agentId:t})})]})})}export{Xs as SessionDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{ab as c,U as n,a9 as i}from"./main-
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{ab as c,U as n,a9 as i}from"./main-Cmt5Bx4n.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{ap as v,al as t}from"./main-
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ap as v,al as t}from"./main-Cmt5Bx4n.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{a2 as m,b as h}from"./main-
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{a2 as m,b as h}from"./main-Cmt5Bx4n.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{aq as f,ar as y,al as r}from"./main-
|
|
1
|
+
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{aq as f,ar as y,al as r}from"./main-Cmt5Bx4n.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,4 +1,4 @@
|
|
|
1
|
-
import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{ab as H,B as T,aq as P,al as i,d as B,X as z,x as G,Y as I,a7 as q,a6 as W,ap as Y,S as X,a9 as J,j as K,o as Q,P as V,k as Z,m as ee,l as M,n as te,z as se}from"./main-
|
|
1
|
+
import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{ab as H,B as T,aq as P,al as i,d as B,X as z,x as G,Y as I,a7 as q,a6 as W,ap as Y,S as X,a9 as J,j as K,o as Q,P as V,k as Z,m as ee,l as M,n as te,z as se}from"./main-Cmt5Bx4n.js";import{U as ae}from"./UserSearchInput-CCwTLowu.js";import{C as D}from"./copy-CxPcy5Mr.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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{ar as l,p as a}from"./main-
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{ar as l,p as a}from"./main-Cmt5Bx4n.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};
|