@myrialabs/clopen 0.4.49 → 0.4.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/backend/chat/attachments.test.ts +106 -17
- package/backend/chat/attachments.ts +131 -34
- package/backend/chat/background-wait.test.ts +28 -0
- package/backend/chat/engine-handoff.ts +42 -6
- package/backend/chat/message-pages.test.ts +17 -0
- package/backend/chat/message-pages.ts +6 -2
- package/backend/chat/stream-manager.ts +114 -19
- package/backend/containers/actions.ts +22 -0
- package/backend/control/actions/projects.ts +93 -37
- package/backend/control/folders.test.ts +27 -2
- package/backend/control/index.ts +2 -1
- package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
- package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
- package/backend/database/migrations/086_single_owner.ts +66 -73
- package/backend/database/migrations/088_create_messages_fts_map.ts +52 -0
- package/backend/database/migrations/089_add_memory_layout_tiles.ts +58 -0
- package/backend/database/migrations/090_create_storage_tables.ts +83 -0
- package/backend/database/migrations/index.ts +25 -2
- package/backend/database/queries/graph-queries.ts +392 -135
- package/backend/database/queries/integration-queries.ts +10 -0
- package/backend/database/queries/memory-queue-queries.ts +11 -0
- package/backend/database/queries/message-fts.test.ts +120 -0
- package/backend/database/queries/message-queries.ts +45 -9
- package/backend/database/queries/project-queries.ts +6 -0
- package/backend/database/queries/session-queries.ts +6 -2
- package/backend/database/queries/utils-queries.ts +3 -0
- package/backend/database/utils/migration-runner.test.ts +196 -0
- package/backend/database/utils/migration-runner.ts +61 -16
- package/backend/database/utils/seeder-runner.ts +22 -16
- package/backend/engine/adapters/claude/environment.ts +4 -0
- package/backend/engine/adapters/claude/input-gate.test.ts +59 -0
- package/backend/engine/adapters/claude/input-gate.ts +74 -0
- package/backend/engine/adapters/claude/message-converter.test.ts +16 -0
- package/backend/engine/adapters/claude/message-converter.ts +8 -0
- package/backend/engine/adapters/claude/stream.ts +20 -0
- package/backend/engine/adapters/cursor/environment.ts +1 -1
- package/backend/engine/adapters/qwen/session-store.ts +10 -1
- package/backend/engine/types.ts +7 -0
- package/backend/git/identity/cli.ts +35 -0
- package/backend/git/identity/env.test.ts +52 -1
- package/backend/git/identity/env.ts +69 -10
- package/backend/git/identity/index.ts +25 -6
- package/backend/git/identity/resolve.ts +2 -1
- package/backend/git/identity/scope-config.test.ts +7 -4
- package/backend/git/identity/scope-config.ts +13 -7
- package/backend/git-hosts/accounts.ts +106 -0
- package/backend/git-hosts/auth/client-ids.ts +34 -0
- package/backend/git-hosts/auth/connect.ts +110 -0
- package/backend/git-hosts/auth/endpoints.ts +130 -0
- package/backend/git-hosts/auth/flows.ts +355 -0
- package/backend/git-hosts/auth/local.ts +152 -0
- package/backend/git-hosts/ci.ts +18 -0
- package/backend/git-hosts/cli.test.ts +82 -0
- package/backend/git-hosts/cli.ts +342 -0
- package/backend/git-hosts/credentials.ts +173 -0
- package/backend/git-hosts/git-credential.ts +30 -0
- package/backend/git-hosts/health.ts +39 -0
- package/backend/git-hosts/http.ts +174 -0
- package/backend/git-hosts/index.ts +34 -0
- package/backend/git-hosts/providers/bitbucket.ts +186 -0
- package/backend/git-hosts/providers/gitea.ts +208 -0
- package/backend/git-hosts/providers/github.ts +270 -0
- package/backend/git-hosts/providers/gitlab-client.ts +70 -0
- package/backend/git-hosts/providers/gitlab.ts +285 -0
- package/backend/git-hosts/providers/locators.test.ts +68 -0
- package/backend/git-hosts/registry.ts +50 -0
- package/backend/git-hosts/service.ts +432 -0
- package/backend/git-hosts/types.ts +82 -0
- package/backend/git-hosts/urls.test.ts +42 -0
- package/backend/git-hosts/urls.ts +69 -0
- package/backend/index.ts +84 -17
- package/backend/integrations/accounts.ts +50 -3
- package/backend/integrations/registry/define.ts +9 -0
- package/backend/integrations/registry/index.ts +11 -0
- package/backend/integrations/registry/providers/bitbucket.ts +51 -0
- package/backend/integrations/registry/providers/gitea.ts +53 -0
- package/backend/integrations/registry/providers/github.ts +24 -7
- package/backend/integrations/registry/providers/gitlab.ts +57 -0
- package/backend/integrations/registry/types.ts +13 -1
- package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
- package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
- package/backend/memory/README.md +7 -4
- package/backend/memory/layout.test.ts +377 -0
- package/backend/memory/layout.ts +1029 -265
- package/backend/memory/view.ts +257 -386
- package/backend/mentions/diff.ts +63 -0
- package/backend/mentions/index.ts +109 -0
- package/backend/mentions/mentions.test.ts +27 -0
- package/backend/mentions/shared.ts +82 -0
- package/backend/mentions/sources/ai-changes.ts +140 -0
- package/backend/mentions/sources/chats.ts +122 -0
- package/backend/mentions/sources/database.ts +211 -0
- package/backend/mentions/sources/files.ts +240 -0
- package/backend/mentions/sources/git.ts +308 -0
- package/backend/mentions/sources/notes-memory.ts +121 -0
- package/backend/mentions/sources/ops.ts +125 -0
- package/backend/mentions/sources/preview.ts +153 -0
- package/backend/mentions/sources/projects.ts +114 -0
- package/backend/mentions/sources/system.ts +135 -0
- package/backend/mentions/sources/terminal.ts +50 -0
- package/backend/mentions/types.ts +75 -0
- package/backend/preview/browser/bot-check-frames.test.ts +49 -0
- package/backend/preview/browser/bot-check-frames.ts +66 -0
- package/backend/preview/browser/browser-dialog-handler.ts +6 -5
- package/backend/preview/browser/browser-host-bridge.ts +4 -2
- package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
- package/backend/preview/browser/browser-pool.ts +26 -17
- package/backend/preview/browser/browser-preview-service.ts +164 -2
- package/backend/preview/browser/browser-screenshot.test.ts +113 -0
- package/backend/preview/browser/browser-screenshot.ts +396 -0
- package/backend/preview/browser/browser-tab-manager.ts +35 -186
- package/backend/preview/browser/browser-video-capture.ts +12 -17
- package/backend/preview/browser/element-describe.ts +125 -0
- package/backend/preview/browser/page-binding.ts +141 -0
- package/backend/preview/browser/screenshot-files.test.ts +117 -0
- package/backend/preview/browser/screenshot-files.ts +134 -0
- package/backend/preview/browser/user-agent.test.ts +25 -0
- package/backend/preview/browser/user-agent.ts +100 -0
- package/backend/project/status-manager.ts +4 -2
- package/backend/projects/engine-transcripts.ts +153 -0
- package/backend/projects/folder-guard.ts +55 -0
- package/backend/projects/move.test.ts +208 -0
- package/backend/projects/move.ts +277 -0
- package/backend/projects/project-cleanup.integration.test.ts +3 -1
- package/backend/projects/project-cleanup.ts +10 -0
- package/backend/storage/actions.ts +260 -0
- package/backend/storage/chats.test.ts +57 -0
- package/backend/storage/chats.ts +170 -0
- package/backend/storage/database.ts +105 -0
- package/backend/storage/engine-homes.ts +145 -0
- package/backend/storage/fs-size.ts +111 -0
- package/backend/storage/history.ts +39 -0
- package/backend/storage/policy.ts +156 -0
- package/backend/storage/preview-profiles.ts +169 -0
- package/backend/storage/purge.ts +158 -0
- package/backend/storage/scanner.ts +339 -0
- package/backend/storage/session-index.ts +208 -0
- package/backend/storage/snapshots.ts +99 -0
- package/backend/storage/storage-flow.test.ts +137 -0
- package/backend/storage/transcripts/aliases.ts +75 -0
- package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
- package/backend/storage/transcripts/claude-dedupe.ts +152 -0
- package/backend/storage/transcripts/claude.ts +155 -0
- package/backend/storage/transcripts/cursor.ts +165 -0
- package/backend/storage/transcripts/file-stores.ts +224 -0
- package/backend/storage/transcripts/index.ts +207 -0
- package/backend/storage/transcripts/opencode.ts +124 -0
- package/backend/storage/transcripts/references.ts +42 -0
- package/backend/storage/transcripts/types.ts +58 -0
- package/backend/storage/worktrees.ts +114 -0
- package/backend/terminal/ptykit.ts +25 -0
- package/backend/update/registry.ts +24 -0
- package/backend/update/release-notes.test.ts +110 -0
- package/backend/update/release-notes.ts +132 -0
- package/backend/update/restart.ts +159 -0
- package/backend/utils/env.test.ts +64 -0
- package/backend/utils/env.ts +23 -55
- package/backend/utils/port-utils.ts +13 -0
- package/backend/work/index.ts +13 -2
- package/backend/work/providers/github/actions-logs.ts +1 -1
- package/backend/work/providers/github/adapter.ts +32 -1
- package/backend/work/providers/github/client.ts +7 -3
- package/backend/work/providers/gitlab/adapter.ts +770 -0
- package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
- package/backend/work/service.ts +60 -36
- package/backend/work/start-work.ts +1 -1
- package/backend/work/types.ts +4 -0
- package/backend/worktrees/index.ts +1 -0
- package/backend/worktrees/service.ts +23 -2
- package/backend/ws/chat/composer.ts +47 -6
- package/backend/ws/chat/stream.ts +19 -10
- package/backend/ws/files/search.ts +1 -1
- package/backend/ws/files/write.ts +27 -0
- package/backend/ws/hosting/index.ts +231 -0
- package/backend/ws/index.ts +12 -2
- package/backend/ws/integrations/crud.ts +31 -5
- package/backend/ws/integrations/hosting-auth.ts +227 -0
- package/backend/ws/integrations/index.ts +2 -0
- package/backend/ws/memory/crud.ts +118 -81
- package/backend/ws/mentions/index.ts +81 -0
- package/backend/ws/messages/crud.ts +3 -1
- package/backend/ws/preview/browser/screenshot.ts +184 -0
- package/backend/ws/preview/index.ts +23 -0
- package/backend/ws/projects/crud.ts +66 -58
- package/backend/ws/sessions/crud.ts +7 -95
- package/backend/ws/snapshot/changes.ts +3 -3
- package/backend/ws/storage/index.ts +102 -0
- package/backend/ws/system/index.ts +7 -0
- package/backend/ws/system/operations.ts +125 -69
- package/backend/ws/work/context.ts +3 -4
- package/backend/ws/work/crud.ts +33 -0
- package/backend/ws/work/schemas.ts +4 -1
- package/bin/clopen.ts +18 -18
- package/dist/assets/{index-DD0-3EWg.js → index-B9rHDvjg.js} +1 -1
- package/dist/assets/index-B9rHDvjg.js.br +0 -0
- package/dist/assets/index-B9rHDvjg.js.gz +0 -0
- package/dist/assets/{index-CrVWZH_D.js → index-DFlwOd7k.js} +1 -1
- package/dist/assets/index-DFlwOd7k.js.br +0 -0
- package/dist/assets/index-DFlwOd7k.js.gz +0 -0
- package/dist/assets/main-Bz_brxxS.css +1 -0
- package/dist/assets/main-Bz_brxxS.css.br +0 -0
- package/dist/assets/main-Bz_brxxS.css.gz +0 -0
- package/dist/assets/main-DRcX9SHx.js +1273 -0
- package/dist/assets/main-DRcX9SHx.js.br +0 -0
- package/dist/assets/main-DRcX9SHx.js.gz +0 -0
- package/dist/assets/pdf-DfwfQPLy.js +57 -0
- package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
- package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
- package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
- package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
- package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
- package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
- package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
- package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
- package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
- package/package.json +8 -9
- package/scripts/start.ts +21 -4
- package/shared/constants/binary-extensions.ts +20 -4
- package/shared/constants/support.test.ts +27 -0
- package/shared/constants/support.ts +79 -0
- package/shared/constants/tool-icons.ts +7 -1
- package/shared/types/database/schema.ts +6 -0
- package/shared/types/git-hosting.ts +241 -0
- package/shared/types/integrations.ts +51 -1
- package/shared/types/memory.ts +96 -73
- package/shared/types/mentions.ts +96 -0
- package/shared/types/release-notes.ts +31 -0
- package/shared/types/storage.ts +175 -0
- package/shared/types/stores/settings.ts +16 -0
- package/shared/types/unified/index.ts +2 -0
- package/shared/types/unified/message.ts +26 -1
- package/shared/types/unified/stream.ts +22 -1
- package/shared/types/unified/tool.ts +4 -0
- package/shared/types/work.ts +6 -0
- package/shared/utils/attachment-mentions.test.ts +39 -0
- package/shared/utils/attachment-mentions.ts +100 -0
- package/shared/utils/context-document.test.ts +53 -0
- package/shared/utils/context-document.ts +226 -0
- package/shared/utils/device-frame.test.ts +73 -0
- package/shared/utils/device-frame.ts +320 -0
- package/shared/utils/fuzzy.ts +79 -0
- package/shared/utils/launcher-fingerprint.test.ts +73 -0
- package/shared/utils/launcher-fingerprint.ts +108 -0
- package/shared/utils/logger.ts +2 -0
- package/shared/utils/page-colors.test.ts +17 -0
- package/shared/utils/page-colors.ts +24 -0
- package/shared/utils/process-supervisor.test.ts +88 -1
- package/shared/utils/process-supervisor.ts +123 -29
- package/shared/utils/process-tree.ts +99 -0
- package/shared/utils/restart-intent.test.ts +57 -0
- package/shared/utils/restart-intent.ts +80 -0
- package/shared/utils/semver.test.ts +33 -0
- package/shared/utils/semver.ts +35 -0
- package/shared/utils/supervised-child.ts +44 -0
- package/shared/utils/supervisor-protocol.ts +20 -0
- package/.env.example +0 -9
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js +0 -1
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
- package/dist/assets/index-CrVWZH_D.js.br +0 -0
- package/dist/assets/index-CrVWZH_D.js.gz +0 -0
- package/dist/assets/index-DD0-3EWg.js.br +0 -0
- package/dist/assets/index-DD0-3EWg.js.gz +0 -0
- package/dist/assets/main-D2_TmcwQ.js +0 -1240
- package/dist/assets/main-D2_TmcwQ.js.br +0 -0
- package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
- package/dist/assets/main-Yucigcmf.css +0 -1
- package/dist/assets/main-Yucigcmf.css.br +0 -0
- package/dist/assets/main-Yucigcmf.css.gz +0 -0
|
@@ -95,6 +95,10 @@ async function _doSetup(): Promise<void> {
|
|
|
95
95
|
|
|
96
96
|
// Bypass permissions for Claude Code
|
|
97
97
|
overrides['CLAUDE_CODE_PERMISSION_MODE'] = 'bypassPermissions';
|
|
98
|
+
// The CLI reports when it is idle, so the adapter can tell "this turn is
|
|
99
|
+
// done but background work will start another" from "nothing left to do"
|
|
100
|
+
// (see adapters/claude/input-gate.ts).
|
|
101
|
+
overrides['CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS'] = '1';
|
|
98
102
|
|
|
99
103
|
// Isolate Claude config to ~/.clopen/claude/user/
|
|
100
104
|
const claudeUserDir = getClaudeUserConfigDir();
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The orders below were recorded from the Claude Agent SDK 0.3.296 with
|
|
3
|
+
* CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS=1.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect } from 'bun:test';
|
|
7
|
+
import { ClaudeInputGate, type InputGateMessage } from './input-gate';
|
|
8
|
+
|
|
9
|
+
const state = (s: string): InputGateMessage => ({ type: 'system', subtype: 'session_state_changed', state: s });
|
|
10
|
+
const tasks = (n: number): InputGateMessage => ({ type: 'system', subtype: 'background_tasks_changed', tasks: Array.from({ length: n }, (_, i) => ({ task_id: `t${i}` })) });
|
|
11
|
+
const notification: InputGateMessage = { type: 'system', subtype: 'task_notification' };
|
|
12
|
+
const assistant: InputGateMessage = { type: 'assistant' };
|
|
13
|
+
const result: InputGateMessage = { type: 'result' };
|
|
14
|
+
|
|
15
|
+
function run(messages: InputGateMessage[]): number[] {
|
|
16
|
+
const closedAt: number[] = [];
|
|
17
|
+
let index = -1;
|
|
18
|
+
const gate = new ClaudeInputGate(() => closedAt.push(index));
|
|
19
|
+
for (index = 0; index < messages.length; index++) gate.observe(messages[index]);
|
|
20
|
+
return closedAt;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe('ClaudeInputGate', () => {
|
|
24
|
+
it('stays open through the first result while a background task runs, and closes after the turn it starts', () => {
|
|
25
|
+
const order = [
|
|
26
|
+
state('running'), assistant, tasks(1), assistant, result,
|
|
27
|
+
state('idle'), // idle WHILE the background task still runs
|
|
28
|
+
notification, tasks(0), state('running'), assistant, result,
|
|
29
|
+
state('idle')
|
|
30
|
+
];
|
|
31
|
+
expect(run(order)).toEqual([order.length - 1]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('closes at the first idle when a background task finished mid-turn', () => {
|
|
35
|
+
const order = [state('running'), assistant, tasks(1), notification, tasks(0), notification, assistant, result, state('idle')];
|
|
36
|
+
expect(run(order)).toEqual([order.length - 1]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('closes at the first idle of a turn without background work', () => {
|
|
40
|
+
const order = [state('running'), assistant, result, state('idle')];
|
|
41
|
+
expect(run(order)).toEqual([3]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('without session-state events, closes on a result with no background task', () => {
|
|
45
|
+
expect(run([assistant, result])).toEqual([1]);
|
|
46
|
+
const order = [assistant, tasks(1), result, notification, tasks(0), assistant, result];
|
|
47
|
+
expect(run(order)).toEqual([order.length - 1]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('closes once', () => {
|
|
51
|
+
let calls = 0;
|
|
52
|
+
const gate = new ClaudeInputGate(() => calls++);
|
|
53
|
+
gate.observe(result);
|
|
54
|
+
gate.shut();
|
|
55
|
+
gate.observe(state('idle'));
|
|
56
|
+
expect(calls).toBe(1);
|
|
57
|
+
expect(gate.isClosed).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a Claude run's prompt input may close.
|
|
3
|
+
*
|
|
4
|
+
* The SDK closes the CLI's stdin once its prompt iterable ends and the first
|
|
5
|
+
* `result` arrives. But the CLI keeps going after that `result` while
|
|
6
|
+
* background work it started is still running: when a backgrounded command or
|
|
7
|
+
* agent finishes, it starts a new turn on its own. Every request that turn
|
|
8
|
+
* makes back to the host — in-process MCP tools (browser automation, memory),
|
|
9
|
+
* `canUseTool`, hooks — travels over stdin, so with stdin closed each one
|
|
10
|
+
* failed at once ("The tool call was interrupted before a result was
|
|
11
|
+
* received"). Recorded with SDK 0.3.296: the in-process tool's handler never
|
|
12
|
+
* ran in the notification turn.
|
|
13
|
+
*
|
|
14
|
+
* So Clopen holds the prompt iterable open and closes it only when the CLI has
|
|
15
|
+
* nothing left to do:
|
|
16
|
+
*
|
|
17
|
+
* - With session-state events (`CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS`), the
|
|
18
|
+
* CLI reports `idle` after every turn — including while background work is
|
|
19
|
+
* still running, which is exactly why `idle` alone was not enough. Close on
|
|
20
|
+
* `idle` when the background task list is empty.
|
|
21
|
+
* - Without them (an older CLI), close on a `result` when the background task
|
|
22
|
+
* list is empty.
|
|
23
|
+
*
|
|
24
|
+
* The background list is the authoritative `background_tasks_changed` list.
|
|
25
|
+
* `task_started` / `task_notification` are not used: foreground commands emit
|
|
26
|
+
* them too (`is_backgrounded: false`), and their notification comes inside the
|
|
27
|
+
* same turn.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export interface InputGateMessage {
|
|
31
|
+
type: string;
|
|
32
|
+
subtype?: string;
|
|
33
|
+
state?: string;
|
|
34
|
+
tasks?: unknown[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class ClaudeInputGate {
|
|
38
|
+
private backgroundTasks = 0;
|
|
39
|
+
private sawSessionState = false;
|
|
40
|
+
private closed = false;
|
|
41
|
+
|
|
42
|
+
constructor(private readonly close: () => void) {}
|
|
43
|
+
|
|
44
|
+
/** Feed every SDK message, in order. */
|
|
45
|
+
observe(message: InputGateMessage): void {
|
|
46
|
+
if (this.closed) return;
|
|
47
|
+
|
|
48
|
+
if (message.type === 'system' && message.subtype === 'background_tasks_changed') {
|
|
49
|
+
this.backgroundTasks = Array.isArray(message.tasks) ? message.tasks.length : 0;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (message.type === 'system' && message.subtype === 'session_state_changed') {
|
|
54
|
+
this.sawSessionState = true;
|
|
55
|
+
if (message.state === 'idle' && this.backgroundTasks === 0) this.shut();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (message.type === 'result' && !this.sawSessionState && this.backgroundTasks === 0) {
|
|
60
|
+
this.shut();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Close regardless — the run was cancelled or the stream ended. */
|
|
65
|
+
shut(): void {
|
|
66
|
+
if (this.closed) return;
|
|
67
|
+
this.closed = true;
|
|
68
|
+
this.close();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get isClosed(): boolean {
|
|
72
|
+
return this.closed;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -81,3 +81,19 @@ describe('Claude sub-agent scoping', () => {
|
|
|
81
81
|
expect(stop).toEqual([{ type: 'stream_event', event: 'stop', sessionId: 'session-1', reasoning: true }]);
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
|
+
|
|
85
|
+
describe('Claude background work', () => {
|
|
86
|
+
test('reports the complete background task list, empty once everything finished', () => {
|
|
87
|
+
const convert = createSdkMessageConverter();
|
|
88
|
+
const running = [...convert({
|
|
89
|
+
type: 'system', subtype: 'background_tasks_changed', session_id: 'session-1', uuid: 'bg-1',
|
|
90
|
+
tasks: [{ task_id: 'b1', run_id: 'r1', task_type: 'local_bash', description: 'sleep 6' }],
|
|
91
|
+
} as any)];
|
|
92
|
+
const done = [...convert({
|
|
93
|
+
type: 'system', subtype: 'background_tasks_changed', session_id: 'session-1', uuid: 'bg-2', tasks: [],
|
|
94
|
+
} as any)];
|
|
95
|
+
|
|
96
|
+
expect(running).toEqual([{ type: 'background_work', sessionId: 'session-1', tasks: [{ id: 'b1', description: 'sleep 6' }] }]);
|
|
97
|
+
expect(done).toEqual([{ type: 'background_work', sessionId: 'session-1', tasks: [] }]);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -41,6 +41,7 @@ import type {
|
|
|
41
41
|
SystemInitEvent,
|
|
42
42
|
RateLimitEvent,
|
|
43
43
|
NotificationEvent,
|
|
44
|
+
BackgroundWorkEvent,
|
|
44
45
|
TokenUsage,
|
|
45
46
|
StopReason,
|
|
46
47
|
} from '$shared/types/unified';
|
|
@@ -586,6 +587,13 @@ function* dispatchUnscopedSdkMessage(msg: SDKMessage, state: StreamConverterStat
|
|
|
586
587
|
yield convertModelRefusalFallback(msg as SDKModelRefusalFallbackMessage);
|
|
587
588
|
} else if (subtype === 'model_refusal_no_fallback') {
|
|
588
589
|
yield convertModelRefusalNoFallback(msg as SDKModelRefusalNoFallbackMessage);
|
|
590
|
+
} else if (subtype === 'background_tasks_changed') {
|
|
591
|
+
const changed = msg as unknown as { session_id: string; tasks?: Array<{ task_id: string; description?: string }> };
|
|
592
|
+
yield {
|
|
593
|
+
type: 'background_work',
|
|
594
|
+
sessionId: changed.session_id,
|
|
595
|
+
tasks: (changed.tasks ?? []).map((task) => ({ id: task.task_id, description: task.description }))
|
|
596
|
+
} satisfies BackgroundWorkEvent;
|
|
589
597
|
} else if (subtype === 'task_started') {
|
|
590
598
|
const task = msg as unknown as { session_id: string; uuid?: string; task_id: string; tool_use_id?: string; task_type?: string; workflow_name?: string; description?: string };
|
|
591
599
|
if (task.task_type === 'local_workflow' && task.tool_use_id) {
|
|
@@ -27,6 +27,7 @@ import type {
|
|
|
27
27
|
} from '@anthropic-ai/claude-agent-sdk';
|
|
28
28
|
import type { EngineOutput } from '$shared/types/unified';
|
|
29
29
|
import type { StructuredGenerationOptions } from '../../types';
|
|
30
|
+
import { ClaudeInputGate, type InputGateMessage } from './input-gate';
|
|
30
31
|
import { createSdkMessageConverter, toSdkUserMessage } from './message-converter';
|
|
31
32
|
import { WorkflowTranscriptTailer } from './workflow-transcript';
|
|
32
33
|
import { resolveOsPath } from '$backend/utils/paths';
|
|
@@ -137,6 +138,7 @@ export class ClaudeCodeEngine implements AIEngine {
|
|
|
137
138
|
projectPath,
|
|
138
139
|
prompt,
|
|
139
140
|
resume,
|
|
141
|
+
resumeAt,
|
|
140
142
|
maxTurns = undefined,
|
|
141
143
|
modelId,
|
|
142
144
|
includePartialMessages = false,
|
|
@@ -165,6 +167,7 @@ export class ClaudeCodeEngine implements AIEngine {
|
|
|
165
167
|
this.runs.add(run);
|
|
166
168
|
|
|
167
169
|
const resolvedProjectPath = resolveOsPath(projectPath);
|
|
170
|
+
let inputGate: ClaudeInputGate | null = null;
|
|
168
171
|
|
|
169
172
|
try {
|
|
170
173
|
// Active Profile for this stream (resolved in stream-manager). Scopes the
|
|
@@ -331,6 +334,10 @@ export class ClaudeCodeEngine implements AIEngine {
|
|
|
331
334
|
}),
|
|
332
335
|
...(modelId && { model: modelId }),
|
|
333
336
|
...(resume && { resume }),
|
|
337
|
+
// A deduplicated fork: `resume` holds this conversation and more, so it
|
|
338
|
+
// is cut where the original ended. forkSession stays on, so the cut is a
|
|
339
|
+
// new session and the shared transcript is never rewritten.
|
|
340
|
+
...(resume && resumeAt && { resumeSessionAt: resumeAt }),
|
|
334
341
|
...(maxTurns && { maxTurns }),
|
|
335
342
|
...(includePartialMessages && { includePartialMessages }),
|
|
336
343
|
forwardSubagentText: true,
|
|
@@ -341,8 +348,18 @@ export class ClaudeCodeEngine implements AIEngine {
|
|
|
341
348
|
|
|
342
349
|
// Convert UserMessage → SDKUserMessage for SDK
|
|
343
350
|
const sdkPrompt = toSdkUserMessage(prompt);
|
|
351
|
+
// The prompt stays open until the CLI has nothing left to do — see
|
|
352
|
+
// ClaudeInputGate. Ending it after the one message let the SDK close
|
|
353
|
+
// stdin at the first result, and every tool call, permission check and
|
|
354
|
+
// hook of a turn started by finished background work then failed.
|
|
355
|
+
let releaseInput!: () => void;
|
|
356
|
+
const inputReleased = new Promise<void>((resolve) => { releaseInput = resolve; });
|
|
357
|
+
inputGate = new ClaudeInputGate(releaseInput);
|
|
358
|
+
const gate = inputGate;
|
|
359
|
+
streamController.signal.addEventListener('abort', () => gate.shut(), { once: true });
|
|
344
360
|
const promptIterable = (async function* () {
|
|
345
361
|
yield sdkPrompt;
|
|
362
|
+
await inputReleased;
|
|
346
363
|
})();
|
|
347
364
|
|
|
348
365
|
const { query } = await loadEngineSdk<typeof import('@anthropic-ai/claude-agent-sdk')>('claude-code', '@anthropic-ai/claude-agent-sdk');
|
|
@@ -363,6 +380,7 @@ export class ClaudeCodeEngine implements AIEngine {
|
|
|
363
380
|
const sdkProducer = (async () => {
|
|
364
381
|
try {
|
|
365
382
|
for await (const sdkMessage of queryInstance) {
|
|
383
|
+
gate.observe(sdkMessage as InputGateMessage);
|
|
366
384
|
observeAskUserQuestion(sdkMessage);
|
|
367
385
|
// Register Workflow launches after queueing the corresponding parent
|
|
368
386
|
// and tool result, preserving their ordering ahead of child records.
|
|
@@ -408,6 +426,8 @@ export class ClaudeCodeEngine implements AIEngine {
|
|
|
408
426
|
} catch (error) {
|
|
409
427
|
handleStreamError(error);
|
|
410
428
|
} finally {
|
|
429
|
+
// However the stream ends, the held-open prompt must end with it.
|
|
430
|
+
inputGate?.shut();
|
|
411
431
|
// Retire THIS run only — a concurrent stream of another chat session in
|
|
412
432
|
// the same project is still using the instance.
|
|
413
433
|
this.forgetRun(run);
|
|
@@ -23,7 +23,7 @@ export function getCursorStoreRoot(): string {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Per-project isolated store directory. */
|
|
26
|
-
function getCursorStoreDir(projectPath: string): string {
|
|
26
|
+
export function getCursorStoreDir(projectPath: string): string {
|
|
27
27
|
return join(getCursorStoreRoot(), projectPath.replace(/[^a-zA-Z0-9]/g, '-') || 'default');
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -57,8 +57,17 @@ function resolveCliCwd(projectPath: string): string {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* The directory the CLI keeps a cwd's chats in, for that exact cwd string —
|
|
62
|
+
* no symlink resolution, so a caller relocating a project's chats can name
|
|
63
|
+
* the old path after it is gone.
|
|
64
|
+
*/
|
|
65
|
+
export function getQwenProjectDir(cwd: string): string {
|
|
66
|
+
return path.join(QWEN_PROJECTS_DIR, sanitizeCwd(cwd));
|
|
67
|
+
}
|
|
68
|
+
|
|
60
69
|
function getSessionStatePath(projectPath: string, sessionId: string): string {
|
|
61
|
-
return path.join(
|
|
70
|
+
return path.join(getQwenProjectDir(resolveCliCwd(projectPath)), 'chats', `${sessionId}.jsonl`);
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
export function sessionStateExists(projectPath: string, sessionId: string): boolean {
|
package/backend/engine/types.ts
CHANGED
|
@@ -29,6 +29,13 @@ export interface EngineQueryOptions {
|
|
|
29
29
|
projectPath: string;
|
|
30
30
|
prompt: UserMessage;
|
|
31
31
|
resume?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Cut the resumed session at this entry (Claude: `resumeSessionAt`). Set when
|
|
34
|
+
* `resume` is an alias target — the transcript the user is continuing was
|
|
35
|
+
* deduplicated into a later fork that holds it, and this is where it ended.
|
|
36
|
+
* Engines that cannot cut a session never receive one.
|
|
37
|
+
*/
|
|
38
|
+
resumeAt?: string;
|
|
32
39
|
forkSession?: boolean;
|
|
33
40
|
maxTurns?: number;
|
|
34
41
|
/** Provider slug (e.g. 'anthropic', 'openai'). Required for OpenCode. */
|
|
@@ -101,6 +101,8 @@ async function runCredentialHelper(argv: string[]): Promise<number> {
|
|
|
101
101
|
const operation = argv.find((a) => !a.startsWith('--')) ?? 'get';
|
|
102
102
|
if (operation !== 'get') return 0;
|
|
103
103
|
|
|
104
|
+
if (argv.includes('--hosted')) return runHostedCredentialHelper(argv);
|
|
105
|
+
|
|
104
106
|
const identityId = identityIdFrom(argv);
|
|
105
107
|
if (!identityId) return 0;
|
|
106
108
|
|
|
@@ -143,6 +145,39 @@ async function runCredentialHelper(argv: string[]): Promise<number> {
|
|
|
143
145
|
return 0;
|
|
144
146
|
}
|
|
145
147
|
|
|
148
|
+
/** `--project=<id>` out of the helper's own arguments. */
|
|
149
|
+
export function projectIdFrom(argv: string[]): string | null {
|
|
150
|
+
for (const arg of argv) {
|
|
151
|
+
if (arg.startsWith('--project=')) {
|
|
152
|
+
const value = arg.slice('--project='.length).trim();
|
|
153
|
+
if (value) return value;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Answer for a host a connected hosting account serves.
|
|
161
|
+
*
|
|
162
|
+
* Git sends the host and — because `useHttpPath` is set for these hosts — the
|
|
163
|
+
* repository path, so the account is chosen by the repository's owner exactly
|
|
164
|
+
* as the Git panel chooses it. Ambiguity answers nothing, same rule as above.
|
|
165
|
+
*/
|
|
166
|
+
async function runHostedCredentialHelper(argv: string[]): Promise<number> {
|
|
167
|
+
const request = parseCredentialRequest(await readStdin());
|
|
168
|
+
if ((request.protocol ?? 'https') !== 'https') return 0;
|
|
169
|
+
const host = (request.host ?? '').toLowerCase().split(':')[0] ?? '';
|
|
170
|
+
if (!host) return 0;
|
|
171
|
+
|
|
172
|
+
await connectReadOnly();
|
|
173
|
+
const { answerHostedCredential } = await import('$backend/git-hosts/git-credential');
|
|
174
|
+
const answer = await answerHostedCredential(host, request.path ?? '', projectIdFrom(argv));
|
|
175
|
+
if (!answer) return 0;
|
|
176
|
+
|
|
177
|
+
process.stdout.write(`username=${answer.username}\npassword=${answer.password}\n`);
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
146
181
|
/**
|
|
147
182
|
* Answer `ssh`'s passphrase prompt.
|
|
148
183
|
*
|
|
@@ -2,7 +2,7 @@ import { describe, expect, test } from 'bun:test';
|
|
|
2
2
|
import { mkdtemp, rm } from 'node:fs/promises';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
import { buildGitConfigPairs, buildGitIdentityEnv, remoteHost } from './env';
|
|
5
|
+
import { buildGitConfigPairs, buildGitIdentityEnv, buildHostedCredentialPairs, remoteHost } from './env';
|
|
6
6
|
|
|
7
7
|
const helper = { runtime: '/usr/local/bin/bun', script: '/opt/clopen/index.js' };
|
|
8
8
|
|
|
@@ -212,3 +212,54 @@ describe('the env block against real git', () => {
|
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
});
|
|
215
|
+
|
|
216
|
+
describe('buildHostedCredentialPairs', () => {
|
|
217
|
+
test('scopes a reset plus Clopen\'s helper to each served host, with the path sent', () => {
|
|
218
|
+
const pairs = buildHostedCredentialPairs(['gitlab.com', 'github.com', 'github.com'], 'proj-1', helper);
|
|
219
|
+
expect(pairs.filter(([key]) => key === 'credential.https://github.com.helper')).toHaveLength(2);
|
|
220
|
+
expect(pairs[0]).toEqual(['credential.https://github.com.helper', '']);
|
|
221
|
+
expect(pairs[1]![1]).toContain('git-credential --hosted');
|
|
222
|
+
expect(pairs[1]![1]).toContain("'--project=proj-1'");
|
|
223
|
+
expect(pairs).toContainEqual(['credential.https://gitlab.com.useHttpPath', 'true']);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
test('no helper or no hosts means nothing — the machine keeps its own helpers', () => {
|
|
227
|
+
expect(buildHostedCredentialPairs(['github.com'], 'p')).toEqual([]);
|
|
228
|
+
expect(buildHostedCredentialPairs([], 'p', helper)).toEqual([]);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('hosted pairs alone still produce an environment', () => {
|
|
232
|
+
const env = buildGitIdentityEnv(null, helper, buildHostedCredentialPairs(['github.com'], 'p', helper));
|
|
233
|
+
expect(pairsOf(env).some(([key]) => key === 'user.name')).toBe(false);
|
|
234
|
+
expect(Number(env.GIT_CONFIG_COUNT)).toBe(3);
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
describe('helper commands carry the data directory', () => {
|
|
239
|
+
// Git starts the helper with Clopen's cleaned environment, which has no
|
|
240
|
+
// NODE_ENV. Without the directory in the command, a dev or relocated
|
|
241
|
+
// instance's helper opened the default database and found no account.
|
|
242
|
+
const pinned = { ...helper, dataDir: '/home/user/.clopen-dev' };
|
|
243
|
+
|
|
244
|
+
test('the hosted helper is prefixed with CLOPEN_DATA_DIR', () => {
|
|
245
|
+
const [, command] = buildHostedCredentialPairs(['github.com'], 'p', pinned)[1]!;
|
|
246
|
+
expect(command.startsWith("!CLOPEN_DATA_DIR='/home/user/.clopen-dev' ")).toBe(true);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test('the identity helper is prefixed too', () => {
|
|
250
|
+
const pairs = buildGitConfigPairs(
|
|
251
|
+
{ id: 'i', name: 'A', email: 'a@example.com', credentialHosts: ['github.com'], httpsUsername: 'a' },
|
|
252
|
+
pinned
|
|
253
|
+
);
|
|
254
|
+
const helperValue = pairs.filter(([key]) => key === 'credential.helper').map(([, value]) => value).find(Boolean);
|
|
255
|
+
expect(helperValue).toContain("CLOPEN_DATA_DIR='/home/user/.clopen-dev'");
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
test('a passphrase askpass gets the directory as a variable, since ssh runs it without a shell', () => {
|
|
259
|
+
const env = buildGitIdentityEnv(
|
|
260
|
+
{ id: 'i', name: 'A', email: 'a@example.com', sshKeyPath: '/k', needsPassphrase: true },
|
|
261
|
+
pinned
|
|
262
|
+
);
|
|
263
|
+
expect(env.CLOPEN_DATA_DIR).toBe('/home/user/.clopen-dev');
|
|
264
|
+
});
|
|
265
|
+
});
|
|
@@ -48,6 +48,27 @@ export interface HelperCommand {
|
|
|
48
48
|
runtime: string;
|
|
49
49
|
/** The entry script (`Bun.main`). */
|
|
50
50
|
script: string;
|
|
51
|
+
/**
|
|
52
|
+
* The data directory of the Clopen that wrote this command.
|
|
53
|
+
*
|
|
54
|
+
* Git runs the helper as a brand-new process with the environment Clopen
|
|
55
|
+
* spawned git with — and that environment is deliberately cleaned of
|
|
56
|
+
* `NODE_ENV`. Without the directory pinned here, a helper started for a
|
|
57
|
+
* development instance (`~/.clopen-dev`) or one with `CLOPEN_DATA_DIR` set
|
|
58
|
+
* opened the DEFAULT database, found no account, answered nothing, and git
|
|
59
|
+
* fell through to "could not read Username".
|
|
60
|
+
*/
|
|
61
|
+
dataDir?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The start of a helper command line: the data directory, then runtime and
|
|
66
|
+
* script. Git runs `!`-helpers through a POSIX shell, so a leading
|
|
67
|
+
* `NAME=value` sets the variable for that one command only.
|
|
68
|
+
*/
|
|
69
|
+
function helperInvocation(helper: HelperCommand): string {
|
|
70
|
+
const parts = [shellQuote(helper.runtime), shellQuote(helper.script)];
|
|
71
|
+
return helper.dataDir ? `CLOPEN_DATA_DIR=${shellQuote(helper.dataDir)} ${parts.join(' ')}` : parts.join(' ');
|
|
51
72
|
}
|
|
52
73
|
|
|
53
74
|
/**
|
|
@@ -107,8 +128,7 @@ export function buildGitConfigPairs(
|
|
|
107
128
|
// this through a shell (the `!` prefix), passes the request on stdin, and
|
|
108
129
|
// reads the answer from stdout.
|
|
109
130
|
const command = [
|
|
110
|
-
|
|
111
|
-
shellQuote(helper.script),
|
|
131
|
+
helperInvocation(helper),
|
|
112
132
|
'git-credential',
|
|
113
133
|
shellQuote(`--identity=${identity.id}`)
|
|
114
134
|
].join(' ');
|
|
@@ -127,18 +147,54 @@ export function buildGitConfigPairs(
|
|
|
127
147
|
}
|
|
128
148
|
|
|
129
149
|
/**
|
|
130
|
-
*
|
|
150
|
+
* Credential pairs for hosts served by a connected hosting account.
|
|
151
|
+
*
|
|
152
|
+
* Scoped per host (`credential.https://github.com.*`), so a host no account
|
|
153
|
+
* serves keeps the machine's own helpers untouched. For a host that IS served,
|
|
154
|
+
* the same reset-then-ours rule as above applies — otherwise the system
|
|
155
|
+
* keychain would answer first with whatever account it happens to hold.
|
|
131
156
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
157
|
+
* `useHttpPath` makes git send the repository path to the helper. That is what
|
|
158
|
+
* lets one helper choose between two accounts on the same host by the
|
|
159
|
+
* repository's owner, the way the Git panel does.
|
|
160
|
+
*/
|
|
161
|
+
export function buildHostedCredentialPairs(
|
|
162
|
+
hosts: string[],
|
|
163
|
+
projectId: string,
|
|
164
|
+
helper?: HelperCommand
|
|
165
|
+
): Array<[string, string]> {
|
|
166
|
+
if (!helper || hosts.length === 0) return [];
|
|
167
|
+
const command = [
|
|
168
|
+
helperInvocation(helper),
|
|
169
|
+
'git-credential',
|
|
170
|
+
'--hosted',
|
|
171
|
+
shellQuote(`--project=${projectId}`)
|
|
172
|
+
].join(' ');
|
|
173
|
+
|
|
174
|
+
const pairs: Array<[string, string]> = [];
|
|
175
|
+
for (const host of [...new Set(hosts)].sort()) {
|
|
176
|
+
pairs.push([`credential.https://${host}.helper`, '']);
|
|
177
|
+
pairs.push([`credential.https://${host}.helper`, `!${command}`]);
|
|
178
|
+
pairs.push([`credential.https://${host}.useHttpPath`, 'true']);
|
|
179
|
+
}
|
|
180
|
+
return pairs;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The environment fragment for an identity, plus any hosted-credential pairs.
|
|
185
|
+
*
|
|
186
|
+
* Returns `{}` when there is neither, so every caller can merge
|
|
187
|
+
* unconditionally and a project without them behaves exactly as Clopen did
|
|
188
|
+
* before this feature.
|
|
134
189
|
*/
|
|
135
190
|
export function buildGitIdentityEnv(
|
|
136
191
|
identity: GitEnvIdentity | null,
|
|
137
|
-
helper?: HelperCommand
|
|
192
|
+
helper?: HelperCommand,
|
|
193
|
+
extraPairs: Array<[string, string]> = []
|
|
138
194
|
): Record<string, string> {
|
|
139
|
-
if (!identity) return {};
|
|
195
|
+
if (!identity && extraPairs.length === 0) return {};
|
|
140
196
|
|
|
141
|
-
const pairs = buildGitConfigPairs(identity, helper);
|
|
197
|
+
const pairs = [...(identity ? buildGitConfigPairs(identity, helper) : []), ...extraPairs];
|
|
142
198
|
const env: Record<string, string> = { GIT_CONFIG_COUNT: String(pairs.length) };
|
|
143
199
|
|
|
144
200
|
pairs.forEach(([key, value], index) => {
|
|
@@ -146,7 +202,7 @@ export function buildGitIdentityEnv(
|
|
|
146
202
|
env[`GIT_CONFIG_VALUE_${index}`] = value;
|
|
147
203
|
});
|
|
148
204
|
|
|
149
|
-
if (identity
|
|
205
|
+
if (identity?.sshKeyPath && identity.needsPassphrase && helper) {
|
|
150
206
|
// `ssh` only consults SSH_ASKPASS when it has no terminal to prompt on.
|
|
151
207
|
// A PTY-backed shell HAS one, so without REQUIRE=force a passphrased key
|
|
152
208
|
// would hang the terminal waiting for input git can never deliver.
|
|
@@ -157,13 +213,16 @@ export function buildGitIdentityEnv(
|
|
|
157
213
|
shellQuote(`--identity=${identity.id}`)
|
|
158
214
|
].join(' ');
|
|
159
215
|
env.SSH_ASKPASS = askpass;
|
|
216
|
+
// ssh runs the askpass program directly, not through a shell, so the
|
|
217
|
+
// data directory travels as a variable rather than a command prefix.
|
|
218
|
+
if (helper.dataDir) env.CLOPEN_DATA_DIR = helper.dataDir;
|
|
160
219
|
env.SSH_ASKPASS_REQUIRE = 'force';
|
|
161
220
|
// Older OpenSSH consults DISPLAY before SSH_ASKPASS. The value is never
|
|
162
221
|
// connected to, it only has to be non-empty.
|
|
163
222
|
env.DISPLAY = env.DISPLAY || ':0';
|
|
164
223
|
}
|
|
165
224
|
|
|
166
|
-
debug.log('git', `Git identity env built for ${identity
|
|
225
|
+
debug.log('git', `Git identity env built for ${identity?.email ?? 'hosted accounts only'} (${pairs.length} config pairs)`);
|
|
167
226
|
return env;
|
|
168
227
|
}
|
|
169
228
|
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
* credential helper.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { buildGitIdentityEnv, remoteHost } from './env';
|
|
13
|
+
import { buildGitIdentityEnv, buildHostedCredentialPairs, remoteHost } from './env';
|
|
14
14
|
import { helperCommand, pickCredentialIdentity, resolveIdentity, toEnvIdentity } from './resolve';
|
|
15
15
|
import { toDTO } from './service';
|
|
16
|
+
import { hostAccounts } from '$backend/git-hosts/accounts';
|
|
17
|
+
import type { GitIdentityRow } from '$backend/database/queries';
|
|
18
|
+
import { debug } from '$shared/utils/logger';
|
|
16
19
|
import type { ResolvedGitIdentity } from '$shared/types/git-identity';
|
|
17
20
|
|
|
18
21
|
export { gitIdentityService, toDTO } from './service';
|
|
19
|
-
export { buildGitIdentityEnv, buildGitConfigPairs, remoteHost } from './env';
|
|
22
|
+
export { buildGitIdentityEnv, buildGitConfigPairs, buildHostedCredentialPairs, remoteHost } from './env';
|
|
20
23
|
export type { GitEnvIdentity, HelperCommand } from './env';
|
|
21
24
|
export { resolveIdentity, pickCredentialIdentity, toEnvIdentity, helperCommand } from './resolve';
|
|
22
25
|
export { identityKeyPath, removeKeyFiles, writeKeyFile } from './keys';
|
|
@@ -36,11 +39,27 @@ export { readMachineIdentity, syncLocalMachineIdentity } from './import-local';
|
|
|
36
39
|
*/
|
|
37
40
|
export function resolveGitEnv(projectId: string, remoteUrl?: string | null): Record<string, string> {
|
|
38
41
|
const { row } = resolveIdentity(projectId);
|
|
39
|
-
if (!row) return {};
|
|
40
|
-
|
|
41
42
|
const host = remoteUrl ? remoteHost(remoteUrl) : null;
|
|
42
|
-
const credential = pickCredentialIdentity(host, row);
|
|
43
|
-
|
|
43
|
+
const credential = row ? pickCredentialIdentity(host, row) : null;
|
|
44
|
+
const hosted = buildHostedCredentialPairs(hostedHosts(projectId, row), projectId, helperCommand());
|
|
45
|
+
return buildGitIdentityEnv(row ? toEnvIdentity(row, credential) : null, helperCommand(), hosted);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Hosts a connected hosting account answers for, in this project.
|
|
50
|
+
*
|
|
51
|
+
* A host an identity's own credential claims is left out: a token chosen in
|
|
52
|
+
* Settings → Git Accounts is an explicit override, and it keeps winning over
|
|
53
|
+
* the account connected for the Git panel.
|
|
54
|
+
*/
|
|
55
|
+
export function hostedHosts(projectId: string, row: GitIdentityRow | null): string[] {
|
|
56
|
+
try {
|
|
57
|
+
const hosts = new Set(hostAccounts(projectId).map((ref) => ref.host));
|
|
58
|
+
return [...hosts].filter((host) => !(row && pickCredentialIdentity(host, row)));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
debug.warn('git', 'Could not list hosting accounts for git credentials:', error);
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
44
63
|
}
|
|
45
64
|
|
|
46
65
|
/**
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
import { debug } from '$shared/utils/logger';
|
|
27
27
|
import type { GitEnvIdentity, HelperCommand } from './env';
|
|
28
28
|
import { identityKeyPath } from './keys';
|
|
29
|
+
import { SERVER_ENV } from '$backend/utils/env';
|
|
29
30
|
|
|
30
31
|
/** Where the identity came from, for the "committing as…" line in the UI. */
|
|
31
32
|
export type IdentitySource = 'project' | 'default' | 'none';
|
|
@@ -135,5 +136,5 @@ export function helperCommand(): HelperCommand | undefined {
|
|
|
135
136
|
debug.warn('git', 'Cannot locate the Clopen entry point; git credential helpers disabled');
|
|
136
137
|
return undefined;
|
|
137
138
|
}
|
|
138
|
-
return { runtime, script };
|
|
139
|
+
return { runtime, script, dataDir: SERVER_ENV.DATA_DIR };
|
|
139
140
|
}
|
|
@@ -42,12 +42,15 @@ async function writeGenerated(pairs: Array<[string, string]>): Promise<string> {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async function gitConfig(key: string, configPath: string, cwd: string): Promise<string> {
|
|
45
|
+
// GIT_CONFIG_COUNT/KEY_n/VALUE_n outrank every config file. A shell Clopen
|
|
46
|
+
// started carries the user's identity in them, which would answer instead
|
|
47
|
+
// of the file under test.
|
|
48
|
+
const env = Object.fromEntries(
|
|
49
|
+
Object.entries(process.env).filter(([name]) => !/^GIT_CONFIG_(COUNT|KEY_\d+|VALUE_\d+)$/.test(name))
|
|
50
|
+
);
|
|
45
51
|
const proc = Bun.spawn(['git', 'config', '--get', key], {
|
|
46
52
|
cwd,
|
|
47
|
-
env: { ...
|
|
48
|
-
string,
|
|
49
|
-
string
|
|
50
|
-
>,
|
|
53
|
+
env: { ...env, GIT_CONFIG_GLOBAL: configPath, GIT_CONFIG_SYSTEM: '/dev/null' } as Record<string, string>,
|
|
51
54
|
stdout: 'pipe',
|
|
52
55
|
stderr: 'pipe'
|
|
53
56
|
});
|