texlite 0.24.0 → 0.25.0

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 (241) hide show
  1. package/DESIGN.md +85 -2
  2. package/NPM_TESTING.md +46 -2
  3. package/OPERATIONS.md +136 -6
  4. package/README.md +1 -2
  5. package/README.zh-CN.md +2 -2
  6. package/THIRD_PARTY_NOTICES.md +12 -0
  7. package/dist/client/assets/AdminUsers-D4ljqr_D.js +1 -0
  8. package/dist/client/assets/AdminUsers-D4ljqr_D.js.br +0 -0
  9. package/dist/client/assets/AdminUsers-D4ljqr_D.js.gz +0 -0
  10. package/dist/client/assets/AgentManagement-DwRMP_nD.js +1 -0
  11. package/dist/client/assets/AgentManagement-DwRMP_nD.js.br +0 -0
  12. package/dist/client/assets/AgentManagement-DwRMP_nD.js.gz +0 -0
  13. package/dist/client/assets/AgentTerminal-CSsr21PC.js +2 -0
  14. package/dist/client/assets/AgentTerminal-CSsr21PC.js.br +0 -0
  15. package/dist/client/assets/AgentTerminal-CSsr21PC.js.gz +0 -0
  16. package/dist/client/assets/{AgentTerminalSurface-DliOcop5.js → AgentTerminalSurface-BLroKMGe.js} +1 -1
  17. package/dist/client/assets/{AgentTerminalSurface-DliOcop5.js.br → AgentTerminalSurface-BLroKMGe.js.br} +0 -0
  18. package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js.gz +0 -0
  19. package/dist/client/assets/{AvatarSettingsDialog-iuEbMO4a.js → AvatarSettingsDialog-BgVGfSzn.js} +1 -1
  20. package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.br +0 -0
  21. package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.gz +0 -0
  22. package/dist/client/assets/CitationBibtexEditor-DLPom-qx.js +1 -0
  23. package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js +3 -0
  24. package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.br +0 -0
  25. package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.gz +0 -0
  26. package/dist/client/assets/Dashboard-7JrR0t6C.js +5 -0
  27. package/dist/client/assets/Dashboard-7JrR0t6C.js.br +0 -0
  28. package/dist/client/assets/Dashboard-7JrR0t6C.js.gz +0 -0
  29. package/dist/client/assets/DrawioEditor-CYQnzKDd.js +1 -0
  30. package/dist/client/assets/DrawioEditor-CYQnzKDd.js.br +0 -0
  31. package/dist/client/assets/DrawioEditor-CYQnzKDd.js.gz +0 -0
  32. package/dist/client/assets/GitDialog-DMCVR8QK.js +4 -0
  33. package/dist/client/assets/GitDialog-DMCVR8QK.js.br +0 -0
  34. package/dist/client/assets/GitDialog-DMCVR8QK.js.gz +0 -0
  35. package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js +1 -0
  36. package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.br +0 -0
  37. package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.gz +0 -0
  38. package/dist/client/assets/{HistoryDialog-upkR8E0L.js → HistoryDialog-CcPWpTLn.js} +3 -3
  39. package/dist/client/assets/HistoryDialog-CcPWpTLn.js.br +0 -0
  40. package/dist/client/assets/HistoryDialog-CcPWpTLn.js.gz +0 -0
  41. package/dist/client/assets/LatexEditor-D7C9jpJO.js +25 -0
  42. package/dist/client/assets/LatexEditor-D7C9jpJO.js.br +0 -0
  43. package/dist/client/assets/LatexEditor-D7C9jpJO.js.gz +0 -0
  44. package/dist/client/assets/{MarkdownPreview-_AXp5G7f.js → MarkdownPreview-Txs5upCY.js} +1 -1
  45. package/dist/client/assets/MarkdownPreview-Txs5upCY.js.br +0 -0
  46. package/dist/client/assets/MarkdownPreview-Txs5upCY.js.gz +0 -0
  47. package/dist/client/assets/{ProjectIconPickerDialog-BxjEYsau.js → ProjectIconPickerDialog-CUlPlfmL.js} +1 -1
  48. package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.br +0 -0
  49. package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.gz +0 -0
  50. package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js +1 -0
  51. package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.br +0 -0
  52. package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.gz +0 -0
  53. package/dist/client/assets/ProjectSettings-B6e7EAxq.js +4 -0
  54. package/dist/client/assets/ProjectSettings-B6e7EAxq.js.br +0 -0
  55. package/dist/client/assets/ProjectSettings-B6e7EAxq.js.gz +0 -0
  56. package/dist/client/assets/ProjectWorkspace-D0EMITec.js +25 -0
  57. package/dist/client/assets/ProjectWorkspace-D0EMITec.js.br +0 -0
  58. package/dist/client/assets/ProjectWorkspace-D0EMITec.js.gz +0 -0
  59. package/dist/client/assets/{QuickOpenDialog-HlkWqVR9.js → QuickOpenDialog-D6yjnquG.js} +1 -1
  60. package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.br +0 -0
  61. package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.gz +0 -0
  62. package/dist/client/assets/{ReadOnlySource-BIdN1YP_.js → ReadOnlySource-BOAnB5L0.js} +1 -1
  63. package/dist/client/assets/{SelectionHistoryDialog-Cb8I-G6m.js → SelectionHistoryDialog-D6ql9E0j.js} +2 -2
  64. package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.br +0 -0
  65. package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.gz +0 -0
  66. package/dist/client/assets/SharedProjectPage-DuscqDx5.js +2 -0
  67. package/dist/client/assets/SharedProjectPage-DuscqDx5.js.br +0 -0
  68. package/dist/client/assets/SharedProjectPage-DuscqDx5.js.gz +0 -0
  69. package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js +1 -0
  70. package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.br +0 -0
  71. package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.gz +0 -0
  72. package/dist/client/assets/TagManagementDialog-BHbqvu3K.js +1 -0
  73. package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.br +0 -0
  74. package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.gz +0 -0
  75. package/dist/client/assets/ThemeSwitcher-5cgNbWiG.js +1 -0
  76. package/dist/client/assets/{TikzGalleryDialog-cPUDQ5Wj.js → TikzGalleryDialog-CFbLjNTt.js} +1 -1
  77. package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.br +0 -0
  78. package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.gz +0 -0
  79. package/dist/client/assets/{WordCountDialog-AiuR3rra.js → WordCountDialog-hXC-cpPs.js} +1 -1
  80. package/dist/client/assets/WordCountDialog-hXC-cpPs.js.br +0 -0
  81. package/dist/client/assets/WordCountDialog-hXC-cpPs.js.gz +0 -0
  82. package/dist/client/assets/{chktex--32C-Pkl.js → chktex-CLzMD_9a.js} +1 -1
  83. package/dist/client/assets/file-down-DA4jGFrF.js +1 -0
  84. package/dist/client/assets/i18n-B8sR-BXw.js +13 -0
  85. package/dist/client/assets/i18n-B8sR-BXw.js.br +0 -0
  86. package/dist/client/assets/i18n-B8sR-BXw.js.gz +0 -0
  87. package/dist/client/assets/index-D6faTuJe.css +1 -0
  88. package/dist/client/assets/index-D6faTuJe.css.br +0 -0
  89. package/dist/client/assets/index-D6faTuJe.css.gz +0 -0
  90. package/dist/client/assets/index-dScQ5LCu.js +2 -0
  91. package/dist/client/assets/index-dScQ5LCu.js.br +0 -0
  92. package/dist/client/assets/index-dScQ5LCu.js.gz +0 -0
  93. package/dist/client/assets/relativeTime-zIVNCN0k.js +1 -0
  94. package/dist/client/assets/relativeTime-zIVNCN0k.js.br +0 -0
  95. package/dist/client/assets/relativeTime-zIVNCN0k.js.gz +0 -0
  96. package/dist/client/assets/sourceCursorStore-DWCXVKvp.js +2 -0
  97. package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.br +0 -0
  98. package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.gz +0 -0
  99. package/dist/client/assets/{spellCheck-DpWPgtM7.js → spellCheck-DpyzDbmq.js} +1 -1
  100. package/dist/client/assets/spellCheck-DpyzDbmq.js.br +0 -0
  101. package/dist/client/assets/spellCheck-DpyzDbmq.js.gz +0 -0
  102. package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js +1 -0
  103. package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.br +0 -0
  104. package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.gz +0 -0
  105. package/dist/client/index.html +3 -4
  106. package/dist/server/agents/adapters/claude.js +5 -2
  107. package/dist/server/agents/adapters/common.js +18 -5
  108. package/dist/server/agents/execution.js +25 -4
  109. package/dist/server/agents/launcher.js +5 -2
  110. package/dist/server/agents/processIdentity.js +1 -1
  111. package/dist/server/agents/terminal.js +5 -2
  112. package/dist/server/agents/windowsJob.js +141 -0
  113. package/dist/server/app.js +24 -6
  114. package/dist/server/auth.js +3 -2
  115. package/dist/server/browserOrigin.js +15 -0
  116. package/dist/server/chktex.js +23 -11
  117. package/dist/server/collaboration.js +2 -1
  118. package/dist/server/compileDiagnostics.js +13 -9
  119. package/dist/server/compiler.js +70 -25
  120. package/dist/server/config.js +5 -1
  121. package/dist/server/db.js +4 -0
  122. package/dist/server/drawioLocks.js +114 -0
  123. package/dist/server/drawioOwnedBrowser.js +122 -0
  124. package/dist/server/drawioPdf.js +182 -0
  125. package/dist/server/environment.js +17 -8
  126. package/dist/server/files.js +86 -20
  127. package/dist/server/git.js +20 -16
  128. package/dist/server/harper.js +29 -10
  129. package/dist/server/history.js +62 -15
  130. package/dist/server/i18n.js +15 -0
  131. package/dist/server/index.js +15 -8
  132. package/dist/server/locales/zh-Hant.js +9 -0
  133. package/dist/server/pdfFonts.js +78 -0
  134. package/dist/server/pm2.js +2 -1
  135. package/dist/server/processTree.js +128 -7
  136. package/dist/server/projectDeletionCleanup.js +62 -0
  137. package/dist/server/projectMutations.js +3 -0
  138. package/dist/server/projectReplace.js +2 -2
  139. package/dist/server/projectSearch.js +2 -1
  140. package/dist/server/projectTemplateCache.js +94 -0
  141. package/dist/server/projectTemplateDownload.js +75 -0
  142. package/dist/server/projectTextSave.js +56 -0
  143. package/dist/server/routes/agents.js +2 -15
  144. package/dist/server/routes/compile.js +67 -9
  145. package/dist/server/routes/drawio.js +192 -0
  146. package/dist/server/routes/projectFiles.js +106 -20
  147. package/dist/server/routes/projects.js +81 -20
  148. package/dist/server/routes/users.js +10 -14
  149. package/dist/server/synctex.js +20 -3
  150. package/dist/server/texcount.js +27 -23
  151. package/dist/server/zip.js +37 -11
  152. package/dist/shared/drawio.js +79 -0
  153. package/dist/shared/fileTypes.js +1 -1
  154. package/dist/shared/pdfFonts.js +14 -0
  155. package/dist/shared/projectImport.js +21 -0
  156. package/package.json +3 -1
  157. package/dist/client/assets/AdminUsers-C-8tXzvj.js +0 -1
  158. package/dist/client/assets/AdminUsers-C-8tXzvj.js.br +0 -0
  159. package/dist/client/assets/AdminUsers-C-8tXzvj.js.gz +0 -0
  160. package/dist/client/assets/AgentManagement-DXgfP7l_.js +0 -1
  161. package/dist/client/assets/AgentManagement-DXgfP7l_.js.br +0 -0
  162. package/dist/client/assets/AgentManagement-DXgfP7l_.js.gz +0 -0
  163. package/dist/client/assets/AgentTerminal-DD4sskCS.js +0 -2
  164. package/dist/client/assets/AgentTerminal-DD4sskCS.js.br +0 -0
  165. package/dist/client/assets/AgentTerminal-DD4sskCS.js.gz +0 -0
  166. package/dist/client/assets/AgentTerminalSurface-DliOcop5.js.gz +0 -0
  167. package/dist/client/assets/AvatarSettingsDialog-iuEbMO4a.js.br +0 -0
  168. package/dist/client/assets/AvatarSettingsDialog-iuEbMO4a.js.gz +0 -0
  169. package/dist/client/assets/CitationBibtexEditor-CDiYDj3M.js +0 -1
  170. package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js +0 -3
  171. package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js.br +0 -0
  172. package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js.gz +0 -0
  173. package/dist/client/assets/Dashboard-DqwGd9wd.js +0 -5
  174. package/dist/client/assets/Dashboard-DqwGd9wd.js.br +0 -0
  175. package/dist/client/assets/Dashboard-DqwGd9wd.js.gz +0 -0
  176. package/dist/client/assets/GitDialog-DUGAigLx.js +0 -4
  177. package/dist/client/assets/GitDialog-DUGAigLx.js.br +0 -0
  178. package/dist/client/assets/GitDialog-DUGAigLx.js.gz +0 -0
  179. package/dist/client/assets/GitHubAccountDialog-B4eD622i.js +0 -1
  180. package/dist/client/assets/GitHubAccountDialog-B4eD622i.js.br +0 -0
  181. package/dist/client/assets/GitHubAccountDialog-B4eD622i.js.gz +0 -0
  182. package/dist/client/assets/HistoryDialog-upkR8E0L.js.br +0 -0
  183. package/dist/client/assets/HistoryDialog-upkR8E0L.js.gz +0 -0
  184. package/dist/client/assets/InfoPopover-CQ3Q10tN.js +0 -1
  185. package/dist/client/assets/LatexEditor-DvDYTc0r.js +0 -25
  186. package/dist/client/assets/LatexEditor-DvDYTc0r.js.br +0 -0
  187. package/dist/client/assets/LatexEditor-DvDYTc0r.js.gz +0 -0
  188. package/dist/client/assets/MarkdownPreview-_AXp5G7f.js.br +0 -0
  189. package/dist/client/assets/MarkdownPreview-_AXp5G7f.js.gz +0 -0
  190. package/dist/client/assets/ProjectIconPickerDialog-BxjEYsau.js.br +0 -0
  191. package/dist/client/assets/ProjectIconPickerDialog-BxjEYsau.js.gz +0 -0
  192. package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js +0 -1
  193. package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js.br +0 -0
  194. package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js.gz +0 -0
  195. package/dist/client/assets/ProjectSettings-Dx-b26uN.js +0 -4
  196. package/dist/client/assets/ProjectSettings-Dx-b26uN.js.br +0 -0
  197. package/dist/client/assets/ProjectSettings-Dx-b26uN.js.gz +0 -0
  198. package/dist/client/assets/ProjectWorkspace-DiurYeU1.js +0 -25
  199. package/dist/client/assets/ProjectWorkspace-DiurYeU1.js.br +0 -0
  200. package/dist/client/assets/ProjectWorkspace-DiurYeU1.js.gz +0 -0
  201. package/dist/client/assets/QuickOpenDialog-HlkWqVR9.js.br +0 -0
  202. package/dist/client/assets/QuickOpenDialog-HlkWqVR9.js.gz +0 -0
  203. package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js.br +0 -0
  204. package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js.gz +0 -0
  205. package/dist/client/assets/SharedProjectPage-BBLOLjnD.js +0 -2
  206. package/dist/client/assets/SharedProjectPage-BBLOLjnD.js.br +0 -0
  207. package/dist/client/assets/SharedProjectPage-BBLOLjnD.js.gz +0 -0
  208. package/dist/client/assets/SystemMetricsDialog-Dr4pYWG6.js +0 -1
  209. package/dist/client/assets/SystemMetricsDialog-Dr4pYWG6.js.br +0 -0
  210. package/dist/client/assets/SystemMetricsDialog-Dr4pYWG6.js.gz +0 -0
  211. package/dist/client/assets/TagManagementDialog-D4fYVboy.js +0 -1
  212. package/dist/client/assets/TagManagementDialog-D4fYVboy.js.br +0 -0
  213. package/dist/client/assets/TagManagementDialog-D4fYVboy.js.gz +0 -0
  214. package/dist/client/assets/ThemeSwitcher-BgzkYTeA.js +0 -1
  215. package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js.br +0 -0
  216. package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js.gz +0 -0
  217. package/dist/client/assets/WordCountDialog-AiuR3rra.js.br +0 -0
  218. package/dist/client/assets/WordCountDialog-AiuR3rra.js.gz +0 -0
  219. package/dist/client/assets/dist-DdUqlCPw.js +0 -1
  220. package/dist/client/assets/dist-DdUqlCPw.js.br +0 -0
  221. package/dist/client/assets/dist-DdUqlCPw.js.gz +0 -0
  222. package/dist/client/assets/i18n-Dpk6KCs6.js +0 -13
  223. package/dist/client/assets/i18n-Dpk6KCs6.js.br +0 -0
  224. package/dist/client/assets/i18n-Dpk6KCs6.js.gz +0 -0
  225. package/dist/client/assets/index-B1vejuOw.js +0 -2
  226. package/dist/client/assets/index-B1vejuOw.js.br +0 -0
  227. package/dist/client/assets/index-B1vejuOw.js.gz +0 -0
  228. package/dist/client/assets/index-Blr4J_Pq.css +0 -1
  229. package/dist/client/assets/index-Blr4J_Pq.css.br +0 -0
  230. package/dist/client/assets/index-Blr4J_Pq.css.gz +0 -0
  231. package/dist/client/assets/relativeTime-CcP1IEvr.js +0 -1
  232. package/dist/client/assets/relativeTime-CcP1IEvr.js.br +0 -0
  233. package/dist/client/assets/relativeTime-CcP1IEvr.js.gz +0 -0
  234. package/dist/client/assets/sourceCursorStore-EycYBVxj.js +0 -1
  235. package/dist/client/assets/sourceCursorStore-EycYBVxj.js.br +0 -0
  236. package/dist/client/assets/sourceCursorStore-EycYBVxj.js.gz +0 -0
  237. package/dist/client/assets/spellCheck-DpWPgtM7.js.br +0 -0
  238. package/dist/client/assets/spellCheck-DpWPgtM7.js.gz +0 -0
  239. package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js +0 -1
  240. package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js.br +0 -0
  241. package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js.gz +0 -0
