@saluzi/saluzi-edu 0.7.8 → 0.7.9
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 +64 -56
- package/dist/rcs-web/assets/{AdminPanel-D0i_28O2.js → AdminPanel-B3NMTdDG.js} +1 -1
- package/dist/rcs-web/assets/{ArtifactView-Dd6d3O3z.js → ArtifactView-BpHLkriL.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ArtifactsGallery-BTVS7sar.js → dist/rcs-web/assets/ArtifactsGallery-B0jHj6Nb.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Claim-CkuDG_ay.js → dist/rcs-web/assets/Claim-I-OsSFKu.js} +1 -1
- package/dist/rcs-web/assets/{Dashboard-BBZHnmut.js → Dashboard-B4gfzFIz.js} +2 -2
- package/dist/rcs-web/assets/{Join-DbBj-5mj.js → Join-DvWucRFF.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Login-Csvt3wvz.js → dist/rcs-web/assets/Login-cT0Y0zLo.js} +1 -1
- package/dist/rcs-web/assets/{MemoriesGallery-C5cT73hA.js → MemoriesGallery-NN16V4oP.js} +1 -1
- package/dist/rcs-web/assets/{Register-Cmp7ogoN.js → Register-C6g-j45z.js} +1 -1
- package/dist/rcs-web/assets/{RegisterEmpty-BoIy42g_.js → RegisterEmpty-C2jnr90K.js} +2 -2
- package/dist/rcs-web/assets/SessionDetail-CcfimSQQ.js +83 -0
- package/dist/rcs-web/assets/{SessionVisibilityBadge-C873QvnC.js → SessionVisibilityBadge-DSkyQ1D4.js} +1 -1
- package/dist/rcs-web/assets/{Setup-DOU0qTNX.js → Setup-CNU_nTSM.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-DMR9eh0F.js → ShareLanding-DH3jnlTD.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/TeamDetail-MPfqesJf.js → dist/rcs-web/assets/TeamDetail-D0FSiAhV.js} +2 -2
- package/dist/rcs-web/assets/{TeamList-CgWVmdPU.js → TeamList-BNOdaGhz.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-V3L0H8Nb.js → TeamSettings-CxuutvGQ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/UserSearchInput-xqtDX6Bz.js → dist/rcs-web/assets/UserSearchInput-Bb-V7fqI.js} +2 -2
- package/dist/rcs-web/assets/{UserSettings-Cfqs_5af.js → UserSettings-DejYD6uF.js} +1 -1
- package/dist/rcs-web/assets/{arc-Bl97za3P.js → arc-CT2VuJG0.js} +1 -1
- package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-B8IQfxi6.js → architectureDiagram-3BPJPVTR-C36ua0-u.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DNfBHM8J.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-AxttQsPe.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-CO4HDUF2.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-fc4pe5bF.js} +1 -1
- package/dist/rcs-web/assets/channel-Bhb276ZI.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-4CBnqzb3.js → chunk-2J33WTMH-B_7vf70s.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-ClbIGQlY.js → chunk-4BX2VUAB-Bvz3jAL7.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-BnrTfmFM.js → chunk-55IACEB6-CBDUoK1T.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-C17NZOQL.js → dist/rcs-web/assets/chunk-727SXJPM-sODvLAmN.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-CljirtnS.js → dist/rcs-web/assets/chunk-AQP2D5EJ-SFZGnUWg.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-Bb20ipZI.js → chunk-FMBD7UC4-DCMkp3hR.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-L3q9_xAn.js → chunk-ND2GUHAM-8ValhK1Z.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-FyYNxzak.js → chunk-QZHKN3VN-DKpH4BaH.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-B0HWxaYK.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-B0HWxaYK.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-CQVTEZwg.js → code-block-IT6T5CEO-BfAWzTW4.js} +1 -1
- package/dist/rcs-web/assets/{copy-CFZBXuu9.js → copy-rIWaoyhG.js} +1 -1
- package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-Cs2MVxlS.js → cose-bilkent-S5V4N54A-D3dbujn0.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-CWZcIIf5.js → dagre-BM42HDAG-BMPLFjpK.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-DpumSk2d.js → diagram-2AECGRRQ-wsUZ_jAQ.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-DcF2qwdh.js → diagram-5GNKFQAL-D7Z0JdaQ.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-BGnqGSPz.js → diagram-KO2AKTUF-B0trDGwz.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-k-UxYOZ9.js → diagram-LMA3HP47-jr9I40Ze.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-BMPzmD6S.js → dist/rcs-web/assets/diagram-OG6HWLK6-p7jsxoor.js} +1 -1
- package/dist/rcs-web/assets/{dialog-DKk230y5.js → dialog-DPpsff0A.js} +1 -1
- package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BvmA6W9Z.js → erDiagram-TEJ5UH35-DCU8Bgzn.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-ptAnksiF.js → dist/rcs-web/assets/flowDiagram-I6XJVG4X-CuKFwUsm.js} +1 -1
- package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-Bhgrzcs3.js → ganttDiagram-6RSMTGT7-DET-FT-l.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-B8-vcbF-.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-DhMTMS0R.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-DaW0unc2.js → infoDiagram-5YYISTIA-kE4u9Vj_.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-4oYGuWP6.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-DMd1Ircr.js} +1 -1
- package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-B9YXpw0W.js → journeyDiagram-JHISSGLW-xpacZaOS.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-Cglus7wI.js → dist/rcs-web/assets/kanban-definition-UN3LZRKU-Bc9Jfdya.js} +1 -1
- package/dist/rcs-web/assets/{linear-CRTJd3_G.js → linear-BBrTPK-D.js} +1 -1
- package/dist/rcs-web/assets/main-B7U6M5cC.css +1 -0
- package/dist/rcs-web/assets/main-RGMHltl_.js +393 -0
- package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-D0JeVL0B.js → dist/rcs-web/assets/mermaid-VLURNSYL-CflWsDy2.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-CobUk_K5.js → mermaid.core-kR5o-DR4.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-DBw5bklZ.js} +1 -1
- package/dist/rcs-web/assets/{notifications-BrgRJuzQ.js → notifications-B1SFmmdZ.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-PcBs9RT_.js → pieDiagram-4H26LBE5-Cj8_4-0o.js} +1 -1
- package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-B2GxITjv.js → quadrantDiagram-W4KKPZXB-Bx7EpAwG.js} +1 -1
- package/dist/rcs-web/assets/{refresh-cw-BwmFF3kw.js → refresh-cw-DjjNpVDe.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-BfyZiasB.js → dist/rcs-web/assets/requirementDiagram-4Y6WPE33-ayn2gFqB.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-Br7tRtmq.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-BiG0sXBu.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CN1NSfHS.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-zSmAX_tO.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-C4S8hKUx.js → dist/rcs-web/assets/stateDiagram-AJRCARHV-CTKOjAIA.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-CbEMz-jf.js → stateDiagram-v2-BHNVJYJU-f6FO1c8y.js} +1 -1
- package/dist/rcs-web/assets/{timeline-definition-PNZ67QCA-mTiK0HwD.js → timeline-definition-PNZ67QCA-DT6XxAXB.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-DCe95URb.js → vennDiagram-CIIHVFJN-yuD7GvWO.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-Cct1r0Ax.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-B810X7vc.js} +1 -1
- package/dist/rcs-web/assets/{workerType-DW9l12WG.js → workerType-CHkBOZGL.js} +1 -1
- package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-CVc0eQYa.js → xychartDiagram-2RQKCTM6-CAli0anm.js} +1 -1
- package/dist/rcs-web/index.html +2 -2
- package/package.json +1 -1
- package/packages/remote-control-server/src/__tests__/memoryBackend.test.ts +298 -0
- package/packages/remote-control-server/src/nodeServer.ts +9 -0
- package/packages/remote-control-server/src/routes/web/memories.ts +196 -0
- package/packages/remote-control-server/src/services/memoryBackend.ts +123 -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-B3NMTdDG.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ArtifactView-Dd6d3O3z.js → ArtifactView-BpHLkriL.js} +1 -1
- package/{dist/rcs-web/assets/ArtifactsGallery-BTVS7sar.js → packages/remote-control-server/web/dist/assets/ArtifactsGallery-B0jHj6Nb.js} +1 -1
- package/{dist/rcs-web/assets/Claim-CkuDG_ay.js → packages/remote-control-server/web/dist/assets/Claim-I-OsSFKu.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Dashboard-BBZHnmut.js → Dashboard-B4gfzFIz.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{Join-DbBj-5mj.js → Join-DvWucRFF.js} +1 -1
- package/{dist/rcs-web/assets/Login-Csvt3wvz.js → packages/remote-control-server/web/dist/assets/Login-cT0Y0zLo.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{MemoriesGallery-C5cT73hA.js → MemoriesGallery-NN16V4oP.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Register-Cmp7ogoN.js → Register-C6g-j45z.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{RegisterEmpty-BoIy42g_.js → RegisterEmpty-C2jnr90K.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/SessionDetail-CcfimSQQ.js +83 -0
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-C873QvnC.js → SessionVisibilityBadge-DSkyQ1D4.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Setup-DOU0qTNX.js → Setup-CNU_nTSM.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-DMR9eh0F.js → ShareLanding-DH3jnlTD.js} +1 -1
- package/{dist/rcs-web/assets/TeamDetail-MPfqesJf.js → packages/remote-control-server/web/dist/assets/TeamDetail-D0FSiAhV.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{TeamList-CgWVmdPU.js → TeamList-BNOdaGhz.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-V3L0H8Nb.js → TeamSettings-CxuutvGQ.js} +1 -1
- package/{dist/rcs-web/assets/UserSearchInput-xqtDX6Bz.js → packages/remote-control-server/web/dist/assets/UserSearchInput-Bb-V7fqI.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{UserSettings-Cfqs_5af.js → UserSettings-DejYD6uF.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-Bl97za3P.js → arc-CT2VuJG0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-B8IQfxi6.js → architectureDiagram-3BPJPVTR-C36ua0-u.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DNfBHM8J.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-AxttQsPe.js} +1 -1
- package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-CO4HDUF2.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-fc4pe5bF.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-Bhb276ZI.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-4CBnqzb3.js → chunk-2J33WTMH-B_7vf70s.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-ClbIGQlY.js → chunk-4BX2VUAB-Bvz3jAL7.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BnrTfmFM.js → chunk-55IACEB6-CBDUoK1T.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-C17NZOQL.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-sODvLAmN.js} +1 -1
- package/{dist/rcs-web/assets/chunk-AQP2D5EJ-CljirtnS.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-SFZGnUWg.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-Bb20ipZI.js → chunk-FMBD7UC4-DCMkp3hR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-L3q9_xAn.js → chunk-ND2GUHAM-8ValhK1Z.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-FyYNxzak.js → chunk-QZHKN3VN-DKpH4BaH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-B0HWxaYK.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-B0HWxaYK.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-CQVTEZwg.js → code-block-IT6T5CEO-BfAWzTW4.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-CFZBXuu9.js → copy-rIWaoyhG.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-Cs2MVxlS.js → cose-bilkent-S5V4N54A-D3dbujn0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-CWZcIIf5.js → dagre-BM42HDAG-BMPLFjpK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-DpumSk2d.js → diagram-2AECGRRQ-wsUZ_jAQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-DcF2qwdh.js → diagram-5GNKFQAL-D7Z0JdaQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-BGnqGSPz.js → diagram-KO2AKTUF-B0trDGwz.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-k-UxYOZ9.js → diagram-LMA3HP47-jr9I40Ze.js} +1 -1
- package/{dist/rcs-web/assets/diagram-OG6HWLK6-BMPzmD6S.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-p7jsxoor.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dialog-DKk230y5.js → dialog-DPpsff0A.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BvmA6W9Z.js → erDiagram-TEJ5UH35-DCU8Bgzn.js} +1 -1
- package/{dist/rcs-web/assets/flowDiagram-I6XJVG4X-ptAnksiF.js → packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-CuKFwUsm.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-Bhgrzcs3.js → ganttDiagram-6RSMTGT7-DET-FT-l.js} +1 -1
- package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-B8-vcbF-.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-DhMTMS0R.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-DaW0unc2.js → infoDiagram-5YYISTIA-kE4u9Vj_.js} +1 -1
- package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-4oYGuWP6.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-DMd1Ircr.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-B9YXpw0W.js → journeyDiagram-JHISSGLW-xpacZaOS.js} +1 -1
- package/{dist/rcs-web/assets/kanban-definition-UN3LZRKU-Cglus7wI.js → packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-Bc9Jfdya.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-CRTJd3_G.js → linear-BBrTPK-D.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/main-B7U6M5cC.css +1 -0
- package/packages/remote-control-server/web/dist/assets/main-RGMHltl_.js +393 -0
- package/{dist/rcs-web/assets/mermaid-VLURNSYL-D0JeVL0B.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-CflWsDy2.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-CobUk_K5.js → mermaid.core-kR5o-DR4.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-DBw5bklZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{notifications-BrgRJuzQ.js → notifications-B1SFmmdZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-PcBs9RT_.js → pieDiagram-4H26LBE5-Cj8_4-0o.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-B2GxITjv.js → quadrantDiagram-W4KKPZXB-Bx7EpAwG.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{refresh-cw-BwmFF3kw.js → refresh-cw-DjjNpVDe.js} +1 -1
- package/{dist/rcs-web/assets/requirementDiagram-4Y6WPE33-BfyZiasB.js → packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-ayn2gFqB.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-Br7tRtmq.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-BiG0sXBu.js} +1 -1
- package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CN1NSfHS.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-zSmAX_tO.js} +1 -1
- package/{dist/rcs-web/assets/stateDiagram-AJRCARHV-C4S8hKUx.js → packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-CTKOjAIA.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-CbEMz-jf.js → stateDiagram-v2-BHNVJYJU-f6FO1c8y.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{timeline-definition-PNZ67QCA-mTiK0HwD.js → timeline-definition-PNZ67QCA-DT6XxAXB.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-DCe95URb.js → vennDiagram-CIIHVFJN-yuD7GvWO.js} +1 -1
- package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-Cct1r0Ax.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-B810X7vc.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{workerType-DW9l12WG.js → workerType-CHkBOZGL.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-CVc0eQYa.js → xychartDiagram-2RQKCTM6-CAli0anm.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +2 -2
- 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/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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var Cn=Object.defineProperty;var Tn=(r,t,s)=>t in r?Cn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var q=(r,t,s)=>Tn(r,typeof t!="symbol"?t+"":t,s);import{j as e,e as i}from"./vendor-DE_-CLIE.js";import{aE as G,ah as En,aM as ns,aL as rs,aS as l,aO as Mn,aN as rt,aT as H,aJ as ge,aw as Rn,av as X,ak as An,as as In,aX as $n,a_ as ne,T as Dn,Q as qn,X as Pn,L as Fe,H as On,I as Fn,i as as,aI as Fs,N as Us,aF as at,e as _e,S as ot,M as Un,y as Kn,aG as Z,aC as xe,aH as Ln,aU as Bn,G as Hn,D as Qn,aV as os,al as Wn,a1 as zn,ar as Vn,ad as Ks,ac as Gn,aa as Yn,at as Jn,ao as Xn,B as Ct,P as Zn,V as er,ab as is,am as tr,a3 as sr,aA as nr,A as rr,aK as ar,aP as or,aQ as ir,Z as ls,a0 as lr,aW as cr,b as dr,a5 as cs,ap as ur,K as Ls,F as mr,d as ds,C as xr,ag as us,l as pr,a as hr,u as Ue,w as Ke,E as fr,g as Le,f as Be,v as He,s as yr}from"./main-RGMHltl_.js";import{A as gr,g as ms}from"./workerType-CHkBOZGL.js";import{D as Ce,a as Te,c as Ee,d as Me,b as br}from"./dialog-DPpsff0A.js";import{R as jr}from"./refresh-cw-DjjNpVDe.js";import{A as wr,U as vr}from"./UserSearchInput-Bb-V7fqI.js";import{C as kr}from"./copy-rIWaoyhG.js";import{E as Nr,S as Sr,A as _r}from"./ArtifactsGallery-B0jHj6Nb.js";import{S as Cr}from"./SessionVisibilityBadge-DSkyQ1D4.js";import{MemoriesGallery as Tr}from"./MemoriesGallery-NN16V4oP.js";import{S as Er,b as Mr}from"./notifications-B1SFmmdZ.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 Rr=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Bs=G("chevron-right",Rr);/**
|
|
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 Ar=[["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"}]],Ir=G("coins",Ar);/**
|
|
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 $r=[["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"}]],Hs=G("cpu",$r);/**
|
|
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 Dr=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],qr=G("gauge",Dr);/**
|
|
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 Pr=[["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"}]],Or=G("hash",Pr);/**
|
|
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 Fr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ur=G("info",Fr);/**
|
|
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 Kr=[["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"}]],Lr=G("layers",Kr);/**
|
|
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 Br=[["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"}]],Qs=G("message-circle-question-mark",Br);/**
|
|
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 Hr=[["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"}]],Qr=G("message-square-text",Hr);/**
|
|
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 Wr=[["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"}]],zr=G("play",Wr);/**
|
|
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 Vr=[["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"}]],Ws=G("plug",Vr);/**
|
|
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 Gr=[["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"}]],Yr=G("server-cog",Gr);/**
|
|
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 Jr=[["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",Jr);/**
|
|
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 Xr=[["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"}]],Zr=G("share-2",Xr);/**
|
|
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 ea=[["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"}]],ta=G("shield-check",ea);function St(){return{tasks:{}}}const xs=3e4;function tt(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 ps(r,t){var c,u,p,h,y,g,N,M,C,j,x,f;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:tt(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:tt(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:tt(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:((h=t.usage)==null?void 0:h.total_tokens)??d.tokenCount,toolUseCount:((y=t.usage)==null?void 0:y.tool_uses)??d.toolUseCount,durationMs:((g=t.usage)==null?void 0:g.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:((f=t.usage)==null?void 0:f.duration_ms)??d.durationMs,evictAfter:a+xs}}}:{tasks:{...r.tasks,[n]:{taskId:n,name:tt(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+xs}}}}function Vs(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 hs={in_process_teammate:0,local_bash:1,monitor_mcp:2,remote_agent:3,local_agent:4,dream:5},fs=100;function sa(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=hs[s]??fs,d=hs[n]??fs;return a===d?s.localeCompare(n):a-d}).map(([s,n])=>({taskType:s,tasks:[...n].sort((a,d)=>a.startTime-d.startTime)}))}function ys(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 na(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 gs(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 bs(r){const t=r.raw&&typeof r.raw=="object"&&!Array.isArray(r.raw)?r.raw:r,s=gs(t.slash_command_details??r.slash_command_details,t.slash_commands??r.slash_commands),n=gs(t.skill_details??r.skill_details,t.skills??r.skills),a=na(t.remote_capabilities??r.remote_capabilities);return s.length===0&&n.length===0&&!a?null:{commands:s,skills:n,capabilities:a}}class ra{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 $n(),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 me=new ra;function vt(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 js(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 kt="streaming-";function ws(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 vs(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 ks(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 aa{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",St());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,f,v,_,A,T;const{events:t}=await En(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 $=vt(E);$&&n.push({type:"user_message",id:w.id||`hist-user-${n.length}`,content:$})}else if(w.type==="assistant"){d();const $=vt(E);if(ns($))continue;const S=ws(E),K=[],F=E.message;if(F&&typeof F=="object"&&Array.isArray(F.content)){for(const Y of F.content)if(Y.type==="tool_use"){const J=Y.id;J&&this.seenToolCallIds.add(J),K.push({type:"tool_call",toolCall:{id:J||`hist-tool-${n.length}`,title:Y.name||"tool",status:"complete",rawInput:Y.input||{}}})}}if($||S||K.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 Y of K)n.push(Y);a=null}}else if(w.type==="conversation_rewound"){const $=ks(E);if($){const S=n.findIndex(K=>rs(K)===$);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=js(n,$.tool_call_id||"");if(S>=0){const K=n[S];n[S]={type:"tool_call",toolCall:{...K.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=vs(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,h=null,y=null,g=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"&&y!=="user"&&w.createdAt>0&&(g=w.createdAt)),w.type==="user"?y="user":(w.type==="result"||w.type==="result_success"||w.type==="interrupt")&&(y="turn_end"),w.type==="system"&&(E.subtype==="init"||((x=E.raw)==null?void 0:x.subtype)==="init")&&(p=bs(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)&&(h={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=St();for(const w of t){if(w.type!=="system")continue;const E=ys(w.payload||{});E&&(C=ps(C,E),M=!0)}M&&(this.subagentState=C,(f=this.onSubagentUpdate)==null||f.call(this,this.subagentState)),u&&((v=this.onModelsStateChange)==null||v.call(this,u)),p&&((_=this.onWorkerInfoChange)==null||_.call(this,p)),h&&((A=this.onUsageChange)==null||A.call(this,h)),this.turnEnded=y==="turn_end",this.userSinceTurnEnd=y==="user",this.setTurnStartedAt(!this.closed&&y==="user"&&g>0&&N>=g?Date.now()-(N-g):null),this.turnEnded&&!this.closed&&((T=this.onStatusChange)==null||T.call(this,"idle"))}connectSSE(){me.connect(this.sessionId),this.unsub=me.onEvent(t=>this.handleEvent(t)),this.unsubState=me.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),me.disconnect()}handleEvent(t){var a,d,c,u,p,h,y,g,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 f=vt(n);f&&this.setEntries(v=>[...v,{type:"user_message",id:t.id||`user-${Date.now()}`,content:f}])}break}case"assistant":{const x=n.uuid;if(typeof x=="string"&&x){if(this.seenUuids.has(x))break;this.seenUuids.add(x)}const f=typeof n.content=="string"?n.content:"";if(ns(f))break;const v=ws(n);this.setEntries(A=>{const T=A[A.length-1];if((T==null?void 0:T.type)==="assistant_message"&&T.id.startsWith(kt))return[...A.slice(0,-1),{...T,id:`assistant-${Date.now()}`,chunks:[...v?[{type:"thought",text:v}]:[],{type:"message",text:f}]}];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+f}]}]:[...A.slice(0,-1),{...T,chunks:[...T.chunks,{type:"message",text:f}]}]}if(f&&f.trim()||v){const w={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...v?[{type:"thought",text:v}]:[],...f?[{type:"message",text:f}]:[]]};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,f=x.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(f))break;this.seenToolCallIds.add(f),this.pendingToolCallIds.add(f);const v={id:f,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 f=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(f,$.toolCall.id),w.map((S,K)=>K===I?{type:"tool_call",toolCall:{...$.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:f,options:[]}}}:S)}return w}),(d=this.onPermissionRequest)==null||d.call(this,{requestId:f,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=ks(n);x&&(this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries(f=>{const v=f.findIndex(_=>rs(_)===x);return v===-1?f:f.slice(0,v)}));break}case"session_status":{if(Mn(n)){this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries([]);break}if(typeof n.status=="string"){if(rt(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,f=typeof x=="object"&&x!==null?x.models_state:n.models_state;f&&Array.isArray(f.availableModels)&&typeof f.currentModelId=="string"&&((h=this.onModelsStateChange)==null||h.call(this,f));break}case"system":{const x=n.raw,f=x&&typeof x=="object"?x:n,v=typeof f.subtype=="string"?f.subtype:void 0,_=ys(n);_&&(this.subagentState=ps(this.subagentState,_),(y=this.onSubagentUpdate)==null||y.call(this,this.subagentState));const A=typeof f.permissionMode=="string"?f.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;if(A&&((g=this.onPermissionModeChange)==null||g.call(this,A)),v==="init"){const T=bs(n);T&&((N=this.onWorkerInfoChange)==null||N.call(this,T))}break}case"control_response":{const x=n.response;if(x&&typeof x=="object"){const f=typeof x.request_id=="string"?x.request_id:"",v=typeof x.subtype=="string"?x.subtype:"";if(f){(M=this.onControlResponse)==null||M.call(this,{subtype:v,requestId:f,error:typeof x.error=="string"?x.error:void 0});const _=this.pendingControlRequests.get(f);_&&(this.pendingControlRequests.delete(f),_({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 f=x.delta;if(!f||typeof f.type!="string")break;const v=f.type==="text_delta"?"message":f.type==="thinking_delta"?"thought":null;if(!v)break;const _=f.text??f.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,f=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(x||f!==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:f})}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:l("adapter.workerCrashed"),outputText:T,variant:"error"}]);break}case"task_state":{const x=Array.isArray(n.tasks)?n.tasks:[];if(x.length===0)break;const f=vs(x);if(f.length===0)break;this.setEntries(v=>[...v.filter(A=>A.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:f}]);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=js(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(kt)){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:`${kt}${Date.now()}`,chunks:[{type:t,text:s}]};return[...n,d]})}async sendMessage(t,s,n){var h;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(y=>[...y,c]);const u=[];if(t&&u.push({type:"text",text:t}),a)for(const y of s)u.push({type:"image",source:{type:"base64",media_type:y.mimeType,data:y.data}});if(d){for(const y of n)if(y.kind==="text"||y.kind==="table"){const g=`📎 ${y.name}${y.size!=null?` (${oa(y.size)})`:""}`,N=y.textContent||l("attach.emptyFile");u.push({type:"text",text:`${g}
|
|
77
|
+
\`\`\`
|
|
78
|
+
${N}
|
|
79
|
+
\`\`\``})}else if(y.kind==="directory"){const g=y.files!=null?`${H("attach.directoryHeader",{name:y.name})} ${H("attach.fileCount",{n:y.files.length})}`:H("attach.directoryHeader",{name:y.name}),N=y.textContent||l("attach.emptyDirectory");u.push({type:"text",text:`${g}
|
|
80
|
+
${N}`})}}const p=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;try{const y=ge();this.postedUserUuids.add(y);const g=await Rn(this.sessionId,{type:"user",uuid:y,content:t,message:{content:p}}),N=(h=g==null?void 0:g.event)==null?void 0:h.id;N&&this.setEntries(M=>M.map(C=>C.type==="user_message"&&C.id===c.id?{...C,id:N}:C))}catch(y){throw this.setEntries(g=>g.filter(N=>!(N.type==="user_message"&&N.id===c.id))),y}}async respondPermission(t,s,n){await X(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 An(this.sessionId)}async setPermissionMode(t){const s=ge();return await X(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_permission_mode",mode:t}}),s}async controlRoundTrip(t,s=8e3){const n=ge(),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 X(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 X(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=ge();return await X(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),s}async setTokenMode(t){const s=ge();return await X(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_token_mode",mode:t}}),s}async setThinkingBudget(t){const s=ge();return await X(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"?l("adapter.stopTimeout"):s.error}:{ok:!0}}catch{return{ok:!1,error:l("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,h=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(h==null?void 0:h.url)=="string"&&h.url?{url:h.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"?l("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"?l("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"?l("adapter.requestTimeout"):s.error}:{ok:!0}}async rewindToMessage(t){await In(this.sessionId,t)}async endSession(t){await X(this.sessionId,{type:"control_request",request_id:ge(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function oa(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function st({onBack:r,title:t,meta:s,actions:n}){return ne(),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":l("nav.dashboard"),title:l("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:l("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(Dn,{}),e.jsx(qn,{onSettingsClick:()=>{window.history.pushState(null,"","/settings"),window.dispatchEvent(new PopStateEvent("popstate"))}})]})})}const Ns="rcs:subagent-panel:collapsed";function ia(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 la(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 ca({status:r}){return r==="running"?e.jsx(Fe,{className:"h-3 w-3 animate-spin text-brand-text"}):r==="completed"?e.jsx(zr,{className:"h-3 w-3 text-status-success"}):r==="failed"||r==="stopped"?e.jsx(On,{className:"h-3 w-3 text-status-error"}):null}function Gs({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=la(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(ca,{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:ia(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:l("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(Pn,{className:"h-3.5 w-3.5"})})]})}function da({state:r,onStopTask:t}){const[s,n]=i.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ns)==="1"}catch{return!1}}),a=()=>{n(g=>{const N=!g;try{window.localStorage.setItem(Ns,N?"1":"0")}catch{}return N})},d=Object.values(r.tasks).some(g=>g.status==="running"),c=Object.values(r.tasks).some(g=>g.status!=="running"&&g.evictAfter!==void 0),[,u]=i.useState(0);i.useEffect(()=>{if(!d&&!c)return;const g=setInterval(()=>{u(N=>N+1)},1e3);return()=>clearInterval(g)},[d,c]);const p=Vs(r);if(p.length===0)return null;const h=p.filter(g=>g.status==="running").length,y=h>0?`${h} 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(Bs,{className:`h-3 w-3 transition-transform ${s?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:y})]}),!s&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:p.map(g=>e.jsx(Gs,{task:g,onStopTask:t},g.taskId))})]})})}function ua(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 ma(r){return r?Date.now()-r<6e4:!1}function xa({onClose:r,session:t,liveStatus:s,pendingPermissions:n,onInterrupt:a,onDelete:d,subagentState:c,onStopTask:u,onEndSession:p}){const[h,y]=i.useState(!1),g=async()=>{await navigator.clipboard.writeText(t.id),y(!0),setTimeout(()=>y(!1),1500)},[N,M]=i.useState(!1),C=async()=>{if(!(!p||N)&&window.confirm(l("task.endConfirm"))){M(!0);try{await p(),r()}catch{M(!1)}}},j=n.length,x=t.worker,f=t.work_item,v=t.environment;return e.jsx(Ce,{open:!0,onOpenChange:_=>{_||r()},children:e.jsxs(Te,{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(Ee,{children:e.jsx(Me,{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(gr,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fn,{status:s||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:x&&(ma(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(as,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ua(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(Hs,{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(as,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Fs(t.created_at)})]})]})]}),e.jsx(fa,{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(Fe,{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(Yr,{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:l("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(Us,{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(Or,{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:g,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:h?"✓":"⧉"})]})]}),f&&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:f.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:f.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 pa={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"},ha=new Set(["dream"]);function fa({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]=i.useState(0);i.useEffect(()=>{if(!s&&!n)return;const p=setInterval(()=>{a(h=>h+1)},1e3);return()=>clearInterval(p)},[s,n]);const d=Vs(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(Lr,{className:"h-3.5 w-3.5"}),l("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:l("task.noBackgroundTasks")}):e.jsx("div",{className:"max-h-[38vh] space-y-2 overflow-y-auto overscroll-contain pr-1",children:sa(d).map(p=>{const h=!ha.has(p.taskType),y=pa[p.taskType]??"task.type.tasks";return e.jsxs("div",{className:"space-y-1",children:[h&&e.jsxs("div",{className:"pl-1 text-[10px] font-medium uppercase tracking-wide text-text-muted/80",children:[l(y)," (",p.tasks.length,")"]}),p.tasks.map(g=>e.jsx(Gs,{task:g,onStopTask:t,fullText:!0},g.taskId))]},p.taskType)})})]})}const ya={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"},ga={connected:"mcp.status.connected",failed:"mcp.status.failed","needs-auth":"mcp.status.needsAuth",pending:"mcp.status.pending",disabled:"mcp.status.disabled"};function ba({onClose:r,fetchServers:t,onToggle:s,onReconnect:n}){ne();const[a,d]=i.useState(null),[c,u]=i.useState(null),[p,h]=i.useState(null),[y,g]=i.useState(null),N=i.useCallback(async()=>{h(null),g(null);try{const j=await t();d(j),u(null)}catch(j){at("[McpPanel] fetch failed",j),u(l("mcp.loadFailed"))}},[t]);i.useEffect(()=>{N()},[N]);const M=async j=>{const x=j.status==="disabled";h(`toggle:${j.name}`),g(null);try{const f=await s(j.name,x);f.ok||g(f.error||l("mcp.toggleFailed"))}finally{await N()}},C=async j=>{h(`reconnect:${j.name}`),g(null);try{const x=await n(j.name);x.ok||g(x.error||l("mcp.reconnectFailed"))}finally{await N()}};return e.jsx(Ce,{open:!0,onOpenChange:j=>{j||r()},children:e.jsxs(Te,{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(Ee,{children:e.jsxs(Me,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Ws,{className:"h-4 w-4"}),l("session.mcp.title")]})}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[y&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:y}),a===null&&!c&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Fe,{className:"h-3.5 w-3.5 animate-spin"}),l("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:l("mcp.empty")}),a==null?void 0:a.map(j=>{const x=p===`toggle:${j.name}`,f=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 ${ya[j.status]}`,children:l(ga[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:f||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:l("mcp.reconnect"),children:e.jsx(jr,{className:`h-3.5 w-3.5 ${f?"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?l("mcp.enable"):l("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 ja(r){if(r==null)return l("settings.unset");if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}function Ss(r){if(r==null)return l("settings.unset");if(typeof r=="object")try{return JSON.stringify(r,null,2)}catch{return String(r)}return String(r)}function wa({onClose:r,fetchSettings:t,onApply:s}){ne();const[n,a]=i.useState(null),[d,c]=i.useState(null),[u,p]=i.useState(""),[h,y]=i.useState(null),[g,N]=i.useState(null),[M,C]=i.useState(null),[j,x]=i.useState(!1),f=i.useCallback(async()=>{y(null),N(null),C(null),x(!1);try{const S=await t();a(S),c(S?null:l("settings.loadFailed"))}catch(S){at("[SettingsDrawer] fetch failed",S),c(l("settings.loadFailed"))}},[t]);i.useEffect(()=>{f()},[f]);const v=i.useMemo(()=>n?Object.entries(n.effective).filter(([,S])=>S!==void 0).sort(([S],[K])=>S.localeCompare(K)):[],[n]),_=i.useMemo(()=>{const S=u.trim().toLowerCase();return S?v.filter(([K,F])=>`${K} ${ja(F)}`.toLowerCase().includes(S)):v},[v,u]),A=S=>typeof S[1]=="boolean",T=i.useMemo(()=>_.filter(A),[_]),w=i.useMemo(()=>_.filter(S=>!A(S)),[_]),E=i.useMemo(()=>M===null?null:v.find(([S])=>S===M)??null,[v,M]),I=async()=>{if(E)try{await navigator.clipboard.writeText(Ss(E[1])),x(!0),window.setTimeout(()=>x(!1),1500)}catch(S){at("[SettingsDrawer] copy failed",S)}},$=async(S,K)=>{y(S),N(null);try{const F=await s({[S]:!K});F.ok||N(F.error||l("settings.writeFailed"))}finally{await f()}};return e.jsx(Ce,{open:!0,onOpenChange:S=>{S||r()},children:e.jsxs(Te,{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(Ee,{children:e.jsxs(Me,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(zs,{className:"h-4 w-4"}),l("session.settings.title")]})}),e.jsxs("div",{className:"mt-3 space-y-4 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}),n===null&&!d&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Fe,{className:"h-3.5 w-3.5 animate-spin"}),l("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:l("settings.model")}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.model||l("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:l("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(wr,{className:"h-3.5 w-3.5"}),l("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:Ss(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(kr,{className:"h-3.5 w-3.5"}),j?l("settings.copied"):l("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(ot,{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:l("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:l("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,K])=>{const F=h===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":K,disabled:F,onClick:()=>void $(S,K),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${K?"bg-brand":"bg-surface-3"}`,title:K?l("settings.turnOff"):l("settings.turnOn"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${K?"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:l("settings.viewDetail"),children:[e.jsx("span",{className:"truncate font-mono text-xs text-text-primary",children:S}),e.jsx(Bs,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"})]},S))]})]})]})]})]})})}function va({onClose:r,onAsk:t}){ne();const[s,n]=i.useState([]),[a,d]=i.useState(""),[c,u]=i.useState(!1),p=async()=>{const h=a.trim();if(!h||c)return;const y=Date.now();n(g=>[...g,{id:y,question:h,answer:null}]),d(""),u(!0);try{const g=await t(h);n(N=>N.map(M=>M.id===y?{...M,answer:g??l("sideQuestion.noAnswer"),error:g===null}:M))}finally{u(!1)}};return e.jsx(Ce,{open:!0,onOpenChange:h=>{h||r()},children:e.jsxs(Te,{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(Ee,{children:e.jsxs(Me,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Qs,{className:"h-4 w-4"}),l("sideQuestion.title")]})}),e.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-text-muted",children:l("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:l("sideQuestion.empty")}),s.map(h=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-br-md border border-user-bubble-border bg-user-bubble px-4 py-2 text-sm text-text-primary",children:h.question})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:24,height:24,className:"object-contain",draggable:!1})}),e.jsx("div",{className:"min-w-0 flex-1 pt-1 text-sm text-text-primary",children:h.answer===null?e.jsxs("span",{className:"chat-typing-indicator inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):e.jsx("div",{className:h.error?"text-status-error":"",children:e.jsx(Un,{children:h.answer})})})]})]},h.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:a,onChange:h=>d(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),p())},rows:Math.min(4,Math.max(1,a.split(`
|
|
81
|
+
`).length)),placeholder:l("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:l("sideQuestion.send"),children:c?e.jsx(Fe,{className:"h-4 w-4 animate-spin"}):e.jsx(Kn,{className:"h-4 w-4"})})]})]})})}const Nt="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-1";function _s(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 ka({requestId:r,toolName:t,toolInput:s,description:n,suggestions:a,onApprove:d,onApproveAlways:c,onReject:u}){ne();const p=s&&typeof s=="object"&&!Array.isArray(s)?s:{},h=Ln(Bn(t),p,{writeUnknownLabel:l("permission.writeUnknown")}),y=typeof s=="string"?s:JSON.stringify(s,null,2),g=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(Hn,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold font-display text-approve-text",children:l("permission.title")})]}),n&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:Z(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:Z(t)}),t!=="AskUserQuestion"&&(h?e.jsx("div",{className:"mb-3 space-y-2",children:h.map((N,M)=>e.jsx(Qn,{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:os(y,500)})),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:d,className:xe("rounded-lg bg-approve px-4 py-2 text-sm font-medium font-display text-white hover:bg-approve-hover transition-colors",Nt),children:l("permission.approve")}),g&&c&&e.jsxs("button",{onClick:c,className:xe("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",Nt),title:l("permission.alwaysAllowHint").replace("{rule}",_s(t,a)),children:[e.jsx(ta,{className:"h-3.5 w-3.5"}),l("permission.alwaysAllow")," ",os(_s(t,a),40)]}),e.jsx("button",{onClick:u,className:xe("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",Nt),children:l("permission.reject")})]})]})}function Na({questions:r,description:t,onSubmit:s,onSkip:n}){const[a,d]=i.useState({}),[c,u]=i.useState({}),[p,h]=i.useState(0),y=(C,j,x)=>{if(x){const f=a[C]||[],v=f.includes(j)?f.filter(_=>_!==j):[...f,j];d({...a,[C]:v})}else d({...a,[C]:j})},g=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[f,v]of Object.entries(a)){const _=r[parseInt(f,10)];_&&(typeof v=="number"?C[f]=((x=(j=_.options)==null?void 0:j[v])==null?void 0:x.label)||String(v):Array.isArray(v)?C[f]=v.map(A=>{var T,w;return((w=(T=_.options)==null?void 0:T[A])==null?void 0:w.label)||String(A)}):C[f]=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:Z(t||C.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(C.options||[]).map((x,f)=>{const v=j?(a[0]||[]).includes(f):a[0]===f;return e.jsxs("button",{onClick:()=>y(0,f,j),className:xe("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:Z(x.label)}),x.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:Z(x.description)})]},f)}),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"&&g(0)}),e.jsx("button",{onClick:()=>g(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:Z(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:r.map((C,j)=>e.jsx("button",{onClick:()=>h(j),className:xe("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(Sa,{question:M,qIdx:p,answers:a,otherTexts:c,onSelect:y,onOtherTextChange:(C,j)=>u({...c,[C]:j}),onOtherSubmit:g}),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 Sa({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:Z(r.question)}),e.jsxs("div",{className:"space-y-2",children:[(r.options||[]).map((p,h)=>{const y=u?(s[t]||[]).includes(h):s[t]===h;return e.jsxs("button",{onClick:()=>a(t,h,u),className:xe("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",y?"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:Z(p.label)}),p.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:Z(p.description)})]},h)}),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 _a({planContent:r,description:t,onSubmit:s}){const[n,a]=i.useState(null),[d,c]=i.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:Ca(r)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Oe,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes"}),e.jsx(Oe,{selected:n==="no",onClick:()=>a("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{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(Oe,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(Oe,{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:h=>c(h.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm 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 Oe({selected:r,onClick:t,label:s,desc:n}){return e.jsxs("button",{onClick:t,className:xe("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:xe("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 Ca(r){let t=Z(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 Ta({request:r,onSubmit:t}){ne();const s=Ea(r.requestedSchema),n=Ma(r.requestedSchema),[a,d]=i.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(Cs,{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(Nr,{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:l("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:l("common.cancel")})]})]}):e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Cs,{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:l("elicitation.required")})]}),p.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:Z(p.description)}),e.jsx("input",{type:p.type==="number"?"number":"text",value:a[u]??"",onChange:h=>d(y=>({...y,[u]:h.target.value})),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const u={};for(const{name:p,prop:h}of s){const y=(a[p]??"").trim();y&&(u[p]=h.type==="number"?Number(y):y)}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:l("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:l("elicitation.decline")})]})]})}function Cs({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(Qr,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-sm font-semibold text-text-primary",children:[l("elicitation.title")," ",e.jsx("span",{className:"font-mono text-xs text-text-muted",children:Z(r)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:Z(t)})]})}function Ea(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 Ma(r){const t=r==null?void 0:r.required;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function Ra(r){const[t,s]=i.useState([]),[n,a]=i.useState(!0),[d,c]=i.useState(null),u=i.useCallback(async()=>{a(!0),c(null);try{const y=await Wn(r);s(y)}catch(y){c(y instanceof Error?y.message:"Failed to load shares")}finally{a(!1)}},[r]);i.useEffect(()=>{u()},[u]);const p=i.useCallback(async y=>{c(null);try{const g=await zn(r,y);return await u(),g}catch(g){throw c(g instanceof Error?g.message:"Failed to create share"),g}},[r,u]),h=i.useCallback(async y=>{c(null);try{await Vn(r,y),await u()}catch(g){throw c(g instanceof Error?g.message:"Failed to revoke share"),g}},[r,u]);return{shares:t,isLoading:n,error:d,createShare:p,revokeShare:h,refresh:u}}function Aa({open:r,onClose:t,sessionId:s,sessionTitle:n}){ne();const{shares:a,isLoading:d,error:c,createShare:u,revokeShare:p}=Ra(s),[h,y]=i.useState("user"),[g,N]=i.useState(""),[M,C]=i.useState(""),[j,x]=i.useState("read"),[f,v]=i.useState(""),[_,A]=i.useState(!1),[T,w]=i.useState(null),[E,I]=i.useState(""),[$,S]=i.useState(!1),[K,F]=i.useState(!1);i.useEffect(()=>{r&&(y("user"),N(""),C(""),x("read"),v(""),A(!1),w(null),I(""),S(!1),F(!1))},[r]);const Y=async()=>{A(!0),I(""),w(null);try{const O={grantedTo:h==="user"?{userId:g.trim()}:{teamId:M.trim()},permission:j};f.trim()&&(O.expiresAt=f.trim());const te=await u(O);w(`${window.location.origin}/code/s/${te.shareToken}`)}catch(O){I(O instanceof Error?O.message:"Failed to create share")}finally{A(!1)}},J=async O=>{try{await p(O)}catch{}},ee=async()=>{if(!T)return;F(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),S(!0),setTimeout(()=>S(!1),2e3);return}}catch{}const O=document.createElement("textarea");O.value=T,O.style.position="fixed",O.style.opacity="0",document.body.appendChild(O),O.select();try{document.execCommand("copy"),S(!0),setTimeout(()=>S(!1),2e3)}catch{F(!0)}document.body.removeChild(O)};return e.jsx(Ce,{open:r,onOpenChange:O=>{O||t()},children:e.jsxs(Te,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ee,{children:e.jsxs(Me,{className:"font-display text-lg font-semibold text-text-primary",children:[l("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:l("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>y("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${h==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:l("share.user")}),e.jsx("button",{onClick:()=>y("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${h==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:l("share.team")})]}),h==="user"?e.jsx(vr,{onSelect:N,placeholder:l("share.userIdPlaceholder"),actionLabel:l("share.selectUser")}):e.jsx("input",{type:"text",value:M,onChange:O=>C(O.target.value),placeholder:l("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),h==="user"&&g&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[l("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:g})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:l("share.permission")}),e.jsxs("select",{value:j,onChange:O=>x(O.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:l("share.permissionRead")}),e.jsx("option",{value:"write",children:l("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:l("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:f,onChange:O=>v(O.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:l("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:ee,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:$?l("share.copied"):l("share.copy")})]}),K&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:l("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:l("share.existingShares")}),d?e.jsx("p",{className:"text-sm text-text-muted",children:l("share.loading")}):a.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:l("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:a.map(O=>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:O.granted_to_user||O.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[O.permission==="write"?l("share.permissionWrite"):l("share.permissionRead"),O.expires_at?` · expires ${O.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>J(O.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:l("share.revoke")})]},O.id))})]})]}),e.jsxs(br,{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:l("common.close")}),e.jsx("button",{onClick:Y,disabled:_||(h==="user"?!g.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:_?l("common.creating"):l("share.createShare")})]})]})})}function Ia(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",l("resume.today")],["yesterday",l("resume.yesterday")],["earlier",l("resume.earlier")]].map(([c,u])=>({label:u,items:a[c]})).filter(c=>c.items.length>0)}function $a(r){return r?new Date(r).toLocaleString():""}function Da({open:r,onClose:t,adapter:s,onResume:n}){const a=ne(),[d,c]=i.useState([]),[u,p]=i.useState(!1),[h,y]=i.useState("");i.useEffect(()=>{if(!r)return;let N=!1;return p(!0),y(""),c([]),s.listResumableSessions().then(M=>{N||c(M)}).catch(M=>{N||y(M instanceof Error?M.message:String(M))}).finally(()=>{N||p(!1)}),()=>{N=!0}},[r,s]);const g=i.useMemo(()=>Ia(d),[d,a]);return e.jsx(Ce,{open:r,onOpenChange:N=>{N||t()},children:e.jsxs(Te,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ee,{children:e.jsx(Me,{className:"font-display text-lg font-semibold text-text-primary",children:l("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:l("resume.loading")}),!u&&h&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:h}),!u&&!h&&d.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:l("resume.empty")}),!u&&!h&&g.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:[$a(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:l("common.cancel")})})]})})}const Ts=["working","episodic","semantic","procedural"];function qa(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 Pa(r){try{return new Date(r).toLocaleDateString()}catch{return"—"}}function Oa({refreshTick:r,recall:t,dreaming:s,onDreamTrigger:n}){ne();const[a,d]=i.useState(null),[c,u]=i.useState("memories"),[p,h]=i.useState("personal"),[y,g]=i.useState([]),[N,M]=i.useState(!1),[C,j]=i.useState(""),[x,f]=i.useState(null),[v,_]=i.useState({}),[A,T]=i.useState(null),[w,E]=i.useState(""),[I,$]=i.useState(""),[S,K]=i.useState(null),[F,Y]=i.useState(null),[J,ee]=i.useState(""),[O,te]=i.useState(null),[be,je]=i.useState(!1),le=i.useRef(null);i.useEffect(()=>{Ks().then(d).catch(()=>d(null))},[]);const Re=i.useCallback(async()=>{M(!0),j("");try{g(await Gn(p))}catch{j(l("memorySidebar.loadFailed"))}finally{M(!1)}},[p]);i.useEffect(()=>{(a==null?void 0:a.mode)==="memdir"&&Re()},[a==null?void 0:a.mode,Re,r]),i.useEffect(()=>{c!=="governance"||(a==null?void 0:a.mode)!=="memdir"||Yn().then(Y).catch(()=>Y(null))},[c,a==null?void 0:a.mode,r]),i.useEffect(()=>{le.current&&clearTimeout(le.current);const b=I.trim();if(!b){K(null);return}return le.current=setTimeout(()=>{Jn(b).then(K).catch(()=>K([]))},300),()=>{le.current&&clearTimeout(le.current)}},[I]);const Qe=async b=>{if(x===b){f(null);return}if(f(b),!v[b])try{const{content:P}=await is(b);_(se=>({...se,[b]:P}))}catch{_(P=>({...P,[b]:l("memorySidebar.loadFailed")}))}},ce=async b=>{if(v[b])E(v[b]);else try{const{content:P}=await is(b);_(se=>({...se,[b]:P})),E(P)}catch{E("")}T(b)},re=async()=>{if(A)try{await nr(A,w),_(b=>({...b,[A]:w})),T(null)}catch{j(l("memorySidebar.updateFailed"))}},Q=async b=>{try{await sr(b),g(P=>P.filter(se=>se.path!==b)),f(P=>P===b?null:P)}catch{j(l("memorySidebar.deleteFailed"))}},pe=async b=>{try{await tr(b),await Re()}catch(P){j(P instanceof Error?P.message:l("memorySidebar.promoteFailed"))}},he=()=>{n==null||n()},ae=i.useCallback(async()=>{const b=J.trim();if(!(!b||be)){je(!0),te(null);try{te(await Xn(b,5))}catch{te([])}finally{je(!1)}}},[J,be]),V=(a==null?void 0:a.teamEnabled)===!0,fe=a==null?void 0:a.automation,We=V&&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:l("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:l("memorySidebar.governanceTab")}),e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e.jsx(ot,{className:"h-3 w-3 text-text-muted"}),e.jsx("input",{value:I,onChange:b=>$(b.target.value),placeholder:l("memorySidebar.searchPlaceholder"),title:l("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}),fe&&fe.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:fe.mode==="sa"?l("memorySidebar.saModeBanner"):l("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:l("memorySidebar.noResults")}):e.jsx("ul",{className:"space-y-1",children:S.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>void Qe(b.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:b.name}),e.jsx("ul",{className:"mt-0.5 space-y-0.5",children:b.matches.map((P,se)=>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:P.line===0?"file":`L${P.line}`}),e.jsx("span",{className:"truncate text-text-secondary",children:P.text})]},se))})]})},b.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:l("memorySidebar.recallTitle")}),e.jsxs("p",{className:"mb-1 truncate text-[10px] text-text-muted",title:t.query,children:[l("memorySidebar.recallQuery"),": ",t.query]}),e.jsx("ul",{className:"space-y-0.5",children:t.hits.slice(0,5).map(b=>e.jsxs("li",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"truncate text-text-secondary",children:b.path.replace(/^team\//,"").replace(/\.md$/,"")}),b.score!==void 0&&e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:[(b.score*100).toFixed(0),"%"]})]},b.path))})]}),We&&e.jsx("div",{className:"mb-2 flex rounded-md bg-surface-2 p-0.5 text-xs",children:["personal","team"].map(b=>e.jsx("button",{type:"button",onClick:()=>h(b),className:`flex-1 rounded px-2 py-1 ${p===b?"bg-brand-light text-white":"text-text-muted"}`,children:b==="personal"?l("memorySidebar.personal"):l("memorySidebar.team")},b))}),N?e.jsx("div",{className:"space-y-2",children:[0,1,2].map(b=>e.jsx("div",{className:"h-12 animate-pulse rounded-md bg-surface-2"},b))}):y.length===0?e.jsxs("div",{className:"py-10 text-center",children:[e.jsx(Ct,{className:"mx-auto h-6 w-6 text-text-muted/40"}),e.jsx("p",{className:"mt-2 text-xs text-text-muted",children:l("memorySidebar.empty")})]}):e.jsx("ul",{className:"space-y-1",children:y.map(b=>e.jsxs("li",{className:"group rounded-md hover:bg-surface-2",children:[e.jsxs("button",{type:"button",onClick:()=>void Qe(b.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:b.name}),b.type&&e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[9px] font-medium ${qa(b.type)}`,children:b.type}),e.jsx("span",{className:"ml-auto flex-shrink-0 text-[9px] text-text-muted",children:Pa(b.mtimeMs)})]}),b.description&&e.jsx("p",{className:"mt-0.5 truncate text-[10px] text-text-muted",children:b.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 ce(b.path),className:"rounded p-1 text-text-secondary hover:bg-surface-3 hover:text-text-primary",title:l("memorySidebar.edit"),children:e.jsx(Zn,{className:"h-3 w-3"})}),b.scope==="personal"&&V&&e.jsx("button",{type:"button",onClick:()=>void pe(b.path),className:"rounded p-1 text-text-secondary hover:bg-surface-3 hover:text-text-primary",title:l("memorySidebar.promote"),children:e.jsx(er,{className:"h-3 w-3"})}),e.jsx("button",{type:"button",onClick:()=>void Q(b.path),className:"ml-auto rounded p-1 text-text-secondary hover:bg-status-error/10 hover:text-status-error",title:l("memorySidebar.delete"),children:e.jsx(Us,{className:"h-3 w-3"})})]}),x===b.path&&A!==b.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[b.path]??"…"}),x===b.path&&A===b.path&&e.jsxs("div",{className:"mx-2 mb-2",children:[e.jsx("textarea",{value:w,onChange:P=>E(P.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 re(),className:"rounded bg-accent px-2 py-0.5 text-[10px] font-medium text-white hover:bg-accent/90",children:l("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:l("memorySidebar.cancel")})]})]})]},b.path))})]}),S===null&&c==="governance"&&e.jsx("div",{className:"flex-1 overflow-y-auto p-3 text-xs",children:F?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("button",{type:"button",disabled:s||!F.automation.autoDream,onClick:he,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(Sr,{className:"h-3.5 w-3.5"}),s?l("memorySidebar.dreaming"):l("memorySidebar.dream")]}),!F.automation.autoDream&&e.jsx("p",{className:"mt-1 text-center text-[10px] text-text-muted",children:l("memorySidebar.dreamDisabled")})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:l("memorySidebar.recallTest.title")}),e.jsx("p",{className:"mb-1.5 text-[10px] leading-relaxed text-text-muted",children:l("memorySidebar.recallTest.hint")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("input",{value:J,onChange:b=>ee(b.target.value),onKeyDown:b=>{b.key==="Enter"&&!b.nativeEvent.isComposing&&ae()},placeholder:l("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 ae(),disabled:be||!J.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:be?l("memorySidebar.recallTest.running"):l("memorySidebar.recallTest.run")})]}),O!==null&&e.jsx("ul",{className:"mt-1.5 space-y-0.5 rounded-md bg-surface-2 p-2",children:O.length===0?e.jsx("li",{className:"text-[10px] text-text-muted",children:l("memorySidebar.recallTest.noResults")}):O.map(b=>e.jsxs("li",{className:"flex items-center justify-between gap-2 text-xs",children:[e.jsx("span",{className:"truncate text-text-secondary",title:b.path,children:b.path.replace(/^team\//,"").replace(/\.md$/,"")}),e.jsxs("span",{className:"flex-shrink-0 text-[10px] text-text-muted",children:[(b.score*100).toFixed(0),"%",b.confidence!==void 0?` · conf ${b.confidence.toFixed(2)}`:""]})]},b.path))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:l("memorySidebar.layers")}),e.jsx("ul",{className:"space-y-1",children:Ts.map(b=>{const P=F.layers[b],se=Math.max(...Ts.map(we=>F.layers[we]),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:b}),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:`${P/se*100}%`}})}),e.jsx("span",{className:"w-6 text-right text-text-muted",children:P})]},b)})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-text-muted",children:l("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:l("memorySidebar.total")}),e.jsx("span",{children:F.health.totalMemories})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:l("memorySidebar.capacity")}),e.jsxs("span",{className:F.health.capacity.tier==="critical"?"text-status-error":F.health.capacity.tier==="warning"?"text-status-warning":"text-status-active",children:[F.health.capacity.utilizationPct.toFixed(0),"% · ",F.health.capacity.tier]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{children:l("memorySidebar.avgConfidence")}),e.jsx("span",{children:F.health.avgConfidence.toFixed(2)})]})]})]}),F.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:[l("memorySidebar.alerts")," (",F.alerts.length,")"]}),e.jsx("ul",{className:"space-y-1 rounded-md bg-status-warning/5 p-2",children:F.alerts.slice(-8).reverse().map((b,P)=>e.jsx("li",{className:"text-[10px] leading-relaxed text-text-secondary",children:b},P))})]}),F.conflicts&&e.jsxs("div",{children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-status-warning",children:l("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:F.conflicts})]})]}):e.jsx("p",{className:"py-10 text-center text-text-muted",children:l("memorySidebar.loadFailed")})})]})}class Fa{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,Es(n),"send")})}catch(n){this.rollback(s,Es(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 Es(r){return r instanceof Error?r.message:String(r)}function nt(r){const t=i.useRef(r);t.current=r;const s=i.useRef(null);s.current||(s.current=new Fa(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 i.useEffect(()=>{n.adoptExternal(r.value)}),i.useMemo(()=>({set:a=>n.set(a),handleControlResponse:a=>n.handleControlResponse(a),sync:a=>n.sync(a)}),[n])}const Ys="rcs_context_usage_";function Js(){try{if(typeof localStorage<"u")return localStorage}catch{}return null}function Ms(){return{totalTokens:0,rawMaxTokens:0,percentage:0}}function Ua(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 Ka(r,t=Js()){if(!t||!r)return null;try{const s=t.getItem(Ys+r);return s?Ua(JSON.parse(s)):null}catch{return null}}function La(r,t,s=Js()){if(!(!s||!r))try{s.setItem(Ys+r,JSON.stringify(t))}catch{}}function Ba(r){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${r}`}function Ha(r){const t=Ba(r),s=ar(),n=s?{proxyUrl:t,token:s}:{proxyUrl:t};return new rr(n)}const Ne=[{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"}],Rs="rcs_permission_mode";function Se(r){return r<1e3?String(r):r<1e6?`${(r/1e3).toFixed(1)}k`:`${(r/1e6).toFixed(1)}M`}function Qa(r){const t=Ne.findIndex(s=>s.value===r);return Ne[(t+1+Ne.length)%Ne.length].value}const it=[{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}],As="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"}],Is=r=>r.labelKey?l(r.labelKey):r.label,$s=r=>r.labelKey?l(r.labelKey):r.label,Ds="rcs_effort",qs=[{value:"normal",descKey:"session.tokenMode.normalDesc"},{value:"poor",descKey:"session.tokenMode.poorDesc"},{value:"sa",descKey:"session.tokenMode.saDesc"}],Ps="rcs_token_mode";function Wa(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 za({budget:r,onBudgetChange:t,disabled:s}){const[n,a]=i.useState(!1),d=it.find(c=>c.value===r);return e.jsxs(Ue,{open:n,onOpenChange:a,children:[e.jsx(Ke,{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:l("session.thinking.title"),children:[e.jsx(Ct,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?$s(d):l("session.thinking.fallback")}),n?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:it.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:$s(c)}),e.jsx("div",{className:"text-xs text-text-muted",children:c.descKey?l(c.descKey):c.description})]})]},c.value))})]})}function Va({effort:r,onEffortChange:t,disabled:s}){const[n,a]=i.useState(!1),d=_t.find(c=>c.value===r);return e.jsxs(Ue,{open:n,onOpenChange:a,children:[e.jsx(Ke,{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:l("session.effort.title"),children:[e.jsx(qr,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?Is(d):l("session.effort.fallback")}),n?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{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:Is(c)}),e.jsx("div",{className:"text-xs text-text-muted",children:l(c.descKey)})]})]},c.value))})]})}function Ga({mode:r,onModeChange:t,disabled:s}){const[n,a]=i.useState(!1),d=qs.find(c=>c.value===r);return e.jsxs(Ue,{open:n,onOpenChange:a,children:[e.jsx(Ke,{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:l("session.tokenMode.title"),children:[e.jsx(Ir,{className:"h-3 w-3"}),e.jsx("span",{className:`max-w-24 truncate ${r!=="normal"?"font-medium text-brand-text":""}`,children:d?l(`session.tokenMode.${d.value}`):l("session.tokenMode.fallback")}),n?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:qs.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:l(`session.tokenMode.${c.value}`)}),e.jsx("div",{className:"text-xs text-text-muted",children:l(c.descKey)})]})]},c.value))})]})}const Ya=new Set(["Free space","Autocompact buffer","Compact buffer"]),Os=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function Ja({usage:r}){const t=Math.min(100,Math.max(0,r.percentage)),s=t>=80,n=(r.categories??[]).filter(u=>!u.isDeferred&&!Ya.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:Se(r.totalTokens),max:Se(r.rawMaxTokens)})}${r.model?` · ${r.model}`:""}`,...n.slice(0,8).map(u=>`${u.name}: ${Se(u.tokens)}`),...a.slice(0,3).map(u=>`${u.name}${l("session.context.deferredSuffix")}: ${Se(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":Os[p%Os.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 Xa({models:r,currentModelId:t,onSelect:s,disabled:n}){const[a,d]=i.useState(!1),c=r.find(h=>h.modelId===t)??null,u=r.length>0,p=async h=>{s(h.modelId),d(!1)};return e.jsxs(Ue,{open:a,onOpenChange:u?d:void 0,children:[e.jsx(Ke,{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:l("session.model.title"),children:[e.jsx(Hs,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(c==null?void 0:c.name)??t??l("session.model.title")}),a?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-72 p-0",align:"start",children:e.jsx(yr,{models:r,currentModelId:t,onSelect:p,showSearch:r.length>5})})]})}function Za({mode:r,onModeChange:t,disabled:s}){const[n,a]=i.useState(!1),d=Ne.find(c=>c.value===r);return e.jsxs(Ue,{open:n,onOpenChange:a,children:[e.jsx(Ke,{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:l("session.mode.title"),children:[e.jsx(fr,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?l(d.labelKey):r}),n?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:Ne.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:l(c.labelKey)}),e.jsx("div",{className:"text-xs text-text-muted",children:l(c.descKey)})]})]},c.value))})]})}function yo({sessionId:r,onBack:t}){var ss;ne();const[s,n]=i.useState(null),[a,d]=i.useState(null),[c,u]=i.useState(""),[p,h]=i.useState(!1),[y,g]=i.useState(!1),[N,M]=i.useState(!1),[C,j]=i.useState(!1),[x,f]=i.useState(!1),[v,_]=i.useState(!1),[A,T]=i.useState(""),[w,E]=i.useState(0),I=i.useRef(null),[$,S]=i.useState({text:"",nonce:0}),[K,F]=i.useState(!1),[Y,J]=i.useState(!1),[ee,O]=i.useState(!1),[te,be]=i.useState(!1),[je,le]=i.useState(0),[Re,Qe]=i.useState(0),[ce,re]=i.useState([]),[Q,pe]=i.useState(!1),[he,ae]=i.useState([]),[V,fe]=i.useState(null),[We,b]=i.useState(()=>St()),[P,se]=i.useState(null),[we,Xs]=i.useState(()=>localStorage.getItem(As)||"off"),[Zs,Tt]=i.useState(()=>Ka(r)),[lt,ct]=i.useState(!0),[Ae,en]=i.useState(null),[Et,tn]=i.useState(null),[ze,Mt]=i.useState(null),[Ve,Ge]=i.useState([]),[sn,dt]=i.useState(!1),[ut,Rt]=i.useState(""),mt=i.useRef(null),[Ye,nn]=i.useState(()=>localStorage.getItem(Rs)||"default"),[At,It]=i.useState(null),Ie=i.useRef(null),[$t,Dt]=i.useState(null),$e=i.useRef(null),oe=i.useRef(null),qt=i.useRef(ce);qt.current=ce;const Je=i.useRef(null);Je.current||(Je.current=new Er(Mr()));const Pt=i.useRef(r);Pt.current=(s==null?void 0:s.title)||r,i.useEffect(()=>{var o;(o=Je.current)==null||o.reset()},[r]);const ie=i.useCallback(o=>{It(o),Ie.current&&clearTimeout(Ie.current),Ie.current=setTimeout(()=>It(null),5e3)},[]),de=i.useCallback(o=>{Dt(o),$e.current&&clearTimeout($e.current),$e.current=setTimeout(()=>Dt(null),5e3)},[]),Xe=nt({value:Ye,apply:o=>{nn(o);try{localStorage.setItem(Rs,o)}catch{}},send:o=>{const m=oe.current;return m?m.setPermissionMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,m)=>{console.error("[SessionDetail] set permission mode failed:",o),ie(m==="send"?H("session.mode.switchFailedRequest",{message:o}):o||l("session.mode.switchFailed"))}}),xt=i.useCallback(o=>Xe.set(o),[Xe]),[Ot,rn]=i.useState(()=>localStorage.getItem(Ps)||"normal"),Ze=nt({value:Ot,apply:o=>{rn(o);try{localStorage.setItem(Ps,o)}catch{}},send:o=>{const m=oe.current;return m?m.setTokenMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,m)=>{console.error("[SessionDetail] set token mode failed:",o),ie(m==="send"?H("session.tokenMode.failedRequest",{message:o}):o||l("session.tokenMode.failed"))}}),pt=nt({value:we,apply:o=>{Xs(o);try{localStorage.setItem(As,o)}catch{}},send:o=>{var R;const m=oe.current;if(!m)return Promise.reject(new Error("adapter not ready"));const k=((R=it.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),ie(m==="send"?H("session.thinking.failedRequest",{message:o}):o||l("session.thinking.failed"))}}),U=i.useMemo(()=>new aa(r,re,{onStatusChange:o=>{var m;d(o),pe(o==="running"||o==="requires_action"),(m=Je.current)==null||m.onStatus(o,Pt.current)},onError:o=>{console.error("[RCSChatAdapter] error:",o)},onPermissionRequest:o=>{ae(m=>m.some(k=>k.requestId===o.requestId)?m:[...m,o])},onModelsStateChange:o=>{fe(o)},onSubagentUpdate:o=>{b(o)},onControlResponse:o=>{pt.handleControlResponse(o)||Ze.handleControlResponse(o)||Bt.handleControlResponse(o)||Xe.handleControlResponse(o)},onPermissionModeChange:o=>{Xe.sync(o)},onUsageChange:o=>{en(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=>{se(m=>JSON.stringify(m)===JSON.stringify(o)?m:o)},onTurnStart:o=>{tn(o)},onElicitationRequest:o=>{Mt(o)}}),[r,ie]);i.useEffect(()=>(oe.current=U,()=>{U.disconnect()}),[U]);const L=i.useMemo(()=>Wa(P),[P]),Ft=i.useRef(!1);i.useEffect(()=>{var k;if(!L.set_max_thinking_tokens||Ft.current)return;const o=oe.current;if(!o)return;const m=((k=it.find(R=>R.value===we))==null?void 0:k.tokens)??null;o.setThinkingBudget(m).then(()=>{Ft.current=!0}).catch(R=>console.error("[SessionDetail] reconcile thinking budget failed:",R))},[L.set_max_thinking_tokens,we,P]);const Ut=L.stop_task?o=>{U.stopSubagent(o).then(m=>{m.ok||de(m.error||l("session.stopTask.failed"))})}:void 0,Kt=i.useRef(!1);i.useEffect(()=>{if(!L.set_token_mode||Kt.current)return;const o=oe.current;o&&(Kt.current=!0,o.getRemoteSettings().then(m=>{const k=m==null?void 0:m.applied.tokenMode;(k==="normal"||k==="poor"||k==="sa")&&Ze.sync(k)}).catch(m=>console.error("[SessionDetail] reconcile token mode failed:",m)))},[L.set_token_mode,Ze]);const an=ne(),ht=i.useMemo(()=>or((P==null?void 0:P.commands)??[],(P==null?void 0:P.skills)??[]),[P,an]),ve=i.useMemo(()=>ir(ce,A),[ce,A]),on=i.useCallback(o=>pt.set(o),[pt]),[Lt,ln]=i.useState(()=>localStorage.getItem(Ds)||"auto"),Bt=nt({value:Lt,apply:o=>{ln(o);try{localStorage.setItem(Ds,o)}catch{}},send:o=>{var R;const m=oe.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),ie(m==="send"?H("session.effort.failedRequest",{message:o}):o||l("session.effort.failed"))}}),ft=i.useCallback(()=>{var o;L.get_context_usage&&((o=oe.current)==null||o.getContextUsage().then(m=>{m&&(Tt(m),La(r,m))}).catch(()=>{}).finally(()=>ct(!1)))},[L,r]);i.useEffect(()=>{if(!L.get_context_usage)return;ft();const o=setInterval(ft,6e4);return()=>clearInterval(o)},[L,Q,ft]),i.useEffect(()=>{P&&!L.get_context_usage&&ct(!1)},[P,L]),i.useEffect(()=>{if(!lt)return;const o=setTimeout(()=>ct(!1),1e4);return()=>clearTimeout(o)},[lt]);const Ht=i.useRef(ee);Ht.current=ee,i.useEffect(()=>me.onEvent(m=>{m.type!=="artifact_created"&&m.type!=="artifact_updated"||(Ht.current&&Qe(k=>k+1),le(k=>k+1))}),[]);const[Qt,et]=i.useState(0),Wt=i.useRef(te);Wt.current=te;const[De,zt]=i.useState(null),[ue,cn]=i.useState(!1),[yt,Vt]=i.useState(0),[dn,un]=i.useState(void 0),gt=i.useRef(ue);gt.current=ue,i.useEffect(()=>me.onEvent(m=>{m.type==="memory_synced"&&Wt.current&&et(k=>k+1)}),[]),i.useEffect(()=>{Ks().then(o=>zt(o.mode)).catch(()=>zt("sqlite"))},[]),i.useEffect(()=>me.onEvent(m=>{var k,R;if(m.type==="memory_changed")gt.current?et(D=>D+1):Vt(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&&un({query:typeof((R=m.payload)==null?void 0:R.query)=="string"?m.payload.query:"",hits:D}),gt.current&&et(z=>z+1)}}),[]),i.useEffect(()=>{ue&&Vt(0)},[ue]);const[qe,mn]=i.useState("idle");i.useEffect(()=>me.onStateChange(m=>mn(m)),[]),i.useEffect(()=>{ee&&le(0)},[ee]),i.useEffect(()=>{let o=!1;async function m(){u("");try{const k=await us(r);if(o)return;n(k),d(k.status),rt(k.status)&&U.markClosed(),pe(k.status==="running"||k.status==="requires_action")}catch(k){if(o)return;u(k instanceof Error?k.message:l("session.loadFailed"));return}try{await U.init()}catch(k){console.warn("Failed to init adapter:",k)}}return m(),()=>{o=!0}},[r,U]);const B=rt(a),Gt=i.useRef(a);Gt.current=a,i.useEffect(()=>{if(B)return;let o=!1;const k=setInterval(async()=>{try{const R=await us(r);if(o||R.status===Gt.current)return;rt(R.status)&&U.markClosed(),d(R.status),pe(R.status==="running"||R.status==="requires_action")}catch{}},6e4);return()=>{o=!0,clearInterval(k)}},[r,B,U]);const W=(s==null?void 0:s.access_level)==="read",Yt=Zs??(lt&&!B&&!W?Ms():null),bt=i.useCallback(()=>{re([]),Tt(Ms()),ls(r).catch(o=>{console.warn("[SessionDetail] Failed to clear session history:",o)})},[r]),Pe=i.useCallback(async(o,m)=>{const k=oe.current;if(!k||B)return;if(o.sessionId===r){re(D=>[...D,{type:"command_output",id:`cmd-resume-${Date.now()}`,commandName:"resume",inputText:m??"/resume",title:"Resume",subtitle:l("session.resume.title"),outputText:l("session.resume.currentBlocked"),variant:"error"}]);return}const R=(D,z="default")=>re(ye=>[...ye,{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:l("session.resume.title"),outputText:D,variant:z}]);R(H("session.resume.restoring",{title:o.title??""}));try{await ls(r),re([]);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]),xn=i.useCallback(async()=>{if(s!=null&&s.environment_id)try{const o=await lr({environment_id:s.environment_id});window.location.href=`/code/${o.id}?resumeFrom=${r}`}catch(o){de(H("session.createFailedWithReason",{message:o instanceof Error?o.message:String(o)}))}},[s,r,de]),pn=i.useRef(new URLSearchParams(window.location.search).get("resumeFrom")),Jt=i.useRef(!1);i.useEffect(()=>{const o=pn.current;!o||Jt.current||!P||!L.resume||(Jt.current=!0,window.history.replaceState({},"",window.location.pathname),Pe({sessionId:o,title:o.slice(0,8),modified:0},null))},[P,L.resume,Pe]);const ke=i.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 z=(R[1]??"").trim();if(!L.resume){re(ye=>[...ye,{type:"user_message",id:`user-${Date.now()}`,content:m},{type:"command_output",id:`cmd-${Date.now()}`,commandName:"resume",inputText:m,title:"Resume",subtitle:l("session.resume.title"),outputText:l("session.resume.unsupported"),variant:"error"}]);return}z?await Pe({sessionId:z,title:z,modified:0},m):f(!0);return}const D=await cr(m,{sessionId:r,availableCommands:ht,availableModels:(V==null?void 0:V.availableModels)??[],currentModel:V?{modelId:V.currentModelId,name:V.currentModelId}:null,supportsImages:!0,entries:qt.current,setModel:async z=>{await X(r,{type:"control_request",request:{subtype:"set_model",model:z}}),fe(ye=>ye&&{...ye,currentModelId:z})},onNewSession:()=>{re([])}}).catch(()=>null);if(D){if(at("[SessionDetail] local command result",D),"clearEntries"in D&&D.clearEntries){bt();return}if("newSession"in D&&D.newSession){bt();return}if("userEntry"in D){re(z=>[...z,D.userEntry,D.cmdEntry]);return}}pe(!0);try{await U.sendMessage(m,o.images,o.attachments)}catch(z){if(console.error("Send failed:",z),z instanceof dr&&z.type==="session_closed"){d("archived"),U.markClosed(),de(l("session.closedSendBlocked"));return}de(`${l("session.sendFailed")}${z instanceof Error?`: ${z.message}`:""}`)}},[U,B,r,V,ht,bt,de,Pe,L]),hn=i.useCallback(o=>{if(Q){Ge(m=>[...m,o]);return}ke(o)},[Q,ke]),[jt,Xt]=i.useState(!1),fn=i.useCallback(()=>{Q||(Xt(!0),ke({text:"/dream"}))},[Q,ke]);i.useEffect(()=>{!Q&&jt&&(Xt(!1),et(o=>o+1))},[Q,jt]);const wt=i.useRef(!1);i.useEffect(()=>{if(B){Ge(m=>m.length>0?[]:m);return}if(Q||Ve.length===0||wt.current)return;const o=Ve[0];o&&(wt.current=!0,Ge(m=>m.slice(1)),ke(o).finally(()=>{wt.current=!1}))},[Q,Ve,ke,B]);const Zt=i.useCallback((o,m)=>{if(Q)return;const k=m==="edit"?l("session.rewind.confirmEdit"):l("session.rewind.confirm");window.confirm(`${k}
|
|
83
|
+
${l("session.rewind.confirmBody")}`)&&U.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),de(H("session.rewind.failed",{message:R instanceof Error?R.message:String(R)}))})},[Q,de]),yn=i.useCallback(o=>{const m=ve.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"})},[ve]),es=i.useCallback(async()=>{try{await U.interrupt()}catch(o){console.error("Interrupt failed:",o)}finally{pe(!1)}},[U]),gn=i.useCallback(()=>{xt(Qa(Ye))},[xt,Ye]);i.useEffect(()=>()=>{Ie.current&&clearTimeout(Ie.current),$e.current&&clearTimeout($e.current)},[]);const bn=i.useCallback(async()=>{if(s&&window.confirm(l("dashboard.confirmDelete").replace("{id}",s.title||s.id)))try{await cs(s.id),window.location.href="/code/"}catch(o){alert(o instanceof Error?o.message:l("dashboard.deleteFailed"))}},[s]),jn=i.useCallback(async o=>{try{await U.respondPermission(o,!0)}catch(m){console.error("Failed to approve:",m)}ae(m=>m.filter(k=>k.requestId!==o))},[U]),wn=i.useCallback(async(o,m)=>{try{await U.respondPermission(o,!0,{updated_permissions:m})}catch(k){console.error("Failed to approve with rules:",k)}ae(k=>k.filter(R=>R.requestId!==o))},[U]),vn=i.useCallback(async(o,m)=>{const k=ze;if(Mt(null),!!k)try{await U.respondElicitation(k.requestId,o,m)}catch(R){console.error("Failed to submit elicitation:",R)}},[ze,U]),kn=i.useCallback(()=>{!s||W||(Rt(s.title||""),dt(!0),setTimeout(()=>{var o,m;(o=mt.current)==null||o.focus(),(m=mt.current)==null||m.select()},0))},[s,W]),ts=i.useCallback(async()=>{const o=ut.trim();if(dt(!1),!(!s||!o||o===s.title))try{const m=await ur(s.id,o);n(k=>k&&{...k,title:m.title??o})}catch(m){console.error("Rename failed:",m),alert(m instanceof Error?m.message:l("session.rename.failed"))}},[s,ut]),Nn=i.useCallback(async o=>{try{await U.respondPermission(o,!1)}catch(m){console.error("Failed to reject:",m)}ae(m=>m.filter(k=>k.requestId!==o))},[U]),Sn=i.useCallback(async(o,m,k)=>{try{await X(r,{type:"permission_response",approved:!0,request_id:o,updated_input:{questions:k,answers:m}})}catch(R){console.error("Failed to submit answers:",R)}ae(R=>R.filter(D=>D.requestId!==o))},[r]),_n=i.useCallback(async(o,m,k)=>{try{m==="no"?await X(r,{type:"permission_response",approved:!1,request_id:o,...k?{message:k}:{}}):await X(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)}ae(R=>R.filter(D=>D.requestId!==o))},[r]);return c?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(st,{onBack:t,title:e.jsx("span",{className:"text-xs font-medium text-text-muted",children:l("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:l("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(st,{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(to,{sessionId:r,agentId:s.environment_id})]}):e.jsx(Ls,{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(st,{onBack:t,title:sn?e.jsx("input",{ref:mt,value:ut,onChange:o=>Rt(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),ts()):o.key==="Escape"&&(o.preventDefault(),dt(!1))},onBlur:()=>void ts(),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:!W&&!B?e.jsx("button",{type:"button",onClick:kn,title:l("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(Cr,{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=ms(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:()=>O(!ee),className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${ee?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:l("artifacts.title"),children:[e.jsx(mr,{className:"h-3.5 w-3.5"}),je>0&&!ee&&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:je>9?"9+":je})]}),e.jsxs("button",{onClick:()=>{De==="memdir"?cn(!ue):be(!te)},className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${De==="memdir"?ue?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary":te?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:l("memories.title"),children:[e.jsx(Ct,{className:"h-3.5 w-3.5"}),De==="memdir"&&yt>0&&!ue&&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:yt>9?"9+":yt})]}),L.side_question&&!B&&!W&&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:l("session.sideQuestion.title"),children:e.jsx(Qs,{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:l("session.search.title"),children:e.jsx(ot,{className:"h-3.5 w-3.5"})}),L.mcp_management&&!B&&!W&&e.jsx("button",{onClick:()=>g(!y),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${y?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:l("session.mcp.title"),children:e.jsx(Ws,{className:"h-3.5 w-3.5"})}),L.remote_settings&&!B&&!W&&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:l("session.settings.title"),children:e.jsx(zs,{className:"h-3.5 w-3.5"})}),!W&&(s==null?void 0:s.access_level)!=="write"&&e.jsx("button",{onClick:()=>J(!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:l("session.share"),children:e.jsx(Zr,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>F(!K),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:l("session.info"),children:e.jsx(Ur,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>h(!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:[l("session.tasks"),he.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:he.length})]})]})})}),K&&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:l("session.metaSession")})," ",s.id]}),s.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:l("session.metaEnvironment")})," ",s.environment_id]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:l("session.metaStatus")})," ",a]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:l("session.metaWorker")})," ",ms(s.source==="acp"?"acp":(ss=s.environment)==null?void 0:ss.worker_type).fullLabel]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:l("session.metaCreated")})," ",Fs(s.created_at)]})]})})}),(qe==="reconnecting"||qe==="failed")&&e.jsxs("div",{className:`flex items-center justify-center gap-2 px-4 py-1.5 text-xs font-medium ${qe==="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 ${qe==="failed"?"bg-status-error":"animate-pulse bg-status-warning"}`}),qe==="failed"?l("session.sseFailed"):l("session.sseReconnecting")]}),ee&&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(_r,{sessionId:r,embedded:!0,refreshTick:Re})})}),te&&De!=="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(Tr,{sessionId:r,embedded:!0,refreshTick:Qt})})}),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(ot,{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(),yn(A&&o.shiftKey?w-1:w+1)):o.key==="Escape"&&(o.preventDefault(),_(!1),T(""))},placeholder:l("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:ve.orderedMatchIds.length===0?l("session.search.noResults"):`${w+1}/${ve.orderedMatchIds.length}`})]})}),De==="memdir"?e.jsxs("div",{className:"flex min-h-0 flex-1",children:[ue&&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(Oa,{refreshTick:Qt,recall:dn,dreaming:Q&&jt,onDreamTrigger:fn})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(ds,{entries:ce,isLoading:Q,turnStartedAt:Et,emptyTitle:l("session.emptyTitle"),emptyDescription:l("session.emptyDescription"),searchMatchIds:A.trim()?ve.matchIds:void 0,onRewindEntry:L.rewind&&!B&&!W&&!Q?(o,m)=>Zt(o,m):void 0})})]}):e.jsx(ds,{entries:ce,isLoading:Q,turnStartedAt:Et,emptyTitle:l("session.emptyTitle"),emptyDescription:l("session.emptyDescription"),searchMatchIds:A.trim()?ve.matchIds:void 0,onRewindEntry:L.rewind&&!B&&!W&&!Q?(o,m)=>Zt(o,m):void 0}),e.jsx(da,{state:We,onStopTask:Ut}),he.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:he.map(o=>e.jsx(eo,{request:o,onApprove:()=>jn(o.requestId),onApproveAlways:o.suggestions&&o.suggestions.length>0?()=>wn(o.requestId,o.suggestions??[]):void 0,onReject:()=>Nn(o.requestId),onSubmitAnswers:Sn,onSubmitPlan:_n},o.requestId))})}),ze&&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(Ta,{request:ze,onSubmit:vn})})}),$t&&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:$t})}),At&&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:At})}),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(Za,{mode:Ye,onModeChange:xt,disabled:B||W}),e.jsx(Xa,{models:(V==null?void 0:V.availableModels)??[],currentModelId:(V==null?void 0:V.currentModelId)??null,onSelect:o=>{X(r,{type:"control_request",request:{subtype:"set_model",model:o}}),fe(m=>m&&{...m,currentModelId:o})},disabled:B||W}),L.set_max_thinking_tokens&&e.jsx(za,{budget:we,onBudgetChange:on,disabled:B||W}),L.set_effort&&e.jsx(Va,{effort:Lt,onEffortChange:o=>Bt.set(o),disabled:B||W}),L.set_token_mode&&e.jsx(Ga,{mode:Ot,onModeChange:o=>Ze.set(o),disabled:B||W})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[Yt&&e.jsx(Ja,{usage:Yt}),Ae&&e.jsxs("span",{className:"text-[10px] text-text-muted font-mono",title:l("session.usage.total"),children:[Se(Ae.inputTokens)," in / ",Se(Ae.outputTokens)," out",Ae.totalCostUsd!=null&&` · $${Ae.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 xn(),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:l("session.resumeInNew")})}),e.jsx(xr,{onSubmit:hn,isLoading:Q,onInterrupt:es,onCycleMode:gn,disabled:B||W,placeholder:B?l("session.closed"):W?l("session.readOnly"):l("session.inputPlaceholder"),supportsAttachments:!0,commands:ht,queueWhileLoading:!0,queuedCount:Ve.length,onDequeue:o=>Ge(m=>m.filter((k,R)=>R!==o)),onSearchFiles:L.file_search?o=>U.searchFiles(o):void 0,historyKey:r,draftOverride:$}),y&&e.jsx(ba,{onClose:()=>g(!1),fetchServers:()=>U.getMcpServers(),onToggle:(o,m)=>U.toggleMcpServer(o,m),onReconnect:o=>U.reconnectMcpServer(o)}),N&&e.jsx(wa,{onClose:()=>M(!1),fetchSettings:()=>U.getRemoteSettings(),onApply:o=>U.applyFlagSettings(o)}),C&&e.jsx(va,{onClose:()=>j(!1),onAsk:o=>U.askSideQuestion(o)}),p&&s&&e.jsx(xa,{onClose:()=>h(!1),session:s,liveStatus:a,pendingPermissions:he,subagentState:We,onStopTask:Ut,onInterrupt:es,onDelete:bn,onEndSession:L.end_session&&!B&&!W?async()=>{await U.endSession("ended from web"),await cs(s.id),window.location.href="/code/"}:void 0}),e.jsx(Aa,{open:Y,onClose:()=>J(!1),sessionId:s.id,sessionTitle:s.title||void 0}),e.jsx(Da,{open:x,onClose:()=>f(!1),adapter:U,onResume:o=>{f(!1),Pe(o,null)}})]})}):e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(st,{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:l("session.loading")})})]})}function eo({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 h=u.questions||[];return e.jsx(Na,{requestId:r.requestId,questions:h,description:p,onSubmit:y=>a(r.requestId,y,h),onSkip:n})}if(c==="ExitPlanMode"){const h=u.plan||"";return e.jsx(_a,{requestId:r.requestId,planContent:h,description:p,onSubmit:(y,g)=>d(r.requestId,y,g)})}return e.jsx(ka,{requestId:r.requestId,toolName:c,toolInput:u,description:p,suggestions:r.suggestions,onApprove:t,onApproveAlways:s,onReject:n})}function to({sessionId:r,agentId:t}){const[s,n]=i.useState(null),[a,d]=i.useState("disconnected"),[c,u]=i.useState(null),p=i.useRef(null);return i.useEffect(()=>{const h=Ha(t);return h.setConnectionStateHandler((y,g)=>{d(y),u(g||null)}),p.current=h,n(h),h.connect().catch(y=>{y instanceof pr||(u(y.message),d("error"))}),()=>{h.disconnect(),p.current=null,n(null),d("disconnected")}},[t]),e.jsx(Ls,{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:l("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:l("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(hr,{client:s,agentId:t})})]})})}export{yo 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{aE as c,V as n,aC as i}from"./main-RGMHltl_.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{aZ as v,c as N,aS as t}from"./main-RGMHltl_.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{aq as m,b as h}from"./main-RGMHltl_.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};
|