@saluzi/saluzi-edu 0.2.57 → 0.2.59

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.
Files changed (163) hide show
  1. package/dist/cli.js +276 -265
  2. package/dist/guide/guide-data.json +158 -158
  3. package/dist/rcs-schema.sql +14 -0
  4. package/dist/rcs-web/assets/{AdminPanel-Gc3BPu1_.js → AdminPanel-CbcZ7Vnr.js} +1 -1
  5. package/{packages/remote-control-server/web/dist/assets/Claim-EI1vEA1D.js → dist/rcs-web/assets/Claim-CN3D3Ku6.js} +1 -1
  6. package/{packages/remote-control-server/web/dist/assets/Dashboard-bYYO5HcG.js → dist/rcs-web/assets/Dashboard-BZGcSCFY.js} +2 -2
  7. package/{packages/remote-control-server/web/dist/assets/Join-DBS1b78K.js → dist/rcs-web/assets/Join-B_e3BKa3.js} +1 -1
  8. package/dist/rcs-web/assets/{Login-wdKYrifx.js → Login-u6CGGkoD.js} +1 -1
  9. package/dist/rcs-web/assets/{Register-DRD2kteD.js → Register-C4Fk0ibc.js} +1 -1
  10. package/dist/rcs-web/assets/SessionDetail-Bd1YgozL.js +65 -0
  11. package/dist/rcs-web/assets/{SessionVisibilityBadge-DuslCmw6.js → SessionVisibilityBadge-BHKxlh8U.js} +1 -1
  12. package/dist/rcs-web/assets/{Setup-DyPAdgXS.js → Setup-DReCE0zx.js} +1 -1
  13. package/dist/rcs-web/assets/{ShareLanding-D9JzXvXa.js → ShareLanding-qE1U0WKZ.js} +1 -1
  14. package/dist/rcs-web/assets/{TeamCreate-Cad1VxMm.js → TeamCreate-BgwgZP4a.js} +1 -1
  15. package/dist/rcs-web/assets/{TeamDetail-Cm0jxf9Z.js → TeamDetail-BHCvnI2t.js} +2 -2
  16. package/dist/rcs-web/assets/{TeamList-BETVmpO1.js → TeamList-B7uC8lDV.js} +1 -1
  17. package/dist/rcs-web/assets/{TeamSettings-Bb9IKTLi.js → TeamSettings-DtgvrKEE.js} +1 -1
  18. package/dist/rcs-web/assets/{UserSearchInput-7Q9EFRPQ.js → UserSearchInput-dgxhGWfJ.js} +1 -1
  19. package/dist/rcs-web/assets/{UserSettings-B9kVG_IR.js → UserSettings-Zyjam23-.js} +1 -1
  20. package/dist/rcs-web/assets/{arc-DiEgUZn-.js → arc-DgC_wPAg.js} +1 -1
  21. package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-BFKqtyBC.js → architectureDiagram-3BPJPVTR-BnnCRJZs.js} +1 -1
  22. package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-CVuiguSe.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-CvpYdvcP.js} +1 -1
  23. package/dist/rcs-web/assets/{c4Diagram-AAUBKEIU-CPy7P1Av.js → c4Diagram-AAUBKEIU-DNK__-3d.js} +1 -1
  24. package/dist/rcs-web/assets/channel-DB6b62-p.js +1 -0
  25. package/dist/rcs-web/assets/{chunk-2J33WTMH-BUqofFnC.js → chunk-2J33WTMH-5JQBz2na.js} +1 -1
  26. package/dist/rcs-web/assets/{chunk-4BX2VUAB-C6aoBjPY.js → chunk-4BX2VUAB-YJh8d73x.js} +1 -1
  27. package/dist/rcs-web/assets/{chunk-55IACEB6-CTXtct1S.js → chunk-55IACEB6-U5c5GQZN.js} +1 -1
  28. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-CcAQhRBy.js → dist/rcs-web/assets/chunk-727SXJPM-ifGCid_3.js} +1 -1
  29. package/dist/rcs-web/assets/{chunk-AQP2D5EJ-CLbfo9u6.js → chunk-AQP2D5EJ-DxqPH2_Q.js} +1 -1
  30. package/dist/rcs-web/assets/{chunk-FMBD7UC4-A5sjn77P.js → chunk-FMBD7UC4-dDtjQRPo.js} +1 -1
  31. package/dist/rcs-web/assets/{chunk-ND2GUHAM-Whwn6TjZ.js → chunk-ND2GUHAM-0UF6vhhE.js} +1 -1
  32. package/dist/rcs-web/assets/{chunk-QZHKN3VN-CRl6OiWH.js → chunk-QZHKN3VN-CfZ4xcBz.js} +1 -1
  33. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DkXLqlKv.js +1 -0
  34. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DkXLqlKv.js +1 -0
  35. package/dist/rcs-web/assets/{code-block-IT6T5CEO-DNG0H7s_.js → code-block-IT6T5CEO-B4B0UrXo.js} +1 -1
  36. package/dist/rcs-web/assets/{copy-ClSInH6Y.js → copy-_OW0eGyp.js} +1 -1
  37. package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-Chx2WwaP.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-B19xQvnh.js} +1 -1
  38. package/dist/rcs-web/assets/{dagre-BM42HDAG-B_pHh3BU.js → dagre-BM42HDAG-5JJnjI1B.js} +1 -1
  39. package/dist/rcs-web/assets/{diagram-2AECGRRQ-BHaFKYHb.js → diagram-2AECGRRQ-BY2NR7vr.js} +1 -1
  40. package/dist/rcs-web/assets/{diagram-5GNKFQAL-C4jq41jo.js → diagram-5GNKFQAL-3zC3GraP.js} +1 -1
  41. package/dist/rcs-web/assets/{diagram-KO2AKTUF-vLZAAlSj.js → diagram-KO2AKTUF-T1Jt5zH3.js} +1 -1
  42. package/dist/rcs-web/assets/{diagram-LMA3HP47-CDsOOsrx.js → diagram-LMA3HP47-ehrkQG1e.js} +1 -1
  43. package/dist/rcs-web/assets/{diagram-OG6HWLK6-CDNVMpGm.js → diagram-OG6HWLK6-D8ZJlGs0.js} +1 -1
  44. package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-Uwz1AUAa.js → erDiagram-TEJ5UH35-Ckn1pY7G.js} +1 -1
  45. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-PZjyAvn1.js → flowDiagram-I6XJVG4X-C1xnAOfH.js} +1 -1
  46. package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Bw-HcaeD.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Dw8qOfCT.js} +1 -1
  47. package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-wQRnZZvR.js → gitGraphDiagram-PVQCEYII-Cg3La45a.js} +1 -1
  48. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-ZaqhXWsh.js → infoDiagram-5YYISTIA-CGH2aXpd.js} +1 -1
  49. package/dist/rcs-web/assets/{ishikawaDiagram-YF4QCWOH-BAwMsw7Q.js → ishikawaDiagram-YF4QCWOH-x89F9Igr.js} +1 -1
  50. package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-BN5PEEeN.js → journeyDiagram-JHISSGLW-Ckd_pKi0.js} +1 -1
  51. package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-a3XUx_Cb.js → kanban-definition-UN3LZRKU-D2dEXdru.js} +1 -1
  52. package/dist/rcs-web/assets/{linear-aDXDuqZd.js → linear-CexxJrg8.js} +1 -1
  53. package/dist/rcs-web/assets/main-DhbquBXW.css +1 -0
  54. package/dist/rcs-web/assets/main-L9iyf39T.js +260 -0
  55. package/dist/rcs-web/assets/{mermaid-VLURNSYL-CPzd5Xw0.js → mermaid-VLURNSYL-BomP37Br.js} +4 -4
  56. package/dist/rcs-web/assets/{mermaid.core-DAedMhfd.js → mermaid.core-BxkfDFm_.js} +5 -5
  57. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-DJN3pb0x.js → mindmap-definition-RKZ34NQL-HVsZx8Je.js} +1 -1
  58. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-Dt5PkY0b.js → pieDiagram-4H26LBE5-D0U9q74D.js} +1 -1
  59. package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-BlB9_lcZ.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-CWPBZMPj.js} +1 -1
  60. package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-C4HVySo4.js → requirementDiagram-4Y6WPE33-CiQbIN_P.js} +1 -1
  61. package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-D2iFqr51.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-Bw66fXM0.js} +1 -1
  62. package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CPnyhZSr.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-lv5WhGb6.js} +1 -1
  63. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-DjOLQSZq.js → stateDiagram-AJRCARHV-BLRRpX3g.js} +1 -1
  64. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-Drrtcjqv.js → stateDiagram-v2-BHNVJYJU-B-5gzDu6.js} +1 -1
  65. package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-DCP3r7hv.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-DO8oVMVA.js} +1 -1
  66. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-Hf1HIER0.js → vennDiagram-CIIHVFJN-D2RbeAHj.js} +1 -1
  67. package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-CWdNIYrR.js → wardleyDiagram-YWT4CUSO-D8D1cIXp.js} +1 -1
  68. package/{packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-BhEhhCTK.js → dist/rcs-web/assets/xychartDiagram-2RQKCTM6-Bzk5AxMb.js} +1 -1
  69. package/dist/rcs-web/index.html +2 -2
  70. package/package.json +1 -1
  71. package/packages/remote-control-server/src/__tests__/bridge-ownership.test.ts +514 -0
  72. package/packages/remote-control-server/src/__tests__/routes.test.ts +39 -2
  73. package/packages/remote-control-server/src/__tests__/ws-handler.test.ts +91 -0
  74. package/packages/remote-control-server/src/db/rcs-schema.sql +14 -0
  75. package/packages/remote-control-server/src/routes/v1/environments.ts +206 -71
  76. package/packages/remote-control-server/src/routes/web/sessions.ts +64 -3
  77. package/packages/remote-control-server/src/services/environment.ts +79 -1
  78. package/packages/remote-control-server/src/services/event-persistence.ts +109 -0
  79. package/packages/remote-control-server/src/services/transport.ts +42 -9
  80. package/packages/remote-control-server/src/store.ts +72 -0
  81. package/packages/remote-control-server/src/transport/client-payload.ts +14 -2
  82. package/packages/remote-control-server/src/transport/event-bus.ts +18 -6
  83. package/packages/remote-control-server/src/transport/ws-handler.ts +17 -1
  84. package/packages/remote-control-server/src/types/api.ts +2 -0
  85. package/packages/remote-control-server/src/types/messages.ts +10 -0
  86. package/packages/remote-control-server/web/dist/assets/{AdminPanel-Gc3BPu1_.js → AdminPanel-CbcZ7Vnr.js} +1 -1
  87. package/{dist/rcs-web/assets/Claim-EI1vEA1D.js → packages/remote-control-server/web/dist/assets/Claim-CN3D3Ku6.js} +1 -1
  88. package/{dist/rcs-web/assets/Dashboard-bYYO5HcG.js → packages/remote-control-server/web/dist/assets/Dashboard-BZGcSCFY.js} +2 -2
  89. package/{dist/rcs-web/assets/Join-DBS1b78K.js → packages/remote-control-server/web/dist/assets/Join-B_e3BKa3.js} +1 -1
  90. package/packages/remote-control-server/web/dist/assets/{Login-wdKYrifx.js → Login-u6CGGkoD.js} +1 -1
  91. package/packages/remote-control-server/web/dist/assets/{Register-DRD2kteD.js → Register-C4Fk0ibc.js} +1 -1
  92. package/packages/remote-control-server/web/dist/assets/SessionDetail-Bd1YgozL.js +65 -0
  93. package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-DuslCmw6.js → SessionVisibilityBadge-BHKxlh8U.js} +1 -1
  94. package/packages/remote-control-server/web/dist/assets/{Setup-DyPAdgXS.js → Setup-DReCE0zx.js} +1 -1
  95. package/packages/remote-control-server/web/dist/assets/{ShareLanding-D9JzXvXa.js → ShareLanding-qE1U0WKZ.js} +1 -1
  96. package/packages/remote-control-server/web/dist/assets/{TeamCreate-Cad1VxMm.js → TeamCreate-BgwgZP4a.js} +1 -1
  97. package/packages/remote-control-server/web/dist/assets/{TeamDetail-Cm0jxf9Z.js → TeamDetail-BHCvnI2t.js} +2 -2
  98. package/packages/remote-control-server/web/dist/assets/{TeamList-BETVmpO1.js → TeamList-B7uC8lDV.js} +1 -1
  99. package/packages/remote-control-server/web/dist/assets/{TeamSettings-Bb9IKTLi.js → TeamSettings-DtgvrKEE.js} +1 -1
  100. package/packages/remote-control-server/web/dist/assets/{UserSearchInput-7Q9EFRPQ.js → UserSearchInput-dgxhGWfJ.js} +1 -1
  101. package/packages/remote-control-server/web/dist/assets/{UserSettings-B9kVG_IR.js → UserSettings-Zyjam23-.js} +1 -1
  102. package/packages/remote-control-server/web/dist/assets/{arc-DiEgUZn-.js → arc-DgC_wPAg.js} +1 -1
  103. package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-BFKqtyBC.js → architectureDiagram-3BPJPVTR-BnnCRJZs.js} +1 -1
  104. package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-CVuiguSe.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-CvpYdvcP.js} +1 -1
  105. package/packages/remote-control-server/web/dist/assets/{c4Diagram-AAUBKEIU-CPy7P1Av.js → c4Diagram-AAUBKEIU-DNK__-3d.js} +1 -1
  106. package/packages/remote-control-server/web/dist/assets/channel-DB6b62-p.js +1 -0
  107. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-BUqofFnC.js → chunk-2J33WTMH-5JQBz2na.js} +1 -1
  108. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-C6aoBjPY.js → chunk-4BX2VUAB-YJh8d73x.js} +1 -1
  109. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-CTXtct1S.js → chunk-55IACEB6-U5c5GQZN.js} +1 -1
  110. package/{dist/rcs-web/assets/chunk-727SXJPM-CcAQhRBy.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-ifGCid_3.js} +1 -1
  111. package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-CLbfo9u6.js → chunk-AQP2D5EJ-DxqPH2_Q.js} +1 -1
  112. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-A5sjn77P.js → chunk-FMBD7UC4-dDtjQRPo.js} +1 -1
  113. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-Whwn6TjZ.js → chunk-ND2GUHAM-0UF6vhhE.js} +1 -1
  114. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-CRl6OiWH.js → chunk-QZHKN3VN-CfZ4xcBz.js} +1 -1
  115. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DkXLqlKv.js +1 -0
  116. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DkXLqlKv.js +1 -0
  117. package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-DNG0H7s_.js → code-block-IT6T5CEO-B4B0UrXo.js} +1 -1
  118. package/packages/remote-control-server/web/dist/assets/{copy-ClSInH6Y.js → copy-_OW0eGyp.js} +1 -1
  119. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-Chx2WwaP.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-B19xQvnh.js} +1 -1
  120. package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-B_pHh3BU.js → dagre-BM42HDAG-5JJnjI1B.js} +1 -1
  121. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-BHaFKYHb.js → diagram-2AECGRRQ-BY2NR7vr.js} +1 -1
  122. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-C4jq41jo.js → diagram-5GNKFQAL-3zC3GraP.js} +1 -1
  123. package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-vLZAAlSj.js → diagram-KO2AKTUF-T1Jt5zH3.js} +1 -1
  124. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-CDsOOsrx.js → diagram-LMA3HP47-ehrkQG1e.js} +1 -1
  125. package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-CDNVMpGm.js → diagram-OG6HWLK6-D8ZJlGs0.js} +1 -1
  126. package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-Uwz1AUAa.js → erDiagram-TEJ5UH35-Ckn1pY7G.js} +1 -1
  127. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-PZjyAvn1.js → flowDiagram-I6XJVG4X-C1xnAOfH.js} +1 -1
  128. package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Bw-HcaeD.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Dw8qOfCT.js} +1 -1
  129. package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-wQRnZZvR.js → gitGraphDiagram-PVQCEYII-Cg3La45a.js} +1 -1
  130. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-ZaqhXWsh.js → infoDiagram-5YYISTIA-CGH2aXpd.js} +1 -1
  131. package/packages/remote-control-server/web/dist/assets/{ishikawaDiagram-YF4QCWOH-BAwMsw7Q.js → ishikawaDiagram-YF4QCWOH-x89F9Igr.js} +1 -1
  132. package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-BN5PEEeN.js → journeyDiagram-JHISSGLW-Ckd_pKi0.js} +1 -1
  133. package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-a3XUx_Cb.js → kanban-definition-UN3LZRKU-D2dEXdru.js} +1 -1
  134. package/packages/remote-control-server/web/dist/assets/{linear-aDXDuqZd.js → linear-CexxJrg8.js} +1 -1
  135. package/packages/remote-control-server/web/dist/assets/main-DhbquBXW.css +1 -0
  136. package/packages/remote-control-server/web/dist/assets/main-L9iyf39T.js +260 -0
  137. package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-CPzd5Xw0.js → mermaid-VLURNSYL-BomP37Br.js} +4 -4
  138. package/packages/remote-control-server/web/dist/assets/{mermaid.core-DAedMhfd.js → mermaid.core-BxkfDFm_.js} +5 -5
  139. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-DJN3pb0x.js → mindmap-definition-RKZ34NQL-HVsZx8Je.js} +1 -1
  140. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-Dt5PkY0b.js → pieDiagram-4H26LBE5-D0U9q74D.js} +1 -1
  141. package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-BlB9_lcZ.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-CWPBZMPj.js} +1 -1
  142. package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-C4HVySo4.js → requirementDiagram-4Y6WPE33-CiQbIN_P.js} +1 -1
  143. package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-D2iFqr51.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-Bw66fXM0.js} +1 -1
  144. package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CPnyhZSr.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-lv5WhGb6.js} +1 -1
  145. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-DjOLQSZq.js → stateDiagram-AJRCARHV-BLRRpX3g.js} +1 -1
  146. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-Drrtcjqv.js → stateDiagram-v2-BHNVJYJU-B-5gzDu6.js} +1 -1
  147. package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-DCP3r7hv.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-DO8oVMVA.js} +1 -1
  148. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-Hf1HIER0.js → vennDiagram-CIIHVFJN-D2RbeAHj.js} +1 -1
  149. package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-CWdNIYrR.js → wardleyDiagram-YWT4CUSO-D8D1cIXp.js} +1 -1
  150. package/{dist/rcs-web/assets/xychartDiagram-2RQKCTM6-BhEhhCTK.js → packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-Bzk5AxMb.js} +1 -1
  151. package/packages/remote-control-server/web/dist/index.html +2 -2
  152. package/dist/rcs-web/assets/SessionDetail-JgtD489A.js +0 -55
  153. package/dist/rcs-web/assets/channel-D5Hz1fY8.js +0 -1
  154. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-C79YEyw1.js +0 -1
  155. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-C79YEyw1.js +0 -1
  156. package/dist/rcs-web/assets/main-Bd3CJlyx.css +0 -1
  157. package/dist/rcs-web/assets/main-Bfbs-lwB.js +0 -253
  158. package/packages/remote-control-server/web/dist/assets/SessionDetail-JgtD489A.js +0 -55
  159. package/packages/remote-control-server/web/dist/assets/channel-D5Hz1fY8.js +0 -1
  160. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-C79YEyw1.js +0 -1
  161. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-C79YEyw1.js +0 -1
  162. package/packages/remote-control-server/web/dist/assets/main-Bd3CJlyx.css +0 -1
  163. package/packages/remote-control-server/web/dist/assets/main-Bfbs-lwB.js +0 -253
