@bastani/atomic 0.10.15 → 0.10.16-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 +50 -0
- package/dist/__atomic_timers/index.js +112 -0
- package/dist/__atomic_timers/index.js.map +1 -0
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/http-YFAPTIZD.js +20 -22
- package/dist/_shared/http-YFAPTIZD.js.map +1 -1
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +55 -25
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js.map +1 -1
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +13 -14
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js.map +1 -1
- package/dist/_shared/mode-shared-2QJSCUM6.js +16 -17
- package/dist/_shared/mode-shared-2QJSCUM6.js.map +1 -1
- package/dist/_shared/p0-cli-BB45ZQY6.js +23 -37
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +6 -5
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-TVB5CBLL.js → p1b-elig-BY2G5BUE.js} +28 -36
- package/dist/_shared/p1b-elig-BY2G5BUE.js.map +1 -0
- package/dist/_shared/runtime-O4KCSG4C.js +4 -4
- package/dist/_shared/sdk-OHKMDJ74.js +382 -45
- package/dist/_shared/sdk-OHKMDJ74.js.map +1 -1
- package/dist/_shared/session-data-AHTU7IS6.js +3 -3
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/settings-startup-HXQLSUWM.js.map +1 -1
- package/dist/_shared/{startup-0-0-Q3MWKUK4.js → startup-0-0-ERMIDHQT.js} +296 -382
- package/dist/_shared/startup-0-0-ERMIDHQT.js.map +1 -0
- package/dist/_shared/{startup-0-1-M6OWAYHH.js → startup-0-1-RTASI3HG.js} +430 -102
- package/dist/_shared/startup-0-1-RTASI3HG.js.map +1 -0
- package/dist/_shared/{startup-0-2-2HUMCPKX.js → startup-0-2-YZZOC22D.js} +8109 -7962
- package/dist/_shared/startup-0-2-YZZOC22D.js.map +1 -0
- package/dist/_shared/{startup-0-3-4ZYBYQNM.js → startup-0-3-DE2NCS6A.js} +130 -83
- package/dist/_shared/startup-0-3-DE2NCS6A.js.map +1 -0
- package/dist/_shared/startup-0-4-ZMJV547D.js +7 -7
- package/dist/_shared/{startup-0-5-YDW47QX6.js → startup-0-5-HZX3ZPTP.js} +411 -85
- package/dist/_shared/startup-0-5-HZX3ZPTP.js.map +1 -0
- package/dist/_shared/startup-10-0-TDQNBDDL.js +42 -29
- 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 +11 -10
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +9 -8
- package/dist/_shared/startup-15-0-YUKGAC63.js.map +1 -1
- package/dist/_shared/startup-15-1-4S7FLMNG.js +24 -16
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +40 -19
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +129 -92
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -1
- package/dist/_shared/storage-command-7MGXLJGZ.js +6 -4
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +7 -6
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -1
- package/dist/_shared/task-reference-stream-JWMUZSJX.js +1 -1
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +4 -3
- package/dist/_shared/team-DOQKICG2.js.map +1 -1
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/index.bundle.mjs +1 -2
- package/dist/builtin/intercom/package.json +1 -1
- 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 +102 -42
- package/dist/builtin/web-access/index.bundle.mjs +1 -2
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +6 -6
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +7 -6
- package/dist/cli/blueprint-command.code.js.map +1 -1
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +2 -2
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +2 -2
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +1 -1
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +2 -2
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.code.js +1 -1
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +2 -2
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.code.js +1 -1
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +2 -2
- package/dist/core/extensions/runner-context.js +1 -1
- package/dist/core/http-dispatcher.d.ts +2 -1
- package/dist/core/intercom-broker-control-host.code.js +1 -1
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/lock-takeover.d.ts +2 -0
- package/dist/core/model-config.d.ts +28 -0
- package/dist/core/model-registry.js +1 -1
- package/dist/core/model-runtime-streaming.d.ts +3 -2
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/provider-rate-limits.d.ts +17 -10
- package/dist/core/provider-request-admission.d.ts +16 -0
- package/dist/core/resume/blueprint/barrier.d.ts +6 -6
- package/dist/core/resume/blueprint/build.d.ts +3 -1
- package/dist/core/resume/blueprint/ledger.d.ts +3 -2
- package/dist/core/resume/blueprint/resume.d.ts +2 -1
- package/dist/core/retry-policy.d.ts +3 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +6 -6
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager-types.d.ts +1 -1
- package/dist/core/session-manager.code.js +2 -2
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-open-markers.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-duration.d.ts +3 -0
- package/dist/core/settings-manager-resource-accessors.d.ts +2 -1
- package/dist/core/settings-schema.d.ts +1 -0
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-file-gate.js +7 -6
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +2 -2
- package/dist/core/storage/node-sqlite.js +2 -2
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.js +3 -0
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/selection.js +2 -2
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +24 -7
- package/dist/core/storage/session/child-reader.code.js.map +1 -1
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.code.js +1 -1
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +3 -3
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-window.code.js +4 -4
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.d.ts +2 -2
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.d.ts +2 -2
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +4 -4
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +4 -4
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.d.ts +13 -4
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.code.js +1 -1
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/session/types.d.ts +20 -2
- package/dist/core/storage/sqlite-facade.js +14 -13
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/heartbeat.d.ts +1 -0
- package/dist/core/tasks/task-completion-entry.code.js +1 -1
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +3 -3
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +1 -1
- package/dist/core/tools/history-session.d.ts +2 -0
- package/dist/core/tools/read-url.code.js +3 -3
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.js +5 -6
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +3 -3
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/git.d.ts +2 -0
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +6 -5
- package/dist/extensions/codemode/execute.code.js.map +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +1 -1
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +8 -4
- package/dist/extensions/mcp/cli.code.js.map +1 -1
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.js +6 -6
- package/dist/main-first-time-setup.code.js +2 -2
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.code.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.code.js +1 -1
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/package-manager-cli.code.js +7 -7
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- 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 +2 -6
- package/dist/startup-stages/3.js +6 -1
- package/dist/startup-stages/4.js +1 -1
- package/dist/startup-stages/5.js +12 -1
- package/dist/startup-stages/6.js +8 -4
- package/dist/startup-stages/7.js +4 -3
- package/dist/startup-stages/8.js +1 -5
- package/dist/startup-stages/9.js +5 -1
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/startup-database-spare.code.js +3 -3
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/dist/utils/windows-cwd.js +3 -3
- package/dist/utils/windows-cwd.js.map +1 -1
- package/docs/changelog.mdx +2 -10
- package/docs/codemode.md +5 -2
- package/docs/compaction/branch-summaries.md +1 -1
- package/docs/compaction/custom-compactors.md +1 -1
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/custom-provider/registration.md +3 -0
- package/docs/custom-provider/streaming.md +1 -1
- package/docs/environment-variables.md +2 -2
- package/docs/guides/resume-on-any-machine.md +1 -0
- package/docs/libraries/ai.md +4 -2
- package/docs/libraries/codemode.md +1 -1
- package/docs/models/choose-a-model.md +1 -1
- package/docs/models-configuration.md +5 -2
- package/docs/models.md +32 -0
- package/docs/providers.md +33 -1
- package/docs/sdk/structured-decisions.md +4 -2
- package/docs/sessions.md +1 -1
- package/docs/settings.md +78 -16
- package/docs/storage/postgres/tuning.md +1 -0
- package/docs/subagents/reference.md +2 -1
- package/docs/tools.md +4 -3
- package/docs/worktree-snapshots/reference.md +2 -0
- package/docs/worktree-snapshots.md +4 -0
- package/package.json +9 -9
- package/schemas/models.schema.json +21 -0
- package/schemas/settings.schema.json +14 -1
- package/dist/_shared/p1b-elig-TVB5CBLL.js.map +0 -1
- package/dist/_shared/startup-0-0-Q3MWKUK4.js.map +0 -1
- package/dist/_shared/startup-0-1-M6OWAYHH.js.map +0 -1
- package/dist/_shared/startup-0-2-2HUMCPKX.js.map +0 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js.map +0 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +0 -1
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.
|
|
9
|
+
const key = `${root.href}#0.10.16-alpha.1`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.
|
|
30
|
+
if (running === undefined || running.version === "0.10.16-alpha.1") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.16-alpha.1 while this session was running; restart it to keep using this feature.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -2,6 +2,7 @@ import { lstatSync, realpathSync, statSync } from "node:fs";
|
|
|
2
2
|
import { lstat, realpath, stat } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { win32 } from "node:path";
|
|
5
|
+
import { setLongTimeout } from "../__atomic_timers/index.js";
|
|
5
6
|
/** Safe Win32 path length threshold for `CreateProcessW` `lpCurrentDirectory` without an extended `\\?\` prefix. */
|
|
6
7
|
const SAFE_WINDOWS_CWD_LENGTH = 248;
|
|
7
8
|
/** Default upper bound on async filesystem probes so slow or offline UNC/OneDrive paths never stall callers. */
|
|
@@ -306,13 +307,12 @@ function boundedFsCall(work, budgetMs, signal) {
|
|
|
306
307
|
if (settled)
|
|
307
308
|
return;
|
|
308
309
|
settled = true;
|
|
309
|
-
|
|
310
|
+
timer.clear();
|
|
310
311
|
signal?.removeEventListener("abort", onAbort);
|
|
311
312
|
resolve(value);
|
|
312
313
|
};
|
|
313
314
|
const onAbort = () => done(undefined);
|
|
314
|
-
const timer =
|
|
315
|
-
timer.unref?.();
|
|
315
|
+
const timer = setLongTimeout(() => done(undefined), budgetMs, { ref: false });
|
|
316
316
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
317
317
|
work.then((value) => done(value), () => done(undefined));
|
|
318
318
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"windows-cwd.js","sourceRoot":"","sources":["../../src/utils/windows-cwd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,oHAAoH;AACpH,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,gHAAgH;AAChH,MAAM,CAAC,MAAM,8BAA8B,GA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AAC,CAAC;QAC7F,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,IAAI,OAAO;gBAAE,OAAO,MAAM,CAAC;YAC3B,mBAAmB,KAAK,MAAM,CAAC;YAC/B,SAAS;QACV,CAAC;QACD,IAAI,OAAO;YAAE,aAAa,KAAK,MAAM,CAAC;QACtC,WAAW,KAAK,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,mBAAmB,IAAI,aAAa,IAAI,WAAW,CAAC;AAC5D,CAAC","sourcesContent":["import { lstatSync, realpathSync, statSync } from \"node:fs\";\nimport { lstat, realpath, stat } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { win32 } from \"node:path\";\n\n/** Safe Win32 path length threshold for `CreateProcessW` `lpCurrentDirectory` without an extended `\\\\?\\` prefix. */\nconst SAFE_WINDOWS_CWD_LENGTH = 248;\n/** Default upper bound on async filesystem probes so slow or offline UNC/OneDrive paths never stall callers. */\nexport const DEFAULT_WINDOWS_CWD_TIMEOUT_MS = 100;\n/** Maximum share of the timeout budget spent resolving protected directories' realpaths before probing local candidates. */\nconst MAX_PROTECTED_REALPATH_BUDGET_MS = 50;\n\ninterface ResolvedProtectedDir {\n\treadonly lexical: string;\n\treadonly real: string | undefined;\n}\n\ninterface ResolvedCandidateDir {\n\treadonly lexical: string;\n\treadonly real: string | undefined;\n\treadonly unverifiedLink: boolean;\n}\n\nexport interface SafeWindowsWorkingDirectoryOptions {\n\t/** Optional explicit/resolved command path whose directory and drive root may be used as fallbacks. */\n\treadonly commandPath?: string;\n\t/** Additional folders (besides `process.cwd()`) that the child process must not run inside. */\n\treadonly protectedDirs?: readonly (string | undefined)[];\n\t/**\n\t * Installation directories (e.g. extension dir, `dist/utils`, standalone executable dir) whose enclosing\n\t * install roots—both lexical and canonical realpath (catching `subst` drives and junctions)—must be protected.\n\t */\n\treadonly installDirs?: readonly (string | undefined)[];\n\t/** When true (kill/stop commands), try `commandPath`'s directory ahead of `os.tmpdir()`. */\n\treadonly preferCommandDir?: boolean;\n\t/** Maximum time in milliseconds spent on async `stat`/`realpath`/`lstat` probes. Default: 100 ms. */\n\treadonly timeoutMs?: number;\n\t/** Optional abort signal to cancel pending timeout timers immediately when the caller no longer needs the result. */\n\treadonly signal?: AbortSignal;\n}\n\nfunction isAsciiLetter(code: number): boolean {\n\treturn (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n}\n\nfunction isDriveRootPrefix(slashed: string): boolean {\n\treturn slashed.length >= 3 && isAsciiLetter(slashed.charCodeAt(0)) && slashed[1] === \":\" && slashed[2] === \"\\\\\";\n}\n\nfunction normalizeUncPath(slashed: string): string | undefined {\n\tconst rest = slashed.slice(2);\n\tconst firstSep = rest.indexOf(\"\\\\\");\n\tif (firstSep <= 0) return undefined;\n\tconst server = rest.slice(0, firstSep);\n\tif (server === \".\" || server === \"..\") return undefined;\n\tconst afterServer = rest.slice(firstSep + 1);\n\tconst secondSep = afterServer.indexOf(\"\\\\\");\n\tconst share = secondSep === -1 ? afterServer : afterServer.slice(0, secondSep);\n\tif (share === \"\" || share === \".\" || share === \"..\") return undefined;\n\treturn win32.resolve(slashed);\n}\n\n/**\n * Normalizes a fully-qualified Windows directory path for containment comparison.\n *\n * Strips extended-length and Win32 device prefixes (`\\\\?\\`, `\\\\.\\`, `\\\\?\\UNC\\`) so aliased paths compare\n * equal to their standard counterparts, preserves trailing separators on drive and share roots, and\n * rejects relative paths, bare drives (`C:`), drive-relative paths (`C:foo`), rooted-without-drive paths\n * (`\\Windows`), raw volume devices (`\\\\?\\C:`, `\\\\?\\Volume{...}` without `\\`), incomplete UNC roots, and\n * NUL bytes.\n */\nexport function normalizeWindowsPathForCompare(value: string): string | undefined {\n\tif (value === \"\" || value.includes(\"\\0\")) return undefined;\n\tconst slashed = value.replaceAll(\"/\", \"\\\\\");\n\tif (slashed.startsWith(\"\\\\\\\\?\\\\\") || slashed.startsWith(\"\\\\\\\\.\\\\\")) {\n\t\tconst rest = slashed.slice(4);\n\t\tif (rest.length >= 4 && rest.slice(0, 4).toLowerCase() === \"unc\\\\\") {\n\t\t\treturn normalizeUncPath(`\\\\\\\\${rest.slice(4)}`);\n\t\t}\n\t\tif (isDriveRootPrefix(rest)) {\n\t\t\treturn win32.resolve(rest);\n\t\t}\n\t\tif (rest.length > 9 && rest.slice(0, 7).toLowerCase() === \"volume{\") {\n\t\t\tconst sepIndex = rest.indexOf(\"\\\\\");\n\t\t\tif (sepIndex <= 8 || rest[sepIndex - 1] !== \"}\") return undefined;\n\t\t\tconst root = `\\\\\\\\?\\\\${rest.slice(0, sepIndex + 1)}`;\n\t\t\tconst tail = rest.slice(sepIndex + 1);\n\t\t\tconst normalizedTail = tail === \"\" ? \"\" : win32.resolve(\"C:\\\\\", tail).slice(3);\n\t\t\treturn `${root}${normalizedTail}`;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (slashed.startsWith(\"\\\\\\\\\")) {\n\t\treturn normalizeUncPath(slashed);\n\t}\n\tif (isDriveRootPrefix(slashed)) {\n\t\treturn win32.resolve(slashed);\n\t}\n\treturn undefined;\n}\n\n/**\n * Formats a normalized comparison path for Win32 filesystem / `CreateProcessW` APIs:\n * keeps short paths (< 248 chars) plain and ensures paths >= 248 chars carry the proper\n * extended-length prefix (`\\\\?\\` for drive paths, `\\\\?\\UNC\\server\\share\\...` for UNC paths).\n */\nexport function toSpawnWindowsPath(comparePath: string): string {\n\tif (comparePath.startsWith(\"\\\\\\\\?\\\\\") || comparePath.length < SAFE_WINDOWS_CWD_LENGTH) {\n\t\treturn comparePath;\n\t}\n\tif (comparePath.startsWith(\"\\\\\\\\\")) {\n\t\treturn `\\\\\\\\?\\\\UNC\\\\${comparePath.slice(2)}`;\n\t}\n\treturn `\\\\\\\\?\\\\${comparePath}`;\n}\n\nexport function isAbsoluteWindowsPath(value: string): boolean {\n\treturn normalizeWindowsPathForCompare(value) !== undefined;\n}\n\n/** Returns the normalized drive, UNC share, or volume root (always ending with `\\`) for an absolute Windows path. */\nexport function windowsDriveRoot(value: string | undefined): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = normalizeWindowsPathForCompare(value);\n\tif (normalized === undefined) return undefined;\n\tif (normalized.startsWith(\"\\\\\\\\?\\\\\")) {\n\t\tconst sepIndex = normalized.indexOf(\"\\\\\", 4);\n\t\treturn sepIndex === -1 ? undefined : normalized.slice(0, sepIndex + 1);\n\t}\n\tconst root = win32.parse(normalized).root;\n\tif (root.length <= 1) return undefined;\n\treturn root.endsWith(\"\\\\\") ? root : `${root}\\\\`;\n}\n\nexport function isDriveRootWindowsPath(normalized: string): boolean {\n\tconst root = windowsDriveRoot(normalized);\n\treturn root !== undefined && normalized.toLowerCase() === root.toLowerCase();\n}\n\nfunction addNonRootWindowsDir(target: string[], seen: Set<string>, candidate: string): void {\n\tconst normalized = normalizeWindowsPathForCompare(candidate);\n\tif (normalized === undefined || isDriveRootWindowsPath(normalized)) return;\n\tconst key = normalized.toLowerCase();\n\tif (seen.has(key)) return;\n\tseen.add(key);\n\ttarget.push(normalized);\n}\n\n/**\n * Returns the install-root directories enclosing `entryDir` that background helpers must not keep as their working\n * directory on Windows (npm/pnpm/bun package root + `@scope`/`node_modules`, standalone binary `versions/<ver>` +\n * install root, or `dist/utils` package root). Never promotes a drive or share root to an inferred protected ancestor.\n */\nexport function collectInstallProtectedDirs(entryDir: string | undefined): string[] {\n\tif (entryDir === undefined || entryDir === \"\") return [];\n\tconst normalized = normalizeWindowsPathForCompare(entryDir);\n\tif (normalized === undefined) return [];\n\tconst result: string[] = [normalized];\n\tconst seen = new Set<string>([normalized.toLowerCase()]);\n\n\tconst add = (dir: string) => addNonRootWindowsDir(result, seen, dir);\n\tconst parent = win32.dirname(normalized);\n\tconst parentName = win32.basename(parent).toLowerCase();\n\tconst ownName = win32.basename(normalized).toLowerCase();\n\tconst grandParent = win32.dirname(parent);\n\tconst grandParentName = win32.basename(grandParent).toLowerCase();\n\n\tlet packageDir = normalized;\n\tif (parentName === \"builtin\" && grandParentName === \"dist\") {\n\t\tpackageDir = win32.dirname(grandParent);\n\t\tadd(grandParent);\n\t\tadd(packageDir);\n\t} else if (parentName === \"builtin\") {\n\t\tconst versionDir = grandParent;\n\t\tpackageDir = versionDir;\n\t\tadd(versionDir);\n\t\tconst versionDirName = win32.basename(versionDir).toLowerCase();\n\t\tconst versionsParent = win32.dirname(versionDir);\n\t\tif (win32.basename(versionsParent).toLowerCase() === \"versions\") {\n\t\t\tadd(versionsParent);\n\t\t\tadd(win32.dirname(versionsParent));\n\t\t} else if (versionDirName === \"current\" || versionDirName === \"atomic-current\") {\n\t\t\tadd(versionsParent);\n\t\t}\n\t} else if (ownName === \"utils\" && parentName === \"dist\") {\n\t\tpackageDir = grandParent;\n\t\tadd(parent);\n\t\tadd(packageDir);\n\t} else if (parentName === \"versions\") {\n\t\tadd(parent);\n\t\tadd(grandParent);\n\t} else if (ownName === \"current\" || ownName === \"atomic-current\") {\n\t\tadd(parent);\n\t}\n\n\tconst pkgParent = win32.dirname(packageDir);\n\tconst pkgParentName = win32.basename(pkgParent).toLowerCase();\n\tconst pkgGrandParent = win32.dirname(pkgParent);\n\tconst pkgGrandParentName = win32.basename(pkgGrandParent).toLowerCase();\n\tif (pkgParentName.startsWith(\"@\") && pkgGrandParentName === \"node_modules\") {\n\t\tadd(pkgParent);\n\t\tadd(pkgGrandParent);\n\t} else if (pkgParentName === \"node_modules\") {\n\t\tadd(pkgParent);\n\t}\n\n\treturn result;\n}\n\nfunction isSubpathOrSame(folderNormalized: string, candidateNormalized: string): boolean {\n\tconst rel = win32.relative(folderNormalized.toLowerCase(), candidateNormalized.toLowerCase());\n\treturn rel !== \"..\" && !rel.startsWith(\"..\\\\\") && !win32.isAbsolute(rel);\n}\n\nfunction conflictsWithNormalizedFolder(folderNormalized: string, candidateNormalized: string): boolean {\n\tif (isDriveRootWindowsPath(folderNormalized)) {\n\t\treturn folderNormalized.toLowerCase() === candidateNormalized.toLowerCase();\n\t}\n\treturn isSubpathOrSame(folderNormalized, candidateNormalized);\n}\n\nfunction isInsideProtectedFolder(folder: ResolvedProtectedDir, candidate: ResolvedCandidateDir): boolean {\n\tif (candidate.unverifiedLink) return true;\n\tif (folder.real !== undefined && candidate.real !== undefined) {\n\t\tif (isDriveRootWindowsPath(folder.real)) {\n\t\t\treturn folder.real.toLowerCase() === candidate.real.toLowerCase();\n\t\t}\n\t\tif (isSubpathOrSame(folder.real, candidate.real)) return true;\n\t\tif (!isDriveRootWindowsPath(folder.lexical) && isSubpathOrSame(folder.lexical, candidate.lexical)) return true;\n\t\treturn false;\n\t}\n\tif (conflictsWithNormalizedFolder(folder.lexical, candidate.lexical)) return true;\n\tif (folder.real !== undefined && conflictsWithNormalizedFolder(folder.real, candidate.lexical)) return true;\n\tif (candidate.real !== undefined && conflictsWithNormalizedFolder(folder.lexical, candidate.real)) return true;\n\treturn false;\n}\n\nfunction preferredCandidatePath(candidate: ResolvedCandidateDir): string {\n\treturn toSpawnWindowsPath(candidate.real ?? candidate.lexical);\n}\n\n/**\n * Win32 `CreateProcessW` rejects `lpCurrentDirectory` >= `MAX_PATH` (even with `\\\\?\\`) when Windows' default\n * `LongPathsEnabled = 0` is in effect. Prefer a short (< 248-char) verified directory outside the project whenever\n * one is available so kill commands work across both default Windows installs and `LongPathsEnabled = 1` hosts.\n */\nfunction isShortWindowsSpawnPath(spawnPath: string): boolean {\n\treturn !spawnPath.startsWith(\"\\\\\\\\?\\\\\") && spawnPath.length < SAFE_WINDOWS_CWD_LENGTH;\n}\n\nfunction probePathFor(rawDir: string, lexical: string): string {\n\tif (rawDir.length >= SAFE_WINDOWS_CWD_LENGTH && !rawDir.startsWith(\"\\\\\\\\?\\\\\")) {\n\t\treturn toSpawnWindowsPath(lexical);\n\t}\n\treturn rawDir;\n}\n\nfunction readProcessCwd(): string | undefined {\n\ttry {\n\t\treturn process.cwd();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction collectRawProtectedDirs(extra?: readonly (string | undefined)[]): string[] {\n\tconst result: string[] = [];\n\tconst seen = new Set<string>();\n\tconst add = (dir: string | undefined) => {\n\t\tif (dir === undefined) return;\n\t\tconst normalized = normalizeWindowsPathForCompare(dir);\n\t\tif (normalized === undefined) return;\n\t\tconst key = normalized.toLowerCase();\n\t\tif (seen.has(key)) return;\n\t\tseen.add(key);\n\t\tresult.push(dir);\n\t};\n\tadd(readProcessCwd());\n\tfor (const dir of extra ?? []) add(dir);\n\treturn result;\n}\n\nfunction dedupeCandidates(rawList: readonly (string | undefined)[]): string[] {\n\tconst deduped: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const item of rawList) {\n\t\tif (item === undefined || item === \"\") continue;\n\t\tconst key = item.toLowerCase();\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tdeduped.push(item);\n\t}\n\treturn deduped;\n}\n\nfunction buildCandidates(\n\tprotectedDirs: readonly ResolvedProtectedDir[],\n\tcommandPath: string | undefined,\n\tpreferCommandDir: boolean,\n): readonly string[] {\n\tconst tempDir = tmpdir();\n\tconst normalizedCommand = commandPath === undefined ? undefined : normalizeWindowsPathForCompare(commandPath);\n\tconst commandDir = normalizedCommand === undefined ? undefined : win32.dirname(normalizedCommand);\n\tconst commandRoot = windowsDriveRoot(normalizedCommand);\n\tconst tempRoot = windowsDriveRoot(tempDir);\n\tconst protectedRoots: (string | undefined)[] = [];\n\tfor (const folder of protectedDirs) {\n\t\tprotectedRoots.push(windowsDriveRoot(folder.real));\n\t\tprotectedRoots.push(windowsDriveRoot(folder.lexical));\n\t}\n\tconst middle = preferCommandDir ? [commandDir, tempDir] : [tempDir, commandDir];\n\treturn dedupeCandidates([\n\t\tprocess.env.SystemRoot,\n\t\tprocess.env.windir,\n\t\t\"C:\\\\Windows\",\n\t\t...middle,\n\t\tcommandRoot,\n\t\ttempRoot,\n\t\t...protectedRoots,\n\t\twindowsDriveRoot(process.env.SystemRoot),\n\t\twindowsDriveRoot(process.env.windir),\n\t\t\"C:\\\\\",\n\t]);\n}\n\nfunction boundedFsCall<T>(work: Promise<T>, budgetMs: number, signal?: AbortSignal): Promise<T | undefined> {\n\tif (signal?.aborted || budgetMs <= 0) {\n\t\tvoid work.catch(() => {});\n\t\treturn Promise.resolve(undefined);\n\t}\n\treturn new Promise<T | undefined>((resolve) => {\n\t\tlet settled = false;\n\t\tconst done = (value: T | undefined) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\tclearTimeout(timer);\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(value);\n\t\t};\n\t\tconst onAbort = () => done(undefined);\n\t\tconst timer = setTimeout(() => done(undefined), budgetMs);\n\t\ttimer.unref?.();\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\twork.then(\n\t\t\t(value) => done(value),\n\t\t\t() => done(undefined),\n\t\t);\n\t});\n}\n\nfunction tryRealPathSync(dir: string): string | undefined {\n\ttry {\n\t\tconst native = realpathSync.native;\n\t\treturn normalizeWindowsPathForCompare(typeof native === \"function\" ? native(dir) : realpathSync(dir));\n\t} catch {\n\t\ttry {\n\t\t\treturn normalizeWindowsPathForCompare(realpathSync(dir));\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\nfunction resolveProtectedDirSync(rawDir: string): ResolvedProtectedDir | undefined {\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\treturn { lexical, real: tryRealPathSync(probePathFor(rawDir, lexical)) };\n}\n\nfunction resolveCandidateDirSync(rawDir: string): ResolvedCandidateDir | undefined {\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\tconst probe = probePathFor(rawDir, lexical);\n\ttry {\n\t\tif (!statSync(probe).isDirectory()) return undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst real = tryRealPathSync(probe);\n\tlet unverifiedLink = false;\n\tif (real === undefined) {\n\t\ttry {\n\t\t\tunverifiedLink = lstatSync(probe).isSymbolicLink();\n\t\t} catch {\n\t\t\tunverifiedLink = false;\n\t\t}\n\t}\n\treturn { lexical, real, unverifiedLink };\n}\n\n/** Synchronously resolves a safe Windows working directory using `statSync` and `realpathSync.native`. */\nexport function resolveSafeWindowsWorkingDirectorySync(\n\toptions: SafeWindowsWorkingDirectoryOptions = {},\n): string | undefined {\n\tconst protectedDirs: ResolvedProtectedDir[] = [];\n\tconst seenProtected = new Set<string>();\n\tconst addProtected = (dir: ResolvedProtectedDir | undefined) => {\n\t\tif (dir === undefined) return;\n\t\tconst key = `${dir.lexical.toLowerCase()}\\0${dir.real?.toLowerCase() ?? \"\"}`;\n\t\tif (seenProtected.has(key)) return;\n\t\tseenProtected.add(key);\n\t\tprotectedDirs.push(dir);\n\t};\n\tfor (const raw of collectRawProtectedDirs(options.protectedDirs)) {\n\t\taddProtected(resolveProtectedDirSync(raw));\n\t}\n\tfor (const rawInstall of options.installDirs ?? []) {\n\t\tif (rawInstall === undefined) continue;\n\t\tconst resolvedEntry = resolveProtectedDirSync(rawInstall);\n\t\taddProtected(resolvedEntry);\n\t\tfor (const dir of collectInstallProtectedDirs(rawInstall)) {\n\t\t\taddProtected(resolveProtectedDirSync(dir));\n\t\t}\n\t\tif (resolvedEntry?.real !== undefined) {\n\t\t\tfor (const dir of collectInstallProtectedDirs(resolvedEntry.real)) {\n\t\t\t\taddProtected({ lexical: dir, real: tryRealPathSync(probePathFor(dir, dir)) ?? dir });\n\t\t\t}\n\t\t}\n\t}\n\tconst candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);\n\tlet longOutsideFallback: string | undefined;\n\tlet shortFallback: string | undefined;\n\tlet anyFallback: string | undefined;\n\tfor (const rawCandidate of candidates) {\n\t\tconst candidate = resolveCandidateDirSync(rawCandidate);\n\t\tif (candidate === undefined) continue;\n\t\tconst chosen = preferredCandidatePath(candidate);\n\t\tconst isShort = isShortWindowsSpawnPath(chosen);\n\t\tconst insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));\n\t\tif (!insideAny) {\n\t\t\tif (isShort) return chosen;\n\t\t\tlongOutsideFallback ??= chosen;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isShort) shortFallback ??= chosen;\n\t\tanyFallback ??= chosen;\n\t}\n\treturn longOutsideFallback ?? shortFallback ?? anyFallback;\n}\n\nasync function tryRealPathAsync(dir: string, deadline: number, signal?: AbortSignal): Promise<string | undefined> {\n\tconst resolved = await boundedFsCall(realpath(dir), deadline - Date.now(), signal);\n\treturn resolved === undefined ? undefined : normalizeWindowsPathForCompare(resolved);\n}\n\nasync function resolveProtectedDirAsync(\n\trawDir: string,\n\tdeadline: number,\n\tsignal?: AbortSignal,\n): Promise<ResolvedProtectedDir | undefined> {\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\tconst real = await tryRealPathAsync(probePathFor(rawDir, lexical), deadline, signal);\n\treturn { lexical, real };\n}\n\nasync function resolveCandidateDirAsync(\n\trawDir: string,\n\tdeadline: number,\n\tsignal?: AbortSignal,\n): Promise<ResolvedCandidateDir | undefined> {\n\tif (signal?.aborted || deadline - Date.now() <= 0) return undefined;\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\tconst probe = probePathFor(rawDir, lexical);\n\tconst stats = await boundedFsCall(stat(probe), deadline - Date.now(), signal);\n\tif (!stats?.isDirectory()) return undefined;\n\tconst real = await tryRealPathAsync(probe, deadline, signal);\n\tlet unverifiedLink = false;\n\tif (real === undefined && !signal?.aborted && deadline - Date.now() > 0) {\n\t\tconst linkStats = await boundedFsCall(lstat(probe), deadline - Date.now(), signal);\n\t\tunverifiedLink = linkStats?.isSymbolicLink() === true;\n\t}\n\treturn { lexical, real, unverifiedLink };\n}\n\n/**\n * Asynchronously selects a safe existing Windows working directory outside `process.cwd()` (and any extra\n * protected folders) within a bounded time budget without blocking the event loop.\n */\nexport async function resolveSafeWindowsWorkingDirectoryAsync(\n\toptions: SafeWindowsWorkingDirectoryOptions = {},\n): Promise<string | undefined> {\n\tconst { signal } = options;\n\tif (signal?.aborted) return undefined;\n\tconst totalMs = Math.max(0, options.timeoutMs ?? DEFAULT_WINDOWS_CWD_TIMEOUT_MS);\n\tconst startedAt = Date.now();\n\tconst overallDeadline = startedAt + totalMs;\n\tconst protectedBudgetMs = Math.min(MAX_PROTECTED_REALPATH_BUDGET_MS, Math.floor(totalMs / 2));\n\tconst protectedDeadline = startedAt + protectedBudgetMs;\n\n\tconst installEntryKeys = new Set<string>();\n\tfor (const raw of options.installDirs ?? []) {\n\t\tif (raw === undefined) continue;\n\t\tconst normalized = normalizeWindowsPathForCompare(raw);\n\t\tif (normalized !== undefined) installEntryKeys.add(normalized.toLowerCase());\n\t}\n\tconst installLexical = (options.installDirs ?? []).flatMap((raw) => collectInstallProtectedDirs(raw));\n\tconst rawProtected = collectRawProtectedDirs([...(options.protectedDirs ?? []), ...installLexical]);\n\tconst resolvedProtected = await Promise.all(\n\t\trawProtected.map((raw) => resolveProtectedDirAsync(raw, protectedDeadline, signal)),\n\t);\n\tif (signal?.aborted) return undefined;\n\tconst protectedDirs: ResolvedProtectedDir[] = [];\n\tconst seenProtected = new Set<string>();\n\tconst addProtected = (dir: ResolvedProtectedDir | undefined) => {\n\t\tif (dir === undefined) return;\n\t\tconst key = `${dir.lexical.toLowerCase()}\\0${dir.real?.toLowerCase() ?? \"\"}`;\n\t\tif (seenProtected.has(key)) return;\n\t\tseenProtected.add(key);\n\t\tprotectedDirs.push(dir);\n\t};\n\tfor (const dir of resolvedProtected) {\n\t\taddProtected(dir);\n\t\tif (dir !== undefined && dir.real !== undefined && installEntryKeys.has(dir.lexical.toLowerCase())) {\n\t\t\tfor (const canonicalAncestor of collectInstallProtectedDirs(dir.real)) {\n\t\t\t\taddProtected({ lexical: canonicalAncestor, real: canonicalAncestor });\n\t\t\t}\n\t\t}\n\t}\n\tconst candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);\n\tlet longOutsideFallback: string | undefined;\n\tlet shortFallback: string | undefined;\n\tlet anyFallback: string | undefined;\n\tfor (const rawCandidate of candidates) {\n\t\tif (signal?.aborted || overallDeadline - Date.now() <= 0) break;\n\t\tconst candidate = await resolveCandidateDirAsync(rawCandidate, overallDeadline, signal);\n\t\tif (candidate === undefined) continue;\n\t\tconst chosen = preferredCandidatePath(candidate);\n\t\tconst isShort = isShortWindowsSpawnPath(chosen);\n\t\tconst insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));\n\t\tif (!insideAny) {\n\t\t\tif (isShort) return chosen;\n\t\t\tlongOutsideFallback ??= chosen;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isShort) shortFallback ??= chosen;\n\t\tanyFallback ??= chosen;\n\t}\n\treturn longOutsideFallback ?? shortFallback ?? anyFallback;\n}\n\n/**\n * Pure synchronous lexical working-directory selector for kill commands (zero filesystem syscalls).\n *\n * Avoids unverified `TMP`/`TEMP` paths (which may not exist) and prefers reliable OS directories\n * (`C:\\Windows` when `SystemRoot` is on `C:` or unset, or `process.cwd()`'s own drive root when Windows is\n * installed on another drive or `process.cwd()` is inside `C:\\Windows`), rejecting relative paths, bare drives,\n * raw devices, incomplete UNC roots, and paths lexically inside any protected folder (including `\\\\?\\`, `\\\\.\\`,\n * and `\\\\?\\UNC\\` aliases). Always preserves `\\\\?\\` / `\\\\?\\UNC\\` on paths >= 248 chars.\n */\nexport function resolveSafeWindowsKillCwdLexical(options: SafeWindowsWorkingDirectoryOptions = {}): string | undefined {\n\tconst protectedDirs: ResolvedProtectedDir[] = [];\n\tconst installLexical = (options.installDirs ?? []).flatMap((raw) => collectInstallProtectedDirs(raw));\n\tfor (const raw of collectRawProtectedDirs([...(options.protectedDirs ?? []), ...installLexical])) {\n\t\tconst lexical = normalizeWindowsPathForCompare(raw);\n\t\tif (lexical !== undefined) protectedDirs.push({ lexical, real: undefined });\n\t}\n\tconst normalizedCommand =\n\t\toptions.commandPath === undefined ? undefined : normalizeWindowsPathForCompare(options.commandPath);\n\tconst commandDir = normalizedCommand === undefined ? undefined : win32.dirname(normalizedCommand);\n\tconst commandRoot = windowsDriveRoot(normalizedCommand);\n\tconst protectedRoots = protectedDirs.map((folder) => windowsDriveRoot(folder.lexical));\n\tconst systemRootDrive = windowsDriveRoot(process.env.SystemRoot)?.toLowerCase();\n\tconst nonCSystemDrive = systemRootDrive !== undefined && systemRootDrive !== \"c:\\\\\";\n\t// On non-C: Windows installs, prefer the existing drive root of process.cwd() / SystemRoot before hardcoded\n\t// C:\\Windows (which may not exist). On standard C: installs (or unset SystemRoot), prefer C:\\Windows ahead of an\n\t// unverified SystemRoot that could be a junction pointing into the project folder.\n\tconst candidates = dedupeCandidates(\n\t\tnonCSystemDrive\n\t\t\t? [\n\t\t\t\t\t...protectedRoots,\n\t\t\t\t\twindowsDriveRoot(process.env.SystemRoot),\n\t\t\t\t\tcommandRoot,\n\t\t\t\t\t\"C:\\\\Windows\",\n\t\t\t\t\tprocess.env.SystemRoot,\n\t\t\t\t\tprocess.env.windir,\n\t\t\t\t\tcommandDir,\n\t\t\t\t\t\"C:\\\\\",\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t\"C:\\\\Windows\",\n\t\t\t\t\t...protectedRoots,\n\t\t\t\t\tcommandDir,\n\t\t\t\t\tcommandRoot,\n\t\t\t\t\tprocess.env.SystemRoot,\n\t\t\t\t\tprocess.env.windir,\n\t\t\t\t\t\"C:\\\\\",\n\t\t\t\t],\n\t);\n\tlet longOutsideFallback: string | undefined;\n\tlet shortFallback: string | undefined;\n\tlet anyFallback: string | undefined;\n\tfor (const rawCandidate of candidates) {\n\t\tconst lexical = normalizeWindowsPathForCompare(rawCandidate);\n\t\tif (lexical === undefined) continue;\n\t\tconst candidate: ResolvedCandidateDir = { lexical, real: undefined, unverifiedLink: false };\n\t\tconst chosen = toSpawnWindowsPath(lexical);\n\t\tconst isShort = isShortWindowsSpawnPath(chosen);\n\t\tconst insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));\n\t\tif (!insideAny) {\n\t\t\tif (isShort) return chosen;\n\t\t\tlongOutsideFallback ??= chosen;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isShort) shortFallback ??= chosen;\n\t\tanyFallback ??= chosen;\n\t}\n\treturn longOutsideFallback ?? shortFallback ?? anyFallback;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"windows-cwd.js","sourceRoot":"","sources":["../../src/utils/windows-cwd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,oHAAoH;AACpH,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,gHAAgH;AAChH,MAAM,CAAC,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAClD,4HAA4H;AAC5H,MAAM,gCAAgC,GAAG,EAAE,CAAC;AA+B5C,SAAS,aAAa,CAAC,IAAY;IAClC,OAAO,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,iBAAiB,CAAC,OAAe;IACzC,OAAO,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AACjH,CAAC;AAED,SAAS,gBAAgB,CAAC,OAAe;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC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ACV,WAAW;YACX,OAAO,CAAC,GAAG,CAAC,UAAU;YACtB,OAAO,CAAC,GAAG,CAAC,MAAM;YAClB,MAAM;SACN,CACH,CAAC;IACF,IAAI,mBAAuC,CAAC;IAC5C,IAAI,aAAiC,CAAC;IACtC,IAAI,WAA+B,CAAC;IACpC,KAAK,MAAM,YAAY,IAAI,UAAU,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,8BAA8B,CAAC,YAAY,CAAC,CAAC;QAC7D,IAAI,OAAO,KAAK,SAAS;YAAE,SAAS;QACpC,MAAM,SAAS,GAAyB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC;QAC5F,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,OAAO,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;QAC7F,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,IAAI,OAAO;gBAAE,OAAO,MAAM,CAAC;YAC3B,mBAAmB,KAAK,MAAM,CAAC;YAC/B,SAAS;QACV,CAAC;QACD,IAAI,OAAO;YAAE,aAAa,KAAK,MAAM,CAAC;QACtC,WAAW,KAAK,MAAM,CAAC;IACxB,CAAC;IACD,OAAO,mBAAmB,IAAI,aAAa,IAAI,WAAW,CAAC;AAC5D,CAAC","sourcesContent":["import { lstatSync, realpathSync, statSync } from \"node:fs\";\nimport { lstat, realpath, stat } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { win32 } from \"node:path\";\nimport { setLongTimeout } from \"@bastani/atomic-timers\";\n\n/** Safe Win32 path length threshold for `CreateProcessW` `lpCurrentDirectory` without an extended `\\\\?\\` prefix. */\nconst SAFE_WINDOWS_CWD_LENGTH = 248;\n/** Default upper bound on async filesystem probes so slow or offline UNC/OneDrive paths never stall callers. */\nexport const DEFAULT_WINDOWS_CWD_TIMEOUT_MS = 100;\n/** Maximum share of the timeout budget spent resolving protected directories' realpaths before probing local candidates. */\nconst MAX_PROTECTED_REALPATH_BUDGET_MS = 50;\n\ninterface ResolvedProtectedDir {\n\treadonly lexical: string;\n\treadonly real: string | undefined;\n}\n\ninterface ResolvedCandidateDir {\n\treadonly lexical: string;\n\treadonly real: string | undefined;\n\treadonly unverifiedLink: boolean;\n}\n\nexport interface SafeWindowsWorkingDirectoryOptions {\n\t/** Optional explicit/resolved command path whose directory and drive root may be used as fallbacks. */\n\treadonly commandPath?: string;\n\t/** Additional folders (besides `process.cwd()`) that the child process must not run inside. */\n\treadonly protectedDirs?: readonly (string | undefined)[];\n\t/**\n\t * Installation directories (e.g. extension dir, `dist/utils`, standalone executable dir) whose enclosing\n\t * install roots—both lexical and canonical realpath (catching `subst` drives and junctions)—must be protected.\n\t */\n\treadonly installDirs?: readonly (string | undefined)[];\n\t/** When true (kill/stop commands), try `commandPath`'s directory ahead of `os.tmpdir()`. */\n\treadonly preferCommandDir?: boolean;\n\t/** Maximum time in milliseconds spent on async `stat`/`realpath`/`lstat` probes. Default: 100 ms. */\n\treadonly timeoutMs?: number;\n\t/** Optional abort signal to cancel pending timeout timers immediately when the caller no longer needs the result. */\n\treadonly signal?: AbortSignal;\n}\n\nfunction isAsciiLetter(code: number): boolean {\n\treturn (code >= 65 && code <= 90) || (code >= 97 && code <= 122);\n}\n\nfunction isDriveRootPrefix(slashed: string): boolean {\n\treturn slashed.length >= 3 && isAsciiLetter(slashed.charCodeAt(0)) && slashed[1] === \":\" && slashed[2] === \"\\\\\";\n}\n\nfunction normalizeUncPath(slashed: string): string | undefined {\n\tconst rest = slashed.slice(2);\n\tconst firstSep = rest.indexOf(\"\\\\\");\n\tif (firstSep <= 0) return undefined;\n\tconst server = rest.slice(0, firstSep);\n\tif (server === \".\" || server === \"..\") return undefined;\n\tconst afterServer = rest.slice(firstSep + 1);\n\tconst secondSep = afterServer.indexOf(\"\\\\\");\n\tconst share = secondSep === -1 ? afterServer : afterServer.slice(0, secondSep);\n\tif (share === \"\" || share === \".\" || share === \"..\") return undefined;\n\treturn win32.resolve(slashed);\n}\n\n/**\n * Normalizes a fully-qualified Windows directory path for containment comparison.\n *\n * Strips extended-length and Win32 device prefixes (`\\\\?\\`, `\\\\.\\`, `\\\\?\\UNC\\`) so aliased paths compare\n * equal to their standard counterparts, preserves trailing separators on drive and share roots, and\n * rejects relative paths, bare drives (`C:`), drive-relative paths (`C:foo`), rooted-without-drive paths\n * (`\\Windows`), raw volume devices (`\\\\?\\C:`, `\\\\?\\Volume{...}` without `\\`), incomplete UNC roots, and\n * NUL bytes.\n */\nexport function normalizeWindowsPathForCompare(value: string): string | undefined {\n\tif (value === \"\" || value.includes(\"\\0\")) return undefined;\n\tconst slashed = value.replaceAll(\"/\", \"\\\\\");\n\tif (slashed.startsWith(\"\\\\\\\\?\\\\\") || slashed.startsWith(\"\\\\\\\\.\\\\\")) {\n\t\tconst rest = slashed.slice(4);\n\t\tif (rest.length >= 4 && rest.slice(0, 4).toLowerCase() === \"unc\\\\\") {\n\t\t\treturn normalizeUncPath(`\\\\\\\\${rest.slice(4)}`);\n\t\t}\n\t\tif (isDriveRootPrefix(rest)) {\n\t\t\treturn win32.resolve(rest);\n\t\t}\n\t\tif (rest.length > 9 && rest.slice(0, 7).toLowerCase() === \"volume{\") {\n\t\t\tconst sepIndex = rest.indexOf(\"\\\\\");\n\t\t\tif (sepIndex <= 8 || rest[sepIndex - 1] !== \"}\") return undefined;\n\t\t\tconst root = `\\\\\\\\?\\\\${rest.slice(0, sepIndex + 1)}`;\n\t\t\tconst tail = rest.slice(sepIndex + 1);\n\t\t\tconst normalizedTail = tail === \"\" ? \"\" : win32.resolve(\"C:\\\\\", tail).slice(3);\n\t\t\treturn `${root}${normalizedTail}`;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (slashed.startsWith(\"\\\\\\\\\")) {\n\t\treturn normalizeUncPath(slashed);\n\t}\n\tif (isDriveRootPrefix(slashed)) {\n\t\treturn win32.resolve(slashed);\n\t}\n\treturn undefined;\n}\n\n/**\n * Formats a normalized comparison path for Win32 filesystem / `CreateProcessW` APIs:\n * keeps short paths (< 248 chars) plain and ensures paths >= 248 chars carry the proper\n * extended-length prefix (`\\\\?\\` for drive paths, `\\\\?\\UNC\\server\\share\\...` for UNC paths).\n */\nexport function toSpawnWindowsPath(comparePath: string): string {\n\tif (comparePath.startsWith(\"\\\\\\\\?\\\\\") || comparePath.length < SAFE_WINDOWS_CWD_LENGTH) {\n\t\treturn comparePath;\n\t}\n\tif (comparePath.startsWith(\"\\\\\\\\\")) {\n\t\treturn `\\\\\\\\?\\\\UNC\\\\${comparePath.slice(2)}`;\n\t}\n\treturn `\\\\\\\\?\\\\${comparePath}`;\n}\n\nexport function isAbsoluteWindowsPath(value: string): boolean {\n\treturn normalizeWindowsPathForCompare(value) !== undefined;\n}\n\n/** Returns the normalized drive, UNC share, or volume root (always ending with `\\`) for an absolute Windows path. */\nexport function windowsDriveRoot(value: string | undefined): string | undefined {\n\tif (value === undefined) return undefined;\n\tconst normalized = normalizeWindowsPathForCompare(value);\n\tif (normalized === undefined) return undefined;\n\tif (normalized.startsWith(\"\\\\\\\\?\\\\\")) {\n\t\tconst sepIndex = normalized.indexOf(\"\\\\\", 4);\n\t\treturn sepIndex === -1 ? undefined : normalized.slice(0, sepIndex + 1);\n\t}\n\tconst root = win32.parse(normalized).root;\n\tif (root.length <= 1) return undefined;\n\treturn root.endsWith(\"\\\\\") ? root : `${root}\\\\`;\n}\n\nexport function isDriveRootWindowsPath(normalized: string): boolean {\n\tconst root = windowsDriveRoot(normalized);\n\treturn root !== undefined && normalized.toLowerCase() === root.toLowerCase();\n}\n\nfunction addNonRootWindowsDir(target: string[], seen: Set<string>, candidate: string): void {\n\tconst normalized = normalizeWindowsPathForCompare(candidate);\n\tif (normalized === undefined || isDriveRootWindowsPath(normalized)) return;\n\tconst key = normalized.toLowerCase();\n\tif (seen.has(key)) return;\n\tseen.add(key);\n\ttarget.push(normalized);\n}\n\n/**\n * Returns the install-root directories enclosing `entryDir` that background helpers must not keep as their working\n * directory on Windows (npm/pnpm/bun package root + `@scope`/`node_modules`, standalone binary `versions/<ver>` +\n * install root, or `dist/utils` package root). Never promotes a drive or share root to an inferred protected ancestor.\n */\nexport function collectInstallProtectedDirs(entryDir: string | undefined): string[] {\n\tif (entryDir === undefined || entryDir === \"\") return [];\n\tconst normalized = normalizeWindowsPathForCompare(entryDir);\n\tif (normalized === undefined) return [];\n\tconst result: string[] = [normalized];\n\tconst seen = new Set<string>([normalized.toLowerCase()]);\n\n\tconst add = (dir: string) => addNonRootWindowsDir(result, seen, dir);\n\tconst parent = win32.dirname(normalized);\n\tconst parentName = win32.basename(parent).toLowerCase();\n\tconst ownName = win32.basename(normalized).toLowerCase();\n\tconst grandParent = win32.dirname(parent);\n\tconst grandParentName = win32.basename(grandParent).toLowerCase();\n\n\tlet packageDir = normalized;\n\tif (parentName === \"builtin\" && grandParentName === \"dist\") {\n\t\tpackageDir = win32.dirname(grandParent);\n\t\tadd(grandParent);\n\t\tadd(packageDir);\n\t} else if (parentName === \"builtin\") {\n\t\tconst versionDir = grandParent;\n\t\tpackageDir = versionDir;\n\t\tadd(versionDir);\n\t\tconst versionDirName = win32.basename(versionDir).toLowerCase();\n\t\tconst versionsParent = win32.dirname(versionDir);\n\t\tif (win32.basename(versionsParent).toLowerCase() === \"versions\") {\n\t\t\tadd(versionsParent);\n\t\t\tadd(win32.dirname(versionsParent));\n\t\t} else if (versionDirName === \"current\" || versionDirName === \"atomic-current\") {\n\t\t\tadd(versionsParent);\n\t\t}\n\t} else if (ownName === \"utils\" && parentName === \"dist\") {\n\t\tpackageDir = grandParent;\n\t\tadd(parent);\n\t\tadd(packageDir);\n\t} else if (parentName === \"versions\") {\n\t\tadd(parent);\n\t\tadd(grandParent);\n\t} else if (ownName === \"current\" || ownName === \"atomic-current\") {\n\t\tadd(parent);\n\t}\n\n\tconst pkgParent = win32.dirname(packageDir);\n\tconst pkgParentName = win32.basename(pkgParent).toLowerCase();\n\tconst pkgGrandParent = win32.dirname(pkgParent);\n\tconst pkgGrandParentName = win32.basename(pkgGrandParent).toLowerCase();\n\tif (pkgParentName.startsWith(\"@\") && pkgGrandParentName === \"node_modules\") {\n\t\tadd(pkgParent);\n\t\tadd(pkgGrandParent);\n\t} else if (pkgParentName === \"node_modules\") {\n\t\tadd(pkgParent);\n\t}\n\n\treturn result;\n}\n\nfunction isSubpathOrSame(folderNormalized: string, candidateNormalized: string): boolean {\n\tconst rel = win32.relative(folderNormalized.toLowerCase(), candidateNormalized.toLowerCase());\n\treturn rel !== \"..\" && !rel.startsWith(\"..\\\\\") && !win32.isAbsolute(rel);\n}\n\nfunction conflictsWithNormalizedFolder(folderNormalized: string, candidateNormalized: string): boolean {\n\tif (isDriveRootWindowsPath(folderNormalized)) {\n\t\treturn folderNormalized.toLowerCase() === candidateNormalized.toLowerCase();\n\t}\n\treturn isSubpathOrSame(folderNormalized, candidateNormalized);\n}\n\nfunction isInsideProtectedFolder(folder: ResolvedProtectedDir, candidate: ResolvedCandidateDir): boolean {\n\tif (candidate.unverifiedLink) return true;\n\tif (folder.real !== undefined && candidate.real !== undefined) {\n\t\tif (isDriveRootWindowsPath(folder.real)) {\n\t\t\treturn folder.real.toLowerCase() === candidate.real.toLowerCase();\n\t\t}\n\t\tif (isSubpathOrSame(folder.real, candidate.real)) return true;\n\t\tif (!isDriveRootWindowsPath(folder.lexical) && isSubpathOrSame(folder.lexical, candidate.lexical)) return true;\n\t\treturn false;\n\t}\n\tif (conflictsWithNormalizedFolder(folder.lexical, candidate.lexical)) return true;\n\tif (folder.real !== undefined && conflictsWithNormalizedFolder(folder.real, candidate.lexical)) return true;\n\tif (candidate.real !== undefined && conflictsWithNormalizedFolder(folder.lexical, candidate.real)) return true;\n\treturn false;\n}\n\nfunction preferredCandidatePath(candidate: ResolvedCandidateDir): string {\n\treturn toSpawnWindowsPath(candidate.real ?? candidate.lexical);\n}\n\n/**\n * Win32 `CreateProcessW` rejects `lpCurrentDirectory` >= `MAX_PATH` (even with `\\\\?\\`) when Windows' default\n * `LongPathsEnabled = 0` is in effect. Prefer a short (< 248-char) verified directory outside the project whenever\n * one is available so kill commands work across both default Windows installs and `LongPathsEnabled = 1` hosts.\n */\nfunction isShortWindowsSpawnPath(spawnPath: string): boolean {\n\treturn !spawnPath.startsWith(\"\\\\\\\\?\\\\\") && spawnPath.length < SAFE_WINDOWS_CWD_LENGTH;\n}\n\nfunction probePathFor(rawDir: string, lexical: string): string {\n\tif (rawDir.length >= SAFE_WINDOWS_CWD_LENGTH && !rawDir.startsWith(\"\\\\\\\\?\\\\\")) {\n\t\treturn toSpawnWindowsPath(lexical);\n\t}\n\treturn rawDir;\n}\n\nfunction readProcessCwd(): string | undefined {\n\ttry {\n\t\treturn process.cwd();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction collectRawProtectedDirs(extra?: readonly (string | undefined)[]): string[] {\n\tconst result: string[] = [];\n\tconst seen = new Set<string>();\n\tconst add = (dir: string | undefined) => {\n\t\tif (dir === undefined) return;\n\t\tconst normalized = normalizeWindowsPathForCompare(dir);\n\t\tif (normalized === undefined) return;\n\t\tconst key = normalized.toLowerCase();\n\t\tif (seen.has(key)) return;\n\t\tseen.add(key);\n\t\tresult.push(dir);\n\t};\n\tadd(readProcessCwd());\n\tfor (const dir of extra ?? []) add(dir);\n\treturn result;\n}\n\nfunction dedupeCandidates(rawList: readonly (string | undefined)[]): string[] {\n\tconst deduped: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const item of rawList) {\n\t\tif (item === undefined || item === \"\") continue;\n\t\tconst key = item.toLowerCase();\n\t\tif (seen.has(key)) continue;\n\t\tseen.add(key);\n\t\tdeduped.push(item);\n\t}\n\treturn deduped;\n}\n\nfunction buildCandidates(\n\tprotectedDirs: readonly ResolvedProtectedDir[],\n\tcommandPath: string | undefined,\n\tpreferCommandDir: boolean,\n): readonly string[] {\n\tconst tempDir = tmpdir();\n\tconst normalizedCommand = commandPath === undefined ? undefined : normalizeWindowsPathForCompare(commandPath);\n\tconst commandDir = normalizedCommand === undefined ? undefined : win32.dirname(normalizedCommand);\n\tconst commandRoot = windowsDriveRoot(normalizedCommand);\n\tconst tempRoot = windowsDriveRoot(tempDir);\n\tconst protectedRoots: (string | undefined)[] = [];\n\tfor (const folder of protectedDirs) {\n\t\tprotectedRoots.push(windowsDriveRoot(folder.real));\n\t\tprotectedRoots.push(windowsDriveRoot(folder.lexical));\n\t}\n\tconst middle = preferCommandDir ? [commandDir, tempDir] : [tempDir, commandDir];\n\treturn dedupeCandidates([\n\t\tprocess.env.SystemRoot,\n\t\tprocess.env.windir,\n\t\t\"C:\\\\Windows\",\n\t\t...middle,\n\t\tcommandRoot,\n\t\ttempRoot,\n\t\t...protectedRoots,\n\t\twindowsDriveRoot(process.env.SystemRoot),\n\t\twindowsDriveRoot(process.env.windir),\n\t\t\"C:\\\\\",\n\t]);\n}\n\nfunction boundedFsCall<T>(work: Promise<T>, budgetMs: number, signal?: AbortSignal): Promise<T | undefined> {\n\tif (signal?.aborted || budgetMs <= 0) {\n\t\tvoid work.catch(() => {});\n\t\treturn Promise.resolve(undefined);\n\t}\n\treturn new Promise<T | undefined>((resolve) => {\n\t\tlet settled = false;\n\t\tconst done = (value: T | undefined) => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\ttimer.clear();\n\t\t\tsignal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve(value);\n\t\t};\n\t\tconst onAbort = () => done(undefined);\n\t\tconst timer = setLongTimeout(() => done(undefined), budgetMs, { ref: false });\n\t\tsignal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\twork.then(\n\t\t\t(value) => done(value),\n\t\t\t() => done(undefined),\n\t\t);\n\t});\n}\n\nfunction tryRealPathSync(dir: string): string | undefined {\n\ttry {\n\t\tconst native = realpathSync.native;\n\t\treturn normalizeWindowsPathForCompare(typeof native === \"function\" ? native(dir) : realpathSync(dir));\n\t} catch {\n\t\ttry {\n\t\t\treturn normalizeWindowsPathForCompare(realpathSync(dir));\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n\nfunction resolveProtectedDirSync(rawDir: string): ResolvedProtectedDir | undefined {\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\treturn { lexical, real: tryRealPathSync(probePathFor(rawDir, lexical)) };\n}\n\nfunction resolveCandidateDirSync(rawDir: string): ResolvedCandidateDir | undefined {\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\tconst probe = probePathFor(rawDir, lexical);\n\ttry {\n\t\tif (!statSync(probe).isDirectory()) return undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n\tconst real = tryRealPathSync(probe);\n\tlet unverifiedLink = false;\n\tif (real === undefined) {\n\t\ttry {\n\t\t\tunverifiedLink = lstatSync(probe).isSymbolicLink();\n\t\t} catch {\n\t\t\tunverifiedLink = false;\n\t\t}\n\t}\n\treturn { lexical, real, unverifiedLink };\n}\n\n/** Synchronously resolves a safe Windows working directory using `statSync` and `realpathSync.native`. */\nexport function resolveSafeWindowsWorkingDirectorySync(\n\toptions: SafeWindowsWorkingDirectoryOptions = {},\n): string | undefined {\n\tconst protectedDirs: ResolvedProtectedDir[] = [];\n\tconst seenProtected = new Set<string>();\n\tconst addProtected = (dir: ResolvedProtectedDir | undefined) => {\n\t\tif (dir === undefined) return;\n\t\tconst key = `${dir.lexical.toLowerCase()}\\0${dir.real?.toLowerCase() ?? \"\"}`;\n\t\tif (seenProtected.has(key)) return;\n\t\tseenProtected.add(key);\n\t\tprotectedDirs.push(dir);\n\t};\n\tfor (const raw of collectRawProtectedDirs(options.protectedDirs)) {\n\t\taddProtected(resolveProtectedDirSync(raw));\n\t}\n\tfor (const rawInstall of options.installDirs ?? []) {\n\t\tif (rawInstall === undefined) continue;\n\t\tconst resolvedEntry = resolveProtectedDirSync(rawInstall);\n\t\taddProtected(resolvedEntry);\n\t\tfor (const dir of collectInstallProtectedDirs(rawInstall)) {\n\t\t\taddProtected(resolveProtectedDirSync(dir));\n\t\t}\n\t\tif (resolvedEntry?.real !== undefined) {\n\t\t\tfor (const dir of collectInstallProtectedDirs(resolvedEntry.real)) {\n\t\t\t\taddProtected({ lexical: dir, real: tryRealPathSync(probePathFor(dir, dir)) ?? dir });\n\t\t\t}\n\t\t}\n\t}\n\tconst candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);\n\tlet longOutsideFallback: string | undefined;\n\tlet shortFallback: string | undefined;\n\tlet anyFallback: string | undefined;\n\tfor (const rawCandidate of candidates) {\n\t\tconst candidate = resolveCandidateDirSync(rawCandidate);\n\t\tif (candidate === undefined) continue;\n\t\tconst chosen = preferredCandidatePath(candidate);\n\t\tconst isShort = isShortWindowsSpawnPath(chosen);\n\t\tconst insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));\n\t\tif (!insideAny) {\n\t\t\tif (isShort) return chosen;\n\t\t\tlongOutsideFallback ??= chosen;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isShort) shortFallback ??= chosen;\n\t\tanyFallback ??= chosen;\n\t}\n\treturn longOutsideFallback ?? shortFallback ?? anyFallback;\n}\n\nasync function tryRealPathAsync(dir: string, deadline: number, signal?: AbortSignal): Promise<string | undefined> {\n\tconst resolved = await boundedFsCall(realpath(dir), deadline - Date.now(), signal);\n\treturn resolved === undefined ? undefined : normalizeWindowsPathForCompare(resolved);\n}\n\nasync function resolveProtectedDirAsync(\n\trawDir: string,\n\tdeadline: number,\n\tsignal?: AbortSignal,\n): Promise<ResolvedProtectedDir | undefined> {\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\tconst real = await tryRealPathAsync(probePathFor(rawDir, lexical), deadline, signal);\n\treturn { lexical, real };\n}\n\nasync function resolveCandidateDirAsync(\n\trawDir: string,\n\tdeadline: number,\n\tsignal?: AbortSignal,\n): Promise<ResolvedCandidateDir | undefined> {\n\tif (signal?.aborted || deadline - Date.now() <= 0) return undefined;\n\tconst lexical = normalizeWindowsPathForCompare(rawDir);\n\tif (lexical === undefined) return undefined;\n\tconst probe = probePathFor(rawDir, lexical);\n\tconst stats = await boundedFsCall(stat(probe), deadline - Date.now(), signal);\n\tif (!stats?.isDirectory()) return undefined;\n\tconst real = await tryRealPathAsync(probe, deadline, signal);\n\tlet unverifiedLink = false;\n\tif (real === undefined && !signal?.aborted && deadline - Date.now() > 0) {\n\t\tconst linkStats = await boundedFsCall(lstat(probe), deadline - Date.now(), signal);\n\t\tunverifiedLink = linkStats?.isSymbolicLink() === true;\n\t}\n\treturn { lexical, real, unverifiedLink };\n}\n\n/**\n * Asynchronously selects a safe existing Windows working directory outside `process.cwd()` (and any extra\n * protected folders) within a bounded time budget without blocking the event loop.\n */\nexport async function resolveSafeWindowsWorkingDirectoryAsync(\n\toptions: SafeWindowsWorkingDirectoryOptions = {},\n): Promise<string | undefined> {\n\tconst { signal } = options;\n\tif (signal?.aborted) return undefined;\n\tconst totalMs = Math.max(0, options.timeoutMs ?? DEFAULT_WINDOWS_CWD_TIMEOUT_MS);\n\tconst startedAt = Date.now();\n\tconst overallDeadline = startedAt + totalMs;\n\tconst protectedBudgetMs = Math.min(MAX_PROTECTED_REALPATH_BUDGET_MS, Math.floor(totalMs / 2));\n\tconst protectedDeadline = startedAt + protectedBudgetMs;\n\n\tconst installEntryKeys = new Set<string>();\n\tfor (const raw of options.installDirs ?? []) {\n\t\tif (raw === undefined) continue;\n\t\tconst normalized = normalizeWindowsPathForCompare(raw);\n\t\tif (normalized !== undefined) installEntryKeys.add(normalized.toLowerCase());\n\t}\n\tconst installLexical = (options.installDirs ?? []).flatMap((raw) => collectInstallProtectedDirs(raw));\n\tconst rawProtected = collectRawProtectedDirs([...(options.protectedDirs ?? []), ...installLexical]);\n\tconst resolvedProtected = await Promise.all(\n\t\trawProtected.map((raw) => resolveProtectedDirAsync(raw, protectedDeadline, signal)),\n\t);\n\tif (signal?.aborted) return undefined;\n\tconst protectedDirs: ResolvedProtectedDir[] = [];\n\tconst seenProtected = new Set<string>();\n\tconst addProtected = (dir: ResolvedProtectedDir | undefined) => {\n\t\tif (dir === undefined) return;\n\t\tconst key = `${dir.lexical.toLowerCase()}\\0${dir.real?.toLowerCase() ?? \"\"}`;\n\t\tif (seenProtected.has(key)) return;\n\t\tseenProtected.add(key);\n\t\tprotectedDirs.push(dir);\n\t};\n\tfor (const dir of resolvedProtected) {\n\t\taddProtected(dir);\n\t\tif (dir !== undefined && dir.real !== undefined && installEntryKeys.has(dir.lexical.toLowerCase())) {\n\t\t\tfor (const canonicalAncestor of collectInstallProtectedDirs(dir.real)) {\n\t\t\t\taddProtected({ lexical: canonicalAncestor, real: canonicalAncestor });\n\t\t\t}\n\t\t}\n\t}\n\tconst candidates = buildCandidates(protectedDirs, options.commandPath, options.preferCommandDir === true);\n\tlet longOutsideFallback: string | undefined;\n\tlet shortFallback: string | undefined;\n\tlet anyFallback: string | undefined;\n\tfor (const rawCandidate of candidates) {\n\t\tif (signal?.aborted || overallDeadline - Date.now() <= 0) break;\n\t\tconst candidate = await resolveCandidateDirAsync(rawCandidate, overallDeadline, signal);\n\t\tif (candidate === undefined) continue;\n\t\tconst chosen = preferredCandidatePath(candidate);\n\t\tconst isShort = isShortWindowsSpawnPath(chosen);\n\t\tconst insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));\n\t\tif (!insideAny) {\n\t\t\tif (isShort) return chosen;\n\t\t\tlongOutsideFallback ??= chosen;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isShort) shortFallback ??= chosen;\n\t\tanyFallback ??= chosen;\n\t}\n\treturn longOutsideFallback ?? shortFallback ?? anyFallback;\n}\n\n/**\n * Pure synchronous lexical working-directory selector for kill commands (zero filesystem syscalls).\n *\n * Avoids unverified `TMP`/`TEMP` paths (which may not exist) and prefers reliable OS directories\n * (`C:\\Windows` when `SystemRoot` is on `C:` or unset, or `process.cwd()`'s own drive root when Windows is\n * installed on another drive or `process.cwd()` is inside `C:\\Windows`), rejecting relative paths, bare drives,\n * raw devices, incomplete UNC roots, and paths lexically inside any protected folder (including `\\\\?\\`, `\\\\.\\`,\n * and `\\\\?\\UNC\\` aliases). Always preserves `\\\\?\\` / `\\\\?\\UNC\\` on paths >= 248 chars.\n */\nexport function resolveSafeWindowsKillCwdLexical(options: SafeWindowsWorkingDirectoryOptions = {}): string | undefined {\n\tconst protectedDirs: ResolvedProtectedDir[] = [];\n\tconst installLexical = (options.installDirs ?? []).flatMap((raw) => collectInstallProtectedDirs(raw));\n\tfor (const raw of collectRawProtectedDirs([...(options.protectedDirs ?? []), ...installLexical])) {\n\t\tconst lexical = normalizeWindowsPathForCompare(raw);\n\t\tif (lexical !== undefined) protectedDirs.push({ lexical, real: undefined });\n\t}\n\tconst normalizedCommand =\n\t\toptions.commandPath === undefined ? undefined : normalizeWindowsPathForCompare(options.commandPath);\n\tconst commandDir = normalizedCommand === undefined ? undefined : win32.dirname(normalizedCommand);\n\tconst commandRoot = windowsDriveRoot(normalizedCommand);\n\tconst protectedRoots = protectedDirs.map((folder) => windowsDriveRoot(folder.lexical));\n\tconst systemRootDrive = windowsDriveRoot(process.env.SystemRoot)?.toLowerCase();\n\tconst nonCSystemDrive = systemRootDrive !== undefined && systemRootDrive !== \"c:\\\\\";\n\t// On non-C: Windows installs, prefer the existing drive root of process.cwd() / SystemRoot before hardcoded\n\t// C:\\Windows (which may not exist). On standard C: installs (or unset SystemRoot), prefer C:\\Windows ahead of an\n\t// unverified SystemRoot that could be a junction pointing into the project folder.\n\tconst candidates = dedupeCandidates(\n\t\tnonCSystemDrive\n\t\t\t? [\n\t\t\t\t\t...protectedRoots,\n\t\t\t\t\twindowsDriveRoot(process.env.SystemRoot),\n\t\t\t\t\tcommandRoot,\n\t\t\t\t\t\"C:\\\\Windows\",\n\t\t\t\t\tprocess.env.SystemRoot,\n\t\t\t\t\tprocess.env.windir,\n\t\t\t\t\tcommandDir,\n\t\t\t\t\t\"C:\\\\\",\n\t\t\t\t]\n\t\t\t: [\n\t\t\t\t\t\"C:\\\\Windows\",\n\t\t\t\t\t...protectedRoots,\n\t\t\t\t\tcommandDir,\n\t\t\t\t\tcommandRoot,\n\t\t\t\t\tprocess.env.SystemRoot,\n\t\t\t\t\tprocess.env.windir,\n\t\t\t\t\t\"C:\\\\\",\n\t\t\t\t],\n\t);\n\tlet longOutsideFallback: string | undefined;\n\tlet shortFallback: string | undefined;\n\tlet anyFallback: string | undefined;\n\tfor (const rawCandidate of candidates) {\n\t\tconst lexical = normalizeWindowsPathForCompare(rawCandidate);\n\t\tif (lexical === undefined) continue;\n\t\tconst candidate: ResolvedCandidateDir = { lexical, real: undefined, unverifiedLink: false };\n\t\tconst chosen = toSpawnWindowsPath(lexical);\n\t\tconst isShort = isShortWindowsSpawnPath(chosen);\n\t\tconst insideAny = protectedDirs.some((folder) => isInsideProtectedFolder(folder, candidate));\n\t\tif (!insideAny) {\n\t\t\tif (isShort) return chosen;\n\t\t\tlongOutsideFallback ??= chosen;\n\t\t\tcontinue;\n\t\t}\n\t\tif (isShort) shortFallback ??= chosen;\n\t\tanyFallback ??= chosen;\n\t}\n\treturn longOutsideFallback ?? shortFallback ?? anyFallback;\n}\n"]}
|
package/docs/changelog.mdx
CHANGED
|
@@ -10,21 +10,13 @@ description: "What's new in Atomic"
|
|
|
10
10
|
After each release, the publish-release skill regenerates this page in its own docs PR.
|
|
11
11
|
*/}
|
|
12
12
|
|
|
13
|
-
<Update label="November 27, 2026" description="0.10.15
|
|
14
|
-
|
|
15
|
-
This prerelease removes unsupported Termux documentation and cleans up the Platform setup navigation.
|
|
16
|
-
|
|
17
|
-
- **Cleaner Platform setup docs.** Removed unsupported Android/Termux documentation (`termux.md` and Termux references across guides and READMEs, redirecting `/termux` to `/getting-started/installation`) and reordered Platform setup to Configure your terminal, Shell aliases, Run on Windows, Run in Tmux, and Run in Herdr ([#6765](https://github.com/bastani-inc/atomic/pull/6765), [#6766](https://github.com/bastani-inc/atomic/pull/6766)).
|
|
18
|
-
|
|
19
|
-
</Update>
|
|
20
|
-
|
|
21
|
-
<Update label="November 27, 2026" description="0.10.15-alpha.1">
|
|
13
|
+
<Update label="November 27, 2026" description="0.10.15">
|
|
22
14
|
|
|
23
15
|
This patch removes the remaining built-in compaction output caps, adds `~` home expansion to `shellPath`, and overhauls the documentation for clarity without reading source code.
|
|
24
16
|
|
|
25
17
|
- **No built-in compaction output caps on extensions.** `session_before_compact` hooks now keep whatever replacement text they return without enforcing a 32,000-token, 50%-trigger-share, or trigger-overflow cap, matching remote compactor models, while retiring the unused cap and line-width constants from compaction logic ([#6763](https://github.com/bastani-inc/atomic/pull/6763)).
|
|
26
18
|
- **Home-directory `~` expansion in `shellPath`.** Custom shell paths in `settings.json` now expand a leading `~/` (and `~\` on Windows) to your home directory, matching the documented schema ([#6763](https://github.com/bastani-inc/atomic/pull/6763)).
|
|
27
|
-
- **Reorganized, source-verified documentation.** Split Compaction into Memory Compaction, Custom Compactors, and Branch Summaries; added `How Atomic works`, `Slash commands`, `Choose a model`, `Worktree snapshots reference`, and `Background tasks reference`; grouped Models Reference with `models.json` fields; flattened single-page storage folders; and corrected verified source-vs-docs discrepancies across the docs ([#6763](https://github.com/bastani-inc/atomic/pull/6763)).
|
|
19
|
+
- **Reorganized, source-verified documentation.** Split Compaction into Memory Compaction, Custom Compactors, and Branch Summaries; added `How Atomic works`, `Slash commands`, `Choose a model`, `Worktree snapshots reference`, and `Background tasks reference`; grouped Models Reference with `models.json` fields; flattened single-page storage folders; removed unsupported Termux docs and cleaned up Platform setup navigation; and corrected verified source-vs-docs discrepancies across the docs ([#6763](https://github.com/bastani-inc/atomic/pull/6763), [#6765](https://github.com/bastani-inc/atomic/pull/6765), [#6766](https://github.com/bastani-inc/atomic/pull/6766)).
|
|
28
20
|
|
|
29
21
|
</Update>
|
|
30
22
|
|
package/docs/codemode.md
CHANGED
|
@@ -43,7 +43,7 @@ return { name: JSON.parse(pkg).name, excerpt: readme.slice(0, 400) };
|
|
|
43
43
|
| Option | Default | Behavior |
|
|
44
44
|
| --- | --- | --- |
|
|
45
45
|
| `max_output_tokens` | `10000` | Non-negative safe integer (`0` is accepted; character budget is `max_output_tokens * 4`). Text overflow keeps the start and end and writes full text to a temp file named in the result. Emitted images survive text truncation and keep their `[Image saved to ...]` paths intact. |
|
|
46
|
-
| `timeout_ms` | Unset | Hard deadline in milliseconds for the whole script, including waiting for a worker slot. Must be a positive
|
|
46
|
+
| `timeout_ms` | Unset | Hard deadline in milliseconds for the whole script, including waiting for a worker slot. Must be a positive whole number in JavaScript's safe range. `0`, negative numbers, decimals, or values outside that range fail before running. Avoid short deadlines when generating images, which can take minutes. |
|
|
47
47
|
|
|
48
48
|
**Result format.** Every run starts with `Script completed` or `Script failed` plus wall time, followed by text and image items in order. Multiple text items (from `text()` or `return`) are separated by `==> text N/M <==`, and `console.*` output follows in one `<console_output>` block. On failure, partial output is kept before `Script error:`. Side effects from completed tool calls are **not** rolled back; still-running tool calls are cancelled and unawaited promises are dropped when the script exits.
|
|
49
49
|
|
|
@@ -119,7 +119,7 @@ Two tools expose a script-safe subset:
|
|
|
119
119
|
|
|
120
120
|
`models` accesses the model catalog and calls non-LLM models using the session's credentials.
|
|
121
121
|
|
|
122
|
-
- **Classifiers.** Answer typed questions about JSON state (and images when supported). Examples: [TypeSafe Jev](/providers#typesafe-jev), [OpenAI GPT-6 Luna](/models#use-classifier-models), and [local llama.cpp models](/llama-cpp).
|
|
122
|
+
- **Classifiers.** Answer typed questions about JSON state (and images when supported). Examples: [TypeSafe Jev](/providers#typesafe-jev), [Gemini Decision 1](/providers#gemini-decisions), [OpenAI GPT-6 Luna](/models#use-classifier-models), and [local llama.cpp models](/llama-cpp).
|
|
123
123
|
- **Image models.** Generate or edit images. Examples: OpenRouter (`provider: "openrouter"`, IDs such as `google/gemini-2.5-flash-image` and `black-forest-labs/flux.2-pro`, reusing your OpenRouter credential) and OpenAI (`provider: "openai-images"`, such as `gpt-image-2.6-flare`, reusing your [OpenAI API key](/providers#subscription-and-api-key-at-the-same-time)).
|
|
124
124
|
|
|
125
125
|
Chat models are listed in the catalog (with active service-tier pricing) but cannot be called from scripts. Neither classifiers nor image models appear in `/model`.
|
|
@@ -179,6 +179,9 @@ interface ClassifierResult {
|
|
|
179
179
|
usage?: ModelUsage;
|
|
180
180
|
stopReason: "stop" | "error" | "aborted";
|
|
181
181
|
errorMessage?: string;
|
|
182
|
+
status?: number; // HTTP status, when reported
|
|
183
|
+
code?: string; // Failure code, when reported
|
|
184
|
+
retryAfterMs?: number; // Server-requested delay, when reported
|
|
182
185
|
}
|
|
183
186
|
|
|
184
187
|
type ClassifierAnswer =
|
|
@@ -49,6 +49,6 @@ Built-in branch summaries keep a cumulative list of read and modified files, car
|
|
|
49
49
|
|
|
50
50
|
## How summary requests run
|
|
51
51
|
|
|
52
|
-
Branch summary requests run no tools and bypass prompt cache writes so summarizing an abandoned branch does not disturb prompt caching on your main branch. They
|
|
52
|
+
Branch summary requests run no tools and bypass prompt cache writes so summarizing an abandoned branch does not disturb prompt caching on your main branch. They retry temporary failures within [your retry settings](/settings#retries-outside-chat). If the account is out of quota or the server asks for a wait longer than the retry limit, Atomic stops without retrying that model. To switch branches anyway, run `/tree` and choose **No summary**.
|
|
53
53
|
|
|
54
54
|
For the exact prompt template, `BranchSummaryEntry` structure, message serialization, edge cases, and the `session_before_tree` extension hook, see [Branch summary format](/compaction/reference#branch-summary-format) and [Extension hooks for branch summarization](/compaction/reference#extension-hooks-for-branch-summarization).
|
|
@@ -122,7 +122,7 @@ For the exact HTTP payload, header, token estimator, and response contract, see
|
|
|
122
122
|
|
|
123
123
|
## Automatic fallback to memory compaction
|
|
124
124
|
|
|
125
|
-
Every compactor failure falls back automatically to **Automatic** ([memory compaction](/compaction/memory-compaction)) so a broken, unauthenticated, or slow remote endpoint never blocks a session:
|
|
125
|
+
Every compactor failure falls back automatically to **Automatic** ([memory compaction](/compaction/memory-compaction)) so a broken, unauthenticated, or slow remote endpoint never blocks a session. Atomic does not retry the remote request. If the endpoint reports that your quota is exhausted, the SDK also marks that failure as not retryable; wait for the quota to reset or replenish it before trying remote compaction again. No settings change is needed for fallback:
|
|
126
126
|
|
|
127
127
|
```text
|
|
128
128
|
Compaction starts
|
|
@@ -199,7 +199,7 @@ For how Atomic sends requests to `ProviderCompactorModelConfig` endpoints, see [
|
|
|
199
199
|
For the complete list of per-API `compat` fields, see [`models.json` compatibility fields](/models-configuration#compatibility). Keep these rules in mind when declaring capabilities on custom providers:
|
|
200
200
|
|
|
201
201
|
- **Capability flags are enforcement claims, not preferences.** `supportsStrictMode` enables strict JSON-schema tools for OpenAI-compatible APIs and Amazon Bedrock Converse (`bedrock-converse-stream`); `supportsStrictTools` applies to Anthropic Messages (`anthropic-messages`) only; `supportsOpenAIGrammarTools` (or Atomic's alias `supportsGrammarTools`, where the canonical field wins on conflict) enables OpenAI Lark/regex custom tools. Leave these unset or `false` unless the endpoint actually enforces them ([Constrained sampling](/extensions/authoring#constrained-sampling)).
|
|
202
|
-
- **Session affinity headers differ by OpenAI API.**
|
|
202
|
+
- **Session affinity headers differ by OpenAI API.** With `compat.sessionAffinityFormat: "openai"`, `openai-responses` sends `session-id` (with `-`), and `openai-completions` sends `session_id` (with `_`) and `x-session-affinity`. `"openai-nosession"` omits the `session-id` or `session_id` header; `"openrouter"` uses `x-session-id`. Compatible endpoints explicitly using either OpenAI format can still receive `x-client-request-id` as an affinity header. Direct `api.openai.com` requests instead use that header for [per-attempt tracing](/models#request-tracing-and-duplicate-charges).
|
|
203
203
|
- **Responses gateway options.** Set `supportsToolSearch: true` only on `openai-responses` providers that support deferred tool loading. `supportsMaxOutputTokens` defaults to `true`; set it to `false` for Responses-compatible gateways that reject `max_output_tokens` with HTTP 400.
|
|
204
204
|
|
|
205
205
|
## OAuthLoginCallbacks
|
|
@@ -93,6 +93,8 @@ The `api` field selects one of Atomic's built-in chat streaming protocols:
|
|
|
93
93
|
| `bedrock-converse-stream` | Amazon Bedrock Converse API |
|
|
94
94
|
| `pi-messages` | Custom gateways speaking Atomic's native `pi-messages` protocol |
|
|
95
95
|
|
|
96
|
+
For a `pi-messages` gateway, return HTTP 404 when the requested model is unavailable or HTTP 400 when the request is incompatible. Chat uses those statuses to advance to the next [fallback model](/settings#fallbackmodels) without retrying the same request. For a temporary outage, return a server error such as HTTP 503 instead.
|
|
97
|
+
|
|
96
98
|
Image (`images`) and classifier (`classifiers`) handlers use their own operation-specific `api` keys independent of this table. Compactor models (`type: "compactor"`) declare a compactor `api` string at model or provider level and follow the [Compactor request contract](/compaction/reference#compactor-request-contract).
|
|
97
99
|
|
|
98
100
|
Most OpenAI-compatible servers use `openai-completions`. Configure model-specific thinking controls with `thinkingLevelMap` and server quirks with `compat`:
|
|
@@ -182,6 +184,7 @@ Confirm the intended account in your browser during login. An alias only isolate
|
|
|
182
184
|
How aliases behave:
|
|
183
185
|
|
|
184
186
|
- **Isolated credentials.** Each alias stores and refreshes its own credentials without borrowing the source's stored login or ambient environment keys. Keeping the same alias ID preserves saved credentials.
|
|
187
|
+
- **Main-chat fallback.** Separate alias names do not make a shared key or Codex account independent. If aliases use the same account at the same endpoint, Atomic skips them together after a rejected credential, exhausted quota, or rate-limit wait beyond the retry cap. Use a separate account with its own quota for a backup. See [`fallbackModels`](/settings#fallbackmodels).
|
|
185
188
|
- **Supported auth types.** Aliases work with OAuth logins and non-empty stored API keys. For ambient-only authentication (such as an AWS profile or environment-based service account), use the original provider or register a full custom provider instead.
|
|
186
189
|
- **Inherited configuration.** Aliases inherit the source's endpoint, shared headers, models, derived Fast variants, OAuth callbacks, and request handling. Do not hard-code account secrets in source headers; supply per-account credentials through `/login`. Saved messages and callbacks keep the alias ID.
|
|
187
190
|
- **Catalog updates.** Source catalog updates are shared across aliases while availability filters run per alias credential. Aliases do not run separate catalog discovery, except `github-copilot` aliases, which refresh their own account's model list independently.
|
|
@@ -121,7 +121,7 @@ function streamMyProvider(
|
|
|
121
121
|
| `toolChoice` | Provider-neutral tool selection preference |
|
|
122
122
|
| `temperature`, `maxTokens`, `samplingParams` | Generation parameters and custom request-body sampling overrides |
|
|
123
123
|
| `sessionId`, `cacheRetention`, `transport` | Session affinity ID, prompt-cache retention tier, and transport preference |
|
|
124
|
-
| `timeoutMs`, `websocketConnectTimeoutMs`, `streamDeadlineMs`, `retryDeadline` | Request, handshake,
|
|
124
|
+
| `timeoutMs`, `websocketConnectTimeoutMs`, `streamDeadlineMs`, `retryDeadline` | Request setup and response headers, WebSocket handshake, stream content progress, and retry admission limits. See [When a provider stops responding](/settings#when-a-provider-stops-responding) |
|
|
125
125
|
| `onPayload`, `onResponse`, `onProviderStreamEvent` | Lifecycle hooks to inspect or modify payloads, inspect HTTP responses, and observe parsed raw stream chunks before normalization |
|
|
126
126
|
|
|
127
127
|
## Event types
|
|
@@ -129,8 +129,8 @@ Sessions default to `~/.atomic/workflows/journal.sqlite`. With a custom `ATOMIC_
|
|
|
129
129
|
| `ATOMIC_EXPERIMENTAL` | `PI_EXPERIMENTAL` | Exact `1` enables experimental features and stricter JSON-schema tool-argument validation for additional built-in tools (`read`, `edit`, `write`, `bash`, and `powershell` already prefer strict schemas by default). The footer shows an `xp` badge |
|
|
130
130
|
| `ATOMIC_NO_PTY` | `PI_NO_PTY` | Exact `1` disables PTY allocation for `bash` and `powershell` tool commands and forces pipe execution |
|
|
131
131
|
| `ATOMIC_HEAP_MB` | `PI_HEAP_MB` | Node.js heap cap in MiB for interactive and non-interactive Node runs (unused by standalone binaries). Defaults to half of available system or container cgroup memory when larger than Node's default; `0` keeps Node's default; invalid values auto-size. Explicit Node heap flags (`--max-old-space-size`, `--max-old-space-size-percentage`, `--max-heap-size`) in `NODE_OPTIONS` or on the command line take precedence |
|
|
132
|
-
| `ATOMIC_STDIN_TIMEOUT_MS` | `PI_STDIN_TIMEOUT_MS` | Milliseconds a print-mode run (`-p`, `--mode json`) waits for the first piped byte or EOF before starting with a prompt argument (default `2000`,
|
|
133
|
-
| `ATOMIC_TOOL_ABORT_GRACE_MS` | None | Milliseconds (digits only) an interrupted tool call may keep running before the turn moves on with `Operation aborted` (default `10000`,
|
|
132
|
+
| `ATOMIC_STDIN_TIMEOUT_MS` | `PI_STDIN_TIMEOUT_MS` | Milliseconds a print-mode run (`-p`, `--mode json`) waits for the first piped byte or EOF before starting with a prompt argument (default `2000`, `0` waits until EOF; invalid values fall back to `2000`). See [Modes](/reference/cli#modes) |
|
|
133
|
+
| `ATOMIC_TOOL_ABORT_GRACE_MS` | None | Milliseconds (digits only) an interrupted tool call may keep running before the turn moves on with `Operation aborted` (default `10000`, `0` stops waiting immediately; invalid values fall back to `10000`). See [Message queue](/usage#message-queue) |
|
|
134
134
|
| `ATOMIC_CODEMODE_MAX_WORKERS` | `PI_CODEMODE_MAX_WORKERS` | Positive integer maximum live codemode workers per Atomic process (default `2`, each capped at 256 MiB; invalid values fall back to `2`). Extra scripts queue until a slot opens. See [Codemode](/codemode) |
|
|
135
135
|
| `ATOMIC_HOST_SPAWN` | None | Set to `child-process` to launch helper processes (Git snapshots, `rg`, `fd`, worktree setup, and standalone shell commands) through standard Node child spawning instead of Atomic's native spawner. Useful for troubleshooting process-spawning issues on Linux or Windows |
|
|
136
136
|
| `ATOMIC_TASK_CGROUP` | None | Exact `0` disables Linux cgroup v2 process-tree containment for background shell tasks. See [Lifetime, retention, and process cleanup](/background-tasks/reference#lifetime-retention-and-cleanup) |
|
|
@@ -195,6 +195,7 @@ Stopping and concurrent builds:
|
|
|
195
195
|
- **Graceful stop (Ctrl-C, signals, or RPC stdin closing).** Atomic stops running build processes and rebuilds the worktree on the next resume.
|
|
196
196
|
- **Abrupt kill (`SIGKILL`).** On Unix, the next resume cancels the interrupted build, terminates confirmed recorded build processes, sets that worktree aside so no session reuses it, and restores and builds a fresh worktree with a warning naming the set-aside path and logs. Atomic cleans up set-aside worktrees once no process uses them ([Pooling and set-aside worktrees](/worktree-snapshots/reference#idle-reuse-eviction-and-set-aside-worktrees)). On Windows, step processes exit with Atomic, so the next resume rebuilds the same worktree.
|
|
197
197
|
- **Concurrent resumes on one worktree.** Only one build runs per worktree. Switching back to a session whose build is still running joins it. Another Atomic process waits up to 5 minutes (printing a stderr line or emitting `blueprint_build_waiting`) before rebuilding with a warning.
|
|
198
|
+
- **Concurrent blueprint ledger updates.** Builds on the same machine take turns saving their results. Atomic tells you when it is waiting for another writer. If it can tell that writer has stopped, it continues without waiting for the lock to expire. Locks from older versions that do not identify a writer still expire after 15 seconds without a refresh.
|
|
198
199
|
|
|
199
200
|
To override the mode default, set `resume.waitForBlueprint` in settings:
|
|
200
201
|
|
package/docs/libraries/ai.md
CHANGED
|
@@ -1527,7 +1527,8 @@ interface OpenAICompletionsCompat {
|
|
|
1527
1527
|
supportsStrictMode?: boolean; // Whether provider supports `strict` in tool definitions (default: false; enabled in metadata for capable built-in models)
|
|
1528
1528
|
supportsOpenAIGrammarTools?: boolean; // Whether to emit OpenAI custom Lark/regex grammar tools; false falls back to normal function tools (default: false; the generated catalog enables it for capable models)
|
|
1529
1529
|
sendSessionAffinityHeaders?: boolean; // Send session-affinity data from `sessionId` (default: true for OpenRouter, false otherwise)
|
|
1530
|
-
sessionAffinityFormat?: 'openai' | 'openai-nosession' | 'openrouter'; //
|
|
1530
|
+
sessionAffinityFormat?: 'openai' | 'openai-nosession' | 'openrouter'; // 'openai' sends `session_id` and `x-session-affinity`; 'openai-nosession' sends only `x-session-affinity`; 'openrouter' sends `x-session-id`. Non-OpenAI endpoints using the OpenAI formats also get the legacy `x-client-request-id` affinity header.
|
|
1531
|
+
sendIdempotencyKey?: boolean; // Send an `Idempotency-Key` stable across retries. Default: false. Only enable on endpoints that support it.
|
|
1531
1532
|
maxTokensField?: 'max_completion_tokens' | 'max_tokens'; // Which field name to use (default: max_completion_tokens)
|
|
1532
1533
|
requiresToolResultName?: boolean; // Whether tool results require the `name` field (default: false)
|
|
1533
1534
|
requiresAssistantAfterToolResult?: boolean; // Whether tool results must be followed by an assistant message (default: false)
|
|
@@ -1548,7 +1549,8 @@ interface OpenAICompletionsCompat {
|
|
|
1548
1549
|
|
|
1549
1550
|
interface OpenAIResponsesCompat {
|
|
1550
1551
|
supportsDeveloperRole?: boolean; // Whether provider supports `developer` role vs `system` (default: true)
|
|
1551
|
-
sessionAffinityFormat?: 'openai' | 'openai-nosession' | 'openrouter'; //
|
|
1552
|
+
sessionAffinityFormat?: 'openai' | 'openai-nosession' | 'openrouter'; // 'openai' sends `session-id`, 'openai-nosession' omits it, and 'openrouter' sends `x-session-id`. Non-OpenAI endpoints explicitly using the OpenAI formats also get the legacy `x-client-request-id` affinity header. Does not affect `prompt_cache_key`.
|
|
1553
|
+
sendIdempotencyKey?: boolean; // Send an `Idempotency-Key` stable across retries. Default: false. Only enable on endpoints that support it.
|
|
1552
1554
|
supportsLongCacheRetention?: boolean; // Whether provider supports `prompt_cache_retention: "24h"` (default: true)
|
|
1553
1555
|
supportsStrictMode?: boolean; // Whether provider supports strict JSON-schema function tools (default: false; enabled in metadata for built-in OpenAI models)
|
|
1554
1556
|
supportsOpenAIGrammarTools?: boolean; // Whether to emit OpenAI custom Lark/regex grammar tools; false falls back to normal function tools (default: false; the generated catalog enables it for capable models)
|
|
@@ -106,7 +106,7 @@ text(JSON.parse(source).name);
|
|
|
106
106
|
Supported header fields (snake_case):
|
|
107
107
|
|
|
108
108
|
- `max_output_tokens`: non-negative safe integer (`>= 0`), returned as `options.maxOutputTokens`.
|
|
109
|
-
- `timeout_ms`: positive safe integer
|
|
109
|
+
- `timeout_ms`: positive safe integer, returned as `options.timeoutMs`.
|
|
110
110
|
|
|
111
111
|
`parseCodemodeSource()` returns `{ code, options: { maxOutputTokens?, timeoutMs? } }` and replaces line 1 with a blank line so stack-trace line numbers match the input. Empty input, invalid JSON, unknown fields, header-only input, or a header after line 1 throws `CodemodeSourceError`. `CODEMODE_SOURCE_GRAMMAR` exports a Lark grammar for grammar-constrained tool calling (both also exported from `@bastani/atomic-codemode/source`). The sandbox does not enforce these parsed options automatically; your caller applies them.
|
|
112
112
|
|
|
@@ -114,7 +114,7 @@ In addition to chat models, Atomic supports three specialized model kinds. None
|
|
|
114
114
|
| Model kind | Configured via | Built-in options | Learn more |
|
|
115
115
|
| --- | --- | --- | --- |
|
|
116
116
|
| **Chat** | `/model`, `defaultModel`, `enabledModels`, `fallbackModels` | All built-in, `models.json`, `llama.cpp`, and extension chat providers | [Connect providers](/providers) |
|
|
117
|
-
| **Classifier** | `decisionModel` (`/settings` → **Decision model**) or codemode | `openai-decisions/gpt-6-luna`, `typesafe/jev-latest`, Cloudflare Clef and Jev, GitHub Copilot, OpenRouter, Vercel AI Gateway, OpenCode Zen, local `llama.cpp` | [Classifier models](/models#use-classifier-models) |
|
|
117
|
+
| **Classifier** | `decisionModel` (`/settings` → **Decision model**) or codemode | `google-decisions/gemini-decision-1`, `openai-decisions/gpt-6-luna`, `typesafe/jev-latest`, Cloudflare Clef and Jev, GitHub Copilot, OpenRouter, Vercel AI Gateway, OpenCode Zen, local `llama.cpp` | [Classifier models](/models#use-classifier-models) |
|
|
118
118
|
| **Compactor** | `compactionModel` (`/settings` → **Compaction model**) | `"auto"` (built-in memory compaction) or `morph/morph-compactor`, plus custom compactors in `models.json` | [Custom compactors](/compaction/custom-compactors) |
|
|
119
119
|
| **Image** | Codemode (`models.generateImages()`) or extensions (`ctx.modelRegistry.generateImages()`) | `openai-images` (GPT Image 1 through GPT Image 2.6, including SVG and GIF) and `openrouter` image models | [Image models](/models#use-image-models) |
|
|
120
120
|
|
|
@@ -149,7 +149,8 @@ See [Image input limits](/models/reference#image-input-limits).
|
|
|
149
149
|
| `supportsStrictMode` | boolean | `false` | Whether the provider supports the strict field in tool definitions. Generated capable models enable it explicitly. |
|
|
150
150
|
| `cacheControlFormat` | `"anthropic"` | | Cache control convention for prompt caching. Anthropic applies cache_control markers to the system prompt, last tool definition, and last user, assistant, or tool-result text content. |
|
|
151
151
|
| `sendSessionAffinityHeaders` | boolean | | Whether to send session-affinity data from options.sessionId. Default: true for OpenRouter endpoints, false otherwise. |
|
|
152
|
-
| `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session_id
|
|
152
|
+
| `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session_id and x-session-affinity; openai-nosession sends x-session-affinity; openrouter sends x-session-id. Compatible endpoints using either OpenAI format also receive the legacy x-client-request-id affinity header. api.openai.com uses that header for request tracing instead. Does not affect prompt_cache_key. Default: auto-detected. |
|
|
153
|
+
| `sendIdempotencyKey` | boolean | | Send an Idempotency-Key across retries of the same request. Enable only if the endpoint documents support. Default: false. |
|
|
153
154
|
| `promptCacheKeyMode` | `"auto" \| "enabled" \| "disabled"` | | Controls the prompt_cache_key request field. auto sends it to api.openai.com, or with long cache retention when supportsLongCacheRetention is true; enabled sends it whenever caching is active, for compatible proxies; disabled never sends it. Default: auto. |
|
|
154
155
|
| `supportsLongCacheRetention` | boolean | | Whether the provider supports long prompt cache retention (prompt_cache_retention: "24h" or Anthropic-style cache_control.ttl: "1h", depending on format). Default: auto-detected from provider and URL. |
|
|
155
156
|
| `vllmPriority` | number | | vLLM scheduler priority sent as the top-level priority request field. Lower values are handled earlier and the server default is 0. Only meaningful with --scheduling-policy priority. Off by default and not set on the generated catalog. |
|
|
@@ -162,7 +163,8 @@ Also applies to `azure-openai-responses` and `openai-codex-responses`.
|
|
|
162
163
|
|---|---|---|---|
|
|
163
164
|
| `supportsDeveloperRole` | boolean | `true` | Whether the provider supports the developer role instead of system. |
|
|
164
165
|
| `supportsMidConvoSystemMessages` | boolean | `false` | Whether the exact model accepts developer or system messages after the conversation has started. When false, later system messages are folded into the leading system message. The generated catalog enables this for verified models. |
|
|
165
|
-
| `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session-id
|
|
166
|
+
| `sessionAffinityFormat` | `"openai" \| "openai-nosession" \| "openrouter"` | | Session-affinity header format. openai sends session-id; openrouter sends x-session-id. Compatible endpoints explicitly configured with openai or openai-nosession also receive the legacy x-client-request-id affinity header. api.openai.com uses that header for request tracing instead. Does not affect prompt_cache_key. Default: auto-detected. |
|
|
167
|
+
| `sendIdempotencyKey` | boolean | | Send an Idempotency-Key across retries of the same openai-responses request. Enable only if the endpoint documents support. Does not apply to Codex or Azure Responses. Default: false. |
|
|
166
168
|
| `promptCacheKeyMode` | `"auto" \| "enabled" \| "disabled"` | | Controls the prompt_cache_key request field. auto and enabled send it whenever caching is active; disabled never sends it, for compatible proxies that reject it. Default: auto. |
|
|
167
169
|
| `supportsLongCacheRetention` | boolean | `true` | Whether the provider supports long prompt cache retention. This uses prompt_cache_options.ttl: "30m" on GPT-5.6+ and prompt_cache_retention: "24h" on earlier models. |
|
|
168
170
|
| `supportsStrictMode` | boolean | | Whether the provider supports strict JSON-schema function tools. Defaults are API-specific; generated OpenAI models enable it explicitly. |
|
|
@@ -177,6 +179,7 @@ Also applies to `azure-openai-responses` and `openai-codex-responses`.
|
|
|
177
179
|
|
|
178
180
|
| Field | Type | Default | Description |
|
|
179
181
|
|---|---|---|---|
|
|
182
|
+
| `thinkingDisplay` | `"updates" \| "summarized" \| "omitted"` | | Default Anthropic thinking display for this model. Use summarized to prefer reasoning summaries over separately visible progress updates. |
|
|
180
183
|
| `supportsEagerToolInputStreaming` | boolean | `true` | Whether the provider accepts per-tool eager_input_streaming. When false, the Anthropic provider omits tools[].eager_input_streaming and sends the legacy fine-grained-tool-streaming-2025-05-14 beta header for tool-enabled requests. |
|
|
181
184
|
| `supportsLongCacheRetention` | boolean | `true` | Whether the provider supports Anthropic long cache retention through cache_control.ttl. |
|
|
182
185
|
| `sendSessionAffinityHeaders` | boolean | | Whether to send x-session-affinity from options.sessionId when caching is enabled. Required for providers like Fireworks that use session affinity for prompt cache routing; requests to the same replica maximize cache hits. Default: true for OpenRouter endpoints, false otherwise. |
|
package/docs/models.md
CHANGED
|
@@ -102,6 +102,34 @@ Some OpenAI-compatible servers (such as Ollama, vLLM, or SGLang) reject the `dev
|
|
|
102
102
|
}
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
### Request tracing and duplicate charges
|
|
106
|
+
|
|
107
|
+
- **[`X-Client-Request-Id`](https://developers.openai.com/api/reference/overview#supplying-your-own-request-id-with-x-client-request-id)** lets OpenAI look up a request, even if the connection dropped before it returned an `x-request-id`. By default, Atomic sends a fresh UUID for every Chat Completions or Responses attempt to `api.openai.com`, including retries. This doesn't change the session ID or prompt-cache key. Tracing IDs, including Cloudflare's `cf-aig-event-id`, **do not prevent duplicate execution or billing**.
|
|
108
|
+
- **Z.ai and Zhipu Coding CN** get a fresh request ID on every attempt, including retries. The ID helps the provider look up a request that timed out; it does not prevent duplicate work or charges.
|
|
109
|
+
- **`Idempotency-Key`** asks a supporting endpoint not to run the same operation twice. Atomic keeps the key for retries of the same request and uses a new one for the next request. This is off by default. Only enable it for models using `openai-completions` or `openai-responses` whose endpoint explicitly documents support. Whether a duplicate is billed, and whether a retry can retrieve the original answer, depends on the endpoint.
|
|
110
|
+
|
|
111
|
+
For example, [OP Inference supports idempotency keys for Chat Completions](https://docs.opinference.com/docs/routing/idempotency). Add this provider to `~/.atomic/agent/models.json`, set `OP_API_KEY` in the environment where you launch Atomic, and select `/model op-inference/openai/gpt-oss-120b`:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"providers": {
|
|
116
|
+
"op-inference": {
|
|
117
|
+
"baseUrl": "https://api.opinference.com/v1",
|
|
118
|
+
"api": "openai-completions",
|
|
119
|
+
"apiKey": "$OP_API_KEY",
|
|
120
|
+
"models": [
|
|
121
|
+
{
|
|
122
|
+
"id": "openai/gpt-oss-120b",
|
|
123
|
+
"compat": { "sendIdempotencyKey": true }
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
OP Inference returns a `409 idempotency_conflict` for a duplicate chat completion instead of replaying the answer. Atomic stops retrying that request when it gets this error. If you configured a fallback model, Atomic can still try it as a new request, which may incur a separate charge. Don't set a static `Idempotency-Key` in `headers`: a key must never be shared between unrelated requests.
|
|
132
|
+
|
|
105
133
|
### Prompt cache lifetimes
|
|
106
134
|
|
|
107
135
|
Declare `promptCache` with positive lifetimes in seconds for `short` and `long` cache-retention tiers when configuring a custom model or overriding a built-in model:
|
|
@@ -216,6 +244,7 @@ Classifier models answer typed questions (`choice`, `bool`, `score`) about struc
|
|
|
216
244
|
|
|
217
245
|
Built-in classifiers:
|
|
218
246
|
|
|
247
|
+
- **Gemini Decisions:** `google-decisions/gemini-decision-1` answers yes/no, choice, and score questions about text and images. It uses your saved `/login google` API key, `GEMINI_API_KEY`, or `GOOGLE_API_KEY`. See [Gemini Decisions](/providers#gemini-decisions) for supported inputs and limits.
|
|
219
248
|
- **OpenAI Decisions:** `openai-decisions/gpt-6-luna` via OpenAI's [Decisions API](https://developers.openai.com/api/docs/guides/decisions). It has no `/login` entry and reuses the first OpenAI API key found (`openai-api`, `openai` API key, then `OPENAI_API_KEY`), skipping ChatGPT sign-in. It accepts up to 128 images and up to 922K tokens; requests above roughly 600K tokens may hit a gateway 504 timeout that is not retried. (`openai/gpt-6-luna` always selects the chat model.)
|
|
220
249
|
- **TypeSafe Jev (direct):** `typesafe/jev-latest` and `typesafe/jev-1.14.0` (up to 262K tokens with PNG/JPEG images; see [TypeSafe Jev](/providers#typesafe-jev)).
|
|
221
250
|
- **Cloudflare Workers AI:** Cloudflare Clef (`@cf/cloudflare/clef`, `@cf/cloudflare/clef-flash`, `@cf/cloudflare/clef-omni`, up to four PNG/JPEG/WebP images) and TypeSafe Jev (`typesafe/jev`, `typesafe/jev-1.14.0`, PNG/JPEG images).
|
|
@@ -226,6 +255,8 @@ Built-in classifiers:
|
|
|
226
255
|
|
|
227
256
|
Open `/settings` → **Decision model** or run `models.getAvailableOfType("classifier")` in codemode to see every classifier available for your authenticated providers.
|
|
228
257
|
|
|
258
|
+
Built-in classifiers do not retry when the provider reports that your account is out of quota. Temporary throttles can still retry if the provider's requested wait fits within the [retry limit](/settings#retries-outside-chat). If you call `models.classify()` directly, failure results include `retryAfterMs` when the provider supplied a delay, even if it exceeded the limit. SDK callers can set the limit with `maxRetryDelayMs` (60,000 ms by default, `0` to disable it). If your quota is exhausted, wait for it to reset, replenish it, or choose a different provider.
|
|
259
|
+
|
|
229
260
|
TypeSafe's **System One** classifier protocol (`/v1/systemone`)—also used by Cloudflare Workers AI, OpenRouter, GitHub Copilot, and Vercel AI Gateway classifiers—accepts different image request layouts depending on the host, controlled by `compat.imageInput` (`"assets"`, `"images"`, or `"state-image-urls"`). Built-in entries configure this automatically, so overriding `baseUrl` preserves it. For a custom proxy targeting another classifier service, set `imageInput` and `sendImageOptInHeader` in provider-level `compat` (for example, a proxy in front of OpenRouter needs `"imageInput": "state-image-urls"` and `"sendImageOptInHeader": false` so OpenRouter does not silently drop images). See [System One compatibility](/models-configuration#typesafe-system-one).
|
|
230
261
|
|
|
231
262
|
## Use image models {#use-image-models}
|
|
@@ -242,6 +273,7 @@ Built-in image providers:
|
|
|
242
273
|
- **OpenRouter (`openrouter`):**
|
|
243
274
|
- Reuses your OpenRouter credential (`/login openrouter` or `OPENROUTER_API_KEY`).
|
|
244
275
|
- Exposes multi-vendor image models through OpenRouter's image generation API—such as `google/gemini-2.5-flash-image`, `google/gemini-3-pro-image`, `black-forest-labs/flux.2-pro`, `black-forest-labs/flux-3-image`, `openai/gpt-image-2.6-flare`, and `recraft/recraft-v4-pro-vector`. OpenAI-specific `ImagesOptions` are ignored by OpenRouter image models.
|
|
276
|
+
- If OpenRouter says the account is out of quota, Atomic returns the error without retrying. Wait for the quota to reset, replenish it, or use another provider. Temporary throttles can still retry if an SDK caller sets `maxRetries` above its default of `0` and the requested wait is within `maxRetryDelayMs` (60,000 ms by default).
|
|
245
277
|
|
|
246
278
|
Example in [codemode](/codemode#generate-images):
|
|
247
279
|
|