@saluzi/saluzi-edu 0.2.59 → 0.2.60
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 +225 -119
- package/dist/guide/guide-data.json +5 -1
- package/dist/parade/web/cube.js +370 -79
- package/dist/parade/web/index.html +172 -41
- package/dist/rcs-web/assets/{AdminPanel-CbcZ7Vnr.js → AdminPanel-BMgxq2d0.js} +1 -1
- package/dist/rcs-web/assets/Claim-DRJ_CmK0.js +1 -0
- package/{packages/remote-control-server/web/dist/assets/Dashboard-BZGcSCFY.js → dist/rcs-web/assets/Dashboard-CablTsf3.js} +2 -2
- package/{packages/remote-control-server/web/dist/assets/Join-B_e3BKa3.js → dist/rcs-web/assets/Join-a80j0Uiw.js} +1 -1
- package/dist/rcs-web/assets/{Login-u6CGGkoD.js → Login-DclVxA4Q.js} +1 -1
- package/dist/rcs-web/assets/{Register-C4Fk0ibc.js → Register-DizfWHKb.js} +1 -1
- package/dist/rcs-web/assets/{SessionDetail-Bd1YgozL.js → SessionDetail-CJoBz0DU.js} +14 -14
- package/dist/rcs-web/assets/{SessionVisibilityBadge-BHKxlh8U.js → SessionVisibilityBadge-Bp4kZdZ4.js} +1 -1
- package/dist/rcs-web/assets/{Setup-DReCE0zx.js → Setup-DIw3Qc5x.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-qE1U0WKZ.js → ShareLanding-CmyujISc.js} +1 -1
- package/dist/rcs-web/assets/{TeamCreate-BgwgZP4a.js → TeamCreate-fq5PdqO_.js} +1 -1
- package/dist/rcs-web/assets/{TeamDetail-BHCvnI2t.js → TeamDetail-haFVDL0P.js} +2 -2
- package/dist/rcs-web/assets/{TeamList-B7uC8lDV.js → TeamList-CR63fSv_.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-DtgvrKEE.js → TeamSettings-BlXY05zK.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-dgxhGWfJ.js → UserSearchInput-Cpg_A_Py.js} +1 -1
- package/dist/rcs-web/assets/{UserSettings-Zyjam23-.js → UserSettings-BzHH2wQ6.js} +1 -1
- package/dist/rcs-web/assets/{arc-DgC_wPAg.js → arc-cULKnhNn.js} +1 -1
- package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-BnnCRJZs.js → architectureDiagram-3BPJPVTR-CXLnNGBR.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-CvpYdvcP.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-BPQU9CvK.js} +1 -1
- package/dist/rcs-web/assets/{c4Diagram-AAUBKEIU-DNK__-3d.js → c4Diagram-AAUBKEIU-x76XWolr.js} +1 -1
- package/dist/rcs-web/assets/channel-DVf9sV9K.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-5JQBz2na.js → chunk-2J33WTMH-C2xuSz2p.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-YJh8d73x.js → chunk-4BX2VUAB-BPsGJ9Ky.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-U5c5GQZN.js → chunk-55IACEB6-DV5Xxy86.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-ifGCid_3.js → dist/rcs-web/assets/chunk-727SXJPM-dwWMJ2pm.js} +1 -1
- package/dist/rcs-web/assets/{chunk-AQP2D5EJ-DxqPH2_Q.js → chunk-AQP2D5EJ-CkxHIiMh.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-dDtjQRPo.js → chunk-FMBD7UC4-CyuNPJ-2.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-0UF6vhhE.js → chunk-ND2GUHAM-L7in2-8e.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-CfZ4xcBz.js → chunk-QZHKN3VN-xFEPbqY9.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DfHzlu2X.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DfHzlu2X.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-B4B0UrXo.js → code-block-IT6T5CEO-hkRn_BN_.js} +1 -1
- package/dist/rcs-web/assets/{copy-_OW0eGyp.js → copy-B8rXAtFb.js} +1 -1
- package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-B19xQvnh.js → cose-bilkent-S5V4N54A-DSZFWhhn.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-5JJnjI1B.js → dagre-BM42HDAG-B5wjmFJL.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-BY2NR7vr.js → diagram-2AECGRRQ-CGeTqGVq.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-3zC3GraP.js → diagram-5GNKFQAL-B9-2D-Y8.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-T1Jt5zH3.js → diagram-KO2AKTUF-BVCQ5UyX.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-ehrkQG1e.js → diagram-LMA3HP47-Cj4gFMtD.js} +1 -1
- package/dist/rcs-web/assets/{diagram-OG6HWLK6-D8ZJlGs0.js → diagram-OG6HWLK6-BBpaH0il.js} +1 -1
- package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-Ckn1pY7G.js → erDiagram-TEJ5UH35-DS19qy_q.js} +1 -1
- package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-C1xnAOfH.js → flowDiagram-I6XJVG4X-D9WY3n6O.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Dw8qOfCT.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-BNOSopT7.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-Cg3La45a.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-WBmYjFoA.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-CGH2aXpd.js → infoDiagram-5YYISTIA-D3l4nC2Y.js} +1 -1
- package/dist/rcs-web/assets/{ishikawaDiagram-YF4QCWOH-x89F9Igr.js → ishikawaDiagram-YF4QCWOH-BYDxMH9Q.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-Ckd_pKi0.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-BSD6AEvb.js} +1 -1
- package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-D2dEXdru.js → kanban-definition-UN3LZRKU-DtqGr_PI.js} +1 -1
- package/dist/rcs-web/assets/{linear-CexxJrg8.js → linear-CaKAAJC6.js} +1 -1
- package/dist/rcs-web/assets/{main-L9iyf39T.js → main-Dk8hyS_b.js} +7 -7
- package/dist/rcs-web/assets/{mermaid-VLURNSYL-BomP37Br.js → mermaid-VLURNSYL-f6St46tQ.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-BxkfDFm_.js → mermaid.core-DWc0M-5V.js} +5 -5
- package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-HVsZx8Je.js → mindmap-definition-RKZ34NQL-D0RkeEqx.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-D0U9q74D.js → pieDiagram-4H26LBE5-YlDnS5wa.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-CWPBZMPj.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-CZcVTIBE.js} +1 -1
- package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-CiQbIN_P.js → requirementDiagram-4Y6WPE33-BUn0r08O.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-Bw66fXM0.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-Dr_ywHhs.js} +1 -1
- package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-lv5WhGb6.js → sequenceDiagram-3UESZ5HK-Bts1oven.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-BLRRpX3g.js → stateDiagram-AJRCARHV-DFbylE7U.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-B-5gzDu6.js → stateDiagram-v2-BHNVJYJU-Bzl4YDMv.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-DO8oVMVA.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-BtqngM31.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-D2RbeAHj.js → vennDiagram-CIIHVFJN-D1hGAcgx.js} +1 -1
- package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-D8D1cIXp.js → wardleyDiagram-YWT4CUSO-Cf3_zw3F.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-Bzk5AxMb.js → dist/rcs-web/assets/xychartDiagram-2RQKCTM6-BuQiwlY7.js} +1 -1
- package/dist/rcs-web/index.html +1 -1
- package/package.json +1 -1
- package/packages/remote-control-server/src/__tests__/event-bus.test.ts +50 -0
- package/packages/remote-control-server/src/__tests__/routes.test.ts +100 -0
- package/packages/remote-control-server/src/routes/web/sessions.ts +64 -1
- package/packages/remote-control-server/src/transport/event-bus.ts +9 -0
- package/packages/remote-control-server/web/dist/assets/{AdminPanel-CbcZ7Vnr.js → AdminPanel-BMgxq2d0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/Claim-DRJ_CmK0.js +1 -0
- package/{dist/rcs-web/assets/Dashboard-BZGcSCFY.js → packages/remote-control-server/web/dist/assets/Dashboard-CablTsf3.js} +2 -2
- package/{dist/rcs-web/assets/Join-B_e3BKa3.js → packages/remote-control-server/web/dist/assets/Join-a80j0Uiw.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Login-u6CGGkoD.js → Login-DclVxA4Q.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Register-C4Fk0ibc.js → Register-DizfWHKb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{SessionDetail-Bd1YgozL.js → SessionDetail-CJoBz0DU.js} +14 -14
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-BHKxlh8U.js → SessionVisibilityBadge-Bp4kZdZ4.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Setup-DReCE0zx.js → Setup-DIw3Qc5x.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-qE1U0WKZ.js → ShareLanding-CmyujISc.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamCreate-BgwgZP4a.js → TeamCreate-fq5PdqO_.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamDetail-BHCvnI2t.js → TeamDetail-haFVDL0P.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{TeamList-B7uC8lDV.js → TeamList-CR63fSv_.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-DtgvrKEE.js → TeamSettings-BlXY05zK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-dgxhGWfJ.js → UserSearchInput-Cpg_A_Py.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSettings-Zyjam23-.js → UserSettings-BzHH2wQ6.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-DgC_wPAg.js → arc-cULKnhNn.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-BnnCRJZs.js → architectureDiagram-3BPJPVTR-CXLnNGBR.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-CvpYdvcP.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-BPQU9CvK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{c4Diagram-AAUBKEIU-DNK__-3d.js → c4Diagram-AAUBKEIU-x76XWolr.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-DVf9sV9K.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-5JQBz2na.js → chunk-2J33WTMH-C2xuSz2p.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-YJh8d73x.js → chunk-4BX2VUAB-BPsGJ9Ky.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-U5c5GQZN.js → chunk-55IACEB6-DV5Xxy86.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-ifGCid_3.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-dwWMJ2pm.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-DxqPH2_Q.js → chunk-AQP2D5EJ-CkxHIiMh.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-dDtjQRPo.js → chunk-FMBD7UC4-CyuNPJ-2.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-0UF6vhhE.js → chunk-ND2GUHAM-L7in2-8e.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-CfZ4xcBz.js → chunk-QZHKN3VN-xFEPbqY9.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DfHzlu2X.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DfHzlu2X.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-B4B0UrXo.js → code-block-IT6T5CEO-hkRn_BN_.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-_OW0eGyp.js → copy-B8rXAtFb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-B19xQvnh.js → cose-bilkent-S5V4N54A-DSZFWhhn.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-5JJnjI1B.js → dagre-BM42HDAG-B5wjmFJL.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-BY2NR7vr.js → diagram-2AECGRRQ-CGeTqGVq.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-3zC3GraP.js → diagram-5GNKFQAL-B9-2D-Y8.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-T1Jt5zH3.js → diagram-KO2AKTUF-BVCQ5UyX.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-ehrkQG1e.js → diagram-LMA3HP47-Cj4gFMtD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-D8ZJlGs0.js → diagram-OG6HWLK6-BBpaH0il.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-Ckn1pY7G.js → erDiagram-TEJ5UH35-DS19qy_q.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-C1xnAOfH.js → flowDiagram-I6XJVG4X-D9WY3n6O.js} +1 -1
- package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Dw8qOfCT.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-BNOSopT7.js} +1 -1
- package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-Cg3La45a.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-WBmYjFoA.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-CGH2aXpd.js → infoDiagram-5YYISTIA-D3l4nC2Y.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ishikawaDiagram-YF4QCWOH-x89F9Igr.js → ishikawaDiagram-YF4QCWOH-BYDxMH9Q.js} +1 -1
- package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-Ckd_pKi0.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-BSD6AEvb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-D2dEXdru.js → kanban-definition-UN3LZRKU-DtqGr_PI.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-CexxJrg8.js → linear-CaKAAJC6.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-L9iyf39T.js → main-Dk8hyS_b.js} +7 -7
- package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-BomP37Br.js → mermaid-VLURNSYL-f6St46tQ.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-BxkfDFm_.js → mermaid.core-DWc0M-5V.js} +5 -5
- package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-HVsZx8Je.js → mindmap-definition-RKZ34NQL-D0RkeEqx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-D0U9q74D.js → pieDiagram-4H26LBE5-YlDnS5wa.js} +1 -1
- package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-CWPBZMPj.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-CZcVTIBE.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-CiQbIN_P.js → requirementDiagram-4Y6WPE33-BUn0r08O.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-Bw66fXM0.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-Dr_ywHhs.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-lv5WhGb6.js → sequenceDiagram-3UESZ5HK-Bts1oven.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-BLRRpX3g.js → stateDiagram-AJRCARHV-DFbylE7U.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-B-5gzDu6.js → stateDiagram-v2-BHNVJYJU-Bzl4YDMv.js} +1 -1
- package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-DO8oVMVA.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-BtqngM31.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-D2RbeAHj.js → vennDiagram-CIIHVFJN-D1hGAcgx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-D8D1cIXp.js → wardleyDiagram-YWT4CUSO-Cf3_zw3F.js} +1 -1
- package/{dist/rcs-web/assets/xychartDiagram-2RQKCTM6-Bzk5AxMb.js → packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-BuQiwlY7.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +1 -1
- package/dist/rcs-web/assets/Claim-CN3D3Ku6.js +0 -1
- package/dist/rcs-web/assets/channel-DB6b62-p.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DkXLqlKv.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DkXLqlKv.js +0 -1
- package/packages/remote-control-server/web/dist/assets/Claim-CN3D3Ku6.js +0 -1
- package/packages/remote-control-server/web/dist/assets/channel-DB6b62-p.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DkXLqlKv.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DkXLqlKv.js +0 -1
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
var
|
|
1
|
+
var at=Object.defineProperty;var ot=(s,t,r)=>t in s?at(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var E=(s,t,r)=>ot(s,typeof t!="symbol"?t+"":t,r);import{e as u,j as e}from"./vendor-DE_-CLIE.js";import{a5 as I,Q as it,ad as lt,a0 as ct,a9 as me,$ as F,V as dt,x as Ae,g as ke,a8 as Ie,L as $e,z as ut,w as mt,a7 as A,a4 as K,d as qe,ag as we,W as xt,H as pt,_ as ht,ak as Pe,af as w,A as ft,aa as yt,F as gt,ah as bt,a6 as jt,I as kt,Y as wt,y as De,P as Nt,c as vt,C as _t,R as Ne,N as Ct,ac as St,D as Mt,a as Et,q as Ue,s as Fe,v as Tt,f as Oe,e as Le,r as He,M as Rt}from"./main-Dk8hyS_b.js";import{g as At}from"./workerType-Bd-zteMi.js";import{D as ze,a as Ve,c as Be,d as We,b as It,S as $t}from"./SessionVisibilityBadge-Bp4kZdZ4.js";import{U as qt}from"./UserSearchInput-Cpg_A_Py.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const Pt=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Dt=I("activity",Pt);/**
|
|
7
7
|
* @license lucide-react v0.555.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const Ut=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ft=I("chevron-right",Ut);/**
|
|
12
12
|
* @license lucide-react v0.555.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const Ot=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Qe=I("cpu",Ot);/**
|
|
17
17
|
* @license lucide-react v0.555.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Lt=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ht=I("external-link",Lt);/**
|
|
22
22
|
* @license lucide-react v0.555.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const zt=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Vt=I("hash",zt);/**
|
|
27
27
|
* @license lucide-react v0.555.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const Bt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Wt=I("info",Bt);/**
|
|
32
32
|
* @license lucide-react v0.555.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const Qt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],Yt=I("message-square-text",Qt);/**
|
|
37
37
|
* @license lucide-react v0.555.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const Kt=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Gt=I("play",Kt);/**
|
|
42
42
|
* @license lucide-react v0.555.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Jt=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],Xt=I("server-cog",Jt);/**
|
|
47
47
|
* @license lucide-react v0.555.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const Zt=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],es=I("share-2",Zt);/**
|
|
52
52
|
* @license lucide-react v0.555.0 - ISC
|
|
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
|
|
56
|
+
*/const ts=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ss=I("shield-check",ts);/**
|
|
57
57
|
* @license lucide-react v0.555.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const es=[["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"}]],ts=I("triangle-alert",es);function Qe(){return{tasks:{}}}const Ne=3e4;function ne(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 ss(s,t){var d,x,y,m,p,g,N,a,o,h,b,k;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:ne(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 j=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:ne(j),description:j,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 j=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:ne(j),description:j,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:(y=t.usage)==null?void 0:y.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:((p=t.usage)==null?void 0:p.tool_uses)??c.toolUseCount,durationMs:((g=t.usage)==null?void 0:g.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:((h=t.usage)==null?void 0:h.total_tokens)??c.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??c.toolUseCount,durationMs:((k=t.usage)==null?void 0:k.duration_ms)??c.durationMs,evictAfter:l+Ne}}}:{tasks:{...s.tasks,[n]:{taskId:n,name:ne(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:l,endTime:l,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(a=t.usage)==null?void 0:a.tool_uses,durationMs:(o=t.usage)==null?void 0:o.duration_ms,evictAfter:l+Ne}}}}function ns(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 rs{constructor(){E(this,"listeners",new Set);E(this,"eventSource",null);E(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 me=new rs;function ve(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 _e(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 xe="streaming-";function as(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 Ce(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 os{constructor(t,r,n){E(this,"sessionId");E(this,"setEntries");E(this,"unsub",null);E(this,"onStatusChange");E(this,"onError");E(this,"onPermissionRequest");E(this,"onModelsStateChange");E(this,"onSubagentUpdate");E(this,"onControlResponse");E(this,"onPermissionModeChange");E(this,"onUsageChange");E(this,"onElicitationRequest");E(this,"subagentState",Qe());E(this,"seenUuids",new Set);E(this,"seenToolCallIds",new Set);E(this,"pendingControlRequests",new Map);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 y,m;const{events:t}=await ot(this.sessionId);if(!t||t.length===0)return;const r=[];let n=null;const l=()=>{n&&(r.push(n),n=null)};for(const p of t){const g=p.payload||{},N=g.uuid;if(typeof N=="string"&&N&&this.seenUuids.add(N),p.type==="tool_use"){const a=g.tool_call_id;typeof a=="string"&&a&&this.seenToolCallIds.add(a)}if(p.type==="user"){if(p.direction==="inbound")continue;l();const a=ve(g);a&&r.push({type:"user_message",id:p.id||`hist-user-${r.length}`,content:a})}else if(p.type==="assistant"){l();const a=ve(g),o=[],h=g.message;if(h&&typeof h=="object"&&Array.isArray(h.content)){for(const b of h.content)if(b.type==="tool_use"){const k=b.id;k&&this.seenToolCallIds.add(k),o.push({type:"tool_call",toolCall:{id:k||`hist-tool-${r.length}`,title:b.name||"tool",status:"complete",rawInput:b.input||{}}})}}if(a||o.length>0){n={type:"assistant_message",id:p.id||`hist-asst-${r.length}`,chunks:a?[{type:"message",text:a}]:[]},r.push(n);for(const b of o)r.push(b);n=null}}else if(p.type==="tool_use"){const a=g,o={type:"tool_call",toolCall:{id:a.tool_call_id||`hist-tool-${r.length}`,title:a.tool_name||"tool",status:"complete",rawInput:a.tool_input||{}}};r.push(o)}else if(p.type==="tool_result"){const a=g,o=_e(r,a.tool_call_id||"");if(o>=0){const h=r[o];r[o]={type:"tool_call",toolCall:{...h.toolCall,rawOutput:{output:a.content||a.output||""}}}}}}l();let c=null;for(const p of t){if(p.type!=="task_state")continue;const g=p.payload||{};Array.isArray(g.tasks)&&(c=g.tasks)}if(c&&c.length>0){const p=Ce(c);p.length>0&&r.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:p})}this.setEntries(r);let d=null,x=null;for(const p of t){const g=p.payload||{};if(p.type==="models_state"){const N=g.raw,a=N&&typeof N=="object"?N.models_state:g.models_state;a&&Array.isArray(a.availableModels)&&typeof a.currentModelId=="string"&&(d=a)}else if(p.type==="result"||p.type==="result_success"){const N=g.usage,a=typeof g.total_cost_usd=="number"?g.total_cost_usd:null;(N||a!==null)&&(x={inputTokens:((N==null?void 0:N.input_tokens)??0)+((N==null?void 0:N.cache_read_input_tokens)??0)+((N==null?void 0:N.cache_creation_input_tokens)??0),outputTokens:(N==null?void 0:N.output_tokens)??0,totalCostUsd:a})}}d&&((y=this.onModelsStateChange)==null||y.call(this,d)),x&&((m=this.onUsageChange)==null||m.call(this,x))}connectSSE(){me.connect(this.sessionId),this.unsub=me.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),me.disconnect()}handleEvent(t){var c,d,x,y,m,p,g,N;const r=t.type,n=t.payload||{},l=JSON.stringify(t);if(!/Remote Control connecting/i.test(l))switch(r){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:"",h=as(n);this.setEntries(k=>{const j=k[k.length-1];if((j==null?void 0:j.type)==="assistant_message"&&j.id.startsWith(xe))return[...k.slice(0,-1),{...j,id:`assistant-${Date.now()}`,chunks:[...h?[{type:"thought",text:h}]:[],{type:"message",text:o}]}];if((j==null?void 0:j.type)==="assistant_message"){const _=j.chunks[j.chunks.length-1];return(_==null?void 0:_.type)==="message"?[...k.slice(0,-1),{...j,chunks:[...j.chunks.slice(0,-1),{type:"message",text:_.text+o}]}]:[...k.slice(0,-1),{...j,chunks:[...j.chunks,{type:"message",text:o}]}]}if(o&&o.trim()||h){const _={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...h?[{type:"thought",text:h}]:[],...o?[{type:"message",text:o}]:[]]};return[...k,_]}return k});const b=n.message;if(b&&typeof b=="object"&&Array.isArray(b.content)){const k=b.content.filter(j=>j.type==="tool_use");for(const j of k){const _=j.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(_))continue;this.seenToolCallIds.add(_);const M={id:_,title:j.name||"tool",status:"running",rawInput:j.input||{}};this.setEntries(T=>[...T,{type:"tool_call",toolCall:M}])}}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 h={id:o,title:a.tool_name||"tool",status:"running",rawInput:a.tool_input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:h}]);break}case"tool_result":{const a=n,o=a.tool_call_id||"";this.setEntries(h=>{const b=_e(h,o);if(b<0)return h;const k=h[b];return h.map((j,_)=>_===b?{type:"tool_call",toolCall:{...k.toolCall,status:"complete",rawOutput:{output:a.content||a.output||""}}}:j)});break}case"control_request":case"permission_request":{const a=n.request;if(a&&a.subtype==="can_use_tool"){const o=n.request_id||"",h=a.tool_name||"unknown",b=a.input||a.tool_input||{},k=a.description||"",j=Array.isArray(a.permission_suggestions)?a.permission_suggestions:[];this.setEntries(_=>{const M=[..._].reverse().findIndex(T=>T.type==="tool_call");if(M>=0){const T=_.length-1-M,$=_[T];if($.toolCall.status==="running")return _.map((z,q)=>q===T?{type:"tool_call",toolCall:{...$.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:o,options:[]}}}:z)}return _}),(c=this.onPermissionRequest)==null||c.call(this,{requestId:o,toolName:h,toolInput:b,description:k,suggestions:j})}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":{typeof n.status=="string"&&((x=this.onStatusChange)==null||x.call(this,n.status));break}case"error":{const a=String(n.message||n.content||"Unknown error");(y=this.onError)==null||y.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,h=typeof o.subtype=="string"?o.subtype:void 0;if(h==="task_started"||h==="task_progress"||h==="task_notification"){const k={subtype:h,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=ss(this.subagentState,k)}const b=typeof o.permissionMode=="string"?o.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;b&&((p=this.onPermissionModeChange)==null||p.call(this,b));break}case"control_response":{const a=n.response;if(a&&typeof a=="object"){const o=typeof a.request_id=="string"?a.request_id:"",h=typeof a.subtype=="string"?a.subtype:"";if(o){(g=this.onControlResponse)==null||g.call(this,{subtype:h,requestId:o,error:typeof a.error=="string"?a.error:void 0});const b=this.pendingControlRequests.get(o);b&&(this.pendingControlRequests.delete(o),b(h==="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 h=o.type==="text_delta"?"message":o.type==="thinking_delta"?"thought":null;if(!h)break;const b=o.text??o.thinking;if(typeof b!="string"||!b)break;this.appendStreamingDelta(h,b)}break}case"partial_assistant":{const a=typeof n.content=="string"?n.content:"";a&&this.appendStreamingDelta("message",a);break}case"result":case"result_success":{const a=n.usage,o=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(a||o!==null){const h=((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);(N=this.onUsageChange)==null||N.call(this,{inputTokens:h,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=Ce(a);if(o.length===0)break;this.setEntries(h=>[...h.filter(k=>k.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(xe)){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:`${xe}${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 p=`📎 ${m.name}${m.size!=null?` (${is(m.size)})`:""}`,g=m.textContent||"(空文件)";x.push({type:"text",text:`${p}
|
|
61
|
+
*/const ns=[["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"}]],rs=I("triangle-alert",ns);function Ye(){return{tasks:{}}}const ve=3e4;function ne(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 as(s,t){var d,x,y,m,p,g,N,a,i,h,b,k;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:ne(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 j=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:ne(j),description:j,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 j=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:ne(j),description:j,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:(y=t.usage)==null?void 0:y.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:((p=t.usage)==null?void 0:p.tool_uses)??c.toolUseCount,durationMs:((g=t.usage)==null?void 0:g.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:((h=t.usage)==null?void 0:h.total_tokens)??c.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??c.toolUseCount,durationMs:((k=t.usage)==null?void 0:k.duration_ms)??c.durationMs,evictAfter:l+ve}}}:{tasks:{...s.tasks,[n]:{taskId:n,name:ne(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:l,endTime:l,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(a=t.usage)==null?void 0:a.tool_uses,durationMs:(i=t.usage)==null?void 0:i.duration_ms,evictAfter:l+ve}}}}function os(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 is{constructor(){E(this,"listeners",new Set);E(this,"eventSource",null);E(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 xe=new is;function _e(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 Ce(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 pe="streaming-";function ls(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 Se(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 cs{constructor(t,r,n){E(this,"sessionId");E(this,"setEntries");E(this,"unsub",null);E(this,"onStatusChange");E(this,"onError");E(this,"onPermissionRequest");E(this,"onModelsStateChange");E(this,"onSubagentUpdate");E(this,"onControlResponse");E(this,"onPermissionModeChange");E(this,"onUsageChange");E(this,"onElicitationRequest");E(this,"subagentState",Ye());E(this,"seenUuids",new Set);E(this,"seenToolCallIds",new Set);E(this,"pendingControlRequests",new Map);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 y,m;const{events:t}=await it(this.sessionId);if(!t||t.length===0)return;const r=[];let n=null;const l=()=>{n&&(r.push(n),n=null)};for(const p of t){const g=p.payload||{},N=g.uuid;if(typeof N=="string"&&N&&this.seenUuids.add(N),p.type==="tool_use"){const a=g.tool_call_id;typeof a=="string"&&a&&this.seenToolCallIds.add(a)}if(p.type==="user"){if(p.direction==="inbound")continue;l();const a=_e(g);a&&r.push({type:"user_message",id:p.id||`hist-user-${r.length}`,content:a})}else if(p.type==="assistant"){l();const a=_e(g),i=[],h=g.message;if(h&&typeof h=="object"&&Array.isArray(h.content)){for(const b of h.content)if(b.type==="tool_use"){const k=b.id;k&&this.seenToolCallIds.add(k),i.push({type:"tool_call",toolCall:{id:k||`hist-tool-${r.length}`,title:b.name||"tool",status:"complete",rawInput:b.input||{}}})}}if(a||i.length>0){n={type:"assistant_message",id:p.id||`hist-asst-${r.length}`,chunks:a?[{type:"message",text:a}]:[]},r.push(n);for(const b of i)r.push(b);n=null}}else if(p.type==="tool_use"){const a=g,i={type:"tool_call",toolCall:{id:a.tool_call_id||`hist-tool-${r.length}`,title:a.tool_name||"tool",status:"complete",rawInput:a.tool_input||{}}};r.push(i)}else if(p.type==="tool_result"){const a=g,i=Ce(r,a.tool_call_id||"");if(i>=0){const h=r[i];r[i]={type:"tool_call",toolCall:{...h.toolCall,rawOutput:{output:a.content||a.output||""}}}}}}l();let c=null;for(const p of t){if(p.type!=="task_state")continue;const g=p.payload||{};Array.isArray(g.tasks)&&(c=g.tasks)}if(c&&c.length>0){const p=Se(c);p.length>0&&r.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:p})}this.setEntries(r);let d=null,x=null;for(const p of t){const g=p.payload||{};if(p.type==="models_state"){const N=g.raw,a=N&&typeof N=="object"?N.models_state:g.models_state;a&&Array.isArray(a.availableModels)&&typeof a.currentModelId=="string"&&(d=a)}else if(p.type==="result"||p.type==="result_success"){const N=g.usage,a=typeof g.total_cost_usd=="number"?g.total_cost_usd:null;(N||a!==null)&&(x={inputTokens:((N==null?void 0:N.input_tokens)??0)+((N==null?void 0:N.cache_read_input_tokens)??0)+((N==null?void 0:N.cache_creation_input_tokens)??0),outputTokens:(N==null?void 0:N.output_tokens)??0,totalCostUsd:a})}}d&&((y=this.onModelsStateChange)==null||y.call(this,d)),x&&((m=this.onUsageChange)==null||m.call(this,x))}connectSSE(){xe.connect(this.sessionId),this.unsub=xe.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),xe.disconnect()}handleEvent(t){var c,d,x,y,m,p,g,N;const r=t.type,n=t.payload||{},l=JSON.stringify(t);if(!/Remote Control connecting/i.test(l))switch(r){case"assistant":{const a=n.uuid;if(typeof a=="string"&&a){if(this.seenUuids.has(a))break;this.seenUuids.add(a)}const i=typeof n.content=="string"?n.content:"",h=ls(n);this.setEntries(k=>{const j=k[k.length-1];if((j==null?void 0:j.type)==="assistant_message"&&j.id.startsWith(pe))return[...k.slice(0,-1),{...j,id:`assistant-${Date.now()}`,chunks:[...h?[{type:"thought",text:h}]:[],{type:"message",text:i}]}];if((j==null?void 0:j.type)==="assistant_message"){const _=j.chunks[j.chunks.length-1];return(_==null?void 0:_.type)==="message"?[...k.slice(0,-1),{...j,chunks:[...j.chunks.slice(0,-1),{type:"message",text:_.text+i}]}]:[...k.slice(0,-1),{...j,chunks:[...j.chunks,{type:"message",text:i}]}]}if(i&&i.trim()||h){const _={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...h?[{type:"thought",text:h}]:[],...i?[{type:"message",text:i}]:[]]};return[...k,_]}return k});const b=n.message;if(b&&typeof b=="object"&&Array.isArray(b.content)){const k=b.content.filter(j=>j.type==="tool_use");for(const j of k){const _=j.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(_))continue;this.seenToolCallIds.add(_);const M={id:_,title:j.name||"tool",status:"running",rawInput:j.input||{}};this.setEntries(T=>[...T,{type:"tool_call",toolCall:M}])}}break}case"tool_use":{const a=n,i=a.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(i))break;this.seenToolCallIds.add(i);const h={id:i,title:a.tool_name||"tool",status:"running",rawInput:a.tool_input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:h}]);break}case"tool_result":{const a=n,i=a.tool_call_id||"";this.setEntries(h=>{const b=Ce(h,i);if(b<0)return h;const k=h[b];return h.map((j,_)=>_===b?{type:"tool_call",toolCall:{...k.toolCall,status:"complete",rawOutput:{output:a.content||a.output||""}}}:j)});break}case"control_request":case"permission_request":{const a=n.request;if(a&&a.subtype==="can_use_tool"){const i=n.request_id||"",h=a.tool_name||"unknown",b=a.input||a.tool_input||{},k=a.description||"",j=Array.isArray(a.permission_suggestions)?a.permission_suggestions:[];this.setEntries(_=>{const M=[..._].reverse().findIndex(T=>T.type==="tool_call");if(M>=0){const T=_.length-1-M,$=_[T];if($.toolCall.status==="running")return _.map((z,q)=>q===T?{type:"tool_call",toolCall:{...$.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:i,options:[]}}}:z)}return _}),(c=this.onPermissionRequest)==null||c.call(this,{requestId:i,toolName:h,toolInput:b,description:k,suggestions:j})}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(lt(n)){this.setEntries([]);break}typeof n.status=="string"&&((x=this.onStatusChange)==null||x.call(this,n.status));break}case"error":{const a=String(n.message||n.content||"Unknown error");(y=this.onError)==null||y.call(this,a);break}case"models_state":{const a=n.raw,i=typeof a=="object"&&a!==null?a.models_state:n.models_state;i&&Array.isArray(i.availableModels)&&typeof i.currentModelId=="string"&&((m=this.onModelsStateChange)==null||m.call(this,i));break}case"system":{const a=n.raw,i=a&&typeof a=="object"?a:n,h=typeof i.subtype=="string"?i.subtype:void 0;if(h==="task_started"||h==="task_progress"||h==="task_notification"){const k={subtype:h,task_id:typeof i.task_id=="string"?i.task_id:void 0,tool_use_id:typeof i.tool_use_id=="string"?i.tool_use_id:void 0,description:typeof i.description=="string"?i.description:void 0,task_type:typeof i.task_type=="string"?i.task_type:void 0,workflow_name:typeof i.workflow_name=="string"?i.workflow_name:void 0,prompt:typeof i.prompt=="string"?i.prompt:void 0,usage:i.usage&&typeof i.usage=="object"?i.usage:void 0,last_tool_name:typeof i.last_tool_name=="string"?i.last_tool_name:void 0,summary:typeof i.summary=="string"?i.summary:void 0,status:i.status==="completed"||i.status==="failed"||i.status==="stopped"?i.status:void 0,output_file:typeof i.output_file=="string"?i.output_file:void 0};this.subagentState=as(this.subagentState,k)}const b=typeof i.permissionMode=="string"?i.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;b&&((p=this.onPermissionModeChange)==null||p.call(this,b));break}case"control_response":{const a=n.response;if(a&&typeof a=="object"){const i=typeof a.request_id=="string"?a.request_id:"",h=typeof a.subtype=="string"?a.subtype:"";if(i){(g=this.onControlResponse)==null||g.call(this,{subtype:h,requestId:i,error:typeof a.error=="string"?a.error:void 0});const b=this.pendingControlRequests.get(i);b&&(this.pendingControlRequests.delete(i),b(h==="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 i=a.delta;if(!i||typeof i.type!="string")break;const h=i.type==="text_delta"?"message":i.type==="thinking_delta"?"thought":null;if(!h)break;const b=i.text??i.thinking;if(typeof b!="string"||!b)break;this.appendStreamingDelta(h,b)}break}case"partial_assistant":{const a=typeof n.content=="string"?n.content:"";a&&this.appendStreamingDelta("message",a);break}case"result":case"result_success":{const a=n.usage,i=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(a||i!==null){const h=((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);(N=this.onUsageChange)==null||N.call(this,{inputTokens:h,outputTokens:(a==null?void 0:a.output_tokens)??0,totalCostUsd:i})}break}case"task_state":{const a=Array.isArray(n.tasks)?n.tasks:[];if(a.length===0)break;const i=Se(a);if(i.length===0)break;this.setEntries(h=>[...h.filter(k=>k.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:i}]);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(pe)){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:`${pe}${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 p=`📎 ${m.name}${m.size!=null?` (${ds(m.size)})`:""}`,g=m.textContent||"(空文件)";x.push({type:"text",text:`${p}
|
|
62
62
|
\`\`\`
|
|
63
63
|
${g}
|
|
64
64
|
\`\`\``})}else if(m.kind==="directory"){const p=`📁 目录: ${m.name}${m.files!=null?` (${m.files.length} 个文件)`:""}`,g=m.textContent||"(空目录)";x.push({type:"text",text:`${p}
|
|
65
|
-
${g}`})}}const y=x.length===1&&x[0].type==="text"?x[0].text||t:x.length>0?x:t;await it(this.sessionId,{type:"user",uuid:ue(),content:t,message:{content:y}})}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 lt(this.sessionId)}async setPermissionMode(t){const r=ue();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=ue(),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 y of d.suggestions)y&&typeof y=="object"&&typeof y.path=="string"&&x.push(y.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 is(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ls(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 cs(s){return s?Date.now()-s<6e4:!1}function ds({onClose:s,session:t,liveStatus:r,pendingPermissions:n,onInterrupt:l,onDelete:c}){const[d,x]=u.useState(!1),y=async()=>{await navigator.clipboard.writeText(t.id),x(!0),setTimeout(()=>x(!1),1500)},m=n.length,p=t.worker,g=t.work_item,N=t.environment;return e.jsx(He,{open:!0,onOpenChange:a=>{a||s()},children:e.jsxs(ze,{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(Ve,{children:e.jsx(Be,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx($t,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{status:r||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:p&&(cs(p.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ls(p.last_heartbeat_at)})]}),N&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(We,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:N.machine_name||N.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Ae(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(Ie,{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(Yt,{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(ct,{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(Lt,{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:y,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:d?"✓":"⧉"})]})]}),g&&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:g.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:g.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})]}),N&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:N.worker_type})]})]})]})]})]})})}const Se="rcs:subagent-panel:collapsed";function us(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 ms(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 xs({status:s}){return s==="running"?e.jsx(Ie,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(Qt,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(dt,{className:"h-3 w-3 text-status-error"}):null}function ps({task:s}){const t=s.status==="running",r=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,n=ms(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(xs,{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:us(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 hs({state:s}){const[t,r]=u.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Se)==="1"}catch{return!1}}),n=()=>{r(y=>{const m=!y;try{window.localStorage.setItem(Se,m?"1":"0")}catch{}return m})},[,l]=u.useState(0);u.useEffect(()=>{const y=Object.values(s.tasks).some(g=>g.status==="running"),m=Object.values(s.tasks).some(g=>g.status!=="running"&&g.evictAfter!==void 0);if(!y&&!m)return;const p=setInterval(()=>{l(g=>g+1)},1e3);return()=>clearInterval(p)},[s]);const c=ns(s);if(c.length===0)return null;const d=c.filter(y=>y.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(Pt,{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(y=>e.jsx(ps,{task:y},y.taskId))})]})})}function Me(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 fs({requestId:s,toolName:t,toolInput:r,description:n,suggestions:l,onApprove:c,onApproveAlways:d,onReject:x}){const y=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(ts,{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:A(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:A(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:ke(y,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:`允许并记住规则:${Me(t,l)}`,children:[e.jsx(Zt,{className:"h-3.5 w-3.5"}),"Always allow ",ke(Me(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 ys({questions:s,description:t,onSubmit:r,onSkip:n}){const[l,c]=u.useState({}),[d,x]=u.useState({}),[y,m]=u.useState(0),p=(o,h,b)=>{if(b){const k=l[o]||[],j=k.includes(h)?k.filter(_=>_!==h):[...k,h];c({...l,[o]:j})}else c({...l,[o]:h})},g=o=>{var b;const h=(b=d[o])==null?void 0:b.trim();h&&(c({...l,[o]:h}),x({...d,[o]:""}))},N=()=>{var h,b;const o={};for(const[k,j]of Object.entries(l)){const _=s[parseInt(k,10)];_&&(typeof j=="number"?o[k]=((b=(h=_.options)==null?void 0:h[j])==null?void 0:b.label)||String(j):Array.isArray(j)?o[k]=j.map(M=>{var T,$;return(($=(T=_.options)==null?void 0:T[M])==null?void 0:$.label)||String(M)}):o[k]=j)}r(o)};if(s.length<=1){const o=s[0]||{question:t,options:[],multiSelect:!1},h=o.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:A(t||o.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(o.options||[]).map((b,k)=>{const j=h?(l[0]||[]).includes(k):l[0]===k;return e.jsxs("button",{onClick:()=>p(0,k,h),className:Y("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",j?"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:A(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(b.description)})]},k)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:d[0]||"",onChange:b=>x({...d,0:b.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:b=>b.key==="Enter"&&g(0)}),e.jsx("button",{onClick:()=>g(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick: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 a=s[y];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:A(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((o,h)=>e.jsx("button",{onClick:()=>m(h),className:Y("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",y===h?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:o.header||`Q${h+1}`},h))}),a&&e.jsx(gs,{question:a,qIdx:y,answers:l,otherTexts:d,onSelect:p,onOtherTextChange:(o,h)=>x({...d,[o]:h}),onOtherSubmit:g}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[y+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick: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 gs({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:A(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((y,m)=>{const p=x?(r[t]||[]).includes(m):r[t]===m;return e.jsxs("button",{onClick:()=>l(t,m,x),className:Y("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",p?"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:A(y.label)}),y.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(y.description)})]},m)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:y=>c(t,y.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:y=>y.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 bs({planContent:s,description:t,onSubmit:r}){const[n,l]=u.useState(null),[c,d]=u.useState(""),x=!s||!s.trim(),y=()=>{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($e,{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:js(s)}}),e.jsx("div",{className:"space-y-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(K,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes"}),e.jsx(K,{selected:n==="no",onClick:()=>l("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{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(K,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(K,{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:y,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 K({selected:s,onClick:t,label:r,desc:n}){return e.jsxs("button",{onClick:t,className:Y("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:Y("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 js(s){let t=A(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 ks({request:s,onSubmit:t}){const r=ws(s.requestedSchema),n=Ns(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(Ee,{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(Ot,{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(Ee,{serverName:s.serverName,message:s.message}),r.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:r.map(({name:x,prop:y})=>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:"必填"})]}),y.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:A(y.description)}),e.jsx("input",{type:y.type==="number"?"number":"text",value:l[x]??"",onChange:m=>c(p=>({...p,[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:y,prop:m}of r){const p=(l[y]??"").trim();p&&(x[y]=m.type==="number"?Number(p):p)}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 Ee({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(Bt,{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:A(s)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:A(t)})]})}function ws(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 Ns(s){const t=s==null?void 0:s.required;return Array.isArray(t)?t.filter(r=>typeof r=="string"):[]}function vs(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 p=await ut(s);r(p)}catch(p){d(p instanceof Error?p.message:"Failed to load shares")}finally{l(!1)}},[s]);u.useEffect(()=>{x()},[x]);const y=u.useCallback(async p=>{d(null);try{const g=await mt(s,p);return await x(),g}catch(g){throw d(g instanceof Error?g.message:"Failed to create share"),g}},[s,x]),m=u.useCallback(async p=>{d(null);try{await xt(s,p),await x()}catch(g){throw d(g instanceof Error?g.message:"Failed to revoke share"),g}},[s,x]);return{shares:t,isLoading:n,error:c,createShare:y,revokeShare:m,refresh:x}}function _s({open:s,onClose:t,sessionId:r,sessionTitle:n}){qe();const{shares:l,isLoading:c,error:d,createShare:x,revokeShare:y}=vs(r),[m,p]=u.useState("user"),[g,N]=u.useState(""),[a,o]=u.useState(""),[h,b]=u.useState("read"),[k,j]=u.useState(""),[_,M]=u.useState(!1),[T,$]=u.useState(null),[z,q]=u.useState(""),[ae,P]=u.useState(!1),[G,F]=u.useState(!1);u.useEffect(()=>{s&&(p("user"),N(""),o(""),b("read"),j(""),M(!1),$(null),q(""),P(!1),F(!1))},[s]);const B=async()=>{M(!0),q(""),$(null);try{const C={grantedTo:m==="user"?{userId:g.trim()}:{teamId:a.trim()},permission:h};k.trim()&&(C.expiresAt=k.trim());const X=await x(C);$(`${window.location.origin}/code/s/${X.shareToken}`)}catch(C){q(C instanceof Error?C.message:"Failed to create share")}finally{M(!1)}},J=async C=>{try{await y(C)}catch{}},W=async()=>{if(!T)return;F(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),P(!0),setTimeout(()=>P(!1),2e3);return}}catch{}const C=document.createElement("textarea");C.value=T,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),P(!0),setTimeout(()=>P(!1),2e3)}catch{F(!0)}document.body.removeChild(C)};return e.jsx(He,{open:s,onOpenChange:C=>{C||t()},children:e.jsxs(ze,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ve,{children:e.jsxs(Be,{className:"font-display text-lg font-semibold text-text-primary",children:[w("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:w("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>p("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:w("share.user")}),e.jsx("button",{onClick:()=>p("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:w("share.team")})]}),m==="user"?e.jsx(At,{onSelect:N,placeholder:w("share.userIdPlaceholder"),actionLabel:w("share.selectUser")}):e.jsx("input",{type:"text",value:a,onChange:C=>o(C.target.value),placeholder:w("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"&&g&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[w("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:g})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:w("share.permission")}),e.jsxs("select",{value:h,onChange:C=>b(C.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:w("share.permissionRead")}),e.jsx("option",{value:"write",children:w("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:w("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:k,onChange:C=>j(C.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"})]}),(z||d)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:z||d}),T&&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:w("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:T}),e.jsx("button",{onClick:W,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:ae?w("share.copied"):w("share.copy")})]}),G&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:w("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:w("share.existingShares")}),c?e.jsx("p",{className:"text-sm text-text-muted",children:w("share.loading")}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:w("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:l.map(C=>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:C.granted_to_user||C.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[C.permission==="write"?w("share.permissionWrite"):w("share.permissionRead"),C.expires_at?` · expires ${C.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>J(C.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:w("share.revoke")})]},C.id))})]})]}),e.jsxs(Tt,{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:w("common.close")}),e.jsx("button",{onClick:B,disabled:_||(m==="user"?!g.trim():!a.trim()),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:_?w("common.creating"):w("share.createShare")})]})]})})}function Cs(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Ss(s){const t=Cs(s),r=ht(),n=r?{proxyUrl:t,token:r}:{proxyUrl:t};return new pt(n)}const V=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],re="rcs_permission_mode";function Te(s){return s<1e3?String(s):s<1e6?`${(s/1e3).toFixed(1)}k`:`${(s/1e6).toFixed(1)}M`}function Ms(s){const t=V.findIndex(r=>r.value===s);return V[(t+1+V.length)%V.length].value}function Es({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,y=async m=>{r(m.modelId),c(!1)};return e.jsxs(De,{open:l,onOpenChange:x?c:void 0,children:[e.jsx(Ue,{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(We,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(d==null?void 0:d.name)??t??"选择模型"}),l?e.jsx(Oe,{className:"h-3 w-3"}):e.jsx(Fe,{className:"h-3 w-3"})]})}),e.jsx(Le,{className:"w-72 p-0",align:"start",children:e.jsx(Mt,{models:s,currentModelId:t,onSelect:y,showSearch:s.length>5})})]})}function Ts({mode:s,onModeChange:t,disabled:r}){const[n,l]=u.useState(!1),c=V.find(d=>d.value===s);return e.jsxs(De,{open:n,onOpenChange:l,children:[e.jsx(Ue,{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(St,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??s}),n?e.jsx(Oe,{className:"h-3 w-3"}):e.jsx(Fe,{className:"h-3 w-3"})]})}),e.jsx(Le,{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($e,{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 Ls({sessionId:s,onSessionLoaded:t}){qe();const[r,n]=u.useState(null),[l,c]=u.useState(null),[d,x]=u.useState(""),[y,m]=u.useState(!1),[p,g]=u.useState(!1),[N,a]=u.useState(!1),[o,h]=u.useState([]),[b,k]=u.useState(!1),[j,_]=u.useState([]),[M,T]=u.useState(null),[$,z]=u.useState(()=>Qe()),[q,ae]=u.useState(null),[P,G]=u.useState(null),[F,B]=u.useState([]),[J,W]=u.useState(!1),[C,X]=u.useState(""),oe=u.useRef(null),[ie,Z]=u.useState(()=>localStorage.getItem(re)||"default"),[pe,he]=u.useState(null),Q=u.useRef(null),U=u.useRef(ie);U.current=ie;const ee=u.useRef(null),fe=u.useRef(null),ye=u.useRef(o);ye.current=o;const te=u.useCallback(i=>{he(i),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>he(null),5e3)},[]),le=u.useCallback(i=>{var v;if(i===U.current)return;const f=U.current;U.current=i,Z(i);try{localStorage.setItem(re,i)}catch{}(v=fe.current)==null||v.setPermissionMode(i).then(S=>{ee.current={requestId:S,previous:f}}).catch(S=>{console.error("[SessionDetail] set permission mode failed:",S),te(`模式切换请求发送失败: ${S instanceof Error?S.message:String(S)}`),U.current=f,Z(f)})},[te]),R=u.useMemo(()=>new os(s,h,{onStatusChange:i=>{c(i),k(i==="running"||i==="requires_action")},onError:i=>{console.error("[RCSChatAdapter] error:",i)},onPermissionRequest:i=>{_(f=>f.some(v=>v.requestId===i.requestId)?f:[...f,i])},onModelsStateChange:i=>{T(i)},onSubagentUpdate:i=>{z(i)},onControlResponse:i=>{const f=ee.current;if(!(!f||f.requestId!==i.requestId)&&(ee.current=null,i.subtype==="error")){U.current=f.previous,Z(f.previous);try{localStorage.setItem(re,f.previous)}catch{}te(i.error||"模式切换失败")}},onPermissionModeChange:i=>{if(i!==U.current){U.current=i,Z(i);try{localStorage.setItem(re,i)}catch{}ee.current=null}},onUsageChange:i=>{ae(f=>({inputTokens:Math.max((f==null?void 0:f.inputTokens)??0,i.inputTokens),outputTokens:Math.max((f==null?void 0:f.outputTokens)??0,i.outputTokens),totalCostUsd:i.totalCostUsd??(f==null?void 0:f.totalCostUsd)??null}))},onElicitationRequest:i=>{G(i)}}),[s,te]);u.useEffect(()=>(fe.current=R,()=>{R.disconnect()}),[R]),u.useEffect(()=>{let i=!1;async function f(){x("");try{const v=await Nt(s);if(i)return;n(v),c(v.status),k(v.status==="running"||v.status==="requires_action"),t==null||t(v)}catch(v){if(i)return;x(v instanceof Error?v.message:w("session.loadFailed"));return}try{await R.init()}catch(v){console.warn("Failed to init adapter:",v)}}return f(),()=>{i=!0}},[s,R,t]);const H=vt(l),L=(r==null?void 0:r.access_level)==="read",se=u.useCallback(async i=>{const f=i.text.trim(),v=i.images&&i.images.length>0||i.attachments&&i.attachments.length>0;if(!f&&!v||H)return;const S=await ft(f,{sessionId:s,availableCommands:we,availableModels:(M==null?void 0:M.availableModels)??[],currentModel:M?{modelId:M.currentModelId,name:M.currentModelId}:null,supportsImages:!0,entries:ye.current,setModel:async D=>{await O(s,{type:"control_request",request:{subtype:"set_model",model:D}}),T(de=>de&&{...de,currentModelId:D})},onNewSession:()=>{h([])}}).catch(()=>null);if(S){if(yt("[SessionDetail] local command result",S),"clearEntries"in S&&S.clearEntries){h([]);return}if("newSession"in S&&S.newSession){h([]);return}if("userEntry"in S){h(D=>[...D,S.userEntry,S.cmdEntry]);return}}k(!0);try{await R.sendMessage(f,i.images,i.attachments)}catch(D){console.error("Send failed:",D)}},[R,H,s,M]),Ke=u.useCallback(i=>{if(b){B(f=>[...f,i]);return}se(i)},[b,se]),ce=u.useRef(!1);u.useEffect(()=>{if(b||F.length===0||ce.current)return;const i=F[0];i&&(ce.current=!0,B(f=>f.slice(1)),se(i).finally(()=>{ce.current=!1}))},[b,F,se]);const ge=u.useCallback(async()=>{try{await R.interrupt()}catch(i){console.error("Interrupt failed:",i)}finally{k(!1)}},[R]),Ye=u.useCallback(()=>{le(Ms(U.current))},[le]);u.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);const Ge=u.useCallback(async()=>{if(r&&window.confirm(w("dashboard.confirmDelete").replace("{id}",r.title||r.id)))try{await gt(r.id),window.location.href="/code/"}catch(i){alert(i instanceof Error?i.message:w("dashboard.deleteFailed"))}},[r]),Je=u.useCallback(async i=>{try{await R.respondPermission(i,!0)}catch(f){console.error("Failed to approve:",f)}_(f=>f.filter(v=>v.requestId!==i))},[R]),Xe=u.useCallback(async(i,f)=>{try{await R.respondPermission(i,!0,{updated_permissions:f})}catch(v){console.error("Failed to approve with rules:",v)}_(v=>v.filter(S=>S.requestId!==i))},[R]),Ze=u.useCallback(async(i,f)=>{const v=P;if(G(null),!!v)try{await R.respondElicitation(v.requestId,i,f)}catch(S){console.error("Failed to submit elicitation:",S)}},[P,R]),et=u.useCallback(()=>{!r||L||(X(r.title||""),W(!0),setTimeout(()=>{var i,f;(i=oe.current)==null||i.focus(),(f=oe.current)==null||f.select()},0))},[r,L]),be=u.useCallback(async()=>{const i=C.trim();if(W(!1),!(!r||!i||i===r.title))try{const f=await bt(r.id,i);n(v=>v&&{...v,title:f.title??i})}catch(f){console.error("Rename failed:",f),alert(f instanceof Error?f.message:"重命名失败")}},[r,C]),tt=u.useCallback(async i=>{try{await R.respondPermission(i,!1)}catch(f){console.error("Failed to reject:",f)}_(f=>f.filter(v=>v.requestId!==i))},[R]),st=u.useCallback(async(i,f,v)=>{try{await O(s,{type:"permission_response",approved:!0,request_id:i,updated_input:{questions:v,answers:f}})}catch(S){console.error("Failed to submit answers:",S)}_(S=>S.filter(D=>D.requestId!==i))},[s]),nt=u.useCallback(async(i,f,v)=>{try{f==="no"?await O(s,{type:"permission_response",approved:!1,request_id:i,...v?{message:v}:{}}):await O(s,{type:"permission_response",approved:!0,request_id:i,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[f]||"default",destination:"session"}]})}catch(S){console.error("Failed to submit plan response:",S)}_(S=>S.filter(D=>D.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:w("session.backToDashboard")})]})}):r?r.source==="acp"&&r.environment_id?e.jsx(As,{sessionId:s,agentId:r.environment_id}):e.jsx(Pe,{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:[J?e.jsx("input",{ref:oe,value:C,onChange:i=>X(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.nativeEvent.isComposing?(i.preventDefault(),be()):i.key==="Escape"&&(i.preventDefault(),W(!1))},onBlur:()=>void be(),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&&!H&&e.jsx("button",{type:"button",onClick:et,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(jt,{className:"h-3.5 w-3.5"})})]}),r.visibility&&!J&&e.jsx(Rt,{visibility:r.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var v;const i=r.source==="acp"?"acp":(v=r.environment)==null?void 0:v.worker_type,f=Et(i);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${f.colorClass}`,children:f.fullLabel})})(),l&&e.jsx(Re,{status:l}),e.jsx("span",{className:"text-xs text-text-muted",children:Ae(r.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!L&&(r==null?void 0:r.access_level)!=="write"&&e.jsx("button",{onClick:()=>a(!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:w("session.share"),children:e.jsx(Jt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>g(!p),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:w("session.info"),children:e.jsx(zt,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>m(!y),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:[w("session.tasks"),j.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:j.length})]})]})]}),p&&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:w("session.metaSession")})," ",r.id]}),r.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:w("session.metaEnvironment")})," ",r.environment_id]})]})]})}),e.jsx(kt,{entries:o,isLoading:b,emptyTitle:w("session.emptyTitle"),emptyDescription:w("session.emptyDescription")}),e.jsx(hs,{state:$}),j.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:j.map(i=>e.jsx(Rs,{request:i,onApprove:()=>Je(i.requestId),onApproveAlways:i.suggestions&&i.suggestions.length>0?()=>Xe(i.requestId,i.suggestions??[]):void 0,onReject:()=>tt(i.requestId),onSubmitAnswers:st,onSubmitPlan:nt},i.requestId))})}),P&&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(ks,{request:P,onSubmit:Ze})})}),pe&&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:pe})}),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(Ts,{mode:ie,onModeChange:le,disabled:H||L}),e.jsx(Es,{models:(M==null?void 0:M.availableModels)??[],currentModelId:(M==null?void 0:M.currentModelId)??null,onSelect:i=>{O(s,{type:"control_request",request:{subtype:"set_model",model:i}}),T(f=>f&&{...f,currentModelId:i})},disabled:H||L})]}),q&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:"会话累计用量(input 含缓存读写)",children:[Te(q.inputTokens)," in / ",Te(q.outputTokens)," out",q.totalCostUsd!=null&&` · $${q.totalCostUsd.toFixed(2)}`]})]}),e.jsx(wt,{onSubmit:Ke,isLoading:b,onInterrupt:ge,onCycleMode:Ye,disabled:H||L,placeholder:H?w("session.closed"):L?w("session.readOnly"):w("session.inputPlaceholder"),supportsAttachments:!0,commands:we,queueWhileLoading:!0,queuedCount:F.length,onDequeue:i=>B(f=>f.filter((v,S)=>S!==i)),onSearchFiles:i=>R.searchFiles(i)}),y&&r&&e.jsx(ds,{onClose:()=>m(!1),session:r,liveStatus:l,pendingPermissions:j,onInterrupt:ge,onDelete:Ge}),e.jsx(_s,{open:N,onClose:()=>a(!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:w("session.loading")})})}function Rs({request:s,onApprove:t,onApproveAlways:r,onReject:n,onSubmitAnswers:l,onSubmitPlan:c}){const d=s.toolName,x=s.toolInput,y=s.description||"";if(d==="AskUserQuestion"){const m=x.questions||[];return e.jsx(ys,{requestId:s.requestId,questions:m,description:y,onSubmit:p=>l(s.requestId,p,m),onSkip:n})}if(d==="ExitPlanMode"){const m=x.plan||"";return e.jsx(bs,{requestId:s.requestId,planContent:m,description:y,onSubmit:(p,g)=>c(s.requestId,p,g)})}return e.jsx(fs,{requestId:s.requestId,toolName:d,toolInput:x,description:y,suggestions:s.suggestions,onApprove:t,onApproveAlways:r,onReject:n})}function As({sessionId:s,agentId:t}){const[r,n]=u.useState(null),[l,c]=u.useState("disconnected"),[d,x]=u.useState(null),y=u.useRef(null);return u.useEffect(()=>{const m=Ss(t);return m.setConnectionStateHandler((p,g)=>{c(p),x(g||null)}),y.current=m,n(m),m.connect().catch(p=>{p instanceof _t||(x(p.message),c("error"))}),()=>{m.disconnect(),y.current=null,n(null),c("disconnected")}},[t]),e.jsx(Pe,{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:w("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:w("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(Ct,{client:r,agentId:t})})]})})}export{Ls as SessionDetail};
|
|
65
|
+
${g}`})}}const y=x.length===1&&x[0].type==="text"?x[0].text||t:x.length>0?x:t;await ct(this.sessionId,{type:"user",uuid:me(),content:t,message:{content:y}})}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 dt(this.sessionId)}async setPermissionMode(t){const r=me();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=me(),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 y of d.suggestions)y&&typeof y=="object"&&typeof y.path=="string"&&x.push(y.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 ds(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function us(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 ms(s){return s?Date.now()-s<6e4:!1}function xs({onClose:s,session:t,liveStatus:r,pendingPermissions:n,onInterrupt:l,onDelete:c}){const[d,x]=u.useState(!1),y=async()=>{await navigator.clipboard.writeText(t.id),x(!0),setTimeout(()=>x(!1),1500)},m=n.length,p=t.worker,g=t.work_item,N=t.environment;return e.jsx(ze,{open:!0,onOpenChange:a=>{a||s()},children:e.jsxs(Ve,{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(Be,{children:e.jsx(We,{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(Dt,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ae,{status:r||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:p&&(ms(p.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:us(p.last_heartbeat_at)})]}),N&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Qe,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:N.machine_name||N.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ke,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Ie(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($e,{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(Xt,{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(ut,{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(Vt,{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:y,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:d?"✓":"⧉"})]})]}),g&&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:g.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:g.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})]}),N&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:N.worker_type})]})]})]})]})]})})}const Me="rcs:subagent-panel:collapsed";function ps(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 hs(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 fs({status:s}){return s==="running"?e.jsx($e,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(Gt,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(mt,{className:"h-3 w-3 text-status-error"}):null}function ys({task:s}){const t=s.status==="running",r=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,n=hs(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(fs,{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:ps(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 gs({state:s}){const[t,r]=u.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Me)==="1"}catch{return!1}}),n=()=>{r(y=>{const m=!y;try{window.localStorage.setItem(Me,m?"1":"0")}catch{}return m})},[,l]=u.useState(0);u.useEffect(()=>{const y=Object.values(s.tasks).some(g=>g.status==="running"),m=Object.values(s.tasks).some(g=>g.status!=="running"&&g.evictAfter!==void 0);if(!y&&!m)return;const p=setInterval(()=>{l(g=>g+1)},1e3);return()=>clearInterval(p)},[s]);const c=os(s);if(c.length===0)return null;const d=c.filter(y=>y.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(Ft,{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(y=>e.jsx(ys,{task:y},y.taskId))})]})})}function Ee(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 bs({requestId:s,toolName:t,toolInput:r,description:n,suggestions:l,onApprove:c,onApproveAlways:d,onReject:x}){const y=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(rs,{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:A(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:A(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:we(y,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:`允许并记住规则:${Ee(t,l)}`,children:[e.jsx(ss,{className:"h-3.5 w-3.5"}),"Always allow ",we(Ee(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 js({questions:s,description:t,onSubmit:r,onSkip:n}){const[l,c]=u.useState({}),[d,x]=u.useState({}),[y,m]=u.useState(0),p=(i,h,b)=>{if(b){const k=l[i]||[],j=k.includes(h)?k.filter(_=>_!==h):[...k,h];c({...l,[i]:j})}else c({...l,[i]:h})},g=i=>{var b;const h=(b=d[i])==null?void 0:b.trim();h&&(c({...l,[i]:h}),x({...d,[i]:""}))},N=()=>{var h,b;const i={};for(const[k,j]of Object.entries(l)){const _=s[parseInt(k,10)];_&&(typeof j=="number"?i[k]=((b=(h=_.options)==null?void 0:h[j])==null?void 0:b.label)||String(j):Array.isArray(j)?i[k]=j.map(M=>{var T,$;return(($=(T=_.options)==null?void 0:T[M])==null?void 0:$.label)||String(M)}):i[k]=j)}r(i)};if(s.length<=1){const i=s[0]||{question:t,options:[],multiSelect:!1},h=i.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:A(t||i.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(i.options||[]).map((b,k)=>{const j=h?(l[0]||[]).includes(k):l[0]===k;return e.jsxs("button",{onClick:()=>p(0,k,h),className:K("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",j?"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:A(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(b.description)})]},k)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:d[0]||"",onChange:b=>x({...d,0:b.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:b=>b.key==="Enter"&&g(0)}),e.jsx("button",{onClick:()=>g(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick: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 a=s[y];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:A(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((i,h)=>e.jsx("button",{onClick:()=>m(h),className:K("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",y===h?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:i.header||`Q${h+1}`},h))}),a&&e.jsx(ks,{question:a,qIdx:y,answers:l,otherTexts:d,onSelect:p,onOtherTextChange:(i,h)=>x({...d,[i]:h}),onOtherSubmit:g}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[y+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick: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 ks({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:A(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((y,m)=>{const p=x?(r[t]||[]).includes(m):r[t]===m;return e.jsxs("button",{onClick:()=>l(t,m,x),className:K("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",p?"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:A(y.label)}),y.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(y.description)})]},m)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:y=>c(t,y.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:y=>y.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 ws({planContent:s,description:t,onSubmit:r}){const[n,l]=u.useState(null),[c,d]=u.useState(""),x=!s||!s.trim(),y=()=>{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(qe,{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:Ns(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:y,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:K("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:K("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 Ns(s){let t=A(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 vs({request:s,onSubmit:t}){const r=_s(s.requestedSchema),n=Cs(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(Te,{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(Ht,{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(Te,{serverName:s.serverName,message:s.message}),r.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:r.map(({name:x,prop:y})=>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:"必填"})]}),y.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:A(y.description)}),e.jsx("input",{type:y.type==="number"?"number":"text",value:l[x]??"",onChange:m=>c(p=>({...p,[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:y,prop:m}of r){const p=(l[y]??"").trim();p&&(x[y]=m.type==="number"?Number(p):p)}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 Te({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(Yt,{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:A(s)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:A(t)})]})}function _s(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 Cs(s){const t=s==null?void 0:s.required;return Array.isArray(t)?t.filter(r=>typeof r=="string"):[]}function Ss(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 p=await xt(s);r(p)}catch(p){d(p instanceof Error?p.message:"Failed to load shares")}finally{l(!1)}},[s]);u.useEffect(()=>{x()},[x]);const y=u.useCallback(async p=>{d(null);try{const g=await pt(s,p);return await x(),g}catch(g){throw d(g instanceof Error?g.message:"Failed to create share"),g}},[s,x]),m=u.useCallback(async p=>{d(null);try{await ht(s,p),await x()}catch(g){throw d(g instanceof Error?g.message:"Failed to revoke share"),g}},[s,x]);return{shares:t,isLoading:n,error:c,createShare:y,revokeShare:m,refresh:x}}function Ms({open:s,onClose:t,sessionId:r,sessionTitle:n}){Pe();const{shares:l,isLoading:c,error:d,createShare:x,revokeShare:y}=Ss(r),[m,p]=u.useState("user"),[g,N]=u.useState(""),[a,i]=u.useState(""),[h,b]=u.useState("read"),[k,j]=u.useState(""),[_,M]=u.useState(!1),[T,$]=u.useState(null),[z,q]=u.useState(""),[ae,P]=u.useState(!1),[G,O]=u.useState(!1);u.useEffect(()=>{s&&(p("user"),N(""),i(""),b("read"),j(""),M(!1),$(null),q(""),P(!1),O(!1))},[s]);const B=async()=>{M(!0),q(""),$(null);try{const C={grantedTo:m==="user"?{userId:g.trim()}:{teamId:a.trim()},permission:h};k.trim()&&(C.expiresAt=k.trim());const X=await x(C);$(`${window.location.origin}/code/s/${X.shareToken}`)}catch(C){q(C instanceof Error?C.message:"Failed to create share")}finally{M(!1)}},J=async C=>{try{await y(C)}catch{}},W=async()=>{if(!T)return;O(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),P(!0),setTimeout(()=>P(!1),2e3);return}}catch{}const C=document.createElement("textarea");C.value=T,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),P(!0),setTimeout(()=>P(!1),2e3)}catch{O(!0)}document.body.removeChild(C)};return e.jsx(ze,{open:s,onOpenChange:C=>{C||t()},children:e.jsxs(Ve,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Be,{children:e.jsxs(We,{className:"font-display text-lg font-semibold text-text-primary",children:[w("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:w("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>p("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:w("share.user")}),e.jsx("button",{onClick:()=>p("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:w("share.team")})]}),m==="user"?e.jsx(qt,{onSelect:N,placeholder:w("share.userIdPlaceholder"),actionLabel:w("share.selectUser")}):e.jsx("input",{type:"text",value:a,onChange:C=>i(C.target.value),placeholder:w("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"&&g&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[w("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:g})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:w("share.permission")}),e.jsxs("select",{value:h,onChange:C=>b(C.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:w("share.permissionRead")}),e.jsx("option",{value:"write",children:w("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:w("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:k,onChange:C=>j(C.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"})]}),(z||d)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:z||d}),T&&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:w("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:T}),e.jsx("button",{onClick:W,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:ae?w("share.copied"):w("share.copy")})]}),G&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:w("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:w("share.existingShares")}),c?e.jsx("p",{className:"text-sm text-text-muted",children:w("share.loading")}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:w("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:l.map(C=>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:C.granted_to_user||C.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[C.permission==="write"?w("share.permissionWrite"):w("share.permissionRead"),C.expires_at?` · expires ${C.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>J(C.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:w("share.revoke")})]},C.id))})]})]}),e.jsxs(It,{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:w("common.close")}),e.jsx("button",{onClick:B,disabled:_||(m==="user"?!g.trim():!a.trim()),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:_?w("common.creating"):w("share.createShare")})]})]})})}function Es(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Ts(s){const t=Es(s),r=yt(),n=r?{proxyUrl:t,token:r}:{proxyUrl:t};return new ft(n)}const V=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],re="rcs_permission_mode";function Re(s){return s<1e3?String(s):s<1e6?`${(s/1e3).toFixed(1)}k`:`${(s/1e6).toFixed(1)}M`}function Rs(s){const t=V.findIndex(r=>r.value===s);return V[(t+1+V.length)%V.length].value}function As({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,y=async m=>{r(m.modelId),c(!1)};return e.jsxs(Ue,{open:l,onOpenChange:x?c:void 0,children:[e.jsx(Fe,{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(Qe,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(d==null?void 0:d.name)??t??"选择模型"}),l?e.jsx(Oe,{className:"h-3 w-3"}):e.jsx(Le,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-72 p-0",align:"start",children:e.jsx(Rt,{models:s,currentModelId:t,onSelect:y,showSearch:s.length>5})})]})}function Is({mode:s,onModeChange:t,disabled:r}){const[n,l]=u.useState(!1),c=V.find(d=>d.value===s);return e.jsxs(Ue,{open:n,onOpenChange:l,children:[e.jsx(Fe,{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(Tt,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??s}),n?e.jsx(Oe,{className:"h-3 w-3"}):e.jsx(Le,{className:"h-3 w-3"})]})}),e.jsx(He,{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(qe,{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 Vs({sessionId:s,onSessionLoaded:t}){Pe();const[r,n]=u.useState(null),[l,c]=u.useState(null),[d,x]=u.useState(""),[y,m]=u.useState(!1),[p,g]=u.useState(!1),[N,a]=u.useState(!1),[i,h]=u.useState([]),[b,k]=u.useState(!1),[j,_]=u.useState([]),[M,T]=u.useState(null),[$,z]=u.useState(()=>Ye()),[q,ae]=u.useState(null),[P,G]=u.useState(null),[O,B]=u.useState([]),[J,W]=u.useState(!1),[C,X]=u.useState(""),oe=u.useRef(null),[ie,Z]=u.useState(()=>localStorage.getItem(re)||"default"),[he,fe]=u.useState(null),Q=u.useRef(null),U=u.useRef(ie);U.current=ie;const ee=u.useRef(null),ye=u.useRef(null),ge=u.useRef(i);ge.current=i;const te=u.useCallback(o=>{fe(o),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>fe(null),5e3)},[]),le=u.useCallback(o=>{var v;if(o===U.current)return;const f=U.current;U.current=o,Z(o);try{localStorage.setItem(re,o)}catch{}(v=ye.current)==null||v.setPermissionMode(o).then(S=>{ee.current={requestId:S,previous:f}}).catch(S=>{console.error("[SessionDetail] set permission mode failed:",S),te(`模式切换请求发送失败: ${S instanceof Error?S.message:String(S)}`),U.current=f,Z(f)})},[te]),R=u.useMemo(()=>new cs(s,h,{onStatusChange:o=>{c(o),k(o==="running"||o==="requires_action")},onError:o=>{console.error("[RCSChatAdapter] error:",o)},onPermissionRequest:o=>{_(f=>f.some(v=>v.requestId===o.requestId)?f:[...f,o])},onModelsStateChange:o=>{T(o)},onSubagentUpdate:o=>{z(o)},onControlResponse:o=>{const f=ee.current;if(!(!f||f.requestId!==o.requestId)&&(ee.current=null,o.subtype==="error")){U.current=f.previous,Z(f.previous);try{localStorage.setItem(re,f.previous)}catch{}te(o.error||"模式切换失败")}},onPermissionModeChange:o=>{if(o!==U.current){U.current=o,Z(o);try{localStorage.setItem(re,o)}catch{}ee.current=null}},onUsageChange:o=>{ae(f=>({inputTokens:Math.max((f==null?void 0:f.inputTokens)??0,o.inputTokens),outputTokens:Math.max((f==null?void 0:f.outputTokens)??0,o.outputTokens),totalCostUsd:o.totalCostUsd??(f==null?void 0:f.totalCostUsd)??null}))},onElicitationRequest:o=>{G(o)}}),[s,te]);u.useEffect(()=>(ye.current=R,()=>{R.disconnect()}),[R]),u.useEffect(()=>{let o=!1;async function f(){x("");try{const v=await Ct(s);if(o)return;n(v),c(v.status),k(v.status==="running"||v.status==="requires_action"),t==null||t(v)}catch(v){if(o)return;x(v instanceof Error?v.message:w("session.loadFailed"));return}try{await R.init()}catch(v){console.warn("Failed to init adapter:",v)}}return f(),()=>{o=!0}},[s,R,t]);const H=St(l),L=(r==null?void 0:r.access_level)==="read",ce=u.useCallback(()=>{h([]),gt(s).catch(o=>{console.warn("[SessionDetail] Failed to clear session history:",o)})},[s]),se=u.useCallback(async o=>{const f=o.text.trim(),v=o.images&&o.images.length>0||o.attachments&&o.attachments.length>0;if(!f&&!v||H)return;const S=await bt(f,{sessionId:s,availableCommands:Ne,availableModels:(M==null?void 0:M.availableModels)??[],currentModel:M?{modelId:M.currentModelId,name:M.currentModelId}:null,supportsImages:!0,entries:ge.current,setModel:async D=>{await F(s,{type:"control_request",request:{subtype:"set_model",model:D}}),T(ue=>ue&&{...ue,currentModelId:D})},onNewSession:()=>{h([])}}).catch(()=>null);if(S){if(jt("[SessionDetail] local command result",S),"clearEntries"in S&&S.clearEntries){ce();return}if("newSession"in S&&S.newSession){ce();return}if("userEntry"in S){h(D=>[...D,S.userEntry,S.cmdEntry]);return}}k(!0);try{await R.sendMessage(f,o.images,o.attachments)}catch(D){console.error("Send failed:",D)}},[R,H,s,M,ce]),Ke=u.useCallback(o=>{if(b){B(f=>[...f,o]);return}se(o)},[b,se]),de=u.useRef(!1);u.useEffect(()=>{if(b||O.length===0||de.current)return;const o=O[0];o&&(de.current=!0,B(f=>f.slice(1)),se(o).finally(()=>{de.current=!1}))},[b,O,se]);const be=u.useCallback(async()=>{try{await R.interrupt()}catch(o){console.error("Interrupt failed:",o)}finally{k(!1)}},[R]),Ge=u.useCallback(()=>{le(Rs(U.current))},[le]);u.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);const Je=u.useCallback(async()=>{if(r&&window.confirm(w("dashboard.confirmDelete").replace("{id}",r.title||r.id)))try{await kt(r.id),window.location.href="/code/"}catch(o){alert(o instanceof Error?o.message:w("dashboard.deleteFailed"))}},[r]),Xe=u.useCallback(async o=>{try{await R.respondPermission(o,!0)}catch(f){console.error("Failed to approve:",f)}_(f=>f.filter(v=>v.requestId!==o))},[R]),Ze=u.useCallback(async(o,f)=>{try{await R.respondPermission(o,!0,{updated_permissions:f})}catch(v){console.error("Failed to approve with rules:",v)}_(v=>v.filter(S=>S.requestId!==o))},[R]),et=u.useCallback(async(o,f)=>{const v=P;if(G(null),!!v)try{await R.respondElicitation(v.requestId,o,f)}catch(S){console.error("Failed to submit elicitation:",S)}},[P,R]),tt=u.useCallback(()=>{!r||L||(X(r.title||""),W(!0),setTimeout(()=>{var o,f;(o=oe.current)==null||o.focus(),(f=oe.current)==null||f.select()},0))},[r,L]),je=u.useCallback(async()=>{const o=C.trim();if(W(!1),!(!r||!o||o===r.title))try{const f=await wt(r.id,o);n(v=>v&&{...v,title:f.title??o})}catch(f){console.error("Rename failed:",f),alert(f instanceof Error?f.message:"重命名失败")}},[r,C]),st=u.useCallback(async o=>{try{await R.respondPermission(o,!1)}catch(f){console.error("Failed to reject:",f)}_(f=>f.filter(v=>v.requestId!==o))},[R]),nt=u.useCallback(async(o,f,v)=>{try{await F(s,{type:"permission_response",approved:!0,request_id:o,updated_input:{questions:v,answers:f}})}catch(S){console.error("Failed to submit answers:",S)}_(S=>S.filter(D=>D.requestId!==o))},[s]),rt=u.useCallback(async(o,f,v)=>{try{f==="no"?await F(s,{type:"permission_response",approved:!1,request_id:o,...v?{message:v}:{}}):await F(s,{type:"permission_response",approved:!0,request_id:o,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[f]||"default",destination:"session"}]})}catch(S){console.error("Failed to submit plan response:",S)}_(S=>S.filter(D=>D.requestId!==o))},[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:w("session.backToDashboard")})]})}):r?r.source==="acp"&&r.environment_id?e.jsx(qs,{sessionId:s,agentId:r.environment_id}):e.jsx(De,{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:[J?e.jsx("input",{ref:oe,value:C,onChange:o=>X(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),je()):o.key==="Escape"&&(o.preventDefault(),W(!1))},onBlur:()=>void je(),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&&!H&&e.jsx("button",{type:"button",onClick:tt,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(Nt,{className:"h-3.5 w-3.5"})})]}),r.visibility&&!J&&e.jsx($t,{visibility:r.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var v;const o=r.source==="acp"?"acp":(v=r.environment)==null?void 0:v.worker_type,f=At(o);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${f.colorClass}`,children:f.fullLabel})})(),l&&e.jsx(Ae,{status:l}),e.jsx("span",{className:"text-xs text-text-muted",children:Ie(r.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!L&&(r==null?void 0:r.access_level)!=="write"&&e.jsx("button",{onClick:()=>a(!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:w("session.share"),children:e.jsx(es,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>g(!p),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:w("session.info"),children:e.jsx(Wt,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>m(!y),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:[w("session.tasks"),j.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:j.length})]})]})]}),p&&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:w("session.metaSession")})," ",r.id]}),r.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:w("session.metaEnvironment")})," ",r.environment_id]})]})]})}),e.jsx(vt,{entries:i,isLoading:b,emptyTitle:w("session.emptyTitle"),emptyDescription:w("session.emptyDescription")}),e.jsx(gs,{state:$}),j.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:j.map(o=>e.jsx($s,{request:o,onApprove:()=>Xe(o.requestId),onApproveAlways:o.suggestions&&o.suggestions.length>0?()=>Ze(o.requestId,o.suggestions??[]):void 0,onReject:()=>st(o.requestId),onSubmitAnswers:nt,onSubmitPlan:rt},o.requestId))})}),P&&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(vs,{request:P,onSubmit:et})})}),he&&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:he})}),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(Is,{mode:ie,onModeChange:le,disabled:H||L}),e.jsx(As,{models:(M==null?void 0:M.availableModels)??[],currentModelId:(M==null?void 0:M.currentModelId)??null,onSelect:o=>{F(s,{type:"control_request",request:{subtype:"set_model",model:o}}),T(f=>f&&{...f,currentModelId:o})},disabled:H||L})]}),q&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:"会话累计用量(input 含缓存读写)",children:[Re(q.inputTokens)," in / ",Re(q.outputTokens)," out",q.totalCostUsd!=null&&` · $${q.totalCostUsd.toFixed(2)}`]})]}),e.jsx(_t,{onSubmit:Ke,isLoading:b,onInterrupt:be,onCycleMode:Ge,disabled:H||L,placeholder:H?w("session.closed"):L?w("session.readOnly"):w("session.inputPlaceholder"),supportsAttachments:!0,commands:Ne,queueWhileLoading:!0,queuedCount:O.length,onDequeue:o=>B(f=>f.filter((v,S)=>S!==o)),onSearchFiles:o=>R.searchFiles(o)}),y&&r&&e.jsx(xs,{onClose:()=>m(!1),session:r,liveStatus:l,pendingPermissions:j,onInterrupt:be,onDelete:Je}),e.jsx(Ms,{open:N,onClose:()=>a(!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:w("session.loading")})})}function $s({request:s,onApprove:t,onApproveAlways:r,onReject:n,onSubmitAnswers:l,onSubmitPlan:c}){const d=s.toolName,x=s.toolInput,y=s.description||"";if(d==="AskUserQuestion"){const m=x.questions||[];return e.jsx(js,{requestId:s.requestId,questions:m,description:y,onSubmit:p=>l(s.requestId,p,m),onSkip:n})}if(d==="ExitPlanMode"){const m=x.plan||"";return e.jsx(ws,{requestId:s.requestId,planContent:m,description:y,onSubmit:(p,g)=>c(s.requestId,p,g)})}return e.jsx(bs,{requestId:s.requestId,toolName:d,toolInput:x,description:y,suggestions:s.suggestions,onApprove:t,onApproveAlways:r,onReject:n})}function qs({sessionId:s,agentId:t}){const[r,n]=u.useState(null),[l,c]=u.useState("disconnected"),[d,x]=u.useState(null),y=u.useRef(null);return u.useEffect(()=>{const m=Ts(t);return m.setConnectionStateHandler((p,g)=>{c(p),x(g||null)}),y.current=m,n(m),m.connect().catch(p=>{p instanceof Mt||(x(p.message),c("error"))}),()=>{m.disconnect(),y.current=null,n(null),c("disconnected")}},[t]),e.jsx(De,{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:w("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:w("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(Et,{client:r,agentId:t})})]})})}export{Vs as SessionDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{j as t}from"./vendor-DE_-CLIE.js";import{a5 as l,u as c,i as d,h as g,X as u,a4 as o,T as x,t as f,O as m,U as p}from"./main-Dk8hyS_b.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aj as v,af as t}from"./main-Dk8hyS_b.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{
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{Z as m,b as h}from"./main-Dk8hyS_b.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){const[t,r]=d.useState("loading"),[i,a]=d.useState(""),l=(typeof window<"u"?window.location.pathname:"").match(/\/code\/s\/([^/?]+)/),o=l?l[1]:null;return d.useEffect(()=>{if(!o){r("invalid"),a("Share link is invalid — no token found.");return}if(!o.startsWith("shr_")){r("invalid"),a("Invalid share token format.");return}let n=!1;async function c(){try{const s=await m(o);if(n)return;window.location.href=`/code/${s.id}`}catch(s){if(n)return;s instanceof h?s.status===401&&s.message.toLowerCase().includes("expired")?(r("expired"),a("This share has expired.")):s.status===404?s.message.toLowerCase().includes("session")?(r("not_found"),a("Session not found.")):(r("invalid"),a("Share not found or has been revoked.")):s.status===403?(r("invalid"),a("You do not have permission to access this share.")):(r("error"),a(s.message||"Failed to resolve share.")):(r("error"),a(s instanceof Error?s.message:"Failed to resolve share."))}}return c(),()=>{n=!0}},[o]),d.useEffect(()=>{if(t!=="loading"&&t!=="error"){const n=setTimeout(()=>{window.location.href="/code"},3e3);return()=>clearTimeout(n)}},[t]),t==="loading"?e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{children:"Resolving share link..."})]})}):e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-primary",children:e.jsxs("div",{className:"text-center max-w-md px-4",children:[t==="expired"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Share Expired"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share has expired."})]}),t==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Invalid Share"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share link is invalid or has been revoked."})]}),t==="not_found"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Not Found"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"The session could not be found."})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Error"}),e.jsx("p",{className:"text-status-error mb-4",children:i})]}),e.jsx("a",{href:"/code",className:"text-brand hover:underline",children:"← Back to Dashboard"})]})})}export{j as ShareLanding};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{ak as f,al as y,af as r}from"./main-Dk8hyS_b.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};
|