package/DESIGN.md CHANGED
@@ -330,7 +330,9 @@ listener. Validation covers paths, limits, engines, timeout/queue settings,
330
330
  URLs, and cross-field constraints such as the default engine being present in
331
331
  the allowed-engine list.
332
332
 
333
- Startup checks Node.js, `latexmk`, and every configured LaTeX engine.
333
+ Startup requires Node.js, `latexmk`, and every engine in
334
+ `latex.allowedEngines`. The same list controls API validation and editor
335
+ choices. Removing an engine does not silently change existing projects.
334
336
  `texlite requirements` performs a configuration-free preflight over the
335
337
  default host commands, requiring Node.js, `latexmk`, and at least one supported
336
338
  LaTeX engine. `texlite doctor` also reports optional host tools in a
@@ -1055,6 +1057,20 @@ The uploaded compressed ZIP remains in memory, while expanded files go directly
1055
1057
  to disk. Exports exclude `.git`, preserve empty folders, and finish in a private
1056
1058
  temporary ZIP under the consistent-read barrier before the HTTP download starts.
1057
1059
 
1060
+ New projects can also import an HTTP(S) ZIP URL without sign-in credentials.
1061
+ DNS resolution and destination reachability follow the host network policy;
1062
+ TexLite does not restrict destination IP ranges. Deployers control network
1063
+ access, including access to internal services, for users allowed to create
1064
+ projects. Downloads have a 30-second overall deadline, a five-redirect limit
1065
+ and the configured upload-size limit.
1066
+ Downloaded archives pass through the same ZIP import checks; project latexmkrc
1067
+ remains disabled. Successfully imported archives are cached by normalized URL
1068
+ under `tmp/template-cache` for seven days, with content hashes checked on reuse.
1069
+ Cache reads do not extend expiry or check the remote URL for changes. Expired
1070
+ entries are cleaned lazily during subsequent imports, at most once per hour.
1071
+ Cache publication failures do not prevent project creation, and existing
1072
+ projects never share writable source files with the cache.
1073
+
1058
1074
  ## Editor, files, and navigation
1059
1075
 
1060
1076
  The file-tree overflow menu opens project-wide search in a lazy-loaded modal.
@@ -1434,8 +1450,21 @@ force either mode without changing project compiler settings. The threshold is
1434
1450
  a size-based heuristic, not a universal latency optimum. Range mode allows
1435
1451
  PDF.js to combine streaming and ranged requests; it does not guarantee that
1436
1452
  only the visible page's bytes are downloaded. The output panel groups the PDF,
1437
- log, warnings, errors, generated artifacts, and recovery actions; clean-cache
1453
+ log, warnings, errors, generated artifacts, PDF fonts, and recovery actions; clean-cache
1438
1454
  and clean-artifact actions are for recovery rather than routine compilation.
1455
+ The Fonts tab invokes optional host `pdffonts` on demand, with bounded runtime
1456
+ and output and cancellation when the panel closes. The authenticated read
1457
+ endpoint validates the project, main document and successful PDF run together;
1458
+ it never substitutes the latest log's run. Raw tool errors and host paths stay
1459
+ out of responses. Font types, embedding, subsetting and ToUnicode presence are
1460
+ reported separately: missing ToUnicode is not proof that text cannot be copied,
1461
+ and a font-free PDF may contain outlines or rasterized text.
1462
+ PDF files in the source tree expose the same diagnostics in a named modal via
1463
+ their row menu. The file endpoint validates read access and source paths, copies
1464
+ the PDF under a short filesystem read barrier, then runs the shared inspector on
1465
+ the temporary copy outside the project queue. Cancellation, failures and success
1466
+ all remove the copy; access is rechecked before returning results.
1467
+
1439
1468
  The Vite build publishes the installed PDF.js version's predefined Adobe CMaps
1440
1469
  and their license under a versioned asset directory. The development server
1441
1470
  serves the same resources. PDF.js resolves this URL against the runtime base
@@ -1519,6 +1548,60 @@ TexLite does not keep an unlimited browsable compile history: old unsuccessful
1519
1548
  run rows and unreferenced bundles are pruned, while the latest successful
1520
1549
  result for each root is retained.
1521
1550
 
1551
+ ## draw.io diagrams
1552
+
1553
+ `.drawio` files are XML text, shared with normal file classification and snapshot
1554
+ tracking, but opened in the editor pane using a lazy-loaded official diagrams.net
1555
+ iframe. The parent checks both message origin and source window. Only diagram
1556
+ XML is exchanged; project URLs and session cookies are not handed to the editor.
1557
+ Diagrams are excluded from Yjs text hydration/mutations and global text
1558
+ search/replace. Explicit saves check source revisions under the project mutation
1559
+ lock, send file notifications, and record the saving user. Snapshot tracking
1560
+ still uses the shared text classification. Conflicts preserve the local editor
1561
+ rather than overwriting newer source.
1562
+
1563
+ `DrawioLocks` grants one runtime-only lease per project/path to a dedicated
1564
+ authenticated, same-origin WebSocket. HTTP saves and PDF export validate its
1565
+ unpredictable token against the owning user and live connection; an account's
1566
+ other tabs do not share ownership. Native ping/pong renews a 60-second lease at
1567
+ 20-second intervals. Explicit release, socket close/error, timeout, revoked
1568
+ authentication/permissions and app shutdown clear the lease. Object identity
1569
+ fences late close/pong events so they cannot affect a successor. Source-tree
1570
+ maintenance revokes project leases before restore/deletion; generic file
1571
+ move/delete/overwrite also checks active source/PDF locks. Host tools can bypass
1572
+ an application lock, so content/output revisions remain independently checked.
1573
+
1574
+ The browser opens viewers read-only, freezes rather than reloads a writable
1575
+ frame after loss of ownership, and retains its unsaved XML until the user
1576
+ explicitly discards it. Lock reconnection is explicit. Effect cleanup closes
1577
+ the exact connection, `pagehide` releases even before React unmounts, and
1578
+ StrictMode's probe mount does not open a socket. A clean stale viewer is refreshed
1579
+ against the source revision supplied when ownership is granted; an existing
1580
+ local draft is never automatically replaced.
1581
+
1582
+ PDF export saves the source and obtains a current-page SVG from the iframe,
1583
+ then sends it to an authenticated write-only project endpoint. A split export
1584
+ button defaults to the current page, optionally exports selected content, and
1585
+ sets a 0–100 px margin (default 0 for a tight bounding box). Both scopes crop to content. Selection uses
1586
+ an on-open metadata-only query to disable the selection option when nothing is
1587
+ selected. Menu queries have independent request identities and are cancelled
1588
+ on close/unmount; late results cannot change a reopened menu. Settings remain
1589
+ local to the open editor and never save source or initiate PDF export.
1590
+ Selection export uses
1591
+ the native lossless JSON/XML selection export, rejecting an empty selection;
1592
+ the complete document is captured separately for saving. A disposable read-only
1593
+ offscreen iframe renders that subset so the live editor and undo history are
1594
+ never replaced. PDF capture freezes live input until finished/cancelled; the
1595
+ temporary frame is removed on success, failure, timeout or cancellation.
1596
+ The server checks
1597
+ ownership and source/output revisions before rendering and again before an atomic write next
1598
+ to the `.drawio` file. Headless `puppeteer-core` drives host Chromium/Chrome/Edge
1599
+ without downloading a browser, using an isolated temporary profile with scripts
1600
+ disabled and outbound/file requests blocked. Rendering never holds the source
1601
+ mutation lock. Each app owns bounded export jobs and aborts them on disconnect
1602
+ or shutdown. Read-only members can view diagrams, but neither they nor anonymous
1603
+ view-link visitors can save diagrams or invoke the host export process.
1604
+
1522
1605
  ## History and recovery
1523
1606
 
1524
1607
  Selection-history requests bind their offsets to a SHA-256 hash of the
package/NPM_TESTING.md CHANGED
@@ -19,6 +19,50 @@ The dry run lists the files that would be published. Check that it contains the
19
19
  compiled server and `dist/client`, and does not contain local databases,
20
20
  projects, credentials, or development-only files.
21
21
 
