@myrialabs/clopen 0.4.50 → 0.4.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/backend/chat/attachments.test.ts +106 -17
- package/backend/chat/attachments.ts +131 -34
- package/backend/chat/engine-handoff.ts +42 -6
- package/backend/chat/stream-manager.ts +41 -5
- package/backend/containers/actions.ts +22 -0
- package/backend/control/actions/projects.ts +93 -37
- package/backend/control/folders.test.ts +27 -2
- package/backend/control/index.ts +2 -1
- package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
- package/backend/database/migrations/086_single_owner.ts +66 -73
- package/backend/database/migrations/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +11 -2
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-queries.ts +3 -0
- package/backend/database/utils/migration-runner.test.ts +196 -0
- package/backend/database/utils/migration-runner.ts +61 -16
- package/backend/database/utils/seeder-runner.ts +22 -16
- package/backend/engine/adapters/claude/stream.ts +5 -0
- package/backend/engine/adapters/cursor/environment.ts +1 -1
- package/backend/engine/adapters/qwen/session-store.ts +10 -1
- package/backend/engine/types.ts +7 -0
- package/backend/git/identity/cli.ts +35 -0
- package/backend/git/identity/env.test.ts +52 -1
- package/backend/git/identity/env.ts +69 -10
- package/backend/git/identity/index.ts +25 -6
- package/backend/git/identity/resolve.ts +2 -1
- package/backend/git/identity/scope-config.ts +13 -7
- package/backend/git-hosts/accounts.ts +106 -0
- package/backend/git-hosts/auth/client-ids.ts +34 -0
- package/backend/git-hosts/auth/connect.ts +110 -0
- package/backend/git-hosts/auth/endpoints.ts +130 -0
- package/backend/git-hosts/auth/flows.ts +355 -0
- package/backend/git-hosts/auth/local.ts +152 -0
- package/backend/git-hosts/ci.ts +18 -0
- package/backend/git-hosts/cli.test.ts +82 -0
- package/backend/git-hosts/cli.ts +342 -0
- package/backend/git-hosts/credentials.ts +173 -0
- package/backend/git-hosts/git-credential.ts +30 -0
- package/backend/git-hosts/health.ts +39 -0
- package/backend/git-hosts/http.ts +174 -0
- package/backend/git-hosts/index.ts +34 -0
- package/backend/git-hosts/providers/bitbucket.ts +186 -0
- package/backend/git-hosts/providers/gitea.ts +208 -0
- package/backend/git-hosts/providers/github.ts +270 -0
- package/backend/git-hosts/providers/gitlab-client.ts +70 -0
- package/backend/git-hosts/providers/gitlab.ts +285 -0
- package/backend/git-hosts/providers/locators.test.ts +68 -0
- package/backend/git-hosts/registry.ts +50 -0
- package/backend/git-hosts/service.ts +432 -0
- package/backend/git-hosts/types.ts +82 -0
- package/backend/git-hosts/urls.test.ts +42 -0
- package/backend/git-hosts/urls.ts +69 -0
- package/backend/index.ts +50 -10
- package/backend/integrations/accounts.ts +50 -3
- package/backend/integrations/registry/define.ts +9 -0
- package/backend/integrations/registry/index.ts +11 -0
- package/backend/integrations/registry/providers/bitbucket.ts +51 -0
- package/backend/integrations/registry/providers/gitea.ts +53 -0
- package/backend/integrations/registry/providers/github.ts +24 -7
- package/backend/integrations/registry/providers/gitlab.ts +57 -0
- package/backend/integrations/registry/types.ts +13 -1
- package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
- package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
- package/backend/mentions/diff.ts +63 -0
- package/backend/mentions/index.ts +109 -0
- package/backend/mentions/mentions.test.ts +27 -0
- package/backend/mentions/shared.ts +82 -0
- package/backend/mentions/sources/ai-changes.ts +140 -0
- package/backend/mentions/sources/chats.ts +122 -0
- package/backend/mentions/sources/database.ts +211 -0
- package/backend/mentions/sources/files.ts +240 -0
- package/backend/mentions/sources/git.ts +308 -0
- package/backend/mentions/sources/notes-memory.ts +121 -0
- package/backend/mentions/sources/ops.ts +125 -0
- package/backend/mentions/sources/preview.ts +153 -0
- package/backend/mentions/sources/projects.ts +114 -0
- package/backend/mentions/sources/system.ts +135 -0
- package/backend/mentions/sources/terminal.ts +50 -0
- package/backend/mentions/types.ts +75 -0
- package/backend/preview/browser/bot-check-frames.test.ts +49 -0
- package/backend/preview/browser/bot-check-frames.ts +66 -0
- package/backend/preview/browser/browser-dialog-handler.ts +6 -5
- package/backend/preview/browser/browser-host-bridge.ts +4 -2
- package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
- package/backend/preview/browser/browser-pool.ts +26 -17
- package/backend/preview/browser/browser-preview-service.ts +164 -2
- package/backend/preview/browser/browser-screenshot.test.ts +113 -0
- package/backend/preview/browser/browser-screenshot.ts +396 -0
- package/backend/preview/browser/browser-tab-manager.ts +35 -186
- package/backend/preview/browser/browser-video-capture.ts +12 -17
- package/backend/preview/browser/element-describe.ts +125 -0
- package/backend/preview/browser/page-binding.ts +141 -0
- package/backend/preview/browser/screenshot-files.test.ts +117 -0
- package/backend/preview/browser/screenshot-files.ts +134 -0
- package/backend/preview/browser/user-agent.test.ts +25 -0
- package/backend/preview/browser/user-agent.ts +100 -0
- package/backend/projects/engine-transcripts.ts +153 -0
- package/backend/projects/folder-guard.ts +55 -0
- package/backend/projects/move.test.ts +208 -0
- package/backend/projects/move.ts +277 -0
- package/backend/projects/project-cleanup.integration.test.ts +3 -1
- package/backend/projects/project-cleanup.ts +10 -0
- package/backend/storage/actions.ts +260 -0
- package/backend/storage/chats.test.ts +57 -0
- package/backend/storage/chats.ts +170 -0
- package/backend/storage/database.ts +105 -0
- package/backend/storage/engine-homes.ts +145 -0
- package/backend/storage/fs-size.ts +111 -0
- package/backend/storage/history.ts +39 -0
- package/backend/storage/policy.ts +156 -0
- package/backend/storage/preview-profiles.ts +169 -0
- package/backend/storage/purge.ts +158 -0
- package/backend/storage/scanner.ts +339 -0
- package/backend/storage/session-index.ts +208 -0
- package/backend/storage/snapshots.ts +99 -0
- package/backend/storage/storage-flow.test.ts +137 -0
- package/backend/storage/transcripts/aliases.ts +75 -0
- package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
- package/backend/storage/transcripts/claude-dedupe.ts +152 -0
- package/backend/storage/transcripts/claude.ts +155 -0
- package/backend/storage/transcripts/cursor.ts +165 -0
- package/backend/storage/transcripts/file-stores.ts +224 -0
- package/backend/storage/transcripts/index.ts +207 -0
- package/backend/storage/transcripts/opencode.ts +124 -0
- package/backend/storage/transcripts/references.ts +42 -0
- package/backend/storage/transcripts/types.ts +58 -0
- package/backend/storage/worktrees.ts +114 -0
- package/backend/terminal/ptykit.ts +25 -0
- package/backend/update/registry.ts +24 -0
- package/backend/update/release-notes.test.ts +110 -0
- package/backend/update/release-notes.ts +132 -0
- package/backend/update/restart.ts +159 -0
- package/backend/utils/env.test.ts +64 -0
- package/backend/utils/env.ts +23 -55
- package/backend/utils/port-utils.ts +13 -0
- package/backend/work/index.ts +13 -2
- package/backend/work/providers/github/actions-logs.ts +1 -1
- package/backend/work/providers/github/adapter.ts +32 -1
- package/backend/work/providers/github/client.ts +7 -3
- package/backend/work/providers/gitlab/adapter.ts +770 -0
- package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
- package/backend/work/service.ts +60 -36
- package/backend/work/start-work.ts +1 -1
- package/backend/work/types.ts +4 -0
- package/backend/worktrees/index.ts +1 -0
- package/backend/worktrees/service.ts +23 -2
- package/backend/ws/chat/composer.ts +47 -6
- package/backend/ws/files/search.ts +1 -1
- package/backend/ws/files/write.ts +27 -0
- package/backend/ws/hosting/index.ts +231 -0
- package/backend/ws/index.ts +12 -2
- package/backend/ws/integrations/crud.ts +31 -5
- package/backend/ws/integrations/hosting-auth.ts +227 -0
- package/backend/ws/integrations/index.ts +2 -0
- package/backend/ws/mentions/index.ts +81 -0
- package/backend/ws/preview/browser/screenshot.ts +184 -0
- package/backend/ws/preview/index.ts +23 -0
- package/backend/ws/projects/crud.ts +66 -58
- package/backend/ws/sessions/crud.ts +7 -95
- package/backend/ws/snapshot/changes.ts +3 -3
- package/backend/ws/storage/index.ts +102 -0
- package/backend/ws/system/index.ts +7 -0
- package/backend/ws/system/operations.ts +125 -69
- package/backend/ws/work/context.ts +3 -4
- package/backend/ws/work/crud.ts +33 -0
- package/backend/ws/work/schemas.ts +4 -1
- package/bin/clopen.ts +15 -16
- package/dist/assets/{index-By6KdSLT.js → index-B9rHDvjg.js} +1 -1
- package/dist/assets/index-B9rHDvjg.js.br +0 -0
- package/dist/assets/index-B9rHDvjg.js.gz +0 -0
- package/dist/assets/{index-DV4TiDn1.js → index-DFlwOd7k.js} +1 -1
- package/dist/assets/index-DFlwOd7k.js.br +0 -0
- package/dist/assets/index-DFlwOd7k.js.gz +0 -0
- package/dist/assets/main-Bz_brxxS.css +1 -0
- package/dist/assets/main-Bz_brxxS.css.br +0 -0
- package/dist/assets/main-Bz_brxxS.css.gz +0 -0
- package/dist/assets/main-DRcX9SHx.js +1273 -0
- package/dist/assets/main-DRcX9SHx.js.br +0 -0
- package/dist/assets/main-DRcX9SHx.js.gz +0 -0
- package/dist/assets/pdf-DfwfQPLy.js +57 -0
- package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
- package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
- package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
- package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
- package/package.json +6 -7
- package/scripts/start.ts +21 -4
- package/shared/constants/binary-extensions.ts +20 -4
- package/shared/constants/support.test.ts +27 -0
- package/shared/constants/support.ts +79 -0
- package/shared/constants/tool-icons.ts +7 -1
- package/shared/types/database/schema.ts +6 -0
- package/shared/types/git-hosting.ts +241 -0
- package/shared/types/integrations.ts +51 -1
- package/shared/types/mentions.ts +96 -0
- package/shared/types/release-notes.ts +31 -0
- package/shared/types/storage.ts +175 -0
- package/shared/types/stores/settings.ts +16 -0
- package/shared/types/unified/index.ts +1 -0
- package/shared/types/unified/message.ts +26 -1
- package/shared/types/unified/tool.ts +4 -0
- package/shared/types/work.ts +6 -0
- package/shared/utils/attachment-mentions.test.ts +39 -0
- package/shared/utils/attachment-mentions.ts +100 -0
- package/shared/utils/context-document.test.ts +53 -0
- package/shared/utils/context-document.ts +226 -0
- package/shared/utils/device-frame.test.ts +73 -0
- package/shared/utils/device-frame.ts +320 -0
- package/shared/utils/fuzzy.ts +79 -0
- package/shared/utils/launcher-fingerprint.test.ts +73 -0
- package/shared/utils/launcher-fingerprint.ts +108 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/page-colors.test.ts +17 -0
- package/shared/utils/page-colors.ts +24 -0
- package/shared/utils/process-supervisor.test.ts +18 -1
- package/shared/utils/process-supervisor.ts +12 -23
- package/shared/utils/restart-intent.test.ts +57 -0
- package/shared/utils/restart-intent.ts +80 -0
- package/shared/utils/semver.test.ts +33 -0
- package/shared/utils/semver.ts +35 -0
- package/shared/utils/supervised-child.ts +44 -0
- package/shared/utils/supervisor-protocol.ts +20 -0
- package/.env.example +0 -9
- package/dist/assets/index-By6KdSLT.js.br +0 -0
- package/dist/assets/index-By6KdSLT.js.gz +0 -0
- package/dist/assets/index-DV4TiDn1.js.br +0 -0
- package/dist/assets/index-DV4TiDn1.js.gz +0 -0
- package/dist/assets/main-DIESTGTD.css +0 -1
- package/dist/assets/main-DIESTGTD.css.br +0 -0
- package/dist/assets/main-DIESTGTD.css.gz +0 -0
- package/dist/assets/main-Da3JKoua.js +0 -1240
- package/dist/assets/main-Da3JKoua.js.br +0 -0
- package/dist/assets/main-Da3JKoua.js.gz +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Restarting the server from the UI, so an update finishes without the user
|
|
3
|
+
* going back to the terminal where they ran `clopen`.
|
|
4
|
+
*
|
|
5
|
+
* It works because the server runs under the launcher's supervisor: the server
|
|
6
|
+
* exits with RESTART_EXIT_CODE, the supervisor starts it again from the files
|
|
7
|
+
* on disk — the new version — and every open tab reloads once it sees the new
|
|
8
|
+
* version (frontend/stores/ui/update.svelte.ts). It is offered only when that
|
|
9
|
+
* is actually what will happen:
|
|
10
|
+
*
|
|
11
|
+
* - `unsupervised`: nothing would start the server again (`bun run dev`, a
|
|
12
|
+
* custom setup).
|
|
13
|
+
* - `launcher-unknown`: the launcher did not say what it runs, so whether the
|
|
14
|
+
* update changed it cannot be told.
|
|
15
|
+
* - `launcher-changed`: the update changes the launcher itself, which only a
|
|
16
|
+
* manual restart of `clopen` replaces (shared/utils/launcher-fingerprint.ts).
|
|
17
|
+
* - `bun-outdated`: the new version needs a newer Bun than the one running;
|
|
18
|
+
* restarting would only crash-loop until the supervisor gives up.
|
|
19
|
+
*
|
|
20
|
+
* What comes back is an ordinary start: scripts/start.ts, then backend/index.ts,
|
|
21
|
+
* which runs pending migrations and seeders before it opens the port — exactly
|
|
22
|
+
* as when `clopen` is run by hand. A start held up by a long migration is not a
|
|
23
|
+
* failure, so the tab never tells the user to stop Clopen; it keeps waiting.
|
|
24
|
+
*
|
|
25
|
+
* Tunnels stop with the server and are not started again, so the browser also
|
|
26
|
+
* withholds Restart now from a device that reaches Clopen through one
|
|
27
|
+
* (`tunnelHosts`) — that device would have no way back.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { readFileSync } from 'node:fs';
|
|
31
|
+
import { join } from 'node:path';
|
|
32
|
+
import { isSupervised, supervisorPid } from '$shared/utils/supervised-child';
|
|
33
|
+
import { LAUNCHER_FINGERPRINT_ENV, computeLauncherFingerprint } from '$shared/utils/launcher-fingerprint';
|
|
34
|
+
import { writeRestartIntent } from '$shared/utils/restart-intent';
|
|
35
|
+
import { SERVER_ENV } from '$backend/utils/env';
|
|
36
|
+
import { streamManager } from '$backend/chat/stream-manager';
|
|
37
|
+
import { countLiveSessions } from '$backend/terminal/ptykit';
|
|
38
|
+
import { tunnelKit } from '$backend/tunnel/tunnel-config';
|
|
39
|
+
import { debug } from '$shared/utils/logger';
|
|
40
|
+
import { fetchLatestManifest, type PackageManifest } from './registry';
|
|
41
|
+
|
|
42
|
+
export type RestartBlocker = 'unsupervised' | 'launcher-unknown' | 'launcher-changed' | 'bun-outdated';
|
|
43
|
+
|
|
44
|
+
export interface RestartReadiness {
|
|
45
|
+
available: boolean;
|
|
46
|
+
blocker?: RestartBlocker;
|
|
47
|
+
/** The Bun range the new version needs, when `bun-outdated`. */
|
|
48
|
+
requiredBun?: string;
|
|
49
|
+
runningBun: string;
|
|
50
|
+
/** Work a restart would stop — shown so nobody loses a reply mid-stream. */
|
|
51
|
+
activeChats: number;
|
|
52
|
+
activeTerminals: number;
|
|
53
|
+
/**
|
|
54
|
+
* Public hostnames of the tunnels that are up. A restart stops them and
|
|
55
|
+
* nothing starts them again — a quick tunnel would come back on a new URL
|
|
56
|
+
* anyway — so a device reaching Clopen through one is cut off. The browser
|
|
57
|
+
* compares its own hostname: this is a decision only the tab can make.
|
|
58
|
+
*/
|
|
59
|
+
tunnelHosts: string[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function tunnelHosts(): string[] {
|
|
63
|
+
const hosts = new Set<string>();
|
|
64
|
+
for (const tunnel of tunnelKit.list()) {
|
|
65
|
+
try {
|
|
66
|
+
if (tunnel.publicUrl) hosts.add(new URL(tunnel.publicUrl).hostname);
|
|
67
|
+
} catch {
|
|
68
|
+
// Not a URL yet (still starting).
|
|
69
|
+
}
|
|
70
|
+
for (const rule of tunnel.ingress ?? []) {
|
|
71
|
+
if (rule.hostname) hosts.add(rule.hostname);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [...hosts];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const PACKAGE_ROOT = join(import.meta.dir, '..', '..');
|
|
78
|
+
|
|
79
|
+
/** Read once: the launcher that started this process does not change under it. */
|
|
80
|
+
const runningLauncher = process.env[LAUNCHER_FINGERPRINT_ENV] || null;
|
|
81
|
+
|
|
82
|
+
function readInstalledManifest(): PackageManifest {
|
|
83
|
+
return JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf-8')) as PackageManifest;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function installedLauncherFingerprint(): string | null {
|
|
87
|
+
try {
|
|
88
|
+
return computeLauncherFingerprint(PACKAGE_ROOT);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
debug.error('server', 'Could not fingerprint the installed launcher:', error);
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether a restart would bring up `target`: what is installed on disk now
|
|
97
|
+
* (after an update), or the latest published version (before one, so the
|
|
98
|
+
* dialog can offer "Update & restart" in one go).
|
|
99
|
+
*/
|
|
100
|
+
export async function getRestartReadiness(target: 'installed' | 'latest'): Promise<RestartReadiness> {
|
|
101
|
+
const base = {
|
|
102
|
+
runningBun: Bun.version,
|
|
103
|
+
activeChats: streamManager.getActiveStreams().length,
|
|
104
|
+
activeTerminals: countLiveSessions(),
|
|
105
|
+
tunnelHosts: tunnelHosts()
|
|
106
|
+
};
|
|
107
|
+
const blocked = (blocker: RestartBlocker, extra: Partial<RestartReadiness> = {}): RestartReadiness => ({
|
|
108
|
+
...base, available: false, blocker, ...extra
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const manifest = target === 'installed' ? readInstalledManifest() : await fetchLatestManifest();
|
|
112
|
+
|
|
113
|
+
// First, because it holds however Clopen is restarted: by hand, the new
|
|
114
|
+
// version would fail to start just the same, so `bun upgrade` is the step
|
|
115
|
+
// the user must not miss.
|
|
116
|
+
const requiredBun = manifest.engines?.bun;
|
|
117
|
+
if (requiredBun && !Bun.semver.satisfies(Bun.version, requiredBun)) {
|
|
118
|
+
return blocked('bun-outdated', { requiredBun });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!isSupervised()) return blocked('unsupervised');
|
|
122
|
+
if (!runningLauncher) return blocked('launcher-unknown');
|
|
123
|
+
|
|
124
|
+
const targetLauncher = target === 'installed'
|
|
125
|
+
? installedLauncherFingerprint()
|
|
126
|
+
: manifest.clopenLauncherFingerprint ?? null;
|
|
127
|
+
if (!targetLauncher) return blocked('launcher-unknown');
|
|
128
|
+
if (targetLauncher !== runningLauncher) return blocked('launcher-changed');
|
|
129
|
+
|
|
130
|
+
return { ...base, available: true };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
let installing = false;
|
|
134
|
+
|
|
135
|
+
/** Set by system:run-update around `bun add -g`; a restart in the middle would start a half-written install. */
|
|
136
|
+
export function setInstalling(value: boolean): void {
|
|
137
|
+
installing = value;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function isInstalling(): boolean {
|
|
141
|
+
return installing;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let restartHandler: (() => void) | null = null;
|
|
145
|
+
|
|
146
|
+
/** Registered by backend/index.ts: shut down cleanly, exiting with RESTART_EXIT_CODE. */
|
|
147
|
+
export function onRestartRequested(handler: () => void): void {
|
|
148
|
+
restartHandler = handler;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Leave the port for the successor and go. Deferred a moment so the reply to
|
|
153
|
+
* the request that asked for this still reaches the browser.
|
|
154
|
+
*/
|
|
155
|
+
export function requestRestart(): void {
|
|
156
|
+
if (!restartHandler) throw new Error('Restart is not available in this process');
|
|
157
|
+
writeRestartIntent(SERVER_ENV.DATA_DIR, SERVER_ENV.PORT, supervisorPid());
|
|
158
|
+
setTimeout(restartHandler, 250);
|
|
159
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { getCleanSpawnEnv } from './env';
|
|
4
|
+
|
|
5
|
+
const touched = new Map<string, string | undefined>();
|
|
6
|
+
|
|
7
|
+
function setEnv(key: string, value: string): void {
|
|
8
|
+
if (!touched.has(key)) touched.set(key, process.env[key]);
|
|
9
|
+
process.env[key] = value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
for (const [key, value] of touched) {
|
|
14
|
+
if (value === undefined) delete process.env[key];
|
|
15
|
+
else process.env[key] = value;
|
|
16
|
+
}
|
|
17
|
+
touched.clear();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('getCleanSpawnEnv', () => {
|
|
21
|
+
test("drops the server's own variables so a nested clopen picks its own port and host", () => {
|
|
22
|
+
setEnv('CLOPEN_HOST', '0.0.0.0');
|
|
23
|
+
setEnv('CLOPEN_PORT', '9200');
|
|
24
|
+
setEnv('CLOPEN_PORT_FRONTEND', '9251');
|
|
25
|
+
setEnv('CLOPEN_PORT_BACKEND', '9261');
|
|
26
|
+
setEnv('CLOPEN_DEBUG', 'true');
|
|
27
|
+
setEnv('CLOPEN_LAUNCHER_FINGERPRINT', 'abc123');
|
|
28
|
+
|
|
29
|
+
const env = getCleanSpawnEnv();
|
|
30
|
+
expect(env.CLOPEN_HOST).toBeUndefined();
|
|
31
|
+
expect(env.CLOPEN_PORT).toBeUndefined();
|
|
32
|
+
expect(env.CLOPEN_PORT_FRONTEND).toBeUndefined();
|
|
33
|
+
expect(env.CLOPEN_PORT_BACKEND).toBeUndefined();
|
|
34
|
+
expect(env.CLOPEN_DEBUG).toBeUndefined();
|
|
35
|
+
expect(env.CLOPEN_LAUNCHER_FINGERPRINT).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('drops runtime pollution', () => {
|
|
39
|
+
setEnv('npm_config_user_agent', 'bun/1.3');
|
|
40
|
+
setEnv('VITE_SOMETHING', '1');
|
|
41
|
+
|
|
42
|
+
const env = getCleanSpawnEnv();
|
|
43
|
+
expect(env.npm_config_user_agent).toBeUndefined();
|
|
44
|
+
expect(env.VITE_SOMETHING).toBeUndefined();
|
|
45
|
+
expect(env.NODE_ENV).toBeUndefined();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("keeps the user's own variables", () => {
|
|
49
|
+
setEnv('MY_TOKEN', 'abc');
|
|
50
|
+
setEnv('CLOPEN_DATA_DIR', '/srv/clopen');
|
|
51
|
+
|
|
52
|
+
const env = getCleanSpawnEnv();
|
|
53
|
+
expect(env.MY_TOKEN).toBe('abc');
|
|
54
|
+
expect(env.CLOPEN_DATA_DIR).toBe('/srv/clopen');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('removes node_modules entries from PATH', () => {
|
|
58
|
+
const sep = process.platform === 'win32' ? ';' : ':';
|
|
59
|
+
const pathKey = process.platform === 'win32' && process.env.Path !== undefined ? 'Path' : 'PATH';
|
|
60
|
+
setEnv(pathKey, ['/usr/bin', '/app/node_modules/.bin', '/bin'].join(sep));
|
|
61
|
+
|
|
62
|
+
expect(getCleanSpawnEnv()[pathKey]).toBe(['/usr/bin', '/bin'].join(sep));
|
|
63
|
+
});
|
|
64
|
+
});
|
package/backend/utils/env.ts
CHANGED
|
@@ -5,16 +5,14 @@
|
|
|
5
5
|
* - SERVER_ENV: saved server configuration values
|
|
6
6
|
* - getCleanSpawnEnv(): clean environment for child processes
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Runtime vars (npm_*, VITE_*, etc.) are always removed.
|
|
8
|
+
* Configuration comes from the shell environment and the CLI flags only —
|
|
9
|
+
* there is no .env file. Child processes get the user's environment minus
|
|
10
|
+
* what Clopen itself injected (its own server variables) and what the
|
|
11
|
+
* runtime injected (npm_*, VITE_*, etc.).
|
|
13
12
|
*
|
|
14
13
|
* No platform-specific code — works on Linux, macOS, Windows, WSL.
|
|
15
14
|
*/
|
|
16
15
|
|
|
17
|
-
import { readFileSync } from 'fs';
|
|
18
16
|
import { join } from 'path';
|
|
19
17
|
import { homedir } from 'os';
|
|
20
18
|
|
|
@@ -61,47 +59,28 @@ export const SERVER_ENV = {
|
|
|
61
59
|
isDevelopment: isDev,
|
|
62
60
|
} as const;
|
|
63
61
|
|
|
64
|
-
// ── .env parsing ────────────────────────────────────────────────────
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Parse a .env file at the given path into a key-value record.
|
|
68
|
-
* Returns an empty object if the file doesn't exist or can't be read.
|
|
69
|
-
*/
|
|
70
|
-
export function loadEnvFile(envPath: string): Record<string, string> {
|
|
71
|
-
const result: Record<string, string> = {};
|
|
72
|
-
try {
|
|
73
|
-
const content = readFileSync(envPath, 'utf-8');
|
|
74
|
-
for (const line of content.split('\n')) {
|
|
75
|
-
let trimmed = line.trim();
|
|
76
|
-
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
77
|
-
if (trimmed.startsWith('export ')) trimmed = trimmed.substring(7).trim();
|
|
78
|
-
const eqIdx = trimmed.indexOf('=');
|
|
79
|
-
if (eqIdx <= 0) continue;
|
|
80
|
-
const key = trimmed.substring(0, eqIdx).trim();
|
|
81
|
-
let value = trimmed.substring(eqIdx + 1).trim();
|
|
82
|
-
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
83
|
-
(value.startsWith("'") && value.endsWith("'"))) {
|
|
84
|
-
value = value.slice(1, -1);
|
|
85
|
-
}
|
|
86
|
-
result[key] = value;
|
|
87
|
-
}
|
|
88
|
-
} catch {
|
|
89
|
-
// .env doesn't exist or can't be read
|
|
90
|
-
}
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Capture once at import time — read from CWD which is set to the clopen
|
|
95
|
-
// installation directory when spawned via bin/clopen.ts (cwd: __dirname).
|
|
96
|
-
const dotEnv = new Map(Object.entries(loadEnvFile(join(process.cwd(), '.env'))));
|
|
97
|
-
|
|
98
62
|
// ── Filter definitions ──────────────────────────────────────────────
|
|
99
63
|
|
|
100
64
|
/** Prefixes always injected by Bun/npm/Vite runtime. */
|
|
101
65
|
const FILTERED_PREFIXES = ['npm_', 'VITE_'];
|
|
102
66
|
|
|
103
|
-
/**
|
|
104
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Specific var names never passed on: injected by the runtime, or Clopen's own
|
|
69
|
+
* server variables. The latter describe *this* server — a `clopen` or
|
|
70
|
+
* `bun run dev` started in a Clopen terminal must pick its own port and host,
|
|
71
|
+
* not inherit the ones the parent server is bound to.
|
|
72
|
+
*/
|
|
73
|
+
const FILTERED_NAMES = new Set([
|
|
74
|
+
'_BUN_WATCHER_CHILD',
|
|
75
|
+
'NODE_ENV',
|
|
76
|
+
'NODE',
|
|
77
|
+
'CLOPEN_HOST',
|
|
78
|
+
'CLOPEN_PORT',
|
|
79
|
+
'CLOPEN_PORT_FRONTEND',
|
|
80
|
+
'CLOPEN_PORT_BACKEND',
|
|
81
|
+
'CLOPEN_DEBUG',
|
|
82
|
+
'CLOPEN_LAUNCHER_FINGERPRINT'
|
|
83
|
+
]);
|
|
105
84
|
|
|
106
85
|
/** Remove node_modules/.bin entries from PATH. */
|
|
107
86
|
function cleanPath(env: Record<string, string>): void {
|
|
@@ -121,15 +100,8 @@ function cleanPath(env: Record<string, string>): void {
|
|
|
121
100
|
/**
|
|
122
101
|
* Build a clean environment for spawning child processes.
|
|
123
102
|
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* → always removed
|
|
127
|
-
* - Key exists in .env AND value still matches .env value
|
|
128
|
-
* → Bun set it, remove (system value was either same or overwritten)
|
|
129
|
-
* - Key exists in .env BUT value differs from .env value
|
|
130
|
-
* → something changed it after .env load, keep current value
|
|
131
|
-
* - Key not in .env, not runtime
|
|
132
|
-
* → system var, keep
|
|
103
|
+
* Every var in process.env is kept except runtime pollution and Clopen's own
|
|
104
|
+
* server variables (FILTERED_PREFIXES / FILTERED_NAMES).
|
|
133
105
|
*/
|
|
134
106
|
export function getCleanSpawnEnv(): Record<string, string> {
|
|
135
107
|
const env: Record<string, string> = {};
|
|
@@ -139,10 +111,6 @@ export function getCleanSpawnEnv(): Record<string, string> {
|
|
|
139
111
|
if (FILTERED_NAMES.has(key)) continue;
|
|
140
112
|
if (FILTERED_PREFIXES.some((p: string) => key.startsWith(p))) continue;
|
|
141
113
|
|
|
142
|
-
// .env comparison: remove only if value still matches what .env defined
|
|
143
|
-
const dotEnvValue = dotEnv.get(key);
|
|
144
|
-
if (dotEnvValue !== undefined && value === dotEnvValue) continue;
|
|
145
|
-
|
|
146
114
|
env[key] = value;
|
|
147
115
|
}
|
|
148
116
|
|
|
@@ -47,6 +47,19 @@ export async function findAvailablePort(startPort: number, maxAttempts = 8): Pro
|
|
|
47
47
|
throw new Error(`No available port found starting from ${startPort} (tried ${maxAttempts} ports)`);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Wait until `port` is free, for a process coming back on the port its
|
|
52
|
+
* predecessor is still letting go of. False if it is still taken at the end.
|
|
53
|
+
*/
|
|
54
|
+
export async function waitForPortFree(port: number, timeoutMs = 15_000, pollMs = 200): Promise<boolean> {
|
|
55
|
+
const deadline = Date.now() + timeoutMs;
|
|
56
|
+
while (await isPortInUse(port)) {
|
|
57
|
+
if (Date.now() >= deadline) return false;
|
|
58
|
+
await new Promise(resolve => setTimeout(resolve, pollMs));
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
50
63
|
const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '[::1]', '::1']);
|
|
51
64
|
|
|
52
65
|
/**
|
package/backend/work/index.ts
CHANGED
|
@@ -21,13 +21,24 @@
|
|
|
21
21
|
import { registerAccountProbe } from '$backend/integrations';
|
|
22
22
|
import { registerWorkProvider } from './registry';
|
|
23
23
|
import { githubWorkAdapter } from './providers/github/adapter';
|
|
24
|
+
import { gitlabWorkAdapter } from './providers/gitlab/adapter';
|
|
24
25
|
import { workService } from './service';
|
|
26
|
+
import { probeHostAccount } from '$backend/git-hosts/health';
|
|
25
27
|
|
|
26
28
|
registerWorkProvider(githubWorkAdapter);
|
|
29
|
+
registerWorkProvider(gitlabWorkAdapter);
|
|
27
30
|
|
|
28
31
|
// Health for accounts whose capability projects no MCP row. Without this the
|
|
29
|
-
// hub would report "Nothing to probe yet" for a GitHub account forever.
|
|
30
|
-
|
|
32
|
+
// hub would report "Nothing to probe yet" for a GitHub account forever. When
|
|
33
|
+
// the Issues & PRs capability is off, the account is still a hosting account,
|
|
34
|
+
// and its health is whether it can still sign in.
|
|
35
|
+
for (const provider of ['github', 'gitlab']) {
|
|
36
|
+
registerAccountProbe(provider, async (accountId, projectId) =>
|
|
37
|
+
(await workService.probe(accountId, projectId)) ?? probeHostAccount(accountId));
|
|
38
|
+
}
|
|
39
|
+
for (const provider of ['gitea', 'bitbucket']) {
|
|
40
|
+
registerAccountProbe(provider, (accountId) => probeHostAccount(accountId));
|
|
41
|
+
}
|
|
31
42
|
|
|
32
43
|
export { workService } from './service';
|
|
33
44
|
export { getWorkAdapter, listWorkAdapters, registerWorkProvider } from './registry';
|
|
@@ -82,7 +82,7 @@ async function fetchJobLog(credentials: GitHubCredentials, jobId: number): Promi
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/** Keep the last `limit` bytes, cut on a line boundary, and say what was dropped. */
|
|
85
|
-
function keepTail(text: string, limit: number): { text: string; truncated: boolean } {
|
|
85
|
+
export function keepTail(text: string, limit: number): { text: string; truncated: boolean } {
|
|
86
86
|
if (text.length <= limit) return { text, truncated: false };
|
|
87
87
|
const tail = text.slice(text.length - limit);
|
|
88
88
|
const firstNewline = tail.indexOf('\n');
|
|
@@ -56,6 +56,8 @@ const CAPABILITIES: WorkProviderCapabilities = {
|
|
|
56
56
|
createIssue: true,
|
|
57
57
|
merge: true,
|
|
58
58
|
assign: true,
|
|
59
|
+
labels: true,
|
|
60
|
+
reviewers: true,
|
|
59
61
|
diff: true
|
|
60
62
|
};
|
|
61
63
|
|
|
@@ -114,6 +116,7 @@ interface GitHubIssue {
|
|
|
114
116
|
/** Present only when this "issue" is really a pull request. */
|
|
115
117
|
pull_request?: unknown;
|
|
116
118
|
head?: { ref: string; sha?: string };
|
|
119
|
+
requested_reviewers?: GitHubUser[];
|
|
117
120
|
base?: { ref: string };
|
|
118
121
|
merged?: boolean;
|
|
119
122
|
mergeable?: boolean | null;
|
|
@@ -248,7 +251,8 @@ function toWorkItem(raw: GitHubIssue, kind: WorkItemKind): WorkItem {
|
|
|
248
251
|
headBranch: raw.head?.ref,
|
|
249
252
|
...(raw.head?.sha && { headSha: raw.head.sha }),
|
|
250
253
|
baseBranch: raw.base?.ref,
|
|
251
|
-
isDraft: raw.draft === true
|
|
254
|
+
isDraft: raw.draft === true,
|
|
255
|
+
...(raw.requested_reviewers && { reviewers: raw.requested_reviewers.map((user) => user.login) })
|
|
252
256
|
})
|
|
253
257
|
};
|
|
254
258
|
}
|
|
@@ -1216,6 +1220,33 @@ export const githubWorkAdapter: WorkProviderAdapter = {
|
|
|
1216
1220
|
invalidateGitHubCache(credentials.token);
|
|
1217
1221
|
},
|
|
1218
1222
|
|
|
1223
|
+
async setLabels(context: WorkContext, _kind: WorkItemKind, id: string, labels: string[]): Promise<void> {
|
|
1224
|
+
const credentials = credentialsOf(context);
|
|
1225
|
+
// PUT replaces the set, which is what the picker means.
|
|
1226
|
+
await onRepo(context, () => githubRequest(
|
|
1227
|
+
credentials,
|
|
1228
|
+
`/repos/${context.binding.locator}/issues/${id}/labels`,
|
|
1229
|
+
{ method: 'PUT', body: { labels } }
|
|
1230
|
+
));
|
|
1231
|
+
invalidateGitHubCache(credentials.token);
|
|
1232
|
+
},
|
|
1233
|
+
|
|
1234
|
+
async setReviewers(context: WorkContext, id: string, logins: string[]): Promise<void> {
|
|
1235
|
+
const credentials = credentialsOf(context);
|
|
1236
|
+
const path = `/repos/${context.binding.locator}/pulls/${id}/requested_reviewers`;
|
|
1237
|
+
// GitHub only adds and removes, so the difference is worked out here —
|
|
1238
|
+
// read fresh, because a cached list would undo someone's change on the web.
|
|
1239
|
+
const current = await onRepo(context, () =>
|
|
1240
|
+
githubRequest<{ users: GitHubUser[] }>(credentials, path, { noCache: true }));
|
|
1241
|
+
const now = new Set((current.data?.users ?? []).map((user) => user.login));
|
|
1242
|
+
const wanted = new Set(logins);
|
|
1243
|
+
const add = [...wanted].filter((login) => !now.has(login));
|
|
1244
|
+
const remove = [...now].filter((login) => !wanted.has(login));
|
|
1245
|
+
if (add.length) await onRepo(context, () => githubRequest(credentials, path, { method: 'POST', body: { reviewers: add } }));
|
|
1246
|
+
if (remove.length) await onRepo(context, () => githubRequest(credentials, path, { method: 'DELETE', body: { reviewers: remove } }));
|
|
1247
|
+
invalidateGitHubCache(credentials.token);
|
|
1248
|
+
},
|
|
1249
|
+
|
|
1219
1250
|
async createIssue(
|
|
1220
1251
|
context: WorkContext,
|
|
1221
1252
|
draft: { title: string; body: string; assignees: string[]; labels: string[] }
|
|
@@ -126,6 +126,8 @@ export interface GitHubResponse<T> {
|
|
|
126
126
|
rateLimit: WorkRateLimit | null;
|
|
127
127
|
/** Present when the response carried a `Link: rel="next"`. */
|
|
128
128
|
nextUrl: string | null;
|
|
129
|
+
/** The response headers — `x-oauth-scopes` is the one callers read. */
|
|
130
|
+
headers: Headers;
|
|
129
131
|
}
|
|
130
132
|
|
|
131
133
|
function parseNextLink(headers: Headers): string | null {
|
|
@@ -175,6 +177,8 @@ async function toError(response: Response): Promise<GitHubError> {
|
|
|
175
177
|
|
|
176
178
|
export interface RequestOptions {
|
|
177
179
|
method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
180
|
+
/** Accept a body that is not JSON and return it as text — template sources, logs. */
|
|
181
|
+
text?: boolean;
|
|
178
182
|
body?: unknown;
|
|
179
183
|
/** Skip the ETag cache — used when a write must be observed immediately. */
|
|
180
184
|
noCache?: boolean;
|
|
@@ -221,14 +225,14 @@ export async function githubRequest<T>(
|
|
|
221
225
|
const rateLimit = parseRateLimit(response.headers);
|
|
222
226
|
|
|
223
227
|
if (response.status === 304 && cached) {
|
|
224
|
-
return { data: cached.body as T, rateLimit, nextUrl: parseNextLink(response.headers) };
|
|
228
|
+
return { data: cached.body as T, rateLimit, nextUrl: parseNextLink(response.headers), headers: response.headers };
|
|
225
229
|
}
|
|
226
230
|
|
|
227
231
|
if (!response.ok) throw await toError(response);
|
|
228
232
|
|
|
229
233
|
// 204 (and any other empty body) is a legitimate success for the write paths.
|
|
230
234
|
const text = await response.text();
|
|
231
|
-
const data = (text ? JSON.parse(text) : null) as T;
|
|
235
|
+
const data = (options.text ? text : text ? JSON.parse(text) : null) as T;
|
|
232
236
|
|
|
233
237
|
const etag = response.headers.get('etag');
|
|
234
238
|
if (method === 'GET' && etag) {
|
|
@@ -241,7 +245,7 @@ export async function githubRequest<T>(
|
|
|
241
245
|
etagCache.set(cacheKey, { etag, body: data });
|
|
242
246
|
}
|
|
243
247
|
|
|
244
|
-
return { data, rateLimit, nextUrl: parseNextLink(response.headers) };
|
|
248
|
+
return { data, rateLimit, nextUrl: parseNextLink(response.headers), headers: response.headers };
|
|
245
249
|
}
|
|
246
250
|
|
|
247
251
|
/**
|