@bastani/atomic 0.10.4 → 0.10.5-alpha.1
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/CHANGELOG.md +44 -0
- package/dist/_shared/compile-cache-warmup-host-RU5L7I7A.js +1 -1
- package/dist/_shared/dist-KOELCESV.js +48 -3
- package/dist/_shared/fork-row-index-UAUAQRD5.js +47 -2
- package/dist/_shared/http-YFAPTIZD.js +16 -4
- package/dist/_shared/http-YFAPTIZD.js.map +1 -1
- package/dist/_shared/lib-4PES5P4V.js +59 -14
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +1706 -258
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +317 -64
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/{mode-shared-HP7GUA7J.js → mode-shared-2QJSCUM6.js} +432 -81
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -0
- package/dist/_shared/p0-cli-BB45ZQY6.js +3482 -0
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -0
- package/dist/_shared/p0-cli-GUFK7TPN.js +2 -2838
- package/dist/_shared/p0-cli-GUFK7TPN.js.map +1 -1
- package/dist/_shared/{p1a-prewarm-YK3KDTLN.js → p1a-prewarm-UQY3X2UK.js} +270 -73
- package/dist/_shared/p1a-prewarm-UQY3X2UK.js.map +1 -0
- package/dist/_shared/{p1b-elig-PXQA2FYP.js → p1b-elig-ENCUPKKJ.js} +190 -121
- package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +1 -0
- package/dist/_shared/p2-common-YLSYXMDQ.js +1 -3
- package/dist/_shared/p2-common-YLSYXMDQ.js.map +1 -1
- package/dist/_shared/p2-shell-TJBYQMCJ.js +1 -1
- package/dist/_shared/p2-shell-main-B2WIALFD.js +500 -127
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +4 -4
- package/dist/_shared/sdk-WQIOHVKO.js +56 -11
- package/dist/_shared/session-data-AHTU7IS6.js +48 -3
- package/dist/_shared/session-manager-list-2BLEEZVG.js +2 -2
- package/dist/_shared/settings-startup-65YEWRV2.js.map +1 -1
- package/dist/_shared/sql-session-store-5FD3WBMZ.js +57 -12
- package/dist/_shared/{startup-0-0-X4NF3GKM.js → startup-0-0-TYUFUOJZ.js} +519 -316
- package/dist/_shared/startup-0-0-TYUFUOJZ.js.map +1 -0
- package/dist/_shared/{startup-0-1-7QTG6VJZ.js → startup-0-1-D4LGGINF.js} +284 -81
- package/dist/_shared/startup-0-1-D4LGGINF.js.map +1 -0
- package/dist/_shared/{startup-0-2-KFDYPDJK.js → startup-0-2-SZGQIWHI.js} +483 -154
- package/dist/_shared/startup-0-2-SZGQIWHI.js.map +1 -0
- package/dist/_shared/startup-0-3-T4DVFYWX.js +340 -110
- package/dist/_shared/startup-0-3-T4DVFYWX.js.map +1 -1
- package/dist/_shared/startup-0-4-HN5EB4K7.js +261 -59
- package/dist/_shared/startup-0-4-HN5EB4K7.js.map +1 -1
- package/dist/_shared/startup-0-5-OHJNE6JH.js +421 -148
- package/dist/_shared/startup-0-5-OHJNE6JH.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +62 -11
- package/dist/_shared/startup-10-0-TDQNBDDL.js.map +1 -1
- package/dist/_shared/startup-12-0-55AAXBJZ.js +3 -3
- package/dist/_shared/startup-14-0-MLX36RBG.js +12 -11
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +53 -158
- package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +231 -46
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +115 -35
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-KQJBDKRU.js → startup-8-1-SJW2GMAM.js} +203 -62
- package/dist/_shared/startup-8-1-SJW2GMAM.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +55 -10
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +47 -2
- package/dist/_shared/tree-outline-MUEPK5B7.js +48 -3
- package/dist/builtin/intercom/CHANGELOG.md +21 -0
- package/dist/builtin/intercom/README.md +0 -1
- package/dist/builtin/intercom/broker/broker-instance.ts +13 -57
- package/dist/builtin/intercom/broker/broker-process.ts +30 -10
- package/dist/builtin/intercom/broker/broker-routing.ts +12 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +2557 -498
- package/dist/builtin/intercom/broker/broker.ts +164 -55
- package/dist/builtin/intercom/broker/client.ts +36 -16
- package/dist/builtin/intercom/broker/control.ts +83 -20
- package/dist/builtin/intercom/broker/durable-ended-queue.ts +65 -19
- package/dist/builtin/intercom/broker/host-command-environment.ts +7 -2
- package/dist/builtin/intercom/broker/multinode-router.ts +1675 -387
- package/dist/builtin/intercom/broker/multinode-state-store.ts +10 -0
- package/dist/builtin/intercom/broker/paths.ts +68 -6
- package/dist/builtin/intercom/broker/pending-send-registry.ts +5 -0
- package/dist/builtin/intercom/broker/registration-bounds.ts +38 -0
- package/dist/builtin/intercom/broker/retiring-broker-check.ts +178 -0
- package/dist/builtin/intercom/broker/return-paths.ts +268 -7
- package/dist/builtin/intercom/broker/send-handler.ts +253 -28
- package/dist/builtin/intercom/broker/send-order-gate.ts +410 -0
- package/dist/builtin/intercom/broker/spawn.ts +950 -202
- package/dist/builtin/intercom/broker/sql-lease-store.ts +37 -0
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +7 -0
- package/dist/builtin/intercom/broker/windows-cwd.ts +546 -0
- package/dist/builtin/intercom/index.bundle.mjs +3506 -2328
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/retry-policy.ts +4 -0
- package/dist/builtin/intercom/types.ts +2 -0
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +336 -86
- package/dist/builtin/web-access/index.bundle.mjs +23 -38
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/cli.js +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/internal-intercom-broker.js +119 -4
- package/dist/bun/internal-intercom-broker.js.map +1 -1
- package/dist/bun/register-theme-validator.js +6 -0
- package/dist/bun/register-theme-validator.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +1102 -0
- package/dist/cli/auth-cli.code.js.map +1 -0
- package/dist/cli/auth-cli.impl.js +30 -1096
- package/dist/cli/auth-cli.impl.js.map +1 -1
- package/dist/cli/auth-cli.js +11 -7
- package/dist/cli/blueprint-command.code.js +906 -0
- package/dist/cli/blueprint-command.code.js.map +1 -0
- package/dist/cli/blueprint-command.impl.js +30 -900
- package/dist/cli/blueprint-command.impl.js.map +1 -1
- package/dist/cli/blueprint-command.js +11 -7
- package/dist/cli/intercom-command.code.js +153 -0
- package/dist/cli/intercom-command.code.js.map +1 -0
- package/dist/cli/intercom-command.impl.js +33 -105
- package/dist/cli/intercom-command.impl.js.map +1 -1
- package/dist/cli/intercom-command.js +11 -7
- package/dist/cli/list-models.code.js +60 -0
- package/dist/cli/list-models.code.js.map +1 -0
- package/dist/cli/list-models.impl.js +33 -57
- package/dist/cli/list-models.impl.js.map +1 -1
- package/dist/cli/list-models.js +11 -7
- package/dist/cli/session-picker.code.js +55 -0
- package/dist/cli/session-picker.code.js.map +1 -0
- package/dist/cli/session-picker.impl.js +33 -52
- package/dist/cli/session-picker.impl.js.map +1 -1
- package/dist/cli/session-picker.js +11 -7
- package/dist/cli/startup-ui.code.js +5 -0
- package/dist/cli/startup-ui.code.js.map +1 -0
- package/dist/cli/startup-ui.impl.js +35 -4
- package/dist/cli/startup-ui.js +11 -7
- package/dist/cli/storage-command.code.js +3 -0
- package/dist/cli/storage-command.code.js.map +1 -0
- package/dist/cli/storage-command.impl.js +35 -2
- package/dist/cli/storage-command.js +11 -7
- package/dist/cli/storage-search-session.code.js +189 -0
- package/dist/cli/storage-search-session.code.js.map +1 -0
- package/dist/cli/storage-search-session.impl.js +33 -186
- package/dist/cli/storage-search-session.impl.js.map +1 -1
- package/dist/cli/storage-search-session.js +11 -7
- package/dist/cli/team-command.code.js +217 -0
- package/dist/cli/team-command.code.js.map +1 -0
- package/dist/cli/team-command.impl.js +32 -213
- package/dist/cli/team-command.impl.js.map +1 -1
- package/dist/cli/team-command.js +11 -7
- package/dist/cli.js +60 -11
- package/dist/cli.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -3
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -0
- package/dist/core/compaction/compaction.d.ts +6 -0
- package/dist/core/compaction/model-resolver.d.ts +1 -1
- package/dist/core/debug.code.js +3 -0
- package/dist/core/debug.code.js.map +1 -0
- package/dist/core/debug.impl.js +35 -2
- package/dist/core/debug.js +11 -7
- package/dist/core/default-model-api-prewarm.d.ts +5 -0
- package/dist/core/export-html/card-projection.code.js +257 -0
- package/dist/core/export-html/card-projection.code.js.map +1 -0
- package/dist/core/export-html/card-projection.impl.js +34 -255
- package/dist/core/export-html/card-projection.impl.js.map +1 -1
- package/dist/core/export-html/card-projection.js +11 -7
- package/dist/core/export-html/index.code.js +655 -0
- package/dist/core/export-html/index.code.js.map +1 -0
- package/dist/core/export-html/index.impl.js +30 -604
- package/dist/core/export-html/index.impl.js.map +1 -1
- package/dist/core/export-html/index.js +11 -7
- package/dist/core/export-html/json-spans.code.js +3 -0
- package/dist/core/export-html/json-spans.code.js.map +1 -0
- package/dist/core/export-html/json-spans.impl.js +35 -2
- package/dist/core/export-html/json-spans.js +11 -7
- package/dist/core/export-html/oversized-render-inputs.code.js +125 -0
- package/dist/core/export-html/oversized-render-inputs.code.js.map +1 -0
- package/dist/core/export-html/oversized-render-inputs.impl.js +31 -120
- package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -1
- package/dist/core/export-html/oversized-render-inputs.js +11 -7
- package/dist/core/export-html/tool-renderer.code.js +350 -0
- package/dist/core/export-html/tool-renderer.code.js.map +1 -0
- package/dist/core/export-html/tool-renderer.impl.js +33 -347
- package/dist/core/export-html/tool-renderer.impl.js.map +1 -1
- package/dist/core/export-html/tool-renderer.js +11 -7
- package/dist/core/extensions/jiti-loader.code.js +3 -0
- package/dist/core/extensions/jiti-loader.code.js.map +1 -0
- package/dist/core/extensions/jiti-loader.impl.js +35 -2
- package/dist/core/extensions/jiti-loader.js +11 -7
- package/dist/core/extensions/jiti-static-loader.code.js +3 -0
- package/dist/core/extensions/jiti-static-loader.code.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.impl.js +35 -2
- package/dist/core/extensions/jiti-static-loader.js +11 -7
- package/dist/core/extensions/loader-host-modules.code.js +3 -0
- package/dist/core/extensions/loader-host-modules.code.js.map +1 -0
- package/dist/core/extensions/loader-host-modules.impl.js +35 -2
- package/dist/core/extensions/loader-host-modules.js +11 -7
- package/dist/core/extensions/loader-virtual-modules.d.ts +1 -6
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +3 -3
- package/dist/core/extensions/session-events.d.ts +4 -0
- package/dist/core/extensions/session-events.js.map +1 -1
- package/dist/core/intercom-broker-control-host.code.js +5 -0
- package/dist/core/intercom-broker-control-host.code.js.map +1 -0
- package/dist/core/intercom-broker-control-host.impl.js +35 -4
- package/dist/core/intercom-broker-control-host.js +11 -7
- package/dist/core/intercom-broker-control.code.js +63 -0
- package/dist/core/intercom-broker-control.code.js.map +1 -0
- package/dist/core/intercom-broker-control.d.ts +21 -0
- package/dist/core/intercom-broker-control.impl.js +35 -17
- package/dist/core/intercom-broker-control.impl.js.map +1 -1
- package/dist/core/intercom-broker-control.js +11 -7
- package/dist/core/package-manager-storage-adapters.code.js +3 -0
- package/dist/core/package-manager-storage-adapters.code.js.map +1 -0
- package/dist/core/package-manager-storage-adapters.impl.js +35 -2
- package/dist/core/package-manager-storage-adapters.js +11 -7
- package/dist/core/process-start-token.d.ts +8 -2
- package/dist/core/process-tree-containment.d.ts +27 -0
- package/dist/core/queued-message-delivery.d.ts +5 -2
- package/dist/core/resume/blueprint/process.d.ts +3 -1
- package/dist/core/sdk.code.js +9 -0
- package/dist/core/sdk.code.js.map +1 -0
- package/dist/core/sdk.impl.js +35 -8
- package/dist/core/sdk.js +11 -7
- package/dist/core/session-manager-core.d.ts +15 -5
- package/dist/core/session-manager-core.js +195 -38
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.code.js +3 -0
- package/dist/core/session-manager-list.code.js.map +1 -0
- package/dist/core/session-manager-list.impl.js +35 -2
- package/dist/core/session-manager-list.js +11 -7
- package/dist/core/session-manager-types.d.ts +20 -0
- package/dist/core/session-manager.code.js +8 -0
- package/dist/core/session-manager.code.js.map +1 -0
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.impl.js +35 -7
- package/dist/core/session-manager.js +11 -7
- package/dist/core/session-storage.code.js +3 -0
- package/dist/core/session-storage.code.js.map +1 -0
- package/dist/core/session-storage.impl.js +35 -2
- package/dist/core/session-storage.js +11 -7
- package/dist/core/storage/file-identity.d.ts +3 -0
- package/dist/core/storage/file-identity.js +296 -86
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -1
- package/dist/core/storage/index.js +52 -7
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +47 -2
- package/dist/core/storage/node-sqlite.js +49 -4
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.code.js +37 -0
- package/dist/core/storage/offline-snapshot-file.code.js.map +1 -0
- package/dist/core/storage/offline-snapshot-file.impl.js +33 -34
- package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.js +11 -7
- package/dist/core/storage/provider.js +52 -7
- package/dist/core/storage/selection.js +49 -4
- package/dist/core/storage/session/branch-fork-source.code.js +146 -0
- package/dist/core/storage/session/branch-fork-source.code.js.map +1 -0
- package/dist/core/storage/session/branch-fork-source.impl.js +32 -97
- package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.js +11 -7
- package/dist/core/storage/session/card-view.code.js +60 -0
- package/dist/core/storage/session/card-view.code.js.map +1 -0
- package/dist/core/storage/session/card-view.impl.js +34 -58
- package/dist/core/storage/session/card-view.impl.js.map +1 -1
- package/dist/core/storage/session/card-view.js +11 -7
- package/dist/core/storage/session/child-reader.code.js +139 -0
- package/dist/core/storage/session/child-reader.code.js.map +1 -0
- package/dist/core/storage/session/child-reader.d.ts +1 -0
- package/dist/core/storage/session/child-reader.impl.js +33 -91
- package/dist/core/storage/session/child-reader.impl.js.map +1 -1
- package/dist/core/storage/session/child-reader.js +11 -7
- package/dist/core/storage/session/chunked-resume-projection.code.js +3 -0
- package/dist/core/storage/session/chunked-resume-projection.code.js.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.impl.js +35 -2
- package/dist/core/storage/session/chunked-resume-projection.js +11 -7
- package/dist/core/storage/session/expanded-child-details.code.js +684 -0
- package/dist/core/storage/session/expanded-child-details.code.js.map +1 -0
- package/dist/core/storage/session/expanded-child-details.impl.js +31 -634
- package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -1
- package/dist/core/storage/session/expanded-child-details.js +11 -7
- package/dist/core/storage/session/fork-row-bytes.code.js +3 -0
- package/dist/core/storage/session/fork-row-bytes.code.js.map +1 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js +35 -2
- package/dist/core/storage/session/fork-row-bytes.js +11 -7
- package/dist/core/storage/session/fork-row-index.code.js +3 -0
- package/dist/core/storage/session/fork-row-index.code.js.map +1 -0
- package/dist/core/storage/session/fork-row-index.impl.js +35 -2
- package/dist/core/storage/session/fork-row-index.js +11 -7
- package/dist/core/storage/session/fork-staging.code.js +580 -0
- package/dist/core/storage/session/fork-staging.code.js.map +1 -0
- package/dist/core/storage/session/fork-staging.impl.js +30 -574
- package/dist/core/storage/session/fork-staging.impl.js.map +1 -1
- package/dist/core/storage/session/fork-staging.js +11 -7
- package/dist/core/storage/session/fork-window.code.js +522 -0
- package/dist/core/storage/session/fork-window.code.js.map +1 -0
- package/dist/core/storage/session/fork-window.impl.js +30 -471
- package/dist/core/storage/session/fork-window.impl.js.map +1 -1
- package/dist/core/storage/session/fork-window.js +11 -7
- package/dist/core/storage/session/history-pages.code.js +3 -0
- package/dist/core/storage/session/history-pages.code.js.map +1 -0
- package/dist/core/storage/session/history-pages.impl.js +35 -2
- package/dist/core/storage/session/history-pages.js +11 -7
- package/dist/core/storage/session/jsonl-entry-projection.code.js +3 -0
- package/dist/core/storage/session/jsonl-entry-projection.code.js.map +1 -0
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +35 -2
- package/dist/core/storage/session/jsonl-entry-projection.js +11 -7
- package/dist/core/storage/session/jsonl-session-store.code.js +3 -0
- package/dist/core/storage/session/jsonl-session-store.code.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.impl.js +35 -2
- package/dist/core/storage/session/jsonl-session-store.js +11 -7
- package/dist/core/storage/session/memory-session-store.code.js +3 -0
- package/dist/core/storage/session/memory-session-store.code.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.impl.js +35 -2
- package/dist/core/storage/session/memory-session-store.js +11 -7
- package/dist/core/storage/session/pinned-branch-resume.code.js +117 -0
- package/dist/core/storage/session/pinned-branch-resume.code.js.map +1 -0
- package/dist/core/storage/session/pinned-branch-resume.impl.js +33 -69
- package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -1
- package/dist/core/storage/session/pinned-branch-resume.js +11 -7
- package/dist/core/storage/session/released-history-files.code.js +465 -0
- package/dist/core/storage/session/released-history-files.code.js.map +1 -0
- package/dist/core/storage/session/released-history-files.impl.js +32 -461
- package/dist/core/storage/session/released-history-files.impl.js.map +1 -1
- package/dist/core/storage/session/released-history-files.js +11 -7
- package/dist/core/storage/session/resident-fork-rows.code.js +57 -0
- package/dist/core/storage/session/resident-fork-rows.code.js.map +1 -0
- package/dist/core/storage/session/resident-fork-rows.impl.js +32 -53
- package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -1
- package/dist/core/storage/session/resident-fork-rows.js +11 -7
- package/dist/core/storage/session/session-resume.code.js +3 -0
- package/dist/core/storage/session/session-resume.code.js.map +1 -0
- package/dist/core/storage/session/session-resume.impl.js +35 -2
- package/dist/core/storage/session/session-resume.js +11 -7
- package/dist/core/storage/session/snapshot-cut.code.js +3 -0
- package/dist/core/storage/session/snapshot-cut.code.js.map +1 -0
- package/dist/core/storage/session/snapshot-cut.impl.js +35 -2
- package/dist/core/storage/session/snapshot-cut.js +11 -7
- package/dist/core/storage/session/snapshot-history.code.js +107 -0
- package/dist/core/storage/session/snapshot-history.code.js.map +1 -0
- package/dist/core/storage/session/snapshot-history.impl.js +34 -60
- package/dist/core/storage/session/snapshot-history.impl.js.map +1 -1
- package/dist/core/storage/session/snapshot-history.js +11 -7
- package/dist/core/storage/session/sql-session-store.code.js +3 -0
- package/dist/core/storage/session/sql-session-store.code.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.impl.js +35 -2
- package/dist/core/storage/session/sql-session-store.js +11 -7
- package/dist/core/storage/session/tree-outline.code.js +3 -0
- package/dist/core/storage/session/tree-outline.code.js.map +1 -0
- package/dist/core/storage/session/tree-outline.impl.js +35 -2
- package/dist/core/storage/session/tree-outline.js +11 -7
- package/dist/core/storage/session/tree-presentation.code.js +342 -0
- package/dist/core/storage/session/tree-presentation.code.js.map +1 -0
- package/dist/core/storage/session/tree-presentation.impl.js +31 -337
- package/dist/core/storage/session/tree-presentation.impl.js.map +1 -1
- package/dist/core/storage/session/tree-presentation.js +11 -7
- package/dist/core/storage/session/types.d.ts +26 -0
- package/dist/core/storage/storage-status.code.js +3 -0
- package/dist/core/storage/storage-status.code.js.map +1 -0
- package/dist/core/storage/storage-status.impl.js +35 -2
- package/dist/core/storage/storage-status.js +11 -7
- package/dist/core/storage/team.code.js +3 -0
- package/dist/core/storage/team.code.js.map +1 -0
- package/dist/core/storage/team.impl.js +35 -2
- package/dist/core/storage/team.js +11 -7
- package/dist/core/structured-output/index.code.js +3 -0
- package/dist/core/structured-output/index.code.js.map +1 -0
- package/dist/core/structured-output/index.impl.js +35 -2
- package/dist/core/structured-output/index.js +11 -7
- package/dist/core/tasks/command-output.d.ts +4 -1
- package/dist/core/tasks/supervisor.d.ts +2 -0
- package/dist/core/tasks/task-completion-entry.code.js +254 -0
- package/dist/core/tasks/task-completion-entry.code.js.map +1 -0
- package/dist/core/tasks/task-completion-entry.impl.js +33 -251
- package/dist/core/tasks/task-completion-entry.impl.js.map +1 -1
- package/dist/core/tasks/task-completion-entry.js +11 -7
- package/dist/core/tasks/task-file-history.code.js +424 -0
- package/dist/core/tasks/task-file-history.code.js.map +1 -0
- package/dist/core/tasks/task-file-history.impl.js +32 -375
- package/dist/core/tasks/task-file-history.impl.js.map +1 -1
- package/dist/core/tasks/task-file-history.js +11 -7
- package/dist/core/tasks/{task-reference-archive.impl.js → task-reference-archive.code.js} +51 -6
- package/dist/core/tasks/{task-reference-archive.impl.js.map → task-reference-archive.code.js.map} +1 -1
- package/dist/core/tasks/task-reference-archive.js +11 -7
- package/dist/core/tasks/{task-reference-identity.impl.js → task-reference-identity.code.js} +1 -1
- package/dist/core/tasks/{task-reference-identity.impl.js.map → task-reference-identity.code.js.map} +1 -1
- package/dist/core/tasks/task-reference-identity.js +11 -7
- package/dist/core/tasks/task-reference-stream.code.js +3 -0
- package/dist/core/tasks/task-reference-stream.code.js.map +1 -0
- package/dist/core/tasks/task-reference-stream.impl.js +35 -2
- package/dist/core/tasks/task-reference-stream.js +11 -7
- package/dist/core/tasks/task-unsaved-answer.code.js +3 -0
- package/dist/core/tasks/task-unsaved-answer.code.js.map +1 -0
- package/dist/core/tasks/task-unsaved-answer.impl.js +35 -2
- package/dist/core/tasks/task-unsaved-answer.js +11 -7
- package/dist/core/tasks/task-view-source.code.js +3 -0
- package/dist/core/tasks/task-view-source.code.js.map +1 -0
- package/dist/core/tasks/task-view-source.d.ts +9 -0
- package/dist/core/tasks/task-view-source.impl.js +35 -2
- package/dist/core/tasks/task-view-source.js +12 -8
- package/dist/core/tools/read-url.code.js +1530 -0
- package/dist/core/tools/read-url.code.js.map +1 -0
- package/dist/core/tools/read-url.impl.js +30 -1524
- package/dist/core/tools/read-url.impl.js.map +1 -1
- package/dist/core/tools/read-url.js +11 -7
- package/dist/core/worktree-snapshot/blob-store.js +50 -5
- package/dist/core/worktree-snapshot/errors.code.js +6 -0
- package/dist/core/worktree-snapshot/errors.code.js.map +1 -0
- package/dist/core/worktree-snapshot/errors.impl.js +35 -5
- package/dist/core/worktree-snapshot/errors.js +11 -7
- package/dist/core/worktree-snapshot/session-index-reset.code.js +136 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +34 -134
- package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.js +11 -7
- package/dist/extensions/codemode/execute.code.js +618 -0
- package/dist/extensions/codemode/execute.code.js.map +1 -0
- package/dist/extensions/codemode/execute.impl.js +30 -612
- package/dist/extensions/codemode/execute.impl.js.map +1 -1
- package/dist/extensions/codemode/execute.js +11 -7
- package/dist/extensions/codemode/renderer.code.js +110 -0
- package/dist/extensions/codemode/renderer.code.js.map +1 -0
- package/dist/extensions/codemode/renderer.impl.js +33 -107
- package/dist/extensions/codemode/renderer.impl.js.map +1 -1
- package/dist/extensions/codemode/renderer.js +11 -7
- package/dist/extensions/mcp/cli.code.js +565 -0
- package/dist/extensions/mcp/cli.code.js.map +1 -0
- package/dist/extensions/mcp/cli.impl.js +32 -561
- package/dist/extensions/mcp/cli.impl.js.map +1 -1
- package/dist/extensions/mcp/cli.js +11 -7
- package/dist/extensions/mcp/cli.lazy.code.js +52 -0
- package/dist/extensions/mcp/cli.lazy.code.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.impl.js +36 -7
- package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -1
- package/dist/extensions/mcp/cli.lazy.js +11 -7
- package/dist/extensions/mcp/client/transports/stdio.d.ts +2 -0
- package/dist/extensions/mcp/runtime.code.js +5 -0
- package/dist/extensions/mcp/runtime.code.js.map +1 -0
- package/dist/extensions/mcp/runtime.impl.js +35 -4
- package/dist/extensions/mcp/runtime.js +11 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/main-first-time-setup.code.js +12 -0
- package/dist/main-first-time-setup.code.js.map +1 -0
- package/dist/main-first-time-setup.impl.js +35 -11
- package/dist/main-first-time-setup.impl.js.map +1 -1
- package/dist/main-first-time-setup.js +11 -7
- package/dist/main.d.ts +1 -1
- package/dist/main.js +2 -2
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +6 -1
- package/dist/modes/interactive/agent-view/contracts.d.ts +4 -0
- package/dist/modes/interactive/chat-reader-records.d.ts +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +338 -0
- package/dist/modes/interactive/components/stored-tree-view.code.js.map +1 -0
- package/dist/modes/interactive/components/stored-tree-view.impl.js +33 -290
- package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -1
- package/dist/modes/interactive/components/stored-tree-view.js +11 -7
- package/dist/modes/interactive/components/task-selection-state.d.ts +8 -3
- package/dist/modes/interactive/components/task-transcript-page.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +191 -0
- package/dist/modes/interactive/components/user-message-selector-archive.code.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +34 -189
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.js +11 -7
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode.js +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +4 -0
- package/dist/modes/interactive/interactive-render-chat.d.ts +22 -0
- package/dist/modes/interactive/interactive-startup.d.ts +2 -0
- package/dist/modes/interactive/program-status-reporter.d.ts +2 -1
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive/steering-queue-controller.d.ts +4 -0
- package/dist/modes/interactive/theme/theme-schema-factory.d.ts +26 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts +4 -5
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +30 -5
- package/dist/modes/interactive-engine/engine-prewarm.js +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +7 -0
- package/dist/modes/interactive-engine/protocol.d.ts +32 -1
- package/dist/modes/rpc/agent-view-rpc-types.d.ts +12 -1
- package/dist/modes/rpc/agent-view-rpc-types.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +3 -1
- package/dist/modes/rpc/rpc-types.d.ts +12 -0
- package/dist/package-manager-cli.code.js +1140 -0
- package/dist/package-manager-cli.code.js.map +1 -0
- package/dist/package-manager-cli.impl.js +36 -1067
- package/dist/package-manager-cli.impl.js.map +1 -1
- package/dist/package-manager-cli.js +11 -7
- package/dist/rpc-entry.js +2 -2
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/13.js +1 -0
- package/dist/startup-stages/2.js +1 -7
- package/dist/startup-stages/3.js +6 -2
- package/dist/startup-stages/4.js +2 -1
- package/dist/startup-stages/5.js +1 -7
- package/dist/startup-stages/6.js +7 -10
- package/dist/startup-stages/7.js +10 -3
- package/dist/startup-stages/8.js +3 -6
- package/dist/startup-stages/9.js +6 -1
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/canonical-path.js +2 -0
- package/dist/utils/canonical-path.js.map +1 -1
- package/dist/utils/child-process.d.ts +41 -1
- package/dist/utils/compile-cache-warmup-host.js +63 -18
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/credential-redaction.d.ts +50 -1
- package/dist/utils/interactive-engine-bootstrap.d.ts +2 -0
- package/dist/utils/interactive-engine-env.d.ts +2 -0
- package/dist/utils/memoize-async.d.ts +32 -0
- package/dist/utils/memoize-async.js +91 -0
- package/dist/utils/memoize-async.js.map +1 -0
- package/dist/utils/photon.js +19 -29
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts +7 -4
- package/dist/utils/startup-database-spare.code.js +108 -0
- package/dist/utils/startup-database-spare.code.js.map +1 -0
- package/dist/utils/startup-database-spare.impl.js +33 -105
- package/dist/utils/startup-database-spare.impl.js.map +1 -1
- package/dist/utils/startup-database-spare.js +11 -7
- package/dist/utils/tools-manager.code.js +3 -0
- package/dist/utils/tools-manager.code.js.map +1 -0
- package/dist/utils/tools-manager.impl.js +35 -2
- package/dist/utils/tools-manager.js +11 -7
- package/dist/utils/windows-cwd.js +585 -0
- package/dist/utils/windows-cwd.js.map +1 -0
- package/docs/extensions.md +1 -1
- package/docs/getting-started/installation.md +2 -0
- package/docs/intercom/operations.md +1 -0
- package/docs/reference/cli.md +1 -1
- package/package.json +24 -24
- package/dist/_shared/mode-shared-HP7GUA7J.js.map +0 -1
- package/dist/_shared/p1a-prewarm-YK3KDTLN.js.map +0 -1
- package/dist/_shared/p1b-elig-PXQA2FYP.js.map +0 -1
- package/dist/_shared/startup-0-0-X4NF3GKM.js.map +0 -1
- package/dist/_shared/startup-0-1-7QTG6VJZ.js.map +0 -1
- package/dist/_shared/startup-0-2-KFDYPDJK.js.map +0 -1
- package/dist/_shared/startup-8-1-KQJBDKRU.js.map +0 -1
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
Lease,
|
|
13
13
|
LeaseKey,
|
|
14
14
|
LeaseKind,
|
|
15
|
+
LeaseRenewResult,
|
|
15
16
|
LeaseState,
|
|
16
17
|
LeaseSubject,
|
|
17
18
|
StateStoreInvalidReason,
|
|
@@ -200,6 +201,42 @@ export async function openSqlBrokerLeaseStore(options: IntercomBrokerStateOption
|
|
|
200
201
|
return changes === 1 ? ({ status: "renewed" } as const) : stale(await holderOf(tx, lease.key));
|
|
201
202
|
});
|
|
202
203
|
},
|
|
204
|
+
async renewMany(requests) {
|
|
205
|
+
if (requests.length === 0) return [];
|
|
206
|
+
const results: Array<LeaseRenewResult | undefined> = new Array(requests.length);
|
|
207
|
+
let validCount = 0;
|
|
208
|
+
for (let i = 0; i < requests.length; i++) {
|
|
209
|
+
const { lease, subject } = requests[i]!;
|
|
210
|
+
const bad = validLease(lease);
|
|
211
|
+
if (bad !== undefined) {
|
|
212
|
+
results[i] = bad;
|
|
213
|
+
} else if (
|
|
214
|
+
subject !== undefined &&
|
|
215
|
+
(subject.kind !== lease.key.kind || keyId(keyOf(subject)) !== keyId(lease.key))
|
|
216
|
+
) {
|
|
217
|
+
results[i] = invalid("subject-key-mismatch");
|
|
218
|
+
} else {
|
|
219
|
+
validCount++;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (validCount === 0) return results as LeaseRenewResult[];
|
|
223
|
+
await database.transaction(async (tx) => {
|
|
224
|
+
for (let i = 0; i < requests.length; i++) {
|
|
225
|
+
if (results[i] !== undefined) continue;
|
|
226
|
+
const { lease, subject } = requests[i]!;
|
|
227
|
+
const { changes } =
|
|
228
|
+
subject === undefined
|
|
229
|
+
? await tx.run(`UPDATE ${table} SET renewed_at = ${nowMs} WHERE ${owned}`, ...ownedParams(lease))
|
|
230
|
+
: await tx.run(
|
|
231
|
+
`UPDATE ${table} SET renewed_at = ${nowMs}, subject_json = ? WHERE ${owned}`,
|
|
232
|
+
JSON.stringify(subject),
|
|
233
|
+
...ownedParams(lease),
|
|
234
|
+
);
|
|
235
|
+
results[i] = changes === 1 ? ({ status: "renewed" } as const) : stale(await holderOf(tx, lease.key));
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return results as LeaseRenewResult[];
|
|
239
|
+
},
|
|
203
240
|
async release(lease) {
|
|
204
241
|
const bad = validLease(lease);
|
|
205
242
|
if (bad !== undefined) return bad;
|
|
@@ -300,6 +300,13 @@ export async function openSqlOutboxStore(options: IntercomBrokerStateOptions): P
|
|
|
300
300
|
async claim(request) {
|
|
301
301
|
if (request.claimantId.length === 0) return invalid("empty-claimant-id");
|
|
302
302
|
if (request.targetIdentity.length === 0) return invalid("empty-target-identity");
|
|
303
|
+
// Fast read-only index check so empty scans (such as fan-out wake-up polls across idle sessions) never take a
|
|
304
|
+
// SQLite write lock. Linearizable: if a row commits after this snapshot, its enqueue writes a new wake-up hint.
|
|
305
|
+
const pending = await database.get(
|
|
306
|
+
`SELECT 1 AS present FROM ${table} WHERE target_identity = ? AND ${UNDELIVERED} LIMIT 1`,
|
|
307
|
+
request.targetIdentity,
|
|
308
|
+
);
|
|
309
|
+
if (pending === undefined) return { status: "claimed", rows: [] } as const;
|
|
303
310
|
return database.transaction(async (executor) => {
|
|
304
311
|
const records = await undelivered(executor, request.targetIdentity);
|
|
305
312
|
const other = records.find(
|
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import { lstatSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { lstat, realpath, stat } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { win32 } from "node:path";
|
|
5
|
+
|
|
6
|
+
/** Safe Win32 path length threshold for `CreateProcessW` `lpCurrentDirectory` without an extended `\\?\` prefix. */
|
|
7
|
+
const SAFE_WINDOWS_CWD_LENGTH = 248;
|
|
8
|
+
/** Default upper bound on async filesystem probes so slow or offline UNC/OneDrive paths never stall callers. */
|
|
9
|
+
export const DEFAULT_WINDOWS_CWD_TIMEOUT_MS = 100;
|
|
10
|
+
/** Maximum share of the timeout budget spent resolving protected directories' realpaths before probing local candidates. */
|
|
11
|
+
const MAX_PROTECTED_REALPATH_BUDGET_MS = 50;
|
|
12
|
+
|
|
13
|
+
interface ResolvedProtectedDir {
|
|
14
|
+
readonly lexical: string;
|
|
15
|
+
readonly real: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ResolvedCandidateDir {
|
|
19
|
+
readonly lexical: string;
|
|
20
|
+
readonly real: string | undefined;
|
|
21
|
+
readonly unverifiedLink: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SafeWindowsWorkingDirectoryOptions {
|
|
25
|
+
/** Optional explicit/resolved command path whose directory and drive root may be used as fallbacks. */
|
|
26
|
+
readonly commandPath?: string;
|
|
27
|
+
/** Additional folders (besides `process.cwd()`) that the child process must not run inside. */
|
|
28
|
+
readonly protectedDirs?: readonly (string | undefined)[];
|
|
29
|
+
/**
|
|
30
|
+
* Installation directories (e.g. extension dir, `dist/utils`, standalone executable dir) whose enclosing
|
|
31
|
+
* install roots—both lexical and canonical realpath (catching `subst` drives and junctions)—must be protected.
|
|
32
|
+
*/
|
|
33
|
+
readonly installDirs?: readonly (string | undefined)[];
|
|
34
|
+
/** When true (kill/stop commands), try `commandPath`'s directory ahead of `os.tmpdir()`. */
|
|
35
|
+
readonly preferCommandDir?: boolean;
|
|
36
|
+
/** Maximum time in milliseconds spent on async `stat`/`realpath`/`lstat` probes. Default: 100 ms. */
|
|
37
|
+
readonly timeoutMs?: number;
|
|
38
|
+
/** Optional abort signal to cancel pending timeout timers immediately when the caller no longer needs the result. */
|
|
39
|
+
readonly signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function isAsciiLetter(code: number): boolean {
|
|
43
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isDriveRootPrefix(slashed: string): boolean {
|
|
47
|
+
return slashed.length >= 3 && isAsciiLetter(slashed.charCodeAt(0)) && slashed[1] === ":" && slashed[2] === "\\";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function normalizeUncPath(slashed: string): string | undefined {
|
|
51
|
+
const rest = slashed.slice(2);
|
|
52
|
+
const firstSep = rest.indexOf("\\");
|
|
53
|
+
if (firstSep <= 0) return undefined;
|
|
54
|
+
const server = rest.slice(0, firstSep);
|
|
55
|
+
if (server === "." || server === "..") return undefined;
|
|
56
|
+
const afterServer = rest.slice(firstSep + 1);
|
|
57
|
+
const secondSep = afterServer.indexOf("\\");
|
|
58
|
+
const share = secondSep === -1 ? afterServer : afterServer.slice(0, secondSep);
|
|
59
|
+
if (share === "" || share === "." || share === "..") return undefined;
|
|
60
|
+
return win32.resolve(slashed);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Normalizes a fully-qualified Windows directory path for containment comparison.
|
|
65
|
+
*
|
|
66
|
+
* Strips extended-length and Win32 device prefixes (`\\?\`, `\\.\`, `\\?\UNC\`) so aliased paths compare
|
|
67
|
+
* equal to their standard counterparts, preserves trailing separators on drive and share roots, and
|
|
68
|
+
* rejects relative paths, bare drives (`C:`), drive-relative paths (`C:foo`), rooted-without-drive paths
|
|
69
|
+
* (`\Windows`), raw volume devices (`\\?\C:`, `\\?\Volume{...}` without `\`), incomplete UNC roots, and
|
|
70
|
+
* NUL bytes.
|
|
71
|
+
*/
|
|
72
|
+
export function normalizeWindowsPathForCompare(value: string): string | undefined {
|
|
73
|
+
if (value === "" || value.includes("\0")) return undefined;
|
|
74
|
+
const slashed = value.replaceAll("/", "\\");
|
|
75
|
+
if (slashed.startsWith("\\\\?\\") || slashed.startsWith("\\\\.\\")) {
|
|
76
|
+
const rest = slashed.slice(4);
|
|
77
|
+
if (rest.length >= 4 && rest.slice(0, 4).toLowerCase() === "unc\\") {
|
|
78
|
+
return normalizeUncPath(`\\\\${rest.slice(4)}`);
|
|
79
|
+
}
|
|
80
|
+
if (isDriveRootPrefix(rest)) {
|
|
81
|
+
return win32.resolve(rest);
|
|
82
|
+
}
|
|
83
|
+
if (rest.length > 9 && rest.slice(0, 7).toLowerCase() === "volume{") {
|
|
84
|
+
const sepIndex = rest.indexOf("\\");
|
|
85
|
+
if (sepIndex <= 8 || rest[sepIndex - 1] !== "}") return undefined;
|
|
86
|
+
const root = `\\\\?\\${rest.slice(0, sepIndex + 1)}`;
|
|
87
|
+
const tail = rest.slice(sepIndex + 1);
|
|
88
|
+
const normalizedTail = tail === "" ? "" : win32.resolve("C:\\", tail).slice(3);
|
|
89
|
+
return `${root}${normalizedTail}`;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
if (slashed.startsWith("\\\\")) {
|
|
94
|
+
return normalizeUncPath(slashed);
|
|
95
|
+
}
|
|
96
|
+
if (isDriveRootPrefix(slashed)) {
|
|
97
|
+
return win32.resolve(slashed);
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Formats a normalized comparison path for Win32 filesystem / `CreateProcessW` APIs:
|
|
104
|
+
* keeps short paths (< 248 chars) plain and ensures paths >= 248 chars carry the proper
|
|
105
|
+
* extended-length prefix (`\\?\` for drive paths, `\\?\UNC\server\share\...` for UNC paths).
|
|
106
|
+
*/
|
|
107
|
+
export function toSpawnWindowsPath(comparePath: string): string {
|
|
108
|
+
if (comparePath.startsWith("\\\\?\\") || comparePath.length < SAFE_WINDOWS_CWD_LENGTH) {
|
|
109
|
+
return comparePath;
|
|
110
|
+
}
|
|
111
|
+
if (comparePath.startsWith("\\\\")) {
|
|
112
|
+
return `\\\\?\\UNC\\${comparePath.slice(2)}`;
|
|
113
|
+
}
|
|
114
|
+
return `\\\\?\\${comparePath}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function isAbsoluteWindowsPath(value: string): boolean {
|
|
118
|
+
return normalizeWindowsPathForCompare(value) !== undefined;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Returns the normalized drive, UNC share, or volume root (always ending with `\`) for an absolute Windows path. */
|
|
122
|
+
export function windowsDriveRoot(value: string | undefined): string | undefined {
|
|
123
|
+
if (value === undefined) return undefined;
|
|
124
|
+
const normalized = normalizeWindowsPathForCompare(value);
|
|
125
|
+
if (normalized === undefined) return undefined;
|
|
126
|
+
if (normalized.startsWith("\\\\?\\")) {
|
|
127
|
+
const sepIndex = normalized.indexOf("\\", 4);
|
|
128
|
+
return sepIndex === -1 ? undefined : normalized.slice(0, sepIndex + 1);
|
|
129
|
+
}
|
|
130
|
+
const root = win32.parse(normalized).root;
|
|
131
|
+
if (root.length <= 1) return undefined;
|
|
132
|
+
return root.endsWith("\\") ? root : `${root}\\`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function isDriveRootWindowsPath(normalized: string): boolean {
|
|
136
|
+
const root = windowsDriveRoot(normalized);
|
|
137
|
+
return root !== undefined && normalized.toLowerCase() === root.toLowerCase();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function addNonRootWindowsDir(target: string[], seen: Set<string>, candidate: string): void {
|
|
141
|
+
const normalized = normalizeWindowsPathForCompare(candidate);
|
|
142
|
+
if (normalized === undefined || isDriveRootWindowsPath(normalized)) return;
|
|
143
|
+
const key = normalized.toLowerCase();
|
|
144
|
+
if (seen.has(key)) return;
|
|
145
|
+
seen.add(key);
|
|
146
|
+
target.push(normalized);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Returns the install-root directories enclosing `entryDir` that background processes must not keep as their working
|
|
151
|
+
* directory on Windows (npm/pnpm/bun package root + `@scope`/`node_modules`, standalone binary `versions/<ver>` +
|
|
152
|
+
* install root, or `dist/utils` package root). Never promotes a drive or share root to an inferred protected ancestor.
|
|
153
|
+
*/
|
|
154
|
+
export function collectInstallProtectedDirs(entryDir: string | undefined): string[] {
|
|
155
|
+
if (entryDir === undefined || entryDir === "") return [];
|
|
156
|
+
const normalized = normalizeWindowsPathForCompare(entryDir);
|
|
157
|
+
if (normalized === undefined) return [];
|
|
158
|
+
const result: string[] = [normalized];
|
|
159
|
+
const seen = new Set<string>([normalized.toLowerCase()]);
|
|
160
|
+
|
|
161
|
+
const add = (dir: string) => addNonRootWindowsDir(result, seen, dir);
|
|
162
|
+
const parent = win32.dirname(normalized);
|
|
163
|
+
const parentName = win32.basename(parent).toLowerCase();
|
|
164
|
+
const ownName = win32.basename(normalized).toLowerCase();
|
|
165
|
+
const grandParent = win32.dirname(parent);
|
|
166
|
+
const grandParentName = win32.basename(grandParent).toLowerCase();
|
|
167
|
+
|
|
168
|
+
let packageDir = normalized;
|
|
169
|
+
if (parentName === "builtin" && grandParentName === "dist") {
|
|
170
|
+
// `<packageDir>\dist\builtin\<name>` (npm/pnpm/bun install layout)
|
|
171
|
+
packageDir = win32.dirname(grandParent);
|
|
172
|
+
add(grandParent);
|
|
173
|
+
add(packageDir);
|
|
174
|
+
} else if (parentName === "builtin") {
|
|
175
|
+
// `<installRoot>\versions\<ver>\builtin\<name>` or `<installRoot>\current\builtin\<name>`
|
|
176
|
+
const versionDir = grandParent;
|
|
177
|
+
packageDir = versionDir;
|
|
178
|
+
add(versionDir);
|
|
179
|
+
const versionDirName = win32.basename(versionDir).toLowerCase();
|
|
180
|
+
const versionsParent = win32.dirname(versionDir);
|
|
181
|
+
if (win32.basename(versionsParent).toLowerCase() === "versions") {
|
|
182
|
+
add(versionsParent);
|
|
183
|
+
add(win32.dirname(versionsParent));
|
|
184
|
+
} else if (versionDirName === "current" || versionDirName === "atomic-current") {
|
|
185
|
+
add(versionsParent);
|
|
186
|
+
}
|
|
187
|
+
} else if (ownName === "utils" && parentName === "dist") {
|
|
188
|
+
// `<packageDir>\dist\utils` (compile-cache warmup / startup-prefetch helpers)
|
|
189
|
+
packageDir = grandParent;
|
|
190
|
+
add(parent);
|
|
191
|
+
add(packageDir);
|
|
192
|
+
} else if (parentName === "versions") {
|
|
193
|
+
// `<installRoot>\versions\<ver>` (standalone binary executable directory)
|
|
194
|
+
add(parent);
|
|
195
|
+
add(grandParent);
|
|
196
|
+
} else if (ownName === "current" || ownName === "atomic-current") {
|
|
197
|
+
add(parent);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const pkgParent = win32.dirname(packageDir);
|
|
201
|
+
const pkgParentName = win32.basename(pkgParent).toLowerCase();
|
|
202
|
+
const pkgGrandParent = win32.dirname(pkgParent);
|
|
203
|
+
const pkgGrandParentName = win32.basename(pkgGrandParent).toLowerCase();
|
|
204
|
+
if (pkgParentName.startsWith("@") && pkgGrandParentName === "node_modules") {
|
|
205
|
+
add(pkgParent);
|
|
206
|
+
add(pkgGrandParent);
|
|
207
|
+
} else if (pkgParentName === "node_modules") {
|
|
208
|
+
add(pkgParent);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function isSubpathOrSame(folderNormalized: string, candidateNormalized: string): boolean {
|
|
215
|
+
const rel = win32.relative(folderNormalized.toLowerCase(), candidateNormalized.toLowerCase());
|
|
216
|
+
return rel !== ".." && !rel.startsWith("..\\") && !win32.isAbsolute(rel);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function conflictsWithNormalizedFolder(folderNormalized: string, candidateNormalized: string): boolean {
|
|
220
|
+
if (isDriveRootWindowsPath(folderNormalized)) {
|
|
221
|
+
return folderNormalized.toLowerCase() === candidateNormalized.toLowerCase();
|
|
222
|
+
}
|
|
223
|
+
return isSubpathOrSame(folderNormalized, candidateNormalized);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function isInsideProtectedFolder(folder: ResolvedProtectedDir, candidate: ResolvedCandidateDir): boolean {
|
|
227
|
+
if (candidate.unverifiedLink) return true;
|
|
228
|
+
if (folder.real !== undefined && candidate.real !== undefined) {
|
|
229
|
+
if (isDriveRootWindowsPath(folder.real)) {
|
|
230
|
+
return folder.real.toLowerCase() === candidate.real.toLowerCase();
|
|
231
|
+
}
|
|
232
|
+
if (isSubpathOrSame(folder.real, candidate.real)) return true;
|
|
233
|
+
if (!isDriveRootWindowsPath(folder.lexical) && isSubpathOrSame(folder.lexical, candidate.lexical)) return true;
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
if (conflictsWithNormalizedFolder(folder.lexical, candidate.lexical)) return true;
|
|
237
|
+
if (folder.real !== undefined && conflictsWithNormalizedFolder(folder.real, candidate.lexical)) return true;
|
|
238
|
+
if (candidate.real !== undefined && conflictsWithNormalizedFolder(folder.lexical, candidate.real)) return true;
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function preferredCandidatePath(candidate: ResolvedCandidateDir): string {
|
|
243
|
+
return toSpawnWindowsPath(candidate.real ?? candidate.lexical);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Win32 `CreateProcessW` rejects `lpCurrentDirectory` >= `MAX_PATH` (even with `\\?\`) when Windows' default
|
|
248
|
+
* `LongPathsEnabled = 0` is in effect. Prefer a short (< 248-char) verified directory outside the project whenever
|
|
249
|
+
* one is available so host commands work across both default Windows installs and `LongPathsEnabled = 1` hosts.
|
|
250
|
+
*/
|
|
251
|
+
function isShortWindowsSpawnPath(spawnPath: string): boolean {
|
|
252
|
+
return !spawnPath.startsWith("\\\\?\\") && spawnPath.length < SAFE_WINDOWS_CWD_LENGTH;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function probePathFor(rawDir: string, lexical: string): string {
|
|
256
|
+
if (rawDir.length >= SAFE_WINDOWS_CWD_LENGTH && !rawDir.startsWith("\\\\?\\")) {
|
|
257
|
+
return toSpawnWindowsPath(lexical);
|
|
258
|
+
}
|
|
259
|
+
return rawDir;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function readProcessCwd(): string | undefined {
|
|
263
|
+
try {
|
|
264
|
+
return process.cwd();
|
|
265
|
+
} catch {
|
|
266
|
+
return undefined;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function collectRawProtectedDirs(extra?: readonly (string | undefined)[]): string[] {
|
|
271
|
+
const result: string[] = [];
|
|
272
|
+
const seen = new Set<string>();
|
|
273
|
+
const add = (dir: string | undefined) => {
|
|
274
|
+
if (dir === undefined) return;
|
|
275
|
+
const normalized = normalizeWindowsPathForCompare(dir);
|
|
276
|
+
if (normalized === undefined) return;
|
|
277
|
+
const key = normalized.toLowerCase();
|
|
278
|
+
if (seen.has(key)) return;
|
|
279
|
+
seen.add(key);
|
|
280
|
+
result.push(dir);
|
|
281
|
+
};
|
|
282
|
+
add(readProcessCwd());
|
|
283
|
+
for (const dir of extra ?? []) add(dir);
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function buildCandidates(
|
|
288
|
+
protectedDirs: readonly ResolvedProtectedDir[],
|
|
289
|
+
commandPath: string | undefined,
|
|
290
|
+
preferCommandDir: boolean,
|
|
291
|
+
): readonly string[] {
|
|
292
|
+
const tempDir = tmpdir();
|
|
293
|
+
const normalizedCommand = commandPath === undefined ? undefined : normalizeWindowsPathForCompare(commandPath);
|
|
294
|
+
const commandDir = normalizedCommand === undefined ? undefined : win32.dirname(normalizedCommand);
|
|
295
|
+
const commandRoot = windowsDriveRoot(normalizedCommand);
|
|
296
|
+
const tempRoot = windowsDriveRoot(tempDir);
|
|
297
|
+
const protectedRoots: (string | undefined)[] = [];
|
|
298
|
+
for (const folder of protectedDirs) {
|
|
299
|
+
protectedRoots.push(windowsDriveRoot(folder.real));
|
|
300
|
+
protectedRoots.push(windowsDriveRoot(folder.lexical));
|
|
301
|
+
}
|
|
302
|
+
const middle = preferCommandDir ? [commandDir, tempDir] : [tempDir, commandDir];
|
|
303
|
+
const rawList: readonly (string | undefined)[] = [
|
|
304
|
+
process.env.SystemRoot,
|
|
305
|
+
process.env.windir,
|
|
306
|
+
"C:\\Windows",
|
|
307
|
+
...middle,
|
|
308
|
+
commandRoot,
|
|
309
|
+
tempRoot,
|
|
310
|
+
...protectedRoots,
|
|
311
|
+
windowsDriveRoot(process.env.SystemRoot),
|
|
312
|
+
windowsDriveRoot(process.env.windir),
|
|
313
|
+
"C:\\",
|
|
314
|
+
];
|
|
315
|
+
const deduped: string[] = [];
|
|
316
|
+
const seen = new Set<string>();
|
|
317
|
+
for (const item of rawList) {
|
|
318
|
+
if (item === undefined || item === "") continue;
|
|
319
|
+
const key = item.toLowerCase();
|
|
320
|
+
if (seen.has(key)) continue;
|
|
321
|
+
seen.add(key);
|
|
322
|
+
deduped.push(item);
|
|
323
|
+
}
|
|
324
|
+
return deduped;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function boundedFsCall<T>(work: Promise<T>, budgetMs: number, signal?: AbortSignal): Promise<T | undefined> {
|
|
328
|
+
if (signal?.aborted || budgetMs <= 0) {
|
|
329
|
+
void work.catch(() => {});
|
|
330
|
+
return Promise.resolve(undefined);
|
|
331
|
+
}
|
|
332
|
+
return new Promise<T | undefined>((resolve) => {
|
|
333
|
+
let settled = false;
|
|
334
|
+
const done = (value: T | undefined) => {
|
|
335
|
+
if (settled) return;
|
|
336
|
+
settled = true;
|
|
337
|
+
clearTimeout(timer);
|
|
338
|
+
signal?.removeEventListener("abort", onAbort);
|
|
339
|
+
resolve(value);
|
|
340
|
+
};
|
|
341
|
+
const onAbort = () => done(undefined);
|
|
342
|
+
const timer = setTimeout(() => done(undefined), budgetMs);
|
|
343
|
+
timer.unref?.();
|
|
344
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
345
|
+
work.then(
|
|
346
|
+
(value) => done(value),
|
|
347
|
+
() => done(undefined),
|
|
348
|
+
);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function tryRealPathSync(dir: string): string | undefined {
|
|
353
|
+
try {
|
|
354
|
+
const native = realpathSync.native;
|
|
355
|
+
return normalizeWindowsPathForCompare(typeof native === "function" ? native(dir) : realpathSync(dir));
|
|
356
|
+
} catch {
|
|
357
|
+
try {
|
|
358
|
+
return normalizeWindowsPathForCompare(realpathSync(dir));
|
|
359
|
+
} catch {
|
|
360
|
+
return undefined;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function resolveProtectedDirSync(rawDir: string): ResolvedProtectedDir | undefined {
|
|
366
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
367
|
+
if (lexical === undefined) return undefined;
|
|
368
|
+
return { lexical, real: tryRealPathSync(probePathFor(rawDir, lexical)) };
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function resolveCandidateDirSync(rawDir: string): ResolvedCandidateDir | undefined {
|
|
372
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
373
|
+
if (lexical === undefined) return undefined;
|
|
374
|
+
const probe = probePathFor(rawDir, lexical);
|
|
375
|
+
try {
|
|
376
|
+
if (!statSync(probe).isDirectory()) return undefined;
|
|
377
|
+
} catch {
|
|
378
|
+
return undefined;
|
|
379
|
+
}
|
|
380
|
+
const real = tryRealPathSync(probe);
|
|
381
|
+
let unverifiedLink = false;
|
|
382
|
+
if (real === undefined) {
|
|
383
|
+
try {
|
|
384
|
+
unverifiedLink = lstatSync(probe).isSymbolicLink();
|
|
385
|
+
} catch {
|
|
386
|
+
unverifiedLink = false;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return { lexical, real, unverifiedLink };
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Synchronously selects a safe existing Windows working directory outside `process.cwd()` (and any extra
|
|
394
|
+
* protected folders), resolving junctions, symlinks, 8.3 short names, `subst` drives, and extended-length
|
|
395
|
+
* aliases while preserving `\\?\` / `\\?\UNC\` on paths >= 248 chars and handling drive roots explicitly.
|
|
396
|
+
*/
|
|
397
|
+
export function resolveSafeWindowsWorkingDirectorySync(
|
|
398
|
+
options: SafeWindowsWorkingDirectoryOptions = {},
|
|
399
|
+
): string | undefined {
|
|
400
|
+
const protectedDirs: ResolvedProtectedDir[] = [];
|
|
401
|
+
const seenProtected = new Set<string>();
|
|
402
|
+
const addProtected = (dir: ResolvedProtectedDir | undefined) => {
|
|
403
|
+
if (dir === undefined) return;
|
|
404
|
+
const key = `${dir.lexical.toLowerCase()}\0${dir.real?.toLowerCase() ?? ""}`;
|
|
405
|
+
if (seenProtected.has(key)) return;
|
|
406
|
+
seenProtected.add(key);
|
|
407
|
+
protectedDirs.push(dir);
|
|
408
|
+
};
|
|
409
|
+
for (const raw of collectRawProtectedDirs(options.protectedDirs)) {
|
|
410
|
+
addProtected(resolveProtectedDirSync(raw));
|
|
411
|
+
}
|
|
412
|
+
for (const rawInstall of options.installDirs ?? []) {
|
|
413
|
+
if (rawInstall === undefined) continue;
|
|
414
|
+
const resolvedEntry = resolveProtectedDirSync(rawInstall);
|
|
415
|
+
addProtected(resolvedEntry);
|
|
416
|
+
for (const dir of collectInstallProtectedDirs(rawInstall)) {
|
|
417
|
+
addProtected(resolveProtectedDirSync(dir));
|
|
418
|
+
}
|
|
419
|
+
if (resolvedEntry?.real !== undefined) {
|
|
420
|
+
for (const dir of collectInstallProtectedDirs(resolvedEntry.real)) {
|
|
421
|
+
addProtected({ lexical: dir, real: tryRealPathSync(probePathFor(dir, dir)) ?? dir });
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);
|
|
426
|
+
let longOutsideFallback: string | undefined;
|
|
427
|
+
let shortFallback: string | undefined;
|
|
428
|
+
let anyFallback: string | undefined;
|
|
429
|
+
for (const rawCandidate of candidates) {
|
|
430
|
+
const candidate = resolveCandidateDirSync(rawCandidate);
|
|
431
|
+
if (candidate === undefined) continue;
|
|
432
|
+
const chosen = preferredCandidatePath(candidate);
|
|
433
|
+
const isShort = isShortWindowsSpawnPath(chosen);
|
|
434
|
+
const insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));
|
|
435
|
+
if (!insideAny) {
|
|
436
|
+
if (isShort) return chosen;
|
|
437
|
+
longOutsideFallback ??= chosen;
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (isShort) shortFallback ??= chosen;
|
|
441
|
+
anyFallback ??= chosen;
|
|
442
|
+
}
|
|
443
|
+
return longOutsideFallback ?? shortFallback ?? anyFallback;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
async function tryRealPathAsync(dir: string, deadline: number, signal?: AbortSignal): Promise<string | undefined> {
|
|
447
|
+
const resolved = await boundedFsCall(realpath(dir), deadline - Date.now(), signal);
|
|
448
|
+
return resolved === undefined ? undefined : normalizeWindowsPathForCompare(resolved);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async function resolveProtectedDirAsync(
|
|
452
|
+
rawDir: string,
|
|
453
|
+
deadline: number,
|
|
454
|
+
signal?: AbortSignal,
|
|
455
|
+
): Promise<ResolvedProtectedDir | undefined> {
|
|
456
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
457
|
+
if (lexical === undefined) return undefined;
|
|
458
|
+
const real = await tryRealPathAsync(probePathFor(rawDir, lexical), deadline, signal);
|
|
459
|
+
return { lexical, real };
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
async function resolveCandidateDirAsync(
|
|
463
|
+
rawDir: string,
|
|
464
|
+
deadline: number,
|
|
465
|
+
signal?: AbortSignal,
|
|
466
|
+
): Promise<ResolvedCandidateDir | undefined> {
|
|
467
|
+
if (signal?.aborted || deadline - Date.now() <= 0) return undefined;
|
|
468
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
469
|
+
if (lexical === undefined) return undefined;
|
|
470
|
+
const probe = probePathFor(rawDir, lexical);
|
|
471
|
+
const stats = await boundedFsCall(stat(probe), deadline - Date.now(), signal);
|
|
472
|
+
if (!stats?.isDirectory()) return undefined;
|
|
473
|
+
const real = await tryRealPathAsync(probe, deadline, signal);
|
|
474
|
+
let unverifiedLink = false;
|
|
475
|
+
if (real === undefined && !signal?.aborted && deadline - Date.now() > 0) {
|
|
476
|
+
const linkStats = await boundedFsCall(lstat(probe), deadline - Date.now(), signal);
|
|
477
|
+
unverifiedLink = linkStats?.isSymbolicLink() === true;
|
|
478
|
+
}
|
|
479
|
+
return { lexical, real, unverifiedLink };
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Asynchronously selects a safe existing Windows working directory outside `process.cwd()` (and any extra
|
|
484
|
+
* protected folders) within a bounded time budget without blocking the event loop.
|
|
485
|
+
*/
|
|
486
|
+
export async function resolveSafeWindowsWorkingDirectoryAsync(
|
|
487
|
+
options: SafeWindowsWorkingDirectoryOptions = {},
|
|
488
|
+
): Promise<string | undefined> {
|
|
489
|
+
const { signal } = options;
|
|
490
|
+
if (signal?.aborted) return undefined;
|
|
491
|
+
const totalMs = Math.max(0, options.timeoutMs ?? DEFAULT_WINDOWS_CWD_TIMEOUT_MS);
|
|
492
|
+
const startedAt = Date.now();
|
|
493
|
+
const overallDeadline = startedAt + totalMs;
|
|
494
|
+
const protectedBudgetMs = Math.min(MAX_PROTECTED_REALPATH_BUDGET_MS, Math.floor(totalMs / 2));
|
|
495
|
+
const protectedDeadline = startedAt + protectedBudgetMs;
|
|
496
|
+
|
|
497
|
+
const installEntryKeys = new Set<string>();
|
|
498
|
+
for (const raw of options.installDirs ?? []) {
|
|
499
|
+
if (raw === undefined) continue;
|
|
500
|
+
const normalized = normalizeWindowsPathForCompare(raw);
|
|
501
|
+
if (normalized !== undefined) installEntryKeys.add(normalized.toLowerCase());
|
|
502
|
+
}
|
|
503
|
+
const installLexical = (options.installDirs ?? []).flatMap((raw) => collectInstallProtectedDirs(raw));
|
|
504
|
+
const rawProtected = collectRawProtectedDirs([...(options.protectedDirs ?? []), ...installLexical]);
|
|
505
|
+
const resolvedProtected = await Promise.all(
|
|
506
|
+
rawProtected.map((raw) => resolveProtectedDirAsync(raw, protectedDeadline, signal)),
|
|
507
|
+
);
|
|
508
|
+
if (signal?.aborted) return undefined;
|
|
509
|
+
const protectedDirs: ResolvedProtectedDir[] = [];
|
|
510
|
+
const seenProtected = new Set<string>();
|
|
511
|
+
const addProtected = (dir: ResolvedProtectedDir | undefined) => {
|
|
512
|
+
if (dir === undefined) return;
|
|
513
|
+
const key = `${dir.lexical.toLowerCase()}\0${dir.real?.toLowerCase() ?? ""}`;
|
|
514
|
+
if (seenProtected.has(key)) return;
|
|
515
|
+
seenProtected.add(key);
|
|
516
|
+
protectedDirs.push(dir);
|
|
517
|
+
};
|
|
518
|
+
for (const dir of resolvedProtected) {
|
|
519
|
+
addProtected(dir);
|
|
520
|
+
if (dir !== undefined && dir.real !== undefined && installEntryKeys.has(dir.lexical.toLowerCase())) {
|
|
521
|
+
for (const canonicalAncestor of collectInstallProtectedDirs(dir.real)) {
|
|
522
|
+
addProtected({ lexical: canonicalAncestor, real: canonicalAncestor });
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);
|
|
527
|
+
let longOutsideFallback: string | undefined;
|
|
528
|
+
let shortFallback: string | undefined;
|
|
529
|
+
let anyFallback: string | undefined;
|
|
530
|
+
for (const rawCandidate of candidates) {
|
|
531
|
+
if (signal?.aborted || overallDeadline - Date.now() <= 0) break;
|
|
532
|
+
const candidate = await resolveCandidateDirAsync(rawCandidate, overallDeadline, signal);
|
|
533
|
+
if (candidate === undefined) continue;
|
|
534
|
+
const chosen = preferredCandidatePath(candidate);
|
|
535
|
+
const isShort = isShortWindowsSpawnPath(chosen);
|
|
536
|
+
const insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));
|
|
537
|
+
if (!insideAny) {
|
|
538
|
+
if (isShort) return chosen;
|
|
539
|
+
longOutsideFallback ??= chosen;
|
|
540
|
+
continue;
|
|
541
|
+
}
|
|
542
|
+
if (isShort) shortFallback ??= chosen;
|
|
543
|
+
anyFallback ??= chosen;
|
|
544
|
+
}
|
|
545
|
+
return longOutsideFallback ?? shortFallback ?? anyFallback;
|
|
546
|
+
}
|