@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,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheduled cleanup.
|
|
3
|
+
*
|
|
4
|
+
* Every action that can be automated can be switched on here, with the same
|
|
5
|
+
* parameters it takes by hand. The defaults switch on only what nothing uses —
|
|
6
|
+
* leftovers, duplicates, old logs — because those are pure loss to keep. Caches,
|
|
7
|
+
* the database rebuild, worktrees and old chats are off until the user turns them
|
|
8
|
+
* on: each has a cost (a download, a pause, lost history) that is theirs to
|
|
9
|
+
* accept.
|
|
10
|
+
*
|
|
11
|
+
* A run happens at most once per `intervalHours`, only while nothing is
|
|
12
|
+
* streaming, and stops between actions as soon as a chat starts.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { settingsQueries } from '$backend/database/queries/settings-queries';
|
|
16
|
+
import type { CleanupActionId, StoragePolicy } from '$shared/types/storage';
|
|
17
|
+
import { debug } from '$shared/utils/logger';
|
|
18
|
+
import { CLEANUP_ACTIONS, runCleanup, runningCleanup } from './actions';
|
|
19
|
+
import { activeChatIds } from './purge';
|
|
20
|
+
import { scanStorage } from './scanner';
|
|
21
|
+
|
|
22
|
+
const POLICY_SETTING = 'storage_policy';
|
|
23
|
+
const TICK_MS = 30 * 60_000;
|
|
24
|
+
const FIRST_TICK_MS = 10 * 60_000;
|
|
25
|
+
|
|
26
|
+
/** Order a scheduled run goes in: cheap and safe first, the database last. */
|
|
27
|
+
const RUN_ORDER: CleanupActionId[] = [
|
|
28
|
+
'orphan-transcripts', 'dedupe-transcripts', 'orphan-snapshots', 'orphan-profiles', 'orphan-worktree-dirs',
|
|
29
|
+
'legacy-engine-data', 'engine-logs', 'browser-cache', 'tool-caches', 'stale-worktrees',
|
|
30
|
+
'slim-old-chats', 'delete-old-chats', 'compact-database'
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export function defaultStoragePolicy(): StoragePolicy {
|
|
34
|
+
return {
|
|
35
|
+
enabled: true,
|
|
36
|
+
intervalHours: 24,
|
|
37
|
+
actions: {
|
|
38
|
+
'orphan-transcripts': { enabled: true },
|
|
39
|
+
'dedupe-transcripts': { enabled: true },
|
|
40
|
+
'orphan-snapshots': { enabled: true },
|
|
41
|
+
'orphan-profiles': { enabled: true },
|
|
42
|
+
'orphan-worktree-dirs': { enabled: true },
|
|
43
|
+
'legacy-engine-data': { enabled: true },
|
|
44
|
+
'engine-logs': { enabled: true },
|
|
45
|
+
'browser-cache': { enabled: false },
|
|
46
|
+
'tool-caches': { enabled: false },
|
|
47
|
+
'compact-database': { enabled: false },
|
|
48
|
+
'stale-worktrees': { enabled: false, olderThanDays: 60 },
|
|
49
|
+
'slim-old-chats': { enabled: false, olderThanDays: 90 },
|
|
50
|
+
'delete-old-chats': { enabled: false, olderThanDays: 365 }
|
|
51
|
+
},
|
|
52
|
+
lastRunAt: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getStoragePolicy(): StoragePolicy {
|
|
57
|
+
const defaults = defaultStoragePolicy();
|
|
58
|
+
const raw = settingsQueries.get(POLICY_SETTING)?.value;
|
|
59
|
+
if (!raw) return defaults;
|
|
60
|
+
try {
|
|
61
|
+
const saved = JSON.parse(raw) as Partial<StoragePolicy>;
|
|
62
|
+
return {
|
|
63
|
+
enabled: saved.enabled ?? defaults.enabled,
|
|
64
|
+
intervalHours: saved.intervalHours ?? defaults.intervalHours,
|
|
65
|
+
actions: { ...defaults.actions, ...saved.actions },
|
|
66
|
+
lastRunAt: saved.lastRunAt ?? null
|
|
67
|
+
};
|
|
68
|
+
} catch {
|
|
69
|
+
return defaults;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function saveStoragePolicy(policy: StoragePolicy): StoragePolicy {
|
|
74
|
+
const automatable = new Set(CLEANUP_ACTIONS.filter(action => action.automatable).map(action => action.id));
|
|
75
|
+
const clean: StoragePolicy = {
|
|
76
|
+
enabled: !!policy.enabled,
|
|
77
|
+
intervalHours: Math.min(24 * 30, Math.max(1, Math.round(policy.intervalHours || 24))),
|
|
78
|
+
actions: {},
|
|
79
|
+
lastRunAt: getStoragePolicy().lastRunAt
|
|
80
|
+
};
|
|
81
|
+
for (const [id, setting] of Object.entries(policy.actions ?? {})) {
|
|
82
|
+
if (!automatable.has(id as CleanupActionId) || !setting) continue;
|
|
83
|
+
clean.actions[id as CleanupActionId] = {
|
|
84
|
+
enabled: !!setting.enabled,
|
|
85
|
+
...(setting.olderThanDays !== undefined && {
|
|
86
|
+
olderThanDays: Math.min(3650, Math.max(1, Math.round(setting.olderThanDays)))
|
|
87
|
+
})
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
settingsQueries.set(POLICY_SETTING, JSON.stringify(clean));
|
|
91
|
+
return getStoragePolicy();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function markRun(): void {
|
|
95
|
+
const policy = getStoragePolicy();
|
|
96
|
+
settingsQueries.set(POLICY_SETTING, JSON.stringify({ ...policy, lastRunAt: new Date().toISOString() }));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let timer: ReturnType<typeof setInterval> | null = null;
|
|
100
|
+
let runInFlight: Promise<void> | null = null;
|
|
101
|
+
|
|
102
|
+
/** Run every enabled action now, in order. */
|
|
103
|
+
export function runScheduledCleanup(): Promise<void> {
|
|
104
|
+
if (runInFlight) return runInFlight;
|
|
105
|
+
runInFlight = (async () => {
|
|
106
|
+
const policy = getStoragePolicy();
|
|
107
|
+
markRun();
|
|
108
|
+
for (const action of RUN_ORDER) {
|
|
109
|
+
const setting = policy.actions[action];
|
|
110
|
+
if (!setting?.enabled) continue;
|
|
111
|
+
if (activeChatIds().size > 0) {
|
|
112
|
+
debug.log('storage', 'Scheduled cleanup paused: a chat started');
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
await runCleanup({ action, ...(setting.olderThanDays && { olderThanDays: setting.olderThanDays }) }, 'auto');
|
|
117
|
+
} catch (error) {
|
|
118
|
+
debug.warn('storage', `Scheduled ${action} failed:`, error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
await scanStorage().catch(() => {});
|
|
122
|
+
})().finally(() => {
|
|
123
|
+
runInFlight = null;
|
|
124
|
+
});
|
|
125
|
+
return runInFlight;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function due(policy: StoragePolicy): boolean {
|
|
129
|
+
if (!policy.enabled) return false;
|
|
130
|
+
if (!policy.lastRunAt) return true;
|
|
131
|
+
return Date.now() - Date.parse(policy.lastRunAt) >= policy.intervalHours * 60 * 60_000;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function tick(): Promise<void> {
|
|
135
|
+
if (runInFlight || runningCleanup()) return;
|
|
136
|
+
if (activeChatIds().size > 0) return;
|
|
137
|
+
try {
|
|
138
|
+
if (due(getStoragePolicy())) await runScheduledCleanup();
|
|
139
|
+
} catch (error) {
|
|
140
|
+
debug.warn('storage', 'Storage maintenance tick failed:', error);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function startStorageMaintenance(): void {
|
|
145
|
+
if (timer) return;
|
|
146
|
+
timer = setInterval(() => void tick(), TICK_MS);
|
|
147
|
+
timer.unref?.();
|
|
148
|
+
const first = setTimeout(() => void tick(), FIRST_TICK_MS);
|
|
149
|
+
first.unref?.();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function stopStorageMaintenance(): void {
|
|
153
|
+
if (!timer) return;
|
|
154
|
+
clearInterval(timer);
|
|
155
|
+
timer = null;
|
|
156
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview Browser profiles: one Chrome user-data dir per workspace, named
|
|
3
|
+
* `<scope slug>-<sha256(scope key) prefix>` with a `.cookies` file beside it.
|
|
4
|
+
*
|
|
5
|
+
* A workspace is a project or one of its worktrees (`makeScopeKey`), so every
|
|
6
|
+
* profile that belongs to something that still exists can be named exactly;
|
|
7
|
+
* anything else in the folder is left over from a deleted project or worktree,
|
|
8
|
+
* or from a tab opened without a workspace.
|
|
9
|
+
*
|
|
10
|
+
* Chrome must not be running on a profile while its files are removed. Profiles
|
|
11
|
+
* with a live browser are skipped by every operation here except a full wipe,
|
|
12
|
+
* which closes the browser first (`browserPool.clearBrowsingData`).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import fs from 'node:fs/promises';
|
|
16
|
+
import { join } from 'node:path';
|
|
17
|
+
import { projectQueries, worktreeQueries } from '$backend/database/queries';
|
|
18
|
+
import { browserPool, profileDirName, profilesRoot } from '$backend/preview/browser/browser-pool';
|
|
19
|
+
import { makeScopeKey } from '$shared/utils/workspace-scope';
|
|
20
|
+
import { debug } from '$shared/utils/logger';
|
|
21
|
+
import { measurePath, removePath } from './fs-size';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* What Chrome's own "Cached images and files" clears, plus the GPU and shader
|
|
25
|
+
* caches it rebuilds on launch. Cookies, local storage, IndexedDB and service
|
|
26
|
+
* worker registrations are site data and are NOT here — removing them signs the
|
|
27
|
+
* user out, which only a full wipe may do.
|
|
28
|
+
*/
|
|
29
|
+
const CACHE_DIRS_IN_PROFILE = ['Cache', 'Code Cache', 'GPUCache', 'DawnGraphiteCache', 'DawnWebGPUCache', 'Service Worker/ScriptCache'];
|
|
30
|
+
const CACHE_DIRS_AT_ROOT = ['GPUPersistentCache', 'GraphiteDawnCache', 'GrShaderCache', 'ShaderCache', 'component_crx_cache', 'extensions_crx_cache'];
|
|
31
|
+
|
|
32
|
+
export interface ProfileDir {
|
|
33
|
+
name: string;
|
|
34
|
+
path: string;
|
|
35
|
+
bytes: number;
|
|
36
|
+
cacheBytes: number;
|
|
37
|
+
mtimeMs: number;
|
|
38
|
+
/** The workspace this profile belongs to, when it still exists. */
|
|
39
|
+
scope: { projectId: string; worktreeId: string | null } | null;
|
|
40
|
+
running: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Profile folders (Default plus any other Chrome profile) inside a user-data dir. */
|
|
44
|
+
async function chromeProfiles(dir: string): Promise<string[]> {
|
|
45
|
+
try {
|
|
46
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
47
|
+
return entries
|
|
48
|
+
.filter(entry => entry.isDirectory() && (entry.name === 'Default' || /^Profile \d+$/.test(entry.name)))
|
|
49
|
+
.map(entry => join(dir, entry.name));
|
|
50
|
+
} catch {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function cachePaths(dir: string, profiles: string[]): string[] {
|
|
56
|
+
return [
|
|
57
|
+
...CACHE_DIRS_AT_ROOT.map(name => join(dir, name)),
|
|
58
|
+
...profiles.flatMap(profile => CACHE_DIRS_IN_PROFILE.map(name => join(profile, name)))
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function knownScopes(): Map<string, { projectId: string; worktreeId: string | null }> {
|
|
63
|
+
const scopes = new Map<string, { projectId: string; worktreeId: string | null }>();
|
|
64
|
+
for (const project of projectQueries.getAll()) {
|
|
65
|
+
scopes.set(profileDirName(makeScopeKey(project.id)), { projectId: project.id, worktreeId: null });
|
|
66
|
+
for (const worktree of worktreeQueries.getByProjectId(project.id)) {
|
|
67
|
+
scopes.set(profileDirName(makeScopeKey(project.id, worktree.id)), { projectId: project.id, worktreeId: worktree.id });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return scopes;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function runningDirNames(): Set<string> {
|
|
74
|
+
return new Set(browserPool.getRunningBrowsers().map(entry => profileDirName(entry.profileKey)));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function listProfileDirs(signal?: AbortSignal): Promise<ProfileDir[]> {
|
|
78
|
+
const root = profilesRoot();
|
|
79
|
+
let entries: import('node:fs').Dirent[];
|
|
80
|
+
try {
|
|
81
|
+
entries = await fs.readdir(root, { withFileTypes: true });
|
|
82
|
+
} catch {
|
|
83
|
+
return [];
|
|
84
|
+
}
|
|
85
|
+
const scopes = knownScopes();
|
|
86
|
+
const running = runningDirNames();
|
|
87
|
+
const dirs: ProfileDir[] = [];
|
|
88
|
+
for (const entry of entries) {
|
|
89
|
+
if (signal?.aborted) break;
|
|
90
|
+
if (!entry.isDirectory()) continue;
|
|
91
|
+
const path = join(root, entry.name);
|
|
92
|
+
const profiles = await chromeProfiles(path);
|
|
93
|
+
let cacheBytes = 0;
|
|
94
|
+
for (const cache of cachePaths(path, profiles)) cacheBytes += (await measurePath(cache)).bytes;
|
|
95
|
+
const cookies = await fs.stat(`${path}.cookies`).catch(() => null);
|
|
96
|
+
const stat = await fs.stat(path).catch(() => null);
|
|
97
|
+
dirs.push({
|
|
98
|
+
name: entry.name,
|
|
99
|
+
path,
|
|
100
|
+
bytes: (await measurePath(path, signal)).bytes + (cookies?.size ?? 0),
|
|
101
|
+
cacheBytes,
|
|
102
|
+
mtimeMs: Math.max(stat?.mtimeMs ?? 0, cookies?.mtimeMs ?? 0),
|
|
103
|
+
scope: scopes.get(entry.name) ?? null,
|
|
104
|
+
running: running.has(entry.name)
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return dirs;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Profiles that belong to no existing workspace. */
|
|
111
|
+
export function orphanProfiles(dirs: ProfileDir[]): ProfileDir[] {
|
|
112
|
+
return dirs.filter(dir => !dir.scope && !dir.running);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function removeProfileDirs(dirs: ProfileDir[]): Promise<{ freedBytes: number; removed: number }> {
|
|
116
|
+
let freedBytes = 0;
|
|
117
|
+
let removed = 0;
|
|
118
|
+
const running = runningDirNames();
|
|
119
|
+
for (const dir of dirs) {
|
|
120
|
+
if (running.has(dir.name)) continue;
|
|
121
|
+
freedBytes += await removePath(dir.path);
|
|
122
|
+
freedBytes += await removePath(`${dir.path}.cookies`);
|
|
123
|
+
removed++;
|
|
124
|
+
}
|
|
125
|
+
return { freedBytes, removed };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Delete the caches of every profile whose browser is not running. Sign-ins stay. */
|
|
129
|
+
export async function clearProfileCaches(dirs: ProfileDir[]): Promise<{ freedBytes: number; cleared: number; skipped: number }> {
|
|
130
|
+
let freedBytes = 0;
|
|
131
|
+
let cleared = 0;
|
|
132
|
+
let skipped = 0;
|
|
133
|
+
const running = runningDirNames();
|
|
134
|
+
for (const dir of dirs) {
|
|
135
|
+
if (running.has(dir.name)) {
|
|
136
|
+
skipped++;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
for (const cache of cachePaths(dir.path, await chromeProfiles(dir.path))) freedBytes += await removePath(cache);
|
|
140
|
+
cleared++;
|
|
141
|
+
}
|
|
142
|
+
return { freedBytes, cleared, skipped };
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Wipe a workspace's profile completely — cookies, storage, sign-ins — closing
|
|
147
|
+
* its browser first. Used when the workspace itself is going away.
|
|
148
|
+
*/
|
|
149
|
+
export async function wipeWorkspaceProfile(projectId: string, worktreeId?: string | null): Promise<number> {
|
|
150
|
+
const key = makeScopeKey(projectId, worktreeId);
|
|
151
|
+
const path = join(profilesRoot(), profileDirName(key));
|
|
152
|
+
const { bytes } = await measurePath(path);
|
|
153
|
+
try {
|
|
154
|
+
await browserPool.clearBrowsingData(key);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
debug.warn('storage', `Could not wipe the preview profile of ${key}:`, error);
|
|
157
|
+
return 0;
|
|
158
|
+
}
|
|
159
|
+
return bytes;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Wipe the profiles of a project and all of its worktrees. */
|
|
163
|
+
export async function wipeProjectProfiles(projectId: string): Promise<number> {
|
|
164
|
+
let freed = await wipeWorkspaceProfile(projectId);
|
|
165
|
+
for (const worktree of worktreeQueries.getByProjectId(projectId)) {
|
|
166
|
+
freed += await wipeWorkspaceProfile(projectId, worktree.id);
|
|
167
|
+
}
|
|
168
|
+
return freed;
|
|
169
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deleting chats — the one path every deletion goes through.
|
|
3
|
+
*
|
|
4
|
+
* Deleting one chat, deleting all of a project's chats, deleting a project, and
|
|
5
|
+
* Storage's "delete old chats" used to be three copies of the same steps, and
|
|
6
|
+
* each had drifted: none removed the engine's own transcript of the chat, and
|
|
7
|
+
* the project path forgot the memory-extraction bookkeeping. They all call this
|
|
8
|
+
* now, so a chat leaves nothing behind whichever way it goes.
|
|
9
|
+
*
|
|
10
|
+
* Order matters:
|
|
11
|
+
* 1. stop the chat's streams, so nothing writes while it is torn down
|
|
12
|
+
* 2. collect the snapshot blobs and engine sessions the chat refers to
|
|
13
|
+
* 3. delete the rows
|
|
14
|
+
* 4. delete blobs nothing else refers to
|
|
15
|
+
* 5. delete engine transcripts nothing else refers to — in the background,
|
|
16
|
+
* because deciding "nothing else" needs a current index of every chat,
|
|
17
|
+
* and building that the first time takes as long as reading the whole
|
|
18
|
+
* message table. The deletion is finished from the user's point of view
|
|
19
|
+
* after step 4.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { sessionQueries, snapshotQueries } from '$backend/database/queries';
|
|
23
|
+
import { streamManager } from '$backend/chat/stream-manager';
|
|
24
|
+
import { snapshotService } from '$backend/snapshot/snapshot-service';
|
|
25
|
+
import { blobStore } from '$backend/snapshot/blob-store';
|
|
26
|
+
import { cancelEpisodicIngest } from '$backend/memory/extract';
|
|
27
|
+
import { forgetSessionContext } from '$backend/memory/context';
|
|
28
|
+
import type { EngineType } from '$shared/types/unified';
|
|
29
|
+
import { debug } from '$shared/utils/logger';
|
|
30
|
+
import { collectEngineRefs, ensureFreshSessionIndex, measureSession, type EngineRef } from './session-index';
|
|
31
|
+
import { listAllTranscripts, transcriptStoreFor } from './transcripts';
|
|
32
|
+
import { pruneTranscriptAliases } from './transcripts/aliases';
|
|
33
|
+
import { recordCleanupRun } from './history';
|
|
34
|
+
|
|
35
|
+
export interface PurgeResult {
|
|
36
|
+
deletedIds: string[];
|
|
37
|
+
freedBlobs: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Delete chats and everything that exists only because of them.
|
|
42
|
+
* `wholeProject` deletes every chat of that project in one statement set.
|
|
43
|
+
*/
|
|
44
|
+
export async function purgeSessions(
|
|
45
|
+
sessionIds: string[],
|
|
46
|
+
options: { wholeProject?: string } = {}
|
|
47
|
+
): Promise<PurgeResult> {
|
|
48
|
+
const ids = options.wholeProject
|
|
49
|
+
? sessionQueries.getByProjectId(options.wholeProject).map(session => session.id)
|
|
50
|
+
: sessionIds.filter(id => sessionQueries.getById(id));
|
|
51
|
+
if (ids.length === 0) return { deletedIds: [], freedBlobs: 0 };
|
|
52
|
+
|
|
53
|
+
await Promise.all(ids.map(id => streamManager.cleanupSessionStreams(id).catch(error => {
|
|
54
|
+
debug.warn('session', `Stream cleanup error for session ${id}:`, error);
|
|
55
|
+
})));
|
|
56
|
+
|
|
57
|
+
const hashes = new Set<string>();
|
|
58
|
+
const refs: EngineRef[] = [];
|
|
59
|
+
for (const id of ids) {
|
|
60
|
+
for (const hash of snapshotService.getSessionBaselineHashes(id)) hashes.add(hash);
|
|
61
|
+
for (const hash of snapshotQueries.collectBlobHashes(snapshotQueries.getAllBySessionId(id))) hashes.add(hash);
|
|
62
|
+
try {
|
|
63
|
+
refs.push(...measureSession(id).refs);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
debug.warn('storage', `Could not read engine references of ${id}:`, error);
|
|
66
|
+
}
|
|
67
|
+
snapshotService.clearSessionBaseline(id);
|
|
68
|
+
cancelEpisodicIngest(id);
|
|
69
|
+
forgetSessionContext(id);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const deletedIds = options.wholeProject
|
|
73
|
+
? sessionQueries.deleteAllByProjectId(options.wholeProject)
|
|
74
|
+
: (ids.forEach(id => sessionQueries.delete(id)), ids);
|
|
75
|
+
|
|
76
|
+
const freedBlobs = await collectOrphanBlobs(hashes);
|
|
77
|
+
if (refs.length > 0) void releaseTranscripts(refs);
|
|
78
|
+
|
|
79
|
+
return { deletedIds, freedBlobs };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Delete those of `candidates` that no snapshot row and no live baseline uses. */
|
|
83
|
+
export async function collectOrphanBlobs(candidates: Set<string>): Promise<number> {
|
|
84
|
+
if (candidates.size === 0) return 0;
|
|
85
|
+
const referencedByDb = snapshotQueries.getAllReferencedBlobHashes();
|
|
86
|
+
const referencedByMemory = snapshotService.getAllBaselineHashes();
|
|
87
|
+
const orphaned = [...candidates].filter(hash => !referencedByDb.has(hash) && !referencedByMemory.has(hash));
|
|
88
|
+
if (orphaned.length === 0) return 0;
|
|
89
|
+
const deleted = await blobStore.deleteBlobs(orphaned);
|
|
90
|
+
debug.log('snapshot', `Cleaned up ${deleted}/${orphaned.length} orphaned blobs`);
|
|
91
|
+
return deleted;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Remove the engine transcripts of deleted chats that no remaining chat refers
|
|
96
|
+
* to. Runs after the deletion has returned; a failure here only leaves files the
|
|
97
|
+
* orphan cleanup will find later.
|
|
98
|
+
*/
|
|
99
|
+
export async function releaseTranscripts(refs: EngineRef[]): Promise<number> {
|
|
100
|
+
const startedAt = new Date().toISOString();
|
|
101
|
+
try {
|
|
102
|
+
await ensureFreshSessionIndex(activeChatIds());
|
|
103
|
+
const { byEngine } = collectEngineRefs();
|
|
104
|
+
const active = activeEngineSessionIds();
|
|
105
|
+
const release = new Map<EngineType, Set<string>>();
|
|
106
|
+
for (const ref of refs) {
|
|
107
|
+
if (byEngine.get(ref.engine)?.has(ref.id) || active.has(ref.id)) continue;
|
|
108
|
+
let set = release.get(ref.engine);
|
|
109
|
+
if (!set) release.set(ref.engine, set = new Set());
|
|
110
|
+
set.add(ref.id);
|
|
111
|
+
}
|
|
112
|
+
if (release.size === 0) return 0;
|
|
113
|
+
|
|
114
|
+
const entries = await listAllTranscripts();
|
|
115
|
+
let freed = 0;
|
|
116
|
+
let removed = 0;
|
|
117
|
+
for (const [engine, set] of release) {
|
|
118
|
+
const store = transcriptStoreFor(engine);
|
|
119
|
+
if (!store) continue;
|
|
120
|
+
const result = await store.remove(entries.filter(entry => entry.engine === engine && set.has(entry.id)));
|
|
121
|
+
freed += result.freedBytes;
|
|
122
|
+
removed += result.removed;
|
|
123
|
+
for (const error of result.errors) debug.warn('storage', `Transcript removal: ${error}`);
|
|
124
|
+
}
|
|
125
|
+
pruneTranscriptAliases('claude-code', new Set(byEngine.get('claude-code') ?? []));
|
|
126
|
+
if (removed > 0) {
|
|
127
|
+
recordCleanupRun({
|
|
128
|
+
action: 'orphan-transcripts', trigger: 'delete', startedAt,
|
|
129
|
+
finishedAt: new Date().toISOString(), freedBytes: freed, items: removed, error: null
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return freed;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
debug.warn('storage', 'Could not release engine transcripts of deleted chats:', error);
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Engine session ids a running stream is reading from or writing to. */
|
|
140
|
+
export function activeEngineSessionIds(): Set<string> {
|
|
141
|
+
const ids = new Set<string>();
|
|
142
|
+
for (const stream of streamManager.getAllStreams()) {
|
|
143
|
+
if (stream.status !== 'active') continue;
|
|
144
|
+
if (stream.sdkSessionId) ids.add(stream.sdkSessionId);
|
|
145
|
+
if (stream.preStreamSessionId) ids.add(stream.preStreamSessionId);
|
|
146
|
+
if (stream.resumeTargetSessionId) ids.add(stream.resumeTargetSessionId);
|
|
147
|
+
}
|
|
148
|
+
return ids;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Chats with a running stream. Nothing of theirs is touched by a cleanup. */
|
|
152
|
+
export function activeChatIds(): Set<string> {
|
|
153
|
+
const ids = new Set<string>();
|
|
154
|
+
for (const stream of streamManager.getAllStreams()) {
|
|
155
|
+
if (stream.status === 'active') ids.add(stream.chatSessionId);
|
|
156
|
+
}
|
|
157
|
+
return ids;
|
|
158
|
+
}
|