22
+ After building, run the same automated package smoke test as Windows CI:
23
+
24
+ ~~~text
25
+ npm run test:package-smoke
26
+ ~~~
27
+
28
+ It packs the existing build, installs it into a temporary npm prefix, checks
29
+ the installed command, then verifies initialization, HTTP health, login and
30
+ clean shutdown on a temporary loopback port and data directory. It uses local
31
+ TeX version fixtures and checks that the server reports the configured engine
32
+ list. This does not test real TeX compilation or PM2.
33
+
34
+ Windows CI separately exercises real optional host tools: Harper on a LaTeX
35
+ file and Poppler on a PDF generated by the runner's Chromium-family browser.
36
+ To repeat those checks with the required executables available locally, run
37
+ the following in PowerShell:
38
+
39
+ ~~~powershell
40
+ $env:TEXLITE_TEST_NATIVE_HOST_TOOLS = '1'
41
+ npm test -- tests/nativeHostTools.test.ts
42
+ Remove-Item Env:TEXLITE_TEST_NATIVE_HOST_TOOLS
43
+ ~~~
44
+
45
+ ## Verify native TeX Live compilation
46
+
47
+ On a host with `latexmk`, `pdflatex`, `xelatex`, `lualatex` and `synctex` on
48
+ `PATH`, run the opt-in compilation tests. They use temporary projects with
49
+ spaces and non-ASCII names and verify cache reuse, SyncTeX in both directions,
50
+ error locations, and cancellation. Standard CI still does not install TeX Live.
51
+
52
+ PowerShell:
53
+
54
+ ~~~powershell
55
+ $env:TEXLITE_TEST_NATIVE_TEXLIVE = '1'
56
+ npm test -- tests/nativeTexLive.test.ts
57
+ Remove-Item Env:TEXLITE_TEST_NATIVE_TEXLIVE
58
+ ~~~
59
+
60
+ POSIX shell:
61
+
62
+ ~~~bash
63
+ TEXLITE_TEST_NATIVE_TEXLIVE=1 npm test -- tests/nativeTexLive.test.ts
64
+ ~~~
65
+
22
66
  ## Install the tarball into an isolated prefix
23
67
 
24
68
  Create a temporary directory, pack the current version, and install it without
@@ -109,8 +153,8 @@ Open <http://127.0.0.1:3000> in a browser and exercise login, project
109
153
  creation, editing, compilation, file upload, comments, and PDF preview. Press
110
154
  Ctrl+C to stop the server.
111
155
 
112
- The package requires Node.js 24 or newer and the LaTeX engines enabled in the
113
- selected configuration.
156
+ The package requires Node.js 24 or newer, `latexmk`, and each engine in
157
+ `latex.allowedEngines`.
114
158
 
115
159
  ## Test optional external agent terminals
116
160
 
package/OPERATIONS.md CHANGED
@@ -12,6 +12,55 @@ For the product's intended use and editor comparison, start with the
12
12
  - At least one configured engine: `pdflatex`, `xelatex`, or `lualatex`
13
13
  - `git` only when a project owner uses the optional Git/GitHub integration
14
14
 
