texlite 0.22.0 → 0.24.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 +75 -15
- package/OPERATIONS.md +21 -1
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/addon.md +76 -0
- package/dist/client/assets/AdminUsers-C-8tXzvj.js +1 -0
- package/dist/client/assets/AdminUsers-C-8tXzvj.js.br +0 -0
- package/dist/client/assets/AdminUsers-C-8tXzvj.js.gz +0 -0
- package/dist/client/assets/{AgentIcon-DeoZDwgh.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-DlV6tHez.js → AgentManagement-DXgfP7l_.js} +1 -1
- package/dist/client/assets/AgentManagement-DXgfP7l_.js.br +0 -0
- package/dist/client/assets/AgentManagement-DXgfP7l_.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-DD4sskCS.js +2 -0
- package/dist/client/assets/AgentTerminal-DD4sskCS.js.br +0 -0
- package/dist/client/assets/AgentTerminal-DD4sskCS.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-DliOcop5.js +16 -0
- package/dist/client/assets/AgentTerminalSurface-DliOcop5.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-DliOcop5.js.gz +0 -0
- package/dist/client/assets/{AvatarSettingsDialog-C8WQhZBK.js → AvatarSettingsDialog-iuEbMO4a.js} +1 -1
- package/dist/client/assets/AvatarSettingsDialog-iuEbMO4a.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-iuEbMO4a.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-CDiYDj3M.js +1 -0
- package/dist/client/assets/{CitationLibraryDialog-DgOIkLwK.js → CitationLibraryDialog-CJlL-Ytx.js} +3 -3
- package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-CJlL-Ytx.js.gz +0 -0
- package/dist/client/assets/Dashboard-DqwGd9wd.js +5 -0
- package/dist/client/assets/Dashboard-DqwGd9wd.js.br +0 -0
- package/dist/client/assets/Dashboard-DqwGd9wd.js.gz +0 -0
- package/dist/client/assets/{GitDialog-DGzZ3GRj.js → GitDialog-DUGAigLx.js} +1 -1
- package/dist/client/assets/GitDialog-DUGAigLx.js.br +0 -0
- package/dist/client/assets/GitDialog-DUGAigLx.js.gz +0 -0
- package/dist/client/assets/{GitHubAccountDialog-CGZl3mcY.js → GitHubAccountDialog-B4eD622i.js} +1 -1
- package/dist/client/assets/GitHubAccountDialog-B4eD622i.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-B4eD622i.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-upkR8E0L.js +8 -0
- package/dist/client/assets/HistoryDialog-upkR8E0L.js.br +0 -0
- package/dist/client/assets/HistoryDialog-upkR8E0L.js.gz +0 -0
- package/dist/client/assets/{InfoPopover-Ba7GvcuW.js → InfoPopover-CQ3Q10tN.js} +1 -1
- package/dist/client/assets/LatexEditor-DvDYTc0r.js +25 -0
- package/dist/client/assets/LatexEditor-DvDYTc0r.js.br +0 -0
- package/dist/client/assets/LatexEditor-DvDYTc0r.js.gz +0 -0
- package/dist/client/assets/{MarkdownPreview-BH2iwvle.js → MarkdownPreview-_AXp5G7f.js} +1 -1
- package/dist/client/assets/MarkdownPreview-_AXp5G7f.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-_AXp5G7f.js.gz +0 -0
- package/dist/client/assets/{ProjectIconPickerDialog-Bfkaxcnh.js → ProjectIconPickerDialog-BxjEYsau.js} +1 -1
- package/dist/client/assets/ProjectIconPickerDialog-BxjEYsau.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-BxjEYsau.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js +1 -0
- package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-BB8thfK9.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-Dx-b26uN.js +4 -0
- package/dist/client/assets/ProjectSettings-Dx-b26uN.js.br +0 -0
- package/dist/client/assets/ProjectSettings-Dx-b26uN.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-DiurYeU1.js +25 -0
- package/dist/client/assets/ProjectWorkspace-DiurYeU1.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-DiurYeU1.js.gz +0 -0
- package/dist/client/assets/{QuickOpenDialog-CHjPlBu2.js → QuickOpenDialog-HlkWqVR9.js} +1 -1
- package/dist/client/assets/QuickOpenDialog-HlkWqVR9.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-HlkWqVR9.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-BIdN1YP_.js +2 -0
- package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js +3 -0
- package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-Cb8I-G6m.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-BBLOLjnD.js +2 -0
- package/dist/client/assets/SharedProjectPage-BBLOLjnD.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-BBLOLjnD.js.gz +0 -0
- package/dist/client/assets/{SystemMetricsDialog-DkmBA4o4.js → SystemMetricsDialog-Dr4pYWG6.js} +1 -1
- package/dist/client/assets/SystemMetricsDialog-Dr4pYWG6.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-Dr4pYWG6.js.gz +0 -0
- package/dist/client/assets/{TagManagementDialog-BM1MRuwh.js → TagManagementDialog-D4fYVboy.js} +1 -1
- package/dist/client/assets/TagManagementDialog-D4fYVboy.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-D4fYVboy.js.gz +0 -0
- package/dist/client/assets/{ThemeSwitcher-dcvtWVCO.js → ThemeSwitcher-BgzkYTeA.js} +1 -1
- package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css +1 -0
- package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-Bqzl2256.css.gz +0 -0
- package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js +1 -0
- package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js.br +0 -0
- package/dist/client/assets/TikzGalleryDialog-cPUDQ5Wj.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-AiuR3rra.js +1 -0
- package/dist/client/assets/WordCountDialog-AiuR3rra.js.br +0 -0
- package/dist/client/assets/WordCountDialog-AiuR3rra.js.gz +0 -0
- package/dist/client/assets/{chktex-BrzPYHey.js → chktex--32C-Pkl.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/{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-Dpk6KCs6.js +13 -0
- package/dist/client/assets/i18n-Dpk6KCs6.js.br +0 -0
- package/dist/client/assets/i18n-Dpk6KCs6.js.gz +0 -0
- package/dist/client/assets/index-B1vejuOw.js +2 -0
- package/dist/client/assets/index-B1vejuOw.js.br +0 -0
- package/dist/client/assets/index-B1vejuOw.js.gz +0 -0
- package/dist/client/assets/index-Blr4J_Pq.css +1 -0
- package/dist/client/assets/index-Blr4J_Pq.css.br +0 -0
- package/dist/client/assets/index-Blr4J_Pq.css.gz +0 -0
- package/dist/client/assets/{relativeTime-mmWGtWRR.js → relativeTime-CcP1IEvr.js} +1 -1
- package/dist/client/assets/relativeTime-CcP1IEvr.js.br +0 -0
- package/dist/client/assets/relativeTime-CcP1IEvr.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-EycYBVxj.js +1 -0
- package/dist/client/assets/sourceCursorStore-EycYBVxj.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-EycYBVxj.js.gz +0 -0
- package/dist/client/assets/{spellCheck-BTyLQAFH.js → spellCheck-DpWPgtM7.js} +1 -1
- package/dist/client/assets/spellCheck-DpWPgtM7.js.br +0 -0
- package/dist/client/assets/spellCheck-DpWPgtM7.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-DvxVkRuo.js +1 -0
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-DvxVkRuo.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 -3
- package/dist/server/agentChanges.js +95 -7
- package/dist/server/agents/outputBuffer.js +105 -0
- package/dist/server/agents/sessions.js +33 -16
- package/dist/server/agents/workspaces.js +14 -1
- package/dist/server/app.js +2 -0
- package/dist/server/cli.js +12 -1
- package/dist/server/collaboration.js +9 -0
- package/dist/server/config.js +10 -0
- package/dist/server/db.js +64 -0
- package/dist/server/editHistory.js +68 -20
- package/dist/server/git.js +9 -7
- package/dist/server/history.js +160 -69
- package/dist/server/i18n.js +8 -0
- package/dist/server/locales/zh-Hant.js +4 -0
- package/dist/server/projectMutations.js +4 -0
- package/dist/server/routes/comments.js +7 -2
- package/dist/server/routes/compile.js +56 -4
- package/dist/server/routes/projectFiles.js +54 -0
- package/dist/server/routes/projectGit.js +1 -1
- package/dist/server/routes/projectHistory.js +19 -5
- package/dist/server/routes/system.js +1 -0
- package/dist/server/routes/tikzGallery.js +38 -0
- package/dist/server/tikzEditorAddon.js +115 -0
- package/dist/server/tikzEditorRelease.js +9 -0
- package/dist/server/tikzGallery.js +63 -0
- package/dist/shared/agentMessages.js +3 -0
- package/dist/shared/tikzStandalone.js +15 -0
- package/package.json +2 -1
- package/templates/agents/AGENTS.md +12 -0
- package/texlite.config.example.json +4 -0
- package/dist/client/assets/AdminUsers-DepqkT6m.js +0 -1
- package/dist/client/assets/AdminUsers-DepqkT6m.js.br +0 -0
- package/dist/client/assets/AdminUsers-DepqkT6m.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DeoZDwgh.css.br +0 -0
- package/dist/client/assets/AgentIcon-DeoZDwgh.css.gz +0 -0
- package/dist/client/assets/AgentManagement-DlV6tHez.js.br +0 -0
- package/dist/client/assets/AgentManagement-DlV6tHez.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-CvOz5X_j.js +0 -2
- package/dist/client/assets/AgentTerminal-CvOz5X_j.js.br +0 -0
- package/dist/client/assets/AgentTerminal-CvOz5X_j.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js +0 -16
- package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-C8WQhZBK.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-C8WQhZBK.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-SpudGDwi.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js.gz +0 -0
- package/dist/client/assets/Dashboard-CD1w42mA.js +0 -5
- package/dist/client/assets/Dashboard-CD1w42mA.js.br +0 -0
- package/dist/client/assets/Dashboard-CD1w42mA.js.gz +0 -0
- package/dist/client/assets/GitDialog-DGzZ3GRj.js.br +0 -0
- package/dist/client/assets/GitDialog-DGzZ3GRj.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-CGZl3mcY.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-CGZl3mcY.js.gz +0 -0
- package/dist/client/assets/HistoryDialog-DTZxCgyT.js +0 -8
- package/dist/client/assets/HistoryDialog-DTZxCgyT.js.br +0 -0
- package/dist/client/assets/HistoryDialog-DTZxCgyT.js.gz +0 -0
- package/dist/client/assets/LatexEditor-Boc-45KL.js +0 -25
- package/dist/client/assets/LatexEditor-Boc-45KL.js.br +0 -0
- package/dist/client/assets/LatexEditor-Boc-45KL.js.gz +0 -0
- package/dist/client/assets/MarkdownPreview-BH2iwvle.js.br +0 -0
- package/dist/client/assets/MarkdownPreview-BH2iwvle.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-Bfkaxcnh.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-Bfkaxcnh.js.gz +0 -0
- package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js +0 -1
- package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js.br +0 -0
- package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-ChXx_cmP.js +0 -4
- package/dist/client/assets/ProjectSettings-ChXx_cmP.js.br +0 -0
- package/dist/client/assets/ProjectSettings-ChXx_cmP.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js +0 -25
- package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-CHjPlBu2.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-CHjPlBu2.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-DKcmDg0e.js +0 -2
- package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js +0 -3
- package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-l8GSYTm-.js +0 -2
- package/dist/client/assets/SharedProjectPage-l8GSYTm-.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-l8GSYTm-.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-DkmBA4o4.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-DkmBA4o4.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BM1MRuwh.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BM1MRuwh.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-DI0Jv-fg.js +0 -1
- package/dist/client/assets/WordCountDialog-DI0Jv-fg.js.br +0 -0
- package/dist/client/assets/WordCountDialog-DI0Jv-fg.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/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-Dtn6w-qA.js +0 -13
- package/dist/client/assets/i18n-Dtn6w-qA.js.br +0 -0
- package/dist/client/assets/i18n-Dtn6w-qA.js.gz +0 -0
- package/dist/client/assets/index-BbU2fbRw.css +0 -1
- package/dist/client/assets/index-BbU2fbRw.css.br +0 -0
- package/dist/client/assets/index-BbU2fbRw.css.gz +0 -0
- package/dist/client/assets/index-CPR6YZEf.js +0 -2
- package/dist/client/assets/index-CPR6YZEf.js.br +0 -0
- package/dist/client/assets/index-CPR6YZEf.js.gz +0 -0
- package/dist/client/assets/relativeTime-mmWGtWRR.js.br +0 -0
- package/dist/client/assets/relativeTime-mmWGtWRR.js.gz +0 -0
- package/dist/client/assets/sourceCursorStore-BVDvDKeP.js +0 -1
- package/dist/client/assets/sourceCursorStore-BVDvDKeP.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-BVDvDKeP.js.gz +0 -0
- package/dist/client/assets/spellCheck-BTyLQAFH.js.br +0 -0
- package/dist/client/assets/spellCheck-BTyLQAFH.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-Ba_yhkrl.js +0 -1
- package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.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-CA-PfOka.js → AgentIcon-CjaO3WzI.js} +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js.br → AgentIcon-CjaO3WzI.js.br} +0 -0
- /package/dist/client/assets/{AgentIcon-CA-PfOka.js.gz → AgentIcon-CjaO3WzI.js.gz} +0 -0
|
@@ -10,6 +10,7 @@ import { isCollaborativeTextFile, maxCollaborativeFileBytes } from "../collabora
|
|
|
10
10
|
import { compileMainFile } from "../compileArtifacts.js";
|
|
11
11
|
import { assertNoSourceSymlinks, listProjectFilesAsync, resolveSourcePath, safePathSegment, safeRelativePath, sourceRoot } from "../files.js";
|
|
12
12
|
import { apiError, contentDisposition, httpError } from "../http.js";
|
|
13
|
+
import { moveEditHistoryPaths } from "../editHistory.js";
|
|
13
14
|
import { accessibleProject, canEdit } from "../projects.js";
|
|
14
15
|
import { mainDocumentCandidates } from "../latexRoot.js";
|
|
15
16
|
import { isTextContent } from "../../shared/fileTypes.js";
|
|
@@ -230,6 +231,7 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
230
231
|
hasCommentUpdates = true;
|
|
231
232
|
}
|
|
232
233
|
}
|
|
234
|
+
moveEditHistoryPaths(db, id, (filePath) => movedProjectPath(filePath, source, destination));
|
|
233
235
|
db.exec("COMMIT");
|
|
234
236
|
}
|
|
235
237
|
catch (error) {
|
|
@@ -370,6 +372,42 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
370
372
|
return reply.code(201).send({ ok: true, path: filePath, comments: commentsForFile(db, config, id, filePath) });
|
|
371
373
|
}, { preflight: () => { requireEditableProject(db, id, user); } });
|
|
372
374
|
});
|
|
375
|
+
// Duplicate a file next to itself. The server chooses the name under the
|
|
376
|
+
// write lock, so two quick copies cannot race for the same "(copy)" name.
|
|
377
|
+
app.post("/api/projects/:id/file/copy", async (request, reply) => {
|
|
378
|
+
const user = requireUser(request, reply, db);
|
|
379
|
+
if (!user)
|
|
380
|
+
return;
|
|
381
|
+
const { id } = request.params;
|
|
382
|
+
if (collaboration.isMaintaining(id))
|
|
383
|
+
return apiError(reply, 409, "PROJECT_BUSY");
|
|
384
|
+
const project = accessibleProject(db, id, user);
|
|
385
|
+
if (!project || !canEdit(project))
|
|
386
|
+
return apiError(reply, 403, "PROJECT_EDIT_FORBIDDEN");
|
|
387
|
+
const body = request.body;
|
|
388
|
+
const source = safeRelativePath(typeof body.path === "string" ? body.path : "");
|
|
389
|
+
return await projectMutations.runWrite(id, () => {
|
|
390
|
+
assertNoSourceSymlinks(config, id);
|
|
391
|
+
// runWrite() has flushed live Yjs edits, so the copy has the text
|
|
392
|
+
// collaborators currently see rather than an older file on disk.
|
|
393
|
+
const sourceAbsolute = resolveSourcePath(config, id, source);
|
|
394
|
+
if (!fs.existsSync(sourceAbsolute) || !fs.statSync(sourceAbsolute).isFile()) {
|
|
395
|
+
return apiError(reply, 404, "FILE_NOT_FOUND", { path: source });
|
|
396
|
+
}
|
|
397
|
+
const destination = copiedFilePath(source, (candidate) => fs.existsSync(resolveSourcePath(config, id, candidate)));
|
|
398
|
+
const destinationAbsolute = resolveSourcePath(config, id, destination);
|
|
399
|
+
fs.copyFileSync(sourceAbsolute, destinationAbsolute, fs.constants.COPYFILE_EXCL);
|
|
400
|
+
touchProject(db, id, user.id);
|
|
401
|
+
const bytes = isCollaborativeTextFile(destination) && fs.statSync(destinationAbsolute).size <= maxCollaborativeFileBytes(config)
|
|
402
|
+
? fs.readFileSync(destinationAbsolute) : null;
|
|
403
|
+
if (bytes !== null && isTextContent(bytes))
|
|
404
|
+
collaboration.updateFile(id, destination, bytes.toString("utf8"), user.id);
|
|
405
|
+
else
|
|
406
|
+
collaboration.invalidateSourceTree(id, destination);
|
|
407
|
+
recordHistory(id, user.id, "file", [destination]);
|
|
408
|
+
return reply.code(201).send({ ok: true, path: destination });
|
|
409
|
+
}, { preflight: () => { requireEditableProject(db, id, user); } });
|
|
410
|
+
});
|
|
373
411
|
app.put("/api/projects/:id/file", async (request, reply) => {
|
|
374
412
|
const user = requireUser(request, reply, db);
|
|
375
413
|
if (!user)
|
|
@@ -569,3 +607,19 @@ export function registerProjectFileRoutes(app, context) {
|
|
|
569
607
|
}
|
|
570
608
|
});
|
|
571
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* Name a copy beside its source: `main.tex` becomes `main (copy).tex`, then
|
|
612
|
+
* `main (copy 2).tex`. A leading dot is part of the name, not an extension.
|
|
613
|
+
*/
|
|
614
|
+
export function copiedFilePath(source, exists) {
|
|
615
|
+
const slash = source.lastIndexOf("/");
|
|
616
|
+
const directory = slash < 0 ? "" : source.slice(0, slash + 1);
|
|
617
|
+
const name = source.slice(slash + 1);
|
|
618
|
+
const dot = name.lastIndexOf(".");
|
|
619
|
+
const [stem, extension] = dot > 0 ? [name.slice(0, dot), name.slice(dot)] : [name, ""];
|
|
620
|
+
for (let attempt = 1;; attempt += 1) {
|
|
621
|
+
const candidate = `${directory}${stem} (copy${attempt === 1 ? "" : ` ${attempt}`})${extension}`;
|
|
622
|
+
if (!exists(candidate))
|
|
623
|
+
return candidate;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
@@ -75,7 +75,7 @@ export function registerProjectGitRoutes(app, context) {
|
|
|
75
75
|
if (collaboration.isMaintaining(id))
|
|
76
76
|
return apiError(reply, 409, "PROJECT_BUSY");
|
|
77
77
|
const body = request.body;
|
|
78
|
-
return await projectMutations.
|
|
78
|
+
return await projectMutations.runConsistentRead(id, async () => {
|
|
79
79
|
const project = requireGitOwner(id, user);
|
|
80
80
|
const commit = await projectGit.commit(project, user, typeof body.message === "string" ? body.message : "");
|
|
81
81
|
return reply.code(201).send({ commit, status: await projectGit.status(project) });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { requireUser } from "../auth.js";
|
|
3
3
|
import { isCollaborativeTextFile, maxCollaborativeFileBytes } from "../collaboration.js";
|
|
4
|
-
import {
|
|
4
|
+
import { normalizeAgentChangeLineEndings } from "../agentChanges.js";
|
|
5
|
+
import { hashText, MAX_SELECTION_HISTORY_OFFSET } from "../editHistory.js";
|
|
5
6
|
import { HISTORY_RETENTION_DELAY_MS } from "../historyRetention.js";
|
|
6
7
|
import { resolveSourcePath, safeRelativePath } from "../files.js";
|
|
7
8
|
import { apiError, httpError } from "../http.js";
|
|
@@ -65,6 +66,9 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
65
66
|
if (start === null || end === null || start === end)
|
|
66
67
|
return apiError(reply, 400, "REQUEST_INVALID");
|
|
67
68
|
const requestedLimit = parseOffset(query.limit);
|
|
69
|
+
const offset = query.offset === undefined ? 0 : parseOffset(query.offset);
|
|
70
|
+
if (offset === null || offset > MAX_SELECTION_HISTORY_OFFSET)
|
|
71
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
68
72
|
return await projectMutations.runConsistentRead(id, () => {
|
|
69
73
|
const source = resolveSourcePath(config, id, filePath);
|
|
70
74
|
if (!fs.existsSync(source) || !fs.statSync(source).isFile())
|
|
@@ -76,7 +80,7 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
76
80
|
return apiError(reply, 409, "SELECTION_HISTORY_SOURCE_CHANGED");
|
|
77
81
|
if (start > end || end > content.length)
|
|
78
82
|
return apiError(reply, 400, "REQUEST_INVALID");
|
|
79
|
-
return editHistory.selectionHistory(id, filePath, content, start, end, requestedLimit ?? undefined);
|
|
83
|
+
return editHistory.selectionHistory(id, filePath, content, start, end, requestedLimit ?? undefined, offset);
|
|
80
84
|
}, { preflight: () => {
|
|
81
85
|
if (!accessibleProject(db, id, user))
|
|
82
86
|
throw httpError(404, "PROJECT_NOT_FOUND");
|
|
@@ -94,10 +98,18 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
94
98
|
const { id } = request.params;
|
|
95
99
|
if (!accessibleProject(db, id, user))
|
|
96
100
|
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
97
|
-
|
|
101
|
+
// Everything below is synchronous, so no autosave can interleave with it.
|
|
102
|
+
return await projectMutations.runSnapshot(id, () => {
|
|
98
103
|
const paths = db.prepare(`SELECT DISTINCT file_path FROM project_edit_segments
|
|
99
104
|
WHERE project_id = ? AND author_id = ? AND has_agent = 1 ORDER BY file_path LIMIT ?`)
|
|
100
105
|
.all(id, user.id, MAX_AGENT_CHANGE_FILES).map((row) => row.file_path);
|
|
106
|
+
// A running agent's newest write may not have reached the edit chain yet.
|
|
107
|
+
// Its file would not match the chain's end and look as if it had no changes.
|
|
108
|
+
try {
|
|
109
|
+
projectMutations.reconcileExternalSources(id, paths);
|
|
110
|
+
}
|
|
111
|
+
catch { /* The writer's next scan reports this and stops the task. */ }
|
|
112
|
+
projectMutations.flushProject(id);
|
|
101
113
|
const files = [];
|
|
102
114
|
for (const filePath of paths) {
|
|
103
115
|
if (!isCollaborativeTextFile(filePath))
|
|
@@ -113,8 +125,10 @@ export function registerProjectHistoryRoutes(app, context) {
|
|
|
113
125
|
continue;
|
|
114
126
|
const content = fs.readFileSync(source, "utf8");
|
|
115
127
|
const changes = editHistory.agentChanges(id, filePath, content, user.id);
|
|
116
|
-
if (changes.length)
|
|
117
|
-
|
|
128
|
+
if (changes.length) {
|
|
129
|
+
const normalized = normalizeAgentChangeLineEndings(changes, content);
|
|
130
|
+
files.push({ path: filePath, sourceHash: hashText(normalized.source), changes: [...normalized.changes] });
|
|
131
|
+
}
|
|
118
132
|
}
|
|
119
133
|
return { files };
|
|
120
134
|
}, { preflight: () => {
|
|
@@ -43,6 +43,7 @@ export function registerSystemRoutes(app, context) {
|
|
|
43
43
|
maxUploadSizeMB: Math.floor(config.maxUploadBytes / 1024 / 1024),
|
|
44
44
|
maxCollaborativeFileSizeMB: Math.floor(maxCollaborativeFileBytes(config) / 1024 / 1024),
|
|
45
45
|
allowedEngines: config.allowedEngines,
|
|
46
|
+
tikzGalleryEnabled: config.tikzGalleryEnabled,
|
|
46
47
|
allowProjectLatexmkrc: config.allowProjectLatexmkrc
|
|
47
48
|
}));
|
|
48
49
|
app.get("/api/health", async () => ({ ok: true, pid: process.pid, latexmk: config.latexmk }));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { requireUser } from "../auth.js";
|
|
3
|
+
import { apiError } from "../http.js";
|
|
4
|
+
import { TikzGalleryLibrary } from "../tikzGallery.js";
|
|
5
|
+
/** A preview comes from a repository this host only chose, not wrote: opened directly, it must not run as TexLite. */
|
|
6
|
+
const SVG_CSP = "default-src 'none'; style-src 'unsafe-inline'; sandbox";
|
|
7
|
+
export function registerTikzGalleryRoutes(app, { config, db }) {
|
|
8
|
+
const library = new TikzGalleryLibrary(config.tikzGalleryDir);
|
|
9
|
+
app.get("/api/tikz-gallery/catalog", async (request, reply) => {
|
|
10
|
+
if (!requireUser(request, reply, db))
|
|
11
|
+
return;
|
|
12
|
+
if (!config.tikzGalleryEnabled)
|
|
13
|
+
return apiError(reply, 404, "TIKZ_GALLERY_DISABLED");
|
|
14
|
+
const result = library.catalog();
|
|
15
|
+
if (result.status === "unavailable")
|
|
16
|
+
return apiError(reply, 503, "TIKZ_GALLERY_UNAVAILABLE");
|
|
17
|
+
if (result.status === "incompatible")
|
|
18
|
+
return apiError(reply, 409, "TIKZ_GALLERY_INCOMPATIBLE");
|
|
19
|
+
reply.header("Cache-Control", "no-store");
|
|
20
|
+
return result.catalog;
|
|
21
|
+
});
|
|
22
|
+
app.get("/api/tikz-gallery/file", async (request, reply) => {
|
|
23
|
+
if (!requireUser(request, reply, db))
|
|
24
|
+
return;
|
|
25
|
+
if (!config.tikzGalleryEnabled)
|
|
26
|
+
return apiError(reply, 404, "TIKZ_GALLERY_DISABLED");
|
|
27
|
+
const { path: relative } = request.query;
|
|
28
|
+
const file = typeof relative === "string" ? library.listedFile(relative) : null;
|
|
29
|
+
if (!file)
|
|
30
|
+
return apiError(reply, 404, "FILE_NOT_FOUND");
|
|
31
|
+
reply.header("Cache-Control", "private, max-age=300").header("X-Content-Type-Options", "nosniff");
|
|
32
|
+
if (/\.svg$/i.test(file))
|
|
33
|
+
reply.header("Content-Security-Policy", SVG_CSP).type("image/svg+xml");
|
|
34
|
+
else
|
|
35
|
+
reply.type("text/plain; charset=utf-8");
|
|
36
|
+
return reply.send(fs.readFileSync(file));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { Readable } from "node:stream";
|
|
6
|
+
import { pipeline } from "node:stream/promises";
|
|
7
|
+
import { TIKZ_BRIDGE_PROTOCOL } from "../shared/tikzStandalone.js";
|
|
8
|
+
import { TIKZ_EDITOR_RELEASE } from "./tikzEditorRelease.js";
|
|
9
|
+
const REPOSITORY_URL = "https://github.com/SWUFE-DB-Group/TexLite";
|
|
10
|
+
const DOWNLOAD_TIMEOUT_MS = 10 * 60_000;
|
|
11
|
+
const MANIFEST = "texlite-bridge.json";
|
|
12
|
+
/** Kept with the instance's data so it survives upgrades of the npm package. */
|
|
13
|
+
export function tikzEditorDirectory(dataDir) {
|
|
14
|
+
return path.join(dataDir, "addons", "tikz-editor");
|
|
15
|
+
}
|
|
16
|
+
export function tikzEditorDownloadUrl(release = TIKZ_EDITOR_RELEASE) {
|
|
17
|
+
return `${REPOSITORY_URL}/releases/download/${release.tag}/${release.asset}`;
|
|
18
|
+
}
|
|
19
|
+
function readManifest(directory) {
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(directory, MANIFEST), "utf8"));
|
|
22
|
+
return typeof parsed.protocol === "number" && typeof parsed.commit === "string" && typeof parsed.version === "string" && typeof parsed.build === "string"
|
|
23
|
+
? { protocol: parsed.protocol, commit: parsed.commit, version: parsed.version, build: parsed.build }
|
|
24
|
+
: null;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function installedTikzEditor(dataDir) {
|
|
31
|
+
return readManifest(tikzEditorDirectory(dataDir));
|
|
32
|
+
}
|
|
33
|
+
async function download(url, destination, fetcher) {
|
|
34
|
+
let response;
|
|
35
|
+
try {
|
|
36
|
+
response = await fetcher(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
throw new Error(`Could not download ${url}: ${error instanceof Error ? error.message : String(error)}. Without access to GitHub, fetch it elsewhere and use --file.`);
|
|
40
|
+
}
|
|
41
|
+
if (!response.ok || !response.body)
|
|
42
|
+
throw new Error(`Could not download ${url} (HTTP ${response.status}). Without access to GitHub, fetch it elsewhere and use --file.`);
|
|
43
|
+
await pipeline(Readable.fromWeb(response.body), fs.createWriteStream(destination));
|
|
44
|
+
}
|
|
45
|
+
async function sha256(file) {
|
|
46
|
+
const hash = createHash("sha256");
|
|
47
|
+
await pipeline(fs.createReadStream(file), hash);
|
|
48
|
+
return hash.digest("hex");
|
|
49
|
+
}
|
|
50
|
+
function extract(archive, destination) {
|
|
51
|
+
fs.mkdirSync(destination);
|
|
52
|
+
const result = spawnSync("tar", ["-xzf", archive, "--no-same-owner", "-C", destination], { encoding: "utf8" });
|
|
53
|
+
if (result.error)
|
|
54
|
+
throw new Error(`Could not run tar to unpack the editor: ${result.error.message}`);
|
|
55
|
+
if (result.status !== 0)
|
|
56
|
+
throw new Error(`Could not unpack the editor: ${result.stderr.trim()}`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Verifies the archive against the digest pinned in this TexLite version, then
|
|
60
|
+
* swaps it in whole, so a failure leaves any existing install untouched. A
|
|
61
|
+
* running server picks up the new files without a restart.
|
|
62
|
+
*/
|
|
63
|
+
export async function installTikzEditor(dataDir, options = {}) {
|
|
64
|
+
const release = options.release ?? TIKZ_EDITOR_RELEASE;
|
|
65
|
+
if (!options.file && !release.sha256)
|
|
66
|
+
throw new Error("This TexLite build has no TikZ Editor release pinned.");
|
|
67
|
+
const target = tikzEditorDirectory(dataDir);
|
|
68
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
69
|
+
const work = fs.mkdtempSync(path.join(path.dirname(target), ".install-"));
|
|
70
|
+
try {
|
|
71
|
+
let archive = options.file ? path.resolve(options.file) : path.join(work, release.asset);
|
|
72
|
+
if (options.file) {
|
|
73
|
+
if (!fs.existsSync(archive))
|
|
74
|
+
throw new Error(`File not found: ${archive}`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const url = tikzEditorDownloadUrl(release);
|
|
78
|
+
options.onDownload?.(url);
|
|
79
|
+
await download(url, archive, options.fetcher ?? fetch);
|
|
80
|
+
}
|
|
81
|
+
const actual = await sha256(archive);
|
|
82
|
+
if (actual !== release.sha256) {
|
|
83
|
+
throw new Error(`The archive is not the TikZ Editor build for this TexLite version (expected ${release.asset}, SHA-256 ${release.sha256}, got ${actual}).`);
|
|
84
|
+
}
|
|
85
|
+
const staged = path.join(work, "editor");
|
|
86
|
+
extract(archive, staged);
|
|
87
|
+
const manifest = readManifest(staged);
|
|
88
|
+
if (!manifest || manifest.protocol !== TIKZ_BRIDGE_PROTOCOL || manifest.build !== release.build || !fs.existsSync(path.join(staged, "index.html"))) {
|
|
89
|
+
throw new Error("The archive does not contain a compatible TikZ Editor build.");
|
|
90
|
+
}
|
|
91
|
+
const previous = path.join(work, "previous");
|
|
92
|
+
const replacing = fs.existsSync(target);
|
|
93
|
+
if (replacing)
|
|
94
|
+
fs.renameSync(target, previous);
|
|
95
|
+
try {
|
|
96
|
+
fs.renameSync(staged, target);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (replacing)
|
|
100
|
+
fs.renameSync(previous, target);
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
return manifest;
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
fs.rmSync(work, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** Returns whether an editor was installed. */
|
|
110
|
+
export function removeTikzEditor(dataDir) {
|
|
111
|
+
const target = tikzEditorDirectory(dataDir);
|
|
112
|
+
const installed = readManifest(target) !== null;
|
|
113
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
114
|
+
return installed;
|
|
115
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Written by scripts/build-tikz-editor.mjs. Do not edit by hand.
|
|
2
|
+
export const TIKZ_EDITOR_RELEASE = {
|
|
3
|
+
version: "1.1.0",
|
|
4
|
+
commit: "2056d9649e89312041ab8353845ec7addc2a8304",
|
|
5
|
+
build: "a2398522",
|
|
6
|
+
tag: "tikz-editor-1.1.0-2056d96-a2398522",
|
|
7
|
+
asset: "tikz-editor-1.1.0-2056d96-a2398522.tar.gz",
|
|
8
|
+
sha256: "f3feb955a7fd2d7fa47746271f663642bd956423389ceddfed40d0c30d5197d4"
|
|
9
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/** The catalog format this TexLite can read; see the add-on's README. */
|
|
4
|
+
const SUPPORTED_CATALOG_VERSION = 1;
|
|
5
|
+
const MAX_FIGURE_FILE_BYTES = 16 * 1024 * 1024;
|
|
6
|
+
/** A file inside `root` once symbolic links are followed, or null. */
|
|
7
|
+
function containedFile(root, relative) {
|
|
8
|
+
try {
|
|
9
|
+
const realRoot = fs.realpathSync(root);
|
|
10
|
+
const real = fs.realpathSync(path.resolve(realRoot, relative));
|
|
11
|
+
return real.startsWith(`${realRoot}${path.sep}`) && fs.statSync(real).isFile() ? real : null;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isCatalog(value) {
|
|
18
|
+
const catalog = value;
|
|
19
|
+
return typeof catalog === "object" && catalog !== null && catalog.version === SUPPORTED_CATALOG_VERSION && Array.isArray(catalog.items)
|
|
20
|
+
&& catalog.items.every((item) => typeof item?.tex === "string" && typeof item.preview === "string");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Reads the add-on an administrator placed on this host. The directory is a
|
|
24
|
+
* whole repository, so only the files its catalog lists are ever exposed. It
|
|
25
|
+
* is read per request (the parse is cached) so `git pull` needs no restart.
|
|
26
|
+
*/
|
|
27
|
+
export class TikzGalleryLibrary {
|
|
28
|
+
directory;
|
|
29
|
+
cached = null;
|
|
30
|
+
constructor(directory) {
|
|
31
|
+
this.directory = directory;
|
|
32
|
+
}
|
|
33
|
+
load() {
|
|
34
|
+
const file = containedFile(this.directory, "catalog.json");
|
|
35
|
+
if (!file)
|
|
36
|
+
return { result: { status: "unavailable" }, listed: new Set() };
|
|
37
|
+
const stat = fs.statSync(file);
|
|
38
|
+
const stamp = `${stat.mtimeMs}:${stat.size}`;
|
|
39
|
+
if (this.cached?.stamp === stamp)
|
|
40
|
+
return this.cached;
|
|
41
|
+
let parsed;
|
|
42
|
+
try {
|
|
43
|
+
parsed = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
parsed = null;
|
|
47
|
+
}
|
|
48
|
+
const result = isCatalog(parsed) ? { status: "ok", catalog: parsed } : { status: "incompatible" };
|
|
49
|
+
const listed = new Set(result.status === "ok" ? result.catalog.items.flatMap(({ tex, preview }) => [tex, preview]) : []);
|
|
50
|
+
this.cached = { stamp, result, listed };
|
|
51
|
+
return this.cached;
|
|
52
|
+
}
|
|
53
|
+
catalog() {
|
|
54
|
+
return this.load().result;
|
|
55
|
+
}
|
|
56
|
+
/** The path of a figure source or preview the catalog lists, or null. */
|
|
57
|
+
listedFile(relative) {
|
|
58
|
+
if (!this.load().listed.has(relative) || !/\.(?:tex|svg)$/i.test(relative))
|
|
59
|
+
return null;
|
|
60
|
+
const file = containedFile(this.directory, relative);
|
|
61
|
+
return file && fs.statSync(file).size <= MAX_FIGURE_FILE_BYTES ? file : null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -8,6 +8,7 @@ export const agentMessages = {
|
|
|
8
8
|
AGENT_SESSION_BUSY: "Wait for the current task operation to finish.",
|
|
9
9
|
AGENT_PROJECT_BUSY: "Another agent task is active in this project. It must end before another can start; hiding the terminal does not stop it.",
|
|
10
10
|
AGENT_SYNC_FAILED: "External file synchronization failed. The agent has been stopped; check the project files and server logs.",
|
|
11
|
+
AGENT_STOPPED_BY_PROJECT_OPERATION: "A project operation ended this agent task's execution.",
|
|
11
12
|
AGENT_SYNC_CONFLICT: "Concurrent edits conflicted. The editor version was preserved and agent files were saved under .texlite-agent-conflicts in this project. The agent has been stopped.",
|
|
12
13
|
AGENT_NO_CONTEXT: "This task's saved conversation cannot be resumed. Create a new task with + to start a new conversation.",
|
|
13
14
|
AGENT_CONTEXT_CHECK_FAILED: "The task's saved conversation could not be verified. Retry, or check the agent's installation and task data. No new conversation was started.",
|
|
@@ -24,6 +25,7 @@ export const agentMessages = {
|
|
|
24
25
|
AGENT_SESSION_BUSY: "请等待当前任务操作完成。",
|
|
25
26
|
AGENT_PROJECT_BUSY: "本项目已有 Agent 任务在运行,需先结束该任务才能启动其他任务;收起终端不会停止任务。",
|
|
26
27
|
AGENT_SYNC_FAILED: "外部文件同步失败,Agent 已停止。请检查项目文件和服务器日志。",
|
|
28
|
+
AGENT_STOPPED_BY_PROJECT_OPERATION: "项目操作已结束此 Agent 任务的运行。",
|
|
27
29
|
AGENT_SYNC_CONFLICT: "并发修改存在冲突。已保留编辑器版本,Agent 的文件已保存在本项目的 .texlite-agent-conflicts 目录中,Agent 已停止。",
|
|
28
30
|
AGENT_NO_CONTEXT: "无法恢复此任务的对话。请通过+新建任务以开始新对话。",
|
|
29
31
|
AGENT_CONTEXT_CHECK_FAILED: "无法确认此任务的对话状态。请重试,或检查 Agent 安装及任务数据;尚未创建新对话。",
|
|
@@ -40,6 +42,7 @@ export const agentMessages = {
|
|
|
40
42
|
AGENT_SESSION_BUSY: "請等待目前任務操作完成。",
|
|
41
43
|
AGENT_PROJECT_BUSY: "此專案已有 Agent 任務正在執行,須先結束該任務才能啟動其他任務;收起終端機不會停止任務。",
|
|
42
44
|
AGENT_SYNC_FAILED: "外部檔案同步失敗,Agent 已停止。請檢查專案檔案與伺服器日誌。",
|
|
45
|
+
AGENT_STOPPED_BY_PROJECT_OPERATION: "專案操作已結束此 Agent 任務的執行。",
|
|
43
46
|
AGENT_SYNC_CONFLICT: "並行修改發生衝突。已保留編輯器版本,Agent 的檔案已儲存於此專案的 .texlite-agent-conflicts 目錄中,Agent 已停止。",
|
|
44
47
|
AGENT_NO_CONTEXT: "無法恢復此任務的對話。請透過+新增任務以開始新對話。",
|
|
45
48
|
AGENT_CONTEXT_CHECK_FAILED: "無法確認此任務的對話狀態。請重試,或檢查 Agent 安裝及任務資料;尚未建立新對話。",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { maskLatexComments, maskLatexLiteralContent } from "./latexLiterals.js";
|
|
2
|
+
/**
|
|
3
|
+
* A complete `standalone` document that draws with TikZ, as opposed to a main
|
|
4
|
+
* document. Comments and verbatim examples do not count.
|
|
5
|
+
*/
|
|
6
|
+
export function isStandaloneTikz(source) {
|
|
7
|
+
if (!source.includes("standalone"))
|
|
8
|
+
return false;
|
|
9
|
+
const visible = maskLatexComments(maskLatexLiteralContent(source));
|
|
10
|
+
const declaration = /\\documentclass(?![A-Za-z@])\s*(?:\[([^\]]*)\]\s*)?\{\s*standalone\s*\}/.exec(visible);
|
|
11
|
+
if (!declaration)
|
|
12
|
+
return false;
|
|
13
|
+
return (declaration[1] ?? "").split(",").some((option) => option.trim() === "tikz")
|
|
14
|
+
|| /\\begin\s*\{tikzpicture\}/.test(visible);
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "texlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "A lightweight local-first collaborative LaTeX workspace",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"OPERATIONS.md",
|
|
29
29
|
"DESIGN.md",
|
|
30
30
|
"NPM_TESTING.md",
|
|
31
|
+
"addon.md",
|
|
31
32
|
"LICENSE",
|
|
32
33
|
"THIRD_PARTY_NOTICES.md",
|
|
33
34
|
"texlite.config.example.json"
|
|
@@ -130,6 +130,18 @@ file modification times or treating an older retained PDF as the latest result.
|
|
|
130
130
|
- Summarize the files changed and checks performed. If you did not recompile,
|
|
131
131
|
or could not verify a fix, state that explicitly.
|
|
132
132
|
|
|
133
|
+
## TikZ and pgfplots figures
|
|
134
|
+
|
|
135
|
+
Before creating or substantially editing a TikZ or pgfplots figure, read
|
|
136
|
+
`tikzGuide` from the JSON file named by `TEXLITE_PROJECT_CONTEXT`. If it is a
|
|
137
|
+
path, TexLite's figure library is installed: read that file and follow it for the
|
|
138
|
+
figure work. If it is `null` or missing, continue without it.
|
|
139
|
+
|
|
140
|
+
That file and the library directory containing it are a read-only exception to
|
|
141
|
+
working in this project's source tree. Copy what you need into the project and
|
|
142
|
+
never change anything in the library. The guide applies only to figure work and
|
|
143
|
+
does not change the rest of these instructions.
|
|
144
|
+
|
|
133
145
|
This file was copied from TexLite's default template because the project had
|
|
134
146
|
no root `AGENTS.md`. Project maintainers can edit it; TexLite does not overwrite
|
|
135
147
|
an existing file.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{i as t,t as n}from"./react-DUEFWlB7.js";import{_ as r}from"./relativeTime-mmWGtWRR.js";import{t as i}from"./useTranslation-DwkoADSz.js";import{t as a}from"./createLucideIcon-CDYIzuiB.js";import{H as o,S as ee,T as te,U as ne,d as re,x as s,z as ie}from"./useDeletionTransitions-Ba_yhkrl.js";import{t as ae}from"./circle-check-CunlnBPw.js";import{t as oe}from"./InfoPopover-Ba7GvcuW.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{g as d,h as ce,w as f,y as p}from"./index-CPR6YZEf.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=a(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=a(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:a}=i(),[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),f(`/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(p(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(a(`auth.passwordMinimum`,{count:t}));j(!0),N(``),k.clear();try{await f(`/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(p(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 f(`/api/admin/users/${e.id}`,{method:`PATCH`,body:JSON.stringify(n)}),$(),Y(null)}catch(e){Z(p(e))}finally{Se(!1)}},Oe=async()=>{if(L&&z&&!A){if(z.length<t)return N(a(`auth.passwordMinimum`,{count:t}));j(!0),N(``),k.clear();try{await f(`/api/admin/users/${L.id}`,{method:`PATCH`,body:JSON.stringify({password:z})}),k.show(`reset:${L.id}`),R(null),B(``)}catch(e){N(p(e))}finally{j(!1)}}},ke=async()=>{if(H&&!K){be(!0),q(``);try{await f(`/api/admin/users/${H.id}`,{method:`DELETE`,body:JSON.stringify({deleteProjects:W})}),U(null),G(!1),$()}catch(e){q(p(e))}finally{be(!1)}}},Ae=[{key:`totalUsers`,detail:b?a(`users.summary.administrators`,{count:b.administrators}):``},{key:`projectCreators`,detail:b?a(`users.summary.ofUsers`,{count:b.totalUsers}):``},{key:`totalProjects`,detail:b?a(`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}),a(`users.manage`)]}),(0,v.jsx)(`p`,{className:`muted`,children:a(`users.onlyAdmin`)})]}),(0,v.jsxs)(`button`,{type:`button`,className:`dashboard-back-button`,onClick:n,children:[(0,v.jsx)(ne,{size:14}),a(`navigation.backToProjects`)]})]}),(0,v.jsxs)(`div`,{className:`admin-user-layout`,children:[(0,v.jsx)(`dl`,{className:`admin-user-summary`,"aria-label":a(`users.overview`),children:Ae.map(({key:e,detail:t})=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{children:a(`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":a(`users.searchPlaceholder`),placeholder:a(`users.searchPlaceholder`),value:x,onChange:e=>{S(e.target.value),w(1)}}),x&&(0,v.jsx)(`button`,{type:`button`,"aria-label":a(`users.clearSearch`),title:a(`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:a(`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:a(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:a(`common.user`)}),(0,v.jsx)(`th`,{children:a(`users.role`)}),(0,v.jsx)(`th`,{children:a(`users.createProjects`)}),(0,v.jsx)(`th`,{children:a(`users.ownedProjects`)}),(0,v.jsx)(`th`,{children:a(`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}),a(`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:a(`users.loadFailed`)}),(0,v.jsx)(`button`,{type:`button`,onClick:$,children:a(`common.retry`)})]})}):m.length===0?(0,v.jsx)(`tr`,{children:(0,v.jsx)(`td`,{colSpan:5,className:`admin-user-list-state`,children:a(Q?`users.noMatches`:`users.empty`)})}):m.map(t=>{let n=t.id===e.id,r=A||X,i=ye===t.id,o=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)(re,{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:a(`users.selfProtected`),children:[(0,v.jsx)(l,{size:12,"aria-hidden":!0}),a(`common.admin`)]}):(0,v.jsxs)(`select`,{className:`admin-user-role`,"aria-label":a(`users.roleFor`,{username:t.username}),value:t.role,disabled:r,onChange:()=>void Te(t),children:[(0,v.jsx)(`option`,{value:`user`,children:a(`common.user`)}),(0,v.jsx)(`option`,{value:`admin`,children:a(`common.admin`)})]})}),(0,v.jsx)(`td`,{children:t.role===`admin`?(0,v.jsxs)(`span`,{className:`admin-user-locked`,title:a(`users.adminCreation`),children:[(0,v.jsx)(l,{size:12,"aria-hidden":!0}),a(`users.alwaysAllowed`)]}):(0,v.jsx)(`button`,{type:`button`,className:`admin-user-switch`,role:`switch`,"aria-checked":t.canCreateProjects,"aria-label":a(`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:a(o?`common.done`:`users.resetPassword`),"aria-label":a(`users.resetPassword`),onClick:()=>{k.clear(),R(t),B(``),N(``)},children:[o?(0,v.jsx)(ae,{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:o?a(`common.done`):``})]}),!n&&(0,v.jsx)(`button`,{type:`button`,className:`icon-button danger-text`,disabled:r,title:a(`users.deleteTitle`),"aria-label":a(`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":a(`users.actionsFor`,{username:t.username}),"aria-expanded":i,"aria-controls":`user-actions-${t.id}`,onClick:()=>V(i?null:t.id),children:(0,v.jsx)(ie,{size:17,"aria-hidden":!0})})]})})]},t.id)})})]})}),T.totalPages>1&&(0,v.jsxs)(`nav`,{className:`project-pagination admin-user-pagination`,"aria-label":a(`users.pagination`),children:[(0,v.jsxs)(`button`,{type:`button`,disabled:E||D||T.page<=1,onClick:()=>w(T.page-1),children:[(0,v.jsx)(r,{size:15}),a(`users.previousPage`)]}),(0,v.jsx)(`span`,{children:a(`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:[a(`users.nextPage`),(0,v.jsx)(o,{size:15})]})]})]})]}),(0,v.jsxs)(d,{className:`management-dialog`,open:ve,title:a(`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}),a(`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}),a(`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:[a(`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:[a(`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:a(`users.initialPassword`)}),(0,v.jsx)(oe,{content:a(`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:a(`users.generatePassword`),onClick:()=>I({...F,password:y()}),children:[(0,v.jsx)(ue,{size:15}),a(`users.randomPassword`)]})]}),(0,v.jsx)(`small`,{className:`field-hint`,children:a(`auth.passwordMinimum`,{count:t})})]}),(0,v.jsxs)(`label`,{className:`form-field`,children:[a(`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:a(`common.user`)}),(0,v.jsx)(`option`,{value:`admin`,children:a(`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})}),` `,a(`users.allowCreate`)]})]})]}),(0,v.jsxs)(d,{className:`management-dialog`,open:!!L,title:a(`users.resetPassword`),description:a(`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}),a(`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}),a(`users.reset`)]})]}),children:[M&&(0,v.jsx)(`p`,{className:`error`,role:`alert`,children:M}),(0,v.jsxs)(`label`,{className:`form-field`,children:[a(`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}),a(`users.randomPassword`)]})]}),(0,v.jsx)(`small`,{className:`field-hint`,children:a(`auth.passwordMinimum`,{count:t})})]})]}),(0,v.jsx)(d,{className:`management-dialog`,open:!!H,title:a(`users.deleteTitle`),description:a(`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}),a(`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}),a(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:a(`users.ownedChoice`,{count:H?.ownedProjects??0})}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`input`,{type:`radio`,checked:!W,onChange:()=>G(!1)}),` `,a(`users.transferProjects`)]}),(0,v.jsxs)(`label`,{children:[(0,v.jsx)(`input`,{type:`radio`,checked:W,onChange:()=>G(!0)}),` `,a(`users.deleteProjects`)]})]})]})}),(0,v.jsx)(ce,{open:!!J,title:a(`userConfirmations.${J?.setting??`demote`}Title`),description:a(`userConfirmations.${J?.setting??`demote`}Description`,{username:J?.target.username??``}),confirmLabel:a(`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};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./AgentTerminalSurface-COqg_GdK.js","./rolldown-runtime-XKyaHtl9.js","./react-DUEFWlB7.js","./relativeTime-mmWGtWRR.js","./i18nInstance-CIMFwH0l.js","./useTranslation-DwkoADSz.js","./basePath-B5-c90eh.js","./createLucideIcon-CDYIzuiB.js","./useDeletionTransitions-Ba_yhkrl.js","./dist-B_WjsTVV.js","./es2015-D2UDOM09.js","./index-CPR6YZEf.js","./i18n-Dtn6w-qA.js","./vite-runtime-CRzLMJPS.js","./loader-circle-DKGyi5EK.js","./dist-DdUqlCPw.js","./index-BbU2fbRw.css","./AgentIcon-CA-PfOka.js","./AgentIcon-DeoZDwgh.css","./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{_ as r,d as i,m as a,r as o,u as s}from"./relativeTime-mmWGtWRR.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{E as d,H as f,P as p,T as m,c as h,w as g,x as _}from"./useDeletionTransitions-Ba_yhkrl.js";import{t as v}from"./check-Dw16EqG-.js";import{o as y}from"./dist-B_WjsTVV.js";import{t as b}from"./chevron-up-BHaMUEEA.js";import{i as x,n as S,t as C}from"./AgentIcon-CA-PfOka.js";import{S as ee}from"./sourceCursorStore-BVDvDKeP.js";import{t as w}from"./git-compare-arrows-158rS_vn.js";import{t as T}from"./InfoPopover-Ba7GvcuW.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{g as re,w as O,y as k}from"./index-CPR6YZEf.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-B-w2ix8N.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 V(e){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)({tasks:[],page:1,pageSize:50,total:0}),[a,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,o=h.current,s=new URLSearchParams({project:e,page:String(a)});O(`/api/agent-tasks?${s}`,{signal:r.signal}).then(e=>{n||r.signal.aborted||o!==h.current||(i(e),l(t=>e.tasks.some(e=>e.id===t)?t:e.tasks[0]?.id??``))}).catch(e=>{!n&&!r.signal.aborted&&o===h.current&&d(k(e))})};r();let o=window.setInterval(r,5e3);return window.addEventListener(`focus`,r),()=>{n=!0,t?.abort(),window.clearInterval(o),window.removeEventListener(`focus`,r)}},[e,a,_]);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||o()},[]);return{catalog:t,result:r,page:a,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,o(),g.current&&(p(!1),y())}}},acceptTask:b}}var H=n();function ie({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,H.jsxs)(I,{modal:!1,open:a,onOpenChange:o,children:[(0,H.jsx)(M,{asChild:!0,children:(0,H.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,H.jsx)(C,{agent:l.id,size:16}),(0,H.jsx)(`span`,{children:l?.label??i(`agents.agent`)}),(0,H.jsx)(y,{size:13,"aria-hidden":`true`})]})}),(0,H.jsx)(A,{container:s.current?.closest(`[role="dialog"]`),children:(0,H.jsx)(N,{className:`agent-select-options`,side:`top`,align:`start`,sideOffset:5,collisionPadding:8,children:(0,H.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,H.jsxs)(F,{value:e.id,textValue:e.label,className:`agent-select-option`,disabled:u||!e.installed||!e.enabled,children:[(0,H.jsx)(C,{agent:e.id,size:16}),(0,H.jsxs)(`span`,{className:`agent-select-label`,children:[e.label,(!e.installed||!e.enabled)&&(0,H.jsx)(`small`,{children:i(e.installed?`agents.disabled`:`agents.notInstalled`)})]}),(0,H.jsx)(j,{className:`agent-select-check`,children:(0,H.jsx)(v,{size:14,"aria-hidden":`true`})})]},e.id))})})})]})}function U({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,H.jsx)(`pre`,{className:`agent-review-content`,children:n.map((e,t)=>e.agent?(0,H.jsx)(`mark`,{children:e.text},t):(0,H.jsx)(`span`,{children:e.text},t))})}function W({review:e,activeId:t,onShow:n,focus:i=null}){let{t:a,i18n:o}=c(),[s,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(i?.id??t),[m,g]=(0,B.useState)(`diff`),{pending:_}=e,x=(0,B.useMemo)(()=>{let e=_.findIndex(e=>e.id===u);return e>=0?e:_.length?0:-1},[_,u]),S=x>=0?_[x]:null;(0,B.useEffect)(()=>{i&&(d(i.id),l(!0))},[i?.nonce]),(0,B.useEffect)(()=>{S&&S.id!==u&&d(S.id)},[S,u]);let C=e=>{let t=_[(e+_.length)%_.length];t&&(d(t.id),l(!0),n(t,!1))};return!_.length&&!e.loading&&!e.error?null:(0,H.jsxs)(`section`,{className:`agent-review`,"aria-label":a(`agents.reviewTitle`),children:[(0,H.jsxs)(`div`,{className:`agent-review-bar`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`agent-review-toggle`,"aria-expanded":s,onClick:()=>l(e=>!e),children:[(0,H.jsx)(w,{size:13,"aria-hidden":!0}),a(`agents.reviewTitle`),(0,H.jsx)(`span`,{className:`agent-review-count`,children:_.length}),s?(0,H.jsx)(b,{size:13,"aria-hidden":!0}):(0,H.jsx)(y,{size:13,"aria-hidden":!0})]}),_.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":a(`agents.previousChange`),title:a(`agents.previousChange`),onClick:()=>C(x-1),children:(0,H.jsx)(r,{size:13})}),(0,H.jsxs)(`small`,{className:`agent-review-position`,children:[x+1,` / `,_.length]}),(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":a(`agents.nextChange`),title:a(`agents.nextChange`),onClick:()=>C(x+1),children:(0,H.jsx)(f,{size:13})})]}),(0,H.jsx)(`span`,{className:`agent-toolbar-spacer`}),_.length>0&&(0,H.jsxs)(`button`,{type:`button`,onClick:e.markAllReviewed,children:[(0,H.jsx)(z,{size:12,"aria-hidden":!0}),a(`agents.markAllReviewed`)]}),(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,"aria-label":a(`agents.refreshChanges`),title:a(`agents.refreshChanges`),disabled:e.loading,onClick:e.refresh,children:e.loading?(0,H.jsx)(E,{className:`spin`,size:13}):(0,H.jsx)(D,{size:13})})]}),e.error&&(0,H.jsx)(`p`,{className:`error agent-inline-error`,role:`alert`,children:e.error}),s&&S&&(0,H.jsxs)(`div`,{className:`agent-review-detail`,children:[(0,H.jsxs)(`div`,{className:`agent-review-location`,children:[(0,H.jsxs)(`button`,{type:`button`,className:`agent-review-file`,onClick:()=>n(S,!0),title:a(`agents.openChange`),children:[(0,H.jsx)(p,{size:12,"aria-hidden":!0}),(0,H.jsxs)(`span`,{children:[S.path,`:`,S.line]})]}),(0,H.jsx)(`time`,{dateTime:S.at,children:h(S.at,o.resolvedLanguage,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),(0,H.jsxs)(`div`,{className:`agent-review-tabs`,role:`tablist`,"aria-label":a(`agents.reviewTitle`),children:[(0,H.jsx)(`button`,{type:`button`,role:`tab`,id:`agent-review-tab-content-${S.id}`,"aria-selected":m===`content`,"aria-controls":`agent-review-panel`,className:m===`content`?`active`:``,onClick:()=>g(`content`),children:a(`agents.contentTab`)}),(0,H.jsx)(`button`,{type:`button`,role:`tab`,id:`agent-review-tab-diff-${S.id}`,"aria-selected":m===`diff`,"aria-controls":`agent-review-panel`,className:m===`diff`?`active`:``,onClick:()=>g(`diff`),children:a(`agents.diffTab`)})]}),(0,H.jsx)(`div`,{id:`agent-review-panel`,role:`tabpanel`,"aria-labelledby":`agent-review-tab-${m}-${S.id}`,children:m===`content`?S.after===null?(0,H.jsx)(`p`,{className:`agent-review-unavailable`,children:a(`agents.contentUnavailable`)}):(0,H.jsx)(U,{change:S}):S.before!==null&&S.after!==null?(0,H.jsx)(L,{original:S.before,replacement:S.after}):(0,H.jsx)(`p`,{className:`agent-review-unavailable`,children:a(`agents.changePreviewUnavailable`)})}),(0,H.jsxs)(`div`,{className:`agent-review-actions`,children:[(0,H.jsxs)(`button`,{type:`button`,onClick:()=>n(S,!0),children:[(0,H.jsx)(p,{size:12,"aria-hidden":!0}),a(`agents.openChange`)]}),(0,H.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>{if(!S)return;let t=_[x+1]??_[x-1]??null;e.markReviewed(S),d(t?.id??null),t&&n(t,!1)},children:[(0,H.jsx)(v,{size:12,"aria-hidden":!0}),a(`agents.markReviewed`)]})]})]})]})}var ae=(0,B.lazy)(()=>l(()=>import(`./AgentTerminalSurface-COqg_GdK.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));function G({projectId:e,readOnly:t,onHide:n,maximized:o=!1,onToggleMaximized:l,review:u,activeChangeId:p=null,onShowChange:h,reviewFocus:v=null}){let{t:w}=c(),D=V(e),k=s(),A=D.selected,[j,M]=(0,B.useState)(!1),[N,P]=(0,B.useState)(``),[F,I]=(0,B.useState)(``),[L,R]=(0,B.useState)(!1),[z,U]=(0,B.useState)(``),[G,K]=(0,B.useState)(!1),q=A&&[`starting`,`running`,`stopping`].includes(A.state),oe=A&&(A.canResume||A.startedAt!==null||[`stopped`,`exited`,`interrupted`].includes(A.state)),J=D.catalog?.agents.find(e=>e.id===A?.agentId),Y=D.catalog?.agents.filter(e=>e.installed&&e.enabled)??[],X=F?D.catalog?.agents.find(e=>e.id===F):Y[0],Z=!!(D.result.activeTaskId&&D.result.activeTaskId!==A?.id),Q=t||D.busy||!!D.result.activeTaskId||!D.catalog?.ptyAvailable||!X?.installed||!X.enabled,se=!Z&&!t&&J?.installed&&J.enabled&&D.catalog?.ptyAvailable&&A?.cleanupState===`none`,ce=e=>{D.setSelectedId(e),R(!1)},$=e=>D.mutate(async()=>{if(!A)return;let t=await O(`/api/agent-tasks/${A.id}${e}`,{method:`POST`});D.acceptTask(t.task)});return(0,H.jsxs)(`section`,{className:`agent-terminal-panel`,"data-agent-terminal":`true`,"aria-label":w(`agents.terminal`),children:[(0,H.jsxs)(`div`,{className:`agent-terminal-heading`,children:[(0,H.jsxs)(`strong`,{children:[(0,H.jsx)(d,{size:14}),w(`agents.terminal`)]}),(0,H.jsx)(T,{className:`agent-session-help`,content:w(`agents.sessionManagementHint`),size:13}),(0,H.jsx)(`div`,{className:`agent-task-tabs`,role:`tablist`,"aria-label":w(`agents.tasks`),children:D.result.tasks.map(e=>(0,H.jsxs)(`button`,{role:`tab`,type:`button`,"aria-selected":e.id===A?.id,title:e.title,className:e.id===A?.id?`active`:``,onClick:()=>ce(e.id),children:[(0,H.jsx)(`span`,{className:`agent-state-dot ${e.state}`}),(0,H.jsx)(C,{agent:e.agentId,size:13}),(0,H.jsx)(`span`,{children:e.title}),(0,H.jsx)(`small`,{children:S[e.agentId]})]},e.id))}),(0,H.jsx)(`button`,{className:`agent-icon-button`,disabled:t||D.busy||!Y.length,title:w(`agents.newTask`),"aria-label":w(`agents.newTask`),onClick:()=>M(e=>!e),children:(0,H.jsx)(te,{size:15})}),l&&(0,H.jsx)(`button`,{type:`button`,className:`agent-icon-button`,title:w(o?`agents.restoreTerminal`:`agents.maximizeTerminal`),"aria-label":w(o?`agents.restoreTerminal`:`agents.maximizeTerminal`),"aria-pressed":o,onClick:l,children:o?(0,H.jsx)(y,{size:15}):(0,H.jsx)(b,{size:15})}),(0,H.jsx)(`button`,{className:`agent-icon-button`,title:w(`agents.hide`),"aria-label":w(`agents.hide`),onClick:n,children:(0,H.jsx)(_,{size:15})})]}),(A||D.result.total>D.result.pageSize)&&(0,H.jsxs)(`div`,{className:`agent-task-toolbar`,children:[D.result.total>D.result.pageSize&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{disabled:D.result.page<=1,"aria-label":w(`agents.previous`),onClick:()=>D.setPage(D.result.page-1),children:(0,H.jsx)(r,{size:13})}),(0,H.jsxs)(`small`,{children:[D.result.page,` / `,Math.ceil(D.result.total/D.result.pageSize)]}),(0,H.jsx)(`button`,{disabled:D.result.page*D.result.pageSize>=D.result.total,"aria-label":w(`agents.next`),onClick:()=>D.setPage(D.result.page+1),children:(0,H.jsx)(f,{size:13})})]}),A&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`agent-task-state`,children:w(`agents.state_${A.state}`)}),(0,H.jsx)(`span`,{className:`agent-toolbar-spacer`}),q?(0,H.jsxs)(`button`,{disabled:D.busy,onClick:()=>void $(`/stop`),children:[(0,H.jsx)(x,{size:12}),w(`agents.end`)]}):(0,H.jsxs)(`button`,{disabled:!se||D.busy,onClick:()=>void $(`/start`),children:[(0,H.jsx)(ee,{size:13}),w(oe?`agents.resume`:`agents.start`)]}),(0,H.jsx)(`button`,{className:`agent-icon-button`,title:w(`agents.rename`),"aria-label":w(`agents.rename`),disabled:D.busy,onClick:()=>{U(A.title),R(e=>!e)},children:(0,H.jsx)(a,{size:13})}),(0,H.jsx)(`button`,{className:`agent-icon-button agent-danger`,title:w(`agents.delete`),"aria-label":w(`agents.delete`),disabled:D.busy,onClick:()=>{D.setError(``),K(!0)},children:(0,H.jsx)(m,{size:13})})]})]}),(j||!A)&&(0,H.jsxs)(`form`,{className:`agent-task-create`,onSubmit:t=>{t.preventDefault(),!Q&&D.mutate(async()=>{let t=X?.id,n=await O(`/api/projects/${e}/agent-tasks`,{method:`POST`,body:JSON.stringify({agentId:t,title:N})});D.acceptTask(n.task),D.setPage(1),D.setSelectedId(n.task.id),M(!1),P(``);let r=await O(`/api/agent-tasks/${n.task.id}/start`,{method:`POST`});D.acceptTask(r.task)})},children:[(0,H.jsx)(`input`,{"aria-label":w(`agents.task`),placeholder:w(`agents.titlePlaceholder`),maxLength:160,value:N,onChange:e=>P(e.target.value),disabled:D.busy||t}),(0,H.jsx)(ie,{agents:D.catalog?.agents??[],value:X?.id??``,onChange:I,disabled:t||D.busy}),(0,H.jsxs)(`button`,{type:`submit`,disabled:Q,children:[D.busy&&(0,H.jsx)(E,{className:`spin`,size:13}),w(`agents.create`)]})]}),L&&A&&(0,H.jsxs)(`form`,{className:`agent-task-create`,onSubmit:e=>{e.preventDefault(),D.mutate(async()=>{let e=await O(`/api/agent-tasks/${A.id}`,{method:`PATCH`,body:JSON.stringify({title:z})});D.acceptTask(e.task),R(!1)})},children:[(0,H.jsx)(`input`,{value:z,onChange:e=>U(e.target.value),required:!0,maxLength:160,"aria-label":w(`agents.task`)}),(0,H.jsx)(ne,{type:`submit`,saving:D.busy,children:w(`common.save`)})]}),D.error&&!G&&(0,H.jsxs)(`p`,{className:`error agent-inline-error`,role:`alert`,children:[D.error,(0,H.jsx)(`button`,{onClick:()=>D.setError(``),"aria-label":w(`common.close`),children:(0,H.jsx)(_,{size:13})})]}),A?.errorCode&&!D.error&&!G&&(0,H.jsx)(`p`,{className:`error agent-inline-error`,role:`alert`,children:w(`errors.codes.${A.errorCode}`,{defaultValue:w(`agents.taskUnavailable`)})}),(Z||j&&D.result.activeTaskId)&&(0,H.jsxs)(`p`,{className:`agent-inline-warning`,role:`status`,children:[(0,H.jsx)(g,{size:14,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:w(`errors.codes.AGENT_PROJECT_BUSY`)})]}),D.catalog&&!D.catalog.ptyAvailable&&(0,H.jsx)(`p`,{className:`error agent-inline-error`,children:w(`agents.ptyUnavailable`)}),u&&h&&(0,H.jsx)(W,{review:u,activeId:p,onShow:h,focus:v}),(0,H.jsx)(`div`,{className:`agent-terminal-body`,style:i(k.theme),children:(0,H.jsx)(B.Suspense,{fallback:(0,H.jsx)(`div`,{className:`agent-task-empty`,children:(0,H.jsx)(E,{className:`spin`,size:18})}),children:A&&q&&!t?(0,H.jsx)(ae,{task:A,onTask:D.acceptTask},A.id):(0,H.jsxs)(`div`,{className:`agent-task-empty`,children:[(0,H.jsx)(d,{size:24}),(0,H.jsx)(`strong`,{children:A?.title||w(`agents.noTasks`)}),(0,H.jsx)(`p`,{children:w(t?`agents.permissionLost`:`agents.readyHint`)}),A?.exitCode!==null&&A?.exitCode!==void 0&&A.exitCode!==0&&(0,H.jsx)(`small`,{children:w(`agents.exitCode`,{code:A.exitCode})})]})})}),k.showExecutionReminder&&q&&A.state!==`stopping`&&(0,H.jsxs)(`p`,{className:`agent-execution-reminder`,children:[(0,H.jsx)(g,{size:12,"aria-hidden":`true`}),(0,H.jsx)(`span`,{children:w(`agents.endReminder`)})]}),A&&(0,H.jsx)(re,{open:G,title:w(`agents.delete`),description:w(`agents.deleteDescription`),onOpenChange:e=>{D.busy||K(e)},footer:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`button`,{disabled:D.busy,onClick:()=>K(!1),children:w(`common.cancel`)}),(0,H.jsxs)(`button`,{className:`danger`,disabled:D.busy,onClick:()=>void D.mutate(async()=>{await O(`/api/agent-tasks/${A.id}`,{method:`DELETE`}),K(!1)}),children:[D.busy&&(0,H.jsx)(E,{className:`spin`,size:13}),w(`agents.delete`)]})]}),children:D.error&&(0,H.jsx)(`p`,{className:`error`,role:`alert`,children:D.error})})]})}export{G as AgentTerminal};
|
|
Binary file
|
|
Binary file
|