@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,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credentials already on this machine: the `gh`, `glab` and `tea` CLIs, and
|
|
3
|
+
* git's own credential store (the system keychain, Git Credential Manager).
|
|
4
|
+
*
|
|
5
|
+
* ── Never silently ──
|
|
6
|
+
* Detection only REPORTS what it found. Nothing here creates an account; the
|
|
7
|
+
* connect dialog shows "Found gh signed in as @you — use it?" and the user
|
|
8
|
+
* decides. A tool that quietly picked up whatever token lay around would
|
|
9
|
+
* authenticate as an account nobody chose.
|
|
10
|
+
*
|
|
11
|
+
* ── Linked, not copied ──
|
|
12
|
+
* A CLI login can be re-asked on every use (`gh auth token`), so an account
|
|
13
|
+
* connected that way stores which CLI and host it came from and re-reads the
|
|
14
|
+
* token rather than keeping its own copy. Logging out or rotating in the CLI is
|
|
15
|
+
* then followed here, which is what a user who "uses their gh login" expects.
|
|
16
|
+
* The keychain is the exception — reading it can raise an OS prompt, so it is
|
|
17
|
+
* read once, on an explicit click, and copied.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
21
|
+
import { homedir } from 'node:os';
|
|
22
|
+
import { join } from 'node:path';
|
|
23
|
+
import type { DetectedCredential, GitHostKind } from '$shared/types/git-hosting';
|
|
24
|
+
import { debug } from '$shared/utils/logger';
|
|
25
|
+
|
|
26
|
+
export type CliTool = 'gh' | 'glab' | 'tea';
|
|
27
|
+
|
|
28
|
+
const CLI_FOR: Partial<Record<GitHostKind, CliTool>> = {
|
|
29
|
+
github: 'gh',
|
|
30
|
+
gitlab: 'glab',
|
|
31
|
+
gitea: 'tea'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function cliForProvider(provider: GitHostKind): CliTool | null {
|
|
35
|
+
return CLI_FOR[provider] ?? null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const CLI_TIMEOUT_MS = 8_000;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The environment a child CLI runs with.
|
|
42
|
+
*
|
|
43
|
+
* Clopen's own git identity variables are stripped: they are meant for git
|
|
44
|
+
* commands Clopen runs on a project, and `git credential fill` inheriting them
|
|
45
|
+
* would ask CLOPEN's helper — reporting our own stored token back as if the
|
|
46
|
+
* machine had it.
|
|
47
|
+
*/
|
|
48
|
+
function childEnv(): Record<string, string> {
|
|
49
|
+
const env: Record<string, string> = {};
|
|
50
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
51
|
+
if (value === undefined) continue;
|
|
52
|
+
if (key === 'GIT_CONFIG_COUNT' || key.startsWith('GIT_CONFIG_KEY_') || key.startsWith('GIT_CONFIG_VALUE_')) continue;
|
|
53
|
+
if (key === 'GIT_CONFIG_GLOBAL' || key === 'GIT_ASKPASS' || key === 'SSH_ASKPASS') continue;
|
|
54
|
+
env[key] = value;
|
|
55
|
+
}
|
|
56
|
+
env.GH_PROMPT_DISABLED = '1';
|
|
57
|
+
env.NO_COLOR = '1';
|
|
58
|
+
env.GIT_TERMINAL_PROMPT = '0';
|
|
59
|
+
env.GCM_INTERACTIVE = 'never';
|
|
60
|
+
return env;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function run(command: string, args: string[], input?: string): Promise<{ code: number; stdout: string } | null> {
|
|
64
|
+
const binary = Bun.which(command);
|
|
65
|
+
if (!binary) return null;
|
|
66
|
+
try {
|
|
67
|
+
const proc = Bun.spawn([binary, ...args], {
|
|
68
|
+
stdin: input !== undefined ? new TextEncoder().encode(input) : 'ignore',
|
|
69
|
+
stdout: 'pipe',
|
|
70
|
+
stderr: 'pipe',
|
|
71
|
+
env: childEnv()
|
|
72
|
+
});
|
|
73
|
+
const timer = setTimeout(() => proc.kill(), CLI_TIMEOUT_MS);
|
|
74
|
+
const [stdout, code] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
return { code, stdout };
|
|
77
|
+
} catch (error) {
|
|
78
|
+
debug.warn('git-hosts', `Could not run ${command}:`, error);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function configHome(): string {
|
|
84
|
+
return process.env.XDG_CONFIG_HOME?.trim() || join(homedir(), '.config');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function readText(path: string): string | null {
|
|
88
|
+
try {
|
|
89
|
+
return existsSync(path) ? readFileSync(path, 'utf8') : null;
|
|
90
|
+
} catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Config parsing. These files are YAML, but only a tiny, regular subset of it;
|
|
97
|
+
// a YAML dependency for three top-level shapes is not worth its tree.
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* `gh`'s hosts.yml: one top-level key per host, with `user:` beneath it.
|
|
102
|
+
*
|
|
103
|
+
* github.com:
|
|
104
|
+
* user: octocat
|
|
105
|
+
* git_protocol: https
|
|
106
|
+
*/
|
|
107
|
+
export function parseGhHosts(text: string): { host: string; login: string | null }[] {
|
|
108
|
+
const hosts: { host: string; login: string | null }[] = [];
|
|
109
|
+
let current: { host: string; login: string | null } | null = null;
|
|
110
|
+
for (const raw of text.split('\n')) {
|
|
111
|
+
const line = raw.replace(/\r$/, '');
|
|
112
|
+
if (!line.trim() || line.trim().startsWith('#')) continue;
|
|
113
|
+
const top = /^([^\s#][^:]*):\s*$/.exec(line);
|
|
114
|
+
if (top) {
|
|
115
|
+
current = { host: top[1]!.trim().replace(/^["']|["']$/g, '').toLowerCase(), login: null };
|
|
116
|
+
hosts.push(current);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const user = /^\s+user:\s*(\S+)\s*$/.exec(line);
|
|
120
|
+
if (user && current && !current.login) current.login = user[1]!.replace(/^["']|["']$/g, '');
|
|
121
|
+
}
|
|
122
|
+
return hosts;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* `glab`'s config.yml: hosts nested under `hosts:`.
|
|
127
|
+
*
|
|
128
|
+
* hosts:
|
|
129
|
+
* gitlab.com:
|
|
130
|
+
* token: glpat-…
|
|
131
|
+
* user: octocat
|
|
132
|
+
*/
|
|
133
|
+
export function parseGlabHosts(text: string): { host: string; login: string | null; hasToken: boolean }[] {
|
|
134
|
+
const hosts: { host: string; login: string | null; hasToken: boolean }[] = [];
|
|
135
|
+
let inHosts = false;
|
|
136
|
+
let hostIndent = -1;
|
|
137
|
+
let current: { host: string; login: string | null; hasToken: boolean } | null = null;
|
|
138
|
+
for (const raw of text.split('\n')) {
|
|
139
|
+
const line = raw.replace(/\r$/, '');
|
|
140
|
+
if (!line.trim() || line.trim().startsWith('#')) continue;
|
|
141
|
+
const indent = line.length - line.trimStart().length;
|
|
142
|
+
if (indent === 0) {
|
|
143
|
+
inHosts = /^hosts:\s*$/.test(line);
|
|
144
|
+
current = null;
|
|
145
|
+
hostIndent = -1;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (!inHosts) continue;
|
|
149
|
+
const key = /^\s*([^:\s]+):\s*(.*)$/.exec(line);
|
|
150
|
+
if (!key) continue;
|
|
151
|
+
if (hostIndent === -1 || indent === hostIndent) {
|
|
152
|
+
if (key[2]!.trim() === '') {
|
|
153
|
+
hostIndent = indent;
|
|
154
|
+
current = { host: key[1]!.replace(/^["']|["']$/g, '').toLowerCase(), login: null, hasToken: false };
|
|
155
|
+
hosts.push(current);
|
|
156
|
+
}
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (!current) continue;
|
|
160
|
+
const value = key[2]!.trim().replace(/^["']|["']$/g, '');
|
|
161
|
+
if (key[1] === 'user' && value) current.login = value;
|
|
162
|
+
if (key[1] === 'token' && value) current.hasToken = true;
|
|
163
|
+
}
|
|
164
|
+
return hosts;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* `tea`'s config.yml: a `logins:` list.
|
|
169
|
+
*
|
|
170
|
+
* logins:
|
|
171
|
+
* - name: work
|
|
172
|
+
* url: https://git.example.com
|
|
173
|
+
* token: …
|
|
174
|
+
* user: octocat
|
|
175
|
+
*/
|
|
176
|
+
export function parseTeaLogins(text: string): { url: string; host: string; login: string | null; token: string | null }[] {
|
|
177
|
+
const logins: { url: string; host: string; login: string | null; token: string | null }[] = [];
|
|
178
|
+
let inLogins = false;
|
|
179
|
+
let current: Record<string, string> | null = null;
|
|
180
|
+
const flush = () => {
|
|
181
|
+
if (!current?.url) return;
|
|
182
|
+
let host = '';
|
|
183
|
+
try {
|
|
184
|
+
host = new URL(current.url).hostname.toLowerCase();
|
|
185
|
+
} catch {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
logins.push({ url: current.url.replace(/\/+$/, ''), host, login: current.user || null, token: current.token || null });
|
|
189
|
+
};
|
|
190
|
+
for (const raw of text.split('\n')) {
|
|
191
|
+
const line = raw.replace(/\r$/, '');
|
|
192
|
+
if (!line.trim() || line.trim().startsWith('#')) continue;
|
|
193
|
+
const indent = line.length - line.trimStart().length;
|
|
194
|
+
if (indent === 0 && !line.startsWith('-')) {
|
|
195
|
+
if (inLogins) flush();
|
|
196
|
+
inLogins = /^logins:\s*$/.test(line);
|
|
197
|
+
current = null;
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
if (!inLogins) continue;
|
|
201
|
+
const item = /^\s*-\s*(.*)$/.exec(line);
|
|
202
|
+
let body = line.trim();
|
|
203
|
+
if (item) {
|
|
204
|
+
flush();
|
|
205
|
+
current = {};
|
|
206
|
+
body = item[1]!.trim();
|
|
207
|
+
if (!body) continue;
|
|
208
|
+
}
|
|
209
|
+
const pair = /^([\w-]+):\s*(.*)$/.exec(body);
|
|
210
|
+
if (pair && current) current[pair[1]!] = pair[2]!.trim().replace(/^["']|["']$/g, '');
|
|
211
|
+
}
|
|
212
|
+
if (inLogins) flush();
|
|
213
|
+
return logins;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function ghConfigDir(): string {
|
|
217
|
+
if (process.env.GH_CONFIG_DIR?.trim()) return process.env.GH_CONFIG_DIR.trim();
|
|
218
|
+
if (process.platform === 'win32' && process.env.APPDATA) return join(process.env.APPDATA, 'GitHub CLI');
|
|
219
|
+
return join(configHome(), 'gh');
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function glabConfigPath(): string {
|
|
223
|
+
if (process.env.GLAB_CONFIG_DIR?.trim()) return join(process.env.GLAB_CONFIG_DIR.trim(), 'config.yml');
|
|
224
|
+
return join(configHome(), 'glab-cli', 'config.yml');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function teaConfigPath(): string {
|
|
228
|
+
return join(configHome(), 'tea', 'config.yml');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// ---------------------------------------------------------------------------
|
|
232
|
+
// Reading a token
|
|
233
|
+
// ---------------------------------------------------------------------------
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* The token a CLI holds for `host`, asked fresh.
|
|
237
|
+
*
|
|
238
|
+
* `gh auth token` and `glab config get token` both resolve the system keyring
|
|
239
|
+
* when the CLI stores the token there, which reading the config file would
|
|
240
|
+
* miss. `tea` has no such command and keeps the token in its file.
|
|
241
|
+
*/
|
|
242
|
+
export async function readCliToken(tool: CliTool, host: string): Promise<string | null> {
|
|
243
|
+
if (tool === 'gh') {
|
|
244
|
+
const result = await run('gh', ['auth', 'token', '--hostname', host]);
|
|
245
|
+
const token = result?.code === 0 ? result.stdout.trim() : '';
|
|
246
|
+
return token || null;
|
|
247
|
+
}
|
|
248
|
+
if (tool === 'glab') {
|
|
249
|
+
const result = await run('glab', ['config', 'get', 'token', '--host', host]);
|
|
250
|
+
const token = result?.code === 0 ? result.stdout.trim() : '';
|
|
251
|
+
return token || null;
|
|
252
|
+
}
|
|
253
|
+
const text = readText(teaConfigPath());
|
|
254
|
+
if (!text) return null;
|
|
255
|
+
return parseTeaLogins(text).find((login) => login.host === host)?.token ?? null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** What a CLI reports for one host, without the token. */
|
|
259
|
+
async function describeCli(tool: CliTool, host: string): Promise<DetectedCredential | null> {
|
|
260
|
+
if (tool === 'gh') {
|
|
261
|
+
if (!Bun.which('gh')) return null;
|
|
262
|
+
const text = readText(join(ghConfigDir(), 'hosts.yml'));
|
|
263
|
+
const entry = text ? parseGhHosts(text).find((candidate) => candidate.host === host) : undefined;
|
|
264
|
+
const token = await readCliToken('gh', host);
|
|
265
|
+
if (!entry && !token) return null;
|
|
266
|
+
return { source: 'gh', host, login: entry?.login ?? null, hasToken: !!token, canLink: true };
|
|
267
|
+
}
|
|
268
|
+
if (tool === 'glab') {
|
|
269
|
+
if (!Bun.which('glab')) return null;
|
|
270
|
+
const text = readText(glabConfigPath());
|
|
271
|
+
const entry = text ? parseGlabHosts(text).find((candidate) => candidate.host === host) : undefined;
|
|
272
|
+
const token = await readCliToken('glab', host);
|
|
273
|
+
if (!entry && !token) return null;
|
|
274
|
+
return { source: 'glab', host, login: entry?.login ?? null, hasToken: !!token, canLink: true };
|
|
275
|
+
}
|
|
276
|
+
const text = readText(teaConfigPath());
|
|
277
|
+
const entry = text ? parseTeaLogins(text).find((login) => login.host === host) : undefined;
|
|
278
|
+
if (!entry) return null;
|
|
279
|
+
return { source: 'tea', host, login: entry.login, hasToken: !!entry.token, canLink: true };
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Every host a provider's CLI is signed in to — for the dialog that opens
|
|
284
|
+
* before a server URL is known, so "gh is signed in to ghe.acme.com" can be
|
|
285
|
+
* offered without the user typing it.
|
|
286
|
+
*/
|
|
287
|
+
export async function detectCliLogins(provider: GitHostKind, host: string | null): Promise<DetectedCredential[]> {
|
|
288
|
+
const tool = cliForProvider(provider);
|
|
289
|
+
if (!tool) return [];
|
|
290
|
+
|
|
291
|
+
if (host) {
|
|
292
|
+
const one = await describeCli(tool, host);
|
|
293
|
+
return one ? [one] : [];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let hosts: string[] = [];
|
|
297
|
+
if (tool === 'gh') {
|
|
298
|
+
const text = readText(join(ghConfigDir(), 'hosts.yml'));
|
|
299
|
+
hosts = text ? parseGhHosts(text).map((entry) => entry.host) : [];
|
|
300
|
+
} else if (tool === 'glab') {
|
|
301
|
+
const text = readText(glabConfigPath());
|
|
302
|
+
hosts = text ? parseGlabHosts(text).map((entry) => entry.host) : [];
|
|
303
|
+
} else {
|
|
304
|
+
const text = readText(teaConfigPath());
|
|
305
|
+
hosts = text ? parseTeaLogins(text).map((entry) => entry.host) : [];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const found = await Promise.all([...new Set(hosts)].map((candidate) => describeCli(tool, candidate)));
|
|
309
|
+
return found.filter((entry): entry is DetectedCredential => entry !== null);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** The URL `tea` has for a host, which carries any sub-path the server lives under. */
|
|
313
|
+
export function teaServerUrl(host: string): string | null {
|
|
314
|
+
const text = readText(teaConfigPath());
|
|
315
|
+
if (!text) return null;
|
|
316
|
+
return parseTeaLogins(text).find((login) => login.host === host)?.url ?? null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ---------------------------------------------------------------------------
|
|
320
|
+
// git's credential store
|
|
321
|
+
// ---------------------------------------------------------------------------
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Ask git's configured credential helpers for `host`.
|
|
325
|
+
*
|
|
326
|
+
* This is what `git push` itself would use — osxkeychain, libsecret, Git
|
|
327
|
+
* Credential Manager. Prompts are disabled so a helper with nothing stored
|
|
328
|
+
* answers "nothing" instead of opening a dialog; a keychain that wants the
|
|
329
|
+
* user to approve access may still ask the OS, which is why this only runs on
|
|
330
|
+
* an explicit click.
|
|
331
|
+
*/
|
|
332
|
+
export async function readKeychain(host: string): Promise<{ username: string; password: string } | null> {
|
|
333
|
+
const result = await run('git', ['credential', 'fill'], `protocol=https\nhost=${host}\n\n`);
|
|
334
|
+
if (!result || result.code !== 0) return null;
|
|
335
|
+
const fields: Record<string, string> = {};
|
|
336
|
+
for (const line of result.stdout.split('\n')) {
|
|
337
|
+
const eq = line.indexOf('=');
|
|
338
|
+
if (eq > 0) fields[line.slice(0, eq)] = line.slice(eq + 1).trim();
|
|
339
|
+
}
|
|
340
|
+
if (!fields.password) return null;
|
|
341
|
+
return { username: fields.username ?? '', password: fields.password };
|
|
342
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An account's credential, as it should be USED right now.
|
|
3
|
+
*
|
|
4
|
+
* Stored credentials are a snapshot. Two kinds of account need more than the
|
|
5
|
+
* snapshot to work:
|
|
6
|
+
*
|
|
7
|
+
* - LINKED to a CLI (`authSource=cli`). The token is re-read from `gh`/`glab`/
|
|
8
|
+
* `tea` on use, so logging out or rotating there is followed here. The
|
|
9
|
+
* snapshot is still kept current, because surfaces that read credentials
|
|
10
|
+
* synchronously (the agent-tools MCP row, the work view's probe) need
|
|
11
|
+
* something to read.
|
|
12
|
+
* - OAUTH with an expiry (`authSource=oauth`). GitLab's tokens last two
|
|
13
|
+
* hours. A token close to expiry is refreshed with the stored refresh
|
|
14
|
+
* token before it is handed out, and the new pair replaces the old.
|
|
15
|
+
*
|
|
16
|
+
* Every hosting call and every work call goes through `credentialsForUse`, and
|
|
17
|
+
* so does the git credential helper, so a push and a page load can never
|
|
18
|
+
* disagree about which token is current.
|
|
19
|
+
*
|
|
20
|
+
* Credential keys this module owns, alongside the provider's own fields:
|
|
21
|
+
* authSource 'token' | 'oauth' | 'cli' | 'keychain'
|
|
22
|
+
* cliTool 'gh' | 'glab' | 'tea' (linked accounts)
|
|
23
|
+
* cliHost the host the CLI was asked about
|
|
24
|
+
* refreshToken OAuth refresh token
|
|
25
|
+
* expiresAt ISO time the access token stops working
|
|
26
|
+
* clientId the OAuth client the token was issued to (needed to refresh)
|
|
27
|
+
* login who the token belongs to, recorded at connect time
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { integrationAccountQueries, type IntegrationAccountRow } from '$backend/database/queries';
|
|
31
|
+
import type { GitHostKind } from '$shared/types/git-hosting';
|
|
32
|
+
import { debug } from '$shared/utils/logger';
|
|
33
|
+
import { readCliToken, type CliTool } from './cli';
|
|
34
|
+
import { refreshEndpoint, requestToken } from './auth/endpoints';
|
|
35
|
+
import { HostApiError } from './http';
|
|
36
|
+
import { isGitHostKind } from './registry';
|
|
37
|
+
|
|
38
|
+
export type AuthSource = 'token' | 'oauth' | 'cli' | 'keychain';
|
|
39
|
+
|
|
40
|
+
interface UseOptions {
|
|
41
|
+
/**
|
|
42
|
+
* False inside the git credential helper: it runs in a process git spawned
|
|
43
|
+
* for one push, and loading the projection layer there would start MCP
|
|
44
|
+
* machinery nobody is waiting for. The server re-projects on its own next
|
|
45
|
+
* use, which reads the token this persisted.
|
|
46
|
+
*/
|
|
47
|
+
reproject?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Refresh this long before the stated expiry, so a slow request does not straddle it. */
|
|
51
|
+
const REFRESH_MARGIN_MS = 2 * 60 * 1000;
|
|
52
|
+
|
|
53
|
+
/** How long a token read from a CLI is trusted before the CLI is asked again. */
|
|
54
|
+
const CLI_CACHE_MS = 60 * 1000;
|
|
55
|
+
|
|
56
|
+
const cliCache = new Map<string, { token: string; at: number }>();
|
|
57
|
+
|
|
58
|
+
/** One in-flight refresh per account — two pushes racing must not burn one refresh token twice. */
|
|
59
|
+
const refreshing = new Map<string, Promise<Record<string, string>>>();
|
|
60
|
+
|
|
61
|
+
export function authSourceOf(credentials: Record<string, string>): AuthSource {
|
|
62
|
+
const source = credentials.authSource;
|
|
63
|
+
return source === 'oauth' || source === 'cli' || source === 'keychain' ? source : 'token';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Persist a changed credential and tell whatever projects it.
|
|
68
|
+
*
|
|
69
|
+
* Imported lazily: the git credential helper runs this module in a short-lived
|
|
70
|
+
* process that must not pull in the projection layer and its MCP machinery.
|
|
71
|
+
*/
|
|
72
|
+
async function persist(account: IntegrationAccountRow, next: Record<string, string>, options: UseOptions): Promise<void> {
|
|
73
|
+
integrationAccountQueries.setCredentials(account.id, next);
|
|
74
|
+
if (options.reproject === false) return;
|
|
75
|
+
try {
|
|
76
|
+
const { reproject } = await import('$backend/integrations/projections');
|
|
77
|
+
reproject(account.id);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
debug.warn('git-hosts', 'Could not re-project a refreshed credential:', error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function fromCli(account: IntegrationAccountRow, current: Record<string, string>, options: UseOptions): Promise<Record<string, string>> {
|
|
84
|
+
const tool = current.cliTool as CliTool | undefined;
|
|
85
|
+
const host = current.cliHost;
|
|
86
|
+
if (!tool || !host) return current;
|
|
87
|
+
|
|
88
|
+
const key = `${account.id}:${tool}:${host}`;
|
|
89
|
+
const cached = cliCache.get(key);
|
|
90
|
+
let token = cached && Date.now() - cached.at < CLI_CACHE_MS ? cached.token : null;
|
|
91
|
+
if (!token) {
|
|
92
|
+
token = await readCliToken(tool, host);
|
|
93
|
+
if (!token) {
|
|
94
|
+
cliCache.delete(key);
|
|
95
|
+
throw new HostApiError(
|
|
96
|
+
`${tool} is not signed in to ${host} any more. Run "${tool} auth login" there, or reconnect this account with a different method.`,
|
|
97
|
+
401,
|
|
98
|
+
'auth'
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
cliCache.set(key, { token, at: Date.now() });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (token === current.token) return current;
|
|
105
|
+
const next = { ...current, token };
|
|
106
|
+
await persist(account, next, options);
|
|
107
|
+
debug.log('git-hosts', `Followed a rotated ${tool} token for "${account.label}"`);
|
|
108
|
+
return next;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function refreshOAuth(account: IntegrationAccountRow, current: Record<string, string>, options: UseOptions): Promise<Record<string, string>> {
|
|
112
|
+
if (!current.refreshToken || !current.expiresAt) return current;
|
|
113
|
+
if (new Date(current.expiresAt).getTime() - Date.now() > REFRESH_MARGIN_MS) return current;
|
|
114
|
+
if (!isGitHostKind(account.provider)) return current;
|
|
115
|
+
|
|
116
|
+
const endpoint = refreshEndpoint(account.provider as GitHostKind, current.baseUrl);
|
|
117
|
+
if (!endpoint || !current.clientId) return current;
|
|
118
|
+
|
|
119
|
+
const inFlight = refreshing.get(account.id);
|
|
120
|
+
if (inFlight) return inFlight;
|
|
121
|
+
|
|
122
|
+
const run = (async () => {
|
|
123
|
+
try {
|
|
124
|
+
const tokens = await requestToken(endpoint, {
|
|
125
|
+
grant_type: 'refresh_token',
|
|
126
|
+
refresh_token: current.refreshToken!,
|
|
127
|
+
client_id: current.clientId!
|
|
128
|
+
});
|
|
129
|
+
const next: Record<string, string> = {
|
|
130
|
+
...current,
|
|
131
|
+
token: tokens.accessToken,
|
|
132
|
+
refreshToken: tokens.refreshToken ?? current.refreshToken!,
|
|
133
|
+
expiresAt: tokens.expiresAt ?? ''
|
|
134
|
+
};
|
|
135
|
+
await persist(account, next, options);
|
|
136
|
+
debug.log('git-hosts', `Refreshed the OAuth token for "${account.label}"`);
|
|
137
|
+
return next;
|
|
138
|
+
} catch (error) {
|
|
139
|
+
throw new HostApiError(
|
|
140
|
+
`The ${account.label} sign-in expired and could not be renewed (${error instanceof Error ? error.message : String(error)}). Sign in again.`,
|
|
141
|
+
401,
|
|
142
|
+
'auth'
|
|
143
|
+
);
|
|
144
|
+
} finally {
|
|
145
|
+
refreshing.delete(account.id);
|
|
146
|
+
}
|
|
147
|
+
})();
|
|
148
|
+
refreshing.set(account.id, run);
|
|
149
|
+
return run;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The credential to use for one call, refreshed or re-read as the account requires. */
|
|
153
|
+
export async function credentialsForUse(
|
|
154
|
+
account: IntegrationAccountRow,
|
|
155
|
+
options: UseOptions = {}
|
|
156
|
+
): Promise<Record<string, string>> {
|
|
157
|
+
const current = integrationAccountQueries.credentialsOf(account);
|
|
158
|
+
switch (authSourceOf(current)) {
|
|
159
|
+
case 'cli':
|
|
160
|
+
return fromCli(account, current, options);
|
|
161
|
+
case 'oauth':
|
|
162
|
+
return refreshOAuth(account, current, options);
|
|
163
|
+
default:
|
|
164
|
+
return current;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Drop any cached CLI token for an account, so the next use asks the CLI again. */
|
|
169
|
+
export function forgetCachedCliToken(accountId: string): void {
|
|
170
|
+
for (const key of cliCache.keys()) {
|
|
171
|
+
if (key.startsWith(`${accountId}:`)) cliCache.delete(key);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hosting accounts' half of the git credential helper.
|
|
3
|
+
*
|
|
4
|
+
* Runs inside the short-lived helper process git spawns (see
|
|
5
|
+
* `backend/git/identity/cli.ts`). Picks the account the way the Git panel
|
|
6
|
+
* does — host, then repository owner — and hands back the token as it should
|
|
7
|
+
* be used now: re-read from a linked CLI, or refreshed when an OAuth token is
|
|
8
|
+
* about to expire.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { accountForRemote } from './accounts';
|
|
12
|
+
import { credentialsForUse } from './credentials';
|
|
13
|
+
|
|
14
|
+
export async function answerHostedCredential(
|
|
15
|
+
host: string,
|
|
16
|
+
path: string,
|
|
17
|
+
projectId: string | null
|
|
18
|
+
): Promise<{ username: string; password: string } | null> {
|
|
19
|
+
const url = `https://${host}/${path.replace(/^\/+/, '')}`;
|
|
20
|
+
// Without a path (`useHttpPath` off, or an old git) the owner is unknown, so
|
|
21
|
+
// the lookup can only succeed when one account serves the host.
|
|
22
|
+
const match = accountForRemote(url, projectId, { strict: true })
|
|
23
|
+
?? (path ? null : accountForRemote(`https://${host}/_/_`, projectId, { strict: true }));
|
|
24
|
+
if (!match) return null;
|
|
25
|
+
|
|
26
|
+
const credentials = await credentialsForUse(match.ref.account, { reproject: false });
|
|
27
|
+
const token = credentials.token;
|
|
28
|
+
if (!token) return null;
|
|
29
|
+
return { username: match.ref.adapter.gitUsername(credentials), password: token };
|
|
30
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health for a hosting account: can it still say who it is.
|
|
3
|
+
*
|
|
4
|
+
* Used for accounts with no work capability (Gitea, Bitbucket, or GitHub with
|
|
5
|
+
* Issues & PRs switched off), whose only job is to push and publish — so the
|
|
6
|
+
* only question worth asking is whether the credential still signs in.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { integrationAccountQueries } from '$backend/database/queries';
|
|
10
|
+
import { HostApiError } from './http';
|
|
11
|
+
import { credentialsForUse } from './credentials';
|
|
12
|
+
import { getHostAdapter } from './registry';
|
|
13
|
+
|
|
14
|
+
export async function probeHostAccount(
|
|
15
|
+
accountId: string
|
|
16
|
+
): Promise<{ status: 'ok' | 'needs_auth' | 'needs_config' | 'error'; detail: string | null } | null> {
|
|
17
|
+
const account = integrationAccountQueries.getById(accountId);
|
|
18
|
+
if (!account) return null;
|
|
19
|
+
const adapter = getHostAdapter(account.provider);
|
|
20
|
+
if (!adapter) return null;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const credentials = await credentialsForUse(account);
|
|
24
|
+
const viewer = await adapter.viewer(credentials);
|
|
25
|
+
if (viewer.missingScopes.length > 0) {
|
|
26
|
+
return {
|
|
27
|
+
status: 'needs_config',
|
|
28
|
+
detail: `Signed in as ${viewer.login}, but the token is missing: ${viewer.missingScopes.join(', ')}. Reconnect to grant them.`
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return { status: 'ok', detail: `Signed in as ${viewer.login}` };
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error instanceof HostApiError) {
|
|
34
|
+
const status = error.kind === 'auth' ? 'needs_auth' : error.kind === 'config' ? 'needs_config' : 'error';
|
|
35
|
+
return { status, detail: error.message };
|
|
36
|
+
}
|
|
37
|
+
return { status: 'error', detail: error instanceof Error ? error.message : String(error) };
|
|
38
|
+
}
|
|
39
|
+
}
|