15
+ Native Windows x64 compatibility is still being verified. The Windows Agent
16
+ terminal uses Windows PowerShell, CIM and a Windows Job Object to track each
17
+ TexLite-launched process tree. It will not start a CLI if Windows policy blocks
18
+ job assignment. Stop all TexLite Agent tasks before upgrading an experimental
19
+ Windows deployment: older running records without job ownership cannot be
20
+ recovered automatically. TexLite keeps those projects reserved instead of
21
+ starting another task on top of a potentially surviving process.
22
+
23
+ Native Windows compilation, Git pushes, and draw.io exports also use a Job Object. If policy
24
+ blocks job assignment, TexLite reports a failure before running the command.
25
+ draw.io exports use a separate browser profile and a DevTools pipe, not a
26
+ debugging port. TexLite waits for the browser job to stop before removing that
27
+ profile.
28
+ Local Git reads and short host-tool probes do not use this launcher. Windows
29
+ sandboxing and real CLI compatibility still need deployment verification.
30
+
31
+ ZIP imports on Windows reject conflicting or invalid paths. For example, an
32
+ archive cannot contain both `Main.tex` and `main.tex`, or a filename with a
33
+ trailing dot or a reserved device name. Use the exact casing shown in the file
34
+ tree. A rename can change only the case of a name. If a viewer or another
35
+ program blocks a rename or deletion, close it and retry; TexLite does not copy
36
+ over or recursively delete the live path as a fallback on Windows.
37
+
38
+ For native Windows x64, put the Windows executables on the `PATH` of the
39
+ account that runs TexLite, then restart TexLite if that environment changes.
40
+ Use `texlite requirements` to check the tools:
41
+
42
+ - **TeX Live:** use the [native Windows distribution](https://tug.org/texlive/).
43
+ Install the relevant TeX Live packages for optional TeXcount, ChkTeX, BibTeX,
44
+ Biber and MakeIndex support. SyncTeX also comes from the TeX toolchain.
45
+ - **Harper:** use `harper-cli-x86_64-pc-windows-msvc.zip` from the
46
+ [Harper releases](https://github.com/Automattic/harper/releases).
47
+ TexLite needs `harper-cli.exe`, not the Harper desktop app or language server.
48
+ - **PDF fonts:** use a [Windows Poppler build](https://github.com/oschwartz10612/poppler-windows/releases)
49
+ and add the directory containing `pdffonts.exe` to `PATH`. Keep its
50
+ accompanying DLLs in place. This is an optional host tool, not an npm package.
51
+ - **Diagram export and Git:** use a native Chromium, Chrome, or Edge
52
+ executable for diagram PDF export, and [Git for Windows](https://gitforwindows.org/)
53
+ for Git/GitHub backup. These tools do not require WSL.
54
+ - **Agent terminals:** install the native CLI, not just the vendor's desktop
55
+ app. Claude Code can use PowerShell; if you configure a custom Git Bash path
56
+ on the TexLite host, TexLite forwards `CLAUDE_CODE_GIT_BASH_PATH`.
57
+ Agent terminals also need the optional npm module `node-pty`.
58
+
59
+ The npm package and Agent PTY are exercised on the Windows CI runner. CI also
60
+ runs the native Harper CLI and exports a diagram PDF for inspection with
61
+ Poppler. Real TeX compilation and authenticated Agent sessions are separate
62
+ deployment checks.
63
+
15
64
  Check a host before initialization:
16
65
 
17
66
  ~~~bash
@@ -29,11 +78,18 @@ harper-cli --version
29
78
  harper-ls --version
30
79
  ~~~
31
80
 
32
- `texlite init` and `texlite start` validate Node.js, `latexmk`, and every
33
- engine named in `latex.allowedEngines`. `texlite requirements` can be run
34
- before initialization: it checks only the default commands on `PATH`, without
35
- reading a configuration file or any TexLite data. It requires Node.js and
36
- `latexmk`, and requires at least one of the three supported LaTeX engines.
81
+ `texlite init`, `texlite start`, and `texlite serve` require Node.js,
82
+ `latexmk`, and every engine in `latex.allowedEngines`. The project engine
83
+ selector uses that exact list. By default it includes `pdflatex`, `xelatex`,
84
+ and `lualatex`. If only XeLaTeX is installed, set `latex.allowedEngines`
85
+ to `["xelatex"]`. The configured `latex.defaultEngine` (normally `xelatex`)
86
+ must appear in the list. If an existing project uses an engine removed from
87
+ the list, select a different engine in the project settings before compiling.
88
+
89
+ `texlite requirements` can be run before initialization: it checks commands
90
+ on `PATH` without reading a configuration file or any TexLite data. It
91
+ requires Node.js, `latexmk`, and at least one supported LaTeX engine. It
92
+ does not verify the engine list in your configuration.
37
93
  `texlite doctor` presents the configured deployment checks and optional host
38
94
  tools in a table with their requirement level, installation state, and
39
95
  detected version. Missing optional tools never stop the editor:
@@ -42,6 +98,65 @@ Git enables GitHub backup, TeXcount enables document statistics, and
42
98
  for host diagnosis and external editor integrations; TexLite itself invokes
43
99
  `harper-cli`.
44
100
 
101
+ PDF font inspection is optional. Install Poppler's `pdffonts` command on the
102
+ server and make it available on `PATH` to use **Compile output → Fonts** or
103
+ **PDF file menu → Inspect fonts** in the file tree.
104
+ TexLite runs it on demand, against the selected PDF run or a source PDF copy;
105
+ missing tools do not prevent startup or compilation. Type 3 and non-embedded
106
+ fonts are highlighted for review, not automatically repaired.
107
+
108
+ ### draw.io diagrams
109
+
110
+ Use **Files → ⋯ → draw.io diagram**, then open the `.drawio` file to edit
111
+ it in the editor pane with an embedded diagrams.net editor. The browser needs access to
112
+ `https://embed.diagrams.net`; the editor is not bundled with TexLite. Diagram
113
+ data is passed directly to the iframe, not placed in its URL. Save explicitly
114
+ before closing or switching files. Unsaved changes require confirmation before
115
+ leaving the diagram. Each file allows one editing browser tab at a time, even
116
+ for the same account. Other tabs are read-only and can use **Try editing** once
117
+ the owner closes the diagram. Different diagram files are independent.
118
+
119
+ Closing, switching files or leaving the page releases ownership. The server
120
+ sends WebSocket pings every 20 seconds; the browser's native pong renews a
121
+ 60-second lease without
122
+ depending on background-tab JavaScript timers. Disconnects, revoked access,
123
+ project restore/deletion, and server shutdown release the lock. A restart never
124
+ restores locks, and old connection tokens cannot save or export. On connection
125
+ loss, the editor freezes but retains its local draft. Reacquiring a lock does
126
+ not bypass the source-version check: external host edits can still cause a save
127
+ conflict. Locked diagrams and their PDFs cannot be moved, deleted or replaced
128
+ through generic file operations until the editing tab is closed.
129
+
130
+ Diagrams use explicit saves, not Yjs real-time text editing, and are excluded
131
+ from global text search/replace. They remain tracked as text in project snapshots.
132
+
133
+ **Export PDF** saves the current diagram page beside the source file by default.
134
+ The attached export options switch between **Current page** and **Selected
135
+ content**, with **Content margin** from 0 to 100 px (default 0 for a tight bounding box). The menu checks
136
+ the current selection on opening and disables **Selected content** when empty.
137
+ Settings take effect immediately, remain when the menu is closed/reopened, and
138
+ never initiate an export; use the main **Export PDF** button to run it.
139
+ Output is always cropped
140
+ to content, not the drawing's paper size. Empty selections are rejected rather
141
+ than exporting the whole page. The full `.drawio` document is saved regardless
142
+ of export scope; selection export never replaces it with a subset. Existing PDFs
143
+ are replaced only after confirmation. It uses a host-installed Chromium,
144
+ Chrome or Edge, in that order; Firefox and Safari are not export backends.
145
+ Missing browsers do not prevent diagram editing, server startup or compilation.
146
+ Set optional `drawio.browserPath` in `texlite.config.json` to an explicit browser
147
+ executable (relative paths resolve from that configuration file). No browser is
148
+ automatically downloaded. In Docker the browser and fonts must be installed
149
+ inside the container. Chromium's sandbox stays enabled.
150
+
151
+ Export runs with an isolated temporary browser profile, scripts disabled and
152
+ network/file requests blocked. Images and custom fonts must be embedded in the
153
+ SVG. Use fonts installed on the host for consistent output. New shapes default
154
+ to plain text labels. This reduces formatting differences but does not guarantee
155
+ font embedding or the absence of Type 3 fonts; inspect the resulting document in
156
+ **Compile output → Fonts** when needed. Exports are limited to two simultaneous
157
+ jobs per instance and 30 seconds per job, and are cancelled when the request
158
+ ends or the server shuts down.
159
+
45
160
  Formatting does not require a host binary. The browser uses bundled `tex-fmt`
46
161
  WASM for `.tex`, `.cls`, and `.sty`, and browser-side `bibtex-tidy` for `.bib`.
47
162
 
@@ -234,6 +349,7 @@ preferred.
234
349
  | `siteName` | `TexLite` | Site title. |
235
350
  | `adminEmail` | empty | Optional administrator contact address. |
236
351
  | `tikzGallery.enabled` / `tikzGallery.path` | `false` / `addon/texlite-tikz` | Optional figure gallery. A relative path is resolved from the configuration file. |
352
+ | `drawio.browserPath` | automatic detection | Optional Chromium-family executable for diagram PDF export. Relative paths resolve from the configuration file. |
237
353
  | `server.host` / `server.port` | `127.0.0.1` / `3000` | Use `0.0.0.0` to serve a trusted local network; keep localhost behind a tunnel or reverse proxy. |
238
354
  | `server.basePath` | `/` | Public URL mount point, such as `/texlite` or `/tools/texlite`. |
239
355
  | `storage.dataDir` | XDG data directory | Stores all persistent project data. |
@@ -246,7 +362,7 @@ preferred.
246
362
  | `latex.latexmk` | `latexmk` | Host command. |
247
363
  | `latex.defaultEngine` | `xelatex` | Must appear in the allowed list. |
248
364
  | `updates.enabled` | `true` | Background release checks and administrator dashboard reminders. Set to `false` for offline deployments. |
249
- | `latex.allowedEngines` | `pdflatex`, `xelatex`, `lualatex` | Engines available in the UI. |
365
+ | `latex.allowedEngines` | `pdflatex`, `xelatex`, `lualatex` | Engines offered in the editor. All entries must be installed. |
250
366
  | `latex.extraArgs` | `[]` | Additional configured compiler arguments. |
251
367
  | `latex.compileTimeoutSeconds` | `600` | Per-job time limit. |
252
368
  | `latex.maxCompileJobs` | `10` | Global concurrent LaTeX-process limit. |
@@ -618,6 +734,20 @@ but the owner must delete the link and create a new one to regain copying.
618
734
  For an online copy of SQLite, include WAL files or use a SQLite-aware backup
619
735
  method.
620
736
 
737
+ If old files cannot be cleaned up after a successful snapshot restore, TexLite
738
+ keeps the restored project live and retries cleanup of `.history-cleanup-*`
739
+ directories at startup. Do not automatically delete `.history-backup-*`
740
+ directories; they may contain the original files from an interrupted restore.
741
+
742
+ When an administrator deletes a user and their projects, a directory that
743
+ cannot be removed (for example, because another Windows process holds it open)
744
+ stays queued in SQLite. TexLite retries at startup and every minute and logs
745
+ the project ID on failure. The user and projects remain deleted in TexLite.
746
+
747
+ An HTTP source save that cannot restore the old file after a failed SQLite
748
+ commit logs the source path and recovery directory. Keep the `previous` file
749
+ in that directory until the source has been recovered.
750
+
621
751
  TexLite is designed for trusted users on localhost. Shell escape is disabled by
622
752
  default and compile jobs have timeouts and concurrency limits, but LaTeX itself
623
753
  is not a security boundary. Before exposing it to an untrusted network, add an
package/README.md CHANGED
@@ -161,8 +161,7 @@ its own login still protects every project.
161
161
  <details>
162
162
  <summary><b>TexLite Share</b>: the simplest HTTPS link for TexLite</summary>
163
163
 
164
- [TexLite Share](https://share.zhongpu.info/) is currently hosted in Hong Kong,
165
- so access from mainland China or regions outside Southeast Asia may be slower.
164
+ [TexLite Share](https://share.zhongpu.info/) is currently hosted in New York State, USA.
166
165
  With TexLite running locally on its default port, install and launch the tunnel
167
166
  client:
168
167
 
package/README.zh-CN.md CHANGED
@@ -144,8 +144,8 @@ TexLite 是面向小型可信团队的单宿主机应用。账号由管理员创
144
144
  <details>
145
145
  <summary><b>TexLite Share</b>:为 TexLite 提供最简单的 HTTPS 链接</summary>
146
146
 
147
- [TexLite Share](https://share.zhongpu.info/) 目前部署在香港,来自中国大陆或东南亚以外
148
- 地区的访问可能较慢。确保 TexLite 已在默认端口启动,然后安装并运行隧道客户端:
147
+ [TexLite Share](https://share.zhongpu.info/) 目前部署在美国纽约州。
148
+ 确保 TexLite 已在默认端口启动,然后安装并运行隧道客户端:
149
149
 
150
150
  ```bash
151
151
  curl -fsSL https://raw.githubusercontent.com/ChenZhongPu/TexLite-Share/main/install-client.sh | bash
@@ -1,5 +1,17 @@
1
1
  # Third-party notices
2
2
 
3
+ ## draw.io integration and Puppeteer
4
+
5
+ The diagram editor is loaded from the external diagrams.net iframe; TexLite
6
+ does not redistribute draw.io. The draw.io and diagrams.net names belong to
7
+ their respective owners and do not imply endorsement.
8
+
9
+ Server-side PDF export uses the separately installed `puppeteer-core` package,
10
+ licensed under Apache-2.0, copyright Google Inc. and Puppeteer contributors.
11
+ Its upstream license and notices are available in the
12
+ [Puppeteer repository](https://github.com/puppeteer/puppeteer/blob/main/LICENSE).
13
+ No Chromium, Chrome or Edge binary is bundled or downloaded by TexLite.
14
+
3
15
  ## Coding agent brand icons
4
16
 
5
17
  The inline SVG paths in `src/client/agents/AgentIcon.tsx` come from theSVG:
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{S as r,v as i}from"./relativeTime-zIVNCN0k.js";import{t as a}from"./useTranslation-DwkoADSz.js";import{t as o}from"./createLucideIcon-CDYIzuiB.js";import{C as ee,E as te,G as ne,V as re,f as ie,u as ae,x as s}from"./useDeletionTransitions-Bm4I5qej.js";import{t as oe}from"./circle-check-CunlnBPw.js";import{t as c}from"./loader-circle-DKGyi5EK.js";import{t as l}from"./lock-keyhole-aC_QjKDi.js";import{t as se}from"./search-DjOWqLig.js";import{t as u}from"./user-plus-NNBQOWDP.js";import{A as d,T as f,_ as p,g as ce}from"./index-dScQ5LCu.js";import{t as le}from"./SuccessNotice-ubBtzzi_.js";var m={name:`dices`,size:24,node:[[`rect`,{width:`12`,height:`12`,x:`2`,y:`10`,rx:`2`,ry:`2`,key:`6agr2n`}],[`path`,{d:`m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6`,key:`1o487t`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M10 14h.01`,key:`ssrbsk`}],[`path`,{d:`M15 6h.01`,key:`cblpky`}],[`path`,{d:`M18 9h.01`,key:`2061c0`}]]};m.node;var ue=o(m),h={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};h.node;var g=o(h),_=e(t(),1),v=n();function y(e=10){let t=crypto.getRandomValues(new Uint8Array(e));return Array.from(t,e=>`ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%`[e%62]).join(``)}function b({currentUser:e,minPasswordLength:t,onBack:n}){let{t:o}=a(),[m,h]=(0,_.useState)([]),[b,de]=(0,_.useState)(null),[x,S]=(0,_.useState)(``),[C,w]=(0,_.useState)(1),[T,fe]=(0,_.useState)({page:1,pageSize:20,total:0,totalPages:0}),[E,pe]=(0,_.useState)(!0),[D,me]=(0,_.useState)(!1),[he,ge]=(0,_.useState)(0),[_e,O]=(0,_.useState)(``),k=le(),[A,j]=(0,_.useState)(!1),[M,N]=(0,_.useState)(``),[ve,P]=(0,_.useState)(!1),[F,I]=(0,_.useState)({username:``,displayName:``,password:``,role:`user`,canCreateProjects:!1}),[L,R]=(0,_.useState)(null),[z,B]=(0,_.useState)(``),[ye,V]=(0,_.useState)(null),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(!1),[K,be]=(0,_.useState)(!1),[xe,q]=(0,_.useState)(``),[J,Y]=(0,_.useState)(null),[X,Se]=(0,_.useState)(!1),[Ce,Z]=(0,_.useState)(``),Q=x.trim(),$=()=>ge(e=>e+1);(0,_.useEffect)(()=>{let e=new AbortController;V(null),pe(!0),me(!1),O(``);let t=window.setTimeout(()=>{let t=new URLSearchParams({page:String(C)});Q&&t.set(`q`,Q),d(`/api/admin/users?${t}`,{signal:e.signal}).then(t=>{e.signal.aborted||(h(t.users),de(t.summary),fe(t.pagination),w(t.pagination.page))}).catch(t=>{e.signal.aborted||(O(f(t)),me(!0))}).finally(()=>{e.signal.aborted||pe(!1)})},Q?200:0);return()=>{window.clearTimeout(t),e.abort()}},[Q,C,he]);let we=async()=>{if(!A){if(F.password.length<t)return N(o(`auth.passwordMinimum`,{count:t}));j(!0),N(``),k.clear();try{await d(`/api/admin/users`,{method:`POST`,body:JSON.stringify({username:F.username,displayName:F.displayName||F.username,password:F.password,role:F.role,canCreateProjects:F.canCreateProjects})}),P(!1),I({username:``,displayName:``,password:``,role:`user`,canCreateProjects:!1}),$(),k.show(`create`)}catch(e){N(f(e))}finally{j(!1)}}},Te=async e=>{Y({target:e,setting:e.role===`admin`?`demote`:`promote`}),Z(``)},Ee=async e=>{Y({target:e,setting:e.canCreateProjects?`denyProjectCreation`:`allowProjectCreation`}),Z(``)},De=async()=>{if(!J||X)return;let{target:e,setting:t}=J,n=t===`demote`?{role:`user`}:t===`promote`?{role:`admin`}:{canCreateProjects:t===`allowProjectCreation`};Se(!0),Z(``);try{await d(`/api/admin/users/${e.id}`,{method:`PATCH`,body:JSON.stringify(n)}),$(),Y(null)}catch(e){Z(f(e))}finally{Se(!1)}},Oe=async()=>{if(L&&z&&!A){if(z.length<t)return N(o(`auth.passwordMinimum`,{count:t}));j(!0),N(``),k.clear();try{await d(`/api/admin/users/${L.id}`,{method:`PATCH`,body:JSON.stringify({password:z})}),k.show(`reset:${L.id}`),R(null),B(``)}catch(e){N(f(e))}finally{j(!1)}}},ke=async()=>{if(H&&!K){be(!0),q(``);try{await d(`/api/admin/users/${H.id}`,{method:`DELETE`,body:JSON.stringify({deleteProjects:W})}),U(null),G(!1),$()}catch(e){q(f(e))}finally{be(!1)}}},Ae=[{key:`totalUsers`,detail:b?o(`users.summary.administrators`,{count:b.administrators}):``},{key:`projectCreators`,detail:b?o(`users.summary.ofUsers`,{count:b.totalUsers}):``},{key:`totalProjects`,detail:b?o(`users.summary.projectOwners`,{count:b.projectOwners}):``}];return(0,v.jsxs)(`section`,{className:`admin-users-page management-page`,children:[(0,v.jsxs)(`div`,{className:`section-title`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`h1`,{children:[(0,v.jsx)(ee,{"aria-hidden":!0,size:25}),o(`users.manage`)]}),(0,v.jsx)(`p`,{className:`muted`,children:o(`users.onlyAdmin`)})]}),(0,v.jsxs)(`button`,{type:`button`,className:`dashboard-back-button`,onClick:n,children:[(0,v.jsx)(r,{size:14}),o(`navigation.backToProjects`)]})]}),(0,v.jsxs)(`div`,{className:`admin-user-layout`,children:[(0,v.jsx)(`dl`,{className:`admin-user-summary`,"aria-label":o(`users.overview`),children:Ae.map(({key:e,detail:t})=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{children:o(`users.summary.${e}`)}),(0,v.jsxs)(`dd`,{className:b?.[e]===0?`admin-user-zero`:void 0,children:[(0,v.jsx)(`strong`,{children:b?.[e]??`—`}),t&&(0,v.jsx)(`span`,{children:t})]})]},e))}),(0,v.jsxs)(`div`,{className:`admin-user-content`,children:[(0,v.jsxs)(`div`,{className:`admin-user-toolbar`,children:[(0,v.jsxs)(`div`,{className:`admin-user-filters`,children:[(0,v.jsxs)(`div`,{className:`admin-user-search`,role:`search`,children:[(0,v.jsx)(se,{"aria-hidden":!0,size:16}),(0,v.jsx)(`input`,{role:`searchbox`,"aria-label":o(`users.searchPlaceholder`),placeholder:o(`users.searchPlaceholder`),value:x,onChange:e=>{S(e.target.value),w(1)}}),x&&(0,v.jsx)(`button`,{type:`button`,"aria-label":o(`users.clearSearch`),title:o(`users.clearSearch`),onClick:()=>{S(``),w(1)},children:(0,v.jsx)(s,{"aria-hidden":!0,size:14})})]}),Q&&!E&&!D&&(0,v.jsx)(`span`,{className:`admin-user-count`,role:`status`,children:o(`users.total`,{count:T.total})})]}),(0,v.jsxs)(`button`,{className:`primary icon-button admin-user-add`,onClick:()=>{k.clear(),N(``),P(!0)},children:[(0,v.jsx)(u,{"aria-hidden":!0,size:15}),(0,v.jsx)(`span`,{role:`status`,children:o(k.message===`create`?`common.done`:`users.add`)})]})]}),_e&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:_e}),(0,v.jsx)(`div`,{className:`table-card admin-user-table`,"aria-busy":E,children:(0,v.jsxs)(`table`,{children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:o(`common.user`)}),(0,v.jsx)(`th`,{children:o(`users.role`)}),(0,v.jsx)(`th`,{children:o(`users.createProjects`)}),(0,v.jsx)(`th`,{children:o(`users.ownedProjects`)}),(0,v.jsx)(`th`,{children:o(`users.actions`)})]})}),(0,v.jsx)(`tbody`,{children:E?(0,v.jsx)(`tr`,{children:(0,v.jsx)(`td`,{colSpan:5,className:`admin-user-list-state`,children:(0,v.jsxs)(`span`,{role:`status`,children:[(0,v.jsx)(c,{className:`spin`,size:16}),o(`common.loading`)]})})}):D?(0,v.jsx)(`tr`,{children:(0,v.jsxs)(`td`,{colSpan:5,className:`admin-user-list-state`,children:[(0,v.jsx)(`span`,{children:o(`users.loadFailed`)}),(0,v.jsx)(`button`,{type:`button`,onClick:$,children:o(`common.retry`)})]})}):m.length===0?(0,v.jsx)(`tr`,{children:(0,v.jsx)(`td`,{colSpan:5,className:`admin-user-list-state`,children:o(Q?`users.noMatches`:`users.empty`)})}):m.map(t=>{let n=t.id===e.id,r=A||X,i=ye===t.id,a=k.message===`reset:${t.id}`;return(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`admin-user-identity`,children:[(0,v.jsx)(ie,{userId:t.id,name:t.displayName,username:t.username,avatarStyle:t.avatarStyle,className:`admin-user-avatar`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`strong`,{children:t.displayName}),(0,v.jsxs)(`small`,{children:[`@`,t.username]})]})]})}),(0,v.jsx)(`td`,{children:n?(0,v.jsxs)(`span`,{className:`admin-user-badge`,title:o(`users.selfProtected`),children:[(0,v.jsx)(l,{size:12,"aria-hidden":!0}),o(`common.admin`)]}):(0,v.jsxs)(`select`,{className:`admin-user-role`,"aria-label":o(`users.roleFor`,{username:t.username}),value:t.role,disabled:r,onChange:()=>void Te(t),children:[(0,v.jsx)(`option`,{value:`user`,children:o(`common.user`)}),(0,v.jsx)(`option`,{value:`admin`,children:o(`common.admin`)})]})}),(0,v.jsx)(`td`,{children:t.role===`admin`?(0,v.jsxs)(`span`,{className:`admin-user-locked`,title:o(`users.adminCreation`),children:[(0,v.jsx)(l,{size:12,"aria-hidden":!0}),o(`users.alwaysAllowed`)]}):(0,v.jsx)(`button`,{type:`button`,className:`admin-user-switch`,role:`switch`,"aria-checked":t.canCreateProjects,"aria-label":o(`users.creationFor`,{username:t.username}),disabled:r,onClick:()=>void Ee(t),children:(0,v.jsx)(`span`,{})})}),(0,v.jsx)(`td`,{className:t.ownedProjects?void 0:`admin-user-zero`,children:t.ownedProjects??0}),(0,v.jsx)(`td`,{children:(0,v.jsxs)(`div`,{className:`admin-user-actions`,children:[(0,v.jsxs)(`div`,{className:`admin-user-action-items`,id:`user-actions-${t.id}`,hidden:!i,children:[(0,v.jsxs)(`button`,{type:`button`,className:`icon-button`,disabled:r,title:o(a?`common.done`:`users.resetPassword`),"aria-label":o(`users.resetPassword`),onClick:()=>{k.clear(),R(t),B(``),N(``)},children:[a?(0,v.jsx)(oe,{className:`admin-user-action-confirmation`,"aria-hidden":!0,size:15}):(0,v.jsx)(g,{"aria-hidden":!0,size:15}),(0,v.jsx)(`span`,{className:`sr-only`,role:`status`,children:a?o(`common.done`):``})]}),!n&&(0,v.jsx)(`button`,{type:`button`,className:`icon-button danger-text`,disabled:r,title:o(`users.deleteTitle`),"aria-label":o(`users.deleteTitle`),onClick:()=>{U(t),G(!1),q(``)},children:(0,v.jsx)(te,{size:15,"aria-hidden":!0})})]}),(0,v.jsx)(`button`,{type:`button`,className:`icon-button admin-user-action-toggle`,disabled:r,"aria-label":o(`users.actionsFor`,{username:t.username}),"aria-expanded":i,"aria-controls":`user-actions-${t.id}`,onClick:()=>V(i?null:t.id),children:(0,v.jsx)(re,{size:17,"aria-hidden":!0})})]})})]},t.id)})})]})}),T.totalPages>1&&(0,v.jsxs)(`nav`,{className:`project-pagination admin-user-pagination`,"aria-label":o(`users.pagination`),children:[(0,v.jsxs)(`button`,{type:`button`,disabled:E||D||T.page<=1,onClick:()=>w(T.page-1),children:[(0,v.jsx)(i,{size:15}),o(`users.previousPage`)]}),(0,v.jsx)(`span`,{children:o(`users.pageOf`,{page:T.page,totalPages:T.totalPages})}),(0,v.jsxs)(`button`,{type:`button`,disabled:E||D||T.page>=T.totalPages,onClick:()=>w(T.page+1),children:[o(`users.nextPage`),(0,v.jsx)(ne,{size:15})]})]})]})]}),(0,v.jsxs)(p,{className:`management-dialog`,open:ve,title:o(`users.add`),onOpenChange:e=>{A||P(e)},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{className:`icon-button`,disabled:A,onClick:()=>P(!1),children:[(0,v.jsx)(s,{"aria-hidden":!0,size:14}),o(`common.cancel`)]}),(0,v.jsxs)(`button`,{className:`primary icon-button`,disabled:A||!F.username.trim()||F.password.length<t,onClick:()=>void we(),children:[(0,v.jsx)(u,{"aria-hidden":!0,size:14}),o(`users.createUser`)]})]}),children:[M&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:M}),(0,v.jsxs)(`fieldset`,{className:`admin-user-form form-stack`,disabled:A,children:[(0,v.jsxs)(`label`,{className:`form-field`,children:[o(`auth.username`),(0,v.jsx)(`input`,{value:F.username,onChange:e=>I({...F,username:e.target.value})})]}),(0,v.jsxs)(`label`,{className:`form-field`,children:[o(`users.displayName`),(0,v.jsx)(`input`,{value:F.displayName,onChange:e=>I({...F,displayName:e.target.value})})]}),(0,v.jsxs)(`div`,{className:`form-field`,children:[(0,v.jsxs)(`div`,{className:`user-password-heading`,children:[(0,v.jsx)(`label`,{htmlFor:`new-user-password`,children:o(`users.initialPassword`)}),(0,v.jsx)(ae,{content:o(`users.addDescription`)})]}),(0,v.jsxs)(`span`,{className:`password-generator`,children:[(0,v.jsx)(`input`,{id:`new-user-password`,minLength:t,autoComplete:`new-password`,value:F.password,onChange:e=>I({...F,password:e.target.value})}),(0,v.jsxs)(`button`,{type:`button`,title:o(`users.generatePassword`),onClick:()=>I({...F,password:y()}),children:[(0,v.jsx)(ue,{size:15}),o(`users.randomPassword`)]})]}),(0,v.jsx)(`small`,{className:`field-hint`,children:o(`auth.passwordMinimum`,{count:t})})]}),(0,v.jsxs)(`label`,{className:`form-field`,children:[o(`users.role`),(0,v.jsxs)(`select`,{value:F.role,onChange:e=>I({...F,role:e.target.value}),children:[(0,v.jsx)(`option`,{value:`user`,children:o(`common.user`)}),(0,v.jsx)(`option`,{value:`admin`,children:o(`common.admin`)})]})]}),(0,v.jsxs)(`label`,{className:`checkbox-field`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:F.canCreateProjects||F.role===`admin`,disabled:F.role===`admin`,onChange:e=>I({...F,canCreateProjects:e.target.checked})}),` `,o(`users.allowCreate`)]})]})]}),(0,v.jsxs)(p,{className:`management-dialog`,open:!!L,title:o(`users.resetPassword`),description:o(`users.resetDescription`,{username:L?.username??``}),onOpenChange:e=>{!e&&!A&&R(null)},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{className:`icon-button`,disabled:A,onClick:()=>R(null),children:[(0,v.jsx)(s,{"aria-hidden":!0,size:14}),o(`common.cancel`)]}),(0,v.jsxs)(`button`,{className:`primary icon-button`,disabled:A||z.length<t,onClick:()=>void Oe(),children:[(0,v.jsx)(g,{"aria-hidden":!0,size:14}),o(`users.reset`)]})]}),children:[M&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:M}),(0,v.jsxs)(`label`,{className:`form-field`,children:[o(`auth.newPassword`),(0,v.jsxs)(`span`,{className:`password-generator`,children:[(0,v.jsx)(`input`,{disabled:A,autoFocus:!0,minLength:t,autoComplete:`new-password`,value:z,onChange:e=>B(e.target.value)}),(0,v.jsxs)(`button`,{type:`button`,disabled:A,onClick:()=>B(y()),children:[(0,v.jsx)(ue,{size:15}),o(`users.randomPassword`)]})]}),(0,v.jsx)(`small`,{className:`field-hint`,children:o(`auth.passwordMinimum`,{count:t})})]})]}),(0,v.jsx)(p,{className:`management-dialog`,open:!!H,title:o(`users.deleteTitle`),description:o(`users.deleteDescription`,{username:H?.username??``}),onOpenChange:e=>{!e&&!K&&(U(null),q(``))},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{className:`icon-button`,disabled:K,onClick:()=>{U(null),q(``)},children:[(0,v.jsx)(s,{"aria-hidden":!0,size:14}),o(`common.cancel`)]}),(0,v.jsxs)(`button`,{className:`danger icon-button`,disabled:K,"aria-busy":K,onClick:()=>void ke(),children:[K?(0,v.jsx)(c,{className:`spin`,"aria-hidden":!0,size:14}):(0,v.jsx)(te,{"aria-hidden":!0,size:14}),o(K?`common.loading`:`users.deleteTitle`)]})]}),children:(0,v.jsxs)(v.Fragment,{children:[xe&&(0,v.jsx)(`p`,{className:`error dialog-error`,children:xe}),(0,v.jsxs)(`fieldset`,{className:`choice-group`,disabled:K,children:[(0,v.jsx)(`legend`,{children:o(`users.ownedChoice`,{count:H?.ownedProjects??0})}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`input`,{type:`radio`,checked:!W,onChange:()=>G(!1)}),` `,o(`users.transferProjects`)]}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`input`,{type:`radio`,checked:W,onChange:()=>G(!0)}),` `,o(`users.deleteProjects`)]})]})]})}),(0,v.jsx)(ce,{open:!!J,title:o(`userConfirmations.${J?.setting??`demote`}Title`),description:o(`userConfirmations.${J?.setting??`demote`}Description`,{username:J?.target.username??``}),confirmLabel:o(`userConfirmations.${J?.setting??`demote`}Confirm`),danger:J?.setting!==`promote`&&J?.setting!==`allowProjectCreation`,busy:X,error:Ce,onCancel:()=>{X||(Y(null),Z(``))},onConfirm:()=>void De()})]})}export{b as AdminUsers};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{S as r,r as i,u as a,v as ee}from"./relativeTime-zIVNCN0k.js";import{t as o}from"./useTranslation-DwkoADSz.js";import{t as te}from"./arrow-down-C_4f1E-E.js";import{D as s,E as c,G as ne,T as re,c as l,u as ie}from"./useDeletionTransitions-Bm4I5qej.js";import{t as ae}from"./circle-check-CunlnBPw.js";import{i as u,n as d,t as f}from"./AgentIcon-CjaO3WzI.js";import{t as p}from"./loader-circle-DKGyi5EK.js";import{t as m}from"./refresh-cw-IqExWG6S.js";import{t as oe}from"./SaveButton-wiTpGLho.js";import{A as h,T as g,_ as se}from"./index-dScQ5LCu.js";import{t as ce}from"./SuccessNotice-ubBtzzi_.js";var _=e(t(),1),v=n();function y({user:e,onBack:t}){let{t:n,i18n:y}=o(),{showExecutionReminder:le}=a(),b=e.role===`admin`,x=b?`/api/admin/agent-tasks`:`/api/agent-tasks`,[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)({allowed:[]}),[E,ue]=(0,_.useState)({tasks:[],page:1,pageSize:50,total:0}),[D,O]=(0,_.useState)(1),[k,de]=(0,_.useState)(``),[A,fe]=(0,_.useState)(``),[j,pe]=(0,_.useState)(``),[M,me]=(0,_.useState)(``),[he,N]=(0,_.useState)(0),[P,F]=(0,_.useState)(!0),[I,L]=(0,_.useState)(!1),R=(0,_.useRef)(!1),z=(0,_.useRef)(!0),[B,V]=(0,_.useState)(``),H=ce(),[U,W]=(0,_.useState)(new Set),[G,K]=(0,_.useState)([]),[q,J]=(0,_.useState)({});(0,_.useEffect)(()=>(z.current=!0,()=>{z.current=!1}),[]),(0,_.useEffect)(()=>{let e=new AbortController;return h(b?`/api/admin/agents`:`/api/agents`,{signal:e.signal}).then(e=>{C(e),T(e.policy)}).catch(t=>{e.signal.aborted||V(g(t))}),()=>e.abort()},[b]),(0,_.useEffect)(()=>{let e,t=!1,n=()=>{if(document.visibilityState===`hidden`)return;e?.abort(),e=new AbortController;let n=e,r=new URLSearchParams({page:String(D)});k&&r.set(`state`,k),A&&r.set(`agent`,A),j.trim()&&r.set(`project`,j.trim()),M.trim()&&r.set(`user`,M.trim()),h(`${x}?${r}`,{signal:n.signal}).then(e=>{!t&&!n.signal.aborted&&(ue(e),F(!1))}).catch(e=>{!t&&!n.signal.aborted&&(V(g(e)),F(!1))})},r=window.setTimeout(n,150),i=window.setInterval(n,5e3);return window.addEventListener(`focus`,n),()=>{t=!0,e?.abort(),window.clearTimeout(r),window.clearInterval(i),window.removeEventListener(`focus`,n)}},[x,D,k,A,j,M,he]);let Y=async e=>{if(!R.current){R.current=!0,L(!0),V(``),H.clear();try{await e()}catch(e){z.current&&V(g(e))}finally{R.current=!1,i(),z.current&&(L(!1),N(e=>e+1))}}},X=async(e,t)=>{let r=await Promise.allSettled(e.map(e=>h(`${x}/${e.id}${t===`stop`?`/stop`:``}`,{method:t===`stop`?`POST`:`DELETE`}))),i={},a=[];r.forEach((t,n)=>{t.status===`rejected`&&(i[e[n].id]=g(t.reason),a.push(e[n]))}),J(i),W(new Set(a.map(e=>e.id))),t===`delete`&&K(a),a.length?V(n(`agents.operationFailed`)):t===`stop`&&e.length===1&&H.show(`stop:${e[0].id}`)},Z=e=>{V(``),J({}),K(e)},Q=(e,t)=>{e(t),O(1),W(new Set)},$=E.tasks.filter(e=>U.has(e.id));return(0,v.jsxs)(`section`,{className:`agent-management management-page`,children:[(0,v.jsxs)(`div`,{className:`section-title`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`h1`,{children:[(0,v.jsx)(s,{size:25}),n(b?`agents.title`:`agents.tasks`)]}),(0,v.jsx)(`p`,{children:n(b?`agents.description`:`agents.personalDescription`)})]}),(0,v.jsxs)(`button`,{type:`button`,className:`dashboard-back-button`,onClick:t,children:[(0,v.jsx)(r,{size:14}),n(`navigation.backToProjects`)]})]}),B&&!G.length&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:B}),b&&(0,v.jsxs)(`section`,{className:`agent-policy-card`,children:[(0,v.jsxs)(`div`,{className:`agent-policy-heading`,children:[(0,v.jsxs)(`div`,{className:`agent-policy-title`,children:[(0,v.jsx)(`strong`,{children:n(`agents.allowedAgents`)}),(0,v.jsx)(ie,{className:`agent-policy-help`,content:n(`agents.usageHint`),size:15})]}),(0,v.jsxs)(`div`,{className:`agent-policy-actions`,children:[(0,v.jsxs)(`button`,{disabled:I,onClick:()=>void Y(async()=>{let e=await h(`/api/admin/agents/refresh`,{method:`POST`});C(e),H.show(`detect`)}),children:[(0,v.jsx)(m,{size:14}),(0,v.jsx)(`span`,{role:`status`,children:n(H.message===`detect`?`common.done`:`agents.detection`)})]}),(0,v.jsx)(oe,{saving:I,feedback:H.message===`policy`?n(`editor.saved`):``,disabled:!S,onClick:()=>void Y(async()=>{let e=await h(`/api/admin/agents`,{method:`PATCH`,body:JSON.stringify(w)});C(e),T(e.policy),H.show(`policy`),window.dispatchEvent(new Event(`texlite:agents-policy`))}),children:n(`common.save`)})]})]}),(0,v.jsx)(`div`,{className:`agent-catalog`,children:S?.agents.map(e=>(0,v.jsxs)(`label`,{className:`agent-catalog-item${e.installed?``:` unavailable`}`,children:[(0,v.jsx)(`input`,{type:`checkbox`,"aria-label":`${n(`agents.allowed`)} ${e.label}`,disabled:I,checked:w.allowed.includes(e.id),onChange:t=>T(n=>({...n,allowed:t.target.checked?[...n.allowed,e.id]:n.allowed.filter(t=>t!==e.id)}))}),(0,v.jsxs)(`div`,{className:`agent-catalog-details`,children:[(0,v.jsxs)(`strong`,{children:[(0,v.jsx)(f,{agent:e.id}),e.label]}),(0,v.jsx)(`small`,{children:e.installed?`${n(`agents.installed`)} · ${e.version??n(`agents.unknown`)}`:n(`agents.notInstalled`)})]})]},e.id))}),S&&!S.ptyAvailable&&(0,v.jsx)(`p`,{className:`error`,children:n(`agents.ptyUnavailable`)})]}),le&&(0,v.jsxs)(`p`,{className:`agent-list-reminder`,children:[(0,v.jsx)(re,{size:14,"aria-hidden":`true`}),(0,v.jsx)(`span`,{children:n(`agents.endReminder`)})]}),(0,v.jsxs)(`div`,{className:`agent-list-controls`,children:[(0,v.jsxs)(`select`,{"aria-label":n(`agents.state`),value:k,onChange:e=>Q(de,e.target.value),children:[(0,v.jsx)(`option`,{value:``,children:n(`agents.all`)}),(0,v.jsx)(`option`,{value:`running`,children:n(`agents.running`)}),(0,v.jsx)(`option`,{value:`cleanup`,children:n(`agents.cleanup`)})]}),(0,v.jsxs)(`select`,{"aria-label":n(`agents.agent`),value:A,onChange:e=>Q(fe,e.target.value),children:[(0,v.jsx)(`option`,{value:``,children:n(`agents.agent`)}),Object.entries(d).map(([e,t])=>(0,v.jsx)(`option`,{value:e,children:t},e))]}),(0,v.jsx)(`input`,{"aria-label":n(`agents.projectFilter`),placeholder:n(`agents.projectFilter`),value:j,onChange:e=>Q(pe,e.target.value)}),b&&(0,v.jsx)(`input`,{"aria-label":n(`agents.userFilter`),placeholder:n(`agents.userFilter`),value:M,onChange:e=>Q(me,e.target.value)}),(0,v.jsx)(`span`,{className:`agent-toolbar-spacer`}),(0,v.jsx)(`small`,{children:n(`agents.taskCount`,{count:E.total})}),(0,v.jsx)(`button`,{"aria-label":n(`agents.refresh`),disabled:I,onClick:()=>N(e=>e+1),children:(0,v.jsx)(m,{size:14})})]}),$.length>0&&(0,v.jsxs)(`div`,{className:`agent-bulk-actions`,children:[(0,v.jsx)(`span`,{children:n(`agents.selected`,{count:$.length})}),(0,v.jsxs)(`button`,{disabled:I,onClick:()=>void Y(()=>X($,`stop`)),children:[(0,v.jsx)(u,{size:13}),n(`agents.batchEnd`)]}),(0,v.jsxs)(`button`,{className:`agent-danger`,disabled:I,onClick:()=>Z($),children:[(0,v.jsx)(c,{size:13}),n(`agents.batchDelete`)]})]}),(0,v.jsxs)(`div`,{className:`agent-table-scroll table-card`,children:[(0,v.jsxs)(`table`,{className:`agent-task-table`,role:`table`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{"data-label":n(`agents.all`),children:(0,v.jsx)(`input`,{type:`checkbox`,"aria-label":n(`agents.all`),checked:E.tasks.length>0&&E.tasks.every(e=>U.has(e.id)),onChange:e=>W(new Set(e.target.checked?E.tasks.map(e=>e.id):[]))})}),(0,v.jsx)(`th`,{children:n(`agents.task`)}),(0,v.jsx)(`th`,{children:n(`agents.project`)}),b&&(0,v.jsx)(`th`,{children:n(`agents.user`)}),(0,v.jsx)(`th`,{children:n(`agents.agent`)}),(0,v.jsx)(`th`,{children:n(`agents.state`)}),(0,v.jsx)(`th`,{scope:`col`,"aria-sort":`descending`,children:(0,v.jsxs)(`span`,{className:`agent-time-heading`,children:[n(`agents.updated`),(0,v.jsx)(te,{size:12,"aria-hidden":`true`})]})}),(0,v.jsx)(`th`,{children:n(`agents.actions`)})]})}),(0,v.jsx)(`tbody`,{children:E.tasks.map(e=>(0,v.jsxs)(`tr`,{className:U.has(e.id)?`selected`:``,children:[(0,v.jsx)(`td`,{className:`agent-task-selection`,children:(0,v.jsx)(`input`,{type:`checkbox`,"aria-label":e.title,checked:U.has(e.id),onChange:t=>W(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})})}),(0,v.jsx)(`td`,{className:`agent-table-task`,children:(0,v.jsx)(`strong`,{className:`agent-task-name`,title:e.title,children:e.title})}),(0,v.jsx)(`td`,{"data-label":n(`agents.project`),children:(0,v.jsx)(`span`,{className:`agent-task-name agent-project-name`,title:e.projectId,children:e.projectName})}),b&&(0,v.jsx)(`td`,{"data-label":n(`agents.user`),children:(0,v.jsx)(`span`,{className:`agent-table-user`,tabIndex:e.userUsername?0:void 0,"data-tooltip":e.userUsername?`@${e.userUsername}`:void 0,children:e.userName})}),(0,v.jsx)(`td`,{"data-label":n(`agents.agent`),children:(0,v.jsxs)(`span`,{className:`agent-identity`,children:[(0,v.jsx)(f,{agent:e.agentId,size:15}),d[e.agentId]]})}),(0,v.jsxs)(`td`,{"data-label":n(`agents.state`),children:[(0,v.jsx)(`span`,{className:`agent-state-badge ${e.state}`,children:n(`agents.state_${e.state}`)}),e.cleanupState!==`none`&&(0,v.jsx)(`small`,{className:`error`,children:n(`agents.cleanup`)}),e.errorCode&&!q[e.id]&&(0,v.jsx)(`small`,{className:`error`,children:n(`errors.codes.${e.errorCode}`,{defaultValue:n(`agents.taskUnavailable`)})}),q[e.id]&&!G.length&&(0,v.jsx)(`small`,{className:`error`,children:q[e.id]})]}),(0,v.jsx)(`td`,{className:`agent-table-time`,"data-label":n(`agents.updated`),children:(0,v.jsx)(`time`,{dateTime:e.updatedAt,tabIndex:0,"data-tooltip":n(`agents.createdTooltip`,{created:l(e.createdAt,y.resolvedLanguage)}),children:l(e.updatedAt,y.resolvedLanguage,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})})}),(0,v.jsxs)(`td`,{className:`agent-row-actions`,children:[(0,v.jsxs)(`button`,{type:`button`,className:`agent-icon-button`,title:n(`agents.end`),"aria-label":n(`agents.end`),disabled:I||![`running`,`starting`,`stopping`].includes(e.state),onClick:()=>void Y(()=>X([e],`stop`)),children:[H.message===`stop:${e.id}`?(0,v.jsx)(ae,{className:`agent-action-confirmation`,size:14,"aria-hidden":`true`}):(0,v.jsx)(u,{size:14,"aria-hidden":`true`}),(0,v.jsx)(`span`,{className:`sr-only`,role:`status`,children:n(H.message===`stop:${e.id}`?`common.done`:`agents.end`)})]}),(0,v.jsx)(`button`,{className:`agent-icon-button agent-danger`,title:n(`agents.delete`),"aria-label":n(`agents.delete`),disabled:I,onClick:()=>Z([e]),children:(0,v.jsx)(c,{size:14})})]})]},e.id))})]}),!E.tasks.length&&(0,v.jsxs)(`div`,{className:`agent-task-empty`,children:[P?(0,v.jsx)(p,{size:24,className:`spin`}):(0,v.jsx)(s,{size:28}),(0,v.jsx)(`strong`,{children:n(P?`common.loading`:`agents.noTasks`)}),!P&&(0,v.jsx)(`p`,{children:n(`agents.noTasksHint`)})]})]}),(0,v.jsxs)(`nav`,{className:`project-pagination agent-pagination`,"aria-label":n(`agents.tasks`),children:[(0,v.jsxs)(`button`,{type:`button`,disabled:I||E.page<=1,onClick:()=>{O(E.page-1),W(new Set)},children:[(0,v.jsx)(ee,{size:14,"aria-hidden":`true`}),n(`agents.previous`)]}),(0,v.jsx)(`span`,{children:n(`common.pageOf`,{page:E.page,totalPages:Math.max(1,Math.ceil(E.total/E.pageSize))})}),(0,v.jsxs)(`button`,{type:`button`,disabled:I||E.page*E.pageSize>=E.total,onClick:()=>{O(E.page+1),W(new Set)},children:[n(`agents.next`),(0,v.jsx)(ne,{size:14,"aria-hidden":`true`})]})]}),(0,v.jsxs)(se,{className:`management-dialog`,open:G.length>0,title:n(`agents.delete`),description:n(`agents.bulkDeleteDescription`),onOpenChange:e=>{!e&&!I&&K([])},footer:(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`button`,{disabled:I,onClick:()=>K([]),children:n(`common.cancel`)}),(0,v.jsxs)(`button`,{className:`danger`,disabled:I,onClick:()=>void Y(()=>X(G,`delete`)),children:[I&&(0,v.jsx)(p,{size:14,className:`spin`}),n(`agents.delete`)]})]}),children:[G.length>1&&(0,v.jsx)(`p`,{children:n(`agents.selected`,{count:G.length})}),G.filter(e=>G.length===1||q[e.id]).map(e=>(0,v.jsxs)(`div`,{className:`agent-delete-item`,children:[(0,v.jsx)(`strong`,{children:e.title}),(0,v.jsxs)(`small`,{children:[e.projectName,` · `,e.userName,` · `,d[e.agentId]]}),q[e.id]&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:q[e.id]})]},e.id))]})]})}export{y as AgentManagement};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./AgentTerminalSurface-BLroKMGe.js","./rolldown-runtime-XKyaHtl9.js","./react-DUEFWlB7.js","./relativeTime-zIVNCN0k.js","./i18nInstance-CIMFwH0l.js","./useTranslation-DwkoADSz.js","./basePath-B5-c90eh.js","./createLucideIcon-CDYIzuiB.js","./useDeletionTransitions-Bm4I5qej.js","./dist-B_WjsTVV.js","./es2015-D2UDOM09.js","./index-dScQ5LCu.js","./i18n-B8sR-BXw.js","./vite-runtime-CRzLMJPS.js","./loader-circle-DKGyi5EK.js","./index-D6faTuJe.css","./AgentIcon-CjaO3WzI.js","./AgentIcon-_B7xXJpJ.css","./latexScanner-D9bMX44Y.js","./AgentTerminalSurface-B5LH8GIb.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{d as r,h as i,r as a,u as o,v as s}from"./relativeTime-zIVNCN0k.js";import{t as c}from"./useTranslation-DwkoADSz.js";import{t as l}from"./vite-runtime-CRzLMJPS.js";import{t as u}from"./createLucideIcon-CDYIzuiB.js";import{T as d}from"./sourceCursorStore-DWCXVKvp.js";import{t as f}from"./check-Dw16EqG-.js";import{o as p}from"./dist-B_WjsTVV.js";import{D as m,E as h,G as g,I as _,T as v,c as y,u as b,x}from"./useDeletionTransitions-Bm4I5qej.js";import{t as S}from"./chevron-up-BHaMUEEA.js";import{i as C,n as ee,t as w}from"./AgentIcon-CjaO3WzI.js";import{t as T}from"./git-compare-arrows-158rS_vn.js";import{t as E}from"./loader-circle-DKGyi5EK.js";import{t as te}from"./plus-Cei21TlT.js";import{t as D}from"./refresh-cw-IqExWG6S.js";import{t as ne}from"./SaveButton-wiTpGLho.js";import{A as O,T as k,_ as re}from"./index-dScQ5LCu.js";import{a as A,i as j,l as M,n as N,o as P,s as F,t as I}from"./dist-C9O-A_C4.js";import{n as L}from"./ProjectWorkspace-D0EMITec.js";var R={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};R.node;var z=u(R),B=e(t(),1);function ie(e){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)({tasks:[],page:1,pageSize:50,total:0}),[o,s]=(0,B.useState)(1),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(!1),m=(0,B.useRef)(!1),h=(0,B.useRef)(0),g=(0,B.useRef)(!1),[_,v]=(0,B.useState)(0);(0,B.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,B.useEffect)(()=>{let e=new AbortController;return O(`/api/agents`,{signal:e.signal}).then(n).catch(t=>{e.signal.aborted||d(k(t))}),()=>e.abort()},[e,_]),(0,B.useEffect)(()=>{let t,n=!1,r=()=>{if(document.visibilityState===`hidden`||m.current)return;t?.abort(),t=new AbortController;let r=t,a=h.current,s=new URLSearchParams({project:e,page:String(o)});O(`/api/agent-tasks?${s}`,{signal:r.signal}).then(e=>{n||r.signal.aborted||a!==h.current||(i(e),l(t=>e.tasks.some(e=>e.id===t)?t:e.tasks[0]?.id??``))}).catch(e=>{!n&&!r.signal.aborted&&a===h.current&&d(k(e))})};r();let a=window.setInterval(r,5e3);return window.addEventListener(`focus`,r),()=>{n=!0,t?.abort(),window.clearInterval(a),window.removeEventListener(`focus`,r)}},[e,o,_]);let y=(0,B.useCallback)(()=>v(e=>e+1),[]),b=(0,B.useCallback)(e=>{h.current++,i(t=>({...t,activeTaskId:[`starting`,`running`,`stopping`].includes(e.state)?e.id:t.activeTaskId===e.id?null:t.activeTaskId,tasks:t.tasks.some(t=>t.id===e.id)?t.tasks.map(t=>t.id===e.id?e:t):[e,...t.tasks],total:t.tasks.some(t=>t.id===e.id)?t.total:t.total+1})),m.current||a()},[]);return{catalog:t,result:r,page:o,setPage:s,selectedId:c,setSelectedId:l,selected:r.tasks.find(e=>e.id===c)??null,error:u,setError:d,busy:f,mutate:async e=>{if(!m.current){m.current=!0,h.current++,p(!0),d(``);try{return await e()}catch(e){g.current&&d(k(e))}finally{m.current=!1,a(),g.current&&(p(!1),y())}}},acceptTask:b,refreshTasks:y}}var V=n();function ae({agents:e,value:t,onChange:n,disabled:r=!1}){let{t:i}=c(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),l=e.find(e=>e.id===t),u=r||e.length===0;return(0,B.useEffect)(()=>{u&&o(!1)},[u]),(0,V.jsxs)(I,{modal:!1,open:a,onOpenChange:o,children:[(0,V.jsx)(M,{asChild:!0,children:(0,V.jsxs)(`button`,{ref:s,type:`button`,className:`agent-select-trigger`,disabled:u,"aria-label":l?`${i(`agents.agent`)}: ${l.label}`:i(`agents.agent`),children:[l&&(0,V.jsx)(w,{agent:l.id,size:16}),(0,V.jsx)(`span`,{children:l?.label??i(`agents.agent`)}),(0,V.jsx)(p,{size:13,"aria-hidden":`true`})]})}),(0,V.jsx)(A,{container:s.current?.closest(`[role="dialog"]`),children:(0,V.jsx)(N,{className:`agent-select-options`,side:`top`,align:`start`,sideOffset:5,collisionPadding:8,children:(0,V.jsx)(P,{value:t,"aria-label":i(`agents.agent`),onValueChange:t=>{let r=e.find(e=>e.id===t);!u&&r?.installed&&r.enabled&&n(r.id)},children:e.map(e=>(0,V.jsxs)(F,{value:e.id,textValue:e.label,className:`agent-select-option`,disabled:u||!e.installed||!e.enabled,children:[(0,V.jsx)(w,{agent:e.id,size:16}),(0,V.jsxs)(`span`,{className:`agent-select-label`,children:[e.label,(!e.installed||!e.enabled)&&(0,V.jsx)(`small`,{children:i(e.installed?`agents.disabled`:`agents.notInstalled`)})]}),(0,V.jsx)(j,{className:`agent-select-check`,children:(0,V.jsx)(f,{size:14,"aria-hidden":`true`})})]},e.id))})})})]})}function H({change:e}){let t=e.after??``,n=[],r=0;for(let i of[...e.pieces].sort((e,t)=>e.from-t.from)){let a=Math.max(r,i.from-e.afterFrom),o=Math.min(t.length,i.to-e.afterFrom);o<=a||(a>r&&n.push({text:t.slice(r,a),agent:!1}),n.push({text:t.slice(a,o),agent:!0}),r=o)}return r<t.length&&n.push({text:t.slice(r),agent:!1}),(0,V.jsx)(`pre`,{className:`agent-review-content`,children:n.map((e,t)=>e.agent?(0,V.jsx)(`mark`,{children:e.text},t):(0,V.jsx)(`span`,{children:e.text},t))})}function oe({review:e,activeId:t,onShow:n,focus:r=null}){let{t:i,i18n:a}=c(),[o,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(r?.id??t),[m,h]=(0,B.useState)(`diff`),{pending:v}=e,b=(0,B.useMemo)(()=>{let e=v.findIndex(e=>e.id===u);return e>=0?e:v.length?0:-1},[v,u]),x=b>=0?v[b]:null;(0,B.useEffect)(()=>{r&&(d(r.id),l(!0))},[r?.nonce]),(0,B.useEffect)(()=>{x&&x.id!==u&&d(x.id)},[x,u]);let C=e=>{let t=v[(e+v.length)%v.length];t&&(d(t.id),l(!0),n(t,!1))};return!v.length&&!e.error?null:(0,V.jsxs)(`section`,{className:`agent-review`,"aria-label":i(`agents.reviewTitle`),children:[(0,V.jsxs)(`div`,{className:`agent-review-bar`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`agent-review-toggle`,"aria-expanded":o,onClick:()=>l(e=>!e),children:[(0,V.jsx)(T,{size:13,"aria-hidden":!0}),i(`agents.reviewTitle`),(0,V.jsx)(`span`,{className:`agent-review-count`,children:v.length}),o?(0,V.jsx)(S,{size:13,"aria-hidden":!0}):(0,V.jsx)(p,{size:13,"aria-hidden":!0})]}),v.length>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":i(`agents.previousChange`),title:i(`agents.previousChange`),onClick:()=>C(b-1),children:(0,V.jsx)(s,{size:13})}),(0,V.jsxs)(`small`,{className:`agent-review-position`,children:[b+1,` / `,v.length]}),(0,V.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":i(`agents.nextChange`),title:i(`agents.nextChange`),onClick:()=>C(b+1),children:(0,V.jsx)(g,{size:13})})]}),(0,V.jsx)(`span`,{className:`agent-toolbar-spacer`}),v.length>0&&(0,V.jsxs)(`button`,{type:`button`,onClick:e.markAllReviewed,children:[(0,V.jsx)(z,{size:12,"aria-hidden":!0}),i(`agents.markAllReviewed`)]}),(0,V.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":i(`agents.refreshChanges`),title:i(`agents.refreshChanges`),disabled:e.loading,onClick:e.refresh,children:e.loading?(0,V.jsx)(E,{className:`spin`,size:13}):(0,V.jsx)(D,{size:13})})]}),e.error&&(0,V.jsx)(`p`,{className:`error agent-inline-error`,role:`alert`,children:e.error}),o&&x&&(0,V.jsxs)(`div`,{className:`agent-review-detail`,children:[(0,V.jsxs)(`div`,{className:`agent-review-location`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`agent-review-file`,onClick:()=>n(x,!0),title:i(`agents.openChange`),children:[(0,V.jsx)(_,{size:12,"aria-hidden":!0}),(0,V.jsxs)(`span`,{children:[x.path,`:`,x.line]})]}),(0,V.jsx)(`time`,{dateTime:x.at,children:y(x.at,a.resolvedLanguage,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),(0,V.jsxs)(`div`,{className:`agent-review-tabs`,role:`tablist`,"aria-label":i(`agents.reviewTitle`),children:[(0,V.jsx)(`button`,{type:`button`,role:`tab`,id:`agent-review-tab-content-${x.id}`,"aria-selected":m===`content`,"aria-controls":`agent-review-panel`,className:m===`content`?`active`:``,onClick:()=>h(`content`),children:i(`agents.contentTab`)}),(0,V.jsx)(`button`,{type:`button`,role:`tab`,id:`agent-review-tab-diff-${x.id}`,"aria-selected":m===`diff`,"aria-controls":`agent-review-panel`,className:m===`diff`?`active`:``,onClick:()=>h(`diff`),children:i(`agents.diffTab`)})]}),(0,V.jsx)(`div`,{id:`agent-review-panel`,role:`tabpanel`,"aria-labelledby":`agent-review-tab-${m}-${x.id}`,children:m===`content`?x.after===null?(0,V.jsx)(`p`,{className:`agent-review-unavailable`,children:i(`agents.contentUnavailable`)}):(0,V.jsx)(H,{change:x}):x.before!==null&&x.after!==null?(0,V.jsx)(L,{original:x.before,replacement:x.after}):(0,V.jsx)(`p`,{className:`agent-review-unavailable`,children:i(`agents.changePreviewUnavailable`)})}),(0,V.jsxs)(`div`,{className:`agent-review-actions`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>n(x,!0),children:[(0,V.jsx)(_,{size:12,"aria-hidden":!0}),i(`agents.openChange`)]}),(0,V.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>{if(!x)return;let t=v[b+1]??v[b-1]??null;e.markReviewed(x),d(t?.id??null),t&&n(t,!1)},children:[(0,V.jsx)(f,{size:12,"aria-hidden":!0}),i(`agents.markReviewed`)]})]})]})]})}var se=(0,B.lazy)(()=>l(()=>import(`./AgentTerminalSurface-BLroKMGe.js`).then(e=>({default:e.AgentTerminalSurface})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]),import.meta.url)),ce=15e3;function U({projectId:e,readOnly:t,onHide:n,maximized:l=!1,onToggleMaximized:u,review:f,activeChangeId:_=null,onShowChange:y,reviewFocus:T=null,pasteRequest:D=null,onPasteFinished:k}){let{t:A}=c(),j=ie(e),M=o(),N=j.selected,[P,F]=(0,B.useState)(!1),[I,L]=(0,B.useState)(``),[R,z]=(0,B.useState)(``),[H,U]=(0,B.useState)(!1),[W,G]=(0,B.useState)(``),[K,q]=(0,B.useState)(!1),J=N&&[`starting`,`running`,`stopping`].includes(N.state),le=N&&(N.canResume||N.startedAt!==null||[`stopped`,`exited`,`interrupted`].includes(N.state)),Y=j.catalog?.agents.find(e=>e.id===N?.agentId),X=j.catalog?.agents.filter(e=>e.installed&&e.enabled)??[],Z=R?j.catalog?.agents.find(e=>e.id===R):X[0],ue=!!(j.result.activeTaskId&&j.result.activeTaskId!==N?.id),de=t||j.busy||!!j.result.activeTaskId||!j.catalog?.ptyAvailable||!Z?.installed||!Z.enabled,fe=!ue&&!t&&Y?.installed&&Y.enabled&&j.catalog?.ptyAvailable&&N?.cleanupState===`none`,Q=j.result.activeTaskId,pe=(0,B.useRef)(``),me=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(D&&Q!==void 0){if(Q&&j.result.tasks.some(e=>e.id===Q)){let e=`${D.id}:${Q}`;pe.current!==e&&(pe.current=e,j.setSelectedId(Q))}else Q&&j.result.page!==1?j.setPage(1):me.current===D.id?(j.setError(A(`agents.commentAgentUnavailable`)),a(),k?.(D.id)):(me.current=D.id,j.refreshTasks())}},[D,Q,j.result]);let $=D?.id;(0,B.useEffect)(()=>{if($===void 0)return;let e=window.setTimeout(()=>{j.setError(A(`agents.commentAgentTimedOut`)),k?.($)},ce);return()=>window.clearTimeout(e)},[$]);let he=e=>{j.setSelectedId(e),U(!1)},ge=e=>j.mutate(async()=>{if(!N)return;let t=await O(`/api/agent-tasks/${N.id}${e}`,{method:`POST`});j.acceptTask(t.task)});return(0,V.jsxs)(`section`,{className:`agent-terminal-panel`,"data-agent-terminal":`true`,"aria-label":A(`agents.terminal`),children:[(0,V.jsxs)(`div`,{className:`agent-terminal-heading`,children:[(0,V.jsxs)(`strong`,{children:[(0,V.jsx)(m,{size:14}),A(`agents.terminal`)]}),(0,V.jsx)(b,{className:`agent-session-help`,content:A(`agents.sessionManagementHint`),size:13}),(0,V.jsx)(`div`,{className:`agent-task-tabs`,role:`tablist`,"aria-label":A(`agents.tasks`),children:j.result.tasks.map(e=>(0,V.jsxs)(`button`,{role:`tab`,type:`button`,"aria-selected":e.id===N?.id,title:e.title,className:e.id===N?.id?`active`:``,onClick:()=>he(e.id),children:[(0,V.jsx)(`span`,{className:`agent-state-dot ${e.state}`}),(0,V.jsx)(w,{agent:e.agentId,size:13}),(0,V.jsx)(`span`,{children:e.title}),(0,V.jsx)(`small`,{children:ee[e.agentId]})]},e.id))}),(0,V.jsx)(`button`,{className:`agent-icon-button`,disabled:t||j.busy||!X.length,title:A(`agents.newTask`),"aria-label":A(`agents.newTask`),onClick:()=>F(e=>!e),children:(0,V.jsx)(te,{size:15})}),u&&(0,V.jsx)(`button`,{type:`button`,className:`agent-icon-button`,title:A(l?`agents.restoreTerminal`:`agents.maximizeTerminal`),"aria-label":A(l?`agents.restoreTerminal`:`agents.maximizeTerminal`),"aria-pressed":l,onClick:u,children:l?(0,V.jsx)(p,{size:15}):(0,V.jsx)(S,{size:15})}),(0,V.jsx)(`button`,{className:`agent-icon-button`,title:A(`agents.hide`),"aria-label":A(`agents.hide`),onClick:n,children:(0,V.jsx)(x,{size:15})})]}),(N||j.result.total>j.result.pageSize)&&(0,V.jsxs)(`div`,{className:`agent-task-toolbar`,children:[j.result.total>j.result.pageSize&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{disabled:j.result.page<=1,"aria-label":A(`agents.previous`),onClick:()=>j.setPage(j.result.page-1),children:(0,V.jsx)(s,{size:13})}),(0,V.jsxs)(`small`,{children:[j.result.page,` / `,Math.ceil(j.result.total/j.result.pageSize)]}),(0,V.jsx)(`button`,{disabled:j.result.page*j.result.pageSize>=j.result.total,"aria-label":A(`agents.next`),onClick:()=>j.setPage(j.result.page+1),children:(0,V.jsx)(g,{size:13})})]}),N&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`agent-task-state`,children:A(`agents.state_${N.state}`)}),(0,V.jsx)(`span`,{className:`agent-toolbar-spacer`}),J?(0,V.jsxs)(`button`,{disabled:j.busy,onClick:()=>void ge(`/stop`),children:[(0,V.jsx)(C,{size:12}),A(`agents.end`)]}):(0,V.jsxs)(`button`,{disabled:!fe||j.busy,onClick:()=>void ge(`/start`),children:[(0,V.jsx)(d,{size:13}),A(le?`agents.resume`:`agents.start`)]}),(0,V.jsx)(`button`,{className:`agent-icon-button`,title:A(`agents.rename`),"aria-label":A(`agents.rename`),disabled:j.busy,onClick:()=>{G(N.title),U(e=>!e)},children:(0,V.jsx)(i,{size:13})}),(0,V.jsx)(`button`,{className:`agent-icon-button agent-danger`,title:A(`agents.delete`),"aria-label":A(`agents.delete`),disabled:j.busy,onClick:()=>{j.setError(``),q(!0)},children:(0,V.jsx)(h,{size:13})})]})]}),(P||!N)&&(0,V.jsxs)(`form`,{className:`agent-task-create`,onSubmit:t=>{t.preventDefault(),!de&&j.mutate(async()=>{let t=Z?.id,n=await O(`/api/projects/${e}/agent-tasks`,{method:`POST`,body:JSON.stringify({agentId:t,title:I})});j.acceptTask(n.task),j.setPage(1),j.setSelectedId(n.task.id),F(!1),L(``);let r=await O(`/api/agent-tasks/${n.task.id}/start`,{method:`POST`});j.acceptTask(r.task)})},children:[(0,V.jsx)(`input`,{"aria-label":A(`agents.task`),placeholder:A(`agents.titlePlaceholder`),maxLength:160,value:I,onChange:e=>L(e.target.value),disabled:j.busy||t}),(0,V.jsx)(ae,{agents:j.catalog?.agents??[],value:Z?.id??``,onChange:z,disabled:t||j.busy}),(0,V.jsxs)(`button`,{type:`submit`,disabled:de,children:[j.busy&&(0,V.jsx)(E,{className:`spin`,size:13}),A(`agents.create`)]})]}),H&&N&&(0,V.jsxs)(`form`,{className:`agent-task-create`,onSubmit:e=>{e.preventDefault(),j.mutate(async()=>{let e=await O(`/api/agent-tasks/${N.id}`,{method:`PATCH`,body:JSON.stringify({title:W})});j.acceptTask(e.task),U(!1)})},children:[(0,V.jsx)(`input`,{value:W,onChange:e=>G(e.target.value),required:!0,maxLength:160,"aria-label":A(`agents.task`)}),(0,V.jsx)(ne,{type:`submit`,saving:j.busy,children:A(`common.save`)})]}),j.error&&!K&&(0,V.jsxs)(`p`,{className:`error agent-inline-error`,role:`alert`,children:[j.error,(0,V.jsx)(`button`,{onClick:()=>j.setError(``),"aria-label":A(`common.close`),children:(0,V.jsx)(x,{size:13})})]}),N?.errorCode&&!j.error&&!K&&(0,V.jsx)(`p`,{className:`error agent-inline-error`,role:`alert`,children:A(`errors.codes.${N.errorCode}`,{defaultValue:A(`agents.taskUnavailable`)})}),(ue||P&&j.result.activeTaskId)&&(0,V.jsxs)(`p`,{className:`agent-inline-warning`,role:`status`,children:[(0,V.jsx)(v,{size:14,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:A(`errors.codes.AGENT_PROJECT_BUSY`)})]}),j.catalog&&!j.catalog.ptyAvailable&&(0,V.jsx)(`p`,{className:`error agent-inline-error`,children:A(`agents.ptyUnavailable`)}),f&&y&&(0,V.jsx)(oe,{review:f,activeId:_,onShow:y,focus:T}),(0,V.jsx)(`div`,{className:`agent-terminal-body`,style:r(M.theme),children:(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(`div`,{className:`agent-task-empty`,children:(0,V.jsx)(E,{className:`spin`,size:18})}),children:N&&J&&!t?(0,V.jsx)(se,{task:N,onTask:j.acceptTask,pasteRequest:N.id===Q?D:null,onPasteFinished:k},N.id):(0,V.jsxs)(`div`,{className:`agent-task-empty`,children:[(0,V.jsx)(m,{size:24}),(0,V.jsx)(`strong`,{children:N?.title||A(`agents.noTasks`)}),(0,V.jsx)(`p`,{children:A(t?`agents.permissionLost`:`agents.readyHint`)}),N?.exitCode!==null&&N?.exitCode!==void 0&&N.exitCode!==0&&(0,V.jsx)(`small`,{children:A(`agents.exitCode`,{code:N.exitCode})})]})})}),M.showExecutionReminder&&J&&N.state!==`stopping`&&(0,V.jsxs)(`p`,{className:`agent-execution-reminder`,children:[(0,V.jsx)(v,{size:12,"aria-hidden":`true`}),(0,V.jsx)(`span`,{children:A(`agents.endReminder`)})]}),N&&(0,V.jsx)(re,{open:K,title:A(`agents.delete`),description:A(`agents.deleteDescription`),onOpenChange:e=>{j.busy||q(e)},footer:(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{disabled:j.busy,onClick:()=>q(!1),children:A(`common.cancel`)}),(0,V.jsxs)(`button`,{className:`danger`,disabled:j.busy,onClick:()=>void j.mutate(async()=>{await O(`/api/agent-tasks/${N.id}`,{method:`DELETE`}),q(!1)}),children:[j.busy&&(0,V.jsx)(E,{className:`spin`,size:13}),A(`agents.delete`)]})]}),children:j.error&&(0,V.jsx)(`p`,{className:`error`,role:`alert`,children:j.error})})]})}export{U as AgentTerminal};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{d as r,f as i,l as a,s as o,u as s}from"./relativeTime-CcP1IEvr.js";import{t as c}from"./useTranslation-DwkoADSz.js";import{t as l}from"./basePath-B5-c90eh.js";import{r as u}from"./AgentIcon-CjaO3WzI.js";import{h as d}from"./latexScanner-D9bMX44Y.js";var f=e(t(),1),p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{for(var i=r>1?void 0:r?m(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&p(t,n,i),i},_=(e,t)=>(n,r)=>t(n,r,e),v=`Terminal input`,ee={get:()=>v,set:e=>v=e},te=`Too much output to announce, navigate to rows manually to read`,y={get:()=>te,set:e=>te=e};function ne(e){return e.replace(/\r?\n/g,`\r`)}function re(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ie(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function b(e,t,n,r){e.stopPropagation(),e.clipboardData&&ae(e.clipboardData.getData(`text/plain`),t,n,r)}function ae(e,t,n,r){e=ne(e),e=re(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function x(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function oe(e,t,n,r,i){x(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function se(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var C=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},ce=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},w=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new de}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},de=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new de,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fe=`di$target`,pe=`di$dependencies`,me=new Map;function he(e){return e[pe]||[]}function E(e){if(me.has(e))return me.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ge(t,e,r)};return t._id=e,me.set(e,t),t}function ge(e,t,n){t[fe]===t?t[pe].push({id:e,index:n}):(t[pe]=[{id:e,index:n}],t[fe]=t)}var D=E(`BufferService`),_e=E(`CoreMouseService`),O=E(`CoreService`),ve=E(`CharsetService`),ye=E(`InstantiationService`),be=E(`LogService`),k=E(`OptionsService`),xe=E(`OscLinkService`),Se=E(`UnicodeService`),Ce=E(`DecorationService`),we=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Te(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};we=g([_(0,D),_(1,k),_(2,xe)],we);function Te(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{d as r,f as i,l as a,s as o,u as s}from"./relativeTime-zIVNCN0k.js";import{t as c}from"./useTranslation-DwkoADSz.js";import{t as l}from"./basePath-B5-c90eh.js";import{r as u}from"./AgentIcon-CjaO3WzI.js";import{h as d}from"./latexScanner-D9bMX44Y.js";var f=e(t(),1),p=Object.defineProperty,m=Object.getOwnPropertyDescriptor,h=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},g=(e,t,n,r)=>{for(var i=r>1?void 0:r?m(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&p(t,n,i),i},_=(e,t)=>(n,r)=>t(n,r,e),v=`Terminal input`,ee={get:()=>v,set:e=>v=e},te=`Too much output to announce, navigate to rows manually to read`,y={get:()=>te,set:e=>te=e};function ne(e){return e.replace(/\r?\n/g,`\r`)}function re(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ie(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function b(e,t,n,r){e.stopPropagation(),e.clipboardData&&ae(e.clipboardData.getData(`text/plain`),t,n,r)}function ae(e,t,n,r){e=ne(e),e=re(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function x(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function oe(e,t,n,r,i){x(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function se(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var C=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},ce=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},w=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new de}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},de=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},T=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new de,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fe=`di$target`,pe=`di$dependencies`,me=new Map;function he(e){return e[pe]||[]}function E(e){if(me.has(e))return me.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ge(t,e,r)};return t._id=e,me.set(e,t),t}function ge(e,t,n){t[fe]===t?t[pe].push({id:e,index:n}):(t[pe]=[{id:e,index:n}],t[fe]=t)}var D=E(`BufferService`),_e=E(`CoreMouseService`),O=E(`CoreService`),ve=E(`CharsetService`),ye=E(`InstantiationService`),be=E(`LogService`),k=E(`OptionsService`),xe=E(`OscLinkService`),Se=E(`UnicodeService`),Ce=E(`DecorationService`),we=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new T,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Te(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};we=g([_(0,D),_(1,k),_(2,xe)],we);function Te(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ee=E(`CharSizeService`),De=E(`CoreBrowserService`),Oe=E(`MouseService`),ke=E(`RenderService`),Ae=E(`SelectionService`),je=E(`CharacterJoinerService`),Me=E(`ThemeService`),Ne=E(`LinkProviderService`),Pe=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Be.isErrorNoTelemetry(e)?new Be(e.message+`
4
4