@saluzi/saluzi-edu 0.3.6 → 0.4.1

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 (181) hide show
  1. package/dist/cli.js +81 -61
  2. package/dist/rcs-schema.sql +11 -0
  3. package/dist/rcs-web/assets/{AdminPanel-B9K3CYqS.js → AdminPanel-BpjNyO3W.js} +1 -1
  4. package/dist/rcs-web/assets/ArtifactView-DMsduT0e.js +1 -0
  5. package/dist/rcs-web/assets/{ArtifactsGallery-CjliWleX.js → ArtifactsGallery--KEN5Q2C.js} +1 -1
  6. package/{packages/remote-control-server/web/dist/assets/Claim-CXcdrgMT.js → dist/rcs-web/assets/Claim-ClHGhexz.js} +1 -1
  7. package/dist/rcs-web/assets/Dashboard-C5LV1cdW.js +6 -0
  8. package/dist/rcs-web/assets/{Join-BIPrGzjB.js → Join-DssmEuDo.js} +1 -1
  9. package/dist/rcs-web/assets/{Login-B3F-J_O_.js → Login-D5-UV7og.js} +1 -1
  10. package/dist/rcs-web/assets/{Register-BOMRs2-X.js → Register-Cgsq_Ibv.js} +1 -1
  11. package/dist/rcs-web/assets/SessionDetail-PIKhgeSE.js +83 -0
  12. package/dist/rcs-web/assets/{SessionVisibilityBadge-CpdH64Ki.js → SessionVisibilityBadge-I2lLxC5g.js} +1 -1
  13. package/dist/rcs-web/assets/{Setup-04VLlDdo.js → Setup-C0Ea6PHX.js} +1 -1
  14. package/dist/rcs-web/assets/{ShareLanding-WwHP77MK.js → ShareLanding-CmSEJlVm.js} +1 -1
  15. package/dist/rcs-web/assets/{TeamCreate-Cgn8TbAD.js → TeamCreate-1i5YF-vx.js} +1 -1
  16. package/dist/rcs-web/assets/{TeamDetail-DjCmVq2J.js → TeamDetail-CT0OPoLU.js} +2 -2
  17. package/dist/rcs-web/assets/{TeamList-DkEsaCsT.js → TeamList-Hhn6XHlf.js} +1 -1
  18. package/dist/rcs-web/assets/{TeamSettings-B37TYBAO.js → TeamSettings-DeSvmHy4.js} +1 -1
  19. package/dist/rcs-web/assets/{UserSearchInput-CnZL2wJc.js → UserSearchInput-DOlIGv2X.js} +1 -1
  20. package/dist/rcs-web/assets/UserSettings-DQZVQw18.js +1 -0
  21. package/dist/rcs-web/assets/{arc-CC5N7Gnz.js → arc-DWZUXcLy.js} +1 -1
  22. package/{packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-CYnwtsAv.js → dist/rcs-web/assets/architectureDiagram-3BPJPVTR-A-l-nUmv.js} +1 -1
  23. package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DQz4PRpo.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-CeAhGtgG.js} +1 -1
  24. package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-CZD52_Kn.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-AVRUF_j5.js} +1 -1
  25. package/dist/rcs-web/assets/channel-arpszf6z.js +1 -0
  26. package/dist/rcs-web/assets/{chunk-2J33WTMH-Gj2ixi6u.js → chunk-2J33WTMH-C0xZCh74.js} +1 -1
  27. package/dist/rcs-web/assets/{chunk-4BX2VUAB-CXN22Y7-.js → chunk-4BX2VUAB-PPBm6YOm.js} +1 -1
  28. package/dist/rcs-web/assets/{chunk-55IACEB6-xQfT-CuW.js → chunk-55IACEB6-DItii7PK.js} +1 -1
  29. package/dist/rcs-web/assets/{chunk-727SXJPM-BbG-ntwa.js → chunk-727SXJPM-BxvtEOH5.js} +1 -1
  30. package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-D4F7B6E5.js → dist/rcs-web/assets/chunk-AQP2D5EJ-C2Q0SXf5.js} +1 -1
  31. package/dist/rcs-web/assets/{chunk-FMBD7UC4-C05UOexr.js → chunk-FMBD7UC4-CRIq1t7y.js} +1 -1
  32. package/dist/rcs-web/assets/{chunk-ND2GUHAM-CgP_C3YR.js → chunk-ND2GUHAM-DWltgrrr.js} +1 -1
  33. package/dist/rcs-web/assets/{chunk-QZHKN3VN-CEG9thbk.js → chunk-QZHKN3VN-DA7d8KIx.js} +1 -1
  34. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-B3HHWAZN.js +1 -0
  35. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-B3HHWAZN.js +1 -0
  36. package/{packages/remote-control-server/web/dist/assets/code-block-IT6T5CEO-LwZNRjDA.js → dist/rcs-web/assets/code-block-IT6T5CEO-BXA78g4Z.js} +1 -1
  37. package/dist/rcs-web/assets/{copy-VKG2qIBt.js → copy-DIHZ4Rnp.js} +1 -1
  38. package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-BDYGEjjT.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-DfAvPuoD.js} +1 -1
  39. package/dist/rcs-web/assets/{dagre-BM42HDAG-4fAyUQHo.js → dagre-BM42HDAG-Qq1-K6d7.js} +1 -1
  40. package/dist/rcs-web/assets/{diagram-2AECGRRQ-D3NtHIEV.js → diagram-2AECGRRQ-BdCpCixY.js} +1 -1
  41. package/dist/rcs-web/assets/{diagram-5GNKFQAL-BKL4sgRR.js → diagram-5GNKFQAL-Bx3h0pH5.js} +1 -1
  42. package/dist/rcs-web/assets/{diagram-KO2AKTUF-B67rX-ug.js → diagram-KO2AKTUF-D87FL1JG.js} +1 -1
  43. package/dist/rcs-web/assets/{diagram-LMA3HP47-BOKNQw_d.js → diagram-LMA3HP47-CgoY1c_8.js} +1 -1
  44. package/dist/rcs-web/assets/{diagram-OG6HWLK6-C7IEoW-1.js → diagram-OG6HWLK6-BtkoOZUL.js} +1 -1
  45. package/{packages/remote-control-server/web/dist/assets/dialog-BkaYnxd7.js → dist/rcs-web/assets/dialog-Ci9ytkis.js} +1 -1
  46. package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-Dk3unY1I.js → erDiagram-TEJ5UH35-B54UzzpA.js} +1 -1
  47. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-DZJ3rxoR.js → flowDiagram-I6XJVG4X-B2MA7cSv.js} +1 -1
  48. package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Db4jo72X.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-sCnFGbUE.js} +1 -1
  49. package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-BX3YMZO1.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-D1hIYZw2.js} +1 -1
  50. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-B3YkgTqr.js → infoDiagram-5YYISTIA-BIJ_iPnH.js} +1 -1
  51. package/dist/rcs-web/assets/{ishikawaDiagram-YF4QCWOH-C72E1awT.js → ishikawaDiagram-YF4QCWOH-VZSMyDVi.js} +1 -1
  52. package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-BQtBob5h.js → journeyDiagram-JHISSGLW-BtQFP7hW.js} +1 -1
  53. package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-u4jbqr1b.js → kanban-definition-UN3LZRKU-4VzgDGK0.js} +1 -1
  54. package/dist/rcs-web/assets/{linear-BgmGl4it.js → linear-BUc89IRk.js} +1 -1
  55. package/dist/rcs-web/assets/main-B67FXcTf.js +274 -0
  56. package/dist/rcs-web/assets/main-CDFTdB3m.css +1 -0
  57. package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-CbW524nw.js → dist/rcs-web/assets/mermaid-VLURNSYL-B9hHZxgz.js} +4 -4
  58. package/dist/rcs-web/assets/{mermaid.core-CHLPnWoP.js → mermaid.core-BJkztS6P.js} +5 -5
  59. package/{packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-BJmEA5fB.js → dist/rcs-web/assets/mindmap-definition-RKZ34NQL-D0P4gWNR.js} +1 -1
  60. package/dist/rcs-web/assets/notifications-D9_SRqI0.js +1 -0
  61. package/{packages/remote-control-server/web/dist/assets/pieDiagram-4H26LBE5-D2yhA9tV.js → dist/rcs-web/assets/pieDiagram-4H26LBE5-DpQuSH_r.js} +1 -1
  62. package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-OsyuYmxV.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-CtFhvAZp.js} +1 -1
  63. package/dist/rcs-web/assets/refresh-cw-CgJEBffB.js +6 -0
  64. package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-DlBCGFrE.js → requirementDiagram-4Y6WPE33-Dvo0fzAz.js} +1 -1
  65. package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-CRf3tVJL.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-gbV73Jae.js} +1 -1
  66. package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CPMzSwEL.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CGIUy6J3.js} +1 -1
  67. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-C8aXVxPs.js → stateDiagram-AJRCARHV-D7pzulbB.js} +1 -1
  68. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-BtaA-6HM.js → stateDiagram-v2-BHNVJYJU-Ct3ciKMZ.js} +1 -1
  69. package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-D4bpIX_3.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-DTR6Rmtz.js} +1 -1
  70. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-BOvGxUBy.js → vennDiagram-CIIHVFJN-WBicpAVq.js} +1 -1
  71. package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-DOap87Nn.js → wardleyDiagram-YWT4CUSO-1HjVSjok.js} +1 -1
  72. package/{packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-BiKOkL9_.js → dist/rcs-web/assets/xychartDiagram-2RQKCTM6-b5vzo0Pc.js} +1 -1
  73. package/dist/rcs-web/index.html +2 -2
  74. package/package.json +1 -1
  75. package/packages/remote-control-server/src/__tests__/attach-wait.test.ts +1 -1
  76. package/packages/remote-control-server/src/__tests__/search.test.ts +157 -0
  77. package/packages/remote-control-server/src/__tests__/services.test.ts +36 -8
  78. package/packages/remote-control-server/src/__tests__/session-rewind.test.ts +186 -0
  79. package/packages/remote-control-server/src/__tests__/session-titles.test.ts +220 -0
  80. package/packages/remote-control-server/src/__tests__/work-dispatch.test.ts +38 -0
  81. package/packages/remote-control-server/src/db/rcs-schema.sql +11 -0
  82. package/packages/remote-control-server/src/routes/v2/worker-events.ts +13 -0
  83. package/packages/remote-control-server/src/routes/v2/worker.ts +7 -6
  84. package/packages/remote-control-server/src/routes/web/sessions.ts +127 -1
  85. package/packages/remote-control-server/src/services/disconnect-monitor.ts +4 -1
  86. package/packages/remote-control-server/src/services/environment.ts +2 -5
  87. package/packages/remote-control-server/src/services/event-persistence.ts +3 -0
  88. package/packages/remote-control-server/src/services/search.ts +195 -0
  89. package/packages/remote-control-server/src/services/session-titles.ts +162 -0
  90. package/packages/remote-control-server/src/services/transport.ts +11 -0
  91. package/packages/remote-control-server/src/services/work-dispatch.ts +14 -0
  92. package/packages/remote-control-server/src/transport/ws-handler.ts +13 -0
  93. package/packages/remote-control-server/web/dist/assets/{AdminPanel-B9K3CYqS.js → AdminPanel-BpjNyO3W.js} +1 -1
  94. package/packages/remote-control-server/web/dist/assets/ArtifactView-DMsduT0e.js +1 -0
  95. package/packages/remote-control-server/web/dist/assets/{ArtifactsGallery-CjliWleX.js → ArtifactsGallery--KEN5Q2C.js} +1 -1
  96. package/{dist/rcs-web/assets/Claim-CXcdrgMT.js → packages/remote-control-server/web/dist/assets/Claim-ClHGhexz.js} +1 -1
  97. package/packages/remote-control-server/web/dist/assets/Dashboard-C5LV1cdW.js +6 -0
  98. package/packages/remote-control-server/web/dist/assets/{Join-BIPrGzjB.js → Join-DssmEuDo.js} +1 -1
  99. package/packages/remote-control-server/web/dist/assets/{Login-B3F-J_O_.js → Login-D5-UV7og.js} +1 -1
  100. package/packages/remote-control-server/web/dist/assets/{Register-BOMRs2-X.js → Register-Cgsq_Ibv.js} +1 -1
  101. package/packages/remote-control-server/web/dist/assets/SessionDetail-PIKhgeSE.js +83 -0
  102. package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-CpdH64Ki.js → SessionVisibilityBadge-I2lLxC5g.js} +1 -1
  103. package/packages/remote-control-server/web/dist/assets/{Setup-04VLlDdo.js → Setup-C0Ea6PHX.js} +1 -1
  104. package/packages/remote-control-server/web/dist/assets/{ShareLanding-WwHP77MK.js → ShareLanding-CmSEJlVm.js} +1 -1
  105. package/packages/remote-control-server/web/dist/assets/{TeamCreate-Cgn8TbAD.js → TeamCreate-1i5YF-vx.js} +1 -1
  106. package/packages/remote-control-server/web/dist/assets/{TeamDetail-DjCmVq2J.js → TeamDetail-CT0OPoLU.js} +2 -2
  107. package/packages/remote-control-server/web/dist/assets/{TeamList-DkEsaCsT.js → TeamList-Hhn6XHlf.js} +1 -1
  108. package/packages/remote-control-server/web/dist/assets/{TeamSettings-B37TYBAO.js → TeamSettings-DeSvmHy4.js} +1 -1
  109. package/packages/remote-control-server/web/dist/assets/{UserSearchInput-CnZL2wJc.js → UserSearchInput-DOlIGv2X.js} +1 -1
  110. package/packages/remote-control-server/web/dist/assets/UserSettings-DQZVQw18.js +1 -0
  111. package/packages/remote-control-server/web/dist/assets/{arc-CC5N7Gnz.js → arc-DWZUXcLy.js} +1 -1
  112. package/{dist/rcs-web/assets/architectureDiagram-3BPJPVTR-CYnwtsAv.js → packages/remote-control-server/web/dist/assets/architectureDiagram-3BPJPVTR-A-l-nUmv.js} +1 -1
  113. package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DQz4PRpo.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-CeAhGtgG.js} +1 -1
  114. package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-CZD52_Kn.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-AVRUF_j5.js} +1 -1
  115. package/packages/remote-control-server/web/dist/assets/channel-arpszf6z.js +1 -0
  116. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-Gj2ixi6u.js → chunk-2J33WTMH-C0xZCh74.js} +1 -1
  117. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-CXN22Y7-.js → chunk-4BX2VUAB-PPBm6YOm.js} +1 -1
  118. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-xQfT-CuW.js → chunk-55IACEB6-DItii7PK.js} +1 -1
  119. package/packages/remote-control-server/web/dist/assets/{chunk-727SXJPM-BbG-ntwa.js → chunk-727SXJPM-BxvtEOH5.js} +1 -1
  120. package/{dist/rcs-web/assets/chunk-AQP2D5EJ-D4F7B6E5.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-C2Q0SXf5.js} +1 -1
  121. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-C05UOexr.js → chunk-FMBD7UC4-CRIq1t7y.js} +1 -1
  122. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-CgP_C3YR.js → chunk-ND2GUHAM-DWltgrrr.js} +1 -1
  123. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-CEG9thbk.js → chunk-QZHKN3VN-DA7d8KIx.js} +1 -1
  124. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-B3HHWAZN.js +1 -0
  125. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-B3HHWAZN.js +1 -0
  126. package/{dist/rcs-web/assets/code-block-IT6T5CEO-LwZNRjDA.js → packages/remote-control-server/web/dist/assets/code-block-IT6T5CEO-BXA78g4Z.js} +1 -1
  127. package/packages/remote-control-server/web/dist/assets/{copy-VKG2qIBt.js → copy-DIHZ4Rnp.js} +1 -1
  128. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-BDYGEjjT.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-DfAvPuoD.js} +1 -1
  129. package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-4fAyUQHo.js → dagre-BM42HDAG-Qq1-K6d7.js} +1 -1
  130. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-D3NtHIEV.js → diagram-2AECGRRQ-BdCpCixY.js} +1 -1
  131. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-BKL4sgRR.js → diagram-5GNKFQAL-Bx3h0pH5.js} +1 -1
  132. package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-B67rX-ug.js → diagram-KO2AKTUF-D87FL1JG.js} +1 -1
  133. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-BOKNQw_d.js → diagram-LMA3HP47-CgoY1c_8.js} +1 -1
  134. package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-C7IEoW-1.js → diagram-OG6HWLK6-BtkoOZUL.js} +1 -1
  135. package/{dist/rcs-web/assets/dialog-BkaYnxd7.js → packages/remote-control-server/web/dist/assets/dialog-Ci9ytkis.js} +1 -1
  136. package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-Dk3unY1I.js → erDiagram-TEJ5UH35-B54UzzpA.js} +1 -1
  137. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-DZJ3rxoR.js → flowDiagram-I6XJVG4X-B2MA7cSv.js} +1 -1
  138. package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Db4jo72X.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-sCnFGbUE.js} +1 -1
  139. package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-BX3YMZO1.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-D1hIYZw2.js} +1 -1
  140. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-B3YkgTqr.js → infoDiagram-5YYISTIA-BIJ_iPnH.js} +1 -1
  141. package/packages/remote-control-server/web/dist/assets/{ishikawaDiagram-YF4QCWOH-C72E1awT.js → ishikawaDiagram-YF4QCWOH-VZSMyDVi.js} +1 -1
  142. package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-BQtBob5h.js → journeyDiagram-JHISSGLW-BtQFP7hW.js} +1 -1
  143. package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-u4jbqr1b.js → kanban-definition-UN3LZRKU-4VzgDGK0.js} +1 -1
  144. package/packages/remote-control-server/web/dist/assets/{linear-BgmGl4it.js → linear-BUc89IRk.js} +1 -1
  145. package/packages/remote-control-server/web/dist/assets/main-B67FXcTf.js +274 -0
  146. package/packages/remote-control-server/web/dist/assets/main-CDFTdB3m.css +1 -0
  147. package/{dist/rcs-web/assets/mermaid-VLURNSYL-CbW524nw.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-B9hHZxgz.js} +4 -4
  148. package/packages/remote-control-server/web/dist/assets/{mermaid.core-CHLPnWoP.js → mermaid.core-BJkztS6P.js} +5 -5
  149. package/{dist/rcs-web/assets/mindmap-definition-RKZ34NQL-BJmEA5fB.js → packages/remote-control-server/web/dist/assets/mindmap-definition-RKZ34NQL-D0P4gWNR.js} +1 -1
  150. package/packages/remote-control-server/web/dist/assets/notifications-D9_SRqI0.js +1 -0
  151. package/{dist/rcs-web/assets/pieDiagram-4H26LBE5-D2yhA9tV.js → packages/remote-control-server/web/dist/assets/pieDiagram-4H26LBE5-DpQuSH_r.js} +1 -1
  152. package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-OsyuYmxV.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-CtFhvAZp.js} +1 -1
  153. package/packages/remote-control-server/web/dist/assets/refresh-cw-CgJEBffB.js +6 -0
  154. package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-DlBCGFrE.js → requirementDiagram-4Y6WPE33-Dvo0fzAz.js} +1 -1
  155. package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-CRf3tVJL.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-gbV73Jae.js} +1 -1
  156. package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CPMzSwEL.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CGIUy6J3.js} +1 -1
  157. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-C8aXVxPs.js → stateDiagram-AJRCARHV-D7pzulbB.js} +1 -1
  158. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-BtaA-6HM.js → stateDiagram-v2-BHNVJYJU-Ct3ciKMZ.js} +1 -1
  159. package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-D4bpIX_3.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-DTR6Rmtz.js} +1 -1
  160. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-BOvGxUBy.js → vennDiagram-CIIHVFJN-WBicpAVq.js} +1 -1
  161. package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-DOap87Nn.js → wardleyDiagram-YWT4CUSO-1HjVSjok.js} +1 -1
  162. package/{dist/rcs-web/assets/xychartDiagram-2RQKCTM6-BiKOkL9_.js → packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-b5vzo0Pc.js} +1 -1
  163. package/packages/remote-control-server/web/dist/index.html +2 -2
  164. package/dist/rcs-web/assets/ArtifactView-xC7kgK6r.js +0 -6
  165. package/dist/rcs-web/assets/Dashboard-GTUc9fNN.js +0 -6
  166. package/dist/rcs-web/assets/SessionDetail-D13hMSu2.js +0 -60
  167. package/dist/rcs-web/assets/UserSettings-IVT2kcbO.js +0 -1
  168. package/dist/rcs-web/assets/channel-Ca4tVWtj.js +0 -1
  169. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-BZnm3s8l.js +0 -1
  170. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-BZnm3s8l.js +0 -1
  171. package/dist/rcs-web/assets/main-DT3Fa5LX.css +0 -1
  172. package/dist/rcs-web/assets/main-uW6v3W3M.js +0 -265
  173. package/packages/remote-control-server/web/dist/assets/ArtifactView-xC7kgK6r.js +0 -6
  174. package/packages/remote-control-server/web/dist/assets/Dashboard-GTUc9fNN.js +0 -6
  175. package/packages/remote-control-server/web/dist/assets/SessionDetail-D13hMSu2.js +0 -60
  176. package/packages/remote-control-server/web/dist/assets/UserSettings-IVT2kcbO.js +0 -1
  177. package/packages/remote-control-server/web/dist/assets/channel-Ca4tVWtj.js +0 -1
  178. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-BZnm3s8l.js +0 -1
  179. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-BZnm3s8l.js +0 -1
  180. package/packages/remote-control-server/web/dist/assets/main-DT3Fa5LX.css +0 -1
  181. package/packages/remote-control-server/web/dist/assets/main-uW6v3W3M.js +0 -265
