@bastani/atomic 0.10.4-alpha.2 → 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 +238 -0
- package/dist/_shared/chunk-CDOYTDYM.js +4 -0
- package/dist/_shared/chunk-CDOYTDYM.js.map +1 -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} +528 -321
- 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 +59 -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 +46 -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/CHANGELOG.md +12 -0
- 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 +36 -0
- package/dist/cli/auth-cli.impl.js.map +1 -0
- package/dist/cli/auth-cli.js +30 -1096
- package/dist/cli/auth-cli.js.map +1 -1
- 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 +36 -0
- package/dist/cli/blueprint-command.impl.js.map +1 -0
- package/dist/cli/blueprint-command.js +30 -900
- package/dist/cli/blueprint-command.js.map +1 -1
- 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 +36 -0
- package/dist/cli/intercom-command.impl.js.map +1 -0
- package/dist/cli/intercom-command.js +33 -105
- package/dist/cli/intercom-command.js.map +1 -1
- 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 +36 -0
- package/dist/cli/list-models.impl.js.map +1 -0
- package/dist/cli/list-models.js +33 -57
- package/dist/cli/list-models.js.map +1 -1
- 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 +36 -0
- package/dist/cli/session-picker.impl.js.map +1 -0
- package/dist/cli/session-picker.js +33 -52
- package/dist/cli/session-picker.js.map +1 -1
- 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 +36 -0
- package/dist/cli/startup-ui.impl.js.map +1 -0
- package/dist/cli/startup-ui.js +35 -4
- 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 +36 -0
- package/dist/cli/storage-command.impl.js.map +1 -0
- package/dist/cli/storage-command.js +35 -2
- 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 +36 -0
- package/dist/cli/storage-search-session.impl.js.map +1 -0
- package/dist/cli/storage-search-session.js +33 -186
- package/dist/cli/storage-search-session.js.map +1 -1
- 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 +36 -0
- package/dist/cli/team-command.impl.js.map +1 -0
- package/dist/cli/team-command.js +32 -213
- package/dist/cli/team-command.js.map +1 -1
- 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 +36 -0
- package/dist/core/debug.impl.js.map +1 -0
- package/dist/core/debug.js +35 -2
- 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 +36 -0
- package/dist/core/export-html/card-projection.impl.js.map +1 -0
- package/dist/core/export-html/card-projection.js +34 -255
- package/dist/core/export-html/card-projection.js.map +1 -1
- 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 +36 -0
- package/dist/core/export-html/index.impl.js.map +1 -0
- package/dist/core/export-html/index.js +30 -604
- package/dist/core/export-html/index.js.map +1 -1
- 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 +36 -0
- package/dist/core/export-html/json-spans.impl.js.map +1 -0
- package/dist/core/export-html/json-spans.js +35 -2
- 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 +36 -0
- package/dist/core/export-html/oversized-render-inputs.impl.js.map +1 -0
- package/dist/core/export-html/oversized-render-inputs.js +31 -120
- package/dist/core/export-html/oversized-render-inputs.js.map +1 -1
- 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 +36 -0
- package/dist/core/export-html/tool-renderer.impl.js.map +1 -0
- package/dist/core/export-html/tool-renderer.js +33 -347
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- 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 +36 -0
- package/dist/core/extensions/jiti-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-loader.js +35 -2
- 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 +36 -0
- package/dist/core/extensions/jiti-static-loader.impl.js.map +1 -0
- package/dist/core/extensions/jiti-static-loader.js +35 -2
- 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 +36 -0
- package/dist/core/extensions/loader-host-modules.impl.js.map +1 -0
- package/dist/core/extensions/loader-host-modules.js +35 -2
- 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 +36 -0
- package/dist/core/intercom-broker-control-host.impl.js.map +1 -0
- package/dist/core/intercom-broker-control-host.js +35 -4
- 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 +36 -0
- package/dist/core/intercom-broker-control.impl.js.map +1 -0
- package/dist/core/intercom-broker-control.js +35 -17
- package/dist/core/intercom-broker-control.js.map +1 -1
- 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 +36 -0
- package/dist/core/package-manager-storage-adapters.impl.js.map +1 -0
- package/dist/core/package-manager-storage-adapters.js +35 -2
- 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 +36 -0
- package/dist/core/sdk.impl.js.map +1 -0
- package/dist/core/sdk.js +35 -8
- 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 +36 -0
- package/dist/core/session-manager-list.impl.js.map +1 -0
- package/dist/core/session-manager-list.js +35 -2
- 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 +36 -0
- package/dist/core/session-manager.impl.js.map +1 -0
- package/dist/core/session-manager.js +35 -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 +36 -0
- package/dist/core/session-storage.impl.js.map +1 -0
- package/dist/core/session-storage.js +35 -2
- 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 +36 -0
- package/dist/core/storage/offline-snapshot-file.impl.js.map +1 -0
- package/dist/core/storage/offline-snapshot-file.js +33 -34
- package/dist/core/storage/offline-snapshot-file.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/branch-fork-source.impl.js.map +1 -0
- package/dist/core/storage/session/branch-fork-source.js +32 -97
- package/dist/core/storage/session/branch-fork-source.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/card-view.impl.js.map +1 -0
- package/dist/core/storage/session/card-view.js +34 -58
- package/dist/core/storage/session/card-view.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/child-reader.impl.js.map +1 -0
- package/dist/core/storage/session/child-reader.js +33 -91
- package/dist/core/storage/session/child-reader.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/chunked-resume-projection.impl.js.map +1 -0
- package/dist/core/storage/session/chunked-resume-projection.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/expanded-child-details.impl.js.map +1 -0
- package/dist/core/storage/session/expanded-child-details.js +31 -634
- package/dist/core/storage/session/expanded-child-details.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/fork-row-bytes.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-bytes.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/fork-row-index.impl.js.map +1 -0
- package/dist/core/storage/session/fork-row-index.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/fork-staging.impl.js.map +1 -0
- package/dist/core/storage/session/fork-staging.js +30 -574
- package/dist/core/storage/session/fork-staging.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/fork-window.impl.js.map +1 -0
- package/dist/core/storage/session/fork-window.js +30 -471
- package/dist/core/storage/session/fork-window.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/history-pages.impl.js.map +1 -0
- package/dist/core/storage/session/history-pages.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/jsonl-entry-projection.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-entry-projection.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/jsonl-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/jsonl-session-store.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/memory-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/memory-session-store.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/pinned-branch-resume.impl.js.map +1 -0
- package/dist/core/storage/session/pinned-branch-resume.js +33 -69
- package/dist/core/storage/session/pinned-branch-resume.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/released-history-files.impl.js.map +1 -0
- package/dist/core/storage/session/released-history-files.js +32 -461
- package/dist/core/storage/session/released-history-files.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/resident-fork-rows.impl.js.map +1 -0
- package/dist/core/storage/session/resident-fork-rows.js +32 -53
- package/dist/core/storage/session/resident-fork-rows.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/session-resume.impl.js.map +1 -0
- package/dist/core/storage/session/session-resume.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/snapshot-cut.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-cut.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/snapshot-history.impl.js.map +1 -0
- package/dist/core/storage/session/snapshot-history.js +34 -60
- package/dist/core/storage/session/snapshot-history.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/session/sql-session-store.impl.js.map +1 -0
- package/dist/core/storage/session/sql-session-store.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/tree-outline.impl.js.map +1 -0
- package/dist/core/storage/session/tree-outline.js +35 -2
- 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 +36 -0
- package/dist/core/storage/session/tree-presentation.impl.js.map +1 -0
- package/dist/core/storage/session/tree-presentation.js +31 -337
- package/dist/core/storage/session/tree-presentation.js.map +1 -1
- 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 +36 -0
- package/dist/core/storage/storage-status.impl.js.map +1 -0
- package/dist/core/storage/storage-status.js +35 -2
- 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 +36 -0
- package/dist/core/storage/team.impl.js.map +1 -0
- package/dist/core/storage/team.js +35 -2
- 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 +36 -0
- package/dist/core/structured-output/index.impl.js.map +1 -0
- package/dist/core/structured-output/index.js +35 -2
- 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 +36 -0
- package/dist/core/tasks/task-completion-entry.impl.js.map +1 -0
- package/dist/core/tasks/task-completion-entry.js +33 -251
- package/dist/core/tasks/task-completion-entry.js.map +1 -1
- 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 +36 -0
- package/dist/core/tasks/task-file-history.impl.js.map +1 -0
- package/dist/core/tasks/task-file-history.js +32 -375
- package/dist/core/tasks/task-file-history.js.map +1 -1
- package/dist/core/tasks/task-reference-archive.code.js +514 -0
- package/dist/core/tasks/task-reference-archive.code.js.map +1 -0
- package/dist/core/tasks/task-reference-archive.js +34 -467
- package/dist/core/tasks/task-reference-archive.js.map +1 -1
- package/dist/core/tasks/task-reference-identity.code.js +164 -0
- package/dist/core/tasks/task-reference-identity.code.js.map +1 -0
- package/dist/core/tasks/task-reference-identity.js +32 -160
- package/dist/core/tasks/task-reference-identity.js.map +1 -1
- 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 +36 -0
- package/dist/core/tasks/task-reference-stream.impl.js.map +1 -0
- package/dist/core/tasks/task-reference-stream.js +35 -2
- 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 +36 -0
- package/dist/core/tasks/task-unsaved-answer.impl.js.map +1 -0
- package/dist/core/tasks/task-unsaved-answer.js +35 -2
- 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 +36 -0
- package/dist/core/tasks/task-view-source.impl.js.map +1 -0
- package/dist/core/tasks/task-view-source.js +35 -2
- 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 +36 -0
- package/dist/core/tools/read-url.impl.js.map +1 -0
- package/dist/core/tools/read-url.js +30 -1524
- package/dist/core/tools/read-url.js.map +1 -1
- 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 +36 -0
- package/dist/core/worktree-snapshot/errors.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/errors.js +35 -5
- 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 +36 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js.map +1 -0
- package/dist/core/worktree-snapshot/session-index-reset.js +34 -134
- package/dist/core/worktree-snapshot/session-index-reset.js.map +1 -1
- 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 +36 -0
- package/dist/extensions/codemode/execute.impl.js.map +1 -0
- package/dist/extensions/codemode/execute.js +30 -612
- package/dist/extensions/codemode/execute.js.map +1 -1
- 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 +36 -0
- package/dist/extensions/codemode/renderer.impl.js.map +1 -0
- package/dist/extensions/codemode/renderer.js +33 -107
- package/dist/extensions/codemode/renderer.js.map +1 -1
- 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 +36 -0
- package/dist/extensions/mcp/cli.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.js +32 -561
- package/dist/extensions/mcp/cli.js.map +1 -1
- 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 -0
- package/dist/extensions/mcp/cli.lazy.impl.js.map +1 -0
- package/dist/extensions/mcp/cli.lazy.js +36 -7
- package/dist/extensions/mcp/cli.lazy.js.map +1 -1
- 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 +36 -0
- package/dist/extensions/mcp/runtime.impl.js.map +1 -0
- package/dist/extensions/mcp/runtime.js +35 -4
- 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 +36 -0
- package/dist/main-first-time-setup.impl.js.map +1 -0
- package/dist/main-first-time-setup.js +35 -11
- package/dist/main-first-time-setup.js.map +1 -1
- 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 +36 -0
- package/dist/modes/interactive/components/stored-tree-view.impl.js.map +1 -0
- package/dist/modes/interactive/components/stored-tree-view.js +33 -290
- package/dist/modes/interactive/components/stored-tree-view.js.map +1 -1
- 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 +36 -0
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector-archive.js +34 -189
- package/dist/modes/interactive/components/user-message-selector-archive.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode-deps.js +4 -0
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -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 -0
- package/dist/package-manager-cli.impl.js.map +1 -0
- package/dist/package-manager-cli.js +36 -1067
- package/dist/package-manager-cli.js.map +1 -1
- 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 +36 -0
- package/dist/utils/startup-database-spare.impl.js.map +1 -0
- package/dist/utils/startup-database-spare.js +33 -105
- package/dist/utils/startup-database-spare.js.map +1 -1
- 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 +36 -0
- package/dist/utils/tools-manager.impl.js.map +1 -0
- package/dist/utils/tools-manager.js +35 -2
- 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 +2 -2
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools-manager.impl.js","sources":[],"names":[],"mappings":""}
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// Written by the build (scripts/in-place-update-gate.mjs): when this module's code cannot load in a process of an earlier release
|
|
2
|
+
// that an in-place update left running, the process is told to restart.
|
|
3
|
+
let module;
|
|
4
|
+
try {
|
|
5
|
+
module = await import("./tools-manager.code.js");
|
|
6
|
+
} catch (error) {
|
|
7
|
+
const root = new URL("../", import.meta.url);
|
|
8
|
+
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
+
const key = `${root.href}#0.10.5-alpha.1`;
|
|
10
|
+
let release = releases.get(key);
|
|
11
|
+
if (release === undefined) {
|
|
12
|
+
const current = (async () => {
|
|
13
|
+
for (const path of ["modes/interactive/interactive-mode-deps.js","_shared/chunk-CDOYTDYM.js","_shared/p0-cli-GUFK7TPN.js"]) {
|
|
14
|
+
try {
|
|
15
|
+
const held = await import(new URL(path, root).href);
|
|
16
|
+
if (typeof held.VERSION === "string") return { version: held.VERSION, name: held.APP_NAME };
|
|
17
|
+
} catch {
|
|
18
|
+
// Not a file this process can load: the next.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
})().then((found) => {
|
|
23
|
+
if (found === undefined && releases.get(key) === current) releases.delete(key);
|
|
24
|
+
return found;
|
|
25
|
+
});
|
|
26
|
+
releases.set(key, current);
|
|
27
|
+
release = current;
|
|
28
|
+
}
|
|
29
|
+
const running = await release;
|
|
30
|
+
if (running === undefined || running.version === "0.10.5-alpha.1") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.5-alpha.1 while this session was running; restart it to keep using this feature.", {
|
|
32
|
+
cause: error,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
export const { GIT_RELEASE, detectLinuxLibc, ensureTool, getGitDistributionTarget, getGitInstallDir, getGitReleaseMarker, getGitShellEnvironment, getGitShellEnvironmentAsync, getGitStatus, getGitStatusAsync, getLatestVersion, getToolEnv, getToolPath, parseGitVersion, plainStatMtimeMs, resetGitProvisionStateForTest, resolveGit, resolveGitSync, resolveInstalledGit, withGitProvisionSettingsForTest } = module;
|
|
3
36
|
//# sourceMappingURL=tools-manager.js.map
|
|
@@ -0,0 +1,585 @@
|
|
|
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
|
+
/** Safe Win32 path length threshold for `CreateProcessW` `lpCurrentDirectory` without an extended `\\?\` prefix. */
|
|
6
|
+
const SAFE_WINDOWS_CWD_LENGTH = 248;
|
|
7
|
+
/** Default upper bound on async filesystem probes so slow or offline UNC/OneDrive paths never stall callers. */
|
|
8
|
+
export const DEFAULT_WINDOWS_CWD_TIMEOUT_MS = 100;
|
|
9
|
+
/** Maximum share of the timeout budget spent resolving protected directories' realpaths before probing local candidates. */
|
|
10
|
+
const MAX_PROTECTED_REALPATH_BUDGET_MS = 50;
|
|
11
|
+
function isAsciiLetter(code) {
|
|
12
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
13
|
+
}
|
|
14
|
+
function isDriveRootPrefix(slashed) {
|
|
15
|
+
return slashed.length >= 3 && isAsciiLetter(slashed.charCodeAt(0)) && slashed[1] === ":" && slashed[2] === "\\";
|
|
16
|
+
}
|
|
17
|
+
function normalizeUncPath(slashed) {
|
|
18
|
+
const rest = slashed.slice(2);
|
|
19
|
+
const firstSep = rest.indexOf("\\");
|
|
20
|
+
if (firstSep <= 0)
|
|
21
|
+
return undefined;
|
|
22
|
+
const server = rest.slice(0, firstSep);
|
|
23
|
+
if (server === "." || server === "..")
|
|
24
|
+
return undefined;
|
|
25
|
+
const afterServer = rest.slice(firstSep + 1);
|
|
26
|
+
const secondSep = afterServer.indexOf("\\");
|
|
27
|
+
const share = secondSep === -1 ? afterServer : afterServer.slice(0, secondSep);
|
|
28
|
+
if (share === "" || share === "." || share === "..")
|
|
29
|
+
return undefined;
|
|
30
|
+
return win32.resolve(slashed);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Normalizes a fully-qualified Windows directory path for containment comparison.
|
|
34
|
+
*
|
|
35
|
+
* Strips extended-length and Win32 device prefixes (`\\?\`, `\\.\`, `\\?\UNC\`) so aliased paths compare
|
|
36
|
+
* equal to their standard counterparts, preserves trailing separators on drive and share roots, and
|
|
37
|
+
* rejects relative paths, bare drives (`C:`), drive-relative paths (`C:foo`), rooted-without-drive paths
|
|
38
|
+
* (`\Windows`), raw volume devices (`\\?\C:`, `\\?\Volume{...}` without `\`), incomplete UNC roots, and
|
|
39
|
+
* NUL bytes.
|
|
40
|
+
*/
|
|
41
|
+
export function normalizeWindowsPathForCompare(value) {
|
|
42
|
+
if (value === "" || value.includes("\0"))
|
|
43
|
+
return undefined;
|
|
44
|
+
const slashed = value.replaceAll("/", "\\");
|
|
45
|
+
if (slashed.startsWith("\\\\?\\") || slashed.startsWith("\\\\.\\")) {
|
|
46
|
+
const rest = slashed.slice(4);
|
|
47
|
+
if (rest.length >= 4 && rest.slice(0, 4).toLowerCase() === "unc\\") {
|
|
48
|
+
return normalizeUncPath(`\\\\${rest.slice(4)}`);
|
|
49
|
+
}
|
|
50
|
+
if (isDriveRootPrefix(rest)) {
|
|
51
|
+
return win32.resolve(rest);
|
|
52
|
+
}
|
|
53
|
+
if (rest.length > 9 && rest.slice(0, 7).toLowerCase() === "volume{") {
|
|
54
|
+
const sepIndex = rest.indexOf("\\");
|
|
55
|
+
if (sepIndex <= 8 || rest[sepIndex - 1] !== "}")
|
|
56
|
+
return undefined;
|
|
57
|
+
const root = `\\\\?\\${rest.slice(0, sepIndex + 1)}`;
|
|
58
|
+
const tail = rest.slice(sepIndex + 1);
|
|
59
|
+
const normalizedTail = tail === "" ? "" : win32.resolve("C:\\", tail).slice(3);
|
|
60
|
+
return `${root}${normalizedTail}`;
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
if (slashed.startsWith("\\\\")) {
|
|
65
|
+
return normalizeUncPath(slashed);
|
|
66
|
+
}
|
|
67
|
+
if (isDriveRootPrefix(slashed)) {
|
|
68
|
+
return win32.resolve(slashed);
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Formats a normalized comparison path for Win32 filesystem / `CreateProcessW` APIs:
|
|
74
|
+
* keeps short paths (< 248 chars) plain and ensures paths >= 248 chars carry the proper
|
|
75
|
+
* extended-length prefix (`\\?\` for drive paths, `\\?\UNC\server\share\...` for UNC paths).
|
|
76
|
+
*/
|
|
77
|
+
export function toSpawnWindowsPath(comparePath) {
|
|
78
|
+
if (comparePath.startsWith("\\\\?\\") || comparePath.length < SAFE_WINDOWS_CWD_LENGTH) {
|
|
79
|
+
return comparePath;
|
|
80
|
+
}
|
|
81
|
+
if (comparePath.startsWith("\\\\")) {
|
|
82
|
+
return `\\\\?\\UNC\\${comparePath.slice(2)}`;
|
|
83
|
+
}
|
|
84
|
+
return `\\\\?\\${comparePath}`;
|
|
85
|
+
}
|
|
86
|
+
export function isAbsoluteWindowsPath(value) {
|
|
87
|
+
return normalizeWindowsPathForCompare(value) !== undefined;
|
|
88
|
+
}
|
|
89
|
+
/** Returns the normalized drive, UNC share, or volume root (always ending with `\`) for an absolute Windows path. */
|
|
90
|
+
export function windowsDriveRoot(value) {
|
|
91
|
+
if (value === undefined)
|
|
92
|
+
return undefined;
|
|
93
|
+
const normalized = normalizeWindowsPathForCompare(value);
|
|
94
|
+
if (normalized === undefined)
|
|
95
|
+
return undefined;
|
|
96
|
+
if (normalized.startsWith("\\\\?\\")) {
|
|
97
|
+
const sepIndex = normalized.indexOf("\\", 4);
|
|
98
|
+
return sepIndex === -1 ? undefined : normalized.slice(0, sepIndex + 1);
|
|
99
|
+
}
|
|
100
|
+
const root = win32.parse(normalized).root;
|
|
101
|
+
if (root.length <= 1)
|
|
102
|
+
return undefined;
|
|
103
|
+
return root.endsWith("\\") ? root : `${root}\\`;
|
|
104
|
+
}
|
|
105
|
+
export function isDriveRootWindowsPath(normalized) {
|
|
106
|
+
const root = windowsDriveRoot(normalized);
|
|
107
|
+
return root !== undefined && normalized.toLowerCase() === root.toLowerCase();
|
|
108
|
+
}
|
|
109
|
+
function addNonRootWindowsDir(target, seen, candidate) {
|
|
110
|
+
const normalized = normalizeWindowsPathForCompare(candidate);
|
|
111
|
+
if (normalized === undefined || isDriveRootWindowsPath(normalized))
|
|
112
|
+
return;
|
|
113
|
+
const key = normalized.toLowerCase();
|
|
114
|
+
if (seen.has(key))
|
|
115
|
+
return;
|
|
116
|
+
seen.add(key);
|
|
117
|
+
target.push(normalized);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns the install-root directories enclosing `entryDir` that background helpers must not keep as their working
|
|
121
|
+
* directory on Windows (npm/pnpm/bun package root + `@scope`/`node_modules`, standalone binary `versions/<ver>` +
|
|
122
|
+
* install root, or `dist/utils` package root). Never promotes a drive or share root to an inferred protected ancestor.
|
|
123
|
+
*/
|
|
124
|
+
export function collectInstallProtectedDirs(entryDir) {
|
|
125
|
+
if (entryDir === undefined || entryDir === "")
|
|
126
|
+
return [];
|
|
127
|
+
const normalized = normalizeWindowsPathForCompare(entryDir);
|
|
128
|
+
if (normalized === undefined)
|
|
129
|
+
return [];
|
|
130
|
+
const result = [normalized];
|
|
131
|
+
const seen = new Set([normalized.toLowerCase()]);
|
|
132
|
+
const add = (dir) => addNonRootWindowsDir(result, seen, dir);
|
|
133
|
+
const parent = win32.dirname(normalized);
|
|
134
|
+
const parentName = win32.basename(parent).toLowerCase();
|
|
135
|
+
const ownName = win32.basename(normalized).toLowerCase();
|
|
136
|
+
const grandParent = win32.dirname(parent);
|
|
137
|
+
const grandParentName = win32.basename(grandParent).toLowerCase();
|
|
138
|
+
let packageDir = normalized;
|
|
139
|
+
if (parentName === "builtin" && grandParentName === "dist") {
|
|
140
|
+
packageDir = win32.dirname(grandParent);
|
|
141
|
+
add(grandParent);
|
|
142
|
+
add(packageDir);
|
|
143
|
+
}
|
|
144
|
+
else if (parentName === "builtin") {
|
|
145
|
+
const versionDir = grandParent;
|
|
146
|
+
packageDir = versionDir;
|
|
147
|
+
add(versionDir);
|
|
148
|
+
const versionDirName = win32.basename(versionDir).toLowerCase();
|
|
149
|
+
const versionsParent = win32.dirname(versionDir);
|
|
150
|
+
if (win32.basename(versionsParent).toLowerCase() === "versions") {
|
|
151
|
+
add(versionsParent);
|
|
152
|
+
add(win32.dirname(versionsParent));
|
|
153
|
+
}
|
|
154
|
+
else if (versionDirName === "current" || versionDirName === "atomic-current") {
|
|
155
|
+
add(versionsParent);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else if (ownName === "utils" && parentName === "dist") {
|
|
159
|
+
packageDir = grandParent;
|
|
160
|
+
add(parent);
|
|
161
|
+
add(packageDir);
|
|
162
|
+
}
|
|
163
|
+
else if (parentName === "versions") {
|
|
164
|
+
add(parent);
|
|
165
|
+
add(grandParent);
|
|
166
|
+
}
|
|
167
|
+
else if (ownName === "current" || ownName === "atomic-current") {
|
|
168
|
+
add(parent);
|
|
169
|
+
}
|
|
170
|
+
const pkgParent = win32.dirname(packageDir);
|
|
171
|
+
const pkgParentName = win32.basename(pkgParent).toLowerCase();
|
|
172
|
+
const pkgGrandParent = win32.dirname(pkgParent);
|
|
173
|
+
const pkgGrandParentName = win32.basename(pkgGrandParent).toLowerCase();
|
|
174
|
+
if (pkgParentName.startsWith("@") && pkgGrandParentName === "node_modules") {
|
|
175
|
+
add(pkgParent);
|
|
176
|
+
add(pkgGrandParent);
|
|
177
|
+
}
|
|
178
|
+
else if (pkgParentName === "node_modules") {
|
|
179
|
+
add(pkgParent);
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
function isSubpathOrSame(folderNormalized, candidateNormalized) {
|
|
184
|
+
const rel = win32.relative(folderNormalized.toLowerCase(), candidateNormalized.toLowerCase());
|
|
185
|
+
return rel !== ".." && !rel.startsWith("..\\") && !win32.isAbsolute(rel);
|
|
186
|
+
}
|
|
187
|
+
function conflictsWithNormalizedFolder(folderNormalized, candidateNormalized) {
|
|
188
|
+
if (isDriveRootWindowsPath(folderNormalized)) {
|
|
189
|
+
return folderNormalized.toLowerCase() === candidateNormalized.toLowerCase();
|
|
190
|
+
}
|
|
191
|
+
return isSubpathOrSame(folderNormalized, candidateNormalized);
|
|
192
|
+
}
|
|
193
|
+
function isInsideProtectedFolder(folder, candidate) {
|
|
194
|
+
if (candidate.unverifiedLink)
|
|
195
|
+
return true;
|
|
196
|
+
if (folder.real !== undefined && candidate.real !== undefined) {
|
|
197
|
+
if (isDriveRootWindowsPath(folder.real)) {
|
|
198
|
+
return folder.real.toLowerCase() === candidate.real.toLowerCase();
|
|
199
|
+
}
|
|
200
|
+
if (isSubpathOrSame(folder.real, candidate.real))
|
|
201
|
+
return true;
|
|
202
|
+
if (!isDriveRootWindowsPath(folder.lexical) && isSubpathOrSame(folder.lexical, candidate.lexical))
|
|
203
|
+
return true;
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
if (conflictsWithNormalizedFolder(folder.lexical, candidate.lexical))
|
|
207
|
+
return true;
|
|
208
|
+
if (folder.real !== undefined && conflictsWithNormalizedFolder(folder.real, candidate.lexical))
|
|
209
|
+
return true;
|
|
210
|
+
if (candidate.real !== undefined && conflictsWithNormalizedFolder(folder.lexical, candidate.real))
|
|
211
|
+
return true;
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
function preferredCandidatePath(candidate) {
|
|
215
|
+
return toSpawnWindowsPath(candidate.real ?? candidate.lexical);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Win32 `CreateProcessW` rejects `lpCurrentDirectory` >= `MAX_PATH` (even with `\\?\`) when Windows' default
|
|
219
|
+
* `LongPathsEnabled = 0` is in effect. Prefer a short (< 248-char) verified directory outside the project whenever
|
|
220
|
+
* one is available so kill commands work across both default Windows installs and `LongPathsEnabled = 1` hosts.
|
|
221
|
+
*/
|
|
222
|
+
function isShortWindowsSpawnPath(spawnPath) {
|
|
223
|
+
return !spawnPath.startsWith("\\\\?\\") && spawnPath.length < SAFE_WINDOWS_CWD_LENGTH;
|
|
224
|
+
}
|
|
225
|
+
function probePathFor(rawDir, lexical) {
|
|
226
|
+
if (rawDir.length >= SAFE_WINDOWS_CWD_LENGTH && !rawDir.startsWith("\\\\?\\")) {
|
|
227
|
+
return toSpawnWindowsPath(lexical);
|
|
228
|
+
}
|
|
229
|
+
return rawDir;
|
|
230
|
+
}
|
|
231
|
+
function readProcessCwd() {
|
|
232
|
+
try {
|
|
233
|
+
return process.cwd();
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return undefined;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function collectRawProtectedDirs(extra) {
|
|
240
|
+
const result = [];
|
|
241
|
+
const seen = new Set();
|
|
242
|
+
const add = (dir) => {
|
|
243
|
+
if (dir === undefined)
|
|
244
|
+
return;
|
|
245
|
+
const normalized = normalizeWindowsPathForCompare(dir);
|
|
246
|
+
if (normalized === undefined)
|
|
247
|
+
return;
|
|
248
|
+
const key = normalized.toLowerCase();
|
|
249
|
+
if (seen.has(key))
|
|
250
|
+
return;
|
|
251
|
+
seen.add(key);
|
|
252
|
+
result.push(dir);
|
|
253
|
+
};
|
|
254
|
+
add(readProcessCwd());
|
|
255
|
+
for (const dir of extra ?? [])
|
|
256
|
+
add(dir);
|
|
257
|
+
return result;
|
|
258
|
+
}
|
|
259
|
+
function dedupeCandidates(rawList) {
|
|
260
|
+
const deduped = [];
|
|
261
|
+
const seen = new Set();
|
|
262
|
+
for (const item of rawList) {
|
|
263
|
+
if (item === undefined || item === "")
|
|
264
|
+
continue;
|
|
265
|
+
const key = item.toLowerCase();
|
|
266
|
+
if (seen.has(key))
|
|
267
|
+
continue;
|
|
268
|
+
seen.add(key);
|
|
269
|
+
deduped.push(item);
|
|
270
|
+
}
|
|
271
|
+
return deduped;
|
|
272
|
+
}
|
|
273
|
+
function buildCandidates(protectedDirs, commandPath, preferCommandDir) {
|
|
274
|
+
const tempDir = tmpdir();
|
|
275
|
+
const normalizedCommand = commandPath === undefined ? undefined : normalizeWindowsPathForCompare(commandPath);
|
|
276
|
+
const commandDir = normalizedCommand === undefined ? undefined : win32.dirname(normalizedCommand);
|
|
277
|
+
const commandRoot = windowsDriveRoot(normalizedCommand);
|
|
278
|
+
const tempRoot = windowsDriveRoot(tempDir);
|
|
279
|
+
const protectedRoots = [];
|
|
280
|
+
for (const folder of protectedDirs) {
|
|
281
|
+
protectedRoots.push(windowsDriveRoot(folder.real));
|
|
282
|
+
protectedRoots.push(windowsDriveRoot(folder.lexical));
|
|
283
|
+
}
|
|
284
|
+
const middle = preferCommandDir ? [commandDir, tempDir] : [tempDir, commandDir];
|
|
285
|
+
return dedupeCandidates([
|
|
286
|
+
process.env.SystemRoot,
|
|
287
|
+
process.env.windir,
|
|
288
|
+
"C:\\Windows",
|
|
289
|
+
...middle,
|
|
290
|
+
commandRoot,
|
|
291
|
+
tempRoot,
|
|
292
|
+
...protectedRoots,
|
|
293
|
+
windowsDriveRoot(process.env.SystemRoot),
|
|
294
|
+
windowsDriveRoot(process.env.windir),
|
|
295
|
+
"C:\\",
|
|
296
|
+
]);
|
|
297
|
+
}
|
|
298
|
+
function boundedFsCall(work, budgetMs, signal) {
|
|
299
|
+
if (signal?.aborted || budgetMs <= 0) {
|
|
300
|
+
void work.catch(() => { });
|
|
301
|
+
return Promise.resolve(undefined);
|
|
302
|
+
}
|
|
303
|
+
return new Promise((resolve) => {
|
|
304
|
+
let settled = false;
|
|
305
|
+
const done = (value) => {
|
|
306
|
+
if (settled)
|
|
307
|
+
return;
|
|
308
|
+
settled = true;
|
|
309
|
+
clearTimeout(timer);
|
|
310
|
+
signal?.removeEventListener("abort", onAbort);
|
|
311
|
+
resolve(value);
|
|
312
|
+
};
|
|
313
|
+
const onAbort = () => done(undefined);
|
|
314
|
+
const timer = setTimeout(() => done(undefined), budgetMs);
|
|
315
|
+
timer.unref?.();
|
|
316
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
317
|
+
work.then((value) => done(value), () => done(undefined));
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function tryRealPathSync(dir) {
|
|
321
|
+
try {
|
|
322
|
+
const native = realpathSync.native;
|
|
323
|
+
return normalizeWindowsPathForCompare(typeof native === "function" ? native(dir) : realpathSync(dir));
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
try {
|
|
327
|
+
return normalizeWindowsPathForCompare(realpathSync(dir));
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function resolveProtectedDirSync(rawDir) {
|
|
335
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
336
|
+
if (lexical === undefined)
|
|
337
|
+
return undefined;
|
|
338
|
+
return { lexical, real: tryRealPathSync(probePathFor(rawDir, lexical)) };
|
|
339
|
+
}
|
|
340
|
+
function resolveCandidateDirSync(rawDir) {
|
|
341
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
342
|
+
if (lexical === undefined)
|
|
343
|
+
return undefined;
|
|
344
|
+
const probe = probePathFor(rawDir, lexical);
|
|
345
|
+
try {
|
|
346
|
+
if (!statSync(probe).isDirectory())
|
|
347
|
+
return undefined;
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
352
|
+
const real = tryRealPathSync(probe);
|
|
353
|
+
let unverifiedLink = false;
|
|
354
|
+
if (real === undefined) {
|
|
355
|
+
try {
|
|
356
|
+
unverifiedLink = lstatSync(probe).isSymbolicLink();
|
|
357
|
+
}
|
|
358
|
+
catch {
|
|
359
|
+
unverifiedLink = false;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return { lexical, real, unverifiedLink };
|
|
363
|
+
}
|
|
364
|
+
/** Synchronously resolves a safe Windows working directory using `statSync` and `realpathSync.native`. */
|
|
365
|
+
export function resolveSafeWindowsWorkingDirectorySync(options = {}) {
|
|
366
|
+
const protectedDirs = [];
|
|
367
|
+
const seenProtected = new Set();
|
|
368
|
+
const addProtected = (dir) => {
|
|
369
|
+
if (dir === undefined)
|
|
370
|
+
return;
|
|
371
|
+
const key = `${dir.lexical.toLowerCase()}\0${dir.real?.toLowerCase() ?? ""}`;
|
|
372
|
+
if (seenProtected.has(key))
|
|
373
|
+
return;
|
|
374
|
+
seenProtected.add(key);
|
|
375
|
+
protectedDirs.push(dir);
|
|
376
|
+
};
|
|
377
|
+
for (const raw of collectRawProtectedDirs(options.protectedDirs)) {
|
|
378
|
+
addProtected(resolveProtectedDirSync(raw));
|
|
379
|
+
}
|
|
380
|
+
for (const rawInstall of options.installDirs ?? []) {
|
|
381
|
+
if (rawInstall === undefined)
|
|
382
|
+
continue;
|
|
383
|
+
const resolvedEntry = resolveProtectedDirSync(rawInstall);
|
|
384
|
+
addProtected(resolvedEntry);
|
|
385
|
+
for (const dir of collectInstallProtectedDirs(rawInstall)) {
|
|
386
|
+
addProtected(resolveProtectedDirSync(dir));
|
|
387
|
+
}
|
|
388
|
+
if (resolvedEntry?.real !== undefined) {
|
|
389
|
+
for (const dir of collectInstallProtectedDirs(resolvedEntry.real)) {
|
|
390
|
+
addProtected({ lexical: dir, real: tryRealPathSync(probePathFor(dir, dir)) ?? dir });
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
const candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);
|
|
395
|
+
let longOutsideFallback;
|
|
396
|
+
let shortFallback;
|
|
397
|
+
let anyFallback;
|
|
398
|
+
for (const rawCandidate of candidates) {
|
|
399
|
+
const candidate = resolveCandidateDirSync(rawCandidate);
|
|
400
|
+
if (candidate === undefined)
|
|
401
|
+
continue;
|
|
402
|
+
const chosen = preferredCandidatePath(candidate);
|
|
403
|
+
const isShort = isShortWindowsSpawnPath(chosen);
|
|
404
|
+
const insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));
|
|
405
|
+
if (!insideAny) {
|
|
406
|
+
if (isShort)
|
|
407
|
+
return chosen;
|
|
408
|
+
longOutsideFallback ??= chosen;
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (isShort)
|
|
412
|
+
shortFallback ??= chosen;
|
|
413
|
+
anyFallback ??= chosen;
|
|
414
|
+
}
|
|
415
|
+
return longOutsideFallback ?? shortFallback ?? anyFallback;
|
|
416
|
+
}
|
|
417
|
+
async function tryRealPathAsync(dir, deadline, signal) {
|
|
418
|
+
const resolved = await boundedFsCall(realpath(dir), deadline - Date.now(), signal);
|
|
419
|
+
return resolved === undefined ? undefined : normalizeWindowsPathForCompare(resolved);
|
|
420
|
+
}
|
|
421
|
+
async function resolveProtectedDirAsync(rawDir, deadline, signal) {
|
|
422
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
423
|
+
if (lexical === undefined)
|
|
424
|
+
return undefined;
|
|
425
|
+
const real = await tryRealPathAsync(probePathFor(rawDir, lexical), deadline, signal);
|
|
426
|
+
return { lexical, real };
|
|
427
|
+
}
|
|
428
|
+
async function resolveCandidateDirAsync(rawDir, deadline, signal) {
|
|
429
|
+
if (signal?.aborted || deadline - Date.now() <= 0)
|
|
430
|
+
return undefined;
|
|
431
|
+
const lexical = normalizeWindowsPathForCompare(rawDir);
|
|
432
|
+
if (lexical === undefined)
|
|
433
|
+
return undefined;
|
|
434
|
+
const probe = probePathFor(rawDir, lexical);
|
|
435
|
+
const stats = await boundedFsCall(stat(probe), deadline - Date.now(), signal);
|
|
436
|
+
if (!stats?.isDirectory())
|
|
437
|
+
return undefined;
|
|
438
|
+
const real = await tryRealPathAsync(probe, deadline, signal);
|
|
439
|
+
let unverifiedLink = false;
|
|
440
|
+
if (real === undefined && !signal?.aborted && deadline - Date.now() > 0) {
|
|
441
|
+
const linkStats = await boundedFsCall(lstat(probe), deadline - Date.now(), signal);
|
|
442
|
+
unverifiedLink = linkStats?.isSymbolicLink() === true;
|
|
443
|
+
}
|
|
444
|
+
return { lexical, real, unverifiedLink };
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Asynchronously selects a safe existing Windows working directory outside `process.cwd()` (and any extra
|
|
448
|
+
* protected folders) within a bounded time budget without blocking the event loop.
|
|
449
|
+
*/
|
|
450
|
+
export async function resolveSafeWindowsWorkingDirectoryAsync(options = {}) {
|
|
451
|
+
const { signal } = options;
|
|
452
|
+
if (signal?.aborted)
|
|
453
|
+
return undefined;
|
|
454
|
+
const totalMs = Math.max(0, options.timeoutMs ?? DEFAULT_WINDOWS_CWD_TIMEOUT_MS);
|
|
455
|
+
const startedAt = Date.now();
|
|
456
|
+
const overallDeadline = startedAt + totalMs;
|
|
457
|
+
const protectedBudgetMs = Math.min(MAX_PROTECTED_REALPATH_BUDGET_MS, Math.floor(totalMs / 2));
|
|
458
|
+
const protectedDeadline = startedAt + protectedBudgetMs;
|
|
459
|
+
const installEntryKeys = new Set();
|
|
460
|
+
for (const raw of options.installDirs ?? []) {
|
|
461
|
+
if (raw === undefined)
|
|
462
|
+
continue;
|
|
463
|
+
const normalized = normalizeWindowsPathForCompare(raw);
|
|
464
|
+
if (normalized !== undefined)
|
|
465
|
+
installEntryKeys.add(normalized.toLowerCase());
|
|
466
|
+
}
|
|
467
|
+
const installLexical = (options.installDirs ?? []).flatMap((raw) => collectInstallProtectedDirs(raw));
|
|
468
|
+
const rawProtected = collectRawProtectedDirs([...(options.protectedDirs ?? []), ...installLexical]);
|
|
469
|
+
const resolvedProtected = await Promise.all(rawProtected.map((raw) => resolveProtectedDirAsync(raw, protectedDeadline, signal)));
|
|
470
|
+
if (signal?.aborted)
|
|
471
|
+
return undefined;
|
|
472
|
+
const protectedDirs = [];
|
|
473
|
+
const seenProtected = new Set();
|
|
474
|
+
const addProtected = (dir) => {
|
|
475
|
+
if (dir === undefined)
|
|
476
|
+
return;
|
|
477
|
+
const key = `${dir.lexical.toLowerCase()}\0${dir.real?.toLowerCase() ?? ""}`;
|
|
478
|
+
if (seenProtected.has(key))
|
|
479
|
+
return;
|
|
480
|
+
seenProtected.add(key);
|
|
481
|
+
protectedDirs.push(dir);
|
|
482
|
+
};
|
|
483
|
+
for (const dir of resolvedProtected) {
|
|
484
|
+
addProtected(dir);
|
|
485
|
+
if (dir !== undefined && dir.real !== undefined && installEntryKeys.has(dir.lexical.toLowerCase())) {
|
|
486
|
+
for (const canonicalAncestor of collectInstallProtectedDirs(dir.real)) {
|
|
487
|
+
addProtected({ lexical: canonicalAncestor, real: canonicalAncestor });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);
|
|
492
|
+
let longOutsideFallback;
|
|
493
|
+
let shortFallback;
|
|
494
|
+
let anyFallback;
|
|
495
|
+
for (const rawCandidate of candidates) {
|
|
496
|
+
if (signal?.aborted || overallDeadline - Date.now() <= 0)
|
|
497
|
+
break;
|
|
498
|
+
const candidate = await resolveCandidateDirAsync(rawCandidate, overallDeadline, signal);
|
|
499
|
+
if (candidate === undefined)
|
|
500
|
+
continue;
|
|
501
|
+
const chosen = preferredCandidatePath(candidate);
|
|
502
|
+
const isShort = isShortWindowsSpawnPath(chosen);
|
|
503
|
+
const insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));
|
|
504
|
+
if (!insideAny) {
|
|
505
|
+
if (isShort)
|
|
506
|
+
return chosen;
|
|
507
|
+
longOutsideFallback ??= chosen;
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
if (isShort)
|
|
511
|
+
shortFallback ??= chosen;
|
|
512
|
+
anyFallback ??= chosen;
|
|
513
|
+
}
|
|
514
|
+
return longOutsideFallback ?? shortFallback ?? anyFallback;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Pure synchronous lexical working-directory selector for kill commands (zero filesystem syscalls).
|
|
518
|
+
*
|
|
519
|
+
* Avoids unverified `TMP`/`TEMP` paths (which may not exist) and prefers reliable OS directories
|
|
520
|
+
* (`C:\Windows` when `SystemRoot` is on `C:` or unset, or `process.cwd()`'s own drive root when Windows is
|
|
521
|
+
* installed on another drive or `process.cwd()` is inside `C:\Windows`), rejecting relative paths, bare drives,
|
|
522
|
+
* raw devices, incomplete UNC roots, and paths lexically inside any protected folder (including `\\?\`, `\\.\`,
|
|
523
|
+
* and `\\?\UNC\` aliases). Always preserves `\\?\` / `\\?\UNC\` on paths >= 248 chars.
|
|
524
|
+
*/
|
|
525
|
+
export function resolveSafeWindowsKillCwdLexical(options = {}) {
|
|
526
|
+
const protectedDirs = [];
|
|
527
|
+
const installLexical = (options.installDirs ?? []).flatMap((raw) => collectInstallProtectedDirs(raw));
|
|
528
|
+
for (const raw of collectRawProtectedDirs([...(options.protectedDirs ?? []), ...installLexical])) {
|
|
529
|
+
const lexical = normalizeWindowsPathForCompare(raw);
|
|
530
|
+
if (lexical !== undefined)
|
|
531
|
+
protectedDirs.push({ lexical, real: undefined });
|
|
532
|
+
}
|
|
533
|
+
const normalizedCommand = options.commandPath === undefined ? undefined : normalizeWindowsPathForCompare(options.commandPath);
|
|
534
|
+
const commandDir = normalizedCommand === undefined ? undefined : win32.dirname(normalizedCommand);
|
|
535
|
+
const commandRoot = windowsDriveRoot(normalizedCommand);
|
|
536
|
+
const protectedRoots = protectedDirs.map((folder) => windowsDriveRoot(folder.lexical));
|
|
537
|
+
const systemRootDrive = windowsDriveRoot(process.env.SystemRoot)?.toLowerCase();
|
|
538
|
+
const nonCSystemDrive = systemRootDrive !== undefined && systemRootDrive !== "c:\\";
|
|
539
|
+
// On non-C: Windows installs, prefer the existing drive root of process.cwd() / SystemRoot before hardcoded
|
|
540
|
+
// C:\Windows (which may not exist). On standard C: installs (or unset SystemRoot), prefer C:\Windows ahead of an
|
|
541
|
+
// unverified SystemRoot that could be a junction pointing into the project folder.
|
|
542
|
+
const candidates = dedupeCandidates(nonCSystemDrive
|
|
543
|
+
? [
|
|
544
|
+
...protectedRoots,
|
|
545
|
+
windowsDriveRoot(process.env.SystemRoot),
|
|
546
|
+
commandRoot,
|
|
547
|
+
"C:\\Windows",
|
|
548
|
+
process.env.SystemRoot,
|
|
549
|
+
process.env.windir,
|
|
550
|
+
commandDir,
|
|
551
|
+
"C:\\",
|
|
552
|
+
]
|
|
553
|
+
: [
|
|
554
|
+
"C:\\Windows",
|
|
555
|
+
...protectedRoots,
|
|
556
|
+
commandDir,
|
|
557
|
+
commandRoot,
|
|
558
|
+
process.env.SystemRoot,
|
|
559
|
+
process.env.windir,
|
|
560
|
+
"C:\\",
|
|
561
|
+
]);
|
|
562
|
+
let longOutsideFallback;
|
|
563
|
+
let shortFallback;
|
|
564
|
+
let anyFallback;
|
|
565
|
+
for (const rawCandidate of candidates) {
|
|
566
|
+
const lexical = normalizeWindowsPathForCompare(rawCandidate);
|
|
567
|
+
if (lexical === undefined)
|
|
568
|
+
continue;
|
|
569
|
+
const candidate = { lexical, real: undefined, unverifiedLink: false };
|
|
570
|
+
const chosen = toSpawnWindowsPath(lexical);
|
|
571
|
+
const isShort = isShortWindowsSpawnPath(chosen);
|
|
572
|
+
const insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));
|
|
573
|
+
if (!insideAny) {
|
|
574
|
+
if (isShort)
|
|
575
|
+
return chosen;
|
|
576
|
+
longOutsideFallback ??= chosen;
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
if (isShort)
|
|
580
|
+
shortFallback ??= chosen;
|
|
581
|
+
anyFallback ??= chosen;
|
|
582
|
+
}
|
|
583
|
+
return longOutsideFallback ?? shortFallback ?? anyFallback;
|
|
584
|
+
}
|
|
585
|
+
//# sourceMappingURL=windows-cwd.js.map
|