@myrialabs/clopen 0.4.50 → 0.4.51
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/README.md +2 -1
- package/backend/chat/attachments.test.ts +106 -17
- package/backend/chat/attachments.ts +131 -34
- package/backend/chat/engine-handoff.ts +42 -6
- package/backend/chat/stream-manager.ts +41 -5
- package/backend/containers/actions.ts +22 -0
- package/backend/control/actions/projects.ts +93 -37
- package/backend/control/folders.test.ts +27 -2
- package/backend/control/index.ts +2 -1
- package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
- package/backend/database/migrations/086_single_owner.ts +66 -73
- package/backend/database/migrations/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +11 -2
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-queries.ts +3 -0
- package/backend/database/utils/migration-runner.test.ts +196 -0
- package/backend/database/utils/migration-runner.ts +61 -16
- package/backend/database/utils/seeder-runner.ts +22 -16
- package/backend/engine/adapters/claude/stream.ts +5 -0
- package/backend/engine/adapters/cursor/environment.ts +1 -1
- package/backend/engine/adapters/qwen/session-store.ts +10 -1
- package/backend/engine/types.ts +7 -0
- package/backend/git/identity/cli.ts +35 -0
- package/backend/git/identity/env.test.ts +52 -1
- package/backend/git/identity/env.ts +69 -10
- package/backend/git/identity/index.ts +25 -6
- package/backend/git/identity/resolve.ts +2 -1
- package/backend/git/identity/scope-config.ts +13 -7
- package/backend/git-hosts/accounts.ts +106 -0
- package/backend/git-hosts/auth/client-ids.ts +34 -0
- package/backend/git-hosts/auth/connect.ts +110 -0
- package/backend/git-hosts/auth/endpoints.ts +130 -0
- package/backend/git-hosts/auth/flows.ts +355 -0
- package/backend/git-hosts/auth/local.ts +152 -0
- package/backend/git-hosts/ci.ts +18 -0
- package/backend/git-hosts/cli.test.ts +82 -0
- package/backend/git-hosts/cli.ts +342 -0
- package/backend/git-hosts/credentials.ts +173 -0
- package/backend/git-hosts/git-credential.ts +30 -0
- package/backend/git-hosts/health.ts +39 -0
- package/backend/git-hosts/http.ts +174 -0
- package/backend/git-hosts/index.ts +34 -0
- package/backend/git-hosts/providers/bitbucket.ts +186 -0
- package/backend/git-hosts/providers/gitea.ts +208 -0
- package/backend/git-hosts/providers/github.ts +270 -0
- package/backend/git-hosts/providers/gitlab-client.ts +70 -0
- package/backend/git-hosts/providers/gitlab.ts +285 -0
- package/backend/git-hosts/providers/locators.test.ts +68 -0
- package/backend/git-hosts/registry.ts +50 -0
- package/backend/git-hosts/service.ts +432 -0
- package/backend/git-hosts/types.ts +82 -0
- package/backend/git-hosts/urls.test.ts +42 -0
- package/backend/git-hosts/urls.ts +69 -0
- package/backend/index.ts +50 -10
- package/backend/integrations/accounts.ts +50 -3
- package/backend/integrations/registry/define.ts +9 -0
- package/backend/integrations/registry/index.ts +11 -0
- package/backend/integrations/registry/providers/bitbucket.ts +51 -0
- package/backend/integrations/registry/providers/gitea.ts +53 -0
- package/backend/integrations/registry/providers/github.ts +24 -7
- package/backend/integrations/registry/providers/gitlab.ts +57 -0
- package/backend/integrations/registry/types.ts +13 -1
- package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
- package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
- package/backend/mentions/diff.ts +63 -0
- package/backend/mentions/index.ts +109 -0
- package/backend/mentions/mentions.test.ts +27 -0
- package/backend/mentions/shared.ts +82 -0
- package/backend/mentions/sources/ai-changes.ts +140 -0
- package/backend/mentions/sources/chats.ts +122 -0
- package/backend/mentions/sources/database.ts +211 -0
- package/backend/mentions/sources/files.ts +240 -0
- package/backend/mentions/sources/git.ts +308 -0
- package/backend/mentions/sources/notes-memory.ts +121 -0
- package/backend/mentions/sources/ops.ts +125 -0
- package/backend/mentions/sources/preview.ts +153 -0
- package/backend/mentions/sources/projects.ts +114 -0
- package/backend/mentions/sources/system.ts +135 -0
- package/backend/mentions/sources/terminal.ts +50 -0
- package/backend/mentions/types.ts +75 -0
- package/backend/preview/browser/bot-check-frames.test.ts +49 -0
- package/backend/preview/browser/bot-check-frames.ts +66 -0
- package/backend/preview/browser/browser-dialog-handler.ts +6 -5
- package/backend/preview/browser/browser-host-bridge.ts +4 -2
- package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
- package/backend/preview/browser/browser-pool.ts +26 -17
- package/backend/preview/browser/browser-preview-service.ts +164 -2
- package/backend/preview/browser/browser-screenshot.test.ts +113 -0
- package/backend/preview/browser/browser-screenshot.ts +396 -0
- package/backend/preview/browser/browser-tab-manager.ts +35 -186
- package/backend/preview/browser/browser-video-capture.ts +12 -17
- package/backend/preview/browser/element-describe.ts +125 -0
- package/backend/preview/browser/page-binding.ts +141 -0
- package/backend/preview/browser/screenshot-files.test.ts +117 -0
- package/backend/preview/browser/screenshot-files.ts +134 -0
- package/backend/preview/browser/user-agent.test.ts +25 -0
- package/backend/preview/browser/user-agent.ts +100 -0
- package/backend/projects/engine-transcripts.ts +153 -0
- package/backend/projects/folder-guard.ts +55 -0
- package/backend/projects/move.test.ts +208 -0
- package/backend/projects/move.ts +277 -0
- package/backend/projects/project-cleanup.integration.test.ts +3 -1
- package/backend/projects/project-cleanup.ts +10 -0
- package/backend/storage/actions.ts +260 -0
- package/backend/storage/chats.test.ts +57 -0
- package/backend/storage/chats.ts +170 -0
- package/backend/storage/database.ts +105 -0
- package/backend/storage/engine-homes.ts +145 -0
- package/backend/storage/fs-size.ts +111 -0
- package/backend/storage/history.ts +39 -0
- package/backend/storage/policy.ts +156 -0
- package/backend/storage/preview-profiles.ts +169 -0
- package/backend/storage/purge.ts +158 -0
- package/backend/storage/scanner.ts +339 -0
- package/backend/storage/session-index.ts +208 -0
- package/backend/storage/snapshots.ts +99 -0
- package/backend/storage/storage-flow.test.ts +137 -0
- package/backend/storage/transcripts/aliases.ts +75 -0
- package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
- package/backend/storage/transcripts/claude-dedupe.ts +152 -0
- package/backend/storage/transcripts/claude.ts +155 -0
- package/backend/storage/transcripts/cursor.ts +165 -0
- package/backend/storage/transcripts/file-stores.ts +224 -0
- package/backend/storage/transcripts/index.ts +207 -0
- package/backend/storage/transcripts/opencode.ts +124 -0
- package/backend/storage/transcripts/references.ts +42 -0
- package/backend/storage/transcripts/types.ts +58 -0
- package/backend/storage/worktrees.ts +114 -0
- package/backend/terminal/ptykit.ts +25 -0
- package/backend/update/registry.ts +24 -0
- package/backend/update/release-notes.test.ts +110 -0
- package/backend/update/release-notes.ts +132 -0
- package/backend/update/restart.ts +159 -0
- package/backend/utils/env.test.ts +64 -0
- package/backend/utils/env.ts +23 -55
- package/backend/utils/port-utils.ts +13 -0
- package/backend/work/index.ts +13 -2
- package/backend/work/providers/github/actions-logs.ts +1 -1
- package/backend/work/providers/github/adapter.ts +32 -1
- package/backend/work/providers/github/client.ts +7 -3
- package/backend/work/providers/gitlab/adapter.ts +770 -0
- package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
- package/backend/work/service.ts +60 -36
- package/backend/work/start-work.ts +1 -1
- package/backend/work/types.ts +4 -0
- package/backend/worktrees/index.ts +1 -0
- package/backend/worktrees/service.ts +23 -2
- package/backend/ws/chat/composer.ts +47 -6
- package/backend/ws/files/search.ts +1 -1
- package/backend/ws/files/write.ts +27 -0
- package/backend/ws/hosting/index.ts +231 -0
- package/backend/ws/index.ts +12 -2
- package/backend/ws/integrations/crud.ts +31 -5
- package/backend/ws/integrations/hosting-auth.ts +227 -0
- package/backend/ws/integrations/index.ts +2 -0
- package/backend/ws/mentions/index.ts +81 -0
- package/backend/ws/preview/browser/screenshot.ts +184 -0
- package/backend/ws/preview/index.ts +23 -0
- package/backend/ws/projects/crud.ts +66 -58
- package/backend/ws/sessions/crud.ts +7 -95
- package/backend/ws/snapshot/changes.ts +3 -3
- package/backend/ws/storage/index.ts +102 -0
- package/backend/ws/system/index.ts +7 -0
- package/backend/ws/system/operations.ts +125 -69
- package/backend/ws/work/context.ts +3 -4
- package/backend/ws/work/crud.ts +33 -0
- package/backend/ws/work/schemas.ts +4 -1
- package/bin/clopen.ts +15 -16
- package/dist/assets/{index-By6KdSLT.js → index-B9rHDvjg.js} +1 -1
- package/dist/assets/index-B9rHDvjg.js.br +0 -0
- package/dist/assets/index-B9rHDvjg.js.gz +0 -0
- package/dist/assets/{index-DV4TiDn1.js → index-DFlwOd7k.js} +1 -1
- package/dist/assets/index-DFlwOd7k.js.br +0 -0
- package/dist/assets/index-DFlwOd7k.js.gz +0 -0
- package/dist/assets/main-Bz_brxxS.css +1 -0
- package/dist/assets/main-Bz_brxxS.css.br +0 -0
- package/dist/assets/main-Bz_brxxS.css.gz +0 -0
- package/dist/assets/main-DRcX9SHx.js +1273 -0
- package/dist/assets/main-DRcX9SHx.js.br +0 -0
- package/dist/assets/main-DRcX9SHx.js.gz +0 -0
- package/dist/assets/pdf-DfwfQPLy.js +57 -0
- package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
- package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
- package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
- package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
- package/package.json +6 -7
- package/scripts/start.ts +21 -4
- package/shared/constants/binary-extensions.ts +20 -4
- package/shared/constants/support.test.ts +27 -0
- package/shared/constants/support.ts +79 -0
- package/shared/constants/tool-icons.ts +7 -1
- package/shared/types/database/schema.ts +6 -0
- package/shared/types/git-hosting.ts +241 -0
- package/shared/types/integrations.ts +51 -1
- package/shared/types/mentions.ts +96 -0
- package/shared/types/release-notes.ts +31 -0
- package/shared/types/storage.ts +175 -0
- package/shared/types/stores/settings.ts +16 -0
- package/shared/types/unified/index.ts +1 -0
- package/shared/types/unified/message.ts +26 -1
- package/shared/types/unified/tool.ts +4 -0
- package/shared/types/work.ts +6 -0
- package/shared/utils/attachment-mentions.test.ts +39 -0
- package/shared/utils/attachment-mentions.ts +100 -0
- package/shared/utils/context-document.test.ts +53 -0
- package/shared/utils/context-document.ts +226 -0
- package/shared/utils/device-frame.test.ts +73 -0
- package/shared/utils/device-frame.ts +320 -0
- package/shared/utils/fuzzy.ts +79 -0
- package/shared/utils/launcher-fingerprint.test.ts +73 -0
- package/shared/utils/launcher-fingerprint.ts +108 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/page-colors.test.ts +17 -0
- package/shared/utils/page-colors.ts +24 -0
- package/shared/utils/process-supervisor.test.ts +18 -1
- package/shared/utils/process-supervisor.ts +12 -23
- package/shared/utils/restart-intent.test.ts +57 -0
- package/shared/utils/restart-intent.ts +80 -0
- package/shared/utils/semver.test.ts +33 -0
- package/shared/utils/semver.ts +35 -0
- package/shared/utils/supervised-child.ts +44 -0
- package/shared/utils/supervisor-protocol.ts +20 -0
- package/.env.example +0 -9
- package/dist/assets/index-By6KdSLT.js.br +0 -0
- package/dist/assets/index-By6KdSLT.js.gz +0 -0
- package/dist/assets/index-DV4TiDn1.js.br +0 -0
- package/dist/assets/index-DV4TiDn1.js.gz +0 -0
- package/dist/assets/main-DIESTGTD.css +0 -1
- package/dist/assets/main-DIESTGTD.css.br +0 -0
- package/dist/assets/main-DIESTGTD.css.gz +0 -0
- package/dist/assets/main-Da3JKoua.js +0 -1240
- package/dist/assets/main-Da3JKoua.js.br +0 -0
- package/dist/assets/main-Da3JKoua.js.gz +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser Screenshot WebSocket Handler
|
|
3
|
+
*
|
|
4
|
+
* The viewer's screenshot controls: capture a tab (on screen, full page, an
|
|
5
|
+
* area, an element), probe the element under the picker, capture the page at
|
|
6
|
+
* other device sizes, and save a finished image into the workspace.
|
|
7
|
+
*
|
|
8
|
+
* Every capture runs in the tab's own browser — the same path the agent's
|
|
9
|
+
* `screenshot` action takes — so the picture is the page at its real
|
|
10
|
+
* resolution, not a frame of the stream.
|
|
11
|
+
*
|
|
12
|
+
* **PROJECT ISOLATION**: Uses project-specific BrowserPreviewService instances
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { t } from 'elysia';
|
|
16
|
+
import { createRouter } from '$shared/utils/ws-server';
|
|
17
|
+
import { debug } from '$shared/utils/logger';
|
|
18
|
+
import { DEVICE_SIZES } from '$shared/constants/preview';
|
|
19
|
+
import { requireProjectWorkspace } from '../../access';
|
|
20
|
+
import { requireBrowserPreviewAccess, requireBrowserTabAccess } from '../access';
|
|
21
|
+
import { ignoreScreenshotFolder, saveScreenshotFile } from '$backend/preview/browser/screenshot-files';
|
|
22
|
+
import type { CapturedScreenshot } from '$backend/preview/browser/browser-screenshot';
|
|
23
|
+
|
|
24
|
+
const formatSchema = t.Optional(t.Union([t.Literal('png'), t.Literal('jpeg')]));
|
|
25
|
+
const qualitySchema = t.Optional(t.Number({ minimum: 1, maximum: 100 }));
|
|
26
|
+
|
|
27
|
+
const targetSchema = t.Union([
|
|
28
|
+
t.Object({ kind: t.Literal('viewport') }),
|
|
29
|
+
t.Object({ kind: t.Literal('fullPage') }),
|
|
30
|
+
t.Object({
|
|
31
|
+
kind: t.Literal('element'),
|
|
32
|
+
x: t.Number(),
|
|
33
|
+
y: t.Number(),
|
|
34
|
+
depth: t.Optional(t.Number({ minimum: 0 }))
|
|
35
|
+
}),
|
|
36
|
+
t.Object({
|
|
37
|
+
kind: t.Literal('region'),
|
|
38
|
+
x: t.Number(),
|
|
39
|
+
y: t.Number(),
|
|
40
|
+
width: t.Number(),
|
|
41
|
+
height: t.Number()
|
|
42
|
+
})
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const imageSchema = t.Object({
|
|
46
|
+
data: t.String(),
|
|
47
|
+
mimeType: t.Union([t.Literal('image/png'), t.Literal('image/jpeg')]),
|
|
48
|
+
width: t.Number(),
|
|
49
|
+
height: t.Number()
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const deviceSchema = t.Union(
|
|
53
|
+
DEVICE_SIZES.filter((size) => size !== 'responsive').map((size) => t.Literal(size))
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const gitStateSchema = t.Union([t.Literal('ignored'), t.Literal('not-ignored'), t.Literal('no-repo')]);
|
|
57
|
+
|
|
58
|
+
function encode(image: CapturedScreenshot) {
|
|
59
|
+
return {
|
|
60
|
+
data: Buffer.from(image.data).toString('base64'),
|
|
61
|
+
mimeType: image.mimeType,
|
|
62
|
+
width: image.width,
|
|
63
|
+
height: image.height
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const screenshotPreviewHandler = createRouter()
|
|
68
|
+
.http('preview:browser-screenshot', {
|
|
69
|
+
data: t.Object({
|
|
70
|
+
tabId: t.String({ minLength: 1 }),
|
|
71
|
+
target: targetSchema,
|
|
72
|
+
format: formatSchema,
|
|
73
|
+
quality: qualitySchema
|
|
74
|
+
}),
|
|
75
|
+
response: t.Object({
|
|
76
|
+
image: imageSchema,
|
|
77
|
+
url: t.String(),
|
|
78
|
+
title: t.String()
|
|
79
|
+
})
|
|
80
|
+
}, async ({ data, conn }) => {
|
|
81
|
+
const { previewService, tab } = requireBrowserTabAccess(conn, data.tabId);
|
|
82
|
+
const image = await previewService.takeScreenshot(
|
|
83
|
+
tab.id,
|
|
84
|
+
data.target,
|
|
85
|
+
{ format: data.format, quality: data.quality },
|
|
86
|
+
'user'
|
|
87
|
+
);
|
|
88
|
+
debug.log('preview', `📸 Screenshot of ${tab.id} (${data.target.kind}): ${image.width}×${image.height}`);
|
|
89
|
+
return { image: encode(image), url: tab.page.url(), title: tab.title };
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
.http('preview:browser-screenshot-element-at', {
|
|
93
|
+
data: t.Object({
|
|
94
|
+
tabId: t.String({ minLength: 1 }),
|
|
95
|
+
x: t.Number(),
|
|
96
|
+
y: t.Number(),
|
|
97
|
+
depth: t.Optional(t.Number({ minimum: 0 }))
|
|
98
|
+
}),
|
|
99
|
+
response: t.Object({
|
|
100
|
+
element: t.Union([
|
|
101
|
+
t.Null(),
|
|
102
|
+
t.Object({
|
|
103
|
+
rect: t.Object({ x: t.Number(), y: t.Number(), width: t.Number(), height: t.Number() }),
|
|
104
|
+
label: t.String(),
|
|
105
|
+
depth: t.Number(),
|
|
106
|
+
hasParent: t.Boolean()
|
|
107
|
+
})
|
|
108
|
+
])
|
|
109
|
+
})
|
|
110
|
+
}, async ({ data, conn }) => {
|
|
111
|
+
const { previewService, tab } = requireBrowserTabAccess(conn, data.tabId);
|
|
112
|
+
return { element: await previewService.screenshotElementAt(tab.id, data.x, data.y, data.depth ?? 0) };
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
.http('preview:browser-screenshot-responsive', {
|
|
116
|
+
data: t.Object({
|
|
117
|
+
tabId: t.String({ minLength: 1 }),
|
|
118
|
+
devices: t.Array(deviceSchema, { minItems: 1, maxItems: 4 }),
|
|
119
|
+
format: formatSchema,
|
|
120
|
+
quality: qualitySchema
|
|
121
|
+
}),
|
|
122
|
+
response: t.Object({
|
|
123
|
+
url: t.String(),
|
|
124
|
+
title: t.String(),
|
|
125
|
+
shots: t.Array(t.Object({
|
|
126
|
+
deviceSize: t.String(),
|
|
127
|
+
deviceModel: t.Union([t.String(), t.Null()]),
|
|
128
|
+
viewport: t.Object({ width: t.Number(), height: t.Number() }),
|
|
129
|
+
image: imageSchema
|
|
130
|
+
}))
|
|
131
|
+
})
|
|
132
|
+
}, async ({ data, conn }) => {
|
|
133
|
+
const { previewService, tab } = requireBrowserTabAccess(conn, data.tabId);
|
|
134
|
+
const shots = await previewService.takeResponsiveScreenshots(tab.id, data.devices, {
|
|
135
|
+
format: data.format,
|
|
136
|
+
quality: data.quality
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
url: tab.page.url(),
|
|
140
|
+
title: tab.title,
|
|
141
|
+
shots: shots.map((shot) => ({ ...shot, image: encode(shot.image) }))
|
|
142
|
+
};
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
// Save a finished image — edits and frame already applied by the viewer.
|
|
146
|
+
.http('preview:browser-screenshot-save', {
|
|
147
|
+
data: t.Object({
|
|
148
|
+
fileName: t.String({ minLength: 1 }),
|
|
149
|
+
data: t.String({ minLength: 1 }),
|
|
150
|
+
mimeType: t.Union([t.Literal('image/png'), t.Literal('image/jpeg')]),
|
|
151
|
+
folder: t.Optional(t.String())
|
|
152
|
+
}),
|
|
153
|
+
response: t.Object({
|
|
154
|
+
path: t.String(),
|
|
155
|
+
folder: t.String(),
|
|
156
|
+
git: gitStateSchema
|
|
157
|
+
})
|
|
158
|
+
}, async ({ data, conn }) => {
|
|
159
|
+
const { projectId } = requireBrowserPreviewAccess(conn);
|
|
160
|
+
const { root } = requireProjectWorkspace(conn, projectId);
|
|
161
|
+
const bytes = new Uint8Array(Buffer.from(data.data, 'base64'));
|
|
162
|
+
const saved = await saveScreenshotFile(
|
|
163
|
+
root,
|
|
164
|
+
data.folder,
|
|
165
|
+
data.fileName,
|
|
166
|
+
bytes,
|
|
167
|
+
data.mimeType === 'image/jpeg' ? 'jpg' : 'png'
|
|
168
|
+
);
|
|
169
|
+
debug.log('preview', `💾 Screenshot saved to ${saved.path} (git: ${saved.git})`);
|
|
170
|
+
return saved;
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
.http('preview:browser-screenshot-ignore-folder', {
|
|
174
|
+
data: t.Object({
|
|
175
|
+
folder: t.Optional(t.String())
|
|
176
|
+
}),
|
|
177
|
+
response: t.Object({
|
|
178
|
+
git: gitStateSchema
|
|
179
|
+
})
|
|
180
|
+
}, async ({ data, conn }) => {
|
|
181
|
+
const { projectId } = requireBrowserPreviewAccess(conn);
|
|
182
|
+
const { root } = requireProjectWorkspace(conn, projectId);
|
|
183
|
+
return { git: await ignoreScreenshotFolder(root, data.folder) };
|
|
184
|
+
});
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* - data.ts: Browsing data (list sites, clear one or all)
|
|
18
18
|
* - mcp.ts: MCP tab coordination response handlers
|
|
19
19
|
* - host.ts: Viewer-answered capabilities (geolocation, camera, clipboard, files)
|
|
20
|
+
* - screenshot.ts: Screenshots (capture, element picker, device sizes, save)
|
|
20
21
|
*
|
|
21
22
|
* Available endpoints:
|
|
22
23
|
* - preview:browser-tab-open - Open new browser tab (with optional URL)
|
|
@@ -42,6 +43,11 @@
|
|
|
42
43
|
* - preview:browser-stream-answer - Send stream answer
|
|
43
44
|
* - preview:browser-stream-ice - Exchange ICE candidates
|
|
44
45
|
* - preview:browser-stream-stop - Stop streaming
|
|
46
|
+
* - preview:browser-screenshot - Capture a tab
|
|
47
|
+
* - preview:browser-screenshot-element-at - Element under the picker
|
|
48
|
+
* - preview:browser-screenshot-responsive - Capture at other device sizes
|
|
49
|
+
* - preview:browser-screenshot-save - Save an image into the workspace
|
|
50
|
+
* - preview:browser-screenshot-ignore-folder - Add the screenshot folder to .gitignore
|
|
45
51
|
*/
|
|
46
52
|
|
|
47
53
|
import { t } from 'elysia';
|
|
@@ -57,6 +63,7 @@ import { streamPreviewHandler } from './browser/webcodecs';
|
|
|
57
63
|
import { nativeUIPreviewHandler } from './browser/native-ui';
|
|
58
64
|
import { mcpPreviewHandler } from './browser/mcp';
|
|
59
65
|
import { hostPreviewHandler } from './browser/host';
|
|
66
|
+
import { screenshotPreviewHandler } from './browser/screenshot';
|
|
60
67
|
import { previewWatchHandler } from './watchers';
|
|
61
68
|
|
|
62
69
|
export const previewRouter = createRouter()
|
|
@@ -71,6 +78,7 @@ export const previewRouter = createRouter()
|
|
|
71
78
|
.merge(nativeUIPreviewHandler)
|
|
72
79
|
.merge(mcpPreviewHandler)
|
|
73
80
|
.merge(hostPreviewHandler)
|
|
81
|
+
.merge(screenshotPreviewHandler)
|
|
74
82
|
.merge(previewWatchHandler)
|
|
75
83
|
// Server-emitted events (for type safety)
|
|
76
84
|
.emit('preview:browser-tab-opened', t.Object({
|
|
@@ -115,6 +123,21 @@ export const previewRouter = createRouter()
|
|
|
115
123
|
sleeping: t.Boolean(),
|
|
116
124
|
timestamp: t.Number()
|
|
117
125
|
}))
|
|
126
|
+
.emit('preview:browser-screenshot', t.Object({
|
|
127
|
+
projectId: t.String(),
|
|
128
|
+
tabId: t.String(),
|
|
129
|
+
/** Who took it — the viewer's controls or an agent. */
|
|
130
|
+
source: t.Union([t.Literal('user'), t.Literal('agent')]),
|
|
131
|
+
/**
|
|
132
|
+
* `start` is only sent for a full-page capture, which visibly relays
|
|
133
|
+
* out the page while it runs; `end` is sent for every capture and is
|
|
134
|
+
* what the shutter flashes on.
|
|
135
|
+
*/
|
|
136
|
+
phase: t.Union([t.Literal('start'), t.Literal('end')]),
|
|
137
|
+
fullPage: t.Boolean(),
|
|
138
|
+
ok: t.Optional(t.Boolean()),
|
|
139
|
+
timestamp: t.Number()
|
|
140
|
+
}))
|
|
118
141
|
.emit('preview:browser-tab-navigated', t.Object({
|
|
119
142
|
projectId: t.String(),
|
|
120
143
|
tabId: t.String(),
|
|
@@ -5,26 +5,28 @@
|
|
|
5
5
|
* - List projects in the workspace
|
|
6
6
|
* - Create new project (or re-list an existing one at the same path)
|
|
7
7
|
* - Get project by ID
|
|
8
|
-
* -
|
|
8
|
+
* - Rename a project's folder, or point it at a folder moved elsewhere
|
|
9
9
|
* - Delete project (remove from the list, or delete it with its chats)
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { t } from 'elysia';
|
|
13
|
+
import { basename } from 'path';
|
|
13
14
|
import { createRouter } from '$shared/utils/ws-server';
|
|
14
15
|
import { initializeDatabase } from '../../database';
|
|
15
|
-
import { projectQueries
|
|
16
|
+
import { projectQueries } from '../../database/queries';
|
|
16
17
|
import { ws } from '$backend/utils/ws';
|
|
17
|
-
import { snapshotService } from '../../snapshot/snapshot-service';
|
|
18
|
-
import { blobStore } from '../../snapshot/blob-store';
|
|
19
|
-
import { streamManager } from '../../chat/stream-manager';
|
|
20
18
|
import { cleanupProjectSessions } from '../../terminal/ptykit';
|
|
21
19
|
import { broadcastPresence } from '../projects/status';
|
|
22
20
|
import { debug } from '$shared/utils/logger';
|
|
23
21
|
import { requireProjectAccess } from '../access';
|
|
24
22
|
import { runProjectCleanups } from '../../projects/project-cleanup-registry';
|
|
23
|
+
import { purgeSessions } from '../../storage/purge';
|
|
25
24
|
import '../../projects/project-cleanup';
|
|
26
25
|
import { ensureHomeProject } from '../../projects/home';
|
|
27
26
|
import { homeFirst, isHomeProject } from '$shared/utils/home-project';
|
|
27
|
+
import { getProjectUsage, moveProject, withFolderState } from '../../projects/move';
|
|
28
|
+
|
|
29
|
+
const usageSchema = t.Object({ chats: t.Number(), terminals: t.Number() });
|
|
28
30
|
|
|
29
31
|
export const crudHandler = createRouter()
|
|
30
32
|
// List projects in the workspace
|
|
@@ -36,19 +38,20 @@ export const crudHandler = createRouter()
|
|
|
36
38
|
// Home is always there, listed first — the place a chat with no project
|
|
37
39
|
// selected lives, and where a fresh install lands.
|
|
38
40
|
ensureHomeProject();
|
|
39
|
-
return homeFirst(projectQueries.getListed());
|
|
41
|
+
return homeFirst(projectQueries.getListed()).map(withFolderState);
|
|
40
42
|
})
|
|
41
43
|
|
|
42
|
-
// Create new project (or re-list an existing project at the same path)
|
|
44
|
+
// Create new project (or re-list an existing project at the same path).
|
|
45
|
+
// The name is always the folder's: renaming a project renames its folder.
|
|
43
46
|
.http('projects:create', {
|
|
44
47
|
data: t.Object({
|
|
45
|
-
name: t.String({ minLength: 1 }),
|
|
46
48
|
path: t.String({ minLength: 1 })
|
|
47
49
|
}),
|
|
48
50
|
response: t.Any()
|
|
49
51
|
}, async ({ data }) => {
|
|
50
52
|
await initializeDatabase();
|
|
51
|
-
const {
|
|
53
|
+
const { path } = data;
|
|
54
|
+
const name = basename(path) || path;
|
|
52
55
|
|
|
53
56
|
// Check if project with this path already exists. If so, put it back in
|
|
54
57
|
// the list and return the existing record. This covers re-adding a
|
|
@@ -60,7 +63,7 @@ export const crudHandler = createRouter()
|
|
|
60
63
|
if (existing && isHomeProject(existing)) throw new Error('That folder is the Home workspace and cannot be added as a project');
|
|
61
64
|
if (existing) {
|
|
62
65
|
projectQueries.list(existing.id);
|
|
63
|
-
return existing;
|
|
66
|
+
return withFolderState(existing);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
const now = new Date().toISOString();
|
|
@@ -73,7 +76,7 @@ export const crudHandler = createRouter()
|
|
|
73
76
|
|
|
74
77
|
projectQueries.list(project.id);
|
|
75
78
|
|
|
76
|
-
return project;
|
|
79
|
+
return withFolderState(project);
|
|
77
80
|
})
|
|
78
81
|
|
|
79
82
|
// Get project by ID
|
|
@@ -89,7 +92,47 @@ export const crudHandler = createRouter()
|
|
|
89
92
|
projectQueries.updateLastOpened(data.id);
|
|
90
93
|
const updatedProject = projectQueries.getById(data.id);
|
|
91
94
|
|
|
92
|
-
return updatedProject;
|
|
95
|
+
return updatedProject ? withFolderState(updatedProject) : updatedProject;
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
// What would stop a project from being moved right now: chats generating
|
|
99
|
+
// and shells running in its main tree.
|
|
100
|
+
.http('projects:usage', {
|
|
101
|
+
data: t.Object({
|
|
102
|
+
id: t.String({ minLength: 1 })
|
|
103
|
+
}),
|
|
104
|
+
response: usageSchema
|
|
105
|
+
}, async ({ data }) => {
|
|
106
|
+
requireProjectAccess(data.id);
|
|
107
|
+
return getProjectUsage(data.id);
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
// Rename a project's folder on disk; the project's name follows it. Answers
|
|
111
|
+
// `busy` while work runs there, unless `force` stops that work first.
|
|
112
|
+
.http('projects:rename', {
|
|
113
|
+
data: t.Object({
|
|
114
|
+
id: t.String({ minLength: 1 }),
|
|
115
|
+
name: t.String({ minLength: 1 }),
|
|
116
|
+
force: t.Optional(t.Boolean())
|
|
117
|
+
}),
|
|
118
|
+
response: t.Any()
|
|
119
|
+
}, async ({ data }) => {
|
|
120
|
+
requireProjectAccess(data.id);
|
|
121
|
+
return await moveProject(data.id, { kind: 'rename', name: data.name }, data.force);
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// Point a project at the folder it now lives in, after it was moved or
|
|
125
|
+
// renamed outside Clopen. Same carrying-along as a rename, minus the rename.
|
|
126
|
+
.http('projects:relocate', {
|
|
127
|
+
data: t.Object({
|
|
128
|
+
id: t.String({ minLength: 1 }),
|
|
129
|
+
path: t.String({ minLength: 1 }),
|
|
130
|
+
force: t.Optional(t.Boolean())
|
|
131
|
+
}),
|
|
132
|
+
response: t.Any()
|
|
133
|
+
}, async ({ data }) => {
|
|
134
|
+
requireProjectAccess(data.id);
|
|
135
|
+
return await moveProject(data.id, { kind: 'relocate', path: data.path }, data.force);
|
|
93
136
|
})
|
|
94
137
|
|
|
95
138
|
// Delete project (remove from list or full delete with sessions)
|
|
@@ -113,51 +156,11 @@ export const crudHandler = createRouter()
|
|
|
113
156
|
debug.log('project', `Cleaned up ${cleanedStreams} terminal sessions for project ${data.id}`);
|
|
114
157
|
|
|
115
158
|
if (mode === 'full') {
|
|
116
|
-
// Full delete:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
await Promise.all(
|
|
122
|
-
sessions.map(s => streamManager.cleanupSessionStreams(s.id).catch((err) => {
|
|
123
|
-
debug.warn('project', `Stream cleanup error for session ${s.id} during project delete:`, err);
|
|
124
|
-
}))
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
// Collect blob hashes before deleting
|
|
128
|
-
const baselineHashes = new Set<string>();
|
|
129
|
-
for (const s of sessions) {
|
|
130
|
-
for (const h of snapshotService.getSessionBaselineHashes(s.id)) {
|
|
131
|
-
baselineHashes.add(h);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
const allSnapshots = snapshotQueries.getAllByProjectId(data.id);
|
|
135
|
-
const deltaHashes = snapshotQueries.collectBlobHashes(allSnapshots);
|
|
136
|
-
|
|
137
|
-
// Clear in-memory baselines
|
|
138
|
-
for (const s of sessions) {
|
|
139
|
-
snapshotService.clearSessionBaseline(s.id);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Delete all sessions and related DB data
|
|
143
|
-
const deletedIds = sessionQueries.deleteAllByProjectId(data.id);
|
|
144
|
-
|
|
145
|
-
// GC orphaned blobs
|
|
146
|
-
const allBlobsOnDisk = await blobStore.scanAllBlobHashes();
|
|
147
|
-
const stillReferencedByDB = snapshotQueries.getAllReferencedBlobHashes();
|
|
148
|
-
const stillReferencedByMemory = snapshotService.getAllBaselineHashes();
|
|
149
|
-
const blobsToDelete = [...allBlobsOnDisk].filter(
|
|
150
|
-
h => !stillReferencedByDB.has(h) && !stillReferencedByMemory.has(h)
|
|
151
|
-
);
|
|
152
|
-
if (blobsToDelete.length > 0) {
|
|
153
|
-
const deleted = await blobStore.deleteBlobs(blobsToDelete);
|
|
154
|
-
debug.log('project', `Cleaned up ${deleted}/${blobsToDelete.length} orphaned blobs`);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Broadcast session deletions
|
|
158
|
-
for (const sessionId of deletedIds) {
|
|
159
|
-
ws.emit.project(data.id, 'sessions:session-deleted', { sessionId, projectId: data.id });
|
|
160
|
-
}
|
|
159
|
+
// Full delete: every chat goes through the shared purge (streams,
|
|
160
|
+
// snapshot blobs, memory bookkeeping, engine transcripts).
|
|
161
|
+
const { deletedIds } = await purgeSessions([], { wholeProject: data.id });
|
|
162
|
+
for (const sessionId of deletedIds) {
|
|
163
|
+
ws.emit.project(data.id, 'sessions:session-deleted', { sessionId, projectId: data.id });
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
|
|
@@ -178,4 +181,9 @@ export const crudHandler = createRouter()
|
|
|
178
181
|
id: data.id,
|
|
179
182
|
deleted: true
|
|
180
183
|
};
|
|
181
|
-
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
.emit('projects:updated', t.Object({
|
|
187
|
+
project: t.Any(),
|
|
188
|
+
previousPath: t.String()
|
|
189
|
+
}));
|
|
@@ -14,13 +14,9 @@ import { t } from 'elysia';
|
|
|
14
14
|
import { createRouter } from '$shared/utils/ws-server';
|
|
15
15
|
import type { EngineType } from '$shared/types/unified';
|
|
16
16
|
import type { ChatSession } from '$shared/types/database/schema';
|
|
17
|
-
import { sessionQueries,
|
|
17
|
+
import { sessionQueries, projectQueries, worktreeQueries } from '../../database/queries';
|
|
18
18
|
import { ws } from '$backend/utils/ws';
|
|
19
|
-
import {
|
|
20
|
-
import { snapshotService } from '../../snapshot/snapshot-service';
|
|
21
|
-
import { blobStore } from '../../snapshot/blob-store';
|
|
22
|
-
import { cancelEpisodicIngest } from '../../memory/extract';
|
|
23
|
-
import { forgetSessionContext } from '../../memory/context';
|
|
19
|
+
import { purgeSessions } from '../../storage/purge';
|
|
24
20
|
import { broadcastPresence } from '../projects/status';
|
|
25
21
|
import { debug } from '$shared/utils/logger';
|
|
26
22
|
import { requireCurrentProjectAccess, requireProjectAccess, requireSessionAccess } from '../access';
|
|
@@ -245,44 +241,9 @@ export const crudHandler = createRouter()
|
|
|
245
241
|
|
|
246
242
|
const projectId = session.project_id;
|
|
247
243
|
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// Collect ALL blob hashes before deleting anything:
|
|
252
|
-
// 1. In-memory baseline hashes (all project files hashed at session start)
|
|
253
|
-
const baselineHashes = snapshotService.getSessionBaselineHashes(data.id);
|
|
254
|
-
// 2. DB snapshot delta hashes (including soft-deleted snapshots)
|
|
255
|
-
const allSnapshots = snapshotQueries.getAllBySessionId(data.id);
|
|
256
|
-
const deltaHashes = snapshotQueries.collectBlobHashes(allSnapshots);
|
|
257
|
-
// Combine both sources
|
|
258
|
-
const hashesToCheck = new Set([...baselineHashes, ...deltaHashes]);
|
|
259
|
-
|
|
260
|
-
debug.log('session', `Session ${data.id}: ${baselineHashes.size} baseline hashes, ${deltaHashes.size} delta hashes, ${hashesToCheck.size} total unique`);
|
|
261
|
-
|
|
262
|
-
// Clear in-memory snapshot baseline
|
|
263
|
-
snapshotService.clearSessionBaseline(data.id);
|
|
264
|
-
|
|
265
|
-
// Drop any memory extraction parked for this session. It reads the message
|
|
266
|
-
// chain, which is about to be deleted, and its injection bookkeeping is now
|
|
267
|
-
// about a session that no longer exists.
|
|
268
|
-
cancelEpisodicIngest(data.id);
|
|
269
|
-
forgetSessionContext(data.id);
|
|
270
|
-
|
|
271
|
-
// Delete session and all related DB data (messages, snapshots, branches, relationships, unread)
|
|
272
|
-
sessionQueries.delete(data.id);
|
|
273
|
-
|
|
274
|
-
// Clean up orphaned blobs — protect hashes still used by other active sessions
|
|
275
|
-
if (hashesToCheck.size > 0) {
|
|
276
|
-
const stillReferencedByDB = snapshotQueries.getAllReferencedBlobHashes();
|
|
277
|
-
const stillReferencedByMemory = snapshotService.getAllBaselineHashes();
|
|
278
|
-
const orphanHashes = [...hashesToCheck].filter(
|
|
279
|
-
h => !stillReferencedByDB.has(h) && !stillReferencedByMemory.has(h)
|
|
280
|
-
);
|
|
281
|
-
if (orphanHashes.length > 0) {
|
|
282
|
-
const deleted = await blobStore.deleteBlobs(orphanHashes);
|
|
283
|
-
debug.log('session', `Cleaned up ${deleted}/${orphanHashes.length} orphaned blobs`);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
244
|
+
// Streams, snapshot blobs, memory bookkeeping and the engine's own
|
|
245
|
+
// transcript all go through the shared purge.
|
|
246
|
+
await purgeSessions([data.id]);
|
|
286
247
|
|
|
287
248
|
// Broadcast to the project so other devices see the deletion
|
|
288
249
|
debug.log('session', `Broadcasting session deleted: ${data.id} in project: ${projectId}`);
|
|
@@ -311,60 +272,11 @@ export const crudHandler = createRouter()
|
|
|
311
272
|
}, async ({ conn }) => {
|
|
312
273
|
const { projectId } = requireCurrentProjectAccess(conn);
|
|
313
274
|
|
|
314
|
-
|
|
315
|
-
const sessions = sessionQueries.getByProjectId(projectId);
|
|
316
|
-
if (sessions.length === 0) {
|
|
275
|
+
if (sessionQueries.getByProjectId(projectId).length === 0) {
|
|
317
276
|
return { message: 'No sessions to delete', deletedCount: 0 };
|
|
318
277
|
}
|
|
319
278
|
|
|
320
|
-
|
|
321
|
-
await Promise.all(
|
|
322
|
-
sessions.map(s => streamManager.cleanupSessionStreams(s.id).catch((err) => {
|
|
323
|
-
debug.warn('session', `Stream cleanup error for session ${s.id}:`, err);
|
|
324
|
-
}))
|
|
325
|
-
);
|
|
326
|
-
|
|
327
|
-
// Collect ALL blob hashes before deleting anything:
|
|
328
|
-
// 1. In-memory baseline hashes from all sessions
|
|
329
|
-
const baselineHashes = new Set<string>();
|
|
330
|
-
for (const s of sessions) {
|
|
331
|
-
for (const h of snapshotService.getSessionBaselineHashes(s.id)) {
|
|
332
|
-
baselineHashes.add(h);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
// 2. DB snapshot delta hashes (including soft-deleted)
|
|
336
|
-
const allSnapshots = snapshotQueries.getAllByProjectId(projectId);
|
|
337
|
-
const deltaHashes = snapshotQueries.collectBlobHashes(allSnapshots);
|
|
338
|
-
// Combine both sources
|
|
339
|
-
const hashesToCheck = new Set([...baselineHashes, ...deltaHashes]);
|
|
340
|
-
|
|
341
|
-
debug.log('session', `Project ${projectId}: ${baselineHashes.size} baseline hashes, ${deltaHashes.size} delta hashes, ${hashesToCheck.size} total unique`);
|
|
342
|
-
|
|
343
|
-
// Clear in-memory snapshot baselines for all sessions
|
|
344
|
-
for (const s of sessions) {
|
|
345
|
-
snapshotService.clearSessionBaseline(s.id);
|
|
346
|
-
cancelEpisodicIngest(s.id);
|
|
347
|
-
forgetSessionContext(s.id);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// Delete all sessions and related DB data (messages, snapshots, branches, relationships, unread)
|
|
351
|
-
const deletedIds = sessionQueries.deleteAllByProjectId(projectId);
|
|
352
|
-
|
|
353
|
-
// Clean up orphaned blobs using mark-and-sweep GC:
|
|
354
|
-
// Scan ALL blobs on disk, keep those still referenced by remaining DB snapshots
|
|
355
|
-
// or by in-memory baselines of other active sessions (other projects)
|
|
356
|
-
const allBlobsOnDisk = await blobStore.scanAllBlobHashes();
|
|
357
|
-
const stillReferencedByDB = snapshotQueries.getAllReferencedBlobHashes();
|
|
358
|
-
const stillReferencedByMemory = snapshotService.getAllBaselineHashes();
|
|
359
|
-
|
|
360
|
-
const blobsToDelete = [...allBlobsOnDisk].filter(
|
|
361
|
-
h => !stillReferencedByDB.has(h) && !stillReferencedByMemory.has(h)
|
|
362
|
-
);
|
|
363
|
-
|
|
364
|
-
if (blobsToDelete.length > 0) {
|
|
365
|
-
const deleted = await blobStore.deleteBlobs(blobsToDelete);
|
|
366
|
-
debug.log('session', `Cleaned up ${deleted}/${blobsToDelete.length} orphaned blobs (full GC after bulk delete)`);
|
|
367
|
-
}
|
|
279
|
+
const { deletedIds } = await purgeSessions([], { wholeProject: projectId });
|
|
368
280
|
|
|
369
281
|
// Broadcast deletion for each session so all connected users update their state
|
|
370
282
|
for (const sessionId of deletedIds) {
|
|
@@ -67,7 +67,7 @@ const TURN_FILE_SCHEMA = t.Object({
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
/** Parse a snapshot's stored changes, treating unreadable JSON as "no changes". */
|
|
70
|
-
function parseSessionChanges(raw: unknown): SessionScopedChanges {
|
|
70
|
+
export function parseSessionChanges(raw: unknown): SessionScopedChanges {
|
|
71
71
|
if (typeof raw !== 'string' || raw === '') return {};
|
|
72
72
|
try {
|
|
73
73
|
return JSON.parse(raw) as SessionScopedChanges;
|
|
@@ -77,7 +77,7 @@ function parseSessionChanges(raw: unknown): SessionScopedChanges {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
/** Read a blob as text, or null when it is missing or not text. */
|
|
80
|
-
async function readTextBlob(hash: string): Promise<string | null> {
|
|
80
|
+
export async function readTextBlob(hash: string): Promise<string | null> {
|
|
81
81
|
if (!hash) return null;
|
|
82
82
|
try {
|
|
83
83
|
const buf = await blobStore.readBlob(hash);
|
|
@@ -92,7 +92,7 @@ async function readTextBlob(hash: string): Promise<string | null> {
|
|
|
92
92
|
* changes are still on disk. Empty when the chat was restored to before its
|
|
93
93
|
* first message.
|
|
94
94
|
*/
|
|
95
|
-
function activeCheckpoints(sessionId: string): DatabaseMessage[] {
|
|
95
|
+
export function activeCheckpoints(sessionId: string): DatabaseMessage[] {
|
|
96
96
|
const allMessages = messageQueries.getAllBySessionId(sessionId);
|
|
97
97
|
if (allMessages.length === 0) return [];
|
|
98
98
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Router — Settings → Storage.
|
|
3
|
+
*
|
|
4
|
+
* - storage:get the last report, scan status, policy, actions, history
|
|
5
|
+
* - storage:scan start a scan (or join the running one); progress arrives
|
|
6
|
+
* as `storage:scan-status`
|
|
7
|
+
* - storage:estimate what an action would free, for the confirm dialog
|
|
8
|
+
* - storage:cleanup run an action now
|
|
9
|
+
* - storage:policy-save save the schedule
|
|
10
|
+
* - storage:run-now run the scheduled set now
|
|
11
|
+
*
|
|
12
|
+
* Report and result payloads are typed in `$shared/types/storage` and sent as
|
|
13
|
+
* `t.Any()`, like the other report-shaped endpoints.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { t } from 'elysia';
|
|
17
|
+
import { createRouter } from '$shared/utils/ws-server';
|
|
18
|
+
import { ws } from '$backend/utils/ws';
|
|
19
|
+
import type { CleanupActionId, StoragePolicy } from '$shared/types/storage';
|
|
20
|
+
import { broadcastPresence } from '../projects/status';
|
|
21
|
+
import { CLEANUP_ACTIONS, estimateCleanup, runCleanup, runningCleanup } from '../../storage/actions';
|
|
22
|
+
import { listCleanupRuns } from '../../storage/history';
|
|
23
|
+
import { getStoragePolicy, runScheduledCleanup, saveStoragePolicy } from '../../storage/policy';
|
|
24
|
+
import { getLastStorageReport, getStorageScanStatus, onStorageScan, scanStorage } from '../../storage/scanner';
|
|
25
|
+
|
|
26
|
+
const actionIds = CLEANUP_ACTIONS.map(action => t.Literal(action.id));
|
|
27
|
+
const cleanupRequest = t.Object({
|
|
28
|
+
action: t.Union(actionIds),
|
|
29
|
+
projectId: t.Optional(t.Union([t.String(), t.Null()])),
|
|
30
|
+
olderThanDays: t.Optional(t.Number({ minimum: 1, maximum: 3650 }))
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
onStorageScan((status, report) => {
|
|
34
|
+
ws.emit.global('storage:scan-status', { status, report });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function snapshot() {
|
|
38
|
+
return {
|
|
39
|
+
report: getLastStorageReport(),
|
|
40
|
+
status: getStorageScanStatus(),
|
|
41
|
+
policy: getStoragePolicy(),
|
|
42
|
+
actions: CLEANUP_ACTIONS,
|
|
43
|
+
history: listCleanupRuns(),
|
|
44
|
+
running: runningCleanup()
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const storageRouter = createRouter()
|
|
49
|
+
.http('storage:get', {
|
|
50
|
+
data: t.Object({}),
|
|
51
|
+
response: t.Any()
|
|
52
|
+
}, async () => snapshot())
|
|
53
|
+
|
|
54
|
+
.http('storage:scan', {
|
|
55
|
+
data: t.Object({}),
|
|
56
|
+
response: t.Any()
|
|
57
|
+
}, async () => {
|
|
58
|
+
void scanStorage().catch(() => {});
|
|
59
|
+
return getStorageScanStatus();
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
.http('storage:estimate', {
|
|
63
|
+
data: cleanupRequest,
|
|
64
|
+
response: t.Any()
|
|
65
|
+
}, async ({ data }) => estimateCleanup({ ...data, action: data.action as CleanupActionId }))
|
|
66
|
+
|
|
67
|
+
.http('storage:cleanup', {
|
|
68
|
+
data: cleanupRequest,
|
|
69
|
+
response: t.Any()
|
|
70
|
+
}, async ({ data }) => {
|
|
71
|
+
const result = await runCleanup({ ...data, action: data.action as CleanupActionId }, 'manual');
|
|
72
|
+
ws.emit.global('storage:cleanup-finished', { result, history: listCleanupRuns() });
|
|
73
|
+
if (data.action === 'delete-old-chats') {
|
|
74
|
+
broadcastPresence().catch(() => {});
|
|
75
|
+
}
|
|
76
|
+
void scanStorage().catch(() => {});
|
|
77
|
+
return result;
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
.http('storage:policy-save', {
|
|
81
|
+
data: t.Object({ policy: t.Any() }),
|
|
82
|
+
response: t.Any()
|
|
83
|
+
}, async ({ data }) => saveStoragePolicy(data.policy as StoragePolicy))
|
|
84
|
+
|
|
85
|
+
.http('storage:run-now', {
|
|
86
|
+
data: t.Object({}),
|
|
87
|
+
response: t.Any()
|
|
88
|
+
}, async () => {
|
|
89
|
+
void runScheduledCleanup().then(() => {
|
|
90
|
+
ws.emit.global('storage:cleanup-finished', { result: null, history: listCleanupRuns() });
|
|
91
|
+
});
|
|
92
|
+
return { started: true };
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
.emit('storage:scan-status', t.Object({
|
|
96
|
+
status: t.Any(),
|
|
97
|
+
report: t.Any()
|
|
98
|
+
}))
|
|
99
|
+
.emit('storage:cleanup-finished', t.Object({
|
|
100
|
+
result: t.Any(),
|
|
101
|
+
history: t.Any()
|
|
102
|
+
}));
|