@saluzi/saluzi-edu 0.2.53 → 0.2.55
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 +44 -44
- package/dist/guide/guide-data.json +18 -0
- package/dist/rcs-web/assets/{AdminPanel-BU_m2tTe.js → AdminPanel-Gc3BPu1_.js} +1 -1
- package/dist/rcs-web/assets/Claim-EI1vEA1D.js +1 -0
- package/{packages/remote-control-server/web/dist/assets/Dashboard-B4nxTeft.js → dist/rcs-web/assets/Dashboard-bYYO5HcG.js} +2 -2
- package/{packages/remote-control-server/web/dist/assets/Join-KIjSy6RI.js → dist/rcs-web/assets/Join-DBS1b78K.js} +1 -1
- package/dist/rcs-web/assets/{Login-BS8dN_pA.js → Login-wdKYrifx.js} +1 -1
- package/dist/rcs-web/assets/{Register-DdWhmPwF.js → Register-DRD2kteD.js} +1 -1
- package/dist/rcs-web/assets/SessionDetail-JgtD489A.js +55 -0
- package/dist/rcs-web/assets/{SessionVisibilityBadge-Bkv-o3zy.js → SessionVisibilityBadge-DuslCmw6.js} +3 -3
- package/dist/rcs-web/assets/{Setup-Dh6nT2Cd.js → Setup-DyPAdgXS.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-AQyowQYz.js → ShareLanding-D9JzXvXa.js} +1 -1
- package/dist/rcs-web/assets/{TeamCreate-DStppJIa.js → TeamCreate-Cad1VxMm.js} +1 -1
- package/dist/rcs-web/assets/{TeamDetail-DudkRM26.js → TeamDetail-Cm0jxf9Z.js} +2 -2
- package/dist/rcs-web/assets/{TeamList-B2YF0znl.js → TeamList-BETVmpO1.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-BpHpHzUj.js → TeamSettings-Bb9IKTLi.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-DHCklRIF.js → UserSearchInput-7Q9EFRPQ.js} +1 -1
- package/dist/rcs-web/assets/{UserSettings-BWd6v4rQ.js → UserSettings-B9kVG_IR.js} +1 -1
- package/dist/rcs-web/assets/{arc-BgGV491M.js → arc-DiEgUZn-.js} +1 -1
- package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-DLhWu9K4.js → architectureDiagram-3BPJPVTR-BFKqtyBC.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DejuGJUT.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-CVuiguSe.js} +1 -1
- package/dist/rcs-web/assets/{c4Diagram-AAUBKEIU-BJP-IVGK.js → c4Diagram-AAUBKEIU-CPy7P1Av.js} +1 -1
- package/dist/rcs-web/assets/channel-D5Hz1fY8.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-yqGAlZsO.js → chunk-2J33WTMH-BUqofFnC.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-C6xp5yYX.js → chunk-4BX2VUAB-C6aoBjPY.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-BnoiueV2.js → chunk-55IACEB6-CTXtct1S.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-BAykCWKk.js → dist/rcs-web/assets/chunk-727SXJPM-CcAQhRBy.js} +1 -1
- package/dist/rcs-web/assets/{chunk-AQP2D5EJ-DeElJ5j7.js → chunk-AQP2D5EJ-CLbfo9u6.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-jP0H_--k.js → chunk-FMBD7UC4-A5sjn77P.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-BGIpLa5_.js → chunk-ND2GUHAM-Whwn6TjZ.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-Blt1Cg58.js → chunk-QZHKN3VN-CRl6OiWH.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-C79YEyw1.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-C79YEyw1.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-BKTU2vHT.js → code-block-IT6T5CEO-DNG0H7s_.js} +1 -1
- package/dist/rcs-web/assets/{copy-B2vFSPoy.js → copy-ClSInH6Y.js} +1 -1
- package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-ZuTAtm7Q.js → cose-bilkent-S5V4N54A-Chx2WwaP.js} +1 -1
- package/dist/rcs-web/assets/{dagre-BM42HDAG-D56sKgGx.js → dagre-BM42HDAG-B_pHh3BU.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-B9z0e8pz.js → diagram-2AECGRRQ-BHaFKYHb.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-CHYkH5kc.js → diagram-5GNKFQAL-C4jq41jo.js} +1 -1
- package/dist/rcs-web/assets/{diagram-KO2AKTUF-B0fefELP.js → diagram-KO2AKTUF-vLZAAlSj.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-v_CNumDx.js → diagram-LMA3HP47-CDsOOsrx.js} +1 -1
- package/dist/rcs-web/assets/{diagram-OG6HWLK6-BiP-PzY3.js → diagram-OG6HWLK6-CDNVMpGm.js} +1 -1
- package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-CA-q3pz9.js → erDiagram-TEJ5UH35-Uwz1AUAa.js} +1 -1
- package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-D0wxPgJk.js → flowDiagram-I6XJVG4X-PZjyAvn1.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-D8tEhnvv.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Bw-HcaeD.js} +1 -1
- package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-Bx4dq1wL.js → gitGraphDiagram-PVQCEYII-wQRnZZvR.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-D9-sPGtp.js → infoDiagram-5YYISTIA-ZaqhXWsh.js} +1 -1
- package/dist/rcs-web/assets/{ishikawaDiagram-YF4QCWOH-DHC2gfHg.js → ishikawaDiagram-YF4QCWOH-BAwMsw7Q.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-CeWu1YkX.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-BN5PEEeN.js} +1 -1
- package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-CtbBamBO.js → kanban-definition-UN3LZRKU-a3XUx_Cb.js} +1 -1
- package/dist/rcs-web/assets/{linear-WFGCU65A.js → linear-aDXDuqZd.js} +1 -1
- package/dist/rcs-web/assets/{main-C6czI38s.js → main-Bfbs-lwB.js} +54 -54
- package/dist/rcs-web/assets/{mermaid-VLURNSYL-CJEG4DJA.js → mermaid-VLURNSYL-CPzd5Xw0.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-aZvgg4gM.js → mermaid.core-DAedMhfd.js} +5 -5
- package/{packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-CYrLhvPq.js → dist/rcs-web/assets/mindmap-definition-RKZ34NQL-DJN3pb0x.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-Cc9GCu8V.js → pieDiagram-4H26LBE5-Dt5PkY0b.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-3VXRYoRB.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-BlB9_lcZ.js} +1 -1
- package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-DznaQwwS.js → requirementDiagram-4Y6WPE33-C4HVySo4.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-B11xI8oj.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-D2iFqr51.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CmUYXS5A.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CPnyhZSr.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-CViWtNni.js → stateDiagram-AJRCARHV-DjOLQSZq.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-DPQ0Q1PA.js → stateDiagram-v2-BHNVJYJU-Drrtcjqv.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-CL0Ql3sZ.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-DCP3r7hv.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-DEYqp1U8.js → vennDiagram-CIIHVFJN-Hf1HIER0.js} +1 -1
- package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-B9Pnv5gW.js → wardleyDiagram-YWT4CUSO-CWdNIYrR.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-DSPoLW7d.js → dist/rcs-web/assets/xychartDiagram-2RQKCTM6-BhEhhCTK.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__/event-bus.test.ts +91 -0
- package/packages/remote-control-server/src/__tests__/routes.test.ts +57 -0
- package/packages/remote-control-server/src/routes/v2/worker-events.ts +10 -0
- 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-Gc3BPu1_.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/Claim-EI1vEA1D.js +1 -0
- package/{dist/rcs-web/assets/Dashboard-B4nxTeft.js → packages/remote-control-server/web/dist/assets/Dashboard-bYYO5HcG.js} +2 -2
- package/{dist/rcs-web/assets/Join-KIjSy6RI.js → packages/remote-control-server/web/dist/assets/Join-DBS1b78K.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Login-BS8dN_pA.js → Login-wdKYrifx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Register-DdWhmPwF.js → Register-DRD2kteD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-JgtD489A.js +55 -0
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-Bkv-o3zy.js → SessionVisibilityBadge-DuslCmw6.js} +3 -3
- package/packages/remote-control-server/web/dist/assets/{Setup-Dh6nT2Cd.js → Setup-DyPAdgXS.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-AQyowQYz.js → ShareLanding-D9JzXvXa.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamCreate-DStppJIa.js → TeamCreate-Cad1VxMm.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamDetail-DudkRM26.js → TeamDetail-Cm0jxf9Z.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{TeamList-B2YF0znl.js → TeamList-BETVmpO1.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-BpHpHzUj.js → TeamSettings-Bb9IKTLi.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-DHCklRIF.js → UserSearchInput-7Q9EFRPQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSettings-BWd6v4rQ.js → UserSettings-B9kVG_IR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-BgGV491M.js → arc-DiEgUZn-.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-DLhWu9K4.js → architectureDiagram-3BPJPVTR-BFKqtyBC.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DejuGJUT.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-CVuiguSe.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{c4Diagram-AAUBKEIU-BJP-IVGK.js → c4Diagram-AAUBKEIU-CPy7P1Av.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-D5Hz1fY8.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-yqGAlZsO.js → chunk-2J33WTMH-BUqofFnC.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-C6xp5yYX.js → chunk-4BX2VUAB-C6aoBjPY.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-BnoiueV2.js → chunk-55IACEB6-CTXtct1S.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-BAykCWKk.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-CcAQhRBy.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-DeElJ5j7.js → chunk-AQP2D5EJ-CLbfo9u6.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-jP0H_--k.js → chunk-FMBD7UC4-A5sjn77P.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-BGIpLa5_.js → chunk-ND2GUHAM-Whwn6TjZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-Blt1Cg58.js → chunk-QZHKN3VN-CRl6OiWH.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-C79YEyw1.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-C79YEyw1.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-BKTU2vHT.js → code-block-IT6T5CEO-DNG0H7s_.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-B2vFSPoy.js → copy-ClSInH6Y.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-ZuTAtm7Q.js → cose-bilkent-S5V4N54A-Chx2WwaP.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-D56sKgGx.js → dagre-BM42HDAG-B_pHh3BU.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-B9z0e8pz.js → diagram-2AECGRRQ-BHaFKYHb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-CHYkH5kc.js → diagram-5GNKFQAL-C4jq41jo.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-B0fefELP.js → diagram-KO2AKTUF-vLZAAlSj.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-v_CNumDx.js → diagram-LMA3HP47-CDsOOsrx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-BiP-PzY3.js → diagram-OG6HWLK6-CDNVMpGm.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-CA-q3pz9.js → erDiagram-TEJ5UH35-Uwz1AUAa.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-D0wxPgJk.js → flowDiagram-I6XJVG4X-PZjyAvn1.js} +1 -1
- package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-D8tEhnvv.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Bw-HcaeD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-Bx4dq1wL.js → gitGraphDiagram-PVQCEYII-wQRnZZvR.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-D9-sPGtp.js → infoDiagram-5YYISTIA-ZaqhXWsh.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ishikawaDiagram-YF4QCWOH-DHC2gfHg.js → ishikawaDiagram-YF4QCWOH-BAwMsw7Q.js} +1 -1
- package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-CeWu1YkX.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-BN5PEEeN.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-CtbBamBO.js → kanban-definition-UN3LZRKU-a3XUx_Cb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-WFGCU65A.js → linear-aDXDuqZd.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-C6czI38s.js → main-Bfbs-lwB.js} +54 -54
- package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-CJEG4DJA.js → mermaid-VLURNSYL-CPzd5Xw0.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-aZvgg4gM.js → mermaid.core-DAedMhfd.js} +5 -5
- package/{dist/rcs-web/assets/mindmap-definition-RKZ34NQL-CYrLhvPq.js → packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-DJN3pb0x.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-Cc9GCu8V.js → pieDiagram-4H26LBE5-Dt5PkY0b.js} +1 -1
- package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-3VXRYoRB.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-BlB9_lcZ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-DznaQwwS.js → requirementDiagram-4Y6WPE33-C4HVySo4.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-B11xI8oj.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-D2iFqr51.js} +1 -1
- package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CmUYXS5A.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CPnyhZSr.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-CViWtNni.js → stateDiagram-AJRCARHV-DjOLQSZq.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-DPQ0Q1PA.js → stateDiagram-v2-BHNVJYJU-Drrtcjqv.js} +1 -1
- package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-CL0Ql3sZ.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-DCP3r7hv.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-DEYqp1U8.js → vennDiagram-CIIHVFJN-Hf1HIER0.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-B9Pnv5gW.js → wardleyDiagram-YWT4CUSO-CWdNIYrR.js} +1 -1
- package/{dist/rcs-web/assets/xychartDiagram-2RQKCTM6-DSPoLW7d.js → packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-BhEhhCTK.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
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
"title": "查看消耗",
|
|
28
28
|
"path": "docs/guide/cost-usage"
|
|
29
29
|
},
|
|
30
|
+
{
|
|
31
|
+
"title": "搭建你的第一个 MCP 服务器",
|
|
32
|
+
"path": "docs/guide/build-mcp-server"
|
|
33
|
+
},
|
|
30
34
|
{
|
|
31
35
|
"title": "主目录与配置",
|
|
32
36
|
"path": "docs/guide/saluzi-home"
|
|
@@ -3092,6 +3096,20 @@
|
|
|
3092
3096
|
},
|
|
3093
3097
|
"content": "\n## 主目录位置\n\nSaluzi 把所有用户数据集中放在主目录下的 `~/.saluzi-edu` 文件夹。路径由 `getSaluziConfigHomeDir()` 统一决定:\n\n- **Linux / macOS**:`~/.saluzi-edu`\n- **Windows**:`%USERPROFILE%\\.saluzi-edu`(即 `C:\\Users\\<你>\\.saluzi-edu`)\n\n可通过环境变量 `SALUZI_CONFIG_DIR` 覆盖到任意位置(支持 `~` 展开),适合多套配置切换或放在加密分区。\n\n> 注意:企业受管配置 `managed-settings.json` **不在此目录**,而是放在系统级路径——macOS 为 `/Library/Application Support/SaluziCode`,Windows 为 `C:\\Program Files\\SaluziCode`,Linux 为 `/etc/saluzi-edu`。普通用户一般不需要动它。\n\n## 子目录与文件清单\n\n启动后 `~/.saluzi-edu` 下会按需出现以下条目。各子目录在首次写入时自动 `mkdir -p`,不需要手动创建。\n\n### 配置与凭证\n\n| 路径 | 作用 | 删除影响 |\n|------|------|---------|\n| `settings.json` | 用户全局设置(env、权限、模型、hooks 等)。详见下文 | 重置为默认配置 |\n| `settings.local.json` | 项目级本地设置(gitignored)。仅在 `<cwd>/.saluzi-edu/` 下生效 | 丢失本地覆盖 |\n| `.credentials.json` | OAuth 登录凭证 | 需重新 `/login` |\n| `.config.json` | 内部运行配置,不要手编 | 自动重建 |\n| `keybindings.json` | 自定义快捷键 | 恢复默认按键 |\n| `SALUZI.md` | 用户级记忆(跨项目的个人偏好) | 丢失用户记忆 |\n| `rules/` | 用户级规则文件 | 丢失规则 |\n\n### 项目数据(按 cwd 隔离)\n\n| 路径 | 作用 |\n|------|------|\n| `projects/<sanitized-cwd>/` | 每个工作目录一个子目录,存放该项目专属的会话与记忆 |\n| `projects/<cwd>/memory/` | 自动记忆:`MEMORY.md` + `logs/YYYY/MM/` 日志 |\n| `projects/<cwd>/*.jsonl` | 该项目的会话转录 |\n\n项目子目录名是 cwd 路径的 sanitized 形式(特殊字符替换),所以同时多个项目互不干扰。\n\n### 扩展与自定义\n\n| 路径 | 作用 |\n|------|------|\n| `skills/` | 用户技能(由 `/skill-learning` 自动生成或手写) |\n| `commands/` | 用户自定义 slash 命令 |\n| `agents/` | 用户自定义 agent(Markdown 文件) |\n| `teams/` | 团队配置 |\n| `templates/` | 任务模板 |\n| `plugins/` | 插件安装目录(由 `/plugin` 管理) |\n| `plugin-options/` | 插件运行时选项 |\n\n### 运行时状态\n\n| 路径 | 作用 |\n|------|------|\n| `sessions/` | 并发会话状态 |\n| `jobs/` | 后台任务状态 |\n| `tasks/` | 任务数据 |\n| `plans/` | plan 文件 |\n| `daemon/` | daemon 进程状态(`<name>.json`) |\n| `shell-snapshots/` | Shell 环境快照(`!` 命令用) |\n| `history.jsonl` | 全局命令历史 |\n| `stats-cache.json` | 使用统计缓存 |\n| `usage-data/` | `/insights` 用量数据 |\n| `pr-subscriptions.json` | PR 订阅列表 |\n| `file-history/` | 文件修改历史 |\n| `session-env/` | 会话环境变量 |\n| `uploads/<sessionId>/` | 入站附件 |\n\n### 缓存与日志\n\n| 路径 | 作用 |\n|------|------|\n| `cache/model-capabilities.json` | 模型能力缓存 |\n| `backups/` | 配置文件备份 |\n| `debug/<sessionId>.txt` | 调试日志 |\n| `traces/` | Perfetto 性能追踪 |\n| `startup-perf/` | 启动性能分析 |\n| `.update.lock` | 自动更新锁文件 |\n\n### IDE 与集成\n\n| 路径 | 作用 |\n|------|------|\n| `ide/` | IDE 集成数据 |\n| `local/` | 本地安装文件 |\n| `magic-docs/prompt.md` | MagicDocs prompt |\n| `skill-learning/` | 技能学习上下文 |\n| `autonomy/` | 自治运行记录(`runs.json`、`flows.json`) |\n\n所有缓存与运行时状态目录都可安全删除——Saluzi 会按需重建。配置类(`settings.json`、`SALUZI.md`、`keybindings.json`)删除会丢失个人定制,需要重新配置。\n\n## settings.json 配置\n\n`~/.saluzi-edu/settings.json` 是用户全局配置文件,JSON 格式,所有字段均可选。下面按主题分组说明。完整 JSON Schema 发布在 `https://json.schemastore.org/saluzi-edu-settings.json`,编辑器开启 JSON Schema 支持后可自动补全。\n\n### 来源与优先级\n\nSaluzi 合并 5 个来源的配置,后者覆盖前者:\n\n| 优先级 | 来源 | 路径 | 可编辑 |\n|--------|------|------|--------|\n| 1(低) | userSettings | `~/.saluzi-edu/settings.json` | 是 |\n| 2 | projectSettings | `<cwd>/.saluzi-edu/settings.json` | 是(共享,入 git) |\n| 3 | localSettings | `<cwd>/.saluzi-edu/settings.local.json` | 是(gitignored) |\n| 4 | flagSettings | `--settings <path>` CLI 参数 | 否 |\n| 5(高) | policySettings | 系统级 managed-settings.json | 否 |\n\n合并规则:标量高优先级直接覆盖;对象深度合并;数组拼接去重。policySettings 内部还按 remote > MDM (HKLM/plist) > managed-settings.json > HKCU 排序。\n\n### 1. 模型与推理\n\n| 字段 | 类型 | 默认 | 说明 |\n|------|------|------|------|\n| `modelType` | enum | `anthropic` | API 提供商:`anthropic`/`openai`/`gemini`/`grok` |\n| `model` | string | - | 覆盖默认模型 ID |\n| `availableModels` | string[] | - | 企业模型白名单(通常 managed) |\n| `modelOverrides` | Record<string,string> | - | 模型 ID 映射(如 Bedrock ARN) |\n| `effortLevel` | enum | `medium` | `low`/`medium`/`high`/`xhigh`/`max` |\n| `alwaysThinkingEnabled` | boolean | true | 是否启用 thinking |\n| `fastMode` | boolean | false | 启用 fast 模式 |\n| `fastModePerSessionOptIn` | boolean | false | fast 不跨会话持久化 |\n| `advisorModel` | string | - | 服务端 advisor 工具模型 |\n| `mom` | object | - | Mixture of Model 配置,见 [MOM 章节](./mom-mixed-models) |\n\n### 2. 环境变量\n\n`env` 是 `Record<string, string>`,写入后会注入到会话进程的环境变量。常用于配置 API Key 和端点:\n\n```json\n{\n \"env\": {\n \"ANTHROPIC_API_KEY\": \"sk-ant-...\",\n \"ANTHROPIC_BASE_URL\": \"https://api.anthropic.com\",\n \"SALUZI_EFFORT_LEVEL\": \"high\"\n }\n}\n```\n\n常用键:\n\n| 键 | 作用 |\n|----|------|\n| `ANTHROPIC_API_KEY` | Anthropic API Key(设置后免 `/login`) |\n| `ANTHROPIC_BASE_URL` | Anthropic 端点(自建反代用) |\n| `OPENAI_API_KEY` / `OPENAI_BASE_URL` / `OPENAI_MODEL` | OpenAI 兼容 |\n| `GEMINI_API_KEY` / `GEMINI_BASE_URL` | Gemini |\n| `GROK_API_KEY` / `GROK_BASE_URL` / `GROK_MODEL` | Grok/xAI |\n| `SALUZI_EFFORT_LEVEL` | 推理深度(覆盖 effortLevel) |\n| `SALUZI_MAX_CONTEXT_TOKENS` | 最大上下文 token |\n| `SALUZI_DISABLE_1M_CONTEXT` | 禁用 1M 上下文 |\n| `SALUZI_CLIENT_CERT` / `SALUZI_CLIENT_KEY` | mTLS 证书 |\n\n### 3. 权限\n\n`permissions` 控制工具调用的授权策略:\n\n```json\n{\n \"permissions\": {\n \"defaultMode\": \"default\",\n \"allow\": [\"Bash(npm test:*)\", \"Read(./src/**)\"],\n \"deny\": [\"Bash(rm -rf:*)\"],\n \"ask\": [\"Write(**)\"],\n \"additionalDirectories\": [\"../other-project\"]\n }\n}\n```\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `defaultMode` | enum | `default`/`acceptEdits`/`bypassPermissions`/`dontAsk`/`plan`/`auto` |\n| `allow` | string[] | 自动放行的工具规则 |\n| `deny` | string[] | 直接拒绝的规则 |\n| `ask` | string[] | 总是弹出确认的规则 |\n| `additionalDirectories` | string[] | 额外允许访问的目录 |\n| `disableBypassPermissionsMode` | `\"disable\"` | 禁用 bypass 模式 |\n\n规则语法如 `Bash(npm test:*)`、`Read(./src/**)`,可用 `*` 通配。\n\n### 4. Hooks\n\n`hooks` 在工具执行前后触发自定义命令。事件类型有 25+ 种,常用的:\n\n| 事件 | 触发时机 |\n|------|---------|\n| `PreToolUse` | 工具调用前 |\n| `PostToolUse` | 工具调用后 |\n| `UserPromptSubmit` | 用户提交输入时 |\n| `SessionStart` / `SessionEnd` | 会话开始/结束 |\n| `Stop` / `StopFailure` | 主循环停止 |\n| `Notification` | 通知发送时 |\n| `PreCompact` / `PostCompact` | 上下文压缩前后 |\n| `PermissionRequest` / `PermissionDenied` | 权限请求/拒绝时 |\n\n每个 hook 是 `{ matcher?: string, hooks: HookCommand[] }`,HookCommand 有四种类型:\n\n```json\n{\n \"hooks\": {\n \"PreToolUse\": [\n {\n \"matcher\": \"Bash\",\n \"hooks\": [\n { \"type\": \"command\", \"command\": \"echo 'running bash'\", \"shell\": \"bash\" },\n { \"type\": \"prompt\", \"prompt\": \"检查这个命令是否安全\" },\n { \"type\": \"http\", \"url\": \"https://audit.example.com/hook\", \"headers\": {} },\n { \"type\": \"agent\", \"prompt\": \"评估风险\", \"model\": \"pro\" }\n ]\n }\n ]\n }\n}\n```\n\n| 字段 | 适用类型 | 说明 |\n|------|---------|------|\n| `command` / `shell` / `timeout` | command | 执行 shell 命令 |\n| `prompt` / `model` | prompt / agent | 让模型评估 |\n| `url` / `headers` / `allowedEnvVars` | http | HTTP 回调 |\n| `statusMessage` / `once` / `async` / `if` | 全部 | 通用控制 |\n\n`disableAllHooks: true` 可一键禁用所有 hooks 和 statusLine。\n\n### 5. 沙箱\n\n`sandbox` 控制工具执行的隔离边界:\n\n```json\n{\n \"sandbox\": {\n \"enabled\": true,\n \"failIfUnavailable\": false,\n \"autoAllowBashIfSandboxed\": true,\n \"network\": {\n \"allowedDomains\": [\"api.anthropic.com\", \"registry.npmjs.org\"]\n },\n \"filesystem\": {\n \"allowWrite\": [\"./src\", \"./tests\"],\n \"denyWrite\": [\".env\", \".git\"]\n }\n }\n}\n```\n\n| 字段 | 说明 |\n|------|------|\n| `enabled` | 启用沙箱 |\n| `failIfUnavailable` | 沙箱不可用时直接失败(通常 managed) |\n| `autoAllowBashIfSandboxed` | 沙箱内自动放行 Bash |\n| `allowUnsandboxedCommands` | 允许未沙箱化的命令 |\n| `network.allowedDomains` | 允许访问的域名 |\n| `network.allowManagedDomainsOnly` | 仅用 managed 域名白名单 |\n| `filesystem.allowWrite` / `denyWrite` | 读写路径规则 |\n| `excludedCommands` | 排除沙箱的命令 |\n\n### 6. UI 与输出\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `outputStyle` | string | 响应输出样式 |\n| `language` | string | 首选语言(如 `chinese`、`japanese`) |\n| `theme` | string | 主题名 |\n| `prefersReducedMotion` | boolean | 减少动画 |\n| `syntaxHighlightingDisabled` | boolean | 禁用 diff 语法高亮 |\n| `terminalTitleFromRename` | boolean | `/rename` 同步终端标题 |\n| `spinnerTipsEnabled` | boolean | spinner 显示提示 |\n| `spinnerVerbs` | object | 自定义 spinner 动词 |\n| `spinnerTipsOverride` | object | 覆盖 spinner tips |\n| `statusLine` | object | 自定义状态行(`{ type: \"command\", command, padding? }`) |\n\n### 7. MCP 服务器\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `enableAllProjectMcpServers` | boolean | 自动批准项目所有 MCP 服务器 |\n| `enabledMcpjsonServers` | string[] | 已批准的 .mcp.json 服务器 |\n| `disabledMcpjsonServers` | string[] | 已拒绝的 .mcp.json 服务器 |\n| `allowedMcpServers` | array | 企业 MCP 白名单 |\n| `deniedMcpServers` | array | 企业 MCP 黑名单(优先于白名单) |\n\n### 8. 插件\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `enabledPlugins` | Record<string, string[]\\|boolean> | 已启用插件(plugin-id@marketplace-id) |\n| `extraKnownMarketplaces` | Record<string, object> | 额外插件市场源 |\n| `pluginConfigs` | Record<string, {mcpServers?, options?}> | 每插件配置 |\n| `strictPluginOnlyCustomization` | boolean\\|enum[] | 阻止非插件自定义(surfaces: `skills`/`agents`/`hooks`/`mcp`) |\n\n### 9. 记忆与技能\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `autoMemoryEnabled` | boolean | 项目自动记忆开关 |\n| `autoMemoryDirectory` | string | 自动记忆存储目录(projectSettings 中忽略) |\n| `autoDreamEnabled` | boolean | 后台记忆整合 |\n| `memoryV2Enabled` | boolean | Memory V2 总开关 |\n| `memoryV2` | object | V2 子特性(gatedWrites、hybridStorage、smartRetrieval 等) |\n| `skillSearchEnabled` | boolean | 技能搜索预取 |\n| `skillLearningEnabled` | boolean | 自动技能学习 |\n| `skillImprovementEnabled` | boolean | 自动技能改进 |\n\n### 10. 自动更新与启动\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `autoUpdatesChannel` | enum | `latest`/`stable` |\n| `minimumVersion` | string | 最低版本(防降级) |\n| `cleanupPeriodDays` | number | 聊天转录保留天数(默认 30,0=禁用持久化) |\n| `includeGitInstructions` | boolean | 系统提示是否含 git 工作流(默认 true) |\n| `respectGitignore` | boolean | 文件选择器是否尊重 .gitignore(默认 true) |\n| `skipWebFetchPreflight` | boolean | 跳过 WebFetch 黑名单检查 |\n\n### 11. 登录与认证\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `forceLoginMethod` | enum | `claudeai`/`console` 强制登录方式 |\n| `forceLoginOrgUUID` | string | OAuth 组织 UUID |\n| `apiKeyHelper` | string | 输出认证值的脚本路径 |\n| `awsCredentialExport` / `awsAuthRefresh` | string | AWS 凭证脚本 |\n| `gcpAuthRefresh` | string | GCP 认证刷新命令 |\n| `otelHeadersHelper` | string | OpenTelemetry headers 脚本 |\n\n### 12. 提交与归属\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `attribution` | object | 提交/PR 归属文本(`{ commit, pr }`) |\n| `includeCoAuthoredBy` | boolean | 已弃用,改用 attribution |\n\n### 13. API Key 绑定\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `keys` | KeyEntry[] | API key 条目(`/keys` 命令) |\n| `keyBindings` | object | 模型 slot→key 索引(`{ default?, max?, pro?, std?, subagent? }`) |\n| `keyModelNames` | Record<string,string> | slot→模型名映射 |\n\n详见 [API Key 绑定章节](./keys-binding)。\n\n### 14. 企业受管字段\n\n以下字段设计上只从 managed-settings.json 读取,普通 settings.json 中写会被忽略:\n\n- `allowManagedHooksOnly` — 仅运行 managed 的 hooks\n- `allowManagedPermissionRulesOnly` — 仅用 managed 的权限规则\n- `allowManagedMcpServersOnly` — 仅从 managed 读 MCP 白名单\n- `strictPluginOnlyCustomization` — 阻止非插件自定义\n- `strictKnownMarketplaces` / `blockedMarketplaces` — 插件市场白/黑名单\n- `pluginTrustMessage` — 插件信任警告附加消息\n- `sandbox.failIfUnavailable` — 沙箱不可用即失败\n- `sandbox.network.allowManagedDomainsOnly` — 仅用 managed 域名\n- `sandbox.filesystem.allowManagedReadPathsOnly` — 仅用 managed 读路径\n\n### 15. 其他\n\n| 字段 | 类型 | 说明 |\n|------|------|------|\n| `defaultShell` | enum | `bash`/`powershell`,`!` 命令默认 shell |\n| `worktree` | object | git worktree 配置(`symlinkDirectories`, `sparsePaths`) |\n| `plansDirectory` | string | plan 文件自定义目录 |\n| `feedbackSurveyRate` | number(0-1) | 会话反馈调查出现概率 |\n| `channelsEnabled` | boolean | 团队/企业频道通知 opt-in |\n| `showClearContextOnPlanAccept` | boolean | plan 批准对话框显示 clear context |\n| `saluziMdExcludes` | string[] | 排除加载 SALUZI.md 的 glob 模式 |\n| `remote.defaultEnvironmentId` | string | 远程会话默认环境 |\n| `sshConfigs` | array | SSH 远程配置(`{ id, name, sshHost, sshPort?, sshIdentityFile?, startDirectory? }`) |\n\n## 编辑建议\n\n- **优先用 userSettings**:`~/.saluzi-edu/settings.json` 放跨项目偏好(主题、模型、env)\n- **项目共享配置用 projectSettings**:`<cwd>/.saluzi-edu/settings.json`,入 git 团队共享\n- **个人项目覆盖用 localSettings**:`<cwd>/.saluzi-edu/settings.local.json`,gitignored\n- **不要手编 .config.json / .credentials.json**:用 `/login` 等命令让 Saluzi 自己写\n- **删除前备份**:`settings.json`、`SALUZI.md`、`keybindings.json` 删了不可恢复\n\n## 下一步\n\n- [排障](./troubleshooting) — `/doctor` 全面体检配置\n- [上下文管理](./context-tips) — SALUZI.md 项目记忆机制\n- [API Key 绑定](./keys-binding) — `/keys` 多 Key 调度\n"
|
|
3094
3098
|
},
|
|
3099
|
+
"docs/guide/build-mcp-server": {
|
|
3100
|
+
"frontmatter": {
|
|
3101
|
+
"title": "搭建你的第一个 MCP 服务器",
|
|
3102
|
+
"description": "从零开始学习 MCP 协议,用 Node.js 搭建一个本地 MCP 服务器,让 Saluzi 调用你自己的工具。零基础友好。",
|
|
3103
|
+
"keywords": [
|
|
3104
|
+
"MCP",
|
|
3105
|
+
"服务器",
|
|
3106
|
+
"自定义工具",
|
|
3107
|
+
"Node.js",
|
|
3108
|
+
"拓展"
|
|
3109
|
+
]
|
|
3110
|
+
},
|
|
3111
|
+
"content": "\n## 什么是 MCP?\n\nMCP(Model Context Protocol,模型上下文协议)是一个开放标准,让 AI 应用(比如 Saluzi)可以安全地调用外部工具和数据源。\n\n**打个比方:** 如果把 AI 比作一个程序员,内置工具(Read、Bash、Edit)是它自带的双手,MCP 就是 USB 接口——你可以插上任何你写的\"外设\",让 AI 拥有新的能力。\n\nMCP 服务器本质上是一个独立进程,通过 **stdin/stdout 走 JSON-RPC 2.0 协议** 和 Saluzi 通信。Saluzi 启动你的服务器进程,通过标准输入输出收发 JSON 格式的请求和响应。\n\n## 前置条件\n\n- 已安装 Saluzi(`npm install -g @saluzi/saluzi-edu`)\n- 已安装 Node.js 18+(运行 `node --version` 确认)\n- 了解最基本的 JavaScript 语法(会写函数就行)\n\n> 如果你只会 Python,跳到文末的《Python 版本》一节,步骤完全一致。\n\n## 第一步:创建项目目录\n\n```bash\nmkdir my-first-mcp-server\ncd my-first-mcp-server\nnpm init -y\n```\n\n这会在当前目录生成一个 `package.json` 文件。\n\n## 第二步:安装 MCP SDK\n\n```bash\nnpm install @modelcontextprotocol/sdk\n```\n\n这是官方提供的 MCP 开发工具包,帮你处理所有通信细节,你只需要写工具的逻辑。\n\n## 第三步:写第一个 MCP 服务器\n\n新建文件 `server.js`:\n\n```javascript\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport {\n ListToolsRequestSchema,\n CallToolRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js'\n\n// 1. 创建服务器实例\n// 参数:服务器信息(名称、版本)、能力声明(声明支持 tools)\nconst server = new Server(\n { name: 'my-first-server', version: '1.0.0' },\n { capabilities: { tools: {} } },\n)\n\n// 2. 声明工具列表(tools/list)\n// 告诉 Saluzi:我这个服务器提供哪些工具,每个工具的参数是什么\nserver.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: 'greet',\n description: '向你问好',\n inputSchema: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: '你的名字',\n },\n },\n required: [],\n },\n },\n ],\n}))\n\n// 3. 实现工具调用(tools/call)\n// 当 AI 决定调用 greet 工具时,这个函数会被执行\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params\n\n if (name === 'greet') {\n const userName = args?.name || '朋友'\n return {\n content: [\n { type: 'text', text: `你好,${userName}!欢迎使用 MCP 🎉` },\n ],\n }\n }\n\n throw new Error(`未知工具: ${name}`)\n})\n\n// 4. 启动服务器\n// StdioServerTransport 让服务器通过 stdin/stdout 通信\nconst transport = new StdioServerTransport()\nawait server.connect(transport)\n```\n\n> `package.json` 中需要添加 `\"type\": \"module\"` 才能使用 `import` 语法。或者你也可以用 `require` 语法(CommonJS)。\n\n## 第四步:连接到 Saluzi\n\n在终端中运行:\n\n```bash\nslz mcp add my-first-server -- node server.js\n```\n\n这条命令做了三件事:\n1. 把 `my-first-server` 这个 MCP 服务器注册到 Saluzi 的配置中\n2. 告诉 Saluzi 用 `node server.js` 来启动它\n3. 立即连接该服务器,获取它声明的工具列表\n\n如果一切正常,你会看到:\n\n```\nAdded stdio MCP server my-first-server with command: node server.js to local config\nFile modified: /path/to/.saluzi/mcp.json\n```\n\n## 第五步:测试\n\n在 Saluzi 会话中直接问 AI:\n\n```\n你好,请用 greet 工具向我问好\n```\n\n或者更直接:\n\n```\n用 my-first-server 的 greet 工具,传 name 为 \"小明\"\n```\n\nAI 会调用 `mcp__my-first-server__greet` 工具,返回自定义的问候语。\n\n你还可以在 Saluzi 中随时输入 `/mcp` 查看当前已连接的所有 MCP 服务器状态。\n\n## 第六步:增加实用工具\n\n现在来加一个真正有用的工具——计算器。修改 `server.js` 的 `ListToolsRequestSchema` 部分,在 `tools` 数组里增加第二个工具:\n\n```javascript\nserver.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: [\n {\n name: 'greet',\n description: '向你问好',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: '你的名字' },\n },\n required: [],\n },\n },\n {\n name: 'calculator',\n description: '执行数学计算(加减乘除)',\n inputSchema: {\n type: 'object',\n properties: {\n a: { type: 'number', description: '第一个数字' },\n b: { type: 'number', description: '第二个数字' },\n operator: {\n type: 'string',\n description: '运算符:add、subtract、multiply、divide',\n enum: ['add', 'subtract', 'multiply', 'divide'],\n },\n },\n required: ['a', 'b', 'operator'],\n },\n },\n ],\n}))\n```\n\n然后在 `CallToolRequestSchema` 中增加 `calculator` 的处理:\n\n```javascript\nserver.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params\n\n if (name === 'greet') {\n const userName = args?.name || '朋友'\n return {\n content: [{ type: 'text', text: `你好,${userName}!欢迎使用 MCP 🎉` }],\n }\n }\n\n if (name === 'calculator') {\n const a = Number(args?.a)\n const b = Number(args?.b)\n const op = args?.operator\n let result\n\n switch (op) {\n case 'add': result = a + b; break\n case 'subtract': result = a - b; break\n case 'multiply': result = a * b; break\n case 'divide':\n if (b === 0) throw new Error('除数不能为 0')\n result = a / b\n break\n default:\n throw new Error(`不支持的运算符: ${op}`)\n }\n\n return {\n content: [{ type: 'text', text: `${a} ${op} ${b} = ${result}` }],\n }\n }\n\n throw new Error(`未知工具: ${name}`)\n})\n```\n\n修改完成后,需要断开并重新连接 MCP 服务器:\n\n```bash\n# 方法一:重启整个 Saluzi\n# 方法二:在 Saluzi 中重连\nslz mcp reconnect my-first-server\n```\n\n现在测试新工具:\n\n```\n帮我算一下 123 + 456\n```\n\n## 理解 MCP 服务器生命周期\n\n```\nSaluzi 启动\n │\n ├── 读取 mcp.json 配置\n │\n ├── 启动 MCP 服务器进程(node server.js)\n │ │\n │ ├── 服务器启动 → 连接 stdin/stdout\n │ │\n │ ├── Saluzi 发送 tools/list 请求\n │ │ └── 服务器返回工具列表\n │ │\n │ └── 等待 AI 调用工具...\n │ │\n │ ├── AI 决定调用 calculator\n │ │\n │ ├── Saluzi 发送 tools/call 请求\n │ │ └── 服务器执行计算,返回结果\n │ │\n │ └── AI 收到结果,继续对话\n │\n └── Saluzi 退出 → 终止服务器进程\n```\n\n关键点:\n- **服务器进程常驻**:与 Saluzi 同生命周期,不需要每次调用都重启\n- **通信协议**:JSON-RPC 2.0,纯文本格式,可以自己用任何语言实现\n- **工具无状态**:每次调用都是独立的,不依赖之前的调用\n\n## 用 .mcp.json 配置文件(推荐)\n\n除了 `slz mcp add` 命令,你也可以在项目根目录创建 `.mcp.json` 文件,这样项目成员共享配置:\n\n```json\n{\n \"mcpServers\": {\n \"my-first-server\": {\n \"type\": \"stdio\",\n \"command\": \"node\",\n \"args\": [\"server.js\"],\n \"env\": {\n \"MY_VAR\": \"some_value\"\n }\n }\n }\n}\n```\n\nSaluzi 会自动检测项目根目录的 `.mcp.json` 并连接。你还可以在 Saluzi 中用 `/mcp` 命令启用或禁用其中的服务器。\n\n## 传递环境变量\n\n有些 MCP 服务器需要 API Key 等敏感信息,通过环境变量传递:\n\n```bash\nslz mcp add my-server -- npx @some/mcp-server\n# 或带环境变量\nslz mcp add -e API_KEY=sk-xxx my-server -- node server.js\n```\n\n环境变量也会写入 `.mcp.json` 或 `mcp.json` 配置中。\n\n## 常见问题\n\n### Q: 修改了服务器代码,怎么更新?\n\nA: 需要重连服务器:`slz mcp reconnect my-first-server`,或者直接重启 Saluzi。\n\n### Q: MCP 服务器启动失败怎么办?\n\nA: 先在终端单独运行 `node server.js` 看看有没有报错。确认无误后再用 `slz mcp add` 注册。\n\n### Q: 可以用其他语言写吗?\n\nA: 可以,只要进程能通过 stdin/stdout 收发 JSON-RPC 2.0 消息即可。Python、Rust、Go、Java 等都可以。\n\n### Q: 工具调用报错怎么排查?\n\nA: 查看 Saluzi 的调试日志:`SALUZI_DEBUG=1 slz`,日志中会包含 MCP 通信的详细内容。\n\n## Python 版本(如果你不会 JS)\n\n如果你更熟悉 Python,步骤完全一样,只是服务器代码不同。\n\n### 安装 Python MCP 库\n\n```bash\npip install mcp\n```\n\n### 编写 Python MCP 服务器\n\n```python\n# server.py\nfrom mcp.server import Server, stdio_server\nfrom mcp.types import Tool, TextContent\nimport datetime\n\napp = Server(\"my-python-server\")\n\n@app.list_tools()\nasync def list_tools():\n return [\n Tool(\n name=\"current_time\",\n description=\"返回当前时间\",\n inputSchema={\n \"type\": \"object\",\n \"properties\": {\n \"timezone\": {\n \"type\": \"string\",\n \"description\": \"时区,如 Asia/Shanghai\",\n }\n },\n },\n )\n ]\n\n@app.call_tool()\nasync def call_tool(name: str, arguments: dict) -> list:\n if name == \"current_time\":\n tz = arguments.get(\"timezone\", \"UTC\")\n now = datetime.datetime.now()\n return [TextContent(type=\"text\", text=f\"当前时间 ({tz}): {now}\")]\n\nif __name__ == \"__main__\":\n import asyncio\n asyncio.run(stdio_server.run(app))\n```\n\n### 注册到 Saluzi\n\n```bash\nslz mcp add my-python-server -- python server.py\n```\n\n## 下一步\n\n现在你已经掌握了 MCP 服务器的搭建方法,可以:\n\n- 给你的项目写一个专用的 MCP 服务器,比如操作数据库、调用内部 API\n- 在 npm 上寻找现成的 MCP 服务器包(搜索 `mcp-server` 或 `@modelcontextprotocol`)\n- 深入了解 MCP 协议规范,实现更复杂的功能(资源、提示模板等)\n\n继续学习 Saluzi 的其他功能:\n\n- [API Key 绑定](./keys-binding) — 管理多个模型密钥\n- [Remote Control 与 ACP](./remote-control-acp) — 远程控制 Saluzi"
|
|
3112
|
+
},
|
|
3095
3113
|
"docs/guide/keys-binding": {
|
|
3096
3114
|
"frontmatter": {
|
|
3097
3115
|
"title": "API Key 绑定",
|
|
@@ -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{af as x,ag as o,G as m,aa as s,a4 as l,v as u}from"./main-Bfbs-lwB.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-Bfbs-lwB.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{a1 as O,a0 as _,ag as T,ae as E,v as P,af as L,aa as a,a4 as A,p as $,r as H,e as W,q as V,d as I,a7 as q,B as G,G as R,H as U,F as Z}from"./main-Bfbs-lwB.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-DuslCmw6.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: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}=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($,{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{ae as v,aa as t}from"./main-Bfbs-lwB.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{ae as f,aa as t}from"./main-Bfbs-lwB.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{ae as y,aa as t}from"./main-Bfbs-lwB.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 Ae=Object.defineProperty;var Re=(s,t,n)=>t in s?Ae(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var E=(s,t,n)=>Re(s,typeof t!="symbol"?t+"":t,n);import{e as p,j as e}from"./vendor-DE_-CLIE.js";import{a1 as R,J as qe,Y as De,a5 as re,W as F,K as Ue,v as de,a4 as ue,L as me,x as Oe,u as Fe,a3 as A,a0 as K,d as xe,ab as Le,N as He,E as Be,V as ze,af as pe,aa as j,A as Ve,a6 as Qe,ac as We,a2 as Ke,F as Ye,w as he,c as Je,C as Ge,I as Xe,a8 as Ze,D as et,a as tt,p as fe,r as ye,t as st,f as be,e as ge,q as je,M as nt}from"./main-Bfbs-lwB.js";import{g as rt}from"./workerType-Bd-zteMi.js";import{D as we,a as Ne,c as ve,d as ke,b as at,S as ot}from"./SessionVisibilityBadge-DuslCmw6.js";import{U as it}from"./UserSearchInput-7Q9EFRPQ.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 lt=[["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"}]],ct=R("activity",lt);/**
|
|
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 dt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ut=R("chevron-right",dt);/**
|
|
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 mt=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ae=R("clock",mt);/**
|
|
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 xt=[["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"}]],Se=R("cpu",xt);/**
|
|
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 pt=[["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"}]],ht=R("hash",pt);/**
|
|
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 ft=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],yt=R("info",ft);/**
|
|
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 bt=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],gt=R("play",bt);/**
|
|
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 jt=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],wt=R("server-cog",jt);/**
|
|
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 Nt=[["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",Nt);/**
|
|
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 kt=[["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"}]],St=R("triangle-alert",kt);function _e(){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 _t(s,t){var m,x,h,d,u,o,l,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 i=Date.now(),a=s.tasks[r];if(n==="task_started"){if(a)return{tasks:{...s.tasks,[r]:{...a,description:t.description??a.description,name:X(t.description??a.description),taskType:t.task_type??a.taskType,workflowName:t.workflow_name??a.workflowName,prompt:t.prompt??a.prompt,toolUseId:t.tool_use_id??a.toolUseId,status:"running",startTime:i,evictAfter:void 0}}};const v=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:X(v),description:v,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:i}}}}if(n==="task_progress"){if(!a){const v=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:X(v),description:v,toolUseId:t.tool_use_id,status:"running",startTime:i,tokenCount:(m=t.usage)==null?void 0:m.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]:{...a,description:t.description??a.description,tokenCount:((d=t.usage)==null?void 0:d.total_tokens)??a.tokenCount,toolUseCount:((u=t.usage)==null?void 0:u.tool_uses)??a.toolUseCount,durationMs:((o=t.usage)==null?void 0:o.duration_ms)??a.durationMs,lastToolName:t.last_tool_name??a.lastToolName,summary:t.summary??a.summary}}}}return a?{tasks:{...s.tasks,[r]:{...a,status:t.status??"completed",endTime:i,finalSummary:t.summary??a.finalSummary,outputFile:t.output_file??a.outputFile,tokenCount:((y=t.usage)==null?void 0:y.total_tokens)??a.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??a.toolUseCount,durationMs:((k=t.usage)==null?void 0:k.duration_ms)??a.durationMs,evictAfter:i+oe}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:X(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:i,endTime:i,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(l=t.usage)==null?void 0:l.total_tokens,toolUseCount:(g=t.usage)==null?void 0:g.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:i+oe}}}}function Ct(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 Mt{constructor(){E(this,"listeners",new Set);E(this,"eventSource",null);E(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const n=`/web/sessions/${t}/events`,r=new EventSource(n,{withCredentials:!0});this.eventSource=r,r.addEventListener("message",i=>{try{const a=JSON.parse(i.data);if(a.seqNum!==void 0&&a.seqNum<=this._lastSeqNum)return;a.seqNum!==void 0&&(this._lastSeqNum=a.seqNum);for(const m of this.listeners)m(a)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const se=new Mt;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 Et{constructor(t,n,r){E(this,"sessionId");E(this,"setEntries");E(this,"unsub",null);E(this,"onStatusChange");E(this,"onError");E(this,"onPermissionRequest");E(this,"onModelsStateChange");E(this,"onSubagentUpdate");E(this,"onControlResponse");E(this,"onPermissionModeChange");E(this,"subagentState",_e());E(this,"seenUuids",new Set);E(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 m;const{events:t}=await qe(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const i=()=>{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;i();const u=ie(h);u&&n.push({type:"user_message",id:x.id||`hist-user-${n.length}`,content:u})}else if(x.type==="assistant"){i();const u=ie(h),o=[],l=h.message;if(l&&typeof l=="object"&&Array.isArray(l.content)){for(const g of l.content)if(g.type==="tool_use"){const f=g.id;f&&this.seenToolCallIds.add(f),o.push({type:"tool_call",toolCall:{id:f||`hist-tool-${n.length}`,title:g.name||"tool",status:"complete",rawInput:g.input||{}}})}}if(u||o.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 o)n.push(g);r=null}}else if(x.type==="tool_use"){const u=h,o={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(o)}else if(x.type==="tool_result"){const u=h,o=le(n,u.tool_call_id||"");if(o>=0){const l=n[o];n[o]={type:"tool_call",toolCall:{...l.toolCall,rawOutput:{output:u.content||u.output||""}}}}}}i(),this.setEntries(n);let a=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"&&(a=u)}a&&((m=this.onModelsStateChange)==null||m.call(this,a))}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 a,m,x,h,d,u;const n=t.type,r=t.payload||{},i=JSON.stringify(t);if(!/Remote Control connecting/i.test(i))switch(n){case"assistant":{const o=r.uuid;if(typeof o=="string"&&o){if(this.seenUuids.has(o))break;this.seenUuids.add(o)}const l=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+l}]}]:[...f.slice(0,-1),{...y,chunks:[...y.chunks,{type:"message",text:l}]}]}if(l&&l.trim()){const b={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:l}]};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(v=>[...v,{type:"tool_call",toolCall:k}])}}break}case"tool_use":{const o=r,l=o.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(l))break;this.seenToolCallIds.add(l);const g={id:l,title:o.tool_name||"tool",status:"running",rawInput:o.tool_input||{}};this.setEntries(f=>[...f,{type:"tool_call",toolCall:g}]);break}case"tool_result":{const o=r,l=o.tool_call_id||"";this.setEntries(g=>{const f=le(g,l);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:o.content||o.output||""}}}:b)});break}case"control_request":case"permission_request":{const o=r.request;if(o&&o.subtype==="can_use_tool"){const l=r.request_id||"",g=o.tool_name||"unknown",f=o.input||o.tool_input||{},y=o.description||"";this.setEntries(b=>{const k=[...b].reverse().findIndex(v=>v.type==="tool_call");if(k>=0){const v=b.length-1-k,M=b[v];if(M.toolCall.status==="running")return b.map((C,T)=>T===v?{type:"tool_call",toolCall:{...M.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:l,options:[]}}}:C)}return b}),(a=this.onPermissionRequest)==null||a.call(this,{requestId:l,toolName:g,toolInput:f,description:y})}break}case"session_status":{typeof r.status=="string"&&((m=this.onStatusChange)==null||m.call(this,r.status));break}case"error":{const o=String(r.message||r.content||"Unknown error");(x=this.onError)==null||x.call(this,o);break}case"models_state":{const o=r.raw,l=typeof o=="object"&&o!==null?o.models_state:r.models_state;l&&Array.isArray(l.availableModels)&&typeof l.currentModelId=="string"&&((h=this.onModelsStateChange)==null||h.call(this,l));break}case"system":{const o=r.raw,l=o&&typeof o=="object"?o:r,g=typeof l.subtype=="string"?l.subtype:void 0;if(g==="task_started"||g==="task_progress"||g==="task_notification"){const y={subtype:g,task_id:typeof l.task_id=="string"?l.task_id:void 0,tool_use_id:typeof l.tool_use_id=="string"?l.tool_use_id:void 0,description:typeof l.description=="string"?l.description:void 0,task_type:typeof l.task_type=="string"?l.task_type:void 0,workflow_name:typeof l.workflow_name=="string"?l.workflow_name:void 0,prompt:typeof l.prompt=="string"?l.prompt:void 0,usage:l.usage&&typeof l.usage=="object"?l.usage:void 0,last_tool_name:typeof l.last_tool_name=="string"?l.last_tool_name:void 0,summary:typeof l.summary=="string"?l.summary:void 0,status:l.status==="completed"||l.status==="failed"||l.status==="stopped"?l.status:void 0,output_file:typeof l.output_file=="string"?l.output_file:void 0};this.subagentState=_t(this.subagentState,y)}const f=typeof l.permissionMode=="string"?l.permissionMode:typeof r.permissionMode=="string"?r.permissionMode:null;f&&((d=this.onPermissionModeChange)==null||d.call(this,f));break}case"control_response":{const o=r.response;if(o&&typeof o=="object"){const l=typeof o.request_id=="string"?o.request_id:"",g=typeof o.subtype=="string"?o.subtype:"";l&&((u=this.onControlResponse)==null||u.call(this,{subtype:g,requestId:l,error:typeof o.error=="string"?o.error:void 0}))}break}}}async sendMessage(t,n,r){const i=n&&n.length>0,a=r&&r.length>0;if(!t.trim()&&!i&&!a)return;const m={type:"user_message",id:`user-${Date.now()}`,content:t,images:i?n:void 0,attachments:a?r:void 0};this.setEntries(d=>[...d,m]);const x=[];if(t&&x.push({type:"text",text:t}),i)for(const d of n)x.push({type:"image",source:{type:"base64",media_type:d.mimeType,data:d.data}});if(a){for(const d of r)if(d.kind==="text"||d.kind==="table"){const u=`📎 ${d.name}${d.size!=null?` (${Tt(d.size)})`:""}`,o=d.textContent||"(空文件)";x.push({type:"text",text:`${u}
|
|
52
|
+
\`\`\`
|
|
53
|
+
${o}
|
|
54
|
+
\`\`\``})}else if(d.kind==="directory"){const u=`📁 目录: ${d.name}${d.files!=null?` (${d.files.length} 个文件)`:""}`,o=d.textContent||"(空目录)";x.push({type:"text",text:`${u}
|
|
55
|
+
${o}`})}}const h=x.length===1&&x[0].type==="text"?x[0].text||t:x.length>0?x:t;await De(this.sessionId,{type:"user",uuid:re(),content:t,message:{content:h}})}async respondPermission(t,n,r){await F(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(i=>i.map(a=>{var m;return a.type!=="tool_call"||((m=a.toolCall.permissionRequest)==null?void 0:m.requestId)!==t?a:{type:"tool_call",toolCall:{...a.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 Ue(this.sessionId)}async setPermissionMode(t){const n=re();return await F(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"set_permission_mode",mode:t}}),n}}function Tt(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function It(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 $t(s){return s?Date.now()-s<6e4:!1}function Pt({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:i,onDelete:a}){const[m,x]=p.useState(!1),h=async()=>{await navigator.clipboard.writeText(t.id),x(!0),setTimeout(()=>x(!1),1500)},d=r.length,u=t.worker,o=t.work_item,l=t.environment;return e.jsx(we,{open:!0,onOpenChange:g=>{g||s()},children:e.jsxs(Ne,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(ve,{children:e.jsx(ke,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(ct,{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&&($t(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:It(u.last_heartbeat_at)})]}),l&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Se,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:l.machine_name||l.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(wt,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:i,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:a,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(Oe,{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(ht,{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:m?"✓":"⧉"})]})]}),o&&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:o.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:o.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})]}),l&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:l.worker_type})]})]})]})]})]})})}const ce="rcs:subagent-panel:collapsed";function At(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 i=Math.floor(n/60),a=n%60;return a?`${i}h${a}m`:`${i}h`}function Rt(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 qt({status:s}){return s==="running"?e.jsx(me,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(gt,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(Fe,{className:"h-3 w-3 text-status-error"}):null}function Dt({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=Rt(s.tokenCount),i=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",a=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(qt,{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:At(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:a}),(r||i||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"]}),i&&e.jsxs("span",{children:["· ",i]}),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 Ut({state:s}){const[t,n]=p.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})},[,i]=p.useState(0);p.useEffect(()=>{const h=Object.values(s.tasks).some(o=>o.status==="running"),d=Object.values(s.tasks).some(o=>o.status!=="running"&&o.evictAfter!==void 0);if(!h&&!d)return;const u=setInterval(()=>{i(o=>o+1)},1e3);return()=>clearInterval(u)},[s]);const a=Ct(s);if(a.length===0)return null;const m=a.filter(h=>h.status==="running").length,x=m>0?`${m} running`:`${a.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(ut,{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:a.map(h=>e.jsx(Dt,{task:h},h.taskId))})]})})}function Ot({requestId:s,toolName:t,toolInput:n,description:r,onApprove:i,onReject:a}){const m=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(St,{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:Le(m,500)}),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:"Approve"}),e.jsx("button",{onClick:a,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 Ft({questions:s,description:t,onSubmit:n,onSkip:r}){const[i,a]=p.useState({}),[m,x]=p.useState({}),[h,d]=p.useState(0),u=(f,y,b)=>{if(b){const k=i[f]||[],v=k.includes(y)?k.filter(M=>M!==y):[...k,y];a({...i,[f]:v})}else a({...i,[f]:y})},o=f=>{var b;const y=(b=m[f])==null?void 0:b.trim();y&&(a({...i,[f]:y}),x({...m,[f]:""}))},l=()=>{var y,b;const f={};for(const[k,v]of Object.entries(i)){const M=s[parseInt(k,10)];M&&(typeof v=="number"?f[k]=((b=(y=M.options)==null?void 0:y[v])==null?void 0:b.label)||String(v):Array.isArray(v)?f[k]=v.map(C=>{var T,D;return((D=(T=M.options)==null?void 0:T[C])==null?void 0:D.label)||String(C)}):f[k]=v)}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 v=y?(i[0]||[]).includes(k):i[0]===k;return e.jsxs("button",{onClick:()=>u(0,k,y),className:K("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",v?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",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:m[0]||"",onChange:b=>x({...m,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"&&o(0)}),e.jsx("button",{onClick:()=>o(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:l,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:K("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(Lt,{question:g,qIdx:h,answers:i,otherTexts:m,onSelect:u,onOtherTextChange:(f,y)=>x({...m,[f]:y}),onOtherSubmit:o}),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:l,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 Lt({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:i,onOtherTextChange:a,onOtherSubmit:m}){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:()=>i(t,d,x),className:K("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=>a(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"&&m(t)}),e.jsx("button",{onClick:()=>m(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 Ht({planContent:s,description:t,onSubmit:n}){const[r,i]=p.useState(null),[a,m]=p.useState(""),x=!s||!s.trim(),h=()=>{r&&n(r,r==="no"?a: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:Bt(s)}}),e.jsx("div",{className:"space-y-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(W,{selected:r==="yes-default",onClick:()=>i("yes-default"),label:"Yes"}),e.jsx(W,{selected:r==="no",onClick:()=>i("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{selected:r==="yes-accept-edits",onClick:()=>i("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(W,{selected:r==="yes-default",onClick:()=>i("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(W,{selected:r==="no",onClick:()=>i("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:a,onChange:d=>m(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 W({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:K("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:K("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:n})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:r})]})}function Bt(s){let t=A(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(n,r,i)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${i.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 zt(s){const[t,n]=p.useState([]),[r,i]=p.useState(!0),[a,m]=p.useState(null),x=p.useCallback(async()=>{i(!0),m(null);try{const u=await He(s);n(u)}catch(u){m(u instanceof Error?u.message:"Failed to load shares")}finally{i(!1)}},[s]);p.useEffect(()=>{x()},[x]);const h=p.useCallback(async u=>{m(null);try{const o=await Be(s,u);return await x(),o}catch(o){throw m(o instanceof Error?o.message:"Failed to create share"),o}},[s,x]),d=p.useCallback(async u=>{m(null);try{await ze(s,u),await x()}catch(o){throw m(o instanceof Error?o.message:"Failed to revoke share"),o}},[s,x]);return{shares:t,isLoading:r,error:a,createShare:h,revokeShare:d,refresh:x}}function Vt({open:s,onClose:t,sessionId:n,sessionTitle:r}){pe();const{shares:i,isLoading:a,error:m,createShare:x,revokeShare:h}=zt(n),[d,u]=p.useState("user"),[o,l]=p.useState(""),[g,f]=p.useState(""),[y,b]=p.useState("read"),[k,v]=p.useState(""),[M,C]=p.useState(!1),[T,D]=p.useState(null),[Y,O]=p.useState(""),[L,U]=p.useState(!1),[J,q]=p.useState(!1);p.useEffect(()=>{s&&(u("user"),l(""),f(""),b("read"),v(""),C(!1),D(null),O(""),U(!1),q(!1))},[s]);const $=async()=>{C(!0),O(""),D(null);try{const N={grantedTo:d==="user"?{userId:o.trim()}:{teamId:g.trim()},permission:y};k.trim()&&(N.expiresAt=k.trim());const B=await x(N);D(`${window.location.origin}/code/s/${B.shareToken}`)}catch(N){O(N instanceof Error?N.message:"Failed to create share")}finally{C(!1)}},H=async N=>{try{await h(N)}catch{}},G=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 N=document.createElement("textarea");N.value=T,N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.select();try{document.execCommand("copy"),U(!0),setTimeout(()=>U(!1),2e3)}catch{q(!0)}document.body.removeChild(N)};return e.jsx(we,{open:s,onOpenChange:N=>{N||t()},children:e.jsxs(Ne,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(ve,{children:e.jsxs(ke,{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(it,{onSelect:l,placeholder:j("share.userIdPlaceholder"),actionLabel:j("share.selectUser")}):e.jsx("input",{type:"text",value:g,onChange:N=>f(N.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"&&o&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[j("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:o})]})]}),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:N=>b(N.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:N=>v(N.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"})]}),(Y||m)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:Y||m}),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:G,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:L?j("share.copied"):j("share.copy")})]}),J&&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")}),a?e.jsx("p",{className:"text-sm text-text-muted",children:j("share.loading")}):i.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:i.map(N=>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:N.granted_to_user||N.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[N.permission==="write"?j("share.permissionWrite"):j("share.permissionRead"),N.expires_at?` · expires ${N.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>H(N.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")})]},N.id))})]})]}),e.jsxs(at,{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:M||(d==="user"?!o.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:M?j("common.creating"):j("share.createShare")})]})]})})}function Qt(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Wt(s){const t=Qt(s),n=Qe(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new Ve(r)}const V=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],Z="rcs_permission_mode";function Kt(s){const t=V.findIndex(n=>n.value===s);return V[(t+1+V.length)%V.length].value}function Yt({models:s,currentModelId:t,onSelect:n,disabled:r}){const[i,a]=p.useState(!1),m=s.find(d=>d.modelId===t)??null,x=s.length>0,h=async d=>{n(d.modelId),a(!1)};return e.jsxs(fe,{open:i,onOpenChange:x?a:void 0,children:[e.jsx(ye,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:r||!x,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"选择模型",children:[e.jsx(Se,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(m==null?void 0:m.name)??t??"选择模型"}),i?e.jsx(be,{className:"h-3 w-3"}):e.jsx(ge,{className:"h-3 w-3"})]})}),e.jsx(je,{className:"w-72 p-0",align:"start",children:e.jsx(nt,{models:s,currentModelId:t,onSelect:h,showSearch:s.length>5})})]})}function Jt({mode:s,onModeChange:t,disabled:n}){const[r,i]=p.useState(!1),a=V.find(m=>m.value===s);return e.jsxs(fe,{open:r,onOpenChange:i,children:[e.jsx(ye,{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(st,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(a==null?void 0:a.label)??s}),r?e.jsx(be,{className:"h-3 w-3"}):e.jsx(ge,{className:"h-3 w-3"})]})}),e.jsx(je,{className:"w-64 p-1",align:"start",children:V.map(m=>e.jsxs("button",{type:"button",onClick:()=>{t(m.value),i(!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===m.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:m.label}),e.jsx("div",{className:"text-xs text-text-muted",children:m.description})]})]},m.value))})]})}function is({sessionId:s,onSessionLoaded:t}){pe();const[n,r]=p.useState(null),[i,a]=p.useState(null),[m,x]=p.useState(""),[h,d]=p.useState(!1),[u,o]=p.useState(!1),[l,g]=p.useState(!1),[f,y]=p.useState([]),[b,k]=p.useState(!1),[v,M]=p.useState([]),[C,T]=p.useState(null),[D,Y]=p.useState(()=>_e()),[O,L]=p.useState(()=>localStorage.getItem(Z)||"default"),[U,J]=p.useState(null),q=p.useRef(null),$=p.useRef(O);$.current=O;const H=p.useRef(null),G=p.useRef(null),N=p.useRef(f);N.current=f;const B=p.useCallback(c=>{J(c),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>J(null),5e3)},[]),ee=p.useCallback(c=>{var S;if(c===$.current)return;const w=$.current;$.current=c,L(c);try{localStorage.setItem(Z,c)}catch{}(S=G.current)==null||S.setPermissionMode(c).then(_=>{H.current={requestId:_,previous:w}}).catch(_=>{console.error("[SessionDetail] set permission mode failed:",_),B(`模式切换请求发送失败: ${_ instanceof Error?_.message:String(_)}`),$.current=w,L(w)})},[B]),I=p.useMemo(()=>new Et(s,y,{onStatusChange:c=>{a(c)},onError:c=>{console.error("[RCSChatAdapter] error:",c)},onPermissionRequest:c=>{M(w=>w.some(S=>S.requestId===c.requestId)?w:[...w,c])},onModelsStateChange:c=>{T(c)},onSubagentUpdate:c=>{Y(c)},onControlResponse:c=>{const w=H.current;if(!(!w||w.requestId!==c.requestId)&&(H.current=null,c.subtype==="error")){$.current=w.previous,L(w.previous);try{localStorage.setItem(Z,w.previous)}catch{}B(c.error||"模式切换失败")}},onPermissionModeChange:c=>{if(c!==$.current){$.current=c,L(c);try{localStorage.setItem(Z,c)}catch{}H.current=null}}}),[s,B]);p.useEffect(()=>(G.current=I,()=>{I.disconnect()}),[I]),p.useEffect(()=>{let c=!1;async function w(){x("");try{const S=await Xe(s);if(c)return;r(S),a(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 z=Ze(i),Q=(n==null?void 0:n.access_level)==="read",Ce=p.useCallback(async c=>{const w=c.text.trim(),S=c.images&&c.images.length>0||c.attachments&&c.attachments.length>0;if(!w&&!S||z)return;const _=await We(w,{sessionId:s,availableCommands:[],availableModels:(C==null?void 0:C.availableModels)??[],currentModel:C?{modelId:C.currentModelId,name:C.currentModelId}:null,supportsImages:!0,entries:N.current,setModel:async P=>{await F(s,{type:"control_request",request:{subtype:"set_model",model:P}}),T(te=>te&&{...te,currentModelId:P})},onNewSession:()=>{y([])}}).catch(()=>null);if(_){if(Ke("[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,z,s,C]),ne=p.useCallback(async()=>{try{await I.interrupt()}catch(c){console.error("Interrupt failed:",c)}finally{k(!1)}},[I]),Me=p.useCallback(()=>{ee(Kt($.current))},[ee]);p.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]);const Ee=p.useCallback(async()=>{if(n&&window.confirm(j("dashboard.confirmDelete").replace("{id}",n.title||n.id)))try{await Ye(n.id),window.location.href="/code/"}catch(c){alert(c instanceof Error?c.message:j("dashboard.deleteFailed"))}},[n]);p.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 Te=p.useCallback(async c=>{try{await I.respondPermission(c,!0)}catch(w){console.error("Failed to approve:",w)}M(w=>w.filter(S=>S.requestId!==c))},[I]),Ie=p.useCallback(async c=>{try{await I.respondPermission(c,!1)}catch(w){console.error("Failed to reject:",w)}M(w=>w.filter(S=>S.requestId!==c))},[I]),$e=p.useCallback(async(c,w,S)=>{try{await F(s,{type:"permission_response",approved:!0,request_id:c,updated_input:{questions:S,answers:w}})}catch(_){console.error("Failed to submit answers:",_)}M(_=>_.filter(P=>P.requestId!==c))},[s]),Pe=p.useCallback(async(c,w,S)=>{try{w==="no"?await F(s,{type:"permission_response",approved:!1,request_id:c,...S?{message:S}:{}}):await F(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:",_)}M(_=>_.filter(P=>P.requestId!==c))},[s]);return m?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:m}),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(Xt,{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(ot,{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=rt(c);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${w.colorClass}`,children:w.fullLabel})})(),i&&e.jsx(de,{status:i}),e.jsx("span",{className:"text-xs text-text-muted",children:ue(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!Q&&(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:()=>o(!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(yt,{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"),v.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:v.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(Je,{entries:f,isLoading:b,emptyTitle:j("session.emptyTitle"),emptyDescription:j("session.emptyDescription")}),e.jsx(Ut,{state:D}),v.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:v.map(c=>e.jsx(Gt,{request:c,onApprove:()=>Te(c.requestId),onReject:()=>Ie(c.requestId),onSubmitAnswers:$e,onSubmitPlan:Pe},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.jsx("div",{className:"max-w-3xl mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Jt,{mode:O,onModeChange:ee,disabled:z||Q}),e.jsx(Yt,{models:(C==null?void 0:C.availableModels)??[],currentModelId:(C==null?void 0:C.currentModelId)??null,onSelect:c=>{F(s,{type:"control_request",request:{subtype:"set_model",model:c}}),T(w=>w&&{...w,currentModelId:c})},disabled:z||Q})]})}),e.jsx(Ge,{onSubmit:Ce,isLoading:b,onInterrupt:ne,onCycleMode:Me,disabled:z||Q,placeholder:z?j("session.closed"):Q?j("session.readOnly"):j("session.inputPlaceholder"),supportsAttachments:!0}),h&&n&&e.jsx(Pt,{onClose:()=>d(!1),session:n,liveStatus:i,pendingPermissions:v,onInterrupt:ne,onDelete:Ee}),e.jsx(Vt,{open:l,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 Gt({request:s,onApprove:t,onReject:n,onSubmitAnswers:r,onSubmitPlan:i}){const a=s.toolName,m=s.toolInput,x=s.description||"";if(a==="AskUserQuestion"){const h=m.questions||[];return e.jsx(Ft,{requestId:s.requestId,questions:h,description:x,onSubmit:d=>r(s.requestId,d,h),onSkip:n})}if(a==="ExitPlanMode"){const h=m.plan||"";return e.jsx(Ht,{requestId:s.requestId,planContent:h,description:x,onSubmit:(d,u)=>i(s.requestId,d,u)})}return e.jsx(Ot,{requestId:s.requestId,toolName:a,toolInput:m,description:x,onApprove:t,onReject:n})}function Xt({sessionId:s,agentId:t}){const[n,r]=p.useState(null),[i,a]=p.useState("disconnected"),[m,x]=p.useState(null),h=p.useRef(null);return p.useEffect(()=>{const d=Wt(t);return d.setConnectionStateHandler((u,o)=>{a(u),x(o||null)}),h.current=d,r(d),d.connect().catch(u=>{u instanceof et||(x(u.message),a("error"))}),()=>{d.disconnect(),h.current=null,r(null),a("disconnected")}},[t]),e.jsx(he,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[m&&i==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:m}),i==="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")})]})}),i==="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:m})]})}),n&&i==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(tt,{client:n,agentId:t})})]})})}export{is 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{a1 as l,R as c,h as d,g,X as u,a0 as o,T as x,s as f,O as m,U as p}from"./main-Bfbs-lwB.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{ae as v,aa as t}from"./main-Bfbs-lwB.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{Q as m,b as h}from"./main-Bfbs-lwB.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{af as f,ag as y,aa as r}from"./main-Bfbs-lwB.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};
|