@@ -105,6 +105,19 @@ CREATE TABLE IF NOT EXISTS sessions (
105
105
  updated_at TEXT NOT NULL
106
106
  );
107
107
 
108
+ -- Durable event log — the in-memory EventBus only retains a bounded window
109
+ -- (5000 events) and is lost on restart. Non-transient events are mirrored
110
+ -- here so history survives restarts and long sessions.
111
+ CREATE TABLE IF NOT EXISTS session_events (
112
+ id TEXT PRIMARY KEY,
113
+ session_id TEXT NOT NULL,
114
+ seq_num INTEGER NOT NULL,
115
+ type TEXT NOT NULL,
116
+ payload TEXT NOT NULL,
117
+ direction TEXT NOT NULL,
118
+ created_at INTEGER NOT NULL
119
+ );
120
+
108
121
  -- Performance indexes
109
122
  CREATE INDEX IF NOT EXISTS idx_session_owners_owner ON session_owners(owner_type, owner_id);
110
123
  CREATE INDEX IF NOT EXISTS idx_session_owners_session ON session_owners(session_id);
@@ -119,3 +132,4 @@ CREATE INDEX IF NOT EXISTS idx_session_tokens_user ON session_tokens(user_id);
119
132
  CREATE INDEX IF NOT EXISTS idx_environments_team ON environments(team_id);
