@saluzi/saluzi-edu 0.7.8 → 0.7.10
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 +83 -73
- package/dist/rcs-web/assets/{AdminPanel-D0i_28O2.js → AdminPanel-CXpzVjDe.js} +1 -1
- package/dist/rcs-web/assets/{ArtifactView-Dd6d3O3z.js → ArtifactView-DTs-WDDA.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ArtifactsGallery-BTVS7sar.js → dist/rcs-web/assets/ArtifactsGallery-CMkE5lMo.js} +13 -13
- package/{packages/remote-control-server/web/dist/assets/Claim-CkuDG_ay.js → dist/rcs-web/assets/Claim-2UA7dVEK.js} +1 -1
- package/dist/rcs-web/assets/{Dashboard-BBZHnmut.js → Dashboard-vu7xIOe9.js} +2 -2
- package/dist/rcs-web/assets/{Join-DbBj-5mj.js → Join-Bdw-8O8z.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Login-Csvt3wvz.js → dist/rcs-web/assets/Login-DlymlyXC.js} +1 -1
- package/dist/rcs-web/assets/MemoriesGallery-kixCh9U5.js +1 -0
- package/dist/rcs-web/assets/{Register-Cmp7ogoN.js → Register-DqhOS0yn.js} +1 -1
- package/dist/rcs-web/assets/{RegisterEmpty-BoIy42g_.js → RegisterEmpty-BcaCZfHC.js} +2 -2
- package/dist/rcs-web/assets/SessionDetail-wcXLkGb0.js +83 -0
- package/dist/rcs-web/assets/{SessionVisibilityBadge-C873QvnC.js → SessionVisibilityBadge-Chp91pvD.js} +1 -1
- package/dist/rcs-web/assets/{Setup-DOU0qTNX.js → Setup-BLXd6zpi.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-DMR9eh0F.js → ShareLanding-BFHEQHLm.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/TeamDetail-MPfqesJf.js → dist/rcs-web/assets/TeamDetail-BTfVJKsB.js} +2 -2
- package/dist/rcs-web/assets/{TeamList-CgWVmdPU.js → TeamList-YilbTSth.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-V3L0H8Nb.js → TeamSettings-BW3M_sL0.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-xqtDX6Bz.js → UserSearchInput-CiYLpJKt.js} +2 -2
- package/dist/rcs-web/assets/{UserSettings-Cfqs_5af.js → UserSettings-Dx51VGFE.js} +1 -1
- package/dist/rcs-web/assets/{arc-Bl97za3P.js → arc-BxbcwikW.js} +1 -1
- package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-B8IQfxi6.js → architectureDiagram-3BPJPVTR-DGSSw0bn.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DNfBHM8J.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-DJg7VkwU.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-CO4HDUF2.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-ORXL37Ui.js} +1 -1
- package/dist/rcs-web/assets/channel-Bn6Wg2Ww.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-4CBnqzb3.js → chunk-2J33WTMH-OVDL38OB.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-ClbIGQlY.js → chunk-4BX2VUAB-Cd53bzwH.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-BnrTfmFM.js → chunk-55IACEB6-DEVYqVNE.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-C17NZOQL.js → dist/rcs-web/assets/chunk-727SXJPM-BlOM2UO1.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-CljirtnS.js → dist/rcs-web/assets/chunk-AQP2D5EJ-DsppWivh.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-Bb20ipZI.js → chunk-FMBD7UC4-CoI2j4wa.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-L3q9_xAn.js → chunk-ND2GUHAM-CUotuxlW.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-FyYNxzak.js → chunk-QZHKN3VN-BVDq8bXi.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DCjl-4m7.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DCjl-4m7.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-CQVTEZwg.js → code-block-IT6T5CEO-DpeiBgWn.js} +1 -1
- package/dist/rcs-web/assets/{copy-CFZBXuu9.js → copy-BLUveJmC.js} +1 -1
- package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-Cs2MVxlS.js → cose-bilkent-S5V4N54A-D85Vo4-1.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-CWZcIIf5.js → dagre-BM42HDAG-DE64wmuQ.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-DpumSk2d.js → diagram-2AECGRRQ-C0ryFqsk.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-DcF2qwdh.js → diagram-5GNKFQAL-DEZ_C1jP.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-BGnqGSPz.js → diagram-KO2AKTUF-zd1LAiTP.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-k-UxYOZ9.js → diagram-LMA3HP47-CVoLIHlx.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-BMPzmD6S.js → dist/rcs-web/assets/diagram-OG6HWLK6-DJRt-C7C.js} +1 -1
- package/dist/rcs-web/assets/{dialog-DKk230y5.js → dialog-D0yI8ywv.js} +1 -1
- package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BvmA6W9Z.js → erDiagram-TEJ5UH35-DkFe3vj_.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-ptAnksiF.js → dist/rcs-web/assets/flowDiagram-I6XJVG4X-BlTyAT6B.js} +1 -1
- package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-Bhgrzcs3.js → ganttDiagram-6RSMTGT7-CuF6h1wT.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-B8-vcbF-.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-CJmCfNop.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-DaW0unc2.js → infoDiagram-5YYISTIA-VRktUnoL.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-4oYGuWP6.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-zfU049FK.js} +1 -1
- package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-B9YXpw0W.js → journeyDiagram-JHISSGLW-CKnjdfDG.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-Cglus7wI.js → dist/rcs-web/assets/kanban-definition-UN3LZRKU-L4wkYkgX.js} +1 -1
- package/dist/rcs-web/assets/{linear-CRTJd3_G.js → linear-qVeyHxNE.js} +1 -1
- package/dist/rcs-web/assets/main-4aV08-w8.js +393 -0
- package/dist/rcs-web/assets/main-B7U6M5cC.css +1 -0
- package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-D0JeVL0B.js → dist/rcs-web/assets/mermaid-VLURNSYL-Lg7484fl.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-CobUk_K5.js → mermaid.core-Dz4PkSPn.js} +5 -5
- package/{packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-B1s-et_p.js → dist/rcs-web/assets/mindmap-definition-RKZ34NQL-B7PvyEFL.js} +1 -1
- package/dist/rcs-web/assets/{notifications-BrgRJuzQ.js → notifications-D21J8rU1.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-PcBs9RT_.js → pieDiagram-4H26LBE5-B-FYIctX.js} +1 -1
- package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-B2GxITjv.js → quadrantDiagram-W4KKPZXB-B15bxGSQ.js} +1 -1
- package/dist/rcs-web/assets/{refresh-cw-BwmFF3kw.js → refresh-cw-Dlmzaahr.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-BfyZiasB.js → dist/rcs-web/assets/requirementDiagram-4Y6WPE33-SEBlK-kl.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-Br7tRtmq.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-BGidBc_h.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CN1NSfHS.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-BKJT_oiG.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-C4S8hKUx.js → dist/rcs-web/assets/stateDiagram-AJRCARHV-Bk7VsyWH.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-CbEMz-jf.js → stateDiagram-v2-BHNVJYJU-CRAMdUTy.js} +1 -1
- package/dist/rcs-web/assets/{timeline-definition-PNZ67QCA-mTiK0HwD.js → timeline-definition-PNZ67QCA-B2HctMrD.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-DCe95URb.js → vennDiagram-CIIHVFJN-DiwPaHG9.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-Cct1r0Ax.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-Bp9DTZxN.js} +1 -1
- package/dist/rcs-web/assets/{workerType-DW9l12WG.js → workerType-Bg13Rvqb.js} +1 -1
- package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-CVc0eQYa.js → xychartDiagram-2RQKCTM6-Bj8DyGSd.js} +1 -1
- package/dist/rcs-web/index.html +2 -2
- package/package.json +1 -1
- package/packages/remote-control-server/src/__tests__/memories.test.ts +75 -0
- package/packages/remote-control-server/src/__tests__/memoryBackend.test.ts +391 -0
- package/packages/remote-control-server/src/nodeServer.ts +9 -0
- package/packages/remote-control-server/src/routes/web/memories.ts +274 -0
- package/packages/remote-control-server/src/services/memoryBackend.ts +142 -0
- package/packages/remote-control-server/src/services/transport.ts +20 -0
- package/packages/remote-control-server/web/dist/assets/{AdminPanel-D0i_28O2.js → AdminPanel-CXpzVjDe.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ArtifactView-Dd6d3O3z.js → ArtifactView-DTs-WDDA.js} +1 -1
- package/{dist/rcs-web/assets/ArtifactsGallery-BTVS7sar.js → packages/remote-control-server/web/dist/assets/ArtifactsGallery-CMkE5lMo.js} +13 -13
- package/{dist/rcs-web/assets/Claim-CkuDG_ay.js → packages/remote-control-server/web/dist/assets/Claim-2UA7dVEK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Dashboard-BBZHnmut.js → Dashboard-vu7xIOe9.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{Join-DbBj-5mj.js → Join-Bdw-8O8z.js} +1 -1
- package/{dist/rcs-web/assets/Login-Csvt3wvz.js → packages/remote-control-server/web/dist/assets/Login-DlymlyXC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/MemoriesGallery-kixCh9U5.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{Register-Cmp7ogoN.js → Register-DqhOS0yn.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{RegisterEmpty-BoIy42g_.js → RegisterEmpty-BcaCZfHC.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/SessionDetail-wcXLkGb0.js +83 -0
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-C873QvnC.js → SessionVisibilityBadge-Chp91pvD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Setup-DOU0qTNX.js → Setup-BLXd6zpi.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-DMR9eh0F.js → ShareLanding-BFHEQHLm.js} +1 -1
- package/{dist/rcs-web/assets/TeamDetail-MPfqesJf.js → packages/remote-control-server/web/dist/assets/TeamDetail-BTfVJKsB.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{TeamList-CgWVmdPU.js → TeamList-YilbTSth.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-V3L0H8Nb.js → TeamSettings-BW3M_sL0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-xqtDX6Bz.js → UserSearchInput-CiYLpJKt.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{UserSettings-Cfqs_5af.js → UserSettings-Dx51VGFE.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-Bl97za3P.js → arc-BxbcwikW.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-B8IQfxi6.js → architectureDiagram-3BPJPVTR-DGSSw0bn.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DNfBHM8J.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DJg7VkwU.js} +1 -1
- package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-CO4HDUF2.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-ORXL37Ui.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-Bn6Wg2Ww.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-4CBnqzb3.js → chunk-2J33WTMH-OVDL38OB.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-ClbIGQlY.js → chunk-4BX2VUAB-Cd53bzwH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BnrTfmFM.js → chunk-55IACEB6-DEVYqVNE.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-C17NZOQL.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BlOM2UO1.js} +1 -1
- package/{dist/rcs-web/assets/chunk-AQP2D5EJ-CljirtnS.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-DsppWivh.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-Bb20ipZI.js → chunk-FMBD7UC4-CoI2j4wa.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-L3q9_xAn.js → chunk-ND2GUHAM-CUotuxlW.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-FyYNxzak.js → chunk-QZHKN3VN-BVDq8bXi.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DCjl-4m7.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DCjl-4m7.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-CQVTEZwg.js → code-block-IT6T5CEO-DpeiBgWn.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-CFZBXuu9.js → copy-BLUveJmC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-Cs2MVxlS.js → cose-bilkent-S5V4N54A-D85Vo4-1.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-CWZcIIf5.js → dagre-BM42HDAG-DE64wmuQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-DpumSk2d.js → diagram-2AECGRRQ-C0ryFqsk.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-DcF2qwdh.js → diagram-5GNKFQAL-DEZ_C1jP.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-BGnqGSPz.js → diagram-KO2AKTUF-zd1LAiTP.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-k-UxYOZ9.js → diagram-LMA3HP47-CVoLIHlx.js} +1 -1
- package/{dist/rcs-web/assets/diagram-OG6HWLK6-BMPzmD6S.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-DJRt-C7C.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dialog-DKk230y5.js → dialog-D0yI8ywv.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BvmA6W9Z.js → erDiagram-TEJ5UH35-DkFe3vj_.js} +1 -1
- package/{dist/rcs-web/assets/flowDiagram-I6XJVG4X-ptAnksiF.js → packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-BlTyAT6B.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-Bhgrzcs3.js → ganttDiagram-6RSMTGT7-CuF6h1wT.js} +1 -1
- package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-B8-vcbF-.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-CJmCfNop.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-DaW0unc2.js → infoDiagram-5YYISTIA-VRktUnoL.js} +1 -1
- package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-4oYGuWP6.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-zfU049FK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-B9YXpw0W.js → journeyDiagram-JHISSGLW-CKnjdfDG.js} +1 -1
- package/{dist/rcs-web/assets/kanban-definition-UN3LZRKU-Cglus7wI.js → packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-L4wkYkgX.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-CRTJd3_G.js → linear-qVeyHxNE.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/main-4aV08-w8.js +393 -0
- package/packages/remote-control-server/web/dist/assets/main-B7U6M5cC.css +1 -0
- package/{dist/rcs-web/assets/mermaid-VLURNSYL-D0JeVL0B.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-Lg7484fl.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-CobUk_K5.js → mermaid.core-Dz4PkSPn.js} +5 -5
- package/{dist/rcs-web/assets/mindmap-definition-RKZ34NQL-B1s-et_p.js → packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-B7PvyEFL.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{notifications-BrgRJuzQ.js → notifications-D21J8rU1.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-PcBs9RT_.js → pieDiagram-4H26LBE5-B-FYIctX.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-B2GxITjv.js → quadrantDiagram-W4KKPZXB-B15bxGSQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{refresh-cw-BwmFF3kw.js → refresh-cw-Dlmzaahr.js} +1 -1
- package/{dist/rcs-web/assets/requirementDiagram-4Y6WPE33-BfyZiasB.js → packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-SEBlK-kl.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-Br7tRtmq.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-BGidBc_h.js} +1 -1
- package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CN1NSfHS.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-BKJT_oiG.js} +1 -1
- package/{dist/rcs-web/assets/stateDiagram-AJRCARHV-C4S8hKUx.js → packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-Bk7VsyWH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-CbEMz-jf.js → stateDiagram-v2-BHNVJYJU-CRAMdUTy.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{timeline-definition-PNZ67QCA-mTiK0HwD.js → timeline-definition-PNZ67QCA-B2HctMrD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-DCe95URb.js → vennDiagram-CIIHVFJN-DiwPaHG9.js} +1 -1
- package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-Cct1r0Ax.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-Bp9DTZxN.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{workerType-DW9l12WG.js → workerType-Bg13Rvqb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-CVc0eQYa.js → xychartDiagram-2RQKCTM6-Bj8DyGSd.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +2 -2
- package/dist/rcs-web/assets/MemoriesGallery-C5cT73hA.js +0 -1
- package/dist/rcs-web/assets/SessionDetail-CocGah-8.js +0 -83
- package/dist/rcs-web/assets/channel-DcTKV8fL.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-5DsQRSDS.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-5DsQRSDS.js +0 -1
- package/dist/rcs-web/assets/main-BKbA2ddo.js +0 -393
- package/dist/rcs-web/assets/main-CP31AzxJ.css +0 -1
- package/packages/remote-control-server/web/dist/assets/MemoriesGallery-C5cT73hA.js +0 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-CocGah-8.js +0 -83
- package/packages/remote-control-server/web/dist/assets/channel-DcTKV8fL.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-5DsQRSDS.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-5DsQRSDS.js +0 -1
- package/packages/remote-control-server/web/dist/assets/main-BKbA2ddo.js +0 -393
- package/packages/remote-control-server/web/dist/assets/main-CP31AzxJ.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{aF as a,i as d,h as l,aD as p,aT as h}from"./main-4aV08-w8.js";import{A as y}from"./workerType-Bg13Rvqb.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -23,4 +23,4 @@ import{j as e}from"./vendor-DE_-CLIE.js";import{av as a,i as d,h as l,at as p,aJ
|
|
|
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 g=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],
|
|
26
|
+
*/const g=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],j=a("wifi",g),v={running:{label:"running",Icon:y},active:{label:"active",Icon:j},idle:{label:"idle",Icon:d},disconnected:{label:"disconnected",Icon:i},offline:{label:"offline",Icon:i},inactive:{label:"inactive",Icon:s},archived:{label:"archived",Icon:s},error:{label:"error",Icon:x,tone:"text-status-error border-status-error/40"},requires_action:{label:"requires_action",Icon:u,tone:"text-status-warning border-status-warning/40"}};function w({status:t,className:n}){const{label:r,Icon:c,tone:o}=v[t]??{label:t,Icon:l,tone:void 0};return e.jsxs("span",{className:p("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",o??"text-text-muted border-border/60",n),title:r,children:[e.jsx(c,{className:"h-3 w-3","aria-hidden":"true"}),r]})}function I({title:t,hint:n}){return e.jsx("div",{className:"ds-reg",children:e.jsxs("div",{className:"ds-reg-row ds-reg-empty",children:[e.jsxs("span",{className:"ds-reg-main",children:[e.jsx("span",{className:"ds-empty-title",children:t}),e.jsx("span",{className:"ds-reg-meta ds-empty-hint",children:n})]}),e.jsx("span",{className:"ds-reg-aside",children:e.jsx("span",{className:"ds-empty-marker",children:h("dashboard.emptyMarker")})})]})})}export{w as E,I as R};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var Tn=Object.defineProperty;var En=(r,t,s)=>t in r?Tn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var q=(r,t,s)=>En(r,typeof t!="symbol"?t+"":t,s);import{j as e,e as l}from"./vendor-DE_-CLIE.js";import{aF as G,ai as Mn,aN as ls,aM as cs,aT as i,aP as Rn,aO as ht,aU as H,aK as ve,ax as An,aw as ee,al as In,at as $n,aY as Dn,a$ as ae,T as qn,Q as Pn,X as On,L as Ge,H as Fn,I as Un,i as ds,aJ as Qs,N as Ws,aG as ft,e as $e,S as yt,M as Kn,y as Ln,aH as te,aD as fe,aI as Bn,aV as Hn,G as Qn,D as Wn,aW as us,am as zn,a2 as Yn,as as Vn,ae as zs,ad as Gn,ab as Jn,au as Xn,ap as Zn,P as ms,t as er,B as Dt,V as tr,ac as xs,$ as sr,an as nr,a4 as rr,aB as ar,A as or,aL as ir,aQ as lr,aR as cr,Z as ps,a1 as dr,aX as ur,b as mr,a6 as hs,aq as xr,K as Ys,F as pr,d as fs,C as hr,ah as ys,l as fr,a as yr,u as Je,w as Xe,E as gr,g as Ze,f as et,v as tt,s as br}from"./main-4aV08-w8.js";import{A as jr,g as gs}from"./workerType-Bg13Rvqb.js";import{D as De,a as qe,c as Pe,d as Oe,b as wr}from"./dialog-D0yI8ywv.js";import{R as vr}from"./refresh-cw-Dlmzaahr.js";import{A as kr,U as Nr}from"./UserSearchInput-CiYLpJKt.js";import{C as Sr}from"./copy-BLUveJmC.js";import{E as _r,S as Cr,A as Tr}from"./ArtifactsGallery-CMkE5lMo.js";import{S as Er}from"./SessionVisibilityBadge-Chp91pvD.js";import{MemoriesGallery as Mr}from"./MemoriesGallery-kixCh9U5.js";import{S as Rr,b as Ar}from"./notifications-D21J8rU1.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";/**
|
|
2
|
+
* @license lucide-react v0.555.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Ir=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Vs=G("chevron-right",Ir);/**
|
|
7
|
+
* @license lucide-react v0.555.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const $r=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],Dr=G("coins",$r);/**
|
|
12
|
+
* @license lucide-react v0.555.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const qr=[["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"}]],Gs=G("cpu",qr);/**
|
|
17
|
+
* @license lucide-react v0.555.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const Pr=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Or=G("gauge",Pr);/**
|
|
22
|
+
* @license lucide-react v0.555.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const Fr=[["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"}]],Ur=G("hash",Fr);/**
|
|
27
|
+
* @license lucide-react v0.555.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Kr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Lr=G("info",Kr);/**
|
|
32
|
+
* @license lucide-react v0.555.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const Br=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],Hr=G("layers",Br);/**
|
|
37
|
+
* @license lucide-react v0.555.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const Qr=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Js=G("message-circle-question-mark",Qr);/**
|
|
42
|
+
* @license lucide-react v0.555.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const Wr=[["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"}]],zr=G("message-square-text",Wr);/**
|
|
47
|
+
* @license lucide-react v0.555.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const Yr=[["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"}]],Vr=G("play",Yr);/**
|
|
52
|
+
* @license lucide-react v0.555.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const Gr=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Xs=G("plug",Gr);/**
|
|
57
|
+
* @license lucide-react v0.555.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const Jr=[["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"}]],Xr=G("server-cog",Jr);/**
|
|
62
|
+
* @license lucide-react v0.555.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const Zr=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Zs=G("settings-2",Zr);/**
|
|
67
|
+
* @license lucide-react v0.555.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const ea=[["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"}]],ta=G("share-2",ea);/**
|
|
72
|
+
* @license lucide-react v0.555.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const sa=[["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"}]],na=G("shield-check",sa);function It(){return{tasks:{}}}const bs=3e4;function mt(r){const t=r.trim();if(!t)return"agent";const s=t.split(/\s+/).slice(0,2).join(" ");return s.length>40?s.slice(0,40)+"…":s}function js(r,t){var c,u,p,f,g,b,N,M,C,j,x,y;const s=t.subtype;if(s!=="task_started"&&s!=="task_progress"&&s!=="task_notification")return r;const n=t.task_id;if(!n)return r;const a=Date.now(),d=r.tasks[n];if(s==="task_started"){if(d)return{tasks:{...r.tasks,[n]:{...d,description:t.description??d.description,name:mt(t.description??d.description),taskType:t.task_type??d.taskType,workflowName:t.workflow_name??d.workflowName,prompt:t.prompt??d.prompt,toolUseId:t.tool_use_id??d.toolUseId,status:"running",startTime:a,evictAfter:void 0}}};const v=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:mt(v),description:v,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:a}}}}if(s==="task_progress"){if(!d){const v=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:mt(v),description:v,toolUseId:t.tool_use_id,status:"running",startTime:a,tokenCount:(c=t.usage)==null?void 0:c.total_tokens,toolUseCount:(u=t.usage)==null?void 0:u.tool_uses,durationMs:(p=t.usage)==null?void 0:p.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...r.tasks,[n]:{...d,description:t.description??d.description,tokenCount:((f=t.usage)==null?void 0:f.total_tokens)??d.tokenCount,toolUseCount:((g=t.usage)==null?void 0:g.tool_uses)??d.toolUseCount,durationMs:((b=t.usage)==null?void 0:b.duration_ms)??d.durationMs,lastToolName:t.last_tool_name??d.lastToolName,summary:t.summary??d.summary}}}}return d?{tasks:{...r.tasks,[n]:{...d,status:t.status??"completed",endTime:a,finalSummary:t.summary??d.finalSummary,outputFile:t.output_file??d.outputFile,tokenCount:((j=t.usage)==null?void 0:j.total_tokens)??d.tokenCount,toolUseCount:((x=t.usage)==null?void 0:x.tool_uses)??d.toolUseCount,durationMs:((y=t.usage)==null?void 0:y.duration_ms)??d.durationMs,evictAfter:a+bs}}}:{tasks:{...r.tasks,[n]:{taskId:n,name:mt(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:a,endTime:a,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(M=t.usage)==null?void 0:M.tool_uses,durationMs:(C=t.usage)==null?void 0:C.duration_ms,evictAfter:a+bs}}}}function en(r,t=Date.now()){return Object.values(r.tasks).filter(s=>s.evictAfter===void 0||s.evictAfter>t).sort((s,n)=>s.startTime-n.startTime)}const ws={in_process_teammate:0,local_bash:1,monitor_mcp:2,remote_agent:3,local_agent:4,dream:5},vs=100;function ra(r){const t=new Map;for(const s of r){const n=s.taskType??"",a=t.get(n);a?a.push(s):t.set(n,[s])}return[...t.entries()].sort(([s],[n])=>{const a=ws[s]??vs,d=ws[n]??vs;return a===d?s.localeCompare(n):a-d}).map(([s,n])=>({taskType:s,tasks:[...n].sort((a,d)=>a.startTime-d.startTime)}))}function ks(r){const t=r.raw,s=t&&typeof t=="object"?t:r,n=typeof s.subtype=="string"?s.subtype:void 0;return n!=="task_started"&&n!=="task_progress"&&n!=="task_notification"?null:{subtype:n,task_id:typeof s.task_id=="string"?s.task_id:void 0,tool_use_id:typeof s.tool_use_id=="string"?s.tool_use_id:void 0,description:typeof s.description=="string"?s.description:void 0,task_type:typeof s.task_type=="string"?s.task_type:void 0,workflow_name:typeof s.workflow_name=="string"?s.workflow_name:void 0,prompt:typeof s.prompt=="string"?s.prompt:void 0,usage:s.usage&&typeof s.usage=="object"?s.usage:void 0,last_tool_name:typeof s.last_tool_name=="string"?s.last_tool_name:void 0,summary:typeof s.summary=="string"?s.summary:void 0,status:s.status==="completed"||s.status==="failed"||s.status==="stopped"?s.status:void 0,output_file:typeof s.output_file=="string"?s.output_file:void 0}}function aa(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const t=r,s={file_search:t.file_search===!0,clear:t.clear===!0,set_max_thinking_tokens:t.set_max_thinking_tokens===!0,get_context_usage:t.get_context_usage===!0,stop_task:t.stop_task===!0,set_model:t.set_model===!0,set_permission_mode:t.set_permission_mode===!0,interrupt:t.interrupt===!0,end_session:t.end_session===!0,mcp_management:t.mcp_management===!0,remote_settings:t.remote_settings===!0,rewind:t.rewind===!0,resume:t.resume===!0,set_effort:t.set_effort===!0,set_token_mode:t.set_token_mode===!0,side_question:t.side_question===!0};return Object.values(s).some(Boolean)?s:null}function Ns(r,t){const s=[];if(Array.isArray(r)){for(const n of r){if(!n||typeof n!="object")continue;const a=n;if(typeof a.name!="string"||!a.name)continue;const d=a.type==="prompt"||a.type==="local"||a.type==="local-jsx"?a.type:void 0;s.push({name:a.name,...typeof a.description=="string"&&a.description?{description:a.description}:{},...typeof a.argumentHint=="string"&&a.argumentHint?{argumentHint:a.argumentHint}:{},...d?{type:d}:{}})}if(s.length>0)return s}if(Array.isArray(t))for(const n of t)typeof n=="string"&&n&&s.push({name:n});return s}function Ss(r){const t=r.raw&&typeof r.raw=="object"&&!Array.isArray(r.raw)?r.raw:r,s=Ns(t.slash_command_details??r.slash_command_details,t.slash_commands??r.slash_commands),n=Ns(t.skill_details??r.skill_details,t.skills??r.skills),a=aa(t.remote_capabilities??r.remote_capabilities);return s.length===0&&n.length===0&&!a?null:{commands:s,skills:n,capabilities:a}}class oa{constructor(t){q(this,"listeners",new Set);q(this,"stateListeners",new Set);q(this,"eventSource",null);q(this,"sessionId",null);q(this,"_lastSeqNum",0);q(this,"lastFrameAt",0);q(this,"firstEventAfterOpen",!1);q(this,"watchdogTimer",null);q(this,"visibilityHandler",null);q(this,"reconnectTimer",null);q(this,"reconnectAttempts",0);q(this,"_state","idle");q(this,"opts");this.opts={stallThresholdMs:45e3,watchdogTickMs:5e3,reconnectBaseDelayMs:1e3,reconnectMaxDelayMs:15e3,maxReconnectAttempts:6,...t}}get state(){return this._state}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onStateChange(t){return this.stateListeners.add(t),()=>this.stateListeners.delete(t)}connect(t){this.stopReconnectTimer(),this.reconnectAttempts=0,this.sessionId=t,this.openStream()}openStream(){if(this.closeStream(),!this.sessionId)return;this.setState("connecting");const t=this._lastSeqNum>0?`/web/sessions/${this.sessionId}/events?fromSeqNum=${this._lastSeqNum}`:`/web/sessions/${this.sessionId}/events`,s=new EventSource(t,{withCredentials:!0});this.eventSource=s,this.lastFrameAt=Date.now(),this.firstEventAfterOpen=!0,s.addEventListener("open",()=>{this.lastFrameAt=Date.now(),this.reconnectAttempts=0,this.firstEventAfterOpen=!0,this.setState("open")}),s.addEventListener("ping",()=>{this.lastFrameAt=Date.now()}),s.addEventListener("message",n=>{this.lastFrameAt=Date.now();try{const a=JSON.parse(n.data);if(this.firstEventAfterOpen&&(this.firstEventAfterOpen=!1,typeof a.seqNum=="number"&&a.seqNum<this._lastSeqNum&&(this._lastSeqNum=a.seqNum-1,this.notifyResync())),a.seqNum!==void 0&&a.seqNum<=this._lastSeqNum)return;a.seqNum!==void 0&&(this._lastSeqNum=a.seqNum);for(const d of this.listeners)d(a)}catch{}}),s.addEventListener("error",()=>{s.readyState===EventSource.CLOSED&&this.scheduleReconnect()}),this.startWatchdog()}disconnect(){this.sessionId=null,this.stopReconnectTimer(),this.closeStream(),this._lastSeqNum=0,this.reconnectAttempts=0,this.setState("idle")}closeStream(){this.stopWatchdog(),this.eventSource&&(this.eventSource.close(),this.eventSource=null)}startWatchdog(){this.stopWatchdog(),this.watchdogTimer=setInterval(()=>{this.probeStall()},this.opts.watchdogTickMs),typeof document<"u"&&(this.visibilityHandler=()=>{document.visibilityState==="visible"&&this.probeStall()},document.addEventListener("visibilitychange",this.visibilityHandler))}probeStall(){const t=this.eventSource;!t||t.readyState!==EventSource.OPEN||Date.now()-this.lastFrameAt<=this.opts.stallThresholdMs||this.scheduleReconnect()}stopWatchdog(){this.watchdogTimer&&(clearInterval(this.watchdogTimer),this.watchdogTimer=null),this.visibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}stopReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}scheduleReconnect(){if(this.reconnectTimer||!this.sessionId)return;if(this.closeStream(),this.reconnectAttempts++,this.reconnectAttempts>this.opts.maxReconnectAttempts){this.setState("failed");return}this.setState("reconnecting");const t=Math.min(this.opts.reconnectBaseDelayMs*2**(this.reconnectAttempts-1),this.opts.reconnectMaxDelayMs),s=Math.max(0,t+t*.25*(2*Math.random()-1));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnect()},s)}async reconnect(){this.sessionId&&(await Dn(),this.sessionId&&this.openStream())}setState(t){if(this._state!==t){this._state=t;for(const s of this.stateListeners)s(t,{})}}notifyResync(){for(const t of this.stateListeners)t(this._state,{resync:!0})}}const he=new oa;function Mt(r){if(typeof r.content=="string")return r.content;if(r.message&&typeof r.message=="object"){const t=r.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(s=>s.type==="text"&&typeof s.text=="string").map(s=>s.text).join("")}return""}function _s(r,t){for(let s=r.length-1;s>=0;s--){const n=r[s];if(n&&n.type==="tool_call"&&n.toolCall.id===t)return s}return-1}const Rt="streaming-";function Cs(r){const t=r.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const s=[];for(const n of t.content)if((n==null?void 0:n.type)==="thinking"){const a=typeof n.thinking=="string"&&n.thinking||typeof n.text=="string"&&n.text||"";a&&s.push(a)}return s.join("")}function Ts(r){return r.filter(t=>typeof t.subject=="string"&&t.subject).map(t=>({content:t.subject,priority:"medium",status:t.status==="completed"?"completed":t.status==="in_progress"?"in_progress":"pending"}))}function Es(r){if(!r||typeof r!="object")return"";const t=r;if(typeof t.target_event_id=="string"&&t.target_event_id)return t.target_event_id;const s=t.raw;if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s.target_event_id;if(typeof n=="string"&&n)return n}return""}class ia{constructor(t,s,n){q(this,"sessionId");q(this,"setEntries");q(this,"unsub",null);q(this,"unsubState",null);q(this,"onStatusChange");q(this,"onError");q(this,"onPermissionRequest");q(this,"onModelsStateChange");q(this,"onSubagentUpdate");q(this,"onControlResponse");q(this,"onPermissionModeChange");q(this,"onUsageChange");q(this,"onElicitationRequest");q(this,"onWorkerInfoChange");q(this,"onTurnStart");q(this,"subagentState",It());q(this,"seenUuids",new Set);q(this,"seenToolCallIds",new Set);q(this,"pendingToolCallIds",new Set);q(this,"pendingPermissionToolIds",new Map);q(this,"postedUserUuids",new Set);q(this,"pendingControlRequests",new Map);q(this,"turnEnded",!1);q(this,"userSinceTurnEnd",!1);q(this,"turnStartedAt",null);q(this,"closed",!1);this.sessionId=t,this.setEntries=s,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,this.onWorkerInfoChange=n==null?void 0:n.onWorkerInfoChange,this.onTurnStart=n==null?void 0:n.onTurnStart}markClosed(){this.closed=!0}setTurnStartedAt(t){var s;this.turnStartedAt!==t&&(this.turnStartedAt=t,(s=this.onTurnStart)==null||s.call(this,t))}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var j,x,y,v,_,A,T;const{events:t}=await Mn(this.sessionId);if(!t||t.length===0)return;const s=new Set;for(const w of t){if(w.type!=="user"||w.direction==="inbound")continue;const E=(j=w.payload)==null?void 0:j.uuid;typeof E=="string"&&E&&s.add(E)}const n=[];let a=null;const d=()=>{a&&(n.push(a),a=null)};for(const w of t){const E=w.payload||{},I=E.uuid;if(typeof I=="string"&&I&&this.seenUuids.add(I),w.type==="tool_use"){const $=E.tool_call_id;typeof $=="string"&&$&&this.seenToolCallIds.add($)}if(w.type==="user"){if(w.direction==="inbound"){const S=E.uuid;if(typeof S!="string"||!S||s.has(S))continue}d();const $=Mt(E);$&&n.push({type:"user_message",id:w.id||`hist-user-${n.length}`,content:$})}else if(w.type==="assistant"){d();const $=Mt(E);if(ls($))continue;const S=Cs(E),U=[],O=E.message;if(O&&typeof O=="object"&&Array.isArray(O.content)){for(const J of O.content)if(J.type==="tool_use"){const X=J.id;X&&this.seenToolCallIds.add(X),U.push({type:"tool_call",toolCall:{id:X||`hist-tool-${n.length}`,title:J.name||"tool",status:"complete",rawInput:J.input||{}}})}}if($||S||U.length>0){a={type:"assistant_message",id:w.id||`hist-asst-${n.length}`,chunks:[...S?[{type:"thought",text:S}]:[],...$?[{type:"message",text:$}]:[]]},n.push(a);for(const J of U)n.push(J);a=null}}else if(w.type==="conversation_rewound"){const $=Es(E);if($){const S=n.findIndex(U=>cs(U)===$);S>=0&&(n.length=S)}}else if(w.type==="tool_use"){const $=E,S={type:"tool_call",toolCall:{id:$.tool_call_id||`hist-tool-${n.length}`,title:$.tool_name||"tool",status:"complete",rawInput:$.tool_input||{}}};n.push(S)}else if(w.type==="tool_result"){const $=E,S=_s(n,$.tool_call_id||"");if(S>=0){const U=n[S];n[S]={type:"tool_call",toolCall:{...U.toolCall,rawOutput:{output:$.content||$.output||""}}}}}}d();let c=null;for(const w of t){if(w.type!=="task_state")continue;const E=w.payload||{};Array.isArray(E.tasks)&&(c=E.tasks)}if(c&&c.length>0){const w=Ts(c);w.length>0&&n.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:w})}this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries(n);let u=null,p=null,f=null,g=null,b=0,N=0;for(const w of t){const E=w.payload||{};if(typeof w.createdAt=="number"&&(w.createdAt>N&&(N=w.createdAt),w.type==="user"&&g!=="user"&&w.createdAt>0&&(b=w.createdAt)),w.type==="user"?g="user":(w.type==="result"||w.type==="result_success"||w.type==="interrupt")&&(g="turn_end"),w.type==="system"&&(E.subtype==="init"||((x=E.raw)==null?void 0:x.subtype)==="init")&&(p=Ss(E)),w.type==="models_state"){const I=E.raw,$=I&&typeof I=="object"?I.models_state:E.models_state;$&&Array.isArray($.availableModels)&&typeof $.currentModelId=="string"&&(u=$)}else if(w.type==="result"||w.type==="result_success"){const I=E.usage,$=typeof E.total_cost_usd=="number"?E.total_cost_usd:null;(I||$!==null)&&(f={inputTokens:((I==null?void 0:I.input_tokens)??0)+((I==null?void 0:I.cache_read_input_tokens)??0)+((I==null?void 0:I.cache_creation_input_tokens)??0),outputTokens:(I==null?void 0:I.output_tokens)??0,totalCostUsd:$})}}let M=!1,C=It();for(const w of t){if(w.type!=="system")continue;const E=ks(w.payload||{});E&&(C=js(C,E),M=!0)}M&&(this.subagentState=C,(y=this.onSubagentUpdate)==null||y.call(this,this.subagentState)),u&&((v=this.onModelsStateChange)==null||v.call(this,u)),p&&((_=this.onWorkerInfoChange)==null||_.call(this,p)),f&&((A=this.onUsageChange)==null||A.call(this,f)),this.turnEnded=g==="turn_end",this.userSinceTurnEnd=g==="user",this.setTurnStartedAt(!this.closed&&g==="user"&&b>0&&N>=b?Date.now()-(N-b):null),this.turnEnded&&!this.closed&&((T=this.onStatusChange)==null||T.call(this,"idle"))}connectSSE(){he.connect(this.sessionId),this.unsub=he.onEvent(t=>this.handleEvent(t)),this.unsubState=he.onStateChange((t,s)=>{s.resync&&!this.closed&&this.loadHistory().catch(()=>{})})}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),this.unsubState&&(this.unsubState(),this.unsubState=null),he.disconnect()}handleEvent(t){var a,d,c,u,p,f,g,b,N,M,C,j;const s=t.type,n=t.payload||{};switch(s){case"user":{if(this.applyEmbeddedToolResults(n),this.userSinceTurnEnd=!0,!this.closed&&this.turnStartedAt===null&&this.setTurnStartedAt(Date.now()),t.direction==="inbound"){const x=n.uuid;if(typeof x!="string"||!x||this.postedUserUuids.has(x)||this.seenUuids.has(x))break;this.seenUuids.add(x);const y=Mt(n);y&&this.setEntries(v=>[...v,{type:"user_message",id:t.id||`user-${Date.now()}`,content:y}])}break}case"assistant":{const x=n.uuid;if(typeof x=="string"&&x){if(this.seenUuids.has(x))break;this.seenUuids.add(x)}const y=typeof n.content=="string"?n.content:"";if(ls(y))break;const v=Cs(n);this.setEntries(A=>{const T=A[A.length-1];if((T==null?void 0:T.type)==="assistant_message"&&T.id.startsWith(Rt))return[...A.slice(0,-1),{...T,id:`assistant-${Date.now()}`,chunks:[...v?[{type:"thought",text:v}]:[],{type:"message",text:y}]}];if((T==null?void 0:T.type)==="assistant_message"){const w=T.chunks[T.chunks.length-1];return(w==null?void 0:w.type)==="message"?[...A.slice(0,-1),{...T,chunks:[...T.chunks.slice(0,-1),{type:"message",text:w.text+y}]}]:[...A.slice(0,-1),{...T,chunks:[...T.chunks,{type:"message",text:y}]}]}if(y&&y.trim()||v){const w={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...v?[{type:"thought",text:v}]:[],...y?[{type:"message",text:y}]:[]]};return[...A,w]}return A});const _=n.message;if(_&&typeof _=="object"&&Array.isArray(_.content)){const A=_.content.filter(T=>T.type==="tool_use");for(const T of A){const w=T.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(w))continue;this.seenToolCallIds.add(w),this.pendingToolCallIds.add(w);const E={id:w,title:T.name||"tool",status:"running",rawInput:T.input||{}};this.setEntries(I=>[...I,{type:"tool_call",toolCall:E}])}}break}case"tool_use":{const x=n,y=x.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(y))break;this.seenToolCallIds.add(y),this.pendingToolCallIds.add(y);const v={id:y,title:x.tool_name||"tool",status:"running",rawInput:x.tool_input||{}};this.setEntries(_=>[..._,{type:"tool_call",toolCall:v}]);break}case"tool_result":{const x=n;this.applyToolResult(x.tool_call_id||"",x.content??x.output);break}case"interrupt":{this.finalizePendingToolCalls("canceled"),this.turnEnded=!0,this.userSinceTurnEnd=!1,this.setTurnStartedAt(null),this.closed||(a=this.onStatusChange)==null||a.call(this,"idle");break}case"control_request":case"permission_request":{const x=n.request;if(x&&x.subtype==="can_use_tool"){const y=n.request_id||"",v=x.tool_name||"unknown",_=x.input||x.tool_input||{},A=x.description||"",T=Array.isArray(x.permission_suggestions)?x.permission_suggestions:[];this.setEntries(w=>{const E=[...w].reverse().findIndex(I=>I.type==="tool_call");if(E>=0){const I=w.length-1-E,$=w[I];if($.toolCall.status==="running")return this.pendingPermissionToolIds.set(y,$.toolCall.id),w.map((S,U)=>U===I?{type:"tool_call",toolCall:{...$.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:y,options:[]}}}:S)}return w}),(d=this.onPermissionRequest)==null||d.call(this,{requestId:y,toolName:v,toolInput:_,description:A,suggestions:T})}else x&&x.subtype==="elicitation"&&((c=this.onElicitationRequest)==null||c.call(this,{requestId:n.request_id||"",serverName:x.mcp_server_name||"",message:x.message||"",mode:x.mode==="url"?"url":"form",url:typeof x.url=="string"?x.url:void 0,requestedSchema:x.requested_schema||void 0}));break}case"conversation_rewound":{const x=Es(n);x&&(this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries(y=>{const v=y.findIndex(_=>cs(_)===x);return v===-1?y:y.slice(0,v)}));break}case"session_status":{if(Rn(n)){this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries([]);break}if(typeof n.status=="string"){if(ht(n.status))this.closed=!0,this.finalizePendingToolCalls("canceled");else if(this.closed)break;if(n.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(u=this.onStatusChange)==null||u.call(this,n.status)}break}case"error":{const x=String(n.message||n.content||"Unknown error");(p=this.onError)==null||p.call(this,x);break}case"models_state":{const x=n.raw,y=typeof x=="object"&&x!==null?x.models_state:n.models_state;y&&Array.isArray(y.availableModels)&&typeof y.currentModelId=="string"&&((f=this.onModelsStateChange)==null||f.call(this,y));break}case"system":{const x=n.raw,y=x&&typeof x=="object"?x:n,v=typeof y.subtype=="string"?y.subtype:void 0,_=ks(n);_&&(this.subagentState=js(this.subagentState,_),(g=this.onSubagentUpdate)==null||g.call(this,this.subagentState));const A=typeof y.permissionMode=="string"?y.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;if(A&&((b=this.onPermissionModeChange)==null||b.call(this,A)),v==="init"){const T=Ss(n);T&&((N=this.onWorkerInfoChange)==null||N.call(this,T))}break}case"control_response":{const x=n.response;if(x&&typeof x=="object"){const y=typeof x.request_id=="string"?x.request_id:"",v=typeof x.subtype=="string"?x.subtype:"";if(y){(M=this.onControlResponse)==null||M.call(this,{subtype:v,requestId:y,error:typeof x.error=="string"?x.error:void 0});const _=this.pendingControlRequests.get(y);_&&(this.pendingControlRequests.delete(y),_({data:v==="success"&&x.response&&typeof x.response=="object"?x.response:null,...v==="error"&&typeof x.error=="string"?{error:x.error}:{}}))}}break}case"stream_event":{const x=n.event;if(!x||typeof x.type!="string")break;if(x.type==="content_block_delta"){const y=x.delta;if(!y||typeof y.type!="string")break;const v=y.type==="text_delta"?"message":y.type==="thinking_delta"?"thought":null;if(!v)break;const _=y.text??y.thinking;if(typeof _!="string"||!_)break;this.appendStreamingDelta(v,_)}break}case"partial_assistant":{const x=typeof n.content=="string"?n.content:"";x&&this.appendStreamingDelta("message",x);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,this.setTurnStartedAt(null),this.finalizePendingToolCalls(n.is_error?"canceled":"complete"),this.closed||(C=this.onStatusChange)==null||C.call(this,"idle");const x=n.usage,y=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(x||y!==null){const w=((x==null?void 0:x.input_tokens)??0)+((x==null?void 0:x.cache_read_input_tokens)??0)+((x==null?void 0:x.cache_creation_input_tokens)??0);(j=this.onUsageChange)==null||j.call(this,{inputTokens:w,outputTokens:(x==null?void 0:x.output_tokens)??0,totalCostUsd:y})}const v=typeof n.subtype=="string"?n.subtype:"",_=n.raw&&typeof n.raw=="object"?n.raw:void 0,T=(typeof n.result=="string"?n.result:typeof(_==null?void 0:_.result)=="string"?_.result:"").trim();v.startsWith("error_")&&T&&this.setEntries(w=>[...w,{type:"command_output",id:`exit-error-${typeof n.uuid=="string"?n.uuid:Date.now()}`,commandName:"worker",inputText:"",title:i("adapter.workerCrashed"),outputText:T,variant:"error"}]);break}case"task_state":{const x=Array.isArray(n.tasks)?n.tasks:[];if(x.length===0)break;const y=Ts(x);if(y.length===0)break;this.setEntries(v=>[...v.filter(A=>A.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:y}]);break}}}applyEmbeddedToolResults(t){const s=t.message;if(!(!s||typeof s!="object"||!Array.isArray(s.content)))for(const n of s.content)!n||n.type!=="tool_result"||this.applyToolResult(n.tool_use_id||"",n.content??n.output)}applyToolResult(t,s){t&&(this.pendingToolCallIds.delete(t),this.setEntries(n=>{const a=_s(n,t);if(a<0)return n;const d=n[a];return d.toolCall.status!=="running"&&d.toolCall.status!=="waiting_for_confirmation"?n:n.map((c,u)=>u===a?{type:"tool_call",toolCall:{...d.toolCall,status:"complete",permissionRequest:void 0,rawOutput:{output:s||""}}}:c)}))}finalizePendingToolCalls(t){if(this.pendingToolCallIds.size===0)return;const s=this.pendingToolCallIds;this.pendingToolCallIds=new Set,this.setEntries(n=>n.map(a=>a.type!=="tool_call"||!s.has(a.toolCall.id)?a:{type:"tool_call",toolCall:{...a.toolCall,status:t,permissionRequest:void 0}}))}appendStreamingDelta(t,s){this.setEntries(n=>{const a=n[n.length-1];if((a==null?void 0:a.type)==="assistant_message"&&a.id.startsWith(Rt)){const c=a.chunks[a.chunks.length-1];return(c==null?void 0:c.type)===t?[...n.slice(0,-1),{...a,chunks:[...a.chunks.slice(0,-1),{type:t,text:c.text+s}]}]:[...n.slice(0,-1),{...a,chunks:[...a.chunks,{type:t,text:s}]}]}const d={type:"assistant_message",id:`${Rt}${Date.now()}`,chunks:[{type:t,text:s}]};return[...n,d]})}async sendMessage(t,s,n){var f;const a=s&&s.length>0,d=n&&n.length>0;if(!t.trim()&&!a&&!d)return;const c={type:"user_message",id:`user-${Date.now()}`,content:t,images:a?s:void 0,attachments:d?n:void 0};this.setEntries(g=>[...g,c]);const u=[];if(t&&u.push({type:"text",text:t}),a)for(const g of s)u.push({type:"image",source:{type:"base64",media_type:g.mimeType,data:g.data}});if(d){for(const g of n)if(g.kind==="text"||g.kind==="table"){const b=`📎 ${g.name}${g.size!=null?` (${la(g.size)})`:""}`,N=g.textContent||i("attach.emptyFile");u.push({type:"text",text:`${b}
|
|
77
|
+
\`\`\`
|
|
78
|
+
${N}
|
|
79
|
+
\`\`\``})}else if(g.kind==="directory"){const b=g.files!=null?`${H("attach.directoryHeader",{name:g.name})} ${H("attach.fileCount",{n:g.files.length})}`:H("attach.directoryHeader",{name:g.name}),N=g.textContent||i("attach.emptyDirectory");u.push({type:"text",text:`${b}
|
|
80
|
+
${N}`})}}const p=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;try{const g=ve();this.postedUserUuids.add(g);const b=await An(this.sessionId,{type:"user",uuid:g,content:t,message:{content:p}}),N=(f=b==null?void 0:b.event)==null?void 0:f.id;N&&this.setEntries(M=>M.map(C=>C.type==="user_message"&&C.id===c.id?{...C,id:N}:C))}catch(g){throw this.setEntries(b=>b.filter(N=>!(N.type==="user_message"&&N.id===c.id))),g}}async respondPermission(t,s,n){await ee(this.sessionId,{type:"permission_response",approved:s,request_id:t,...n});const a=this.pendingPermissionToolIds.get(t);this.pendingPermissionToolIds.delete(t),a&&!s&&this.pendingToolCallIds.delete(a),this.setEntries(d=>d.map(c=>{var u;return c.type!=="tool_call"||((u=c.toolCall.permissionRequest)==null?void 0:u.requestId)!==t?c:{type:"tool_call",toolCall:{...c.toolCall,status:s?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.finalizePendingToolCalls("canceled"),await In(this.sessionId)}async setPermissionMode(t){const s=ve();return await ee(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_permission_mode",mode:t}}),s}async controlRoundTrip(t,s=8e3){const n=ve(),a=new Promise(c=>{this.pendingControlRequests.set(n,c)}),d=setTimeout(()=>{const c=this.pendingControlRequests.get(n);c&&(this.pendingControlRequests.delete(n),c({data:null,error:"timeout"}))},s);try{return await ee(this.sessionId,{type:"control_request",request_id:n,request:t}),await a}catch(c){throw this.pendingControlRequests.delete(n),c}finally{clearTimeout(d)}}async searchFiles(t,s=20){const n=await this.controlRoundTrip({subtype:"file_search",query:t,limit:s});try{if(!n.data||!Array.isArray(n.data.suggestions))return[];const a=[];for(const d of n.data.suggestions)d&&typeof d=="object"&&typeof d.path=="string"&&a.push(d.path);return a}catch{return[]}}async respondElicitation(t,s,n){await ee(this.sessionId,{type:"permission_response",approved:s==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:s,...n?{content:n}:{}}}})}async askSideQuestion(t){const s=await this.controlRoundTrip({subtype:"side_question",question:t},12e4);if(s.error||!s.data)return null;const n=s.data.response;return typeof n=="string"?n:null}async listResumableSessions(){const t=await this.controlRoundTrip({subtype:"list_sessions"});if(!t.data||!Array.isArray(t.data.sessions))throw new Error(t.error??"list_sessions failed");const s=[];for(const n of t.data.sessions){if(!n||typeof n!="object")continue;const a=n;typeof a.session_id!="string"||!a.session_id||s.push({sessionId:a.session_id,title:typeof a.title=="string"&&a.title?a.title:a.session_id.slice(0,8),modified:typeof a.modified=="number"?a.modified:0,...typeof a.created_at=="number"?{createdAt:a.created_at}:{},...typeof a.git_branch=="string"&&a.git_branch?{gitBranch:a.git_branch}:{}})}return s}async resumeSession(t){const s=await this.controlRoundTrip({subtype:"resume_session",session_id:t},3e4);if(!s.data)throw new Error(s.error??"resume_session failed");return{title:typeof s.data.title=="string"?s.data.title:null,messageCount:typeof s.data.message_count=="number"?s.data.message_count:0}}async setEffort(t){const s=ve();return await ee(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),s}async setTokenMode(t){const s=ve();return await ee(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_token_mode",mode:t}}),s}async setThinkingBudget(t){const s=ve();return await ee(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_max_thinking_tokens",max_thinking_tokens:t}}),s}async getContextUsage(){const t=await this.controlRoundTrip({subtype:"get_context_usage"});try{if(!t.data)return null;const s=t.data.totalTokens,n=t.data.rawMaxTokens,a=t.data.percentage;if(typeof s!="number"||typeof n!="number")return null;const d=t.data.categories,c=Array.isArray(d)?d.filter(u=>!!u&&typeof u=="object"&&typeof u.name=="string").map(u=>({name:u.name,tokens:typeof u.tokens=="number"?u.tokens:0,...u.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:n,percentage:typeof a=="number"?a:0,...typeof t.data.model=="string"&&t.data.model?{model:t.data.model}:{},...c&&c.length>0?{categories:c}:{}}}catch{return null}}async stopSubagent(t){const s=await this.controlRoundTrip({subtype:"stop_task",task_id:t});try{return s.error?{ok:!1,error:s.error==="timeout"?i("adapter.stopTimeout"):s.error}:{ok:!0}}catch{return{ok:!1,error:i("adapter.stopFailed")}}}async getMcpServers(){var a;const s=(a=(await this.controlRoundTrip({subtype:"mcp_status"})).data)==null?void 0:a.mcpServers;if(!Array.isArray(s))return[];const n=[];for(const d of s){if(!d||typeof d!="object")continue;const c=d;if(typeof c.name!="string"||!c.name)continue;const u=c.status;if(u!=="connected"&&u!=="failed"&&u!=="needs-auth"&&u!=="pending"&&u!=="disabled")continue;const p=c.serverInfo,f=c.config;n.push({name:c.name,status:u,...p&&typeof p.name=="string"&&typeof p.version=="string"?{serverInfo:{name:p.name,version:p.version}}:{},...typeof c.error=="string"&&c.error?{error:c.error}:{},...typeof(f==null?void 0:f.url)=="string"&&f.url?{url:f.url}:{},...Array.isArray(c.tools)?{toolCount:c.tools.length}:{}})}return n}async toggleMcpServer(t,s){const n=await this.controlRoundTrip({subtype:"mcp_toggle",serverName:t,enabled:s},15e3);return n.error?{ok:!1,error:n.error==="timeout"?i("adapter.requestTimeout"):n.error}:{ok:!0}}async reconnectMcpServer(t){const s=await this.controlRoundTrip({subtype:"mcp_reconnect",serverName:t},2e4);return s.error?{ok:!1,error:s.error==="timeout"?i("adapter.requestTimeout"):s.error}:{ok:!0}}async getRemoteSettings(){const s=(await this.controlRoundTrip({subtype:"get_settings"})).data;if(!s)return null;const n=s.applied,a=s.effective&&typeof s.effective=="object"&&!Array.isArray(s.effective)?s.effective:{},d=s.sources,c=[];if(Array.isArray(d))for(const u of d){if(!u||typeof u!="object")continue;const p=u;typeof p.source=="string"&&c.push({source:p.source,settings:p.settings&&typeof p.settings=="object"&&!Array.isArray(p.settings)?p.settings:{}})}return{applied:{model:typeof(n==null?void 0:n.model)=="string"?n.model:null,effort:typeof(n==null?void 0:n.effort)=="string"?n.effort:null,tokenMode:typeof(n==null?void 0:n.tokenMode)=="string"?n.tokenMode:null},effective:a,sources:c}}async applyFlagSettings(t){const s=await this.controlRoundTrip({subtype:"apply_flag_settings",settings:t},15e3);return s.error?{ok:!1,error:s.error==="timeout"?i("adapter.requestTimeout"):s.error}:{ok:!0}}async rewindToMessage(t){await $n(this.sessionId,t)}async endSession(t){await ee(this.sessionId,{type:"control_request",request_id:ve(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function la(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function xt({onBack:r,title:t,meta:s,actions:n}){return ae(),e.jsx("div",{className:"flex-shrink-0 border-b border-nav-rule bg-surface-1/80 backdrop-blur-md",children:e.jsxs("div",{className:"mx-auto flex h-12 w-full page-measure items-center gap-2 px-4 sm:px-8",children:[e.jsx("button",{type:"button",onClick:r,"aria-label":i("nav.dashboard"),title:i("nav.dashboard"),className:"-mx-2 flex-shrink-0 rounded-md px-2 py-1 text-xs text-text-muted transition hover:-translate-x-0.5 hover:bg-surface-2 hover:text-text-primary",children:i("nav.dashboard")}),e.jsx("span",{className:"mx-1 h-4 w-px flex-shrink-0 bg-border","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t,s&&e.jsx("div",{className:"flex flex-shrink-0 items-center gap-2",children:s})]}),n&&e.jsx("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:n}),e.jsx("span",{className:"mx-1 h-4 w-px flex-shrink-0 bg-border","aria-hidden":"true"}),e.jsx(qn,{}),e.jsx(Pn,{onSettingsClick:()=>{window.history.pushState(null,"","/settings"),window.dispatchEvent(new PopStateEvent("popstate"))}})]})})}const Ms="rcs:subagent-panel:collapsed";function ca(r){if(r<1e3)return"0s";const t=Math.floor(r/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60),n=t%60;if(s<60)return n?`${s}m${n}s`:`${s}m`;const a=Math.floor(s/60),d=s%60;return d?`${a}h${d}m`:`${a}h`}function da(r){return r===void 0||r<=0?"":r<1e3?`${r}`:r<1e6?`${(r/1e3).toFixed(r<1e4?1:0)}k`:`${(r/1e6).toFixed(1)}M`}function ua({status:r}){return r==="running"?e.jsx(Ge,{className:"h-3 w-3 animate-spin text-brand-text"}):r==="completed"?e.jsx(Vr,{className:"h-3 w-3 text-status-success"}):r==="failed"||r==="stopped"?e.jsx(Fn,{className:"h-3 w-3 text-status-error"}):null}function tn({task:r,onStopTask:t,fullText:s}){const n=r.status==="running",a=n?r.durationMs??Date.now()-r.startTime:(r.endTime??Date.now())-r.startTime,d=da(r.tokenCount),c=r.toolUseCount!==void 0&&r.toolUseCount>0?`${r.toolUseCount} tool${r.toolUseCount>1?"s":""}`:"",u=r.summary||r.description||"(no description)";return e.jsxs("div",{className:"group/task flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(ua,{status:r.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:r.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:ca(a)})]}),e.jsx("div",{className:`mt-0.5 text-text-secondary ${s?"line-clamp-2 break-words":"truncate"}`,children:u}),(d||c||r.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-x-2 overflow-hidden whitespace-nowrap font-mono text-[10px] text-text-muted",children:[d&&e.jsxs("span",{className:"flex-shrink-0",children:["↕ ",d," tok"]}),c&&e.jsxs("span",{className:"flex-shrink-0",children:["· ",c]}),r.lastToolName&&e.jsxs("span",{className:"min-w-0 truncate",children:["· last: ",r.lastToolName]})]}),!n&&r.finalSummary&&e.jsx("div",{className:"mt-1 line-clamp-2 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:r.finalSummary})]}),n&&t&&e.jsx("button",{type:"button",onClick:()=>t(r.taskId),title:i("subagent.stop"),className:"mt-0.5 flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:bg-status-error/10 hover:text-status-error focus:opacity-100 group-hover/task:opacity-100",children:e.jsx(On,{className:"h-3.5 w-3.5"})})]})}function ma({state:r,onStopTask:t}){const[s,n]=l.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ms)==="1"}catch{return!1}}),a=()=>{n(b=>{const N=!b;try{window.localStorage.setItem(Ms,N?"1":"0")}catch{}return N})},d=Object.values(r.tasks).some(b=>b.status==="running"),c=Object.values(r.tasks).some(b=>b.status!=="running"&&b.evictAfter!==void 0),[,u]=l.useState(0);l.useEffect(()=>{if(!d&&!c)return;const b=setInterval(()=>{u(N=>N+1)},1e3);return()=>clearInterval(b)},[d,c]);const p=en(r);if(p.length===0)return null;const f=p.filter(b=>b.status==="running").length,g=f>0?`${f} running`:`${p.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:a,"aria-expanded":!s,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Vs,{className:`h-3 w-3 transition-transform ${s?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:g})]}),!s&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:p.map(b=>e.jsx(tn,{task:b,onStopTask:t},b.taskId))})]})})}function xa(r){if(!r)return"never";const t=Math.max(0,Date.now()-r);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 pa(r){return r?Date.now()-r<6e4:!1}function ha({onClose:r,session:t,liveStatus:s,pendingPermissions:n,onInterrupt:a,onDelete:d,subagentState:c,onStopTask:u,onEndSession:p}){const[f,g]=l.useState(!1),b=async()=>{await navigator.clipboard.writeText(t.id),g(!0),setTimeout(()=>g(!1),1500)},[N,M]=l.useState(!1),C=async()=>{if(!(!p||N)&&window.confirm(i("task.endConfirm"))){M(!0);try{await p(),r()}catch{M(!1)}}},j=n.length,x=t.worker,y=t.work_item,v=t.environment;return e.jsx(De,{open:!0,onOpenChange:_=>{_||r()},children:e.jsxs(qe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(Pe,{children:e.jsx(Oe,{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(jr,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Un,{status:s||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:x&&(pa(x.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[x&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ds,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:xa(x.last_heartbeat_at)})]}),v&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Gs,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:v.machine_name||v.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ds,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Qs(t.created_at)})]})]})]}),e.jsx(ga,{state:c,onStopTask:u}),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(Ge,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),j>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[j," permission request",j>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(Xr,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:a,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"}),p&&e.jsx("button",{onClick:C,disabled:N,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:i("task.endHint"),children:N?"Ending…":"End session"}),e.jsxs("button",{onClick:d,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(Ws,{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(Ur,{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:b,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:f?"✓":"⧉"})]})]}),y&&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:y.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:y.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})]}),v&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:v.worker_type})]})]})]})]})]})})}const fa={in_process_teammate:"task.type.teammates",local_bash:"task.type.shells",monitor_mcp:"task.type.monitors",remote_agent:"task.type.remoteAgents",local_agent:"task.type.localAgents"},ya=new Set(["dream"]);function ga({state:r,onStopTask:t}){const s=Object.values(r.tasks).some(p=>p.status==="running"),n=Object.values(r.tasks).some(p=>p.status!=="running"&&p.evictAfter!==void 0),[,a]=l.useState(0);l.useEffect(()=>{if(!s&&!n)return;const p=setInterval(()=>{a(f=>f+1)},1e3);return()=>clearInterval(p)},[s,n]);const d=en(r),c=d.filter(p=>p.status==="running").length,u=d.length-c;return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Hr,{className:"h-3.5 w-3.5"}),i("task.backgroundTasks")]}),d.length>0&&e.jsx("span",{className:"font-mono text-[10px] text-text-muted",children:c>0&&u>0?H("task.mixedCount",{running:c,recent:u}):c>0?H("task.runningCount",{count:c}):H("task.recentCount",{count:d.length})})]}),d.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:i("task.noBackgroundTasks")}):e.jsx("div",{className:"max-h-[38vh] space-y-2 overflow-y-auto overscroll-contain pr-1",children:ra(d).map(p=>{const f=!ya.has(p.taskType),g=fa[p.taskType]??"task.type.tasks";return e.jsxs("div",{className:"space-y-1",children:[f&&e.jsxs("div",{className:"pl-1 text-[10px] font-medium uppercase tracking-wide text-text-muted/80",children:[i(g)," (",p.tasks.length,")"]}),p.tasks.map(b=>e.jsx(tn,{task:b,onStopTask:t,fullText:!0},b.taskId))]},p.taskType)})})]})}const ba={connected:"bg-status-success/15 text-status-success",failed:"bg-status-error/15 text-status-error","needs-auth":"bg-status-warning/15 text-status-warning",pending:"bg-status-active/15 text-status-active",disabled:"bg-surface-3 text-text-muted"},ja={connected:"mcp.status.connected",failed:"mcp.status.failed","needs-auth":"mcp.status.needsAuth",pending:"mcp.status.pending",disabled:"mcp.status.disabled"};function wa({onClose:r,fetchServers:t,onToggle:s,onReconnect:n}){ae();const[a,d]=l.useState(null),[c,u]=l.useState(null),[p,f]=l.useState(null),[g,b]=l.useState(null),N=l.useCallback(async()=>{f(null),b(null);try{const j=await t();d(j),u(null)}catch(j){ft("[McpPanel] fetch failed",j),u(i("mcp.loadFailed"))}},[t]);l.useEffect(()=>{N()},[N]);const M=async j=>{const x=j.status==="disabled";f(`toggle:${j.name}`),b(null);try{const y=await s(j.name,x);y.ok||b(y.error||i("mcp.toggleFailed"))}finally{await N()}},C=async j=>{f(`reconnect:${j.name}`),b(null);try{const x=await n(j.name);x.ok||b(x.error||i("mcp.reconnectFailed"))}finally{await N()}};return e.jsx(De,{open:!0,onOpenChange:j=>{j||r()},children:e.jsxs(qe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Xs,{className:"h-4 w-4"}),i("session.mcp.title")]})}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[g&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:g}),a===null&&!c&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Ge,{className:"h-3.5 w-3.5 animate-spin"}),i("mcp.loading")]}),c&&e.jsx("p",{className:"text-xs text-status-error",children:c}),a!==null&&a.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:i("mcp.empty")}),a==null?void 0:a.map(j=>{const x=p===`toggle:${j.name}`,y=p===`reconnect:${j.name}`,v=j.status==="disabled";return e.jsx("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-text-primary",children:j.name}),e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium ${ba[j.status]}`,children:i(ja[j.status])})]}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:[j.serverInfo?`${j.serverInfo.name} v${j.serverInfo.version}`:j.url||"stdio",j.toolCount!==void 0&&` · ${H("mcp.toolCount",{n:j.toolCount})}`]}),j.error&&e.jsx("div",{className:"mt-1 truncate text-xs text-status-error",title:j.error,children:j.error})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void C(j),disabled:y||v,className:"rounded-md p-1.5 text-text-muted hover:bg-surface-3 hover:text-text-primary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:i("mcp.reconnect"),children:e.jsx(vr,{className:`h-3.5 w-3.5 ${y?"animate-spin":""}`})}),e.jsx("button",{type:"button",role:"switch","aria-checked":!v,onClick:()=>void M(j),disabled:x,className:`relative h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${v?"bg-surface-3":"bg-brand"}`,title:v?i("mcp.enable"):i("mcp.disable"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${v?"left-0.5":"left-4.5"}`})})]})]})},j.name)})]})]})})}function va(r){if(r==null)return i("settings.unset");if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}function Rs(r){if(r==null)return i("settings.unset");if(typeof r=="object")try{return JSON.stringify(r,null,2)}catch{return String(r)}return String(r)}function ka({onClose:r,fetchSettings:t,onApply:s}){ae();const[n,a]=l.useState(null),[d,c]=l.useState(null),[u,p]=l.useState(""),[f,g]=l.useState(null),[b,N]=l.useState(null),[M,C]=l.useState(null),[j,x]=l.useState(!1),y=l.useCallback(async()=>{g(null),N(null),C(null),x(!1);try{const S=await t();a(S),c(S?null:i("settings.loadFailed"))}catch(S){ft("[SettingsDrawer] fetch failed",S),c(i("settings.loadFailed"))}},[t]);l.useEffect(()=>{y()},[y]);const v=l.useMemo(()=>n?Object.entries(n.effective).filter(([,S])=>S!==void 0).sort(([S],[U])=>S.localeCompare(U)):[],[n]),_=l.useMemo(()=>{const S=u.trim().toLowerCase();return S?v.filter(([U,O])=>`${U} ${va(O)}`.toLowerCase().includes(S)):v},[v,u]),A=S=>typeof S[1]=="boolean",T=l.useMemo(()=>_.filter(A),[_]),w=l.useMemo(()=>_.filter(S=>!A(S)),[_]),E=l.useMemo(()=>M===null?null:v.find(([S])=>S===M)??null,[v,M]),I=async()=>{if(E)try{await navigator.clipboard.writeText(Rs(E[1])),x(!0),window.setTimeout(()=>x(!1),1500)}catch(S){ft("[SettingsDrawer] copy failed",S)}},$=async(S,U)=>{g(S),N(null);try{const O=await s({[S]:!U});O.ok||N(O.error||i("settings.writeFailed"))}finally{await y()}};return e.jsx(De,{open:!0,onOpenChange:S=>{S||r()},children:e.jsxs(qe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Zs,{className:"h-4 w-4"}),i("session.settings.title")]})}),e.jsxs("div",{className:"mt-3 space-y-4 text-sm",children:[b&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:b}),n===null&&!d&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Ge,{className:"h-3.5 w-3.5 animate-spin"}),i("settings.loading")]}),d&&e.jsx("p",{className:"text-xs text-status-error",children:d}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:i("settings.model")}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.model||i("settings.defaultModel")})]}),n.applied.effort&&e.jsxs("div",{className:"mt-1 flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:"Effort"}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.effort})]}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-text-muted",children:i("settings.hint")})]}),E?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>{C(null),x(!1)},className:"flex items-center gap-1.5 text-xs text-text-muted transition-colors hover:text-text-primary",children:[e.jsx(kr,{className:"h-3.5 w-3.5"}),i("settings.back")]}),e.jsx("div",{className:"break-all font-mono text-xs font-medium text-text-primary",children:E[0]}),e.jsx("pre",{className:"max-h-[60vh] overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 p-3 font-mono text-[10px] leading-relaxed text-text-secondary",children:Rs(E[1])}),e.jsxs("button",{type:"button",onClick:()=>void I(),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary",children:[j?e.jsx($e,{className:"h-3.5 w-3.5 text-status-success"}):e.jsx(Sr,{className:"h-3.5 w-3.5"}),j?i("settings.copied"):i("settings.copyValue")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2.5 py-1.5",children:[e.jsx(yt,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{value:u,onChange:S=>p(S.target.value),placeholder:i("settings.searchPlaceholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"})]}),_.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:i("settings.noMatch")}),T.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:H("settings.togglable",{n:T.length})}),T.map(([S,U])=>{const O=f===S;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2",children:[e.jsx("div",{className:"truncate font-mono text-xs text-text-primary",children:S}),e.jsx("button",{type:"button",role:"switch","aria-checked":U,disabled:O,onClick:()=>void $(S,U),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${U?"bg-brand":"bg-surface-3"}`,title:U?i("settings.turnOff"):i("settings.turnOn"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${U?"left-4.5":"left-0.5"}`})})]},S)})]}),w.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:H("settings.readOnly",{n:w.length})}),w.map(([S])=>e.jsxs("button",{type:"button",onClick:()=>C(S),className:"flex w-full items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2 text-left transition-colors hover:bg-surface-3",title:i("settings.viewDetail"),children:[e.jsx("span",{className:"truncate font-mono text-xs text-text-primary",children:S}),e.jsx(Vs,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"})]},S))]})]})]})]})]})})}function Na({onClose:r,onAsk:t}){ae();const[s,n]=l.useState([]),[a,d]=l.useState(""),[c,u]=l.useState(!1),p=async()=>{const f=a.trim();if(!f||c)return;const g=Date.now();n(b=>[...b,{id:g,question:f,answer:null}]),d(""),u(!0);try{const b=await t(f);n(N=>N.map(M=>M.id===g?{...M,answer:b??i("sideQuestion.noAnswer"),error:b===null}:M))}finally{u(!1)}};return e.jsx(De,{open:!0,onOpenChange:f=>{f||r()},children:e.jsxs(qe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-[26rem] h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md flex flex-col",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Js,{className:"h-4 w-4"}),i("sideQuestion.title")]})}),e.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-text-muted",children:i("sideQuestion.desc")}),e.jsxs("div",{className:"mt-3 flex-1 space-y-4 overflow-y-auto",children:[s.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:i("sideQuestion.empty")}),s.map(f=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-br-md border border-user-bubble-border bg-user-bubble px-4 py-2 text-sm text-text-primary",children:f.question})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:24,height:24,className:"object-contain",draggable:!1})}),e.jsx("div",{className:"min-w-0 flex-1 pt-1 text-sm text-text-primary",children:f.answer===null?e.jsxs("span",{className:"chat-typing-indicator inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):e.jsx("div",{className:f.error?"text-status-error":"",children:e.jsx(Kn,{children:f.answer})})})]})]},f.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:a,onChange:f=>d(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&!f.nativeEvent.isComposing&&(f.preventDefault(),p())},rows:Math.min(4,Math.max(1,a.split(`
|
|
81
|
+
`).length)),placeholder:i("sideQuestion.placeholder"),disabled:c,className:"flex-1 resize-none rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none disabled:opacity-50"}),e.jsx("button",{type:"button",onClick:()=>void p(),disabled:c||!a.trim(),className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-brand text-white transition-colors hover:bg-brand-light disabled:opacity-40 disabled:cursor-not-allowed",title:i("sideQuestion.send"),children:c?e.jsx(Ge,{className:"h-4 w-4 animate-spin"}):e.jsx(Ln,{className:"h-4 w-4"})})]})]})})}const At="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-1";function As(r,t){var a;const s=(a=t==null?void 0:t.find(d=>d.type==="addRules"||d.type==="replaceRules"))==null?void 0:a.rules,n=s==null?void 0:s[0];return n!=null&&n.ruleContent?`${n.toolName}(${n.ruleContent})`:n!=null&&n.toolName?n.toolName:r}function Sa({requestId:r,toolName:t,toolInput:s,description:n,suggestions:a,onApprove:d,onApproveAlways:c,onReject:u}){ae();const p=s&&typeof s=="object"&&!Array.isArray(s)?s:{},f=Bn(Hn(t),p,{writeUnknownLabel:i("permission.writeUnknown")}),g=typeof s=="string"?s:JSON.stringify(s,null,2),b=Array.isArray(a)&&a.length>0;return e.jsxs("div",{role:"group","aria-label":H("permission.requestAria",{tool:t}),className:"rounded-xl border border-approve/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-approve/15 text-approve-text",children:e.jsx(Qn,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold font-display text-approve-text",children:i("permission.title")})]}),n&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:te(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:te(t)}),t!=="AskUserQuestion"&&(f?e.jsx("div",{className:"mb-3 space-y-2",children:f.map((N,M)=>e.jsx(Wn,{filePath:N.filePath,oldString:N.oldString,newString:N.newString,label:N.label},M))}):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:us(g,500)})),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:d,className:fe("rounded-lg bg-approve px-4 py-2 text-sm font-medium font-display text-white hover:bg-approve-hover transition-colors",At),children:i("permission.approve")}),b&&c&&e.jsxs("button",{onClick:c,className:fe("flex items-center gap-1.5 rounded-lg border border-approve/40 bg-approve/10 px-4 py-2 text-sm font-medium font-display text-approve-text hover:bg-approve/20 transition-colors",At),title:i("permission.alwaysAllowHint").replace("{rule}",As(t,a)),children:[e.jsx(na,{className:"h-3.5 w-3.5"}),i("permission.alwaysAllow")," ",us(As(t,a),40)]}),e.jsx("button",{onClick:u,className:fe("rounded-lg border border-status-error/40 px-4 py-2 text-sm font-medium font-display text-status-error hover:bg-status-error/10 transition-colors",At),children:i("permission.reject")})]})]})}function _a({questions:r,description:t,onSubmit:s,onSkip:n}){const[a,d]=l.useState({}),[c,u]=l.useState({}),[p,f]=l.useState(0),g=(C,j,x)=>{if(x){const y=a[C]||[],v=y.includes(j)?y.filter(_=>_!==j):[...y,j];d({...a,[C]:v})}else d({...a,[C]:j})},b=C=>{var x;const j=(x=c[C])==null?void 0:x.trim();j&&(d({...a,[C]:j}),u({...c,[C]:""}))},N=()=>{var j,x;const C={};for(const[y,v]of Object.entries(a)){const _=r[parseInt(y,10)];_&&(typeof v=="number"?C[y]=((x=(j=_.options)==null?void 0:j[v])==null?void 0:x.label)||String(v):Array.isArray(v)?C[y]=v.map(A=>{var T,w;return((w=(T=_.options)==null?void 0:T[A])==null?void 0:w.label)||String(A)}):C[y]=v)}s(C)};if(r.length<=1){const C=r[0]||{question:t,options:[],multiSelect:!1},j=C.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 font-display text-text-primary",children:te(t||C.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(C.options||[]).map((x,y)=>{const v=j?(a[0]||[]).includes(y):a[0]===y;return e.jsxs("button",{onClick:()=>g(0,y,j),className:fe("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",v?"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 font-display",children:te(x.label)}),x.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:te(x.description)})]},y)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:c[0]||"",onChange:x=>u({...c,0:x.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:x=>x.key==="Enter"&&b(0)}),e.jsx("button",{onClick:()=>b(0),className:"rounded-lg border border-border px-3 py-2 text-sm font-display 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 font-display 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 font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const M=r[p];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold font-display text-text-primary",children:te(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:r.map((C,j)=>e.jsx("button",{onClick:()=>f(j),className:fe("rounded-md px-3 py-1.5 text-xs font-display whitespace-nowrap transition-colors",p===j?"bg-brand/20 text-brand-text":"text-text-muted hover:bg-surface-2"),children:C.header||`Q${j+1}`},j))}),M&&e.jsx(Ca,{question:M,qIdx:p,answers:a,otherTexts:c,onSelect:g,onOtherTextChange:(C,j)=>u({...c,[C]:j}),onOtherSubmit:b}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-display text-text-muted",children:[p+1," / ",r.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 font-display 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 font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function Ca({question:r,qIdx:t,answers:s,otherTexts:n,onSelect:a,onOtherTextChange:d,onOtherSubmit:c}){const u=r.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:te(r.question)}),e.jsxs("div",{className:"space-y-2",children:[(r.options||[]).map((p,f)=>{const g=u?(s[t]||[]).includes(f):s[t]===f;return e.jsxs("button",{onClick:()=>a(t,f,u),className:fe("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",g?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium font-display",children:te(p.label)}),p.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:te(p.description)})]},f)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:p=>d(t,p.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:p=>p.key==="Enter"&&c(t)}),e.jsx("button",{onClick:()=>c(t),className:"rounded-lg border border-border px-3 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function Ta({planContent:r,description:t,onSubmit:s}){const[n,a]=l.useState(null),[d,c]=l.useState(""),u=!r||!r.trim(),p=()=>{n&&s(n,n==="no"?d:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand-text",children:e.jsx($e,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold font-display text-text-primary",children:u?"Exit plan mode?":"Ready to code?"})]}),!u&&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:Ea(r)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes"}),e.jsx(Ve,{selected:n==="no",onClick:()=>a("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{selected:n==="yes-accept-edits",onClick:()=>a("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(Ve,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(Ve,{selected:n==="no",onClick:()=>a("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),n==="no"&&e.jsx("textarea",{value:d,onChange:f=>c(f.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 font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:p,disabled:!n,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium font-display text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function Ve({selected:r,onClick:t,label:s,desc:n}){return e.jsxs("button",{onClick:t,className:fe("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",r?"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:fe("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",r?"border-brand bg-brand text-white":"border-border"),children:r&&"✓"}),e.jsx("span",{className:"font-medium font-display",children:s})]}),n&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs font-sans text-text-muted",children:n})]})}function Ea(r){let t=te(r);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(s,n,a)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${a.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 Ma({request:r,onSubmit:t}){ae();const s=Ra(r.requestedSchema),n=Aa(r.requestedSchema),[a,d]=l.useState({}),c=s.length===0||n.every(u=>(a[u]??"").trim()!=="");return r.mode==="url"&&r.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Is,{serverName:r.serverName,message:r.message}),e.jsxs("a",{href:r.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-text hover:bg-brand/10 transition-colors",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:r.url}),e.jsx(_r,{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:i("elicitation.done")}),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:i("common.cancel")})]})]}):e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Is,{serverName:r.serverName,message:r.message}),s.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:s.map(({name:u,prop:p})=>e.jsxs("label",{className:"block",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-medium text-text-primary",children:u}),n.includes(u)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:i("elicitation.required")})]}),p.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:te(p.description)}),e.jsx("input",{type:p.type==="number"?"number":"text",value:a[u]??"",onChange:f=>d(g=>({...g,[u]:f.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"})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const u={};for(const{name:p,prop:f}of s){const g=(a[p]??"").trim();g&&(u[p]=f.type==="number"?Number(g):g)}t("accept",u)},disabled:!c,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:i("elicitation.submit")}),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:i("elicitation.decline")})]})]})}function Is({serverName:r,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-text",children:e.jsx(zr,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-sm font-semibold text-text-primary",children:[i("elicitation.title")," ",e.jsx("span",{className:"font-mono text-xs text-text-muted",children:te(r)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:te(t)})]})}function Ra(r){const t=r==null?void 0:r.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,s])=>s&&typeof s=="object").map(([s,n])=>({name:s,prop:n}))}function Aa(r){const t=r==null?void 0:r.required;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Ia(r){const[t,s]=l.useState([]),[n,a]=l.useState(!0),[d,c]=l.useState(null),u=l.useCallback(async()=>{a(!0),c(null);try{const g=await zn(r);s(g)}catch(g){c(g instanceof Error?g.message:"Failed to load shares")}finally{a(!1)}},[r]);l.useEffect(()=>{u()},[u]);const p=l.useCallback(async g=>{c(null);try{const b=await Yn(r,g);return await u(),b}catch(b){throw c(b instanceof Error?b.message:"Failed to create share"),b}},[r,u]),f=l.useCallback(async g=>{c(null);try{await Vn(r,g),await u()}catch(b){throw c(b instanceof Error?b.message:"Failed to revoke share"),b}},[r,u]);return{shares:t,isLoading:n,error:d,createShare:p,revokeShare:f,refresh:u}}function $a({open:r,onClose:t,sessionId:s,sessionTitle:n}){ae();const{shares:a,isLoading:d,error:c,createShare:u,revokeShare:p}=Ia(s),[f,g]=l.useState("user"),[b,N]=l.useState(""),[M,C]=l.useState(""),[j,x]=l.useState("read"),[y,v]=l.useState(""),[_,A]=l.useState(!1),[T,w]=l.useState(null),[E,I]=l.useState(""),[$,S]=l.useState(!1),[U,O]=l.useState(!1);l.useEffect(()=>{r&&(g("user"),N(""),C(""),x("read"),v(""),A(!1),w(null),I(""),S(!1),O(!1))},[r]);const J=async()=>{A(!0),I(""),w(null);try{const P={grantedTo:f==="user"?{userId:b.trim()}:{teamId:M.trim()},permission:j};y.trim()&&(P.expiresAt=y.trim());const ne=await u(P);w(`${window.location.origin}/code/s/${ne.shareToken}`)}catch(P){I(P instanceof Error?P.message:"Failed to create share")}finally{A(!1)}},X=async P=>{try{await p(P)}catch{}},se=async()=>{if(!T)return;O(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),S(!0),setTimeout(()=>S(!1),2e3);return}}catch{}const P=document.createElement("textarea");P.value=T,P.style.position="fixed",P.style.opacity="0",document.body.appendChild(P),P.select();try{document.execCommand("copy"),S(!0),setTimeout(()=>S(!1),2e3)}catch{O(!0)}document.body.removeChild(P)};return e.jsx(De,{open:r,onOpenChange:P=>{P||t()},children:e.jsxs(qe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Pe,{children:e.jsxs(Oe,{className:"font-display text-lg font-semibold text-text-primary",children:[i("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:i("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>g("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${f==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:i("share.user")}),e.jsx("button",{onClick:()=>g("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${f==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:i("share.team")})]}),f==="user"?e.jsx(Nr,{onSelect:N,placeholder:i("share.userIdPlaceholder"),actionLabel:i("share.selectUser")}):e.jsx("input",{type:"text",value:M,onChange:P=>C(P.target.value),placeholder:i("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"}),f==="user"&&b&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[i("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:b})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:i("share.permission")}),e.jsxs("select",{value:j,onChange:P=>x(P.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:i("share.permissionRead")}),e.jsx("option",{value:"write",children:i("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:i("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:y,onChange:P=>v(P.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"})]}),(E||c)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:E||c}),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:i("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:se,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:$?i("share.copied"):i("share.copy")})]}),U&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:i("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:i("share.existingShares")}),d?e.jsx("p",{className:"text-sm text-text-muted",children:i("share.loading")}):a.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:i("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:a.map(P=>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:P.granted_to_user||P.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[P.permission==="write"?i("share.permissionWrite"):i("share.permissionRead"),P.expires_at?` · expires ${P.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>X(P.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:i("share.revoke")})]},P.id))})]})]}),e.jsxs(wr,{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:i("common.close")}),e.jsx("button",{onClick:J,disabled:_||(f==="user"?!b.trim():!M.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:_?i("common.creating"):i("share.createShare")})]})]})})}function Da(r){const t=new Date,s=new Date(t.getTime()-1440*60*1e3),n=(c,u)=>c.getFullYear()===u.getFullYear()&&c.getMonth()===u.getMonth()&&c.getDate()===u.getDate(),a={today:[],yesterday:[],earlier:[]};for(const c of r){const u=new Date(c.modified||0);n(u,t)?a.today.push(c):n(u,s)?a.yesterday.push(c):a.earlier.push(c)}return[["today",i("resume.today")],["yesterday",i("resume.yesterday")],["earlier",i("resume.earlier")]].map(([c,u])=>({label:u,items:a[c]})).filter(c=>c.items.length>0)}function qa(r){return r?new Date(r).toLocaleString():""}function Pa({open:r,onClose:t,adapter:s,onResume:n}){const a=ae(),[d,c]=l.useState([]),[u,p]=l.useState(!1),[f,g]=l.useState("");l.useEffect(()=>{if(!r)return;let N=!1;return p(!0),g(""),c([]),s.listResumableSessions().then(M=>{N||c(M)}).catch(M=>{N||g(M instanceof Error?M.message:String(M))}).finally(()=>{N||p(!1)}),()=>{N=!0}},[r,s]);const b=l.useMemo(()=>Da(d),[d,a]);return e.jsx(De,{open:r,onOpenChange:N=>{N||t()},children:e.jsxs(qe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Pe,{children:e.jsx(Oe,{className:"font-display text-lg font-semibold text-text-primary",children:i("session.resume.title")})}),e.jsxs("div",{className:"max-h-96 min-w-0 space-y-4 overflow-y-auto",children:[u&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:i("resume.loading")}),!u&&f&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:f}),!u&&!f&&d.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:i("resume.empty")}),!u&&!f&&b.map(N=>e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-text-muted",children:N.label}),e.jsx("div",{className:"space-y-1",children:N.items.map(M=>e.jsxs("button",{type:"button",onClick:()=>n(M),className:"w-full rounded-md px-3 py-2 text-left transition-colors hover:bg-surface-3",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:M.title}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[qa(M.modified),M.gitBranch?` · ${M.gitBranch}`:""]})]},M.sessionId))})]},N.label))]}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx("button",{type:"button",onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary transition-colors hover:bg-surface-2",children:i("common.cancel")})})]})})}const $s=["working","episodic","semantic","procedural"],Oa=["user","feedback","project","reference"];function Fa(r){switch(r){case"user":return"bg-accent/15 text-accent";case"feedback":return"bg-status-warning/15 text-status-warning";case"project":return"bg-status-active/15 text-status-active";default:return"bg-surface-3 text-text-muted"}}function Ua(r){try{return new Date(r).toLocaleDateString()}catch{return"—"}}function Ka({refreshTick:r,recall:t,dreaming:s,onDreamTrigger:n}){ae();const[a,d]=l.useState(null),[c,u]=l.useState("memories"),[p,f]=l.useState("personal"),[g,b]=l.useState([]),[N,M]=l.useState(!1),[C,j]=l.useState(""),[x,y]=l.useState(null),[v,_]=l.useState({}),[A,T]=l.useState(null),[w,E]=l.useState(""),[I,$]=l.useState(""),[S,U]=l.useState(null),[O,J]=l.useState(null),[X,se]=l.useState(""),[P,ne]=l.useState(null),[ke,Ne]=l.useState(!1),ue=l.useRef(null);l.useEffect(()=>{zs().then(d).catch(()=>d(null))},[]);const Se=l.useCallback(async()=>{M(!0),j("");try{b(await Gn(p))}catch{j(i("memorySidebar.loadFailed"))}finally{M(!1)}},[p]);l.useEffect(()=>{(a==null?void 0:a.mode)==="memdir"&&Se()},[a==null?void 0:a.mode,Se,r]),l.useEffect(()=>{c!=="governance"||(a==null?void 0:a.mode)!=="memdir"||Jn().then(J).catch(()=>J(null))},[c,a==null?void 0:a.mode,r]),l.useEffect(()=>{ue.current&&clearTimeout(ue.current);const h=I.trim();if(!h){U(null);return}return ue.current=setTimeout(()=>{Xn(h).then(U).catch(()=>U([]))},300),()=>{ue.current&&clearTimeout(ue.current)}},[I]);const _e=async h=>{if(x===h){y(null);return}if(y(h),!v[h])try{const{content:K}=await xs(h);_(Z=>({...Z,[h]:K}))}catch{_(K=>({...K,[h]:i("memorySidebar.loadFailed")}))}},oe=h=>x===h?e.jsx("pre",{className:"mt-1 max-h-48 overflow-y-auto whitespace-pre-wrap rounded bg-surface-3 p-2 text-[10px] leading-relaxed text-text-secondary",children:v[h]??"…"}):null,ie=async h=>{if(v[h])E(v[h]);else try{const{content:K}=await xs(h);_(Z=>({...Z,[h]:K})),E(K)}catch{E("")}T(h)},Q=async()=>{if(A)try{await ar(A,w),_(h=>({...h,[A]:w})),T(null)}catch{j(i("memorySidebar.updateFailed"))}},ye=async h=>{try{await rr(h),b(K=>K.filter(Z=>Z.path!==h)),y(K=>K===h?null:K)}catch{j(i("memorySidebar.deleteFailed"))}},ge=async h=>{try{await nr(h),await Se()}catch(K){j(K instanceof Error?K.message:i("memorySidebar.promoteFailed"))}},[re,W]=l.useState(!1),[be,Fe]=l.useState(""),[st,V]=l.useState(""),[nt,je]=l.useState("project"),[Ue,rt]=l.useState(""),[Ke,Ce]=l.useState(!1),Le=()=>{W(!0),Fe(""),V(""),je("project"),rt("")},me=be.trim().length>0&&Ue.trim().length>0&&!Ke,bt=async()=>{if(me){Ce(!0),j("");try{await sr({scope:p,name:be.trim(),description:st.trim()||void 0,type:nt,content:Ue}),W(!1),await Se()}catch(h){j(h instanceof Error?h.message:i("memorySidebar.createFailed"))}finally{Ce(!1)}}},at=()=>{n==null||n()},ot=l.useCallback(async()=>{const h=X.trim();if(!(!h||ke)){Ne(!0),ne(null);try{ne(await Zn(h,5))}catch{ne([])}finally{Ne(!1)}}},[X,ke]),le=(a==null?void 0:a.teamEnabled)===!0,Te=a==null?void 0:a.automation,Ee=le&&c==="memories"&&!I;return e.jsxs("div",{className:"flex h-full flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[e.jsx("button",{type:"button",onClick:()=>u("memories"),className:`rounded-md px-2 py-1 text-xs font-medium ${c==="memories"?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2"}`,children:i("memorySidebar.memoriesTab")}),e.jsx("button",{type:"button",onClick:()=>u("governance"),className:`rounded-md px-2 py-1 text-xs font-medium ${c==="governance"?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2"}`,children:i("memorySidebar.governanceTab")}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[(a==null?void 0:a.mode)==="memdir"&&c==="memories"&&!I&&e.jsx("button",{type:"button",onClick:re?()=>W(!1):Le,disabled:p==="team"&&!le,className:"rounded p-1 text-text-secondary hover:bg-surface-2 hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-50",title:i("memorySidebar.new"),children:re?e.jsx(ms,{className:"h-3 w-3"}):e.jsx(er,{className:"h-3 w-3"})}),e.jsx(yt,{className:"h-3 w-3 text-text-muted"}),e.jsx("input",{value:I,onChange:h=>$(h.target.value),placeholder:i("memorySidebar.searchPlaceholder"),title:i("memorySidebar.searchHint"),className:"w-28 bg-transparent text-xs text-text-primary placeholder:text-text-muted focus:outline-none"})]})]}),C&&e.jsx("p",{className:"px-3 py-1 text-xs text-status-error",children:C}),Te&&Te.mode!=="normal"&&e.jsx("div",{className:"border-b border-status-warning/30 bg-status-warning/10 px-3 py-1.5 text-xs text-status-warning",children:Te.mode==="sa"?i("memorySidebar.saModeBanner"):i("memorySidebar.poorModeBanner")}),S!==null&&e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:S.length===0?e.jsx("p",{className:"py-8 text-center text-xs text-text-muted",children:i("memorySidebar.noResults")}):e.jsx("ul",{className:"space-y-1",children:S.map(h=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>void _e(h.path),className:"w-full rounded-md px-2 py-1.5 text-left hover:bg-surface-2",children:[e.jsx("span",{className:"block truncate text-xs font-medium text-text-primary",children:h.name}),e.jsx("ul",{className:"mt-0.5 space-y-0.5",children:h.matches.map((K,Z)=>e.jsxs("li",{className:"flex gap-1.5 text-[10px] leading-relaxed",children:[e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:K.line===0?"file":`L${K.line}`}),e.jsx("span",{className:"truncate text-text-secondary",children:K.text})]},Z))})]}),oe(h.path)]},h.path))})}),S===null&&c==="memories"&&e.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[t&&t.hits.length>0&&e.jsxs("div",{className:"mb-2 rounded-md border border-brand/30 bg-brand/5 p-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-brand-text",children:i("memorySidebar.recallTitle")}),e.jsxs("p",{className:"mb-1 truncate text-[10px] text-text-muted",title:t.query,children:[i("memorySidebar.recallQuery"),": ",t.query]}),e.jsx("ul",{className:"space-y-0.5",children:t.hits.slice(0,5).map(h=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>void _e(h.path),className:"flex w-full items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-xs hover:bg-surface-2",title:h.path,children:[e.jsx("span",{className:"truncate text-text-secondary",children:h.path.replace(/^team\//,"").replace(/\.md$/,"")}),h.score!==void 0&&e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:[(h.score*100).toFixed(0),"%"]})]}),oe(h.path)]},h.path))})]}),Ee&&e.jsx("div",{className:"mb-2 flex rounded-md bg-surface-2 p-0.5 text-xs",children:["personal","team"].map(h=>e.jsx("button",{type:"button",onClick:()=>f(h),className:`flex-1 rounded px-2 py-1 ${p===h?"bg-brand-light text-white":"text-text-muted"}`,children:h==="personal"?i("memorySidebar.personal"):i("memorySidebar.team")},h))}),p==="team"&&le&&!re&&e.jsx("p",{className:"mb-2 px-1 text-[10px] leading-relaxed text-text-muted",children:i("memorySidebar.teamHint")}),re&&e.jsxs("div",{className:"mb-2 space-y-1.5 rounded-md border border-border bg-surface-2 p-2",children:[e.jsx("input",{value:be,onChange:h=>Fe(h.target.value),placeholder:i("memorySidebar.create.namePlaceholder"),className:"w-full rounded bg-surface-3 px-2 py-1 text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsx("input",{value:st,onChange:h=>V(h.target.value),placeholder:i("memorySidebar.create.descriptionPlaceholder"),className:"w-full rounded bg-surface-3 px-2 py-1 text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("select",{value:nt,onChange:h=>je(h.target.value),className:"flex-shrink-0 rounded bg-surface-3 px-1.5 py-1 text-xs text-text-primary focus:outline-none",children:Oa.map(h=>e.jsx("option",{value:h,children:h},h))}),e.jsx("span",{className:"truncate text-[10px] text-text-muted",children:p==="team"?i("memorySidebar.team"):i("memorySidebar.personal")})]}),e.jsx("textarea",{value:Ue,onChange:h=>rt(h.target.value),placeholder:i("memorySidebar.create.contentPlaceholder"),rows:6,className:"w-full rounded bg-surface-3 p-2 text-[10px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void bt(),disabled:!me,className:"rounded bg-accent px-2 py-0.5 text-[10px] font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50",children:Ke?"…":i("memorySidebar.new")}),e.jsx("button",{type:"button",onClick:()=>W(!1),className:"rounded px-2 py-0.5 text-[10px] text-text-muted hover:bg-surface-3",children:i("memorySidebar.cancel")})]})]}),N?e.jsx("div",{className:"space-y-2",children:[0,1,2].map(h=>e.jsx("div",{className:"h-12 animate-pulse rounded-md bg-surface-2"},h))}):g.length===0?e.jsxs("div",{className:"py-10 text-center",children:[e.jsx(Dt,{className:"mx-auto h-6 w-6 text-text-muted/40"}),e.jsx("p",{className:"mt-2 text-xs text-text-muted",children:i("memorySidebar.empty")})]}):e.jsx("ul",{className:"space-y-1",children:g.map(h=>e.jsxs("li",{className:"group rounded-md hover:bg-surface-2",children:[e.jsxs("button",{type:"button",onClick:()=>void _e(h.path),className:"w-full px-2 py-1.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-xs font-medium text-text-primary",children:h.name}),h.type&&e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[9px] font-medium ${Fa(h.type)}`,children:h.type}),e.jsx("span",{className:"ml-auto flex-shrink-0 text-[9px] text-text-muted",children:Ua(h.mtimeMs)})]}),h.description&&e.jsx("p",{className:"mt-0.5 truncate text-[10px] text-text-muted",children:h.description})]}),e.jsxs("div",{className:"flex items-center gap-0.5 px-2 pb-1 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx("button",{type:"button",onClick:()=>void ie(h.path),className:"rounded p-1 text-text-secondary hover:bg-surface-3 hover:text-text-primary",title:i("memorySidebar.edit"),children:e.jsx(ms,{className:"h-3 w-3"})}),h.scope==="personal"&&le&&e.jsx("button",{type:"button",onClick:()=>void ge(h.path),className:"rounded p-1 text-text-secondary hover:bg-surface-3 hover:text-text-primary",title:i("memorySidebar.promote"),children:e.jsx(tr,{className:"h-3 w-3"})}),e.jsx("button",{type:"button",onClick:()=>void ye(h.path),className:"ml-auto rounded p-1 text-text-secondary hover:bg-status-error/10 hover:text-status-error",title:i("memorySidebar.delete"),children:e.jsx(Ws,{className:"h-3 w-3"})})]}),x===h.path&&A!==h.path&&e.jsx("pre",{className:"mx-2 mb-2 max-h-48 overflow-y-auto whitespace-pre-wrap rounded bg-surface-3 p-2 text-[10px] leading-relaxed text-text-secondary",children:v[h.path]??"…"}),x===h.path&&A===h.path&&e.jsxs("div",{className:"mx-2 mb-2",children:[e.jsx("textarea",{value:w,onChange:K=>E(K.target.value),rows:8,className:"w-full rounded bg-surface-3 p-2 text-[10px] leading-relaxed text-text-primary focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsxs("div",{className:"mt-1 flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void Q(),className:"rounded bg-accent px-2 py-0.5 text-[10px] font-medium text-white hover:bg-accent/90",children:i("memorySidebar.save")}),e.jsx("button",{type:"button",onClick:()=>T(null),className:"rounded px-2 py-0.5 text-[10px] text-text-muted hover:bg-surface-2",children:i("memorySidebar.cancel")})]})]})]},h.path))})]}),S===null&&c==="governance"&&e.jsx("div",{className:"flex-1 overflow-y-auto p-3 text-xs",children:O?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("button",{type:"button",disabled:s||!O.automation.autoDream,onClick:at,className:"inline-flex w-full items-center justify-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(Cr,{className:"h-3.5 w-3.5"}),s?i("memorySidebar.dreaming"):i("memorySidebar.dream")]}),!O.automation.autoDream&&e.jsx("p",{className:"mt-1 text-center text-[10px] text-text-muted",children:i("memorySidebar.dreamDisabled")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:i("memorySidebar.recallTest.title")}),e.jsx("p",{className:"mb-1.5 text-[10px] leading-relaxed text-text-muted",children:i("memorySidebar.recallTest.hint")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("input",{value:X,onChange:h=>se(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.nativeEvent.isComposing&&ot()},placeholder:i("memorySidebar.recallTest.placeholder"),className:"min-w-0 flex-1 rounded-md bg-surface-2 px-2 py-1 text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-brand/40"}),e.jsx("button",{type:"button",onClick:()=>void ot(),disabled:ke||!X.trim(),className:"flex-shrink-0 rounded-md bg-accent px-2.5 py-1 text-xs font-medium text-white hover:bg-accent/90 disabled:cursor-not-allowed disabled:opacity-50",children:ke?i("memorySidebar.recallTest.running"):i("memorySidebar.recallTest.run")})]}),P!==null&&e.jsx("ul",{className:"mt-1.5 space-y-0.5 rounded-md bg-surface-2 p-2",children:P.length===0?e.jsx("li",{className:"text-[10px] text-text-muted",children:i("memorySidebar.recallTest.noResults")}):P.map(h=>e.jsxs("li",{children:[e.jsxs("button",{type:"button",onClick:()=>void _e(h.path),className:"flex w-full items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-xs hover:bg-surface-3",title:h.path,children:[e.jsx("span",{className:"truncate text-text-secondary",children:h.path.replace(/^team\//,"").replace(/\.md$/,"")}),e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:[(h.score*100).toFixed(0),"%",h.confidence!==void 0?` · conf ${h.confidence.toFixed(2)}`:""]})]}),oe(h.path)]},h.path))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:i("memorySidebar.layers")}),e.jsx("ul",{className:"space-y-1",children:$s.map(h=>{const K=O.layers[h],Z=Math.max(...$s.map(Be=>O.layers[Be]),1);return e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-16 flex-shrink-0 text-text-secondary",children:h}),e.jsx("div",{className:"h-1.5 flex-1 overflow-hidden rounded-full bg-surface-2",children:e.jsx("div",{className:"h-full rounded-full bg-brand",style:{width:`${K/Z*100}%`}})}),e.jsx("span",{className:"w-6 text-right text-text-muted",children:K})]},h)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:i("memorySidebar.health")}),e.jsxs("div",{className:"rounded-md bg-surface-2 p-2 text-[10px] text-text-secondary",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:i("memorySidebar.total")}),e.jsx("span",{children:O.health.totalMemories})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:i("memorySidebar.capacity")}),e.jsxs("span",{className:O.health.capacity.tier==="critical"?"text-status-error":O.health.capacity.tier==="warning"?"text-status-warning":"text-status-active",children:[O.health.capacity.utilizationPct.toFixed(0),"% · ",O.health.capacity.tier]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:i("memorySidebar.avgConfidence")}),e.jsx("span",{children:O.health.avgConfidence.toFixed(2)})]})]})]}),O.alerts.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:[i("memorySidebar.alerts")," (",O.alerts.length,")"]}),e.jsx("ul",{className:"space-y-1 rounded-md bg-status-warning/5 p-2",children:O.alerts.slice(-8).reverse().map((h,K)=>e.jsx("li",{className:"text-[10px] leading-relaxed text-text-secondary",children:h},K))})]}),O.conflicts&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-status-warning",children:i("memorySidebar.conflicts")}),e.jsx("pre",{className:"max-h-40 overflow-y-auto whitespace-pre-wrap rounded-md bg-surface-2 p-2 text-[10px] leading-relaxed text-text-secondary",children:O.conflicts})]})]}):e.jsx("p",{className:"py-10 text-center text-text-muted",children:i("memorySidebar.loadFailed")})})]})}class La{constructor(t,s,n,a){q(this,"pending",null);this.current=t,this.apply=s,this.send=n,this.onError=a}set(t){if(t===this.current)return;const s=this.current;this.current=t,this.pending={requestId:null,previous:s},this.apply(t);try{Promise.resolve(this.send(t)).then(n=>{this.pending&&(this.pending.requestId=n)}).catch(n=>{this.rollback(s,Ds(n),"send")})}catch(n){this.rollback(s,Ds(n),"send")}}handleControlResponse(t){const s=this.pending;if(!s||s.requestId!==t.requestId)return!1;const{previous:n}=s;return this.pending=null,t.subtype==="error"&&this.rollback(n,t.error??"","response"),!0}sync(t){t!==this.current&&(this.current=t,this.apply(t),this.pending=null)}adoptExternal(t){this.pending||t!==this.current&&(this.current=t)}getCurrent(){return this.current}rollback(t,s,n){var a;this.pending=null,this.current=t,this.apply(t),s&&((a=this.onError)==null||a.call(this,s,n))}}function Ds(r){return r instanceof Error?r.message:String(r)}function pt(r){const t=l.useRef(r);t.current=r;const s=l.useRef(null);s.current||(s.current=new La(r.value,a=>t.current.apply(a),a=>t.current.send(a),(a,d)=>{var c,u;return(u=(c=t.current).onError)==null?void 0:u.call(c,a,d)}));const n=s.current;return l.useEffect(()=>{n.adoptExternal(r.value)}),l.useMemo(()=>({set:a=>n.set(a),handleControlResponse:a=>n.handleControlResponse(a),sync:a=>n.sync(a)}),[n])}const sn="rcs_context_usage_";function nn(){try{if(typeof localStorage<"u")return localStorage}catch{}return null}function qs(){return{totalTokens:0,rawMaxTokens:0,percentage:0}}function Ba(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const t=r,{totalTokens:s,rawMaxTokens:n,percentage:a}=t;if(typeof s!="number"||typeof n!="number"||typeof a!="number")return null;const d=t.categories,c=Array.isArray(d)?d.filter(u=>!!u&&typeof u=="object"&&typeof u.name=="string").map(u=>({name:u.name,tokens:typeof u.tokens=="number"?u.tokens:0,...u.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:n,percentage:a,...typeof t.model=="string"&&t.model?{model:t.model}:{},...c&&c.length>0?{categories:c}:{}}}function Ha(r,t=nn()){if(!t||!r)return null;try{const s=t.getItem(sn+r);return s?Ba(JSON.parse(s)):null}catch{return null}}function Qa(r,t,s=nn()){if(!(!s||!r))try{s.setItem(sn+r,JSON.stringify(t))}catch{}}function Wa(r){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${r}`}function za(r){const t=Wa(r),s=ir(),n=s?{proxyUrl:t,token:s}:{proxyUrl:t};return new or(n)}const Ae=[{value:"default",labelKey:"session.mode.default",descKey:"session.mode.defaultDesc"},{value:"acceptEdits",labelKey:"session.mode.acceptEdits",descKey:"session.mode.acceptEditsDesc"},{value:"plan",labelKey:"session.mode.plan",descKey:"session.mode.planDesc"},{value:"bypassPermissions",labelKey:"session.mode.bypass",descKey:"session.mode.bypassDesc"}],Ps="rcs_permission_mode";function Ie(r){return r<1e3?String(r):r<1e6?`${(r/1e3).toFixed(1)}k`:`${(r/1e6).toFixed(1)}M`}function Ya(r){const t=Ae.findIndex(s=>s.value===r);return Ae[(t+1+Ae.length)%Ae.length].value}const gt=[{value:"off",labelKey:"session.thinking.off",descKey:"session.thinking.offDesc",label:void 0,description:void 0,tokens:0},{value:"on",labelKey:"session.thinking.on",descKey:"session.thinking.onDesc",label:void 0,description:void 0,tokens:null},{value:"8192",labelKey:void 0,descKey:void 0,label:"8k",description:"8192 tokens",tokens:8192},{value:"16384",labelKey:void 0,descKey:void 0,label:"16k",description:"16384 tokens",tokens:16384},{value:"32768",labelKey:void 0,descKey:void 0,label:"32k",description:"32768 tokens",tokens:32768}],Os="rcs_thinking_budget",$t=[{value:"auto",effort:void 0,labelKey:"session.effort.auto",descKey:"session.effort.autoDesc",label:void 0},{value:"low",effort:"low",labelKey:void 0,descKey:"session.effort.lowDesc",label:"low"},{value:"medium",effort:"medium",labelKey:void 0,descKey:"session.effort.mediumDesc",label:"medium"},{value:"high",effort:"high",labelKey:void 0,descKey:"session.effort.highDesc",label:"high"},{value:"xhigh",effort:"xhigh",labelKey:void 0,descKey:"session.effort.xhighDesc",label:"xhigh"},{value:"max",effort:"max",labelKey:void 0,descKey:"session.effort.maxDesc",label:"max"}],Fs=r=>r.labelKey?i(r.labelKey):r.label,Us=r=>r.labelKey?i(r.labelKey):r.label,Ks="rcs_effort",Ls=[{value:"normal",descKey:"session.tokenMode.normalDesc"},{value:"poor",descKey:"session.tokenMode.poorDesc"},{value:"sa",descKey:"session.tokenMode.saDesc"}],Bs="rcs_token_mode";function Va(r){return r!=null&&r.capabilities?r.capabilities:r?{file_search:!0,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!0,stop_task:!0,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!0,mcp_management:!0,remote_settings:!0,rewind:!0,resume:!0,set_effort:!0,set_token_mode:!1,side_question:!0}:{file_search:!1,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!1,stop_task:!1,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!1,mcp_management:!1,remote_settings:!1,rewind:!1,resume:!1,set_effort:!1,set_token_mode:!1,side_question:!1}}function Ga({budget:r,onBudgetChange:t,disabled:s}){const[n,a]=l.useState(!1),d=gt.find(c=>c.value===r);return e.jsxs(Je,{open:n,onOpenChange:a,children:[e.jsx(Xe,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:i("session.thinking.title"),children:[e.jsx(Dt,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?Us(d):i("session.thinking.fallback")}),n?e.jsx(Ze,{className:"h-3 w-3"}):e.jsx(et,{className:"h-3 w-3"})]})}),e.jsx(tt,{className:"w-64 p-1",align:"start",children:gt.map(c=>e.jsxs("button",{type:"button",onClick:()=>{t(c.value,c.tokens),a(!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:r===c.value&&e.jsx($e,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:Us(c)}),e.jsx("div",{className:"text-xs text-text-muted",children:c.descKey?i(c.descKey):c.description})]})]},c.value))})]})}function Ja({effort:r,onEffortChange:t,disabled:s}){const[n,a]=l.useState(!1),d=$t.find(c=>c.value===r);return e.jsxs(Je,{open:n,onOpenChange:a,children:[e.jsx(Xe,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:i("session.effort.title"),children:[e.jsx(Or,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?Fs(d):i("session.effort.fallback")}),n?e.jsx(Ze,{className:"h-3 w-3"}):e.jsx(et,{className:"h-3 w-3"})]})}),e.jsx(tt,{className:"w-64 p-1",align:"start",children:$t.map(c=>e.jsxs("button",{type:"button",onClick:()=>{t(c.value),a(!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:r===c.value&&e.jsx($e,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:Fs(c)}),e.jsx("div",{className:"text-xs text-text-muted",children:i(c.descKey)})]})]},c.value))})]})}function Xa({mode:r,onModeChange:t,disabled:s}){const[n,a]=l.useState(!1),d=Ls.find(c=>c.value===r);return e.jsxs(Je,{open:n,onOpenChange:a,children:[e.jsx(Xe,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:i("session.tokenMode.title"),children:[e.jsx(Dr,{className:"h-3 w-3"}),e.jsx("span",{className:`max-w-24 truncate ${r!=="normal"?"font-medium text-brand-text":""}`,children:d?i(`session.tokenMode.${d.value}`):i("session.tokenMode.fallback")}),n?e.jsx(Ze,{className:"h-3 w-3"}):e.jsx(et,{className:"h-3 w-3"})]})}),e.jsx(tt,{className:"w-64 p-1",align:"start",children:Ls.map(c=>e.jsxs("button",{type:"button",onClick:()=>{t(c.value),a(!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:r===c.value&&e.jsx($e,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:i(`session.tokenMode.${c.value}`)}),e.jsx("div",{className:"text-xs text-text-muted",children:i(c.descKey)})]})]},c.value))})]})}const Za=new Set(["Free space","Autocompact buffer","Compact buffer"]),Hs=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function eo({usage:r}){const t=Math.min(100,Math.max(0,r.percentage)),s=t>=80,n=(r.categories??[]).filter(u=>!u.isDeferred&&!Za.has(u.name)),a=(r.categories??[]).filter(u=>u.isDeferred),d=n.reduce((u,p)=>u+p.tokens,0),c=[`${H("session.context.tooltip",{used:Ie(r.totalTokens),max:Ie(r.rawMaxTokens)})}${r.model?` · ${r.model}`:""}`,...n.slice(0,8).map(u=>`${u.name}: ${Ie(u.tokens)}`),...a.slice(0,3).map(u=>`${u.name}${i("session.context.deferredSuffix")}: ${Ie(u.tokens)}`)];return e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-text-muted font-mono",title:c.join(`
|
|
82
|
+
`),children:[e.jsx("span",{className:"relative flex h-1.5 w-16 overflow-hidden rounded-full bg-surface-3",children:n.length>0?n.map((u,p)=>e.jsx("span",{className:s&&p===0?"bg-status-warning":Hs[p%Hs.length],style:{width:`${Math.min(100,Math.max(0,d>0?u.tokens/d*t:0))}%`}},u.name)):e.jsx("span",{className:`absolute inset-y-0 left-0 rounded-full transition-all ${s?"bg-status-warning":"bg-brand/70"}`,style:{width:`${t}%`}})}),e.jsxs("span",{children:[t,"%"]})]})}function to({models:r,currentModelId:t,onSelect:s,disabled:n}){const[a,d]=l.useState(!1),c=r.find(f=>f.modelId===t)??null,u=r.length>0,p=async f=>{s(f.modelId),d(!1)};return e.jsxs(Je,{open:a,onOpenChange:u?d:void 0,children:[e.jsx(Xe,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n||!u,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:i("session.model.title"),children:[e.jsx(Gs,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(c==null?void 0:c.name)??t??i("session.model.title")}),a?e.jsx(Ze,{className:"h-3 w-3"}):e.jsx(et,{className:"h-3 w-3"})]})}),e.jsx(tt,{className:"w-72 p-0",align:"start",children:e.jsx(br,{models:r,currentModelId:t,onSelect:p,showSearch:r.length>5})})]})}function so({mode:r,onModeChange:t,disabled:s}){const[n,a]=l.useState(!1),d=Ae.find(c=>c.value===r);return e.jsxs(Je,{open:n,onOpenChange:a,children:[e.jsx(Xe,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:i("session.mode.title"),children:[e.jsx(gr,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?i(d.labelKey):r}),n?e.jsx(Ze,{className:"h-3 w-3"}):e.jsx(et,{className:"h-3 w-3"})]})}),e.jsx(tt,{className:"w-64 p-1",align:"start",children:Ae.map(c=>e.jsxs("button",{type:"button",onClick:()=>{t(c.value),a(!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:r===c.value&&e.jsx($e,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:i(c.labelKey)}),e.jsx("div",{className:"text-xs text-text-muted",children:i(c.descKey)})]})]},c.value))})]})}function jo({sessionId:r,onBack:t}){var is;ae();const[s,n]=l.useState(null),[a,d]=l.useState(null),[c,u]=l.useState(""),[p,f]=l.useState(!1),[g,b]=l.useState(!1),[N,M]=l.useState(!1),[C,j]=l.useState(!1),[x,y]=l.useState(!1),[v,_]=l.useState(!1),[A,T]=l.useState(""),[w,E]=l.useState(0),I=l.useRef(null),[$,S]=l.useState({text:"",nonce:0}),[U,O]=l.useState(!1),[J,X]=l.useState(!1),[se,P]=l.useState(!1),[ne,ke]=l.useState(!1),[Ne,ue]=l.useState(0),[Se,_e]=l.useState(0),[oe,ie]=l.useState([]),[Q,ye]=l.useState(!1),[ge,re]=l.useState([]),[W,be]=l.useState(null),[Fe,st]=l.useState(()=>It()),[V,nt]=l.useState(null),[je,Ue]=l.useState(()=>localStorage.getItem(Os)||"off"),[rt,Ke]=l.useState(()=>Ha(r)),[Ce,Le]=l.useState(!0),[me,bt]=l.useState(null),[at,ot]=l.useState(null),[le,Te]=l.useState(null),[Ee,h]=l.useState([]),[K,Z]=l.useState(!1),[Be,qt]=l.useState(""),jt=l.useRef(null),[it,rn]=l.useState(()=>localStorage.getItem(Ps)||"default"),[Pt,Ot]=l.useState(null),He=l.useRef(null),[Ft,Ut]=l.useState(null),Qe=l.useRef(null),ce=l.useRef(null),Kt=l.useRef(oe);Kt.current=oe;const lt=l.useRef(null);lt.current||(lt.current=new Rr(Ar()));const Lt=l.useRef(r);Lt.current=(s==null?void 0:s.title)||r,l.useEffect(()=>{var o;(o=lt.current)==null||o.reset()},[r]);const de=l.useCallback(o=>{Ot(o),He.current&&clearTimeout(He.current),He.current=setTimeout(()=>Ot(null),5e3)},[]),xe=l.useCallback(o=>{Ut(o),Qe.current&&clearTimeout(Qe.current),Qe.current=setTimeout(()=>Ut(null),5e3)},[]),ct=pt({value:it,apply:o=>{rn(o);try{localStorage.setItem(Ps,o)}catch{}},send:o=>{const m=ce.current;return m?m.setPermissionMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,m)=>{console.error("[SessionDetail] set permission mode failed:",o),de(m==="send"?H("session.mode.switchFailedRequest",{message:o}):o||i("session.mode.switchFailed"))}}),wt=l.useCallback(o=>ct.set(o),[ct]),[Bt,an]=l.useState(()=>localStorage.getItem(Bs)||"normal"),dt=pt({value:Bt,apply:o=>{an(o);try{localStorage.setItem(Bs,o)}catch{}},send:o=>{const m=ce.current;return m?m.setTokenMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,m)=>{console.error("[SessionDetail] set token mode failed:",o),de(m==="send"?H("session.tokenMode.failedRequest",{message:o}):o||i("session.tokenMode.failed"))}}),vt=pt({value:je,apply:o=>{Ue(o);try{localStorage.setItem(Os,o)}catch{}},send:o=>{var R;const m=ce.current;if(!m)return Promise.reject(new Error("adapter not ready"));const k=((R=gt.find(D=>D.value===o))==null?void 0:R.tokens)??null;return m.setThinkingBudget(k)},onError:(o,m)=>{console.error("[SessionDetail] set thinking budget failed:",o),de(m==="send"?H("session.thinking.failedRequest",{message:o}):o||i("session.thinking.failed"))}}),F=l.useMemo(()=>new ia(r,ie,{onStatusChange:o=>{var m;d(o),ye(o==="running"||o==="requires_action"),(m=lt.current)==null||m.onStatus(o,Lt.current)},onError:o=>{console.error("[RCSChatAdapter] error:",o)},onPermissionRequest:o=>{re(m=>m.some(k=>k.requestId===o.requestId)?m:[...m,o])},onModelsStateChange:o=>{be(o)},onSubagentUpdate:o=>{st(o)},onControlResponse:o=>{vt.handleControlResponse(o)||dt.handleControlResponse(o)||Yt.handleControlResponse(o)||ct.handleControlResponse(o)},onPermissionModeChange:o=>{ct.sync(o)},onUsageChange:o=>{bt(m=>({inputTokens:Math.max((m==null?void 0:m.inputTokens)??0,o.inputTokens),outputTokens:Math.max((m==null?void 0:m.outputTokens)??0,o.outputTokens),totalCostUsd:o.totalCostUsd??(m==null?void 0:m.totalCostUsd)??null}))},onWorkerInfoChange:o=>{nt(m=>JSON.stringify(m)===JSON.stringify(o)?m:o)},onTurnStart:o=>{ot(o)},onElicitationRequest:o=>{Te(o)}}),[r,de]);l.useEffect(()=>(ce.current=F,()=>{F.disconnect()}),[F]);const L=l.useMemo(()=>Va(V),[V]),Ht=l.useRef(!1);l.useEffect(()=>{var k;if(!L.set_max_thinking_tokens||Ht.current)return;const o=ce.current;if(!o)return;const m=((k=gt.find(R=>R.value===je))==null?void 0:k.tokens)??null;o.setThinkingBudget(m).then(()=>{Ht.current=!0}).catch(R=>console.error("[SessionDetail] reconcile thinking budget failed:",R))},[L.set_max_thinking_tokens,je,V]);const Qt=L.stop_task?o=>{F.stopSubagent(o).then(m=>{m.ok||xe(m.error||i("session.stopTask.failed"))})}:void 0,Wt=l.useRef(!1);l.useEffect(()=>{if(!L.set_token_mode||Wt.current)return;const o=ce.current;o&&(Wt.current=!0,o.getRemoteSettings().then(m=>{const k=m==null?void 0:m.applied.tokenMode;(k==="normal"||k==="poor"||k==="sa")&&dt.sync(k)}).catch(m=>console.error("[SessionDetail] reconcile token mode failed:",m)))},[L.set_token_mode,dt]);const on=ae(),kt=l.useMemo(()=>lr((V==null?void 0:V.commands)??[],(V==null?void 0:V.skills)??[]),[V,on]),Me=l.useMemo(()=>cr(oe,A),[oe,A]),ln=l.useCallback(o=>vt.set(o),[vt]),[zt,cn]=l.useState(()=>localStorage.getItem(Ks)||"auto"),Yt=pt({value:zt,apply:o=>{cn(o);try{localStorage.setItem(Ks,o)}catch{}},send:o=>{var R;const m=ce.current;if(!m)return Promise.reject(new Error("adapter not ready"));const k=(R=$t.find(D=>D.value===o))==null?void 0:R.effort;return m.setEffort(k)},onError:(o,m)=>{console.error("[SessionDetail] set effort failed:",o),de(m==="send"?H("session.effort.failedRequest",{message:o}):o||i("session.effort.failed"))}}),Nt=l.useCallback(()=>{var o;L.get_context_usage&&((o=ce.current)==null||o.getContextUsage().then(m=>{m&&(Ke(m),Qa(r,m))}).catch(()=>{}).finally(()=>Le(!1)))},[L,r]);l.useEffect(()=>{if(!L.get_context_usage)return;Nt();const o=setInterval(Nt,6e4);return()=>clearInterval(o)},[L,Q,Nt]),l.useEffect(()=>{V&&!L.get_context_usage&&Le(!1)},[V,L]),l.useEffect(()=>{if(!Ce)return;const o=setTimeout(()=>Le(!1),1e4);return()=>clearTimeout(o)},[Ce]);const Vt=l.useRef(se);Vt.current=se,l.useEffect(()=>he.onEvent(m=>{m.type!=="artifact_created"&&m.type!=="artifact_updated"||(Vt.current&&_e(k=>k+1),ue(k=>k+1))}),[]);const[Gt,ut]=l.useState(0),Jt=l.useRef(ne);Jt.current=ne;const[We,Xt]=l.useState(null),[pe,dn]=l.useState(!1),[St,Zt]=l.useState(0),[un,mn]=l.useState(void 0),_t=l.useRef(pe);_t.current=pe,l.useEffect(()=>he.onEvent(m=>{m.type==="memory_synced"&&Jt.current&&ut(k=>k+1)}),[]),l.useEffect(()=>{zs().then(o=>Xt(o.mode)).catch(()=>Xt("sqlite"))},[]),l.useEffect(()=>he.onEvent(m=>{var k,R;if(m.type==="memory_changed")_t.current?ut(D=>D+1):Zt(D=>D+1);else if(m.type==="memory_recall"){const D=Array.isArray((k=m.payload)==null?void 0:k.hits)?m.payload.hits:void 0;D&&mn({query:typeof((R=m.payload)==null?void 0:R.query)=="string"?m.payload.query:"",hits:D}),_t.current&&ut(Y=>Y+1)}}),[]),l.useEffect(()=>{pe&&Zt(0)},[pe]);const[ze,xn]=l.useState("idle");l.useEffect(()=>he.onStateChange(m=>xn(m)),[]),l.useEffect(()=>{se&&ue(0)},[se]),l.useEffect(()=>{let o=!1;async function m(){u("");try{const k=await ys(r);if(o)return;n(k),d(k.status),ht(k.status)&&F.markClosed(),ye(k.status==="running"||k.status==="requires_action")}catch(k){if(o)return;u(k instanceof Error?k.message:i("session.loadFailed"));return}try{await F.init()}catch(k){console.warn("Failed to init adapter:",k)}}return m(),()=>{o=!0}},[r,F]);const B=ht(a),es=l.useRef(a);es.current=a,l.useEffect(()=>{if(B)return;let o=!1;const k=setInterval(async()=>{try{const R=await ys(r);if(o||R.status===es.current)return;ht(R.status)&&F.markClosed(),d(R.status),ye(R.status==="running"||R.status==="requires_action")}catch{}},6e4);return()=>{o=!0,clearInterval(k)}},[r,B,F]);const z=(s==null?void 0:s.access_level)==="read",ts=rt??(Ce&&!B&&!z?qs():null),Ct=l.useCallback(()=>{ie([]),Ke(qs()),ps(r).catch(o=>{console.warn("[SessionDetail] Failed to clear session history:",o)})},[r]),Ye=l.useCallback(async(o,m)=>{const k=ce.current;if(!k||B)return;if(o.sessionId===r){ie(D=>[...D,{type:"command_output",id:`cmd-resume-${Date.now()}`,commandName:"resume",inputText:m??"/resume",title:"Resume",subtitle:i("session.resume.title"),outputText:i("session.resume.currentBlocked"),variant:"error"}]);return}const R=(D,Y="default")=>ie(we=>[...we,{type:"command_output",id:`cmd-resume-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,commandName:"resume",inputText:m??`/resume ${o.sessionId.slice(0,8)}`,title:"Resume",subtitle:i("session.resume.title"),outputText:D,variant:Y}]);R(H("session.resume.restoring",{title:o.title??""}));try{await ps(r),ie([]);const D=await k.resumeSession(o.sessionId);R(D.title?H("session.resume.restoredWithTitle",{count:D.messageCount,title:D.title}):H("session.resume.restored",{count:D.messageCount}))}catch(D){R(H("session.resume.failed",{message:D instanceof Error?D.message:String(D)}),"error")}},[B,r]),pn=l.useCallback(async()=>{if(s!=null&&s.environment_id)try{const o=await dr({environment_id:s.environment_id});window.location.href=`/code/${o.id}?resumeFrom=${r}`}catch(o){xe(H("session.createFailedWithReason",{message:o instanceof Error?o.message:String(o)}))}},[s,r,xe]),hn=l.useRef(new URLSearchParams(window.location.search).get("resumeFrom")),ss=l.useRef(!1);l.useEffect(()=>{const o=hn.current;!o||ss.current||!V||!L.resume||(ss.current=!0,window.history.replaceState({},"",window.location.pathname),Ye({sessionId:o,title:o.slice(0,8),modified:0},null))},[V,L.resume,Ye]);const Re=l.useCallback(async o=>{const m=o.text.trim(),k=o.images&&o.images.length>0||o.attachments&&o.attachments.length>0;if(!m&&!k||B)return;const R=/^\/resume(?:\s+(.*))?$/.exec(m);if(R){const Y=(R[1]??"").trim();if(!L.resume){ie(we=>[...we,{type:"user_message",id:`user-${Date.now()}`,content:m},{type:"command_output",id:`cmd-${Date.now()}`,commandName:"resume",inputText:m,title:"Resume",subtitle:i("session.resume.title"),outputText:i("session.resume.unsupported"),variant:"error"}]);return}Y?await Ye({sessionId:Y,title:Y,modified:0},m):y(!0);return}const D=await ur(m,{sessionId:r,availableCommands:kt,availableModels:(W==null?void 0:W.availableModels)??[],currentModel:W?{modelId:W.currentModelId,name:W.currentModelId}:null,supportsImages:!0,entries:Kt.current,setModel:async Y=>{await ee(r,{type:"control_request",request:{subtype:"set_model",model:Y}}),be(we=>we&&{...we,currentModelId:Y})},onNewSession:()=>{ie([])}}).catch(()=>null);if(D){if(ft("[SessionDetail] local command result",D),"clearEntries"in D&&D.clearEntries){Ct();return}if("newSession"in D&&D.newSession){Ct();return}if("userEntry"in D){ie(Y=>[...Y,D.userEntry,D.cmdEntry]);return}}ye(!0);try{await F.sendMessage(m,o.images,o.attachments)}catch(Y){if(console.error("Send failed:",Y),Y instanceof mr&&Y.type==="session_closed"){d("archived"),F.markClosed(),xe(i("session.closedSendBlocked"));return}xe(`${i("session.sendFailed")}${Y instanceof Error?`: ${Y.message}`:""}`)}},[F,B,r,W,kt,Ct,xe,Ye,L]),fn=l.useCallback(o=>{if(Q){h(m=>[...m,o]);return}Re(o)},[Q,Re]),[Tt,ns]=l.useState(!1),yn=l.useCallback(()=>{Q||(ns(!0),Re({text:"/dream"}))},[Q,Re]);l.useEffect(()=>{!Q&&Tt&&(ns(!1),ut(o=>o+1))},[Q,Tt]);const Et=l.useRef(!1);l.useEffect(()=>{if(B){h(m=>m.length>0?[]:m);return}if(Q||Ee.length===0||Et.current)return;const o=Ee[0];o&&(Et.current=!0,h(m=>m.slice(1)),Re(o).finally(()=>{Et.current=!1}))},[Q,Ee,Re,B]);const rs=l.useCallback((o,m)=>{if(Q)return;const k=m==="edit"?i("session.rewind.confirmEdit"):i("session.rewind.confirm");window.confirm(`${k}
|
|
83
|
+
${i("session.rewind.confirmBody")}`)&&F.rewindToMessage(o.id).then(()=>{m==="edit"&&o.content&&S(R=>({text:o.content,nonce:R.nonce+1}))}).catch(R=>{console.error("[SessionDetail] rewind failed:",R),xe(H("session.rewind.failed",{message:R instanceof Error?R.message:String(R)}))})},[Q,xe]),gn=l.useCallback(o=>{const m=Me.orderedMatchIds;if(m.length===0)return;const k=(o%m.length+m.length)%m.length;E(k);const R=m[k],D=document.querySelector(`[data-entry-id="${CSS.escape(R)}"]`);D==null||D.scrollIntoView({block:"center",behavior:"smooth"})},[Me]),as=l.useCallback(async()=>{try{await F.interrupt()}catch(o){console.error("Interrupt failed:",o)}finally{ye(!1)}},[F]),bn=l.useCallback(()=>{wt(Ya(it))},[wt,it]);l.useEffect(()=>()=>{He.current&&clearTimeout(He.current),Qe.current&&clearTimeout(Qe.current)},[]);const jn=l.useCallback(async()=>{if(s&&window.confirm(i("dashboard.confirmDelete").replace("{id}",s.title||s.id)))try{await hs(s.id),window.location.href="/code/"}catch(o){alert(o instanceof Error?o.message:i("dashboard.deleteFailed"))}},[s]),wn=l.useCallback(async o=>{try{await F.respondPermission(o,!0)}catch(m){console.error("Failed to approve:",m)}re(m=>m.filter(k=>k.requestId!==o))},[F]),vn=l.useCallback(async(o,m)=>{try{await F.respondPermission(o,!0,{updated_permissions:m})}catch(k){console.error("Failed to approve with rules:",k)}re(k=>k.filter(R=>R.requestId!==o))},[F]),kn=l.useCallback(async(o,m)=>{const k=le;if(Te(null),!!k)try{await F.respondElicitation(k.requestId,o,m)}catch(R){console.error("Failed to submit elicitation:",R)}},[le,F]),Nn=l.useCallback(()=>{!s||z||(qt(s.title||""),Z(!0),setTimeout(()=>{var o,m;(o=jt.current)==null||o.focus(),(m=jt.current)==null||m.select()},0))},[s,z]),os=l.useCallback(async()=>{const o=Be.trim();if(Z(!1),!(!s||!o||o===s.title))try{const m=await xr(s.id,o);n(k=>k&&{...k,title:m.title??o})}catch(m){console.error("Rename failed:",m),alert(m instanceof Error?m.message:i("session.rename.failed"))}},[s,Be]),Sn=l.useCallback(async o=>{try{await F.respondPermission(o,!1)}catch(m){console.error("Failed to reject:",m)}re(m=>m.filter(k=>k.requestId!==o))},[F]),_n=l.useCallback(async(o,m,k)=>{try{await ee(r,{type:"permission_response",approved:!0,request_id:o,updated_input:{questions:k,answers:m}})}catch(R){console.error("Failed to submit answers:",R)}re(R=>R.filter(D=>D.requestId!==o))},[r]),Cn=l.useCallback(async(o,m,k)=>{try{m==="no"?await ee(r,{type:"permission_response",approved:!1,request_id:o,...k?{message:k}:{}}):await ee(r,{type:"permission_response",approved:!0,request_id:o,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[m]||"default",destination:"session"}]})}catch(R){console.error("Failed to submit plan response:",R)}re(R=>R.filter(D=>D.requestId!==o))},[r]);return c?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(xt,{onBack:t,title:e.jsx("span",{className:"text-xs font-medium text-text-muted",children:i("session.loadFailed")})}),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:c}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand-text hover:underline",children:i("session.backToDashboard")})]})})]}):s?s.source==="acp"&&s.environment_id?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx(xt,{onBack:t,title:e.jsx("span",{className:"truncate text-xs font-semibold text-text-primary",children:s.title||s.id}),meta:e.jsx("span",{className:"rounded-full bg-brand/15 px-2 py-0.5 text-[10px] font-medium text-brand-text",children:"ACP"})}),e.jsx(ro,{sessionId:r,agentId:s.environment_id})]}):e.jsx(Ys,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx(xt,{onBack:t,title:K?e.jsx("input",{ref:jt,value:Be,onChange:o=>qt(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),os()):o.key==="Escape"&&(o.preventDefault(),Z(!1))},onBlur:()=>void os(),maxLength:200,className:"w-full max-w-xs rounded-md border border-brand/50 bg-surface-2 px-2 py-0.5 text-xs font-semibold text-text-primary focus:outline-none focus:ring-2 focus:ring-brand/30"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex min-w-0 items-center gap-2 text-xs font-semibold text-text-primary",children:!z&&!B?e.jsx("button",{type:"button",onClick:Nn,title:i("session.rename.title"),className:"truncate text-left transition-colors hover:text-text-secondary",children:s.title||s.id}):e.jsx("span",{className:"truncate",children:s.title||s.id})}),s.visibility&&e.jsx(Er,{visibility:s.visibility||"private",className:"hidden flex-shrink-0 text-[10px] sm:inline-flex"})]}),meta:e.jsx(e.Fragment,{children:(()=>{var k;const o=s.source==="acp"?"acp":(k=s.environment)==null?void 0:k.worker_type,m=gs(o);return e.jsx("span",{className:`hidden items-center rounded-full px-2 py-0.5 text-[10px] font-medium sm:inline-flex ${m.colorClass}`,children:m.fullLabel})})()}),actions:e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs("button",{onClick:()=>P(!se),className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${se?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("artifacts.title"),children:[e.jsx(pr,{className:"h-3.5 w-3.5"}),Ne>0&&!se&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-brand px-0.5 text-[10px] font-bold text-white",children:Ne>9?"9+":Ne})]}),e.jsxs("button",{onClick:()=>{We==="memdir"?dn(!pe):ke(!ne)},className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${We==="memdir"?pe?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary":ne?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("memories.title"),children:[e.jsx(Dt,{className:"h-3.5 w-3.5"}),We==="memdir"&&St>0&&!pe&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-brand px-0.5 text-[10px] font-bold text-white",children:St>9?"9+":St})]}),L.side_question&&!B&&!z&&e.jsx("button",{onClick:()=>j(!C),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${C?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.sideQuestion.title"),children:e.jsx(Js,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>{const o=!v;_(o),o?setTimeout(()=>{var m;return(m=I.current)==null?void 0:m.focus()},0):(T(""),E(0))},className:`flex h-7 w-7 items-center justify-center rounded-md transition-colors ${v?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.search.title"),children:e.jsx(yt,{className:"h-3.5 w-3.5"})}),L.mcp_management&&!B&&!z&&e.jsx("button",{onClick:()=>b(!g),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${g?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.mcp.title"),children:e.jsx(Xs,{className:"h-3.5 w-3.5"})}),L.remote_settings&&!B&&!z&&e.jsx("button",{onClick:()=>M(!N),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${N?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:i("session.settings.title"),children:e.jsx(Zs,{className:"h-3.5 w-3.5"})}),!z&&(s==null?void 0:s.access_level)!=="write"&&e.jsx("button",{onClick:()=>X(!0),className:"flex h-7 w-7 items-center justify-center rounded-md text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:i("session.share"),children:e.jsx(ta,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>O(!U),className:"hidden h-7 w-7 items-center justify-center rounded-md text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors sm:flex",title:i("session.info"),children:e.jsx(Lr,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>f(!p),className:"ml-0.5 flex items-center gap-1 rounded-md px-2 py-1 text-xs font-semibold text-text-primary hover:bg-brand-light hover:text-white transition-colors",children:[i("session.tasks"),ge.length>0&&e.jsx("span",{className:"rounded-full bg-status-warning/15 px-1.5 py-0.5 text-[10px] font-medium text-status-warning",children:ge.length})]})]})})}),U&&e.jsx("div",{className:"flex-shrink-0 border-b bg-surface-1 py-2",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsxs("div",{className:"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:i("session.metaSession")})," ",s.id]}),s.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:i("session.metaEnvironment")})," ",s.environment_id]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:i("session.metaStatus")})," ",a]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:i("session.metaWorker")})," ",gs(s.source==="acp"?"acp":(is=s.environment)==null?void 0:is.worker_type).fullLabel]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:i("session.metaCreated")})," ",Qs(s.created_at)]})]})})}),(ze==="reconnecting"||ze==="failed")&&e.jsxs("div",{className:`flex items-center justify-center gap-2 px-4 py-1.5 text-xs font-medium ${ze==="failed"?"bg-status-error/10 text-status-error":"bg-status-warning/10 text-status-warning"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${ze==="failed"?"bg-status-error":"animate-pulse bg-status-warning"}`}),ze==="failed"?i("session.sseFailed"):i("session.sseReconnecting")]}),se&&e.jsx("div",{className:"border-b bg-surface-1 py-4",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(Tr,{sessionId:r,embedded:!0,refreshTick:Se})})}),ne&&We!=="memdir"&&e.jsx("div",{className:"border-b bg-surface-1 py-4",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(Mr,{sessionId:r,embedded:!0,refreshTick:Gt})})}),v&&e.jsx("div",{className:"border-b bg-surface-1 py-2",children:e.jsxs("div",{className:"mx-auto flex page-measure px-4 sm:px-8 items-center gap-2",children:[e.jsx(yt,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{ref:I,value:A,onChange:o=>{T(o.target.value),E(0)},onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),gn(A&&o.shiftKey?w-1:w+1)):o.key==="Escape"&&(o.preventDefault(),_(!1),T(""))},placeholder:i("session.search.placeholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),A.trim()&&e.jsx("span",{className:"flex-shrink-0 font-mono text-[10px] text-text-muted",children:Me.orderedMatchIds.length===0?i("session.search.noResults"):`${w+1}/${Me.orderedMatchIds.length}`})]})}),We==="memdir"?e.jsxs("div",{className:"flex min-h-0 flex-1",children:[pe&&e.jsx("aside",{className:"w-72 flex-shrink-0 overflow-y-auto border-r border-border bg-surface-1","data-testid":"memory-sidebar",children:e.jsx(Ka,{refreshTick:Gt,recall:un,dreaming:Q&&Tt,onDreamTrigger:yn})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(fs,{entries:oe,isLoading:Q,turnStartedAt:at,emptyTitle:i("session.emptyTitle"),emptyDescription:i("session.emptyDescription"),searchMatchIds:A.trim()?Me.matchIds:void 0,onRewindEntry:L.rewind&&!B&&!z&&!Q?(o,m)=>rs(o,m):void 0})})]}):e.jsx(fs,{entries:oe,isLoading:Q,turnStartedAt:at,emptyTitle:i("session.emptyTitle"),emptyDescription:i("session.emptyDescription"),searchMatchIds:A.trim()?Me.matchIds:void 0,onRewindEntry:L.rewind&&!B&&!z&&!Q?(o,m)=>rs(o,m):void 0}),e.jsx(ma,{state:Fe,onStopTask:Qt}),ge.length>0&&e.jsx("div",{className:"border-t bg-surface-1 py-3",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8 space-y-3",children:ge.map(o=>e.jsx(no,{request:o,onApprove:()=>wn(o.requestId),onApproveAlways:o.suggestions&&o.suggestions.length>0?()=>vn(o.requestId,o.suggestions??[]):void 0,onReject:()=>Sn(o.requestId),onSubmitAnswers:_n,onSubmitPlan:Cn},o.requestId))})}),le&&e.jsx("div",{className:"border-t bg-surface-1 py-3",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(Ma,{request:le,onSubmit:kn})})}),Ft&&e.jsx("div",{className:"mx-auto page-measure 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:Ft})}),Pt&&e.jsx("div",{className:"mx-auto page-measure 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:Pt})}),e.jsxs("div",{className:"page-measure 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(so,{mode:it,onModeChange:wt,disabled:B||z}),e.jsx(to,{models:(W==null?void 0:W.availableModels)??[],currentModelId:(W==null?void 0:W.currentModelId)??null,onSelect:o=>{ee(r,{type:"control_request",request:{subtype:"set_model",model:o}}),be(m=>m&&{...m,currentModelId:o})},disabled:B||z}),L.set_max_thinking_tokens&&e.jsx(Ga,{budget:je,onBudgetChange:ln,disabled:B||z}),L.set_effort&&e.jsx(Ja,{effort:zt,onEffortChange:o=>Yt.set(o),disabled:B||z}),L.set_token_mode&&e.jsx(Xa,{mode:Bt,onModeChange:o=>dt.set(o),disabled:B||z})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[ts&&e.jsx(eo,{usage:ts}),me&&e.jsxs("span",{className:"text-[10px] text-text-muted font-mono",title:i("session.usage.total"),children:[Ie(me.inputTokens)," in / ",Ie(me.outputTokens)," out",me.totalCostUsd!=null&&` · $${me.totalCostUsd.toFixed(2)}`]})]})]}),B&&(s==null?void 0:s.environment_id)&&e.jsx("div",{className:"mx-auto w-full page-measure px-4 pb-2 sm:px-8",children:e.jsx("button",{type:"button",onClick:()=>void pn(),className:"w-full rounded-lg border border-border bg-surface-1 px-4 py-2.5 text-sm text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary",children:i("session.resumeInNew")})}),e.jsx(hr,{onSubmit:fn,isLoading:Q,onInterrupt:as,onCycleMode:bn,disabled:B||z,placeholder:B?i("session.closed"):z?i("session.readOnly"):i("session.inputPlaceholder"),supportsAttachments:!0,commands:kt,queueWhileLoading:!0,queuedCount:Ee.length,onDequeue:o=>h(m=>m.filter((k,R)=>R!==o)),onSearchFiles:L.file_search?o=>F.searchFiles(o):void 0,historyKey:r,draftOverride:$}),g&&e.jsx(wa,{onClose:()=>b(!1),fetchServers:()=>F.getMcpServers(),onToggle:(o,m)=>F.toggleMcpServer(o,m),onReconnect:o=>F.reconnectMcpServer(o)}),N&&e.jsx(ka,{onClose:()=>M(!1),fetchSettings:()=>F.getRemoteSettings(),onApply:o=>F.applyFlagSettings(o)}),C&&e.jsx(Na,{onClose:()=>j(!1),onAsk:o=>F.askSideQuestion(o)}),p&&s&&e.jsx(ha,{onClose:()=>f(!1),session:s,liveStatus:a,pendingPermissions:ge,subagentState:Fe,onStopTask:Qt,onInterrupt:as,onDelete:jn,onEndSession:L.end_session&&!B&&!z?async()=>{await F.endSession("ended from web"),await hs(s.id),window.location.href="/code/"}:void 0}),e.jsx($a,{open:J,onClose:()=>X(!1),sessionId:s.id,sessionTitle:s.title||void 0}),e.jsx(Pa,{open:x,onClose:()=>y(!1),adapter:F,onResume:o=>{y(!1),Ye(o,null)}})]})}):e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(xt,{onBack:t,title:e.jsx("span",{className:"h-3.5 w-40 animate-pulse rounded bg-surface-2"})}),e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:i("session.loading")})})]})}function no({request:r,onApprove:t,onApproveAlways:s,onReject:n,onSubmitAnswers:a,onSubmitPlan:d}){const c=r.toolName,u=r.toolInput,p=r.description||"";if(c==="AskUserQuestion"){const f=u.questions||[];return e.jsx(_a,{requestId:r.requestId,questions:f,description:p,onSubmit:g=>a(r.requestId,g,f),onSkip:n})}if(c==="ExitPlanMode"){const f=u.plan||"";return e.jsx(Ta,{requestId:r.requestId,planContent:f,description:p,onSubmit:(g,b)=>d(r.requestId,g,b)})}return e.jsx(Sa,{requestId:r.requestId,toolName:c,toolInput:u,description:p,suggestions:r.suggestions,onApprove:t,onApproveAlways:s,onReject:n})}function ro({sessionId:r,agentId:t}){const[s,n]=l.useState(null),[a,d]=l.useState("disconnected"),[c,u]=l.useState(null),p=l.useRef(null);return l.useEffect(()=>{const f=za(t);return f.setConnectionStateHandler((g,b)=>{d(g),u(b||null)}),p.current=f,n(f),f.connect().catch(g=>{g instanceof fr||(u(g.message),d("error"))}),()=>{f.disconnect(),p.current=null,n(null),d("disconnected")}},[t]),e.jsx(Ys,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[c&&a==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:c}),a==="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:i("session.connectingAgent")})]})}),a==="error"&&!s&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:i("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:c})]})}),s&&a==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(yr,{client:s,agentId:t})})]})})}export{jo as SessionDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{aF as c,V as n,aD as i}from"./main-4aV08-w8.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{a_ as v,c as N,aT as t}from"./main-4aV08-w8.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function E({onSuccess:p,onAlreadyDone:b}){const{setup:h}=v(),[d,f]=r.useState(""),[l,y]=r.useState(""),[a,g]=r.useState(""),[u,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!==u){o(t("auth.setup.passwordMismatch"));return}m(!0);try{await h(d,l,a),p()}catch(x){const n=x instanceof Error?x.message:"Setup failed";if(n.includes("already")||n.includes("409")){b();return}o(n)}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:"hero-enter w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(N,{className:"mx-auto mb-5 h-10 w-10"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight 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:d,onChange:s=>f(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:u,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.5 font-display text-sm font-medium text-white shadow-lg shadow-brand/25 transition-all hover:-translate-y-0.5 hover:bg-brand-light hover:shadow-brand/40 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:translate-y-0 disabled:hover:shadow-none",children:c?t("common.loading"):t("auth.setup.submit")})]})]})})}export{E 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{ar as m,b as h}from"./main-4aV08-w8.js";import"./preload-helper-BiaRt2Oj.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-text hover:underline",children:"← Back to Dashboard"})]})})}export{j as ShareLanding};
|