@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,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One request against a hosting service's REST API.
|
|
3
|
+
*
|
|
4
|
+
* GitHub has its own client (`backend/work/providers/github/client.ts`) because
|
|
5
|
+
* it has ETag caching and a rate-limit footer worth keeping. GitLab, Gitea and
|
|
6
|
+
* Bitbucket go through this smaller one: JSON over HTTPS, a timeout, and the
|
|
7
|
+
* same honest error mapping — 401 means "sign in again", 403/404 mean "this
|
|
8
|
+
* account cannot reach it", and anything else is reported verbatim.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { WorkRateLimit } from '$shared/types/work';
|
|
12
|
+
|
|
13
|
+
const REQUEST_TIMEOUT_MS = 20_000;
|
|
14
|
+
|
|
15
|
+
export type HostErrorKind = 'auth' | 'config' | 'rate-limit' | 'conflict' | 'error';
|
|
16
|
+
|
|
17
|
+
export class HostApiError extends Error {
|
|
18
|
+
constructor(
|
|
19
|
+
message: string,
|
|
20
|
+
readonly status: number,
|
|
21
|
+
readonly kind: HostErrorKind
|
|
22
|
+
) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'HostApiError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface HostRequestOptions {
|
|
29
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
/** JSON body. Use `form` for `application/x-www-form-urlencoded`. */
|
|
32
|
+
body?: unknown;
|
|
33
|
+
form?: Record<string, string>;
|
|
34
|
+
/** Accept a non-JSON body and return it as text. */
|
|
35
|
+
text?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface HostResponse<T> {
|
|
39
|
+
data: T;
|
|
40
|
+
headers: Headers;
|
|
41
|
+
status: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The most specific message a failed response carries. */
|
|
45
|
+
async function messageOf(response: Response): Promise<string> {
|
|
46
|
+
const fallback = response.statusText || `HTTP ${response.status}`;
|
|
47
|
+
try {
|
|
48
|
+
const text = await response.text();
|
|
49
|
+
if (!text) return fallback;
|
|
50
|
+
try {
|
|
51
|
+
const body = JSON.parse(text) as Record<string, unknown>;
|
|
52
|
+
// GitLab: { message } or { error, error_description }. Gitea: { message }.
|
|
53
|
+
// Bitbucket: { error: { message } }.
|
|
54
|
+
const nested = body.error as { message?: unknown } | string | undefined;
|
|
55
|
+
const candidates = [
|
|
56
|
+
body.message,
|
|
57
|
+
body.error_description,
|
|
58
|
+
typeof nested === 'object' ? nested?.message : nested
|
|
59
|
+
];
|
|
60
|
+
for (const candidate of candidates) {
|
|
61
|
+
if (typeof candidate === 'string' && candidate.trim()) return candidate.trim();
|
|
62
|
+
if (candidate && typeof candidate === 'object') return JSON.stringify(candidate);
|
|
63
|
+
}
|
|
64
|
+
return fallback;
|
|
65
|
+
} catch {
|
|
66
|
+
return text.length < 300 ? text : fallback;
|
|
67
|
+
}
|
|
68
|
+
} catch {
|
|
69
|
+
return fallback;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function toHostError(response: Response, service: string): Promise<HostApiError> {
|
|
74
|
+
const message = await messageOf(response);
|
|
75
|
+
if (response.status === 401) {
|
|
76
|
+
return new HostApiError(`${message}. The ${service} credential is invalid, expired or was revoked.`, 401, 'auth');
|
|
77
|
+
}
|
|
78
|
+
if (response.status === 429) {
|
|
79
|
+
return new HostApiError(`${service} is rate limiting requests. Try again in a minute.`, 429, 'rate-limit');
|
|
80
|
+
}
|
|
81
|
+
if (response.status === 403) {
|
|
82
|
+
return new HostApiError(`${message}. The ${service} account is missing a permission this needs.`, 403, 'config');
|
|
83
|
+
}
|
|
84
|
+
if (response.status === 404) {
|
|
85
|
+
return new HostApiError(`${message}. It does not exist, or this ${service} account cannot see it.`, 404, 'config');
|
|
86
|
+
}
|
|
87
|
+
if (response.status === 409 || response.status === 422) {
|
|
88
|
+
return new HostApiError(message, response.status, 'conflict');
|
|
89
|
+
}
|
|
90
|
+
return new HostApiError(message, response.status, 'error');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export async function hostRequest<T>(
|
|
94
|
+
service: string,
|
|
95
|
+
url: string,
|
|
96
|
+
options: HostRequestOptions = {}
|
|
97
|
+
): Promise<HostResponse<T>> {
|
|
98
|
+
const headers: Record<string, string> = {
|
|
99
|
+
Accept: 'application/json',
|
|
100
|
+
'User-Agent': 'clopen',
|
|
101
|
+
...options.headers
|
|
102
|
+
};
|
|
103
|
+
let body: string | undefined;
|
|
104
|
+
if (options.form) {
|
|
105
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
|
106
|
+
body = new URLSearchParams(options.form).toString();
|
|
107
|
+
} else if (options.body !== undefined) {
|
|
108
|
+
headers['Content-Type'] = 'application/json';
|
|
109
|
+
body = JSON.stringify(options.body);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let response: Response;
|
|
113
|
+
try {
|
|
114
|
+
response = await fetch(url, {
|
|
115
|
+
method: options.method ?? 'GET',
|
|
116
|
+
headers,
|
|
117
|
+
...(body !== undefined && { body }),
|
|
118
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
|
|
119
|
+
});
|
|
120
|
+
} catch (error) {
|
|
121
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
122
|
+
throw new HostApiError(`Could not reach ${service}: ${detail}`, 0, 'error');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!response.ok) throw await toHostError(response, service);
|
|
126
|
+
|
|
127
|
+
const text = await response.text();
|
|
128
|
+
if (options.text) return { data: text as T, headers: response.headers, status: response.status };
|
|
129
|
+
let data: T;
|
|
130
|
+
try {
|
|
131
|
+
data = (text ? JSON.parse(text) : null) as T;
|
|
132
|
+
} catch {
|
|
133
|
+
throw new HostApiError(`${service} answered with something that is not JSON`, response.status, 'error');
|
|
134
|
+
}
|
|
135
|
+
return { data, headers: response.headers, status: response.status };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** GitLab-style rate limit headers, which Gitea mirrors. Null when absent. */
|
|
139
|
+
export function rateLimitFrom(headers: Headers): WorkRateLimit | null {
|
|
140
|
+
const remaining = headers.get('ratelimit-remaining') ?? headers.get('x-ratelimit-remaining');
|
|
141
|
+
const limit = headers.get('ratelimit-limit') ?? headers.get('x-ratelimit-limit');
|
|
142
|
+
if (remaining === null || limit === null) return null;
|
|
143
|
+
const reset = headers.get('ratelimit-reset') ?? headers.get('x-ratelimit-reset');
|
|
144
|
+
return {
|
|
145
|
+
remaining: Number(remaining),
|
|
146
|
+
limit: Number(limit),
|
|
147
|
+
resetAt: reset ? new Date(Number(reset) * 1000).toISOString() : null
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Run `work` over `items` with at most `limit` in flight. Order is preserved. */
|
|
152
|
+
export async function mapLimited<T, R>(items: T[], limit: number, work: (item: T) => Promise<R>): Promise<R[]> {
|
|
153
|
+
const results: R[] = new Array(items.length);
|
|
154
|
+
let next = 0;
|
|
155
|
+
const runners = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
156
|
+
while (next < items.length) {
|
|
157
|
+
const index = next++;
|
|
158
|
+
results[index] = await work(items[index]!);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
await Promise.all(runners);
|
|
162
|
+
return results;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Wait, then try again until `check` returns a value or the deadline passes. */
|
|
166
|
+
export async function waitFor<T>(check: () => Promise<T | null>, timeoutMs: number, intervalMs = 1500): Promise<T | null> {
|
|
167
|
+
const deadline = Date.now() + timeoutMs;
|
|
168
|
+
while (Date.now() < deadline) {
|
|
169
|
+
const value = await check().catch(() => null);
|
|
170
|
+
if (value !== null) return value;
|
|
171
|
+
await Bun.sleep(intervalMs);
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git hosting — GitHub, GitLab, Gitea/Forgejo and Bitbucket, as the services a
|
|
3
|
+
* repository lives on.
|
|
4
|
+
*
|
|
5
|
+
* types.ts the adapter contract
|
|
6
|
+
* registry.ts provider id → adapter
|
|
7
|
+
* providers/ one adapter per service
|
|
8
|
+
* accounts.ts which connected account answers for a host or a remote
|
|
9
|
+
* credentials.ts a credential as it should be used now (linked CLI, OAuth refresh)
|
|
10
|
+
* cli.ts logins already on this machine — gh, glab, tea, git's keychain
|
|
11
|
+
* auth/ device flow, browser flow, and turning any credential into an account
|
|
12
|
+
* service.ts what the Git panel asks: context, publish, fork, CI, templates
|
|
13
|
+
* git-credential the hosting half of the git credential helper
|
|
14
|
+
*
|
|
15
|
+
* Importing this module wires the one side effect it has: a terminal's git
|
|
16
|
+
* config file names the hosts that accounts answer for, so it is rewritten
|
|
17
|
+
* whenever an account is connected, changed or removed.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { onAccountsChanged } from '$backend/integrations';
|
|
21
|
+
import { refreshScopeConfigs } from '$backend/git/identity';
|
|
22
|
+
|
|
23
|
+
onAccountsChanged(() => {
|
|
24
|
+
void refreshScopeConfigs();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export { hostingService, suggestGitignore } from './service';
|
|
28
|
+
export { getHostAdapter, isGitHostKind, cloudHostKind } from './registry';
|
|
29
|
+
export { accountForRemote, hostAccounts, hostAccountById } from './accounts';
|
|
30
|
+
export { credentialsForUse, authSourceOf } from './credentials';
|
|
31
|
+
export { connectHostAccount } from './auth/connect';
|
|
32
|
+
export { startDeviceFlow, startBrowserFlow, completeBrowserFlow, failBrowserFlow, pollFlow, cancelFlow, oauthCallbackUri } from './auth/flows';
|
|
33
|
+
export { detectLocal, connectFromCli, connectFromKeychain, probeServer } from './auth/local';
|
|
34
|
+
export type { GitHostAdapter, HostCredentials } from './types';
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitbucket Cloud as a repository host.
|
|
3
|
+
*
|
|
4
|
+
* Authenticated with an Atlassian API token: `email:token` over Basic auth for
|
|
5
|
+
* the REST API. Owners are WORKSPACES, and a repository's locator is
|
|
6
|
+
* `workspace/slug`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { CommitCiState, CommitCiStatus, HostedRepo, HostOwner, HostViewer } from '$shared/types/git-hosting';
|
|
10
|
+
import { HostApiError, hostRequest, mapLimited, type HostRequestOptions } from '../http';
|
|
11
|
+
import { parseRemoteUrl, withoutUserInfo } from '../urls';
|
|
12
|
+
import type { CreateRepoInput, GitHostAdapter, HostCredentials, RepoQuery } from '../types';
|
|
13
|
+
import { rollUp } from '../ci';
|
|
14
|
+
|
|
15
|
+
const API = 'https://api.bitbucket.org/2.0';
|
|
16
|
+
const WEB = 'https://bitbucket.org';
|
|
17
|
+
|
|
18
|
+
async function bbRequest<T>(credentials: HostCredentials, path: string, options: HostRequestOptions = {}) {
|
|
19
|
+
const email = credentials.email ?? '';
|
|
20
|
+
const token = credentials.token ?? '';
|
|
21
|
+
if (!email || !token) throw new HostApiError('This Bitbucket account needs an email and an API token', 0, 'config');
|
|
22
|
+
const basic = Buffer.from(`${email}:${token}`).toString('base64');
|
|
23
|
+
return hostRequest<T>('Bitbucket', path.startsWith('http') ? path : `${API}${path}`, {
|
|
24
|
+
...options,
|
|
25
|
+
headers: { Authorization: `Basic ${basic}`, ...options.headers }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface BitbucketRepoWire {
|
|
30
|
+
full_name: string;
|
|
31
|
+
slug: string;
|
|
32
|
+
name: string;
|
|
33
|
+
workspace?: { slug: string };
|
|
34
|
+
description: string;
|
|
35
|
+
is_private: boolean;
|
|
36
|
+
parent?: { full_name: string } | null;
|
|
37
|
+
mainbranch?: { name: string } | null;
|
|
38
|
+
updated_on?: string;
|
|
39
|
+
links: {
|
|
40
|
+
html: { href: string };
|
|
41
|
+
clone?: { name: string; href: string }[];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function toRepo(raw: BitbucketRepoWire): HostedRepo {
|
|
46
|
+
const clone = raw.links.clone ?? [];
|
|
47
|
+
const https = clone.find((entry) => entry.name === 'https')?.href ?? `${WEB}/${raw.full_name}.git`;
|
|
48
|
+
return {
|
|
49
|
+
fullName: raw.full_name,
|
|
50
|
+
owner: raw.workspace?.slug ?? raw.full_name.split('/')[0] ?? '',
|
|
51
|
+
name: raw.slug,
|
|
52
|
+
description: raw.description || null,
|
|
53
|
+
isPrivate: raw.is_private,
|
|
54
|
+
isFork: !!raw.parent,
|
|
55
|
+
parentFullName: raw.parent?.full_name ?? null,
|
|
56
|
+
defaultBranch: raw.mainbranch?.name ?? null,
|
|
57
|
+
// The clone link carries the user's name; written into `.git/config` it
|
|
58
|
+
// would override the credential helper's username.
|
|
59
|
+
cloneUrlHttps: withoutUserInfo(https),
|
|
60
|
+
cloneUrlSsh: clone.find((entry) => entry.name === 'ssh')?.href ?? null,
|
|
61
|
+
webUrl: raw.links.html.href,
|
|
62
|
+
updatedAt: raw.updated_on ?? null,
|
|
63
|
+
canPush: null
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const REPO_PAGE = 50;
|
|
68
|
+
|
|
69
|
+
export const bitbucketHost: GitHostAdapter = {
|
|
70
|
+
kind: 'bitbucket',
|
|
71
|
+
serviceName: 'Bitbucket',
|
|
72
|
+
|
|
73
|
+
webBase: () => WEB,
|
|
74
|
+
host: () => 'bitbucket.org',
|
|
75
|
+
|
|
76
|
+
locatorFromRemote(url) {
|
|
77
|
+
const parsed = parseRemoteUrl(url);
|
|
78
|
+
if (!parsed || parsed.host !== 'bitbucket.org') return null;
|
|
79
|
+
const parts = parsed.path.split('/').filter(Boolean);
|
|
80
|
+
return parts.length >= 2 ? `${parts[0]}/${parts[1]}` : null;
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// The fixed username Bitbucket expects for git over HTTPS with an API token.
|
|
84
|
+
gitUsername: () => 'x-bitbucket-api-token-auth',
|
|
85
|
+
|
|
86
|
+
async viewer(credentials): Promise<HostViewer> {
|
|
87
|
+
const response = await bbRequest<{ username: string; display_name: string | null; links?: { avatar?: { href: string } } }>(
|
|
88
|
+
credentials,
|
|
89
|
+
'/user'
|
|
90
|
+
);
|
|
91
|
+
return {
|
|
92
|
+
login: response.data.username,
|
|
93
|
+
name: response.data.display_name,
|
|
94
|
+
avatarUrl: response.data.links?.avatar?.href ?? null,
|
|
95
|
+
scopes: null,
|
|
96
|
+
missingScopes: []
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
async listOwners(credentials): Promise<HostOwner[]> {
|
|
101
|
+
const [user, workspaces] = await Promise.all([
|
|
102
|
+
bbRequest<{ username: string }>(credentials, '/user'),
|
|
103
|
+
bbRequest<{ values: { workspace: { slug: string; name: string } }[] }>(credentials, '/user/workspaces?pagelen=100')
|
|
104
|
+
]);
|
|
105
|
+
const login = user.data.username;
|
|
106
|
+
return (workspaces.data.values ?? [])
|
|
107
|
+
.map(({ workspace }): HostOwner => ({
|
|
108
|
+
login: workspace.slug,
|
|
109
|
+
kind: workspace.slug === login ? 'user' : 'org',
|
|
110
|
+
name: workspace.name,
|
|
111
|
+
avatarUrl: null
|
|
112
|
+
}))
|
|
113
|
+
// The personal workspace first, like the other services.
|
|
114
|
+
.sort((a, b) => (a.kind === 'user' ? -1 : b.kind === 'user' ? 1 : a.login.localeCompare(b.login)));
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
async listRepos(credentials, query: RepoQuery) {
|
|
118
|
+
const params = new URLSearchParams({ role: 'member', sort: '-updated_on', pagelen: String(REPO_PAGE), page: String(query.page) });
|
|
119
|
+
const clauses: string[] = [];
|
|
120
|
+
if (query.search?.trim()) clauses.push(`name ~ "${query.search.trim().replace(/"/g, '')}"`);
|
|
121
|
+
if (clauses.length) params.set('q', clauses.join(' AND '));
|
|
122
|
+
const path = query.owner
|
|
123
|
+
? `/repositories/${encodeURIComponent(query.owner)}?${params.toString()}`
|
|
124
|
+
: `/repositories?${params.toString()}`;
|
|
125
|
+
const response = await bbRequest<{ values: BitbucketRepoWire[]; next?: string }>(credentials, path);
|
|
126
|
+
return { repos: (response.data.values ?? []).map(toRepo), hasMore: !!response.data.next };
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
async getRepo(credentials, locator) {
|
|
130
|
+
const response = await bbRequest<BitbucketRepoWire>(credentials, `/repositories/${locator}`);
|
|
131
|
+
return toRepo(response.data);
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
async createRepo(credentials, input: CreateRepoInput) {
|
|
135
|
+
const slug = input.name.toLowerCase();
|
|
136
|
+
const response = await bbRequest<BitbucketRepoWire>(
|
|
137
|
+
credentials,
|
|
138
|
+
`/repositories/${encodeURIComponent(input.owner.login)}/${encodeURIComponent(slug)}`,
|
|
139
|
+
{
|
|
140
|
+
method: 'POST',
|
|
141
|
+
body: { scm: 'git', is_private: input.isPrivate, description: input.description, name: input.name }
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
return toRepo(response.data);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
async fork(credentials, locator) {
|
|
148
|
+
const response = await bbRequest<BitbucketRepoWire>(credentials, `/repositories/${locator}/forks`, {
|
|
149
|
+
method: 'POST',
|
|
150
|
+
body: {}
|
|
151
|
+
});
|
|
152
|
+
return toRepo(response.data);
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
async commitStatuses(credentials, locator, shas): Promise<CommitCiStatus[]> {
|
|
156
|
+
return mapLimited(shas, 4, async (sha): Promise<CommitCiStatus> => {
|
|
157
|
+
try {
|
|
158
|
+
const response = await bbRequest<{ values: { state: string }[] }>(
|
|
159
|
+
credentials,
|
|
160
|
+
`/repositories/${locator}/commit/${encodeURIComponent(sha)}/statuses?pagelen=50`
|
|
161
|
+
);
|
|
162
|
+
const states = (response.data.values ?? []).map((entry): CommitCiState =>
|
|
163
|
+
entry.state === 'SUCCESSFUL' ? 'success'
|
|
164
|
+
: entry.state === 'INPROGRESS' ? 'pending'
|
|
165
|
+
: entry.state === 'FAILED' ? 'failure'
|
|
166
|
+
: 'none').filter((state) => state !== 'none');
|
|
167
|
+
return rollUp(sha, states, `${WEB}/${locator}/commits/${sha}`);
|
|
168
|
+
} catch {
|
|
169
|
+
return { sha, state: 'none', url: null, summary: 'No checks' };
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
links(_credentials, locator) {
|
|
175
|
+
const repo = `${WEB}/${locator}`;
|
|
176
|
+
return {
|
|
177
|
+
repo,
|
|
178
|
+
commit: `${repo}/commits/{sha}`,
|
|
179
|
+
branch: `${repo}/branch/{branch}`,
|
|
180
|
+
file: `${repo}/src/{ref}/{path}`,
|
|
181
|
+
fileLine: '#lines-{line}',
|
|
182
|
+
compare: `${repo}/branches/compare/{head}%0D{base}`,
|
|
183
|
+
newPullRequest: `${repo}/pull-requests/new?source={head}&dest={base}`
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gitea and Forgejo as a repository host.
|
|
3
|
+
*
|
|
4
|
+
* Forgejo kept Gitea's API, so one adapter serves both. Always self-hosted:
|
|
5
|
+
* there is no default server, and the account's `baseUrl` is required.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { CommitCiState, CommitCiStatus, HostedRepo, HostOwner, HostViewer } from '$shared/types/git-hosting';
|
|
9
|
+
import { HostApiError, hostRequest, mapLimited, type HostRequestOptions } from '../http';
|
|
10
|
+
import { hostOfBase, normaliseBaseUrl, parseRemoteUrl } from '../urls';
|
|
11
|
+
import type { CreateRepoInput, GitHostAdapter, HostCredentials, RepoQuery } from '../types';
|
|
12
|
+
|
|
13
|
+
function webBase(credentials: HostCredentials): string {
|
|
14
|
+
return normaliseBaseUrl(credentials.baseUrl);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function giteaRequest<T>(credentials: HostCredentials, path: string, options: HostRequestOptions = {}) {
|
|
18
|
+
const base = webBase(credentials);
|
|
19
|
+
if (!base) throw new HostApiError('This Gitea account has no server URL', 0, 'config');
|
|
20
|
+
return hostRequest<T>('Gitea', `${base}/api/v1${path}`, {
|
|
21
|
+
...options,
|
|
22
|
+
headers: { Authorization: `Bearer ${credentials.token ?? ''}`, ...options.headers }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface GiteaRepoWire {
|
|
27
|
+
full_name: string;
|
|
28
|
+
name: string;
|
|
29
|
+
owner: { login: string };
|
|
30
|
+
description: string | null;
|
|
31
|
+
private: boolean;
|
|
32
|
+
fork: boolean;
|
|
33
|
+
parent?: { full_name: string } | null;
|
|
34
|
+
default_branch?: string;
|
|
35
|
+
clone_url: string;
|
|
36
|
+
ssh_url?: string;
|
|
37
|
+
html_url: string;
|
|
38
|
+
updated_at?: string;
|
|
39
|
+
permissions?: { push?: boolean; admin?: boolean };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function toRepo(raw: GiteaRepoWire): HostedRepo {
|
|
43
|
+
return {
|
|
44
|
+
fullName: raw.full_name,
|
|
45
|
+
owner: raw.owner.login,
|
|
46
|
+
name: raw.name,
|
|
47
|
+
description: raw.description || null,
|
|
48
|
+
isPrivate: raw.private,
|
|
49
|
+
isFork: raw.fork,
|
|
50
|
+
parentFullName: raw.parent?.full_name ?? null,
|
|
51
|
+
defaultBranch: raw.default_branch ?? null,
|
|
52
|
+
cloneUrlHttps: raw.clone_url,
|
|
53
|
+
cloneUrlSsh: raw.ssh_url ?? null,
|
|
54
|
+
webUrl: raw.html_url,
|
|
55
|
+
updatedAt: raw.updated_at ?? null,
|
|
56
|
+
canPush: raw.permissions ? raw.permissions.push === true || raw.permissions.admin === true : null
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const REPO_PAGE = 50;
|
|
61
|
+
|
|
62
|
+
export const giteaHost: GitHostAdapter = {
|
|
63
|
+
kind: 'gitea',
|
|
64
|
+
serviceName: 'Gitea',
|
|
65
|
+
|
|
66
|
+
webBase,
|
|
67
|
+
host: (credentials) => hostOfBase(webBase(credentials)),
|
|
68
|
+
|
|
69
|
+
locatorFromRemote(url, credentials) {
|
|
70
|
+
const parsed = parseRemoteUrl(url);
|
|
71
|
+
if (!parsed || parsed.host !== this.host(credentials)) return null;
|
|
72
|
+
const parts = parsed.path.split('/').filter(Boolean);
|
|
73
|
+
// A Gitea served under a sub-path puts that prefix in front of every
|
|
74
|
+
// repository path; the last two segments are always owner/name.
|
|
75
|
+
return parts.length >= 2 ? `${parts[parts.length - 2]}/${parts[parts.length - 1]}` : null;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Gitea checks the token, not the name, but the name must be one it knows.
|
|
79
|
+
gitUsername: (credentials) => credentials.login || 'oauth2',
|
|
80
|
+
|
|
81
|
+
async viewer(credentials): Promise<HostViewer> {
|
|
82
|
+
const response = await giteaRequest<{ login: string; full_name: string | null; avatar_url: string | null }>(credentials, '/user');
|
|
83
|
+
return {
|
|
84
|
+
login: response.data.login,
|
|
85
|
+
name: response.data.full_name || null,
|
|
86
|
+
avatarUrl: response.data.avatar_url,
|
|
87
|
+
scopes: null,
|
|
88
|
+
missingScopes: []
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
async listOwners(credentials): Promise<HostOwner[]> {
|
|
93
|
+
const [user, orgs] = await Promise.all([
|
|
94
|
+
giteaRequest<{ login: string; full_name: string | null; avatar_url: string | null }>(credentials, '/user'),
|
|
95
|
+
giteaRequest<{ username: string; full_name: string | null; avatar_url: string | null }[]>(credentials, '/user/orgs?limit=50')
|
|
96
|
+
]);
|
|
97
|
+
return [
|
|
98
|
+
{ login: user.data.login, kind: 'user', name: user.data.full_name || null, avatarUrl: user.data.avatar_url },
|
|
99
|
+
...(orgs.data ?? []).map((org): HostOwner => ({
|
|
100
|
+
login: org.username,
|
|
101
|
+
kind: 'org',
|
|
102
|
+
name: org.full_name || null,
|
|
103
|
+
avatarUrl: org.avatar_url
|
|
104
|
+
}))
|
|
105
|
+
];
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
async listRepos(credentials, query: RepoQuery) {
|
|
109
|
+
const needle = (query.search ?? '').trim().toLowerCase();
|
|
110
|
+
const owner = (query.owner ?? '').trim().toLowerCase();
|
|
111
|
+
const response = await giteaRequest<GiteaRepoWire[]>(
|
|
112
|
+
credentials,
|
|
113
|
+
`/user/repos?limit=${REPO_PAGE}&page=${query.page}`
|
|
114
|
+
);
|
|
115
|
+
const page = response.data ?? [];
|
|
116
|
+
const repos = page.map(toRepo).filter((repo) =>
|
|
117
|
+
(!owner || repo.owner.toLowerCase() === owner)
|
|
118
|
+
&& (!needle || `${repo.fullName} ${repo.description ?? ''}`.toLowerCase().includes(needle)));
|
|
119
|
+
return { repos, hasMore: page.length === REPO_PAGE };
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
async getRepo(credentials, locator) {
|
|
123
|
+
const response = await giteaRequest<GiteaRepoWire>(credentials, `/repos/${locator}`);
|
|
124
|
+
return toRepo(response.data);
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
async createRepo(credentials, input: CreateRepoInput) {
|
|
128
|
+
const path = input.owner.kind === 'org' ? `/orgs/${encodeURIComponent(input.owner.login)}/repos` : '/user/repos';
|
|
129
|
+
const response = await giteaRequest<GiteaRepoWire>(credentials, path, {
|
|
130
|
+
method: 'POST',
|
|
131
|
+
body: {
|
|
132
|
+
name: input.name,
|
|
133
|
+
description: input.description,
|
|
134
|
+
private: input.isPrivate,
|
|
135
|
+
auto_init: false
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return toRepo(response.data);
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
async fork(credentials, locator) {
|
|
142
|
+
const response = await giteaRequest<GiteaRepoWire>(credentials, `/repos/${locator}/forks`, {
|
|
143
|
+
method: 'POST',
|
|
144
|
+
body: {}
|
|
145
|
+
});
|
|
146
|
+
return toRepo(response.data);
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
async commitStatuses(credentials, locator, shas): Promise<CommitCiStatus[]> {
|
|
150
|
+
return mapLimited(shas, 4, async (sha): Promise<CommitCiStatus> => {
|
|
151
|
+
try {
|
|
152
|
+
const response = await giteaRequest<{ state: string; total_count: number }>(
|
|
153
|
+
credentials,
|
|
154
|
+
`/repos/${locator}/commits/${encodeURIComponent(sha)}/status`
|
|
155
|
+
);
|
|
156
|
+
const raw = response.data;
|
|
157
|
+
if (!raw.total_count) return { sha, state: 'none', url: null, summary: 'No checks' };
|
|
158
|
+
const state: CommitCiState = raw.state === 'success' ? 'success'
|
|
159
|
+
: raw.state === 'pending' ? 'pending'
|
|
160
|
+
: raw.state === 'failure' || raw.state === 'error' ? 'failure'
|
|
161
|
+
: 'none';
|
|
162
|
+
return {
|
|
163
|
+
sha,
|
|
164
|
+
state,
|
|
165
|
+
url: `${webBase(credentials)}/${locator}/commit/${sha}`,
|
|
166
|
+
summary: `${raw.total_count} check${raw.total_count === 1 ? '' : 's'}: ${raw.state}`
|
|
167
|
+
};
|
|
168
|
+
} catch {
|
|
169
|
+
return { sha, state: 'none', url: null, summary: 'No checks' };
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
links(credentials, locator) {
|
|
175
|
+
const repo = `${webBase(credentials)}/${locator}`;
|
|
176
|
+
return {
|
|
177
|
+
repo,
|
|
178
|
+
commit: `${repo}/commit/{sha}`,
|
|
179
|
+
branch: `${repo}/src/branch/{branch}`,
|
|
180
|
+
file: `${repo}/src/branch/{ref}/{path}`,
|
|
181
|
+
fileLine: '#L{line}',
|
|
182
|
+
compare: `${repo}/compare/{base}...{head}`,
|
|
183
|
+
newPullRequest: `${repo}/compare/{base}...{head}`
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
templates: {
|
|
188
|
+
async gitignoreList(credentials) {
|
|
189
|
+
const response = await giteaRequest<string[]>(credentials, '/gitignore/templates');
|
|
190
|
+
return (response.data ?? []).map((name) => ({ key: name, name }));
|
|
191
|
+
},
|
|
192
|
+
async gitignore(credentials, key) {
|
|
193
|
+
const response = await giteaRequest<{ source: string }>(credentials, `/gitignore/templates/${encodeURIComponent(key)}`);
|
|
194
|
+
return response.data.source;
|
|
195
|
+
},
|
|
196
|
+
async licenseList(credentials) {
|
|
197
|
+
const response = await giteaRequest<{ key: string; name: string }[]>(credentials, '/licenses');
|
|
198
|
+
return (response.data ?? []).map((entry) => ({ key: entry.key, name: entry.name }));
|
|
199
|
+
},
|
|
200
|
+
async license(credentials, key, holder) {
|
|
201
|
+
const response = await giteaRequest<{ body: string }>(credentials, `/licenses/${encodeURIComponent(key)}`);
|
|
202
|
+
// Gitea ships the SPDX texts, whose placeholders vary by license.
|
|
203
|
+
return response.data.body
|
|
204
|
+
.replace(/<year>|\[year\]|\[yyyy\]|<yyyy>/gi, holder.year)
|
|
205
|
+
.replace(/<name of author>|<copyright holders?>|\[fullname\]|\[name of copyright owner\]/gi, holder.fullname);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|