@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
|
@@ -3,6 +3,7 @@ import type { Page, Dialog } from 'puppeteer';
|
|
|
3
3
|
import type { BrowserDialogResponse } from './types';
|
|
4
4
|
import { debug } from '$shared/utils/logger';
|
|
5
5
|
import { nanoid } from 'nanoid';
|
|
6
|
+
import { exposeBinding } from './page-binding';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Browser Dialog Handler
|
|
@@ -110,12 +111,12 @@ export class BrowserDialogHandler extends EventEmitter {
|
|
|
110
111
|
*/
|
|
111
112
|
/**
|
|
112
113
|
* Setup dialog bindings - MUST be called BEFORE navigation
|
|
113
|
-
* This includes
|
|
114
|
+
* This includes binding calls which require page to not be navigated yet
|
|
114
115
|
*/
|
|
115
116
|
async setupDialogBindings(sessionId: string, page: Page) {
|
|
116
117
|
debug.log('preview', `🎭 Setting up dialog bindings (pre-navigation) for session: ${sessionId}`);
|
|
117
118
|
|
|
118
|
-
// Setup print interception bindings - requires
|
|
119
|
+
// Setup print interception bindings - requires a page binding
|
|
119
120
|
await this.setupPrintInterception(sessionId, page);
|
|
120
121
|
|
|
121
122
|
debug.log('preview', `✅ Dialog bindings setup complete for session: ${sessionId}`);
|
|
@@ -249,9 +250,9 @@ export class BrowserDialogHandler extends EventEmitter {
|
|
|
249
250
|
*/
|
|
250
251
|
private async setupPrintInterception(sessionId: string, page: Page) {
|
|
251
252
|
try {
|
|
252
|
-
// IMPORTANT:
|
|
253
|
+
// IMPORTANT: the binding must exist BEFORE any navigation or evaluateOnNewDocument
|
|
253
254
|
// Listen for print requests
|
|
254
|
-
await page
|
|
255
|
+
await exposeBinding(page, '__notifyPrintRequest__', () => {
|
|
255
256
|
const printEvent: any = {
|
|
256
257
|
sessionId, // Internal use only, converted to tabId at previewService layer
|
|
257
258
|
timestamp: Date.now()
|
|
@@ -288,7 +289,7 @@ export class BrowserDialogHandler extends EventEmitter {
|
|
|
288
289
|
|
|
289
290
|
debug.log('preview', `✅ Print interception setup successfully for session: ${sessionId}`);
|
|
290
291
|
} catch (error) {
|
|
291
|
-
// If
|
|
292
|
+
// If the binding fails (e.g., target closed), print interception won't work
|
|
292
293
|
// but we shouldn't fail the entire session creation
|
|
293
294
|
debug.warn('preview', `⚠️ Print interception setup failed for session ${sessionId}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
294
295
|
debug.warn('preview', ` Print functionality will not be available for this session`);
|
|
@@ -25,6 +25,8 @@ import { join } from 'path';
|
|
|
25
25
|
import type { CDPSession, Page } from 'puppeteer';
|
|
26
26
|
import { debug } from '$shared/utils/logger';
|
|
27
27
|
import { getClopenDir } from '$backend/utils/paths';
|
|
28
|
+
import { outsideBotChecks } from './bot-check-frames';
|
|
29
|
+
import { exposeBinding } from './page-binding';
|
|
28
30
|
|
|
29
31
|
/** Capability requests the injected shim can raise. */
|
|
30
32
|
export type HostRequestKind =
|
|
@@ -154,10 +156,10 @@ export class BrowserHostBridge extends EventEmitter {
|
|
|
154
156
|
this.tabs.set(tabId, { bindingName, transferDir });
|
|
155
157
|
|
|
156
158
|
try {
|
|
157
|
-
await page
|
|
159
|
+
await exposeBinding(page, bindingName, (raw: string) => this.handlePageRequest(tabId, raw));
|
|
158
160
|
|
|
159
161
|
const { hostBridgeScript } = await import('./scripts/host-bridge');
|
|
160
|
-
await page.evaluateOnNewDocument(hostBridgeScript, bindingName);
|
|
162
|
+
await page.evaluateOnNewDocument(outsideBotChecks(hostBridgeScript, bindingName));
|
|
161
163
|
|
|
162
164
|
debug.log('preview', `🌉 Host bridge installed for tab ${tabId}`);
|
|
163
165
|
} catch (error) {
|
|
@@ -13,6 +13,17 @@ import { resolveFrameTarget } from './frame-targeting';
|
|
|
13
13
|
import { debug } from '$shared/utils/logger';
|
|
14
14
|
import { nanoid } from 'nanoid';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Context menu entries the viewer carries out itself: it takes the
|
|
18
|
+
* screenshot and keeps the image. Their response only closes the menu here.
|
|
19
|
+
*/
|
|
20
|
+
export const SCREENSHOT_MENU_ITEMS: ReadonlySet<string> = new Set([
|
|
21
|
+
'screenshot-copy',
|
|
22
|
+
'screenshot-element',
|
|
23
|
+
'screenshot-annotate',
|
|
24
|
+
'mention-element'
|
|
25
|
+
]);
|
|
26
|
+
|
|
16
27
|
/**
|
|
17
28
|
* Read the current text selection from wherever it actually lives.
|
|
18
29
|
*
|
|
@@ -548,6 +559,15 @@ export class BrowserNativeUIHandler extends EventEmitter {
|
|
|
548
559
|
{ id: 'print', label: 'Print…', enabled: true, icon: 'lucide:printer' }
|
|
549
560
|
);
|
|
550
561
|
divider();
|
|
562
|
+
// Carried out by the viewer, which holds the image afterwards; the
|
|
563
|
+
// backend only has to close the menu (see SCREENSHOT_MENU_ITEMS).
|
|
564
|
+
items.push(
|
|
565
|
+
{ id: 'screenshot-copy', label: 'Copy Screenshot', enabled: true, icon: 'lucide:camera' },
|
|
566
|
+
{ id: 'screenshot-element', label: 'Screenshot This Element', enabled: true, icon: 'lucide:square-dashed-mouse-pointer' },
|
|
567
|
+
{ id: 'screenshot-annotate', label: 'Annotate Screenshot…', enabled: true, icon: 'lucide:pencil-line' },
|
|
568
|
+
{ id: 'mention-element', label: 'Mention This Element in Chat', enabled: true, icon: 'lucide:at-sign' }
|
|
569
|
+
);
|
|
570
|
+
divider();
|
|
551
571
|
items.push({ id: 'inspect', label: 'Inspect', enabled: true, icon: 'lucide:code' });
|
|
552
572
|
|
|
553
573
|
return items;
|
|
@@ -873,6 +893,7 @@ export class BrowserNativeUIHandler extends EventEmitter {
|
|
|
873
893
|
break;
|
|
874
894
|
|
|
875
895
|
default:
|
|
896
|
+
if (SCREENSHOT_MENU_ITEMS.has(itemId)) break;
|
|
876
897
|
debug.warn('preview', `⚠️ Unknown context menu action: ${itemId}`);
|
|
877
898
|
return false;
|
|
878
899
|
}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Browser Pool Module
|
|
3
3
|
*
|
|
4
|
-
* Uses puppeteer-extra with StealthPlugin for Cloudflare bypass.
|
|
5
4
|
* - One Chrome per workspace, launched against a profile directory on disk
|
|
6
5
|
* - Every tab is a page in that profile's default context, in its own window
|
|
7
|
-
*
|
|
6
|
+
*
|
|
7
|
+
* **Why plain Chrome, with nothing faked.**
|
|
8
|
+
* Bot checks look for an automated browser in two ways: the marks automation
|
|
9
|
+
* leaves, and values that contradict each other. The preview used to run
|
|
10
|
+
* puppeteer-extra's stealth plugin against the first, and it now feeds the
|
|
11
|
+
* second — it reports an Intel GPU and four cores on an Apple Silicon Mac,
|
|
12
|
+
* and old-style brands that disagree with the full version list. Cloudflare's
|
|
13
|
+
* challenge and Google sign-in both turned the preview away for it, while the
|
|
14
|
+
* same Chrome with nothing patched passes them. What is left to hide is the
|
|
15
|
+
* `HeadlessChrome` token, which `user-agent.ts` takes out at launch, and
|
|
16
|
+
* `navigator.webdriver`, which `--disable-blink-features=AutomationControlled`
|
|
17
|
+
* already keeps false.
|
|
8
18
|
*
|
|
9
19
|
* **Why a profile per workspace rather than a context per tab.**
|
|
10
20
|
* A `BrowserContext` is always incognito: it cannot be written to disk, and it
|
|
@@ -26,11 +36,8 @@
|
|
|
26
36
|
* profile.
|
|
27
37
|
*
|
|
28
38
|
* Why not puppeteer-cluster?
|
|
29
|
-
* - Cluster's CONCURRENCY_CONTEXT mode
|
|
30
|
-
*
|
|
31
|
-
* - This causes a race condition where stealth evasions (evaluateOnNewDocument)
|
|
32
|
-
* may not be registered before the first navigation, breaking Cloudflare bypass.
|
|
33
|
-
* - Direct launch() ensures puppeteer-extra wraps ALL page creation correctly.
|
|
39
|
+
* - Cluster's CONCURRENCY_CONTEXT mode hands out incognito contexts, which is
|
|
40
|
+
* exactly what a profile per workspace exists to avoid.
|
|
34
41
|
*/
|
|
35
42
|
|
|
36
43
|
import { existsSync, mkdirSync, rmSync, writeFileSync, readFileSync } from 'fs';
|
|
@@ -38,15 +45,13 @@ import { createHash } from 'crypto';
|
|
|
38
45
|
import { join } from 'path';
|
|
39
46
|
import type { Browser, BrowserContext, CDPSession, Page, Protocol } from 'puppeteer';
|
|
40
47
|
import { debug } from '$shared/utils/logger';
|
|
41
|
-
import puppeteer from 'puppeteer
|
|
42
|
-
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
|
|
48
|
+
import puppeteer from 'puppeteer';
|
|
43
49
|
import { getChromeExecutablePath } from '$backend/engine/install-recipes';
|
|
44
50
|
import { getClopenDir } from '$backend/utils/paths';
|
|
45
51
|
import { scopeSlug } from '$shared/utils/workspace-scope';
|
|
46
52
|
import { open as openSealed, seal } from '$backend/database/crypto/envelope';
|
|
47
53
|
import { isProfileInUseError, releaseProfile, sweepOrphanedProfiles } from './profile-lock';
|
|
48
|
-
|
|
49
|
-
puppeteer.use(StealthPlugin());
|
|
54
|
+
import { resolveUserAgent } from './user-agent';
|
|
50
55
|
|
|
51
56
|
export interface PoolConfig {
|
|
52
57
|
maxConcurrency: number;
|
|
@@ -89,9 +94,10 @@ const DEFAULT_CONFIG: PoolConfig = {
|
|
|
89
94
|
* Chrome launch arguments.
|
|
90
95
|
*
|
|
91
96
|
* Three groups, kept separate because they answer different questions:
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
97
|
+
* not reading as automated (bot checks), capture (what the preview pipeline
|
|
98
|
+
* needs from the renderer), and host adaptation (what a headless VPS needs
|
|
99
|
+
* that a desktop doesn't). The User-Agent joins them at launch, once it is
|
|
100
|
+
* known — see `user-agent.ts`.
|
|
95
101
|
*/
|
|
96
102
|
function buildChromeArgs(): string[] {
|
|
97
103
|
// Chrome only honours the last `--disable-features`, so every entry has to
|
|
@@ -193,11 +199,11 @@ const COOKIE_FLUSH_INTERVAL_MS = 60_000;
|
|
|
193
199
|
* Hashed rather than slugged alone: `scopeSlug` truncates, and two workspaces
|
|
194
200
|
* that collided would share a login.
|
|
195
201
|
*/
|
|
196
|
-
function profilesRoot(): string {
|
|
202
|
+
export function profilesRoot(): string {
|
|
197
203
|
return join(getClopenDir(), 'preview', 'profiles');
|
|
198
204
|
}
|
|
199
205
|
|
|
200
|
-
function profileDirName(profileKey: string): string {
|
|
206
|
+
export function profileDirName(profileKey: string): string {
|
|
201
207
|
const digest = createHash('sha256').update(profileKey).digest('hex').slice(0, 16);
|
|
202
208
|
return `${scopeSlug(profileKey) || 'ws'}-${digest}`;
|
|
203
209
|
}
|
|
@@ -288,12 +294,15 @@ class BrowserPool {
|
|
|
288
294
|
await this.orphanSweep;
|
|
289
295
|
await releaseProfile(userDataDir);
|
|
290
296
|
|
|
297
|
+
const userAgent = await resolveUserAgent(executablePath);
|
|
298
|
+
const args = userAgent ? [...CHROME_ARGS, `--user-agent=${userAgent}`] : CHROME_ARGS;
|
|
299
|
+
|
|
291
300
|
const launch = () =>
|
|
292
301
|
puppeteer.launch({
|
|
293
302
|
headless: true,
|
|
294
303
|
executablePath,
|
|
295
304
|
userDataDir,
|
|
296
|
-
args
|
|
305
|
+
args,
|
|
297
306
|
// A pipe, not a WebSocket. Chrome exits the moment its end of the
|
|
298
307
|
// pipe closes, so it cannot outlive this server — a crash, a kill
|
|
299
308
|
// or a restart used to leave a headless Chrome running with the
|
|
@@ -13,8 +13,21 @@ import { WorkspaceClipboard, type ClipboardSource } from './browser-clipboard.js
|
|
|
13
13
|
import { browserMcpControl } from './browser-mcp-control.js';
|
|
14
14
|
import { browserPool } from './browser-pool.js';
|
|
15
15
|
import { ws } from '$backend/utils/ws';
|
|
16
|
-
import { defaultRotation, type DeviceRequest } from '$shared/constants/preview.js';
|
|
17
|
-
import { applyViewport, type EmulationPatch } from './viewport';
|
|
16
|
+
import { defaultRotation, planDevice, type DeviceRequest } from '$shared/constants/preview.js';
|
|
17
|
+
import { applyDevice, applyViewport, mergeEmulation, type EmulationPatch } from './viewport';
|
|
18
|
+
import { frameDrawInput, type FrameSpec } from '$shared/utils/device-frame';
|
|
19
|
+
import {
|
|
20
|
+
captureScreenshot,
|
|
21
|
+
elementAtPoint,
|
|
22
|
+
frameScreenshot,
|
|
23
|
+
type CapturedScreenshot,
|
|
24
|
+
type ElementAtPoint,
|
|
25
|
+
type ResponsiveScreenshot,
|
|
26
|
+
type ScreenshotOptions,
|
|
27
|
+
type ScreenshotSource,
|
|
28
|
+
type ScreenshotTarget
|
|
29
|
+
} from './browser-screenshot';
|
|
30
|
+
import { describeElementAt, type DescribedElement } from './element-describe';
|
|
18
31
|
import { debug } from '$shared/utils/logger';
|
|
19
32
|
import { emitToPreviewWatchers, forgetAgentCursor, rememberAgentCursor } from '../../ws/preview/watchers';
|
|
20
33
|
import { sleep } from '$shared/utils/async';
|
|
@@ -858,6 +871,150 @@ export class BrowserPreviewService extends EventEmitter {
|
|
|
858
871
|
return this.tabManager.getAllTabs();
|
|
859
872
|
}
|
|
860
873
|
|
|
874
|
+
// ============================================================================
|
|
875
|
+
// Screenshots
|
|
876
|
+
// ============================================================================
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* A tab that can be captured right now, awake.
|
|
880
|
+
*
|
|
881
|
+
* A page blocked on a dialog cannot render a frame until someone answers,
|
|
882
|
+
* so the capture would hang for its whole timeout and then fail without
|
|
883
|
+
* saying why. Refused up front instead, with the reason.
|
|
884
|
+
*/
|
|
885
|
+
private async screenshotTab(tabId: string): Promise<BrowserTab> {
|
|
886
|
+
const tab = this.tabManager.getTab(tabId);
|
|
887
|
+
if (!tab || tab.page.isClosed()) throw new Error('That tab is no longer open');
|
|
888
|
+
if (this.dialogHandler.getPendingDialog(tabId)) {
|
|
889
|
+
throw new Error('The page is showing a dialog — answer it first');
|
|
890
|
+
}
|
|
891
|
+
await this.lifecycle.ensureAwake(tabId);
|
|
892
|
+
this.lifecycle.touch(tabId);
|
|
893
|
+
return tab;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Capture a tab — the toolbar's, the context menu's and the agent's path.
|
|
898
|
+
*
|
|
899
|
+
* Every viewer of the tab is told, whoever asked: they all see the same
|
|
900
|
+
* page, so they all see the shutter. A full-page capture also announces
|
|
901
|
+
* its start, because Chrome lays the page out at its full height for it
|
|
902
|
+
* and the stream visibly jumps while it does.
|
|
903
|
+
*/
|
|
904
|
+
async takeScreenshot(
|
|
905
|
+
tabId: string,
|
|
906
|
+
target: ScreenshotTarget,
|
|
907
|
+
options: ScreenshotOptions,
|
|
908
|
+
source: ScreenshotSource
|
|
909
|
+
): Promise<CapturedScreenshot> {
|
|
910
|
+
const tab = await this.screenshotTab(tabId);
|
|
911
|
+
const fullPage = target.kind === 'fullPage';
|
|
912
|
+
|
|
913
|
+
// The agent owns the page while it holds the tab; a capture that relays
|
|
914
|
+
// out the page would move it under the agent's next action.
|
|
915
|
+
if (source === 'user' && fullPage && browserMcpControl.isTabControlled(tabId, this.projectId)) {
|
|
916
|
+
throw new Error('A full-page screenshot is not available while an agent is using this tab');
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
if (fullPage) this.emit('preview:browser-screenshot', { tabId, source, phase: 'start', fullPage, timestamp: Date.now() });
|
|
920
|
+
let ok = false;
|
|
921
|
+
try {
|
|
922
|
+
const shot = await captureScreenshot(tab.page, target, options);
|
|
923
|
+
ok = true;
|
|
924
|
+
return shot;
|
|
925
|
+
} finally {
|
|
926
|
+
this.emit('preview:browser-screenshot', { tabId, source, phase: 'end', fullPage, ok, timestamp: Date.now() });
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/** The device spec a tab's captures are framed in. */
|
|
931
|
+
screenshotFrameSpec(tabId: string): FrameSpec | null {
|
|
932
|
+
const tab = this.tabManager.peekTab(tabId);
|
|
933
|
+
if (!tab) return null;
|
|
934
|
+
return { deviceSize: tab.deviceSize, viewport: tab.viewport, deviceModel: tab.deviceModel, pageColors: tab.pageColors };
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Put captures inside their device mockups — the agent's path to what the
|
|
939
|
+
* viewer's editor does. Drawn in a scratch page, never in a tab's page.
|
|
940
|
+
*/
|
|
941
|
+
async frameScreenshots(
|
|
942
|
+
items: Array<{ image: CapturedScreenshot; spec: FrameSpec }>,
|
|
943
|
+
options: ScreenshotOptions
|
|
944
|
+
): Promise<CapturedScreenshot[]> {
|
|
945
|
+
const inputs = items.map((item) => {
|
|
946
|
+
const input = frameDrawInput(item.spec);
|
|
947
|
+
if (!input) throw new Error(`The ${item.spec.deviceSize} device has no frame to draw`);
|
|
948
|
+
return input;
|
|
949
|
+
});
|
|
950
|
+
return this.tabManager.withScratchPage(async (page) => {
|
|
951
|
+
const framed: CapturedScreenshot[] = [];
|
|
952
|
+
for (const [index, item] of items.entries()) {
|
|
953
|
+
framed.push(await frameScreenshot(page, item.image, inputs[index], options));
|
|
954
|
+
}
|
|
955
|
+
return framed;
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/** What the element picker highlights under the viewer's pointer. */
|
|
960
|
+
async screenshotElementAt(tabId: string, x: number, y: number, depth: number): Promise<ElementAtPoint | null> {
|
|
961
|
+
const tab = await this.screenshotTab(tabId);
|
|
962
|
+
return elementAtPoint(tab.page, x, y, depth);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/** The element under a viewport point, described for a chat mention. */
|
|
966
|
+
async describeElementAt(tabId: string, x: number, y: number, depth: number): Promise<DescribedElement | null> {
|
|
967
|
+
const tab = await this.screenshotTab(tabId);
|
|
968
|
+
return describeElementAt(tab.page, x, y, depth);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Capture a tab's page as it looks on other devices.
|
|
973
|
+
*
|
|
974
|
+
* Laid out in a scratch page of the same profile rather than by resizing
|
|
975
|
+
* the tab: switching between a phone and a desktop changes the mobile and
|
|
976
|
+
* touch flags, which reloads the page — the tab would lose whatever state
|
|
977
|
+
* the user had brought it to, and every viewer would watch it happen. The
|
|
978
|
+
* scratch page loads the tab's address fresh, signed in as the tab is.
|
|
979
|
+
*/
|
|
980
|
+
async takeResponsiveScreenshots(
|
|
981
|
+
tabId: string,
|
|
982
|
+
devices: DeviceSize[],
|
|
983
|
+
options: ScreenshotOptions
|
|
984
|
+
): Promise<ResponsiveScreenshot[]> {
|
|
985
|
+
const tab = await this.screenshotTab(tabId);
|
|
986
|
+
const url = tab.page.url();
|
|
987
|
+
if (!/^(https?|file):/i.test(url)) throw new Error('This page cannot be opened again at another size');
|
|
988
|
+
|
|
989
|
+
// Colour scheme and reduced motion are the user's choice, not the
|
|
990
|
+
// device's, so they carry over; touch and mobile belong to each device.
|
|
991
|
+
const emulation = mergeEmulation({}, {
|
|
992
|
+
colorScheme: tab.emulation.colorScheme,
|
|
993
|
+
reducedMotion: tab.emulation.reducedMotion
|
|
994
|
+
});
|
|
995
|
+
|
|
996
|
+
let ok = false;
|
|
997
|
+
try {
|
|
998
|
+
const shots = await this.tabManager.withScratchPage(async (page) => {
|
|
999
|
+
const taken: ResponsiveScreenshot[] = [];
|
|
1000
|
+
for (const deviceSize of devices) {
|
|
1001
|
+
const plan = planDevice(null, { deviceSize });
|
|
1002
|
+
await applyDevice(page, { deviceSize, viewport: plan.viewport, emulation });
|
|
1003
|
+
await page.goto(url, { waitUntil: 'load' });
|
|
1004
|
+
// Load fires before late layout — web fonts, a hydrating app.
|
|
1005
|
+
await sleep(600);
|
|
1006
|
+
const image = await captureScreenshot(page, { kind: 'viewport' }, options);
|
|
1007
|
+
taken.push({ deviceSize, deviceModel: plan.deviceModel, viewport: plan.viewport, image });
|
|
1008
|
+
}
|
|
1009
|
+
return taken;
|
|
1010
|
+
});
|
|
1011
|
+
ok = true;
|
|
1012
|
+
return shots;
|
|
1013
|
+
} finally {
|
|
1014
|
+
this.emit('preview:browser-screenshot', { tabId, source: 'user', phase: 'end', fullPage: false, ok, timestamp: Date.now() });
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
861
1018
|
/**
|
|
862
1019
|
* Change the device class, orientation or exact size of an existing tab,
|
|
863
1020
|
* and rebuild the capture around it.
|
|
@@ -1771,6 +1928,11 @@ class BrowserPreviewServiceManager {
|
|
|
1771
1928
|
ws.emit.project(roomId, 'preview:browser-tab-meta', { ...data, projectId });
|
|
1772
1929
|
});
|
|
1773
1930
|
|
|
1931
|
+
// A screenshot of a tab, whoever took it — every viewer shows the shutter.
|
|
1932
|
+
service.on('preview:browser-screenshot', (data) => {
|
|
1933
|
+
ws.emit.project(roomId, 'preview:browser-screenshot', { ...data, projectId });
|
|
1934
|
+
});
|
|
1935
|
+
|
|
1774
1936
|
// Forward host-capability requests (geolocation, camera, clipboard, …)
|
|
1775
1937
|
// and relayed downloads — both are answered by the viewer's own browser.
|
|
1776
1938
|
service.on('preview:browser-host-request', (data) => {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { elementToClip, readImageSize, regionToClip } from './browser-screenshot';
|
|
3
|
+
|
|
4
|
+
/** The smallest valid PNG header: signature plus an IHDR with the given size. */
|
|
5
|
+
function pngHeader(width: number, height: number): Uint8Array {
|
|
6
|
+
const bytes = new Uint8Array(33);
|
|
7
|
+
bytes.set([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
8
|
+
const view = new DataView(bytes.buffer);
|
|
9
|
+
view.setUint32(8, 13);
|
|
10
|
+
bytes.set([0x49, 0x48, 0x44, 0x52], 12);
|
|
11
|
+
view.setUint32(16, width);
|
|
12
|
+
view.setUint32(20, height);
|
|
13
|
+
return bytes;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** SOI, an APP0 segment to skip, then a baseline start-of-frame. */
|
|
17
|
+
function jpegHeader(width: number, height: number): Uint8Array {
|
|
18
|
+
return new Uint8Array([
|
|
19
|
+
0xff, 0xd8,
|
|
20
|
+
0xff, 0xe0, 0x00, 0x06, 0x4a, 0x46, 0x49, 0x46,
|
|
21
|
+
0xff, 0xc0, 0x00, 0x11, 0x08, height >> 8, height & 0xff, width >> 8, width & 0xff, 0x03,
|
|
22
|
+
0x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('readImageSize', () => {
|
|
27
|
+
test('reads a PNG header', () => {
|
|
28
|
+
expect(readImageSize(pngHeader(1440, 900))).toEqual({ width: 1440, height: 900 });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('reads a JPEG frame header past the segments before it', () => {
|
|
32
|
+
expect(readImageSize(jpegHeader(402, 874))).toEqual({ width: 402, height: 874 });
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('a full-page height past 65535 still reads from a PNG', () => {
|
|
36
|
+
expect(readImageSize(pngHeader(1440, 70_000))).toEqual({ width: 1440, height: 70_000 });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('anything else is not an image it can size', () => {
|
|
40
|
+
expect(readImageSize(new Uint8Array([1, 2, 3, 4]))).toBeNull();
|
|
41
|
+
expect(readImageSize(new Uint8Array())).toBeNull();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('regionToClip', () => {
|
|
46
|
+
const viewport = { width: 1000, height: 800 };
|
|
47
|
+
|
|
48
|
+
test('moves a viewport rectangle into the document by the scroll offset', () => {
|
|
49
|
+
expect(regionToClip({ x: 10, y: 20, width: 300, height: 200 }, viewport, { x: 0, y: 1500 })).toEqual({
|
|
50
|
+
x: 10,
|
|
51
|
+
y: 1520,
|
|
52
|
+
width: 300,
|
|
53
|
+
height: 200
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('a drag made right-to-left or bottom-to-top is the same rectangle', () => {
|
|
58
|
+
expect(regionToClip({ x: 310, y: 220, width: -300, height: -200 }, viewport, { x: 0, y: 0 })).toEqual({
|
|
59
|
+
x: 10,
|
|
60
|
+
y: 20,
|
|
61
|
+
width: 300,
|
|
62
|
+
height: 200
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('stays inside the viewport when the drag ran past its edge', () => {
|
|
67
|
+
expect(regionToClip({ x: -50, y: 700, width: 200, height: 400 }, viewport, { x: 0, y: 0 })).toEqual({
|
|
68
|
+
x: 0,
|
|
69
|
+
y: 700,
|
|
70
|
+
width: 150,
|
|
71
|
+
height: 100
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('an empty selection is no clip', () => {
|
|
76
|
+
expect(regionToClip({ x: 50, y: 50, width: 0, height: 100 }, viewport, { x: 0, y: 0 })).toBeNull();
|
|
77
|
+
expect(regionToClip({ x: 1200, y: 50, width: 100, height: 100 }, viewport, { x: 0, y: 0 })).toBeNull();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('elementToClip', () => {
|
|
82
|
+
const page = {
|
|
83
|
+
label: 'div',
|
|
84
|
+
depth: 0,
|
|
85
|
+
hasParent: true,
|
|
86
|
+
scrollX: 0,
|
|
87
|
+
scrollY: 400,
|
|
88
|
+
viewportWidth: 1000,
|
|
89
|
+
viewportHeight: 800,
|
|
90
|
+
documentWidth: 1000,
|
|
91
|
+
documentHeight: 5000
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
test('an element on screen is captured without leaving the viewport', () => {
|
|
95
|
+
const result = elementToClip({ ...page, rect: { x: 100, y: 50, width: 200, height: 100 } });
|
|
96
|
+
expect(result).toEqual({ clip: { x: 100, y: 450, width: 200, height: 100 }, beyondViewport: false });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('an element taller than the screen asks for the capture beyond it', () => {
|
|
100
|
+
const result = elementToClip({ ...page, rect: { x: 0, y: -100, width: 1000, height: 2000 } });
|
|
101
|
+
expect(result?.beyondViewport).toBe(true);
|
|
102
|
+
expect(result?.clip).toEqual({ x: 0, y: 300, width: 1000, height: 2000 });
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('is kept inside the document', () => {
|
|
106
|
+
const result = elementToClip({ ...page, scrollY: 0, rect: { x: 900, y: 4900, width: 300, height: 300 } });
|
|
107
|
+
expect(result?.clip).toEqual({ x: 900, y: 4900, width: 100, height: 100 });
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('an element with no size is no clip', () => {
|
|
111
|
+
expect(elementToClip({ ...page, rect: { x: 10, y: 10, width: 0, height: 0 } })).toBeNull();
|
|
112
|
+
});
|
|
113
|
+
});
|