@@ -154,6 +154,17 @@ CREATE INDEX IF NOT EXISTS idx_environments_team ON environments(team_id);
154
154
  CREATE INDEX IF NOT EXISTS idx_environments_owner_user ON environments(owner_user_id);
155
155
  CREATE INDEX IF NOT EXISTS idx_environments_claim_token ON environments(claim_token);
156
156
  CREATE INDEX IF NOT EXISTS idx_session_events_session ON session_events(session_id);
157
+
158
+ -- Full-text search over conversation events (Web cross-session search).
159
+ -- Contentless-synced from session_events on write (services/search.ts);
160
+ -- event_id is the join key back to the source row, session_id UNINDEXED
161
+ -- for grouping. The index is rebuilt lazily on first search if empty
162
+ -- (services/search.ts backfillSearchIndex).
163
+ CREATE VIRTUAL TABLE IF NOT EXISTS session_events_fts USING fts5(
164
+ text,
165
+ session_id UNINDEXED,
166
+ event_id UNINDEXED
167
+ );
157
168
  CREATE INDEX IF NOT EXISTS idx_artifacts_session ON artifacts(session_id);
158
169
  CREATE INDEX IF NOT EXISTS idx_artifacts_team ON artifacts(team_id);
159
170
  CREATE INDEX IF NOT EXISTS idx_artifacts_expires ON artifacts(expires_at);
