@myrialabs/clopen 0.4.49 → 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/background-wait.test.ts +28 -0
- package/backend/chat/engine-handoff.ts +42 -6
- package/backend/chat/message-pages.test.ts +17 -0
- package/backend/chat/message-pages.ts +6 -2
- package/backend/chat/stream-manager.ts +114 -19
- 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/088_create_messages_fts_map.ts +52 -0
- package/backend/database/migrations/089_add_memory_layout_tiles.ts +58 -0
- package/backend/database/migrations/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +25 -2
- package/backend/database/queries/graph-queries.ts +392 -135
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/message-fts.test.ts +120 -0
- package/backend/database/queries/message-queries.ts +45 -9
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-queries.ts +6 -2
- package/backend/database/queries/utils-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/environment.ts +4 -0
- package/backend/engine/adapters/claude/input-gate.test.ts +59 -0
- package/backend/engine/adapters/claude/input-gate.ts +74 -0
- package/backend/engine/adapters/claude/message-converter.test.ts +16 -0
- package/backend/engine/adapters/claude/message-converter.ts +8 -0
- package/backend/engine/adapters/claude/stream.ts +20 -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.test.ts +7 -4
- 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 +84 -17
- 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/memory/README.md +7 -4
- package/backend/memory/layout.test.ts +377 -0
- package/backend/memory/layout.ts +1029 -265
- package/backend/memory/view.ts +257 -386
- 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/project/status-manager.ts +4 -2
- 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/chat/stream.ts +19 -10
- 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/memory/crud.ts +118 -81
- package/backend/ws/mentions/index.ts +81 -0
- package/backend/ws/messages/crud.ts +3 -1
- 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 +18 -18
- package/dist/assets/{index-DD0-3EWg.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-CrVWZH_D.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 +8 -9
- 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/memory.ts +96 -73
- 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 +2 -0
- package/shared/types/unified/message.ts +26 -1
- package/shared/types/unified/stream.ts +22 -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 +88 -1
- package/shared/utils/process-supervisor.ts +123 -29
- package/shared/utils/process-tree.ts +99 -0
- 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/graph-layout.worker-CRFqN7ZQ.js +0 -1
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
- package/dist/assets/index-CrVWZH_D.js.br +0 -0
- package/dist/assets/index-CrVWZH_D.js.gz +0 -0
- package/dist/assets/index-DD0-3EWg.js.br +0 -0
- package/dist/assets/index-DD0-3EWg.js.gz +0 -0
- package/dist/assets/main-D2_TmcwQ.js +0 -1240
- package/dist/assets/main-D2_TmcwQ.js.br +0 -0
- package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
- package/dist/assets/main-Yucigcmf.css +0 -1
- package/dist/assets/main-Yucigcmf.css.br +0 -0
- package/dist/assets/main-Yucigcmf.css.gz +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The User-Agent the preview's Chrome presents.
|
|
3
|
+
*
|
|
4
|
+
* Headless Chrome announces itself as `HeadlessChrome/<version>`, and bot
|
|
5
|
+
* checks read exactly that: Cloudflare Turnstile and Google sign-in turn the
|
|
6
|
+
* browser away on it alone. Everything else headless Chrome reports is the
|
|
7
|
+
* real machine, so the fix is the one token, applied with `--user-agent` at
|
|
8
|
+
* launch. The flag reaches every target — pages, cross-origin iframes (where
|
|
9
|
+
* Turnstile runs), workers and request headers — which a per-page CDP
|
|
10
|
+
* override does not.
|
|
11
|
+
*
|
|
12
|
+
* The string is Chrome's own, read from the binary, rather than a template:
|
|
13
|
+
* the platform part differs per OS and the version moves with every update.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import puppeteer, { type Browser } from 'puppeteer';
|
|
17
|
+
import { debug } from '$shared/utils/logger';
|
|
18
|
+
|
|
19
|
+
/** Chrome's own User-Agent with the headless marker taken out. */
|
|
20
|
+
export function toHeadfulUserAgent(userAgent: string): string {
|
|
21
|
+
return userAgent.replace(/HeadlessChrome\//g, 'Chrome/');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** One read per binary for the life of the server; an update means a new path or a restart. */
|
|
25
|
+
const cache = new Map<string, Promise<string | null>>();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Ask a throwaway headless Chrome what it calls itself.
|
|
29
|
+
*
|
|
30
|
+
* Costs one short launch, the first time a preview opens. Resolves to null
|
|
31
|
+
* when the binary cannot be started — the real launch will report why.
|
|
32
|
+
*/
|
|
33
|
+
export function resolveUserAgent(executablePath: string): Promise<string | null> {
|
|
34
|
+
let pending = cache.get(executablePath);
|
|
35
|
+
if (!pending) {
|
|
36
|
+
pending = readUserAgent(executablePath);
|
|
37
|
+
cache.set(executablePath, pending);
|
|
38
|
+
// A failed read is not remembered, so the next launch tries again.
|
|
39
|
+
void pending.then((value) => {
|
|
40
|
+
if (value === null) cache.delete(executablePath);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return pending;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Long enough for a cold start on a slow host. Past it the preview launches
|
|
48
|
+
* without the flag rather than waiting on a probe that will not answer.
|
|
49
|
+
*/
|
|
50
|
+
const READ_TIMEOUT_MS = 15_000;
|
|
51
|
+
|
|
52
|
+
async function readUserAgent(executablePath: string): Promise<string | null> {
|
|
53
|
+
let probe: Browser | null = null;
|
|
54
|
+
let timedOut = false;
|
|
55
|
+
// A probe that stopped answering is killed rather than closed: close()
|
|
56
|
+
// waits on the very connection that went quiet.
|
|
57
|
+
const kill = (browser: Browser) => browser.process()?.kill('SIGKILL');
|
|
58
|
+
|
|
59
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
60
|
+
const expired = new Promise<never>((_, reject) => {
|
|
61
|
+
timer = setTimeout(() => {
|
|
62
|
+
timedOut = true;
|
|
63
|
+
if (probe) kill(probe);
|
|
64
|
+
reject(new Error(`no answer within ${READ_TIMEOUT_MS}ms`));
|
|
65
|
+
}, READ_TIMEOUT_MS);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const read = (async () => {
|
|
69
|
+
// A WebSocket, not the pipe the preview's own Chrome uses. Under Bun,
|
|
70
|
+
// closing one pipe-connected Chrome and launching the next in the same
|
|
71
|
+
// process leaves the new one's connection dropping replies, so a probe
|
|
72
|
+
// on a pipe would hang the very launch it exists to serve.
|
|
73
|
+
const browser = await puppeteer.launch({
|
|
74
|
+
headless: true,
|
|
75
|
+
executablePath,
|
|
76
|
+
args: ['--no-sandbox', '--no-first-run', '--no-default-browser-check'],
|
|
77
|
+
pipe: false,
|
|
78
|
+
timeout: READ_TIMEOUT_MS
|
|
79
|
+
});
|
|
80
|
+
probe = browser;
|
|
81
|
+
// Started only after the wait was given up on.
|
|
82
|
+
if (timedOut) kill(browser);
|
|
83
|
+
try {
|
|
84
|
+
return toHeadfulUserAgent(await browser.userAgent());
|
|
85
|
+
} finally {
|
|
86
|
+
await browser.close().catch(() => {});
|
|
87
|
+
}
|
|
88
|
+
})();
|
|
89
|
+
// After a timeout the read still settles, with nobody left to hear it.
|
|
90
|
+
void read.catch(() => {});
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
return await Promise.race([read, expired]);
|
|
94
|
+
} catch (error) {
|
|
95
|
+
debug.warn('preview', '⚠️ Could not read Chrome\'s User-Agent:', error instanceof Error ? error.message : error);
|
|
96
|
+
return null;
|
|
97
|
+
} finally {
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Shared logic for getting project status data
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { streamManager, type StreamState } from '../chat/stream-manager.js';
|
|
6
|
+
import { streamManager, waitingOnBackground, type StreamState } from '../chat/stream-manager.js';
|
|
7
7
|
import { sessionQueries } from '../database/queries/session-queries.js';
|
|
8
8
|
import type { UnifiedMessage } from '$shared/types/unified';
|
|
9
9
|
import { isWaitingForInteractiveInput } from '$shared/utils/interactive-input';
|
|
@@ -48,7 +48,9 @@ function toStreamStatus(stream: StreamState, worktreeMemo: Map<string, string |
|
|
|
48
48
|
status: stream.status,
|
|
49
49
|
startedAt: stream.startedAt,
|
|
50
50
|
messagesCount: stream.messages.length,
|
|
51
|
-
isWaitingInput: detectStreamWaitingInput(stream)
|
|
51
|
+
isWaitingInput: detectStreamWaitingInput(stream),
|
|
52
|
+
/** Background tasks the stream waits on between turns (0 while generating). */
|
|
53
|
+
waitingOnBackground: waitingOnBackground(stream)
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Carry a project's engine chat history to its new folder.
|
|
3
|
+
*
|
|
4
|
+
* Several engines file their transcripts under a directory named after the
|
|
5
|
+
* working directory, so resuming a chat after the project folder moved looks
|
|
6
|
+
* in a directory that does not exist and the chat starts over with no memory.
|
|
7
|
+
* Moving that directory along with the folder is what keeps every existing
|
|
8
|
+
* chat resumable.
|
|
9
|
+
*
|
|
10
|
+
* Only the engines that key by cwd are here. Codex finds a thread by id under
|
|
11
|
+
* its date-sharded `sessions/` tree and takes the cwd from the turn; Copilot,
|
|
12
|
+
* OpenCode and Cline look sessions up by id as well — none of them need moving.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { existsSync, readdirSync, realpathSync, renameSync, statSync } from 'fs';
|
|
16
|
+
import { basename, dirname, join } from 'path';
|
|
17
|
+
import { getClaudeUserConfigDir } from '$backend/engine/adapters/claude/environment';
|
|
18
|
+
import { getQwenProjectDir } from '$backend/engine/adapters/qwen/session-store';
|
|
19
|
+
import { getPiSessionDir } from '$backend/engine/adapters/pi/session-fork';
|
|
20
|
+
import { getCursorStoreDir } from '$backend/engine/adapters/cursor/environment';
|
|
21
|
+
import { resolveOsPath } from '$backend/utils/paths';
|
|
22
|
+
import { debug } from '$shared/utils/logger';
|
|
23
|
+
|
|
24
|
+
/** Claude Code shortens a sanitised cwd past this length and appends a hash we cannot reproduce. */
|
|
25
|
+
const CLAUDE_MAX_DIR_NAME = 200;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Claude Code's `projects/<sanitised cwd>` directory, or null when the name
|
|
29
|
+
* would be the shortened-and-hashed form.
|
|
30
|
+
*/
|
|
31
|
+
function claudeProjectDir(cwd: string): string | null {
|
|
32
|
+
const name = cwd.replace(/[^a-zA-Z0-9]/g, '-');
|
|
33
|
+
if (name.length > CLAUDE_MAX_DIR_NAME) return null;
|
|
34
|
+
return join(getClaudeUserConfigDir(), 'projects', name);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface TranscriptStore {
|
|
38
|
+
engine: string;
|
|
39
|
+
dirFor: (cwd: string) => string | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const STORES: TranscriptStore[] = [
|
|
43
|
+
{ engine: 'Claude Code', dirFor: claudeProjectDir },
|
|
44
|
+
{ engine: 'Qwen Code', dirFor: getQwenProjectDir },
|
|
45
|
+
{ engine: 'Pi', dirFor: getPiSessionDir },
|
|
46
|
+
{ engine: 'Cursor', dirFor: getCursorStoreDir }
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The spellings of one folder an engine may have been handed: the stored
|
|
51
|
+
* path, the OS-normalised one adapters pass as cwd, and the one with symlinks
|
|
52
|
+
* in its parent resolved (what a CLI's own `process.cwd()` reports). Each
|
|
53
|
+
* comes as an old/new pair built the same way, so a directory found under one
|
|
54
|
+
* spelling moves to the new folder under that same spelling.
|
|
55
|
+
*/
|
|
56
|
+
function spellings(oldPath: string, newPath: string): Array<[string, string]> {
|
|
57
|
+
const realParent = (path: string): string => {
|
|
58
|
+
try {
|
|
59
|
+
return join(realpathSync(dirname(path)), basename(path));
|
|
60
|
+
} catch {
|
|
61
|
+
return path;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const pairs: Array<[string, string]> = [
|
|
65
|
+
[oldPath, newPath],
|
|
66
|
+
[resolveOsPath(oldPath), resolveOsPath(newPath)],
|
|
67
|
+
[realParent(oldPath), realParent(newPath)]
|
|
68
|
+
];
|
|
69
|
+
const unique = new Map<string, string>();
|
|
70
|
+
for (const [from, to] of pairs) if (!unique.has(from)) unique.set(from, to);
|
|
71
|
+
return [...unique];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Move `from` to `to`. When `to` already exists (the engine already ran in
|
|
76
|
+
* the new folder), entries are moved one by one and a name present on both
|
|
77
|
+
* sides is left where it is — the newer side wins, nothing is overwritten.
|
|
78
|
+
*/
|
|
79
|
+
function moveDirectory(from: string, to: string): number {
|
|
80
|
+
if (!existsSync(to)) {
|
|
81
|
+
renameSync(from, to);
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
let skipped = 0;
|
|
85
|
+
for (const entry of readdirSync(from)) {
|
|
86
|
+
const target = join(to, entry);
|
|
87
|
+
if (existsSync(target)) {
|
|
88
|
+
skipped++;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
renameSync(join(from, entry), target);
|
|
92
|
+
}
|
|
93
|
+
return skipped;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Move every engine's transcripts for `oldPath` to where that engine will
|
|
98
|
+
* look for `newPath`. Returns what could not be carried over, one line each,
|
|
99
|
+
* worded for the person who renamed the project — empty when all moved.
|
|
100
|
+
*/
|
|
101
|
+
export function moveEngineTranscripts(oldPath: string, newPath: string): string[] {
|
|
102
|
+
const problems: string[] = [];
|
|
103
|
+
for (const store of STORES) {
|
|
104
|
+
for (const [from, to] of spellings(oldPath, newPath)) {
|
|
105
|
+
let source: string | null;
|
|
106
|
+
let target: string | null;
|
|
107
|
+
try {
|
|
108
|
+
source = store.dirFor(from);
|
|
109
|
+
target = store.dirFor(to);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
debug.warn('project', `Could not resolve ${store.engine} transcript directory:`, error);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (!source) {
|
|
115
|
+
// Only worth saying when there was history under the long form.
|
|
116
|
+
const prefix = claudeProjectDir(from.slice(0, CLAUDE_MAX_DIR_NAME));
|
|
117
|
+
if (prefix && hasSiblingWithPrefix(prefix)) {
|
|
118
|
+
problems.push(`${store.engine} chat history could not be moved: the folder path is too long.`);
|
|
119
|
+
}
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (!target || source === target || !isDirectory(source)) continue;
|
|
123
|
+
try {
|
|
124
|
+
const skipped = moveDirectory(source, target);
|
|
125
|
+
if (skipped > 0) {
|
|
126
|
+
problems.push(`${skipped} ${store.engine} chat file${skipped === 1 ? '' : 's'} already existed for the new folder and were left in place.`);
|
|
127
|
+
}
|
|
128
|
+
debug.log('project', `Moved ${store.engine} transcripts: ${source} -> ${target}`);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
debug.warn('project', `Could not move ${store.engine} transcripts from ${source}:`, error);
|
|
131
|
+
problems.push(`${store.engine} chat history could not be moved, so its earlier chats will start fresh.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return problems;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function isDirectory(path: string): boolean {
|
|
139
|
+
try {
|
|
140
|
+
return statSync(path).isDirectory();
|
|
141
|
+
} catch {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function hasSiblingWithPrefix(prefixDir: string): boolean {
|
|
147
|
+
try {
|
|
148
|
+
const name = basename(prefixDir);
|
|
149
|
+
return readdirSync(dirname(prefixDir)).some((entry) => entry.startsWith(`${name}-`));
|
|
150
|
+
} catch {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which folders may be renamed or deleted, shared by every surface that can do
|
|
3
|
+
* it — the web folder picker and a chat app's folder menu.
|
|
4
|
+
*
|
|
5
|
+
* A project whose folder moved or vanished is broken in Clopen: its chats,
|
|
6
|
+
* terminals and file panels all point at a path that is no longer there. So a
|
|
7
|
+
* project's own folder only moves through `moveProject()`, which carries the
|
|
8
|
+
* project along, and a folder holding a project never moves at all.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { resolve, sep } from 'path';
|
|
12
|
+
import { homedir } from 'os';
|
|
13
|
+
import { projectQueries } from '$backend/database/queries';
|
|
14
|
+
import { getClopenDir } from '$backend/utils/paths';
|
|
15
|
+
import { isPathInside } from '$backend/worktrees/paths';
|
|
16
|
+
import { isHomeProject, HOME_PROJECT_NAME } from '$shared/utils/home-project';
|
|
17
|
+
import type { Project } from '$shared/types/database/schema';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Why `folder` must not be renamed or deleted, or null when it may. The home
|
|
21
|
+
* folder and everything above it, Clopen's own data, and any folder that is
|
|
22
|
+
* (or holds) a project are off limits. `ownProjectId` exempts that project's
|
|
23
|
+
* own folder, for the rename that moves the project with it — a folder inside
|
|
24
|
+
* it that is another project still blocks.
|
|
25
|
+
*/
|
|
26
|
+
export function protectedFolderReason(folder: string, ownProjectId?: string): string | null {
|
|
27
|
+
const target = resolve(folder);
|
|
28
|
+
if (target === resolve(sep) || isPathInside(target, homedir())) return 'it is your home folder or one above it';
|
|
29
|
+
const data = getClopenDir();
|
|
30
|
+
if (isPathInside(data, target) || isPathInside(target, data)) return "it holds Clopen's own data";
|
|
31
|
+
const project = projectQueries
|
|
32
|
+
.getAll()
|
|
33
|
+
.find((entry) => entry.id !== ownProjectId && isPathInside(target, resolve(entry.path)));
|
|
34
|
+
if (project) return `it ${resolve(project.path) === target ? 'is' : 'holds'} the project ${projectName(project)}`;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The project whose folder is exactly `folder`, listed or not. */
|
|
39
|
+
export function projectAtFolder(folder: string): Project | null {
|
|
40
|
+
const target = resolve(folder);
|
|
41
|
+
return projectQueries.getAll().find((entry) => resolve(entry.path) === target) ?? null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A folder name a person typed: one path segment, nothing that climbs out. */
|
|
45
|
+
export function validFolderName(input: string | undefined): string {
|
|
46
|
+
const name = (input ?? '').trim();
|
|
47
|
+
if (!name || name === '.' || name === '..' || /[/\\\0]/.test(name) || name.length > 255) {
|
|
48
|
+
throw new Error('That is not a folder name. Use a single name, without slashes.');
|
|
49
|
+
}
|
|
50
|
+
return name;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function projectName(project: Project): string {
|
|
54
|
+
return isHomeProject(project) ? HOME_PROJECT_NAME : project.name;
|
|
55
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moving a project: the folder, the record, and everything keyed by the old
|
|
3
|
+
* path go together — or nothing moves at all.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect, beforeAll, afterAll, afterEach } from 'bun:test';
|
|
7
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
8
|
+
import { tmpdir } from 'os';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
import { initializeDatabase, closeDatabase, getDatabase } from '$backend/database';
|
|
11
|
+
import { memoryQueueQueries, projectQueries } from '$backend/database/queries';
|
|
12
|
+
import { streamManager } from '$backend/chat/stream-manager';
|
|
13
|
+
import { getClaudeUserConfigDir } from '$backend/engine/adapters/claude/environment';
|
|
14
|
+
import { getPiSessionDir } from '$backend/engine/adapters/pi/session-fork';
|
|
15
|
+
import { moveProject, rewritePathPrefix } from './move';
|
|
16
|
+
import { protectedFolderReason } from './folder-guard';
|
|
17
|
+
|
|
18
|
+
let root: string;
|
|
19
|
+
const created: string[] = [];
|
|
20
|
+
|
|
21
|
+
function makeProject(name: string): { id: string; path: string } {
|
|
22
|
+
const path = join(root, name);
|
|
23
|
+
mkdirSync(path, { recursive: true });
|
|
24
|
+
const now = new Date().toISOString();
|
|
25
|
+
const project = projectQueries.create({ name, path, created_at: now, last_opened_at: now });
|
|
26
|
+
projectQueries.list(project.id);
|
|
27
|
+
created.push(project.id);
|
|
28
|
+
return { id: project.id, path };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function claudeDir(cwd: string): string {
|
|
32
|
+
return join(getClaudeUserConfigDir(), 'projects', cwd.replace(/[^a-zA-Z0-9]/g, '-'));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
beforeAll(async () => {
|
|
36
|
+
await initializeDatabase();
|
|
37
|
+
root = mkdtempSync(join(tmpdir(), 'clopen-move-'));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
for (const id of created.splice(0)) projectQueries.deleteProject(id);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterAll(() => {
|
|
45
|
+
rmSync(root, { recursive: true, force: true });
|
|
46
|
+
closeDatabase();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('rewritePathPrefix', () => {
|
|
50
|
+
it('re-roots paths at and under the folder, and only those', () => {
|
|
51
|
+
const value = {
|
|
52
|
+
root: '/work/app',
|
|
53
|
+
file: '/work/app/src/index.ts',
|
|
54
|
+
sibling: '/work/app-two/readme.md',
|
|
55
|
+
windows: 'C:\\work\\app\\src',
|
|
56
|
+
list: ['/work/app/a', 'unrelated']
|
|
57
|
+
};
|
|
58
|
+
expect(rewritePathPrefix(value, '/work/app', '/work/renamed')).toEqual({
|
|
59
|
+
root: '/work/renamed',
|
|
60
|
+
file: '/work/renamed/src/index.ts',
|
|
61
|
+
sibling: '/work/app-two/readme.md',
|
|
62
|
+
windows: 'C:\\work\\app\\src',
|
|
63
|
+
list: ['/work/renamed/a', 'unrelated']
|
|
64
|
+
});
|
|
65
|
+
expect(rewritePathPrefix('C:\\work\\app\\src', 'C:\\work\\app', 'C:\\work\\new')).toBe('C:\\work\\new\\src');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('opens JSON stored inside JSON, and leaves untouched values as the same object', () => {
|
|
69
|
+
const inner = JSON.stringify({ openTabs: [{ path: '/work/app/a.ts' }] });
|
|
70
|
+
const outer = JSON.stringify({ v: 2, scopes: { main: inner } });
|
|
71
|
+
const rewritten = JSON.parse(rewritePathPrefix(outer, '/work/app', '/work/new') as string);
|
|
72
|
+
expect(JSON.parse(rewritten.scopes.main).openTabs[0].path).toBe('/work/new/a.ts');
|
|
73
|
+
|
|
74
|
+
const untouched = { a: '/elsewhere', b: [1, 2] };
|
|
75
|
+
expect(rewritePathPrefix(untouched, '/work/app', '/work/new')).toBe(untouched);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('moveProject', () => {
|
|
80
|
+
it('renames the folder and carries the record, history and saved state along', async () => {
|
|
81
|
+
const project = makeProject('alpha');
|
|
82
|
+
writeFileSync(join(project.path, 'keep.txt'), 'kept');
|
|
83
|
+
const renamedPath = join(root, 'alpha-renamed');
|
|
84
|
+
|
|
85
|
+
mkdirSync(claudeDir(project.path), { recursive: true });
|
|
86
|
+
writeFileSync(join(claudeDir(project.path), 'session.jsonl'), '{}');
|
|
87
|
+
mkdirSync(getPiSessionDir(project.path), { recursive: true });
|
|
88
|
+
writeFileSync(join(getPiSessionDir(project.path), 'pi.jsonl'), '{}');
|
|
89
|
+
|
|
90
|
+
memoryQueueQueries.enqueue({
|
|
91
|
+
sessionId: `move-test-${project.id}`,
|
|
92
|
+
projectId: project.id,
|
|
93
|
+
projectPath: project.path,
|
|
94
|
+
userMessageId: 'm1',
|
|
95
|
+
changedPaths: [],
|
|
96
|
+
delaySeconds: 3600
|
|
97
|
+
});
|
|
98
|
+
projectQueries.setWorkspaceState(project.id, JSON.stringify({ v: 1, docks: { git: { repoPath: join(project.path, 'sub') } } }));
|
|
99
|
+
|
|
100
|
+
const outcome = await moveProject(project.id, { kind: 'rename', name: 'alpha-renamed' });
|
|
101
|
+
|
|
102
|
+
expect(outcome.status).toBe('moved');
|
|
103
|
+
if (outcome.status !== 'moved') return;
|
|
104
|
+
expect(outcome.project.path).toBe(renamedPath);
|
|
105
|
+
expect(outcome.project.name).toBe('alpha-renamed');
|
|
106
|
+
expect(outcome.project.missing).toBe(false);
|
|
107
|
+
expect(outcome.previousPath).toBe(project.path);
|
|
108
|
+
expect(outcome.warnings).toEqual([]);
|
|
109
|
+
|
|
110
|
+
expect(existsSync(project.path)).toBe(false);
|
|
111
|
+
expect(readFileSync(join(renamedPath, 'keep.txt'), 'utf8')).toBe('kept');
|
|
112
|
+
expect(projectQueries.getById(project.id)).toMatchObject({ path: renamedPath, name: 'alpha-renamed' });
|
|
113
|
+
|
|
114
|
+
expect(existsSync(join(claudeDir(renamedPath), 'session.jsonl'))).toBe(true);
|
|
115
|
+
expect(existsSync(claudeDir(project.path))).toBe(false);
|
|
116
|
+
expect(existsSync(join(getPiSessionDir(renamedPath), 'pi.jsonl'))).toBe(true);
|
|
117
|
+
|
|
118
|
+
const row = getDatabase()
|
|
119
|
+
.prepare('SELECT project_path FROM memory_extraction_queue WHERE session_id = ?')
|
|
120
|
+
.get(`move-test-${project.id}`) as { project_path: string } | null;
|
|
121
|
+
expect(row?.project_path).toBe(renamedPath);
|
|
122
|
+
getDatabase().prepare('DELETE FROM memory_extraction_queue WHERE session_id = ?').run(`move-test-${project.id}`);
|
|
123
|
+
|
|
124
|
+
const blob = JSON.parse(projectQueries.getWorkspaceState(project.id)!);
|
|
125
|
+
expect(blob.docks.git.repoPath).toBe(join(renamedPath, 'sub'));
|
|
126
|
+
|
|
127
|
+
rmSync(claudeDir(renamedPath), { recursive: true, force: true });
|
|
128
|
+
rmSync(getPiSessionDir(renamedPath), { recursive: true, force: true });
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('answers busy and moves nothing while a chat runs in the main tree', async () => {
|
|
132
|
+
const project = makeProject('busy');
|
|
133
|
+
const streams = (streamManager as unknown as { activeStreams: Map<string, unknown> }).activeStreams;
|
|
134
|
+
streams.set('move-test-stream', {
|
|
135
|
+
streamId: 'move-test-stream',
|
|
136
|
+
projectId: project.id,
|
|
137
|
+
chatSessionId: 'move-test-no-such-session',
|
|
138
|
+
status: 'active',
|
|
139
|
+
messages: []
|
|
140
|
+
});
|
|
141
|
+
try {
|
|
142
|
+
const outcome = await moveProject(project.id, { kind: 'rename', name: 'busy-renamed' });
|
|
143
|
+
expect(outcome).toEqual({ status: 'busy', usage: { chats: 1, terminals: 0 } });
|
|
144
|
+
expect(existsSync(project.path)).toBe(true);
|
|
145
|
+
expect(projectQueries.getById(project.id)?.path).toBe(project.path);
|
|
146
|
+
} finally {
|
|
147
|
+
streams.delete('move-test-stream');
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('puts the folder back when the record cannot be updated', async () => {
|
|
152
|
+
const project = makeProject('rollback');
|
|
153
|
+
const original = projectQueries.relocate;
|
|
154
|
+
projectQueries.relocate = () => {
|
|
155
|
+
throw new Error('disk full');
|
|
156
|
+
};
|
|
157
|
+
try {
|
|
158
|
+
await expect(moveProject(project.id, { kind: 'rename', name: 'rollback-renamed' })).rejects.toThrow('disk full');
|
|
159
|
+
} finally {
|
|
160
|
+
projectQueries.relocate = original;
|
|
161
|
+
}
|
|
162
|
+
expect(existsSync(project.path)).toBe(true);
|
|
163
|
+
expect(existsSync(join(root, 'rollback-renamed'))).toBe(false);
|
|
164
|
+
expect(projectQueries.getById(project.id)?.path).toBe(project.path);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('points a project whose folder vanished at where it is now', async () => {
|
|
168
|
+
const project = makeProject('lost');
|
|
169
|
+
const foundPath = join(root, 'found-again');
|
|
170
|
+
mkdirSync(foundPath);
|
|
171
|
+
rmSync(project.path, { recursive: true });
|
|
172
|
+
|
|
173
|
+
const outcome = await moveProject(project.id, { kind: 'relocate', path: foundPath });
|
|
174
|
+
expect(outcome.status).toBe('moved');
|
|
175
|
+
if (outcome.status !== 'moved') return;
|
|
176
|
+
expect(outcome.project).toMatchObject({ path: foundPath, name: 'found-again', missing: false });
|
|
177
|
+
expect(existsSync(foundPath)).toBe(true);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('refuses a name that is taken, a folder that holds another project, and Home', async () => {
|
|
181
|
+
const project = makeProject('outer');
|
|
182
|
+
mkdirSync(join(root, 'taken'));
|
|
183
|
+
await expect(moveProject(project.id, { kind: 'rename', name: 'taken' })).rejects.toThrow(/already exists/);
|
|
184
|
+
await expect(moveProject(project.id, { kind: 'rename', name: '../escape' })).rejects.toThrow(/not a folder name/);
|
|
185
|
+
|
|
186
|
+
makeProject('outer/inner');
|
|
187
|
+
await expect(moveProject(project.id, { kind: 'rename', name: 'outer-2' })).rejects.toThrow(/holds the project/);
|
|
188
|
+
expect(existsSync(project.path)).toBe(true);
|
|
189
|
+
|
|
190
|
+
const home = projectQueries.getHome();
|
|
191
|
+
if (home) await expect(moveProject(home.id, { kind: 'rename', name: 'x' })).rejects.toThrow(/Home cannot/);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('refuses to point a project at a folder another project already has', async () => {
|
|
195
|
+
const first = makeProject('first');
|
|
196
|
+
const second = makeProject('second');
|
|
197
|
+
await expect(moveProject(first.id, { kind: 'relocate', path: second.path })).rejects.toThrow(/is the project second/);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
describe('protectedFolderReason', () => {
|
|
202
|
+
it('exempts only the moving project, never one inside it', () => {
|
|
203
|
+
const project = makeProject('guarded');
|
|
204
|
+
expect(protectedFolderReason(project.path)).toMatch(/is the project guarded/);
|
|
205
|
+
expect(protectedFolderReason(project.path, project.id)).toBeNull();
|
|
206
|
+
expect(protectedFolderReason(root)).toMatch(/holds the project/);
|
|
207
|
+
});
|
|
208
|
+
});
|