texlite 0.23.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.
- package/DESIGN.md +155 -17
- package/NPM_TESTING.md +46 -2
- package/OPERATIONS.md +136 -6
- package/README.md +1 -2
- package/README.zh-CN.md +2 -2
- package/THIRD_PARTY_NOTICES.md +12 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js +1 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js.br +0 -0
- package/dist/client/assets/AdminUsers-D4ljqr_D.js.gz +0 -0
- package/dist/client/assets/{AgentIcon-DJGGRJnV.css → AgentIcon-_B7xXJpJ.css} +1 -1
- package/dist/client/assets/AgentIcon-_B7xXJpJ.css.br +0 -0
- package/dist/client/assets/AgentIcon-_B7xXJpJ.css.gz +0 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js +1 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js.br +0 -0
- package/dist/client/assets/AgentManagement-DwRMP_nD.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js +2 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js.br +0 -0
- package/dist/client/assets/AgentTerminal-CSsr21PC.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js +16 -0
- package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-BLroKMGe.js.gz +0 -0
- package/dist/client/assets/{AvatarSettingsDialog-ChKrdDqp.js → AvatarSettingsDialog-BgVGfSzn.js} +1 -1
- package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-BgVGfSzn.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-DLPom-qx.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js +3 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-Cn-kFi8E.js.gz +0 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js +5 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js.br +0 -0
- package/dist/client/assets/Dashboard-7JrR0t6C.js.gz +0 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js +1 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js.br +0 -0
- package/dist/client/assets/DrawioEditor-CYQnzKDd.js.gz +0 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js +4 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js.br +0 -0
- package/dist/client/assets/GitDialog-DMCVR8QK.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js +1 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-BbJpR9Vq.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js +8 -0
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js.br +0 -0
- package/dist/client/assets/HistoryDialog-CcPWpTLn.js.gz +0 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js +25 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js.br +0 -0
- package/dist/client/assets/LatexEditor-D7C9jpJO.js.gz +0 -0
- package/dist/client/assets/{MarkdownPreview-BJPqGTcw.js → MarkdownPreview-Txs5upCY.js} +1 -1
- package/dist/client/assets/MarkdownPreview-Txs5upCY.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-Txs5upCY.js.gz +0 -0
- package/dist/client/assets/{ProjectIconPickerDialog-ChiEUQ0g.js → ProjectIconPickerDialog-CUlPlfmL.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CUlPlfmL.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js +1 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-Bt6NyHIJ.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js +4 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js.br +0 -0
- package/dist/client/assets/ProjectSettings-B6e7EAxq.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js +25 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-D0EMITec.js.gz +0 -0
- package/dist/client/assets/{QuickOpenDialog-B7NTqOpu.js → QuickOpenDialog-D6yjnquG.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-D6yjnquG.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-BOAnB5L0.js +2 -0
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js +3 -0
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-D6ql9E0j.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js +2 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-DuscqDx5.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js +1 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-KiKZOF2N.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js +1 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BHbqvu3K.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-5cgNbWiG.js +1 -0
- package/dist/client/assets/{TikzGalleryDialog-CLAmKmS6.js → TikzGalleryDialog-CFbLjNTt.js} +1 -1
- package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-CFbLjNTt.js.gz +0 -0
- package/dist/client/assets/{WordCountDialog-ByxE-RUs.js → WordCountDialog-hXC-cpPs.js} +1 -1
- package/dist/client/assets/WordCountDialog-hXC-cpPs.js.br +0 -0
- package/dist/client/assets/WordCountDialog-hXC-cpPs.js.gz +0 -0
- package/dist/client/assets/{chktex-22lKGvKa.js → chktex-CLzMD_9a.js} +1 -1
- package/dist/client/assets/{citationLibrary-DxGdbZEQ.js → citationLibrary-BJRzAgaV.js} +1 -1
- package/dist/client/assets/citationLibrary-BJRzAgaV.js.br +0 -0
- package/dist/client/assets/citationLibrary-BJRzAgaV.js.gz +0 -0
- package/dist/client/assets/editor-CSq7NymY.js +14 -0
- package/dist/client/assets/editor-CSq7NymY.js.br +0 -0
- package/dist/client/assets/editor-CSq7NymY.js.gz +0 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js +36 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js.br +0 -0
- package/dist/client/assets/editor-languages-CKP1xVf6.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js +1 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-CjBD77yn.js.gz +0 -0
- package/dist/client/assets/file-cog-D_mhAnBe.js +1 -0
- package/dist/client/assets/file-down-DA4jGFrF.js +1 -0
- package/dist/client/assets/{generatedParser-CZa2vsK6.js → generatedParser-2izSCuvk.js} +1 -1
- package/dist/client/assets/generatedParser-2izSCuvk.js.br +0 -0
- package/dist/client/assets/generatedParser-2izSCuvk.js.gz +0 -0
- package/dist/client/assets/i18n-B8sR-BXw.js +13 -0
- package/dist/client/assets/i18n-B8sR-BXw.js.br +0 -0
- package/dist/client/assets/i18n-B8sR-BXw.js.gz +0 -0
- package/dist/client/assets/index-D6faTuJe.css +1 -0
- package/dist/client/assets/index-D6faTuJe.css.br +0 -0
- package/dist/client/assets/index-D6faTuJe.css.gz +0 -0
- package/dist/client/assets/index-dScQ5LCu.js +2 -0
- package/dist/client/assets/index-dScQ5LCu.js.br +0 -0
- package/dist/client/assets/index-dScQ5LCu.js.gz +0 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js +1 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js.br +0 -0
- package/dist/client/assets/relativeTime-zIVNCN0k.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js +2 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-DWCXVKvp.js.gz +0 -0
- package/dist/client/assets/{spellCheck-kxvnxrvw.js → spellCheck-DpyzDbmq.js} +1 -1
- package/dist/client/assets/spellCheck-DpyzDbmq.js.br +0 -0
- package/dist/client/assets/spellCheck-DpyzDbmq.js.gz +0 -0
- package/dist/client/assets/textLanguageSupport-tGXUsMU9.js +1 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js +78 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js.br +0 -0
- package/dist/client/assets/textLanguages-BpqiXyQi.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js +1 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Bm4I5qej.js.gz +0 -0
- package/dist/client/assets/{vimSupport-C-WiMLjc.js → vimSupport-DMVGjr9R.js} +6 -6
- package/dist/client/assets/vimSupport-DMVGjr9R.js.br +0 -0
- package/dist/client/assets/vimSupport-DMVGjr9R.js.gz +0 -0
- package/dist/client/index.html +3 -4
- package/dist/server/agentChanges.js +95 -7
- package/dist/server/agents/adapters/claude.js +5 -2
- package/dist/server/agents/adapters/common.js +18 -5
- package/dist/server/agents/execution.js +25 -4
- package/dist/server/agents/launcher.js +5 -2
- package/dist/server/agents/outputBuffer.js +105 -0
- package/dist/server/agents/processIdentity.js +1 -1
- package/dist/server/agents/sessions.js +33 -16
- package/dist/server/agents/terminal.js +5 -2
- package/dist/server/agents/windowsJob.js +141 -0
- package/dist/server/app.js +24 -6
- package/dist/server/auth.js +3 -2
- package/dist/server/browserOrigin.js +15 -0
- package/dist/server/chktex.js +23 -11
- package/dist/server/collaboration.js +11 -1
- package/dist/server/compileDiagnostics.js +13 -9
- package/dist/server/compiler.js +70 -25
- package/dist/server/config.js +5 -1
- package/dist/server/db.js +68 -0
- package/dist/server/drawioLocks.js +114 -0
- package/dist/server/drawioOwnedBrowser.js +122 -0
- package/dist/server/drawioPdf.js +182 -0
- package/dist/server/editHistory.js +68 -20
- package/dist/server/environment.js +17 -8
- package/dist/server/files.js +86 -20
- package/dist/server/git.js +29 -23
- package/dist/server/harper.js +29 -10
- package/dist/server/history.js +220 -82
- package/dist/server/i18n.js +17 -0
- package/dist/server/index.js +15 -8
- package/dist/server/locales/zh-Hant.js +10 -0
- package/dist/server/pdfFonts.js +78 -0
- package/dist/server/pm2.js +2 -1
- package/dist/server/processTree.js +128 -7
- package/dist/server/projectDeletionCleanup.js +62 -0
- package/dist/server/projectMutations.js +7 -0
- package/dist/server/projectReplace.js +2 -2
- package/dist/server/projectSearch.js +2 -1
- package/dist/server/projectTemplateCache.js +94 -0
- package/dist/server/projectTemplateDownload.js +75 -0
- package/dist/server/projectTextSave.js +56 -0
- package/dist/server/routes/agents.js +2 -15
- package/dist/server/routes/comments.js +7 -2
- package/dist/server/routes/compile.js +67 -9
- package/dist/server/routes/drawio.js +192 -0
- package/dist/server/routes/projectFiles.js +160 -20
- package/dist/server/routes/projectGit.js +1 -1
- package/dist/server/routes/projectHistory.js +19 -5
- package/dist/server/routes/projects.js +81 -20
- package/dist/server/routes/users.js +10 -14
- package/dist/server/synctex.js +20 -3
- package/dist/server/texcount.js +27 -23
- package/dist/server/zip.js +37 -11
- package/dist/shared/agentMessages.js +3 -0
- package/dist/shared/drawio.js +79 -0
- package/dist/shared/fileTypes.js +1 -1
- package/dist/shared/pdfFonts.js +14 -0
- package/dist/shared/projectImport.js +21 -0
- package/package.json +3 -1
- package/dist/client/assets/AdminUsers-xuVuiwoh.js +0 -1
- package/dist/client/assets/AdminUsers-xuVuiwoh.js.br +0 -0
- package/dist/client/assets/AdminUsers-xuVuiwoh.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DJGGRJnV.css.br +0 -0
- package/dist/client/assets/AgentIcon-DJGGRJnV.css.gz +0 -0
- package/dist/client/assets/AgentManagement-D-0hrv6f.js +0 -1
- package/dist/client/assets/AgentManagement-D-0hrv6f.js.br +0 -0
- package/dist/client/assets/AgentManagement-D-0hrv6f.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-DZo-22RN.js +0 -2
- package/dist/client/assets/AgentTerminal-DZo-22RN.js.br +0 -0
- package/dist/client/assets/AgentTerminal-DZo-22RN.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js +0 -16
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-CcC17_CY.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-ChKrdDqp.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-BZIU4Lif.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js +0 -3
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DqO9e0GV.js.gz +0 -0
- package/dist/client/assets/Dashboard-BYgqCgBM.js +0 -5
- package/dist/client/assets/Dashboard-BYgqCgBM.js.br +0 -0
- package/dist/client/assets/Dashboard-BYgqCgBM.js.gz +0 -0
- package/dist/client/assets/GitDialog-CA68baSd.js +0 -4
- package/dist/client/assets/GitDialog-CA68baSd.js.br +0 -0
- package/dist/client/assets/GitDialog-CA68baSd.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js +0 -1
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-CnxfR0JD.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js +0 -8
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js.br +0 -0
- package/dist/client/assets/HistoryDialog-c2EEaFsl.js.gz +0 -0
- package/dist/client/assets/InfoPopover-BJYnFn1P.js +0 -1
- package/dist/client/assets/LatexEditor-vNOVTIl7.js +0 -25
- package/dist/client/assets/LatexEditor-vNOVTIl7.js.br +0 -0
- package/dist/client/assets/LatexEditor-vNOVTIl7.js.gz +0 -0
- package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-BJPqGTcw.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-ChiEUQ0g.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js +0 -1
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-DxgjbnmY.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js +0 -4
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js.br +0 -0
- package/dist/client/assets/ProjectSettings-BwQTbXhh.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js +0 -25
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-C2QAb-Fc.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-B7NTqOpu.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-DIalHHvP.js +0 -2
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js +0 -3
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-BhOyneNx.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js +0 -2
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-s-khOyvB.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js +0 -1
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-Bycm88U1.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js +0 -1
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-DwUAA8uC.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-RSqZi7kx.js +0 -1
- package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-CLAmKmS6.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-ByxE-RUs.js.br +0 -0
- package/dist/client/assets/WordCountDialog-ByxE-RUs.js.gz +0 -0
- package/dist/client/assets/citationLibrary-DxGdbZEQ.js.br +0 -0
- package/dist/client/assets/citationLibrary-DxGdbZEQ.js.gz +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js +0 -1
- package/dist/client/assets/dist-DdUqlCPw.js.br +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js.gz +0 -0
- package/dist/client/assets/editor-CkUEg2La.js +0 -14
- package/dist/client/assets/editor-CkUEg2La.js.br +0 -0
- package/dist/client/assets/editor-CkUEg2La.js.gz +0 -0
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js +0 -36
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js.br +0 -0
- package/dist/client/assets/editor-languages-kcWr1Z3Q.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js +0 -1
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.gz +0 -0
- package/dist/client/assets/generatedParser-CZa2vsK6.js.br +0 -0
- package/dist/client/assets/generatedParser-CZa2vsK6.js.gz +0 -0
- package/dist/client/assets/i18n-Wn96VbWM.js +0 -13
- package/dist/client/assets/i18n-Wn96VbWM.js.br +0 -0
- package/dist/client/assets/i18n-Wn96VbWM.js.gz +0 -0
- package/dist/client/assets/index-CemLYDYL.js +0 -2
- package/dist/client/assets/index-CemLYDYL.js.br +0 -0
- package/dist/client/assets/index-CemLYDYL.js.gz +0 -0
- package/dist/client/assets/index-DSF5eT29.css +0 -1
- package/dist/client/assets/index-DSF5eT29.css.br +0 -0
- package/dist/client/assets/index-DSF5eT29.css.gz +0 -0
- package/dist/client/assets/relativeTime-C-GTw3lA.js +0 -1
- package/dist/client/assets/relativeTime-C-GTw3lA.js.br +0 -0
- package/dist/client/assets/relativeTime-C-GTw3lA.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js +0 -1
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-Dpoi7PAL.js.gz +0 -0
- package/dist/client/assets/spellCheck-kxvnxrvw.js.br +0 -0
- package/dist/client/assets/spellCheck-kxvnxrvw.js.gz +0 -0
- package/dist/client/assets/textLanguageSupport-Ck8lMOWz.js +0 -1
- package/dist/client/assets/textLanguages-CwWstpJ5.js +0 -78
- package/dist/client/assets/textLanguages-CwWstpJ5.js.br +0 -0
- package/dist/client/assets/textLanguages-CwWstpJ5.js.gz +0 -0
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js +0 -1
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Xlq7HabP.js.gz +0 -0
- package/dist/client/assets/vimSupport-C-WiMLjc.js.br +0 -0
- package/dist/client/assets/vimSupport-C-WiMLjc.js.gz +0 -0
- /package/dist/client/assets/{AgentIcon-qmglBc3M.js → AgentIcon-CjaO3WzI.js} +0 -0
- /package/dist/client/assets/{AgentIcon-qmglBc3M.js.br → AgentIcon-CjaO3WzI.js.br} +0 -0
- /package/dist/client/assets/{AgentIcon-qmglBc3M.js.gz → AgentIcon-CjaO3WzI.js.gz} +0 -0
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
import { inspectAgentProcess, agentProcessGroupAlive } from "./processIdentity.js";
|
|
5
5
|
import { stopAgentPty, windowsAgentCommand } from "./terminal.js";
|
|
6
6
|
import { httpError } from "../http.js";
|
|
7
|
+
import { attachWindowsAgentJob, stopWindowsAgentJob } from "./windowsJob.js";
|
|
7
8
|
function readRecord(filename) {
|
|
8
9
|
let value;
|
|
9
10
|
try {
|
|
@@ -14,7 +15,8 @@ function readRecord(filename) {
|
|
|
14
15
|
return null;
|
|
15
16
|
throw error;
|
|
16
17
|
}
|
|
17
|
-
if (value?.version !== 1 || !/^[a-f\d-]{
|
|
18
|
+
if ((value?.version !== 1 && value?.version !== 2) || !/^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/.test(value.executionId) || value.platform !== process.platform
|
|
19
|
+
|| (value.version === 2 && (value.platform !== "win32" || value.pid === null))
|
|
18
20
|
|| !(value.pid === null && value.identity === null || Number.isSafeInteger(value.pid) && value.pid > 0 && typeof value.identity === "string" && value.identity)) {
|
|
19
21
|
throw httpError(409, "AGENT_RECOVERY_FAILED");
|
|
20
22
|
}
|
|
@@ -34,7 +36,19 @@ export async function recoverAgentExecution(filename) {
|
|
|
34
36
|
const record = readRecord(filename);
|
|
35
37
|
if (!record)
|
|
36
38
|
return;
|
|
39
|
+
if (record.version === 2) {
|
|
40
|
+
// The job outlives a dead launcher until all its members have exited.
|
|
41
|
+
// Never stop a recycled PID or infer completion from launcher exit.
|
|
42
|
+
await stopWindowsAgentJob(record.executionId);
|
|
43
|
+
clearAgentExecution(filename);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
37
46
|
if (record.pid !== null) {
|
|
47
|
+
if (record.platform === "win32") {
|
|
48
|
+
// Legacy records have no owned job and cannot prove that every
|
|
49
|
+
// descendant is gone. Do not release the project on that basis.
|
|
50
|
+
throw httpError(409, "AGENT_RECOVERY_FAILED");
|
|
51
|
+
}
|
|
38
52
|
const process = await inspectAgentProcess(record.pid, record.executionId);
|
|
39
53
|
if (process && process.identity === record.identity && process.owned) {
|
|
40
54
|
// Verify twice before signalling; a recycled PID must never be targeted.
|
|
@@ -68,14 +82,14 @@ export async function recoverAgentExecution(filename) {
|
|
|
68
82
|
/** Start a gated, identifiable group leader without changing the CLI's TTY. */
|
|
69
83
|
export async function spawnRecoverableAgent(spawn, executable, args, options, filename, beforeStart) {
|
|
70
84
|
const record = { version: 1, executionId: randomUUID(), platform: process.platform, pid: null, identity: null };
|
|
71
|
-
fs.writeFileSync(filename, JSON.stringify(record), { flag: "wx", mode: 0o600 });
|
|
72
85
|
const compiled = new URL("./launcher.js", import.meta.url);
|
|
73
86
|
const launcher = fileURLToPath(fs.existsSync(compiled) ? compiled : new URL("./launcher.ts", import.meta.url));
|
|
74
87
|
let launch = { executable, args, windowsVerbatimArguments: false };
|
|
75
88
|
if (process.platform === "win32" && /\.(?:cmd|bat)$/i.test(executable)) {
|
|
76
89
|
const command = windowsAgentCommand(executable, args);
|
|
77
|
-
launch = { executable: command.executable, args:
|
|
90
|
+
launch = { executable: command.executable, args: command.argv, windowsVerbatimArguments: true };
|
|
78
91
|
}
|
|
92
|
+
fs.writeFileSync(filename, JSON.stringify(record), { flag: "wx", mode: 0o600 });
|
|
79
93
|
let pty;
|
|
80
94
|
try {
|
|
81
95
|
pty = await spawn(process.execPath, [launcher, filename, record.executionId], {
|
|
@@ -93,6 +107,11 @@ export async function spawnRecoverableAgent(spawn, executable, args, options, fi
|
|
|
93
107
|
throw httpError(409, "AGENT_START_FAILED");
|
|
94
108
|
record.pid = pty.pid;
|
|
95
109
|
record.identity = identity.identity;
|
|
110
|
+
if (process.platform === "win32") {
|
|
111
|
+
await attachWindowsAgentJob(pty.pid, record.executionId);
|
|
112
|
+
record.version = 2;
|
|
113
|
+
wrapped.stop = () => stopWindowsAgentJob(record.executionId);
|
|
114
|
+
}
|
|
96
115
|
// Conversation cleanup ownership must be durable before the CLI is allowed
|
|
97
116
|
// to create any native state, not after the launch promise returns.
|
|
98
117
|
beforeStart?.();
|
|
@@ -104,7 +123,9 @@ export async function spawnRecoverableAgent(spawn, executable, args, options, fi
|
|
|
104
123
|
catch (error) {
|
|
105
124
|
// No permit was issued, so the CLI cannot have started. Keep any failed
|
|
106
125
|
// cleanup lease so service recovery can cancel the waiting launcher.
|
|
107
|
-
|
|
126
|
+
// On Windows no permit was issued. The launcher will exit when the
|
|
127
|
+
// pending record is removed; no CLI or descendants can have started.
|
|
128
|
+
if (pty && process.platform !== "win32")
|
|
108
129
|
await stopAgentPty(pty);
|
|
109
130
|
clearAgentExecution(filename);
|
|
110
131
|
throw error;
|
|
@@ -14,7 +14,7 @@ process.on("SIGTERM", () => undefined);
|
|
|
14
14
|
process.on("SIGINT", () => undefined);
|
|
15
15
|
if (process.platform !== "win32")
|
|
16
16
|
process.on("SIGHUP", () => undefined);
|
|
17
|
-
const deadline = Date.now() + 10_000;
|
|
17
|
+
const deadline = Date.now() + (process.platform === "win32" ? 30_000 : 10_000);
|
|
18
18
|
while (true) {
|
|
19
19
|
let record;
|
|
20
20
|
try {
|
|
@@ -25,8 +25,11 @@ while (true) {
|
|
|
25
25
|
}
|
|
26
26
|
if (record.executionId !== executionId)
|
|
27
27
|
process.exit(1);
|
|
28
|
-
if (record.pid === process.pid && record.identity)
|
|
28
|
+
if (record.pid === process.pid && record.identity) {
|
|
29
|
+
if (record.version !== (process.platform === "win32" ? 2 : 1))
|
|
30
|
+
process.exit(1);
|
|
29
31
|
break;
|
|
32
|
+
}
|
|
30
33
|
if (Date.now() >= deadline)
|
|
31
34
|
process.exit(1);
|
|
32
35
|
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** Bounded chunk storage plus input modes that may outlive the retained output.
|
|
2
|
+
* This is not a screen emulator: old scrollback and screen cells can be lost.
|
|
3
|
+
*/
|
|
4
|
+
export class AgentOutputBuffer {
|
|
5
|
+
limit;
|
|
6
|
+
chunks = [];
|
|
7
|
+
length = 0;
|
|
8
|
+
head = 0;
|
|
9
|
+
sequence = "";
|
|
10
|
+
state = "text";
|
|
11
|
+
modes = new Map();
|
|
12
|
+
keypad = null;
|
|
13
|
+
truncated = false;
|
|
14
|
+
constructor(limit = 256 * 1024) {
|
|
15
|
+
this.limit = limit;
|
|
16
|
+
}
|
|
17
|
+
append(data) {
|
|
18
|
+
if (!data)
|
|
19
|
+
return;
|
|
20
|
+
for (const char of data)
|
|
21
|
+
this.track(char);
|
|
22
|
+
this.chunks.push(data);
|
|
23
|
+
this.length += data.length;
|
|
24
|
+
while (this.length > this.limit && this.head < this.chunks.length) {
|
|
25
|
+
this.truncated = true;
|
|
26
|
+
const chunk = this.chunks[this.head];
|
|
27
|
+
const excess = this.length - this.limit;
|
|
28
|
+
if (chunk.length <= excess) {
|
|
29
|
+
this.length -= chunk.length;
|
|
30
|
+
this.chunks[this.head++] = "";
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
let cut = excess;
|
|
34
|
+
if (/^[\uDC00-\uDFFF]$/.test(chunk[cut] ?? ""))
|
|
35
|
+
cut++;
|
|
36
|
+
this.chunks[this.head] = chunk.slice(cut);
|
|
37
|
+
this.length -= cut;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (this.head > 1024 && this.head * 2 > this.chunks.length) {
|
|
41
|
+
this.chunks = this.chunks.slice(this.head);
|
|
42
|
+
this.head = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
replay() {
|
|
46
|
+
const output = this.chunks.slice(this.head).join("");
|
|
47
|
+
if (!this.truncated)
|
|
48
|
+
return output;
|
|
49
|
+
// CAN cancels a partial escape at the end of truncated output. Reapply
|
|
50
|
+
// only input modes, not alternate-screen switches that can clear cells.
|
|
51
|
+
return output + "\x18" + [...this.modes].map(([mode, enabled]) => `\x1b[?${mode}${enabled ? "h" : "l"}`).join("")
|
|
52
|
+
+ (this.keypad === null ? "" : this.keypad ? "\x1b=" : "\x1b>")
|
|
53
|
+
+ (this.state === "csi" ? `\x1b[${this.sequence}` : this.state === "escape" ? "\x1b" : "");
|
|
54
|
+
}
|
|
55
|
+
track(char) {
|
|
56
|
+
if (this.state === "string") {
|
|
57
|
+
if (char === "\x07")
|
|
58
|
+
this.state = "text";
|
|
59
|
+
else if (char === "\x1b")
|
|
60
|
+
this.state = "stringEscape";
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (this.state === "stringEscape") {
|
|
64
|
+
this.state = char === "\\" ? "text" : "string";
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (char === "\x1b") {
|
|
68
|
+
this.state = "escape";
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (this.state === "escape") {
|
|
72
|
+
if (char === "[") {
|
|
73
|
+
this.state = "csi";
|
|
74
|
+
this.sequence = "";
|
|
75
|
+
}
|
|
76
|
+
else if ("]P_^X".includes(char))
|
|
77
|
+
this.state = "string";
|
|
78
|
+
else {
|
|
79
|
+
if (char === "=" || char === ">")
|
|
80
|
+
this.keypad = char === "=";
|
|
81
|
+
if (char === "c") {
|
|
82
|
+
this.modes.clear();
|
|
83
|
+
this.keypad = null;
|
|
84
|
+
}
|
|
85
|
+
this.state = "text";
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (this.state !== "csi")
|
|
90
|
+
return;
|
|
91
|
+
if (char >= "@" && char <= "~") {
|
|
92
|
+
if ((char === "h" || char === "l") && /^\?[\d;]+$/.test(this.sequence)) {
|
|
93
|
+
for (const mode of this.sequence.slice(1).split(";")) {
|
|
94
|
+
if (["1", "1000", "1002", "1003", "1004", "1005", "1006", "1015", "2004"].includes(mode))
|
|
95
|
+
this.modes.set(mode, char === "h");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
this.state = "text";
|
|
99
|
+
}
|
|
100
|
+
else if (this.sequence.length < 128)
|
|
101
|
+
this.sequence += char;
|
|
102
|
+
else
|
|
103
|
+
this.state = "text";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -54,7 +54,7 @@ export async function inspectAgentProcess(pid, executionId, io = systemIO) {
|
|
|
54
54
|
/** A vanished leader is not proof that all members of its POSIX group exited. */
|
|
55
55
|
export async function agentProcessGroupAlive(pid, io = systemIO) {
|
|
56
56
|
if (io.platform === "win32")
|
|
57
|
-
|
|
57
|
+
throw new Error("Windows agent groups require an owned Job Object");
|
|
58
58
|
const output = await io.command("ps", ["-axo", "pgid=,stat="]);
|
|
59
59
|
return output.split("\n").some((line) => {
|
|
60
60
|
const [group, state] = line.trim().split(/\s+/);
|
|
@@ -10,6 +10,7 @@ import { agentTaskRoot, AgentSourceSync, ensureAgentInstructions, writeAgentProj
|
|
|
10
10
|
import { sourceRoot } from "../files.js";
|
|
11
11
|
import { loadAgentPty, stopAgentPty } from "./terminal.js";
|
|
12
12
|
import { clearAgentExecution, recoverAgentExecution } from "./execution.js";
|
|
13
|
+
import { AgentOutputBuffer } from "./outputBuffer.js";
|
|
13
14
|
const now = () => new Date().toISOString();
|
|
14
15
|
const taskNameCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
|
|
15
16
|
function randomTaskName() {
|
|
@@ -39,7 +40,7 @@ export class AgentService {
|
|
|
39
40
|
continue;
|
|
40
41
|
this.db.prepare("UPDATE agent_tasks SET state = 'stopping', error_code = 'AGENT_RECOVERY_FAILED' WHERE id = ?").run(row.id);
|
|
41
42
|
this.activeProjects.set(row.project_id, row.id);
|
|
42
|
-
const releaseWriter = this.context.projectMutations.registerExternalWriter(row.project_id, async () => { await this.stop(row.id); });
|
|
43
|
+
const releaseWriter = this.context.projectMutations.registerExternalWriter(row.project_id, async () => { await this.stop(row.id, undefined, false, "AGENT_STOPPED_BY_PROJECT_OPERATION"); });
|
|
43
44
|
this.recoveries.set(row.id, () => {
|
|
44
45
|
if (this.activeProjects.get(row.project_id) === row.id)
|
|
45
46
|
this.activeProjects.delete(row.project_id);
|
|
@@ -59,7 +60,8 @@ export class AgentService {
|
|
|
59
60
|
COUNT(CASE WHEN state IN ('starting', 'running', 'stopping')
|
|
60
61
|
AND (? IS NULL OR project_id = ?) THEN 1 END) AS activeCount
|
|
61
62
|
FROM agent_tasks WHERE user_id = ?`).get(projectId ?? null, projectId ?? null, userId);
|
|
62
|
-
|
|
63
|
+
const enabled = this.policy().allowed.length > 0;
|
|
64
|
+
return { visible: enabled || total > 0, activeCount, enabled };
|
|
63
65
|
}
|
|
64
66
|
async catalog(refresh = false) {
|
|
65
67
|
await this.recovery;
|
|
@@ -168,7 +170,7 @@ export class AgentService {
|
|
|
168
170
|
// This applies to all users, agents and tasks in this project.
|
|
169
171
|
if (this.activeProjects.has(row.project_id))
|
|
170
172
|
throw httpError(409, "AGENT_PROJECT_BUSY");
|
|
171
|
-
const releaseWriter = this.context.projectMutations.registerExternalWriter(row.project_id, async () => { await this.stop(id); });
|
|
173
|
+
const releaseWriter = this.context.projectMutations.registerExternalWriter(row.project_id, async () => { await this.stop(id, undefined, false, "AGENT_STOPPED_BY_PROJECT_OPERATION"); });
|
|
172
174
|
if (!releaseWriter)
|
|
173
175
|
throw httpError(409, "AGENT_PROJECT_BUSY");
|
|
174
176
|
this.activeProjects.set(row.project_id, id);
|
|
@@ -221,7 +223,7 @@ export class AgentService {
|
|
|
221
223
|
executionFile: this.executionFile(id),
|
|
222
224
|
beforeStart: () => { this.db.prepare("UPDATE agent_tasks SET ever_started = 1 WHERE id = ?").run(id); } });
|
|
223
225
|
let finish;
|
|
224
|
-
const execution = { pty, attachments: new Set(), controller: null, output:
|
|
226
|
+
const execution = { pty, attachments: new Set(), controller: null, output: new AgentOutputBuffer(), permissionsCheckedAt: -Infinity, cols: 100, rows: 24, stopping: false, termination: null, exitCode: null,
|
|
225
227
|
finished: new Promise((resolve) => { finish = resolve; }), finish: () => finish(), subscriptions: [], source, releaseProject };
|
|
226
228
|
this.executions.set(id, execution);
|
|
227
229
|
execution.subscriptions.push(pty.onData((data) => this.output(id, execution, data)));
|
|
@@ -261,11 +263,14 @@ export class AgentService {
|
|
|
261
263
|
}
|
|
262
264
|
});
|
|
263
265
|
}
|
|
264
|
-
async stop(id, user, administration = false) {
|
|
266
|
+
async stop(id, user, administration = false, reason) {
|
|
265
267
|
return this.withTask(id, async () => {
|
|
266
268
|
if (user)
|
|
267
269
|
this.owned(id, user, administration);
|
|
268
|
-
|
|
270
|
+
if (reason && (this.executions.has(id) || this.recoveries.has(id))) {
|
|
271
|
+
this.db.prepare("UPDATE agent_tasks SET error_code = ? WHERE id = ? AND error_code IS NULL").run(reason, id);
|
|
272
|
+
}
|
|
273
|
+
await this.stopExecution(id, reason);
|
|
269
274
|
await this.captureContext(id);
|
|
270
275
|
const row = this.row(id);
|
|
271
276
|
if (user && row)
|
|
@@ -320,8 +325,10 @@ export class AgentService {
|
|
|
320
325
|
if (!execution.controller)
|
|
321
326
|
execution.controller = attachment;
|
|
322
327
|
this.send(socket, { type: "state", task: this.json(row) });
|
|
323
|
-
|
|
324
|
-
|
|
328
|
+
this.send(socket, { type: "size", cols: execution.cols, rows: execution.rows });
|
|
329
|
+
const replay = execution.output.replay();
|
|
330
|
+
if (replay)
|
|
331
|
+
this.send(socket, { type: "output", data: replay });
|
|
325
332
|
this.controls(execution);
|
|
326
333
|
socket.on("message", (raw) => {
|
|
327
334
|
if (!authorized()) {
|
|
@@ -350,6 +357,10 @@ export class AgentService {
|
|
|
350
357
|
execution.pty.write(message.data);
|
|
351
358
|
if (message.type === "resize") {
|
|
352
359
|
execution.pty.resize(message.cols, message.rows);
|
|
360
|
+
execution.cols = message.cols;
|
|
361
|
+
execution.rows = message.rows;
|
|
362
|
+
for (const peer of execution.attachments)
|
|
363
|
+
this.send(peer.socket, { type: "size", cols: message.cols, rows: message.rows });
|
|
353
364
|
}
|
|
354
365
|
});
|
|
355
366
|
socket.on("close", () => {
|
|
@@ -408,9 +419,9 @@ export class AgentService {
|
|
|
408
419
|
this.db.prepare("UPDATE agent_tasks SET native_session_id = ? WHERE id = ?").run(native.id, id);
|
|
409
420
|
return native;
|
|
410
421
|
}
|
|
411
|
-
async stopExecution(id) {
|
|
422
|
+
async stopExecution(id, reason) {
|
|
412
423
|
if (this.recoveries.has(id)) {
|
|
413
|
-
await this.recoverExecution(id, "stopped");
|
|
424
|
+
await this.recoverExecution(id, "stopped", reason);
|
|
414
425
|
return;
|
|
415
426
|
}
|
|
416
427
|
const execution = this.executions.get(id);
|
|
@@ -471,12 +482,18 @@ export class AgentService {
|
|
|
471
482
|
return termination;
|
|
472
483
|
}
|
|
473
484
|
output(id, execution, data) {
|
|
474
|
-
|
|
475
|
-
if (!row || !this.editable(row)) {
|
|
476
|
-
void this.stop(id).catch((error) => this.options.onError?.(error));
|
|
485
|
+
if (execution.stopping)
|
|
477
486
|
return;
|
|
487
|
+
const checkedAt = performance.now();
|
|
488
|
+
if (checkedAt - execution.permissionsCheckedAt >= 1000) {
|
|
489
|
+
const row = this.row(id);
|
|
490
|
+
if (!row || !this.editable(row)) {
|
|
491
|
+
void this.stop(id).catch((error) => this.options.onError?.(error));
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
execution.permissionsCheckedAt = checkedAt;
|
|
478
495
|
}
|
|
479
|
-
execution.output
|
|
496
|
+
execution.output.append(data);
|
|
480
497
|
for (const attachment of execution.attachments) {
|
|
481
498
|
if (!attachment.authorized()) {
|
|
482
499
|
attachment.socket.close(1008, "Authentication expired");
|
|
@@ -538,7 +555,7 @@ export class AgentService {
|
|
|
538
555
|
catch { /* Failure is logged and its task/claim remains available for retry. */ }
|
|
539
556
|
}));
|
|
540
557
|
}
|
|
541
|
-
async recoverExecution(id, state) {
|
|
558
|
+
async recoverExecution(id, state, reason = null) {
|
|
542
559
|
try {
|
|
543
560
|
await recoverAgentExecution(this.executionFile(id));
|
|
544
561
|
const row = this.row(id);
|
|
@@ -548,7 +565,7 @@ export class AgentService {
|
|
|
548
565
|
const author = this.db.prepare("SELECT 1 FROM users WHERE id = ?").get(row.user_id) ? row.user_id : null;
|
|
549
566
|
this.context.recordHistory(row.project_id, author, "file", undefined, { hasAgent: true });
|
|
550
567
|
}
|
|
551
|
-
this.db.prepare("UPDATE agent_tasks SET state = ?, error_code =
|
|
568
|
+
this.db.prepare("UPDATE agent_tasks SET state = ?, error_code = ?, ended_at = ?, updated_at = ? WHERE id = ?").run(state, reason, now(), now(), id);
|
|
552
569
|
this.recoveries.get(id)?.();
|
|
553
570
|
this.recoveries.delete(id);
|
|
554
571
|
}
|
|
@@ -30,15 +30,18 @@ export function windowsAgentCommand(executable, args) {
|
|
|
30
30
|
const quote = (value) => {
|
|
31
31
|
// Registered CLI flags/IDs never require shell expansion. Refuse values
|
|
32
32
|
// that cmd.exe would reinterpret even within double quotes.
|
|
33
|
-
if (/["%\r\n]/.test(value))
|
|
33
|
+
if (/["%\0\r\n]/.test(value))
|
|
34
34
|
throw new Error("Unsupported Windows command argument");
|
|
35
35
|
return `"${value}"`;
|
|
36
36
|
};
|
|
37
37
|
const command = [executable, ...args].map(quote).join(" ");
|
|
38
|
-
|
|
38
|
+
const argv = ["/d", "/v:off", "/s", "/c", `"${command}"`];
|
|
39
|
+
return { executable: process.env.COMSPEC ?? process.env.ComSpec ?? "cmd.exe", args: argv.join(" "), argv };
|
|
39
40
|
}
|
|
40
41
|
/** Caller must own the live PTY or verify the persisted launcher's birth identity. */
|
|
41
42
|
export async function stopAgentPty(pty) {
|
|
43
|
+
if (pty.stop)
|
|
44
|
+
return pty.stop();
|
|
42
45
|
if (process.platform === "win32") {
|
|
43
46
|
// Natural exit (or another stop) may have already removed the process.
|
|
44
47
|
// Do not interpret localized taskkill output/exit codes as proof of this:
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
const run = promisify(execFile);
|
|
5
|
+
// Windows PowerShell provides .NET interop on the target Windows x64 hosts.
|
|
6
|
+
// Keep the handle in the gated Node launcher, not in TexLite or a permanent
|
|
7
|
+
// helper process. The handle is non-inheritable and dies with that launcher.
|
|
8
|
+
const native = String.raw `
|
|
9
|
+
using System;
|
|
10
|
+
using System.ComponentModel;
|
|
11
|
+
using System.Diagnostics;
|
|
12
|
+
using System.Runtime.InteropServices;
|
|
13
|
+
using System.Threading;
|
|
14
|
+
|
|
15
|
+
public static class TexLiteJob {
|
|
16
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
17
|
+
struct BasicLimits {
|
|
18
|
+
public long ProcessTime, JobTime;
|
|
19
|
+
public uint Flags;
|
|
20
|
+
public UIntPtr MinimumWorkingSet, MaximumWorkingSet;
|
|
21
|
+
public uint ActiveProcessLimit;
|
|
22
|
+
public UIntPtr Affinity;
|
|
23
|
+
public uint Priority, Scheduling;
|
|
24
|
+
}
|
|
25
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
26
|
+
struct ExtendedLimits {
|
|
27
|
+
public BasicLimits Basic;
|
|
28
|
+
public ulong ReadOperations, WriteOperations, OtherOperations;
|
|
29
|
+
public ulong ReadBytes, WriteBytes, OtherBytes;
|
|
30
|
+
public UIntPtr ProcessMemory, JobMemory, PeakProcessMemory, PeakJobMemory;
|
|
31
|
+
}
|
|
32
|
+
[StructLayout(LayoutKind.Sequential)]
|
|
33
|
+
struct Accounting {
|
|
34
|
+
public long TotalUserTime, TotalKernelTime, PeriodUserTime, PeriodKernelTime;
|
|
35
|
+
public uint PageFaults, TotalProcesses, ActiveProcesses, TerminatedProcesses;
|
|
36
|
+
}
|
|
37
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
38
|
+
static extern IntPtr CreateJobObject(IntPtr attributes, string name);
|
|
39
|
+
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
|
40
|
+
static extern IntPtr OpenJobObject(uint access, bool inherit, string name);
|
|
41
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
42
|
+
static extern bool SetInformationJobObject(IntPtr job, int type, ref ExtendedLimits value, uint size);
|
|
43
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
44
|
+
static extern bool QueryInformationJobObject(IntPtr job, int type, out Accounting value, uint size, IntPtr returned);
|
|
45
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
46
|
+
static extern bool AssignProcessToJobObject(IntPtr job, IntPtr process);
|
|
47
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
48
|
+
static extern bool DuplicateHandle(IntPtr sourceProcess, IntPtr source, IntPtr targetProcess, out IntPtr target, uint access, bool inherit, uint options);
|
|
49
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
|
50
|
+
static extern bool TerminateJobObject(IntPtr job, uint exitCode);
|
|
51
|
+
[DllImport("kernel32.dll")]
|
|
52
|
+
static extern IntPtr GetCurrentProcess();
|
|
53
|
+
[DllImport("kernel32.dll")]
|
|
54
|
+
static extern bool CloseHandle(IntPtr handle);
|
|
55
|
+
|
|
56
|
+
public static void Attach(string name, IntPtr process) {
|
|
57
|
+
IntPtr job = CreateJobObject(IntPtr.Zero, name);
|
|
58
|
+
int error = Marshal.GetLastWin32Error();
|
|
59
|
+
if (job == IntPtr.Zero) throw new Win32Exception(error);
|
|
60
|
+
try {
|
|
61
|
+
if (error == 183) throw new Win32Exception(error); // ERROR_ALREADY_EXISTS
|
|
62
|
+
ExtendedLimits limits = new ExtendedLimits();
|
|
63
|
+
limits.Basic.Flags = 0x2000; // JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; no breakaway
|
|
64
|
+
if (!SetInformationJobObject(job, 9, ref limits, (uint)Marshal.SizeOf(limits))) throw new Win32Exception();
|
|
65
|
+
if (!AssignProcessToJobObject(job, process)) throw new Win32Exception();
|
|
66
|
+
IntPtr ownedHandle;
|
|
67
|
+
if (!DuplicateHandle(GetCurrentProcess(), job, process, out ownedHandle, 0, false, 2)) throw new Win32Exception();
|
|
68
|
+
} finally { CloseHandle(job); }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public static void Stop(string name) {
|
|
72
|
+
IntPtr job = OpenJobObject(0x000C, false, name); // JOB_OBJECT_QUERY | JOB_OBJECT_TERMINATE
|
|
73
|
+
if (job == IntPtr.Zero) {
|
|
74
|
+
int error = Marshal.GetLastWin32Error();
|
|
75
|
+
// Once the last handle is closed, the kernel destroys the job
|
|
76
|
+
// only after every member has terminated.
|
|
77
|
+
if (error == 2) return; // ERROR_FILE_NOT_FOUND
|
|
78
|
+
throw new Win32Exception(error);
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
if (Active(job) == 0) return;
|
|
82
|
+
if (!TerminateJobObject(job, 1)) {
|
|
83
|
+
int error = Marshal.GetLastWin32Error();
|
|
84
|
+
if (Active(job) != 0) throw new Win32Exception(error);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
Stopwatch timer = Stopwatch.StartNew();
|
|
88
|
+
while (true) {
|
|
89
|
+
if (Active(job) == 0) return;
|
|
90
|
+
if (timer.ElapsedMilliseconds >= 3000) throw new TimeoutException("TexLite job still has active processes");
|
|
91
|
+
Thread.Sleep(30);
|
|
92
|
+
}
|
|
93
|
+
} finally { CloseHandle(job); }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static uint Active(IntPtr job) {
|
|
97
|
+
Accounting value;
|
|
98
|
+
if (!QueryInformationJobObject(job, 1, out value, (uint)Marshal.SizeOf(typeof(Accounting)), IntPtr.Zero)) throw new Win32Exception();
|
|
99
|
+
return value.ActiveProcesses;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
function jobName(executionId, kind) {
|
|
104
|
+
if (!/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/i.test(executionId))
|
|
105
|
+
throw new Error("Invalid execution ID");
|
|
106
|
+
// Use the same namespace across login sessions when the server restarts.
|
|
107
|
+
return `Global\\TexLite.${kind}.${executionId}`;
|
|
108
|
+
}
|
|
109
|
+
async function powershell(body) {
|
|
110
|
+
const command = `$ErrorActionPreference = 'Stop'\nAdd-Type -TypeDefinition @'\n${native}\n'@\n${body}`;
|
|
111
|
+
const executable = path.win32.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
112
|
+
try {
|
|
113
|
+
await run(executable, ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(command, "utf16le").toString("base64")], { timeout: 10_000, windowsHide: true, maxBuffer: 32 * 1024 });
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
const stderr = error?.stderr?.trim();
|
|
117
|
+
throw new Error(stderr ? `Windows job: ${stderr.slice(0, 512)}` : "Could not manage the Windows job", { cause: error });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Attach before issuing the launch permit, so all CLI descendants inherit the job. */
|
|
121
|
+
export async function attachWindowsJob(pid, executionId, kind) {
|
|
122
|
+
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
123
|
+
throw new Error("Invalid Windows launcher PID");
|
|
124
|
+
const name = jobName(executionId, kind);
|
|
125
|
+
await powershell(`
|
|
126
|
+
$launcher = Get-Process -Id ${pid} -ErrorAction Stop
|
|
127
|
+
try {
|
|
128
|
+
$handle = $launcher.Handle
|
|
129
|
+
$entry = Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}' -ErrorAction Stop
|
|
130
|
+
if (-not $entry.CommandLine -or -not $entry.CommandLine.Contains('${executionId}') -or $launcher.HasExited) {
|
|
131
|
+
throw 'The launcher identity changed before job assignment'
|
|
132
|
+
}
|
|
133
|
+
[TexLiteJob]::Attach('${name}', $handle)
|
|
134
|
+
} finally { $launcher.Dispose() }
|
|
135
|
+
`);
|
|
136
|
+
}
|
|
137
|
+
export function stopWindowsJob(executionId, kind) {
|
|
138
|
+
return powershell(`[TexLiteJob]::Stop('${jobName(executionId, kind)}')`);
|
|
139
|
+
}
|
|
140
|
+
export const attachWindowsAgentJob = (pid, id) => attachWindowsJob(pid, id, "Agent");
|
|
141
|
+
export const stopWindowsAgentJob = (id) => stopWindowsJob(id, "Agent");
|
package/dist/server/app.js
CHANGED
|
@@ -9,10 +9,11 @@ import websocket from "@fastify/websocket";
|
|
|
9
9
|
import { pruneExpiredSessions } from "./db.js";
|
|
10
10
|
import { digestToken, LoginRateLimiter } from "./security.js";
|
|
11
11
|
import { currentUser } from "./auth.js";
|
|
12
|
-
import { pruneTrashDirectory } from "./files.js";
|
|
12
|
+
import { pruneTrashDirectory, removeProjectDirectory } from "./files.js";
|
|
13
13
|
import { CompileQueue, ProjectCompileCoordinator, listPublishedCompileArtifacts, pruneOrphanedCompileRuns, reconcilePublishedCompileRuns } from "./compiler.js";
|
|
14
14
|
import { CollaborationService } from "./collaboration.js";
|
|
15
15
|
import { ProjectMutationCoordinator } from "./projectMutations.js";
|
|
16
|
+
import { ProjectDeletionCleanup } from "./projectDeletionCleanup.js";
|
|
16
17
|
import { ProjectGitService } from "./git.js";
|
|
17
18
|
import { LatexCompletionService } from "./latexCompletion.js";
|
|
18
19
|
import { ProjectHistoryService } from "./history.js";
|
|
@@ -32,6 +33,7 @@ import { registerCommentRoutes } from "./routes/comments.js";
|
|
|
32
33
|
import { registerProjectMemberRoutes } from "./routes/projectMembers.js";
|
|
33
34
|
import { registerProjectViewLinkRoutes } from "./routes/projectViewLinks.js";
|
|
34
35
|
import { registerProjectFileRoutes } from "./routes/projectFiles.js";
|
|
36
|
+
import { registerDrawioRoutes } from "./routes/drawio.js";
|
|
35
37
|
import { registerProjectSearchRoutes } from "./routes/projectSearch.js";
|
|
36
38
|
import { registerProjectReferenceRoutes } from "./routes/projectReferences.js";
|
|
37
39
|
import { registerProjectHistoryRoutes } from "./routes/projectHistory.js";
|
|
@@ -86,10 +88,16 @@ export async function buildApp(config, db, options = {}) {
|
|
|
86
88
|
app.addHook("onClose", async () => { await updates.dispose(); });
|
|
87
89
|
const queue = new CompileQueue(config.maxCompileJobs);
|
|
88
90
|
const compileCoordinator = new ProjectCompileCoordinator(queue);
|
|
91
|
+
// Windows PM2 uses a bounded IPC shutdown. Do not change when a POSIX
|
|
92
|
+
// instance drains in-flight compile requests.
|
|
93
|
+
if (process.platform === "win32")
|
|
94
|
+
app.addHook("preClose", async () => { await compileCoordinator.close(); });
|
|
89
95
|
const metrics = new MetricRegistry(200);
|
|
90
96
|
const eventLoopDelay = monitorEventLoopDelay({ resolution: EVENT_LOOP_DELAY_RESOLUTION_MS });
|
|
91
97
|
eventLoopDelay.enable();
|
|
92
|
-
const history = new ProjectHistoryService(config, db)
|
|
98
|
+
const history = new ProjectHistoryService(config, db, (error, directory) => {
|
|
99
|
+
app.log.warn({ err: error, directory }, "Could not clean up a snapshot restore directory");
|
|
100
|
+
});
|
|
93
101
|
const editHistory = new ProjectEditHistoryService(db, config.editHistoryMaxStorageBytes, config.editHistoryMaxSegments);
|
|
94
102
|
const historyRetention = new HistoryRetentionScheduler(history, {
|
|
95
103
|
onError: (error, projectId) => app.log.error({ err: error, projectId }, "Failed to enforce project history retention")
|
|
@@ -151,6 +159,14 @@ export async function buildApp(config, db, options = {}) {
|
|
|
151
159
|
metrics.record("collaboration.persist", durationMs + performance.now() - started);
|
|
152
160
|
});
|
|
153
161
|
const projectMutations = new ProjectMutationCoordinator(collaboration);
|
|
162
|
+
const projectDeletionCleanup = new ProjectDeletionCleanup(db, (id) => projectMutations.runExclusive(id, "admin user deletion cleanup", () => {
|
|
163
|
+
collaboration.resetProject(id);
|
|
164
|
+
latexCompletions.invalidate(id);
|
|
165
|
+
projectOutlines.invalidate(id);
|
|
166
|
+
removeProjectDirectory(config, id);
|
|
167
|
+
}, { flush: false }), (err, projectId) => app.log.warn({ err, projectId }, "Pending project directory cleanup will be retried"));
|
|
168
|
+
app.addHook("onListen", async () => { projectDeletionCleanup.start(); });
|
|
169
|
+
app.addHook("preClose", async () => { projectMutations.drawioLocks.close(); });
|
|
154
170
|
const agents = new AgentService({ config, db, collaboration, projectMutations, recordHistory,
|
|
155
171
|
recordEdits: (id, edits) => editRetry.save(id, edits)
|
|
156
172
|
}, { onError: (error) => app.log.error({ err: error }, "External agent operation failed"), ...options.agents });
|
|
@@ -207,11 +223,13 @@ export async function buildApp(config, db, options = {}) {
|
|
|
207
223
|
// instance lock is held. Finish cleanup before accepting requests so a
|
|
208
224
|
// freshly started server never races a stale trash/tmp removal.
|
|
209
225
|
await pruneTrashDirectory(config);
|
|
226
|
+
await projectDeletionCleanup.retryPending();
|
|
210
227
|
for (const row of db.prepare("SELECT id FROM projects").all()) {
|
|
228
|
+
history.pruneRestoreBackups(row.id);
|
|
211
229
|
history.enforceRetention(row.id);
|
|
212
230
|
editHistory.enforceRetention(row.id);
|
|
213
231
|
pruneCompileRuns(row.id);
|
|
214
|
-
pruneOrphanedCompileRuns(config, row.id);
|
|
232
|
+
pruneOrphanedCompileRuns(config, row.id, (err, directory) => app.log.warn({ err, directory }, "Could not remove a retired compile run"));
|
|
215
233
|
}
|
|
216
234
|
app.addHook("onClose", async () => {
|
|
217
235
|
eventLoopDelay.disable();
|
|
@@ -271,6 +289,7 @@ export async function buildApp(config, db, options = {}) {
|
|
|
271
289
|
// Fastify runs close hooks in reverse registration order. Drain external
|
|
272
290
|
// writers while Yjs rooms and history retry/retention services still exist.
|
|
273
291
|
app.addHook("onClose", async () => { await agents.dispose(); });
|
|
292
|
+
app.addHook("onClose", async () => { await projectDeletionCleanup.close(); });
|
|
274
293
|
const indexPath = path.join(config.clientDir, "index.html");
|
|
275
294
|
const renderedIndex = fs.existsSync(indexPath)
|
|
276
295
|
? renderClientIndex(fs.readFileSync(indexPath, "utf8"), config.basePath)
|
|
@@ -311,12 +330,10 @@ export async function buildApp(config, db, options = {}) {
|
|
|
311
330
|
registerAvatarRoutes(routes, { db, collaboration });
|
|
312
331
|
registerCitationRoutes(routes, { db });
|
|
313
332
|
registerUserManagementRoutes(routes, {
|
|
314
|
-
config,
|
|
315
333
|
db,
|
|
316
334
|
collaboration,
|
|
317
335
|
projectMutations,
|
|
318
|
-
|
|
319
|
-
projectOutlines
|
|
336
|
+
projectDeletionCleanup
|
|
320
337
|
});
|
|
321
338
|
registerCommentRoutes(routes, { config, db, collaboration, projectMutations });
|
|
322
339
|
registerProjectMemberRoutes(routes, { db, collaboration, projectMutations });
|
|
@@ -332,6 +349,7 @@ export async function buildApp(config, db, options = {}) {
|
|
|
332
349
|
recordHistory
|
|
333
350
|
});
|
|
334
351
|
registerProjectSearchRoutes(routes, { config, db, projectMutations, collaboration });
|
|
352
|
+
registerDrawioRoutes(routes, { config, db, collaboration, projectMutations, recordHistory });
|
|
335
353
|
registerProjectReferenceRoutes(routes, { config, db, projectMutations });
|
|
336
354
|
registerProjectHistoryRoutes(routes, { config, db, history, editHistory, projectMutations, recordHistory,
|
|
337
355
|
clearPendingEdits: (id) => { editRetry.clear(id); failedEdits.delete(id); signalHistory(id); },
|
package/dist/server/auth.js
CHANGED
|
@@ -14,8 +14,9 @@ export function publicUser(user) {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
const requestUserCache = new WeakMap();
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/** Refresh after a long operation when authorization may have changed meanwhile. */
|
|
18
|
+
export function currentUser(request, db, refresh = false) {
|
|
19
|
+
if (!refresh && requestUserCache.has(request)) {
|
|
19
20
|
return requestUserCache.get(request) ?? null;
|
|
20
21
|
}
|
|
21
22
|
const token = request.cookies.texlite_session;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Cookie-authenticated WebSockets must originate from this deployment. */
|
|
2
|
+
export function browserOriginAllowed(request) {
|
|
3
|
+
const origin = request.headers.origin;
|
|
4
|
+
if (!origin)
|
|
5
|
+
return false;
|
|
6
|
+
try {
|
|
7
|
+
const parsed = new URL(origin);
|
|
8
|
+
const forwarded = request.headers["x-forwarded-proto"];
|
|
9
|
+
const protocol = forwarded === "https" || forwarded === "http" ? forwarded : request.protocol;
|
|
10
|
+
return parsed.host === request.headers.host && parsed.protocol === `${protocol}:` && parsed.origin === origin;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|