@@ -1 +1 @@
1
- import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{au as x,av as o,Q as m,ap as s,ag as l,w as u}from"./main-uW6v3W3M.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{aB as x,aC as o,Y as m,aw as s,al as l,z as u}from"./main-B67FXcTf.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){x();const[a,i]=d.useState([]),{myTeams:r,isLoading:c}=o(),n=d.useCallback(async()=>{try{const t=await m();i(t||[])}catch(t){console.error("Admin: failed to load sessions",t)}},[]);return d.useEffect(()=>{n()},[n]),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8",children:[e.jsx("h1",{className:"mb-6 font-display text-2xl font-semibold text-text-primary",children:s("admin.title")}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.teams")," (",r.length,")"]}),c?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("common.loading")}):r.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noTeams")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("a",{href:`/teams/${t.slug}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium text-text-primary",children:t.name}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:t.slug})]}),e.jsx("span",{className:"text-xs text-text-muted",children:l(new Date(t.created_at).getTime()/1e3)})]},t.id))})]}),e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.sessions")," (",a.length,")"]}),a.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noSessions")}):e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("a",{href:`/code/${t.id}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.title||t.id}),e.jsx("span",{className:"rounded-full bg-surface-2 px-2 py-0.5 text-xs text-text-muted",children:t.source||"unknown"})]}),e.jsx("div",{className:"truncate text-xs text-text-muted",children:t.id})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-3",children:[e.jsx(u,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:l(t.updated_at||t.created_at)})]})]},t.id))})]})]})})}export{j as AdminPanel};
@@ -0,0 +1 @@
1
+ import{e as a,j as t}from"./vendor-DE_-CLIE.js";import{aB as A,Z as j,aw as r,V as q,ah as R,P as U,G as F}from"./main-B67FXcTf.js";import{S as O,E as G,C as K}from"./ArtifactsGallery--KEN5Q2C.js";import{R as P}from"./refresh-cw-CgJEBffB.js";import{C as V}from"./copy-DIHZ4Rnp.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";import"./dialog-Ci9ytkis.js";let m=null;function J(n,c,e=0){b();const o=`/web/sessions/${n}/events`,l=new EventSource(o,{withCredentials:!0});m=l;let u=e;l.addEventListener("message",p=>{try{const x=JSON.parse(p.data);if(x.seqNum!==void 0&&x.seqNum<=u)return;x.seqNum!==void 0&&(u=x.seqNum),c(x)}catch{}}),l.addEventListener("error",()=>{console.warn("[SSE] error, readyState:",l.readyState),l.readyState===EventSource.CLOSED&&(l.close(),b())})}function b(){m&&(m.close(),m=null)}function M(n,c){const e=a.useRef(c);e.current=c;const o=a.useCallback(l=>{e.current(l)},[]);a.useEffect(()=>{if(n)return J(n,o),()=>{b()}},[n,o])}function I({artifactId:n,onBack:c}){A();const[e,o]=a.useState(null),[l,u]=a.useState(""),[p,x]=a.useState(!1),[S,f]=a.useState(0),[w,h]=a.useState(!1),[g,C]=a.useState(null),[E,k]=a.useState("template"),[d,y]=a.useState(!1);a.useEffect(()=>{let s=!1;return j(n).then(i=>{s||o(i)}).catch(i=>{s||u(i instanceof Error?i.message:r("artifacts.viewNotFound"))}),()=>{s=!0}},[n]);const v=a.useCallback(()=>{j(n).then(s=>o(s)).catch(()=>{})},[n]),_=a.useCallback(s=>{var i;s.type==="artifact_updated"&&((i=s.payload)!=null&&i.id&&s.payload.id!==n||(v(),f(D=>D+1),y(!0)))},[n,v]);M((e==null?void 0:e.session_id)??null,_),a.useEffect(()=>{if(!d)return;const s=setTimeout(()=>y(!1),2500);return()=>clearTimeout(s)},[d]);const N=a.useCallback(s=>{e&&(C(e),k(s),h(!0))},[e]),$=a.useCallback(s=>{h(!1),o(i=>i?{...i,...s}:s),f(i=>i+1)},[]),T=a.useCallback(async()=>{if(window.confirm(r("artifacts.delete")+" — "+n.slice(0,8)+"…?"))try{await q(n),c()}catch(s){alert(s instanceof Error?s.message:r("artifacts.deleteFailed"))}},[n,c]),L=a.useCallback(async()=>{if(!e)return;await R(`${window.location.origin}${e.url}`)&&(x(!0),setTimeout(()=>x(!1),1500))},[e]);return l?t.jsx("div",{className:"flex flex-1 items-center justify-center",children:t.jsxs("div",{className:"text-center",children:[t.jsx("p",{className:"text-status-error",children:r("artifacts.viewNotFound")}),t.jsx("p",{className:"mt-1 text-xs text-text-muted",children:l}),t.jsx("button",{type:"button",onClick:c,className:"mt-4 rounded-md border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2",children:r("artifacts.backToGallery")})]})}):e?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-b border-border bg-surface-1 px-4 py-2.5",children:[t.jsx("button",{type:"button",onClick:c,className:"text-sm text-text-muted hover:text-text-primary",children:r("artifacts.backToGallery")}),t.jsx("span",{className:"text-text-muted/40",children:"/"}),t.jsx("span",{className:"truncate font-medium text-text-primary",children:e.title||e.id.slice(0,12)}),t.jsx("span",{className:`rounded-full px-2 py-0.5 text-[11px] transition-colors ${d?"bg-status-active/15 text-status-active":"bg-surface-3 text-text-muted"}`,title:d?r("artifacts.view.liveUpdated"):void 0,children:d?`↻ v${e.version}`:`v${e.version}`}),e.session_id&&t.jsxs("a",{href:`/code/${e.session_id}`,className:"truncate font-mono text-[11px] text-text-muted hover:text-accent",title:e.session_id,children:[r("artifacts.session"),": ",e.session_id.slice(0,14),"…"]}),e.expires_at&&t.jsxs("span",{className:"text-[11px] text-text-muted",title:e.expires_at,children:[r("artifacts.expires"),": ",new Date(e.expires_at).toLocaleDateString()]}),t.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>f(s=>s+1),className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary hover:bg-surface-2 hover:text-text-primary",title:r("common.loading"),children:t.jsx(P,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:()=>N("ai"),className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary hover:bg-surface-2 hover:text-text-primary",title:r("artifacts.aiUpdate"),children:t.jsx(O,{className:"h-3.5 w-3.5"})}),e.can_manage&&t.jsx("button",{type:"button",onClick:()=>N("template"),className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary hover:bg-surface-2 hover:text-text-primary",title:r("artifacts.edit"),children:t.jsx(U,{className:"h-3.5 w-3.5"})}),t.jsxs("button",{type:"button",onClick:L,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary hover:bg-surface-2 hover:text-text-primary",title:`${r("artifacts.copyLink")} · ${r("artifacts.linkNotice")}`,children:[t.jsx(V,{className:"h-3.5 w-3.5"}),p&&t.jsx("span",{className:"text-status-active",children:r("artifacts.copied")})]}),t.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary hover:bg-surface-2 hover:text-text-primary",title:r("artifacts.openInNewTab"),children:t.jsx(G,{className:"h-3.5 w-3.5"})}),t.jsx("button",{type:"button",onClick:T,className:"inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-secondary hover:bg-status-error/10 hover:text-status-error",title:r("artifacts.delete"),children:t.jsx(F,{className:"h-3.5 w-3.5"})})]})]}),t.jsx("iframe",{src:`${e.url}${e.url.includes("?")?"&":"?"}_=${Date.now()}`,title:e.title||e.id,className:"min-h-0 w-full flex-1 border-0 bg-white",sandbox:"allow-scripts allow-popups allow-forms"},S),t.jsx(K,{open:w,onClose:()=>h(!1),onCreated:$,editArtifact:g,initialMode:E})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-text-muted",children:r("common.loading")})}export{I as ArtifactView};
@@ -1,4 +1,4 @@
1
- var ht=Object.defineProperty;var ut=(t,e,r)=>e in t?ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>ut(t,typeof e!="symbol"?e+"":e,r);import{e as k,j as o}from"./vendor-DE_-CLIE.js";import{ad as Re,ah as ft,au as Ve,av as mt,W as xt,ap as f,K as gt,ac as bt,F as kt,g as yt,P as wt,y as vt,p as He,V as St,a0 as Rt,al as Tt,$ as $t,a6 as jt,a7 as Et,H as Nt,b as Ct}from"./main-uW6v3W3M.js";import{D as It,a as At,c as Lt,d as zt,b as _t}from"./dialog-BkaYnxd7.js";import{C as Dt}from"./copy-VKG2qIBt.js";/**
1
+ var ht=Object.defineProperty;var ut=(t,e,r)=>e in t?ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>ut(t,typeof e!="symbol"?e+"":e,r);import{e as k,j as o}from"./vendor-DE_-CLIE.js";import{ai as Re,am as ft,aB as Ve,aC as mt,_ as xt,aw as f,V as gt,ah as bt,F as kt,g as yt,P as wt,G as vt,q as He,Z as St,a3 as Rt,ar as Tt,a2 as $t,ab as jt,ac as Et,K as Nt,b as Ct}from"./main-B67FXcTf.js";import{D as It,a as At,c as Lt,d as zt,b as _t}from"./dialog-Ci9ytkis.js";import{C as Dt}from"./copy-DIHZ4Rnp.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{E as u,Q as f}from"./main-uW6v3W3M.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";const v=2e3,N=3e4;function E(){const c=window.location.pathname.split("/"),i=c[c.length-1]||"",[s,n]=r.useState("idle"),[m,l]=r.useState(null),[a,d]=r.useState(null);return r.useEffect(()=>{if(!i||!i.startsWith("clm_")){l("Invalid claim token"),n("error");return}n("claiming"),u(i).then(t=>{d(t.environment_id),n("waiting")}).catch(t=>{l(t instanceof Error?t.message:"Claim failed"),n("error")})},[i]),r.useEffect(()=>{if(s!=="waiting"||!a)return;let t=!1;const x=Date.now(),o=setInterval(()=>{if(Date.now()-x>N){clearInterval(o),t||n("timeout");return}f().then(h=>{t||(h||[]).some(p=>p.environment_id===a)&&(clearInterval(o),window.location.href="/code/")}).catch(()=>{})},v);return()=>{t=!0,clearInterval(o)}},[s,a]),s==="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..."})}):s==="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:m}),e.jsx("a",{href:"/code",className:"mt-4 inline-block text-accent hover:underline",children:"Back to dashboard"})]}):s==="waiting"||s==="timeout"?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:[a&&e.jsx("p",{className:"font-mono text-xs text-text-muted",children:a}),s==="waiting"?e.jsxs("p",{className:"text-sm text-text-muted",children:["Waiting for the worker to create a session",e.jsx("span",{className:"animate-pulse",children:"…"})]}):e.jsx("p",{className:"text-sm text-text-muted",children:"The worker has not created a session yet — it may be offline or stopped. The session will appear on the dashboard once the worker connects."}),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"})]})]}):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..."})})}export{E as Claim};
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{I as u,Y as f}from"./main-B67FXcTf.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";const v=2e3,N=3e4;function E(){const c=window.location.pathname.split("/"),i=c[c.length-1]||"",[s,n]=r.useState("idle"),[m,l]=r.useState(null),[a,d]=r.useState(null);return r.useEffect(()=>{if(!i||!i.startsWith("clm_")){l("Invalid claim token"),n("error");return}n("claiming"),u(i).then(t=>{d(t.environment_id),n("waiting")}).catch(t=>{l(t instanceof Error?t.message:"Claim failed"),n("error")})},[i]),r.useEffect(()=>{if(s!=="waiting"||!a)return;let t=!1;const x=Date.now(),o=setInterval(()=>{if(Date.now()-x>N){clearInterval(o),t||n("timeout");return}f().then(h=>{t||(h||[]).some(p=>p.environment_id===a)&&(clearInterval(o),window.location.href="/code/")}).catch(()=>{})},v);return()=>{t=!0,clearInterval(o)}},[s,a]),s==="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..."})}):s==="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:m}),e.jsx("a",{href:"/code",className:"mt-4 inline-block text-accent hover:underline",children:"Back to dashboard"})]}):s==="waiting"||s==="timeout"?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:[a&&e.jsx("p",{className:"font-mono text-xs text-text-muted",children:a}),s==="waiting"?e.jsxs("p",{className:"text-sm text-text-muted",children:["Waiting for the worker to create a session",e.jsx("span",{className:"animate-pulse",children:"…"})]}):e.jsx("p",{className:"text-sm text-text-muted",children:"The worker has not created a session yet — it may be offline or stopped. The session will appear on the dashboard once the worker connects."}),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"})]})]}):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..."})})}export{E as Claim};
@@ -0,0 +1,6 @@
1
+ import{j as e,e as n}from"./vendor-DE_-CLIE.js";import{ai as O,ag as S,aC as D,aA as L,z as F,aB as M,aw as a,al as A,r as R,t as $,e as W,s as q,d as I,ao as H,N as Q,aa as V,Y as z,$ as U,W as Y}from"./main-B67FXcTf.js";import{g as T}from"./workerType-Bd-zteMi.js";import{S as Z}from"./SessionVisibilityBadge-I2lLxC5g.js";import{D as G,a as J,c as K,d as X,b as ee}from"./dialog-Ci9ytkis.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 te=[["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"}]],se=O("folder",te);function re({teamName:c,className:u}){return c?e.jsx("span",{className:S("inline-flex items-center rounded-full border border-border/60 bg-surface-2 px-2 py-0.5 text-xs text-text-muted",u),children:c}):null}function ae({environments:c,onSelectEnvironment:u}){const{activeTeam:b}=D(),{user:p}=L(),i=n.useMemo(()=>(p==null?void 0:p.role)==="admin"?c:b?c.filter(l=>l.team_id===b.id):c.filter(l=>!l.team_id),[c,b,p]);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(l=>{const m=l.worker_type==="acp",j=T(l.worker_type),h=j.fullLabel,g=j.colorClass;return e.jsxs("button",{type:"button",onClick:()=>u==null?void 0:u(l),disabled:m,className:`flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors ${m?"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:l.machine_name||l.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${g}`,children:h}),e.jsx(re,{teamName:l.team_name??null})]}),e.jsx("div",{className:"text-sm text-text-muted",children:l.directory||""})]})}),e.jsxs("div",{className:"text-right",children:[e.jsx(F,{status:l.status}),e.jsx("div",{className:"mt-1 text-xs text-text-muted",children:l.branch||""})]})]},l.id)})})}function ne({sessions:c,environments:u,onSelect:b,onDelete:p}){M();const{activeTeam:i,myTeams:l}=D(),{user:m}=L(),j=n.useMemo(()=>{const t=new Map;for(const d of l)t.set(d.id,d.name);return t},[l]),h=n.useMemo(()=>(m==null?void 0:m.role)==="admin"?c:i?c.filter(t=>t.owner_type==="team"&&t.owner_id===i.id):c.filter(t=>t.owner_type==="user"||t.access_level==="write"||t.access_level==="read"),[c,i,m]),{mySessions:g,sharedSessions:v}=n.useMemo(()=>{const t=[],d=[];for(const o of h)i?t.push(o):o.access_level==="write"||o.access_level==="read"?d.push(o):t.push(o);return{mySessions:t,sharedSessions:d}},[h,i]),w=new Map;for(const t of u??[])t!=null&&t.id&&t.worker_type&&w.set(t.id,t.worker_type);const N=(t,d)=>(d.updated_at||0)-(t.updated_at||0);function f(t){const d=!!p&&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:()=>b(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 x;let o=t.source==="acp"?"acp":(x=t.environment)==null?void 0:x.worker_type;!o&&t.environment_id&&(o=w.get(t.environment_id));const r=T(o);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${r.colorClass}`,children:r.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:j.get(t.owner_id)||t.owner_id})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(F,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:A(t.created_at||t.updated_at)}),d&&e.jsx("button",{type:"button",onClick:o=>{o.stopPropagation(),p(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(h.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 y=[...g].sort(N),k=[...v].sort(N);return e.jsxs("div",{className:"space-y-4",children:[y.length>0&&e.jsxs("section",{className:"space-y-2",children:[!i&&k.length>0&&e.jsx("h3",{className:"px-1 text-xs font-medium uppercase tracking-wide text-text-muted",children:a("session.mySessions")}),y.map(f)]}),k.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")}),k.map(f)]})]})}function le({open:c,environments:u,onClose:b,onCreated:p}){M();const{activeTeam:i}=D(),{user:l}=L(),[m,j]=n.useState(""),[h,g]=n.useState(""),[v,w]=n.useState("same-dir"),[N,f]=n.useState(""),[y,k]=n.useState(!1),[t,d]=n.useState(!1),o=n.useMemo(()=>(l==null?void 0:l.role)==="admin"?u:i?u.filter(s=>s.team_id===i.id):u.filter(s=>!s.team_id),[u,i,l]);n.useEffect(()=>{c&&(j(""),g(""),w("same-dir"),f(""),d(!1))},[c]);const r=o.find(s=>s.id===h)||null,x=r?o.findIndex(s=>s.id===r.id)+1:null,_=async()=>{k(!0),f("");try{const s={};m.trim()&&(s.title=m.trim()),h&&(s.environment_id=h),s.spawn_mode=v;const C=H();C&&(s.team_id=C);const E=await Q(s);p(E)}catch(s){f(s instanceof Error?s.message:a("dialog.createFailed"))}finally{k(!1)}};return e.jsx(G,{open:c,onOpenChange:s=>{s||b()},children:e.jsxs(J,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(K,{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:m,onChange:s=>j(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(R,{open:t,onOpenChange:d,children:[e.jsx($,{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:S("flex items-center gap-2 truncate",!r&&"text-text-muted"),children:r?e.jsxs(e.Fragment,{children:[x!==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:["#",x]}),e.jsx("span",{className:"truncate",children:r.machine_name||r.id}),e.jsx("span",{className:"shrink-0 text-text-muted",children:"·"}),e.jsx("span",{className:"shrink-0 text-text-muted",children:T(r.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(q,{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(""),d(!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")}),!h&&e.jsx(I,{className:"h-3.5 w-3.5 text-brand"})]}),o.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:o.map((s,C)=>{const E=T(s.worker_type),P=!!s.team_id,B=s.id===h;return e.jsxs("button",{type:"button",onClick:()=>{g(s.id),d(!1)},className:S("flex w-full flex-col gap-1.5 rounded-md px-3 py-2 text-left transition-colors",B?"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:["#",C+1]}),e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.machine_name||s.id}),e.jsx("span",{className:S("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium",E.colorClass),children:E.shortLabel}),e.jsx("span",{className:S("shrink-0 rounded-full border px-2 py-0.5 text-[10px] font-medium",P?"border-border/60 bg-surface-2 text-text-muted":"border-brand/30 bg-brand/10 text-brand"),children:P?`${a("dialog.envTeam")}: ${s.team_name||s.team_id}`:a("dialog.envPersonal")}),B&&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(se,{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=>w(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")})]})]}),N&&e.jsx("div",{className:"text-sm text-status-error",children:N})]}),e.jsxs(ee,{children:[e.jsx("button",{onClick:b,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:_,disabled:y,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:y?a("common.creating"):a("common.create")})]})]})})}function pe({onNavigateSession:c}){M();const[u,b]=n.useState([]),[p,i]=n.useState([]),[l,m]=n.useState(!1),[j,h]=n.useState(""),[g,v]=n.useState(null),[w,N]=n.useState(!1),f=n.useRef(0);n.useEffect(()=>{const r=j.trim();if(!r){f.current+=1,v(null),N(!1);return}N(!0);const x=++f.current,_=setTimeout(()=>{V(r).then(s=>{f.current===x&&v(s.results??[])}).catch(()=>{f.current===x&&v([])}).finally(()=>{f.current===x&&N(!1)})},300);return()=>clearTimeout(_)},[j]);const y=n.useCallback(async()=>{try{const[r,x]=await Promise.all([z(),U()]);b(r||[]),i(x||[])}catch(r){console.error("Dashboard render error:",r)}},[]);n.useEffect(()=>{y();const r=setInterval(y,5e3);return window.addEventListener("focus",y),()=>{clearInterval(r),window.removeEventListener("focus",y)}},[y]);const k=r=>{m(!1),c(r.id)},t=n.useCallback(r=>{},[]),d=n.useCallback(r=>{c(r)},[c]),o=n.useCallback(async r=>{if(window.confirm(a("dashboard.confirmDelete").replace("{id}",r)))try{await Y(r),b(x=>x.filter(_=>_.id!==r))}catch(x){alert(x instanceof Error?x.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(ae,{environments:p,onSelectEnvironment:t})]}),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:()=>m(!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.jsxs("div",{className:"mb-6 flex items-center gap-2 rounded-lg border border-border bg-surface-2 px-3 py-2",children:[e.jsxs("svg",{className:"h-4 w-4 flex-shrink-0 text-text-muted",fill:"none",stroke:"currentColor",strokeWidth:"2",viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]}),e.jsx("input",{value:j,onChange:r=>h(r.target.value),placeholder:a("dashboard.searchPlaceholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),w&&e.jsx("span",{className:"flex-shrink-0 text-xs text-text-muted",children:"搜索中…"})]}),g!==null?e.jsxs("div",{className:"space-y-2",children:[g.length===0&&!w&&e.jsx("p",{className:"text-sm text-text-muted",children:a("dashboard.searchNoResults")}),g.map(r=>e.jsxs("button",{type:"button",onClick:()=>c(r.session_id),className:"block w-full rounded-lg border border-border bg-surface-1 px-4 py-3 text-left transition-colors hover:bg-surface-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-text-primary",children:r.title||r.session_id}),e.jsxs("span",{className:"flex-shrink-0 text-xs text-text-muted",children:[r.match_count," 处匹配"]})]}),e.jsx("p",{className:"mt-1 line-clamp-2 text-xs leading-relaxed text-text-muted",children:r.snippet})]},r.session_id))]}):e.jsx(ne,{sessions:u,environments:p,onSelect:d,onDelete:o})]}),e.jsx(le,{open:l,environments:p,onClose:()=>m(!1),onCreated:k})]})})}export{pe as Dashboard};
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{at as v,ap as t}from"./main-uW6v3W3M.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{aA as v,aw as t}from"./main-B67FXcTf.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function E({onSuccess:b,onInvalidInvite:l}){const{join:h}=v(),[u,f]=r.useState(""),[d,j]=r.useState(""),[o,w]=r.useState(""),[c,g]=r.useState(""),[m,n]=r.useState(""),[x,p]=r.useState(!1);r.useEffect(()=>{const a=new URLSearchParams(window.location.search).get("invite");a?f(a):l()},[l]);const y=async s=>{if(s.preventDefault(),n(""),o.length<8){n(t("auth.setup.passwordTooShort"));return}if(o!==c){n(t("auth.setup.passwordMismatch"));return}p(!0);try{await h(u,d,o),b()}catch(a){const i=a instanceof Error?a.message:"Join failed";if(i.includes("Invalid invitation")||i.includes("expired")||i.includes("already used")){l();return}n(i)}finally{p(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.join.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.join.welcome")}),e.jsx("p",{className:"mt-1 text-sm text-text-muted",children:t("auth.join.description")})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.username")}),e.jsx("input",{type:"text",value:d,onChange:s=>j(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>w(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:c,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),m&&e.jsx("p",{className:"text-sm text-status-error",children:m}),e.jsx("button",{type:"submit",disabled:x||!u,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:x?t("common.loading"):t("auth.join.submit")})]})]})})}export{E as Join};
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{at as f,ap as t}from"./main-uW6v3W3M.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function v({onSuccess:u,onNavigateRegister:c}){const{login:m,registrationAllowed:x,singleUserMode:p}=f(),[a,b]=r.useState(""),[o,h]=r.useState(""),[n,l]=r.useState(""),[i,d]=r.useState(!1),g=async s=>{s.preventDefault(),l(""),d(!0);try{await m(a,o),u()}catch{l(t("auth.login.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.login.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.login.description")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[p&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2 text-xs text-text-secondary",children:[e.jsx("p",{children:t("auth.login.singleUserHint")}),e.jsx("p",{className:"mt-1 font-mono text-text-primary",children:"admin / admin123"}),e.jsx("p",{className:"mt-1 text-text-muted",children:t("auth.login.singleUserHintFooter")})]}),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=>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:o,onChange:s=>h(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"})]}),n&&e.jsx("p",{className:"text-sm text-status-error",children:n}),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{v as Login};
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aA as f,aw as t}from"./main-B67FXcTf.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function v({onSuccess:u,onNavigateRegister:c}){const{login:m,registrationAllowed:x,singleUserMode:p}=f(),[a,b]=r.useState(""),[o,h]=r.useState(""),[n,l]=r.useState(""),[i,d]=r.useState(!1),g=async s=>{s.preventDefault(),l(""),d(!0);try{await m(a,o),u()}catch{l(t("auth.login.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.login.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.login.description")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[p&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2 text-xs text-text-secondary",children:[e.jsx("p",{children:t("auth.login.singleUserHint")}),e.jsx("p",{className:"mt-1 font-mono text-text-primary",children:"admin / admin123"}),e.jsx("p",{className:"mt-1 text-text-muted",children:t("auth.login.singleUserHintFooter")})]}),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=>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:o,onChange:s=>h(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"})]}),n&&e.jsx("p",{className:"text-sm text-status-error",children:n}),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{v as Login};
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{at as y,ap as t}from"./main-uW6v3W3M.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{aA as w,aw as t}from"./main-B67FXcTf.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function S({onSuccess:m,onBack:x}){const{register:p}=w(),[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,83 @@
1
+ var fs=Object.defineProperty;var hs=(r,t,s)=>t in r?fs(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var T=(r,t,s)=>hs(r,typeof t!="symbol"?t+"":t,s);import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{ai as P,a1 as gs,aq as gt,ap as yt,as as ys,ar as Je,ac as bs,am as X,ab as F,a4 as js,a9 as ws,z as Dt,g as bt,al as Ot,L as ue,G as ks,aj as tt,S as Xe,M as Ns,v as vs,X as _s,y as Ss,ak as U,ag as de,d as Ee,ax as jt,a5 as Cs,Q as Es,a8 as Ms,aB as Ut,aw as v,A as Ts,an as Rs,at as $s,au as As,J as Is,ay as qs,b as Ps,W as wt,a6 as Ds,E as Ft,P as Os,F as Us,c as Fs,C as Bs,a0 as Ls,D as Hs,a as Ws,r as Me,t as Te,x as Qs,f as Re,e as $e,s as Ae,p as zs,B as Vs}from"./main-B67FXcTf.js";import{g as Ks}from"./workerType-Bd-zteMi.js";import{D as me,a as xe,c as pe,d as fe,b as Gs}from"./dialog-Ci9ytkis.js";import{R as Ys}from"./refresh-cw-CgJEBffB.js";import{E as Js,A as Xs}from"./ArtifactsGallery--KEN5Q2C.js";import{S as Zs}from"./SessionVisibilityBadge-I2lLxC5g.js";import{U as en}from"./UserSearchInput-DOlIGv2X.js";import{S as tn,b as sn}from"./notifications-D9_SRqI0.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";import"./copy-DIHZ4Rnp.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 nn=[["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"}]],rn=P("activity",nn);/**
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 an=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],on=P("chevron-right",an);/**
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 ln=[["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"}]],Bt=P("cpu",ln);/**
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 cn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],dn=P("gauge",cn);/**
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 un=[["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"}]],mn=P("hash",un);/**
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 xn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],pn=P("info",xn);/**
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 fn=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Lt=P("message-circle-question-mark",fn);/**
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 hn=[["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"}]],gn=P("message-square-text",hn);/**
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 yn=[["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"}]],bn=P("play",yn);/**
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 jn=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Ht=P("plug",jn);/**
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 wn=[["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"}]],kn=P("server-cog",wn);/**
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 Nn=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Wt=P("settings-2",Nn);/**
62
+ * @license lucide-react v0.555.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const vn=[["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"}]],_n=P("share-2",vn);/**
67
+ * @license lucide-react v0.555.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Sn=[["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"}]],Cn=P("shield-check",Sn);/**
72
+ * @license lucide-react v0.555.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const En=[["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"}]],Mn=P("triangle-alert",En);function Qt(){return{tasks:{}}}const kt=3e4;function Se(r){const t=r.trim();if(!t)return"agent";const s=t.split(/\s+/).slice(0,2).join(" ");return s.length>40?s.slice(0,40)+"…":s}function Tn(r,t){var l,m,b,h,y,j,N,C,u,i,g,p;const s=t.subtype;if(s!=="task_started"&&s!=="task_progress"&&s!=="task_notification")return r;const n=t.task_id;if(!n)return r;const o=Date.now(),c=r.tasks[n];if(s==="task_started"){if(c)return{tasks:{...r.tasks,[n]:{...c,description:t.description??c.description,name:Se(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:o,evictAfter:void 0}}};const f=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:Se(f),description:f,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:o}}}}if(s==="task_progress"){if(!c){const f=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:Se(f),description:f,toolUseId:t.tool_use_id,status:"running",startTime:o,tokenCount:(l=t.usage)==null?void 0:l.total_tokens,toolUseCount:(m=t.usage)==null?void 0:m.tool_uses,durationMs:(b=t.usage)==null?void 0:b.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...r.tasks,[n]:{...c,description:t.description??c.description,tokenCount:((h=t.usage)==null?void 0:h.total_tokens)??c.tokenCount,toolUseCount:((y=t.usage)==null?void 0:y.tool_uses)??c.toolUseCount,durationMs:((j=t.usage)==null?void 0:j.duration_ms)??c.durationMs,lastToolName:t.last_tool_name??c.lastToolName,summary:t.summary??c.summary}}}}return c?{tasks:{...r.tasks,[n]:{...c,status:t.status??"completed",endTime:o,finalSummary:t.summary??c.finalSummary,outputFile:t.output_file??c.outputFile,tokenCount:((i=t.usage)==null?void 0:i.total_tokens)??c.tokenCount,toolUseCount:((g=t.usage)==null?void 0:g.tool_uses)??c.toolUseCount,durationMs:((p=t.usage)==null?void 0:p.duration_ms)??c.durationMs,evictAfter:o+kt}}}:{tasks:{...r.tasks,[n]:{taskId:n,name:Se(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:o,endTime:o,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(C=t.usage)==null?void 0:C.tool_uses,durationMs:(u=t.usage)==null?void 0:u.duration_ms,evictAfter:o+kt}}}}function Rn(r,t=Date.now()){return Object.values(r.tasks).filter(s=>s.evictAfter===void 0||s.evictAfter>t).sort((s,n)=>s.startTime-n.startTime)}function $n(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const t=r,s={file_search:t.file_search===!0,clear:t.clear===!0,set_max_thinking_tokens:t.set_max_thinking_tokens===!0,get_context_usage:t.get_context_usage===!0,stop_task:t.stop_task===!0,set_model:t.set_model===!0,set_permission_mode:t.set_permission_mode===!0,interrupt:t.interrupt===!0,end_session:t.end_session===!0,mcp_management:t.mcp_management===!0,remote_settings:t.remote_settings===!0,rewind:t.rewind===!0,set_effort:t.set_effort===!0,side_question:t.side_question===!0};return Object.values(s).some(Boolean)?s:null}function Nt(r,t){const s=[];if(Array.isArray(r)){for(const n of r){if(!n||typeof n!="object")continue;const o=n;if(typeof o.name!="string"||!o.name)continue;const c=o.type==="prompt"||o.type==="local"||o.type==="local-jsx"?o.type:void 0;s.push({name:o.name,...typeof o.description=="string"&&o.description?{description:o.description}:{},...typeof o.argumentHint=="string"&&o.argumentHint?{argumentHint:o.argumentHint}:{},...c?{type:c}:{}})}if(s.length>0)return s}if(Array.isArray(t))for(const n of t)typeof n=="string"&&n&&s.push({name:n});return s}function vt(r){const t=r.raw&&typeof r.raw=="object"&&!Array.isArray(r.raw)?r.raw:r,s=Nt(t.slash_command_details??r.slash_command_details,t.slash_commands??r.slash_commands),n=Nt(t.skill_details??r.skill_details,t.skills??r.skills),o=$n(t.remote_capabilities??r.remote_capabilities);return s.length===0&&n.length===0&&!o?null:{commands:s,skills:n,capabilities:o}}class An{constructor(){T(this,"listeners",new Set);T(this,"eventSource",null);T(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const s=`/web/sessions/${t}/events`,n=new EventSource(s,{withCredentials:!0});this.eventSource=n,n.addEventListener("message",o=>{try{const c=JSON.parse(o.data);if(c.seqNum!==void 0&&c.seqNum<=this._lastSeqNum)return;c.seqNum!==void 0&&(this._lastSeqNum=c.seqNum);for(const l of this.listeners)l(c)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const Ce=new An;function _t(r){if(typeof r.content=="string")return r.content;if(r.message&&typeof r.message=="object"){const t=r.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(s=>s.type==="text"&&typeof s.text=="string").map(s=>s.text).join("")}return""}function St(r,t){for(let s=r.length-1;s>=0;s--){const n=r[s];if(n&&n.type==="tool_call"&&n.toolCall.id===t)return s}return-1}const Ke="streaming-";function In(r){const t=r.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const s=[];for(const n of t.content)if((n==null?void 0:n.type)==="thinking"){const o=typeof n.thinking=="string"&&n.thinking||typeof n.text=="string"&&n.text||"";o&&s.push(o)}return s.join("")}function Ct(r){return r.filter(t=>typeof t.subject=="string"&&t.subject).map(t=>({content:t.subject,priority:"medium",status:t.status==="completed"?"completed":t.status==="in_progress"?"in_progress":"pending"}))}function Et(r){if(!r||typeof r!="object")return"";const t=r;if(typeof t.target_event_id=="string"&&t.target_event_id)return t.target_event_id;const s=t.raw;if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s.target_event_id;if(typeof n=="string"&&n)return n}return""}class qn{constructor(t,s,n){T(this,"sessionId");T(this,"setEntries");T(this,"unsub",null);T(this,"onStatusChange");T(this,"onError");T(this,"onPermissionRequest");T(this,"onModelsStateChange");T(this,"onSubagentUpdate");T(this,"onControlResponse");T(this,"onPermissionModeChange");T(this,"onUsageChange");T(this,"onElicitationRequest");T(this,"onWorkerInfoChange");T(this,"subagentState",Qt());T(this,"seenUuids",new Set);T(this,"seenToolCallIds",new Set);T(this,"pendingControlRequests",new Map);T(this,"turnEnded",!1);T(this,"userSinceTurnEnd",!1);T(this,"closed",!1);this.sessionId=t,this.setEntries=s,this.onStatusChange=n==null?void 0:n.onStatusChange,this.onError=n==null?void 0:n.onError,this.onPermissionRequest=n==null?void 0:n.onPermissionRequest,this.onModelsStateChange=n==null?void 0:n.onModelsStateChange,this.onSubagentUpdate=n==null?void 0:n.onSubagentUpdate,this.onControlResponse=n==null?void 0:n.onControlResponse,this.onPermissionModeChange=n==null?void 0:n.onPermissionModeChange,this.onUsageChange=n==null?void 0:n.onUsageChange,this.onElicitationRequest=n==null?void 0:n.onElicitationRequest,this.onWorkerInfoChange=n==null?void 0:n.onWorkerInfoChange}markClosed(){this.closed=!0}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var y,j,N,C,u;const{events:t}=await gs(this.sessionId);if(!t||t.length===0)return;const s=[];let n=null;const o=()=>{n&&(s.push(n),n=null)};for(const i of t){const g=i.payload||{},p=g.uuid;if(typeof p=="string"&&p&&this.seenUuids.add(p),i.type==="tool_use"){const f=g.tool_call_id;typeof f=="string"&&f&&this.seenToolCallIds.add(f)}if(i.type==="user"){if(i.direction==="inbound")continue;o();const f=_t(g);f&&s.push({type:"user_message",id:i.id||`hist-user-${s.length}`,content:f})}else if(i.type==="assistant"){o();const f=_t(g);if(gt(f))continue;const w=[],S=g.message;if(S&&typeof S=="object"&&Array.isArray(S.content)){for(const R of S.content)if(R.type==="tool_use"){const A=R.id;A&&this.seenToolCallIds.add(A),w.push({type:"tool_call",toolCall:{id:A||`hist-tool-${s.length}`,title:R.name||"tool",status:"complete",rawInput:R.input||{}}})}}if(f||w.length>0){n={type:"assistant_message",id:i.id||`hist-asst-${s.length}`,chunks:f?[{type:"message",text:f}]:[]},s.push(n);for(const R of w)s.push(R);n=null}}else if(i.type==="conversation_rewound"){const f=Et(g);if(f){const w=s.findIndex(S=>yt(S)===f);w>=0&&(s.length=w)}}else if(i.type==="tool_use"){const f=g,w={type:"tool_call",toolCall:{id:f.tool_call_id||`hist-tool-${s.length}`,title:f.tool_name||"tool",status:"complete",rawInput:f.tool_input||{}}};s.push(w)}else if(i.type==="tool_result"){const f=g,w=St(s,f.tool_call_id||"");if(w>=0){const S=s[w];s[w]={type:"tool_call",toolCall:{...S.toolCall,rawOutput:{output:f.content||f.output||""}}}}}}o();let c=null;for(const i of t){if(i.type!=="task_state")continue;const g=i.payload||{};Array.isArray(g.tasks)&&(c=g.tasks)}if(c&&c.length>0){const i=Ct(c);i.length>0&&s.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:i})}this.setEntries(s);let l=null,m=null,b=null,h=null;for(const i of t){const g=i.payload||{};if(i.type==="user"?h="user":(i.type==="result"||i.type==="result_success"||i.type==="interrupt")&&(h="turn_end"),i.type==="system"&&(g.subtype==="init"||((y=g.raw)==null?void 0:y.subtype)==="init")&&(m=vt(g)),i.type==="models_state"){const p=g.raw,f=p&&typeof p=="object"?p.models_state:g.models_state;f&&Array.isArray(f.availableModels)&&typeof f.currentModelId=="string"&&(l=f)}else if(i.type==="result"||i.type==="result_success"){const p=g.usage,f=typeof g.total_cost_usd=="number"?g.total_cost_usd:null;(p||f!==null)&&(b={inputTokens:((p==null?void 0:p.input_tokens)??0)+((p==null?void 0:p.cache_read_input_tokens)??0)+((p==null?void 0:p.cache_creation_input_tokens)??0),outputTokens:(p==null?void 0:p.output_tokens)??0,totalCostUsd:f})}}l&&((j=this.onModelsStateChange)==null||j.call(this,l)),m&&((N=this.onWorkerInfoChange)==null||N.call(this,m)),b&&((C=this.onUsageChange)==null||C.call(this,b)),this.turnEnded=h==="turn_end",this.userSinceTurnEnd=h==="user",this.turnEnded&&!this.closed&&((u=this.onStatusChange)==null||u.call(this,"idle"))}connectSSE(){Ce.connect(this.sessionId),this.unsub=Ce.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),Ce.disconnect()}handleEvent(t){var o,c,l,m,b,h,y,j,N,C;const s=t.type,n=t.payload||{};switch(s){case"user":{this.userSinceTurnEnd=!0;break}case"assistant":{const u=n.uuid;if(typeof u=="string"&&u){if(this.seenUuids.has(u))break;this.seenUuids.add(u)}const i=typeof n.content=="string"?n.content:"";if(gt(i))break;const g=In(n);this.setEntries(f=>{const w=f[f.length-1];if((w==null?void 0:w.type)==="assistant_message"&&w.id.startsWith(Ke))return[...f.slice(0,-1),{...w,id:`assistant-${Date.now()}`,chunks:[...g?[{type:"thought",text:g}]:[],{type:"message",text:i}]}];if((w==null?void 0:w.type)==="assistant_message"){const S=w.chunks[w.chunks.length-1];return(S==null?void 0:S.type)==="message"?[...f.slice(0,-1),{...w,chunks:[...w.chunks.slice(0,-1),{type:"message",text:S.text+i}]}]:[...f.slice(0,-1),{...w,chunks:[...w.chunks,{type:"message",text:i}]}]}if(i&&i.trim()||g){const S={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...g?[{type:"thought",text:g}]:[],...i?[{type:"message",text:i}]:[]]};return[...f,S]}return f});const p=n.message;if(p&&typeof p=="object"&&Array.isArray(p.content)){const f=p.content.filter(w=>w.type==="tool_use");for(const w of f){const S=w.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(S))continue;this.seenToolCallIds.add(S);const R={id:S,title:w.name||"tool",status:"running",rawInput:w.input||{}};this.setEntries(A=>[...A,{type:"tool_call",toolCall:R}])}}break}case"tool_use":{const u=n,i=u.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(i))break;this.seenToolCallIds.add(i);const g={id:i,title:u.tool_name||"tool",status:"running",rawInput:u.tool_input||{}};this.setEntries(p=>[...p,{type:"tool_call",toolCall:g}]);break}case"tool_result":{const u=n,i=u.tool_call_id||"";this.setEntries(g=>{const p=St(g,i);if(p<0)return g;const f=g[p];return g.map((w,S)=>S===p?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:u.content||u.output||""}}}:w)});break}case"control_request":case"permission_request":{const u=n.request;if(u&&u.subtype==="can_use_tool"){const i=n.request_id||"",g=u.tool_name||"unknown",p=u.input||u.tool_input||{},f=u.description||"",w=Array.isArray(u.permission_suggestions)?u.permission_suggestions:[];this.setEntries(S=>{const R=[...S].reverse().findIndex(A=>A.type==="tool_call");if(R>=0){const A=S.length-1-R,W=S[A];if(W.toolCall.status==="running")return S.map((Q,K)=>K===A?{type:"tool_call",toolCall:{...W.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:i,options:[]}}}:Q)}return S}),(o=this.onPermissionRequest)==null||o.call(this,{requestId:i,toolName:g,toolInput:p,description:f,suggestions:w})}else u&&u.subtype==="elicitation"&&((c=this.onElicitationRequest)==null||c.call(this,{requestId:n.request_id||"",serverName:u.mcp_server_name||"",message:u.message||"",mode:u.mode==="url"?"url":"form",url:typeof u.url=="string"?u.url:void 0,requestedSchema:u.requested_schema||void 0}));break}case"conversation_rewound":{const u=Et(n);u&&this.setEntries(i=>{const g=i.findIndex(p=>yt(p)===u);return g===-1?i:i.slice(0,g)});break}case"session_status":{if(ys(n)){this.setEntries([]);break}if(typeof n.status=="string"){if(Je(n.status))this.closed=!0;else if(this.closed)break;if(n.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(l=this.onStatusChange)==null||l.call(this,n.status)}break}case"error":{const u=String(n.message||n.content||"Unknown error");(m=this.onError)==null||m.call(this,u);break}case"models_state":{const u=n.raw,i=typeof u=="object"&&u!==null?u.models_state:n.models_state;i&&Array.isArray(i.availableModels)&&typeof i.currentModelId=="string"&&((b=this.onModelsStateChange)==null||b.call(this,i));break}case"system":{const u=n.raw,i=u&&typeof u=="object"?u:n,g=typeof i.subtype=="string"?i.subtype:void 0;if(g==="task_started"||g==="task_progress"||g==="task_notification"){const f={subtype:g,task_id:typeof i.task_id=="string"?i.task_id:void 0,tool_use_id:typeof i.tool_use_id=="string"?i.tool_use_id:void 0,description:typeof i.description=="string"?i.description:void 0,task_type:typeof i.task_type=="string"?i.task_type:void 0,workflow_name:typeof i.workflow_name=="string"?i.workflow_name:void 0,prompt:typeof i.prompt=="string"?i.prompt:void 0,usage:i.usage&&typeof i.usage=="object"?i.usage:void 0,last_tool_name:typeof i.last_tool_name=="string"?i.last_tool_name:void 0,summary:typeof i.summary=="string"?i.summary:void 0,status:i.status==="completed"||i.status==="failed"||i.status==="stopped"?i.status:void 0,output_file:typeof i.output_file=="string"?i.output_file:void 0};this.subagentState=Tn(this.subagentState,f)}const p=typeof i.permissionMode=="string"?i.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;if(p&&((h=this.onPermissionModeChange)==null||h.call(this,p)),g==="init"){const f=vt(n);f&&((y=this.onWorkerInfoChange)==null||y.call(this,f))}break}case"control_response":{const u=n.response;if(u&&typeof u=="object"){const i=typeof u.request_id=="string"?u.request_id:"",g=typeof u.subtype=="string"?u.subtype:"";if(i){(j=this.onControlResponse)==null||j.call(this,{subtype:g,requestId:i,error:typeof u.error=="string"?u.error:void 0});const p=this.pendingControlRequests.get(i);p&&(this.pendingControlRequests.delete(i),p({data:g==="success"&&u.response&&typeof u.response=="object"?u.response:null,...g==="error"&&typeof u.error=="string"?{error:u.error}:{}}))}}break}case"stream_event":{const u=n.event;if(!u||typeof u.type!="string")break;if(u.type==="content_block_delta"){const i=u.delta;if(!i||typeof i.type!="string")break;const g=i.type==="text_delta"?"message":i.type==="thinking_delta"?"thought":null;if(!g)break;const p=i.text??i.thinking;if(typeof p!="string"||!p)break;this.appendStreamingDelta(g,p)}break}case"partial_assistant":{const u=typeof n.content=="string"?n.content:"";u&&this.appendStreamingDelta("message",u);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,this.closed||(N=this.onStatusChange)==null||N.call(this,"idle");const u=n.usage,i=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(u||i!==null){const g=((u==null?void 0:u.input_tokens)??0)+((u==null?void 0:u.cache_read_input_tokens)??0)+((u==null?void 0:u.cache_creation_input_tokens)??0);(C=this.onUsageChange)==null||C.call(this,{inputTokens:g,outputTokens:(u==null?void 0:u.output_tokens)??0,totalCostUsd:i})}break}case"task_state":{const u=Array.isArray(n.tasks)?n.tasks:[];if(u.length===0)break;const i=Ct(u);if(i.length===0)break;this.setEntries(g=>[...g.filter(f=>f.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:i}]);break}}}appendStreamingDelta(t,s){this.setEntries(n=>{const o=n[n.length-1];if((o==null?void 0:o.type)==="assistant_message"&&o.id.startsWith(Ke)){const l=o.chunks[o.chunks.length-1];return(l==null?void 0:l.type)===t?[...n.slice(0,-1),{...o,chunks:[...o.chunks.slice(0,-1),{type:t,text:l.text+s}]}]:[...n.slice(0,-1),{...o,chunks:[...o.chunks,{type:t,text:s}]}]}const c={type:"assistant_message",id:`${Ke}${Date.now()}`,chunks:[{type:t,text:s}]};return[...n,c]})}async sendMessage(t,s,n){var h;const o=s&&s.length>0,c=n&&n.length>0;if(!t.trim()&&!o&&!c)return;const l={type:"user_message",id:`user-${Date.now()}`,content:t,images:o?s:void 0,attachments:c?n:void 0};this.setEntries(y=>[...y,l]);const m=[];if(t&&m.push({type:"text",text:t}),o)for(const y of s)m.push({type:"image",source:{type:"base64",media_type:y.mimeType,data:y.data}});if(c){for(const y of n)if(y.kind==="text"||y.kind==="table"){const j=`📎 ${y.name}${y.size!=null?` (${Pn(y.size)})`:""}`,N=y.textContent||"(空文件)";m.push({type:"text",text:`${j}
77
+ \`\`\`
78
+ ${N}
79
+ \`\`\``})}else if(y.kind==="directory"){const j=`📁 目录: ${y.name}${y.files!=null?` (${y.files.length} 个文件)`:""}`,N=y.textContent||"(空目录)";m.push({type:"text",text:`${j}
80
+ ${N}`})}}const b=m.length===1&&m[0].type==="text"?m[0].text||t:m.length>0?m:t;try{const y=await bs(this.sessionId,{type:"user",uuid:X(),content:t,message:{content:b}}),j=(h=y==null?void 0:y.event)==null?void 0:h.id;j&&this.setEntries(N=>N.map(C=>C.type==="user_message"&&C.id===l.id?{...C,id:j}:C))}catch(y){throw this.setEntries(j=>j.filter(N=>!(N.type==="user_message"&&N.id===l.id))),y}}async respondPermission(t,s,n){await F(this.sessionId,{type:"permission_response",approved:s,request_id:t,...n}),this.setEntries(o=>o.map(c=>{var l;return c.type!=="tool_call"||((l=c.toolCall.permissionRequest)==null?void 0:l.requestId)!==t?c:{type:"tool_call",toolCall:{...c.toolCall,status:s?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(s=>s.type!=="tool_call"||s.toolCall.status!=="running"&&s.toolCall.status!=="waiting_for_confirmation"?s:{type:"tool_call",toolCall:{...s.toolCall,status:"canceled",permissionRequest:void 0}})),await js(this.sessionId)}async setPermissionMode(t){const s=X();return await F(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_permission_mode",mode:t}}),s}async controlRoundTrip(t,s=8e3){const n=X(),o=new Promise(l=>{this.pendingControlRequests.set(n,l)}),c=setTimeout(()=>{const l=this.pendingControlRequests.get(n);l&&(this.pendingControlRequests.delete(n),l({data:null,error:"timeout"}))},s);try{return await F(this.sessionId,{type:"control_request",request_id:n,request:t}),await o}catch(l){throw this.pendingControlRequests.delete(n),l}finally{clearTimeout(c)}}async searchFiles(t,s=20){const n=await this.controlRoundTrip({subtype:"file_search",query:t,limit:s});try{if(!n.data||!Array.isArray(n.data.suggestions))return[];const o=[];for(const c of n.data.suggestions)c&&typeof c=="object"&&typeof c.path=="string"&&o.push(c.path);return o}catch{return[]}}async respondElicitation(t,s,n){await F(this.sessionId,{type:"permission_response",approved:s==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:s,...n?{content:n}:{}}}})}async askSideQuestion(t){const s=await this.controlRoundTrip({subtype:"side_question",question:t},12e4);if(s.error||!s.data)return null;const n=s.data.response;return typeof n=="string"?n:null}async setEffort(t){const s=X();return await F(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),s}async setThinkingBudget(t){const s=X();return await F(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_max_thinking_tokens",max_thinking_tokens:t}}),s}async getContextUsage(){const t=await this.controlRoundTrip({subtype:"get_context_usage"});try{if(!t.data)return null;const s=t.data.totalTokens,n=t.data.rawMaxTokens,o=t.data.percentage;if(typeof s!="number"||typeof n!="number")return null;const c=t.data.categories,l=Array.isArray(c)?c.filter(m=>!!m&&typeof m=="object"&&typeof m.name=="string").map(m=>({name:m.name,tokens:typeof m.tokens=="number"?m.tokens:0,...m.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:n,percentage:typeof o=="number"?o:0,...typeof t.data.model=="string"&&t.data.model?{model:t.data.model}:{},...l&&l.length>0?{categories:l}:{}}}catch{return null}}async stopSubagent(t){const s=await this.controlRoundTrip({subtype:"stop_task",task_id:t});try{return s.error?{ok:!1,error:s.error==="timeout"?"停止请求超时":s.error}:{ok:!0}}catch{return{ok:!1,error:"停止请求失败"}}}async getMcpServers(){var o;const s=(o=(await this.controlRoundTrip({subtype:"mcp_status"})).data)==null?void 0:o.mcpServers;if(!Array.isArray(s))return[];const n=[];for(const c of s){if(!c||typeof c!="object")continue;const l=c;if(typeof l.name!="string"||!l.name)continue;const m=l.status;if(m!=="connected"&&m!=="failed"&&m!=="needs-auth"&&m!=="pending"&&m!=="disabled")continue;const b=l.serverInfo,h=l.config;n.push({name:l.name,status:m,...b&&typeof b.name=="string"&&typeof b.version=="string"?{serverInfo:{name:b.name,version:b.version}}:{},...typeof l.error=="string"&&l.error?{error:l.error}:{},...typeof(h==null?void 0:h.url)=="string"&&h.url?{url:h.url}:{},...Array.isArray(l.tools)?{toolCount:l.tools.length}:{}})}return n}async toggleMcpServer(t,s){const n=await this.controlRoundTrip({subtype:"mcp_toggle",serverName:t,enabled:s},15e3);return n.error?{ok:!1,error:n.error==="timeout"?"请求超时":n.error}:{ok:!0}}async reconnectMcpServer(t){const s=await this.controlRoundTrip({subtype:"mcp_reconnect",serverName:t},2e4);return s.error?{ok:!1,error:s.error==="timeout"?"请求超时":s.error}:{ok:!0}}async getRemoteSettings(){const s=(await this.controlRoundTrip({subtype:"get_settings"})).data;if(!s)return null;const n=s.applied,o=s.effective&&typeof s.effective=="object"&&!Array.isArray(s.effective)?s.effective:{},c=s.sources,l=[];if(Array.isArray(c))for(const m of c){if(!m||typeof m!="object")continue;const b=m;typeof b.source=="string"&&l.push({source:b.source,settings:b.settings&&typeof b.settings=="object"&&!Array.isArray(b.settings)?b.settings:{}})}return{applied:{model:typeof(n==null?void 0:n.model)=="string"?n.model:null,effort:typeof(n==null?void 0:n.effort)=="string"?n.effort:null},effective:o,sources:l}}async applyFlagSettings(t){const s=await this.controlRoundTrip({subtype:"apply_flag_settings",settings:t},15e3);return s.error?{ok:!1,error:s.error==="timeout"?"请求超时":s.error}:{ok:!0}}async rewindToMessage(t){await ws(this.sessionId,t)}async endSession(t){await F(this.sessionId,{type:"control_request",request_id:X(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function Pn(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function Dn(r){if(!r)return"never";const t=Math.max(0,Date.now()-r);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function On(r){return r?Date.now()-r<6e4:!1}function Un({onClose:r,session:t,liveStatus:s,pendingPermissions:n,onInterrupt:o,onDelete:c,onEndSession:l}){const[m,b]=d.useState(!1),h=async()=>{await navigator.clipboard.writeText(t.id),b(!0),setTimeout(()=>b(!1),1500)},[y,j]=d.useState(!1),N=async()=>{if(!(!l||y)&&window.confirm("结束 worker 会话?正在进行的回合将被中止,会话随后归档。")){j(!0);try{await l(),r()}catch{j(!1)}}},C=n.length,u=t.worker,i=t.work_item,g=t.environment;return e.jsx(me,{open:!0,onOpenChange:p=>{p||r()},children:e.jsxs(xe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(pe,{children:e.jsx(fe,{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(rn,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dt,{status:s||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:u&&(On(u.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[u&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(bt,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Dn(u.last_heartbeat_at)})]}),g&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Bt,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:g.machine_name||g.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(bt,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Ot(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(ue,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),C>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[C," permission request",C>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(kn,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:o,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"}),l&&e.jsx("button",{onClick:N,disabled:y,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"通知 worker 中止在途回合并退出,随后归档会话",children:y?"Ending…":"End session"}),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(ks,{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(mn,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:h,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:m?"✓":"⧉"})]})]}),i&&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:i.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:i.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})]}),g&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:g.worker_type})]})]})]})]})]})})}const Fn={connected:"bg-status-success/15 text-status-success",failed:"bg-status-error/15 text-status-error","needs-auth":"bg-status-warning/15 text-status-warning",pending:"bg-status-active/15 text-status-active",disabled:"bg-surface-3 text-text-muted"},Bn={connected:"已连接",failed:"失败","needs-auth":"待认证",pending:"连接中",disabled:"已禁用"};function Ln({onClose:r,fetchServers:t,onToggle:s,onReconnect:n}){const[o,c]=d.useState(null),[l,m]=d.useState(null),[b,h]=d.useState(null),[y,j]=d.useState(null),N=d.useCallback(async()=>{h(null),j(null);try{const i=await t();c(i),m(null)}catch(i){tt("[McpPanel] fetch failed",i),m("获取 MCP 状态失败 — worker 可能不支持")}},[t]);d.useEffect(()=>{N()},[N]);const C=async i=>{const g=i.status==="disabled";h(`toggle:${i.name}`),j(null);try{const p=await s(i.name,g);p.ok||j(p.error||"切换失败")}finally{await N()}},u=async i=>{h(`reconnect:${i.name}`),j(null);try{const g=await n(i.name);g.ok||j(g.error||"重连失败")}finally{await N()}};return e.jsx(me,{open:!0,onOpenChange:i=>{i||r()},children:e.jsxs(xe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(pe,{children:e.jsxs(fe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Ht,{className:"h-4 w-4"}),"MCP 服务器"]})}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[y&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:y}),o===null&&!l&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),"加载 MCP 状态…"]}),l&&e.jsx("p",{className:"text-xs text-status-error",children:l}),o!==null&&o.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:"没有配置 MCP 服务器"}),o==null?void 0:o.map(i=>{const g=b===`toggle:${i.name}`,p=b===`reconnect:${i.name}`,f=i.status==="disabled";return e.jsx("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-text-primary",children:i.name}),e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium ${Fn[i.status]}`,children:Bn[i.status]})]}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:[i.serverInfo?`${i.serverInfo.name} v${i.serverInfo.version}`:i.url||"stdio",i.toolCount!==void 0&&` · ${i.toolCount} 工具`]}),i.error&&e.jsx("div",{className:"mt-1 truncate text-xs text-status-error",title:i.error,children:i.error})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void u(i),disabled:p||f,className:"rounded-md p-1.5 text-text-muted hover:bg-surface-3 hover:text-text-primary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:"重连",children:e.jsx(Ys,{className:`h-3.5 w-3.5 ${p?"animate-spin":""}`})}),e.jsx("button",{type:"button",role:"switch","aria-checked":!f,onClick:()=>void C(i),disabled:g,className:`relative h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${f?"bg-surface-3":"bg-brand"}`,title:f?"启用":"禁用",children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${f?"left-0.5":"left-4.5"}`})})]})]})},i.name)})]})]})})}function Ge(r){if(r==null)return"(未设置)";if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}function Hn({onClose:r,fetchSettings:t,onApply:s}){const[n,o]=d.useState(null),[c,l]=d.useState(null),[m,b]=d.useState(""),[h,y]=d.useState(null),[j,N]=d.useState(null),C=d.useCallback(async()=>{y(null),N(null);try{const p=await t();o(p),l(p?null:"获取设置失败 — worker 可能不支持")}catch(p){tt("[SettingsDrawer] fetch failed",p),l("获取设置失败 — worker 可能不支持")}},[t]);d.useEffect(()=>{C()},[C]);const u=d.useMemo(()=>n?Object.entries(n.effective).filter(([,p])=>p!==void 0).sort(([p],[f])=>p.localeCompare(f)):[],[n]),i=d.useMemo(()=>{const p=m.trim().toLowerCase();return p?u.filter(([f,w])=>`${f} ${Ge(w)}`.toLowerCase().includes(p)):u},[u,m]),g=async(p,f)=>{y(p),N(null);try{const w=await s({[p]:!f});w.ok||N(w.error||"写入失败")}finally{await C()}};return e.jsx(me,{open:!0,onOpenChange:p=>{p||r()},children:e.jsxs(xe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-[26rem] h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(pe,{children:e.jsxs(fe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Wt,{className:"h-4 w-4"}),"会话设置"]})}),e.jsxs("div",{className:"mt-3 space-y-4 text-sm",children:[j&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:j}),n===null&&!c&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(ue,{className:"h-3.5 w-3.5 animate-spin"}),"加载设置…"]}),c&&e.jsx("p",{className:"text-xs text-status-error",children:c}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:"模型"}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.model||"(默认)"})]}),n.applied.effort&&e.jsxs("div",{className:"mt-1 flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:"Effort"}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.effort})]}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-text-muted",children:"布尔开关写入会话级 flag 层(apply_flag_settings);非布尔键为只读展示。"})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2.5 py-1.5",children:[e.jsx(Xe,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{value:m,onChange:p=>b(p.target.value),placeholder:"搜索设置项…",className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"})]}),i.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:"没有匹配的设置项"}),e.jsx("div",{className:"space-y-1.5",children:i.map(([p,f])=>{const w=typeof f=="boolean",S=h===p;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-mono text-xs text-text-primary",children:p}),!w&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[11px] text-text-muted",title:Ge(f),children:Ge(f)})]}),w?e.jsx("button",{type:"button",role:"switch","aria-checked":f,disabled:S,onClick:()=>void g(p,f),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${f?"bg-brand":"bg-surface-3"}`,title:f?"关闭(写入 false)":"开启(写入 true)",children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${f?"left-4.5":"left-0.5"}`})}):e.jsx("span",{className:"flex-shrink-0 text-[11px] text-text-muted",children:"只读"})]},p)})})]})]})]})})}function Wn({onClose:r,onAsk:t}){const[s,n]=d.useState([]),[o,c]=d.useState(""),[l,m]=d.useState(!1),b=async()=>{const h=o.trim();if(!h||l)return;const y=Date.now();n(j=>[...j,{id:y,question:h,answer:null}]),c(""),m(!0);try{const j=await t(h);n(N=>N.map(C=>C.id===y?{...C,answer:j??"没有获得回答(超时或 worker 不支持)",error:j===null}:C))}finally{m(!1)}};return e.jsx(me,{open:!0,onOpenChange:h=>{h||r()},children:e.jsxs(xe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-[26rem] h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md flex flex-col",children:[e.jsx(pe,{children:e.jsxs(fe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Lt,{className:"h-4 w-4"}),"旁路提问"]})}),e.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-text-muted",children:"针对当前会话上下文提问,不进入主对话、不消耗会话历史 — 适合「这个会话干了什么」式的快速核对。"}),e.jsxs("div",{className:"mt-3 flex-1 space-y-4 overflow-y-auto",children:[s.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:"还没有提问。在下方输入你的问题。"}),s.map(h=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-br-md border border-user-bubble-border bg-user-bubble px-4 py-2 text-sm text-text-primary",children:h.question})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:24,height:24,className:"object-contain",draggable:!1})}),e.jsx("div",{className:"min-w-0 flex-1 pt-1 text-sm text-text-primary",children:h.answer===null?e.jsxs("span",{className:"chat-typing-indicator inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):e.jsx("div",{className:h.error?"text-status-error":"",children:e.jsx(Ns,{children:h.answer})})})]})]},h.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:o,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&!h.nativeEvent.isComposing&&(h.preventDefault(),b())},rows:Math.min(4,Math.max(1,o.split(`
81
+ `).length)),placeholder:"问点什么…",disabled:l,className:"flex-1 resize-none rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none disabled:opacity-50"}),e.jsx("button",{type:"button",onClick:()=>void b(),disabled:l||!o.trim(),className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-brand text-white transition-colors hover:bg-brand-light disabled:opacity-40 disabled:cursor-not-allowed",title:"提问(Enter)",children:l?e.jsx(ue,{className:"h-4 w-4 animate-spin"}):e.jsx(vs,{className:"h-4 w-4"})})]})]})})}const Mt="rcs:subagent-panel:collapsed";function Qn(r){if(r<1e3)return"0s";const t=Math.floor(r/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60),n=t%60;if(s<60)return n?`${s}m${n}s`:`${s}m`;const o=Math.floor(s/60),c=s%60;return c?`${o}h${c}m`:`${o}h`}function zn(r){return r===void 0||r<=0?"":r<1e3?`${r}`:r<1e6?`${(r/1e3).toFixed(r<1e4?1:0)}k`:`${(r/1e6).toFixed(1)}M`}function Vn({status:r}){return r==="running"?e.jsx(ue,{className:"h-3 w-3 animate-spin text-brand"}):r==="completed"?e.jsx(bn,{className:"h-3 w-3 text-status-success"}):r==="failed"||r==="stopped"?e.jsx(Ss,{className:"h-3 w-3 text-status-error"}):null}function Kn({task:r,onStopTask:t}){const s=r.status==="running",n=s?r.durationMs??Date.now()-r.startTime:(r.endTime??Date.now())-r.startTime,o=zn(r.tokenCount),c=r.toolUseCount!==void 0&&r.toolUseCount>0?`${r.toolUseCount} tool${r.toolUseCount>1?"s":""}`:"",l=r.summary||r.description||"(no description)";return e.jsxs("div",{className:"group/task flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(Vn,{status:r.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:r.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:Qn(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:l}),(o||c||r.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:[o&&e.jsxs("span",{children:["↕ ",o," tok"]}),c&&e.jsxs("span",{children:["· ",c]}),r.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",r.lastToolName]})]}),!s&&r.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:r.finalSummary})]}),s&&t&&e.jsx("button",{type:"button",onClick:()=>t(r.taskId),title:"停止此任务",className:"mt-0.5 flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:bg-status-error/10 hover:text-status-error focus:opacity-100 group-hover/task:opacity-100",children:e.jsx(_s,{className:"h-3.5 w-3.5"})})]})}function Gn({state:r,onStopTask:t}){const[s,n]=d.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Mt)==="1"}catch{return!1}}),o=()=>{n(h=>{const y=!h;try{window.localStorage.setItem(Mt,y?"1":"0")}catch{}return y})},[,c]=d.useState(0);d.useEffect(()=>{const h=Object.values(r.tasks).some(N=>N.status==="running"),y=Object.values(r.tasks).some(N=>N.status!=="running"&&N.evictAfter!==void 0);if(!h&&!y)return;const j=setInterval(()=>{c(N=>N+1)},1e3);return()=>clearInterval(j)},[r]);const l=Rn(r);if(l.length===0)return null;const m=l.filter(h=>h.status==="running").length,b=m>0?`${m} running`:`${l.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:o,"aria-expanded":!s,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(on,{className:`h-3 w-3 transition-transform ${s?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:b})]}),!s&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:l.map(h=>e.jsx(Kn,{task:h,onStopTask:t},h.taskId))})]})})}function Tt(r,t){var o;const s=(o=t==null?void 0:t.find(c=>c.type==="addRules"||c.type==="replaceRules"))==null?void 0:o.rules,n=s==null?void 0:s[0];return n!=null&&n.ruleContent?`${n.toolName}(${n.ruleContent})`:n!=null&&n.toolName?n.toolName:r}function Yn({requestId:r,toolName:t,toolInput:s,description:n,suggestions:o,onApprove:c,onApproveAlways:l,onReject:m}){const b=typeof s=="string"?s:JSON.stringify(s,null,2),h=Array.isArray(o)&&o.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(Mn,{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:U(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:U(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:jt(b,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"}),h&&l&&e.jsxs("button",{onClick:l,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:`允许并记住规则:${Tt(t,o)}`,children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Always allow ",jt(Tt(t,o),40)]}),e.jsx("button",{onClick:m,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 Jn({questions:r,description:t,onSubmit:s,onSkip:n}){const[o,c]=d.useState({}),[l,m]=d.useState({}),[b,h]=d.useState(0),y=(u,i,g)=>{if(g){const p=o[u]||[],f=p.includes(i)?p.filter(w=>w!==i):[...p,i];c({...o,[u]:f})}else c({...o,[u]:i})},j=u=>{var g;const i=(g=l[u])==null?void 0:g.trim();i&&(c({...o,[u]:i}),m({...l,[u]:""}))},N=()=>{var i,g;const u={};for(const[p,f]of Object.entries(o)){const w=r[parseInt(p,10)];w&&(typeof f=="number"?u[p]=((g=(i=w.options)==null?void 0:i[f])==null?void 0:g.label)||String(f):Array.isArray(f)?u[p]=f.map(S=>{var R,A;return((A=(R=w.options)==null?void 0:R[S])==null?void 0:A.label)||String(S)}):u[p]=f)}s(u)};if(r.length<=1){const u=r[0]||{question:t,options:[],multiSelect:!1},i=u.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:U(t||u.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(u.options||[]).map((g,p)=>{const f=i?(o[0]||[]).includes(p):o[0]===p;return e.jsxs("button",{onClick:()=>y(0,p,i),className:de("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",f?"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:U(g.label)}),g.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:U(g.description)})]},p)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:l[0]||"",onChange:g=>m({...l,0:g.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:g=>g.key==="Enter"&&j(0)}),e.jsx("button",{onClick:()=>j(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 C=r[b];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:U(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:r.map((u,i)=>e.jsx("button",{onClick:()=>h(i),className:de("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",b===i?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:u.header||`Q${i+1}`},i))}),C&&e.jsx(Xn,{question:C,qIdx:b,answers:o,otherTexts:l,onSelect:y,onOtherTextChange:(u,i)=>m({...l,[u]:i}),onOtherSubmit:j}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[b+1," / ",r.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium 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 Xn({question:r,qIdx:t,answers:s,otherTexts:n,onSelect:o,onOtherTextChange:c,onOtherSubmit:l}){const m=r.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:U(r.question)}),e.jsxs("div",{className:"space-y-2",children:[(r.options||[]).map((b,h)=>{const y=m?(s[t]||[]).includes(h):s[t]===h;return e.jsxs("button",{onClick:()=>o(t,h,m),className:de("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",y?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:U(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:U(b.description)})]},h)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:b=>c(t,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"&&l(t)}),e.jsx("button",{onClick:()=>l(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 Zn({planContent:r,description:t,onSubmit:s}){const[n,o]=d.useState(null),[c,l]=d.useState(""),m=!r||!r.trim(),b=()=>{n&&s(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(Ee,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:m?"Exit plan mode?":"Ready to code?"})]}),!m&&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:er(r)}}),e.jsx("div",{className:"space-y-2",children:m?e.jsxs(e.Fragment,{children:[e.jsx(ce,{selected:n==="yes-default",onClick:()=>o("yes-default"),label:"Yes"}),e.jsx(ce,{selected:n==="no",onClick:()=>o("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{selected:n==="yes-accept-edits",onClick:()=>o("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(ce,{selected:n==="yes-default",onClick:()=>o("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(ce,{selected:n==="no",onClick:()=>o("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),n==="no"&&e.jsx("textarea",{value:c,onChange:h=>l(h.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm 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: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:"Submit"})})]})}function ce({selected:r,onClick:t,label:s,desc:n}){return e.jsxs("button",{onClick:t,className:de("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",r?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:de("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",r?"border-brand bg-brand text-white":"border-border"),children:r&&"✓"}),e.jsx("span",{className:"font-medium",children:s})]}),n&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:n})]})}function er(r){let t=U(r);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(s,n,o)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${o.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 tr({request:r,onSubmit:t}){const s=sr(r.requestedSchema),n=nr(r.requestedSchema),[o,c]=d.useState({}),l=s.length===0||n.every(m=>(o[m]??"").trim()!=="");return r.mode==="url"&&r.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Rt,{serverName:r.serverName,message:r.message}),e.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 flex w-full items-center justify-between rounded-lg border border-border bg-surface-2 px-4 py-2.5 text-sm text-brand hover:bg-brand/10 transition-colors",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:r.url}),e.jsx(Js,{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(Rt,{serverName:r.serverName,message:r.message}),s.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:s.map(({name:m,prop:b})=>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:m}),n.includes(m)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:"必填"})]}),b.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:U(b.description)}),e.jsx("input",{type:b.type==="number"?"number":"text",value:o[m]??"",onChange:h=>c(y=>({...y,[m]:h.target.value})),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]},m))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const m={};for(const{name:b,prop:h}of s){const y=(o[b]??"").trim();y&&(m[b]=h.type==="number"?Number(y):y)}t("accept",m)},disabled:!l,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 Rt({serverName:r,message:t}){return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(gn,{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:U(r)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:U(t)})]})}function sr(r){const t=r==null?void 0:r.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,s])=>s&&typeof s=="object").map(([s,n])=>({name:s,prop:n}))}function nr(r){const t=r==null?void 0:r.required;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function rr(r){const[t,s]=d.useState([]),[n,o]=d.useState(!0),[c,l]=d.useState(null),m=d.useCallback(async()=>{o(!0),l(null);try{const y=await Cs(r);s(y)}catch(y){l(y instanceof Error?y.message:"Failed to load shares")}finally{o(!1)}},[r]);d.useEffect(()=>{m()},[m]);const b=d.useCallback(async y=>{l(null);try{const j=await Es(r,y);return await m(),j}catch(j){throw l(j instanceof Error?j.message:"Failed to create share"),j}},[r,m]),h=d.useCallback(async y=>{l(null);try{await Ms(r,y),await m()}catch(j){throw l(j instanceof Error?j.message:"Failed to revoke share"),j}},[r,m]);return{shares:t,isLoading:n,error:c,createShare:b,revokeShare:h,refresh:m}}function ar({open:r,onClose:t,sessionId:s,sessionTitle:n}){Ut();const{shares:o,isLoading:c,error:l,createShare:m,revokeShare:b}=rr(s),[h,y]=d.useState("user"),[j,N]=d.useState(""),[C,u]=d.useState(""),[i,g]=d.useState("read"),[p,f]=d.useState(""),[w,S]=d.useState(!1),[R,A]=d.useState(null),[W,Q]=d.useState(""),[K,z]=d.useState(!1),[Ie,G]=d.useState(!1);d.useEffect(()=>{r&&(y("user"),N(""),u(""),g("read"),f(""),S(!1),A(null),Q(""),z(!1),G(!1))},[r]);const L=async()=>{S(!0),Q(""),A(null);try{const E={grantedTo:h==="user"?{userId:j.trim()}:{teamId:C.trim()},permission:i};p.trim()&&(E.expiresAt=p.trim());const Pe=await m(E);A(`${window.location.origin}/code/s/${Pe.shareToken}`)}catch(E){Q(E instanceof Error?E.message:"Failed to create share")}finally{S(!1)}},qe=async E=>{try{await b(E)}catch{}},te=async()=>{if(!R)return;G(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(R),z(!0),setTimeout(()=>z(!1),2e3);return}}catch{}const E=document.createElement("textarea");E.value=R,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),z(!0),setTimeout(()=>z(!1),2e3)}catch{G(!0)}document.body.removeChild(E)};return e.jsx(me,{open:r,onOpenChange:E=>{E||t()},children:e.jsxs(xe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(pe,{children:e.jsxs(fe,{className:"font-display text-lg font-semibold text-text-primary",children:[v("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:v("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>y("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${h==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:v("share.user")}),e.jsx("button",{onClick:()=>y("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${h==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:v("share.team")})]}),h==="user"?e.jsx(en,{onSelect:N,placeholder:v("share.userIdPlaceholder"),actionLabel:v("share.selectUser")}):e.jsx("input",{type:"text",value:C,onChange:E=>u(E.target.value),placeholder:v("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),h==="user"&&j&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[v("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:j})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:v("share.permission")}),e.jsxs("select",{value:i,onChange:E=>g(E.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:v("share.permissionRead")}),e.jsx("option",{value:"write",children:v("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:v("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:p,onChange:E=>f(E.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"})]}),(W||l)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:W||l}),R&&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:v("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:R}),e.jsx("button",{onClick:te,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:K?v("share.copied"):v("share.copy")})]}),Ie&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:v("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:v("share.existingShares")}),c?e.jsx("p",{className:"text-sm text-text-muted",children:v("share.loading")}):o.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:v("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:o.map(E=>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:E.granted_to_user||E.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[E.permission==="write"?v("share.permissionWrite"):v("share.permissionRead"),E.expires_at?` · expires ${E.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>qe(E.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:v("share.revoke")})]},E.id))})]})]}),e.jsxs(Gs,{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:v("common.close")}),e.jsx("button",{onClick:L,disabled:w||(h==="user"?!j.trim():!C.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?v("common.creating"):v("share.createShare")})]})]})})}class or{constructor(t,s,n,o){T(this,"pending",null);this.current=t,this.apply=s,this.send=n,this.onError=o}set(t){if(t===this.current)return;const s=this.current;this.current=t,this.pending={requestId:null,previous:s},this.apply(t);try{Promise.resolve(this.send(t)).then(n=>{this.pending&&(this.pending.requestId=n)}).catch(n=>{this.rollback(s,$t(n),"send")})}catch(n){this.rollback(s,$t(n),"send")}}handleControlResponse(t){const s=this.pending;if(!s||s.requestId!==t.requestId)return!1;const{previous:n}=s;return this.pending=null,t.subtype==="error"&&this.rollback(n,t.error??"","response"),!0}sync(t){t!==this.current&&(this.current=t,this.apply(t),this.pending=null)}adoptExternal(t){this.pending||t!==this.current&&(this.current=t)}getCurrent(){return this.current}rollback(t,s,n){var o;this.pending=null,this.current=t,this.apply(t),s&&((o=this.onError)==null||o.call(this,s,n))}}function $t(r){return r instanceof Error?r.message:String(r)}function Ye(r){const t=d.useRef(r);t.current=r;const s=d.useRef(null);s.current||(s.current=new or(r.value,o=>t.current.apply(o),o=>t.current.send(o),(o,c)=>{var l,m;return(m=(l=t.current).onError)==null?void 0:m.call(l,o,c)}));const n=s.current;return d.useEffect(()=>{n.adoptExternal(r.value)}),d.useMemo(()=>({set:o=>n.set(o),handleControlResponse:o=>n.handleControlResponse(o),sync:o=>n.sync(o)}),[n])}function ir(r){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${r}`}function lr(r){const t=ir(r),s=Rs(),n=s?{proxyUrl:t,token:s}:{proxyUrl:t};return new Ts(n)}const Z=[{value:"default",label:"默认",description:"手动审批权限请求"},{value:"acceptEdits",label:"自动接受编辑",description:"自动允许文件编辑操作"},{value:"plan",label:"规划模式",description:"仅规划,不执行工具"},{value:"bypassPermissions",label:"跳过权限",description:"跳过所有权限检查"}],At="rcs_permission_mode";function ee(r){return r<1e3?String(r):r<1e6?`${(r/1e3).toFixed(1)}k`:`${(r/1e6).toFixed(1)}M`}function cr(r){const t=Z.findIndex(s=>s.value===r);return Z[(t+1+Z.length)%Z.length].value}const Ze=[{value:"off",label:"关闭思考",tokens:null,description:"不使用扩展思考"},{value:"on",label:"默认思考",tokens:0,description:"开启,使用默认预算"},{value:"8192",label:"8k",tokens:8192,description:"8192 tokens"},{value:"16384",label:"16k",tokens:16384,description:"16384 tokens"},{value:"32768",label:"32k",tokens:32768,description:"32768 tokens"}],It="rcs_thinking_budget",et=[{value:"auto",effort:void 0,label:"自动",description:"使用模型默认 effort"},{value:"low",effort:"low",label:"low",description:"低推理力度"},{value:"medium",effort:"medium",label:"medium",description:"中推理力度"},{value:"high",effort:"high",label:"high",description:"高推理力度"},{value:"xhigh",effort:"xhigh",label:"xhigh",description:"超高推理力度"},{value:"max",effort:"max",label:"max",description:"最大推理力度"}],qt="rcs_effort";function dr(r){return r!=null&&r.capabilities?r.capabilities:r?{file_search:!0,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!0,stop_task:!0,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!0,mcp_management:!0,remote_settings:!0,rewind:!0,set_effort:!0,side_question:!0}:{file_search:!1,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!1,stop_task:!1,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!1,mcp_management:!1,remote_settings:!1,rewind:!1,set_effort:!1,side_question:!1}}function ur({budget:r,onBudgetChange:t,disabled:s}){const[n,o]=d.useState(!1),c=Ze.find(l=>l.value===r);return e.jsxs(Me,{open:n,onOpenChange:o,children:[e.jsx(Te,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"思考预算",children:[e.jsx(Vs,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??"思考"}),n?e.jsx(Re,{className:"h-3 w-3"}):e.jsx($e,{className:"h-3 w-3"})]})}),e.jsx(Ae,{className:"w-64 p-1",align:"start",children:Ze.map(l=>e.jsxs("button",{type:"button",onClick:()=>{t(l.value,l.tokens),o(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:r===l.value&&e.jsx(Ee,{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:l.label}),e.jsx("div",{className:"text-xs text-text-muted",children:l.description})]})]},l.value))})]})}function mr({effort:r,onEffortChange:t,disabled:s}){const[n,o]=d.useState(!1),c=et.find(l=>l.value===r);return e.jsxs(Me,{open:n,onOpenChange:o,children:[e.jsx(Te,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"Effort 档位",children:[e.jsx(dn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??"自动"}),n?e.jsx(Re,{className:"h-3 w-3"}):e.jsx($e,{className:"h-3 w-3"})]})}),e.jsx(Ae,{className:"w-64 p-1",align:"start",children:et.map(l=>e.jsxs("button",{type:"button",onClick:()=>{t(l.value),o(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:r===l.value&&e.jsx(Ee,{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:l.label}),e.jsx("div",{className:"text-xs text-text-muted",children:l.description})]})]},l.value))})]})}const Pt=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function xr({usage:r}){const t=Math.min(100,Math.max(0,r.percentage)),s=t>=80,n=(r.categories??[]).filter(l=>!l.isDeferred),o=(r.categories??[]).filter(l=>l.isDeferred),c=[`上下文用量:${ee(r.totalTokens)} / ${ee(r.rawMaxTokens)} tokens${r.model?` · ${r.model}`:""}`,...n.slice(0,8).map(l=>`${l.name}: ${ee(l.tokens)}`),...o.slice(0,3).map(l=>`${l.name}(延迟加载): ${ee(l.tokens)}`)];return e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",title:c.join(`
82
+ `),children:[e.jsx("span",{className:"relative flex h-1.5 w-16 overflow-hidden rounded-full bg-surface-3",children:n.length>0?n.map((l,m)=>e.jsx("span",{className:s&&m===0?"bg-status-warning":Pt[m%Pt.length],style:{width:`${Math.min(100,Math.max(0,l.tokens/r.rawMaxTokens*100))}%`}},l.name)):e.jsx("span",{className:`absolute inset-y-0 left-0 rounded-full transition-all ${s?"bg-status-warning":"bg-brand/70"}`,style:{width:`${t}%`}})}),e.jsxs("span",{children:[t,"%"]})]})}function pr({models:r,currentModelId:t,onSelect:s,disabled:n}){const[o,c]=d.useState(!1),l=r.find(h=>h.modelId===t)??null,m=r.length>0,b=async h=>{s(h.modelId),c(!1)};return e.jsxs(Me,{open:o,onOpenChange:m?c:void 0,children:[e.jsx(Te,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n||!m,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(Bt,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(l==null?void 0:l.name)??t??"选择模型"}),o?e.jsx(Re,{className:"h-3 w-3"}):e.jsx($e,{className:"h-3 w-3"})]})}),e.jsx(Ae,{className:"w-72 p-0",align:"start",children:e.jsx(zs,{models:r,currentModelId:t,onSelect:b,showSearch:r.length>5})})]})}function fr({mode:r,onModeChange:t,disabled:s}){const[n,o]=d.useState(!1),c=Z.find(l=>l.value===r);return e.jsxs(Me,{open:n,onOpenChange:o,children:[e.jsx(Te,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:"权限模式(Shift+Tab 循环)",children:[e.jsx(Qs,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:(c==null?void 0:c.label)??r}),n?e.jsx(Re,{className:"h-3 w-3"}):e.jsx($e,{className:"h-3 w-3"})]})}),e.jsx(Ae,{className:"w-64 p-1",align:"start",children:Z.map(l=>e.jsxs("button",{type:"button",onClick:()=>{t(l.value),o(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:r===l.value&&e.jsx(Ee,{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:l.label}),e.jsx("div",{className:"text-xs text-text-muted",children:l.description})]})]},l.value))})]})}function Rr({sessionId:r,onSessionLoaded:t}){Ut();const[s,n]=d.useState(null),[o,c]=d.useState(null),[l,m]=d.useState(""),[b,h]=d.useState(!1),[y,j]=d.useState(!1),[N,C]=d.useState(!1),[u,i]=d.useState(!1),[g,p]=d.useState(!1),[f,w]=d.useState(""),[S,R]=d.useState(0),A=d.useRef(null),[W,Q]=d.useState({text:"",nonce:0}),[K,z]=d.useState(!1),[Ie,G]=d.useState(!1),[L,qe]=d.useState(!1),[te,E]=d.useState(0),[Pe,zt]=d.useState(0),[se,he]=d.useState([]),[B,ge]=d.useState(!1),[ne,Y]=d.useState([]),[D,De]=d.useState(null),[Vt,Kt]=d.useState(()=>Qt()),[H,Gt]=d.useState(null),[st,Yt]=d.useState(()=>localStorage.getItem(It)||"off"),[nt,Jt]=d.useState(null),[re,Xt]=d.useState(null),[ye,rt]=d.useState(null),[be,je]=d.useState([]),[at,Oe]=d.useState(!1),[Ue,ot]=d.useState(""),Fe=d.useRef(null),[we,Zt]=d.useState(()=>localStorage.getItem(At)||"default"),[it,lt]=d.useState(null),ae=d.useRef(null),[ct,dt]=d.useState(null),oe=d.useRef(null),ie=d.useRef(null),ut=d.useRef(se);ut.current=se;const ke=d.useRef(t);ke.current=t;const Ne=d.useRef(null);Ne.current||(Ne.current=new tn(sn()));const mt=d.useRef(r);mt.current=(s==null?void 0:s.title)||r,d.useEffect(()=>{var a;(a=Ne.current)==null||a.reset()},[r]);const V=d.useCallback(a=>{lt(a),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>lt(null),5e3)},[]),J=d.useCallback(a=>{dt(a),oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>dt(null),5e3)},[]),ve=Ye({value:we,apply:a=>{Zt(a);try{localStorage.setItem(At,a)}catch{}},send:a=>{const x=ie.current;return x?x.setPermissionMode(a):Promise.reject(new Error("adapter not ready"))},onError:(a,x)=>{console.error("[SessionDetail] set permission mode failed:",a),V(x==="send"?`模式切换请求发送失败: ${a}`:a||"模式切换失败")}}),Be=d.useCallback(a=>ve.set(a),[ve]),Le=Ye({value:st,apply:a=>{Yt(a);try{localStorage.setItem(It,a)}catch{}},send:a=>{var k;const x=ie.current;if(!x)return Promise.reject(new Error("adapter not ready"));const _=((k=Ze.find($=>$.value===a))==null?void 0:k.tokens)??null;return x.setThinkingBudget(_)},onError:(a,x)=>{console.error("[SessionDetail] set thinking budget failed:",a),V(x==="send"?`思考预算请求发送失败: ${a}`:a||"思考预算切换失败")}}),M=d.useMemo(()=>new qn(r,he,{onStatusChange:a=>{var x;c(a),ge(a==="running"||a==="requires_action"),(x=Ne.current)==null||x.onStatus(a,mt.current)},onError:a=>{console.error("[RCSChatAdapter] error:",a)},onPermissionRequest:a=>{Y(x=>x.some(_=>_.requestId===a.requestId)?x:[...x,a])},onModelsStateChange:a=>{De(a)},onSubagentUpdate:a=>{Kt(a)},onControlResponse:a=>{Le.handleControlResponse(a)||ve.handleControlResponse(a)},onPermissionModeChange:a=>{ve.sync(a)},onUsageChange:a=>{Xt(x=>({inputTokens:Math.max((x==null?void 0:x.inputTokens)??0,a.inputTokens),outputTokens:Math.max((x==null?void 0:x.outputTokens)??0,a.outputTokens),totalCostUsd:a.totalCostUsd??(x==null?void 0:x.totalCostUsd)??null}))},onWorkerInfoChange:a=>{Gt(x=>JSON.stringify(x)===JSON.stringify(a)?x:a)},onElicitationRequest:a=>{rt(a)}}),[r,V]);d.useEffect(()=>(ie.current=M,()=>{M.disconnect()}),[M]);const O=d.useMemo(()=>dr(H),[H]),He=d.useMemo(()=>$s((H==null?void 0:H.commands)??[],(H==null?void 0:H.skills)??[]),[H]),le=d.useMemo(()=>As(se,f),[se,f]),es=d.useCallback(a=>Le.set(a),[Le]),[xt,ts]=d.useState(()=>localStorage.getItem(qt)||"auto"),ss=Ye({value:xt,apply:a=>{ts(a);try{localStorage.setItem(qt,a)}catch{}},send:a=>{var k;const x=ie.current;if(!x)return Promise.reject(new Error("adapter not ready"));const _=(k=et.find($=>$.value===a))==null?void 0:k.effort;return x.setEffort(_)},onError:(a,x)=>{console.error("[SessionDetail] set effort failed:",a),V(x==="send"?`Effort 切换请求发送失败: ${a}`:a||"Effort 切换失败")}}),We=d.useCallback(()=>{var a;O.get_context_usage&&((a=ie.current)==null||a.getContextUsage().then(x=>{x&&Jt(x)}).catch(()=>{}))},[O]);d.useEffect(()=>{if(!O.get_context_usage)return;B||We();const a=setInterval(We,6e4);return()=>clearInterval(a)},[O,B,We]);const pt=d.useRef(L);pt.current=L,d.useEffect(()=>Ce.onEvent(x=>{x.type!=="artifact_created"&&x.type!=="artifact_updated"||(pt.current&&zt(_=>_+1),E(_=>_+1))}),[]),d.useEffect(()=>{L&&E(0)},[L]),d.useEffect(()=>{let a=!1;async function x(){var _;m("");try{const k=await Ls(r);if(a)return;n(k),c(k.status),Je(k.status)&&M.markClosed(),ge(k.status==="running"||k.status==="requires_action"),(_=ke.current)==null||_.call(ke,k)}catch(k){if(a)return;m(k instanceof Error?k.message:v("session.loadFailed"));return}try{await M.init()}catch(k){console.warn("Failed to init adapter:",k)}}return x(),()=>{a=!0}},[r,M]);const I=Je(o),q=(s==null?void 0:s.access_level)==="read",Qe=d.useCallback(()=>{he([]),Is(r).catch(a=>{console.warn("[SessionDetail] Failed to clear session history:",a)})},[r]),_e=d.useCallback(async a=>{const x=a.text.trim(),_=a.images&&a.images.length>0||a.attachments&&a.attachments.length>0;if(!x&&!_||I)return;const k=await qs(x,{sessionId:r,availableCommands:He,availableModels:(D==null?void 0:D.availableModels)??[],currentModel:D?{modelId:D.currentModelId,name:D.currentModelId}:null,supportsImages:!0,entries:ut.current,setModel:async $=>{await F(r,{type:"control_request",request:{subtype:"set_model",model:$}}),De(Ve=>Ve&&{...Ve,currentModelId:$})},onNewSession:()=>{he([])}}).catch(()=>null);if(k){if(tt("[SessionDetail] local command result",k),"clearEntries"in k&&k.clearEntries){Qe();return}if("newSession"in k&&k.newSession){Qe();return}if("userEntry"in k){he($=>[...$,k.userEntry,k.cmdEntry]);return}}ge(!0);try{await M.sendMessage(x,a.images,a.attachments)}catch($){if(console.error("Send failed:",$),$ instanceof Ps&&$.type==="session_closed"){c("archived"),M.markClosed(),J(v("session.closedSendBlocked"));return}J(`${v("session.sendFailed")}${$ instanceof Error?`: ${$.message}`:""}`)}},[M,I,r,D,He,Qe,J]),ns=d.useCallback(a=>{if(B){je(x=>[...x,a]);return}_e(a)},[B,_e]),ze=d.useRef(!1);d.useEffect(()=>{if(I){je(x=>x.length>0?[]:x);return}if(B||be.length===0||ze.current)return;const a=be[0];a&&(ze.current=!0,je(x=>x.slice(1)),_e(a).finally(()=>{ze.current=!1}))},[B,be,_e,I]);const rs=d.useCallback((a,x)=>{if(B)return;const _=x==="edit"?"回退到这条消息并编辑?":"回退到这条消息?";window.confirm(`${_}
83
+ 之后的对话将移除,已修改的文件将恢复到当时的状态(若有快照)。`)&&M.rewindToMessage(a.id).then(()=>{x==="edit"&&a.content&&Q(k=>({text:a.content,nonce:k.nonce+1}))}).catch(k=>{console.error("[SessionDetail] rewind failed:",k),J(`回退失败: ${k instanceof Error?k.message:String(k)}`)})},[B,J]),as=d.useCallback(a=>{const x=le.orderedMatchIds;if(x.length===0)return;const _=(a%x.length+x.length)%x.length;R(_);const k=x[_],$=document.querySelector(`[data-entry-id="${CSS.escape(k)}"]`);$==null||$.scrollIntoView({block:"center",behavior:"smooth"})},[le]),ft=d.useCallback(async()=>{try{await M.interrupt()}catch(a){console.error("Interrupt failed:",a)}finally{ge(!1)}},[M]),os=d.useCallback(()=>{Be(cr(we))},[Be,we]);d.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current),oe.current&&clearTimeout(oe.current)},[]);const is=d.useCallback(async()=>{if(s&&window.confirm(v("dashboard.confirmDelete").replace("{id}",s.title||s.id)))try{await wt(s.id),window.location.href="/code/"}catch(a){alert(a instanceof Error?a.message:v("dashboard.deleteFailed"))}},[s]),ls=d.useCallback(async a=>{try{await M.respondPermission(a,!0)}catch(x){console.error("Failed to approve:",x)}Y(x=>x.filter(_=>_.requestId!==a))},[M]),cs=d.useCallback(async(a,x)=>{try{await M.respondPermission(a,!0,{updated_permissions:x})}catch(_){console.error("Failed to approve with rules:",_)}Y(_=>_.filter(k=>k.requestId!==a))},[M]),ds=d.useCallback(async(a,x)=>{const _=ye;if(rt(null),!!_)try{await M.respondElicitation(_.requestId,a,x)}catch(k){console.error("Failed to submit elicitation:",k)}},[ye,M]),us=d.useCallback(()=>{!s||q||(ot(s.title||""),Oe(!0),setTimeout(()=>{var a,x;(a=Fe.current)==null||a.focus(),(x=Fe.current)==null||x.select()},0))},[s,q]),ht=d.useCallback(async()=>{const a=Ue.trim();if(Oe(!1),!(!s||!a||a===s.title))try{const x=await Ds(s.id,a);n(_=>_&&{..._,title:x.title??a})}catch(x){console.error("Rename failed:",x),alert(x instanceof Error?x.message:"重命名失败")}},[s,Ue]),ms=d.useCallback(async a=>{try{await M.respondPermission(a,!1)}catch(x){console.error("Failed to reject:",x)}Y(x=>x.filter(_=>_.requestId!==a))},[M]),xs=d.useCallback(async(a,x,_)=>{try{await F(r,{type:"permission_response",approved:!0,request_id:a,updated_input:{questions:_,answers:x}})}catch(k){console.error("Failed to submit answers:",k)}Y(k=>k.filter($=>$.requestId!==a))},[r]),ps=d.useCallback(async(a,x,_)=>{try{x==="no"?await F(r,{type:"permission_response",approved:!1,request_id:a,..._?{message:_}:{}}):await F(r,{type:"permission_response",approved:!0,request_id:a,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[x]||"default",destination:"session"}]})}catch(k){console.error("Failed to submit plan response:",k)}Y(k=>k.filter($=>$.requestId!==a))},[r]);return l?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:l}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:v("session.backToDashboard")})]})}):s?s.source==="acp"&&s.environment_id?e.jsx(gr,{sessionId:r,agentId:s.environment_id}):e.jsx(Ft,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx("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:[at?e.jsx("input",{ref:Fe,value:Ue,onChange:a=>ot(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing?(a.preventDefault(),ht()):a.key==="Escape"&&(a.preventDefault(),Oe(!1))},onBlur:()=>void ht(),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:s.title||s.id}),!q&&!I&&e.jsx("button",{type:"button",onClick:us,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(Os,{className:"h-3.5 w-3.5"})})]}),s.visibility&&!at&&e.jsx(Zs,{visibility:s.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var _;const a=s.source==="acp"?"acp":(_=s.environment)==null?void 0:_.worker_type,x=Ks(a);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${x.colorClass}`,children:x.fullLabel})})(),o&&e.jsx(Dt,{status:o}),e.jsx("span",{className:"text-xs text-text-muted",children:Ot(s.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>qe(!L),className:`relative flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${L?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:v("artifacts.title"),children:[e.jsx(Us,{className:"h-3.5 w-3.5"}),te>0&&!L&&e.jsx("span",{className:"absolute -right-1.5 -top-1.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-status-active px-1 text-[10px] font-bold text-white",children:te>9?"9+":te})]}),O.side_question&&!I&&!q&&e.jsx("button",{onClick:()=>i(!u),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${u?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"旁路提问 — 针对会话上下文提问,不进入主对话",children:e.jsx(Lt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>{const a=!g;p(a),a?setTimeout(()=>{var x;return(x=A.current)==null?void 0:x.focus()},0):(w(""),R(0))},className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${g?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"搜索会话内容",children:e.jsx(Xe,{className:"h-3.5 w-3.5"})}),O.mcp_management&&!I&&!q&&e.jsx("button",{onClick:()=>j(!y),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${y?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"MCP 服务器",children:e.jsx(Ht,{className:"h-3.5 w-3.5"})}),O.remote_settings&&!I&&!q&&e.jsx("button",{onClick:()=>C(!N),className:`flex items-center gap-1 rounded-md px-2 py-1 text-xs transition-colors ${N?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:"会话设置",children:e.jsx(Wt,{className:"h-3.5 w-3.5"})}),!q&&(s==null?void 0:s.access_level)!=="write"&&e.jsx("button",{onClick:()=>G(!0),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:v("session.share"),children:e.jsx(_n,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>z(!K),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:v("session.info"),children:e.jsx(pn,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>h(!b),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:[v("session.tasks"),ne.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:ne.length})]})]})]}),K&&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:v("session.metaSession")})," ",s.id]}),s.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:v("session.metaEnvironment")})," ",s.environment_id]})]})]})}),L&&e.jsx("div",{className:"border-b bg-surface-1 px-4 py-4",children:e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(Xs,{sessionId:r,embedded:!0,refreshTick:Pe})})}),g&&e.jsx("div",{className:"border-b bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto flex max-w-3xl items-center gap-2",children:[e.jsx(Xe,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{ref:A,value:f,onChange:a=>{w(a.target.value),R(0)},onKeyDown:a=>{a.key==="Enter"&&!a.nativeEvent.isComposing?(a.preventDefault(),as(f&&a.shiftKey?S-1:S+1)):a.key==="Escape"&&(a.preventDefault(),p(!1),w(""))},placeholder:"搜索会话内容…",className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),f.trim()&&e.jsx("span",{className:"flex-shrink-0 font-mono text-[11px] text-text-muted",children:le.orderedMatchIds.length===0?"无结果":`${S+1}/${le.orderedMatchIds.length}`})]})}),e.jsx(Fs,{entries:se,isLoading:B,emptyTitle:v("session.emptyTitle"),emptyDescription:v("session.emptyDescription"),searchMatchIds:f.trim()?le.matchIds:void 0,onRewindEntry:O.rewind&&!I&&!q&&!B?(a,x)=>rs(a,x):void 0}),e.jsx(Gn,{state:Vt,onStopTask:O.stop_task?a=>{M.stopSubagent(a).then(x=>{x.ok||J(x.error||"停止任务失败")})}:void 0}),ne.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:ne.map(a=>e.jsx(hr,{request:a,onApprove:()=>ls(a.requestId),onApproveAlways:a.suggestions&&a.suggestions.length>0?()=>cs(a.requestId,a.suggestions??[]):void 0,onReject:()=>ms(a.requestId),onSubmitAnswers:xs,onSubmitPlan:ps},a.requestId))})}),ye&&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(tr,{request:ye,onSubmit:ds})})}),ct&&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:ct})}),it&&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:it})}),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(fr,{mode:we,onModeChange:Be,disabled:I||q}),e.jsx(pr,{models:(D==null?void 0:D.availableModels)??[],currentModelId:(D==null?void 0:D.currentModelId)??null,onSelect:a=>{F(r,{type:"control_request",request:{subtype:"set_model",model:a}}),De(x=>x&&{...x,currentModelId:a})},disabled:I||q}),O.set_max_thinking_tokens&&e.jsx(ur,{budget:st,onBudgetChange:es,disabled:I||q}),O.set_effort&&e.jsx(mr,{effort:xt,onEffortChange:a=>ss.set(a),disabled:I||q})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[nt&&e.jsx(xr,{usage:nt}),re&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:"会话累计用量(input 含缓存读写)",children:[ee(re.inputTokens)," in / ",ee(re.outputTokens)," out",re.totalCostUsd!=null&&` · $${re.totalCostUsd.toFixed(2)}`]})]})]}),e.jsx(Bs,{onSubmit:ns,isLoading:B,onInterrupt:ft,onCycleMode:os,disabled:I||q,placeholder:I?v("session.closed"):q?v("session.readOnly"):v("session.inputPlaceholder"),supportsAttachments:!0,commands:He,queueWhileLoading:!0,queuedCount:be.length,onDequeue:a=>je(x=>x.filter((_,k)=>k!==a)),onSearchFiles:O.file_search?a=>M.searchFiles(a):void 0,historyKey:r,draftOverride:W}),y&&e.jsx(Ln,{onClose:()=>j(!1),fetchServers:()=>M.getMcpServers(),onToggle:(a,x)=>M.toggleMcpServer(a,x),onReconnect:a=>M.reconnectMcpServer(a)}),N&&e.jsx(Hn,{onClose:()=>C(!1),fetchSettings:()=>M.getRemoteSettings(),onApply:a=>M.applyFlagSettings(a)}),u&&e.jsx(Wn,{onClose:()=>i(!1),onAsk:a=>M.askSideQuestion(a)}),b&&s&&e.jsx(Un,{onClose:()=>h(!1),session:s,liveStatus:o,pendingPermissions:ne,onInterrupt:ft,onDelete:is,onEndSession:O.end_session&&!I&&!q?async()=>{await M.endSession("ended from web"),await wt(s.id),window.location.href="/code/"}:void 0}),e.jsx(ar,{open:Ie,onClose:()=>G(!1),sessionId:s.id,sessionTitle:s.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:v("session.loading")})})}function hr({request:r,onApprove:t,onApproveAlways:s,onReject:n,onSubmitAnswers:o,onSubmitPlan:c}){const l=r.toolName,m=r.toolInput,b=r.description||"";if(l==="AskUserQuestion"){const h=m.questions||[];return e.jsx(Jn,{requestId:r.requestId,questions:h,description:b,onSubmit:y=>o(r.requestId,y,h),onSkip:n})}if(l==="ExitPlanMode"){const h=m.plan||"";return e.jsx(Zn,{requestId:r.requestId,planContent:h,description:b,onSubmit:(y,j)=>c(r.requestId,y,j)})}return e.jsx(Yn,{requestId:r.requestId,toolName:l,toolInput:m,description:b,suggestions:r.suggestions,onApprove:t,onApproveAlways:s,onReject:n})}function gr({sessionId:r,agentId:t}){const[s,n]=d.useState(null),[o,c]=d.useState("disconnected"),[l,m]=d.useState(null),b=d.useRef(null);return d.useEffect(()=>{const h=lr(t);return h.setConnectionStateHandler((y,j)=>{c(y),m(j||null)}),b.current=h,n(h),h.connect().catch(y=>{y instanceof Hs||(m(y.message),c("error"))}),()=>{h.disconnect(),b.current=null,n(null),c("disconnected")}},[t]),e.jsx(Ft,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[l&&o==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:l}),o==="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:v("session.connectingAgent")})]})}),o==="error"&&!s&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:v("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:l})]})}),s&&o==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ws,{client:s,agentId:t})})]})})}export{Rr as SessionDetail};
@@ -1,4 +1,4 @@
1
- import{j as e}from"./vendor-DE_-CLIE.js";import{ad as c,U as n,ab as i}from"./main-uW6v3W3M.js";/**
1
+ import{j as e}from"./vendor-DE_-CLIE.js";import{ai as c,U as n,ag as i}from"./main-B67FXcTf.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{at as v,ap as t}from"./main-uW6v3W3M.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{aA as v,aw as t}from"./main-B67FXcTf.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{a4 as m,b as h}from"./main-uW6v3W3M.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{a7 as m,b as h}from"./main-B67FXcTf.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};