120
133
  CREATE INDEX IF NOT EXISTS idx_environments_owner_user ON environments(owner_user_id);
121
134
  CREATE INDEX IF NOT EXISTS idx_environments_claim_token ON environments(claim_token);
135
+ CREATE INDEX IF NOT EXISTS idx_session_events_session ON session_events(session_id);
@@ -1 +1 @@
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};
1
+ import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{ai as c,aj as o,I as m,ad as s,a7 as l,x as u}from"./main-L9iyf39T.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){c();const[a,i]=d.useState([]),{myTeams:r,isLoading:x}=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,")"]}),x?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};
@@ -1 +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
+ import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{E as d}from"./main-L9iyf39T.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{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";/**
1
+ import{j as e,e as o}from"./vendor-DE_-CLIE.js";import{a4 as O,a3 as _,aj as T,ah as E,x as P,ai as L,ad as a,a7 as A,q as $,s as H,e as W,r as V,d as F,aa as q,F as J,I as R,J as U,H as Z}from"./main-L9iyf39T.js";import{g as D}from"./workerType-Bd-zteMi.js";import{S as z,D as G,a as K,c as Q,d as X,b as Y}from"./SessionVisibilityBadge-BHKxlh8U.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}=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};
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 J(s);u(C)}catch(s){h(s instanceof Error?s.message:a("dialog.createFailed"))}finally{w(!1)}};return e.jsx(G,{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(F,{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,I=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",I?"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")}),I&&e.jsx(F,{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{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
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ah as v,ad as t}from"./main-L9iyf39T.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function E({onSuccess:h,onInvalidInvite:l}){const{join:b}=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 b(u,d,o),h()}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{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
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ah as f,ad as t}from"./main-L9iyf39T.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{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};
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ah as y,ad as t}from"./main-L9iyf39T.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,65 @@
1
+ var rt=Object.defineProperty;var at=(s,t,r)=>t in s?rt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r;var E=(s,t,r)=>at(s,typeof t!="symbol"?t+"":t,r);import{e as u,j as e}from"./vendor-DE_-CLIE.js";import{a4 as I,N as ot,$ as it,a8 as ue,_ as O,Q as lt,x as Re,g as je,a7 as Ae,L as Ie,z as ct,w as dt,a6 as A,a3 as Y,d as $e,ae as ke,V as ut,G as mt,Z as xt,ai as qe,ad as w,A as pt,a9 as ht,af as ft,a5 as yt,H as gt,W as bt,y as Pe,P as jt,c as kt,C as wt,R as we,K as Nt,ab as vt,D as _t,a as Ct,q as De,s as Ue,v as St,f as Oe,e as Fe,r as Le,M as Mt}from"./main-L9iyf39T.js";import{g as Et}from"./workerType-Bd-zteMi.js";import{D as He,a as ze,c as Ve,d as Be,b as Tt,S as Rt}from"./SessionVisibilityBadge-BHKxlh8U.js";import{U as At}from"./UserSearchInput-dgxhGWfJ.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 It=[["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"}]],$t=I("activity",It);/**
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 qt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Pt=I("chevron-right",qt);/**
12
+ * @license lucide-react v0.555.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Dt=[["path",{d:"M12 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"}]],We=I("cpu",Dt);/**
17
+ * @license lucide-react v0.555.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Ut=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ot=I("external-link",Ut);/**
22
+ * @license lucide-react v0.555.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Ft=[["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"}]],Lt=I("hash",Ft);/**
27
+ * @license lucide-react v0.555.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Ht=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],zt=I("info",Ht);/**
32
+ * @license lucide-react v0.555.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Vt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],Bt=I("message-square-text",Vt);/**
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 Wt=[["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"}]],Qt=I("play",Wt);/**
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 Kt=[["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"}]],Yt=I("server-cog",Kt);/**
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 Gt=[["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"}]],Jt=I("share-2",Gt);/**
52
+ * @license lucide-react v0.555.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const Xt=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Zt=I("shield-check",Xt);/**
57
+ * @license lucide-react v0.555.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const es=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ts=I("triangle-alert",es);function Qe(){return{tasks:{}}}const Ne=3e4;function ne(s){const t=s.trim();if(!t)return"agent";const r=t.split(/\s+/).slice(0,2).join(" ");return r.length>40?r.slice(0,40)+"…":r}function ss(s,t){var d,x,y,m,p,g,N,a,o,h,b,k;const r=t.subtype;if(r!=="task_started"&&r!=="task_progress"&&r!=="task_notification")return s;const n=t.task_id;if(!n)return s;const l=Date.now(),c=s.tasks[n];if(r==="task_started"){if(c)return{tasks:{...s.tasks,[n]:{...c,description:t.description??c.description,name:ne(t.description??c.description),taskType:t.task_type??c.taskType,workflowName:t.workflow_name??c.workflowName,prompt:t.prompt??c.prompt,toolUseId:t.tool_use_id??c.toolUseId,status:"running",startTime:l,evictAfter:void 0}}};const j=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:ne(j),description:j,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:l}}}}if(r==="task_progress"){if(!c){const j=t.description??"";return{tasks:{...s.tasks,[n]:{taskId:n,name:ne(j),description:j,toolUseId:t.tool_use_id,status:"running",startTime:l,tokenCount:(d=t.usage)==null?void 0:d.total_tokens,toolUseCount:(x=t.usage)==null?void 0:x.tool_uses,durationMs:(y=t.usage)==null?void 0:y.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[n]:{...c,description:t.description??c.description,tokenCount:((m=t.usage)==null?void 0:m.total_tokens)??c.tokenCount,toolUseCount:((p=t.usage)==null?void 0:p.tool_uses)??c.toolUseCount,durationMs:((g=t.usage)==null?void 0:g.duration_ms)??c.durationMs,lastToolName:t.last_tool_name??c.lastToolName,summary:t.summary??c.summary}}}}return c?{tasks:{...s.tasks,[n]:{...c,status:t.status??"completed",endTime:l,finalSummary:t.summary??c.finalSummary,outputFile:t.output_file??c.outputFile,tokenCount:((h=t.usage)==null?void 0:h.total_tokens)??c.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??c.toolUseCount,durationMs:((k=t.usage)==null?void 0:k.duration_ms)??c.durationMs,evictAfter:l+Ne}}}:{tasks:{...s.tasks,[n]:{taskId:n,name:ne(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:l,endTime:l,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(a=t.usage)==null?void 0:a.tool_uses,durationMs:(o=t.usage)==null?void 0:o.duration_ms,evictAfter:l+Ne}}}}function ns(s,t=Date.now()){return Object.values(s.tasks).filter(r=>r.evictAfter===void 0||r.evictAfter>t).sort((r,n)=>r.startTime-n.startTime)}class rs{constructor(){E(this,"listeners",new Set);E(this,"eventSource",null);E(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const r=`/web/sessions/${t}/events`,n=new EventSource(r,{withCredentials:!0});this.eventSource=n,n.addEventListener("message",l=>{try{const c=JSON.parse(l.data);if(c.seqNum!==void 0&&c.seqNum<=this._lastSeqNum)return;c.seqNum!==void 0&&(this._lastSeqNum=c.seqNum);for(const d of this.listeners)d(c)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const me=new rs;function ve(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(r=>r.type==="text"&&typeof r.text=="string").map(r=>r.text).join("")}return""}function _e(s,t){for(let r=s.length-1;r>=0;r--){const n=s[r];if(n&&n.type==="tool_call"&&n.toolCall.id===t)return r}return-1}const xe="streaming-";function as(s){const t=s.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const r=[];for(const n of t.content)if((n==null?void 0:n.type)==="thinking"){const l=typeof n.thinking=="string"&&n.thinking||typeof n.text=="string"&&n.text||"";l&&r.push(l)}return r.join("")}function Ce(s){return s.filter(t=>typeof t.subject=="string"&&t.subject).map(t=>({content:t.subject,priority:"medium",status:t.status==="completed"?"completed":t.status==="in_progress"?"in_progress":"pending"}))}class os{constructor(t,r,n){E(this,"sessionId");E(this,"setEntries");E(this,"unsub",null);E(this,"onStatusChange");E(this,"onError");E(this,"onPermissionRequest");E(this,"onModelsStateChange");E(this,"onSubagentUpdate");E(this,"onControlResponse");E(this,"onPermissionModeChange");E(this,"onUsageChange");E(this,"onElicitationRequest");E(this,"subagentState",Qe());E(this,"seenUuids",new Set);E(this,"seenToolCallIds",new Set);E(this,"pendingControlRequests",new Map);this.sessionId=t,this.setEntries=r,this.onStatusChange=n==null?void 0:n.onStatusChange,this.onError=n==null?void 0:n.onError,this.onPermissionRequest=n==null?void 0:n.onPermissionRequest,this.onModelsStateChange=n==null?void 0:n.onModelsStateChange,this.onSubagentUpdate=n==null?void 0:n.onSubagentUpdate,this.onControlResponse=n==null?void 0:n.onControlResponse,this.onPermissionModeChange=n==null?void 0:n.onPermissionModeChange,this.onUsageChange=n==null?void 0:n.onUsageChange,this.onElicitationRequest=n==null?void 0:n.onElicitationRequest}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var y,m;const{events:t}=await ot(this.sessionId);if(!t||t.length===0)return;const r=[];let n=null;const l=()=>{n&&(r.push(n),n=null)};for(const p of t){const g=p.payload||{},N=g.uuid;if(typeof N=="string"&&N&&this.seenUuids.add(N),p.type==="tool_use"){const a=g.tool_call_id;typeof a=="string"&&a&&this.seenToolCallIds.add(a)}if(p.type==="user"){if(p.direction==="inbound")continue;l();const a=ve(g);a&&r.push({type:"user_message",id:p.id||`hist-user-${r.length}`,content:a})}else if(p.type==="assistant"){l();const a=ve(g),o=[],h=g.message;if(h&&typeof h=="object"&&Array.isArray(h.content)){for(const b of h.content)if(b.type==="tool_use"){const k=b.id;k&&this.seenToolCallIds.add(k),o.push({type:"tool_call",toolCall:{id:k||`hist-tool-${r.length}`,title:b.name||"tool",status:"complete",rawInput:b.input||{}}})}}if(a||o.length>0){n={type:"assistant_message",id:p.id||`hist-asst-${r.length}`,chunks:a?[{type:"message",text:a}]:[]},r.push(n);for(const b of o)r.push(b);n=null}}else if(p.type==="tool_use"){const a=g,o={type:"tool_call",toolCall:{id:a.tool_call_id||`hist-tool-${r.length}`,title:a.tool_name||"tool",status:"complete",rawInput:a.tool_input||{}}};r.push(o)}else if(p.type==="tool_result"){const a=g,o=_e(r,a.tool_call_id||"");if(o>=0){const h=r[o];r[o]={type:"tool_call",toolCall:{...h.toolCall,rawOutput:{output:a.content||a.output||""}}}}}}l();let c=null;for(const p of t){if(p.type!=="task_state")continue;const g=p.payload||{};Array.isArray(g.tasks)&&(c=g.tasks)}if(c&&c.length>0){const p=Ce(c);p.length>0&&r.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:p})}this.setEntries(r);let d=null,x=null;for(const p of t){const g=p.payload||{};if(p.type==="models_state"){const N=g.raw,a=N&&typeof N=="object"?N.models_state:g.models_state;a&&Array.isArray(a.availableModels)&&typeof a.currentModelId=="string"&&(d=a)}else if(p.type==="result"||p.type==="result_success"){const N=g.usage,a=typeof g.total_cost_usd=="number"?g.total_cost_usd:null;(N||a!==null)&&(x={inputTokens:((N==null?void 0:N.input_tokens)??0)+((N==null?void 0:N.cache_read_input_tokens)??0)+((N==null?void 0:N.cache_creation_input_tokens)??0),outputTokens:(N==null?void 0:N.output_tokens)??0,totalCostUsd:a})}}d&&((y=this.onModelsStateChange)==null||y.call(this,d)),x&&((m=this.onUsageChange)==null||m.call(this,x))}connectSSE(){me.connect(this.sessionId),this.unsub=me.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),me.disconnect()}handleEvent(t){var c,d,x,y,m,p,g,N;const r=t.type,n=t.payload||{},l=JSON.stringify(t);if(!/Remote Control connecting/i.test(l))switch(r){case"assistant":{const a=n.uuid;if(typeof a=="string"&&a){if(this.seenUuids.has(a))break;this.seenUuids.add(a)}const o=typeof n.content=="string"?n.content:"",h=as(n);this.setEntries(k=>{const j=k[k.length-1];if((j==null?void 0:j.type)==="assistant_message"&&j.id.startsWith(xe))return[...k.slice(0,-1),{...j,id:`assistant-${Date.now()}`,chunks:[...h?[{type:"thought",text:h}]:[],{type:"message",text:o}]}];if((j==null?void 0:j.type)==="assistant_message"){const _=j.chunks[j.chunks.length-1];return(_==null?void 0:_.type)==="message"?[...k.slice(0,-1),{...j,chunks:[...j.chunks.slice(0,-1),{type:"message",text:_.text+o}]}]:[...k.slice(0,-1),{...j,chunks:[...j.chunks,{type:"message",text:o}]}]}if(o&&o.trim()||h){const _={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...h?[{type:"thought",text:h}]:[],...o?[{type:"message",text:o}]:[]]};return[...k,_]}return k});const b=n.message;if(b&&typeof b=="object"&&Array.isArray(b.content)){const k=b.content.filter(j=>j.type==="tool_use");for(const j of k){const _=j.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(_))continue;this.seenToolCallIds.add(_);const M={id:_,title:j.name||"tool",status:"running",rawInput:j.input||{}};this.setEntries(T=>[...T,{type:"tool_call",toolCall:M}])}}break}case"tool_use":{const a=n,o=a.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(o))break;this.seenToolCallIds.add(o);const h={id:o,title:a.tool_name||"tool",status:"running",rawInput:a.tool_input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:h}]);break}case"tool_result":{const a=n,o=a.tool_call_id||"";this.setEntries(h=>{const b=_e(h,o);if(b<0)return h;const k=h[b];return h.map((j,_)=>_===b?{type:"tool_call",toolCall:{...k.toolCall,status:"complete",rawOutput:{output:a.content||a.output||""}}}:j)});break}case"control_request":case"permission_request":{const a=n.request;if(a&&a.subtype==="can_use_tool"){const o=n.request_id||"",h=a.tool_name||"unknown",b=a.input||a.tool_input||{},k=a.description||"",j=Array.isArray(a.permission_suggestions)?a.permission_suggestions:[];this.setEntries(_=>{const M=[..._].reverse().findIndex(T=>T.type==="tool_call");if(M>=0){const T=_.length-1-M,$=_[T];if($.toolCall.status==="running")return _.map((z,q)=>q===T?{type:"tool_call",toolCall:{...$.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:o,options:[]}}}:z)}return _}),(c=this.onPermissionRequest)==null||c.call(this,{requestId:o,toolName:h,toolInput:b,description:k,suggestions:j})}else a&&a.subtype==="elicitation"&&((d=this.onElicitationRequest)==null||d.call(this,{requestId:n.request_id||"",serverName:a.mcp_server_name||"",message:a.message||"",mode:a.mode==="url"?"url":"form",url:typeof a.url=="string"?a.url:void 0,requestedSchema:a.requested_schema||void 0}));break}case"session_status":{typeof n.status=="string"&&((x=this.onStatusChange)==null||x.call(this,n.status));break}case"error":{const a=String(n.message||n.content||"Unknown error");(y=this.onError)==null||y.call(this,a);break}case"models_state":{const a=n.raw,o=typeof a=="object"&&a!==null?a.models_state:n.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&((m=this.onModelsStateChange)==null||m.call(this,o));break}case"system":{const a=n.raw,o=a&&typeof a=="object"?a:n,h=typeof o.subtype=="string"?o.subtype:void 0;if(h==="task_started"||h==="task_progress"||h==="task_notification"){const k={subtype:h,task_id:typeof o.task_id=="string"?o.task_id:void 0,tool_use_id:typeof o.tool_use_id=="string"?o.tool_use_id:void 0,description:typeof o.description=="string"?o.description:void 0,task_type:typeof o.task_type=="string"?o.task_type:void 0,workflow_name:typeof o.workflow_name=="string"?o.workflow_name:void 0,prompt:typeof o.prompt=="string"?o.prompt:void 0,usage:o.usage&&typeof o.usage=="object"?o.usage:void 0,last_tool_name:typeof o.last_tool_name=="string"?o.last_tool_name:void 0,summary:typeof o.summary=="string"?o.summary:void 0,status:o.status==="completed"||o.status==="failed"||o.status==="stopped"?o.status:void 0,output_file:typeof o.output_file=="string"?o.output_file:void 0};this.subagentState=ss(this.subagentState,k)}const b=typeof o.permissionMode=="string"?o.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;b&&((p=this.onPermissionModeChange)==null||p.call(this,b));break}case"control_response":{const a=n.response;if(a&&typeof a=="object"){const o=typeof a.request_id=="string"?a.request_id:"",h=typeof a.subtype=="string"?a.subtype:"";if(o){(g=this.onControlResponse)==null||g.call(this,{subtype:h,requestId:o,error:typeof a.error=="string"?a.error:void 0});const b=this.pendingControlRequests.get(o);b&&(this.pendingControlRequests.delete(o),b(h==="success"&&a.response&&typeof a.response=="object"?a.response:null))}}break}case"stream_event":{const a=n.event;if(!a||typeof a.type!="string")break;if(a.type==="content_block_delta"){const o=a.delta;if(!o||typeof o.type!="string")break;const h=o.type==="text_delta"?"message":o.type==="thinking_delta"?"thought":null;if(!h)break;const b=o.text??o.thinking;if(typeof b!="string"||!b)break;this.appendStreamingDelta(h,b)}break}case"partial_assistant":{const a=typeof n.content=="string"?n.content:"";a&&this.appendStreamingDelta("message",a);break}case"result":case"result_success":{const a=n.usage,o=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(a||o!==null){const h=((a==null?void 0:a.input_tokens)??0)+((a==null?void 0:a.cache_read_input_tokens)??0)+((a==null?void 0:a.cache_creation_input_tokens)??0);(N=this.onUsageChange)==null||N.call(this,{inputTokens:h,outputTokens:(a==null?void 0:a.output_tokens)??0,totalCostUsd:o})}break}case"task_state":{const a=Array.isArray(n.tasks)?n.tasks:[];if(a.length===0)break;const o=Ce(a);if(o.length===0)break;this.setEntries(h=>[...h.filter(k=>k.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:o}]);break}}}appendStreamingDelta(t,r){this.setEntries(n=>{const l=n[n.length-1];if((l==null?void 0:l.type)==="assistant_message"&&l.id.startsWith(xe)){const d=l.chunks[l.chunks.length-1];return(d==null?void 0:d.type)===t?[...n.slice(0,-1),{...l,chunks:[...l.chunks.slice(0,-1),{type:t,text:d.text+r}]}]:[...n.slice(0,-1),{...l,chunks:[...l.chunks,{type:t,text:r}]}]}const c={type:"assistant_message",id:`${xe}${Date.now()}`,chunks:[{type:t,text:r}]};return[...n,c]})}async sendMessage(t,r,n){const l=r&&r.length>0,c=n&&n.length>0;if(!t.trim()&&!l&&!c)return;const d={type:"user_message",id:`user-${Date.now()}`,content:t,images:l?r:void 0,attachments:c?n:void 0};this.setEntries(m=>[...m,d]);const x=[];if(t&&x.push({type:"text",text:t}),l)for(const m of r)x.push({type:"image",source:{type:"base64",media_type:m.mimeType,data:m.data}});if(c){for(const m of n)if(m.kind==="text"||m.kind==="table"){const p=`📎 ${m.name}${m.size!=null?` (${is(m.size)})`:""}`,g=m.textContent||"(空文件)";x.push({type:"text",text:`${p}
62
+ \`\`\`
63
+ ${g}
64
+ \`\`\``})}else if(m.kind==="directory"){const p=`📁 目录: ${m.name}${m.files!=null?` (${m.files.length} 个文件)`:""}`,g=m.textContent||"(空目录)";x.push({type:"text",text:`${p}
65
+ ${g}`})}}const y=x.length===1&&x[0].type==="text"?x[0].text||t:x.length>0?x:t;await it(this.sessionId,{type:"user",uuid:ue(),content:t,message:{content:y}})}async respondPermission(t,r,n){await O(this.sessionId,{type:"permission_response",approved:r,request_id:t,...n}),this.setEntries(l=>l.map(c=>{var d;return c.type!=="tool_call"||((d=c.toolCall.permissionRequest)==null?void 0:d.requestId)!==t?c:{type:"tool_call",toolCall:{...c.toolCall,status:r?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(r=>r.type!=="tool_call"||r.toolCall.status!=="running"&&r.toolCall.status!=="waiting_for_confirmation"?r:{type:"tool_call",toolCall:{...r.toolCall,status:"canceled",permissionRequest:void 0}})),await lt(this.sessionId)}async setPermissionMode(t){const r=ue();return await O(this.sessionId,{type:"control_request",request_id:r,request:{subtype:"set_permission_mode",mode:t}}),r}async searchFiles(t,r=20){const n=ue(),l=new Promise(d=>{this.pendingControlRequests.set(n,d)});await O(this.sessionId,{type:"control_request",request_id:n,request:{subtype:"file_search",query:t,limit:r}});const c=setTimeout(()=>{const d=this.pendingControlRequests.get(n);d&&(this.pendingControlRequests.delete(n),d(null))},8e3);try{const d=await l;if(!d||!Array.isArray(d.suggestions))return[];const x=[];for(const y of d.suggestions)y&&typeof y=="object"&&typeof y.path=="string"&&x.push(y.path);return x}finally{clearTimeout(c)}}async respondElicitation(t,r,n){await O(this.sessionId,{type:"permission_response",approved:r==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:r,...n?{content:n}:{}}}})}}function is(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function ls(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function cs(s){return s?Date.now()-s<6e4:!1}function ds({onClose:s,session:t,liveStatus:r,pendingPermissions:n,onInterrupt:l,onDelete:c}){const[d,x]=u.useState(!1),y=async()=>{await navigator.clipboard.writeText(t.id),x(!0),setTimeout(()=>x(!1),1500)},m=n.length,p=t.worker,g=t.work_item,N=t.environment;return e.jsx(He,{open:!0,onOpenChange:a=>{a||s()},children:e.jsxs(ze,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(Ve,{children:e.jsx(Be,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx($t,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{status:r||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:p&&(cs(p.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[p&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ls(p.last_heartbeat_at)})]}),N&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(We,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:N.machine_name||N.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Ae(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),m>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[m," permission request",m>1?"s":""," awaiting your approval"]}):e.jsx("p",{className:"text-xs text-text-muted",children:"No pending actions"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Yt,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:l,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),e.jsxs("button",{onClick:c,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(ct,{className:"mr-1 inline h-3 w-3"}),"Delete"]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Lt,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:y,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:d?"✓":"⧉"})]})]}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Spawn mode"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:g.spawn_mode??"default"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Work state"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:g.state})]})]}),t.source&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:t.source})]}),N&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:N.worker_type})]})]})]})]})]})})}const Se="rcs:subagent-panel:collapsed";function us(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const r=Math.floor(t/60),n=t%60;if(r<60)return n?`${r}m${n}s`:`${r}m`;const l=Math.floor(r/60),c=r%60;return c?`${l}h${c}m`:`${l}h`}function ms(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function xs({status:s}){return s==="running"?e.jsx(Ie,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(Qt,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(dt,{className:"h-3 w-3 text-status-error"}):null}function ps({task:s}){const t=s.status==="running",r=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,n=ms(s.tokenCount),l=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",c=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(xs,{status:s.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:us(r)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:c}),(n||l||s.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[n&&e.jsxs("span",{children:["↕ ",n," tok"]}),l&&e.jsxs("span",{children:["· ",l]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function hs({state:s}){const[t,r]=u.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Se)==="1"}catch{return!1}}),n=()=>{r(y=>{const m=!y;try{window.localStorage.setItem(Se,m?"1":"0")}catch{}return m})},[,l]=u.useState(0);u.useEffect(()=>{const y=Object.values(s.tasks).some(g=>g.status==="running"),m=Object.values(s.tasks).some(g=>g.status!=="running"&&g.evictAfter!==void 0);if(!y&&!m)return;const p=setInterval(()=>{l(g=>g+1)},1e3);return()=>clearInterval(p)},[s]);const c=ns(s);if(c.length===0)return null;const d=c.filter(y=>y.status==="running").length,x=d>0?`${d} running`:`${c.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:n,"aria-expanded":!t,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Pt,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:x})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:c.map(y=>e.jsx(ps,{task:y},y.taskId))})]})})}function Me(s,t){var l;const r=(l=t==null?void 0:t.find(c=>c.type==="addRules"||c.type==="replaceRules"))==null?void 0:l.rules,n=r==null?void 0:r[0];return n!=null&&n.ruleContent?`${n.toolName}(${n.ruleContent})`:n!=null&&n.toolName?n.toolName:s}function fs({requestId:s,toolName:t,toolInput:r,description:n,suggestions:l,onApprove:c,onApproveAlways:d,onReject:x}){const y=typeof r=="string"?r:JSON.stringify(r,null,2),m=Array.isArray(l)&&l.length>0;return e.jsxs("div",{className:"rounded-xl border border-warning-border/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-warning-border/15 text-warning-text",children:e.jsx(ts,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),n&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:A(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:A(t)}),t!=="AskUserQuestion"&&e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:ke(y,500)}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:c,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),m&&d&&e.jsxs("button",{onClick:d,className:"flex items-center gap-1.5 rounded-lg border border-brand/40 bg-brand/10 px-4 py-2 text-sm font-medium text-brand hover:bg-brand/20 transition-colors",title:`允许并记住规则:${Me(t,l)}`,children:[e.jsx(Zt,{className:"h-3.5 w-3.5"}),"Always allow ",ke(Me(t,l),40)]}),e.jsx("button",{onClick:x,className:"rounded-lg bg-status-error/20 px-4 py-2 text-sm font-medium text-status-error hover:bg-status-error/30 transition-colors",children:"Reject"})]})]})}function ys({questions:s,description:t,onSubmit:r,onSkip:n}){const[l,c]=u.useState({}),[d,x]=u.useState({}),[y,m]=u.useState(0),p=(o,h,b)=>{if(b){const k=l[o]||[],j=k.includes(h)?k.filter(_=>_!==h):[...k,h];c({...l,[o]:j})}else c({...l,[o]:h})},g=o=>{var b;const h=(b=d[o])==null?void 0:b.trim();h&&(c({...l,[o]:h}),x({...d,[o]:""}))},N=()=>{var h,b;const o={};for(const[k,j]of Object.entries(l)){const _=s[parseInt(k,10)];_&&(typeof j=="number"?o[k]=((b=(h=_.options)==null?void 0:h[j])==null?void 0:b.label)||String(j):Array.isArray(j)?o[k]=j.map(M=>{var T,$;return(($=(T=_.options)==null?void 0:T[M])==null?void 0:$.label)||String(M)}):o[k]=j)}r(o)};if(s.length<=1){const o=s[0]||{question:t,options:[],multiSelect:!1},h=o.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:A(t||o.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(o.options||[]).map((b,k)=>{const j=h?(l[0]||[]).includes(k):l[0]===k;return e.jsxs("button",{onClick:()=>p(0,k,h),className:Y("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",j?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:A(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(b.description)})]},k)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:d[0]||"",onChange:b=>x({...d,0:b.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:b=>b.key==="Enter"&&g(0)}),e.jsx("button",{onClick:()=>g(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:n,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const a=s[y];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:A(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((o,h)=>e.jsx("button",{onClick:()=>m(h),className:Y("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",y===h?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:o.header||`Q${h+1}`},h))}),a&&e.jsx(gs,{question:a,qIdx:y,answers:l,otherTexts:d,onSelect:p,onOtherTextChange:(o,h)=>x({...d,[o]:h}),onOtherSubmit:g}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[y+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:n,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function gs({question:s,qIdx:t,answers:r,otherTexts:n,onSelect:l,onOtherTextChange:c,onOtherSubmit:d}){const x=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:A(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((y,m)=>{const p=x?(r[t]||[]).includes(m):r[t]===m;return e.jsxs("button",{onClick:()=>l(t,m,x),className:Y("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",p?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:A(y.label)}),y.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:A(y.description)})]},m)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:y=>c(t,y.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:y=>y.key==="Enter"&&d(t)}),e.jsx("button",{onClick:()=>d(t),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function bs({planContent:s,description:t,onSubmit:r}){const[n,l]=u.useState(null),[c,d]=u.useState(""),x=!s||!s.trim(),y=()=>{n&&r(n,n==="no"?c:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx($e,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:x?"Exit plan mode?":"Ready to code?"})]}),!x&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:js(s)}}),e.jsx("div",{className:"space-y-2",children:x?e.jsxs(e.Fragment,{children:[e.jsx(K,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes"}),e.jsx(K,{selected:n==="no",onClick:()=>l("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{selected:n==="yes-accept-edits",onClick:()=>l("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(K,{selected:n==="yes-default",onClick:()=>l("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(K,{selected:n==="no",onClick:()=>l("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),n==="no"&&e.jsx("textarea",{value:c,onChange:m=>d(m.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:y,disabled:!n,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function K({selected:s,onClick:t,label:r,desc:n}){return e.jsxs("button",{onClick:t,className:Y("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:Y("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:r})]}),n&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:n})]})}function js(s){let t=A(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(r,n,l)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${l.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function ks({request:s,onSubmit:t}){const r=ws(s.requestedSchema),n=Ns(s.requestedSchema),[l,c]=u.useState({}),d=r.length===0||n.every(x=>(l[x]??"").trim()!=="");return s.mode==="url"&&s.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Ee,{serverName:s.serverName,message:s.message}),e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 flex w-full items-center justify-between rounded-lg border border-border bg-surface-2 px-4 py-2.5 text-sm text-brand hover:bg-brand/10 transition-colors",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:s.url}),e.jsx(Ot,{className:"ml-2 h-4 w-4 flex-shrink-0"})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:()=>t("accept"),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"完成"}),e.jsx("button",{onClick:()=>t("cancel"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"取消"})]})]}):e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Ee,{serverName:s.serverName,message:s.message}),r.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:r.map(({name:x,prop:y})=>e.jsxs("label",{className:"block",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-medium text-text-primary",children:x}),n.includes(x)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:"必填"})]}),y.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:A(y.description)}),e.jsx("input",{type:y.type==="number"?"number":"text",value:l[x]??"",onChange:m=>c(p=>({...p,[x]:m.target.value})),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]},x))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const x={};for(const{name:y,prop:m}of r){const p=(l[y]??"").trim();p&&(x[y]=m.type==="number"?Number(p):p)}t("accept",x)},disabled:!d,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"提交"}),e.jsx("button",{onClick:()=>t("decline"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"拒绝"})]})]})}function Ee({serverName:s,message:t}){return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(Bt,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-sm font-semibold text-text-primary",children:["MCP 请求输入 ",e.jsx("span",{className:"font-mono text-xs text-text-muted",children:A(s)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:A(t)})]})}function ws(s){const t=s==null?void 0:s.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,r])=>r&&typeof r=="object").map(([r,n])=>({name:r,prop:n}))}function Ns(s){const t=s==null?void 0:s.required;return Array.isArray(t)?t.filter(r=>typeof r=="string"):[]}function vs(s){const[t,r]=u.useState([]),[n,l]=u.useState(!0),[c,d]=u.useState(null),x=u.useCallback(async()=>{l(!0),d(null);try{const p=await ut(s);r(p)}catch(p){d(p instanceof Error?p.message:"Failed to load shares")}finally{l(!1)}},[s]);u.useEffect(()=>{x()},[x]);const y=u.useCallback(async p=>{d(null);try{const g=await mt(s,p);return await x(),g}catch(g){throw d(g instanceof Error?g.message:"Failed to create share"),g}},[s,x]),m=u.useCallback(async p=>{d(null);try{await xt(s,p),await x()}catch(g){throw d(g instanceof Error?g.message:"Failed to revoke share"),g}},[s,x]);return{shares:t,isLoading:n,error:c,createShare:y,revokeShare:m,refresh:x}}function _s({open:s,onClose:t,sessionId:r,sessionTitle:n}){qe();const{shares:l,isLoading:c,error:d,createShare:x,revokeShare:y}=vs(r),[m,p]=u.useState("user"),[g,N]=u.useState(""),[a,o]=u.useState(""),[h,b]=u.useState("read"),[k,j]=u.useState(""),[_,M]=u.useState(!1),[T,$]=u.useState(null),[z,q]=u.useState(""),[ae,P]=u.useState(!1),[G,F]=u.useState(!1);u.useEffect(()=>{s&&(p("user"),N(""),o(""),b("read"),j(""),M(!1),$(null),q(""),P(!1),F(!1))},[s]);const B=async()=>{M(!0),q(""),$(null);try{const C={grantedTo:m==="user"?{userId:g.trim()}:{teamId:a.trim()},permission:h};k.trim()&&(C.expiresAt=k.trim());const X=await x(C);$(`${window.location.origin}/code/s/${X.shareToken}`)}catch(C){q(C instanceof Error?C.message:"Failed to create share")}finally{M(!1)}},J=async C=>{try{await y(C)}catch{}},W=async()=>{if(!T)return;F(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),P(!0),setTimeout(()=>P(!1),2e3);return}}catch{}const C=document.createElement("textarea");C.value=T,C.style.position="fixed",C.style.opacity="0",document.body.appendChild(C),C.select();try{document.execCommand("copy"),P(!0),setTimeout(()=>P(!1),2e3)}catch{F(!0)}document.body.removeChild(C)};return e.jsx(He,{open:s,onOpenChange:C=>{C||t()},children:e.jsxs(ze,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(Ve,{children:e.jsxs(Be,{className:"font-display text-lg font-semibold text-text-primary",children:[w("share.title"),n?`: ${n}`:""]})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:w("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>p("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${m==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:w("share.user")}),e.jsx("button",{onClick:()=>p("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${m==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:w("share.team")})]}),m==="user"?e.jsx(At,{onSelect:N,placeholder:w("share.userIdPlaceholder"),actionLabel:w("share.selectUser")}):e.jsx("input",{type:"text",value:a,onChange:C=>o(C.target.value),placeholder:w("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),m==="user"&&g&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[w("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:g})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:w("share.permission")}),e.jsxs("select",{value:h,onChange:C=>b(C.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"read",children:w("share.permissionRead")}),e.jsx("option",{value:"write",children:w("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:w("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:k,onChange:C=>j(C.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none"})]}),(z||d)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:z||d}),T&&e.jsxs("div",{className:"rounded-md bg-surface-2 px-3 py-2",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-1",children:w("share.linkCreated")}),e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs text-text-primary",children:T}),e.jsx("button",{onClick:W,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:ae?w("share.copied"):w("share.copy")})]}),G&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:w("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:w("share.existingShares")}),c?e.jsx("p",{className:"text-sm text-text-muted",children:w("share.loading")}):l.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:w("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:l.map(C=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md bg-surface-2 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:C.granted_to_user||C.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[C.permission==="write"?w("share.permissionWrite"):w("share.permissionRead"),C.expires_at?` · expires ${C.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>J(C.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:w("share.revoke")})]},C.id))})]})]}),e.jsxs(Tt,{children:[e.jsx("button",{onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:w("common.close")}),e.jsx("button",{onClick:B,disabled:_||(m==="user"?!g.trim():!a.trim()),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:_?w("common.creating"):w("share.createShare")})]})]})})}function Cs(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function Ss(s){const t=Cs(s),r=ht(),n=r?{proxyUrl:t,token:r}:{proxyUrl:t};return new pt(n)}const V=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],re="rcs_permission_mode";function Te(s){return s<1e3?String(s):s<1e6?`${(s/1e3).toFixed(1)}k`:`${(s/1e6).toFixed(1)}M`}function Ms(s){const t=V.findIndex(r=>r.value===s);return V[(t+1+V.length)%V.length].value}function Es({models:s,currentModelId:t,onSelect:r,disabled:n}){const[l,c]=u.useState(!1),d=s.find(m=>m.modelId===t)??null,x=s.length>0,y=async m=>{r(m.modelId),c(!1)};return e.jsxs(De,{open:l,onOpenChange:x?c:void 0,children:[e.jsx(Ue,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n||!x,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"选择模型",children:[e.jsx(We,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(d==null?void 0:d.name)??t??"选择模型"}),l?e.jsx(Oe,{className:"h-3 w-3"}):e.jsx(Fe,{className:"h-3 w-3"})]})}),e.jsx(Le,{className:"w-72 p-0",align:"start",children:e.jsx(Mt,{models:s,currentModelId:t,onSelect:y,showSearch:s.length>5})})]})}function Ts({mode:s,onModeChange:t,disabled:r}){const[n,l]=u.useState(!1),c=V.find(d=>d.value===s);return e.jsxs(De,{open:n,onOpenChange:l,children:[e.jsx(Ue,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:r,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"权限模式(Shift+Tab 循环)",children:[e.jsx(St,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??s}),n?e.jsx(Oe,{className:"h-3 w-3"}):e.jsx(Fe,{className:"h-3 w-3"})]})}),e.jsx(Le,{className:"w-64 p-1",align:"start",children:V.map(d=>e.jsxs("button",{type:"button",onClick:()=>{t(d.value),l(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:s===d.value&&e.jsx($e,{className:"h-3.5 w-3.5 text-brand"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:d.label}),e.jsx("div",{className:"text-xs text-text-muted",children:d.description})]})]},d.value))})]})}function Ls({sessionId:s,onSessionLoaded:t}){qe();const[r,n]=u.useState(null),[l,c]=u.useState(null),[d,x]=u.useState(""),[y,m]=u.useState(!1),[p,g]=u.useState(!1),[N,a]=u.useState(!1),[o,h]=u.useState([]),[b,k]=u.useState(!1),[j,_]=u.useState([]),[M,T]=u.useState(null),[$,z]=u.useState(()=>Qe()),[q,ae]=u.useState(null),[P,G]=u.useState(null),[F,B]=u.useState([]),[J,W]=u.useState(!1),[C,X]=u.useState(""),oe=u.useRef(null),[ie,Z]=u.useState(()=>localStorage.getItem(re)||"default"),[pe,he]=u.useState(null),Q=u.useRef(null),U=u.useRef(ie);U.current=ie;const ee=u.useRef(null),fe=u.useRef(null),ye=u.useRef(o);ye.current=o;const te=u.useCallback(i=>{he(i),Q.current&&clearTimeout(Q.current),Q.current=setTimeout(()=>he(null),5e3)},[]),le=u.useCallback(i=>{var v;if(i===U.current)return;const f=U.current;U.current=i,Z(i);try{localStorage.setItem(re,i)}catch{}(v=fe.current)==null||v.setPermissionMode(i).then(S=>{ee.current={requestId:S,previous:f}}).catch(S=>{console.error("[SessionDetail] set permission mode failed:",S),te(`模式切换请求发送失败: ${S instanceof Error?S.message:String(S)}`),U.current=f,Z(f)})},[te]),R=u.useMemo(()=>new os(s,h,{onStatusChange:i=>{c(i),k(i==="running"||i==="requires_action")},onError:i=>{console.error("[RCSChatAdapter] error:",i)},onPermissionRequest:i=>{_(f=>f.some(v=>v.requestId===i.requestId)?f:[...f,i])},onModelsStateChange:i=>{T(i)},onSubagentUpdate:i=>{z(i)},onControlResponse:i=>{const f=ee.current;if(!(!f||f.requestId!==i.requestId)&&(ee.current=null,i.subtype==="error")){U.current=f.previous,Z(f.previous);try{localStorage.setItem(re,f.previous)}catch{}te(i.error||"模式切换失败")}},onPermissionModeChange:i=>{if(i!==U.current){U.current=i,Z(i);try{localStorage.setItem(re,i)}catch{}ee.current=null}},onUsageChange:i=>{ae(f=>({inputTokens:Math.max((f==null?void 0:f.inputTokens)??0,i.inputTokens),outputTokens:Math.max((f==null?void 0:f.outputTokens)??0,i.outputTokens),totalCostUsd:i.totalCostUsd??(f==null?void 0:f.totalCostUsd)??null}))},onElicitationRequest:i=>{G(i)}}),[s,te]);u.useEffect(()=>(fe.current=R,()=>{R.disconnect()}),[R]),u.useEffect(()=>{let i=!1;async function f(){x("");try{const v=await Nt(s);if(i)return;n(v),c(v.status),k(v.status==="running"||v.status==="requires_action"),t==null||t(v)}catch(v){if(i)return;x(v instanceof Error?v.message:w("session.loadFailed"));return}try{await R.init()}catch(v){console.warn("Failed to init adapter:",v)}}return f(),()=>{i=!0}},[s,R,t]);const H=vt(l),L=(r==null?void 0:r.access_level)==="read",se=u.useCallback(async i=>{const f=i.text.trim(),v=i.images&&i.images.length>0||i.attachments&&i.attachments.length>0;if(!f&&!v||H)return;const S=await ft(f,{sessionId:s,availableCommands:we,availableModels:(M==null?void 0:M.availableModels)??[],currentModel:M?{modelId:M.currentModelId,name:M.currentModelId}:null,supportsImages:!0,entries:ye.current,setModel:async D=>{await O(s,{type:"control_request",request:{subtype:"set_model",model:D}}),T(de=>de&&{...de,currentModelId:D})},onNewSession:()=>{h([])}}).catch(()=>null);if(S){if(yt("[SessionDetail] local command result",S),"clearEntries"in S&&S.clearEntries){h([]);return}if("newSession"in S&&S.newSession){h([]);return}if("userEntry"in S){h(D=>[...D,S.userEntry,S.cmdEntry]);return}}k(!0);try{await R.sendMessage(f,i.images,i.attachments)}catch(D){console.error("Send failed:",D)}},[R,H,s,M]),Ke=u.useCallback(i=>{if(b){B(f=>[...f,i]);return}se(i)},[b,se]),ce=u.useRef(!1);u.useEffect(()=>{if(b||F.length===0||ce.current)return;const i=F[0];i&&(ce.current=!0,B(f=>f.slice(1)),se(i).finally(()=>{ce.current=!1}))},[b,F,se]);const ge=u.useCallback(async()=>{try{await R.interrupt()}catch(i){console.error("Interrupt failed:",i)}finally{k(!1)}},[R]),Ye=u.useCallback(()=>{le(Ms(U.current))},[le]);u.useEffect(()=>()=>{Q.current&&clearTimeout(Q.current)},[]);const Ge=u.useCallback(async()=>{if(r&&window.confirm(w("dashboard.confirmDelete").replace("{id}",r.title||r.id)))try{await gt(r.id),window.location.href="/code/"}catch(i){alert(i instanceof Error?i.message:w("dashboard.deleteFailed"))}},[r]),Je=u.useCallback(async i=>{try{await R.respondPermission(i,!0)}catch(f){console.error("Failed to approve:",f)}_(f=>f.filter(v=>v.requestId!==i))},[R]),Xe=u.useCallback(async(i,f)=>{try{await R.respondPermission(i,!0,{updated_permissions:f})}catch(v){console.error("Failed to approve with rules:",v)}_(v=>v.filter(S=>S.requestId!==i))},[R]),Ze=u.useCallback(async(i,f)=>{const v=P;if(G(null),!!v)try{await R.respondElicitation(v.requestId,i,f)}catch(S){console.error("Failed to submit elicitation:",S)}},[P,R]),et=u.useCallback(()=>{!r||L||(X(r.title||""),W(!0),setTimeout(()=>{var i,f;(i=oe.current)==null||i.focus(),(f=oe.current)==null||f.select()},0))},[r,L]),be=u.useCallback(async()=>{const i=C.trim();if(W(!1),!(!r||!i||i===r.title))try{const f=await bt(r.id,i);n(v=>v&&{...v,title:f.title??i})}catch(f){console.error("Rename failed:",f),alert(f instanceof Error?f.message:"重命名失败")}},[r,C]),tt=u.useCallback(async i=>{try{await R.respondPermission(i,!1)}catch(f){console.error("Failed to reject:",f)}_(f=>f.filter(v=>v.requestId!==i))},[R]),st=u.useCallback(async(i,f,v)=>{try{await O(s,{type:"permission_response",approved:!0,request_id:i,updated_input:{questions:v,answers:f}})}catch(S){console.error("Failed to submit answers:",S)}_(S=>S.filter(D=>D.requestId!==i))},[s]),nt=u.useCallback(async(i,f,v)=>{try{f==="no"?await O(s,{type:"permission_response",approved:!1,request_id:i,...v?{message:v}:{}}):await O(s,{type:"permission_response",approved:!0,request_id:i,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[f]||"default",destination:"session"}]})}catch(S){console.error("Failed to submit plan response:",S)}_(S=>S.filter(D=>D.requestId!==i))},[s]);return d?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-status-error",children:d}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:w("session.backToDashboard")})]})}):r?r.source==="acp"&&r.environment_id?e.jsx(As,{sessionId:s,agentId:r.environment_id}):e.jsx(Pe,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:r.title||r.id}),e.jsx("div",{className:"border-b bg-surface-1 px-4 py-3",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[J?e.jsx("input",{ref:oe,value:C,onChange:i=>X(i.target.value),onKeyDown:i=>{i.key==="Enter"&&!i.nativeEvent.isComposing?(i.preventDefault(),be()):i.key==="Escape"&&(i.preventDefault(),W(!1))},onBlur:()=>void be(),maxLength:200,className:"w-full max-w-md rounded-lg border border-brand/50 bg-surface-2 px-2.5 py-1 font-display text-lg font-semibold text-text-primary focus:outline-none focus:ring-2 focus:ring-brand/30"}):e.jsxs("h2",{className:"group/title flex min-w-0 items-center gap-1.5 font-display text-lg font-semibold text-text-primary",children:[e.jsx("span",{className:"truncate",children:r.title||r.id}),!L&&!H&&e.jsx("button",{type:"button",onClick:et,className:"flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:text-text-primary group-hover/title:opacity-100",title:"重命名会话",children:e.jsx(jt,{className:"h-3.5 w-3.5"})})]}),r.visibility&&!J&&e.jsx(Rt,{visibility:r.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var v;const i=r.source==="acp"?"acp":(v=r.environment)==null?void 0:v.worker_type,f=Et(i);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${f.colorClass}`,children:f.fullLabel})})(),l&&e.jsx(Re,{status:l}),e.jsx("span",{className:"text-xs text-text-muted",children:Ae(r.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!L&&(r==null?void 0:r.access_level)!=="write"&&e.jsx("button",{onClick:()=>a(!0),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:w("session.share"),children:e.jsx(Jt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>g(!p),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:w("session.info"),children:e.jsx(zt,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>m(!y),className:"flex items-center gap-1 rounded-md px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",children:[w("session.tasks"),j.length>0&&e.jsx("span",{className:"ml-1 rounded-full bg-status-warning px-1.5 py-0.5 text-[10px] font-medium text-white",children:j.length})]})]})]}),p&&e.jsxs("div",{className:"mt-2 rounded-md bg-surface-2 px-3 py-2 text-xs text-text-muted space-y-1 font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:w("session.metaSession")})," ",r.id]}),r.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:w("session.metaEnvironment")})," ",r.environment_id]})]})]})}),e.jsx(kt,{entries:o,isLoading:b,emptyTitle:w("session.emptyTitle"),emptyDescription:w("session.emptyDescription")}),e.jsx(hs,{state:$}),j.length>0&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl space-y-3",children:j.map(i=>e.jsx(Rs,{request:i,onApprove:()=>Je(i.requestId),onApproveAlways:i.suggestions&&i.suggestions.length>0?()=>Xe(i.requestId,i.suggestions??[]):void 0,onReject:()=>tt(i.requestId),onSubmitAnswers:st,onSubmitPlan:nt},i.requestId))})}),P&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(ks,{request:P,onSubmit:Ze})})}),pe&&e.jsx("div",{className:"mx-auto max-w-3xl w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:pe})}),e.jsxs("div",{className:"max-w-3xl mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ts,{mode:ie,onModeChange:le,disabled:H||L}),e.jsx(Es,{models:(M==null?void 0:M.availableModels)??[],currentModelId:(M==null?void 0:M.currentModelId)??null,onSelect:i=>{O(s,{type:"control_request",request:{subtype:"set_model",model:i}}),T(f=>f&&{...f,currentModelId:i})},disabled:H||L})]}),q&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:"会话累计用量(input 含缓存读写)",children:[Te(q.inputTokens)," in / ",Te(q.outputTokens)," out",q.totalCostUsd!=null&&` · $${q.totalCostUsd.toFixed(2)}`]})]}),e.jsx(wt,{onSubmit:Ke,isLoading:b,onInterrupt:ge,onCycleMode:Ye,disabled:H||L,placeholder:H?w("session.closed"):L?w("session.readOnly"):w("session.inputPlaceholder"),supportsAttachments:!0,commands:we,queueWhileLoading:!0,queuedCount:F.length,onDequeue:i=>B(f=>f.filter((v,S)=>S!==i)),onSearchFiles:i=>R.searchFiles(i)}),y&&r&&e.jsx(ds,{onClose:()=>m(!1),session:r,liveStatus:l,pendingPermissions:j,onInterrupt:ge,onDelete:Ge}),e.jsx(_s,{open:N,onClose:()=>a(!1),sessionId:r.id,sessionTitle:r.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:w("session.loading")})})}function Rs({request:s,onApprove:t,onApproveAlways:r,onReject:n,onSubmitAnswers:l,onSubmitPlan:c}){const d=s.toolName,x=s.toolInput,y=s.description||"";if(d==="AskUserQuestion"){const m=x.questions||[];return e.jsx(ys,{requestId:s.requestId,questions:m,description:y,onSubmit:p=>l(s.requestId,p,m),onSkip:n})}if(d==="ExitPlanMode"){const m=x.plan||"";return e.jsx(bs,{requestId:s.requestId,planContent:m,description:y,onSubmit:(p,g)=>c(s.requestId,p,g)})}return e.jsx(fs,{requestId:s.requestId,toolName:d,toolInput:x,description:y,suggestions:s.suggestions,onApprove:t,onApproveAlways:r,onReject:n})}function As({sessionId:s,agentId:t}){const[r,n]=u.useState(null),[l,c]=u.useState("disconnected"),[d,x]=u.useState(null),y=u.useRef(null);return u.useEffect(()=>{const m=Ss(t);return m.setConnectionStateHandler((p,g)=>{c(p),x(g||null)}),y.current=m,n(m),m.connect().catch(p=>{p instanceof _t||(x(p.message),c("error"))}),()=>{m.disconnect(),y.current=null,n(null),c("disconnected")}},[t]),e.jsx(Pe,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[d&&l==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:d}),l==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-text-muted text-sm",children:w("session.connectingAgent")})]})}),l==="error"&&!r&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:w("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:d})]})}),r&&l==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ct,{client:r,agentId:t})})]})})}export{Ls as SessionDetail};
@@ -1,4 +1,4 @@
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";/**
1
+ import{j as t}from"./vendor-DE_-CLIE.js";import{a4 as l,u as c,i as d,h as g,X as u,a3 as o,T as x,t as f,O as m,U as p}from"./main-L9iyf39T.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{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
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{ah as v,ad as t}from"./main-L9iyf39T.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{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
+ import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{Y as m,b as h}from"./main-L9iyf39T.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{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};
1
+ import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{ai as f,aj as y,ad as r}from"./main-L9iyf39T.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};