toolcraft 0.0.749 → 0.0.750
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/composition.json +23 -3
- package/dist/composition.json +23 -3
- package/dist/human-in-loop/approvals-commands.d.ts +1 -1
- package/dist/index.d.ts +1 -262
- package/dist/index.js +1 -573
- package/dist/runtime-platform.d.ts +2 -0
- package/dist/runtime-platform.js +2 -0
- package/dist/runtime-platform.workerd.d.ts +3 -0
- package/dist/runtime-platform.workerd.js +10 -0
- package/dist/runtime.d.ts +262 -0
- package/dist/runtime.js +576 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +478 -0
- package/node_modules/@noble/hashes/_blake.d.ts +20 -0
- package/node_modules/@noble/hashes/_blake.js +59 -0
- package/node_modules/@noble/hashes/_md.d.ts +95 -0
- package/node_modules/@noble/hashes/_md.js +209 -0
- package/node_modules/@noble/hashes/_u64.d.ts +36 -0
- package/node_modules/@noble/hashes/_u64.js +77 -0
- package/node_modules/@noble/hashes/argon2.d.ts +148 -0
- package/node_modules/@noble/hashes/argon2.js +577 -0
- package/node_modules/@noble/hashes/blake1.d.ts +162 -0
- package/node_modules/@noble/hashes/blake1.js +630 -0
- package/node_modules/@noble/hashes/blake2.d.ts +203 -0
- package/node_modules/@noble/hashes/blake2.js +573 -0
- package/node_modules/@noble/hashes/blake3.d.ts +68 -0
- package/node_modules/@noble/hashes/blake3.js +310 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +91 -0
- package/node_modules/@noble/hashes/eskdf.js +225 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +70 -0
- package/node_modules/@noble/hashes/hkdf.js +152 -0
- package/node_modules/@noble/hashes/hmac.d.ts +50 -0
- package/node_modules/@noble/hashes/hmac.js +93 -0
- package/node_modules/@noble/hashes/index.d.ts +1 -0
- package/node_modules/@noble/hashes/index.js +34 -0
- package/node_modules/@noble/hashes/legacy.d.ts +107 -0
- package/node_modules/@noble/hashes/legacy.js +348 -0
- package/node_modules/@noble/hashes/package.json +91 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
- package/node_modules/@noble/hashes/pbkdf2.js +176 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +98 -0
- package/node_modules/@noble/hashes/scrypt.js +304 -0
- package/node_modules/@noble/hashes/sha2.d.ts +176 -0
- package/node_modules/@noble/hashes/sha2.js +446 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
- package/node_modules/@noble/hashes/sha3-addons.js +973 -0
- package/node_modules/@noble/hashes/sha3.d.ts +208 -0
- package/node_modules/@noble/hashes/sha3.js +475 -0
- package/node_modules/@noble/hashes/src/_blake.ts +67 -0
- package/node_modules/@noble/hashes/src/_md.ts +227 -0
- package/node_modules/@noble/hashes/src/_u64.ts +111 -0
- package/node_modules/@noble/hashes/src/argon2.ts +693 -0
- package/node_modules/@noble/hashes/src/blake1.ts +677 -0
- package/node_modules/@noble/hashes/src/blake2.ts +648 -0
- package/node_modules/@noble/hashes/src/blake3.ts +344 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +265 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +161 -0
- package/node_modules/@noble/hashes/src/hmac.ts +130 -0
- package/node_modules/@noble/hashes/src/index.ts +33 -0
- package/node_modules/@noble/hashes/src/legacy.ts +361 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +375 -0
- package/node_modules/@noble/hashes/src/sha2.ts +486 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
- package/node_modules/@noble/hashes/src/sha3.ts +525 -0
- package/node_modules/@noble/hashes/src/utils.ts +978 -0
- package/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
- package/node_modules/@noble/hashes/utils.d.ts +560 -0
- package/node_modules/@noble/hashes/utils.js +687 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
- package/node_modules/@noble/hashes/webcrypto.js +228 -0
- package/node_modules/@poe-code/agent-mcp-config/dist/apply.js +23 -9
- package/node_modules/@poe-code/config-mutations/README.md +2 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +4 -5
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +3 -4
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +3 -3
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +1 -1
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +2 -2
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +3 -6
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +4 -2
- package/node_modules/@poe-code/process-runner/README.md +2 -1
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.d.ts +1 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.js +1 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.d.ts +2 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.js +1 -0
- package/node_modules/@poe-code/process-runner/dist/types.d.ts +1 -1
- package/node_modules/@poe-code/process-runner/dist/workspace-transfer.d.ts +6 -5
- package/node_modules/@poe-code/process-runner/dist/workspace-transfer.js +67 -29
- package/node_modules/@poe-code/process-runner/package.json +13 -0
- package/node_modules/@poe-code/safe-fs/LICENSE +21 -0
- package/node_modules/@poe-code/safe-fs/PROVENANCE.json +428 -0
- package/node_modules/@poe-code/safe-fs/README.md +411 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.js +171 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.d.ts +93 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.js +453 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/index.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/index.js +19 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/stats.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/stats.js +37 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/types.d.ts +81 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/types.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/values.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/values.js +65 -0
- package/node_modules/@poe-code/safe-fs/dist/config/memory.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/config/memory.js +7 -0
- package/node_modules/@poe-code/safe-fs/dist/config/real.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/config/real.js +16 -0
- package/node_modules/@poe-code/safe-fs/dist/config/registry.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/config/registry.js +15 -0
- package/node_modules/@poe-code/safe-fs/dist/config.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/config.js +46 -0
- package/node_modules/@poe-code/safe-fs/dist/config.node.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/config.node.js +11 -0
- package/node_modules/@poe-code/safe-fs/dist/config.portable.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/config.portable.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/abort.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/abort.js +34 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.d.ts +38 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/errors.d.ts +53 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/errors.js +99 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.d.ts +379 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/index.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/index.js +6 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/io.d.ts +12 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/io.js +321 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/object.d.ts +134 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/object.js +97 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/path.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/path.js +2 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.d.ts +21 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.js +78 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.js +162 -0
- package/node_modules/@poe-code/safe-fs/dist/core.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/core.js +17 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.d.ts +10 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.js +216 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.js +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.d.ts +21 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.js +279 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.d.ts +59 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.js +875 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.js +250 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.js +136 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.js +14 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.d.ts +11 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.js +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.d.ts +186 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.js +3771 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.js +96 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.d.ts +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.js +26 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.js +144 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.js +118 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.js +29 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.d.ts +74 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.js +1291 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.d.ts +27 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.js +287 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.d.ts +45 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.js +531 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.d.ts +87 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.js +1185 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.d.ts +42 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.js +558 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.js +63 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.d.ts +12 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.js +520 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.d.ts +37 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.js +208 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.js +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/index.d.ts +105 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/index.js +1259 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.js +38 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.d.ts +130 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.js +1137 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.js +74 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.js +111 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.d.ts +17 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.js +89 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.d.ts +20 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.js +76 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.js +478 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.d.ts +30 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.d.ts +14 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.js +192 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.js +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.js +11 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.js +167 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.d.ts +48 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.js +249 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.d.ts +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.js +400 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.d.ts +10 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.js +73 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.d.ts +103 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.js +28 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/scoped.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/scoped.js +663 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.js +115 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.js +63 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.d.ts +18 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.js +109 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.d.ts +141 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.js +1377 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.js +59 -0
- package/node_modules/@poe-code/safe-fs/dist/index.d.ts +25 -0
- package/node_modules/@poe-code/safe-fs/dist/index.js +21 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/linux-x64-glibc.node +0 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.mjs +120 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/manifest.json +46 -0
- package/node_modules/@poe-code/safe-fs/dist/node/filesystem.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/node/filesystem.js +30 -0
- package/node_modules/@poe-code/safe-fs/dist/node/host.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/host.js +78 -0
- package/node_modules/@poe-code/safe-fs/dist/node/index.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/index.js +2 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.js +5 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek.js +54 -0
- package/node_modules/@poe-code/safe-fs/dist/node/stats.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/stats.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/values.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/values.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-host.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-host.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-unavailable.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-unavailable.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/package.json +29 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser.js +58 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node-path.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node-path.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node.js +64 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.d.ts +9 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.js +17 -0
- package/node_modules/@poe-code/safe-fs/dist/python/emscripten.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/python/emscripten.js +357 -0
- package/node_modules/@poe-code/safe-fs/dist/python/filesystem.d.ts +51 -0
- package/node_modules/@poe-code/safe-fs/dist/python/filesystem.js +243 -0
- package/node_modules/@poe-code/safe-fs/dist/python/flags.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/python/flags.js +14 -0
- package/node_modules/@poe-code/safe-fs/dist/python/index.d.ts +9 -0
- package/node_modules/@poe-code/safe-fs/dist/python/index.js +5 -0
- package/node_modules/@poe-code/safe-fs/dist/python/native.d.ts +18 -0
- package/node_modules/@poe-code/safe-fs/dist/python/native.js +446 -0
- package/node_modules/@poe-code/safe-fs/dist/python/request.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/python/request.js +61 -0
- package/node_modules/@poe-code/safe-fs/dist/python/stat.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/python/stat.js +34 -0
- package/node_modules/@poe-code/safe-fs/dist/runtime-core.d.ts +27 -0
- package/node_modules/@poe-code/safe-fs/dist/runtime-core.js +57 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.d.ts +16 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.js +496 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.d.ts +23 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.js +39 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.d.ts +31 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.js +143 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.js +209 -0
- package/node_modules/@poe-code/safe-fs/dist/xml.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/xml.js +1 -0
- package/node_modules/@poe-code/safe-fs/package.json +189 -0
- package/node_modules/@poe-code/task-list/README.md +2 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +1 -1
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +11 -4
- package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +2 -2
- package/node_modules/@poe-code/task-list/dist/backends/utils.js +5 -7
- package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +1 -1
- package/node_modules/@poe-code/task-list/dist/default-host.d.ts +2 -0
- package/node_modules/@poe-code/task-list/dist/default-host.js +2 -0
- package/node_modules/@poe-code/task-list/dist/default-host.workerd.d.ts +4 -0
- package/node_modules/@poe-code/task-list/dist/default-host.workerd.js +6 -0
- package/node_modules/@poe-code/task-list/dist/filesystem.d.ts +3 -0
- package/node_modules/@poe-code/task-list/dist/filesystem.js +32 -0
- package/node_modules/@poe-code/task-list/dist/move.js +3 -3
- package/node_modules/@poe-code/task-list/dist/open.js +2 -5
- package/node_modules/@poe-code/task-list/dist/paths.d.ts +12 -0
- package/node_modules/@poe-code/task-list/dist/paths.js +7 -0
- package/node_modules/@poe-code/task-list/dist/types.d.ts +6 -5
- package/node_modules/@poe-code/task-list/package.json +9 -0
- package/node_modules/@poe-code/terminal-text/LICENSE +21 -0
- package/node_modules/@poe-code/terminal-text/README.md +12 -0
- package/node_modules/@poe-code/terminal-text/dist/index.d.ts +2 -0
- package/node_modules/@poe-code/terminal-text/dist/index.js +20 -0
- package/node_modules/@poe-code/terminal-text/package.json +22 -0
- package/node_modules/@poe-code/xml-ast/LICENSE +21 -0
- package/node_modules/@poe-code/xml-ast/README.md +28 -0
- package/node_modules/@poe-code/xml-ast/dist/index.d.ts +47 -0
- package/node_modules/@poe-code/xml-ast/dist/index.js +635 -0
- package/node_modules/@poe-code/xml-ast/package.json +25 -0
- package/node_modules/auth-store/README.md +35 -0
- package/node_modules/auth-store/dist/index.browser.d.ts +4 -0
- package/node_modules/auth-store/dist/index.browser.js +2 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +1 -1
- package/node_modules/auth-store/dist/safe-fs-secret-store.d.ts +21 -0
- package/node_modules/auth-store/dist/safe-fs-secret-store.js +119 -0
- package/node_modules/auth-store/dist/secret-store.d.ts +12 -0
- package/node_modules/auth-store/dist/secret-store.js +1 -0
- package/node_modules/auth-store/dist/transaction-lock.d.ts +2 -4
- package/node_modules/auth-store/dist/types.d.ts +2 -9
- package/node_modules/auth-store/package.json +16 -2
- package/node_modules/tiny-http-mcp-server/dist/composition.json +16 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/README.md +25 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-state.js +4 -4
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +6 -40
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.d.ts +10 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.js +20 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.js +4 -3
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.d.ts +14 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.js +53 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.d.ts +16 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.js +29 -9
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.d.ts +12 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.js +23 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-endpoint.js +6 -19
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-fetch.js +1 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.d.ts +6 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.js +5 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.d.ts +5 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.js +4 -1
- package/node_modules/tiny-http-mcp-server/package.json +4 -4
- package/node_modules/tiny-mcp-client/README.md +2 -0
- package/node_modules/tiny-mcp-client/dist/index.browser.d.ts +25 -23
- package/node_modules/tiny-mcp-client/dist/index.browser.js +116 -1
- package/node_modules/tiny-mcp-client/dist/index.d.ts +25 -23
- package/node_modules/tiny-mcp-client/dist/index.js +1034 -561
- package/node_modules/tiny-mcp-client/package.json +15 -0
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-design/dist/components/table.js +6 -0
- package/node_modules/toolcraft-design/dist/escape-terminal-text.d.ts +1 -2
- package/node_modules/toolcraft-design/dist/escape-terminal-text.js +1 -20
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +2 -1
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +2 -1
- package/node_modules/toolcraft-schema/dist/json-schema/utils.js +3 -0
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +32 -7
|
@@ -0,0 +1,875 @@
|
|
|
1
|
+
import { snapshotStagingCreation } from "../staging-cleanup.js";
|
|
2
|
+
import { FsError, isFsError } from "../../contracts/errors.js";
|
|
3
|
+
import { finishCleanup } from "../../contracts/cleanup.js";
|
|
4
|
+
import { admitDirectoryEntries, directoryEntryLimit } from "../directory-admission.js";
|
|
5
|
+
import { compareEntries } from "../mount/comparison.js";
|
|
6
|
+
import { deviceDirectory, lexicalDevicePath, nullPath, resolveDevicePath } from "./path.js";
|
|
7
|
+
import { tryResolveMemoryDevicePath } from "../../runtime-core.js";
|
|
8
|
+
import { createDeviceYield, deviceReadStream, drainDeviceFile, drainDeviceInput } from "./stream.js";
|
|
9
|
+
import { openRetainedReadFile, openRetainedResizeFile, retainedResizeCapabilities, ownedMutationCapabilities, requireOwnedMutation } from "../capabilities.js";
|
|
10
|
+
import { pathNamespace } from "../path-namespace.js";
|
|
11
|
+
import { runStagingGuard, snapshotDirectoryAncestry, snapshotStagingResolution } from "../staging-ancestry.js";
|
|
12
|
+
import { openFileDescriptor } from "../descriptor.js";
|
|
13
|
+
import { normalizePath } from "../../contracts/virtual-path.js";
|
|
14
|
+
const views = new WeakMap();
|
|
15
|
+
const deviceCapabilities = Object.freeze({
|
|
16
|
+
synchronousStagingResolution: false,
|
|
17
|
+
readOnly: false, read: true, stat: true, realpath: true, access: true, readdir: false,
|
|
18
|
+
write: true, append: true, exclusiveCreate: true, streamingRead: true, retainedRead: true,
|
|
19
|
+
streamingWrite: true, streamingAppend: true, independentWriteStreams: true, copy: true, exclusiveCopy: true,
|
|
20
|
+
remove: false, removeDirectory: false, recursiveRemove: false, rename: false,
|
|
21
|
+
mkdir: false, recursiveMkdir: false, symlinks: false, hardlinks: false, readlink: false,
|
|
22
|
+
permissions: false, timestamps: false, truncate: false, randomAccessWrite: false,
|
|
23
|
+
open: true, retainedStagingCleanup: false, atomicFilePublication: false, atomicFileMutation: false, atomicEntryRemoval: false, atomicEntryRemovalReceipt: false, atomicTreeRemoval: false, atomicFileStaging: false, atomicDirectoryMetadata: false, trustedOwnedStaging: false,
|
|
24
|
+
atomicRename: false, atomicRenameNoReplace: false, descriptorWriteStream: true, retainedResize: true, atomicResize: false,
|
|
25
|
+
});
|
|
26
|
+
function globalCapabilities(filesystem) {
|
|
27
|
+
const capabilities = { readOnly: false };
|
|
28
|
+
const optional = {
|
|
29
|
+
open: ["open"],
|
|
30
|
+
retainedStagingCleanup: ["createStagedFile", "publishStagedFile", "removeStagedFile"],
|
|
31
|
+
synchronousDirectoryValidation: ["prepareDirectoryAncestry"], guardedStagingPublication: ["createStagedFile", "publishStagedFile", "removeStagedFile"],
|
|
32
|
+
synchronousStagingResolution: ["prepareStagingResolution"],
|
|
33
|
+
trustedOwnedStaging: ["createStagedFile", "publishStagedFile", "removeStagedFile", "writeFileConditional", "removeFileConditional", "prepareDirectory"],
|
|
34
|
+
atomicFilePublication: ["publishFileConditional"], atomicEntryRemoval: ["removeEntryConditional"], atomicEntryRemovalReceipt: ["removeEntryConditional"], atomicTreeRemoval: ["removeTreeConditional"], atomicFileMutation: ["writeFileConditional", "removeFileConditional"], atomicFileStaging: ["createStagedFile", "publishStagedFile", "removeStagedFile"], atomicDirectoryMetadata: ["prepareDirectory"],
|
|
35
|
+
streamingRead: ["readStream"], streamingWrite: ["writeStream"], retainedRead: ["openReadFile"],
|
|
36
|
+
streamingAppend: ["writeStream"], descriptorWriteStream: ["writeStream"], retainedResize: ["openResizeFile"], atomicResize: ["resizeFile"],
|
|
37
|
+
symlinks: ["symlink", "readlink"], hardlinks: ["link"], permissions: ["chmod"],
|
|
38
|
+
timestamps: ["utimes"], readlink: ["readlink"], truncate: ["truncate"], removeDirectory: ["rmdir"],
|
|
39
|
+
};
|
|
40
|
+
for (const key of new Set([...Object.keys(filesystem.capabilities), ...Object.keys(deviceCapabilities)])) {
|
|
41
|
+
if (key === "readOnly")
|
|
42
|
+
continue;
|
|
43
|
+
Object.defineProperty(capabilities, key, { enumerable: true, get() {
|
|
44
|
+
if (key === "copy" || key === "exclusiveCopy")
|
|
45
|
+
return undefined;
|
|
46
|
+
let declared = filesystem.capabilities[key];
|
|
47
|
+
if (key === "atomicEntryRemovalReceipt")
|
|
48
|
+
declared = ownedMutationCapabilities(filesystem).atomicEntryRemovalReceipt;
|
|
49
|
+
if (declared === true) {
|
|
50
|
+
const req = optional[key];
|
|
51
|
+
if (req) {
|
|
52
|
+
for (let i = 0; i < req.length; i++) {
|
|
53
|
+
if (typeof filesystem[req[i]] !== "function") {
|
|
54
|
+
declared = false;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (key === "retainedResize" && filesystem.capabilities.readOnly === true)
|
|
61
|
+
declared = false;
|
|
62
|
+
if (key === "descriptorWriteStream" && filesystem.capabilities.streamingWrite === false)
|
|
63
|
+
declared = false;
|
|
64
|
+
return declared === deviceCapabilities[key] ? declared : undefined;
|
|
65
|
+
} });
|
|
66
|
+
}
|
|
67
|
+
return Object.freeze(capabilities);
|
|
68
|
+
}
|
|
69
|
+
function reserved(path) { return path === "/" || path === deviceDirectory || path === nullPath; }
|
|
70
|
+
function nonnegative(value, path) {
|
|
71
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 0))
|
|
72
|
+
throw new FsError("EINVAL", { path });
|
|
73
|
+
}
|
|
74
|
+
const sharedUnknownEntryAuthority = async () => "unknown";
|
|
75
|
+
export class DeviceFileSystem {
|
|
76
|
+
#filesystem;
|
|
77
|
+
capabilities;
|
|
78
|
+
#identityScopeObj;
|
|
79
|
+
#nullStatObj;
|
|
80
|
+
#directoryStatObj;
|
|
81
|
+
get [pathNamespace]() {
|
|
82
|
+
return Reflect.get(this.#filesystem, pathNamespace);
|
|
83
|
+
}
|
|
84
|
+
get #nullStat() {
|
|
85
|
+
if (this.#nullStatObj)
|
|
86
|
+
return this.#nullStatObj;
|
|
87
|
+
const identityScope = (this.#identityScopeObj ??= Object.freeze({}));
|
|
88
|
+
return (this.#nullStatObj = Object.freeze({
|
|
89
|
+
type: "character", mode: 0o020666, size: 0, allocatedBytes: 0, uid: 0, gid: 0,
|
|
90
|
+
mtimeMs: 0, atimeMs: 0, ctimeMs: 0, birthtimeMs: 0, identityScope, ino: 1, dev: 0, nlink: 1, preferredIoBlockSize: 4096,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
get #directoryStat() {
|
|
94
|
+
if (this.#directoryStatObj)
|
|
95
|
+
return this.#directoryStatObj;
|
|
96
|
+
const identityScope = (this.#identityScopeObj ??= Object.freeze({}));
|
|
97
|
+
return (this.#directoryStatObj = Object.freeze({
|
|
98
|
+
type: "directory", mode: 0o040755, size: 0, allocatedBytes: 0, uid: 0, gid: 0,
|
|
99
|
+
mtimeMs: 0, atimeMs: 0, ctimeMs: 0, birthtimeMs: 0, identityScope, ino: 2, dev: 0, nlink: 1,
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
_resolveEntryView = async (path, options) => {
|
|
103
|
+
const resolved = await this.#resolve(path, options);
|
|
104
|
+
if (resolved === nullPath || resolved === deviceDirectory) {
|
|
105
|
+
return { filesystem: this, path: resolved, stat: resolved === nullPath ? this.#nullStat : this.#directoryStat, readOnly: false };
|
|
106
|
+
}
|
|
107
|
+
return { filesystem: this.#filesystem, path };
|
|
108
|
+
};
|
|
109
|
+
_entryAuthority = sharedUnknownEntryAuthority;
|
|
110
|
+
constructor(filesystem) {
|
|
111
|
+
this.#filesystem = filesystem;
|
|
112
|
+
this.capabilities = globalCapabilities(filesystem);
|
|
113
|
+
let methods;
|
|
114
|
+
const view = new Proxy(this, {
|
|
115
|
+
set: (_target, property, value) => Reflect.set(filesystem, property, value, filesystem),
|
|
116
|
+
get(target, property) {
|
|
117
|
+
const value = Reflect.get(target, property, target);
|
|
118
|
+
if (typeof value !== "function" || property === "constructor")
|
|
119
|
+
return value;
|
|
120
|
+
const backing = Reflect.get(filesystem, property, filesystem);
|
|
121
|
+
const cached = methods?.get(property);
|
|
122
|
+
if (cached && cached.backing === backing)
|
|
123
|
+
return cached.bound;
|
|
124
|
+
const bound = value.bind(target);
|
|
125
|
+
(methods ??= new Map()).set(property, { backing, bound });
|
|
126
|
+
return bound;
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return view;
|
|
130
|
+
}
|
|
131
|
+
#resolve(path, options, followFinal = true, resizeCreate, traversal) {
|
|
132
|
+
return resolveDevicePath(this.#filesystem, path, options, followFinal, resizeCreate, traversal);
|
|
133
|
+
}
|
|
134
|
+
#tryResolveSync(path, options) {
|
|
135
|
+
if (options.signal?.aborted)
|
|
136
|
+
return undefined;
|
|
137
|
+
if (Reflect.get(this.#filesystem, pathNamespace) === undefined) {
|
|
138
|
+
return tryResolveMemoryDevicePath(this.#filesystem, path);
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
async #mutable(path, options, followFinal = true) {
|
|
143
|
+
if (reserved(await this.#resolve(path, options, followFinal)))
|
|
144
|
+
throw new FsError("EBUSY", { path });
|
|
145
|
+
}
|
|
146
|
+
async #writeTarget(path, options) {
|
|
147
|
+
let resolved;
|
|
148
|
+
try {
|
|
149
|
+
resolved = await this.#resolve(path, options);
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
options.signal?.throwIfAborted();
|
|
153
|
+
if ((options.flag === "wx" || options.flag === "ax") && isFsError(error, "ELOOP"))
|
|
154
|
+
return false;
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
if (resolved === nullPath) {
|
|
158
|
+
if (options.flag === "wx" || options.flag === "ax")
|
|
159
|
+
throw new FsError("EEXIST", { path });
|
|
160
|
+
if (options.flag !== undefined && options.flag !== "w" && options.flag !== "a")
|
|
161
|
+
throw new FsError("EINVAL", { path });
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
if (resolved === "/" || resolved === deviceDirectory)
|
|
165
|
+
throw new FsError("EISDIR", { path });
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
canonicalizeMissingTarget(path, options = {}) {
|
|
169
|
+
options.signal?.throwIfAborted();
|
|
170
|
+
const resolved = lexicalDevicePath(path);
|
|
171
|
+
return reserved(resolved) ? resolved : this.#filesystem.canonicalizeMissingTarget?.(path, options);
|
|
172
|
+
}
|
|
173
|
+
async capabilitiesFor(path, options = {}) {
|
|
174
|
+
options.signal?.throwIfAborted();
|
|
175
|
+
if (options.stagingResolution === true && (normalizePath(path) !== path || !path.startsWith("/")))
|
|
176
|
+
throw new FsError("EINVAL", { path });
|
|
177
|
+
let resolved;
|
|
178
|
+
let selected;
|
|
179
|
+
const traversal = options.stagingResolution === true ? { virtual: false } : undefined;
|
|
180
|
+
try {
|
|
181
|
+
resolved = await this.#resolve(path, options, options.stagingResolution !== true && (options.create !== undefined || options.creation !== "exclusive"), options.create, traversal);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
options.signal?.throwIfAborted();
|
|
185
|
+
if (options.create !== true || !isFsError(error, "ENOENT"))
|
|
186
|
+
throw error;
|
|
187
|
+
// Implicit prefixes need not exist before the authoritative backend opens
|
|
188
|
+
// a new file. Resolve device aliases without creating namespace entries.
|
|
189
|
+
resolved = await this.#resolve(path, options);
|
|
190
|
+
options.signal?.throwIfAborted();
|
|
191
|
+
if (reserved(resolved))
|
|
192
|
+
throw error;
|
|
193
|
+
const query = this.#filesystem.capabilitiesFor;
|
|
194
|
+
options.signal?.throwIfAborted();
|
|
195
|
+
selected = (query === undefined || query === null ? undefined : await Reflect.apply(query, this.#filesystem, [path, options])) ?? this.#filesystem.capabilities;
|
|
196
|
+
options.signal?.throwIfAborted();
|
|
197
|
+
if (selected.implicitDirectories !== true)
|
|
198
|
+
throw error;
|
|
199
|
+
}
|
|
200
|
+
options.signal?.throwIfAborted();
|
|
201
|
+
if (options.create !== undefined && (resolved === deviceDirectory || resolved === "/"))
|
|
202
|
+
throw new FsError("EISDIR", { syscall: "capabilitiesFor", path });
|
|
203
|
+
if (resolved === nullPath)
|
|
204
|
+
return deviceCapabilities;
|
|
205
|
+
if (resolved === deviceDirectory)
|
|
206
|
+
return { ...deviceCapabilities, open: false, readdir: true, write: false, append: false,
|
|
207
|
+
exclusiveCreate: false, streamingWrite: false, streamingAppend: false, independentWriteStreams: false, descriptorWriteStream: false,
|
|
208
|
+
retainedRead: false, retainedResize: false, streamingRead: false, copy: false, exclusiveCopy: false };
|
|
209
|
+
// This intent cannot bind virtual traversal. Do not infer other path
|
|
210
|
+
// capabilities by resolving the shadowed entry in the backing filesystem.
|
|
211
|
+
if (traversal?.virtual)
|
|
212
|
+
return Object.freeze({ synchronousStagingResolution: false });
|
|
213
|
+
if (selected === undefined) {
|
|
214
|
+
const query = this.#filesystem.capabilitiesFor;
|
|
215
|
+
options.signal?.throwIfAborted();
|
|
216
|
+
selected = query === undefined || query === null ? undefined : await Reflect.apply(query, this.#filesystem, [path, options]);
|
|
217
|
+
}
|
|
218
|
+
options.signal?.throwIfAborted();
|
|
219
|
+
const observed = ownedMutationCapabilities(this.#filesystem, selected ?? this.#filesystem.capabilities);
|
|
220
|
+
options.signal?.throwIfAborted();
|
|
221
|
+
const capabilities = observed.retainedResize === true ? retainedResizeCapabilities(this.#filesystem, observed) : observed;
|
|
222
|
+
let unavailable;
|
|
223
|
+
if (options.stagingResolution === true && observed.synchronousStagingResolution === true) {
|
|
224
|
+
try {
|
|
225
|
+
const resolution = snapshotStagingResolution(await this.#filesystem.prepareStagingResolution(path, options));
|
|
226
|
+
options.signal?.throwIfAborted();
|
|
227
|
+
if (resolution.path !== resolved)
|
|
228
|
+
throw new FsError("EAGAIN", { path });
|
|
229
|
+
if ([resolution.path, ...resolution.traversed.map(entry => entry.path)].some(entry => entry === deviceDirectory || entry.startsWith(`${deviceDirectory}/`))) {
|
|
230
|
+
(unavailable ??= {}).synchronousStagingResolution = false;
|
|
231
|
+
}
|
|
232
|
+
runStagingGuard(resolution.validate);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
options.signal?.throwIfAborted();
|
|
236
|
+
if (!isFsError(error, "ENOTSUP"))
|
|
237
|
+
throw error;
|
|
238
|
+
(unavailable ??= {}).synchronousStagingResolution = false;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (resolved.startsWith(`${deviceDirectory}/`)) {
|
|
242
|
+
const u = unavailable ??= {};
|
|
243
|
+
u.atomicStagingAncestry = false;
|
|
244
|
+
u.synchronousDirectoryValidation = false;
|
|
245
|
+
u.synchronousStagingResolution = false;
|
|
246
|
+
}
|
|
247
|
+
if (typeof this.#filesystem.open !== "function" && capabilities.open !== false)
|
|
248
|
+
(unavailable ??= {}).open = false;
|
|
249
|
+
if (typeof this.#filesystem.readStream !== "function" && capabilities.streamingRead !== false)
|
|
250
|
+
(unavailable ??= {}).streamingRead = false;
|
|
251
|
+
if (typeof this.#filesystem.writeStream !== "function") {
|
|
252
|
+
if (capabilities.streamingWrite !== false)
|
|
253
|
+
(unavailable ??= {}).streamingWrite = false;
|
|
254
|
+
if (capabilities.streamingAppend !== false)
|
|
255
|
+
(unavailable ??= {}).streamingAppend = false;
|
|
256
|
+
if (capabilities.descriptorWriteStream !== false)
|
|
257
|
+
(unavailable ??= {}).descriptorWriteStream = false;
|
|
258
|
+
}
|
|
259
|
+
if (typeof this.#filesystem.openReadFile !== "function" && capabilities.retainedRead !== false)
|
|
260
|
+
(unavailable ??= {}).retainedRead = false;
|
|
261
|
+
if (observed.atomicResize === true && (typeof this.#filesystem.resizeFile !== "function" || observed.readOnly === true) && capabilities.atomicResize !== false)
|
|
262
|
+
(unavailable ??= {}).atomicResize = false;
|
|
263
|
+
const result = unavailable ? { ...capabilities, ...unavailable } : capabilities;
|
|
264
|
+
options.signal?.throwIfAborted();
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
267
|
+
stat(path, options = {}) {
|
|
268
|
+
if (this.#tryResolveSync(path, options) !== undefined) {
|
|
269
|
+
return this.#filesystem.stat(path, options);
|
|
270
|
+
}
|
|
271
|
+
return this.#statSlow(path, options);
|
|
272
|
+
}
|
|
273
|
+
async #statSlow(path, options) {
|
|
274
|
+
const resolved = await this.#resolve(path, options);
|
|
275
|
+
options.signal?.throwIfAborted();
|
|
276
|
+
if (resolved === nullPath)
|
|
277
|
+
return { ...this.#nullStat };
|
|
278
|
+
if (resolved === deviceDirectory)
|
|
279
|
+
return { ...this.#directoryStat };
|
|
280
|
+
const stat = this.#filesystem.stat;
|
|
281
|
+
options.signal?.throwIfAborted();
|
|
282
|
+
const result = await Reflect.apply(stat, this.#filesystem, [path, options]);
|
|
283
|
+
options.signal?.throwIfAborted();
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
lstat(path, options = {}) {
|
|
287
|
+
if (this.#tryResolveSync(path, options) !== undefined) {
|
|
288
|
+
return this.#filesystem.lstat(path, options);
|
|
289
|
+
}
|
|
290
|
+
return this.#lstatSlow(path, options);
|
|
291
|
+
}
|
|
292
|
+
async #lstatSlow(path, options) {
|
|
293
|
+
const resolved = await this.#resolve(path, options, false);
|
|
294
|
+
options.signal?.throwIfAborted();
|
|
295
|
+
if (resolved === nullPath)
|
|
296
|
+
return { ...this.#nullStat };
|
|
297
|
+
if (resolved === deviceDirectory)
|
|
298
|
+
return { ...this.#directoryStat };
|
|
299
|
+
const lstat = this.#filesystem.lstat;
|
|
300
|
+
options.signal?.throwIfAborted();
|
|
301
|
+
const result = await Reflect.apply(lstat, this.#filesystem, [path, options]);
|
|
302
|
+
options.signal?.throwIfAborted();
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
compareEntry(path, peer, peerPath, options = {}) {
|
|
306
|
+
return compareEntries(this, path, peer, peerPath, options);
|
|
307
|
+
}
|
|
308
|
+
realpath(path, options = {}) {
|
|
309
|
+
if (this.#tryResolveSync(path, options) !== undefined) {
|
|
310
|
+
return this.#filesystem.realpath(path, options);
|
|
311
|
+
}
|
|
312
|
+
return this.#realpathSlow(path, options);
|
|
313
|
+
}
|
|
314
|
+
async #realpathSlow(path, options) {
|
|
315
|
+
const resolved = await this.#resolve(path, options);
|
|
316
|
+
return reserved(resolved) ? resolved : this.#filesystem.realpath(path, options);
|
|
317
|
+
}
|
|
318
|
+
readFile(path, options = {}) {
|
|
319
|
+
if (this.#tryResolveSync(path, options) !== undefined) {
|
|
320
|
+
return this.#filesystem.readFile(path, options);
|
|
321
|
+
}
|
|
322
|
+
return this.#readFileSlow(path, options);
|
|
323
|
+
}
|
|
324
|
+
async #readFileSlow(path, options) {
|
|
325
|
+
const resolved = await this.#resolve(path, options);
|
|
326
|
+
if (resolved === nullPath) {
|
|
327
|
+
if (options.maxBytes !== Infinity)
|
|
328
|
+
nonnegative(options.maxBytes, path);
|
|
329
|
+
return new Uint8Array();
|
|
330
|
+
}
|
|
331
|
+
if (resolved === deviceDirectory)
|
|
332
|
+
throw new FsError("EISDIR", { path });
|
|
333
|
+
return this.#filesystem.readFile(path, options);
|
|
334
|
+
}
|
|
335
|
+
readStream(path, options = {}) {
|
|
336
|
+
return deviceReadStream(async () => {
|
|
337
|
+
const resolved = await this.#resolve(path, options);
|
|
338
|
+
if (resolved === nullPath) {
|
|
339
|
+
nonnegative(options.start, path);
|
|
340
|
+
nonnegative(options.endExclusive, path);
|
|
341
|
+
nonnegative(options.chunkSize, path);
|
|
342
|
+
if (options.chunkSize === 0 || (options.endExclusive !== undefined && options.endExclusive < (options.start ?? 0)))
|
|
343
|
+
throw new FsError("EINVAL", { path });
|
|
344
|
+
return { [Symbol.asyncIterator]: () => ({ next: async () => ({ done: true, value: undefined }) }) };
|
|
345
|
+
}
|
|
346
|
+
if (resolved === deviceDirectory)
|
|
347
|
+
throw new FsError("EISDIR", { path });
|
|
348
|
+
if (!this.#filesystem.readStream)
|
|
349
|
+
throw new FsError("ENOTSUP", { path });
|
|
350
|
+
return this.#filesystem.readStream(path, options);
|
|
351
|
+
}, options.signal);
|
|
352
|
+
}
|
|
353
|
+
async openReadFile(path, options = {}) {
|
|
354
|
+
const resolved = await this.#resolve(path, options);
|
|
355
|
+
if (resolved !== nullPath) {
|
|
356
|
+
if (resolved === deviceDirectory)
|
|
357
|
+
throw new FsError("EISDIR", { path });
|
|
358
|
+
return openRetainedReadFile(this.#filesystem, path, options);
|
|
359
|
+
}
|
|
360
|
+
const stat = this.#nullStat;
|
|
361
|
+
let closed = false;
|
|
362
|
+
const check = (settings) => { settings.signal?.throwIfAborted(); if (closed)
|
|
363
|
+
throw new FsError("EBADF", { path }); };
|
|
364
|
+
return {
|
|
365
|
+
async stat(settings = {}) { check(settings); return { ...stat }; },
|
|
366
|
+
async read(position, maxBytes, settings = {}) { check(settings); nonnegative(position, path); nonnegative(maxBytes, path); return new Uint8Array(); },
|
|
367
|
+
async seekEnd(settings = {}) { check(settings); return 0n; },
|
|
368
|
+
async close() { closed = true; },
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
async open(path, options) {
|
|
372
|
+
options?.signal?.throwIfAborted();
|
|
373
|
+
if (!options || typeof options !== "object")
|
|
374
|
+
throw new FsError("EINVAL", { syscall: "open", path });
|
|
375
|
+
const resolved = await this.#resolve(path, options, !options.noFollow && options.creation !== "exclusive");
|
|
376
|
+
options.signal?.throwIfAborted();
|
|
377
|
+
if (resolved === nullPath)
|
|
378
|
+
return openFileDescriptor(path, options, {
|
|
379
|
+
noFollow: true, position: true, positionedRead: true, positionedWrite: true, positionedAppendWrite: true,
|
|
380
|
+
openTruncate: true, delegateZeroLengthWrite: true, truncate: false, synchronization: "none",
|
|
381
|
+
}, async (admitted) => {
|
|
382
|
+
if (admitted.creation === "exclusive")
|
|
383
|
+
throw new FsError("EEXIST", { syscall: "open", path });
|
|
384
|
+
const yieldAfterWrite = createDeviceYield();
|
|
385
|
+
return {
|
|
386
|
+
resource: this.#nullStat,
|
|
387
|
+
getPosition: async () => 0,
|
|
388
|
+
stat: async (stat) => ({ ...stat }),
|
|
389
|
+
read: async () => 0,
|
|
390
|
+
write: async (_stat, buffer, _position, forwarded) => {
|
|
391
|
+
await yieldAfterWrite(buffer.byteLength, forwarded.signal);
|
|
392
|
+
return buffer.byteLength;
|
|
393
|
+
},
|
|
394
|
+
truncate: async () => { throw new FsError("ENOTSUP", { syscall: "ftruncate", path }); },
|
|
395
|
+
sync: async () => { throw new FsError("ENOTSUP", { syscall: "fsync", path }); },
|
|
396
|
+
close: async () => { },
|
|
397
|
+
};
|
|
398
|
+
});
|
|
399
|
+
if (resolved === deviceDirectory)
|
|
400
|
+
throw new FsError("ENOTSUP", { syscall: "open", path });
|
|
401
|
+
const query = this.#filesystem.capabilitiesFor;
|
|
402
|
+
options.signal?.throwIfAborted();
|
|
403
|
+
const capabilities = query && !options.noFollow && options.creation !== "exclusive" ? await Reflect.apply(query, this.#filesystem, [path, options]) : this.#filesystem.capabilities;
|
|
404
|
+
options.signal?.throwIfAborted();
|
|
405
|
+
const open = this.#filesystem.open;
|
|
406
|
+
options.signal?.throwIfAborted();
|
|
407
|
+
if (capabilities.readOnly === true && (options.access === "write" || options.access === "readwrite" || options.creation === "ifMissing" || options.creation === "exclusive" || options.truncate === true || options.append === true))
|
|
408
|
+
throw new FsError("EROFS", { syscall: "open", path });
|
|
409
|
+
if (capabilities.open === false || typeof open !== "function")
|
|
410
|
+
throw new FsError("ENOTSUP", { syscall: "open", path });
|
|
411
|
+
let descriptor;
|
|
412
|
+
try {
|
|
413
|
+
descriptor = await Reflect.apply(open, this.#filesystem, [path, options]);
|
|
414
|
+
options.signal?.throwIfAborted();
|
|
415
|
+
return descriptor;
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
if (descriptor)
|
|
419
|
+
await finishCleanup(() => descriptor.close(), true);
|
|
420
|
+
options.signal?.throwIfAborted();
|
|
421
|
+
throw error;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
async resizeFile(path, operation, options = {}) {
|
|
425
|
+
await this.#mutable(path, options);
|
|
426
|
+
const capabilities = await this.capabilitiesFor(path, options);
|
|
427
|
+
options.signal?.throwIfAborted();
|
|
428
|
+
if (capabilities.readOnly === true)
|
|
429
|
+
throw new FsError("EROFS", { syscall: "resizeFile", path });
|
|
430
|
+
const resize = this.#filesystem.resizeFile;
|
|
431
|
+
options.signal?.throwIfAborted();
|
|
432
|
+
if (capabilities.atomicResize !== true || typeof resize !== "function")
|
|
433
|
+
throw new FsError("ENOTSUP", { syscall: "resizeFile", path });
|
|
434
|
+
await Reflect.apply(resize, this.#filesystem, [path, operation, options]);
|
|
435
|
+
options.signal?.throwIfAborted();
|
|
436
|
+
}
|
|
437
|
+
async openResizeFile(path, options = {}) {
|
|
438
|
+
options.signal?.throwIfAborted();
|
|
439
|
+
const resolution = this.#resolve(path, options, true, options.create ?? false);
|
|
440
|
+
const signal = options.signal;
|
|
441
|
+
const resolved = await (signal ? new Promise((resolve, reject) => {
|
|
442
|
+
const abort = () => { signal.removeEventListener("abort", abort); reject(signal.reason); };
|
|
443
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
444
|
+
resolution.then(value => { signal.removeEventListener("abort", abort); resolve(value); }, error => { signal.removeEventListener("abort", abort); reject(error); });
|
|
445
|
+
if (signal.aborted)
|
|
446
|
+
abort();
|
|
447
|
+
}) : resolution);
|
|
448
|
+
options.signal?.throwIfAborted();
|
|
449
|
+
if (resolved === deviceDirectory || resolved === "/")
|
|
450
|
+
throw new FsError("EISDIR", { syscall: "openResizeFile", path });
|
|
451
|
+
if (resolved !== nullPath)
|
|
452
|
+
return openRetainedResizeFile(this.#filesystem, path, options);
|
|
453
|
+
const stat = this.#nullStat;
|
|
454
|
+
let closing;
|
|
455
|
+
const check = (settings, syscall) => {
|
|
456
|
+
settings.signal?.throwIfAborted();
|
|
457
|
+
if (closing)
|
|
458
|
+
throw new FsError("EBADF", { syscall, path });
|
|
459
|
+
};
|
|
460
|
+
return {
|
|
461
|
+
async stat(settings = {}) { check(settings, "fstat"); return { ...stat }; },
|
|
462
|
+
async seekEnd(settings = {}) { check(settings, "lseek"); return 0n; },
|
|
463
|
+
async truncate(_length, settings = {}) {
|
|
464
|
+
check(settings, "ftruncate");
|
|
465
|
+
throw new FsError("EINVAL", { syscall: "ftruncate", path });
|
|
466
|
+
},
|
|
467
|
+
close: () => closing ??= Promise.resolve(),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
async writeFile(path, data, options = {}) {
|
|
471
|
+
if (await this.#writeTarget(path, options)) {
|
|
472
|
+
if (!(data instanceof Uint8Array))
|
|
473
|
+
throw new TypeError("File data must be Uint8Array");
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
await this.#filesystem.writeFile(path, data, options);
|
|
477
|
+
}
|
|
478
|
+
async appendFile(path, data, options = {}) {
|
|
479
|
+
if (await this.#writeTarget(path, options)) {
|
|
480
|
+
if (!(data instanceof Uint8Array))
|
|
481
|
+
throw new TypeError("File data must be Uint8Array");
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
await this.#filesystem.appendFile(path, data, options);
|
|
485
|
+
}
|
|
486
|
+
async writeStream(path, source, options = {}) {
|
|
487
|
+
if (await this.#writeTarget(path, options))
|
|
488
|
+
return drainDeviceInput(source, options.signal);
|
|
489
|
+
if (!this.#filesystem.writeStream)
|
|
490
|
+
throw new FsError("ENOTSUP", { path });
|
|
491
|
+
await this.#filesystem.writeStream(path, source, options);
|
|
492
|
+
}
|
|
493
|
+
readdir(path, options = {}) {
|
|
494
|
+
const fast = this.#tryResolveSync(path, options);
|
|
495
|
+
if (fast !== undefined && fast !== "/") {
|
|
496
|
+
return this.#filesystem.readdir(path, options);
|
|
497
|
+
}
|
|
498
|
+
return this.#readdirSlow(path, options);
|
|
499
|
+
}
|
|
500
|
+
async #readdirSlow(path, options) {
|
|
501
|
+
const resolved = await this.#resolve(path, options);
|
|
502
|
+
if (resolved === nullPath)
|
|
503
|
+
throw new FsError("ENOTDIR", { path });
|
|
504
|
+
if (resolved !== "/" && resolved !== deviceDirectory)
|
|
505
|
+
return this.#filesystem.readdir(path, options);
|
|
506
|
+
const limit = directoryEntryLimit(options, path);
|
|
507
|
+
let entries;
|
|
508
|
+
try {
|
|
509
|
+
entries = await this.#filesystem.readdir(resolved, options);
|
|
510
|
+
}
|
|
511
|
+
catch (error) {
|
|
512
|
+
options.signal?.throwIfAborted();
|
|
513
|
+
if (!isFsError(error, "ENOENT") && !isFsError(error, "ENOTDIR"))
|
|
514
|
+
throw error;
|
|
515
|
+
entries = [];
|
|
516
|
+
}
|
|
517
|
+
options.signal?.throwIfAborted();
|
|
518
|
+
const merged = new Map();
|
|
519
|
+
for (const entry of entries) {
|
|
520
|
+
if (entry.name === "." || entry.name === "..")
|
|
521
|
+
continue;
|
|
522
|
+
if (!entry.name || entry.name.includes("/") || entry.name.includes("\0"))
|
|
523
|
+
throw new FsError("EIO", { path, message: "invalid directory entry" });
|
|
524
|
+
merged.set(entry.name, { name: entry.name, type: entry.type });
|
|
525
|
+
admitDirectoryEntries(merged.size, limit, path);
|
|
526
|
+
}
|
|
527
|
+
const name = resolved === "/" ? "dev" : "null";
|
|
528
|
+
merged.set(name, { name, type: resolved === "/" ? "directory" : "character" });
|
|
529
|
+
admitDirectoryEntries(merged.size, limit, path);
|
|
530
|
+
return [...merged.values()];
|
|
531
|
+
}
|
|
532
|
+
mkdir(path, options = {}) {
|
|
533
|
+
if (this.#tryResolveSync(path, options) !== undefined) {
|
|
534
|
+
return this.#filesystem.mkdir(path, options);
|
|
535
|
+
}
|
|
536
|
+
return this.#mkdirSlow(path, options);
|
|
537
|
+
}
|
|
538
|
+
async #mkdirSlow(path, options) {
|
|
539
|
+
const resolved = await this.#resolve(path, options);
|
|
540
|
+
if (reserved(resolved)) {
|
|
541
|
+
if (resolved !== nullPath && options.recursive)
|
|
542
|
+
return;
|
|
543
|
+
throw new FsError("EEXIST", { path });
|
|
544
|
+
}
|
|
545
|
+
await this.#filesystem.mkdir(path, options);
|
|
546
|
+
}
|
|
547
|
+
rm(path, options = {}) {
|
|
548
|
+
if (this.#tryResolveSync(path, options) !== undefined) {
|
|
549
|
+
return this.#filesystem.rm(path, options);
|
|
550
|
+
}
|
|
551
|
+
return this.#rmSlow(path, options);
|
|
552
|
+
}
|
|
553
|
+
async #rmSlow(path, options) {
|
|
554
|
+
await this.#mutable(path, options, false);
|
|
555
|
+
await this.#filesystem.rm(path, options);
|
|
556
|
+
}
|
|
557
|
+
async unlink(path, options = {}) {
|
|
558
|
+
await this.#mutable(path, options, false);
|
|
559
|
+
if (!this.#filesystem.unlink)
|
|
560
|
+
throw new FsError("ENOTSUP", { syscall: "unlink", path });
|
|
561
|
+
options.signal?.throwIfAborted();
|
|
562
|
+
await this.#filesystem.unlink(path, options);
|
|
563
|
+
}
|
|
564
|
+
async rmdir(path, options = {}) {
|
|
565
|
+
const resolved = await this.#resolve(path, options, false);
|
|
566
|
+
if (resolved === nullPath)
|
|
567
|
+
throw new FsError("ENOTDIR", { path });
|
|
568
|
+
if (reserved(resolved))
|
|
569
|
+
throw new FsError("EBUSY", { path });
|
|
570
|
+
if (!this.#filesystem.rmdir)
|
|
571
|
+
throw new FsError("ENOTSUP", { path });
|
|
572
|
+
await this.#filesystem.rmdir(path, options);
|
|
573
|
+
}
|
|
574
|
+
async publishFileConditional(path, source, options) {
|
|
575
|
+
await this.#mutable(path, options, false);
|
|
576
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicFilePublication", options, options.expected === null);
|
|
577
|
+
if (!this.#filesystem.publishFileConditional)
|
|
578
|
+
throw new FsError("ENOTSUP", { path });
|
|
579
|
+
return this.#filesystem.publishFileConditional(path, source, options);
|
|
580
|
+
}
|
|
581
|
+
async writeFileConditional(path, data, options) {
|
|
582
|
+
await this.#mutable(path, options, false);
|
|
583
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicFileMutation", options, options.expected === null);
|
|
584
|
+
if (!this.#filesystem.writeFileConditional)
|
|
585
|
+
throw new FsError("ENOTSUP", { path });
|
|
586
|
+
return this.#filesystem.writeFileConditional(path, data, options);
|
|
587
|
+
}
|
|
588
|
+
async removeEntryConditional(path, options) {
|
|
589
|
+
options = { ...options };
|
|
590
|
+
const requested = options.returnRemainingStat === true;
|
|
591
|
+
await this.#mutable(path, options, false);
|
|
592
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicEntryRemoval", options);
|
|
593
|
+
if (requested)
|
|
594
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicEntryRemovalReceipt", options);
|
|
595
|
+
if (!this.#filesystem.removeEntryConditional)
|
|
596
|
+
throw new FsError("ENOTSUP", { path });
|
|
597
|
+
const receipt = await this.#filesystem.removeEntryConditional(path, options);
|
|
598
|
+
return requested && receipt !== undefined ? Object.freeze({ ...receipt }) : undefined;
|
|
599
|
+
}
|
|
600
|
+
async removeFileConditional(path, options) {
|
|
601
|
+
await this.#mutable(path, options, false);
|
|
602
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicFileMutation", options);
|
|
603
|
+
if (!this.#filesystem.removeFileConditional)
|
|
604
|
+
throw new FsError("ENOTSUP", { path });
|
|
605
|
+
await this.#filesystem.removeFileConditional(path, options);
|
|
606
|
+
}
|
|
607
|
+
async removeTreeConditional(path, options) {
|
|
608
|
+
await this.#mutable(path, options, false);
|
|
609
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicTreeRemoval", options);
|
|
610
|
+
if (!this.#filesystem.removeTreeConditional)
|
|
611
|
+
throw new FsError("ENOTSUP", { path });
|
|
612
|
+
await this.#filesystem.removeTreeConditional(path, options);
|
|
613
|
+
}
|
|
614
|
+
async createStagedFile(path, name, content, options) {
|
|
615
|
+
options = snapshotStagingCreation(options, path);
|
|
616
|
+
await this.#mutable(path, options, false);
|
|
617
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicFileStaging", options, true);
|
|
618
|
+
if (options.retainCleanup === true)
|
|
619
|
+
await requireOwnedMutation(this.#filesystem, path, "retainedStagingCleanup", options, true);
|
|
620
|
+
if (!this.#filesystem.createStagedFile)
|
|
621
|
+
throw new FsError("ENOTSUP", { path });
|
|
622
|
+
return this.#filesystem.createStagedFile(path, name, content, options);
|
|
623
|
+
}
|
|
624
|
+
async publishStagedFile(staging, destination, options) {
|
|
625
|
+
options.signal?.throwIfAborted();
|
|
626
|
+
if (options.ancestors !== undefined) {
|
|
627
|
+
const entries = snapshotDirectoryAncestry(options.ancestors);
|
|
628
|
+
if (entries.some(entry => entry.path === deviceDirectory || entry.path.startsWith(`${deviceDirectory}/`)))
|
|
629
|
+
throw new FsError("ENOTSUP", { path: destination });
|
|
630
|
+
await requireOwnedMutation(this.#filesystem, destination, "atomicStagingAncestry", options, options.destination === null);
|
|
631
|
+
}
|
|
632
|
+
for (const path of [staging.directory.path, staging.file.path, destination])
|
|
633
|
+
await this.#mutable(path, options, false);
|
|
634
|
+
await requireOwnedMutation(this.#filesystem, staging.directory.path, "atomicFileStaging", options);
|
|
635
|
+
await requireOwnedMutation(this.#filesystem, destination, "atomicFileStaging", options, options.destination === null);
|
|
636
|
+
if (!this.#filesystem.publishStagedFile)
|
|
637
|
+
throw new FsError("ENOTSUP", { path: destination });
|
|
638
|
+
if (options.commitGuard !== undefined)
|
|
639
|
+
await requireOwnedMutation(this.#filesystem, destination, "guardedStagingPublication", options, options.destination === null);
|
|
640
|
+
await this.#filesystem.publishStagedFile(staging, destination, options);
|
|
641
|
+
}
|
|
642
|
+
async publishStagedFileSet(receipt, destination, supplied) {
|
|
643
|
+
const publish = this.#filesystem.publishStagedFileSet;
|
|
644
|
+
if (!publish)
|
|
645
|
+
throw new FsError("ENOTSUP", { path: destination });
|
|
646
|
+
const entry = (value) => ({ path: value.path, stat: { ...value.stat } });
|
|
647
|
+
const staging = { ...receipt, parent: entry(receipt.parent), directory: entry(receipt.directory), file: entry(receipt.file) };
|
|
648
|
+
const options = {
|
|
649
|
+
...supplied,
|
|
650
|
+
parent: { ...supplied.parent },
|
|
651
|
+
destination: supplied.destination === null ? null : { ...supplied.destination },
|
|
652
|
+
companions: supplied.companions.map(value => ({ ...value, expected: value.expected === null ? null : { ...value.expected } })),
|
|
653
|
+
...(supplied.ancestors === undefined ? {} : { ancestors: snapshotDirectoryAncestry(supplied.ancestors) }),
|
|
654
|
+
};
|
|
655
|
+
options.signal?.throwIfAborted();
|
|
656
|
+
const capabilities = await this.#filesystem.capabilitiesFor?.(destination, { ...options, create: options.destination === null }) ?? this.#filesystem.capabilities;
|
|
657
|
+
if (capabilities.readOnly === true)
|
|
658
|
+
throw new FsError("EROFS", { path: destination });
|
|
659
|
+
for (const path of [staging.parent.path, staging.directory.path])
|
|
660
|
+
await this.#mutable(path, options, false);
|
|
661
|
+
const guards = [];
|
|
662
|
+
if (options.ancestors)
|
|
663
|
+
guards.push(await this.prepareDirectoryAncestry(options.ancestors, options));
|
|
664
|
+
for (const path of [staging.file.path, destination, ...options.companions.map(value => value.path)]) {
|
|
665
|
+
await this.#mutable(path, options, false);
|
|
666
|
+
const resolution = await this.prepareStagingResolution(path, options);
|
|
667
|
+
guards.push(resolution.validate);
|
|
668
|
+
}
|
|
669
|
+
const callerGuard = options.commitGuard;
|
|
670
|
+
options.signal?.throwIfAborted();
|
|
671
|
+
return publish.call(this.#filesystem, staging, destination, { ...options, commitGuard: () => {
|
|
672
|
+
options.signal?.throwIfAborted();
|
|
673
|
+
if (callerGuard !== undefined)
|
|
674
|
+
runStagingGuard(callerGuard);
|
|
675
|
+
// Recheck every route in the backend's atomic commit, so a source cannot
|
|
676
|
+
// cross into the virtual device namespace after asynchronous admission.
|
|
677
|
+
for (const guard of guards)
|
|
678
|
+
runStagingGuard(guard);
|
|
679
|
+
options.signal?.throwIfAborted();
|
|
680
|
+
return true;
|
|
681
|
+
} });
|
|
682
|
+
}
|
|
683
|
+
async prepareDirectoryAncestry(ancestors, options = {}) {
|
|
684
|
+
options.signal?.throwIfAborted();
|
|
685
|
+
try {
|
|
686
|
+
const entries = snapshotDirectoryAncestry(ancestors);
|
|
687
|
+
const controls = options.signal === undefined ? {} : { signal: options.signal };
|
|
688
|
+
controls.signal?.throwIfAborted();
|
|
689
|
+
if (entries.some(entry => entry.path === deviceDirectory || entry.path.startsWith(`${deviceDirectory}/`))
|
|
690
|
+
|| !this.#filesystem.prepareDirectoryAncestry) {
|
|
691
|
+
throw new FsError("ENOTSUP", { syscall: "prepareDirectoryAncestry" });
|
|
692
|
+
}
|
|
693
|
+
for (const entry of entries) {
|
|
694
|
+
const declared = await this.#filesystem.capabilitiesFor?.(entry.path, { ...controls, stagingAncestry: true }) ?? this.#filesystem.capabilities;
|
|
695
|
+
controls.signal?.throwIfAborted();
|
|
696
|
+
if (declared.synchronousDirectoryValidation !== true)
|
|
697
|
+
throw new FsError("ENOTSUP", { syscall: "prepareDirectoryAncestry", path: entry.path });
|
|
698
|
+
}
|
|
699
|
+
const guard = await this.#filesystem.prepareDirectoryAncestry(entries, controls);
|
|
700
|
+
controls.signal?.throwIfAborted();
|
|
701
|
+
if (typeof guard !== "function")
|
|
702
|
+
throw new FsError("ENOTSUP", { syscall: "prepareDirectoryAncestry" });
|
|
703
|
+
return () => {
|
|
704
|
+
controls.signal?.throwIfAborted();
|
|
705
|
+
runStagingGuard(guard);
|
|
706
|
+
return true;
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
catch (error) {
|
|
710
|
+
options.signal?.throwIfAborted();
|
|
711
|
+
throw error;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
async prepareStagingResolution(path, options = {}) {
|
|
715
|
+
const controls = options.signal === undefined ? {} : { signal: options.signal };
|
|
716
|
+
controls.signal?.throwIfAborted();
|
|
717
|
+
if (normalizePath(path) !== path || !path.startsWith("/"))
|
|
718
|
+
throw new FsError("EINVAL", { path });
|
|
719
|
+
try {
|
|
720
|
+
const traversal = { virtual: false };
|
|
721
|
+
const resolved = await this.#resolve(path, controls, false, undefined, traversal);
|
|
722
|
+
controls.signal?.throwIfAborted();
|
|
723
|
+
if (traversal.virtual)
|
|
724
|
+
throw new FsError("ENOTSUP", { path });
|
|
725
|
+
const declared = ownedMutationCapabilities(this.#filesystem, await this.#filesystem.capabilitiesFor?.(path, { ...controls, stagingResolution: true }) ?? this.#filesystem.capabilities);
|
|
726
|
+
controls.signal?.throwIfAborted();
|
|
727
|
+
if (declared.synchronousStagingResolution !== true || !this.#filesystem.prepareStagingResolution)
|
|
728
|
+
throw new FsError("ENOTSUP", { path });
|
|
729
|
+
const receipt = snapshotStagingResolution(await this.#filesystem.prepareStagingResolution(path, controls));
|
|
730
|
+
controls.signal?.throwIfAborted();
|
|
731
|
+
if (receipt.path !== resolved)
|
|
732
|
+
throw new FsError("EAGAIN", { path });
|
|
733
|
+
if ([receipt.path, ...receipt.traversed.map(entry => entry.path)].some(entry => entry === deviceDirectory || entry.startsWith(`${deviceDirectory}/`))) {
|
|
734
|
+
throw new FsError("ENOTSUP", { path });
|
|
735
|
+
}
|
|
736
|
+
const validate = () => { controls.signal?.throwIfAborted(); runStagingGuard(receipt.validate); return true; };
|
|
737
|
+
runStagingGuard(validate);
|
|
738
|
+
return snapshotStagingResolution({ ...receipt, validate });
|
|
739
|
+
}
|
|
740
|
+
catch (error) {
|
|
741
|
+
controls.signal?.throwIfAborted();
|
|
742
|
+
throw error;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
async removeStagedFile(staging, options = {}) {
|
|
746
|
+
for (const path of [staging.directory.path, staging.file.path])
|
|
747
|
+
await this.#mutable(path, options, false);
|
|
748
|
+
await requireOwnedMutation(this.#filesystem, staging.directory.path, "atomicFileStaging", options);
|
|
749
|
+
if (!this.#filesystem.removeStagedFile)
|
|
750
|
+
throw new FsError("ENOTSUP", { path: staging.directory.path });
|
|
751
|
+
await this.#filesystem.removeStagedFile(staging, options);
|
|
752
|
+
}
|
|
753
|
+
async prepareDirectory(path, options) {
|
|
754
|
+
await this.#mutable(path, options, false);
|
|
755
|
+
await requireOwnedMutation(this.#filesystem, path, "atomicDirectoryMetadata", options, options.expected === null);
|
|
756
|
+
if (!this.#filesystem.prepareDirectory)
|
|
757
|
+
throw new FsError("ENOTSUP", { path });
|
|
758
|
+
return this.#filesystem.prepareDirectory(path, options);
|
|
759
|
+
}
|
|
760
|
+
async rename(source, destination, options = {}) {
|
|
761
|
+
await this.#mutable(source, options, false);
|
|
762
|
+
await this.#mutable(destination, options, false);
|
|
763
|
+
if (options.noReplace) {
|
|
764
|
+
const capabilities = await this.#filesystem.capabilitiesFor?.(destination, options) ?? this.#filesystem.capabilities;
|
|
765
|
+
options.signal?.throwIfAborted();
|
|
766
|
+
if (capabilities.atomicRenameNoReplace !== true)
|
|
767
|
+
throw new FsError("ENOTSUP", { syscall: "rename", path: source, dest: destination });
|
|
768
|
+
}
|
|
769
|
+
await this.#filesystem.rename(source, destination, options);
|
|
770
|
+
}
|
|
771
|
+
async copyFile(source, destination, options = {}) {
|
|
772
|
+
const target = await this.#resolve(destination, options);
|
|
773
|
+
if (target === nullPath && options.exclusive)
|
|
774
|
+
throw new FsError("EEXIST", { path: destination });
|
|
775
|
+
const origin = await this.#resolve(source, options);
|
|
776
|
+
if (target !== nullPath && origin !== nullPath) {
|
|
777
|
+
if (target === "/" || target === deviceDirectory)
|
|
778
|
+
throw new FsError("EISDIR", { path: destination });
|
|
779
|
+
await this.#filesystem.copyFile(source, destination, options);
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
if (target === nullPath) {
|
|
783
|
+
if (origin === nullPath)
|
|
784
|
+
return;
|
|
785
|
+
if (origin === "/" || origin === deviceDirectory)
|
|
786
|
+
throw new FsError("EISDIR", { path: source });
|
|
787
|
+
const capabilities = await this.capabilitiesFor(source, options);
|
|
788
|
+
if (this.#filesystem.readStream && capabilities.streamingRead !== false) {
|
|
789
|
+
await drainDeviceInput(this.#filesystem.readStream(source, options), options.signal);
|
|
790
|
+
}
|
|
791
|
+
else if (this.#filesystem.openReadFile && capabilities.retainedRead !== false) {
|
|
792
|
+
await drainDeviceFile(await this.#filesystem.openReadFile(source, options), options.signal);
|
|
793
|
+
}
|
|
794
|
+
else
|
|
795
|
+
throw new FsError("ENOTSUP", { path: source });
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
if (reserved(target))
|
|
799
|
+
throw new FsError("EISDIR", { path: destination });
|
|
800
|
+
await this.#filesystem.writeFile(destination, new Uint8Array(), { ...options, flag: options.exclusive ? "wx" : "w" });
|
|
801
|
+
}
|
|
802
|
+
access(path, mode = 0, options = {}) {
|
|
803
|
+
if (this.#tryResolveSync(path, options) !== undefined) {
|
|
804
|
+
return this.#filesystem.access(path, mode, options);
|
|
805
|
+
}
|
|
806
|
+
return this.#accessSlow(path, mode, options);
|
|
807
|
+
}
|
|
808
|
+
async #accessSlow(path, mode, options) {
|
|
809
|
+
const resolved = await this.#resolve(path, options);
|
|
810
|
+
if (resolved === nullPath || resolved === deviceDirectory) {
|
|
811
|
+
if (!Number.isInteger(mode) || mode < 0 || mode > 7)
|
|
812
|
+
throw new FsError("EINVAL", { path });
|
|
813
|
+
if ((resolved === nullPath && (mode & 1)) || (resolved === deviceDirectory && (mode & 2)))
|
|
814
|
+
throw new FsError("EACCES", { path });
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
await this.#filesystem.access(path, mode, options);
|
|
818
|
+
}
|
|
819
|
+
async readlink(path, options = {}) {
|
|
820
|
+
if (reserved(await this.#resolve(path, options, false)))
|
|
821
|
+
throw new FsError("EINVAL", { path });
|
|
822
|
+
if (!this.#filesystem.readlink)
|
|
823
|
+
throw new FsError("ENOTSUP", { path });
|
|
824
|
+
return this.#filesystem.readlink(path, options);
|
|
825
|
+
}
|
|
826
|
+
async symlink(target, path, options = {}) {
|
|
827
|
+
await this.#mutable(path, options, false);
|
|
828
|
+
if (!this.#filesystem.symlink)
|
|
829
|
+
throw new FsError("ENOTSUP", { path });
|
|
830
|
+
await this.#filesystem.symlink(target, path, options);
|
|
831
|
+
}
|
|
832
|
+
async confineExtraction(roots, options = {}) {
|
|
833
|
+
options.signal?.throwIfAborted();
|
|
834
|
+
if (!this.#filesystem.confineExtraction)
|
|
835
|
+
throw new FsError("ENOTSUP", { syscall: "confineExtraction" });
|
|
836
|
+
// Extraction uses only the backing namespace; synthetic devices must never
|
|
837
|
+
// become archive publication destinations.
|
|
838
|
+
return this.#filesystem.confineExtraction(roots, options);
|
|
839
|
+
}
|
|
840
|
+
async link(existingPath, newPath, options = {}) {
|
|
841
|
+
await this.#mutable(existingPath, options, false);
|
|
842
|
+
await this.#mutable(newPath, options, false);
|
|
843
|
+
if (!this.#filesystem.link)
|
|
844
|
+
throw new FsError("ENOTSUP", { path: newPath });
|
|
845
|
+
await this.#filesystem.link(existingPath, newPath, options);
|
|
846
|
+
}
|
|
847
|
+
async chmod(path, mode, options = {}) {
|
|
848
|
+
await this.#mutable(path, options);
|
|
849
|
+
if (!this.#filesystem.chmod)
|
|
850
|
+
throw new FsError("ENOTSUP", { path });
|
|
851
|
+
await this.#filesystem.chmod(path, mode, options);
|
|
852
|
+
}
|
|
853
|
+
async utimes(path, atimeMs, mtimeMs, options = {}) {
|
|
854
|
+
await this.#mutable(path, options);
|
|
855
|
+
if (!this.#filesystem.utimes)
|
|
856
|
+
throw new FsError("ENOTSUP", { path });
|
|
857
|
+
await this.#filesystem.utimes(path, atimeMs, mtimeMs, options);
|
|
858
|
+
}
|
|
859
|
+
async truncate(path, length, options = {}) {
|
|
860
|
+
await this.#mutable(path, options);
|
|
861
|
+
if (!this.#filesystem.truncate)
|
|
862
|
+
throw new FsError("ENOTSUP", { path });
|
|
863
|
+
await this.#filesystem.truncate(path, length, options);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
export function createDeviceFileSystem(filesystem) {
|
|
867
|
+
if (filesystem instanceof DeviceFileSystem)
|
|
868
|
+
return filesystem;
|
|
869
|
+
let view = views.get(filesystem);
|
|
870
|
+
if (!view) {
|
|
871
|
+
view = new DeviceFileSystem(filesystem);
|
|
872
|
+
views.set(filesystem, view);
|
|
873
|
+
}
|
|
874
|
+
return view;
|
|
875
|
+
}
|