@saluzi/saluzi-edu 0.2.52 → 0.2.54
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 +70 -63
- package/dist/guide/guide-data.json +3 -3
- package/dist/rcs-web/assets/{AdminPanel-BU_m2tTe.js → AdminPanel-BlettL5E.js} +1 -1
- package/dist/rcs-web/assets/Claim-Dx6kdKcg.js +1 -0
- package/{packages/remote-control-server/web/dist/assets/Dashboard-B4nxTeft.js → dist/rcs-web/assets/Dashboard-BIJynSOn.js} +2 -2
- package/{packages/remote-control-server/web/dist/assets/Join-KIjSy6RI.js → dist/rcs-web/assets/Join-qGEjVZhQ.js} +1 -1
- package/dist/rcs-web/assets/{Login-BS8dN_pA.js → Login-Chuk4Hri.js} +1 -1
- package/dist/rcs-web/assets/{Register-DdWhmPwF.js → Register-C4r85OYv.js} +1 -1
- package/dist/rcs-web/assets/SessionDetail-Dnd2OkYE.js +55 -0
- package/dist/rcs-web/assets/{SessionVisibilityBadge-Bkv-o3zy.js → SessionVisibilityBadge-Dw6mot6J.js} +3 -3
- package/dist/rcs-web/assets/{Setup-Dh6nT2Cd.js → Setup-DBwigsKM.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-AQyowQYz.js → ShareLanding-CoX-L7Km.js} +1 -1
- package/dist/rcs-web/assets/{TeamCreate-DStppJIa.js → TeamCreate-B2Aj8Nnb.js} +1 -1
- package/dist/rcs-web/assets/{TeamDetail-DudkRM26.js → TeamDetail-CYolCA0E.js} +2 -2
- package/dist/rcs-web/assets/{TeamList-B2YF0znl.js → TeamList-CLjVTcqR.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-BpHpHzUj.js → TeamSettings-xvHnx7pH.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-DHCklRIF.js → UserSearchInput-BFAPXnsU.js} +1 -1
- package/dist/rcs-web/assets/{UserSettings-BWd6v4rQ.js → UserSettings-DcK2vFjv.js} +1 -1
- package/dist/rcs-web/assets/{arc-BgGV491M.js → arc-yjPvvuAR.js} +1 -1
- package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-DLhWu9K4.js → architectureDiagram-3BPJPVTR-DLkODHY6.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DejuGJUT.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-_YHO7Q0s.js} +1 -1
- package/dist/rcs-web/assets/{c4Diagram-AAUBKEIU-BJP-IVGK.js → c4Diagram-AAUBKEIU-CZkvXF0K.js} +1 -1
- package/dist/rcs-web/assets/channel-CNGHIs-P.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-yqGAlZsO.js → chunk-2J33WTMH-CCCfDI4q.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-C6xp5yYX.js → chunk-4BX2VUAB-aMiP-Z9K.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-BnoiueV2.js → chunk-55IACEB6-Hv5LgKFJ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BAykCWKk.js → dist/rcs-web/assets/chunk-727SXJPM-CmXF4bYB.js} +1 -1
- package/dist/rcs-web/assets/{chunk-AQP2D5EJ-DeElJ5j7.js → chunk-AQP2D5EJ-DA_QMZ5V.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-jP0H_--k.js → chunk-FMBD7UC4-DIuYm078.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-BGIpLa5_.js → chunk-ND2GUHAM-BDSJpl8Y.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-Blt1Cg58.js → chunk-QZHKN3VN-DiagQt-W.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-C8XDr1xN.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-C8XDr1xN.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-BKTU2vHT.js → code-block-IT6T5CEO-C4wcxAZM.js} +1 -1
- package/dist/rcs-web/assets/{copy-B2vFSPoy.js → copy-DxWeOd_i.js} +1 -1
- package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-ZuTAtm7Q.js → cose-bilkent-S5V4N54A-Dipsu_NR.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-D56sKgGx.js → dagre-BM42HDAG-BiNTOVZK.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-B9z0e8pz.js → diagram-2AECGRRQ-BsNrymYR.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-CHYkH5kc.js → diagram-5GNKFQAL-sUgYZPG2.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-B0fefELP.js → diagram-KO2AKTUF-Bz3P8wQp.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-v_CNumDx.js → diagram-LMA3HP47-C_-oOtbI.js} +1 -1
- package/dist/rcs-web/assets/{diagram-OG6HWLK6-BiP-PzY3.js → diagram-OG6HWLK6-C58BCG59.js} +1 -1
- package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-CA-q3pz9.js → erDiagram-TEJ5UH35-CUX7kvKj.js} +1 -1
- package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-D0wxPgJk.js → flowDiagram-I6XJVG4X-D852vEO8.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-D8tEhnvv.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-BuKAj2OL.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-Bx4dq1wL.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-aAROYKoC.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-D9-sPGtp.js → infoDiagram-5YYISTIA-CmHRCU11.js} +1 -1
- package/dist/rcs-web/assets/{ishikawaDiagram-YF4QCWOH-DHC2gfHg.js → ishikawaDiagram-YF4QCWOH-Dzkk7Moa.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-CeWu1YkX.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-C20ymMis.js} +1 -1
- package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-CtbBamBO.js → kanban-definition-UN3LZRKU-DP2cVK5z.js} +1 -1
- package/dist/rcs-web/assets/{linear-WFGCU65A.js → linear-BnTsCiay.js} +1 -1
- package/dist/rcs-web/assets/{main-C6czI38s.js → main-BAk_zq3S.js} +54 -54
- package/dist/rcs-web/assets/{mermaid-VLURNSYL-CJEG4DJA.js → mermaid-VLURNSYL-BVE9ST1K.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-aZvgg4gM.js → mermaid.core-Csf3Nkt4.js} +5 -5
- package/{packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-CYrLhvPq.js → dist/rcs-web/assets/mindmap-definition-RKZ34NQL-BR_C1V37.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-Cc9GCu8V.js → pieDiagram-4H26LBE5-DxqpZgPJ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-3VXRYoRB.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-BwzD17xK.js} +1 -1
- package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-DznaQwwS.js → requirementDiagram-4Y6WPE33-CCflHIKp.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-B11xI8oj.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-CscLnnxh.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CmUYXS5A.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-DjR4GAkF.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-CViWtNni.js → stateDiagram-AJRCARHV-kzGBoh5a.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-DPQ0Q1PA.js → stateDiagram-v2-BHNVJYJU-DpcuQvFJ.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-CL0Ql3sZ.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-BI9MtKOS.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-DEYqp1U8.js → vennDiagram-CIIHVFJN-Cxxls1wJ.js} +1 -1
- package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-B9Pnv5gW.js → wardleyDiagram-YWT4CUSO-BygCBXd1.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-DSPoLW7d.js → dist/rcs-web/assets/xychartDiagram-2RQKCTM6-B5rLufoB.js} +1 -1
- package/dist/rcs-web/index.html +1 -1
- package/package.json +1 -1
- package/packages/remote-control-server/src/__tests__/data-layer-round2.test.ts +13 -1
- package/packages/remote-control-server/src/__tests__/db.test.ts +47 -0
- package/packages/remote-control-server/src/__tests__/event-bus.test.ts +91 -0
- package/packages/remote-control-server/src/__tests__/routes.test.ts +57 -0
- package/packages/remote-control-server/src/__tests__/teams.test.ts +0 -25
- package/packages/remote-control-server/src/db/sqlite.ts +36 -1
- package/packages/remote-control-server/src/routes/v2/worker-events.ts +10 -0
- package/packages/remote-control-server/src/routes/web/auth-routes.ts +14 -25
- package/packages/remote-control-server/src/services/transport.ts +9 -0
- package/packages/remote-control-server/src/transport/event-bus.ts +32 -5
- package/packages/remote-control-server/src/transport/ws-handler.ts +5 -0
- package/packages/remote-control-server/web/dist/assets/{AdminPanel-BU_m2tTe.js → AdminPanel-BlettL5E.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/Claim-Dx6kdKcg.js +1 -0
- package/{dist/rcs-web/assets/Dashboard-B4nxTeft.js → packages/remote-control-server/web/dist/assets/Dashboard-BIJynSOn.js} +2 -2
- package/{dist/rcs-web/assets/Join-KIjSy6RI.js → packages/remote-control-server/web/dist/assets/Join-qGEjVZhQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Login-BS8dN_pA.js → Login-Chuk4Hri.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Register-DdWhmPwF.js → Register-C4r85OYv.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-Dnd2OkYE.js +55 -0
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-Bkv-o3zy.js → SessionVisibilityBadge-Dw6mot6J.js} +3 -3
- package/packages/remote-control-server/web/dist/assets/{Setup-Dh6nT2Cd.js → Setup-DBwigsKM.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-AQyowQYz.js → ShareLanding-CoX-L7Km.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamCreate-DStppJIa.js → TeamCreate-B2Aj8Nnb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamDetail-DudkRM26.js → TeamDetail-CYolCA0E.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{TeamList-B2YF0znl.js → TeamList-CLjVTcqR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-BpHpHzUj.js → TeamSettings-xvHnx7pH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-DHCklRIF.js → UserSearchInput-BFAPXnsU.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSettings-BWd6v4rQ.js → UserSettings-DcK2vFjv.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-BgGV491M.js → arc-yjPvvuAR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-DLhWu9K4.js → architectureDiagram-3BPJPVTR-DLkODHY6.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DejuGJUT.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-_YHO7Q0s.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{c4Diagram-AAUBKEIU-BJP-IVGK.js → c4Diagram-AAUBKEIU-CZkvXF0K.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-CNGHIs-P.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-yqGAlZsO.js → chunk-2J33WTMH-CCCfDI4q.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-C6xp5yYX.js → chunk-4BX2VUAB-aMiP-Z9K.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BnoiueV2.js → chunk-55IACEB6-Hv5LgKFJ.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-BAykCWKk.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-CmXF4bYB.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-DeElJ5j7.js → chunk-AQP2D5EJ-DA_QMZ5V.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-jP0H_--k.js → chunk-FMBD7UC4-DIuYm078.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-BGIpLa5_.js → chunk-ND2GUHAM-BDSJpl8Y.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-Blt1Cg58.js → chunk-QZHKN3VN-DiagQt-W.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-C8XDr1xN.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-C8XDr1xN.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-BKTU2vHT.js → code-block-IT6T5CEO-C4wcxAZM.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-B2vFSPoy.js → copy-DxWeOd_i.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-ZuTAtm7Q.js → cose-bilkent-S5V4N54A-Dipsu_NR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-D56sKgGx.js → dagre-BM42HDAG-BiNTOVZK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-B9z0e8pz.js → diagram-2AECGRRQ-BsNrymYR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-CHYkH5kc.js → diagram-5GNKFQAL-sUgYZPG2.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-B0fefELP.js → diagram-KO2AKTUF-Bz3P8wQp.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-v_CNumDx.js → diagram-LMA3HP47-C_-oOtbI.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-BiP-PzY3.js → diagram-OG6HWLK6-C58BCG59.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-CA-q3pz9.js → erDiagram-TEJ5UH35-CUX7kvKj.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-D0wxPgJk.js → flowDiagram-I6XJVG4X-D852vEO8.js} +1 -1
- package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-D8tEhnvv.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-BuKAj2OL.js} +1 -1
- package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-Bx4dq1wL.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-aAROYKoC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-D9-sPGtp.js → infoDiagram-5YYISTIA-CmHRCU11.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ishikawaDiagram-YF4QCWOH-DHC2gfHg.js → ishikawaDiagram-YF4QCWOH-Dzkk7Moa.js} +1 -1
- package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-CeWu1YkX.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-C20ymMis.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-CtbBamBO.js → kanban-definition-UN3LZRKU-DP2cVK5z.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-WFGCU65A.js → linear-BnTsCiay.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-C6czI38s.js → main-BAk_zq3S.js} +54 -54
- package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-CJEG4DJA.js → mermaid-VLURNSYL-BVE9ST1K.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-aZvgg4gM.js → mermaid.core-Csf3Nkt4.js} +5 -5
- package/{dist/rcs-web/assets/mindmap-definition-RKZ34NQL-CYrLhvPq.js → packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-BR_C1V37.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-Cc9GCu8V.js → pieDiagram-4H26LBE5-DxqpZgPJ.js} +1 -1
- package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-3VXRYoRB.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-BwzD17xK.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-DznaQwwS.js → requirementDiagram-4Y6WPE33-CCflHIKp.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-B11xI8oj.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-CscLnnxh.js} +1 -1
- package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CmUYXS5A.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-DjR4GAkF.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-CViWtNni.js → stateDiagram-AJRCARHV-kzGBoh5a.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-DPQ0Q1PA.js → stateDiagram-v2-BHNVJYJU-DpcuQvFJ.js} +1 -1
- package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-CL0Ql3sZ.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-BI9MtKOS.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-DEYqp1U8.js → vennDiagram-CIIHVFJN-Cxxls1wJ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-B9Pnv5gW.js → wardleyDiagram-YWT4CUSO-BygCBXd1.js} +1 -1
- package/{dist/rcs-web/assets/xychartDiagram-2RQKCTM6-DSPoLW7d.js → packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-B5rLufoB.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +1 -1
- package/dist/rcs-web/assets/Claim-76lutQis.js +0 -1
- package/dist/rcs-web/assets/SessionDetail-B9zVxGG0.js +0 -55
- package/dist/rcs-web/assets/channel-6hQBS9Uq.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-BHUV1B5s.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-BHUV1B5s.js +0 -1
- package/packages/remote-control-server/web/dist/assets/Claim-76lutQis.js +0 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-B9zVxGG0.js +0 -55
- package/packages/remote-control-server/web/dist/assets/channel-6hQBS9Uq.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-BHUV1B5s.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-BHUV1B5s.js +0 -1
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
},
|
|
200
200
|
{
|
|
201
201
|
"name": "sa",
|
|
202
|
-
"description": "Toggle SA mode
|
|
202
|
+
"description": "Toggle SA mode, or switch tool level: /sa [minimal|extended]. Minimal = 4 tools (Read/Edit/Write/Bash), extended = 7 (+Glob/Grep/WebFetch).",
|
|
203
203
|
"descriptionZh": "切换 SA 极简模式:4 工具 + 20 行 prompt + 零后台任务"
|
|
204
204
|
},
|
|
205
205
|
{
|
|
@@ -677,7 +677,7 @@
|
|
|
677
677
|
},
|
|
678
678
|
"sa": {
|
|
679
679
|
"name": "sa",
|
|
680
|
-
"description": "Toggle SA mode
|
|
680
|
+
"description": "Toggle SA mode, or switch tool level: /sa [minimal|extended]. Minimal = 4 tools (Read/Edit/Write/Bash), extended = 7 (+Glob/Grep/WebFetch).",
|
|
681
681
|
"descriptionZh": "切换 SA 极简模式:4 工具 + 20 行 prompt + 零后台任务"
|
|
682
682
|
},
|
|
683
683
|
"skill-learning": {
|
|
@@ -3123,7 +3123,7 @@
|
|
|
3123
3123
|
"省 token"
|
|
3124
3124
|
]
|
|
3125
3125
|
},
|
|
3126
|
-
"content": "\n## 为什么需要 Token 节约模式\n\nSaluzi 默认开启大量「让 AI 更聪明」的后台机制:自动记忆提取、提示建议、会话记忆整合、验证 Agent、相关记忆预取、Agent 摘要……这些机制各自只消耗少量 token,但叠在一起会让每次对话的「隐性开销」相当可观。\n\n当你处于以下场景时,这些开销就是纯浪费:\n\n- **API Key 按量计费**,想压到最低\n- **弱模型 / 小上下文窗口**,每一段 prompt 都很贵\n- **一次性脚本任务**,不需要长期记忆\n- **清晰的单文件修改**,不需要多角度验证\n\n两种节约模式就是为这些场景设计的开关,按「砍多少」分档:\n\n| 模式 | 砍掉的范围 | 工具集 | System Prompt | 适合 |\n|------|-----------|--------|--------------|------|\n| **Poor** | 5 项后台副作用 | 全部保留 | 完整 | 日常开发省 token |\n| **SA** | 全部后台 + 工具收敛 | 仅 4 核心 | ~20 行极简 | 极限省 token / 弱模型 |\n\nSA 是 Poor 的**严格超集**——Poor 关掉的一切,SA 也关掉;SA 还额外砍掉工具和 prompt。两者的关系类似「省电模式」与「飞行模式」。\n\n## Poor 节约模式\n\n### 是什么\n\n`/poor` 切换 Poor 模式。开启后 Saluzi 跳过 5 类后台副作用任务,并对若干辅助模型调用降级。**主对话的工具集与 system prompt 完全不变**——你只是少了一些「后台 whisper」。\n\n### 关闭了什么\n\n| 被关闭的子系统 | 位置 | 原本做什么 |\n|---------------|------|-----------|\n| extract_memories | Stop hook | 每轮结束后从对话提取记忆写入 MEMORY.md |\n| prompt_suggestion | Stop hook | 给用户猜测「下一步可能想问什么」 |\n| autoDream | Stop hook | 后台整合/蒸馏历史记忆 |\n| AgentSummary | 后台 | 给子 Agent 生成摘要 |\n| 验证 Agent | System prompt | 非平凡改动后强制独立审查 |\n\n同时这些**辅助模型调用降级**(不影响主模型):\n\n| 调用点 | 原模型 | Poor 后 |\n|--------|--------|---------|\n| autoMode critique | MainLoop | SmallFast |\n| permission explainer | MainLoop | SmallFast |\n| universal classifier | MainLoop | DefaultPro |\n| yolo classifier | MainLoop | DefaultPro |\n\n降级意味着权限分类、自动模式批评等「辅助判断」用更便宜的模型跑,质量略降但成本显著下降。主对话模型不变。\n\n### 优势\n\n- **工具集完整**:Read/Edit/Write/Bash/Glob/Grep/WebFetch/Task/MCP……全部照常\n- **System prompt 完整**:项目记忆、CodeGraph、技能、SALUZI.md 仍然注入\n- **可逆且持久**:`/poor` 再按一次关闭;状态写入 `settings.json` 的 `poorMode` 字段,重启后保留\n- **粒度温和**:只砍「后台 whisper」,主循环质量基本无损\n\n### 劣势\n\n- **不再自动积累记忆**:MEMORY.md 不会自动更新,需要手动 `/memory` 编辑\n- **无提示建议**:终端不再显示「你可能想问……」的快捷建议\n- **无验证 Agent**:复杂改动后没有独立审查兜底,需要自己跑测试\n- **辅助分类降级**:权限判断、自动模式批评的精度略降\n\n## SA 极简模式\n\n### 是什么\n\n`/sa` 切换 SA 模式(极简风格 minimal harness)。开启后 Saluzi 收敛到「最小可用 harness」:\n\n- **System prompt 收缩到 ~20 行**:只有角色定义 + 4 个工具说明 + 基本准则 + cwd + 日期。没有动态段落、没有项目记忆、没有 CodeGraph、没有 MCP 说明、没有会话指导。\n- **工具收敛到 4 个核心**:Read / Edit / Write / Bash。其余工具(Glob、Grep、WebFetch、Task、TodoWrite、MCP、Skill……)全部移除。\n- **所有后台副作用归零**:Poor 关掉的 5 项 + 会话记忆 + 相关记忆预取,全部跳过。\n\n这是「把 Saluzi 当成一个极简的 Read/Edit/Write/Bash 编码助手」的开关——类似极简 harness 的体验。\n\n### SA 的 System Prompt 长什么样\n\n完整内容就这些:\n\n```\nYou are an expert coding assistant operating inside Saluzi, a coding agent harness.\nYou help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n- Read: Read file contents from the filesystem\n- Edit: Make targeted edits to existing files\n- Write: Create new files or overwrite existing files\n- Bash: Execute shell commands\n\nGuidelines:\n- Be concise in your responses\n- Show file paths clearly when working with files\n- Use file_path:line_number format when referencing code locations\n- Do not use a colon before tool calls\n- Ask the user before making significant architectural decisions\n\nCurrent working directory: <cwd>\nDate: <date>\n```\n\n对比默认 prompt 的数千字(项目记忆 + CodeGraph + 技能 + 会话指导 + 工具说明 + 安全规则……),SA prompt 几乎是零开销。\n\n### 关闭了什么\n\nSA 关闭 = Poor 的全部 + 以下额外项:\n\n| 额外关闭项 | 位置 | 原本做什么 |\n|-----------|------|-----------|\n| 会话记忆提取 | sessionMemory | 跨会话蒸馏项目级记忆 |\n| 相关记忆预取 | attachments | 每轮用户消息后 side-query 检索相关记忆 |\n| 全部工具(除 4 核心) | tools | Glob/Grep/Task/WebFetch/MCP/Skill 等 |\n| 完整 system prompt | prompts | 替换为 20 行极简版 |\n\n### 优势\n\n- **极限省 token**:prompt 从数千字降到 ~20 行,每轮省下大量输入 token\n- **弱模型友好**:小上下文窗口 / 弱模型不会被巨型 prompt 挤占空间\n- **响应快**:没有后台 side-query 拖慢首字节\n- **行为可预测**:AI 只有 4 个工具,不会偷偷跑 WebFetch / Task / MCP,调试简单\n- **可逆且持久**:`/sa` 再按一次关闭;状态写入 `settings.json` 的 `saMode` 字段\n\n### 劣势\n\n- **没有 Glob/Grep**:AI 找文件只能用 `Bash(ls/find)` + `Read`,搜索效率低\n- **没有 Task/TodoWrite**:无法拆分多步任务、不能 spawn 子 Agent\n- **没有 WebFetch/WebSearch**:不能查文档、不能上网\n- **没有 MCP/Skill**:所有 MCP 服务器工具、自定义技能全部不可用\n- **没有项目记忆**:SALUZI.md、MEMORY.md、CodeGraph 知识都不注入,AI 对项目「无记忆」\n- **没有验证 Agent**:同 Poor\n- **AI 不知道自己的完整能力**:极简 prompt 不说明权限模式、安全规则、提交规范等,复杂工作流需要你手动提示\n\n> 简言之:SA 模式适合「我就让 AI 改这一个文件」「跑个脚本看看」这类窄任务,不适合复杂架构重构或需要项目上下文的工作。\n\n## 两种模式的完整对比\n\n| 维度 | 默认 | Poor | SA |\n|------|------|------|-----|\n| System prompt | 数千字(完整动态) | 数千字(完整动态) | ~20 行(极简) |\n| 工具集 | 全部 | 全部 | 4 核心(Read/Edit/Write/Bash) |\n| extract_memories | ✅ | ❌ | ❌ |\n| prompt_suggestion | ✅ | ❌ | ❌ |\n| autoDream | ✅ | ❌ | ❌ |\n| AgentSummary | ✅ | ❌ | ❌ |\n| 验证 Agent | ✅ | ❌ | ❌ |\n| 会话记忆提取 | ✅ | ✅ | ❌ |\n| 相关记忆预取 | ✅ | ✅ | ❌ |\n| 项目记忆注入 (SALUZI.md) | ✅ | ✅ | ❌ |\n| CodeGraph | ✅ | ✅ | ❌ |\n| MCP 工具 | ✅ | ✅ | ❌ |\n| Skill 工具 | ✅ | ✅ | ❌ |\n| Glob/Grep/WebFetch/Task | ✅ | ✅ | ❌ |\n| 辅助分类模型 | MainLoop | Pro/SmallFast | Pro/SmallFast |\n| 主对话模型 | 不变 | 不变 | 不变 |\n| 输入 token / 轮 | 基准 | 略低(少后台 side-query) | 显著低(prompt 极小) |\n| 适合场景 | 日常全功能 | 日常省 token | 极限省 / 弱模型 / 窄任务 |\n\n## 与其他功能的兼容性\n\n这是最关键的部分——开了节约模式后,你常用的那些 Saluzi 特色还能不能用。\n\n### MOM 混合模型\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ✅ 完全兼容 | Poor 不触碰 MOM 配置,顾问与主机按 `/mom` 设置正常运行 |\n| SA | ⚠️ 受限兼容 | MOM 仍可运行,但**主机只有 4 个工具**(Read/Edit/Write/Bash);顾问本就是 text-only 不受影响 |\n\n> 如果在 SA 模式下用 mom-stair,弱模型顾问(text-only)正常工作;升级到主机后主机也只能用 4 工具执行——不能 Glob/Grep/WebFetch。建议 SA + MOM 时把主机任务限定在文件读写 + 命令执行。\n\n### CodeGraph 代码智能\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ✅ 完全兼容 | CodeGraph 工具与 prompt 段落照常注入 |\n| SA | ❌ 不可用 | 工具被收敛到 4 核心(无 CodeGraph 工具),prompt 也不含 CodeGraph 段落 |\n\n### 记忆系统 (Memory V2 / SALUZI.md)\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ⚠️ 只读不写 | 已有记忆仍注入 prompt;但 extract_memories/autoDream 关闭,不再自动积累新记忆 |\n| SA | ❌ 完全隔离 | 既不注入(极简 prompt 无记忆段),也不提取(session memory 关闭) |\n\n### 验证 Agent (Verification Agent)\n\n| 模式 | 兼容性 |\n|------|--------|\n| Poor | ❌ 跳过 |\n| SA | ❌ 跳过 |\n\n两种模式都跳过验证 Agent。需要独立审查时请关闭节约模式后再跑,或手动 spawn 子 Agent(SA 模式下无 Task 工具,需先关 SA)。\n\n### Plan 模式 / Sandbox / Hooks\n\n| 模式 | Plan | Sandbox | Hooks |\n|------|------|---------|-------|\n| Poor | ✅ | ✅ | ✅ |\n| SA | ✅ | ✅ | ✅ |\n\n权限模式、沙箱、hooks 都是工具执行层机制,与节约模式正交,完全不受影响。\n\n### MCP 服务器 / Skill\n\n| 模式 | MCP | Skill |\n|------|-----|-------|\n| Poor | ✅ | ✅ |\n| SA | ❌ 工具被移除 | ❌ 工具被移除 |\n\nSA 模式下 MCP 服务器仍可连接(连接层不变),但 MCP 提供的工具不在 4 核心之列,不会被注入工具列表。\n\n### Auto Mode (/auto)\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ⚠️ 降级 | autoMode 仍运行,但 critique 步骤用 SmallFast 模型 |\n| SA | ⚠️ 降级 | 同 Poor;且主机工具受限 |\n\n## 权限模式与安全风险\n\n> 用户最关心的问题:**开了节约模式,AI 会不会偷偷执行 `rm -rf /`、`drop database` 这类删库命令?**\n>\n> 简短回答:**节约模式本身不改变权限策略,不会让危险命令「更容易跑」**。真正的风险来自你选的**权限模式**(`default` / `acceptEdits` / `bypassPermissions` / `auto`),而不是 Poor/SA。但 Poor/SA 会把权限分类器降级到更便宜的模型,在 `bypassPermissions`/`auto` 模式下**理论上**误判概率略升。下面逐层拆解。\n\n### 权限模式与节约模式正交\n\n权限模式由 `/permissions` 或 `settings.json` 的 `permissions.defaultMode` 控制,**与 Poor/SA 完全独立**。开 Poor 或 SA 不会切换你的权限模式:\n\n| 权限模式 | Bash 危险命令会怎样 | Poor/SA 影响 |\n|---------|---------------------|-------------|\n| `default` | 每条命令弹确认,`rm -rf` 类必问你 | 无——该问还是问 |\n| `acceptEdits` | 只自动放行文件编辑,**Bash 仍逐条问** | 无——Bash 仍问 |\n| `plan` | 只读,不能执行任何写操作 | 无——根本跑不了 |\n| `bypassPermissions` | 分类器自动判断,不问你 | ⚠️ 分类器降级(见下) |\n| `auto` | autoMode 分类器自动判断 | ⚠️ 分类器降级(见下) |\n\n**结论**:在 `default` / `acceptEdits` / `plan` 这三种模式下,无论开不开 Poor/SA,危险命令都必须经过你手动确认——**不存在「开了 SA 就自动删库」的情况**。\n\n### SA 模式仍执行 deny 规则\n\nSA 模式收敛工具集时调用的是 `filterToolsByDenyRules`——也就是说你在 `settings.json` 里配的 `permissions.deny` 规则**在 SA 模式下照常生效**:\n\n```json\n{\n \"permissions\": {\n \"deny\": [\n \"Bash(rm -rf:*)\",\n \"Bash(rm -rf /*:*)\",\n \"Bash(drop database:*)\",\n \"Bash(git push --force:*)\",\n \"Bash(:(){ :|:& };:)\",\n \"Bash(mkfs*:*)\"\n ]\n }\n}\n```\n\n这些规则会在工具列表阶段就**直接屏蔽**匹配的命令——AI 根本看不到这些工具能跑这类命令,分类器也不会被调用。这是比分类器更硬的防线,且**不受 Poor/SA 影响**。\n\n> 强烈建议:无论用不用节约模式,都把 `rm -rf /`、`drop database`、`mkfs`、fork 炸弹等不可逆命令写进 `deny`。这是「物理隔离」级别的一刀切。\n\n### 分类器降级:风险有多大\n\n在 `bypassPermissions` 或 `auto` 模式下,命令是否自动放行由**分类器**(yoloClassifier / universalClassifier)决定。Saluzi 的分类器 prompt 明确把以下列为 **Irreversible Local Destruction(不可逆本地破坏)**:\n\n- `rm -rf` 递归强制删除非平凡路径\n- `Remove-Item -Recurse -Force`(PowerShell 等价物)\n- `> file` 截断已有文件为空\n- `drop database` 删库\n- `git push --force`(视上下文)\n\nPoor/SA 模式下分类器模型降级:\n\n| 模式 | 分类器模型 | 影响 |\n|------|-----------|------|\n| 默认 | MainLoop(如 Max/Pro 主模型) | 精度最高 |\n| Poor/SA | DefaultPro | 略低,但仍是 Pro 级模型 |\n\n**关键点**:\n\n- 分类器**仍然运行**——Poor/SA 没有关闭分类器,只是让它用更便宜的模型跑。\n- Pro 级模型对 `rm -rf /` 这种明显的破坏性命令识别能力依然很强——这不是「盲放」。\n- 降级影响的是**边界模糊**的命令(如 `rm -rf ./build` 这种有歧义的)的判断精度,不是放行 `rm -rf /`。\n\n**所以「删库」风险的真实情况**:\n\n1. `default` / `acceptEdits` / `plan` 模式:**零风险**,必须你确认。\n2. `bypassPermissions` / `auto` + 默认:**低风险**,分类器(MainLoop)会拦。\n3. `bypassPermissions` / `auto` + Poor/SA:**略升的边界风险**,分类器(Pro)对明显破坏命令仍拦,但对模糊命令误判概率略高。\n4. 任何模式 + 配了 `deny` 规则:**零风险**,物理屏蔽。\n\n### SA 模式的特殊风险面\n\nSA 模式只保留 4 个工具(Read/Edit/Write/Bash),这反而**缩小**了攻击面:\n\n- **没有 WebFetch/WebSearch**:AI 不能下载并执行远程脚本。\n- **没有 Task**:不能 spawn 子 Agent 绕过主循环审查。\n- **没有 MCP 工具**:外部 MCP 服务器不能注入未审查的工具。\n- **没有 Skill**:自定义技能不会被执行。\n\n但 **Bash 仍在**——这是 SA 模式下唯一的「能干坏事」的入口。只要 Bash 的权限策略到位(`default` 模式或 `deny` 规则),SA 模式的整体风险面比默认模式**更小**,不是更大。\n\n### 安全使用建议\n\n| 建议 | 原因 |\n|------|------|\n| 默认用 `default` 或 `acceptEdits` 权限模式 | Bash 逐条确认,物理安全 |\n| 在 `settings.json` 配 `permissions.deny` 屏蔽 `rm -rf /`、`drop database`、`mkfs`、fork 炸弹 | 一刀切物理隔离,不受任何模式影响 |\n| 开启沙箱(`sandbox.enabled: true`)| 限制写入路径与网络访问,`rm -rf /` 直接失败 |\n| 避免 `bypassPermissions` + Poor/SA 组合 | 分类器降级 + 不问你 = 信任分类器,边界命令风险略升 |\n| SA 模式下尤其盯紧 Bash 输出 | 没有验证 Agent 兜底,需要你自己看命令 |\n| 用 `/permissions` 临时切 `plan` 模式做危险探索 | 只读,根本不能执行写操作 |\n\n### 一句话总结\n\n**Poor/SA 不会让 Saluzi「更敢删库」**——它们只砍后台副作用和工具数量,不动权限策略与 deny 规则。真正的删库风险来自 `bypassPermissions`/`auto` 权限模式本身;要彻底消除风险,配 `deny` 规则 + 开沙箱 + 用 `default` 模式,这三道防线与节约模式正交,同时开启完全安全。\n\n## 如何开启 / 关闭\n\n### 命令切换\n\n```\n> /poor # 切换 Poor 模式(开↔关)\n> /sa # 切换 SA 模式(开↔关)\n```\n\n输出会确认当前状态,例如:\n\n```\nSA mode ON — minimal prompt, 4 tools (Read/Edit/Write/Bash), all background tasks disabled\n```\n\n### 配置面板\n\n`/config` → 找到 `SA mode (minimal harness)` 与 `poor mode` 开关,`Enter` 切换。\n\n### settings.json\n\n直接编辑 `~/.saluzi-edu/settings.json`:\n\n```json\n{\n \"poorMode\": true,\n \"saMode\": true\n}\n```\n\n两个字段都可选,`true` 开启、省略或 `false` 关闭。重启 Saluzi 后生效。\n\n> **不要同时开 Poor 和 SA**。SA 是 Poor 的严格超集,同时开启只是冗余——工具集与 prompt 都按 SA 走,Poor 的标志位不起额外作用。需要极限省 token 就直接开 SA;需要保留全部工具就开 Poor。\n\n## 何时该用哪个\n\n| 你的情况 | 推荐 |\n|---------|------|\n| 日常开发,想省点 token,但还要用 Glob/Grep/MOM/CodeGraph | **Poor** |\n| API Key 按量计费,想压到最低 | **Poor**(日常)或 **SA**(窄任务) |\n| 用弱模型 / 小上下文窗口 | **SA** |\n| 一次性脚本:改一个文件、跑个命令 | **SA** |\n| 复杂架构重构、需要项目记忆与多步任务 | **关闭**(用默认) |\n| 需要 MOM 多顾问交叉验证 | **Poor**(保留工具)或 **关闭** |\n| 调试时想要「AI 不要偷偷干别的」 | **SA** |\n| 长期挂着的会话,不想后台烧 token | **Poor** |\n\n## 节约效果怎么看\n\n开启后用 `/cost` 观察单轮 token:\n\n```\n> /cost\n```\n\n重点看**输入 token**——SA 模式下每轮输入 token 会显著下降(因为 prompt 从数千字缩到 ~20 行)。后台 side-query 的输出 token 也归零。多轮对比即可看到差异。\n\n## 下一步\n\n- [MOM 混合模型](./mom-mixed-models) — 节约模式下 MOM 如何运行\n- [模型选择与切换](./model-selection) — `/poor` 命令的简述与模型降级\n- [查看消耗](./cost-usage) — `/cost` 监控节约效果\n- [记忆系统](./memory-system) — Poor/SA 对记忆的影响\n"
|
|
3126
|
+
"content": "\n## 为什么需要 Token 节约模式\n\nSaluzi 默认开启大量「让 AI 更聪明」的后台机制:自动记忆提取、提示建议、会话记忆整合、验证 Agent、相关记忆预取、Agent 摘要……这些机制各自只消耗少量 token,但叠在一起会让每次对话的「隐性开销」相当可观。\n\n当你处于以下场景时,这些开销就是纯浪费:\n\n- **API Key 按量计费**,想压到最低\n- **弱模型 / 小上下文窗口**,每一段 prompt 都很贵\n- **一次性脚本任务**,不需要长期记忆\n- **清晰的单文件修改**,不需要多角度验证\n\n两种节约模式就是为这些场景设计的开关,按「砍多少」分档:\n\n| 模式 | 砍掉的范围 | 工具集 | System Prompt | 适合 |\n|------|-----------|--------|--------------|------|\n| **Poor** | 5 项后台副作用 | 全部保留 | 完整 | 日常开发省 token |\n| **SA** | 全部后台 + 工具收敛 | 仅 4 核心 | ~20 行极简 | 极限省 token / 弱模型 |\n\nSA 是 Poor 的**严格超集**——Poor 关掉的一切,SA 也关掉;SA 还额外砍掉工具和 prompt。两者的关系类似「省电模式」与「飞行模式」。\n\n## Poor 节约模式\n\n### 是什么\n\n`/poor` 切换 Poor 模式。开启后 Saluzi 跳过 5 类后台副作用任务,并对若干辅助模型调用降级。**主对话的工具集与 system prompt 完全不变**——你只是少了一些「后台 whisper」。\n\n### 关闭了什么\n\n| 被关闭的子系统 | 位置 | 原本做什么 |\n|---------------|------|-----------|\n| extract_memories | Stop hook | 每轮结束后从对话提取记忆写入 MEMORY.md |\n| prompt_suggestion | Stop hook | 给用户猜测「下一步可能想问什么」 |\n| autoDream | Stop hook | 后台整合/蒸馏历史记忆 |\n| AgentSummary | 后台 | 给子 Agent 生成摘要 |\n| 验证 Agent | System prompt | 非平凡改动后强制独立审查 |\n\n同时这些**辅助模型调用降级**(不影响主模型):\n\n| 调用点 | 原模型 | Poor 后 |\n|--------|--------|---------|\n| autoMode critique | MainLoop | SmallFast |\n| permission explainer | MainLoop | SmallFast |\n| universal classifier | MainLoop | DefaultPro |\n| yolo classifier | MainLoop | DefaultPro |\n\n降级意味着权限分类、自动模式批评等「辅助判断」用更便宜的模型跑,质量略降但成本显著下降。主对话模型不变。\n\n### 优势\n\n- **工具集完整**:Read/Edit/Write/Bash/Glob/Grep/WebFetch/Task/MCP……全部照常\n- **System prompt 完整**:项目记忆、CodeGraph、技能、SALUZI.md 仍然注入\n- **可逆且持久**:`/poor` 再按一次关闭;状态写入 `settings.json` 的 `poorMode` 字段,重启后保留\n- **粒度温和**:只砍「后台 whisper」,主循环质量基本无损\n\n### 劣势\n\n- **不再自动积累记忆**:MEMORY.md 不会自动更新,需要手动 `/memory` 编辑\n- **无提示建议**:终端不再显示「你可能想问……」的快捷建议\n- **无验证 Agent**:复杂改动后没有独立审查兜底,需要自己跑测试\n- **辅助分类降级**:权限判断、自动模式批评的精度略降\n\n## SA 极简模式\n\n### 是什么\n\n`/sa` 切换 SA 模式(极简风格 minimal harness)。开启后 Saluzi 收敛到「最小可用 harness」:\n\n- **System prompt 收缩到 ~20 行**:只有角色定义 + 工具说明 + 基本准则 + cwd + 日期。没有动态段落、没有项目记忆、没有 CodeGraph、没有 MCP 说明、没有会话指导。\n- **工具收敛到核心集**:`minimal` 档 4 个(Read / Edit / Write / Bash),`extended` 档 7 个(再加 Glob / Grep / WebFetch)。其余工具(Task、TodoWrite、MCP、Skill……)全部移除。\n- **所有后台副作用归零**:Poor 关掉的 5 项 + 会话记忆 + 相关记忆预取,全部跳过。\n\n这是「把 Saluzi 当成一个极简的编码助手」的开关——类似极简 harness 的体验。工具集分两档,按需选择。\n\n### SA 的 System Prompt 长什么样\n\n完整内容就这些:\n\n```\nYou are an expert coding assistant operating inside Saluzi, a coding agent harness.\nYou help users by reading files, executing commands, editing code, and writing new files.\n\nAvailable tools:\n- Read: Read file contents from the filesystem\n- Edit: Make targeted edits to existing files\n- Write: Create new files or overwrite existing files\n- Bash: Execute shell commands\n\nGuidelines:\n- Be concise in your responses\n- Show file paths clearly when working with files\n- Use file_path:line_number format when referencing code locations\n- Do not use a colon before tool calls\n- Ask the user before making significant architectural decisions\n\nCurrent working directory: <cwd>\nDate: <date>\n```\n\n以上是 `minimal` 档的 prompt。`extended` 档的 `Available tools` 部分会多列 3 行(Glob / Grep / WebFetch),其余不变。\n\n对比默认 prompt 的数千字(项目记忆 + CodeGraph + 技能 + 会话指导 + 工具说明 + 安全规则……),SA prompt 几乎是零开销。\n\n### 关闭了什么\n\nSA 关闭 = Poor 的全部 + 以下额外项:\n\n| 额外关闭项 | 位置 | 原本做什么 |\n|-----------|------|-----------|\n| 会话记忆提取 | sessionMemory | 跨会话蒸馏项目级记忆 |\n| 相关记忆预取 | attachments | 每轮用户消息后 side-query 检索相关记忆 |\n| 全部工具(除核心集) | tools | Task/TodoWrite/MCP/Skill 等(minimal 档还去掉 Glob/Grep/WebFetch) |\n| 完整 system prompt | prompts | 替换为 20 行极简版 |\n\n### 优势\n\n- **极限省 token**:prompt 从数千字降到 ~20 行,每轮省下大量输入 token\n- **弱模型友好**:小上下文窗口 / 弱模型不会被巨型 prompt 挤占空间\n- **响应快**:没有后台 side-query 拖慢首字节\n- **行为可预测**:AI 只有核心工具,不会偷偷跑 Task / MCP,调试简单\n- **可逆且持久**:`/sa` 再按一次关闭;状态写入 `settings.json` 的 `saMode` 字段\n\n### 劣势\n\n- **minimal 档没有 Glob/Grep/WebFetch**:AI 找文件只能用 `Bash(ls/find)` + `Read`,搜索效率低。切到 `extended` 档可恢复这三个工具\n- **没有 Task/TodoWrite**:无法拆分多步任务、不能 spawn 子 Agent\n- **没有 WebSearch**:minimal/extended 都不含 WebSearch,不能搜索网络(WebFetch 在 extended 档可用)\n- **没有 MCP/Skill**:所有 MCP 服务器工具、自定义技能全部不可用\n- **没有项目记忆**:SALUZI.md、MEMORY.md、CodeGraph 知识都不注入,AI 对项目「无记忆」\n- **没有验证 Agent**:同 Poor\n- **AI 不知道自己的完整能力**:极简 prompt 不说明权限模式、安全规则、提交规范等,复杂工作流需要你手动提示\n\n> 简言之:SA 模式适合「我就让 AI 改这一个文件」「跑个脚本看看」这类窄任务,不适合复杂架构重构或需要项目上下文的工作。\n\n## 两种模式的完整对比\n\n| 维度 | 默认 | Poor | SA |\n|------|------|------|-----|\n| System prompt | 数千字(完整动态) | 数千字(完整动态) | ~20 行(极简) |\n| 工具集 | 全部 | 全部 | 核心集(minimal 4 / extended 7) |\n| extract_memories | ✅ | ❌ | ❌ |\n| prompt_suggestion | ✅ | ❌ | ❌ |\n| autoDream | ✅ | ❌ | ❌ |\n| AgentSummary | ✅ | ❌ | ❌ |\n| 验证 Agent | ✅ | ❌ | ❌ |\n| 会话记忆提取 | ✅ | ✅ | ❌ |\n| 相关记忆预取 | ✅ | ✅ | ❌ |\n| 项目记忆注入 (SALUZI.md) | ✅ | ✅ | ❌ |\n| CodeGraph | ✅ | ✅ | ❌ |\n| MCP 工具 | ✅ | ✅ | ❌ |\n| Skill 工具 | ✅ | ✅ | ❌ |\n| Glob/Grep/WebFetch/Task | ✅ | ✅ | ❌ |\n| 辅助分类模型 | MainLoop | Pro/SmallFast | Pro/SmallFast |\n| 主对话模型 | 不变 | 不变 | 不变 |\n| 输入 token / 轮 | 基准 | 略低(少后台 side-query) | 显著低(prompt 极小) |\n| 适合场景 | 日常全功能 | 日常省 token | 极限省 / 弱模型 / 窄任务 |\n\n## 与其他功能的兼容性\n\n这是最关键的部分——开了节约模式后,你常用的那些 Saluzi 特色还能不能用。\n\n### MOM 混合模型\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ✅ 完全兼容 | Poor 不触碰 MOM 配置,顾问与主机按 `/mom` 设置正常运行 |\n| SA | ⚠️ 受限兼容 | MOM 仍可运行,但**主机只有核心工具**(minimal 4 / extended 7);顾问本就是 text-only 不受影响 |\n\n> 如果在 SA 模式下用 mom-stair,弱模型顾问(text-only)正常工作;升级到主机后主机也只能用核心工具执行——minimal 档不能 Glob/Grep/WebFetch,extended 档可以。建议 SA + MOM 时按需选档位。\n\n### CodeGraph 代码智能\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ✅ 完全兼容 | CodeGraph 工具与 prompt 段落照常注入 |\n| SA | ❌ 不可用 | 工具被收敛到 4 核心(无 CodeGraph 工具),prompt 也不含 CodeGraph 段落 |\n\n### 记忆系统 (Memory V2 / SALUZI.md)\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ⚠️ 只读不写 | 已有记忆仍注入 prompt;但 extract_memories/autoDream 关闭,不再自动积累新记忆 |\n| SA | ❌ 完全隔离 | 既不注入(极简 prompt 无记忆段),也不提取(session memory 关闭) |\n\n### 验证 Agent (Verification Agent)\n\n| 模式 | 兼容性 |\n|------|--------|\n| Poor | ❌ 跳过 |\n| SA | ❌ 跳过 |\n\n两种模式都跳过验证 Agent。需要独立审查时请关闭节约模式后再跑,或手动 spawn 子 Agent(SA 模式下无 Task 工具,需先关 SA)。\n\n### Plan 模式 / Sandbox / Hooks\n\n| 模式 | Plan | Sandbox | Hooks |\n|------|------|---------|-------|\n| Poor | ✅ | ✅ | ✅ |\n| SA | ✅ | ✅ | ✅ |\n\n权限模式、沙箱、hooks 都是工具执行层机制,与节约模式正交,完全不受影响。\n\n### MCP 服务器 / Skill\n\n| 模式 | MCP | Skill |\n|------|-----|-------|\n| Poor | ✅ | ✅ |\n| SA | ❌ 工具被移除 | ❌ 工具被移除 |\n\nSA 模式下 MCP 服务器仍可连接(连接层不变),但 MCP 提供的工具不在 4 核心之列,不会被注入工具列表。\n\n### Auto Mode (/auto)\n\n| 模式 | 兼容性 | 说明 |\n|------|--------|------|\n| Poor | ⚠️ 降级 | autoMode 仍运行,但 critique 步骤用 SmallFast 模型 |\n| SA | ⚠️ 降级 | 同 Poor;且主机工具受限 |\n\n## 权限模式与安全风险\n\n> 用户最关心的问题:**开了节约模式,AI 会不会偷偷执行 `rm -rf /`、`drop database` 这类删库命令?**\n>\n> 简短回答:**节约模式本身不改变权限策略,不会让危险命令「更容易跑」**。真正的风险来自你选的**权限模式**(`default` / `acceptEdits` / `bypassPermissions` / `auto`),而不是 Poor/SA。但 Poor/SA 会把权限分类器降级到更便宜的模型,在 `bypassPermissions`/`auto` 模式下**理论上**误判概率略升。下面逐层拆解。\n\n### 权限模式与节约模式正交\n\n权限模式由 `/permissions` 或 `settings.json` 的 `permissions.defaultMode` 控制,**与 Poor/SA 完全独立**。开 Poor 或 SA 不会切换你的权限模式:\n\n| 权限模式 | Bash 危险命令会怎样 | Poor/SA 影响 |\n|---------|---------------------|-------------|\n| `default` | 每条命令弹确认,`rm -rf` 类必问你 | 无——该问还是问 |\n| `acceptEdits` | 只自动放行文件编辑,**Bash 仍逐条问** | 无——Bash 仍问 |\n| `plan` | 只读,不能执行任何写操作 | 无——根本跑不了 |\n| `bypassPermissions` | 分类器自动判断,不问你 | ⚠️ 分类器降级(见下) |\n| `auto` | autoMode 分类器自动判断 | ⚠️ 分类器降级(见下) |\n\n**结论**:在 `default` / `acceptEdits` / `plan` 这三种模式下,无论开不开 Poor/SA,危险命令都必须经过你手动确认——**不存在「开了 SA 就自动删库」的情况**。\n\n### SA 模式仍执行 deny 规则\n\nSA 模式收敛工具集时调用的是 `filterToolsByDenyRules`——也就是说你在 `settings.json` 里配的 `permissions.deny` 规则**在 SA 模式下照常生效**:\n\n```json\n{\n \"permissions\": {\n \"deny\": [\n \"Bash(rm -rf:*)\",\n \"Bash(rm -rf /*:*)\",\n \"Bash(drop database:*)\",\n \"Bash(git push --force:*)\",\n \"Bash(:(){ :|:& };:)\",\n \"Bash(mkfs*:*)\"\n ]\n }\n}\n```\n\n这些规则会在工具列表阶段就**直接屏蔽**匹配的命令——AI 根本看不到这些工具能跑这类命令,分类器也不会被调用。这是比分类器更硬的防线,且**不受 Poor/SA 影响**。\n\n> 强烈建议:无论用不用节约模式,都把 `rm -rf /`、`drop database`、`mkfs`、fork 炸弹等不可逆命令写进 `deny`。这是「物理隔离」级别的一刀切。\n\n### 分类器降级:风险有多大\n\n在 `bypassPermissions` 或 `auto` 模式下,命令是否自动放行由**分类器**(yoloClassifier / universalClassifier)决定。Saluzi 的分类器 prompt 明确把以下列为 **Irreversible Local Destruction(不可逆本地破坏)**:\n\n- `rm -rf` 递归强制删除非平凡路径\n- `Remove-Item -Recurse -Force`(PowerShell 等价物)\n- `> file` 截断已有文件为空\n- `drop database` 删库\n- `git push --force`(视上下文)\n\nPoor/SA 模式下分类器模型降级:\n\n| 模式 | 分类器模型 | 影响 |\n|------|-----------|------|\n| 默认 | MainLoop(如 Max/Pro 主模型) | 精度最高 |\n| Poor/SA | DefaultPro | 略低,但仍是 Pro 级模型 |\n\n**关键点**:\n\n- 分类器**仍然运行**——Poor/SA 没有关闭分类器,只是让它用更便宜的模型跑。\n- Pro 级模型对 `rm -rf /` 这种明显的破坏性命令识别能力依然很强——这不是「盲放」。\n- 降级影响的是**边界模糊**的命令(如 `rm -rf ./build` 这种有歧义的)的判断精度,不是放行 `rm -rf /`。\n\n**所以「删库」风险的真实情况**:\n\n1. `default` / `acceptEdits` / `plan` 模式:**零风险**,必须你确认。\n2. `bypassPermissions` / `auto` + 默认:**低风险**,分类器(MainLoop)会拦。\n3. `bypassPermissions` / `auto` + Poor/SA:**略升的边界风险**,分类器(Pro)对明显破坏命令仍拦,但对模糊命令误判概率略高。\n4. 任何模式 + 配了 `deny` 规则:**零风险**,物理屏蔽。\n\n### SA 模式的特殊风险面\n\nSA 模式只保留核心工具(minimal 4 / extended 7),这反而**缩小**了攻击面:\n\n- **minimal 档没有 WebFetch/WebSearch**:AI 不能下载并执行远程脚本。extended 档恢复 WebFetch,但仍无 WebSearch。\n- **没有 Task**:不能 spawn 子 Agent 绕过主循环审查。\n- **没有 MCP 工具**:外部 MCP 服务器不能注入未审查的工具。\n- **没有 Skill**:自定义技能不会被执行。\n\n但 **Bash 仍在**——这是 SA 模式下唯一的「能干坏事」的入口。只要 Bash 的权限策略到位(`default` 模式或 `deny` 规则),SA 模式的整体风险面比默认模式**更小**,不是更大。\n\n### 安全使用建议\n\n| 建议 | 原因 |\n|------|------|\n| 默认用 `default` 或 `acceptEdits` 权限模式 | Bash 逐条确认,物理安全 |\n| 在 `settings.json` 配 `permissions.deny` 屏蔽 `rm -rf /`、`drop database`、`mkfs`、fork 炸弹 | 一刀切物理隔离,不受任何模式影响 |\n| 开启沙箱(`sandbox.enabled: true`)| 限制写入路径与网络访问,`rm -rf /` 直接失败 |\n| 避免 `bypassPermissions` + Poor/SA 组合 | 分类器降级 + 不问你 = 信任分类器,边界命令风险略升 |\n| SA 模式下尤其盯紧 Bash 输出 | 没有验证 Agent 兜底,需要你自己看命令 |\n| 用 `/permissions` 临时切 `plan` 模式做危险探索 | 只读,根本不能执行写操作 |\n\n### 一句话总结\n\n**Poor/SA 不会让 Saluzi「更敢删库」**——它们只砍后台副作用和工具数量,不动权限策略与 deny 规则。真正的删库风险来自 `bypassPermissions`/`auto` 权限模式本身;要彻底消除风险,配 `deny` 规则 + 开沙箱 + 用 `default` 模式,这三道防线与节约模式正交,同时开启完全安全。\n\n## 如何开启 / 关闭\n\n### 命令切换\n\n```\n> /poor # 切换 Poor 模式(开↔关)\n> /sa # 切换 SA 模式(开↔关,保留当前档位)\n> /sa minimal # 切到 minimal 档(4 工具:Read/Edit/Write/Bash)\n> /sa extended # 切到 extended 档(7 工具:+Glob/Grep/WebFetch)\n```\n\n输出会确认当前状态,例如:\n\n```\nSA mode ON — minimal prompt, 4 tools (Read/Edit/Write/Bash), all background tasks disabled\nSA tool level set to extended (7 tools when SA is active)\n```\n\n### 配置面板\n\n`/config` → 找到 `Token saving mode`(normal / poor / sa)。选 `sa` 后会多出一个 `SA tool level` 子项(minimal / extended),`Enter` 切换。\n\n### settings.json\n\n直接编辑 `~/.saluzi-edu/settings.json`:\n\n```json\n{\n \"poorMode\": true,\n \"saMode\": {\n \"enabled\": true,\n \"tools\": \"minimal\"\n }\n}\n```\n\n`poorMode` 是布尔,`true` 开启、省略或 `false` 关闭。`saMode` 是对象:`enabled` 控制开关,`tools` 取 `minimal` 或 `extended`。旧版本写 `\"saMode\": true` 仍兼容,等同于 `{ \"enabled\": true, \"tools\": \"minimal\" }`。重启 Saluzi 后生效。\n\n> **不要同时开 Poor 和 SA**。SA 是 Poor 的严格超集,同时开启只是冗余——工具集与 prompt 都按 SA 走,Poor 的标志位不起额外作用。需要极限省 token 就直接开 SA;需要保留全部工具就开 Poor。\n\n## 何时该用哪个\n\n| 你的情况 | 推荐 |\n|---------|------|\n| 日常开发,想省点 token,但还要用 Glob/Grep/MOM/CodeGraph | **Poor** |\n| API Key 按量计费,想压到最低 | **Poor**(日常)或 **SA**(窄任务) |\n| 用弱模型 / 小上下文窗口 | **SA** |\n| 一次性脚本:改一个文件、跑个命令 | **SA** |\n| 复杂架构重构、需要项目记忆与多步任务 | **关闭**(用默认) |\n| 需要 MOM 多顾问交叉验证 | **Poor**(保留工具)或 **关闭** |\n| 调试时想要「AI 不要偷偷干别的」 | **SA** |\n| 长期挂着的会话,不想后台烧 token | **Poor** |\n\n## 节约效果怎么看\n\n开启后用 `/cost` 观察单轮 token:\n\n```\n> /cost\n```\n\n重点看**输入 token**——SA 模式下每轮输入 token 会显著下降(因为 prompt 从数千字缩到 ~20 行)。后台 side-query 的输出 token 也归零。多轮对比即可看到差异。\n\n## 下一步\n\n- [MOM 混合模型](./mom-mixed-models) — 节约模式下 MOM 如何运行\n- [模型选择与切换](./model-selection) — `/poor` 命令的简述与模型降级\n- [查看消耗](./cost-usage) — `/cost` 监控节约效果\n- [记忆系统](./memory-system) — Poor/SA 对记忆的影响\n"
|
|
3127
3127
|
},
|
|
3128
3128
|
"docs/guide/assistant-proactive": {
|
|
3129
3129
|
"frontmatter": {
|
|
@@ -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{ae as x,af as o,G as m,a9 as s,a3 as l,v as u}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){x();const[a,i]=d.useState([]),{myTeams:r,isLoading:c}=o(),n=d.useCallback(async()=>{try{const t=await m();i(t||[])}catch(t){console.error("Admin: failed to load sessions",t)}},[]);return d.useEffect(()=>{n()},[n]),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8",children:[e.jsx("h1",{className:"mb-6 font-display text-2xl font-semibold text-text-primary",children:s("admin.title")}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.teams")," (",r.length,")"]}),c?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("common.loading")}):r.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noTeams")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("a",{href:`/teams/${t.slug}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium text-text-primary",children:t.name}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:t.slug})]}),e.jsx("span",{className:"text-xs text-text-muted",children:l(new Date(t.created_at).getTime()/1e3)})]},t.id))})]}),e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.sessions")," (",a.length,")"]}),a.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noSessions")}):e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("a",{href:`/code/${t.id}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.title||t.id}),e.jsx("span",{className:"rounded-full bg-surface-2 px-2 py-0.5 text-xs text-text-muted",children:t.source||"unknown"})]}),e.jsx("div",{className:"truncate text-xs text-text-muted",children:t.id})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-3",children:[e.jsx(u,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:l(t.updated_at||t.created_at)})]})]},t.id))})]})]})})}export{j as AdminPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{z as d}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function f(){const r=window.location.pathname.split("/"),t=r[r.length-1]||"",[i,s]=a.useState("idle"),[o,c]=a.useState(null),[m,l]=a.useState(null);return a.useEffect(()=>{if(!t||!t.startsWith("clm_")){c("Invalid claim token"),s("error");return}s("claiming"),d(t).then(n=>{l(n.environment_id),s("success")}).catch(n=>{c(n instanceof Error?n.message:"Claim failed"),s("error")})},[t]),i==="claiming"?e.jsx("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:e.jsx("p",{className:"text-sm text-text-muted",children:"Claiming environment..."})}):i==="error"?e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsx("p",{className:"text-sm text-destructive",children:o}),e.jsx("a",{href:"/code",className:"mt-4 inline-block text-accent hover:underline",children:"Back to dashboard"})]}):e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-10",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:"Environment claimed"}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:"You are now the owner of this environment."})]}),e.jsxs("div",{className:"space-y-4",children:[m&&e.jsx("p",{className:"font-mono text-xs text-text-muted",children:m}),e.jsx("a",{href:"/code",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 transition-colors",children:"Go to dashboard"})]})]})}export{f as Claim};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{j as e,e as o}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{j as e,e as o}from"./vendor-DE_-CLIE.js";import{a0 as O,$ as _,af as T,ad as E,v as P,ae as L,a9 as a,a3 as $,p as A,r as H,e as W,q as V,d as I,a6 as q,B as G,G as R,H as U,F as Z}from"./main-BAk_zq3S.js";import{g as D}from"./workerType-Bd-zteMi.js";import{S as z,D as J,a as K,c as Q,d as X,b as Y}from"./SessionVisibilityBadge-Dw6mot6J.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ee=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],te=O("folder",ee);function se({teamName:n,className:x}){return n?e.jsx("span",{className:_("inline-flex items-center rounded-full border border-border/60 bg-surface-2 px-2 py-0.5 text-xs text-text-muted",x),children:n}):null}function re({environments:n,onSelectEnvironment:x}){const{activeTeam:f}=E(),{user:u}=T(),i=o.useMemo(()=>(u==null?void 0:u.role)==="admin"?n:f?n.filter(r=>r.team_id===f.id):n.filter(r=>!r.team_id),[n,f,u]);return!i||i.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No active environments"}):e.jsx("div",{className:"space-y-2",children:i.map(r=>{const c=r.worker_type==="acp",b=D(r.worker_type),p=b.fullLabel,g=b.colorClass;return e.jsxs("button",{type:"button",onClick:()=>x==null?void 0:x(r),disabled:c,className:`flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors ${c?"cursor-default opacity-80":"hover:border-border-light cursor-pointer"}`,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:r.machine_name||r.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${g}`,children:p}),e.jsx(se,{teamName:r.team_name??null})]}),e.jsx("div",{className:"text-sm text-text-muted",children:r.directory||""})]})}),e.jsxs("div",{className:"text-right",children:[e.jsx(P,{status:r.status}),e.jsx("div",{className:"mt-1 text-xs text-text-muted",children:r.branch||""})]})]},r.id)})})}function ae({sessions:n,environments:x,onSelect:f,onDelete:u}){L();const{activeTeam:i,myTeams:r}=E(),{user:c}=T(),b=o.useMemo(()=>{const t=new Map;for(const m of r)t.set(m.id,m.name);return t},[r]),p=o.useMemo(()=>(c==null?void 0:c.role)==="admin"?n:i?n.filter(t=>t.owner_type==="team"&&t.owner_id===i.id):n.filter(t=>t.owner_type==="user"||t.access_level==="write"||t.access_level==="read"),[n,i,c]),{mySessions:g,sharedSessions:v}=o.useMemo(()=>{const t=[],m=[];for(const d of p)i?t.push(d):d.access_level==="write"||d.access_level==="read"?m.push(d):t.push(d);return{mySessions:t,sharedSessions:m}},[p,i]),y=new Map;for(const t of x??[])t!=null&&t.id&&t.worker_type&&y.set(t.id,t.worker_type);const l=(t,m)=>(m.updated_at||0)-(t.updated_at||0);function h(t){const m=!!u&&t.access_level!=="write"&&t.access_level!=="read";return e.jsxs("div",{className:"group flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("button",{type:"button",onClick:()=>f(t.id),className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.title||t.id}),t.visibility&&e.jsx(G,{visibility:t.visibility||"private"}),(()=>{var k;let d=t.source==="acp"?"acp":(k=t.environment)==null?void 0:k.worker_type;!d&&t.environment_id&&(d=y.get(t.environment_id));const j=D(d);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${j.colorClass}`,children:j.fullLabel})})()]}),e.jsxs("div",{className:"flex items-center gap-2 truncate text-xs text-text-muted",children:[e.jsx("span",{className:"truncate font-mono",children:t.id}),t.owner_type==="team"&&t.owner_id&&e.jsxs("span",{className:"inline-flex items-center gap-2 truncate",children:[e.jsx("span",{className:"text-text-muted/40",children:"|"}),e.jsx("span",{className:"truncate",children:b.get(t.owner_id)||t.owner_id})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(P,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:A(t.created_at||t.updated_at)}),m&&e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),u(t.id)},className:"rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100",title:"Delete session",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},t.id)}if(p.length===0)return e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No sessions"});const N=[...g].sort(l),w=[...v].sort(l);return e.jsxs("div",{className:"space-y-4",children:[N.length>0&&e.jsxs("section",{className:"space-y-2",children:[!i&&w.length>0&&e.jsx("h3",{className:"px-1 text-xs font-medium uppercase tracking-wide text-text-muted",children:a("session.mySessions")}),N.map(h)]}),w.length>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"px-1 text-xs font-medium uppercase tracking-wide text-text-muted",children:a("session.sharedWithMe")}),w.map(h)]})]})}function ne({open:n,environments:x,onClose:f,onCreated:u}){L();const{activeTeam:i}=E(),{user:r}=T(),[c,b]=o.useState(""),[p,g]=o.useState(""),[v,y]=o.useState("same-dir"),[l,h]=o.useState(""),[N,w]=o.useState(!1),[t,m]=o.useState(!1),d=o.useMemo(()=>(r==null?void 0:r.role)==="admin"?x:i?x.filter(s=>s.team_id===i.id):x.filter(s=>!s.team_id),[x,i,r]);o.useEffect(()=>{n&&(b(""),g(""),y("same-dir"),h(""),m(!1))},[n]);const j=d.find(s=>s.id===p)||null,k=j?d.findIndex(s=>s.id===j.id)+1:null,B=async()=>{w(!0),h("");try{const s={};c.trim()&&(s.title=c.trim()),p&&(s.environment_id=p),s.spawn_mode=v;const S=Z();S&&(s.team_id=S);const C=await q(s);u(C)}catch(s){h(s instanceof Error?s.message:a("dialog.createFailed"))}finally{w(!1)}};return e.jsx(J,{open:n,onOpenChange:s=>{s||f()},children:e.jsxs(K,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Q,{children:e.jsx(X,{className:"font-display text-lg font-semibold text-text-primary",children:a("dialog.newSession")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:a("dialog.titleOptional")}),e.jsx("input",{type:"text",value:c,onChange:s=>b(s.target.value),placeholder:a("dialog.titlePlaceholder"),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 text-text-secondary",children:a("dialog.environment")}),e.jsxs($,{open:t,onOpenChange:m,children:[e.jsx(W,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary hover:border-border-light focus:border-brand focus:outline-none transition-colors",children:[e.jsx("span",{className:_("flex items-center gap-2 truncate",!j&&"text-text-muted"),children:j?e.jsxs(e.Fragment,{children:[k!==null&&e.jsxs("span",{className:"shrink-0 rounded bg-surface-3 px-1.5 py-0.5 text-[10px] font-mono text-text-muted",children:["#",k]}),e.jsx("span",{className:"truncate",children:j.machine_name||j.id}),e.jsx("span",{className:"shrink-0 text-text-muted",children:"·"}),e.jsx("span",{className:"shrink-0 text-text-muted",children:D(j.worker_type).shortLabel})]}):e.jsx("span",{children:a("dialog.none")})}),e.jsx(H,{className:"h-4 w-4 shrink-0 text-text-muted"})]})}),e.jsxs(V,{align:"start",className:"max-h-80 w-80 overflow-y-auto rounded-lg border-border bg-surface-1 p-1 shadow-xl",children:[e.jsxs("button",{type:"button",onClick:()=>{g(""),m(!1)},className:"flex w-full items-center justify-between rounded-md px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:[e.jsx("span",{children:a("dialog.none")}),!p&&e.jsx(I,{className:"h-3.5 w-3.5 text-brand"})]}),d.length===0?e.jsx("p",{className:"px-3 py-2 text-xs text-text-muted",children:a("dialog.envEmpty")}):e.jsx("div",{className:"space-y-1 pt-1",children:d.map((s,S)=>{const C=D(s.worker_type),M=!!s.team_id,F=s.id===p;return e.jsxs("button",{type:"button",onClick:()=>{g(s.id),m(!1)},className:_("flex w-full flex-col gap-1.5 rounded-md px-3 py-2 text-left transition-colors",F?"bg-brand/10":"hover:bg-surface-2"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"shrink-0 rounded bg-surface-3 px-1.5 py-0.5 text-[10px] font-mono text-text-muted",children:["#",S+1]}),e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.machine_name||s.id}),e.jsx("span",{className:_("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium",C.colorClass),children:C.shortLabel}),e.jsx("span",{className:_("shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium",M?"border-border/60 bg-surface-2 text-text-muted":"border-brand/30 bg-brand/10 text-brand"),children:M?`${a("dialog.envTeam")}: ${s.team_name||s.team_id}`:a("dialog.envPersonal")}),F&&e.jsx(I,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-brand"})]}),s.directory&&e.jsxs("div",{className:"flex items-center gap-1.5 truncate text-xs text-text-muted",children:[e.jsx(te,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-mono",children:s.directory}),s.branch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-muted/40",children:"·"}),e.jsx("span",{className:"truncate",children:s.branch})]})]})]},s.id)})})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:a("dialog.workspaceMode")}),e.jsxs("select",{value:v,onChange:s=>y(s.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"same-dir",children:a("dialog.sameDir")}),e.jsx("option",{value:"worktree",children:a("dialog.worktree")})]})]}),l&&e.jsx("div",{className:"text-sm text-status-error",children:l})]}),e.jsxs(Y,{children:[e.jsx("button",{onClick:f,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:a("common.cancel")}),e.jsx("button",{onClick:B,disabled:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:N?a("common.creating"):a("common.create")})]})]})})}function me({onNavigateSession:n}){L();const[x,f]=o.useState([]),[u,i]=o.useState([]),[r,c]=o.useState(!1),b=o.useCallback(async()=>{try{const[l,h]=await Promise.all([R(),U()]);f(l||[]),i(h||[])}catch(l){console.error("Dashboard render error:",l)}},[]);o.useEffect(()=>{b();const l=setInterval(b,1e4);return()=>clearInterval(l)},[b]);const p=l=>{c(!1),n(l.id)},g=o.useCallback(l=>{},[]),v=o.useCallback(l=>{n(l)},[n]),y=o.useCallback(async l=>{if(window.confirm(a("dashboard.confirmDelete").replace("{id}",l)))try{await z(l),f(h=>h.filter(N=>N.id!==l))}catch(h){alert(h instanceof Error?h.message:a("dashboard.deleteFailed"))}},[]);return e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsx("h1",{className:"sr-only",children:a("dashboard.title")}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:a("dashboard.environments")}),e.jsx(re,{environments:u,onSelectEnvironment:g})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium text-text-primary",children:a("dashboard.sessions")}),e.jsx("button",{onClick:()=>c(!0),className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent/90 transition-colors",children:a("dashboard.newSession")})]}),e.jsx(ae,{sessions:x,environments:u,onSelect:v,onDelete:y})]}),e.jsx(ne,{open:r,environments:u,onClose:()=>c(!1),onCreated:p})]})})}export{me as Dashboard};
|
|
6
|
+
*/const ee=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],te=O("folder",ee);function se({teamName:n,className:x}){return n?e.jsx("span",{className:_("inline-flex items-center rounded-full border border-border/60 bg-surface-2 px-2 py-0.5 text-xs text-text-muted",x),children:n}):null}function re({environments:n,onSelectEnvironment:x}){const{activeTeam:f}=T(),{user:u}=E(),i=o.useMemo(()=>(u==null?void 0:u.role)==="admin"?n:f?n.filter(r=>r.team_id===f.id):n.filter(r=>!r.team_id),[n,f,u]);return!i||i.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No active environments"}):e.jsx("div",{className:"space-y-2",children:i.map(r=>{const c=r.worker_type==="acp",b=D(r.worker_type),p=b.fullLabel,g=b.colorClass;return e.jsxs("button",{type:"button",onClick:()=>x==null?void 0:x(r),disabled:c,className:`flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors ${c?"cursor-default opacity-80":"hover:border-border-light cursor-pointer"}`,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:r.machine_name||r.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${g}`,children:p}),e.jsx(se,{teamName:r.team_name??null})]}),e.jsx("div",{className:"text-sm text-text-muted",children:r.directory||""})]})}),e.jsxs("div",{className:"text-right",children:[e.jsx(P,{status:r.status}),e.jsx("div",{className:"mt-1 text-xs text-text-muted",children:r.branch||""})]})]},r.id)})})}function ae({sessions:n,environments:x,onSelect:f,onDelete:u}){L();const{activeTeam:i,myTeams:r}=T(),{user:c}=E(),b=o.useMemo(()=>{const t=new Map;for(const m of r)t.set(m.id,m.name);return t},[r]),p=o.useMemo(()=>(c==null?void 0:c.role)==="admin"?n:i?n.filter(t=>t.owner_type==="team"&&t.owner_id===i.id):n.filter(t=>t.owner_type==="user"||t.access_level==="write"||t.access_level==="read"),[n,i,c]),{mySessions:g,sharedSessions:v}=o.useMemo(()=>{const t=[],m=[];for(const d of p)i?t.push(d):d.access_level==="write"||d.access_level==="read"?m.push(d):t.push(d);return{mySessions:t,sharedSessions:m}},[p,i]),y=new Map;for(const t of x??[])t!=null&&t.id&&t.worker_type&&y.set(t.id,t.worker_type);const l=(t,m)=>(m.updated_at||0)-(t.updated_at||0);function h(t){const m=!!u&&t.access_level!=="write"&&t.access_level!=="read";return e.jsxs("div",{className:"group flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("button",{type:"button",onClick:()=>f(t.id),className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.title||t.id}),t.visibility&&e.jsx(z,{visibility:t.visibility||"private"}),(()=>{var k;let d=t.source==="acp"?"acp":(k=t.environment)==null?void 0:k.worker_type;!d&&t.environment_id&&(d=y.get(t.environment_id));const j=D(d);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${j.colorClass}`,children:j.fullLabel})})()]}),e.jsxs("div",{className:"flex items-center gap-2 truncate text-xs text-text-muted",children:[e.jsx("span",{className:"truncate font-mono",children:t.id}),t.owner_type==="team"&&t.owner_id&&e.jsxs("span",{className:"inline-flex items-center gap-2 truncate",children:[e.jsx("span",{className:"text-text-muted/40",children:"|"}),e.jsx("span",{className:"truncate",children:b.get(t.owner_id)||t.owner_id})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(P,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:$(t.created_at||t.updated_at)}),m&&e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),u(t.id)},className:"rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100",title:"Delete session",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},t.id)}if(p.length===0)return e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No sessions"});const N=[...g].sort(l),w=[...v].sort(l);return e.jsxs("div",{className:"space-y-4",children:[N.length>0&&e.jsxs("section",{className:"space-y-2",children:[!i&&w.length>0&&e.jsx("h3",{className:"px-1 text-xs font-medium uppercase tracking-wide text-text-muted",children:a("session.mySessions")}),N.map(h)]}),w.length>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"px-1 text-xs font-medium uppercase tracking-wide text-text-muted",children:a("session.sharedWithMe")}),w.map(h)]})]})}function ne({open:n,environments:x,onClose:f,onCreated:u}){L();const{activeTeam:i}=T(),{user:r}=E(),[c,b]=o.useState(""),[p,g]=o.useState(""),[v,y]=o.useState("same-dir"),[l,h]=o.useState(""),[N,w]=o.useState(!1),[t,m]=o.useState(!1),d=o.useMemo(()=>(r==null?void 0:r.role)==="admin"?x:i?x.filter(s=>s.team_id===i.id):x.filter(s=>!s.team_id),[x,i,r]);o.useEffect(()=>{n&&(b(""),g(""),y("same-dir"),h(""),m(!1))},[n]);const j=d.find(s=>s.id===p)||null,k=j?d.findIndex(s=>s.id===j.id)+1:null,B=async()=>{w(!0),h("");try{const s={};c.trim()&&(s.title=c.trim()),p&&(s.environment_id=p),s.spawn_mode=v;const S=q();S&&(s.team_id=S);const C=await G(s);u(C)}catch(s){h(s instanceof Error?s.message:a("dialog.createFailed"))}finally{w(!1)}};return e.jsx(J,{open:n,onOpenChange:s=>{s||f()},children:e.jsxs(K,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Q,{children:e.jsx(X,{className:"font-display text-lg font-semibold text-text-primary",children:a("dialog.newSession")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:a("dialog.titleOptional")}),e.jsx("input",{type:"text",value:c,onChange:s=>b(s.target.value),placeholder:a("dialog.titlePlaceholder"),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 text-text-secondary",children:a("dialog.environment")}),e.jsxs(A,{open:t,onOpenChange:m,children:[e.jsx(H,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary hover:border-border-light focus:border-brand focus:outline-none transition-colors",children:[e.jsx("span",{className:_("flex items-center gap-2 truncate",!j&&"text-text-muted"),children:j?e.jsxs(e.Fragment,{children:[k!==null&&e.jsxs("span",{className:"shrink-0 rounded bg-surface-3 px-1.5 py-0.5 text-[10px] font-mono text-text-muted",children:["#",k]}),e.jsx("span",{className:"truncate",children:j.machine_name||j.id}),e.jsx("span",{className:"shrink-0 text-text-muted",children:"·"}),e.jsx("span",{className:"shrink-0 text-text-muted",children:D(j.worker_type).shortLabel})]}):e.jsx("span",{children:a("dialog.none")})}),e.jsx(W,{className:"h-4 w-4 shrink-0 text-text-muted"})]})}),e.jsxs(V,{align:"start",className:"max-h-80 w-80 overflow-y-auto rounded-lg border-border bg-surface-1 p-1 shadow-xl",children:[e.jsxs("button",{type:"button",onClick:()=>{g(""),m(!1)},className:"flex w-full items-center justify-between rounded-md px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:[e.jsx("span",{children:a("dialog.none")}),!p&&e.jsx(I,{className:"h-3.5 w-3.5 text-brand"})]}),d.length===0?e.jsx("p",{className:"px-3 py-2 text-xs text-text-muted",children:a("dialog.envEmpty")}):e.jsx("div",{className:"space-y-1 pt-1",children:d.map((s,S)=>{const C=D(s.worker_type),M=!!s.team_id,F=s.id===p;return e.jsxs("button",{type:"button",onClick:()=>{g(s.id),m(!1)},className:_("flex w-full flex-col gap-1.5 rounded-md px-3 py-2 text-left transition-colors",F?"bg-brand/10":"hover:bg-surface-2"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"shrink-0 rounded bg-surface-3 px-1.5 py-0.5 text-[10px] font-mono text-text-muted",children:["#",S+1]}),e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.machine_name||s.id}),e.jsx("span",{className:_("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium",C.colorClass),children:C.shortLabel}),e.jsx("span",{className:_("shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium",M?"border-border/60 bg-surface-2 text-text-muted":"border-brand/30 bg-brand/10 text-brand"),children:M?`${a("dialog.envTeam")}: ${s.team_name||s.team_id}`:a("dialog.envPersonal")}),F&&e.jsx(I,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-brand"})]}),s.directory&&e.jsxs("div",{className:"flex items-center gap-1.5 truncate text-xs text-text-muted",children:[e.jsx(te,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-mono",children:s.directory}),s.branch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-muted/40",children:"·"}),e.jsx("span",{className:"truncate",children:s.branch})]})]})]},s.id)})})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:a("dialog.workspaceMode")}),e.jsxs("select",{value:v,onChange:s=>y(s.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"same-dir",children:a("dialog.sameDir")}),e.jsx("option",{value:"worktree",children:a("dialog.worktree")})]})]}),l&&e.jsx("div",{className:"text-sm text-status-error",children:l})]}),e.jsxs(Y,{children:[e.jsx("button",{onClick:f,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:a("common.cancel")}),e.jsx("button",{onClick:B,disabled:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:N?a("common.creating"):a("common.create")})]})]})})}function me({onNavigateSession:n}){L();const[x,f]=o.useState([]),[u,i]=o.useState([]),[r,c]=o.useState(!1),b=o.useCallback(async()=>{try{const[l,h]=await Promise.all([R(),U()]);f(l||[]),i(h||[])}catch(l){console.error("Dashboard render error:",l)}},[]);o.useEffect(()=>{b();const l=setInterval(b,1e4);return()=>clearInterval(l)},[b]);const p=l=>{c(!1),n(l.id)},g=o.useCallback(l=>{},[]),v=o.useCallback(l=>{n(l)},[n]),y=o.useCallback(async l=>{if(window.confirm(a("dashboard.confirmDelete").replace("{id}",l)))try{await Z(l),f(h=>h.filter(N=>N.id!==l))}catch(h){alert(h instanceof Error?h.message:a("dashboard.deleteFailed"))}},[]);return e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsx("h1",{className:"sr-only",children:a("dashboard.title")}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:a("dashboard.environments")}),e.jsx(re,{environments:u,onSelectEnvironment:g})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium text-text-primary",children:a("dashboard.sessions")}),e.jsx("button",{onClick:()=>c(!0),className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent/90 transition-colors",children:a("dashboard.newSession")})]}),e.jsx(ae,{sessions:x,environments:u,onSelect:v,onDelete:y})]}),e.jsx(ne,{open:r,environments:u,onClose:()=>c(!1),onCreated:p})]})})}export{me as Dashboard};
|
|
@@ -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{ad as v,a9 as t}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function E({onSuccess:b,onInvalidInvite:l}){const{join:h}=v(),[u,f]=r.useState(""),[d,j]=r.useState(""),[o,w]=r.useState(""),[c,g]=r.useState(""),[m,n]=r.useState(""),[x,p]=r.useState(!1);r.useEffect(()=>{const a=new URLSearchParams(window.location.search).get("invite");a?f(a):l()},[l]);const y=async s=>{if(s.preventDefault(),n(""),o.length<8){n(t("auth.setup.passwordTooShort"));return}if(o!==c){n(t("auth.setup.passwordMismatch"));return}p(!0);try{await h(u,d,o),b()}catch(a){const i=a instanceof Error?a.message:"Join failed";if(i.includes("Invalid invitation")||i.includes("expired")||i.includes("already used")){l();return}n(i)}finally{p(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.join.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.join.welcome")}),e.jsx("p",{className:"mt-1 text-sm text-text-muted",children:t("auth.join.description")})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.username")}),e.jsx("input",{type:"text",value:d,onChange:s=>j(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>w(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:c,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),m&&e.jsx("p",{className:"text-sm text-status-error",children:m}),e.jsx("button",{type:"submit",disabled:x||!u,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:x?t("common.loading"):t("auth.join.submit")})]})]})})}export{E as Join};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ad as f,a9 as t}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function N({onSuccess:d,onNavigateRegister:c}){const{login:m,registrationAllowed:x}=f(),[a,p]=r.useState(""),[o,b]=r.useState(""),[l,n]=r.useState(""),[i,u]=r.useState(!1),h=async s=>{s.preventDefault(),n(""),u(!0);try{await m(a,o),d()}catch{n(t("auth.login.failed"))}finally{u(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.login.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.login.description")})]}),e.jsxs("form",{onSubmit:h,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:a,onChange:s=>p(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>b(s.target.value),required:!0,autoComplete:"current-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),l&&e.jsx("p",{className:"text-sm text-status-error",children:l}),e.jsx("button",{type:"submit",disabled:i,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:i?t("common.loading"):t("auth.login.submit")})]}),x&&e.jsx("button",{type:"button",onClick:c,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.login.register")})]})})}export{N as Login};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ad as y,a9 as t}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function S({onSuccess:m,onBack:x}){const{register:p}=y(),[n,b]=r.useState(""),[a,h]=r.useState(""),[l,f]=r.useState(""),[i,o]=r.useState(""),[u,d]=r.useState(!1),g=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==l){o(t("auth.setup.passwordMismatch"));return}d(!0);try{await p(n,a),m()}catch(c){o(c instanceof Error?c.message:t("auth.register.failed"))}finally{d(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.register.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.register.description")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:n,onChange:s=>b(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>h(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:l,onChange:s=>f(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),i&&e.jsx("p",{className:"text-sm text-status-error",children:i}),e.jsx("button",{type:"submit",disabled:u,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:u?t("common.loading"):t("auth.register.submit")})]}),e.jsx("button",{type:"button",onClick:x,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.register.backToLogin")})]})})}export{S as Register};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var Me=Object.defineProperty;var Ee=(s,t,n)=>t in s?Me(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var M=(s,t,n)=>Ee(s,typeof t!="symbol"?t+"":t,n);import{e as m,j as e}from"./vendor-DE_-CLIE.js";import{a0 as R,J as Te,W as Ie,a4 as re,V as B,K as $e,v as de,a3 as ue,L as me,x as Pe,u as Ae,a2 as A,$ as W,d as xe,aa as Re,M as qe,E as De,Q as Ue,ae as pe,a9 as j,A as Oe,a5 as Fe,ab as Le,a1 as He,F as Be,w as he,c as ze,C as Qe,I as Ve,a7 as We,D as Ke,a as Ye,p as Je,r as Ge,t as Xe,f as Ze,e as et,q as tt}from"./main-BAk_zq3S.js";import{g as st}from"./workerType-Bd-zteMi.js";import{D as fe,a as ye,c as be,d as ge,b as nt,S as rt}from"./SessionVisibilityBadge-Dw6mot6J.js";import{U as at}from"./UserSearchInput-BFAPXnsU.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
|
|
2
|
+
* @license lucide-react v0.555.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const ot=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],it=R("activity",ot);/**
|
|
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 lt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ct=R("chevron-right",lt);/**
|
|
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 dt=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ae=R("clock",dt);/**
|
|
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 ut=[["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"}]],mt=R("cpu",ut);/**
|
|
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 xt=[["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"}]],pt=R("hash",xt);/**
|
|
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 ht=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ft=R("info",ht);/**
|
|
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 yt=[["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"}]],bt=R("play",yt);/**
|
|
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 gt=[["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"}]],jt=R("server-cog",gt);/**
|
|
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 wt=[["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"}]],vt=R("share-2",wt);/**
|
|
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 Nt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],kt=R("triangle-alert",Nt);function je(){return{tasks:{}}}const oe=3e4;function X(s){const t=s.trim();if(!t)return"agent";const n=t.split(/\s+/).slice(0,2).join(" ");return n.length>40?n.slice(0,40)+"…":n}function St(s,t){var p,x,h,d,u,a,i,g,f,y,b,k;const n=t.subtype;if(n!=="task_started"&&n!=="task_progress"&&n!=="task_notification")return s;const r=t.task_id;if(!r)return s;const l=Date.now(),o=s.tasks[r];if(n==="task_started"){if(o)return{tasks:{...s.tasks,[r]:{...o,description:t.description??o.description,name:X(t.description??o.description),taskType:t.task_type??o.taskType,workflowName:t.workflow_name??o.workflowName,prompt:t.prompt??o.prompt,toolUseId:t.tool_use_id??o.toolUseId,status:"running",startTime:l,evictAfter:void 0}}};const N=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:X(N),description:N,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:l}}}}if(n==="task_progress"){if(!o){const N=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:X(N),description:N,toolUseId:t.tool_use_id,status:"running",startTime:l,tokenCount:(p=t.usage)==null?void 0:p.total_tokens,toolUseCount:(x=t.usage)==null?void 0:x.tool_uses,durationMs:(h=t.usage)==null?void 0:h.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...o,description:t.description??o.description,tokenCount:((d=t.usage)==null?void 0:d.total_tokens)??o.tokenCount,toolUseCount:((u=t.usage)==null?void 0:u.tool_uses)??o.toolUseCount,durationMs:((a=t.usage)==null?void 0:a.duration_ms)??o.durationMs,lastToolName:t.last_tool_name??o.lastToolName,summary:t.summary??o.summary}}}}return o?{tasks:{...s.tasks,[r]:{...o,status:t.status??"completed",endTime:l,finalSummary:t.summary??o.finalSummary,outputFile:t.output_file??o.outputFile,tokenCount:((y=t.usage)==null?void 0:y.total_tokens)??o.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??o.toolUseCount,durationMs:((k=t.usage)==null?void 0:k.duration_ms)??o.durationMs,evictAfter:l+oe}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:X(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:l,endTime:l,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(i=t.usage)==null?void 0:i.total_tokens,toolUseCount:(g=t.usage)==null?void 0:g.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:l+oe}}}}function _t(s,t=Date.now()){return Object.values(s.tasks).filter(n=>n.evictAfter===void 0||n.evictAfter>t).sort((n,r)=>n.startTime-r.startTime)}class Ct{constructor(){M(this,"listeners",new Set);M(this,"eventSource",null);M(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const n=`/web/sessions/${t}/events`,r=new EventSource(n,{withCredentials:!0});this.eventSource=r,r.addEventListener("message",l=>{try{const o=JSON.parse(l.data);if(o.seqNum!==void 0&&o.seqNum<=this._lastSeqNum)return;o.seqNum!==void 0&&(this._lastSeqNum=o.seqNum);for(const p of this.listeners)p(o)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const se=new Ct;function ie(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("")}return""}function le(s,t){for(let n=s.length-1;n>=0;n--){const r=s[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}class Mt{constructor(t,n,r){M(this,"sessionId");M(this,"setEntries");M(this,"unsub",null);M(this,"onStatusChange");M(this,"onError");M(this,"onPermissionRequest");M(this,"onModelsStateChange");M(this,"onSubagentUpdate");M(this,"onControlResponse");M(this,"onPermissionModeChange");M(this,"subagentState",je());M(this,"seenUuids",new Set);M(this,"seenToolCallIds",new Set);this.sessionId=t,this.setEntries=n,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate,this.onControlResponse=r==null?void 0:r.onControlResponse,this.onPermissionModeChange=r==null?void 0:r.onPermissionModeChange}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var p;const{events:t}=await Te(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const l=()=>{r&&(n.push(r),r=null)};for(const x of t){const h=x.payload||{},d=h.uuid;if(typeof d=="string"&&d&&this.seenUuids.add(d),x.type==="tool_use"){const u=h.tool_call_id;typeof u=="string"&&u&&this.seenToolCallIds.add(u)}if(x.type==="user"){if(x.direction==="inbound")continue;l();const u=ie(h);u&&n.push({type:"user_message",id:x.id||`hist-user-${n.length}`,content:u})}else if(x.type==="assistant"){l();const u=ie(h),a=[],i=h.message;if(i&&typeof i=="object"&&Array.isArray(i.content)){for(const g of i.content)if(g.type==="tool_use"){const f=g.id;f&&this.seenToolCallIds.add(f),a.push({type:"tool_call",toolCall:{id:f||`hist-tool-${n.length}`,title:g.name||"tool",status:"complete",rawInput:g.input||{}}})}}if(u||a.length>0){r={type:"assistant_message",id:x.id||`hist-asst-${n.length}`,chunks:u?[{type:"message",text:u}]:[]},n.push(r);for(const g of a)n.push(g);r=null}}else if(x.type==="tool_use"){const u=h,a={type:"tool_call",toolCall:{id:u.tool_call_id||`hist-tool-${n.length}`,title:u.tool_name||"tool",status:"complete",rawInput:u.tool_input||{}}};n.push(a)}else if(x.type==="tool_result"){const u=h,a=le(n,u.tool_call_id||"");if(a>=0){const i=n[a];n[a]={type:"tool_call",toolCall:{...i.toolCall,rawOutput:{output:u.content||u.output||""}}}}}}l(),this.setEntries(n);let o=null;for(const x of t){if(x.type!=="models_state")continue;const h=x.payload||{},d=h.raw,u=d&&typeof d=="object"?d.models_state:h.models_state;u&&Array.isArray(u.availableModels)&&typeof u.currentModelId=="string"&&(o=u)}o&&((p=this.onModelsStateChange)==null||p.call(this,o))}connectSSE(){se.connect(this.sessionId),this.unsub=se.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),se.disconnect()}handleEvent(t){var o,p,x,h,d,u;const n=t.type,r=t.payload||{},l=JSON.stringify(t);if(!/Remote Control connecting/i.test(l))switch(n){case"assistant":{const a=r.uuid;if(typeof a=="string"&&a){if(this.seenUuids.has(a))break;this.seenUuids.add(a)}const i=typeof r.content=="string"?r.content:"";this.setEntries(f=>{const y=f[f.length-1];if((y==null?void 0:y.type)==="assistant_message"){const b=y.chunks[y.chunks.length-1];return(b==null?void 0:b.type)==="message"?[...f.slice(0,-1),{...y,chunks:[...y.chunks.slice(0,-1),{type:"message",text:b.text+i}]}]:[...f.slice(0,-1),{...y,chunks:[...y.chunks,{type:"message",text:i}]}]}if(i&&i.trim()){const b={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:i}]};return[...f,b]}return f});const g=r.message;if(g&&typeof g=="object"&&Array.isArray(g.content)){const f=g.content.filter(y=>y.type==="tool_use");for(const y of f){const b=y.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(b))continue;this.seenToolCallIds.add(b);const k={id:b,title:y.name||"tool",status:"running",rawInput:y.input||{}};this.setEntries(N=>[...N,{type:"tool_call",toolCall:k}])}}break}case"tool_use":{const a=r,i=a.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(i))break;this.seenToolCallIds.add(i);const g={id:i,title:a.tool_name||"tool",status:"running",rawInput:a.tool_input||{}};this.setEntries(f=>[...f,{type:"tool_call",toolCall:g}]);break}case"tool_result":{const a=r,i=a.tool_call_id||"";this.setEntries(g=>{const f=le(g,i);if(f<0)return g;const y=g[f];return g.map((b,k)=>k===f?{type:"tool_call",toolCall:{...y.toolCall,status:"complete",rawOutput:{output:a.content||a.output||""}}}:b)});break}case"control_request":case"permission_request":{const a=r.request;if(a&&a.subtype==="can_use_tool"){const i=r.request_id||"",g=a.tool_name||"unknown",f=a.input||a.tool_input||{},y=a.description||"";this.setEntries(b=>{const k=[...b].reverse().findIndex(N=>N.type==="tool_call");if(k>=0){const N=b.length-1-k,C=b[N];if(C.toolCall.status==="running")return b.map((E,T)=>T===N?{type:"tool_call",toolCall:{...C.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:i,options:[]}}}:E)}return b}),(o=this.onPermissionRequest)==null||o.call(this,{requestId:i,toolName:g,toolInput:f,description:y})}break}case"session_status":{typeof r.status=="string"&&((p=this.onStatusChange)==null||p.call(this,r.status));break}case"error":{const a=String(r.message||r.content||"Unknown error");(x=this.onError)==null||x.call(this,a);break}case"models_state":{const a=r.raw,i=typeof a=="object"&&a!==null?a.models_state:r.models_state;i&&Array.isArray(i.availableModels)&&typeof i.currentModelId=="string"&&((h=this.onModelsStateChange)==null||h.call(this,i));break}case"system":{const a=r.raw,i=a&&typeof a=="object"?a:r,g=typeof i.subtype=="string"?i.subtype:void 0;if(g==="task_started"||g==="task_progress"||g==="task_notification"){const y={subtype:g,task_id:typeof i.task_id=="string"?i.task_id:void 0,tool_use_id:typeof i.tool_use_id=="string"?i.tool_use_id:void 0,description:typeof i.description=="string"?i.description:void 0,task_type:typeof i.task_type=="string"?i.task_type:void 0,workflow_name:typeof i.workflow_name=="string"?i.workflow_name:void 0,prompt:typeof i.prompt=="string"?i.prompt:void 0,usage:i.usage&&typeof i.usage=="object"?i.usage:void 0,last_tool_name:typeof i.last_tool_name=="string"?i.last_tool_name:void 0,summary:typeof i.summary=="string"?i.summary:void 0,status:i.status==="completed"||i.status==="failed"||i.status==="stopped"?i.status:void 0,output_file:typeof i.output_file=="string"?i.output_file:void 0};this.subagentState=St(this.subagentState,y)}const f=typeof i.permissionMode=="string"?i.permissionMode:typeof r.permissionMode=="string"?r.permissionMode:null;f&&((d=this.onPermissionModeChange)==null||d.call(this,f));break}case"control_response":{const a=r.response;if(a&&typeof a=="object"){const i=typeof a.request_id=="string"?a.request_id:"",g=typeof a.subtype=="string"?a.subtype:"";i&&((u=this.onControlResponse)==null||u.call(this,{subtype:g,requestId:i,error:typeof a.error=="string"?a.error:void 0}))}break}}}async sendMessage(t,n,r){const l=n&&n.length>0,o=r&&r.length>0;if(!t.trim()&&!l&&!o)return;const p={type:"user_message",id:`user-${Date.now()}`,content:t,images:l?n:void 0,attachments:o?r:void 0};this.setEntries(d=>[...d,p]);const x=[];if(t&&x.push({type:"text",text:t}),l)for(const d of n)x.push({type:"image",source:{type:"base64",media_type:d.mimeType,data:d.data}});if(o){for(const d of r)if(d.kind==="text"||d.kind==="table"){const u=`📎 ${d.name}${d.size!=null?` (${Et(d.size)})`:""}`,a=d.textContent||"(空文件)";x.push({type:"text",text:`${u}
|
|
52
|
+
\`\`\`
|
|
53
|
+
${a}
|
|
54
|
+
\`\`\``})}else if(d.kind==="directory"){const u=`📁 目录: ${d.name}${d.files!=null?` (${d.files.length} 个文件)`:""}`,a=d.textContent||"(空目录)";x.push({type:"text",text:`${u}
|
|
55
|
+
${a}`})}}const h=x.length===1&&x[0].type==="text"?x[0].text||t:x.length>0?x:t;await Ie(this.sessionId,{type:"user",uuid:re(),content:t,message:{content:h}})}async respondPermission(t,n,r){await B(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(l=>l.map(o=>{var p;return o.type!=="tool_call"||((p=o.toolCall.permissionRequest)==null?void 0:p.requestId)!==t?o:{type:"tool_call",toolCall:{...o.toolCall,status:n?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(n=>n.type!=="tool_call"||n.toolCall.status!=="running"&&n.toolCall.status!=="waiting_for_confirmation"?n:{type:"tool_call",toolCall:{...n.toolCall,status:"canceled",permissionRequest:void 0}})),await $e(this.sessionId)}async setPermissionMode(t){const n=re();return await B(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"set_permission_mode",mode:t}}),n}}function Et(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Tt(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function It(s){return s?Date.now()-s<6e4:!1}function $t({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:l,onDelete:o}){const[p,x]=m.useState(!1),h=async()=>{await navigator.clipboard.writeText(t.id),x(!0),setTimeout(()=>x(!1),1500)},d=r.length,u=t.worker,a=t.work_item,i=t.environment;return e.jsx(fe,{open:!0,onOpenChange:g=>{g||s()},children:e.jsxs(ye,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(be,{children:e.jsx(ge,{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(it,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(de,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:u&&(It(u.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[u&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ae,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Tt(u.last_heartbeat_at)})]}),i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(mt,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:i.machine_name||i.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ae,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ue(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(me,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),d>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[d," permission request",d>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(jt,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:l,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),e.jsxs("button",{onClick:o,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(Pe,{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(pt,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:h,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:p?"✓":"⧉"})]})]}),a&&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:a.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:a.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})]}),i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:i.worker_type})]})]})]})]})]})})}const ce="rcs:subagent-panel:collapsed";function Pt(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m${r}s`:`${n}m`;const l=Math.floor(n/60),o=n%60;return o?`${l}h${o}m`:`${l}h`}function At(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function Rt({status:s}){return s==="running"?e.jsx(me,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(bt,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(Ae,{className:"h-3 w-3 text-status-error"}):null}function qt({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=At(s.tokenCount),l=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",o=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(Rt,{status:s.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:Pt(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:o}),(r||l||s.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[r&&e.jsxs("span",{children:["↕ ",r," tok"]}),l&&e.jsxs("span",{children:["· ",l]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function Dt({state:s}){const[t,n]=m.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(ce)==="1"}catch{return!1}}),r=()=>{n(h=>{const d=!h;try{window.localStorage.setItem(ce,d?"1":"0")}catch{}return d})},[,l]=m.useState(0);m.useEffect(()=>{const h=Object.values(s.tasks).some(a=>a.status==="running"),d=Object.values(s.tasks).some(a=>a.status!=="running"&&a.evictAfter!==void 0);if(!h&&!d)return;const u=setInterval(()=>{l(a=>a+1)},1e3);return()=>clearInterval(u)},[s]);const o=_t(s);if(o.length===0)return null;const p=o.filter(h=>h.status==="running").length,x=p>0?`${p} running`:`${o.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:r,"aria-expanded":!t,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ct,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:x})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:o.map(h=>e.jsx(qt,{task:h},h.taskId))})]})})}function Ut({requestId:s,toolName:t,toolInput:n,description:r,onApprove:l,onReject:o}){const p=typeof n=="string"?n:JSON.stringify(n,null,2);return e.jsxs("div",{className:"rounded-xl border border-warning-border/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-warning-border/15 text-warning-text",children:e.jsx(kt,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:A(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:A(t)}),t!=="AskUserQuestion"&&e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:Re(p,500)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:l,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),e.jsx("button",{onClick:o,className:"rounded-lg bg-status-error/20 px-4 py-2 text-sm font-medium text-status-error hover:bg-status-error/30 transition-colors",children:"Reject"})]})]})}function Ot({questions:s,description:t,onSubmit:n,onSkip:r}){const[l,o]=m.useState({}),[p,x]=m.useState({}),[h,d]=m.useState(0),u=(f,y,b)=>{if(b){const k=l[f]||[],N=k.includes(y)?k.filter(C=>C!==y):[...k,y];o({...l,[f]:N})}else o({...l,[f]:y})},a=f=>{var b;const y=(b=p[f])==null?void 0:b.trim();y&&(o({...l,[f]:y}),x({...p,[f]:""}))},i=()=>{var y,b;const f={};for(const[k,N]of Object.entries(l)){const C=s[parseInt(k,10)];C&&(typeof N=="number"?f[k]=((b=(y=C.options)==null?void 0:y[N])==null?void 0:b.label)||String(N):Array.isArray(N)?f[k]=N.map(E=>{var T,D;return((D=(T=C.options)==null?void 0:T[E])==null?void 0:D.label)||String(E)}):f[k]=N)}n(f)};if(s.length<=1){const f=s[0]||{question:t,options:[],multiSelect:!1},y=f.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:A(t||f.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(f.options||[]).map((b,k)=>{const N=y?(l[0]||[]).includes(k):l[0]===k;return e.jsxs("button",{onClick:()=>u(0,k,y),className:W("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",N?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:A(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(b.description)})]},k)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:p[0]||"",onChange:b=>x({...p,0:b.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:b=>b.key==="Enter"&&a(0)}),e.jsx("button",{onClick:()=>a(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:i,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const g=s[h];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:A(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((f,y)=>e.jsx("button",{onClick:()=>d(y),className:W("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",h===y?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:f.header||`Q${y+1}`},y))}),g&&e.jsx(Ft,{question:g,qIdx:h,answers:l,otherTexts:p,onSelect:u,onOtherTextChange:(f,y)=>x({...p,[f]:y}),onOtherSubmit:a}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[h+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:i,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function Ft({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:l,onOtherTextChange:o,onOtherSubmit:p}){const x=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:A(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((h,d)=>{const u=x?(n[t]||[]).includes(d):n[t]===d;return e.jsxs("button",{onClick:()=>l(t,d,x),className:W("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",u?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:A(h.label)}),h.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(h.description)})]},d)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:h=>o(t,h.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:h=>h.key==="Enter"&&p(t)}),e.jsx("button",{onClick:()=>p(t),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function Lt({planContent:s,description:t,onSubmit:n}){const[r,l]=m.useState(null),[o,p]=m.useState(""),x=!s||!s.trim(),h=()=>{r&&n(r,r==="no"?o:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(xe,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:x?"Exit plan mode?":"Ready to code?"})]}),!x&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:Ht(s)}}),e.jsx("div",{className:"space-y-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(V,{selected:r==="yes-default",onClick:()=>l("yes-default"),label:"Yes"}),e.jsx(V,{selected:r==="no",onClick:()=>l("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{selected:r==="yes-accept-edits",onClick:()=>l("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(V,{selected:r==="yes-default",onClick:()=>l("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(V,{selected:r==="no",onClick:()=>l("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:o,onChange:d=>p(d.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:h,disabled:!r,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function V({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:W("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:W("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:n})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:r})]})}function Ht(s){let t=A(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(n,r,l)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${l.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function Bt(s){const[t,n]=m.useState([]),[r,l]=m.useState(!0),[o,p]=m.useState(null),x=m.useCallback(async()=>{l(!0),p(null);try{const u=await qe(s);n(u)}catch(u){p(u instanceof Error?u.message:"Failed to load shares")}finally{l(!1)}},[s]);m.useEffect(()=>{x()},[x]);const h=m.useCallback(async u=>{p(null);try{const a=await De(s,u);return await x(),a}catch(a){throw p(a instanceof Error?a.message:"Failed to create share"),a}},[s,x]),d=m.useCallback(async u=>{p(null);try{await Ue(s,u),await x()}catch(a){throw p(a instanceof Error?a.message:"Failed to revoke share"),a}},[s,x]);return{shares:t,isLoading:r,error:o,createShare:h,revokeShare:d,refresh:x}}function zt({open:s,onClose:t,sessionId:n,sessionTitle:r}){pe();const{shares:l,isLoading:o,error:p,createShare:x,revokeShare:h}=Bt(n),[d,u]=m.useState("user"),[a,i]=m.useState(""),[g,f]=m.useState(""),[y,b]=m.useState("read"),[k,N]=m.useState(""),[C,E]=m.useState(!1),[T,D]=m.useState(null),[K,O]=m.useState(""),[F,U]=m.useState(!1),[Y,q]=m.useState(!1);m.useEffect(()=>{s&&(u("user"),i(""),f(""),b("read"),N(""),E(!1),D(null),O(""),U(!1),q(!1))},[s]);const $=async()=>{E(!0),O(""),D(null);try{const v={grantedTo:d==="user"?{userId:a.trim()}:{teamId:g.trim()},permission:y};k.trim()&&(v.expiresAt=k.trim());const H=await x(v);D(`${window.location.origin}/code/s/${H.shareToken}`)}catch(v){O(v instanceof Error?v.message:"Failed to create share")}finally{E(!1)}},L=async v=>{try{await h(v)}catch{}},J=async()=>{if(!T)return;q(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),U(!0),setTimeout(()=>U(!1),2e3);return}}catch{}const v=document.createElement("textarea");v.value=T,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select();try{document.execCommand("copy"),U(!0),setTimeout(()=>U(!1),2e3)}catch{q(!0)}document.body.removeChild(v)};return e.jsx(fe,{open:s,onOpenChange:v=>{v||t()},children:e.jsxs(ye,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(be,{children:e.jsxs(ge,{className:"font-display text-lg font-semibold text-text-primary",children:[j("share.title"),r?`: ${r}`:""]})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:j("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>u("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${d==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:j("share.user")}),e.jsx("button",{onClick:()=>u("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${d==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:j("share.team")})]}),d==="user"?e.jsx(at,{onSelect:i,placeholder:j("share.userIdPlaceholder"),actionLabel:j("share.selectUser")}):e.jsx("input",{type:"text",value:g,onChange:v=>f(v.target.value),placeholder:j("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"}),d==="user"&&a&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[j("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:a})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:j("share.permission")}),e.jsxs("select",{value:y,onChange:v=>b(v.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:j("share.permissionRead")}),e.jsx("option",{value:"write",children:j("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:j("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:k,onChange:v=>N(v.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"})]}),(K||p)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:K||p}),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:j("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:J,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:F?j("share.copied"):j("share.copy")})]}),Y&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:j("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:j("share.existingShares")}),o?e.jsx("p",{className:"text-sm text-text-muted",children:j("share.loading")}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:j("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:l.map(v=>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:v.granted_to_user||v.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[v.permission==="write"?j("share.permissionWrite"):j("share.permissionRead"),v.expires_at?` · expires ${v.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>L(v.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:j("share.revoke")})]},v.id))})]})]}),e.jsxs(nt,{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:j("common.close")}),e.jsx("button",{onClick:$,disabled:C||(d==="user"?!a.trim():!g.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:C?j("common.creating"):j("share.createShare")})]})]})})}function Qt(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Vt(s){const t=Qt(s),n=Fe(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new Oe(r)}const z=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],Z="rcs_permission_mode";function Wt(s){const t=z.findIndex(n=>n.value===s);return z[(t+1+z.length)%z.length].value}function Kt({mode:s,onModeChange:t,disabled:n}){const[r,l]=m.useState(!1),o=z.find(p=>p.value===s);return e.jsxs(Je,{open:r,onOpenChange:l,children:[e.jsx(Ge,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"权限模式(Shift+Tab 循环)",children:[e.jsx(Xe,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(o==null?void 0:o.label)??s}),r?e.jsx(Ze,{className:"h-3 w-3"}):e.jsx(et,{className:"h-3 w-3"})]})}),e.jsx(tt,{className:"w-64 p-1",align:"start",children:z.map(p=>e.jsxs("button",{type:"button",onClick:()=>{t(p.value),l(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:s===p.value&&e.jsx(xe,{className:"h-3.5 w-3.5 text-brand"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:p.label}),e.jsx("div",{className:"text-xs text-text-muted",children:p.description})]})]},p.value))})]})}function as({sessionId:s,onSessionLoaded:t}){pe();const[n,r]=m.useState(null),[l,o]=m.useState(null),[p,x]=m.useState(""),[h,d]=m.useState(!1),[u,a]=m.useState(!1),[i,g]=m.useState(!1),[f,y]=m.useState([]),[b,k]=m.useState(!1),[N,C]=m.useState([]),[E,T]=m.useState(null),[D,K]=m.useState(()=>je()),[O,F]=m.useState(()=>localStorage.getItem(Z)||"default"),[U,Y]=m.useState(null),q=m.useRef(null),$=m.useRef(O);$.current=O;const L=m.useRef(null),J=m.useRef(null),v=m.useRef(f);v.current=f;const H=m.useCallback(c=>{Y(c),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>Y(null),5e3)},[]),ee=m.useCallback(c=>{var S;if(c===$.current)return;const w=$.current;$.current=c,F(c);try{localStorage.setItem(Z,c)}catch{}(S=J.current)==null||S.setPermissionMode(c).then(_=>{L.current={requestId:_,previous:w}}).catch(_=>{console.error("[SessionDetail] set permission mode failed:",_),H(`模式切换请求发送失败: ${_ instanceof Error?_.message:String(_)}`),$.current=w,F(w)})},[H]),I=m.useMemo(()=>new Mt(s,y,{onStatusChange:c=>{o(c)},onError:c=>{console.error("[RCSChatAdapter] error:",c)},onPermissionRequest:c=>{C(w=>w.some(S=>S.requestId===c.requestId)?w:[...w,c])},onModelsStateChange:c=>{T(c)},onSubagentUpdate:c=>{K(c)},onControlResponse:c=>{const w=L.current;if(!(!w||w.requestId!==c.requestId)&&(L.current=null,c.subtype==="error")){$.current=w.previous,F(w.previous);try{localStorage.setItem(Z,w.previous)}catch{}H(c.error||"模式切换失败")}},onPermissionModeChange:c=>{if(c!==$.current){$.current=c,F(c);try{localStorage.setItem(Z,c)}catch{}L.current=null}}}),[s,H]);m.useEffect(()=>(J.current=I,()=>{I.disconnect()}),[I]),m.useEffect(()=>{let c=!1;async function w(){x("");try{const S=await Ve(s);if(c)return;r(S),o(S.status),t==null||t(S)}catch(S){if(c)return;x(S instanceof Error?S.message:j("session.loadFailed"));return}try{await I.init()}catch(S){console.warn("Failed to init adapter:",S)}}return w(),()=>{c=!0}},[s,I,t]);const Q=We(l),G=(n==null?void 0:n.access_level)==="read",we=m.useCallback(async c=>{const w=c.text.trim(),S=c.images&&c.images.length>0||c.attachments&&c.attachments.length>0;if(!w&&!S||Q)return;const _=await Le(w,{sessionId:s,availableCommands:[],availableModels:(E==null?void 0:E.availableModels)??[],currentModel:E?{modelId:E.currentModelId,name:E.currentModelId}:null,supportsImages:!0,entries:v.current,setModel:async P=>{await B(s,{type:"control_request",request:{subtype:"set_model",model:P}}),T(te=>te&&{...te,currentModelId:P})},onNewSession:()=>{y([])}}).catch(()=>null);if(_){if(He("[SessionDetail] local command result",_),"clearEntries"in _&&_.clearEntries){y([]);return}if("newSession"in _&&_.newSession){y([]);return}if("userEntry"in _){y(P=>[...P,_.userEntry,_.cmdEntry]);return}}k(!0);try{await I.sendMessage(w,c.images,c.attachments)}catch(P){console.error("Send failed:",P)}},[I,Q,s,E]),ne=m.useCallback(async()=>{try{await I.interrupt()}catch(c){console.error("Interrupt failed:",c)}finally{k(!1)}},[I]),ve=m.useCallback(()=>{ee(Wt($.current))},[ee]);m.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]);const Ne=m.useCallback(async()=>{if(n&&window.confirm(j("dashboard.confirmDelete").replace("{id}",n.title||n.id)))try{await Be(n.id),window.location.href="/code/"}catch(c){alert(c instanceof Error?c.message:j("dashboard.deleteFailed"))}},[n]);m.useEffect(()=>{if(f.length===0)return;const c=f[f.length-1];if((c==null?void 0:c.type)==="assistant_message"||(c==null?void 0:c.type)==="tool_call"){if(c.type==="tool_call"&&c.toolCall.status==="running")return;k(!1)}},[f]);const ke=m.useCallback(async c=>{try{await I.respondPermission(c,!0)}catch(w){console.error("Failed to approve:",w)}C(w=>w.filter(S=>S.requestId!==c))},[I]),Se=m.useCallback(async c=>{try{await I.respondPermission(c,!1)}catch(w){console.error("Failed to reject:",w)}C(w=>w.filter(S=>S.requestId!==c))},[I]),_e=m.useCallback(async(c,w,S)=>{try{await B(s,{type:"permission_response",approved:!0,request_id:c,updated_input:{questions:S,answers:w}})}catch(_){console.error("Failed to submit answers:",_)}C(_=>_.filter(P=>P.requestId!==c))},[s]),Ce=m.useCallback(async(c,w,S)=>{try{w==="no"?await B(s,{type:"permission_response",approved:!1,request_id:c,...S?{message:S}:{}}):await B(s,{type:"permission_response",approved:!0,request_id:c,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[w]||"default",destination:"session"}]})}catch(_){console.error("Failed to submit plan response:",_)}C(_=>_.filter(P=>P.requestId!==c))},[s]);return p?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:p}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:j("session.backToDashboard")})]})}):n?n.source==="acp"&&n.environment_id?e.jsx(Jt,{sessionId:s,agentId:n.environment_id}):e.jsx(he,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:n.title||n.id}),e.jsx("div",{className:"border-b bg-surface-1 px-4 py-3",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:e.jsx("span",{className:"truncate",children:n.title||n.id})}),n.visibility&&e.jsx(rt,{visibility:n.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var S;const c=n.source==="acp"?"acp":(S=n.environment)==null?void 0:S.worker_type,w=st(c);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${w.colorClass}`,children:w.fullLabel})})(),l&&e.jsx(de,{status:l}),e.jsx("span",{className:"text-xs text-text-muted",children:ue(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!G&&(n==null?void 0:n.access_level)!=="write"&&e.jsx("button",{onClick:()=>g(!0),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:j("session.share"),children:e.jsx(vt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>a(!u),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:j("session.info"),children:e.jsx(ft,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>d(!h),className:"flex items-center gap-1 rounded-md px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",children:[j("session.tasks"),N.length>0&&e.jsx("span",{className:"ml-1 rounded-full bg-status-warning px-1.5 py-0.5 text-[10px] font-medium text-white",children:N.length})]})]})]}),u&&e.jsxs("div",{className:"mt-2 rounded-md bg-surface-2 px-3 py-2 text-xs text-text-muted space-y-1 font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:j("session.metaSession")})," ",n.id]}),n.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:j("session.metaEnvironment")})," ",n.environment_id]})]})]})}),e.jsx(ze,{entries:f,isLoading:b,emptyTitle:j("session.emptyTitle"),emptyDescription:j("session.emptyDescription")}),e.jsx(Dt,{state:D}),N.length>0&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl space-y-3",children:N.map(c=>e.jsx(Yt,{request:c,onApprove:()=>ke(c.requestId),onReject:()=>Se(c.requestId),onSubmitAnswers:_e,onSubmitPlan:Ce},c.requestId))})}),U&&e.jsx("div",{className:"mx-auto max-w-3xl w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:U})}),e.jsxs("div",{className:"max-w-3xl mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:[e.jsx(Kt,{mode:O,onModeChange:ee,disabled:Q||G}),e.jsx("span",{className:"text-[11px] text-text-muted font-display",children:"Shift+Tab 切换模式"})]}),e.jsx(Qe,{onSubmit:we,isLoading:b,onInterrupt:ne,onCycleMode:ve,disabled:Q||G,placeholder:Q?j("session.closed"):G?j("session.readOnly"):j("session.inputPlaceholder"),supportsAttachments:!0}),h&&n&&e.jsx($t,{onClose:()=>d(!1),session:n,liveStatus:l,pendingPermissions:N,onInterrupt:ne,onDelete:Ne}),e.jsx(zt,{open:i,onClose:()=>g(!1),sessionId:n.id,sessionTitle:n.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:j("session.loading")})})}function Yt({request:s,onApprove:t,onReject:n,onSubmitAnswers:r,onSubmitPlan:l}){const o=s.toolName,p=s.toolInput,x=s.description||"";if(o==="AskUserQuestion"){const h=p.questions||[];return e.jsx(Ot,{requestId:s.requestId,questions:h,description:x,onSubmit:d=>r(s.requestId,d,h),onSkip:n})}if(o==="ExitPlanMode"){const h=p.plan||"";return e.jsx(Lt,{requestId:s.requestId,planContent:h,description:x,onSubmit:(d,u)=>l(s.requestId,d,u)})}return e.jsx(Ut,{requestId:s.requestId,toolName:o,toolInput:p,description:x,onApprove:t,onReject:n})}function Jt({sessionId:s,agentId:t}){const[n,r]=m.useState(null),[l,o]=m.useState("disconnected"),[p,x]=m.useState(null),h=m.useRef(null);return m.useEffect(()=>{const d=Vt(t);return d.setConnectionStateHandler((u,a)=>{o(u),x(a||null)}),h.current=d,r(d),d.connect().catch(u=>{u instanceof Ke||(x(u.message),o("error"))}),()=>{d.disconnect(),h.current=null,r(null),o("disconnected")}},[t]),e.jsx(he,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[p&&l==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:p}),l==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-text-muted text-sm",children:j("session.connectingAgent")})]})}),l==="error"&&!n&&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:j("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:p})]})}),n&&l==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ye,{client:n,agentId:t})})]})})}export{as as SessionDetail};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{j as t}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{j as t}from"./vendor-DE_-CLIE.js";import{a0 as l,R as c,h as d,g,X as u,$ as o,T as x,s as f,O as m,U as p}from"./main-BAk_zq3S.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const b=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],
|
|
6
|
+
*/const b=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],h=l("globe",b);/**
|
|
7
7
|
* @license lucide-react v0.555.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const y=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],j=l("lock",y);function z({...a}){return t.jsx(c,{"data-slot":"dialog",...a})}function v({...a}){return t.jsx(f,{"data-slot":"dialog-portal",...a})}function k({className:a,...e}){return t.jsx(m,{"data-slot":"dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...e})}function C({className:a,children:e,showCloseButton:s=!0,...n}){return t.jsxs(v,{"data-slot":"dialog-portal",children:[t.jsx(k,{}),t.jsxs(d,{"data-slot":"dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...n,children:[e,s&&t.jsxs(g,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(u,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function D({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...e})}function _({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...e})}function I({className:a,...e}){return t.jsx(x,{"data-slot":"dialog-title",className:o("text-lg leading-none font-semibold",a),...e})}function P({visibility:a,className:e}){const s={private:{label:"Private",Icon:j,colorClass:"text-text-muted border-border/60"},team:{label:"Team",Icon:p,colorClass:"text-accent border-accent/40"},public:{label:"Public",Icon:h,colorClass:"text-accent border-accent/40"}},{label:n,Icon:i,colorClass:r}=s[a];return t.jsxs("span",{className:o("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",r,e),children:[t.jsx(i,{className:"h-3 w-3"}),n]})}export{z as D,P as S,C as a,_ as b,D as c,I as d};
|
|
@@ -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{ad as v,a9 as t}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function q({onSuccess:p,onAlreadyDone:b}){const{setup:f}=v(),[n,h]=r.useState(""),[l,y]=r.useState(""),[a,g]=r.useState(""),[d,w]=r.useState(""),[i,o]=r.useState(""),[c,m]=r.useState(!1),j=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==d){o(t("auth.setup.passwordMismatch"));return}m(!0);try{await f(n,l,a),p()}catch(x){const u=x instanceof Error?x.message:"Setup failed";if(u.includes("already")||u.includes("409")){b();return}o(u)}finally{m(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.setup.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.setup.description")})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.apiKey")}),e.jsx("input",{type:"password",value:n,onChange:s=>h(s.target.value),required:!0,autoComplete:"off",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.username")}),e.jsx("input",{type:"text",value:l,onChange:s=>y(s.target.value),required:!0,autoComplete:"username",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.confirmPassword")}),e.jsx("input",{type:"password",value:d,onChange:s=>w(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),i&&e.jsx("p",{className:"text-sm text-status-error",children:i}),e.jsx("button",{type:"submit",disabled:c,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:c?t("common.loading"):t("auth.setup.submit")})]})]})})}export{q as Setup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{N as m,b as h}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){const[t,r]=d.useState("loading"),[i,a]=d.useState(""),l=(typeof window<"u"?window.location.pathname:"").match(/\/code\/s\/([^/?]+)/),o=l?l[1]:null;return d.useEffect(()=>{if(!o){r("invalid"),a("Share link is invalid — no token found.");return}if(!o.startsWith("shr_")){r("invalid"),a("Invalid share token format.");return}let n=!1;async function c(){try{const s=await m(o);if(n)return;window.location.href=`/code/${s.id}`}catch(s){if(n)return;s instanceof h?s.status===401&&s.message.toLowerCase().includes("expired")?(r("expired"),a("This share has expired.")):s.status===404?s.message.toLowerCase().includes("session")?(r("not_found"),a("Session not found.")):(r("invalid"),a("Share not found or has been revoked.")):s.status===403?(r("invalid"),a("You do not have permission to access this share.")):(r("error"),a(s.message||"Failed to resolve share.")):(r("error"),a(s instanceof Error?s.message:"Failed to resolve share."))}}return c(),()=>{n=!0}},[o]),d.useEffect(()=>{if(t!=="loading"&&t!=="error"){const n=setTimeout(()=>{window.location.href="/code"},3e3);return()=>clearTimeout(n)}},[t]),t==="loading"?e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{children:"Resolving share link..."})]})}):e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-primary",children:e.jsxs("div",{className:"text-center max-w-md px-4",children:[t==="expired"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Share Expired"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share has expired."})]}),t==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Invalid Share"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share link is invalid or has been revoked."})]}),t==="not_found"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Not Found"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"The session could not be found."})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Error"}),e.jsx("p",{className:"text-status-error mb-4",children:i})]}),e.jsx("a",{href:"/code",className:"text-brand hover:underline",children:"← Back to Dashboard"})]})})}export{j as ShareLanding};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{ae as f,af as y,a9 as r}from"./main-BAk_zq3S.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function S(){f();const{createTeam:u}=y(),[o,p]=a.useState(""),[s,c]=a.useState(""),[i,b]=a.useState(""),[m,l]=a.useState(null),[d,x]=a.useState(!1),h=t=>{p(t),s||c(t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-"))},g=async t=>{t.preventDefault(),l(null),x(!0);try{const n=await u({name:o,slug:s,description:i||void 0});window.location.href=`/teams/${n.slug}`}catch(n){l(n instanceof Error?n.message:"Failed to create team")}finally{x(!1)}};return e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsx("h1",{className:"mb-10 font-display text-2xl font-semibold tracking-tight text-text-primary",children:r("team.create.title")}),e.jsxs("form",{onSubmit:g,className:"max-w-md space-y-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.name")}),e.jsx("input",{id:"name",type:"text",required:!0,value:o,onChange:t=>h(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"Engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.nameHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"slug",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.slug")}),e.jsx("input",{id:"slug",type:"text",required:!0,value:s,onChange:t=>c(t.target.value),pattern:"^[a-z0-9-]{3,32}$",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.slugHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.description")}),e.jsx("textarea",{id:"description",value:i,onChange:t=>b(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",rows:3})]}),m&&e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded-md border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2 transition-colors",children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:d||!o||!s,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:d?r("common.creating"):r("team.create.submit")})]})]})]})})}export{S as TeamCreate};
|